@keetanetwork/anchor 0.0.78 → 0.0.80
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/lib/anchor-external.d.ts +94 -1
- package/lib/anchor-external.d.ts.map +1 -1
- package/lib/anchor-external.generated.js +52 -3
- package/lib/anchor-external.generated.js.map +1 -1
- package/lib/anchor-external.js +126 -3
- package/lib/anchor-external.js.map +1 -1
- package/lib/anchor-metadata-server.d.ts +15 -2
- package/lib/anchor-metadata-server.d.ts.map +1 -1
- package/lib/anchor-metadata-server.js +54 -0
- package/lib/anchor-metadata-server.js.map +1 -1
- package/lib/anchor-status.d.ts +149 -0
- package/lib/anchor-status.d.ts.map +1 -0
- package/lib/anchor-status.js +93 -0
- package/lib/anchor-status.js.map +1 -0
- package/lib/chaining.d.ts +2 -1
- package/lib/chaining.d.ts.map +1 -1
- package/lib/chaining.js +67 -8
- package/lib/chaining.js.map +1 -1
- package/lib/history.d.ts +405 -0
- package/lib/history.d.ts.map +1 -0
- package/lib/history.js +723 -0
- package/lib/history.js.map +1 -0
- package/lib/http-server/index.d.ts +1 -0
- package/lib/http-server/index.d.ts.map +1 -1
- package/lib/http-server/index.js +1 -0
- package/lib/http-server/index.js.map +1 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/metadata.types.d.ts +3 -0
- package/lib/metadata.types.d.ts.map +1 -1
- package/lib/metadata.types.js.map +1 -1
- package/lib/resolver.d.ts +28 -7
- package/lib/resolver.d.ts.map +1 -1
- package/lib/resolver.generated.js +528 -453
- package/lib/resolver.generated.js.map +1 -1
- package/lib/resolver.js +67 -8
- package/lib/resolver.js.map +1 -1
- package/lib/utils/brand.d.ts +5 -0
- package/lib/utils/brand.d.ts.map +1 -1
- package/lib/utils/brand.js +4 -1
- package/lib/utils/brand.js.map +1 -1
- package/npm-shrinkwrap.json +10 -17
- package/package.json +2 -2
- package/services/asset-movement/client.d.ts +7 -1
- package/services/asset-movement/client.d.ts.map +1 -1
- package/services/asset-movement/client.js +70 -15
- package/services/asset-movement/client.js.map +1 -1
- package/services/asset-movement/common.d.ts +1 -1
- package/services/asset-movement/common.d.ts.map +1 -1
- package/services/asset-movement/common.generated.js +11 -409
- package/services/asset-movement/common.generated.js.map +1 -1
- package/services/asset-movement/common.js.map +1 -1
- package/services/asset-movement/common.server.generated.js +1153 -15478
- package/services/asset-movement/common.server.generated.js.map +1 -1
- package/services/asset-movement/lib/location.d.ts.map +1 -1
- package/services/asset-movement/lib/location.js +1 -0
- package/services/asset-movement/lib/location.js.map +1 -1
- package/services/asset-movement/server.d.ts +1 -1
- package/services/asset-movement/server.d.ts.map +1 -1
- package/services/asset-movement/server.js +1 -1
- package/services/asset-movement/server.js.map +1 -1
- package/services/asset-movement/status-source.d.ts +32 -0
- package/services/asset-movement/status-source.d.ts.map +1 -0
- package/services/asset-movement/status-source.js +77 -0
- package/services/asset-movement/status-source.js.map +1 -0
- package/services/fx/server.d.ts +2 -2
- package/services/fx/server.d.ts.map +1 -1
- package/services/fx/server.js +2 -1
- package/services/fx/server.js.map +1 -1
- package/services/kyc/server.d.ts +1 -1
- package/services/kyc/server.d.ts.map +1 -1
- package/services/kyc/server.js +1 -1
- package/services/kyc/server.js.map +1 -1
- package/services/notification/client.js +50 -6
- package/services/notification/client.js.map +1 -1
- package/services/notification/server.d.ts.map +1 -1
- package/services/notification/server.js +4 -1
- package/services/notification/server.js.map +1 -1
- package/services/storage/client.js +50 -6
- package/services/storage/client.js.map +1 -1
- package/services/storage/clients/contacts.d.ts +5 -0
- package/services/storage/clients/contacts.d.ts.map +1 -1
- package/services/storage/clients/contacts.js +20 -9
- package/services/storage/clients/contacts.js.map +1 -1
- package/services/storage/server.d.ts +1 -1
- package/services/storage/server.d.ts.map +1 -1
- package/services/storage/server.js +2 -2
- package/services/storage/server.js.map +1 -1
- package/services/username/client.js +50 -6
- package/services/username/client.js.map +1 -1
- package/services/username/server.d.ts.map +1 -1
- package/services/username/server.js +4 -1
- package/services/username/server.js.map +1 -1
package/lib/anchor-external.d.ts
CHANGED
|
@@ -40,9 +40,35 @@ export type AnchorExternalBinding = {
|
|
|
40
40
|
previousBlockHash: string;
|
|
41
41
|
/**
|
|
42
42
|
* Index of the SEND operation within its block.
|
|
43
|
+
*
|
|
44
|
+
* Valid range: `0` to `2^32 - 1` inclusive.
|
|
43
45
|
*/
|
|
44
46
|
operationIndex: number;
|
|
45
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Reference to a prior on-chain operation that is relevant to the
|
|
50
|
+
* transfer this envelope describes.
|
|
51
|
+
*
|
|
52
|
+
* Inputs are backward links: an envelope can only reference operations
|
|
53
|
+
* whose block hashes are already known when the carrying SEND is
|
|
54
|
+
* constructed.
|
|
55
|
+
*
|
|
56
|
+
* When the envelope is signed, inputs are part of the signed plaintext
|
|
57
|
+
* and the signer cannot later repudiate the claimed relevance.
|
|
58
|
+
*/
|
|
59
|
+
export type AnchorExternalInput = {
|
|
60
|
+
/**
|
|
61
|
+
* Hash of the block carrying the referenced operation.
|
|
62
|
+
*/
|
|
63
|
+
blockHash: string;
|
|
64
|
+
/**
|
|
65
|
+
* Index of the referenced operation within its block. Omit to
|
|
66
|
+
* reference the block as a whole.
|
|
67
|
+
*
|
|
68
|
+
* Valid range: `0` to `2^32 - 1` inclusive.
|
|
69
|
+
*/
|
|
70
|
+
operationIndex?: number;
|
|
71
|
+
};
|
|
46
72
|
/**
|
|
47
73
|
* Decoded anchor-external envelope as exposed to callers.
|
|
48
74
|
*/
|
|
@@ -61,6 +87,11 @@ export type AnchorExternalEnvelope = {
|
|
|
61
87
|
* Signature binding. Present if the envelope is signed.
|
|
62
88
|
*/
|
|
63
89
|
binding?: AnchorExternalBinding;
|
|
90
|
+
/**
|
|
91
|
+
* References to prior on-chain operations relevant to this transfer,
|
|
92
|
+
* in the order they were added. Present only when non-empty.
|
|
93
|
+
*/
|
|
94
|
+
inputs?: AnchorExternalInput[];
|
|
64
95
|
};
|
|
65
96
|
/**
|
|
66
97
|
* Authenticity record attached to a verified signed envelope. Present only
|
|
@@ -100,10 +131,19 @@ export type EncodedAnchorExternalBindingV1 = {
|
|
|
100
131
|
p: string;
|
|
101
132
|
o: number;
|
|
102
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Input reference as it appears in the encoded envelope.
|
|
136
|
+
*
|
|
137
|
+
* `h` = block hash, `o` = operation index.
|
|
138
|
+
*/
|
|
139
|
+
export type EncodedAnchorExternalInputV1 = {
|
|
140
|
+
h: string;
|
|
141
|
+
o?: number;
|
|
142
|
+
};
|
|
103
143
|
/**
|
|
104
144
|
* Anchor-external envelope as it appears inside the encoded blob.
|
|
105
145
|
*
|
|
106
|
-
* `v` = envelope version, `a` = anchors, `b` = binding.
|
|
146
|
+
* `v` = envelope version, `a` = anchors, `b` = binding, `i` = inputs.
|
|
107
147
|
*/
|
|
108
148
|
export type EncodedAnchorExternalEnvelopeV1 = {
|
|
109
149
|
v: typeof ANCHOR_EXTERNAL_VERSION;
|
|
@@ -111,6 +151,7 @@ export type EncodedAnchorExternalEnvelopeV1 = {
|
|
|
111
151
|
[anchorPublicKey: string]: EncodedAnchorExternalEntryV1;
|
|
112
152
|
};
|
|
113
153
|
b?: EncodedAnchorExternalBindingV1;
|
|
154
|
+
i?: EncodedAnchorExternalInputV1[];
|
|
114
155
|
};
|
|
115
156
|
/**
|
|
116
157
|
* Error codes for anchor-external envelope operations.
|
|
@@ -147,6 +188,15 @@ export declare class AnchorExternalBuilder {
|
|
|
147
188
|
* for the same anchor.
|
|
148
189
|
*/
|
|
149
190
|
setAnchor(anchor: Account, entry: AnchorExternalEntry): this;
|
|
191
|
+
/**
|
|
192
|
+
* Append a reference to a prior on-chain operation relevant to this
|
|
193
|
+
* transfer. Order of addition is preserved in the envelope.
|
|
194
|
+
*
|
|
195
|
+
* @param blockHash Hash of the block carrying the referenced operation.
|
|
196
|
+
* @param operationIndex Index of the operation within its block. Omit to
|
|
197
|
+
* reference the block as a whole.
|
|
198
|
+
*/
|
|
199
|
+
addInput(blockHash: string, operationIndex?: number): this;
|
|
150
200
|
/**
|
|
151
201
|
* Sign the produced envelope with the given account.
|
|
152
202
|
*/
|
|
@@ -180,6 +230,38 @@ export declare class AnchorExternalBuilder {
|
|
|
180
230
|
*/
|
|
181
231
|
build(): Promise<string>;
|
|
182
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Inputs to {@link buildSignedAnchorExternal}.
|
|
235
|
+
*/
|
|
236
|
+
export type AnchorPayoutExternalOptions = {
|
|
237
|
+
/**
|
|
238
|
+
* Anchor signing account; also the envelope's anchor entry key.
|
|
239
|
+
*/
|
|
240
|
+
anchor: Account;
|
|
241
|
+
/**
|
|
242
|
+
* Service-scoped transfer/transaction id to correlate.
|
|
243
|
+
*/
|
|
244
|
+
transactionID: string;
|
|
245
|
+
/**
|
|
246
|
+
* On-chain operations feeding this payout in relevance order.
|
|
247
|
+
*/
|
|
248
|
+
inputs?: AnchorExternalInput[];
|
|
249
|
+
/**
|
|
250
|
+
* Binding coordinates of the block about to be published.
|
|
251
|
+
*/
|
|
252
|
+
binding: AnchorExternalBinding;
|
|
253
|
+
/**
|
|
254
|
+
* Encrypt the envelope to these recipients.
|
|
255
|
+
*/
|
|
256
|
+
encryptTo?: Account[];
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Build the signed, encoded SEND.external string an anchor attaches to a
|
|
260
|
+
* payout (anchor-to-user) SEND.
|
|
261
|
+
*
|
|
262
|
+
* @throws {@link KeetaAnchorError} on caller misuse (invalid binding or inputs).
|
|
263
|
+
*/
|
|
264
|
+
export declare function buildSignedAnchorExternal(options: AnchorPayoutExternalOptions): Promise<string>;
|
|
183
265
|
/**
|
|
184
266
|
* Immutable, verified view of a parsed SEND.external envelope.
|
|
185
267
|
*/
|
|
@@ -214,6 +296,17 @@ export declare class AnchorExternal {
|
|
|
214
296
|
* @throws {@link KeetaAnchorError} if `principals` is empty.
|
|
215
297
|
*/
|
|
216
298
|
static fromEncryptedExternal(external: string, principals: Account[]): Promise<AnchorExternal>;
|
|
299
|
+
/**
|
|
300
|
+
* Decode an external string, dispatching on whether the blob is encrypted.
|
|
301
|
+
*
|
|
302
|
+
* Encrypted blobs are decrypted with the supplied decryption keys.
|
|
303
|
+
* Plaintext blobs ignore them.
|
|
304
|
+
*
|
|
305
|
+
* @throws {@link AnchorExternalError} on decode failure.
|
|
306
|
+
*/
|
|
307
|
+
static fromExternal(external: string, options?: {
|
|
308
|
+
decryptionKeys?: Account[];
|
|
309
|
+
}): Promise<AnchorExternal>;
|
|
217
310
|
/**
|
|
218
311
|
* Inspect encrypted/signed flags of a candidate external string
|
|
219
312
|
* without reading plaintext or requiring a decryption key.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-external.d.ts","sourceRoot":"","sources":["../../src/lib/anchor-external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAIxE,OAAO,EAAoB,oBAAoB,EAAkC,MAAM,YAAY,CAAC;AAIpG,KAAK,OAAO,GAAG,YAAY,CAAC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAUxD;;GAEG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"anchor-external.d.ts","sourceRoot":"","sources":["../../src/lib/anchor-external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAIxE,OAAO,EAAoB,oBAAoB,EAAkC,MAAM,YAAY,CAAC;AAIpG,KAAK,OAAO,GAAG,YAAY,CAAC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAUxD;;GAEG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAUzC;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC5B;IACD;;OAEG;IAC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AG,SAAS,CAE7C;IAED;;;;OAIG;WACU,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAwBzE;;;;;;OAMG;WACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IA6BpG;;;;;;;OAOG;WACU,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAW9G;;;OAGG;WACU,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAmBtE;;OAEG;mBACkB,aAAa;IAOlC;;OAEG;mBACkB,YAAY;IAyCjC;;OAEG;mBACkB,UAAU;CAuC/B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
|
|
2
2
|
import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
|
|
3
3
|
import { createAssertEquals } from 'typia';
|
|
4
|
-
export const assertEncodedAnchorExternalEnvelopeV1 = (() => { const _io0 = (input, _exceptionable = true) => 1 === input.v && ("object" === typeof input.a && null !== input.a && false === Array.isArray(input.a) && _io1(input.a, true && _exceptionable)) && (undefined === input.b || "object" === typeof input.b && null !== input.b && _io5(input.b, true && _exceptionable)) && (2 === Object.keys(input).length || Object.keys(input).every(key => {
|
|
5
|
-
if (["v", "a", "b"].some(prop => key === prop))
|
|
4
|
+
export const assertEncodedAnchorExternalEnvelopeV1 = (() => { const _io0 = (input, _exceptionable = true) => 1 === input.v && ("object" === typeof input.a && null !== input.a && false === Array.isArray(input.a) && _io1(input.a, true && _exceptionable)) && (undefined === input.b || "object" === typeof input.b && null !== input.b && _io5(input.b, true && _exceptionable)) && (undefined === input.i || Array.isArray(input.i) && input.i.every((elem, _index1) => "object" === typeof elem && null !== elem && _io6(elem, true && _exceptionable))) && (2 === Object.keys(input).length || Object.keys(input).every(key => {
|
|
5
|
+
if (["v", "a", "b", "i"].some(prop => key === prop))
|
|
6
6
|
return true;
|
|
7
7
|
const value = input[key];
|
|
8
8
|
if (undefined === value)
|
|
@@ -41,6 +41,13 @@ export const assertEncodedAnchorExternalEnvelopeV1 = (() => { const _io0 = (inpu
|
|
|
41
41
|
if (undefined === value)
|
|
42
42
|
return true;
|
|
43
43
|
return false;
|
|
44
|
+
})); const _io6 = (input, _exceptionable = true) => "string" === typeof input.h && (undefined === input.o || "number" === typeof input.o) && (1 === Object.keys(input).length || Object.keys(input).every(key => {
|
|
45
|
+
if (["h", "o"].some(prop => key === prop))
|
|
46
|
+
return true;
|
|
47
|
+
const value = input[key];
|
|
48
|
+
if (undefined === value)
|
|
49
|
+
return true;
|
|
50
|
+
return false;
|
|
44
51
|
})); const _iu0 = (input, _exceptionable = true) => (() => {
|
|
45
52
|
if (undefined !== input.t)
|
|
46
53
|
return _io2(input, true && _exceptionable);
|
|
@@ -75,8 +82,28 @@ export const assertEncodedAnchorExternalEnvelopeV1 = (() => { const _io0 = (inpu
|
|
|
75
82
|
path: _path + ".b",
|
|
76
83
|
expected: "(EncodedAnchorExternalBindingV1 | undefined)",
|
|
77
84
|
value: input.b
|
|
85
|
+
}, _errorFactory)) && (undefined === input.i || (Array.isArray(input.i) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
86
|
+
method: "createAssertEquals",
|
|
87
|
+
path: _path + ".i",
|
|
88
|
+
expected: "(Array<EncodedAnchorExternalInputV1> | undefined)",
|
|
89
|
+
value: input.i
|
|
90
|
+
}, _errorFactory)) && input.i.every((elem, _index2) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
91
|
+
method: "createAssertEquals",
|
|
92
|
+
path: _path + ".i[" + _index2 + "]",
|
|
93
|
+
expected: "EncodedAnchorExternalInputV1",
|
|
94
|
+
value: elem
|
|
95
|
+
}, _errorFactory)) && _ao6(elem, _path + ".i[" + _index2 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
96
|
+
method: "createAssertEquals",
|
|
97
|
+
path: _path + ".i[" + _index2 + "]",
|
|
98
|
+
expected: "EncodedAnchorExternalInputV1",
|
|
99
|
+
value: elem
|
|
100
|
+
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
101
|
+
method: "createAssertEquals",
|
|
102
|
+
path: _path + ".i",
|
|
103
|
+
expected: "(Array<EncodedAnchorExternalInputV1> | undefined)",
|
|
104
|
+
value: input.i
|
|
78
105
|
}, _errorFactory)) && (2 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
|
|
79
|
-
if (["v", "a", "b"].some(prop => key === prop))
|
|
106
|
+
if (["v", "a", "b", "i"].some(prop => key === prop))
|
|
80
107
|
return true;
|
|
81
108
|
const value = input[key];
|
|
82
109
|
if (undefined === value)
|
|
@@ -175,6 +202,28 @@ export const assertEncodedAnchorExternalEnvelopeV1 = (() => { const _io0 = (inpu
|
|
|
175
202
|
expected: "undefined",
|
|
176
203
|
value: value
|
|
177
204
|
}, _errorFactory);
|
|
205
|
+
}))); const _ao6 = (input, _path, _exceptionable = true) => ("string" === typeof input.h || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
206
|
+
method: "createAssertEquals",
|
|
207
|
+
path: _path + ".h",
|
|
208
|
+
expected: "string",
|
|
209
|
+
value: input.h
|
|
210
|
+
}, _errorFactory)) && (undefined === input.o || "number" === typeof input.o || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
211
|
+
method: "createAssertEquals",
|
|
212
|
+
path: _path + ".o",
|
|
213
|
+
expected: "(number | undefined)",
|
|
214
|
+
value: input.o
|
|
215
|
+
}, _errorFactory)) && (1 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
|
|
216
|
+
if (["h", "o"].some(prop => key === prop))
|
|
217
|
+
return true;
|
|
218
|
+
const value = input[key];
|
|
219
|
+
if (undefined === value)
|
|
220
|
+
return true;
|
|
221
|
+
return __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
222
|
+
method: "createAssertEquals",
|
|
223
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
224
|
+
expected: "undefined",
|
|
225
|
+
value: value
|
|
226
|
+
}, _errorFactory);
|
|
178
227
|
}))); const _au0 = (input, _path, _exceptionable = true) => (() => {
|
|
179
228
|
if (undefined !== input.t)
|
|
180
229
|
return _ao2(input, _path, true && _exceptionable);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-external.generated.js","sourceRoot":"","sources":["../../src/lib/anchor-external.generated.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAG3C,MAAM,CAAC,MAAM,qCAAqC
|
|
1
|
+
{"version":3,"file":"anchor-external.generated.js","sourceRoot":"","sources":["../../src/lib/anchor-external.generated.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAG3C,MAAM,CAAC,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAA6G,CAAC","sourcesContent":["import { createAssertEquals } from 'typia';\nimport type { EncodedAnchorExternalEnvelopeV1 } from './anchor-external.js';\n\nexport const assertEncodedAnchorExternalEnvelopeV1: (input: unknown) => EncodedAnchorExternalEnvelopeV1 = createAssertEquals<EncodedAnchorExternalEnvelopeV1>();\n"]}
|
package/lib/anchor-external.js
CHANGED
|
@@ -14,6 +14,11 @@ const MAX_PLAINTEXT_BYTES = 4096;
|
|
|
14
14
|
* Current envelope format version.
|
|
15
15
|
*/
|
|
16
16
|
export const ANCHOR_EXTERNAL_VERSION = 1;
|
|
17
|
+
/**
|
|
18
|
+
* Largest valid operation index, matching the 32-bit bound used for
|
|
19
|
+
* operation indexes elsewhere in the protocol.
|
|
20
|
+
*/
|
|
21
|
+
const MAX_OPERATION_INDEX = 2 ** 32 - 1;
|
|
17
22
|
// #endregion
|
|
18
23
|
// #region Error Handling
|
|
19
24
|
/**
|
|
@@ -117,6 +122,26 @@ function entryFromEncoded(entry) {
|
|
|
117
122
|
}
|
|
118
123
|
return ({ destination: entry.d });
|
|
119
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Convert a public input reference to an encoded input reference.
|
|
127
|
+
*/
|
|
128
|
+
function inputToEncoded(input) {
|
|
129
|
+
const result = { h: input.blockHash };
|
|
130
|
+
if (input.operationIndex !== undefined) {
|
|
131
|
+
result.o = input.operationIndex;
|
|
132
|
+
}
|
|
133
|
+
return (result);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert an encoded input reference to a public input reference.
|
|
137
|
+
*/
|
|
138
|
+
function inputFromEncoded(input) {
|
|
139
|
+
const result = { blockHash: input.h };
|
|
140
|
+
if (input.o !== undefined) {
|
|
141
|
+
result.operationIndex = input.o;
|
|
142
|
+
}
|
|
143
|
+
return (result);
|
|
144
|
+
}
|
|
120
145
|
/**
|
|
121
146
|
* Convert a public envelope to an encoded envelope.
|
|
122
147
|
*/
|
|
@@ -132,6 +157,9 @@ function envelopeToEncoded(envelope) {
|
|
|
132
157
|
if (envelope.binding !== undefined) {
|
|
133
158
|
result.b = { p: envelope.binding.previousBlockHash, o: envelope.binding.operationIndex };
|
|
134
159
|
}
|
|
160
|
+
if (envelope.inputs !== undefined) {
|
|
161
|
+
result.i = envelope.inputs.map(inputToEncoded);
|
|
162
|
+
}
|
|
135
163
|
return (result);
|
|
136
164
|
}
|
|
137
165
|
/**
|
|
@@ -149,6 +177,9 @@ function envelopeFromEncoded(encoded) {
|
|
|
149
177
|
if (encoded.b !== undefined) {
|
|
150
178
|
result.binding = { previousBlockHash: encoded.b.p, operationIndex: encoded.b.o };
|
|
151
179
|
}
|
|
180
|
+
if (encoded.i !== undefined) {
|
|
181
|
+
result.inputs = encoded.i.map(inputFromEncoded);
|
|
182
|
+
}
|
|
152
183
|
return (result);
|
|
153
184
|
}
|
|
154
185
|
/**
|
|
@@ -175,6 +206,24 @@ function signerListed(envelope, signer) {
|
|
|
175
206
|
const signerKey = signer.publicKeyString.get();
|
|
176
207
|
return (signerKey in envelope.anchors);
|
|
177
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Validate an operation index against its valid range of `0` to
|
|
211
|
+
* `2^32 - 1` inclusive.
|
|
212
|
+
*
|
|
213
|
+
* @returns `undefined` if valid, or an error message.
|
|
214
|
+
*/
|
|
215
|
+
function validateOperationIndex(label, value) {
|
|
216
|
+
if (!Number.isSafeInteger(value)) {
|
|
217
|
+
return (`${label} must be an integer, got ${value}`);
|
|
218
|
+
}
|
|
219
|
+
if (value < 0) {
|
|
220
|
+
return (`${label} must not be negative, got ${value}`);
|
|
221
|
+
}
|
|
222
|
+
if (value > MAX_OPERATION_INDEX) {
|
|
223
|
+
return (`${label} must not exceed ${MAX_OPERATION_INDEX}, got ${value}`);
|
|
224
|
+
}
|
|
225
|
+
return (undefined);
|
|
226
|
+
}
|
|
178
227
|
/**
|
|
179
228
|
* Validate the shape of a {@link AnchorExternalBinding}.
|
|
180
229
|
*
|
|
@@ -184,10 +233,21 @@ function validateBindingShape(binding) {
|
|
|
184
233
|
if (typeof binding.previousBlockHash !== 'string' || binding.previousBlockHash.length === 0) {
|
|
185
234
|
return ('binding.previousBlockHash must be a non-empty string');
|
|
186
235
|
}
|
|
187
|
-
|
|
188
|
-
|
|
236
|
+
return (validateOperationIndex('binding.operationIndex', binding.operationIndex));
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validate the shape of an {@link AnchorExternalInput}.
|
|
240
|
+
*
|
|
241
|
+
* @returns `undefined` if valid, or an error message.
|
|
242
|
+
*/
|
|
243
|
+
function validateInputShape(input) {
|
|
244
|
+
if (typeof input.blockHash !== 'string' || input.blockHash.length === 0) {
|
|
245
|
+
return ('input.blockHash must be a non-empty string');
|
|
246
|
+
}
|
|
247
|
+
if (input.operationIndex === undefined) {
|
|
248
|
+
return (undefined);
|
|
189
249
|
}
|
|
190
|
-
return (
|
|
250
|
+
return (validateOperationIndex('input.operationIndex', input.operationIndex));
|
|
191
251
|
}
|
|
192
252
|
/**
|
|
193
253
|
* Decode the base64-encoded string.
|
|
@@ -207,6 +267,7 @@ function decodeExternal(external) {
|
|
|
207
267
|
*/
|
|
208
268
|
export class AnchorExternalBuilder {
|
|
209
269
|
#anchors = {};
|
|
270
|
+
#inputs = [];
|
|
210
271
|
#signer;
|
|
211
272
|
#principals;
|
|
212
273
|
#maxLength;
|
|
@@ -219,6 +280,26 @@ export class AnchorExternalBuilder {
|
|
|
219
280
|
this.#anchors[anchor.publicKeyString.get()] = entry;
|
|
220
281
|
return (this);
|
|
221
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Append a reference to a prior on-chain operation relevant to this
|
|
285
|
+
* transfer. Order of addition is preserved in the envelope.
|
|
286
|
+
*
|
|
287
|
+
* @param blockHash Hash of the block carrying the referenced operation.
|
|
288
|
+
* @param operationIndex Index of the operation within its block. Omit to
|
|
289
|
+
* reference the block as a whole.
|
|
290
|
+
*/
|
|
291
|
+
addInput(blockHash, operationIndex) {
|
|
292
|
+
const candidate = { blockHash };
|
|
293
|
+
if (operationIndex !== undefined) {
|
|
294
|
+
candidate.operationIndex = operationIndex;
|
|
295
|
+
}
|
|
296
|
+
const error = validateInputShape(candidate);
|
|
297
|
+
if (error !== undefined) {
|
|
298
|
+
throw (new KeetaAnchorError(`addInput: ${error}`));
|
|
299
|
+
}
|
|
300
|
+
this.#inputs.push(candidate);
|
|
301
|
+
return (this);
|
|
302
|
+
}
|
|
222
303
|
/**
|
|
223
304
|
* Sign the produced envelope with the given account.
|
|
224
305
|
*/
|
|
@@ -272,6 +353,11 @@ export class AnchorExternalBuilder {
|
|
|
272
353
|
if (this.#binding !== undefined) {
|
|
273
354
|
result.binding = { ...this.#binding };
|
|
274
355
|
}
|
|
356
|
+
if (this.#inputs.length > 0) {
|
|
357
|
+
result.inputs = this.#inputs.map(function (input) {
|
|
358
|
+
return ({ ...input });
|
|
359
|
+
});
|
|
360
|
+
}
|
|
275
361
|
return (result);
|
|
276
362
|
}
|
|
277
363
|
/**
|
|
@@ -307,6 +393,26 @@ export class AnchorExternalBuilder {
|
|
|
307
393
|
return (external);
|
|
308
394
|
}
|
|
309
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* Build the signed, encoded SEND.external string an anchor attaches to a
|
|
398
|
+
* payout (anchor-to-user) SEND.
|
|
399
|
+
*
|
|
400
|
+
* @throws {@link KeetaAnchorError} on caller misuse (invalid binding or inputs).
|
|
401
|
+
*/
|
|
402
|
+
export async function buildSignedAnchorExternal(options) {
|
|
403
|
+
const builder = new AnchorExternalBuilder();
|
|
404
|
+
builder.setAnchor(options.anchor, { transactionId: options.transactionID });
|
|
405
|
+
builder.withSigner(options.anchor);
|
|
406
|
+
builder.withBinding(options.binding.previousBlockHash, options.binding.operationIndex);
|
|
407
|
+
for (const input of options.inputs ?? []) {
|
|
408
|
+
builder.addInput(input.blockHash, input.operationIndex);
|
|
409
|
+
}
|
|
410
|
+
if (options.encryptTo !== undefined) {
|
|
411
|
+
builder.withPrincipals(options.encryptTo);
|
|
412
|
+
}
|
|
413
|
+
const external = await builder.build();
|
|
414
|
+
return (external);
|
|
415
|
+
}
|
|
310
416
|
// #endregion
|
|
311
417
|
// #region AnchorExternal
|
|
312
418
|
/**
|
|
@@ -398,6 +504,23 @@ export class AnchorExternal {
|
|
|
398
504
|
const result = await AnchorExternal.fromContainer(container, true);
|
|
399
505
|
return (result);
|
|
400
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Decode an external string, dispatching on whether the blob is encrypted.
|
|
509
|
+
*
|
|
510
|
+
* Encrypted blobs are decrypted with the supplied decryption keys.
|
|
511
|
+
* Plaintext blobs ignore them.
|
|
512
|
+
*
|
|
513
|
+
* @throws {@link AnchorExternalError} on decode failure.
|
|
514
|
+
*/
|
|
515
|
+
static async fromExternal(external, options) {
|
|
516
|
+
const peeked = await AnchorExternal.peek(external);
|
|
517
|
+
if (peeked.encrypted) {
|
|
518
|
+
const encryptedResult = await AnchorExternal.fromEncryptedExternal(external, options?.decryptionKeys ?? []);
|
|
519
|
+
return (encryptedResult);
|
|
520
|
+
}
|
|
521
|
+
const plainResult = await AnchorExternal.fromPlainExternal(external);
|
|
522
|
+
return (plainResult);
|
|
523
|
+
}
|
|
401
524
|
/**
|
|
402
525
|
* Inspect encrypted/signed flags of a candidate external string
|
|
403
526
|
* without reading plaintext or requiring a decryption key.
|