Refactor scripts to use imports from crdt-meta.

This commit is contained in:
Spencer Ofwiti 2021-04-14 16:42:41 +03:00
parent 426818baa1
commit 2f8531c195
4 changed files with 116 additions and 2181 deletions

View File

@ -3,10 +3,11 @@ const path = require('path');
const http = require('http'); const http = require('http');
const cic = require('cic-client-meta'); const cic = require('cic-client-meta');
import { Config, PGPKeyStore, PGPSigner, Syncable } from 'crdt-meta';
//const conf = JSON.parse(fs.readFileSync('./cic.conf')); //const conf = JSON.parse(fs.readFileSync('./cic.conf'));
const config = new cic.Config('./config'); const config = new Config('./config');
config.process(); config.process();
console.log(config); console.log(config);
@ -41,7 +42,7 @@ function sendit(uid, envelope) {
} }
function doOne(keystore, filePath) { function doOne(keystore, filePath) {
const signer = new cic.PGPSigner(keystore); const signer = new PGPSigner(keystore);
const parts = path.basename(filePath).split('.'); const parts = path.basename(filePath).split('.');
const ethereum_address = path.basename(parts[0]); const ethereum_address = path.basename(parts[0]);
@ -51,7 +52,7 @@ function doOne(keystore, filePath) {
//console.log(o); //console.log(o);
fs.unlinkSync(filePath); fs.unlinkSync(filePath);
const s = new cic.Syncable(uid, o); const s = new Syncable(uid, o);
s.setSigner(signer); s.setSigner(signer);
s.onwrap = (env) => { s.onwrap = (env) => {
sendit(uid, env); sendit(uid, env);
@ -65,7 +66,7 @@ const publicKeyPath = path.join(config.get('PGP_EXPORTS_DIR'), config.get('PGP_P
pk = fs.readFileSync(privateKeyPath); pk = fs.readFileSync(privateKeyPath);
pubk = fs.readFileSync(publicKeyPath); pubk = fs.readFileSync(publicKeyPath);
new cic.PGPKeyStore( new PGPKeyStore(
config.get('PGP_PASSPHRASE'), config.get('PGP_PASSPHRASE'),
pk, pk,
pubk, pubk,

View File

@ -4,10 +4,11 @@ const http = require('http');
const cic = require('cic-client-meta'); const cic = require('cic-client-meta');
const vcfp = require('vcard-parser'); const vcfp = require('vcard-parser');
import { Config, PGPKeyStore, PGPSigner, Syncable } from 'crdt-meta';
//const conf = JSON.parse(fs.readFileSync('./cic.conf')); //const conf = JSON.parse(fs.readFileSync('./cic.conf'));
const config = new cic.Config('./config'); const config = new Config('./config');
config.process(); config.process();
console.log(config); console.log(config);
@ -42,7 +43,7 @@ function sendit(uid, envelope) {
} }
function doOne(keystore, filePath, address) { function doOne(keystore, filePath, address) {
const signer = new cic.PGPSigner(keystore); const signer = new PGPSigner(keystore);
const j = JSON.parse(fs.readFileSync(filePath).toString()); const j = JSON.parse(fs.readFileSync(filePath).toString());
const b = Buffer.from(j['vcard'], 'base64'); const b = Buffer.from(j['vcard'], 'base64');
@ -53,7 +54,7 @@ function doOne(keystore, filePath, address) {
cic.Phone.toKey(phone).then((uid) => { cic.Phone.toKey(phone).then((uid) => {
const o = fs.readFileSync(filePath, 'utf-8'); const o = fs.readFileSync(filePath, 'utf-8');
const s = new cic.Syncable(uid, o); const s = new Syncable(uid, o);
s.setSigner(signer); s.setSigner(signer);
s.onwrap = (env) => { s.onwrap = (env) => {
sendit(uid, env); sendit(uid, env);
@ -67,7 +68,7 @@ const publicKeyPath = path.join(config.get('PGP_EXPORTS_DIR'), config.get('PGP_P
pk = fs.readFileSync(privateKeyPath); pk = fs.readFileSync(privateKeyPath);
pubk = fs.readFileSync(publicKeyPath); pubk = fs.readFileSync(publicKeyPath);
new cic.PGPKeyStore( new PGPKeyStore(
config.get('PGP_PASSPHRASE'), config.get('PGP_PASSPHRASE'),
pk, pk,
pubk, pubk,

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
{ {
"dependencies": { "dependencies": {
"cic-client-meta": "^0.0.7-alpha.6", "cic-client-meta": "^0.0.7-alpha.8",
"crdt-meta": "0.0.8",
"vcard-parser": "^1.0.0" "vcard-parser": "^1.0.0"
} }
} }