@learncard/lca-api-plugin 2.0.5 → 2.0.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/dist/lca-api-plugin.cjs.development.cjs +2 -1
- package/dist/lca-api-plugin.cjs.development.cjs.map +2 -2
- package/dist/lca-api-plugin.cjs.production.min.cjs +1 -1
- package/dist/lca-api-plugin.cjs.production.min.cjs.map +3 -3
- package/dist/lca-api-plugin.esm.js +2 -1
- package/dist/lca-api-plugin.esm.js.map +2 -2
- package/dist/plugin.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/plugin.ts +2 -1
- package/src/test/plugin-mode.test.ts +53 -0
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAG/D,cAAc,SAAS,CAAC;AA0DxB;;GAEG;AACH,eAAO,MAAM,YAAY,GACrB,kBAAkB,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,yBAAyB,CAAC,EACjE,KAAK,MAAM,EACX,uBAAqB,EACrB,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAG/D,cAAc,SAAS,CAAC;AA0DxB;;GAEG;AACH,eAAO,MAAM,YAAY,GACrB,kBAAkB,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,yBAAyB,CAAC,EACjE,KAAK,MAAM,EACX,uBAAqB,EACrB,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,CA+oBnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/lca-api-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
},
|
|
49
49
|
"types": "./dist/index.d.ts",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@learncard/core": "9.4.
|
|
52
|
-
"@learncard/didkit-plugin": "1.10.
|
|
53
|
-
"@learncard/init": "2.
|
|
51
|
+
"@learncard/core": "9.4.36",
|
|
52
|
+
"@learncard/didkit-plugin": "1.10.1",
|
|
53
|
+
"@learncard/init": "2.5.0",
|
|
54
54
|
"@learncard/lca-api-client": "1.2.5",
|
|
55
|
-
"@learncard/types": "5.
|
|
55
|
+
"@learncard/types": "5.21.0",
|
|
56
56
|
"hex-lite": "^1.5.0",
|
|
57
57
|
"isomorphic-fetch": "^3.0.0",
|
|
58
58
|
"isomorphic-webcrypto": "^2.3.8",
|
package/src/plugin.ts
CHANGED
|
@@ -107,9 +107,10 @@ export const getLCAPlugin = async (
|
|
|
107
107
|
);
|
|
108
108
|
})
|
|
109
109
|
.catch(error => {
|
|
110
|
-
console.warn('[LCA Plugin] Initialization warning:', error);
|
|
111
110
|
// Continue without encryption JWK if initialization fails
|
|
112
111
|
// This allows the plugin methods to still work even if initial setup has issues
|
|
112
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
113
|
+
console.warn(`[LCA Plugin] Initialization warning: ${message}`);
|
|
113
114
|
});
|
|
114
115
|
|
|
115
116
|
return {
|
|
@@ -13,6 +13,59 @@ const learnCard = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
describe('getLCAPlugin', () => {
|
|
16
|
+
it.each([undefined, { profileId: 'alice' }])(
|
|
17
|
+
'loads the encryption key with profile %j',
|
|
18
|
+
async profile => {
|
|
19
|
+
const key = { kty: 'OKP', crv: 'Ed25519', x: 'public', d: 'private' };
|
|
20
|
+
const query = vi.fn().mockResolvedValue('ab'.repeat(32));
|
|
21
|
+
const card = {
|
|
22
|
+
...learnCard,
|
|
23
|
+
invoke: {
|
|
24
|
+
getProfile: vi.fn().mockResolvedValue(profile),
|
|
25
|
+
generateEd25519KeyFromBytes: vi.fn().mockResolvedValue(key),
|
|
26
|
+
decryptDagJwe: vi.fn().mockResolvedValue('decrypted'),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
mockedGetClient.mockResolvedValue({
|
|
30
|
+
utilities: { getEncryptionKey: { query } },
|
|
31
|
+
} as never);
|
|
32
|
+
const plugin = await getLCAPlugin(card as never, 'https://example.com/trpc');
|
|
33
|
+
await plugin.methods.decryptDagJwe(card as never, {} as never);
|
|
34
|
+
expect(query).toHaveBeenCalledOnce();
|
|
35
|
+
expect(card.invoke.generateEd25519KeyFromBytes).toHaveBeenCalledWith(
|
|
36
|
+
new Uint8Array(32).fill(171)
|
|
37
|
+
);
|
|
38
|
+
expect(card.invoke.decryptDagJwe).toHaveBeenCalledWith({}, [key]);
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
it('warns concisely and continues when profileless key initialization fails', async () => {
|
|
43
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
44
|
+
try {
|
|
45
|
+
const card = {
|
|
46
|
+
...learnCard,
|
|
47
|
+
invoke: {
|
|
48
|
+
getProfile: vi.fn().mockResolvedValue(undefined),
|
|
49
|
+
decryptDagJwe: vi.fn().mockResolvedValue('decrypted'),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
mockedGetClient.mockResolvedValue({
|
|
53
|
+
utilities: {
|
|
54
|
+
getEncryptionKey: {
|
|
55
|
+
query: vi.fn().mockRejectedValue(new Error('connection failed')),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
} as never);
|
|
59
|
+
const plugin = await getLCAPlugin(card as never, 'https://example.com/trpc');
|
|
60
|
+
await plugin.methods.decryptDagJwe(card as never, {} as never);
|
|
61
|
+
expect(warn).toHaveBeenCalledWith(
|
|
62
|
+
'[LCA Plugin] Initialization warning: connection failed'
|
|
63
|
+
);
|
|
64
|
+
expect(card.invoke.decryptDagJwe).toHaveBeenCalledWith({}, []);
|
|
65
|
+
} finally {
|
|
66
|
+
warn.mockRestore();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
16
69
|
beforeEach(() => {
|
|
17
70
|
mockedGetClient.mockReset();
|
|
18
71
|
});
|