signify-ts 0.2.1 → 0.3.0-dev.e31e78d

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 (129) 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 +54 -18
  7. package/{src/keri/app/aiding.ts → dist/keri/app/aiding.js} +130 -236
  8. package/dist/keri/app/clienting.d.ts +59 -22
  9. package/{src/keri/app/clienting.ts → dist/keri/app/clienting.js} +146 -235
  10. package/dist/keri/app/contacting.d.ts +30 -23
  11. package/{src/keri/app/contacting.ts → dist/keri/app/contacting.js} +26 -63
  12. package/dist/keri/app/controller.d.ts +49 -6
  13. package/{src/keri/app/controller.ts → dist/keri/app/controller.js} +80 -186
  14. package/dist/keri/app/coring.d.ts +134 -25
  15. package/{src/keri/app/coring.ts → dist/keri/app/coring.js} +83 -56
  16. package/dist/keri/app/credentialing.d.ts +187 -69
  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 +5 -3
  21. package/{src/keri/app/escrowing.ts → dist/keri/app/escrowing.js} +3 -9
  22. package/dist/keri/app/exchanging.d.ts +243 -11
  23. package/dist/keri/app/exchanging.js +242 -0
  24. package/dist/keri/app/grouping.d.ts +11 -9
  25. package/{src/keri/app/grouping.ts → dist/keri/app/grouping.js} +10 -29
  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 +6 -6
  51. package/dist/keri/core/eventing.js +383 -0
  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 +113 -46
  57. package/dist/keri/core/keeping.js +347 -0
  58. package/{src/keri/core/kering.ts → dist/keri/core/kering.js} +1 -3
  59. package/dist/keri/core/keyState.d.ts +98 -0
  60. package/dist/keri/core/manager.d.ts +147 -12
  61. package/dist/keri/core/manager.js +880 -0
  62. package/dist/keri/core/matter.d.ts +1 -1
  63. package/dist/keri/core/matter.js +460 -0
  64. package/dist/keri/core/number.d.ts +2 -2
  65. package/{src/keri/core/number.ts → dist/keri/core/number.js} +26 -32
  66. package/dist/keri/core/pather.d.ts +2 -2
  67. package/{src/keri/core/pather.ts → dist/keri/core/pather.js} +12 -27
  68. package/dist/keri/core/prefixer.d.ts +10 -10
  69. package/dist/keri/core/prefixer.js +182 -0
  70. package/dist/keri/core/saider.d.ts +2 -12
  71. package/dist/keri/core/saider.js +107 -0
  72. package/dist/keri/core/salter.d.ts +44 -9
  73. package/dist/keri/core/salter.js +110 -0
  74. package/dist/keri/core/seqner.d.ts +1 -1
  75. package/{src/keri/core/seqner.ts → dist/keri/core/seqner.js} +20 -21
  76. package/dist/keri/core/serder.d.ts +25 -12
  77. package/dist/keri/core/serder.js +133 -0
  78. package/dist/keri/core/siger.d.ts +2 -2
  79. package/{src/keri/core/siger.ts → dist/keri/core/siger.js} +4 -14
  80. package/dist/keri/core/signer.d.ts +4 -4
  81. package/dist/keri/core/signer.js +84 -0
  82. package/{src/keri/core/tholder.ts → dist/keri/core/tholder.js} +69 -94
  83. package/dist/keri/core/utils.d.ts +1 -1
  84. package/{src/keri/core/utils.ts → dist/keri/core/utils.js} +30 -60
  85. package/dist/keri/core/vdring.d.ts +2 -2
  86. package/dist/keri/core/vdring.js +61 -0
  87. package/dist/keri/core/verfer.d.ts +2 -6
  88. package/dist/keri/core/verfer.js +37 -0
  89. package/dist/keri/end/ending.d.ts +10 -8
  90. package/dist/keri/end/ending.js +136 -0
  91. package/{src/ready.ts → dist/ready.js} +1 -2
  92. package/dist/types/keria-api-schema.d.ts +1158 -0
  93. package/dist/types/keria-api-schema.js +34 -0
  94. package/package.json +53 -52
  95. package/dist/math.d.ts +0 -1
  96. package/dist/signify-ts.cjs +0 -7842
  97. package/dist/signify-ts.cjs.development.js +0 -9501
  98. package/dist/signify-ts.cjs.development.js.map +0 -1
  99. package/dist/signify-ts.cjs.map +0 -7
  100. package/dist/signify-ts.cjs.production.min.js +0 -2
  101. package/dist/signify-ts.cjs.production.min.js.map +0 -1
  102. package/dist/signify-ts.esm.js +0 -9345
  103. package/dist/signify-ts.esm.js.map +0 -1
  104. package/dist/signify-ts.mjs +0 -7818
  105. package/dist/signify-ts.mjs.map +0 -7
  106. package/src/buffer-polyfill.ts +0 -5
  107. package/src/exports.ts +0 -44
  108. package/src/index.ts +0 -4
  109. package/src/keri/app/credentialing.ts +0 -841
  110. package/src/keri/app/exchanging.ts +0 -220
  111. package/src/keri/app/habery.ts +0 -185
  112. package/src/keri/core/cigar.ts +0 -18
  113. package/src/keri/core/core.ts +0 -326
  114. package/src/keri/core/counter.ts +0 -273
  115. package/src/keri/core/eventing.ts +0 -581
  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
  129. /package/dist/{buffer-polyfill.d.ts → keri/core/keyState.js} +0 -0
@@ -1,5 +1,11 @@
1
- import { SignifyClient } from './clienting';
2
- import { Operation } from './coring';
1
+ import { SignifyClient } from './clienting.ts';
2
+ import { components } from '../../types/keria-api-schema.ts';
3
+ import { ChallengeOperation } from '../core/keyState.ts';
4
+ import { Exn } from './exchanging.ts';
5
+ export type Contact = components['schemas']['Contact'];
6
+ export interface ContactInfo {
7
+ [key: string]: unknown;
8
+ }
3
9
  /**
4
10
  * Contacts
5
11
  */
@@ -18,29 +24,29 @@ export declare class Contacts {
18
24
  * @param {string} [filterValue] Optional field value to filter contacts
19
25
  * @returns {Promise<any>} A promise to the list of contacts
20
26
  */
21
- list(group?: string, filterField?: string, filterValue?: string): Promise<any>;
27
+ list(group?: string, filterField?: string, filterValue?: string): Promise<Contact[]>;
22
28
  /**
23
29
  * Get a contact
24
30
  * @async
25
31
  * @param {string} pre Prefix of the contact
26
32
  * @returns {Promise<any>} A promise to the contact
27
33
  */
28
- get(pre: string): Promise<any>;
34
+ get(pre: string): Promise<Contact>;
29
35
  /**
30
36
  * Add a contact
31
37
  * @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
38
+ * @param pre Prefix of the contact
39
+ * @param info Information about the contact
40
+ * @returns A promise to the result of the addition
35
41
  */
36
- add(pre: string, info: any): Promise<any>;
42
+ add(pre: string, info: ContactInfo): Promise<Contact>;
37
43
  /**
38
44
  * Delete a contact
39
45
  * @async
40
46
  * @param {string} pre Prefix of the contact
41
- * @returns {Promise<any>} A promise to the result of the deletion
47
+ * @returns {Promise<void>}
42
48
  */
43
- delete(pre: string): Promise<any>;
49
+ delete(pre: string): Promise<void>;
44
50
  /**
45
51
  * Update a contact
46
52
  * @async
@@ -48,8 +54,9 @@ export declare class Contacts {
48
54
  * @param {any} info Updated information about the contact
49
55
  * @returns {Promise<any>} A promise to the result of the update
50
56
  */
51
- update(pre: string, info: any): Promise<any>;
57
+ update(pre: string, info: ContactInfo): Promise<Contact>;
52
58
  }
59
+ export type Challenge = components['schemas']['Challenge'];
53
60
  /**
54
61
  * Challenges
55
62
  */
@@ -64,29 +71,29 @@ export declare class Challenges {
64
71
  * Generate a random challenge word list based on BIP39
65
72
  * @async
66
73
  * @param {number} strength Integer representing the strength of the challenge. Typically 128 or 256
67
- * @returns {Promise<any>} A promise to the list of random words
74
+ * @returns {Promise<Challenge>} A promise to the generated challenge
68
75
  */
69
- generate(strength?: number): Promise<any>;
76
+ generate(strength?: number): Promise<Challenge>;
70
77
  /**
71
78
  * Respond to a challenge by signing a message with the list of words
72
79
  * @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
80
+ * @param name Name or alias of the identifier
81
+ * @param recipient Prefix of the recipient of the response
82
+ * @param words List of words to embed in the signed response
83
+ * @returns {Promise<Exn>} A promise to the signed response exn message
77
84
  */
78
- respond(name: string, recipient: string, words: string[]): Promise<Response>;
85
+ respond(name: string, recipient: string, words: string[]): Promise<Exn>;
79
86
  /**
80
87
  * 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
88
+ * @param source Prefix of the identifier that was challenged
89
+ * @param words List of challenge words to check for
83
90
  * @returns A promise to the long running operation
84
91
  */
85
- verify(source: string, words: string[]): Promise<Operation<unknown>>;
92
+ verify(source: string, words: string[]): Promise<ChallengeOperation>;
86
93
  /**
87
94
  * 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
95
+ * @param source Prefix of the identifier that was challenged
96
+ * @param said qb64 AID of exn message representing the signed response
90
97
  * @returns {Promise<Response>} A promise to the result
91
98
  */
92
99
  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
- * @returns {Promise<any>} A promise to the list of random words
99
+ * @returns {Promise<Challenge>} A promise to the generated challenge
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 {Promise<Exn>} A promise to the signed response exn message
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>;