@docknetwork/wallet-sdk-core 1.5.14 → 1.7.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/.claude/settings.local.json +12 -0
- package/generate-docs.js +33 -0
- package/jsdoc.conf.json +28 -0
- package/lib/biometric-provider.d.ts +124 -32
- package/lib/biometric-provider.d.ts.map +1 -1
- package/lib/biometric-provider.js +146 -7
- package/lib/biometric-provider.js.map +1 -1
- package/lib/cloud-wallet.d.ts +8 -6
- package/lib/cloud-wallet.d.ts.map +1 -1
- package/lib/cloud-wallet.js +41 -57
- package/lib/cloud-wallet.js.map +1 -1
- package/lib/credential-provider.d.ts +58 -33
- package/lib/credential-provider.d.ts.map +1 -1
- package/lib/credential-provider.js +212 -11
- package/lib/credential-provider.js.map +1 -1
- package/lib/credentials/oidvc.js +4 -5
- package/lib/credentials/oidvc.js.map +1 -1
- package/lib/did-provider.d.ts +102 -36
- package/lib/did-provider.d.ts.map +1 -1
- package/lib/did-provider.js +185 -27
- package/lib/did-provider.js.map +1 -1
- package/lib/ecosystem-tools.js +4 -5
- package/lib/ecosystem-tools.js.map +1 -1
- package/lib/helpers.js +6 -6
- package/lib/helpers.js.map +1 -1
- package/lib/message-provider.d.ts +39 -13
- package/lib/message-provider.d.ts.map +1 -1
- package/lib/message-provider.js +173 -22
- package/lib/message-provider.js.map +1 -1
- package/lib/messages/message-helpers.js +6 -6
- package/lib/messages/message-helpers.js.map +1 -1
- package/lib/network-resolver.js +5 -5
- package/lib/network-resolver.js.map +1 -1
- package/lib/qr-handlers/builtin/index.d.ts +30 -0
- package/lib/qr-handlers/builtin/index.d.ts.map +1 -0
- package/lib/qr-handlers/builtin/index.js +46 -0
- package/lib/qr-handlers/builtin/index.js.map +1 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.d.ts +137 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.d.ts.map +1 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.js +134 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.js.map +1 -0
- package/lib/qr-handlers/index.d.ts +76 -0
- package/lib/qr-handlers/index.d.ts.map +1 -0
- package/lib/qr-handlers/index.js +92 -0
- package/lib/qr-handlers/index.js.map +1 -0
- package/lib/qr-handlers/processor.d.ts +110 -0
- package/lib/qr-handlers/processor.d.ts.map +1 -0
- package/lib/qr-handlers/processor.js +251 -0
- package/lib/qr-handlers/processor.js.map +1 -0
- package/lib/qr-handlers/types.d.ts +205 -0
- package/lib/qr-handlers/types.d.ts.map +1 -0
- package/lib/qr-handlers/types.js +10 -0
- package/lib/qr-handlers/types.js.map +1 -0
- package/lib/types.d.ts +613 -13
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +16 -0
- package/lib/types.js.map +1 -1
- package/lib/verification-controller.d.ts +3 -4
- package/lib/verification-controller.d.ts.map +1 -1
- package/lib/verification-controller.js +10 -3
- package/lib/verification-controller.js.map +1 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts +0 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts.map +1 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js +2 -2
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js.map +1 -1
- package/lib/wallet-wasm.d.ts +2 -2
- package/lib/wallet-wasm.d.ts.map +1 -1
- package/lib/wallet-wasm.js +15 -17
- package/lib/wallet-wasm.js.map +1 -1
- package/lib/wallet.d.ts +36 -20
- package/lib/wallet.d.ts.map +1 -1
- package/lib/wallet.js +172 -26
- package/lib/wallet.js.map +1 -1
- package/package.json +19 -11
- package/src/biometric-provider.ts +157 -42
- package/src/cloud-wallet.ts +21 -60
- package/src/credential-provider.test.ts +191 -1
- package/src/credential-provider.ts +208 -27
- package/src/did-provider.ts +183 -34
- package/src/message-provider.ts +177 -38
- package/src/qr-handlers/builtin/index.ts +30 -0
- package/src/qr-handlers/builtin/oid4vc-handler.ts +198 -0
- package/src/qr-handlers/index.ts +76 -0
- package/src/qr-handlers/processor.test.ts +514 -0
- package/src/qr-handlers/processor.ts +311 -0
- package/src/qr-handlers/types.ts +228 -0
- package/src/types.ts +671 -11
- package/src/verification-controller.test.ts +1 -2
- package/src/verification-controller.ts +14 -2
- package/src/wallet-wasm.ts +5 -8
- package/src/wallet.ts +173 -24
- package/tsconfig.build.tsbuildinfo +1 -1
package/generate-docs.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const jsdoc2md = require('jsdoc-to-markdown');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
async function generateMarkdownDocs() {
|
|
8
|
+
console.log('Generating markdown documentation...');
|
|
9
|
+
|
|
10
|
+
const outputDir = path.resolve('../../docs/api');
|
|
11
|
+
if (!fs.existsSync(outputDir)) {
|
|
12
|
+
fs.mkdirSync(outputDir, {recursive: true});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const outputFile = path.join(outputDir, 'core.md');
|
|
16
|
+
|
|
17
|
+
const output = await jsdoc2md.render({
|
|
18
|
+
files: ['./src/**/*.ts'],
|
|
19
|
+
configure: './jsdoc.conf.json',
|
|
20
|
+
'no-cache': true,
|
|
21
|
+
template: `# Wallet SDK Core API Documentation
|
|
22
|
+
|
|
23
|
+
{{>main}}
|
|
24
|
+
`,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Ensure we have substantial content
|
|
28
|
+
fs.writeFileSync(outputFile, output);
|
|
29
|
+
console.log(`✅ API documentation generated successfully: ${outputFile}`);
|
|
30
|
+
console.log(`📄 Generated ${output.length} characters of documentation`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
generateMarkdownDocs();
|
package/jsdoc.conf.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": {
|
|
3
|
+
"includePattern": ".+\\.ts$",
|
|
4
|
+
"exclude": ["node_modules", "lib", "fixtures"]
|
|
5
|
+
},
|
|
6
|
+
"opts": {
|
|
7
|
+
"destination": "./jsdocs/",
|
|
8
|
+
"recurse": true
|
|
9
|
+
},
|
|
10
|
+
"plugins": [
|
|
11
|
+
"plugins/markdown",
|
|
12
|
+
"jsdoc-babel"
|
|
13
|
+
],
|
|
14
|
+
"babel": {
|
|
15
|
+
"extensions": ["ts"],
|
|
16
|
+
"ignore": ["**/*.(test|spec).ts"],
|
|
17
|
+
"babelrc": false,
|
|
18
|
+
"presets": [["@babel/preset-typescript", { "allExtensions": true }]]
|
|
19
|
+
},
|
|
20
|
+
"templates": {
|
|
21
|
+
"cleverLinks": false,
|
|
22
|
+
"monospaceLinks": false
|
|
23
|
+
},
|
|
24
|
+
"tags": {
|
|
25
|
+
"allowUnknownTags": true,
|
|
26
|
+
"dictionaries": ["jsdoc", "closure"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,28 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module biometric-provider
|
|
3
|
+
* @description Biometric plugin for the Truvera Wallet SDK.
|
|
4
|
+
* This module provides functions for biometric enrollment, matching, and identity verification processes.
|
|
5
|
+
*/
|
|
6
|
+
import { IWallet, BiometricsProviderConfigs, IDVProcessOptions, BiometricPlugin, IDVProvider, IDVProviderFactory, IBiometricProvider } from './types';
|
|
7
|
+
export type { BiometricsProviderConfigs, IDVProcessOptions, BiometricPlugin, IDVProvider, IDVProviderFactory, IBiometricProvider, };
|
|
4
8
|
import { Credential } from './credential-provider';
|
|
5
9
|
import { EventEmitter } from 'events';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
10
|
+
/**
|
|
11
|
+
* Sets the global biometric provider configurations for the SDK
|
|
12
|
+
* @param {BiometricsProviderConfigs<unknown>} configs - The biometric provider configurations to set
|
|
13
|
+
* @param {string} configs.enrollmentCredentialType - The credential type for enrollment
|
|
14
|
+
* @param {string} configs.biometricMatchCredentialType - The credential type for biometric matching
|
|
15
|
+
* @param {any} [configs.idvProvider] - Optional IDV provider configuration
|
|
16
|
+
* @example
|
|
17
|
+
* import { setConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
18
|
+
*
|
|
19
|
+
* setConfigs({
|
|
20
|
+
* enrollmentCredentialType: 'BiometricEnrollment',
|
|
21
|
+
* biometricMatchCredentialType: 'BiometricMatch',
|
|
22
|
+
* idvProvider: myIDVProviderConfig
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
22
25
|
export declare function setConfigs(configs: BiometricsProviderConfigs<unknown>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the biometric plugin is enabled by verifying if biometric match credential type is configured
|
|
28
|
+
* @returns {boolean} True if biometric match credential type is configured, false otherwise
|
|
29
|
+
* @example
|
|
30
|
+
* import { isBiometricPluginEnabled, setConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
31
|
+
*
|
|
32
|
+
* // Before configuration
|
|
33
|
+
* console.log(isBiometricPluginEnabled()); // false
|
|
34
|
+
*
|
|
35
|
+
* // After configuration
|
|
36
|
+
* setConfigs({
|
|
37
|
+
* enrollmentCredentialType: 'BiometricEnrollment',
|
|
38
|
+
* biometricMatchCredentialType: 'BiometricMatch'
|
|
39
|
+
* });
|
|
40
|
+
* console.log(isBiometricPluginEnabled()); // true
|
|
41
|
+
*/
|
|
23
42
|
export declare function isBiometricPluginEnabled(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Asserts that biometric provider configurations are available
|
|
45
|
+
* @throws {Error} If biometric provider configs are not set
|
|
46
|
+
* @example
|
|
47
|
+
* import { assertConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
48
|
+
*
|
|
49
|
+
* try {
|
|
50
|
+
* assertConfigs();
|
|
51
|
+
* console.log('Biometric configs are available');
|
|
52
|
+
* } catch (error) {
|
|
53
|
+
* console.error('Biometric configs missing:', error.message);
|
|
54
|
+
* }
|
|
55
|
+
*/
|
|
24
56
|
export declare function assertConfigs(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the current biometric provider configurations
|
|
59
|
+
* @returns {BiometricsProviderConfigs<unknown>} The current biometric provider configurations
|
|
60
|
+
* @throws {Error} If biometric provider configs are not set
|
|
61
|
+
* @example
|
|
62
|
+
* import { getBiometricConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
63
|
+
*
|
|
64
|
+
* try {
|
|
65
|
+
* const configs = getBiometricConfigs();
|
|
66
|
+
* console.log('Enrollment credential type:', configs.enrollmentCredentialType);
|
|
67
|
+
* console.log('Match credential type:', configs.biometricMatchCredentialType);
|
|
68
|
+
* } catch (error) {
|
|
69
|
+
* console.error('Failed to get configs:', error.message);
|
|
70
|
+
* }
|
|
71
|
+
*/
|
|
25
72
|
export declare function getBiometricConfigs(): BiometricsProviderConfigs<unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a proof request requires biometric credentials
|
|
75
|
+
* @param {any} proofRequest - The proof request to analyze
|
|
76
|
+
* @returns {boolean} True if the proof request requires biometric credentials
|
|
77
|
+
* @example
|
|
78
|
+
* import { hasProofOfBiometrics } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
79
|
+
*
|
|
80
|
+
* const proofRequest = {
|
|
81
|
+
* input_descriptors: [{
|
|
82
|
+
* constraints: {
|
|
83
|
+
* fields: [{
|
|
84
|
+
* path: ['$.credentialSubject.biometric.id']
|
|
85
|
+
* }, {
|
|
86
|
+
* path: ['$.credentialSubject.biometric.created']
|
|
87
|
+
* }]
|
|
88
|
+
* }
|
|
89
|
+
* }]
|
|
90
|
+
* };
|
|
91
|
+
*
|
|
92
|
+
* if (hasProofOfBiometrics(proofRequest)) {
|
|
93
|
+
* console.log('This proof request requires biometric verification');
|
|
94
|
+
* }
|
|
95
|
+
*/
|
|
26
96
|
export declare function hasProofOfBiometrics(proofRequest: any): any;
|
|
27
97
|
export declare const IDV_EVENTS: {
|
|
28
98
|
onDeepLink: string;
|
|
@@ -31,26 +101,48 @@ export declare const IDV_EVENTS: {
|
|
|
31
101
|
onCancel: string;
|
|
32
102
|
onComplete: string;
|
|
33
103
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Creates a biometric provider instance for identity verification and biometric credential management
|
|
106
|
+
* @param {Object} params - Provider configuration
|
|
107
|
+
* @param {IWallet} params.wallet - The wallet instance to use for credential storage
|
|
108
|
+
* @param {IDVProviderFactory} params.idvProviderFactory - Factory for creating IDV provider instances
|
|
109
|
+
* @returns {IBiometricProvider} A biometric provider instance with identity verification methods
|
|
110
|
+
* @throws {Error} If wallet or idvProviderFactory is not provided
|
|
111
|
+
* @see {@link IBiometricProvider} - The interface defining all available biometric provider methods
|
|
112
|
+
* @example
|
|
113
|
+
* import { createBiometricProvider } from '@docknetwork/wallet-sdk-core';
|
|
114
|
+
*
|
|
115
|
+
* const biometricProvider = createBiometricProvider({
|
|
116
|
+
* wallet,
|
|
117
|
+
* idvProviderFactory: myIDVFactory
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* // Start identity verification process
|
|
121
|
+
* const result = await biometricProvider.startIDV(proofRequest);
|
|
122
|
+
* console.log('Enrollment credential:', result.enrollmentCredential);
|
|
123
|
+
* console.log('Match credential:', result.matchCredential);
|
|
124
|
+
*
|
|
125
|
+
* // Listen for IDV events
|
|
126
|
+
* biometricProvider.eventEmitter.on('onComplete', (data) => {
|
|
127
|
+
* console.log('IDV process completed:', data);
|
|
128
|
+
* });
|
|
129
|
+
*/
|
|
46
130
|
export declare function createBiometricProvider({ wallet, idvProviderFactory, }: {
|
|
47
131
|
wallet: IWallet;
|
|
48
132
|
idvProviderFactory: IDVProviderFactory;
|
|
49
133
|
}): {
|
|
134
|
+
/**
|
|
135
|
+
* Starts the identity verification process using biometric credentials
|
|
136
|
+
* @memberof IBiometricProvider
|
|
137
|
+
*/
|
|
50
138
|
startIDV: (proofRequest: any) => Promise<{
|
|
51
139
|
enrollmentCredential: Credential;
|
|
52
140
|
matchCredential: Credential;
|
|
53
141
|
}>;
|
|
54
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Event emitter for IDV process events (onDeepLink, onMessage, onError, onCancel, onComplete)
|
|
144
|
+
* @memberof IBiometricProvider
|
|
145
|
+
*/
|
|
146
|
+
eventEmitter: EventEmitter<[never]>;
|
|
55
147
|
};
|
|
56
148
|
//# sourceMappingURL=biometric-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biometric-provider.d.ts","sourceRoot":"","sources":["../src/biometric-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"biometric-provider.d.ts","sourceRoot":"","sources":["../src/biometric-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,OAAO,EACP,yBAAyB,EACzB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,yBAAyB,EACzB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,kBAAkB,GACnB,CAAC;AACF,OAAO,EAEL,UAAU,EAEX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAKpC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,QAErE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,YAEvC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,SAE5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,uCAGlC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,KAAA,OAShD;AAGD,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,kBAAkB,GACnB,EAAE;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;IAyFG;;;OAGG;6BAnEiC,GAAG,KAAG,OAAO,CAAC;QAClD,oBAAoB,EAAE,UAAU,CAAC;QACjC,eAAe,EAAE,UAAU,CAAC;KAC7B,CAAC;IAkEA;;;OAGG;;EAGN"}
|
|
@@ -1,31 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module biometric-provider
|
|
4
|
+
* @description Biometric plugin for the Truvera Wallet SDK.
|
|
5
|
+
* This module provides functions for biometric enrollment, matching, and identity verification processes.
|
|
6
|
+
*/
|
|
2
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
9
|
};
|
|
5
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
11
|
+
exports.IDV_EVENTS = void 0;
|
|
12
|
+
exports.setConfigs = setConfigs;
|
|
13
|
+
exports.isBiometricPluginEnabled = isBiometricPluginEnabled;
|
|
14
|
+
exports.assertConfigs = assertConfigs;
|
|
15
|
+
exports.getBiometricConfigs = getBiometricConfigs;
|
|
16
|
+
exports.hasProofOfBiometrics = hasProofOfBiometrics;
|
|
17
|
+
exports.createBiometricProvider = createBiometricProvider;
|
|
7
18
|
const credential_provider_1 = require("./credential-provider");
|
|
8
19
|
const assert_1 = __importDefault(require("assert"));
|
|
9
20
|
const events_1 = require("events");
|
|
10
21
|
const did_provider_1 = require("./did-provider");
|
|
11
22
|
let currentConfigs = null;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the global biometric provider configurations for the SDK
|
|
25
|
+
* @param {BiometricsProviderConfigs<unknown>} configs - The biometric provider configurations to set
|
|
26
|
+
* @param {string} configs.enrollmentCredentialType - The credential type for enrollment
|
|
27
|
+
* @param {string} configs.biometricMatchCredentialType - The credential type for biometric matching
|
|
28
|
+
* @param {any} [configs.idvProvider] - Optional IDV provider configuration
|
|
29
|
+
* @example
|
|
30
|
+
* import { setConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
31
|
+
*
|
|
32
|
+
* setConfigs({
|
|
33
|
+
* enrollmentCredentialType: 'BiometricEnrollment',
|
|
34
|
+
* biometricMatchCredentialType: 'BiometricMatch',
|
|
35
|
+
* idvProvider: myIDVProviderConfig
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
12
38
|
function setConfigs(configs) {
|
|
13
39
|
currentConfigs = configs;
|
|
14
40
|
}
|
|
15
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the biometric plugin is enabled by verifying if biometric match credential type is configured
|
|
43
|
+
* @returns {boolean} True if biometric match credential type is configured, false otherwise
|
|
44
|
+
* @example
|
|
45
|
+
* import { isBiometricPluginEnabled, setConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
46
|
+
*
|
|
47
|
+
* // Before configuration
|
|
48
|
+
* console.log(isBiometricPluginEnabled()); // false
|
|
49
|
+
*
|
|
50
|
+
* // After configuration
|
|
51
|
+
* setConfigs({
|
|
52
|
+
* enrollmentCredentialType: 'BiometricEnrollment',
|
|
53
|
+
* biometricMatchCredentialType: 'BiometricMatch'
|
|
54
|
+
* });
|
|
55
|
+
* console.log(isBiometricPluginEnabled()); // true
|
|
56
|
+
*/
|
|
16
57
|
function isBiometricPluginEnabled() {
|
|
17
58
|
return !!currentConfigs?.biometricMatchCredentialType;
|
|
18
59
|
}
|
|
19
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Asserts that biometric provider configurations are available
|
|
62
|
+
* @throws {Error} If biometric provider configs are not set
|
|
63
|
+
* @example
|
|
64
|
+
* import { assertConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
65
|
+
*
|
|
66
|
+
* try {
|
|
67
|
+
* assertConfigs();
|
|
68
|
+
* console.log('Biometric configs are available');
|
|
69
|
+
* } catch (error) {
|
|
70
|
+
* console.error('Biometric configs missing:', error.message);
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
20
73
|
function assertConfigs() {
|
|
21
74
|
(0, assert_1.default)(!!currentConfigs, 'Missing biometric provider configs');
|
|
22
75
|
}
|
|
23
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Gets the current biometric provider configurations
|
|
78
|
+
* @returns {BiometricsProviderConfigs<unknown>} The current biometric provider configurations
|
|
79
|
+
* @throws {Error} If biometric provider configs are not set
|
|
80
|
+
* @example
|
|
81
|
+
* import { getBiometricConfigs } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
82
|
+
*
|
|
83
|
+
* try {
|
|
84
|
+
* const configs = getBiometricConfigs();
|
|
85
|
+
* console.log('Enrollment credential type:', configs.enrollmentCredentialType);
|
|
86
|
+
* console.log('Match credential type:', configs.biometricMatchCredentialType);
|
|
87
|
+
* } catch (error) {
|
|
88
|
+
* console.error('Failed to get configs:', error.message);
|
|
89
|
+
* }
|
|
90
|
+
*/
|
|
24
91
|
function getBiometricConfigs() {
|
|
25
92
|
assertConfigs();
|
|
26
93
|
return currentConfigs;
|
|
27
94
|
}
|
|
28
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Checks if a proof request requires biometric credentials
|
|
97
|
+
* @param {any} proofRequest - The proof request to analyze
|
|
98
|
+
* @returns {boolean} True if the proof request requires biometric credentials
|
|
99
|
+
* @example
|
|
100
|
+
* import { hasProofOfBiometrics } from '@docknetwork/wallet-sdk-core/biometric-provider';
|
|
101
|
+
*
|
|
102
|
+
* const proofRequest = {
|
|
103
|
+
* input_descriptors: [{
|
|
104
|
+
* constraints: {
|
|
105
|
+
* fields: [{
|
|
106
|
+
* path: ['$.credentialSubject.biometric.id']
|
|
107
|
+
* }, {
|
|
108
|
+
* path: ['$.credentialSubject.biometric.created']
|
|
109
|
+
* }]
|
|
110
|
+
* }
|
|
111
|
+
* }]
|
|
112
|
+
* };
|
|
113
|
+
*
|
|
114
|
+
* if (hasProofOfBiometrics(proofRequest)) {
|
|
115
|
+
* console.log('This proof request requires biometric verification');
|
|
116
|
+
* }
|
|
117
|
+
*/
|
|
29
118
|
function hasProofOfBiometrics(proofRequest) {
|
|
30
119
|
const fields = proofRequest.input_descriptors
|
|
31
120
|
?.map(input => input.constraints?.fields)
|
|
@@ -34,7 +123,6 @@ function hasProofOfBiometrics(proofRequest) {
|
|
|
34
123
|
return (paths?.includes('$.credentialSubject.biometric.id') &&
|
|
35
124
|
paths?.includes('$.credentialSubject.biometric.created'));
|
|
36
125
|
}
|
|
37
|
-
exports.hasProofOfBiometrics = hasProofOfBiometrics;
|
|
38
126
|
// map for events
|
|
39
127
|
exports.IDV_EVENTS = {
|
|
40
128
|
onDeepLink: 'onDeepLink',
|
|
@@ -43,11 +131,55 @@ exports.IDV_EVENTS = {
|
|
|
43
131
|
onCancel: 'onCancel',
|
|
44
132
|
onComplete: 'onComplete',
|
|
45
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Creates a biometric provider instance for identity verification and biometric credential management
|
|
136
|
+
* @param {Object} params - Provider configuration
|
|
137
|
+
* @param {IWallet} params.wallet - The wallet instance to use for credential storage
|
|
138
|
+
* @param {IDVProviderFactory} params.idvProviderFactory - Factory for creating IDV provider instances
|
|
139
|
+
* @returns {IBiometricProvider} A biometric provider instance with identity verification methods
|
|
140
|
+
* @throws {Error} If wallet or idvProviderFactory is not provided
|
|
141
|
+
* @see {@link IBiometricProvider} - The interface defining all available biometric provider methods
|
|
142
|
+
* @example
|
|
143
|
+
* import { createBiometricProvider } from '@docknetwork/wallet-sdk-core';
|
|
144
|
+
*
|
|
145
|
+
* const biometricProvider = createBiometricProvider({
|
|
146
|
+
* wallet,
|
|
147
|
+
* idvProviderFactory: myIDVFactory
|
|
148
|
+
* });
|
|
149
|
+
*
|
|
150
|
+
* // Start identity verification process
|
|
151
|
+
* const result = await biometricProvider.startIDV(proofRequest);
|
|
152
|
+
* console.log('Enrollment credential:', result.enrollmentCredential);
|
|
153
|
+
* console.log('Match credential:', result.matchCredential);
|
|
154
|
+
*
|
|
155
|
+
* // Listen for IDV events
|
|
156
|
+
* biometricProvider.eventEmitter.on('onComplete', (data) => {
|
|
157
|
+
* console.log('IDV process completed:', data);
|
|
158
|
+
* });
|
|
159
|
+
*/
|
|
46
160
|
function createBiometricProvider({ wallet, idvProviderFactory, }) {
|
|
47
161
|
const credentialProvider = (0, credential_provider_1.createCredentialProvider)({ wallet });
|
|
48
162
|
const didProvider = (0, did_provider_1.createDIDProvider)({ wallet });
|
|
49
163
|
const eventEmitter = new events_1.EventEmitter();
|
|
50
164
|
const idvProvider = idvProviderFactory.create(eventEmitter, wallet);
|
|
165
|
+
/**
|
|
166
|
+
* Starts the identity verification process using biometric credentials
|
|
167
|
+
* @memberof IBiometricProvider
|
|
168
|
+
* @param {any} proofRequest - The proof request containing biometric requirements
|
|
169
|
+
* @returns {Promise<{enrollmentCredential: Credential, matchCredential: Credential}>} The enrollment and match credentials
|
|
170
|
+
* @throws {Error} If IDV process fails or biometric configs are missing
|
|
171
|
+
* @example
|
|
172
|
+
* const result = await biometricProvider.startIDV({
|
|
173
|
+
* input_descriptors: [{
|
|
174
|
+
* constraints: {
|
|
175
|
+
* fields: [{
|
|
176
|
+
* path: ['$.credentialSubject.biometric.id'],
|
|
177
|
+
* purpose: 'Biometric ID verification'
|
|
178
|
+
* }]
|
|
179
|
+
* }
|
|
180
|
+
* }]
|
|
181
|
+
* });
|
|
182
|
+
*/
|
|
51
183
|
async function startIDV(proofRequest) {
|
|
52
184
|
const walletDID = await didProvider.getDefaultDID();
|
|
53
185
|
let [enrollmentCredential] = await credentialProvider.getCredentials(currentConfigs.enrollmentCredentialType);
|
|
@@ -85,9 +217,16 @@ function createBiometricProvider({ wallet, idvProviderFactory, }) {
|
|
|
85
217
|
};
|
|
86
218
|
}
|
|
87
219
|
return {
|
|
220
|
+
/**
|
|
221
|
+
* Starts the identity verification process using biometric credentials
|
|
222
|
+
* @memberof IBiometricProvider
|
|
223
|
+
*/
|
|
88
224
|
startIDV,
|
|
225
|
+
/**
|
|
226
|
+
* Event emitter for IDV process events (onDeepLink, onMessage, onError, onCancel, onComplete)
|
|
227
|
+
* @memberof IBiometricProvider
|
|
228
|
+
*/
|
|
89
229
|
eventEmitter,
|
|
90
230
|
};
|
|
91
231
|
}
|
|
92
|
-
exports.createBiometricProvider = createBiometricProvider;
|
|
93
232
|
//# sourceMappingURL=biometric-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biometric-provider.js","sourceRoot":"","sources":["../src/biometric-provider.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"biometric-provider.js","sourceRoot":"","sources":["../src/biometric-provider.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AA8CH,gCAEC;AAkBD,4DAEC;AAeD,sCAEC;AAiBD,kDAGC;AAyBD,oDASC;AAsCD,0DA0GC;AAvQD,+DAI+B;AAC/B,oDAA4B;AAC5B,mCAAoC;AACpC,iDAAiD;AAEjD,IAAI,cAAc,GAAuC,IAAI,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,OAA2C;IACpE,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,wBAAwB;IACtC,OAAO,CAAC,CAAC,cAAc,EAAE,4BAA4B,CAAC;AACxD,CAAC;AAED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GAAG,MAAM,kBAAkB,CAAC,OAAO,CAC9D,WAAW,CAAC,eAAe,CAAC,EAAE,CAC/B,CAAC;YAEF,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC7B,MAAM,kBAAkB,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YACtE,CAAC;YAED,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC;QAChD,CAAC;QAED,OAAO;YACL,oBAAoB;YACpB,eAAe;SAChB,CAAC;IACJ,CAAC;IAED,OAAO;QACL;;;WAGG;QACH,QAAQ;QACR;;;WAGG;QACH,YAAY;KACb,CAAC;AACJ,CAAC"}
|
package/lib/cloud-wallet.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module cloud-wallet
|
|
3
|
+
* @description Cloud wallet functionality for the Truvera Wallet SDK.
|
|
4
|
+
* This module provides the main cloud wallet creation and management functions.
|
|
5
|
+
*/
|
|
2
6
|
import { DataStore } from '@docknetwork/wallet-sdk-data-store/lib/types';
|
|
3
|
-
import {
|
|
7
|
+
import { edvService } from '@docknetwork/wallet-sdk-wasm/lib/services/edv';
|
|
4
8
|
export declare const SYNC_MARKER_TYPE = "SyncMarkerDocument";
|
|
5
9
|
export declare const MNEMONIC_WORD_COUNT = 12;
|
|
6
10
|
export declare const KEY_MAPPING_TYPE = "KeyMappingDocument";
|
|
7
|
-
export declare const HKDF_LENGTH = 32;
|
|
8
|
-
export declare const HKDF_HASH = "SHA-256";
|
|
9
11
|
/**
|
|
10
12
|
* Derives a key from biometric data using HKDF
|
|
11
13
|
* @param biometricData Biometric data from provider
|
|
@@ -58,7 +60,7 @@ export declare function decryptMasterKey(encryptedKey: Uint8Array, decryptionKey
|
|
|
58
60
|
* @param identifier User's identifier (email, phone number, etc.)
|
|
59
61
|
* @returns Initialized EDV service
|
|
60
62
|
*/
|
|
61
|
-
export declare function initializeKeyMappingVault(edvUrl: string, authKey: string, biometricData: Buffer, identifier: string): Promise<
|
|
63
|
+
export declare function initializeKeyMappingVault(edvUrl: string, authKey: string, biometricData: Buffer, identifier: string): Promise<typeof edvService>;
|
|
62
64
|
/**
|
|
63
65
|
* Enrolls a user by creating necessary vaults and keys
|
|
64
66
|
* @param edvUrl URL for the edv
|
|
@@ -79,7 +81,7 @@ export declare function enrollUserWithBiometrics(edvUrl: string, authKey: string
|
|
|
79
81
|
* @param iv Initialization vector for decryption
|
|
80
82
|
* @returns The decrypted master key for CloudWalletVault
|
|
81
83
|
*/
|
|
82
|
-
export declare function getKeyMappingMasterKey(keyMappingEdv:
|
|
84
|
+
export declare function getKeyMappingMasterKey(keyMappingEdv: typeof edvService, identifier: string, decryptionKey: Buffer): Promise<Uint8Array>;
|
|
83
85
|
/**
|
|
84
86
|
* Authenticates a user with biometric data and identifier
|
|
85
87
|
* @param edvUrl URL for the edv
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-wallet.d.ts","sourceRoot":"","sources":["../src/cloud-wallet.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cloud-wallet.d.ts","sourceRoot":"","sources":["../src/cloud-wallet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EAEV,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAG3E,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AACrD,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAGrD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,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