@learncard/didkit-plugin 1.9.4 → 1.9.6

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/README.md CHANGED
@@ -9,25 +9,26 @@
9
9
  The LearnCard Core is a pluggable, open-source, universal digital wallet to enable any individual or organization to seamlessly **issue, earn, store, share, and spend currency and credentials** built for the future of education and work.
10
10
 
11
11
  ## Documentation
12
+
12
13
  All LearnCard documentation can be found at:
13
14
  https://docs.learncard.com
14
15
 
15
16
  ## Install
16
17
 
17
18
  ```bash
18
- pnpm i @learncard/core
19
+ bun add @learncard/core
19
20
  ```
20
21
 
21
22
  ## Usage
22
23
 
23
24
  ### Instantiation
24
25
 
25
- Instantiate a wallet using `initLearnCard`. This method accepts a unique identifier string that is
26
+ Instantiate a wallet using `initLearnCard`. This method accepts a unique identifier string that is
26
27
  up to 64 characters long. If it is less than 64 characters, `initLearnCard` will pad the start of
27
28
  the string with 0's until it is 64 characters long.
28
29
 
29
30
  ```js
30
- import { initLearnCard } from "@learncard/core";
31
+ import { initLearnCard } from '@learncard/core';
31
32
 
32
33
  const wallet = await initLearnCard({ seed: 'a'.repeat(64) });
33
34
  ```
@@ -35,6 +36,7 @@ const wallet = await initLearnCard({ seed: 'a'.repeat(64) });
35
36
  ### Issuing/Verifying Credentials and Presentations
36
37
 
37
38
  #### Issue a credential
39
+
38
40
  ```js
39
41
  // Grab a test VC, or create your own!
40
42
  const unsignedVc = await wallet.invoke.getTestVc();
@@ -43,6 +45,7 @@ const vc = await wallet.invoke.issueCredential(unsignedVc);
43
45
  ```
44
46
 
45
47
  #### Verify a credential
48
+
46
49
  ```js
47
50
  const result = await wallet.invoke.verifyCredential(vc, {}, true);
48
51
 
@@ -53,11 +56,13 @@ else console.log('This credential is valid!');
53
56
  ```
54
57
 
55
58
  #### Issue a presentation
59
+
56
60
  ```js
57
61
  const vp = await wallet.invoke.issuePresentation(vc);
58
62
  ```
59
63
 
60
64
  #### Verify a presentation
65
+
61
66
  ```js
62
67
  const result = await wallet.invoke.verifyPresentation(vp);
63
68
 
@@ -74,14 +79,14 @@ else console.log('This presentation is valid!');
74
79
  To maintain co-ownership of credentials, it is best to store credentials in a public place, and then
75
80
  store references to that public place. While this is not the only way to store credentials (and is
76
81
  also definitely not a silver bullet! E.g. credentials containing private data), it is the opinion of
77
- this library that it should be used by default. As a result, instantiating a wallet, will
78
- automatically connect you to WeLibrary's ceramic node, and allow you to publish and retrieve
82
+ this library that it should be used by default. As a result, instantiating a wallet, will
83
+ automatically connect you to WeLibrary's ceramic node, and allow you to publish and retrieve
79
84
  credentials there using IDX.
80
85
 
81
86
  #### Publish Credential
82
87
 
83
88
  After signing a VC, you may choose to publish that credential to Ceramic. Doing so will return a
84
- stream ID, which you may share to the recipient. That stream ID can then be used to resolve the
89
+ stream ID, which you may share to the recipient. That stream ID can then be used to resolve the
85
90
  issued credential. This means both the issuer and recipient may store the _stream ID_ instead of the
86
91
  credential itself.
87
92
 
@@ -126,6 +131,7 @@ const vcs = await Promise.all(uris.map(async uri => wallet.read.get(uri)));
126
131
  ```
127
132
 
128
133
  ## Contributing
134
+
129
135
  Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
130
136
 
131
137
  Please make sure to update tests as appropriate.
@@ -134,7 +140,6 @@ Please make sure to update tests as appropriate.
134
140
 
135
141
  **[Learning Economy Foundation (LEF)](https://www.learningeconomy.io)** is a 501(c)(3) non-profit organization leveraging global standards and web3 protocols to bring quality skills and equal opportunity to every human on earth, and address the persistent inequities that exist around the globe in education and employment. We help you build the future of education and work with:
136
142
 
137
-
138
143
  ## License
139
144
 
140
145
  MIT © [Learning Economy Foundation](https://github.com/Learning-Economy-Foundation)
package/package.json CHANGED
@@ -1,59 +1,67 @@
1
1
  {
2
- "name": "@learncard/didkit-plugin",
3
- "version": "1.9.4",
4
- "description": "",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/didkit-plugin.esm.js",
8
- "exports": {
9
- ".": {
10
- "import": {
11
- "types": "./dist/index.d.ts",
12
- "default": "./dist/didkit-plugin.esm.js"
13
- },
14
- "require": {
15
- "types": "./dist/index.d.cts",
16
- "default": "./dist/index.cjs"
17
- }
2
+ "name": "@learncard/didkit-plugin",
3
+ "version": "1.9.6",
4
+ "description": "",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/didkit-plugin.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "development": "./src/index.ts",
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/didkit-plugin.esm.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "./dist/didkit_wasm_bg.wasm": {
21
+ "development": "./src/didkit/pkg/didkit_wasm_bg.wasm",
22
+ "default": "./dist/didkit_wasm_bg.wasm"
23
+ },
24
+ "./dist/didkit/didkit_wasm_bg.wasm": {
25
+ "development": "./src/didkit/pkg/didkit_wasm_bg.wasm",
26
+ "default": "./dist/didkit/didkit_wasm_bg.wasm"
27
+ }
18
28
  },
19
- "./dist/didkit_wasm_bg.wasm": "./dist/didkit_wasm_bg.wasm",
20
- "./dist/didkit/didkit_wasm_bg.wasm": "./dist/didkit/didkit_wasm_bg.wasm"
21
- },
22
- "files": [
23
- "dist"
24
- ],
25
- "author": "Learning Economy Foundation (www.learningeconomy.io)",
26
- "license": "MIT",
27
- "homepage": "https://github.com/learningeconomy/LearnCard/tree/main/packages/plugins/didkit/README.md",
28
- "repository": {
29
- "type": "git",
30
- "url": "https://github.com/learningeconomy/LearnCard"
31
- },
32
- "bugs": {
33
- "url": "https://github.com/learningeconomy/LearnCard/issues"
34
- },
35
- "devDependencies": {
36
- "@types/jest": "^29.2.2",
37
- "@types/node": "^17.0.31",
38
- "aqu": "0.4.3",
39
- "dids": "^3.2.0",
40
- "esbuild": "^0.27.1",
41
- "esbuild-jest": "^0.5.0",
42
- "esbuild-plugin-copy": "^1.6.0",
43
- "jest": "^29.3.0",
44
- "shx": "^0.3.4",
45
- "ts-jest": "^29.0.3"
46
- },
47
- "types": "./dist/index.d.ts",
48
- "dependencies": {
49
- "@learncard/core": "9.4.24",
50
- "@learncard/types": "5.17.4"
51
- },
52
- "sideEffects": false,
53
- "scripts": {
54
- "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.cjs && tsc --p tsconfig.json && shx cp ./dist/index.d.ts ./dist/index.d.cts",
55
- "test": "jest --passWithNoTests",
56
- "test:watch": "jest --watch",
57
- "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""
58
- }
59
- }
29
+ "files": [
30
+ "dist",
31
+ "src"
32
+ ],
33
+ "scripts": {
34
+ "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.cjs && tsc --p tsconfig.json && shx cp ./dist/index.d.ts ./dist/index.d.cts",
35
+ "test": "jest --passWithNoTests",
36
+ "test:watch": "jest --watch",
37
+ "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""
38
+ },
39
+ "author": "Learning Economy Foundation (www.learningeconomy.io)",
40
+ "license": "MIT",
41
+ "homepage": "https://github.com/learningeconomy/LearnCard/tree/main/packages/plugins/didkit/README.md",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/learningeconomy/LearnCard"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/learningeconomy/LearnCard/issues"
48
+ },
49
+ "devDependencies": {
50
+ "@types/jest": "^29.2.2",
51
+ "@types/node": "^17.0.31",
52
+ "aqu": "0.4.3",
53
+ "dids": "^3.2.0",
54
+ "esbuild": "^0.27.1",
55
+ "esbuild-jest": "^0.5.0",
56
+ "esbuild-plugin-copy": "^1.6.0",
57
+ "jest": "^29.3.0",
58
+ "shx": "^0.3.4",
59
+ "ts-jest": "^29.0.3"
60
+ },
61
+ "types": "./dist/index.d.ts",
62
+ "dependencies": {
63
+ "@learncard/core": "9.4.26",
64
+ "@learncard/types": "5.17.5"
65
+ },
66
+ "sideEffects": false
67
+ }
@@ -0,0 +1,31 @@
1
+ import _init, { InitInput } from './pkg/didkit_wasm';
2
+
3
+ export * from './pkg/didkit_wasm';
4
+
5
+ let initialized = false;
6
+ let generating = false; // Mutex flag to allow first init call to acquire a lock
7
+
8
+ export const init = async (
9
+ arg: InitInput | Promise<InitInput> = 'https://cdn.filestackcontent.com/6v059q3KQlmXd6XoVPyC'
10
+ ) => {
11
+ // Do not return until we are done generating!
12
+ while (generating) await new Promise(res => setTimeout(res, 250));
13
+
14
+ // allow calling multiple times without reinitializing
15
+ if (initialized) return;
16
+
17
+ try {
18
+ generating = true;
19
+
20
+ await _init({ module_or_path: arg });
21
+
22
+ generating = false;
23
+ initialized = true;
24
+ } catch (error) {
25
+ generating = false;
26
+
27
+ throw error;
28
+ }
29
+ };
30
+
31
+ export default init;
@@ -0,0 +1,112 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export function verifyInvocationSignature(invocation: string): Promise<any>;
4
+ export function keyToDID(method_pattern: string, jwk: string): string;
5
+ export function completeDelegateCapability(capability: string, preparation: string, signature: string): Promise<any>;
6
+ export function keyToVerificationMethod(method_pattern: string, jwk: string): Promise<any>;
7
+ export function prepareIssueCredential(credential: string, linked_data_proof_options: string, public_key: string): Promise<any>;
8
+ export function invokeCapability(invocation: string, target_id: string, linked_data_proof_options: string, key: string): Promise<any>;
9
+ export function generateSecp256k1KeyFromBytes(bytes: Uint8Array): string;
10
+ export function completeIssueCredential(credential: string, preparation: string, signature: string): Promise<any>;
11
+ export function generateSecp256k1Key(): string;
12
+ export function delegateCapability(capability: string, linked_data_proof_options: string, parents: string, key: string): Promise<any>;
13
+ export function prepareDelegateCapability(capability: string, linked_data_proof_options: string, parents: string, public_key: string): Promise<any>;
14
+ export function createDagJwe(cleartext: any, recipients: string[]): Promise<any>;
15
+ export function completeInvokeCapability(invocation: string, preparation: string, signature: string): Promise<any>;
16
+ export function verifyDelegation(delegation: string): Promise<any>;
17
+ export function didToVerificationMethod(did: string): Promise<any>;
18
+ export function verifyPresentation(vp: string, proof_options: string, context_map: string): Promise<any>;
19
+ export function prepareIssuePresentation(presentation: string, linked_data_proof_options: string, public_key: string): Promise<any>;
20
+ export function issueCredential(credential: string, proof_options: string, key: string, context_map: string): Promise<any>;
21
+ export function didResolver(did: string, input_metadata: string): Promise<any>;
22
+ export function createJwe(cleartext: string, recipients: string[]): Promise<any>;
23
+ export function prepareInvokeCapability(invocation: string, target_id: string, linked_data_proof_options: string, public_key: string): Promise<any>;
24
+ export function decryptJwe(jwe: string, jwks: string[]): Promise<any>;
25
+ export function JWKFromTezos(tz: string): Promise<any>;
26
+ export function generateEd25519Key(): string;
27
+ export function issuePresentation(presentation: string, proof_options: string, key: string, context_map: string): Promise<any>;
28
+ export function clearCache(): Promise<any>;
29
+ export function verifyCredential(vc: string, proof_options: string, context_map: string): Promise<any>;
30
+ export function resolveDID(did: string, input_metadata: string): Promise<any>;
31
+ export function contextLoader(url: string): Promise<any>;
32
+ export function verifyInvocation(invocation: string, delegation: string): Promise<any>;
33
+ export function generateEd25519KeyFromBytes(bytes: Uint8Array): string;
34
+ export function decryptDagJwe(jwe: string, jwks: string[]): Promise<any>;
35
+ export function DIDAuth(holder: string, linked_data_proof_options: string, key: string, context_map: string): Promise<any>;
36
+ export function completeIssuePresentation(presentation: string, preparation: string, signature: string): Promise<any>;
37
+ export function getVersion(): string;
38
+
39
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
40
+
41
+ export interface InitOutput {
42
+ readonly memory: WebAssembly.Memory;
43
+ readonly DIDAuth: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
44
+ readonly JWKFromTezos: (a: number, b: number) => any;
45
+ readonly clearCache: () => any;
46
+ readonly completeDelegateCapability: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
47
+ readonly completeInvokeCapability: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
48
+ readonly completeIssueCredential: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
49
+ readonly completeIssuePresentation: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
50
+ readonly contextLoader: (a: number, b: number) => any;
51
+ readonly createDagJwe: (a: any, b: number, c: number) => any;
52
+ readonly createJwe: (a: number, b: number, c: number, d: number) => any;
53
+ readonly decryptDagJwe: (a: number, b: number, c: number, d: number) => any;
54
+ readonly decryptJwe: (a: number, b: number, c: number, d: number) => any;
55
+ readonly delegateCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
56
+ readonly didResolver: (a: number, b: number, c: number, d: number) => any;
57
+ readonly didToVerificationMethod: (a: number, b: number) => any;
58
+ readonly generateEd25519Key: () => [number, number, number, number];
59
+ readonly generateEd25519KeyFromBytes: (a: number, b: number) => [number, number, number, number];
60
+ readonly generateSecp256k1Key: () => [number, number, number, number];
61
+ readonly generateSecp256k1KeyFromBytes: (a: number, b: number) => [number, number, number, number];
62
+ readonly getVersion: () => [number, number];
63
+ readonly invokeCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
64
+ readonly issueCredential: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
65
+ readonly issuePresentation: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
66
+ readonly keyToDID: (a: number, b: number, c: number, d: number) => [number, number, number, number];
67
+ readonly keyToVerificationMethod: (a: number, b: number, c: number, d: number) => any;
68
+ readonly prepareDelegateCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
69
+ readonly prepareInvokeCapability: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
70
+ readonly prepareIssueCredential: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
71
+ readonly prepareIssuePresentation: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
72
+ readonly resolveDID: (a: number, b: number, c: number, d: number) => any;
73
+ readonly verifyCredential: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
74
+ readonly verifyDelegation: (a: number, b: number) => any;
75
+ readonly verifyInvocation: (a: number, b: number, c: number, d: number) => any;
76
+ readonly verifyInvocationSignature: (a: number, b: number) => any;
77
+ readonly verifyPresentation: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
78
+ readonly didkit_error_code: () => number;
79
+ readonly didkit_error_message: () => number;
80
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
81
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
82
+ readonly __wbindgen_exn_store: (a: number) => void;
83
+ readonly __externref_table_alloc: () => number;
84
+ readonly __wbindgen_export_4: WebAssembly.Table;
85
+ readonly __wbindgen_export_5: WebAssembly.Table;
86
+ readonly __externref_table_dealloc: (a: number) => void;
87
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
88
+ readonly closure4149_externref_shim: (a: number, b: number, c: any) => void;
89
+ readonly closure4546_externref_shim: (a: number, b: number, c: any, d: any) => void;
90
+ readonly __wbindgen_start: () => void;
91
+ }
92
+
93
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
94
+ /**
95
+ * Instantiates the given `module`, which can either be bytes or
96
+ * a precompiled `WebAssembly.Module`.
97
+ *
98
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
99
+ *
100
+ * @returns {InitOutput}
101
+ */
102
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
103
+
104
+ /**
105
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
106
+ * for everything else, calls `WebAssembly.instantiate` directly.
107
+ *
108
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
109
+ *
110
+ * @returns {Promise<InitOutput>}
111
+ */
112
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;