signify-ts 0.2.1 → 0.3.0-rc2

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.
Files changed (128) hide show
  1. package/README.md +104 -34
  2. package/dist/exports.d.ts +40 -40
  3. package/dist/exports.js +40 -0
  4. package/dist/index.d.ts +2 -3
  5. package/dist/index.js +3 -8
  6. package/dist/keri/app/aiding.d.ts +34 -14
  7. package/{src/keri/app/aiding.ts → dist/keri/app/aiding.js} +104 -235
  8. package/dist/keri/app/clienting.d.ts +57 -22
  9. package/{src/keri/app/clienting.ts → dist/keri/app/clienting.js} +145 -234
  10. package/dist/keri/app/contacting.d.ts +33 -21
  11. package/{src/keri/app/contacting.ts → dist/keri/app/contacting.js} +25 -62
  12. package/dist/keri/app/controller.d.ts +49 -6
  13. package/{src/keri/app/controller.ts → dist/keri/app/controller.js} +79 -185
  14. package/dist/keri/app/coring.d.ts +30 -8
  15. package/{src/keri/app/coring.ts → dist/keri/app/coring.js} +62 -51
  16. package/dist/keri/app/credentialing.d.ts +183 -65
  17. package/dist/keri/app/credentialing.js +540 -0
  18. package/dist/keri/app/delegating.d.ts +18 -0
  19. package/dist/keri/app/delegating.js +24 -0
  20. package/dist/keri/app/escrowing.d.ts +1 -1
  21. package/{src/keri/app/escrowing.ts → dist/keri/app/escrowing.js} +2 -8
  22. package/dist/keri/app/exchanging.d.ts +7 -6
  23. package/{src/keri/app/exchanging.ts → dist/keri/app/exchanging.js} +33 -110
  24. package/dist/keri/app/grouping.d.ts +2 -2
  25. package/{src/keri/app/grouping.ts → dist/keri/app/grouping.js} +6 -25
  26. package/dist/keri/app/habery.d.ts +2 -2
  27. package/dist/keri/app/habery.js +117 -0
  28. package/dist/keri/app/notifying.d.ts +2 -2
  29. package/{src/keri/app/notifying.ts → dist/keri/app/notifying.js} +7 -17
  30. package/dist/keri/core/authing.d.ts +2 -2
  31. package/{src/keri/core/authing.ts → dist/keri/core/authing.js} +26 -42
  32. package/dist/keri/core/base64.d.ts +2 -0
  33. package/dist/keri/core/base64.js +16 -0
  34. package/dist/keri/core/bexter.d.ts +1 -1
  35. package/{src/keri/core/bexter.ts → dist/keri/core/bexter.js} +18 -32
  36. package/dist/keri/core/cigar.d.ts +2 -2
  37. package/dist/keri/core/cigar.js +13 -0
  38. package/dist/keri/core/cipher.d.ts +1 -1
  39. package/{src/keri/core/cipher.ts → dist/keri/core/cipher.js} +10 -19
  40. package/dist/keri/core/core.d.ts +117 -9
  41. package/dist/keri/core/core.js +385 -0
  42. package/dist/keri/core/counter.d.ts +2 -2
  43. package/dist/keri/core/counter.js +221 -0
  44. package/dist/keri/core/decrypter.d.ts +4 -4
  45. package/{src/keri/core/decrypter.ts → dist/keri/core/decrypter.js} +23 -40
  46. package/dist/keri/core/diger.d.ts +3 -3
  47. package/{src/keri/core/diger.ts → dist/keri/core/diger.js} +18 -33
  48. package/dist/keri/core/encrypter.d.ts +2 -2
  49. package/{src/keri/core/encrypter.ts → dist/keri/core/encrypter.js} +18 -38
  50. package/dist/keri/core/eventing.d.ts +4 -4
  51. package/{src/keri/core/eventing.ts → dist/keri/core/eventing.js} +134 -321
  52. package/dist/keri/core/httping.d.ts +11 -4
  53. package/{src/keri/core/httping.ts → dist/keri/core/httping.js} +36 -101
  54. package/dist/keri/core/indexer.d.ts +1 -1
  55. package/dist/keri/core/indexer.js +407 -0
  56. package/dist/keri/core/keeping.d.ts +98 -46
  57. package/dist/keri/core/keeping.js +365 -0
  58. package/{src/keri/core/kering.ts → dist/keri/core/kering.js} +1 -3
  59. package/dist/keri/core/keyState.d.ts +85 -0
  60. package/dist/keri/core/keyState.js +1 -0
  61. package/dist/keri/core/manager.d.ts +147 -12
  62. package/dist/keri/core/manager.js +880 -0
  63. package/dist/keri/core/matter.d.ts +1 -1
  64. package/dist/keri/core/matter.js +460 -0
  65. package/dist/keri/core/number.d.ts +1 -1
  66. package/{src/keri/core/number.ts → dist/keri/core/number.js} +21 -30
  67. package/dist/keri/core/pather.d.ts +2 -2
  68. package/{src/keri/core/pather.ts → dist/keri/core/pather.js} +12 -27
  69. package/dist/keri/core/prefixer.d.ts +10 -10
  70. package/dist/keri/core/prefixer.js +182 -0
  71. package/dist/keri/core/saider.d.ts +2 -12
  72. package/dist/keri/core/saider.js +107 -0
  73. package/dist/keri/core/salter.d.ts +45 -3
  74. package/dist/keri/core/salter.js +117 -0
  75. package/dist/keri/core/seqner.d.ts +1 -1
  76. package/{src/keri/core/seqner.ts → dist/keri/core/seqner.js} +20 -21
  77. package/dist/keri/core/serder.d.ts +25 -12
  78. package/dist/keri/core/serder.js +133 -0
  79. package/dist/keri/core/siger.d.ts +2 -2
  80. package/{src/keri/core/siger.ts → dist/keri/core/siger.js} +4 -14
  81. package/dist/keri/core/signer.d.ts +4 -4
  82. package/dist/keri/core/signer.js +84 -0
  83. package/{src/keri/core/tholder.ts → dist/keri/core/tholder.js} +69 -94
  84. package/dist/keri/core/utils.d.ts +1 -1
  85. package/{src/keri/core/utils.ts → dist/keri/core/utils.js} +30 -60
  86. package/dist/keri/core/vdring.d.ts +2 -2
  87. package/dist/keri/core/vdring.js +61 -0
  88. package/dist/keri/core/verfer.d.ts +2 -6
  89. package/dist/keri/core/verfer.js +37 -0
  90. package/dist/keri/end/ending.d.ts +10 -8
  91. package/dist/keri/end/ending.js +136 -0
  92. package/{src/ready.ts → dist/ready.js} +1 -2
  93. package/dist/types/keria-api-schema.d.ts +304 -0
  94. package/dist/types/keria-api-schema.js +2 -0
  95. package/package.json +53 -50
  96. package/dist/buffer-polyfill.d.ts +0 -1
  97. package/dist/math.d.ts +0 -1
  98. package/dist/signify-ts.cjs +0 -7842
  99. package/dist/signify-ts.cjs.development.js +0 -9501
  100. package/dist/signify-ts.cjs.development.js.map +0 -1
  101. package/dist/signify-ts.cjs.map +0 -7
  102. package/dist/signify-ts.cjs.production.min.js +0 -2
  103. package/dist/signify-ts.cjs.production.min.js.map +0 -1
  104. package/dist/signify-ts.esm.js +0 -9345
  105. package/dist/signify-ts.esm.js.map +0 -1
  106. package/dist/signify-ts.mjs +0 -7818
  107. package/dist/signify-ts.mjs.map +0 -7
  108. package/src/buffer-polyfill.ts +0 -5
  109. package/src/exports.ts +0 -44
  110. package/src/index.ts +0 -4
  111. package/src/keri/app/credentialing.ts +0 -841
  112. package/src/keri/app/habery.ts +0 -185
  113. package/src/keri/core/cigar.ts +0 -18
  114. package/src/keri/core/core.ts +0 -326
  115. package/src/keri/core/counter.ts +0 -273
  116. package/src/keri/core/indexer.ts +0 -509
  117. package/src/keri/core/keeping.ts +0 -684
  118. package/src/keri/core/manager.ts +0 -1183
  119. package/src/keri/core/matter.ts +0 -521
  120. package/src/keri/core/prefixer.ts +0 -233
  121. package/src/keri/core/saider.ts +0 -186
  122. package/src/keri/core/salter.ts +0 -120
  123. package/src/keri/core/serder.ts +0 -163
  124. package/src/keri/core/signer.ts +0 -133
  125. package/src/keri/core/vdring.ts +0 -94
  126. package/src/keri/core/verfer.ts +0 -47
  127. package/src/keri/end/ending.ts +0 -170
  128. package/src/math.ts +0 -3
@@ -1,5 +1,14 @@
1
- import { SignifyClient } from './clienting';
2
- import { Operation } from './coring';
1
+ import { SignifyClient } from './clienting.ts';
2
+ import { Operation } from './coring.ts';
3
+ export interface Contact {
4
+ alias: string;
5
+ oobi: string;
6
+ id: string;
7
+ [key: string]: unknown;
8
+ }
9
+ export interface ContactInfo {
10
+ [key: string]: unknown;
11
+ }
3
12
  /**
4
13
  * Contacts
5
14
  */
@@ -18,29 +27,29 @@ export declare class Contacts {
18
27
  * @param {string} [filterValue] Optional field value to filter contacts
19
28
  * @returns {Promise<any>} A promise to the list of contacts
20
29
  */
21
- list(group?: string, filterField?: string, filterValue?: string): Promise<any>;
30
+ list(group?: string, filterField?: string, filterValue?: string): Promise<Contact[]>;
22
31
  /**
23
32
  * Get a contact
24
33
  * @async
25
34
  * @param {string} pre Prefix of the contact
26
35
  * @returns {Promise<any>} A promise to the contact
27
36
  */
28
- get(pre: string): Promise<any>;
37
+ get(pre: string): Promise<Contact>;
29
38
  /**
30
39
  * Add a contact
31
40
  * @async
32
- * @param {string} pre Prefix of the contact
33
- * @param {any} info Information about the contact
34
- * @returns {Promise<any>} A promise to the result of the addition
41
+ * @param pre Prefix of the contact
42
+ * @param info Information about the contact
43
+ * @returns A promise to the result of the addition
35
44
  */
36
- add(pre: string, info: any): Promise<any>;
45
+ add(pre: string, info: ContactInfo): Promise<Contact>;
37
46
  /**
38
47
  * Delete a contact
39
48
  * @async
40
49
  * @param {string} pre Prefix of the contact
41
- * @returns {Promise<any>} A promise to the result of the deletion
50
+ * @returns {Promise<void>}
42
51
  */
43
- delete(pre: string): Promise<any>;
52
+ delete(pre: string): Promise<void>;
44
53
  /**
45
54
  * Update a contact
46
55
  * @async
@@ -48,7 +57,10 @@ export declare class Contacts {
48
57
  * @param {any} info Updated information about the contact
49
58
  * @returns {Promise<any>} A promise to the result of the update
50
59
  */
51
- update(pre: string, info: any): Promise<any>;
60
+ update(pre: string, info: ContactInfo): Promise<Contact>;
61
+ }
62
+ export interface Challenge {
63
+ words: string[];
52
64
  }
53
65
  /**
54
66
  * Challenges
@@ -66,27 +78,27 @@ export declare class Challenges {
66
78
  * @param {number} strength Integer representing the strength of the challenge. Typically 128 or 256
67
79
  * @returns {Promise<any>} A promise to the list of random words
68
80
  */
69
- generate(strength?: number): Promise<any>;
81
+ generate(strength?: number): Promise<Challenge>;
70
82
  /**
71
83
  * Respond to a challenge by signing a message with the list of words
72
84
  * @async
73
- * @param {string} name Name or alias of the identifier
74
- * @param {string} recipient Prefix of the recipient of the response
75
- * @param {Array<string>} words List of words to embed in the signed response
76
- * @returns {Promise<Response>} A promise to the result of the response
85
+ * @param name Name or alias of the identifier
86
+ * @param recipient Prefix of the recipient of the response
87
+ * @param words List of words to embed in the signed response
88
+ * @returns A promise to the result of the response
77
89
  */
78
- respond(name: string, recipient: string, words: string[]): Promise<Response>;
90
+ respond(name: string, recipient: string, words: string[]): Promise<unknown>;
79
91
  /**
80
92
  * Ask Agent to verify a given sender signed the provided words
81
- * @param {string} source Prefix of the identifier that was challenged
82
- * @param {Array<string>} words List of challenge words to check for
93
+ * @param source Prefix of the identifier that was challenged
94
+ * @param words List of challenge words to check for
83
95
  * @returns A promise to the long running operation
84
96
  */
85
97
  verify(source: string, words: string[]): Promise<Operation<unknown>>;
86
98
  /**
87
99
  * Mark challenge response as signed and accepted
88
- * @param {string} source Prefix of the identifier that was challenged
89
- * @param {string} said qb64 AID of exn message representing the signed response
100
+ * @param source Prefix of the identifier that was challenged
101
+ * @param said qb64 AID of exn message representing the signed response
90
102
  * @returns {Promise<Response>} A promise to the result
91
103
  */
92
104
  responded(source: string, said: string): Promise<Response>;
@@ -1,19 +1,14 @@
1
- import { SignifyClient } from './clienting';
2
- import { Operation } from './coring';
3
-
4
1
  /**
5
2
  * Contacts
6
3
  */
7
4
  export class Contacts {
8
- client: SignifyClient;
9
5
  /**
10
6
  * Contacts
11
7
  * @param {SignifyClient} client
12
8
  */
13
- constructor(client: SignifyClient) {
9
+ constructor(client) {
14
10
  this.client = client;
15
11
  }
16
-
17
12
  /**
18
13
  * List contacts
19
14
  * @async
@@ -22,11 +17,7 @@ export class Contacts {
22
17
  * @param {string} [filterValue] Optional field value to filter contacts
23
18
  * @returns {Promise<any>} A promise to the list of contacts
24
19
  */
25
- async list(
26
- group?: string,
27
- filterField?: string,
28
- filterValue?: string
29
- ): Promise<any> {
20
+ async list(group, filterField, filterValue) {
30
21
  const params = new URLSearchParams();
31
22
  if (group !== undefined) {
32
23
  params.append('group', group);
@@ -35,55 +26,47 @@ export class Contacts {
35
26
  params.append('filter_field', filterField);
36
27
  params.append('filter_value', filterValue);
37
28
  }
38
-
39
29
  const path = `/contacts` + '?' + params.toString();
40
30
  const method = 'GET';
41
31
  const res = await this.client.fetch(path, method, null);
42
32
  return await res.json();
43
33
  }
44
-
45
34
  /**
46
35
  * Get a contact
47
36
  * @async
48
37
  * @param {string} pre Prefix of the contact
49
38
  * @returns {Promise<any>} A promise to the contact
50
39
  */
51
- async get(pre: string): Promise<any> {
40
+ async get(pre) {
52
41
  const path = `/contacts/` + pre;
53
42
  const method = 'GET';
54
43
  const res = await this.client.fetch(path, method, null);
55
44
  return await res.json();
56
45
  }
57
-
58
46
  /**
59
47
  * Add a contact
60
48
  * @async
61
- * @param {string} pre Prefix of the contact
62
- * @param {any} info Information about the contact
63
- * @returns {Promise<any>} A promise to the result of the addition
49
+ * @param pre Prefix of the contact
50
+ * @param info Information about the contact
51
+ * @returns A promise to the result of the addition
64
52
  */
65
- async add(pre: string, info: any): Promise<any> {
53
+ async add(pre, info) {
66
54
  const path = `/contacts/` + pre;
67
55
  const method = 'POST';
68
-
69
56
  const res = await this.client.fetch(path, method, info);
70
57
  return await res.json();
71
58
  }
72
-
73
59
  /**
74
60
  * Delete a contact
75
61
  * @async
76
62
  * @param {string} pre Prefix of the contact
77
- * @returns {Promise<any>} A promise to the result of the deletion
63
+ * @returns {Promise<void>}
78
64
  */
79
- async delete(pre: string): Promise<any> {
65
+ async delete(pre) {
80
66
  const path = `/contacts/` + pre;
81
67
  const method = 'DELETE';
82
-
83
- const res = await this.client.fetch(path, method, null);
84
- return await res.json();
68
+ await this.client.fetch(path, method, undefined);
85
69
  }
86
-
87
70
  /**
88
71
  * Update a contact
89
72
  * @async
@@ -91,92 +74,72 @@ export class Contacts {
91
74
  * @param {any} info Updated information about the contact
92
75
  * @returns {Promise<any>} A promise to the result of the update
93
76
  */
94
- async update(pre: string, info: any): Promise<any> {
77
+ async update(pre, info) {
95
78
  const path = `/contacts/` + pre;
96
79
  const method = 'PUT';
97
-
98
80
  const res = await this.client.fetch(path, method, info);
99
81
  return await res.json();
100
82
  }
101
83
  }
102
-
103
84
  /**
104
85
  * Challenges
105
86
  */
106
87
  export class Challenges {
107
- client: SignifyClient;
108
88
  /**
109
89
  * Challenges
110
90
  * @param {SignifyClient} client
111
91
  */
112
- constructor(client: SignifyClient) {
92
+ constructor(client) {
113
93
  this.client = client;
114
94
  }
115
-
116
95
  /**
117
96
  * Generate a random challenge word list based on BIP39
118
97
  * @async
119
98
  * @param {number} strength Integer representing the strength of the challenge. Typically 128 or 256
120
99
  * @returns {Promise<any>} A promise to the list of random words
121
100
  */
122
- async generate(strength: number = 128): Promise<any> {
101
+ async generate(strength = 128) {
123
102
  const path = `/challenges?strength=${strength.toString()}`;
124
103
  const method = 'GET';
125
104
  const res = await this.client.fetch(path, method, null);
126
105
  return await res.json();
127
106
  }
128
-
129
107
  /**
130
108
  * Respond to a challenge by signing a message with the list of words
131
109
  * @async
132
- * @param {string} name Name or alias of the identifier
133
- * @param {string} recipient Prefix of the recipient of the response
134
- * @param {Array<string>} words List of words to embed in the signed response
135
- * @returns {Promise<Response>} A promise to the result of the response
110
+ * @param name Name or alias of the identifier
111
+ * @param recipient Prefix of the recipient of the response
112
+ * @param words List of words to embed in the signed response
113
+ * @returns A promise to the result of the response
136
114
  */
137
- async respond(
138
- name: string,
139
- recipient: string,
140
- words: string[]
141
- ): Promise<Response> {
115
+ async respond(name, recipient, words) {
142
116
  const hab = await this.client.identifiers().get(name);
143
117
  const exchanges = this.client.exchanges();
144
- const resp = await exchanges.send(
145
- name,
146
- 'challenge',
147
- hab,
148
- '/challenge/response',
149
- { words: words },
150
- {},
151
- [recipient]
152
- );
118
+ const resp = await exchanges.send(name, 'challenge', hab, '/challenge/response', { words: words }, {}, [recipient]);
153
119
  return resp;
154
120
  }
155
-
156
121
  /**
157
122
  * Ask Agent to verify a given sender signed the provided words
158
- * @param {string} source Prefix of the identifier that was challenged
159
- * @param {Array<string>} words List of challenge words to check for
123
+ * @param source Prefix of the identifier that was challenged
124
+ * @param words List of challenge words to check for
160
125
  * @returns A promise to the long running operation
161
126
  */
162
- async verify(source: string, words: string[]): Promise<Operation<unknown>> {
127
+ async verify(source, words) {
163
128
  const path = `/challenges_verify/${source}`;
164
129
  const method = 'POST';
165
130
  const data = {
166
131
  words: words,
167
132
  };
168
133
  const res = await this.client.fetch(path, method, data);
169
-
170
134
  return await res.json();
171
135
  }
172
-
173
136
  /**
174
137
  * Mark challenge response as signed and accepted
175
- * @param {string} source Prefix of the identifier that was challenged
176
- * @param {string} said qb64 AID of exn message representing the signed response
138
+ * @param source Prefix of the identifier that was challenged
139
+ * @param said qb64 AID of exn message representing the signed response
177
140
  * @returns {Promise<Response>} A promise to the result
178
141
  */
179
- async responded(source: string, said: string): Promise<Response> {
142
+ async responded(source, said) {
180
143
  const path = `/challenges_verify/${source}`;
181
144
  const method = 'PUT';
182
145
  const data = {
@@ -1,8 +1,8 @@
1
- import { Tier } from '../core/salter';
2
- import { Serder } from '../core/serder';
3
- import { Verfer } from '../core/verfer';
4
- import { Encrypter } from '../core/encrypter';
5
- import { Decrypter } from '../core/decrypter';
1
+ import { Tier } from '../core/salter.ts';
2
+ import { Serder } from '../core/serder.ts';
3
+ import { Verfer } from '../core/verfer.ts';
4
+ import { Encrypter } from '../core/encrypter.ts';
5
+ import { Decrypter } from '../core/decrypter.ts';
6
6
  /**
7
7
  * Agent is a custodial entity that can be used in conjuntion with a local Client to establish the
8
8
  * KERI "signing at the edge" semantic
@@ -24,15 +24,58 @@ export declare class Agent {
24
24
  */
25
25
  export declare class Controller {
26
26
  private bran;
27
+ /**
28
+ * The stem is the prefix for the stretched input bytes the controller's cryptographic
29
+ * key pairs are derived from.
30
+ */
27
31
  stem: string;
32
+ /**
33
+ * The security tier for the identifiers created by this Controller.
34
+ */
28
35
  tier: Tier;
36
+ /**
37
+ * The rotation index used during key generation by this Controller.
38
+ */
29
39
  ridx: number;
40
+ /**
41
+ * The salter is a cryptographic salt used to derive the controller's cryptographic key pairs
42
+ * and is deterministically derived from the bran and the security tier.
43
+ */
30
44
  salter: any;
45
+ /**
46
+ * The current signing key used to sign requests for this controller.
47
+ */
31
48
  signer: any;
49
+ /**
50
+ * The next signing key of which a digest is committed to in an establishment event (inception or rotation) to become the
51
+ * signing key after the next rotation.
52
+ * @private
53
+ */
32
54
  private nsigner;
55
+ /**
56
+ * Either the current establishment event, inception or rotation, or the interaction event used for delegation approval.
57
+ */
33
58
  serder: Serder;
59
+ /**
60
+ * Current public keys formatted in fully-qualified Base64.
61
+ * @private
62
+ */
34
63
  private keys;
64
+ /**
65
+ * Digests of the next public keys formatted in fully-qualified Base64.
66
+ */
35
67
  ndigs: string[];
68
+ /**
69
+ * Creates a Signify Controller starting at key index 0 that generates keys in
70
+ * memory based on the provided seed, or bran, the tier, and the rotation index.
71
+ *
72
+ * The rotation index is used as follows:
73
+ *
74
+ * @param bran
75
+ * @param tier
76
+ * @param ridx
77
+ * @param state
78
+ */
36
79
  constructor(bran: string, tier: Tier, ridx?: number, state?: any | null);
37
80
  approveDelegation(_agent: Agent): any[];
38
81
  get pre(): string;
@@ -40,7 +83,7 @@ export declare class Controller {
40
83
  get verfers(): [];
41
84
  derive(state: any): Serder;
42
85
  rotate(bran: string, aids: Array<any>): {
43
- rot: import("../core/core").Dict<any>;
86
+ rot: import("../core/core.ts").Dict<any>;
44
87
  sigs: any[];
45
88
  sxlt: any;
46
89
  keys: Record<any, any>;