@docknetwork/wallet-sdk-core 1.5.14 → 1.7.0

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.
Files changed (91) hide show
  1. package/generate-docs.js +33 -0
  2. package/jsdoc.conf.json +28 -0
  3. package/lib/biometric-provider.d.ts +123 -31
  4. package/lib/biometric-provider.d.ts.map +1 -1
  5. package/lib/biometric-provider.js +146 -7
  6. package/lib/biometric-provider.js.map +1 -1
  7. package/lib/cloud-wallet.d.ts +7 -3
  8. package/lib/cloud-wallet.d.ts.map +1 -1
  9. package/lib/cloud-wallet.js +29 -18
  10. package/lib/cloud-wallet.js.map +1 -1
  11. package/lib/credential-provider.d.ts +58 -33
  12. package/lib/credential-provider.d.ts.map +1 -1
  13. package/lib/credential-provider.js +214 -13
  14. package/lib/credential-provider.js.map +1 -1
  15. package/lib/credentials/oidvc.js +6 -7
  16. package/lib/credentials/oidvc.js.map +1 -1
  17. package/lib/did-provider.d.ts +102 -36
  18. package/lib/did-provider.d.ts.map +1 -1
  19. package/lib/did-provider.js +186 -28
  20. package/lib/did-provider.js.map +1 -1
  21. package/lib/ecosystem-tools.js +5 -6
  22. package/lib/ecosystem-tools.js.map +1 -1
  23. package/lib/helpers.js +6 -6
  24. package/lib/helpers.js.map +1 -1
  25. package/lib/message-provider.d.ts +39 -13
  26. package/lib/message-provider.d.ts.map +1 -1
  27. package/lib/message-provider.js +146 -20
  28. package/lib/message-provider.js.map +1 -1
  29. package/lib/messages/message-helpers.js +6 -6
  30. package/lib/messages/message-helpers.js.map +1 -1
  31. package/lib/network-resolver.d.ts +1 -1
  32. package/lib/network-resolver.js +5 -5
  33. package/lib/network-resolver.js.map +1 -1
  34. package/lib/qr-handlers/builtin/index.d.ts +30 -0
  35. package/lib/qr-handlers/builtin/index.d.ts.map +1 -0
  36. package/lib/qr-handlers/builtin/index.js +46 -0
  37. package/lib/qr-handlers/builtin/index.js.map +1 -0
  38. package/lib/qr-handlers/builtin/oid4vc-handler.d.ts +137 -0
  39. package/lib/qr-handlers/builtin/oid4vc-handler.d.ts.map +1 -0
  40. package/lib/qr-handlers/builtin/oid4vc-handler.js +134 -0
  41. package/lib/qr-handlers/builtin/oid4vc-handler.js.map +1 -0
  42. package/lib/qr-handlers/index.d.ts +76 -0
  43. package/lib/qr-handlers/index.d.ts.map +1 -0
  44. package/lib/qr-handlers/index.js +92 -0
  45. package/lib/qr-handlers/index.js.map +1 -0
  46. package/lib/qr-handlers/processor.d.ts +110 -0
  47. package/lib/qr-handlers/processor.d.ts.map +1 -0
  48. package/lib/qr-handlers/processor.js +251 -0
  49. package/lib/qr-handlers/processor.js.map +1 -0
  50. package/lib/qr-handlers/types.d.ts +205 -0
  51. package/lib/qr-handlers/types.d.ts.map +1 -0
  52. package/lib/qr-handlers/types.js +10 -0
  53. package/lib/qr-handlers/types.js.map +1 -0
  54. package/lib/types.d.ts +610 -14
  55. package/lib/types.d.ts.map +1 -1
  56. package/lib/types.js +16 -0
  57. package/lib/types.js.map +1 -1
  58. package/lib/verification-controller.d.ts +0 -1
  59. package/lib/verification-controller.d.ts.map +1 -1
  60. package/lib/verification-controller.js +12 -5
  61. package/lib/verification-controller.js.map +1 -1
  62. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts +0 -1
  63. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts.map +1 -1
  64. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js +3 -3
  65. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js.map +1 -1
  66. package/lib/wallet-wasm.d.ts.map +1 -1
  67. package/lib/wallet-wasm.js +13 -14
  68. package/lib/wallet-wasm.js.map +1 -1
  69. package/lib/wallet.d.ts +36 -20
  70. package/lib/wallet.d.ts.map +1 -1
  71. package/lib/wallet.js +174 -28
  72. package/lib/wallet.js.map +1 -1
  73. package/package.json +17 -9
  74. package/src/biometric-provider.ts +157 -42
  75. package/src/cloud-wallet.ts +13 -0
  76. package/src/credential-provider.test.ts +191 -1
  77. package/src/credential-provider.ts +208 -27
  78. package/src/did-provider.ts +183 -34
  79. package/src/message-provider.ts +148 -34
  80. package/src/qr-handlers/builtin/index.ts +30 -0
  81. package/src/qr-handlers/builtin/oid4vc-handler.ts +198 -0
  82. package/src/qr-handlers/index.ts +76 -0
  83. package/src/qr-handlers/processor.test.ts +514 -0
  84. package/src/qr-handlers/processor.ts +311 -0
  85. package/src/qr-handlers/types.ts +228 -0
  86. package/src/types.ts +666 -11
  87. package/src/verification-controller.test.ts +1 -2
  88. package/src/verification-controller.ts +9 -1
  89. package/src/wallet-wasm.ts +1 -3
  90. package/src/wallet.ts +173 -24
  91. package/tsconfig.build.tsbuildinfo +1 -1
@@ -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();
@@ -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
- /// <reference types="node" />
2
- import { WalletDocument } from '@docknetwork/wallet-sdk-wasm/lib/types';
3
- import { IWallet } from './types';
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
- export type BiometricsProviderConfigs<E> = {
7
- enrollmentCredentialType: string;
8
- biometricMatchCredentialType: string;
9
- idvConfigs: E;
10
- };
11
- export interface IDVProcessOptions {
12
- onDeepLink?: () => void;
13
- onMessage?: () => void;
14
- onError?: (error: Error) => void;
15
- onCancel?: () => void;
16
- onComplete?: (credential: any) => void;
17
- }
18
- export interface BiometricPlugin {
19
- onEnroll(walletDID: string): Promise<WalletDocument>;
20
- onMatch(walletDID: string, enrollmentCredential: Credential): Promise<WalletDocument>;
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
- export interface IDVProvider {
35
- enroll(walletDID: string, proofRequest: any): Promise<{
36
- enrollmentCredential: Credential;
37
- matchCredential: Credential;
38
- }>;
39
- match(walletDID: string, enrollmentCredential: Credential, proofRequest: any): Promise<{
40
- matchCredential: Credential;
41
- }>;
42
- }
43
- export interface IDVProviderFactory {
44
- create(eventEmitter: EventEmitter, wallet: IWallet): IDVProvider;
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
  }>;
142
+ /**
143
+ * Event emitter for IDV process events (onDeepLink, onMessage, onError, onCancel, onComplete)
144
+ * @memberof IBiometricProvider
145
+ */
54
146
  eventEmitter: EventEmitter;
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":";AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,EAEL,UAAU,EAEX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAGpC,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI;IAEzC,wBAAwB,EAAE,MAAM,CAAC;IACjC,4BAA4B,EAAE,MAAM,CAAC;IAErC,UAAU,EAAE,CAAC,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,IA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,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;6BAOuC,GAAG;8BACjB,UAAU;yBACf,UAAU;;;EAiE9B"}
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.createBiometricProvider = exports.IDV_EVENTS = exports.hasProofOfBiometrics = exports.getBiometricConfigs = exports.assertConfigs = exports.isBiometricPluginEnabled = exports.setConfigs = void 0;
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
- exports.setConfigs = setConfigs;
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
- exports.isBiometricPluginEnabled = isBiometricPluginEnabled;
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
- exports.assertConfigs = assertConfigs;
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
- exports.getBiometricConfigs = getBiometricConfigs;
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
@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,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"}
@@ -1,6 +1,10 @@
1
- /// <reference types="node" />
2
- import { DataStore } from '@docknetwork/wallet-sdk-data-store/lib/types';
3
- import { EDVService } from '@docknetwork/wallet-sdk-wasm/lib/services/edv/service';
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
+ */
6
+ import { DataStore } from '@docknetwork/wallet-sdk-data-store/src/types';
7
+ import { EDVService } from '@docknetwork/wallet-sdk-wasm/src/services/edv/service';
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";
@@ -1 +1 @@
1
- {"version":3,"file":"cloud-wallet.d.ts","sourceRoot":"","sources":["../src/cloud-wallet.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EAEV,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAc,UAAU,EAAE,MAAM,uDAAuD,CAAC;AAK/F,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AACrD,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AACrD,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,SAAS,YAAY,CAAC;AAGnC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAA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BAAsB,CAC1C,aAAa,EAAE,UAAU,EACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAiCrB;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,CAYrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,GAAG,CAAC,CAcd;AAaD,wBAAsB,4BAA4B,IAAI,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,CAAC,CASzG;AAED,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAIvF;AAED,wBAAsB,qBAAqB,CAAC,EAC1C,SAAS,EACT,MAAM,EACN,OAAO,EACP,SAAS,GACV,EAAE;IACD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,UAAU,CAAC;CACvB;;;;;;0BAoE4B,OAAO,CAAC,IAAI,CAAC;;;GA2JzC"}
@@ -1,15 +1,33 @@
1
1
  "use strict";
2
+ /**
3
+ * @module cloud-wallet
4
+ * @description Cloud wallet functionality for the Truvera Wallet SDK.
5
+ * This module provides the main cloud wallet creation and management functions.
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.initializeCloudWallet = exports.recoverCloudWalletMasterKey = exports.generateCloudWalletMasterKey = exports.initializeCloudWalletWithBiometrics = exports.authenticateWithBiometrics = exports.getKeyMappingMasterKey = exports.enrollUserWithBiometrics = exports.initializeKeyMappingVault = exports.decryptMasterKey = exports.encryptMasterKey = exports.deriveBiometricEncryptionKey = exports.deriveKeyMappingVaultKeys = exports.deriveBiometricKey = exports.HKDF_HASH = exports.HKDF_LENGTH = exports.KEY_MAPPING_TYPE = exports.MNEMONIC_WORD_COUNT = exports.SYNC_MARKER_TYPE = void 0;
7
- const types_1 = require("@docknetwork/wallet-sdk-data-store/lib/types");
8
- const logger_1 = require("@docknetwork/wallet-sdk-data-store/lib/logger");
9
- const service_1 = require("@docknetwork/wallet-sdk-wasm/lib/services/edv/service");
11
+ exports.HKDF_HASH = exports.HKDF_LENGTH = exports.KEY_MAPPING_TYPE = exports.MNEMONIC_WORD_COUNT = exports.SYNC_MARKER_TYPE = void 0;
12
+ exports.deriveBiometricKey = deriveBiometricKey;
13
+ exports.deriveKeyMappingVaultKeys = deriveKeyMappingVaultKeys;
14
+ exports.deriveBiometricEncryptionKey = deriveBiometricEncryptionKey;
15
+ exports.encryptMasterKey = encryptMasterKey;
16
+ exports.decryptMasterKey = decryptMasterKey;
17
+ exports.initializeKeyMappingVault = initializeKeyMappingVault;
18
+ exports.enrollUserWithBiometrics = enrollUserWithBiometrics;
19
+ exports.getKeyMappingMasterKey = getKeyMappingMasterKey;
20
+ exports.authenticateWithBiometrics = authenticateWithBiometrics;
21
+ exports.initializeCloudWalletWithBiometrics = initializeCloudWalletWithBiometrics;
22
+ exports.generateCloudWalletMasterKey = generateCloudWalletMasterKey;
23
+ exports.recoverCloudWalletMasterKey = recoverCloudWalletMasterKey;
24
+ exports.initializeCloudWallet = initializeCloudWallet;
25
+ const types_1 = require("@docknetwork/wallet-sdk-data-store/src/types");
26
+ const logger_1 = require("@docknetwork/wallet-sdk-data-store/src/logger");
27
+ const service_1 = require("@docknetwork/wallet-sdk-wasm/src/services/edv/service");
10
28
  const futoin_hkdf_1 = __importDefault(require("futoin-hkdf"));
11
29
  const crypto_1 = __importDefault(require("@docknetwork/universal-wallet/crypto"));
12
- const util_crypto_1 = require("@docknetwork/wallet-sdk-wasm/lib/services/util-crypto");
30
+ const util_crypto_1 = require("@docknetwork/wallet-sdk-wasm/src/services/util-crypto");
13
31
  exports.SYNC_MARKER_TYPE = 'SyncMarkerDocument';
14
32
  exports.MNEMONIC_WORD_COUNT = 12;
15
33
  exports.KEY_MAPPING_TYPE = 'KeyMappingDocument';
@@ -26,7 +44,6 @@ function deriveBiometricKey(biometricData, identifier) {
26
44
  const salt = identifier;
27
45
  return (0, futoin_hkdf_1.default)(biometricData, exports.HKDF_LENGTH, { salt, hash: exports.HKDF_HASH });
28
46
  }
29
- exports.deriveBiometricKey = deriveBiometricKey;
30
47
  /**
31
48
  * Derives EDV keys from biometric data for the KeyMappingVault
32
49
  * @param biometricData Biometric data from the provider
@@ -37,7 +54,6 @@ async function deriveKeyMappingVaultKeys(biometricData, identifier) {
37
54
  const seedBuffer = deriveBiometricKey(biometricData, identifier);
38
55
  return service_1.edvService.deriveKeys(new Uint8Array(seedBuffer));
39
56
  }
40
- exports.deriveKeyMappingVaultKeys = deriveKeyMappingVaultKeys;
41
57
  /**
42
58
  * Generates a key for encrypting/decrypting the master key
43
59
  * @param biometricData Biometric data from provider
@@ -53,7 +69,6 @@ async function deriveBiometricEncryptionKey(biometricData, identifier) {
53
69
  iv
54
70
  };
55
71
  }
56
- exports.deriveBiometricEncryptionKey = deriveBiometricEncryptionKey;
57
72
  /**
58
73
  * Encrypts the master key using a key derived from biometric data
59
74
  * @param masterKey The CloudWalletVault master key to encrypt
@@ -68,7 +83,6 @@ async function encryptMasterKey(masterKey, encryptionKey, iv) {
68
83
  const encryptedBuffer = await crypto_1.default.subtle.encrypt({ name: 'AES-GCM', iv: ivData }, key, masterKey);
69
84
  return new Uint8Array(encryptedBuffer);
70
85
  }
71
- exports.encryptMasterKey = encryptMasterKey;
72
86
  /**
73
87
  * Decrypts the master key using biometric-derived key
74
88
  * @param encryptedKey The encrypted master key
@@ -88,7 +102,6 @@ async function decryptMasterKey(encryptedKey, decryptionKey, iv) {
88
102
  throw new Error('Decryption failed: Invalid key or corrupted data');
89
103
  }
90
104
  }
91
- exports.decryptMasterKey = decryptMasterKey;
92
105
  /**
93
106
  * Initializes the KeyMappingVault using biometric data
94
107
  * @param edvUrl URL for the edv
@@ -109,7 +122,6 @@ async function initializeKeyMappingVault(edvUrl, authKey, biometricData, identif
109
122
  });
110
123
  return keyMappingEdvService;
111
124
  }
112
- exports.initializeKeyMappingVault = initializeKeyMappingVault;
113
125
  /**
114
126
  * Enrolls a user by creating necessary vaults and keys
115
127
  * @param edvUrl URL for the edv
@@ -139,7 +151,6 @@ async function enrollUserWithBiometrics(edvUrl, authKey, biometricData, identifi
139
151
  });
140
152
  return { masterKey, mnemonic };
141
153
  }
142
- exports.enrollUserWithBiometrics = enrollUserWithBiometrics;
143
154
  /**
144
155
  * Gets the master key from the key mapping vault using provided decryption keys
145
156
  * @param keyMappingEdv Initialized key mapping vault service
@@ -153,6 +164,12 @@ async function getKeyMappingMasterKey(keyMappingEdv, identifier, decryptionKey)
153
164
  equals: {
154
165
  'content.id': identifier
155
166
  }
167
+ }).catch(error => {
168
+ if (error.message && error.message.includes('does not exist')) {
169
+ logger_1.logger.error('KeyMappingVault does not exist, skipping find');
170
+ return { documents: [] };
171
+ }
172
+ throw error;
156
173
  });
157
174
  if (!result.documents || result.documents.length === 0) {
158
175
  throw new Error('Authentication failed: Invalid identifier');
@@ -171,7 +188,6 @@ async function getKeyMappingMasterKey(keyMappingEdv, identifier, decryptionKey)
171
188
  throw new Error('Authentication failed: Invalid decryption key');
172
189
  }
173
190
  }
174
- exports.getKeyMappingMasterKey = getKeyMappingMasterKey;
175
191
  /**
176
192
  * Authenticates a user with biometric data and identifier
177
193
  * @param edvUrl URL for the edv
@@ -186,7 +202,6 @@ async function authenticateWithBiometrics(edvUrl, authKey, biometricData, identi
186
202
  const contentId = `${await keyMappingEdv.getController()}#${MASTER_KEY_SUFFIX}`;
187
203
  return getKeyMappingMasterKey(keyMappingEdv, contentId, decryptionKey);
188
204
  }
189
- exports.authenticateWithBiometrics = authenticateWithBiometrics;
190
205
  /**
191
206
  * Initializes the Cloud Wallet using biometric authentication
192
207
  * @param edvUrl Cloud wallet vault URL
@@ -205,7 +220,6 @@ async function initializeCloudWalletWithBiometrics(edvUrl, authKey, biometricDat
205
220
  masterKey
206
221
  });
207
222
  }
208
- exports.initializeCloudWalletWithBiometrics = initializeCloudWalletWithBiometrics;
209
223
  async function generateCloudWalletMasterKey() {
210
224
  const mnemonic = await util_crypto_1.utilCryptoService.mnemonicGenerate(exports.MNEMONIC_WORD_COUNT);
211
225
  const masterKey = await util_crypto_1.utilCryptoService.mnemonicToMiniSecret(mnemonic);
@@ -214,12 +228,10 @@ async function generateCloudWalletMasterKey() {
214
228
  masterKey,
215
229
  };
216
230
  }
217
- exports.generateCloudWalletMasterKey = generateCloudWalletMasterKey;
218
231
  async function recoverCloudWalletMasterKey(mnemonic) {
219
232
  const masterKey = await util_crypto_1.utilCryptoService.mnemonicToMiniSecret(mnemonic);
220
233
  return masterKey;
221
234
  }
222
- exports.recoverCloudWalletMasterKey = recoverCloudWalletMasterKey;
223
235
  async function initializeCloudWallet({ dataStore, edvUrl, authKey, masterKey, }) {
224
236
  const { hmacKey, agreementKey, verificationKey, } = await service_1.edvService.deriveKeys(masterKey);
225
237
  await service_1.edvService.initialize({
@@ -408,5 +420,4 @@ async function initializeCloudWallet({ dataStore, edvUrl, authKey, masterKey, })
408
420
  unsubscribeEventListeners,
409
421
  };
410
422
  }
411
- exports.initializeCloudWallet = initializeCloudWallet;
412
423
  //# sourceMappingURL=cloud-wallet.js.map