/
index.ts
38 lines (35 loc) · 1.17 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { toQrCode, fromQrCode } from '@digitalbazaar/vpqr';
import { VpqrPluginDependentMethods, VpqrPluginMethods } from './types';
import { Wallet, Plugin } from 'types/wallet';
export * from './types';
/**
* @group Plugins
*/
export const getVpqrPlugin = (
wallet: Wallet<string, VpqrPluginDependentMethods>
): Plugin<'Vpqr', VpqrPluginMethods> => {
return {
pluginMethods: {
vpFromQrCode: async (_wallet, text) => {
return (
await fromQrCode({
text,
documentLoader: async (url: string) => ({
document: await wallet.pluginMethods.contextLoader(url),
}),
})
)?.vp;
},
vpToQrCode: async (_wallet, vp) => {
return (
await toQrCode({
vp,
documentLoader: async (url: string) => ({
document: await wallet.pluginMethods.contextLoader(url),
}),
})
)?.imageDataUrl;
},
},
};
};