@verified-network/verified-custody 0.4.3 → 0.4.5

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/README.md CHANGED
@@ -350,6 +350,231 @@ function App() {
350
350
  }
351
351
  ```
352
352
 
353
+ # 🔄 React(Create React App) Setup and Fixes
354
+
355
+ ✅ 1. Initialize the Project
356
+
357
+ ```jsx
358
+ npx create-react-app my-app
359
+ cd my-app
360
+ ```
361
+
362
+ ✅ 2. Install react-app-rewired
363
+
364
+ ```jsx
365
+ npm install react-app-rewired --save-dev
366
+ OR
367
+ yarn add --dev react-app-rewired
368
+ ```
369
+
370
+ ✅ 3. Install other dependencies for node polyfils
371
+
372
+ ```jsx
373
+ npm install --save-dev crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
374
+ OR
375
+ yarn add crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
376
+ ```
377
+
378
+ note: the above dependencies are needed dependencies to make node related packages work, more dependencies can be added to handle any other nodeJs polyfills error.
379
+
380
+ ✅ 4. Override create-react-app webpack configuration
381
+ In the root folder of your project, create a new file named 'config-overrides.js', and add:
382
+
383
+ ```jsx
384
+ //config-overrides.js
385
+
386
+ const webpack = require("webpack");
387
+ module.exports = function override(config) {
388
+ const fallback = config.resolve.fallback || {};
389
+ Object.assign(fallback, {
390
+ crypto: require.resolve("crypto-browserify"),
391
+ stream: require.resolve("stream-browserify"),
392
+ assert: require.resolve("assert"),
393
+ http: require.resolve("stream-http"),
394
+ https: require.resolve("https-browserify"),
395
+ os: require.resolve("os-browserify"),
396
+ url: require.resolve("url"),
397
+ path: require.resolve("path-browserify"),
398
+ vm: require.resolve("vm-browserify"),
399
+ fs: false,
400
+ });
401
+ config.plugins.push(
402
+ new webpack.IgnorePlugin({
403
+ resourceRegExp:
404
+ /^react-native$|^expo-font$|^@react-native-async-storage\/async-storage$/,
405
+ })
406
+ );
407
+
408
+ config.plugins = (config.plugins || []).concat([
409
+ new webpack.ProvidePlugin({
410
+ process: "process/browser",
411
+ Buffer: ["buffer", "Buffer"],
412
+ }),
413
+ ]);
414
+ config.module.rules = [
415
+ ...config.module.rules,
416
+ {
417
+ test: /\.m?js/,
418
+ resolve: {
419
+ fullySpecified: false,
420
+ },
421
+ },
422
+ ];
423
+ config.resolve.fallback = fallback;
424
+ config.ignoreWarnings = [/Failed to parse source map/];
425
+ return config;
426
+ };
427
+ ```
428
+
429
+ config-overrides.js' code snippet instructs webpack how to resolve node js related dependencies that may not be available on browser side but are required. It also instruct webpack to ignore react-native related dependencies that may breack our react app.
430
+
431
+ ✅ 5. Modify package.json Scripts
432
+ In your package.json, replace this:
433
+
434
+ ```json
435
+ "scripts": {
436
+ "start": "react-scripts start",
437
+ "build": "react-scripts build",
438
+ "test": "react-scripts test",
439
+ "eject": "react-scripts eject"
440
+ }
441
+ ```
442
+
443
+ With this:
444
+
445
+ ```json
446
+ "scripts": {
447
+ "start": "react-app-rewired start",
448
+ "build": "react-app-rewired build",
449
+ "test": "react-app-rewired test"
450
+ }
451
+
452
+ ```
453
+
454
+ note: the above scripts changes ensure your app is handled by react-app-rewired scripts instead of react-scripts this way the webpack configuration will be acknowledged.
455
+
456
+ ✅ 6. Import and Initialize Verified-Custody-Module and Start the application
457
+ Using the instruction on Verified Custody Module Usage initialize the module to suit your app logic,
458
+ You can start the application using:
459
+
460
+ ```jsx
461
+ npm start
462
+ ```
463
+
464
+ # React(Create React App) Folder Structure
465
+
466
+ ```pgsql
467
+ my-app/
468
+ ├── node_modules/
469
+ ├── public/
470
+ ├── src/
471
+ │ ├── App.js
472
+ │ └── index.js
473
+ ├── config-overrides.js
474
+ ├── package.json
475
+ └── README.md
476
+ ```
477
+
478
+ # 🔄 React Native(Using Expo) Setup and Fixes
479
+
480
+ ✅ 1. Initialize the Project
481
+
482
+ ```jsx
483
+ npx create-expo-app my-rn-app
484
+ cd my-rn-app
485
+ ```
486
+
487
+ ✅ 2. Install required dependencies
488
+
489
+ ```jsx
490
+ npm react-native-get-random-values expo-font @react-native-async-storage/async-storage
491
+ OR
492
+ yarn add react-native-get-random-values expo-font @react-native-async-storage/async-storage
493
+ ```
494
+
495
+ ✅ 3. Install other dependencies for node polyfils
496
+
497
+ ```jsx
498
+ npm install --save-dev crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
499
+ OR
500
+ yarn add crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
501
+ ```
502
+
503
+ note: the above dependencies are required as external/peer dependencies for the module to work on react-native.
504
+
505
+ ✅ 4. Modify the (tabs) index.js or index.ts
506
+ In the app/(tabs) folder, open the index.js or index.ts file and add:
507
+
508
+ ```jsx
509
+ //index.js or index.ts
510
+
511
+ import "react-native-get-random-values";
512
+ OR
513
+ require("react-native-get-random-values")
514
+ };
515
+ ```
516
+
517
+ note the react-native-get-random-values import needs to be on the first line of the file so this is import early before the custody module is used. The react-native-get-random-values is very important for node packages like crypto and various hashing/encryption functions to work.
518
+
519
+ ✅ 6. Import and Initialize Verified-Custody-Module and Start the application
520
+ Using the instruction on Verified Custody Module Usage initialize the module to suit your app logic,
521
+ You can start the application using:
522
+
523
+ ```jsx
524
+ npm start(if your script is setup)
525
+ OR
526
+ npx expo start
527
+ OR
528
+ npx expo run:android (to start the application on android)
529
+ OR
530
+ npx expo run:ios (to start the application on ios)
531
+ ```
532
+
533
+ # React Native(With Expo) Folder Structure
534
+
535
+ ```pgsql
536
+ my-rn-app/
537
+ ├── node_modules/
538
+ ├── public/
539
+ ├── app/
540
+ │ ├── (tabs)
541
+ │ └── index.ts or index.js
542
+ ├── package.json
543
+ └── README.md
544
+ ```
545
+
546
+ # 🔄 Web Extension Setup and Fixes
547
+
548
+ Web Extension has various setup procedures, any of the setup you decide to use will work fine with Verify Custody Module.
549
+ It is important to know that Web extension are to be built like react app and therefore during build react native related dependencies should be ignored or set as external.
550
+ This can be done using plugin on webpack.
551
+ For Example:
552
+
553
+ ```jsx
554
+ plugins: [
555
+ {
556
+ name: "node-and-react-native-polyfills",
557
+ setup(build) {
558
+ // treat react-native as external don't build
559
+ build.onResolve({ filter: /^react-native$/ }, () => {
560
+ return { external: true };
561
+ });
562
+ build.onResolve({ filter: /^expo-font$/ }, () => {
563
+ return { external: true };
564
+ });
565
+ build.onResolve(
566
+ { filter: /^@react-native-async-storage\/async-storage$/ },
567
+ () => {
568
+ return { external: true };
569
+ }
570
+ );
571
+
572
+ ...Other polyfills
573
+ },
574
+ }
575
+ ]
576
+ ```
577
+
353
578
  ## Summary
354
579
 
355
580
  - Secure blockchain wallet custody with private key sharding and on-chain encrypted storage.
package/dist/index.d.mts CHANGED
@@ -52,12 +52,13 @@ interface VerifiedCustodyProps {
52
52
  }
53
53
  interface VerifiedCustodyHelpers {
54
54
  sendCoSignerInvitation: (channel: "sms" | "email", cosigerId: string, cretorId: string, hashedCretorPin: string) => Promise<boolean>;
55
- sendCreatorConfirmation: (channel: "sms" | "email", cretorId: string, cosigersList: [], requiredSigners: number) => Promise<boolean>;
55
+ sendCreatorConfirmation: (channel: "sms" | "email", cretorId: string, cosigersList: [], requiredSigners: number, hashedCretorPin: string, isRemoved?: boolean) => Promise<boolean>;
56
56
  sendCreatorInitiation: (channel: "sms" | "email", cretorId: string, hashedCretorPin: string, txId: number, requiredSigners: number) => Promise<boolean>;
57
- sendCreatorSigned: (channel: "sms" | "email", cretorId: string, coSignerId: string) => Promise<boolean>;
57
+ sendCreatorSigned: (channel: "sms" | "email", cretorId: string, coSignerId: string, vaultPinHashed: string) => Promise<boolean>;
58
58
  sendCreatorCompleted: (channel: "sms" | "email", cretorId: string, txId: number) => Promise<boolean>;
59
- sendCreatorAcceptance: (channel: "sms" | "email", creatorId: string, coSignerId: string) => Promise<boolean>;
60
- sendCreatorRejection: (channel: "sms" | "email", creatorId: string, coSignerId: string) => Promise<boolean>;
59
+ sendCreatorAuthChanged: (channel: "sms" | "email", cretorId: string, vaultPinHashed: string, oldVaultPinHashed: string, timestamp: number) => Promise<boolean>;
60
+ sendCreatorAcceptance: (channel: "sms" | "email", creatorId: string, coSignerId: string, vaultPinHashed: string) => Promise<boolean>;
61
+ sendCreatorRejection: (channel: "sms" | "email", creatorId: string, coSignerId: string, vaultPinHashed: string) => Promise<boolean>;
61
62
  sendOTPVerification: (creatorUniqueId: string, channel: "sms" | "email", creatorId: string) => Promise<boolean>;
62
63
  checkOTPVerification: (creatorUniqueId: string, creatorId: string, otp: string) => Promise<boolean>;
63
64
  }
@@ -102,6 +103,8 @@ declare const FTUPage: (props: {
102
103
  helperFunctions?: VerifiedCustodyHelpers;
103
104
  setIsLoading?: (isLoading: boolean) => void;
104
105
  setShowDashboard?: (showDashboard: boolean) => void;
106
+ setShowResetPin?: (showResetPin: boolean) => void;
107
+ setShowRemoveCosigner?: (showRemoveCosigner: boolean) => void;
105
108
  dashbordElement?: React$1.ComponentType<{
106
109
  setIsLoading: React$1.Dispatch<React$1.SetStateAction<boolean>>;
107
110
  }>;
@@ -144,6 +147,8 @@ declare const EnterPinPage: (props: {
144
147
  txToSign?: any;
145
148
  setIsLoading: (isLoading: boolean) => void;
146
149
  setShowDashboard?: (showDashboard: boolean) => void;
150
+ setShowResetPin?: (showResetPin: boolean) => void;
151
+ setShowRemoveCosigner?: (showRemoveCosigner: boolean) => void;
147
152
  setShowCompleteVault?: (showDashboard: boolean) => void;
148
153
  setUserEmail?: (userEmail: string) => void;
149
154
  setUserNumberFmt?: (userNumberFmt: string) => void;
@@ -154,6 +159,9 @@ declare const EnterPinPage: (props: {
154
159
  }) => void;
155
160
  helperFunctions?: VerifiedCustodyHelpers;
156
161
  enablePhone?: boolean;
162
+ dashbordElement?: React$1.ComponentType<{
163
+ setIsLoading: React$1.Dispatch<React$1.SetStateAction<boolean>>;
164
+ }>;
157
165
  }) => React$1.JSX.Element;
158
166
 
159
167
  declare const CreatePinPage: (props: {
@@ -306,6 +314,13 @@ declare const AddCosignersPage: (props: {
306
314
  };
307
315
  helperFunctions?: VerifiedCustodyHelpers;
308
316
  enablePhone?: boolean;
317
+ action?: string;
318
+ setShowDashboard?: (showDashboard: boolean) => void;
319
+ setShowResetPin?: (showResetPin: boolean) => void;
320
+ setShowRemoveCosigner?: (showRemoveCosigner: boolean) => void;
321
+ dashbordElement?: React$1.ComponentType<{
322
+ setIsLoading: React$1.Dispatch<React$1.SetStateAction<boolean>>;
323
+ }>;
309
324
  }) => React$1.JSX.Element;
310
325
 
311
326
  /**
@@ -319,6 +334,7 @@ declare const loadAllGoogleFonts: (document: Document) => boolean;
319
334
  */
320
335
  declare const loadAllGoogleFontsRN: (expoFont: any) => Promise<boolean>;
321
336
  declare const hashTheString: (text: string) => string;
337
+ declare const hashTheBuffer: (buffer: ArrayBuffer | Uint8Array) => string;
322
338
  declare const encryptString: (text: string, secretKey: string) => string;
323
339
  declare const decryptString: (encryptedText: string, secretKey: string) => string;
324
340
  declare const publicKeyCredentialRequestOptions: () => any;
@@ -348,4 +364,4 @@ declare const VaultContextProvider: ({ children }: {
348
364
  children: any;
349
365
  }) => React$1.JSX.Element;
350
366
 
351
- export { AddCosignersPage as AddCoSignersPage, ContactPage, CreatePinPage, EnterPinPage, FTUPage, OTPPage, VaultContextProvider, VerifiedCustody, type VerifiedCustodyHelpers, type VerifiedCustodyProps, type VerifiedWalletAction, type VerifiedWalletTx, type VerifiedWalletVault, decryptString, decryptWithPasskey, encryptString, encryptWithPasskey, getPlatformComponents, hashTheString, initPlatform, loadAllGoogleFonts, loadAllGoogleFontsRN, publicKeyCredentialRequestOptions };
367
+ export { AddCosignersPage as AddCoSignersPage, ContactPage, CreatePinPage, EnterPinPage, FTUPage, OTPPage, VaultContextProvider, VerifiedCustody, type VerifiedCustodyHelpers, type VerifiedCustodyProps, type VerifiedWalletAction, type VerifiedWalletTx, type VerifiedWalletVault, decryptString, decryptWithPasskey, encryptString, encryptWithPasskey, getPlatformComponents, hashTheBuffer, hashTheString, initPlatform, loadAllGoogleFonts, loadAllGoogleFontsRN, publicKeyCredentialRequestOptions };
package/dist/index.d.ts CHANGED
@@ -52,12 +52,13 @@ interface VerifiedCustodyProps {
52
52
  }
53
53
  interface VerifiedCustodyHelpers {
54
54
  sendCoSignerInvitation: (channel: "sms" | "email", cosigerId: string, cretorId: string, hashedCretorPin: string) => Promise<boolean>;
55
- sendCreatorConfirmation: (channel: "sms" | "email", cretorId: string, cosigersList: [], requiredSigners: number) => Promise<boolean>;
55
+ sendCreatorConfirmation: (channel: "sms" | "email", cretorId: string, cosigersList: [], requiredSigners: number, hashedCretorPin: string, isRemoved?: boolean) => Promise<boolean>;
56
56
  sendCreatorInitiation: (channel: "sms" | "email", cretorId: string, hashedCretorPin: string, txId: number, requiredSigners: number) => Promise<boolean>;
57
- sendCreatorSigned: (channel: "sms" | "email", cretorId: string, coSignerId: string) => Promise<boolean>;
57
+ sendCreatorSigned: (channel: "sms" | "email", cretorId: string, coSignerId: string, vaultPinHashed: string) => Promise<boolean>;
58
58
  sendCreatorCompleted: (channel: "sms" | "email", cretorId: string, txId: number) => Promise<boolean>;
59
- sendCreatorAcceptance: (channel: "sms" | "email", creatorId: string, coSignerId: string) => Promise<boolean>;
60
- sendCreatorRejection: (channel: "sms" | "email", creatorId: string, coSignerId: string) => Promise<boolean>;
59
+ sendCreatorAuthChanged: (channel: "sms" | "email", cretorId: string, vaultPinHashed: string, oldVaultPinHashed: string, timestamp: number) => Promise<boolean>;
60
+ sendCreatorAcceptance: (channel: "sms" | "email", creatorId: string, coSignerId: string, vaultPinHashed: string) => Promise<boolean>;
61
+ sendCreatorRejection: (channel: "sms" | "email", creatorId: string, coSignerId: string, vaultPinHashed: string) => Promise<boolean>;
61
62
  sendOTPVerification: (creatorUniqueId: string, channel: "sms" | "email", creatorId: string) => Promise<boolean>;
62
63
  checkOTPVerification: (creatorUniqueId: string, creatorId: string, otp: string) => Promise<boolean>;
63
64
  }
@@ -102,6 +103,8 @@ declare const FTUPage: (props: {
102
103
  helperFunctions?: VerifiedCustodyHelpers;
103
104
  setIsLoading?: (isLoading: boolean) => void;
104
105
  setShowDashboard?: (showDashboard: boolean) => void;
106
+ setShowResetPin?: (showResetPin: boolean) => void;
107
+ setShowRemoveCosigner?: (showRemoveCosigner: boolean) => void;
105
108
  dashbordElement?: React$1.ComponentType<{
106
109
  setIsLoading: React$1.Dispatch<React$1.SetStateAction<boolean>>;
107
110
  }>;
@@ -144,6 +147,8 @@ declare const EnterPinPage: (props: {
144
147
  txToSign?: any;
145
148
  setIsLoading: (isLoading: boolean) => void;
146
149
  setShowDashboard?: (showDashboard: boolean) => void;
150
+ setShowResetPin?: (showResetPin: boolean) => void;
151
+ setShowRemoveCosigner?: (showRemoveCosigner: boolean) => void;
147
152
  setShowCompleteVault?: (showDashboard: boolean) => void;
148
153
  setUserEmail?: (userEmail: string) => void;
149
154
  setUserNumberFmt?: (userNumberFmt: string) => void;
@@ -154,6 +159,9 @@ declare const EnterPinPage: (props: {
154
159
  }) => void;
155
160
  helperFunctions?: VerifiedCustodyHelpers;
156
161
  enablePhone?: boolean;
162
+ dashbordElement?: React$1.ComponentType<{
163
+ setIsLoading: React$1.Dispatch<React$1.SetStateAction<boolean>>;
164
+ }>;
157
165
  }) => React$1.JSX.Element;
158
166
 
159
167
  declare const CreatePinPage: (props: {
@@ -306,6 +314,13 @@ declare const AddCosignersPage: (props: {
306
314
  };
307
315
  helperFunctions?: VerifiedCustodyHelpers;
308
316
  enablePhone?: boolean;
317
+ action?: string;
318
+ setShowDashboard?: (showDashboard: boolean) => void;
319
+ setShowResetPin?: (showResetPin: boolean) => void;
320
+ setShowRemoveCosigner?: (showRemoveCosigner: boolean) => void;
321
+ dashbordElement?: React$1.ComponentType<{
322
+ setIsLoading: React$1.Dispatch<React$1.SetStateAction<boolean>>;
323
+ }>;
309
324
  }) => React$1.JSX.Element;
310
325
 
311
326
  /**
@@ -319,6 +334,7 @@ declare const loadAllGoogleFonts: (document: Document) => boolean;
319
334
  */
320
335
  declare const loadAllGoogleFontsRN: (expoFont: any) => Promise<boolean>;
321
336
  declare const hashTheString: (text: string) => string;
337
+ declare const hashTheBuffer: (buffer: ArrayBuffer | Uint8Array) => string;
322
338
  declare const encryptString: (text: string, secretKey: string) => string;
323
339
  declare const decryptString: (encryptedText: string, secretKey: string) => string;
324
340
  declare const publicKeyCredentialRequestOptions: () => any;
@@ -348,4 +364,4 @@ declare const VaultContextProvider: ({ children }: {
348
364
  children: any;
349
365
  }) => React$1.JSX.Element;
350
366
 
351
- export { AddCosignersPage as AddCoSignersPage, ContactPage, CreatePinPage, EnterPinPage, FTUPage, OTPPage, VaultContextProvider, VerifiedCustody, type VerifiedCustodyHelpers, type VerifiedCustodyProps, type VerifiedWalletAction, type VerifiedWalletTx, type VerifiedWalletVault, decryptString, decryptWithPasskey, encryptString, encryptWithPasskey, getPlatformComponents, hashTheString, initPlatform, loadAllGoogleFonts, loadAllGoogleFontsRN, publicKeyCredentialRequestOptions };
367
+ export { AddCosignersPage as AddCoSignersPage, ContactPage, CreatePinPage, EnterPinPage, FTUPage, OTPPage, VaultContextProvider, VerifiedCustody, type VerifiedCustodyHelpers, type VerifiedCustodyProps, type VerifiedWalletAction, type VerifiedWalletTx, type VerifiedWalletVault, decryptString, decryptWithPasskey, encryptString, encryptWithPasskey, getPlatformComponents, hashTheBuffer, hashTheString, initPlatform, loadAllGoogleFonts, loadAllGoogleFontsRN, publicKeyCredentialRequestOptions };