@verified-network/verified-custody 0.4.2 → 0.4.4

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,204 @@ function App() {
350
350
  }
351
351
  ```
352
352
 
353
+ # 🔄 React(Create React App) Setup and Fixes
354
+ ✅ 1. Initialize the Project
355
+ ```jsx
356
+ npx create-react-app my-app
357
+ cd my-app
358
+ ```
359
+
360
+ ✅ 2. Install react-app-rewired
361
+ ```jsx
362
+ npm install react-app-rewired --save-dev
363
+ OR
364
+ yarn add --dev react-app-rewired
365
+ ```
366
+ ✅ 3. Install other dependencies for node polyfils
367
+ ```jsx
368
+ npm install --save-dev crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
369
+ OR
370
+ yarn add crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
371
+ ```
372
+ 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.
373
+
374
+ ✅ 4. Override create-react-app webpack configuration
375
+ In the root folder of your project, create a new file named 'config-overrides.js', and add:
376
+ ```jsx
377
+ //config-overrides.js
378
+
379
+ const webpack = require("webpack");
380
+ module.exports = function override(config) {
381
+ const fallback = config.resolve.fallback || {};
382
+ Object.assign(fallback, {
383
+ crypto: require.resolve("crypto-browserify"),
384
+ stream: require.resolve("stream-browserify"),
385
+ assert: require.resolve("assert"),
386
+ http: require.resolve("stream-http"),
387
+ https: require.resolve("https-browserify"),
388
+ os: require.resolve("os-browserify"),
389
+ url: require.resolve("url"),
390
+ path: require.resolve("path-browserify"),
391
+ vm: require.resolve("vm-browserify"),
392
+ fs: false,
393
+ });
394
+ config.plugins.push(
395
+ new webpack.IgnorePlugin({
396
+ resourceRegExp:
397
+ /^react-native$|^expo-font$|^@react-native-async-storage\/async-storage$/,
398
+ })
399
+ );
400
+
401
+ config.plugins = (config.plugins || []).concat([
402
+ new webpack.ProvidePlugin({
403
+ process: "process/browser",
404
+ Buffer: ["buffer", "Buffer"],
405
+ }),
406
+ ]);
407
+ config.module.rules = [
408
+ ...config.module.rules,
409
+ {
410
+ test: /\.m?js/,
411
+ resolve: {
412
+ fullySpecified: false,
413
+ },
414
+ },
415
+ ];
416
+ config.resolve.fallback = fallback;
417
+ config.ignoreWarnings = [/Failed to parse source map/];
418
+ return config;
419
+ };
420
+ ```
421
+ 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.
422
+
423
+ ✅ 5. Modify package.json Scripts
424
+ In your package.json, replace this:
425
+ ```json
426
+ "scripts": {
427
+ "start": "react-scripts start",
428
+ "build": "react-scripts build",
429
+ "test": "react-scripts test",
430
+ "eject": "react-scripts eject"
431
+ }
432
+ ```
433
+ With this:
434
+ ```json
435
+ "scripts": {
436
+ "start": "react-app-rewired start",
437
+ "build": "react-app-rewired build",
438
+ "test": "react-app-rewired test"
439
+ }
440
+
441
+ ```
442
+ 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.
443
+
444
+ ✅ 6. Import and Initialize Verified-Custody-Module and Start the application
445
+ Using the instruction on Verified Custody Module Usage initialize the module to suit your app logic,
446
+ You can start the application using:
447
+ ```jsx
448
+ npm start
449
+ ```
450
+ # React(Create React App) Folder Structure
451
+ ```pgsql
452
+ my-app/
453
+ ├── node_modules/
454
+ ├── public/
455
+ ├── src/
456
+ │ ├── App.js
457
+ │ └── index.js
458
+ ├── config-overrides.js
459
+ ├── package.json
460
+ └── README.md
461
+ ```
462
+
463
+ # 🔄 React Native(Using Expo) Setup and Fixes
464
+ ✅ 1. Initialize the Project
465
+ ```jsx
466
+ npx create-expo-app my-rn-app
467
+ cd my-rn-app
468
+ ```
469
+
470
+ ✅ 2. Install required dependencies
471
+ ```jsx
472
+ npm react-native-get-random-values expo-font @react-native-async-storage/async-storage
473
+ OR
474
+ yarn add react-native-get-random-values expo-font @react-native-async-storage/async-storage
475
+ ```
476
+ ✅ 3. Install other dependencies for node polyfils
477
+ ```jsx
478
+ npm install --save-dev crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
479
+ OR
480
+ yarn add crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url path-browserify vm-browserify buffer process
481
+ ```
482
+ note: the above dependencies are required as external/peer dependencies for the module to work on react-native.
483
+
484
+
485
+ ✅ 4. Modify the (tabs) index.js or index.ts
486
+ In the app/(tabs) folder, open the index.js or index.ts file and add:
487
+ ```jsx
488
+ //index.js or index.ts
489
+
490
+ import "react-native-get-random-values";
491
+ OR
492
+ require("react-native-get-random-values")
493
+ };
494
+ ```
495
+ 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.
496
+
497
+ ✅ 6. Import and Initialize Verified-Custody-Module and Start the application
498
+ Using the instruction on Verified Custody Module Usage initialize the module to suit your app logic,
499
+ You can start the application using:
500
+ ```jsx
501
+ npm start(if your script is setup)
502
+ OR
503
+ npx expo start
504
+ OR
505
+ npx expo run:android (to start the application on android)
506
+ OR
507
+ npx expo run:ios (to start the application on ios)
508
+ ```
509
+ # React Native(With Expo) Folder Structure
510
+ ```pgsql
511
+ my-rn-app/
512
+ ├── node_modules/
513
+ ├── public/
514
+ ├── app/
515
+ │ ├── (tabs)
516
+ │ └── index.ts or index.js
517
+ ├── package.json
518
+ └── README.md
519
+ ```
520
+
521
+ # 🔄 Web Extension Setup and Fixes
522
+ Web Extension has various setup procedures, any of the setup you decide to use will work fine with Verify Custody Module.
523
+ 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.
524
+ This can be done using plugin on webpack.
525
+ For Example:
526
+ ```jsx
527
+ plugins: [
528
+ {
529
+ name: "node-and-react-native-polyfills",
530
+ setup(build) {
531
+ // treat react-native as external don't build
532
+ build.onResolve({ filter: /^react-native$/ }, () => {
533
+ return { external: true };
534
+ });
535
+ build.onResolve({ filter: /^expo-font$/ }, () => {
536
+ return { external: true };
537
+ });
538
+ build.onResolve(
539
+ { filter: /^@react-native-async-storage\/async-storage$/ },
540
+ () => {
541
+ return { external: true };
542
+ }
543
+ );
544
+
545
+ ...Other polyfills
546
+ },
547
+ }
548
+ ]
549
+ ```
550
+
353
551
  ## Summary
354
552
 
355
553
  - 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 };