@exodus/headless 4.0.0-rc.1 → 4.0.0-rc.10
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/package.json +12 -13
- package/src/api/index.js +1 -0
- package/src/application/constants.js +1 -1
- package/src/application/module/application.js +10 -2
- package/src/application/plugins/lifecycle.js +2 -5
- package/src/dependencies/modules.js +0 -6
- package/src/index.js +2 -2
- package/src/plugins/log-lifecycle.js +0 -1
- package/src/unlock-encrypted-storage.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/headless",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.10",
|
|
4
4
|
"description": "The platform-agnostic Exodus wallet SDK",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"!**/*.test.js"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"lint": "eslint . --ignore-path ../../.gitignore",
|
|
24
|
+
"lint": "run -T eslint . --ignore-path ../../.gitignore",
|
|
25
25
|
"lint:fix": "yarn lint --fix",
|
|
26
|
-
"test": "NODE_OPTIONS=--max-old-space-size=4096 jest"
|
|
26
|
+
"test": "NODE_OPTIONS=--max-old-space-size=4096 run -T jest"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@exodus/address-provider": "^10.0.0",
|
|
@@ -57,10 +57,9 @@
|
|
|
57
57
|
"@exodus/restore-progress-tracker": "^3.0.0",
|
|
58
58
|
"@exodus/sodium-crypto": "^3.2.0",
|
|
59
59
|
"@exodus/startup-counter": "^1.0.0",
|
|
60
|
-
"@exodus/tx-signer": "^2.0.
|
|
61
|
-
"@exodus/wallet": "^
|
|
62
|
-
"@exodus/wallet-accounts": "^16.
|
|
63
|
-
"@exodus/wallet-compatibility-modes": "^4.0.0",
|
|
60
|
+
"@exodus/tx-signer": "^2.0.1-rc.3",
|
|
61
|
+
"@exodus/wallet": "^13.0.0-rc.2",
|
|
62
|
+
"@exodus/wallet-accounts": "^16.2.0-rc.2",
|
|
64
63
|
"bip39": "^2.6.0",
|
|
65
64
|
"events": "^3.3.0",
|
|
66
65
|
"lodash": "npm:@exodus/lodash@^4.17.21-exodus.2",
|
|
@@ -71,8 +70,10 @@
|
|
|
71
70
|
"@exodus/algorand-lib": "^2.0.1",
|
|
72
71
|
"@exodus/algorand-meta": "^1.1.4",
|
|
73
72
|
"@exodus/analytics": "^12.0.0",
|
|
73
|
+
"@exodus/announcements": "^2.6.0",
|
|
74
74
|
"@exodus/apy-rates": "^3.3.1",
|
|
75
75
|
"@exodus/assets-feature": "^4.1.2",
|
|
76
|
+
"@exodus/bip32": "^2.1.1",
|
|
76
77
|
"@exodus/bitcoin-plugin": "^1.0.14",
|
|
77
78
|
"@exodus/connected-origins": "^3.3.0",
|
|
78
79
|
"@exodus/crypto-news-monitor": "^4.1.0",
|
|
@@ -81,13 +82,13 @@
|
|
|
81
82
|
"@exodus/ethereum-meta": "^1.0.23",
|
|
82
83
|
"@exodus/exodus-pricing-client": "^1.2.0",
|
|
83
84
|
"@exodus/key-utils": "^3.0.0",
|
|
84
|
-
"@exodus/kyc": "^4.
|
|
85
|
+
"@exodus/kyc": "^4.4.0",
|
|
85
86
|
"@exodus/litecoin-meta": "^1.0.0",
|
|
86
|
-
"@exodus/market-history": "^7.
|
|
87
|
+
"@exodus/market-history": "^7.4.0",
|
|
87
88
|
"@exodus/models": "^11.9.0",
|
|
88
|
-
"@exodus/nfts": "^8.0.
|
|
89
|
+
"@exodus/nfts": "^8.0.1",
|
|
89
90
|
"@exodus/personal-notes": "^3.6.0",
|
|
90
|
-
"@exodus/referrals": "^8.
|
|
91
|
+
"@exodus/referrals": "^8.2.0",
|
|
91
92
|
"@exodus/solana-lib": "^1.3.11",
|
|
92
93
|
"@exodus/solana-meta": "^1.0.2",
|
|
93
94
|
"@exodus/storage-encrypted": "^1.2.0",
|
|
@@ -98,10 +99,8 @@
|
|
|
98
99
|
"buffer-json": "^2.0.0",
|
|
99
100
|
"deepmerge": "^4.2.2",
|
|
100
101
|
"delay": "^5.0.0",
|
|
101
|
-
"eslint": "^8.44.0",
|
|
102
102
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
103
103
|
"events": "^3.3.0",
|
|
104
|
-
"jest": "^29.1.2",
|
|
105
104
|
"msw": "^2.0.0",
|
|
106
105
|
"p-defer": "^4.0.0"
|
|
107
106
|
}
|
package/src/api/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const createApi = ({ ioc, port, config, debug }) => {
|
|
|
19
19
|
// TODO: Improve api here. exodus.wallet.create makes sense, but it's confusing it calls application
|
|
20
20
|
featureApis.wallet = {
|
|
21
21
|
...featureApis.wallet,
|
|
22
|
+
addSeed: application.addSeed,
|
|
22
23
|
start: application.start,
|
|
23
24
|
stop: application.stop,
|
|
24
25
|
load: application.load,
|
|
@@ -3,6 +3,7 @@ export const LifecycleHook = Object.freeze({
|
|
|
3
3
|
Unlock: 'unlock',
|
|
4
4
|
Clear: 'clear',
|
|
5
5
|
Import: 'import',
|
|
6
|
+
AddSeed: 'add-seed',
|
|
6
7
|
Migrate: 'migrate',
|
|
7
8
|
Start: 'start',
|
|
8
9
|
Stop: 'stop',
|
|
@@ -10,7 +11,6 @@ export const LifecycleHook = Object.freeze({
|
|
|
10
11
|
Load: 'load',
|
|
11
12
|
Unload: 'unload',
|
|
12
13
|
Create: 'create',
|
|
13
|
-
Backup: 'backup',
|
|
14
14
|
Restore: 'restore',
|
|
15
15
|
RestoreCompleted: 'restore-completed',
|
|
16
16
|
AssetsSynced: 'assets-synced',
|
|
@@ -195,7 +195,6 @@ class Application extends ExodusModule {
|
|
|
195
195
|
const { forceRestart, forgotPassphrase, ...wallet } = opts
|
|
196
196
|
|
|
197
197
|
await this.#wallet.import(wallet)
|
|
198
|
-
await this.fire(Hook.Backup)
|
|
199
198
|
|
|
200
199
|
if (forceRestart || walletExists) {
|
|
201
200
|
await this.#storage.set(IMPORT_FLAG, true)
|
|
@@ -208,10 +207,19 @@ class Application extends ExodusModule {
|
|
|
208
207
|
}
|
|
209
208
|
}
|
|
210
209
|
|
|
210
|
+
addSeed = async ({ mnemonic, compatibilityMode }) => {
|
|
211
|
+
this._logger.log('adding seed to wallet')
|
|
212
|
+
|
|
213
|
+
await this.#applicationStarted
|
|
214
|
+
|
|
215
|
+
const seedId = await this.#wallet.addSeed({ mnemonic })
|
|
216
|
+
await this.fire(Hook.AddSeed, { seedId, compatibilityMode })
|
|
217
|
+
}
|
|
218
|
+
|
|
211
219
|
getMnemonic = async (opts) => this.#wallet.getMnemonic(opts)
|
|
212
220
|
|
|
213
221
|
setBackedUp = async () => {
|
|
214
|
-
await this.
|
|
222
|
+
await this.#backedUpAtom.set(true)
|
|
215
223
|
}
|
|
216
224
|
|
|
217
225
|
lock = async (opts) => {
|
|
@@ -23,6 +23,7 @@ const applicationLifecyclePlugin = ({
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const onImport = () => {
|
|
26
|
+
backedUpAtom.set(true)
|
|
26
27
|
restoreAtom.set(true)
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -30,10 +31,6 @@ const applicationLifecyclePlugin = ({
|
|
|
30
31
|
await restoreAtom.set(false)
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
const onBackup = async () => {
|
|
34
|
-
await backedUpAtom.set(true)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
34
|
const onStop = () => {
|
|
38
35
|
observers.forEach((observer) => observer.unregister())
|
|
39
36
|
}
|
|
@@ -42,7 +39,7 @@ const applicationLifecyclePlugin = ({
|
|
|
42
39
|
await backedUpAtom.set(undefined)
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
return { onStart, onLoad, onImport, onAssetsSynced,
|
|
42
|
+
return { onStart, onLoad, onImport, onAssetsSynced, onStop, onClear }
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
const applicationLifecyclePluginDefinition = {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
|
|
2
|
-
import walletCompatibilityModesDefinition from '@exodus/wallet-compatibility-modes/module'
|
|
3
2
|
|
|
4
3
|
import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
|
|
5
4
|
import { withType } from './utils'
|
|
@@ -13,11 +12,6 @@ const createModuleDependencies = ({ config }) =>
|
|
|
13
12
|
dependencies: [],
|
|
14
13
|
},
|
|
15
14
|
},
|
|
16
|
-
{
|
|
17
|
-
definition: walletCompatibilityModesDefinition,
|
|
18
|
-
storage: { namespace: 'walletCompatibilityModes' },
|
|
19
|
-
aliases: [{ implementationId: 'unsafeStorage', interfaceId: 'storage' }],
|
|
20
|
-
},
|
|
21
15
|
{ definition: unlockEncryptedStorageDefinition },
|
|
22
16
|
].map(withType('module'))
|
|
23
17
|
|
package/src/index.js
CHANGED
|
@@ -89,8 +89,6 @@ const createExodus = ({ adapters, config, port, debug = false }) => {
|
|
|
89
89
|
|
|
90
90
|
application.on('lock', () => port.emit('lock'))
|
|
91
91
|
|
|
92
|
-
application.on('backup', () => port.emit('backup'))
|
|
93
|
-
|
|
94
92
|
application.on('restore', () => port.emit('restore'))
|
|
95
93
|
|
|
96
94
|
application.on('restore-completed', () => {
|
|
@@ -101,6 +99,8 @@ const createExodus = ({ adapters, config, port, debug = false }) => {
|
|
|
101
99
|
|
|
102
100
|
application.on('import', () => port.emit('import', { walletExists: true }))
|
|
103
101
|
|
|
102
|
+
application.on('add-seed', () => port.emit('add-seed'))
|
|
103
|
+
|
|
104
104
|
application.hook('unlock', async () => {
|
|
105
105
|
if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
|
|
106
106
|
|
|
@@ -13,7 +13,6 @@ const logLifecyclePluginDefinition = {
|
|
|
13
13
|
onLoad: () => logger.debug('onLoad'),
|
|
14
14
|
onUnload: () => logger.debug('onUnload'),
|
|
15
15
|
onCreate: () => logger.debug('onCreate'),
|
|
16
|
-
onBackup: () => logger.debug('onBackup'),
|
|
17
16
|
onRestore: () => logger.debug('onRestore'),
|
|
18
17
|
onRestoreCompleted: () => logger.debug('onRestoreCompleted'),
|
|
19
18
|
onAssetsSynced: () => logger.debug('onAssetsSynced'),
|
|
@@ -3,11 +3,11 @@ import sodium from '@exodus/sodium-crypto'
|
|
|
3
3
|
|
|
4
4
|
const WALLET_INFO_KEY = EXODUS_KEY_IDS.WALLET_INFO
|
|
5
5
|
|
|
6
|
-
const createUnlockEncryptedStorage = ({ keychain,
|
|
6
|
+
const createUnlockEncryptedStorage = ({ keychain, wallet }) => {
|
|
7
7
|
return async (encryptedStorage) => {
|
|
8
8
|
// Fusion might write on storage even after keychain is locked, so we get keys
|
|
9
9
|
// directly instead of creating encryptor that does not preserves it anymore
|
|
10
|
-
const primarySeedId = await
|
|
10
|
+
const primarySeedId = await wallet.getPrimarySeedId()
|
|
11
11
|
const { privateKey } = await keychain.exportKey({
|
|
12
12
|
seedId: primarySeedId,
|
|
13
13
|
keyId: WALLET_INFO_KEY,
|
|
@@ -25,7 +25,7 @@ const unlockEncryptedStorageDefinition = {
|
|
|
25
25
|
id: 'unlockEncryptedStorage',
|
|
26
26
|
type: 'module',
|
|
27
27
|
factory: createUnlockEncryptedStorage,
|
|
28
|
-
dependencies: ['keychain', '
|
|
28
|
+
dependencies: ['keychain', 'wallet'],
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export default unlockEncryptedStorageDefinition
|