@reallyme/codec 0.1.21 → 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 +55 -4
- package/dist/boundary.d.ts +17 -0
- package/dist/boundary.js +277 -0
- package/dist/cbor.d.ts +67 -4
- package/dist/cbor.js +1252 -66
- package/dist/deterministicCborBoundary.d.ts +11 -0
- package/dist/deterministicCborBoundary.js +17 -0
- package/dist/index.d.ts +39 -22
- package/dist/index.js +14 -18
- package/dist/jcs.js +3 -60
- package/dist/multiformat.d.ts +10 -12
- package/dist/multiformat.js +155 -91
- package/dist/operationContract.d.ts +31 -0
- package/dist/operationContract.js +754 -0
- package/dist/pem.d.ts +2 -5
- package/dist/pem.js +265 -41
- package/dist/proto/generated/reallyme/codec/v1/codec_pb.d.ts +906 -13
- package/dist/proto/generated/reallyme/codec/v1/codec_pb.js +278 -23
- package/dist/proto.d.ts +2 -2
- package/dist/proto.js +1 -1
- package/dist/readOutput.d.ts +8 -7
- package/dist/readOutput.js +136 -22
- package/dist/wasm/reallyme_codec_wasm.d.ts +25 -140
- package/dist/wasm/reallyme_codec_wasm.js +134 -428
- package/dist/wasm/reallyme_codec_wasm_bg.wasm +0 -0
- package/dist/wasmProvider.d.ts +5 -31
- package/dist/wasmProvider.js +18 -51
- package/package.json +4 -1
|
Binary file
|
package/dist/wasmProvider.d.ts
CHANGED
|
@@ -1,21 +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: string, optionsJson: string) => unknown;
|
|
12
|
-
type PemEncodeFn = (label: string, der: Uint8Array, optionsJson: string) => unknown;
|
|
13
10
|
type Function0 = () => unknown;
|
|
14
|
-
|
|
15
|
-
type BytesToObjectOutputFn = (bytes: Uint8Array) => unknown;
|
|
16
|
-
type StringBytesToObjectOutputFn = (text: string, bytes: Uint8Array) => unknown;
|
|
17
|
-
type PemDecodeObjectOutputFn = (input: string, optionsJson: string) => unknown;
|
|
18
|
-
export declare const REALLYME_CODEC_WASM_EXPORTS: readonly ["base64Decode", "base64Encode", "base64urlDecode", "base64urlEncode", "bytesToLowerHex", "lowerHexToBytes", "base58btcDecode", "base58btcEncode", "multibaseBase58btcEncode", "multibaseBase64urlEncode", "multibaseDecode", "multicodecLookupPrefix", "multicodecLookupPrefixProto", "multicodecLookupPrefixProtoResult", "multicodecPrefixForName", "multicodecPrefixForNameProto", "multicodecPrefixForNameProtoResult", "multicodecStripPrefix", "multicodecTable", "multicodecTableProto", "multicodecTableProtoResult", "multikeyEncode", "multikeyParse", "multikeyParseProto", "multikeyParseProtoResult", "bindingTypeMatchesCodec", "validateKeyBinding", "requireSupportedMulticodec", "dagCborCodecCode", "dagCborComputeCid", "dagCborDecode", "dagCborEncode", "dagCborMultihash", "dagCborSha256ContentHash", "dagCborVerifyCid", "dagCborVerifyCidProto", "dagCborVerifyCidProtoResult", "isValidCidString", "tryParseCid", "canonicalizeJson", "pemDecode", "pemDecodeProto", "pemDecodeProtoResult", "pemEncode"];
|
|
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"];
|
|
19
12
|
export type ReallyMeCodecWasmProvider = Readonly<{
|
|
20
13
|
base64Decode: StringToBytesFn;
|
|
21
14
|
base64Encode: BytesToStringFn;
|
|
@@ -28,39 +21,20 @@ export type ReallyMeCodecWasmProvider = Readonly<{
|
|
|
28
21
|
multibaseBase58btcEncode: BytesToStringFn;
|
|
29
22
|
multibaseBase64urlEncode: BytesToStringFn;
|
|
30
23
|
multibaseDecode: StringToBytesFn;
|
|
31
|
-
multicodecLookupPrefix: BytesToObjectFn;
|
|
32
|
-
multicodecLookupPrefixProto: BytesToBytesFn;
|
|
33
|
-
multicodecLookupPrefixProtoResult: BytesToObjectOutputFn;
|
|
34
|
-
multicodecPrefixForName: StringToObjectFn;
|
|
35
|
-
multicodecPrefixForNameProto: StringToBytesFn;
|
|
36
|
-
multicodecPrefixForNameProtoResult: StringToObjectOutputFn;
|
|
37
24
|
multicodecStripPrefix: BytesToBytesFn;
|
|
38
|
-
multicodecTable: Function0;
|
|
39
|
-
multicodecTableProto: Function0;
|
|
40
|
-
multicodecTableProtoResult: Function0;
|
|
41
25
|
multikeyEncode: StringBytesToStringFn;
|
|
42
|
-
multikeyParse: StringToObjectFn;
|
|
43
|
-
multikeyParseProto: StringToBytesFn;
|
|
44
|
-
multikeyParseProtoResult: StringToObjectOutputFn;
|
|
45
26
|
bindingTypeMatchesCodec: StringStringToBooleanFn;
|
|
46
27
|
validateKeyBinding: ValidateKeyBindingFn;
|
|
47
28
|
requireSupportedMulticodec: StringToStringFn;
|
|
48
29
|
dagCborCodecCode: Function0;
|
|
49
30
|
dagCborComputeCid: BytesToStringFn;
|
|
50
|
-
dagCborDecode: BytesToStringFn;
|
|
51
|
-
dagCborEncode: StringToBytesFn;
|
|
52
31
|
dagCborMultihash: BytesToBytesFn;
|
|
53
32
|
dagCborSha256ContentHash: BytesToBytesFn;
|
|
54
|
-
dagCborVerifyCid: StringBytesToStringFn;
|
|
55
|
-
dagCborVerifyCidProto: StringBytesToStringFn;
|
|
56
|
-
dagCborVerifyCidProtoResult: StringBytesToObjectOutputFn;
|
|
57
33
|
isValidCidString: StringToBooleanFn;
|
|
58
|
-
tryParseCid:
|
|
34
|
+
tryParseCid: StringToUnknownFn;
|
|
59
35
|
canonicalizeJson: StringToStringFn;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
pemDecodeProtoResult: PemDecodeObjectOutputFn;
|
|
63
|
-
pemEncode: PemEncodeFn;
|
|
36
|
+
processOperation: BytesToBytesFn;
|
|
37
|
+
processOperationJson: BytesToBytesFn;
|
|
64
38
|
}>;
|
|
65
39
|
export declare const installReallyMeCodecWasmProvider: (module: unknown) => void;
|
|
66
40
|
export declare const requireReallyMeCodecWasmProvider: () => ReallyMeCodecWasmProvider;
|
package/dist/wasmProvider.js
CHANGED
|
@@ -14,39 +14,20 @@ export const REALLYME_CODEC_WASM_EXPORTS = [
|
|
|
14
14
|
"multibaseBase58btcEncode",
|
|
15
15
|
"multibaseBase64urlEncode",
|
|
16
16
|
"multibaseDecode",
|
|
17
|
-
"multicodecLookupPrefix",
|
|
18
|
-
"multicodecLookupPrefixProto",
|
|
19
|
-
"multicodecLookupPrefixProtoResult",
|
|
20
|
-
"multicodecPrefixForName",
|
|
21
|
-
"multicodecPrefixForNameProto",
|
|
22
|
-
"multicodecPrefixForNameProtoResult",
|
|
23
17
|
"multicodecStripPrefix",
|
|
24
|
-
"multicodecTable",
|
|
25
|
-
"multicodecTableProto",
|
|
26
|
-
"multicodecTableProtoResult",
|
|
27
18
|
"multikeyEncode",
|
|
28
|
-
"multikeyParse",
|
|
29
|
-
"multikeyParseProto",
|
|
30
|
-
"multikeyParseProtoResult",
|
|
31
19
|
"bindingTypeMatchesCodec",
|
|
32
20
|
"validateKeyBinding",
|
|
33
21
|
"requireSupportedMulticodec",
|
|
34
22
|
"dagCborCodecCode",
|
|
35
23
|
"dagCborComputeCid",
|
|
36
|
-
"dagCborDecode",
|
|
37
|
-
"dagCborEncode",
|
|
38
24
|
"dagCborMultihash",
|
|
39
25
|
"dagCborSha256ContentHash",
|
|
40
|
-
"dagCborVerifyCid",
|
|
41
|
-
"dagCborVerifyCidProto",
|
|
42
|
-
"dagCborVerifyCidProtoResult",
|
|
43
26
|
"isValidCidString",
|
|
44
27
|
"tryParseCid",
|
|
45
28
|
"canonicalizeJson",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"pemDecodeProtoResult",
|
|
49
|
-
"pemEncode",
|
|
29
|
+
"processOperation",
|
|
30
|
+
"processOperationJson",
|
|
50
31
|
];
|
|
51
32
|
let installedProvider;
|
|
52
33
|
const wasmErrorCode = (error) => {
|
|
@@ -69,7 +50,20 @@ const requireObject = (module) => {
|
|
|
69
50
|
return module;
|
|
70
51
|
};
|
|
71
52
|
const requireFunction = (module, name) => {
|
|
72
|
-
|
|
53
|
+
let candidate;
|
|
54
|
+
try {
|
|
55
|
+
const descriptor = Object.getOwnPropertyDescriptor(module, name);
|
|
56
|
+
if (descriptor === undefined || !("value" in descriptor)) {
|
|
57
|
+
throw new ReallyMeCodecError("provider-failure");
|
|
58
|
+
}
|
|
59
|
+
candidate = descriptor.value;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error instanceof ReallyMeCodecError) {
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
throw new ReallyMeCodecError("provider-failure");
|
|
66
|
+
}
|
|
73
67
|
if (typeof candidate !== "function") {
|
|
74
68
|
throw new ReallyMeCodecError("provider-failure");
|
|
75
69
|
}
|
|
@@ -110,14 +104,6 @@ const validateKeyBindingFunction = (module, name) => {
|
|
|
110
104
|
const callable = requireFunction(module, name);
|
|
111
105
|
return (bindingType, algorithm, multikey) => callable(bindingType, algorithm, multikey);
|
|
112
106
|
};
|
|
113
|
-
const pemDecodeFunction = (module, name) => {
|
|
114
|
-
const callable = requireFunction(module, name);
|
|
115
|
-
return (input, optionsJson) => callable(input, optionsJson);
|
|
116
|
-
};
|
|
117
|
-
const pemEncodeFunction = (module, name) => {
|
|
118
|
-
const callable = requireFunction(module, name);
|
|
119
|
-
return (label, der, optionsJson) => callable(label, der, optionsJson);
|
|
120
|
-
};
|
|
121
107
|
export const installReallyMeCodecWasmProvider = (module) => {
|
|
122
108
|
if (installedProvider !== undefined) {
|
|
123
109
|
throw new ReallyMeCodecError("provider-failure");
|
|
@@ -135,39 +121,20 @@ export const installReallyMeCodecWasmProvider = (module) => {
|
|
|
135
121
|
multibaseBase58btcEncode: bytesFunction1(providerModule, "multibaseBase58btcEncode"),
|
|
136
122
|
multibaseBase64urlEncode: bytesFunction1(providerModule, "multibaseBase64urlEncode"),
|
|
137
123
|
multibaseDecode: stringFunction1(providerModule, "multibaseDecode"),
|
|
138
|
-
multicodecLookupPrefix: bytesFunction1(providerModule, "multicodecLookupPrefix"),
|
|
139
|
-
multicodecLookupPrefixProto: bytesFunction1(providerModule, "multicodecLookupPrefixProto"),
|
|
140
|
-
multicodecLookupPrefixProtoResult: bytesFunction1(providerModule, "multicodecLookupPrefixProtoResult"),
|
|
141
|
-
multicodecPrefixForName: stringFunction1(providerModule, "multicodecPrefixForName"),
|
|
142
|
-
multicodecPrefixForNameProto: stringFunction1(providerModule, "multicodecPrefixForNameProto"),
|
|
143
|
-
multicodecPrefixForNameProtoResult: stringFunction1(providerModule, "multicodecPrefixForNameProtoResult"),
|
|
144
124
|
multicodecStripPrefix: bytesFunction1(providerModule, "multicodecStripPrefix"),
|
|
145
|
-
multicodecTable: function0(providerModule, "multicodecTable"),
|
|
146
|
-
multicodecTableProto: function0(providerModule, "multicodecTableProto"),
|
|
147
|
-
multicodecTableProtoResult: function0(providerModule, "multicodecTableProtoResult"),
|
|
148
125
|
multikeyEncode: stringBytesFunction2(providerModule, "multikeyEncode"),
|
|
149
|
-
multikeyParse: stringFunction1(providerModule, "multikeyParse"),
|
|
150
|
-
multikeyParseProto: stringFunction1(providerModule, "multikeyParseProto"),
|
|
151
|
-
multikeyParseProtoResult: stringFunction1(providerModule, "multikeyParseProtoResult"),
|
|
152
126
|
bindingTypeMatchesCodec: stringStringBooleanFunction(providerModule, "bindingTypeMatchesCodec"),
|
|
153
127
|
validateKeyBinding: validateKeyBindingFunction(providerModule, "validateKeyBinding"),
|
|
154
128
|
requireSupportedMulticodec: stringFunction1(providerModule, "requireSupportedMulticodec"),
|
|
155
129
|
dagCborCodecCode: function0(providerModule, "dagCborCodecCode"),
|
|
156
130
|
dagCborComputeCid: bytesFunction1(providerModule, "dagCborComputeCid"),
|
|
157
|
-
dagCborDecode: bytesFunction1(providerModule, "dagCborDecode"),
|
|
158
|
-
dagCborEncode: stringFunction1(providerModule, "dagCborEncode"),
|
|
159
131
|
dagCborMultihash: bytesFunction1(providerModule, "dagCborMultihash"),
|
|
160
132
|
dagCborSha256ContentHash: bytesFunction1(providerModule, "dagCborSha256ContentHash"),
|
|
161
|
-
dagCborVerifyCid: stringBytesFunction2(providerModule, "dagCborVerifyCid"),
|
|
162
|
-
dagCborVerifyCidProto: stringBytesFunction2(providerModule, "dagCborVerifyCidProto"),
|
|
163
|
-
dagCborVerifyCidProtoResult: stringBytesFunction2(providerModule, "dagCborVerifyCidProtoResult"),
|
|
164
133
|
isValidCidString: stringBooleanFunction(providerModule, "isValidCidString"),
|
|
165
134
|
tryParseCid: stringFunction1(providerModule, "tryParseCid"),
|
|
166
135
|
canonicalizeJson: stringFunction1(providerModule, "canonicalizeJson"),
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
pemDecodeProtoResult: pemDecodeFunction(providerModule, "pemDecodeProtoResult"),
|
|
170
|
-
pemEncode: pemEncodeFunction(providerModule, "pemEncode"),
|
|
136
|
+
processOperation: bytesFunction1(providerModule, "processOperation"),
|
|
137
|
+
processOperationJson: bytesFunction1(providerModule, "processOperationJson"),
|
|
171
138
|
};
|
|
172
139
|
};
|
|
173
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": {
|