@learncard/core 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ [![](https://img.shields.io/npm/v/@spruceid/didkit-wasm?label=%40spruceid%2Fdidkit-wasm&logo=npm)](https://www.npmjs.com/package/@spruceid/didkit-wasm) [![](https://img.shields.io/npm/v/@spruceid/didkit-wasm-node?label=%40spruceid%2Fdidkit-wasm-node&logo=npm)](https://www.npmjs.com/package/@spruceid/didkit-wasm-node)
2
+ <!-- Might want those badge in the main README. -->
3
+
4
+ # DIDKit WASM
5
+
6
+ ## Prerequisites to Build from Source
7
+
8
+ NPM packages are available but if you would like to compile DIDKit yourself
9
+ (e.g. to enable different cryptographic backends) you will need the WASM
10
+ compiler toolchain as well as a specific build tool:
11
+
12
+ ```bash
13
+ $ rustup target add wasm32-unknown-unknown
14
+ $ cargo install wasm-pack
15
+ # OR
16
+ # $ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
17
+ ```
18
+
19
+ ## Installation and Usage
20
+
21
+ ### Node
22
+
23
+ WASM can be used in Node.js (any recent version):
24
+ ```bash
25
+ $ npm i @spruceid/didkit-wasm-node
26
+ ```
27
+
28
+ Or build it from source:
29
+ ```bash
30
+ $ wasm-pack build --target nodejs
31
+ ```
32
+
33
+ ### Web Frameworks (Bundled)
34
+
35
+ WASM can be used with web frameworks and bundlers like Webpack:
36
+ ```bash
37
+ $ npm i @spruceid/didkit-wasm
38
+ ```
39
+
40
+ Or build it from source:
41
+ ```bash
42
+ $ wasm-pack build
43
+ ```
44
+
45
+ > If Webpack doesn't work with the default configuration, you can have a look at
46
+ > our configuration for
47
+ > [tzprofiles](https://github.com/spruceid/tzprofiles/blob/main/dapp/webpack.config.js).
48
+
49
+ ### Vanilla Javascript
50
+
51
+ WASM can be used with plain Javascript with newer browsers. As it cannot be used
52
+ as a NPM package you have to build it manually:
53
+ ```bash
54
+ $ wasm-pack build --target web
55
+ ```
56
+
57
+ The manual tests in `test/` serve as an example on how to import DIDKit.
58
+
59
+ ## Tests
60
+
61
+ The `test/` directory contains manual tests to run in the browser. Instructions
62
+ are in the README of the directory.
63
+
64
+ ## Non-Default Compilation
65
+
66
+ _**The current version of the `ring` crate does not provide all the symbols
67
+ needed to run on the browser, see DEPS.md**_
68
+
69
+ To compile all features plus `wasm32_c` on `ring`, a C compiler is needed, see
70
+ [spruceid/ssi](https://github.com/spruceid/didkit/tree/wasm):
71
+
72
+ On Ubuntu this one option is to install `clang` and `llvm`:
73
+ ```bash
74
+ sudo apt install clang-10 llvm-10
75
+ ```
76
+
77
+ Then to compile with all features:
78
+ ```bash
79
+ TARGET_CC=clang-10 TARGET_AR=llvm-ar-10 wasm-pack build --out-dir pkg
80
+ ```
81
+
82
+ To use a custom subset of features:
83
+ ```bash
84
+ wasm-pack build --out-dir pkg -- --no-default-features --features=issue # issue credential/presentation
85
+ wasm-pack build --out-dir pkg -- --no-default-features --features=verify # verify credential/presentation
86
+ wasm-pack build --out-dir pkg -- --no-default-features --features=credential # issue/verify credential
87
+ wasm-pack build --out-dir pkg -- --no-default-features --features=presentation # issue/verify presentation
88
+ ```
89
+ *don't forget to add `TARGET_CC` and `TARGET_AR` if using `ring` with `wasm32_c`*
@@ -0,0 +1,222 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @returns {string}
5
+ */
6
+ export function getVersion(): string;
7
+ /**
8
+ * @param {string} did
9
+ * @param {string} input_metadata
10
+ * @returns {Promise<any>}
11
+ */
12
+ export function resolveDID(did: string, input_metadata: string): Promise<any>;
13
+ /**
14
+ * @returns {string}
15
+ */
16
+ export function generateEd25519Key(): string;
17
+ /**
18
+ * @param {Uint8Array} bytes
19
+ * @returns {string}
20
+ */
21
+ export function generateEd25519KeyFromBytes(bytes: Uint8Array): string;
22
+ /**
23
+ * @param {string} method_pattern
24
+ * @param {string} jwk
25
+ * @returns {string}
26
+ */
27
+ export function keyToDID(method_pattern: string, jwk: string): string;
28
+ /**
29
+ * @param {string} method_pattern
30
+ * @param {string} jwk
31
+ * @returns {Promise<any>}
32
+ */
33
+ export function keyToVerificationMethod(method_pattern: string, jwk: string): Promise<any>;
34
+ /**
35
+ * @param {string} credential
36
+ * @param {string} proof_options
37
+ * @param {string} key
38
+ * @returns {Promise<any>}
39
+ */
40
+ export function issueCredential(credential: string, proof_options: string, key: string): Promise<any>;
41
+ /**
42
+ * @param {string} credential
43
+ * @param {string} linked_data_proof_options
44
+ * @param {string} public_key
45
+ * @returns {Promise<any>}
46
+ */
47
+ export function prepareIssueCredential(credential: string, linked_data_proof_options: string, public_key: string): Promise<any>;
48
+ /**
49
+ * @param {string} credential
50
+ * @param {string} preparation
51
+ * @param {string} signature
52
+ * @returns {Promise<any>}
53
+ */
54
+ export function completeIssueCredential(credential: string, preparation: string, signature: string): Promise<any>;
55
+ /**
56
+ * @param {string} vc
57
+ * @param {string} proof_options
58
+ * @returns {Promise<any>}
59
+ */
60
+ export function verifyCredential(vc: string, proof_options: string): Promise<any>;
61
+ /**
62
+ * @param {string} presentation
63
+ * @param {string} proof_options
64
+ * @param {string} key
65
+ * @returns {Promise<any>}
66
+ */
67
+ export function issuePresentation(presentation: string, proof_options: string, key: string): Promise<any>;
68
+ /**
69
+ * @param {string} presentation
70
+ * @param {string} linked_data_proof_options
71
+ * @param {string} public_key
72
+ * @returns {Promise<any>}
73
+ */
74
+ export function prepareIssuePresentation(presentation: string, linked_data_proof_options: string, public_key: string): Promise<any>;
75
+ /**
76
+ * @param {string} presentation
77
+ * @param {string} preparation
78
+ * @param {string} signature
79
+ * @returns {Promise<any>}
80
+ */
81
+ export function completeIssuePresentation(presentation: string, preparation: string, signature: string): Promise<any>;
82
+ /**
83
+ * @param {string} vp
84
+ * @param {string} proof_options
85
+ * @returns {Promise<any>}
86
+ */
87
+ export function verifyPresentation(vp: string, proof_options: string): Promise<any>;
88
+ /**
89
+ * @param {string} holder
90
+ * @param {string} linked_data_proof_options
91
+ * @param {string} key
92
+ * @returns {Promise<any>}
93
+ */
94
+ export function DIDAuth(holder: string, linked_data_proof_options: string, key: string): Promise<any>;
95
+ /**
96
+ * @param {string} tz
97
+ * @returns {Promise<any>}
98
+ */
99
+ export function JWKFromTezos(tz: string): Promise<any>;
100
+ /**
101
+ * @param {string} capability
102
+ * @param {string} linked_data_proof_options
103
+ * @param {string} parents
104
+ * @param {string} key
105
+ * @returns {Promise<any>}
106
+ */
107
+ export function delegateCapability(capability: string, linked_data_proof_options: string, parents: string, key: string): Promise<any>;
108
+ /**
109
+ * @param {string} capability
110
+ * @param {string} linked_data_proof_options
111
+ * @param {string} parents
112
+ * @param {string} public_key
113
+ * @returns {Promise<any>}
114
+ */
115
+ export function prepareDelegateCapability(capability: string, linked_data_proof_options: string, parents: string, public_key: string): Promise<any>;
116
+ /**
117
+ * @param {string} capability
118
+ * @param {string} preparation
119
+ * @param {string} signature
120
+ * @returns {Promise<any>}
121
+ */
122
+ export function completeDelegateCapability(capability: string, preparation: string, signature: string): Promise<any>;
123
+ /**
124
+ * @param {string} delegation
125
+ * @returns {Promise<any>}
126
+ */
127
+ export function verifyDelegation(delegation: string): Promise<any>;
128
+ /**
129
+ * @param {string} invocation
130
+ * @param {string} target_id
131
+ * @param {string} linked_data_proof_options
132
+ * @param {string} key
133
+ * @returns {Promise<any>}
134
+ */
135
+ export function invokeCapability(invocation: string, target_id: string, linked_data_proof_options: string, key: string): Promise<any>;
136
+ /**
137
+ * @param {string} invocation
138
+ * @param {string} target_id
139
+ * @param {string} linked_data_proof_options
140
+ * @param {string} public_key
141
+ * @returns {Promise<any>}
142
+ */
143
+ export function prepareInvokeCapability(invocation: string, target_id: string, linked_data_proof_options: string, public_key: string): Promise<any>;
144
+ /**
145
+ * @param {string} invocation
146
+ * @param {string} preparation
147
+ * @param {string} signature
148
+ * @returns {Promise<any>}
149
+ */
150
+ export function completeInvokeCapability(invocation: string, preparation: string, signature: string): Promise<any>;
151
+ /**
152
+ * @param {string} invocation
153
+ * @returns {Promise<any>}
154
+ */
155
+ export function verifyInvocationSignature(invocation: string): Promise<any>;
156
+ /**
157
+ * @param {string} invocation
158
+ * @param {string} delegation
159
+ * @returns {Promise<any>}
160
+ */
161
+ export function verifyInvocation(invocation: string, delegation: string): Promise<any>;
162
+
163
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
164
+
165
+ export interface InitOutput {
166
+ readonly memory: WebAssembly.Memory;
167
+ readonly getVersion: (a: number) => void;
168
+ readonly resolveDID: (a: number, b: number, c: number, d: number) => number;
169
+ readonly generateEd25519Key: (a: number) => void;
170
+ readonly generateEd25519KeyFromBytes: (a: number, b: number, c: number) => void;
171
+ readonly keyToDID: (a: number, b: number, c: number, d: number, e: number) => void;
172
+ readonly keyToVerificationMethod: (a: number, b: number, c: number, d: number) => number;
173
+ readonly issueCredential: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
174
+ readonly prepareIssueCredential: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
175
+ readonly completeIssueCredential: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
176
+ readonly verifyCredential: (a: number, b: number, c: number, d: number) => number;
177
+ readonly issuePresentation: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
178
+ readonly prepareIssuePresentation: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
179
+ readonly completeIssuePresentation: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
180
+ readonly verifyPresentation: (a: number, b: number, c: number, d: number) => number;
181
+ readonly DIDAuth: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
182
+ readonly JWKFromTezos: (a: number, b: number) => number;
183
+ readonly delegateCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
184
+ readonly prepareDelegateCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
185
+ readonly completeDelegateCapability: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
186
+ readonly verifyDelegation: (a: number, b: number) => number;
187
+ readonly invokeCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
188
+ readonly prepareInvokeCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
189
+ readonly completeInvokeCapability: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
190
+ readonly verifyInvocationSignature: (a: number, b: number) => number;
191
+ readonly verifyInvocation: (a: number, b: number, c: number, d: number) => number;
192
+ readonly didkit_error_message: () => number;
193
+ readonly didkit_error_code: () => number;
194
+ readonly SHA1DCUpdate: (a: number, b: number, c: number) => void;
195
+ readonly sha1_compression_states: (a: number, b: number, c: number, d: number) => void;
196
+ readonly SHA1DCInit: (a: number) => void;
197
+ readonly SHA1DCSetSafeHash: (a: number, b: number) => void;
198
+ readonly SHA1DCSetUseUBC: (a: number, b: number) => void;
199
+ readonly SHA1DCSetUseDetectColl: (a: number, b: number) => void;
200
+ readonly SHA1DCSetDetectReducedRoundCollision: (a: number, b: number) => void;
201
+ readonly SHA1DCSetCallback: (a: number, b: number) => void;
202
+ readonly ubc_check: (a: number, b: number) => void;
203
+ readonly SHA1DCFinal: (a: number, b: number) => number;
204
+ readonly __wbindgen_malloc: (a: number) => number;
205
+ readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
206
+ readonly __wbindgen_export_2: WebAssembly.Table;
207
+ readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h91a8814f66f14b17: (a: number, b: number, c: number) => void;
208
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
209
+ readonly __wbindgen_free: (a: number, b: number) => void;
210
+ readonly __wbindgen_exn_store: (a: number) => void;
211
+ readonly wasm_bindgen__convert__closures__invoke2_mut__h3ecfeb7a01c1be81: (a: number, b: number, c: number, d: number) => void;
212
+ }
213
+
214
+ /**
215
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
216
+ * for everything else, calls `WebAssembly.instantiate` directly.
217
+ *
218
+ * @param {InitInput | Promise<InitInput>} module_or_path
219
+ *
220
+ * @returns {Promise<InitOutput>}
221
+ */
222
+ export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;