@learncard/vpqr-plugin 1.1.23 → 1.1.25

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/package.json CHANGED
@@ -1,57 +1,59 @@
1
1
  {
2
- "name": "@learncard/vpqr-plugin",
3
- "version": "1.1.23",
4
- "description": "",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/vpqr-plugin.esm.js",
8
- "exports": {
9
- ".": {
10
- "import": {
11
- "types": "./dist/index.d.ts",
12
- "default": "./dist/vpqr-plugin.esm.js"
13
- },
14
- "require": {
15
- "types": "./dist/index.d.cts",
16
- "default": "./dist/index.cjs"
17
- }
18
- }
19
- },
20
- "files": [
21
- "dist"
22
- ],
23
- "author": "Learning Economy Foundation (www.learningeconomy.io)",
24
- "license": "MIT",
25
- "homepage": "https://github.com/learningeconomy/LearnCard/tree/main/packages/plugins/vpqr/README.md",
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/learningeconomy/LearnCard"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/learningeconomy/LearnCard/issues"
32
- },
33
- "devDependencies": {
34
- "@types/jest": "^29.2.2",
35
- "@types/node": "^17.0.31",
36
- "aqu": "0.4.3",
37
- "esbuild": "^0.27.1",
38
- "esbuild-jest": "^0.5.0",
39
- "esbuild-plugin-copy": "^1.3.0",
40
- "jest": "^29.3.0",
41
- "shx": "^0.3.4",
42
- "ts-jest": "^29.0.3"
43
- },
44
- "types": "./dist/index.d.ts",
45
- "dependencies": {
46
- "@digitalbazaar/vpqr": "^3.0.0",
47
- "@learncard/core": "9.4.23",
48
- "@learncard/types": "5.17.3"
49
- },
50
- "sideEffects": false,
51
- "scripts": {
52
- "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",
53
- "test": "jest --passWithNoTests",
54
- "test:watch": "jest --watch",
55
- "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""
56
- }
57
- }
2
+ "name": "@learncard/vpqr-plugin",
3
+ "version": "1.1.25",
4
+ "description": "",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/vpqr-plugin.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "development": "./src/index.ts",
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/vpqr-plugin.esm.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "scripts": {
26
+ "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",
27
+ "test": "jest --passWithNoTests",
28
+ "test:watch": "jest --watch",
29
+ "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""
30
+ },
31
+ "author": "Learning Economy Foundation (www.learningeconomy.io)",
32
+ "license": "MIT",
33
+ "homepage": "https://github.com/learningeconomy/LearnCard/tree/main/packages/plugins/vpqr/README.md",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/learningeconomy/LearnCard"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/learningeconomy/LearnCard/issues"
40
+ },
41
+ "devDependencies": {
42
+ "@types/jest": "^29.2.2",
43
+ "@types/node": "^17.0.31",
44
+ "aqu": "0.4.3",
45
+ "esbuild": "^0.27.1",
46
+ "esbuild-jest": "^0.5.0",
47
+ "esbuild-plugin-copy": "^1.3.0",
48
+ "jest": "^29.3.0",
49
+ "shx": "^0.3.4",
50
+ "ts-jest": "^29.0.3"
51
+ },
52
+ "types": "./dist/index.d.ts",
53
+ "dependencies": {
54
+ "@digitalbazaar/vpqr": "^3.0.0",
55
+ "@learncard/core": "workspace:*",
56
+ "@learncard/types": "workspace:*"
57
+ },
58
+ "sideEffects": false
59
+ }
@@ -0,0 +1,23 @@
1
+ declare module '@digitalbazaar/vpqr' {
2
+ import { VP } from '@learncard/types';
3
+
4
+ function toQrCode(args: {
5
+ vp: VP;
6
+ documentLoader: (url: string) => Promise<{ document: Record<string, any> }>;
7
+ size?: number;
8
+ diagnose?: typeof console.log;
9
+ }): Promise<{
10
+ payload: string;
11
+ imageDataUrl: string;
12
+ encodedCborld: string;
13
+ rawCborldBytes: Uint8Array;
14
+ version: number;
15
+ }>;
16
+ function fromQrCode(args: {
17
+ text: string;
18
+ documentLoader: (url: string) => Promise<{ document: Record<string, any> }>;
19
+ diagnose?: typeof console.log;
20
+ }): Promise<{ vp: VP }>;
21
+ }
22
+
23
+ declare module 'qrcode-reader' { }
package/src/index.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { toQrCode, fromQrCode } from '@digitalbazaar/vpqr';
2
+
3
+ import { VpqrPlugin, VpqrPluginDependentMethods } from './types';
4
+ import { LearnCard } from '@learncard/core';
5
+
6
+ export * from './types';
7
+
8
+ /**
9
+ * @group Plugins
10
+ */
11
+ export const getVpqrPlugin = (
12
+ learnCard: LearnCard<any, any, VpqrPluginDependentMethods>
13
+ ): VpqrPlugin => {
14
+ return {
15
+ name: 'Vpqr',
16
+ displayName: 'VP QR',
17
+ description: 'Allows reading and creating QR codes with Verifiable Presentations in them',
18
+ methods: {
19
+ vpFromQrCode: async (_learnCard, text) => {
20
+ return (
21
+ await fromQrCode({
22
+ text,
23
+ documentLoader: async (url: string) => ({
24
+ document: await learnCard.invoke.contextLoader(url),
25
+ }),
26
+ })
27
+ )?.vp;
28
+ },
29
+ vpToQrCode: async (_learnCard, vp) => {
30
+ return (
31
+ await toQrCode({
32
+ vp,
33
+ documentLoader: async (url: string) => ({
34
+ document: await learnCard.invoke.contextLoader(url),
35
+ }),
36
+ })
37
+ )?.imageDataUrl;
38
+ },
39
+ },
40
+ };
41
+ };
package/src/types.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { VP } from '@learncard/types';
2
+ import { Plugin } from '@learncard/core';
3
+
4
+ /** @group VPQR Plugin */
5
+ export type VpqrPluginMethods = {
6
+ vpFromQrCode: (text: string) => Promise<VP>;
7
+ vpToQrCode: (vp: VP) => Promise<string>;
8
+ };
9
+
10
+ /** @group VPQR Plugin */
11
+ export type VpqrPluginDependentMethods = {
12
+ contextLoader: (url: string) => Promise<Record<string, any>>;
13
+ };
14
+
15
+ export type VpqrPlugin = Plugin<'Vpqr', any, VpqrPluginMethods, any, VpqrPluginDependentMethods>;