@metamask-previews/seedless-onboarding-controller 0.0.0-preview-ddbcf048

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 (60) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +20 -0
  3. package/README.md +15 -0
  4. package/dist/SeedPhraseMetadata.cjs +146 -0
  5. package/dist/SeedPhraseMetadata.cjs.map +1 -0
  6. package/dist/SeedPhraseMetadata.d.cts +82 -0
  7. package/dist/SeedPhraseMetadata.d.cts.map +1 -0
  8. package/dist/SeedPhraseMetadata.d.mts +82 -0
  9. package/dist/SeedPhraseMetadata.d.mts.map +1 -0
  10. package/dist/SeedPhraseMetadata.mjs +142 -0
  11. package/dist/SeedPhraseMetadata.mjs.map +1 -0
  12. package/dist/SeedlessOnboardingController.cjs +578 -0
  13. package/dist/SeedlessOnboardingController.cjs.map +1 -0
  14. package/dist/SeedlessOnboardingController.d.cts +87 -0
  15. package/dist/SeedlessOnboardingController.d.cts.map +1 -0
  16. package/dist/SeedlessOnboardingController.d.mts +87 -0
  17. package/dist/SeedlessOnboardingController.d.mts.map +1 -0
  18. package/dist/SeedlessOnboardingController.mjs +573 -0
  19. package/dist/SeedlessOnboardingController.mjs.map +1 -0
  20. package/dist/constants.cjs +29 -0
  21. package/dist/constants.cjs.map +1 -0
  22. package/dist/constants.d.cts +24 -0
  23. package/dist/constants.d.cts.map +1 -0
  24. package/dist/constants.d.mts +24 -0
  25. package/dist/constants.d.mts.map +1 -0
  26. package/dist/constants.mjs +26 -0
  27. package/dist/constants.mjs.map +1 -0
  28. package/dist/errors.cjs +76 -0
  29. package/dist/errors.cjs.map +1 -0
  30. package/dist/errors.d.cts +26 -0
  31. package/dist/errors.d.cts.map +1 -0
  32. package/dist/errors.d.mts +26 -0
  33. package/dist/errors.d.mts.map +1 -0
  34. package/dist/errors.mjs +72 -0
  35. package/dist/errors.mjs.map +1 -0
  36. package/dist/index.cjs +24 -0
  37. package/dist/index.cjs.map +1 -0
  38. package/dist/index.d.cts +5 -0
  39. package/dist/index.d.cts.map +1 -0
  40. package/dist/index.d.mts +5 -0
  41. package/dist/index.d.mts.map +1 -0
  42. package/dist/index.mjs +4 -0
  43. package/dist/index.mjs.map +1 -0
  44. package/dist/logger.cjs +8 -0
  45. package/dist/logger.cjs.map +1 -0
  46. package/dist/logger.d.cts +5 -0
  47. package/dist/logger.d.cts.map +1 -0
  48. package/dist/logger.d.mts +5 -0
  49. package/dist/logger.d.mts.map +1 -0
  50. package/dist/logger.mjs +5 -0
  51. package/dist/logger.mjs.map +1 -0
  52. package/dist/types.cjs +3 -0
  53. package/dist/types.cjs.map +1 -0
  54. package/dist/types.d.cts +120 -0
  55. package/dist/types.d.cts.map +1 -0
  56. package/dist/types.d.mts +120 -0
  57. package/dist/types.d.mts.map +1 -0
  58. package/dist/types.mjs +2 -0
  59. package/dist/types.mjs.map +1 -0
  60. package/package.json +80 -0
@@ -0,0 +1,120 @@
1
+ import type { RestrictedMessenger } from "@metamask/base-controller";
2
+ import type { ControllerGetStateAction } from "@metamask/base-controller";
3
+ import type { ControllerStateChangeEvent } from "@metamask/base-controller";
4
+ import type { NodeAuthTokens } from "@metamask/toprf-secure-backup";
5
+ import type { Json } from "@metamask/utils";
6
+ import type { MutexInterface } from "async-mutex";
7
+ import type { controllerName, Web3AuthNetwork } from "./constants.cjs";
8
+ export type AuthenticatedUserDetails = {
9
+ /**
10
+ * The node auth tokens from OAuth User authentication after the Social login.
11
+ *
12
+ * This values are used to authenticate users when they go through the Seedless Onboarding flow.
13
+ */
14
+ nodeAuthTokens: NodeAuthTokens;
15
+ /**
16
+ * OAuth connection id from web3auth dashboard.
17
+ */
18
+ authConnectionId: string;
19
+ /**
20
+ * The optional grouped authConnectionId to authenticate the user with Web3Auth network.
21
+ */
22
+ groupedAuthConnectionId?: string;
23
+ /**
24
+ * The user email or ID from Social login.
25
+ */
26
+ userId: string;
27
+ };
28
+ export type SeedlessOnboardingControllerState = Partial<AuthenticatedUserDetails> & {
29
+ /**
30
+ * Encrypted array of serialized keyrings data.
31
+ */
32
+ vault?: string;
33
+ /**
34
+ * The hashes of the seed phrase backups.
35
+ *
36
+ * This is to facilitate the UI to display backup status of the seed phrases.
37
+ */
38
+ backupHashes: string[];
39
+ };
40
+ export type SeedlessOnboardingControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SeedlessOnboardingControllerState>;
41
+ export type SeedlessOnboardingControllerActions = SeedlessOnboardingControllerGetStateAction;
42
+ export type AllowedActions = never;
43
+ export type SeedlessOnboardingControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SeedlessOnboardingControllerState>;
44
+ export type SeedlessOnboardingControllerEvents = SeedlessOnboardingControllerStateChangeEvent;
45
+ export type AllowedEvents = never;
46
+ export type SeedlessOnboardingControllerMessenger = RestrictedMessenger<typeof controllerName, SeedlessOnboardingControllerActions | AllowedActions, SeedlessOnboardingControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
47
+ /**
48
+ * Encryptor interface for encrypting and decrypting seedless onboarding vault.
49
+ */
50
+ export type VaultEncryptor = {
51
+ /**
52
+ * Encrypts the given object with the given password.
53
+ *
54
+ * @param password - The password to encrypt with.
55
+ * @param object - The object to encrypt.
56
+ * @returns The encrypted string.
57
+ */
58
+ encrypt: (password: string, object: Json) => Promise<string>;
59
+ /**
60
+ * Decrypts the given encrypted string with the given password.
61
+ *
62
+ * @param password - The password to decrypt with.
63
+ * @param encryptedString - The encrypted string to decrypt.
64
+ * @returns The decrypted object.
65
+ */
66
+ decrypt: (password: string, encryptedString: string) => Promise<unknown>;
67
+ };
68
+ /**
69
+ * Seedless Onboarding Controller Options.
70
+ *
71
+ * @param messenger - The messenger to use for this controller.
72
+ * @param state - The initial state to set on this controller.
73
+ * @param encryptor - The encryptor to use for encrypting and decrypting seedless onboarding vault.
74
+ */
75
+ export type SeedlessOnboardingControllerOptions = {
76
+ messenger: SeedlessOnboardingControllerMessenger;
77
+ /**
78
+ * Initial state to set on this controller.
79
+ */
80
+ state?: Partial<SeedlessOnboardingControllerState>;
81
+ /**
82
+ * Encryptor to use for encrypting and decrypting seedless onboarding vault.
83
+ *
84
+ * @default browser-passworder @link https://github.com/MetaMask/browser-passworder
85
+ */
86
+ encryptor?: VaultEncryptor;
87
+ /**
88
+ * Type of Web3Auth network to be used for the Seedless Onboarding flow.
89
+ *
90
+ * @default Web3AuthNetwork.Mainnet
91
+ */
92
+ network?: Web3AuthNetwork;
93
+ };
94
+ /**
95
+ * A function executed within a mutually exclusive lock, with
96
+ * a mutex releaser in its option bag.
97
+ *
98
+ * @param releaseLock - A function to release the lock.
99
+ */
100
+ export type MutuallyExclusiveCallback<Result> = ({ releaseLock, }: {
101
+ releaseLock: MutexInterface.Releaser;
102
+ }) => Promise<Result>;
103
+ /**
104
+ * The structure of the data which is serialized and stored in the vault.
105
+ */
106
+ export type VaultData = {
107
+ /**
108
+ * The node auth tokens from OAuth User authentication after the Social login.
109
+ */
110
+ authTokens: NodeAuthTokens;
111
+ /**
112
+ * The encryption key to encrypt the seed phrase.
113
+ */
114
+ toprfEncryptionKey: string;
115
+ /**
116
+ * The authentication key pair to authenticate the TOPRF.
117
+ */
118
+ toprfAuthKeyPair: string;
119
+ };
120
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAC1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,kCAAkC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,sCAAsC;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,wBAAoB;AAEnE,MAAM,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C;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,SAAS,EAAE,qCAAqC,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAEnD;;;;OAIG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,CAAC,MAAM,IAAI,CAAC,EAC/C,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,cAAc,CAAC,QAAQ,CAAC;CACtC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,UAAU,EAAE,cAAc,CAAC;IAC3B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC"}
@@ -0,0 +1,120 @@
1
+ import type { RestrictedMessenger } from "@metamask/base-controller";
2
+ import type { ControllerGetStateAction } from "@metamask/base-controller";
3
+ import type { ControllerStateChangeEvent } from "@metamask/base-controller";
4
+ import type { NodeAuthTokens } from "@metamask/toprf-secure-backup";
5
+ import type { Json } from "@metamask/utils";
6
+ import type { MutexInterface } from "async-mutex";
7
+ import type { controllerName, Web3AuthNetwork } from "./constants.mjs";
8
+ export type AuthenticatedUserDetails = {
9
+ /**
10
+ * The node auth tokens from OAuth User authentication after the Social login.
11
+ *
12
+ * This values are used to authenticate users when they go through the Seedless Onboarding flow.
13
+ */
14
+ nodeAuthTokens: NodeAuthTokens;
15
+ /**
16
+ * OAuth connection id from web3auth dashboard.
17
+ */
18
+ authConnectionId: string;
19
+ /**
20
+ * The optional grouped authConnectionId to authenticate the user with Web3Auth network.
21
+ */
22
+ groupedAuthConnectionId?: string;
23
+ /**
24
+ * The user email or ID from Social login.
25
+ */
26
+ userId: string;
27
+ };
28
+ export type SeedlessOnboardingControllerState = Partial<AuthenticatedUserDetails> & {
29
+ /**
30
+ * Encrypted array of serialized keyrings data.
31
+ */
32
+ vault?: string;
33
+ /**
34
+ * The hashes of the seed phrase backups.
35
+ *
36
+ * This is to facilitate the UI to display backup status of the seed phrases.
37
+ */
38
+ backupHashes: string[];
39
+ };
40
+ export type SeedlessOnboardingControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SeedlessOnboardingControllerState>;
41
+ export type SeedlessOnboardingControllerActions = SeedlessOnboardingControllerGetStateAction;
42
+ export type AllowedActions = never;
43
+ export type SeedlessOnboardingControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SeedlessOnboardingControllerState>;
44
+ export type SeedlessOnboardingControllerEvents = SeedlessOnboardingControllerStateChangeEvent;
45
+ export type AllowedEvents = never;
46
+ export type SeedlessOnboardingControllerMessenger = RestrictedMessenger<typeof controllerName, SeedlessOnboardingControllerActions | AllowedActions, SeedlessOnboardingControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
47
+ /**
48
+ * Encryptor interface for encrypting and decrypting seedless onboarding vault.
49
+ */
50
+ export type VaultEncryptor = {
51
+ /**
52
+ * Encrypts the given object with the given password.
53
+ *
54
+ * @param password - The password to encrypt with.
55
+ * @param object - The object to encrypt.
56
+ * @returns The encrypted string.
57
+ */
58
+ encrypt: (password: string, object: Json) => Promise<string>;
59
+ /**
60
+ * Decrypts the given encrypted string with the given password.
61
+ *
62
+ * @param password - The password to decrypt with.
63
+ * @param encryptedString - The encrypted string to decrypt.
64
+ * @returns The decrypted object.
65
+ */
66
+ decrypt: (password: string, encryptedString: string) => Promise<unknown>;
67
+ };
68
+ /**
69
+ * Seedless Onboarding Controller Options.
70
+ *
71
+ * @param messenger - The messenger to use for this controller.
72
+ * @param state - The initial state to set on this controller.
73
+ * @param encryptor - The encryptor to use for encrypting and decrypting seedless onboarding vault.
74
+ */
75
+ export type SeedlessOnboardingControllerOptions = {
76
+ messenger: SeedlessOnboardingControllerMessenger;
77
+ /**
78
+ * Initial state to set on this controller.
79
+ */
80
+ state?: Partial<SeedlessOnboardingControllerState>;
81
+ /**
82
+ * Encryptor to use for encrypting and decrypting seedless onboarding vault.
83
+ *
84
+ * @default browser-passworder @link https://github.com/MetaMask/browser-passworder
85
+ */
86
+ encryptor?: VaultEncryptor;
87
+ /**
88
+ * Type of Web3Auth network to be used for the Seedless Onboarding flow.
89
+ *
90
+ * @default Web3AuthNetwork.Mainnet
91
+ */
92
+ network?: Web3AuthNetwork;
93
+ };
94
+ /**
95
+ * A function executed within a mutually exclusive lock, with
96
+ * a mutex releaser in its option bag.
97
+ *
98
+ * @param releaseLock - A function to release the lock.
99
+ */
100
+ export type MutuallyExclusiveCallback<Result> = ({ releaseLock, }: {
101
+ releaseLock: MutexInterface.Releaser;
102
+ }) => Promise<Result>;
103
+ /**
104
+ * The structure of the data which is serialized and stored in the vault.
105
+ */
106
+ export type VaultData = {
107
+ /**
108
+ * The node auth tokens from OAuth User authentication after the Social login.
109
+ */
110
+ authTokens: NodeAuthTokens;
111
+ /**
112
+ * The encryption key to encrypt the seed phrase.
113
+ */
114
+ toprfEncryptionKey: string;
115
+ /**
116
+ * The authentication key pair to authenticate the TOPRF.
117
+ */
118
+ toprfAuthKeyPair: string;
119
+ };
120
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAC1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,kCAAkC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,sCAAsC;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB;AAElD,OAAO,KAAK,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AAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1E,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,SAAS,EAAE,qCAAqC,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAEnD;;;;OAIG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,CAAC,MAAM,IAAI,CAAC,EAC/C,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,cAAc,CAAC,QAAQ,CAAC;CACtC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,UAAU,EAAE,cAAc,CAAC;IAC3B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC"}
package/dist/types.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RestrictedMessenger } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { NodeAuthTokens } from '@metamask/toprf-secure-backup';\nimport type { Json } from '@metamask/utils';\nimport type { MutexInterface } from 'async-mutex';\n\nimport type { controllerName, Web3AuthNetwork } from './constants';\n\nexport type AuthenticatedUserDetails = {\n /**\n * The node auth tokens from OAuth User authentication after the Social login.\n *\n * This values are used to authenticate users when they go through the Seedless Onboarding flow.\n */\n nodeAuthTokens: NodeAuthTokens;\n\n /**\n * OAuth connection id from web3auth dashboard.\n */\n authConnectionId: string;\n\n /**\n * The optional grouped authConnectionId to authenticate the user with Web3Auth network.\n */\n groupedAuthConnectionId?: string;\n\n /**\n * The user email or ID from Social login.\n */\n userId: string;\n};\n\n// State\nexport type SeedlessOnboardingControllerState =\n Partial<AuthenticatedUserDetails> & {\n /**\n * Encrypted array of serialized keyrings data.\n */\n vault?: string;\n\n /**\n * The hashes of the seed phrase backups.\n *\n * This is to facilitate the UI to display backup status of the seed phrases.\n */\n backupHashes: string[];\n };\n\n// Actions\nexport type SeedlessOnboardingControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n SeedlessOnboardingControllerState\n >;\nexport type SeedlessOnboardingControllerActions =\n SeedlessOnboardingControllerGetStateAction;\n\nexport type AllowedActions = never;\n\n// Events\nexport type SeedlessOnboardingControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n SeedlessOnboardingControllerState\n >;\nexport type SeedlessOnboardingControllerEvents =\n SeedlessOnboardingControllerStateChangeEvent;\n\nexport type AllowedEvents = never;\n\n// Messenger\nexport type SeedlessOnboardingControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n SeedlessOnboardingControllerActions | AllowedActions,\n SeedlessOnboardingControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Encryptor interface for encrypting and decrypting seedless onboarding vault.\n */\nexport type VaultEncryptor = {\n /**\n * Encrypts the given object with the given password.\n *\n * @param password - The password to encrypt with.\n * @param object - The object to encrypt.\n * @returns The encrypted string.\n */\n encrypt: (password: string, object: Json) => Promise<string>;\n /**\n * Decrypts the given encrypted string with the given password.\n *\n * @param password - The password to decrypt with.\n * @param encryptedString - The encrypted string to decrypt.\n * @returns The decrypted object.\n */\n decrypt: (password: string, encryptedString: string) => Promise<unknown>;\n};\n\n/**\n * Seedless Onboarding Controller Options.\n *\n * @param messenger - The messenger to use for this controller.\n * @param state - The initial state to set on this controller.\n * @param encryptor - The encryptor to use for encrypting and decrypting seedless onboarding vault.\n */\nexport type SeedlessOnboardingControllerOptions = {\n messenger: SeedlessOnboardingControllerMessenger;\n\n /**\n * Initial state to set on this controller.\n */\n state?: Partial<SeedlessOnboardingControllerState>;\n\n /**\n * Encryptor to use for encrypting and decrypting seedless onboarding vault.\n *\n * @default browser-passworder @link https://github.com/MetaMask/browser-passworder\n */\n encryptor?: VaultEncryptor;\n\n /**\n * Type of Web3Auth network to be used for the Seedless Onboarding flow.\n *\n * @default Web3AuthNetwork.Mainnet\n */\n network?: Web3AuthNetwork;\n};\n\n/**\n * A function executed within a mutually exclusive lock, with\n * a mutex releaser in its option bag.\n *\n * @param releaseLock - A function to release the lock.\n */\nexport type MutuallyExclusiveCallback<Result> = ({\n releaseLock,\n}: {\n releaseLock: MutexInterface.Releaser;\n}) => Promise<Result>;\n\n/**\n * The structure of the data which is serialized and stored in the vault.\n */\nexport type VaultData = {\n /**\n * The node auth tokens from OAuth User authentication after the Social login.\n */\n authTokens: NodeAuthTokens;\n /**\n * The encryption key to encrypt the seed phrase.\n */\n toprfEncryptionKey: string;\n /**\n * The authentication key pair to authenticate the TOPRF.\n */\n toprfAuthKeyPair: string;\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@metamask-previews/seedless-onboarding-controller",
3
+ "version": "0.0.0-preview-ddbcf048",
4
+ "description": "Backup and rehydrate SRP(s) using social login and password",
5
+ "keywords": [
6
+ "MetaMask",
7
+ "Ethereum"
8
+ ],
9
+ "homepage": "https://github.com/MetaMask/core/tree/main/packages/seedless-onboarding-controller#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/MetaMask/core/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/MetaMask/core.git"
16
+ },
17
+ "license": "MIT",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "types": "./dist/index.d.cts",
34
+ "files": [
35
+ "dist/"
36
+ ],
37
+ "scripts": {
38
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
39
+ "build:docs": "typedoc",
40
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/seedless-onboarding-controller",
41
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/seedless-onboarding-controller",
42
+ "publish:preview": "yarn npm publish --tag preview",
43
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
44
+ "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
45
+ "test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
46
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
47
+ "since-latest-release": "../../scripts/since-latest-release.sh"
48
+ },
49
+ "dependencies": {
50
+ "@metamask/auth-network-utils": "./auth-network-utils.tgz",
51
+ "@metamask/base-controller": "^8.0.0",
52
+ "@metamask/browser-passworder": "^4.3.0",
53
+ "@metamask/toprf-secure-backup": "./toprf-secure-backup.tgz",
54
+ "@metamask/utils": "^11.2.0",
55
+ "async-mutex": "^0.5.0"
56
+ },
57
+ "devDependencies": {
58
+ "@metamask/auto-changelog": "^3.4.4",
59
+ "@noble/ciphers": "^0.5.2",
60
+ "@noble/curves": "^1.2.0",
61
+ "@noble/hashes": "^1.4.0",
62
+ "@types/elliptic": "^6",
63
+ "@types/jest": "^27.4.1",
64
+ "deepmerge": "^4.2.2",
65
+ "jest": "^27.5.1",
66
+ "jest-environment-node": "^27.5.1",
67
+ "nock": "^13.3.1",
68
+ "ts-jest": "^27.1.4",
69
+ "typedoc": "^0.24.8",
70
+ "typedoc-plugin-missing-exports": "^2.0.0",
71
+ "typescript": "~5.2.2"
72
+ },
73
+ "engines": {
74
+ "node": "^18.18 || >=20"
75
+ },
76
+ "publishConfig": {
77
+ "access": "public",
78
+ "registry": "https://registry.npmjs.org/"
79
+ }
80
+ }