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,6 +1,237 @@
1
- import { SignifyClient } from './clienting';
2
- import { Dict } from '../core/core';
3
- import { Serder } from '../core/serder';
1
+ import { SignifyClient } from './clienting.ts';
2
+ import { Dict } from '../core/core.ts';
3
+ import { Serder } from '../core/serder.ts';
4
+ import { Dip, ExnV1, HabState, Icp, Ixn } from '../core/keyState.ts';
5
+ import { Rpy } from './escrowing.ts';
6
+ import { components } from '../../types/keria-api-schema.ts';
7
+ export type Exn = components['schemas']['Exn'];
8
+ export type ExchangeResource = components['schemas']['ExchangeResource'];
9
+ export type ExchangeResourceV1 = Omit<ExchangeResource, 'exn'> & {
10
+ exn: ExnV1;
11
+ };
12
+ export type ExnMultisig = components['schemas']['ExnMultisig'];
13
+ export declare const MULTISIG_ICP_ROUTE = "/multisig/icp";
14
+ export declare const MULTISIG_ROT_ROUTE = "/multisig/rot";
15
+ export declare const MULTISIG_IXN_ROUTE = "/multisig/ixn";
16
+ export declare const MULTISIG_RPY_ROUTE = "/multisig/rpy";
17
+ export declare const MULTISIG_VCP_ROUTE = "/multisig/vcp";
18
+ export declare const MULTISIG_ISS_ROUTE = "/multisig/iss";
19
+ export declare const MULTISIG_EXN_ROUTE = "/multisig/exn";
20
+ export declare const MULTISIG_REV_ROUTE = "/multisig/rev";
21
+ export declare const IPEX_GRANT_ROUTE = "/ipex/grant";
22
+ export declare const IPEX_OFFER_ROUTE = "/ipex/offer";
23
+ export declare const IPEX_APPLY_ROUTE = "/ipex/apply";
24
+ export declare const IPEX_AGREE_ROUTE = "/ipex/agree";
25
+ export declare const IPEX_ADMIT_ROUTE = "/ipex/admit";
26
+ export type AnchorEvent = components['schemas']['IXN_V_1'] | components['schemas']['ICP_V_1'] | components['schemas']['ROT_V_1'] | components['schemas']['DIP_V_1'] | components['schemas']['DIP_V_2'];
27
+ export type MultisigIcpExchange = ExchangeResourceV1 & {
28
+ exn: ExnV1 & {
29
+ r: typeof MULTISIG_ICP_ROUTE;
30
+ e: {
31
+ icp: Icp | Dip;
32
+ d?: string;
33
+ };
34
+ a: {
35
+ gid: string;
36
+ smids: string[];
37
+ rmids?: string[];
38
+ [key: string]: unknown;
39
+ };
40
+ };
41
+ };
42
+ export type MultisigRotExchange = ExchangeResourceV1 & {
43
+ exn: ExnV1 & {
44
+ r: typeof MULTISIG_ROT_ROUTE;
45
+ e: {
46
+ rot: components['schemas']['ROT_V_1'];
47
+ d?: string;
48
+ };
49
+ a: {
50
+ gid: string;
51
+ smids: string[];
52
+ rmids?: string[];
53
+ [key: string]: unknown;
54
+ };
55
+ };
56
+ };
57
+ export type MultisigIxnExchange = ExchangeResourceV1 & {
58
+ exn: ExnV1 & {
59
+ r: typeof MULTISIG_IXN_ROUTE;
60
+ e: {
61
+ ixn: Ixn;
62
+ d?: string;
63
+ };
64
+ a: {
65
+ gid: string;
66
+ smids: string[];
67
+ rmids?: string[];
68
+ [key: string]: unknown;
69
+ };
70
+ };
71
+ };
72
+ export type MultisigRpyExchange = ExchangeResourceV1 & {
73
+ exn: ExnV1 & {
74
+ r: typeof MULTISIG_RPY_ROUTE;
75
+ e: {
76
+ rpy: Rpy;
77
+ d?: string;
78
+ };
79
+ a: {
80
+ gid: string;
81
+ [key: string]: unknown;
82
+ };
83
+ };
84
+ };
85
+ export type MultisigVcpExchange = ExchangeResourceV1 & {
86
+ exn: ExnV1 & {
87
+ r: typeof MULTISIG_VCP_ROUTE;
88
+ e: {
89
+ vcp: components['schemas']['VCP_V_1'];
90
+ anc: AnchorEvent;
91
+ d?: string;
92
+ };
93
+ a: {
94
+ gid: string;
95
+ usage?: string;
96
+ [key: string]: unknown;
97
+ };
98
+ };
99
+ };
100
+ export type MultisigIssExchange = ExchangeResourceV1 & {
101
+ exn: ExnV1 & {
102
+ r: typeof MULTISIG_ISS_ROUTE;
103
+ e: {
104
+ acdc: components['schemas']['ACDC_V_1'];
105
+ iss: components['schemas']['ISS_V_1'];
106
+ anc: AnchorEvent;
107
+ d?: string;
108
+ };
109
+ a: {
110
+ gid: string;
111
+ [key: string]: unknown;
112
+ };
113
+ };
114
+ };
115
+ export type MultisigExnExchange = ExchangeResourceV1 & {
116
+ exn: ExnV1 & {
117
+ r: typeof MULTISIG_EXN_ROUTE;
118
+ e: {
119
+ exn: ExnV1;
120
+ d?: string;
121
+ };
122
+ a: {
123
+ gid: string;
124
+ [key: string]: unknown;
125
+ };
126
+ };
127
+ };
128
+ export type MultisigRevExchange = ExchangeResourceV1 & {
129
+ exn: ExnV1 & {
130
+ r: typeof MULTISIG_REV_ROUTE;
131
+ e: {
132
+ rev: components['schemas']['REV_V_1'];
133
+ d?: string;
134
+ };
135
+ a: {
136
+ gid: string;
137
+ [key: string]: unknown;
138
+ };
139
+ };
140
+ };
141
+ type WithGroupMetadata = Pick<ExnMultisig, 'paths' | 'groupName' | 'memberName' | 'sender'>;
142
+ export type MultisigIcpGroup = Omit<MultisigIcpExchange, 'pathed'> & WithGroupMetadata;
143
+ export type MultisigRotGroup = Omit<MultisigRotExchange, 'pathed'> & WithGroupMetadata;
144
+ export type MultisigIxnGroup = Omit<MultisigIxnExchange, 'pathed'> & WithGroupMetadata;
145
+ export type MultisigRpyGroup = Omit<MultisigRpyExchange, 'pathed'> & WithGroupMetadata;
146
+ export type MultisigVcpGroup = Omit<MultisigVcpExchange, 'pathed'> & WithGroupMetadata;
147
+ export type MultisigIssGroup = Omit<MultisigIssExchange, 'pathed'> & WithGroupMetadata;
148
+ export type MultisigExnGroup = Omit<MultisigExnExchange, 'pathed'> & WithGroupMetadata;
149
+ export type MultisigRevGroup = Omit<MultisigRevExchange, 'pathed'> & WithGroupMetadata;
150
+ export type IpexGrantExchange = ExchangeResourceV1 & {
151
+ exn: ExnV1 & {
152
+ r: typeof IPEX_GRANT_ROUTE;
153
+ e: {
154
+ acdc: components['schemas']['ACDC_V_1'];
155
+ iss: components['schemas']['ISS_V_1'];
156
+ anc: AnchorEvent;
157
+ d?: string;
158
+ };
159
+ };
160
+ };
161
+ export type IpexOfferExchange = ExchangeResourceV1 & {
162
+ exn: ExnV1 & {
163
+ r: typeof IPEX_OFFER_ROUTE;
164
+ e: {
165
+ acdc: components['schemas']['ACDC_V_1'];
166
+ d?: string;
167
+ };
168
+ };
169
+ };
170
+ export type IpexApplyExchange = ExchangeResourceV1 & {
171
+ exn: ExnV1 & {
172
+ r: typeof IPEX_APPLY_ROUTE;
173
+ e: object;
174
+ };
175
+ };
176
+ export type IpexAgreeExchange = ExchangeResourceV1 & {
177
+ exn: ExnV1 & {
178
+ r: typeof IPEX_AGREE_ROUTE;
179
+ e: object;
180
+ };
181
+ };
182
+ export type IpexAdmitExchange = ExchangeResourceV1 & {
183
+ exn: ExnV1 & {
184
+ r: typeof IPEX_ADMIT_ROUTE;
185
+ e: object;
186
+ };
187
+ };
188
+ export declare function isMultisigIcp(msg: ExchangeResourceV1): msg is MultisigIcpExchange;
189
+ export declare function isMultisigIcp(msg: ExnMultisig): msg is MultisigIcpGroup;
190
+ export declare function isMultisigRot(msg: ExchangeResourceV1): msg is MultisigRotExchange;
191
+ export declare function isMultisigRot(msg: ExnMultisig): msg is MultisigRotGroup;
192
+ export declare function isMultisigIxn(msg: ExchangeResourceV1): msg is MultisigIxnExchange;
193
+ export declare function isMultisigIxn(msg: ExnMultisig): msg is MultisigIxnGroup;
194
+ export declare function isMultisigRpy(msg: ExchangeResourceV1): msg is MultisigRpyExchange;
195
+ export declare function isMultisigRpy(msg: ExnMultisig): msg is MultisigRpyGroup;
196
+ export declare function isMultisigVcp(msg: ExchangeResourceV1): msg is MultisigVcpExchange;
197
+ export declare function isMultisigVcp(msg: ExnMultisig): msg is MultisigVcpGroup;
198
+ export declare function isMultisigIss(msg: ExchangeResourceV1): msg is MultisigIssExchange;
199
+ export declare function isMultisigIss(msg: ExnMultisig): msg is MultisigIssGroup;
200
+ export declare function isMultisigExn(msg: ExchangeResourceV1): msg is MultisigExnExchange;
201
+ export declare function isMultisigExn(msg: ExnMultisig): msg is MultisigExnGroup;
202
+ export declare function isMultisigRev(msg: ExchangeResourceV1): msg is MultisigRevExchange;
203
+ export declare function isMultisigRev(msg: ExnMultisig): msg is MultisigRevGroup;
204
+ export declare function isIpexGrant(msg: ExchangeResourceV1): msg is IpexGrantExchange;
205
+ export declare function isIpexOffer(msg: ExchangeResourceV1): msg is IpexOfferExchange;
206
+ export declare function isIpexApply(msg: ExchangeResourceV1): msg is IpexApplyExchange;
207
+ export declare function isIpexAgree(msg: ExchangeResourceV1): msg is IpexAgreeExchange;
208
+ export declare function isIpexAdmit(msg: ExchangeResourceV1): msg is IpexAdmitExchange;
209
+ export declare function assertMultisigIss(msg: ExchangeResourceV1): MultisigIssExchange;
210
+ export declare function assertMultisigIss(msg: ExnMultisig): MultisigIssGroup;
211
+ export declare function assertMultisigIcp(msg: ExchangeResourceV1): MultisigIcpExchange;
212
+ export declare function assertMultisigIcp(msg: ExnMultisig): MultisigIcpGroup;
213
+ export declare function assertMultisigRot(msg: ExchangeResourceV1): MultisigRotExchange;
214
+ export declare function assertMultisigRot(msg: ExnMultisig): MultisigRotGroup;
215
+ export declare function assertMultisigIxn(msg: ExchangeResourceV1): MultisigIxnExchange;
216
+ export declare function assertMultisigIxn(msg: ExnMultisig): MultisigIxnGroup;
217
+ export declare function assertMultisigRpy(msg: ExchangeResourceV1): MultisigRpyExchange;
218
+ export declare function assertMultisigRpy(msg: ExnMultisig): MultisigRpyGroup;
219
+ export declare function assertMultisigVcp(msg: ExchangeResourceV1): MultisigVcpExchange;
220
+ export declare function assertMultisigVcp(msg: ExnMultisig): MultisigVcpGroup;
221
+ export declare function assertMultisigExn(msg: ExchangeResourceV1): MultisigExnExchange;
222
+ export declare function assertMultisigExn(msg: ExnMultisig): MultisigExnGroup;
223
+ export declare function assertMultisigRev(msg: ExchangeResourceV1): MultisigRevExchange;
224
+ export declare function assertMultisigRev(msg: ExnMultisig): MultisigRevGroup;
225
+ export declare function assertIpexGrant(msg: ExchangeResourceV1): IpexGrantExchange;
226
+ export declare function assertIpexGrant(msg: ExnMultisig): ExnMultisig;
227
+ export declare function assertIpexOffer(msg: ExchangeResourceV1): IpexOfferExchange;
228
+ export declare function assertIpexOffer(msg: ExnMultisig): ExnMultisig;
229
+ export declare function assertIpexApply(msg: ExchangeResourceV1): IpexApplyExchange;
230
+ export declare function assertIpexApply(msg: ExnMultisig): ExnMultisig;
231
+ export declare function assertIpexAgree(msg: ExchangeResourceV1): IpexAgreeExchange;
232
+ export declare function assertIpexAgree(msg: ExnMultisig): ExnMultisig;
233
+ export declare function assertIpexAdmit(msg: ExchangeResourceV1): IpexAdmitExchange;
234
+ export declare function assertIpexAdmit(msg: ExnMultisig): ExnMultisig;
4
235
  /**
5
236
  * Exchanges
6
237
  */
@@ -23,11 +254,11 @@ export declare class Exchanges {
23
254
  * @param datetime
24
255
  * @param dig
25
256
  */
26
- createExchangeMessage(sender: Dict<any>, route: string, payload: Dict<any>, embeds: Dict<any>, recipient?: string, datetime?: string, dig?: string): Promise<[Serder, string[], string]>;
257
+ createExchangeMessage(sender: HabState, route: string, payload: Dict<any>, embeds: Dict<any>, recipient: string, datetime?: string, dig?: string): Promise<[Serder, string[], string]>;
27
258
  /**
28
259
  * Send exn messages to list of recipients
29
260
  * @async
30
- * @returns {Promise<any>} A promise to the list of replay messages
261
+ * @returns {Promise<Exn>} A promise to the list of replay messages
31
262
  * @param name
32
263
  * @param topic
33
264
  * @param sender
@@ -36,11 +267,11 @@ export declare class Exchanges {
36
267
  * @param embeds
37
268
  * @param recipients
38
269
  */
39
- send(name: string, topic: string, sender: Dict<any>, route: string, payload: Dict<any>, embeds: Dict<any>, recipients: string[]): Promise<any>;
270
+ send(name: string, topic: string, sender: HabState, route: string, payload: Dict<any>, embeds: Dict<any>, recipients: string[]): Promise<Exn>;
40
271
  /**
41
- * Send exn messaget to list of recipients
272
+ * Send exn message to list of recipients
42
273
  * @async
43
- * @returns {Promise<any>} A promise to the list of replay messages
274
+ * @returns {Promise<Exn>} A promise to the list of replay messages
44
275
  * @param name
45
276
  * @param topic
46
277
  * @param exn
@@ -48,13 +279,14 @@ export declare class Exchanges {
48
279
  * @param atc
49
280
  * @param recipients
50
281
  */
51
- sendFromEvents(name: string, topic: string, exn: Serder, sigs: string[], atc: string, recipients: string[]): Promise<any>;
282
+ sendFromEvents(name: string, topic: string, exn: Serder, sigs: string[], atc: string, recipients: string[]): Promise<Exn>;
52
283
  /**
53
284
  * Get exn message by said
54
285
  * @async
55
286
  * @returns A promise to the exn message
56
287
  * @param said The said of the exn message
57
288
  */
58
- get(said: string): Promise<any>;
289
+ get(said: string): Promise<ExchangeResourceV1>;
59
290
  }
60
- export declare function exchange(route: string, payload: Dict<any>, sender: string, recipient?: string, date?: string, dig?: string, modifiers?: Dict<any>, embeds?: Dict<any>): [Serder, Uint8Array];
291
+ export declare function exchange(route: string, payload: Dict<any>, sender: string, recipient: string, date?: string, dig?: string, modifiers?: Dict<any>, embeds?: Dict<any>): [Serder, Uint8Array];
292
+ export {};
@@ -0,0 +1,242 @@
1
+ import { b, d, Protocols, Ilks, Serials, versify } from "../core/core.js";
2
+ import { Serder } from "../core/serder.js";
3
+ import { nowUTC } from "../core/utils.js";
4
+ import { Pather } from "../core/pather.js";
5
+ import { Counter, CtrDex } from "../core/counter.js";
6
+ import { Saider } from "../core/saider.js";
7
+ export const MULTISIG_ICP_ROUTE = '/multisig/icp';
8
+ export const MULTISIG_ROT_ROUTE = '/multisig/rot';
9
+ export const MULTISIG_IXN_ROUTE = '/multisig/ixn';
10
+ export const MULTISIG_RPY_ROUTE = '/multisig/rpy';
11
+ export const MULTISIG_VCP_ROUTE = '/multisig/vcp';
12
+ export const MULTISIG_ISS_ROUTE = '/multisig/iss';
13
+ export const MULTISIG_EXN_ROUTE = '/multisig/exn';
14
+ export const MULTISIG_REV_ROUTE = '/multisig/rev';
15
+ export const IPEX_GRANT_ROUTE = '/ipex/grant';
16
+ export const IPEX_OFFER_ROUTE = '/ipex/offer';
17
+ export const IPEX_APPLY_ROUTE = '/ipex/apply';
18
+ export const IPEX_AGREE_ROUTE = '/ipex/agree';
19
+ export const IPEX_ADMIT_ROUTE = '/ipex/admit';
20
+ export function isMultisigIcp(msg) {
21
+ return msg.exn.r === MULTISIG_ICP_ROUTE;
22
+ }
23
+ export function isMultisigRot(msg) {
24
+ return msg.exn.r === MULTISIG_ROT_ROUTE;
25
+ }
26
+ export function isMultisigIxn(msg) {
27
+ return msg.exn.r === MULTISIG_IXN_ROUTE;
28
+ }
29
+ export function isMultisigRpy(msg) {
30
+ return msg.exn.r === MULTISIG_RPY_ROUTE;
31
+ }
32
+ export function isMultisigVcp(msg) {
33
+ return msg.exn.r === MULTISIG_VCP_ROUTE;
34
+ }
35
+ export function isMultisigIss(msg) {
36
+ return msg.exn.r === MULTISIG_ISS_ROUTE;
37
+ }
38
+ export function isMultisigExn(msg) {
39
+ return msg.exn.r === MULTISIG_EXN_ROUTE;
40
+ }
41
+ export function isMultisigRev(msg) {
42
+ return msg.exn.r === MULTISIG_REV_ROUTE;
43
+ }
44
+ export function isIpexGrant(msg) {
45
+ return msg.exn.r === IPEX_GRANT_ROUTE;
46
+ }
47
+ export function isIpexOffer(msg) {
48
+ return msg.exn.r === IPEX_OFFER_ROUTE;
49
+ }
50
+ export function isIpexApply(msg) {
51
+ return msg.exn.r === IPEX_APPLY_ROUTE;
52
+ }
53
+ export function isIpexAgree(msg) {
54
+ return msg.exn.r === IPEX_AGREE_ROUTE;
55
+ }
56
+ export function isIpexAdmit(msg) {
57
+ return msg.exn.r === IPEX_ADMIT_ROUTE;
58
+ }
59
+ function assertRoute(msg, route, label) {
60
+ var _a, _b;
61
+ if (((_a = msg.exn) === null || _a === void 0 ? void 0 : _a.r) !== route) {
62
+ throw new Error(`Expected ${label} but got route: ${(_b = msg.exn) === null || _b === void 0 ? void 0 : _b.r}`);
63
+ }
64
+ return msg;
65
+ }
66
+ export function assertMultisigIss(msg) {
67
+ return assertRoute(msg, MULTISIG_ISS_ROUTE, 'Multisig ISS message');
68
+ }
69
+ export function assertMultisigIcp(msg) {
70
+ return assertRoute(msg, MULTISIG_ICP_ROUTE, 'Multisig ICP message');
71
+ }
72
+ export function assertMultisigRot(msg) {
73
+ return assertRoute(msg, MULTISIG_ROT_ROUTE, 'Multisig ROT message');
74
+ }
75
+ export function assertMultisigIxn(msg) {
76
+ return assertRoute(msg, MULTISIG_IXN_ROUTE, 'Multisig IXN message');
77
+ }
78
+ export function assertMultisigRpy(msg) {
79
+ return assertRoute(msg, MULTISIG_RPY_ROUTE, 'Multisig RPY message');
80
+ }
81
+ export function assertMultisigVcp(msg) {
82
+ return assertRoute(msg, MULTISIG_VCP_ROUTE, 'Multisig VCP message');
83
+ }
84
+ export function assertMultisigExn(msg) {
85
+ return assertRoute(msg, MULTISIG_EXN_ROUTE, 'Multisig EXN message');
86
+ }
87
+ export function assertMultisigRev(msg) {
88
+ return assertRoute(msg, MULTISIG_REV_ROUTE, 'Multisig REV message');
89
+ }
90
+ export function assertIpexGrant(msg) {
91
+ return assertRoute(msg, IPEX_GRANT_ROUTE, 'IPEX grant message');
92
+ }
93
+ export function assertIpexOffer(msg) {
94
+ return assertRoute(msg, IPEX_OFFER_ROUTE, 'IPEX offer message');
95
+ }
96
+ export function assertIpexApply(msg) {
97
+ return assertRoute(msg, IPEX_APPLY_ROUTE, 'IPEX apply message');
98
+ }
99
+ export function assertIpexAgree(msg) {
100
+ return assertRoute(msg, IPEX_AGREE_ROUTE, 'IPEX agree message');
101
+ }
102
+ export function assertIpexAdmit(msg) {
103
+ return assertRoute(msg, IPEX_ADMIT_ROUTE, 'IPEX admit message');
104
+ }
105
+ /**
106
+ * Exchanges
107
+ */
108
+ export class Exchanges {
109
+ /**
110
+ * Exchanges
111
+ * @param {SignifyClient} client
112
+ */
113
+ constructor(client) {
114
+ this.client = client;
115
+ }
116
+ /**
117
+ * Create exn message
118
+ * @async
119
+ * @returns {Promise<any>} A promise to the list of replay messages
120
+ * @param sender
121
+ * @param route
122
+ * @param payload
123
+ * @param embeds
124
+ * @param recipient
125
+ * @param datetime
126
+ * @param dig
127
+ */
128
+ async createExchangeMessage(sender, route, payload, embeds, recipient, datetime, dig) {
129
+ const keeper = this.client.manager.get(sender);
130
+ const [exn, end] = exchange(route, payload, sender['prefix'], recipient, datetime, dig, undefined, embeds);
131
+ const sigs = await keeper.sign(b(exn.raw));
132
+ return [exn, sigs, d(end)];
133
+ }
134
+ /**
135
+ * Send exn messages to list of recipients
136
+ * @async
137
+ * @returns {Promise<Exn>} A promise to the list of replay messages
138
+ * @param name
139
+ * @param topic
140
+ * @param sender
141
+ * @param route
142
+ * @param payload
143
+ * @param embeds
144
+ * @param recipients
145
+ */
146
+ async send(name, topic, sender, route, payload, embeds, recipients) {
147
+ for (const recipient of recipients) {
148
+ const [exn, sigs, atc] = await this.createExchangeMessage(sender, route, payload, embeds, recipient);
149
+ return await this.sendFromEvents(name, topic, exn, sigs, atc, recipients);
150
+ }
151
+ throw new Error('recipients list was empty');
152
+ }
153
+ /**
154
+ * Send exn message to list of recipients
155
+ * @async
156
+ * @returns {Promise<Exn>} A promise to the list of replay messages
157
+ * @param name
158
+ * @param topic
159
+ * @param exn
160
+ * @param sigs
161
+ * @param atc
162
+ * @param recipients
163
+ */
164
+ async sendFromEvents(name, topic, exn, sigs, atc, recipients) {
165
+ const path = `/identifiers/${name}/exchanges`;
166
+ const method = 'POST';
167
+ const data = {
168
+ tpc: topic,
169
+ exn: exn.sad,
170
+ sigs: sigs,
171
+ atc: atc,
172
+ rec: recipients,
173
+ };
174
+ const res = await this.client.fetch(path, method, data);
175
+ return await res.json();
176
+ }
177
+ /**
178
+ * Get exn message by said
179
+ * @async
180
+ * @returns A promise to the exn message
181
+ * @param said The said of the exn message
182
+ */
183
+ async get(said) {
184
+ const path = `/exchanges/${said}`;
185
+ const method = 'GET';
186
+ const res = await this.client.fetch(path, method, null);
187
+ return await res.json();
188
+ }
189
+ }
190
+ export function exchange(route, payload, sender, recipient, date, dig, modifiers, embeds) {
191
+ const vs = versify(Protocols.KERI, undefined, Serials.JSON, 0);
192
+ const ilk = Ilks.exn;
193
+ const dt = date !== undefined
194
+ ? date
195
+ : nowUTC().toISOString().replace('Z', '000+00:00');
196
+ const p = dig !== undefined ? dig : '';
197
+ const q = modifiers !== undefined ? modifiers : {};
198
+ const ems = embeds != undefined ? embeds : {};
199
+ let e = {};
200
+ let end = '';
201
+ Object.entries(ems).forEach(([key, value]) => {
202
+ const serder = value[0];
203
+ const atc = value[1];
204
+ e[key] = serder.sad;
205
+ if (atc == undefined) {
206
+ return;
207
+ }
208
+ let pathed = '';
209
+ const pather = new Pather({}, undefined, ['e', key]);
210
+ pathed += pather.qb64;
211
+ pathed += atc;
212
+ const counter = new Counter({
213
+ code: CtrDex.PathedMaterialQuadlets,
214
+ count: Math.floor(pathed.length / 4),
215
+ });
216
+ end += counter.qb64;
217
+ end += pathed;
218
+ });
219
+ if (Object.keys(e).length > 0) {
220
+ e['d'] = '';
221
+ [, e] = Saider.saidify(e);
222
+ }
223
+ const attrs = {};
224
+ attrs['i'] = recipient;
225
+ const a = Object.assign(Object.assign({}, attrs), payload);
226
+ const _sad = {
227
+ v: vs,
228
+ t: ilk,
229
+ d: '',
230
+ i: sender,
231
+ rp: recipient,
232
+ p: p,
233
+ dt: dt,
234
+ r: route,
235
+ q: q,
236
+ a: a,
237
+ e: e,
238
+ };
239
+ const [, sad] = Saider.saidify(_sad);
240
+ const exn = new Serder(sad);
241
+ return [exn, b(end)];
242
+ }
@@ -1,5 +1,7 @@
1
- import { SignifyClient } from './clienting';
2
- import { Dict } from '../core/core';
1
+ import { SignifyClient } from './clienting.ts';
2
+ import { GroupOperation } from '../core/keyState.ts';
3
+ import { ExnMultisig } from './exchanging.ts';
4
+ import { Exn } from './exchanging.ts';
3
5
  /**
4
6
  * Groups
5
7
  */
@@ -14,19 +16,19 @@ export declare class Groups {
14
16
  * Get group request messages
15
17
  * @async
16
18
  * @param {string} [said] SAID of exn message to load
17
- * @returns {Promise<any>} A promise to the list of replay messages
19
+ * @returns {Promise<ExnMultisig[]>} A promise to the list of replay messages
18
20
  */
19
- getRequest(said: string): Promise<any>;
21
+ getRequest(said: string): Promise<ExnMultisig[]>;
20
22
  /**
21
23
  * Send multisig exn request messages to other group members
22
24
  * @async
23
25
  * @param {string} [name] human readable name of group AID
24
- * @param {Dict<any>} [exn] exn message to send to other members
26
+ * @param {Exn} [exn] exn message to send to other members
25
27
  * @param {string[]} [sigs] signature of the participant over the exn
26
28
  * @param {string} [atc] additional attachments from embedded events in exn
27
- * @returns {Promise<any>} A promise to the list of replay messages
29
+ * @returns {Promise<Exn>} A promise to the list of replay messages
28
30
  */
29
- sendRequest(name: string, exn: Dict<any>, sigs: string[], atc: string): Promise<any>;
31
+ sendRequest(name: string, exn: Exn, sigs: string[], atc: string): Promise<Exn>;
30
32
  /**
31
33
  * Join multisig group using rotation event.
32
34
  * This can be used by participants being asked to contribute keys to a rotation event to join an existing group.
@@ -37,8 +39,8 @@ export declare class Groups {
37
39
  * @param {string} [gid] prefix
38
40
  * @param {string[]} [smids] array of particpants
39
41
  * @param {string[]} [rmids] array of particpants
40
- * @returns {Promise<any>} A promise to the list of replay messages
42
+ * @returns {Promise<GroupOperation>} A promise to the list of replay messages
41
43
  */
42
44
  join(name: string, rot: any, sigs: any, //string[],
43
- gid: string, smids: string[], rmids: string[]): Promise<any>;
45
+ gid: string, smids: string[], rmids: string[]): Promise<GroupOperation>;
44
46
  }
@@ -1,48 +1,36 @@
1
- import { SignifyClient } from './clienting';
2
- import { Dict } from '../core/core';
3
-
4
1
  /**
5
2
  * Groups
6
3
  */
7
4
  export class Groups {
8
- client: SignifyClient;
9
-
10
5
  /**
11
6
  * Groups
12
7
  * @param {SignifyClient} client
13
8
  */
14
- constructor(client: SignifyClient) {
9
+ constructor(client) {
15
10
  this.client = client;
16
11
  }
17
-
18
12
  /**
19
13
  * Get group request messages
20
14
  * @async
21
15
  * @param {string} [said] SAID of exn message to load
22
- * @returns {Promise<any>} A promise to the list of replay messages
16
+ * @returns {Promise<ExnMultisig[]>} A promise to the list of replay messages
23
17
  */
24
- async getRequest(said: string): Promise<any> {
18
+ async getRequest(said) {
25
19
  const path = `/multisig/request/` + said;
26
20
  const method = 'GET';
27
21
  const res = await this.client.fetch(path, method, null);
28
22
  return await res.json();
29
23
  }
30
-
31
24
  /**
32
25
  * Send multisig exn request messages to other group members
33
26
  * @async
34
27
  * @param {string} [name] human readable name of group AID
35
- * @param {Dict<any>} [exn] exn message to send to other members
28
+ * @param {Exn} [exn] exn message to send to other members
36
29
  * @param {string[]} [sigs] signature of the participant over the exn
37
30
  * @param {string} [atc] additional attachments from embedded events in exn
38
- * @returns {Promise<any>} A promise to the list of replay messages
31
+ * @returns {Promise<Exn>} A promise to the list of replay messages
39
32
  */
40
- async sendRequest(
41
- name: string,
42
- exn: Dict<any>,
43
- sigs: string[],
44
- atc: string
45
- ): Promise<any> {
33
+ async sendRequest(name, exn, sigs, atc) {
46
34
  const path = `/identifiers/${name}/multisig/request`;
47
35
  const method = 'POST';
48
36
  const data = {
@@ -53,7 +41,6 @@ export class Groups {
53
41
  const res = await this.client.fetch(path, method, data);
54
42
  return await res.json();
55
43
  }
56
-
57
44
  /**
58
45
  * Join multisig group using rotation event.
59
46
  * This can be used by participants being asked to contribute keys to a rotation event to join an existing group.
@@ -64,21 +51,15 @@ export class Groups {
64
51
  * @param {string} [gid] prefix
65
52
  * @param {string[]} [smids] array of particpants
66
53
  * @param {string[]} [rmids] array of particpants
67
- * @returns {Promise<any>} A promise to the list of replay messages
54
+ * @returns {Promise<GroupOperation>} A promise to the list of replay messages
68
55
  */
69
- async join(
70
- name: string,
71
- rot: any,
72
- sigs: any, //string[],
73
- gid: string,
74
- smids: string[],
75
- rmids: string[]
76
- ): Promise<any> {
56
+ async join(name, rot, sigs, //string[],
57
+ gid, smids, rmids) {
77
58
  const path = `/identifiers/${name}/multisig/join`;
78
59
  const method = 'POST';
79
60
  const data = {
80
61
  tpc: 'multisig',
81
- rot: rot.ked,
62
+ rot: rot.sad,
82
63
  sigs: sigs,
83
64
  gid: gid,
84
65
  smids: smids,
@@ -1,5 +1,5 @@
1
- import { Manager } from '../core/manager';
2
- import { Serder } from '../core/serder';
1
+ import { Manager } from '../core/manager.ts';
2
+ import { Serder } from '../core/serder.ts';
3
3
  export declare class TraitCodex {
4
4
  EstOnly: string;
5
5
  DoNotDelegate: string;