@reallyme/codec 0.1.22 → 0.2.0
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/NOTICE +16 -0
- package/README.md +52 -15
- package/dist/boundary.d.ts +8 -2
- package/dist/boundary.js +31 -4
- package/dist/cbor.d.ts +67 -4
- package/dist/cbor.js +1170 -74
- package/dist/deterministicCborBoundary.d.ts +11 -0
- package/dist/deterministicCborBoundary.js +17 -0
- package/dist/index.d.ts +37 -23
- package/dist/index.js +14 -22
- package/dist/multiformat.d.ts +10 -12
- package/dist/multiformat.js +149 -128
- package/dist/operationContract.d.ts +31 -0
- package/dist/operationContract.js +754 -0
- package/dist/pem.d.ts +0 -3
- package/dist/pem.js +111 -34
- package/dist/proto/generated/reallyme/codec/v1/codec_pb.d.ts +641 -38
- package/dist/proto/generated/reallyme/codec/v1/codec_pb.js +187 -43
- package/dist/proto.d.ts +2 -2
- package/dist/proto.js +1 -1
- package/dist/readOutput.d.ts +7 -6
- package/dist/readOutput.js +62 -11
- package/dist/wasm/reallyme_codec_wasm.d.ts +7 -62
- package/dist/wasm/reallyme_codec_wasm.js +11 -168
- package/dist/wasm/reallyme_codec_wasm_bg.wasm +0 -0
- package/dist/wasmProvider.d.ts +5 -17
- package/dist/wasmProvider.js +4 -30
- package/package.json +4 -1
- package/dist/protoProcess.d.ts +0 -16
- package/dist/protoProcess.js +0 -282
|
@@ -56,16 +56,6 @@ export function dagCborCodecCode(): number;
|
|
|
56
56
|
*/
|
|
57
57
|
export function dagCborComputeCid(bytes: Uint8Array): string;
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
* Decode canonical DAG-CBOR bytes into the tagged JSON representation.
|
|
61
|
-
*/
|
|
62
|
-
export function dagCborDecode(bytes: Uint8Array): string;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Encode a tagged JSON representation as canonical DAG-CBOR bytes.
|
|
66
|
-
*/
|
|
67
|
-
export function dagCborEncode(value_json: string): Uint8Array;
|
|
68
|
-
|
|
69
59
|
/**
|
|
70
60
|
* Return the sha2-256 multihash envelope for canonical DAG-CBOR bytes.
|
|
71
61
|
*/
|
|
@@ -76,11 +66,6 @@ export function dagCborMultihash(bytes: Uint8Array): Uint8Array;
|
|
|
76
66
|
*/
|
|
77
67
|
export function dagCborSha256ContentHash(bytes: Uint8Array): Uint8Array;
|
|
78
68
|
|
|
79
|
-
/**
|
|
80
|
-
* Recompute and compare a CIDv1 dag-cbor/sha2-256 string.
|
|
81
|
-
*/
|
|
82
|
-
export function dagCborVerifyCid(cid: string, bytes: Uint8Array): any;
|
|
83
|
-
|
|
84
69
|
/**
|
|
85
70
|
* Return whether a string parses as a CID.
|
|
86
71
|
*/
|
|
@@ -106,55 +91,25 @@ export function multibaseBase64urlEncode(bytes: Uint8Array): string;
|
|
|
106
91
|
*/
|
|
107
92
|
export function multibaseDecode(encoded: string): Uint8Array;
|
|
108
93
|
|
|
109
|
-
/**
|
|
110
|
-
* Resolve a byte slice that starts with a known multicodec prefix.
|
|
111
|
-
*/
|
|
112
|
-
export function multicodecLookupPrefix(bytes: Uint8Array): any;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Return multicodec metadata for a canonical codec name.
|
|
116
|
-
*/
|
|
117
|
-
export function multicodecPrefixForName(codec_name: string): any;
|
|
118
|
-
|
|
119
94
|
/**
|
|
120
95
|
* Strip a known multicodec prefix, or return the original bytes when none is found.
|
|
121
96
|
*/
|
|
122
97
|
export function multicodecStripPrefix(bytes: Uint8Array): Uint8Array;
|
|
123
98
|
|
|
124
|
-
/**
|
|
125
|
-
* Return the supported multicodec table.
|
|
126
|
-
*/
|
|
127
|
-
export function multicodecTable(): any;
|
|
128
|
-
|
|
129
99
|
/**
|
|
130
100
|
* Encode a public key as a multibase base58btc multikey.
|
|
131
101
|
*/
|
|
132
102
|
export function multikeyEncode(codec_name: string, public_key: Uint8Array): string;
|
|
133
103
|
|
|
134
104
|
/**
|
|
135
|
-
*
|
|
136
|
-
*/
|
|
137
|
-
export function multikeyParse(multikey: string): any;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Decode PEM armor bytes with caller-supplied size and label policy.
|
|
141
|
-
*/
|
|
142
|
-
export function pemDecode(input: Uint8Array, options_json: string): any;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Encode DER bytes as wipeable PEM armor bytes.
|
|
105
|
+
* Execute one generated binary protobuf request and return a fully discriminated response.
|
|
146
106
|
*/
|
|
147
|
-
export function
|
|
107
|
+
export function processOperation(request: Uint8Array): Uint8Array;
|
|
148
108
|
|
|
149
109
|
/**
|
|
150
|
-
* Execute one generated
|
|
110
|
+
* Execute one generated ProtoJSON request and return a discriminated response.
|
|
151
111
|
*/
|
|
152
|
-
export function
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Execute one generated ProtoJSON request and return a binary result envelope.
|
|
156
|
-
*/
|
|
157
|
-
export function processProtoJson(request_json: Uint8Array): Uint8Array;
|
|
112
|
+
export function processOperationJson(request_json: Uint8Array): Uint8Array;
|
|
158
113
|
|
|
159
114
|
/**
|
|
160
115
|
* Fail closed when a codec name is not in the supported table.
|
|
@@ -186,36 +141,26 @@ export interface InitOutput {
|
|
|
186
141
|
readonly canonicalizeJson: (a: any) => [number, number, number, number];
|
|
187
142
|
readonly dagCborCodecCode: () => number;
|
|
188
143
|
readonly dagCborComputeCid: (a: any) => [number, number, number, number];
|
|
189
|
-
readonly dagCborDecode: (a: any) => [number, number, number, number];
|
|
190
|
-
readonly dagCborEncode: (a: any) => [number, number, number];
|
|
191
144
|
readonly dagCborMultihash: (a: any) => [number, number, number];
|
|
192
145
|
readonly dagCborSha256ContentHash: (a: any) => [number, number, number];
|
|
193
|
-
readonly dagCborVerifyCid: (a: any, b: any) => [number, number, number];
|
|
194
146
|
readonly isValidCidString: (a: any) => [number, number, number];
|
|
195
147
|
readonly lowerHexToBytes: (a: any) => [number, number, number];
|
|
196
148
|
readonly multibaseBase58btcEncode: (a: any) => [number, number, number, number];
|
|
197
149
|
readonly multibaseBase64urlEncode: (a: any) => [number, number, number, number];
|
|
198
150
|
readonly multibaseDecode: (a: any) => [number, number, number];
|
|
199
|
-
readonly multicodecLookupPrefix: (a: any) => [number, number, number];
|
|
200
|
-
readonly multicodecPrefixForName: (a: any) => [number, number, number];
|
|
201
151
|
readonly multicodecStripPrefix: (a: any) => [number, number, number];
|
|
202
|
-
readonly multicodecTable: () => [number, number, number];
|
|
203
152
|
readonly multikeyEncode: (a: any, b: any) => [number, number, number, number];
|
|
204
|
-
readonly
|
|
205
|
-
readonly
|
|
206
|
-
readonly pemEncode: (a: any, b: any, c: any) => [number, number, number];
|
|
207
|
-
readonly processProto: (a: any) => [number, number, number];
|
|
208
|
-
readonly processProtoJson: (a: any) => [number, number, number];
|
|
153
|
+
readonly processOperation: (a: any) => [number, number, number];
|
|
154
|
+
readonly processOperationJson: (a: any) => [number, number, number];
|
|
209
155
|
readonly requireSupportedMulticodec: (a: any) => [number, number];
|
|
210
156
|
readonly tryParseCid: (a: any) => [number, number, number];
|
|
211
157
|
readonly validateKeyBinding: (a: any, b: number, c: any) => [number, number];
|
|
212
158
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
213
159
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
214
|
-
readonly __wbindgen_exn_store: (a: number) => void;
|
|
215
|
-
readonly __externref_table_alloc: () => number;
|
|
216
160
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
217
161
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
218
162
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
163
|
+
readonly __externref_table_alloc: () => number;
|
|
219
164
|
readonly __wbindgen_start: () => void;
|
|
220
165
|
}
|
|
221
166
|
|
|
@@ -206,43 +206,6 @@ export function dagCborComputeCid(bytes) {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
/**
|
|
210
|
-
* Decode canonical DAG-CBOR bytes into the tagged JSON representation.
|
|
211
|
-
* @param {Uint8Array} bytes
|
|
212
|
-
* @returns {string}
|
|
213
|
-
*/
|
|
214
|
-
export function dagCborDecode(bytes) {
|
|
215
|
-
let deferred2_0;
|
|
216
|
-
let deferred2_1;
|
|
217
|
-
try {
|
|
218
|
-
const ret = wasm.dagCborDecode(bytes);
|
|
219
|
-
var ptr1 = ret[0];
|
|
220
|
-
var len1 = ret[1];
|
|
221
|
-
if (ret[3]) {
|
|
222
|
-
ptr1 = 0; len1 = 0;
|
|
223
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
224
|
-
}
|
|
225
|
-
deferred2_0 = ptr1;
|
|
226
|
-
deferred2_1 = len1;
|
|
227
|
-
return getStringFromWasm0(ptr1, len1);
|
|
228
|
-
} finally {
|
|
229
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Encode a tagged JSON representation as canonical DAG-CBOR bytes.
|
|
235
|
-
* @param {string} value_json
|
|
236
|
-
* @returns {Uint8Array}
|
|
237
|
-
*/
|
|
238
|
-
export function dagCborEncode(value_json) {
|
|
239
|
-
const ret = wasm.dagCborEncode(value_json);
|
|
240
|
-
if (ret[2]) {
|
|
241
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
242
|
-
}
|
|
243
|
-
return takeFromExternrefTable0(ret[0]);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
209
|
/**
|
|
247
210
|
* Return the sha2-256 multihash envelope for canonical DAG-CBOR bytes.
|
|
248
211
|
* @param {Uint8Array} bytes
|
|
@@ -269,20 +232,6 @@ export function dagCborSha256ContentHash(bytes) {
|
|
|
269
232
|
return takeFromExternrefTable0(ret[0]);
|
|
270
233
|
}
|
|
271
234
|
|
|
272
|
-
/**
|
|
273
|
-
* Recompute and compare a CIDv1 dag-cbor/sha2-256 string.
|
|
274
|
-
* @param {string} cid
|
|
275
|
-
* @param {Uint8Array} bytes
|
|
276
|
-
* @returns {any}
|
|
277
|
-
*/
|
|
278
|
-
export function dagCborVerifyCid(cid, bytes) {
|
|
279
|
-
const ret = wasm.dagCborVerifyCid(cid, bytes);
|
|
280
|
-
if (ret[2]) {
|
|
281
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
282
|
-
}
|
|
283
|
-
return takeFromExternrefTable0(ret[0]);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
235
|
/**
|
|
287
236
|
* Return whether a string parses as a CID.
|
|
288
237
|
* @param {string} cid
|
|
@@ -370,32 +319,6 @@ export function multibaseDecode(encoded) {
|
|
|
370
319
|
return takeFromExternrefTable0(ret[0]);
|
|
371
320
|
}
|
|
372
321
|
|
|
373
|
-
/**
|
|
374
|
-
* Resolve a byte slice that starts with a known multicodec prefix.
|
|
375
|
-
* @param {Uint8Array} bytes
|
|
376
|
-
* @returns {any}
|
|
377
|
-
*/
|
|
378
|
-
export function multicodecLookupPrefix(bytes) {
|
|
379
|
-
const ret = wasm.multicodecLookupPrefix(bytes);
|
|
380
|
-
if (ret[2]) {
|
|
381
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
382
|
-
}
|
|
383
|
-
return takeFromExternrefTable0(ret[0]);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Return multicodec metadata for a canonical codec name.
|
|
388
|
-
* @param {string} codec_name
|
|
389
|
-
* @returns {any}
|
|
390
|
-
*/
|
|
391
|
-
export function multicodecPrefixForName(codec_name) {
|
|
392
|
-
const ret = wasm.multicodecPrefixForName(codec_name);
|
|
393
|
-
if (ret[2]) {
|
|
394
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
395
|
-
}
|
|
396
|
-
return takeFromExternrefTable0(ret[0]);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
322
|
/**
|
|
400
323
|
* Strip a known multicodec prefix, or return the original bytes when none is found.
|
|
401
324
|
* @param {Uint8Array} bytes
|
|
@@ -409,18 +332,6 @@ export function multicodecStripPrefix(bytes) {
|
|
|
409
332
|
return takeFromExternrefTable0(ret[0]);
|
|
410
333
|
}
|
|
411
334
|
|
|
412
|
-
/**
|
|
413
|
-
* Return the supported multicodec table.
|
|
414
|
-
* @returns {any}
|
|
415
|
-
*/
|
|
416
|
-
export function multicodecTable() {
|
|
417
|
-
const ret = wasm.multicodecTable();
|
|
418
|
-
if (ret[2]) {
|
|
419
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
420
|
-
}
|
|
421
|
-
return takeFromExternrefTable0(ret[0]);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
335
|
/**
|
|
425
336
|
* Encode a public key as a multibase base58btc multikey.
|
|
426
337
|
* @param {string} codec_name
|
|
@@ -447,54 +358,12 @@ export function multikeyEncode(codec_name, public_key) {
|
|
|
447
358
|
}
|
|
448
359
|
|
|
449
360
|
/**
|
|
450
|
-
*
|
|
451
|
-
* @param {string} multikey
|
|
452
|
-
* @returns {any}
|
|
453
|
-
*/
|
|
454
|
-
export function multikeyParse(multikey) {
|
|
455
|
-
const ret = wasm.multikeyParse(multikey);
|
|
456
|
-
if (ret[2]) {
|
|
457
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
458
|
-
}
|
|
459
|
-
return takeFromExternrefTable0(ret[0]);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Decode PEM armor bytes with caller-supplied size and label policy.
|
|
464
|
-
* @param {Uint8Array} input
|
|
465
|
-
* @param {string} options_json
|
|
466
|
-
* @returns {any}
|
|
467
|
-
*/
|
|
468
|
-
export function pemDecode(input, options_json) {
|
|
469
|
-
const ret = wasm.pemDecode(input, options_json);
|
|
470
|
-
if (ret[2]) {
|
|
471
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
472
|
-
}
|
|
473
|
-
return takeFromExternrefTable0(ret[0]);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Encode DER bytes as wipeable PEM armor bytes.
|
|
478
|
-
* @param {string} label
|
|
479
|
-
* @param {Uint8Array} der
|
|
480
|
-
* @param {string} options_json
|
|
481
|
-
* @returns {Uint8Array}
|
|
482
|
-
*/
|
|
483
|
-
export function pemEncode(label, der, options_json) {
|
|
484
|
-
const ret = wasm.pemEncode(label, der, options_json);
|
|
485
|
-
if (ret[2]) {
|
|
486
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
487
|
-
}
|
|
488
|
-
return takeFromExternrefTable0(ret[0]);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Execute one generated binary protobuf request and return a binary result envelope.
|
|
361
|
+
* Execute one generated binary protobuf request and return a fully discriminated response.
|
|
493
362
|
* @param {Uint8Array} request
|
|
494
363
|
* @returns {Uint8Array}
|
|
495
364
|
*/
|
|
496
|
-
export function
|
|
497
|
-
const ret = wasm.
|
|
365
|
+
export function processOperation(request) {
|
|
366
|
+
const ret = wasm.processOperation(request);
|
|
498
367
|
if (ret[2]) {
|
|
499
368
|
throw takeFromExternrefTable0(ret[1]);
|
|
500
369
|
}
|
|
@@ -502,12 +371,12 @@ export function processProto(request) {
|
|
|
502
371
|
}
|
|
503
372
|
|
|
504
373
|
/**
|
|
505
|
-
* Execute one generated ProtoJSON request and return a
|
|
374
|
+
* Execute one generated ProtoJSON request and return a discriminated response.
|
|
506
375
|
* @param {Uint8Array} request_json
|
|
507
376
|
* @returns {Uint8Array}
|
|
508
377
|
*/
|
|
509
|
-
export function
|
|
510
|
-
const ret = wasm.
|
|
378
|
+
export function processOperationJson(request_json) {
|
|
379
|
+
const ret = wasm.processOperationJson(request_json);
|
|
511
380
|
if (ret[2]) {
|
|
512
381
|
throw takeFromExternrefTable0(ret[1]);
|
|
513
382
|
}
|
|
@@ -564,6 +433,10 @@ function __wbg_get_imports() {
|
|
|
564
433
|
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
565
434
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
566
435
|
},
|
|
436
|
+
__wbg_charCodeAt_2a30bc7c17474cc6: function(arg0, arg1) {
|
|
437
|
+
const ret = arg0.charCodeAt(arg1 >>> 0);
|
|
438
|
+
return ret;
|
|
439
|
+
},
|
|
567
440
|
__wbg_fill_5663f5c647107cce: function(arg0, arg1, arg2, arg3) {
|
|
568
441
|
const ret = arg0.fill(arg1, arg2 >>> 0, arg3 >>> 0);
|
|
569
442
|
return ret;
|
|
@@ -576,14 +449,6 @@ function __wbg_get_imports() {
|
|
|
576
449
|
const ret = arg0.length;
|
|
577
450
|
return ret;
|
|
578
451
|
},
|
|
579
|
-
__wbg_new_32b398fb48b6d94a: function() {
|
|
580
|
-
const ret = new Array();
|
|
581
|
-
return ret;
|
|
582
|
-
},
|
|
583
|
-
__wbg_new_da52cf8fe3429cb2: function() {
|
|
584
|
-
const ret = new Object();
|
|
585
|
-
return ret;
|
|
586
|
-
},
|
|
587
452
|
__wbg_new_from_slice_77cdfb7977362f3c: function(arg0, arg1) {
|
|
588
453
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
589
454
|
return ret;
|
|
@@ -595,27 +460,14 @@ function __wbg_get_imports() {
|
|
|
595
460
|
__wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
|
|
596
461
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
597
462
|
},
|
|
598
|
-
__wbg_push_d2ae3af0c1217ae6: function(arg0, arg1) {
|
|
599
|
-
const ret = arg0.push(arg1);
|
|
600
|
-
return ret;
|
|
601
|
-
},
|
|
602
463
|
__wbg_set_61e45ae8061eca11: function(arg0, arg1, arg2) {
|
|
603
464
|
arg0.set(arg1, arg2 >>> 0);
|
|
604
465
|
},
|
|
605
|
-
__wbg_set_8535240470bf2500: function() { return handleError(function (arg0, arg1, arg2) {
|
|
606
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
607
|
-
return ret;
|
|
608
|
-
}, arguments); },
|
|
609
466
|
__wbg_subarray_3ed232c8a6baee09: function(arg0, arg1, arg2) {
|
|
610
467
|
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
611
468
|
return ret;
|
|
612
469
|
},
|
|
613
|
-
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
614
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
615
|
-
const ret = arg0;
|
|
616
|
-
return ret;
|
|
617
|
-
},
|
|
618
|
-
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
470
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
619
471
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
620
472
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
621
473
|
return ret;
|
|
@@ -667,15 +519,6 @@ function getUint8ArrayMemory0() {
|
|
|
667
519
|
return cachedUint8ArrayMemory0;
|
|
668
520
|
}
|
|
669
521
|
|
|
670
|
-
function handleError(f, args) {
|
|
671
|
-
try {
|
|
672
|
-
return f.apply(this, args);
|
|
673
|
-
} catch (e) {
|
|
674
|
-
const idx = addToExternrefTable0(e);
|
|
675
|
-
wasm.__wbindgen_exn_store(idx);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
522
|
function isLikeNone(x) {
|
|
680
523
|
return x === undefined || x === null;
|
|
681
524
|
}
|
|
Binary file
|
package/dist/wasmProvider.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
type BytesToStringFn = (bytes: Uint8Array) => unknown;
|
|
2
2
|
type StringToBytesFn = (text: string) => unknown;
|
|
3
3
|
type StringToStringFn = (text: string) => unknown;
|
|
4
|
-
type
|
|
5
|
-
type BytesToObjectFn = (bytes: Uint8Array) => unknown;
|
|
4
|
+
type StringToUnknownFn = (text: string) => unknown;
|
|
6
5
|
type BytesToBytesFn = (bytes: Uint8Array) => unknown;
|
|
7
6
|
type StringBytesToStringFn = (text: string, bytes: Uint8Array) => unknown;
|
|
8
7
|
type StringToBooleanFn = (text: string) => unknown;
|
|
9
8
|
type StringStringToBooleanFn = (left: string, right: string) => unknown;
|
|
10
9
|
type ValidateKeyBindingFn = (bindingType: string, algorithm: string | undefined, multikey: string) => unknown;
|
|
11
|
-
type PemDecodeFn = (input: Uint8Array, optionsJson: string) => unknown;
|
|
12
|
-
type PemEncodeFn = (label: string, der: Uint8Array, optionsJson: string) => unknown;
|
|
13
10
|
type Function0 = () => unknown;
|
|
14
|
-
export declare const REALLYME_CODEC_WASM_EXPORTS: readonly ["base64Decode", "base64Encode", "base64urlDecode", "base64urlEncode", "bytesToLowerHex", "lowerHexToBytes", "base58btcDecode", "base58btcEncode", "multibaseBase58btcEncode", "multibaseBase64urlEncode", "multibaseDecode", "
|
|
11
|
+
export declare const REALLYME_CODEC_WASM_EXPORTS: readonly ["base64Decode", "base64Encode", "base64urlDecode", "base64urlEncode", "bytesToLowerHex", "lowerHexToBytes", "base58btcDecode", "base58btcEncode", "multibaseBase58btcEncode", "multibaseBase64urlEncode", "multibaseDecode", "multicodecStripPrefix", "multikeyEncode", "bindingTypeMatchesCodec", "validateKeyBinding", "requireSupportedMulticodec", "dagCborCodecCode", "dagCborComputeCid", "dagCborMultihash", "dagCborSha256ContentHash", "isValidCidString", "tryParseCid", "canonicalizeJson", "processOperation", "processOperationJson"];
|
|
15
12
|
export type ReallyMeCodecWasmProvider = Readonly<{
|
|
16
13
|
base64Decode: StringToBytesFn;
|
|
17
14
|
base64Encode: BytesToStringFn;
|
|
@@ -24,29 +21,20 @@ export type ReallyMeCodecWasmProvider = Readonly<{
|
|
|
24
21
|
multibaseBase58btcEncode: BytesToStringFn;
|
|
25
22
|
multibaseBase64urlEncode: BytesToStringFn;
|
|
26
23
|
multibaseDecode: StringToBytesFn;
|
|
27
|
-
multicodecLookupPrefix: BytesToObjectFn;
|
|
28
|
-
multicodecPrefixForName: StringToObjectFn;
|
|
29
24
|
multicodecStripPrefix: BytesToBytesFn;
|
|
30
|
-
multicodecTable: Function0;
|
|
31
25
|
multikeyEncode: StringBytesToStringFn;
|
|
32
|
-
multikeyParse: StringToObjectFn;
|
|
33
26
|
bindingTypeMatchesCodec: StringStringToBooleanFn;
|
|
34
27
|
validateKeyBinding: ValidateKeyBindingFn;
|
|
35
28
|
requireSupportedMulticodec: StringToStringFn;
|
|
36
29
|
dagCborCodecCode: Function0;
|
|
37
30
|
dagCborComputeCid: BytesToStringFn;
|
|
38
|
-
dagCborDecode: BytesToStringFn;
|
|
39
|
-
dagCborEncode: StringToBytesFn;
|
|
40
31
|
dagCborMultihash: BytesToBytesFn;
|
|
41
32
|
dagCborSha256ContentHash: BytesToBytesFn;
|
|
42
|
-
dagCborVerifyCid: StringBytesToStringFn;
|
|
43
33
|
isValidCidString: StringToBooleanFn;
|
|
44
|
-
tryParseCid:
|
|
34
|
+
tryParseCid: StringToUnknownFn;
|
|
45
35
|
canonicalizeJson: StringToStringFn;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
processProto: BytesToBytesFn;
|
|
49
|
-
processProtoJson: BytesToBytesFn;
|
|
36
|
+
processOperation: BytesToBytesFn;
|
|
37
|
+
processOperationJson: BytesToBytesFn;
|
|
50
38
|
}>;
|
|
51
39
|
export declare const installReallyMeCodecWasmProvider: (module: unknown) => void;
|
|
52
40
|
export declare const requireReallyMeCodecWasmProvider: () => ReallyMeCodecWasmProvider;
|
package/dist/wasmProvider.js
CHANGED
|
@@ -14,29 +14,20 @@ export const REALLYME_CODEC_WASM_EXPORTS = [
|
|
|
14
14
|
"multibaseBase58btcEncode",
|
|
15
15
|
"multibaseBase64urlEncode",
|
|
16
16
|
"multibaseDecode",
|
|
17
|
-
"multicodecLookupPrefix",
|
|
18
|
-
"multicodecPrefixForName",
|
|
19
17
|
"multicodecStripPrefix",
|
|
20
|
-
"multicodecTable",
|
|
21
18
|
"multikeyEncode",
|
|
22
|
-
"multikeyParse",
|
|
23
19
|
"bindingTypeMatchesCodec",
|
|
24
20
|
"validateKeyBinding",
|
|
25
21
|
"requireSupportedMulticodec",
|
|
26
22
|
"dagCborCodecCode",
|
|
27
23
|
"dagCborComputeCid",
|
|
28
|
-
"dagCborDecode",
|
|
29
|
-
"dagCborEncode",
|
|
30
24
|
"dagCborMultihash",
|
|
31
25
|
"dagCborSha256ContentHash",
|
|
32
|
-
"dagCborVerifyCid",
|
|
33
26
|
"isValidCidString",
|
|
34
27
|
"tryParseCid",
|
|
35
28
|
"canonicalizeJson",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"processProto",
|
|
39
|
-
"processProtoJson",
|
|
29
|
+
"processOperation",
|
|
30
|
+
"processOperationJson",
|
|
40
31
|
];
|
|
41
32
|
let installedProvider;
|
|
42
33
|
const wasmErrorCode = (error) => {
|
|
@@ -113,14 +104,6 @@ const validateKeyBindingFunction = (module, name) => {
|
|
|
113
104
|
const callable = requireFunction(module, name);
|
|
114
105
|
return (bindingType, algorithm, multikey) => callable(bindingType, algorithm, multikey);
|
|
115
106
|
};
|
|
116
|
-
const pemDecodeFunction = (module, name) => {
|
|
117
|
-
const callable = requireFunction(module, name);
|
|
118
|
-
return (input, optionsJson) => callable(input, optionsJson);
|
|
119
|
-
};
|
|
120
|
-
const pemEncodeFunction = (module, name) => {
|
|
121
|
-
const callable = requireFunction(module, name);
|
|
122
|
-
return (label, der, optionsJson) => callable(label, der, optionsJson);
|
|
123
|
-
};
|
|
124
107
|
export const installReallyMeCodecWasmProvider = (module) => {
|
|
125
108
|
if (installedProvider !== undefined) {
|
|
126
109
|
throw new ReallyMeCodecError("provider-failure");
|
|
@@ -138,29 +121,20 @@ export const installReallyMeCodecWasmProvider = (module) => {
|
|
|
138
121
|
multibaseBase58btcEncode: bytesFunction1(providerModule, "multibaseBase58btcEncode"),
|
|
139
122
|
multibaseBase64urlEncode: bytesFunction1(providerModule, "multibaseBase64urlEncode"),
|
|
140
123
|
multibaseDecode: stringFunction1(providerModule, "multibaseDecode"),
|
|
141
|
-
multicodecLookupPrefix: bytesFunction1(providerModule, "multicodecLookupPrefix"),
|
|
142
|
-
multicodecPrefixForName: stringFunction1(providerModule, "multicodecPrefixForName"),
|
|
143
124
|
multicodecStripPrefix: bytesFunction1(providerModule, "multicodecStripPrefix"),
|
|
144
|
-
multicodecTable: function0(providerModule, "multicodecTable"),
|
|
145
125
|
multikeyEncode: stringBytesFunction2(providerModule, "multikeyEncode"),
|
|
146
|
-
multikeyParse: stringFunction1(providerModule, "multikeyParse"),
|
|
147
126
|
bindingTypeMatchesCodec: stringStringBooleanFunction(providerModule, "bindingTypeMatchesCodec"),
|
|
148
127
|
validateKeyBinding: validateKeyBindingFunction(providerModule, "validateKeyBinding"),
|
|
149
128
|
requireSupportedMulticodec: stringFunction1(providerModule, "requireSupportedMulticodec"),
|
|
150
129
|
dagCborCodecCode: function0(providerModule, "dagCborCodecCode"),
|
|
151
130
|
dagCborComputeCid: bytesFunction1(providerModule, "dagCborComputeCid"),
|
|
152
|
-
dagCborDecode: bytesFunction1(providerModule, "dagCborDecode"),
|
|
153
|
-
dagCborEncode: stringFunction1(providerModule, "dagCborEncode"),
|
|
154
131
|
dagCborMultihash: bytesFunction1(providerModule, "dagCborMultihash"),
|
|
155
132
|
dagCborSha256ContentHash: bytesFunction1(providerModule, "dagCborSha256ContentHash"),
|
|
156
|
-
dagCborVerifyCid: stringBytesFunction2(providerModule, "dagCborVerifyCid"),
|
|
157
133
|
isValidCidString: stringBooleanFunction(providerModule, "isValidCidString"),
|
|
158
134
|
tryParseCid: stringFunction1(providerModule, "tryParseCid"),
|
|
159
135
|
canonicalizeJson: stringFunction1(providerModule, "canonicalizeJson"),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
processProto: bytesFunction1(providerModule, "processProto"),
|
|
163
|
-
processProtoJson: bytesFunction1(providerModule, "processProtoJson"),
|
|
136
|
+
processOperation: bytesFunction1(providerModule, "processOperation"),
|
|
137
|
+
processOperationJson: bytesFunction1(providerModule, "processOperationJson"),
|
|
164
138
|
};
|
|
165
139
|
};
|
|
166
140
|
export const requireReallyMeCodecWasmProvider = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reallyme/codec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript facade for the ReallyMe codec WASM package.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
29
|
"LICENSE",
|
|
30
|
+
"NOTICE",
|
|
30
31
|
"README.md"
|
|
31
32
|
],
|
|
32
33
|
"scripts": {
|
|
33
34
|
"build": "node scripts/clean-dist.mjs && npm run build:wasm && tsc",
|
|
34
35
|
"build:wasm": "node scripts/build-wasm.mjs",
|
|
35
36
|
"prepack": "npm run build",
|
|
37
|
+
"test:browser": "npm run build && node scripts/browser-wasm-test.mjs",
|
|
36
38
|
"typecheck": "tsc --noEmit",
|
|
37
39
|
"test": "npm run build && node --test \"test/*.test.mjs\""
|
|
38
40
|
},
|
|
@@ -40,6 +42,7 @@
|
|
|
40
42
|
"@bufbuild/protobuf": "2.12.1"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
45
|
+
"fast-check": "3.23.2",
|
|
43
46
|
"typescript": "5.8.3"
|
|
44
47
|
},
|
|
45
48
|
"engines": {
|
package/dist/protoProcess.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CodecOperationRequest } from "./proto/generated/reallyme/codec/v1/codec_pb.js";
|
|
2
|
-
import type { ReallyMeCodecProtoResult } from "./readOutput.js";
|
|
3
|
-
/**
|
|
4
|
-
* Execute one binary generated-protobuf request.
|
|
5
|
-
*
|
|
6
|
-
* The returned bytes are always a `CodecProtoResultEnvelope`; malformed or
|
|
7
|
-
* unsupported requests are represented inside that envelope.
|
|
8
|
-
*/
|
|
9
|
-
export declare const processProto: (requestBytes: Uint8Array) => Uint8Array;
|
|
10
|
-
/**
|
|
11
|
-
* Execute one generated ProtoJSON request and return the same binary envelope
|
|
12
|
-
* used by `processProto`.
|
|
13
|
-
*/
|
|
14
|
-
export declare const processProtoJson: (requestJson: Uint8Array) => Uint8Array;
|
|
15
|
-
export declare const processGeneratedProtoRequest: (request: CodecOperationRequest) => ReallyMeCodecProtoResult;
|
|
16
|
-
export declare const protoPayloadOrThrow: (result: ReallyMeCodecProtoResult) => Uint8Array;
|