@docknetwork/wallet-sdk-core 1.5.0 → 1.5.8

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.
@@ -1,29 +1,56 @@
1
+ /// <reference types="node" />
1
2
  import { WalletDocument } from '@docknetwork/wallet-sdk-wasm/lib/types';
2
3
  import { IWallet } from './types';
3
- export type BiometricsPluginIssuerConfig = {
4
- networkId: string;
5
- did: string;
6
- apiKey: string;
7
- apiUrl: string;
8
- };
9
- export type BiometricsPluginConfigs = {
4
+ import { Credential } from './credential-provider';
5
+ import { EventEmitter } from 'events';
6
+ export type BiometricsProviderConfigs<E> = {
10
7
  enrollmentCredentialType: string;
11
8
  biometricMatchCredentialType: string;
12
- biometricMatchExpirationMinutes: number;
13
- issuerConfigs: BiometricsPluginIssuerConfig[];
9
+ idvConfigs: E;
14
10
  };
15
- export declare function setBiometricConfigs(_configs: BiometricsPluginConfigs): void;
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
+ }
22
+ export declare function setConfigs(configs: BiometricsProviderConfigs<unknown>): void;
23
+ export declare function isBiometricPluginEnabled(): boolean;
16
24
  export declare function assertConfigs(): void;
17
- export declare function getBiometricConfigs(): BiometricsPluginConfigs;
18
- export declare function getIssuerConfigsForNetwork(networkId: any): BiometricsPluginIssuerConfig;
19
- export declare function createBiometricBindingProvider({ wallet, onEnroll, onMatch, onCheckBiometryRequired, }: {
25
+ export declare function getBiometricConfigs(): BiometricsProviderConfigs<unknown>;
26
+ export declare function hasProofOfBiometrics(proofRequest: any): any;
27
+ export declare const IDV_EVENTS: {
28
+ onDeepLink: string;
29
+ onMessage: string;
30
+ onError: string;
31
+ onCancel: string;
32
+ onComplete: string;
33
+ };
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
+ }
46
+ export declare function createBiometricProvider({ wallet, idvProviderFactory, }: {
20
47
  wallet: IWallet;
21
- onEnroll: () => Promise<WalletDocument>;
22
- onMatch: (biometricTemplate: WalletDocument) => Promise<WalletDocument>;
23
- onCheckBiometryRequired: (request: any) => boolean;
48
+ idvProviderFactory: IDVProviderFactory;
24
49
  }): {
25
- enrollBiometry: () => Promise<any>;
26
- matchBiometry: () => Promise<WalletDocument>;
27
- checkIsBiometryRequired: (request: any) => boolean;
50
+ startIDV: (proofRequest: any) => Promise<{
51
+ enrollmentCredential: Credential;
52
+ matchCredential: Credential;
53
+ }>;
54
+ eventEmitter: EventEmitter;
28
55
  };
29
56
  //# 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;AAIhC,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,wBAAwB,EAAE,MAAM,CAAC;IACjC,4BAA4B,EAAE,MAAM,CAAC;IACrC,+BAA+B,EAAE,MAAM,CAAC;IACxC,aAA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,CAAC,UAAU,EAAE,GAAG,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACrD,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,UAAU,GAC/B,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B;AAID,wBAAgB,UAAU,CAAC,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,QAErE;AAED,wBAAgB,wBAAwB,YAEvC;AAED,wBAAgB,aAAa,SAE5B;AAED,wBAAgB,mBAAmB,uCAGlC;AAED,wBAAgB,oBAAoB,CAAC,YAAY,KAAA,OAShD;AAGD,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,GAAG,GAChB,OAAO,CAAC;QAAC,oBAAoB,EAAE,UAAU,CAAC;QAAC,eAAe,EAAE,UAAU,CAAA;KAAC,CAAC,CAAC;IAC5E,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,UAAU,EAChC,YAAY,EAAE,GAAG,GAChB,OAAO,CAAC;QACT,eAAe,EAAE,UAAU,CAAC;KAC7B,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,WAAW,CAAC;CAClE;AAED,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,kBAAkB,GACnB,EAAE;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;6BAOuC,GAAG;8BACjB,UAAU;yBACf,UAAU;;;EAiE9B"}
@@ -3,61 +3,91 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createBiometricBindingProvider = exports.getIssuerConfigsForNetwork = exports.getBiometricConfigs = exports.assertConfigs = exports.setBiometricConfigs = void 0;
6
+ exports.createBiometricProvider = exports.IDV_EVENTS = exports.hasProofOfBiometrics = exports.getBiometricConfigs = exports.assertConfigs = exports.isBiometricPluginEnabled = exports.setConfigs = void 0;
7
7
  const credential_provider_1 = require("./credential-provider");
8
8
  const assert_1 = __importDefault(require("assert"));
9
- let configs = null;
10
- function setBiometricConfigs(_configs) {
11
- configs = _configs;
9
+ const events_1 = require("events");
10
+ const did_provider_1 = require("./did-provider");
11
+ let currentConfigs = null;
12
+ function setConfigs(configs) {
13
+ currentConfigs = configs;
12
14
  }
13
- exports.setBiometricConfigs = setBiometricConfigs;
14
- ;
15
+ exports.setConfigs = setConfigs;
16
+ function isBiometricPluginEnabled() {
17
+ return !!currentConfigs?.biometricMatchCredentialType;
18
+ }
19
+ exports.isBiometricPluginEnabled = isBiometricPluginEnabled;
15
20
  function assertConfigs() {
16
- (0, assert_1.default)(!!configs, 'Biometrics plugin not configured');
21
+ (0, assert_1.default)(!!currentConfigs, 'Missing biometric provider configs');
17
22
  }
18
23
  exports.assertConfigs = assertConfigs;
19
24
  function getBiometricConfigs() {
20
25
  assertConfigs();
21
- return configs;
26
+ return currentConfigs;
22
27
  }
23
28
  exports.getBiometricConfigs = getBiometricConfigs;
24
- function getIssuerConfigsForNetwork(networkId) {
25
- return getBiometricConfigs()?.issuerConfigs.find(config => config.networkId === networkId);
29
+ function hasProofOfBiometrics(proofRequest) {
30
+ const fields = proofRequest.input_descriptors
31
+ ?.map(input => input.constraints?.fields)
32
+ .flat();
33
+ const paths = fields.map(field => field.path).flat();
34
+ return (paths?.includes('$.credentialSubject.biometric.id') &&
35
+ paths?.includes('$.credentialSubject.biometric.created'));
26
36
  }
27
- exports.getIssuerConfigsForNetwork = getIssuerConfigsForNetwork;
28
- function createBiometricBindingProvider({ wallet, onEnroll, onMatch, onCheckBiometryRequired, }) {
37
+ exports.hasProofOfBiometrics = hasProofOfBiometrics;
38
+ // map for events
39
+ exports.IDV_EVENTS = {
40
+ onDeepLink: 'onDeepLink',
41
+ onMessage: 'onMessage',
42
+ onError: 'onError',
43
+ onCancel: 'onCancel',
44
+ onComplete: 'onComplete',
45
+ };
46
+ function createBiometricProvider({ wallet, idvProviderFactory, }) {
29
47
  const credentialProvider = (0, credential_provider_1.createCredentialProvider)({ wallet });
30
- return {
31
- enrollBiometry: async () => {
32
- const enrollmentCredential = await onEnroll();
33
- return await credentialProvider.addCredential(enrollmentCredential);
34
- },
35
- matchBiometry: async () => {
36
- const CREDENTIAL_TYPE = configs.enrollmentCredentialType;
37
- const enrollmentCredentials = await wallet.getDocumentsByType(CREDENTIAL_TYPE);
38
- if (!enrollmentCredentials.length) {
39
- throw new Error('Enrollment credential not found');
48
+ const didProvider = (0, did_provider_1.createDIDProvider)({ wallet });
49
+ const eventEmitter = new events_1.EventEmitter();
50
+ const idvProvider = idvProviderFactory.create(eventEmitter, wallet);
51
+ async function startIDV(proofRequest) {
52
+ const walletDID = await didProvider.getDefaultDID();
53
+ let [enrollmentCredential] = await credentialProvider.getCredentials(currentConfigs.enrollmentCredentialType);
54
+ // Remove any existing match credentials
55
+ const existingMatchCredentials = await credentialProvider.getCredentials(currentConfigs.biometricMatchCredentialType);
56
+ for (const credential of existingMatchCredentials) {
57
+ await credentialProvider.removeCredential(credential.id);
58
+ }
59
+ let matchCredential;
60
+ if (!enrollmentCredential) {
61
+ // call IDV to start enrollment process and issue the enrollment credential + match credential
62
+ const credentials = await idvProvider.enroll(walletDID, proofRequest);
63
+ // check if credential is already in the credential store
64
+ const receivedViaDistribution = await credentialProvider.getById(credentials.matchCredential.id);
65
+ if (!receivedViaDistribution) {
66
+ await credentialProvider.addCredential(credentials.enrollmentCredential);
67
+ await credentialProvider.addCredential(credentials.matchCredential);
40
68
  }
41
- const matchConfirmationCredential = await onMatch(enrollmentCredentials[0]);
42
- if (matchConfirmationCredential) {
43
- const biometricMatchCredentials = await wallet.getDocumentsByType(configs.biometricMatchCredentialType);
44
- for (let i = 0; i < biometricMatchCredentials.length; i++) {
45
- await wallet.removeDocument(biometricMatchCredentials[0].id);
46
- }
47
- await wallet.addDocument(matchConfirmationCredential);
48
- // make the biometric credential valid by default
49
- await wallet.addDocument({
50
- id: `${matchConfirmationCredential.id}#status`,
51
- status: credential_provider_1.CredentialStatus.Verified,
52
- type: 'CredentialStatus',
53
- createdAt: new Date().toISOString(),
54
- updatedAt: new Date().toISOString(),
55
- });
69
+ matchCredential = credentials.matchCredential;
70
+ enrollmentCredential = credentials.enrollmentCredential;
71
+ }
72
+ else {
73
+ // call IDV to match the enrollment credential and issue the match credential
74
+ const credentials = await idvProvider.match(walletDID, enrollmentCredential, proofRequest);
75
+ // check if credential is already in the credential store
76
+ const receivedViaDistribution = await credentialProvider.getById(credentials.matchCredential.id);
77
+ if (!receivedViaDistribution) {
78
+ await credentialProvider.addCredential(credentials.matchCredential);
56
79
  }
57
- return matchConfirmationCredential;
58
- },
59
- checkIsBiometryRequired: onCheckBiometryRequired,
80
+ matchCredential = credentials.matchCredential;
81
+ }
82
+ return {
83
+ enrollmentCredential,
84
+ matchCredential,
85
+ };
86
+ }
87
+ return {
88
+ startIDV,
89
+ eventEmitter,
60
90
  };
61
91
  }
62
- exports.createBiometricBindingProvider = createBiometricBindingProvider;
92
+ exports.createBiometricProvider = createBiometricProvider;
63
93
  //# sourceMappingURL=biometric-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"biometric-provider.js","sourceRoot":"","sources":["../src/biometric-provider.ts"],"names":[],"mappings":";;;;;;AAEA,+DAAiF;AACjF,oDAA4B;AAgB5B,IAAI,OAAO,GAA4B,IAAI,CAAC;AAE5C,SAAgB,mBAAmB,CAAC,QAAiC;IACnE,OAAO,GAAG,QAAQ,CAAC;AACrB,CAAC;AAFD,kDAEC;AAAA,CAAC;AAEF,SAAgB,aAAa;IAC3B,IAA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} from '@docknetwork/wallet-sdk-data-store/lib/types';
3
+ import { EDVService } from '@docknetwork/wallet-sdk-wasm/lib/services/edv/service';
2
4
  export declare const SYNC_MARKER_TYPE = "SyncMarkerDocument";
5
+ export declare const MNEMONIC_WORD_COUNT = 12;
6
+ export declare const KEY_MAPPING_TYPE = "KeyMappingDocument";
7
+ export declare const HKDF_LENGTH = 32;
8
+ export declare const HKDF_HASH = "SHA-256";
9
+ /**
10
+ * Derives a key from biometric data using HKDF
11
+ * @param biometricData Biometric data from provider
12
+ * @param identifier User's identifier as salt (email, phone number, etc.)
13
+ * @returns Derived key
14
+ */
15
+ export declare function deriveBiometricKey(biometricData: Buffer, identifier: string): Buffer;
16
+ /**
17
+ * Derives EDV keys from biometric data for the KeyMappingVault
18
+ * @param biometricData Biometric data from the provider
19
+ * @param identifier User's identifier as additional entropy (email, phone number, etc.)
20
+ * @returns Keys for accessing the KeyMappingVault
21
+ */
22
+ export declare function deriveKeyMappingVaultKeys(biometricData: Buffer, identifier: string): Promise<{
23
+ hmacKey: string;
24
+ agreementKey: string;
25
+ verificationKey: string;
26
+ }>;
27
+ /**
28
+ * Generates a key for encrypting/decrypting the master key
29
+ * @param biometricData Biometric data from provider
30
+ * @param identifier User's identifier as salt (email, phone number, etc.)
31
+ * @returns Encryption key and IV for AES encryption
32
+ */
33
+ export declare function deriveBiometricEncryptionKey(biometricData: Buffer, identifier: string): Promise<{
34
+ key: Buffer;
35
+ iv: Buffer;
36
+ }>;
37
+ /**
38
+ * Encrypts the master key using a key derived from biometric data
39
+ * @param masterKey The CloudWalletVault master key to encrypt
40
+ * @param encryptionKey Key derived from biometric data
41
+ * @param iv Initialization vector
42
+ * @returns Encrypted master key
43
+ */
44
+ export declare function encryptMasterKey(masterKey: Uint8Array, encryptionKey: Buffer, iv: Buffer): Promise<Uint8Array>;
45
+ /**
46
+ * Decrypts the master key using biometric-derived key
47
+ * @param encryptedKey The encrypted master key
48
+ * @param decryptionKey Key derived from biometric data
49
+ * @param iv Initialization vector
50
+ * @returns The decrypted master key
51
+ */
52
+ export declare function decryptMasterKey(encryptedKey: Uint8Array, decryptionKey: Buffer, iv: Buffer): Promise<Uint8Array>;
53
+ /**
54
+ * Initializes the KeyMappingVault using biometric data
55
+ * @param edvUrl URL for the edv
56
+ * @param authKey Auth key for the edv
57
+ * @param biometricData User's biometric data
58
+ * @param identifier User's identifier (email, phone number, etc.)
59
+ * @returns Initialized EDV service
60
+ */
61
+ export declare function initializeKeyMappingVault(edvUrl: string, authKey: string, biometricData: Buffer, identifier: string): Promise<EDVService>;
62
+ /**
63
+ * Enrolls a user by creating necessary vaults and keys
64
+ * @param edvUrl URL for the edv
65
+ * @param authKey Auth key for the edv
66
+ * @param biometricData Biometric data from provider
67
+ * @param identifier User's identifier (email, phone number, etc.)
68
+ * @returns The master key and mnemonic for backup
69
+ */
70
+ export declare function enrollUserWithBiometrics(edvUrl: string, authKey: string, biometricData: Buffer, identifier: string): Promise<{
71
+ masterKey: Uint8Array;
72
+ mnemonic: string;
73
+ }>;
74
+ /**
75
+ * Gets the master key from the key mapping vault using provided decryption keys
76
+ * @param keyMappingEdv Initialized key mapping vault service
77
+ * @param identifier User's identifier (email, phone number, etc.)
78
+ * @param decryptionKey Key for decrypting the master key
79
+ * @param iv Initialization vector for decryption
80
+ * @returns The decrypted master key for CloudWalletVault
81
+ */
82
+ export declare function getKeyMappingMasterKey(keyMappingEdv: EDVService, identifier: string, decryptionKey: Buffer): Promise<Uint8Array>;
83
+ /**
84
+ * Authenticates a user with biometric data and identifier
85
+ * @param edvUrl URL for the edv
86
+ * @param authKey Auth key for the edv
87
+ * @param biometricData Biometric data from the provider
88
+ * @param identifier User's identifier (email, phone number, etc.)
89
+ * @returns The decrypted master key for CloudWalletVault
90
+ */
91
+ export declare function authenticateWithBiometrics(edvUrl: string, authKey: string, biometricData: Buffer, identifier: string): Promise<Uint8Array>;
92
+ /**
93
+ * Initializes the Cloud Wallet using biometric authentication
94
+ * @param edvUrl Cloud wallet vault URL
95
+ * @param authKey Cloud wallet auth key
96
+ * @param biometricData User's biometric data
97
+ * @param identifier User's identifier (email, phone number, etc.)
98
+ * @param dataStore Optional data store for the wallet
99
+ * @returns Initialized cloud wallet
100
+ */
101
+ export declare function initializeCloudWalletWithBiometrics(edvUrl: string, authKey: string, biometricData: Buffer, identifier: string, dataStore?: any): Promise<any>;
3
102
  export declare function generateCloudWalletMasterKey(): Promise<{
4
103
  mnemonic: string;
5
- masterKey: string;
104
+ masterKey: Uint8Array;
6
105
  }>;
7
- export declare function recoverCloudWalletMasterKey(mnemonic: string): Promise<string>;
106
+ export declare function recoverCloudWalletMasterKey(mnemonic: string): Promise<Uint8Array>;
8
107
  export declare function initializeCloudWallet({ dataStore, edvUrl, authKey, masterKey, }: {
9
108
  dataStore?: DataStore;
10
109
  edvUrl: string;
11
110
  authKey: string;
12
- masterKey: any;
111
+ masterKey: Uint8Array;
13
112
  }): Promise<{
14
113
  clearEdvDocuments: () => Promise<void>;
15
114
  pushSyncMarker: () => Promise<void>;
@@ -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;AAOtD,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAarD,wBAAsB,4BAA4B,IAAI,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAUrG;AAED,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKnF;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,GAAG,CAAC;CA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