signify-ts 0.1.1 → 0.2.1
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 +245 -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 +7842 -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 +7818 -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 +841 -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
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { randomNonce } from '../app/coring';
|
|
2
|
+
import { TraitDex } from '../app/habery';
|
|
3
|
+
import {
|
|
4
|
+
Serials,
|
|
5
|
+
Versionage,
|
|
6
|
+
Version,
|
|
7
|
+
Ident,
|
|
8
|
+
versify,
|
|
9
|
+
Ilks,
|
|
10
|
+
} from '../core/core';
|
|
11
|
+
import { ample } from './eventing';
|
|
12
|
+
import { MtrDex } from './matter';
|
|
13
|
+
import { Prefixer } from './prefixer';
|
|
14
|
+
import { Serder } from './serder';
|
|
15
|
+
|
|
16
|
+
namespace vdr {
|
|
17
|
+
export interface VDRInceptArgs {
|
|
18
|
+
pre: string;
|
|
19
|
+
toad?: number | string;
|
|
20
|
+
nonce?: string;
|
|
21
|
+
baks?: string[];
|
|
22
|
+
cnfg?: string[];
|
|
23
|
+
version?: Version;
|
|
24
|
+
kind?: Serials;
|
|
25
|
+
code?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function incept({
|
|
29
|
+
pre,
|
|
30
|
+
toad,
|
|
31
|
+
nonce = randomNonce(),
|
|
32
|
+
baks = [],
|
|
33
|
+
cnfg = [],
|
|
34
|
+
version = Versionage,
|
|
35
|
+
kind = Serials.JSON,
|
|
36
|
+
code = MtrDex.Blake3_256,
|
|
37
|
+
}: VDRInceptArgs): Serder {
|
|
38
|
+
const vs = versify(Ident.KERI, version, kind, 0);
|
|
39
|
+
const isn = 0;
|
|
40
|
+
const ilk = Ilks.vcp;
|
|
41
|
+
|
|
42
|
+
if (cnfg.includes(TraitDex.NoBackers) && baks.length > 0) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`${baks.length} backers specified for NB vcp, 0 allowed`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (new Set(baks).size < baks.length) {
|
|
49
|
+
throw new Error(`Invalid baks ${baks} has duplicates`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let _toad: number;
|
|
53
|
+
if (toad === undefined) {
|
|
54
|
+
if (baks.length === 0) {
|
|
55
|
+
_toad = 0;
|
|
56
|
+
} else {
|
|
57
|
+
_toad = ample(baks.length);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
_toad = +toad;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (baks.length > 0) {
|
|
64
|
+
if (_toad < 1 || _toad > baks.length) {
|
|
65
|
+
throw new Error(`Invalid toad ${_toad} for baks in ${baks}`);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
if (_toad != 0) {
|
|
69
|
+
throw new Error(`Invalid toad ${_toad} for no baks`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const ked = {
|
|
74
|
+
v: vs,
|
|
75
|
+
t: ilk,
|
|
76
|
+
d: '',
|
|
77
|
+
i: '',
|
|
78
|
+
ii: pre,
|
|
79
|
+
s: '' + isn,
|
|
80
|
+
c: cnfg,
|
|
81
|
+
bt: _toad.toString(16),
|
|
82
|
+
b: baks,
|
|
83
|
+
n: nonce,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const prefixer = new Prefixer({ code }, ked);
|
|
87
|
+
ked.i = prefixer.qb64;
|
|
88
|
+
ked.d = prefixer.qb64;
|
|
89
|
+
|
|
90
|
+
return new Serder(ked);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { vdr };
|
package/src/keri/core/verfer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
import libsodium from
|
|
3
|
-
|
|
4
|
-
import
|
|
2
|
+
import libsodium from 'libsodium-wrappers-sumo';
|
|
3
|
+
import { Matter, MatterArgs, MtrDex } from './matter';
|
|
4
|
+
import secp256r1 from 'ecdsa-secp256r1';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @description Verfer :sublclass of Matter,helps to verify signature of serialization
|
|
@@ -9,24 +9,37 @@ import {Matter, MatterArgs, MtrDex} from './matter';
|
|
|
9
9
|
*/
|
|
10
10
|
export class Verfer extends Matter {
|
|
11
11
|
private readonly _verify: (sig: any, ser: any, key: any) => boolean;
|
|
12
|
-
constructor({raw, code, qb64, qb64b, qb2}: MatterArgs) {
|
|
13
|
-
super({raw, code, qb64, qb64b, qb2});
|
|
12
|
+
constructor({ raw, code, qb64, qb64b, qb2 }: MatterArgs) {
|
|
13
|
+
super({ raw, code, qb64, qb64b, qb2 });
|
|
14
14
|
|
|
15
15
|
if (Array.from([MtrDex.Ed25519N, MtrDex.Ed25519]).includes(this.code)) {
|
|
16
|
-
this._verify = this._ed25519
|
|
16
|
+
this._verify = this._ed25519;
|
|
17
|
+
} else if (
|
|
18
|
+
Array.from([MtrDex.ECDSA_256r1N, MtrDex.ECDSA_256r1]).includes(
|
|
19
|
+
this.code
|
|
20
|
+
)
|
|
21
|
+
) {
|
|
22
|
+
this._verify = this._secp256r1;
|
|
17
23
|
} else {
|
|
18
|
-
throw new Error(`Unsupported code = ${this.code} for verifier.`)
|
|
24
|
+
throw new Error(`Unsupported code = ${this.code} for verifier.`);
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
verify(sig: any, ser: any) {
|
|
23
|
-
return this._verify(sig, ser, this.raw)
|
|
29
|
+
return this._verify(sig, ser, this.raw);
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
_ed25519(sig: any, ser: any, key: any) {
|
|
27
33
|
try {
|
|
28
34
|
return libsodium.crypto_sign_verify_detached(sig, ser, key);
|
|
29
|
-
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new Error(error as string);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
_secp256r1(sig: any, ser: any, key: any) {
|
|
40
|
+
try {
|
|
41
|
+
const publicKey = secp256r1.fromCompressedPublicKey(key);
|
|
42
|
+
return publicKey.verify(ser, sig);
|
|
30
43
|
} catch (error) {
|
|
31
44
|
throw new Error(error as string);
|
|
32
45
|
}
|
package/src/keri/end/ending.ts
CHANGED
|
@@ -1,160 +1,170 @@
|
|
|
1
|
-
import {Siger} from
|
|
2
|
-
import {Cigar} from
|
|
1
|
+
import { Siger } from '../core/siger';
|
|
2
|
+
import { Cigar } from '../core/cigar';
|
|
3
3
|
|
|
4
|
-
export const FALSY = [false, 0,
|
|
5
|
-
export const TRUTHY = [true, 1,
|
|
4
|
+
export const FALSY = [false, 0, '?0', 'no', 'false', 'False', 'off'];
|
|
5
|
+
export const TRUTHY = [true, 1, '?1', 'yes', 'true', 'True', 'on'];
|
|
6
6
|
|
|
7
7
|
export class Signage {
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
constructor(
|
|
9
|
+
markers: any,
|
|
10
|
+
indexed?: boolean,
|
|
11
|
+
signer?: string,
|
|
12
|
+
ordinal?: string,
|
|
13
|
+
digest?: string,
|
|
14
|
+
kind?: string
|
|
15
|
+
) {
|
|
16
|
+
this.markers = markers;
|
|
17
|
+
this.indexed = indexed;
|
|
18
|
+
this.signer = signer;
|
|
19
|
+
this.ordinal = ordinal;
|
|
20
|
+
this.digest = digest;
|
|
21
|
+
this.kind = kind;
|
|
16
22
|
}
|
|
17
|
-
public markers: any
|
|
18
|
-
public indexed: boolean | undefined = false
|
|
19
|
-
public signer: string | undefined
|
|
20
|
-
public ordinal: string | undefined
|
|
21
|
-
public digest: string | undefined
|
|
22
|
-
public kind: string | undefined
|
|
23
|
+
public markers: any;
|
|
24
|
+
public indexed: boolean | undefined = false;
|
|
25
|
+
public signer: string | undefined;
|
|
26
|
+
public ordinal: string | undefined;
|
|
27
|
+
public digest: string | undefined;
|
|
28
|
+
public kind: string | undefined;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
export function signature(signages: Array<Signage>): Headers {
|
|
26
|
-
|
|
32
|
+
const values = new Array<string>();
|
|
27
33
|
|
|
28
|
-
for (
|
|
29
|
-
let markers: Array<Siger | Cigar
|
|
30
|
-
let indexed = signage.indexed
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
let tags: Array<string
|
|
34
|
+
for (const signage of signages) {
|
|
35
|
+
let markers: Array<Siger | Cigar>;
|
|
36
|
+
let indexed = signage.indexed;
|
|
37
|
+
const signer = signage.signer;
|
|
38
|
+
const ordinal = signage.ordinal;
|
|
39
|
+
const digest = signage.digest;
|
|
40
|
+
const kind = signage.kind;
|
|
41
|
+
let tags: Array<string>;
|
|
36
42
|
|
|
37
43
|
if (signage.markers instanceof Map) {
|
|
38
|
-
tags = Array.from(signage.markers.keys())
|
|
39
|
-
markers = Array.from(signage.markers.values())
|
|
44
|
+
tags = Array.from(signage.markers.keys());
|
|
45
|
+
markers = Array.from(signage.markers.values());
|
|
40
46
|
} else {
|
|
41
|
-
markers = signage.markers as Array<Siger | Cigar
|
|
42
|
-
tags = new Array<string>()
|
|
47
|
+
markers = signage.markers as Array<Siger | Cigar>;
|
|
48
|
+
tags = new Array<string>();
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
if (indexed == undefined) {
|
|
46
|
-
indexed = markers[0] instanceof Siger
|
|
52
|
+
indexed = markers[0] instanceof Siger;
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
const items = new Array<string>();
|
|
56
|
+
const tag = 'indexed';
|
|
51
57
|
|
|
52
|
-
let val = indexed ?
|
|
53
|
-
items.push(`${tag}="${val}"`)
|
|
58
|
+
let val = indexed ? '?1' : '?0';
|
|
59
|
+
items.push(`${tag}="${val}"`);
|
|
54
60
|
|
|
55
61
|
if (signer != undefined) {
|
|
56
|
-
items.push(`signer="${signer}"`)
|
|
62
|
+
items.push(`signer="${signer}"`);
|
|
57
63
|
}
|
|
58
64
|
if (ordinal != undefined) {
|
|
59
|
-
items.push(`ordinal="${ordinal}"`)
|
|
65
|
+
items.push(`ordinal="${ordinal}"`);
|
|
60
66
|
}
|
|
61
67
|
if (digest != undefined) {
|
|
62
|
-
items.push(`digest="${digest}"`)
|
|
68
|
+
items.push(`digest="${digest}"`);
|
|
63
69
|
}
|
|
64
70
|
if (kind != undefined) {
|
|
65
|
-
items.push(`kind="${kind}"`)
|
|
71
|
+
items.push(`kind="${kind}"`);
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
markers.forEach((marker, idx) => {
|
|
69
|
-
let tag: string
|
|
70
|
-
if (tags != undefined) {
|
|
71
|
-
tag = tags[idx]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (marker instanceof Siger) {
|
|
75
|
+
let tag: string;
|
|
76
|
+
if (tags != undefined && tags.length > idx) {
|
|
77
|
+
tag = tags[idx];
|
|
78
|
+
} else if (marker instanceof Siger) {
|
|
75
79
|
if (!indexed)
|
|
76
|
-
throw new Error(
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Indexed signature marker ${marker} when indexed False.`
|
|
82
|
+
);
|
|
77
83
|
|
|
78
|
-
tag = marker.index.toString()
|
|
79
|
-
} else {
|
|
84
|
+
tag = marker.index.toString();
|
|
85
|
+
} else {
|
|
86
|
+
// Must be a Cigar
|
|
80
87
|
if (indexed)
|
|
81
|
-
throw new Error(
|
|
82
|
-
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Unindexed signature marker ${marker} when indexed True.`
|
|
90
|
+
);
|
|
91
|
+
tag = marker.verfer!.qb64;
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
val = marker.qb64
|
|
86
|
-
items.push(`${tag}="${val}"`)
|
|
87
|
-
})
|
|
94
|
+
val = marker.qb64;
|
|
95
|
+
items.push(`${tag}="${val}"`);
|
|
96
|
+
});
|
|
88
97
|
|
|
89
|
-
values.push(items.join(
|
|
98
|
+
values.push(items.join(';'));
|
|
90
99
|
}
|
|
91
100
|
|
|
92
|
-
return new Headers([
|
|
93
|
-
["Signature", values.join(",")]
|
|
94
|
-
])
|
|
101
|
+
return new Headers([['Signature', values.join(',')]]);
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
export function designature(value: string) {
|
|
98
|
-
|
|
105
|
+
const values = value.replace(' ', '').split(',');
|
|
99
106
|
|
|
100
|
-
|
|
107
|
+
const signages = new Array<Signage>();
|
|
101
108
|
values.forEach((val) => {
|
|
102
|
-
|
|
103
|
-
val.split(
|
|
104
|
-
|
|
105
|
-
dict.set(splits[0], splits[1].replaceAll("
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
if (!dict.has(
|
|
109
|
-
throw new Error(
|
|
109
|
+
const dict = new Map<string, string>();
|
|
110
|
+
val.split(';').forEach((v) => {
|
|
111
|
+
const splits = v.split('=', 2);
|
|
112
|
+
dict.set(splits[0], splits[1].replaceAll('"', ''));
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (!dict.has('indexed')) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
'Missing indexed field in Signature header signage.'
|
|
118
|
+
);
|
|
110
119
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
dict.delete(
|
|
114
|
-
|
|
115
|
-
let signer
|
|
116
|
-
if (dict.has(
|
|
117
|
-
signer = dict.get(
|
|
118
|
-
dict.delete(
|
|
120
|
+
const item = dict.get('indexed')!;
|
|
121
|
+
const indexed = !FALSY.includes(item);
|
|
122
|
+
dict.delete('indexed');
|
|
123
|
+
|
|
124
|
+
let signer;
|
|
125
|
+
if (dict.has('signer')) {
|
|
126
|
+
signer = dict.get('signer') as string;
|
|
127
|
+
dict.delete('signer');
|
|
119
128
|
}
|
|
120
129
|
|
|
121
|
-
let ordinal
|
|
122
|
-
if (dict.has(
|
|
123
|
-
ordinal = dict.get(
|
|
124
|
-
dict.delete(
|
|
130
|
+
let ordinal;
|
|
131
|
+
if (dict.has('ordinal')) {
|
|
132
|
+
ordinal = dict.get('ordinal') as string;
|
|
133
|
+
dict.delete('ordinal');
|
|
125
134
|
}
|
|
126
135
|
|
|
127
|
-
let digest
|
|
128
|
-
if (dict.has(
|
|
129
|
-
digest = dict.get(
|
|
130
|
-
dict.delete(
|
|
136
|
+
let digest;
|
|
137
|
+
if (dict.has('digest')) {
|
|
138
|
+
digest = dict.get('digest') as string;
|
|
139
|
+
dict.delete('digest');
|
|
131
140
|
}
|
|
132
141
|
|
|
133
|
-
let kind
|
|
134
|
-
if (dict.has(
|
|
135
|
-
kind = dict.get(
|
|
136
|
-
dict.delete(
|
|
142
|
+
let kind;
|
|
143
|
+
if (dict.has('kind')) {
|
|
144
|
+
kind = dict.get('kind') as string;
|
|
145
|
+
dict.delete('kind');
|
|
137
146
|
} else {
|
|
138
|
-
kind =
|
|
147
|
+
kind = 'CESR';
|
|
139
148
|
}
|
|
140
149
|
|
|
141
|
-
let markers: Map<string, string|Siger|Cigar
|
|
142
|
-
if (kind ==
|
|
143
|
-
markers = new Map<string, Siger|Cigar>()
|
|
150
|
+
let markers: Map<string, string | Siger | Cigar>;
|
|
151
|
+
if (kind == 'CESR') {
|
|
152
|
+
markers = new Map<string, Siger | Cigar>();
|
|
144
153
|
dict.forEach((val, key) => {
|
|
145
154
|
if (indexed) {
|
|
146
|
-
markers.set(key, new Siger({qb64: val as string}))
|
|
155
|
+
markers.set(key, new Siger({ qb64: val as string }));
|
|
147
156
|
} else {
|
|
148
|
-
markers.set(key, new Cigar({qb64: val as string}))
|
|
157
|
+
markers.set(key, new Cigar({ qb64: val as string }));
|
|
149
158
|
}
|
|
150
|
-
})
|
|
159
|
+
});
|
|
151
160
|
} else {
|
|
152
|
-
markers = dict
|
|
161
|
+
markers = dict;
|
|
153
162
|
}
|
|
154
163
|
|
|
155
|
-
signages.push(
|
|
164
|
+
signages.push(
|
|
165
|
+
new Signage(markers, indexed, signer, ordinal, digest, kind)
|
|
166
|
+
);
|
|
167
|
+
});
|
|
156
168
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return signages
|
|
160
|
-
}
|
|
169
|
+
return signages;
|
|
170
|
+
}
|
package/src/math.ts
ADDED
package/src/ready.ts
ADDED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Manager } from "../core/manager";
|
|
2
|
-
export declare class Accountant {
|
|
3
|
-
private readonly _agentKey;
|
|
4
|
-
private readonly _mgr;
|
|
5
|
-
private readonly _ready;
|
|
6
|
-
constructor(mgr: Manager, agentKey: string);
|
|
7
|
-
get ready(): Promise<void>;
|
|
8
|
-
sign(): Manager;
|
|
9
|
-
verify(): string;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function randomPasscode(): string;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {Manager} from "../core/manager";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export class Accountant {
|
|
5
|
-
private readonly _agentKey: string
|
|
6
|
-
private readonly _mgr: Manager
|
|
7
|
-
private readonly _ready: Promise<void>
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* Accountant is responsible for managing signing keys for the client and agent. The client
|
|
11
|
-
* signing key represents the Account for the client on the agent
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
constructor(mgr: Manager, agentKey: string) {
|
|
15
|
-
this._mgr = mgr
|
|
16
|
-
this._agentKey = agentKey
|
|
17
|
-
this._ready = new Promise<void>(()=>{})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get ready(): Promise<void> {
|
|
21
|
-
return this._ready
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
sign() {
|
|
26
|
-
return this._mgr
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
verify() {
|
|
31
|
-
return this._agentKey
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
package/src/keri/app/apping.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import libsodium from "libsodium-wrappers-sumo";
|
|
2
|
-
import {Salter} from "../core/salter";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function randomPasscode(): string {
|
|
6
|
-
let raw = libsodium.randombytes_buf(16);
|
|
7
|
-
let salter = new Salter({raw: raw})
|
|
8
|
-
|
|
9
|
-
return salter.qb64.substring(2)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
package/src/keri/app/client.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export class Client {
|
|
4
|
-
private readonly _url: string
|
|
5
|
-
|
|
6
|
-
constructor(url: string) {
|
|
7
|
-
this._url = url
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
url(path: string): string {
|
|
11
|
-
let url = new URL(path, this._url)
|
|
12
|
-
|
|
13
|
-
return url.href
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getAccount(name: string): Promise<Response> {
|
|
17
|
-
let url = this.url(`/account/${name}`)
|
|
18
|
-
let req = new Request(url, {method: "GET"})
|
|
19
|
-
return fetch(req)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
createAccount(name: string, key: string, ndig: string): Promise<Response> {
|
|
23
|
-
let url = this.url(`/account/${name}`)
|
|
24
|
-
let body = {key, ndig}
|
|
25
|
-
let req = new Request(url, {method: "POST", body: JSON.stringify(body)})
|
|
26
|
-
return fetch(req)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
package/src/keri/app/signify.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {Habery} from "./habery";
|
|
2
|
-
import {Accountant} from "./accountant";
|
|
3
|
-
import {Client} from "./client";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export class Signify {
|
|
7
|
-
private readonly _hby?: Habery
|
|
8
|
-
private readonly _act?: Accountant
|
|
9
|
-
private readonly _client?: Client
|
|
10
|
-
constructor(url:string, name:string, passcode: string) {
|
|
11
|
-
}
|
|
12
|
-
}
|