signify-ts 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -47
- package/dist/buffer-polyfill.d.ts +1 -0
- package/dist/exports.d.ts +40 -0
- package/dist/index.d.ts +4 -3
- package/dist/keri/app/aiding.d.ts +138 -0
- package/dist/keri/app/clienting.d.ts +182 -0
- package/dist/keri/app/contacting.d.ts +93 -0
- package/dist/keri/app/controller.d.ts +49 -0
- package/dist/keri/app/coring.d.ts +121 -0
- package/dist/keri/app/credentialing.d.ts +239 -0
- package/dist/keri/app/escrowing.d.ts +19 -0
- package/dist/keri/app/exchanging.d.ts +60 -0
- package/dist/keri/app/grouping.d.ts +44 -0
- package/dist/keri/app/habery.d.ts +48 -47
- package/dist/keri/app/notifying.d.ts +34 -0
- package/dist/keri/core/authing.d.ts +10 -9
- package/dist/keri/core/bexter.d.ts +7 -0
- package/dist/keri/core/cigar.d.ts +8 -8
- package/dist/keri/core/cipher.d.ts +5 -5
- package/dist/keri/core/core.d.ts +59 -53
- package/dist/keri/core/counter.d.ts +43 -43
- package/dist/keri/core/decrypter.d.ts +10 -10
- package/dist/keri/core/diger.d.ts +21 -21
- package/dist/keri/core/encrypter.d.ts +9 -9
- package/dist/keri/core/eventing.d.ts +54 -21
- package/dist/keri/core/httping.d.ts +44 -34
- package/dist/keri/core/indexer.d.ts +98 -88
- package/dist/keri/core/keeping.d.ts +103 -1
- package/dist/keri/core/kering.d.ts +5 -5
- package/dist/keri/core/manager.d.ts +174 -172
- package/dist/keri/core/matter.d.ts +116 -69
- package/dist/keri/core/number.d.ts +7 -6
- package/dist/keri/core/pather.d.ts +7 -0
- package/dist/keri/core/prefixer.d.ts +15 -15
- package/dist/keri/core/saider.d.ts +23 -23
- package/dist/keri/core/salter.d.ts +23 -23
- package/dist/keri/core/seqner.d.ts +15 -0
- package/dist/keri/core/serder.d.ts +31 -23
- package/dist/keri/core/siger.d.ts +18 -18
- package/dist/keri/core/signer.d.ts +34 -34
- package/dist/keri/core/tholder.d.ts +29 -14
- package/dist/keri/core/utils.d.ts +20 -15
- package/dist/keri/core/vdring.d.ts +16 -0
- package/dist/keri/core/verfer.d.ts +13 -12
- package/dist/keri/end/ending.d.ts +13 -13
- package/dist/math.d.ts +1 -0
- package/dist/ready.d.ts +1 -0
- package/dist/signify-ts.cjs +7835 -0
- package/dist/signify-ts.cjs.development.js +6369 -256
- package/dist/signify-ts.cjs.development.js.map +1 -1
- package/dist/signify-ts.cjs.map +7 -0
- package/dist/signify-ts.cjs.production.min.js +1 -1
- package/dist/signify-ts.cjs.production.min.js.map +1 -1
- package/dist/signify-ts.esm.js +6205 -229
- package/dist/signify-ts.esm.js.map +1 -1
- package/dist/signify-ts.mjs +7811 -0
- package/dist/signify-ts.mjs.map +7 -0
- package/package.json +49 -49
- package/src/buffer-polyfill.ts +5 -0
- package/src/exports.ts +44 -0
- package/src/index.ts +4 -5
- package/src/keri/app/aiding.ts +493 -0
- package/src/keri/app/clienting.ts +492 -0
- package/src/keri/app/contacting.ts +188 -0
- package/src/keri/app/controller.ts +372 -0
- package/src/keri/app/coring.ts +225 -0
- package/src/keri/app/credentialing.ts +820 -0
- package/src/keri/app/escrowing.ts +34 -0
- package/src/keri/app/exchanging.ts +220 -0
- package/src/keri/app/grouping.ts +90 -0
- package/src/keri/app/habery.ts +118 -85
- package/src/keri/app/notifying.ts +69 -0
- package/src/keri/core/authing.ts +73 -85
- package/src/keri/core/bexter.ts +138 -0
- package/src/keri/core/cigar.ts +10 -11
- package/src/keri/core/cipher.ts +23 -14
- package/src/keri/core/core.ts +223 -81
- package/src/keri/core/counter.ts +182 -116
- package/src/keri/core/decrypter.ts +48 -34
- package/src/keri/core/diger.ts +23 -22
- package/src/keri/core/encrypter.ts +37 -27
- package/src/keri/core/eventing.ts +468 -106
- package/src/keri/core/httping.ts +151 -105
- package/src/keri/core/indexer.ts +313 -211
- package/src/keri/core/keeping.ts +679 -3
- package/src/keri/core/kering.ts +4 -6
- package/src/keri/core/manager.ts +660 -499
- package/src/keri/core/matter.ts +382 -148
- package/src/keri/core/number.ts +56 -11
- package/src/keri/core/pather.ts +98 -0
- package/src/keri/core/prefixer.ts +122 -101
- package/src/keri/core/saider.ts +104 -76
- package/src/keri/core/salter.ts +71 -40
- package/src/keri/core/seqner.ts +46 -0
- package/src/keri/core/serder.ts +102 -38
- package/src/keri/core/siger.ts +19 -18
- package/src/keri/core/signer.ts +73 -53
- package/src/keri/core/tholder.ts +196 -30
- package/src/keri/core/utils.ts +121 -50
- package/src/keri/core/vdring.ts +94 -0
- package/src/keri/core/verfer.ts +22 -9
- package/src/keri/end/ending.ts +111 -101
- package/src/math.ts +3 -0
- package/src/ready.ts +5 -0
- package/dist/keri/app/accountant.d.ts +0 -10
- package/dist/keri/app/apping.d.ts +0 -1
- package/dist/keri/app/client.d.ts +0 -7
- package/dist/keri/app/signify.d.ts +0 -6
- package/src/keri/app/accountant.ts +0 -35
- package/src/keri/app/apping.ts +0 -12
- package/src/keri/app/client.ts +0 -30
- package/src/keri/app/signify.ts +0 -12
- package/src/keri/app/tsconfig.json +0 -100
- package/src/keri/core/tsconfig.json +0 -100
- package/src/keri/end/tsconfig.json +0 -100
|
@@ -1,60 +1,70 @@
|
|
|
1
|
-
import libsodium from
|
|
2
|
-
|
|
3
|
-
import {Matter, MatterArgs, MtrDex} from './matter';
|
|
4
|
-
import {Verfer} from "./verfer";
|
|
5
|
-
import {Signer} from "./signer";
|
|
6
|
-
import {Cipher} from "./cipher";
|
|
7
|
-
import {arrayEquals} from "./utils";
|
|
1
|
+
import libsodium from 'libsodium-wrappers-sumo';
|
|
8
2
|
|
|
3
|
+
import { Matter, MatterArgs, MtrDex } from './matter';
|
|
4
|
+
import { Verfer } from './verfer';
|
|
5
|
+
import { Signer } from './signer';
|
|
6
|
+
import { Cipher } from './cipher';
|
|
7
|
+
import { arrayEquals } from './utils';
|
|
9
8
|
|
|
10
9
|
export class Encrypter extends Matter {
|
|
11
10
|
private _encrypt: any;
|
|
12
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
{ raw, code = MtrDex.X25519, qb64, qb64b, qb2 }: MatterArgs,
|
|
13
|
+
verkey: Uint8Array | null = null
|
|
14
|
+
) {
|
|
13
15
|
if (raw == undefined && verkey != null) {
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
16
|
+
const verfer = new Verfer({ qb64b: verkey });
|
|
17
|
+
if (
|
|
18
|
+
!Array.from([MtrDex.Ed25519N, MtrDex.Ed25519]).includes(
|
|
19
|
+
verfer.code
|
|
20
|
+
)
|
|
21
|
+
) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Unsupported verkey derivation code = ${verfer.code}.`
|
|
24
|
+
);
|
|
17
25
|
}
|
|
18
|
-
raw = libsodium.crypto_sign_ed25519_pk_to_curve25519(verfer.raw)
|
|
26
|
+
raw = libsodium.crypto_sign_ed25519_pk_to_curve25519(verfer.raw);
|
|
19
27
|
}
|
|
20
28
|
|
|
21
|
-
super({raw, code, qb64, qb64b, qb2});
|
|
29
|
+
super({ raw, code, qb64, qb64b, qb2 });
|
|
22
30
|
|
|
23
31
|
if (this.code == MtrDex.X25519) {
|
|
24
32
|
this._encrypt = this._x25519;
|
|
25
33
|
} else {
|
|
26
|
-
throw new Error(`Unsupported encrypter code = ${this.code}.`)
|
|
34
|
+
throw new Error(`Unsupported encrypter code = ${this.code}.`);
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
verifySeed(seed: Uint8Array) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
const signer = new Signer({ qb64b: seed });
|
|
40
|
+
const keypair = libsodium.crypto_sign_seed_keypair(signer.raw);
|
|
41
|
+
const pubkey = libsodium.crypto_sign_ed25519_pk_to_curve25519(
|
|
42
|
+
keypair.publicKey
|
|
43
|
+
);
|
|
44
|
+
return arrayEquals(pubkey, this.raw);
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
encrypt(ser: Uint8Array | null = null, matter: Matter | null = null) {
|
|
38
48
|
if (ser == null && matter == null) {
|
|
39
|
-
throw new Error(
|
|
49
|
+
throw new Error('Neither ser nor matter are provided.');
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
if (ser != null) {
|
|
43
|
-
matter = new Matter({qb64b: ser})
|
|
53
|
+
matter = new Matter({ qb64b: ser });
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
let code
|
|
56
|
+
let code;
|
|
47
57
|
if (matter!.code == MtrDex.Salt_128) {
|
|
48
|
-
code = MtrDex.X25519_Cipher_Salt
|
|
58
|
+
code = MtrDex.X25519_Cipher_Salt;
|
|
49
59
|
} else {
|
|
50
|
-
code = MtrDex.X25519_Cipher_Seed
|
|
60
|
+
code = MtrDex.X25519_Cipher_Seed;
|
|
51
61
|
}
|
|
52
62
|
|
|
53
|
-
return this._encrypt(matter!.qb64, this.raw, code)
|
|
63
|
+
return this._encrypt(matter!.qb64, this.raw, code);
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
_x25519(ser: Uint8Array, pubkey: Uint8Array, code: string) {
|
|
57
|
-
|
|
58
|
-
return new Cipher({raw: raw, code: code})
|
|
67
|
+
const raw = libsodium.crypto_box_seal(ser, pubkey);
|
|
68
|
+
return new Cipher({ raw: raw, code: code });
|
|
59
69
|
}
|
|
60
|
-
}
|
|
70
|
+
}
|