@exodus/headless 3.0.0 → 3.1.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.1.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@3.1.0...@exodus/headless@3.1.1) (2024-01-29)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **headless:** lockedAtom writes ([#5555](https://github.com/ExodusMovement/exodus-hydra/issues/5555)) ([aa24ca0](https://github.com/ExodusMovement/exodus-hydra/commit/aa24ca03d07e5b47ef2d1bd08de22a569496c6a2))
11
+
12
+ ## [3.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@3.0.0...@exodus/headless@3.1.0) (2024-01-27)
13
+
14
+ ### Features
15
+
16
+ - catch assets synced hook ([#5537](https://github.com/ExodusMovement/exodus-hydra/issues/5537)) ([b811d8d](https://github.com/ExodusMovement/exodus-hydra/commit/b811d8de338ae2c10b2900c68b15e931b6a8e740))
17
+ - **geolocation:** update handler to use v3 with App-Name and App-Version ([#5529](https://github.com/ExodusMovement/exodus-hydra/issues/5529)) ([2a12c3e](https://github.com/ExodusMovement/exodus-hydra/commit/2a12c3e8568af4cdf689815ec7e70d2580ae9a6c))
18
+
6
19
  ## [3.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.4.0...@exodus/headless@3.0.0) (2024-01-25)
7
20
 
8
21
  ### ⚠ BREAKING CHANGES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "The platform-agnostic Exodus wallet SDK",
5
5
  "author": "Exodus Movement Inc.",
6
6
  "main": "src/index.js",
@@ -41,10 +41,10 @@
41
41
  "@exodus/fetch": "^1.2.1",
42
42
  "@exodus/filesystem": "^1.1.0",
43
43
  "@exodus/fusion-atoms": "^1.1.2",
44
- "@exodus/geolocation": "^4.0.0",
44
+ "@exodus/geolocation": "^4.1.0",
45
45
  "@exodus/hd-key-slip-10": "^2.0.0",
46
46
  "@exodus/key-identifier-provider": "^1.4.0",
47
- "@exodus/keychain": "^4.3.0",
47
+ "@exodus/keychain": "^5.0.1",
48
48
  "@exodus/locale": "^2.0.2",
49
49
  "@exodus/module": "^1.2.2",
50
50
  "@exodus/pricing": "^1.1.0",
@@ -67,7 +67,7 @@
67
67
  "@exodus/ab-testing": "^7.3.0",
68
68
  "@exodus/algorand-lib": "^2.0.1",
69
69
  "@exodus/algorand-meta": "^1.1.4",
70
- "@exodus/analytics": "^12.0.0",
70
+ "@exodus/analytics": "^12.0.1",
71
71
  "@exodus/apy-rates": "^3.3.1",
72
72
  "@exodus/assets-feature": "workspace:^",
73
73
  "@exodus/bitcoin-plugin": "^1.0.14",
@@ -102,5 +102,5 @@
102
102
  "msw": "^2.0.0",
103
103
  "p-defer": "^4.0.0"
104
104
  },
105
- "gitHead": "5052dcafa0b903350e25ed7df175a6d65ce37afe"
105
+ "gitHead": "5f285cee06abaf98437619a5a8aa5381b8eefc36"
106
106
  }
@@ -33,6 +33,7 @@ class Application extends ExodusModule {
33
33
  #hooks = {}
34
34
  #wallet = null
35
35
  #storage = null
36
+ #lockedAtom = null
36
37
  #backedUpAtom = null
37
38
  #passphraseCache = null
38
39
  #applicationStarted = null
@@ -41,6 +42,7 @@ class Application extends ExodusModule {
41
42
  constructor({
42
43
  wallet,
43
44
  unsafeStorage,
45
+ lockedAtom,
44
46
  backedUpAtom,
45
47
  passphraseCache = passphraseCachePlaceholder,
46
48
  logger,
@@ -48,6 +50,7 @@ class Application extends ExodusModule {
48
50
  super({ name: 'Application', logger })
49
51
 
50
52
  this.#wallet = wallet
53
+ this.#lockedAtom = lockedAtom
51
54
  this.#backedUpAtom = backedUpAtom
52
55
  this.#passphraseCache = passphraseCache
53
56
  this.#storage = unsafeStorage.namespace('flags')
@@ -216,6 +219,7 @@ class Application extends ExodusModule {
216
219
 
217
220
  await this.#applicationStarted
218
221
  await this.#wallet.lock(opts)
222
+ await this.#lockedAtom.set(true)
219
223
  await this.#passphraseCache.clear()
220
224
  await this.fire(Hook.Lock)
221
225
 
@@ -231,7 +235,9 @@ class Application extends ExodusModule {
231
235
  await this.fire(Hook.RestoreCompleted)
232
236
  }
233
237
 
234
- this.fire(Hook.AssetsSynced)
238
+ this.fire(Hook.AssetsSynced).catch((e) => {
239
+ console.warn('failed to execute onAssetsSynced hooks', e)
240
+ })
235
241
  }
236
242
 
237
243
  restore = async () => {
@@ -249,6 +255,7 @@ class Application extends ExodusModule {
249
255
  this._logger.log('unlocking with cache')
250
256
 
251
257
  await this.#wallet.unlock({ passphrase })
258
+ await this.#lockedAtom.set(false)
252
259
 
253
260
  await this.fire(Hook.Migrate)
254
261
  await this.fire(Hook.Unlock)
@@ -266,6 +273,7 @@ class Application extends ExodusModule {
266
273
 
267
274
  await this.#applicationStarted
268
275
  await this.#wallet.unlock({ passphrase })
276
+ await this.#lockedAtom.set(false)
269
277
 
270
278
  await this.fire(Hook.Migrate)
271
279
  await this.fire(Hook.Unlock)
@@ -4,7 +4,14 @@ const applicationDefinition = {
4
4
  id: 'application',
5
5
  type: 'module',
6
6
  factory: createApplication,
7
- dependencies: ['unsafeStorage', 'backedUpAtom', 'passphraseCache?', 'wallet', 'logger'],
7
+ dependencies: [
8
+ 'unsafeStorage',
9
+ 'backedUpAtom',
10
+ 'lockedAtom',
11
+ 'passphraseCache?',
12
+ 'wallet',
13
+ 'logger',
14
+ ],
8
15
  }
9
16
 
10
17
  export default applicationDefinition
@@ -30,14 +30,6 @@ const applicationLifecyclePlugin = ({
30
30
  await restoreAtom.set(false)
31
31
  }
32
32
 
33
- const onLock = async () => {
34
- await lockedAtom.set(true)
35
- }
36
-
37
- const onUnlock = async () => {
38
- await lockedAtom.set(false)
39
- }
40
-
41
33
  const onBackup = async () => {
42
34
  await backedUpAtom.set(true)
43
35
  }
@@ -50,7 +42,7 @@ const applicationLifecyclePlugin = ({
50
42
  await backedUpAtom.set(undefined)
51
43
  }
52
44
 
53
- return { onStart, onLoad, onImport, onAssetsSynced, onLock, onUnlock, onBackup, onStop, onClear }
45
+ return { onStart, onLoad, onImport, onAssetsSynced, onBackup, onStop, onClear }
54
46
  }
55
47
 
56
48
  const applicationLifecyclePluginDefinition = {
package/src/index.js CHANGED
@@ -22,6 +22,7 @@ import walletAccounts from '@exodus/wallet-accounts'
22
22
 
23
23
  import createApi from './api'
24
24
  import application from './application'
25
+ import createDependencies from './dependencies'
25
26
  import createIOC from './ioc'
26
27
  import attachMigrations from './migrations/attach'
27
28
  import attachPlugins from './plugins/attach'
@@ -52,6 +53,7 @@ const createExodus = ({ adapters, config, port, debug = false }) => {
52
53
  ioc.use(wallet())
53
54
  ioc.use(walletAccounts())
54
55
 
56
+ ioc.registerMultiple(createDependencies({ adapters, config }))
55
57
  ioc.register({ definition: { id: 'port', type: 'port', factory: () => port } })
56
58
 
57
59
  const resolve = () => {
package/src/ioc.js CHANGED
@@ -11,8 +11,6 @@ import performanceMonitor from '@exodus/dependency-preprocessors/src/preprocesso
11
11
  import readOnlyAtoms from '@exodus/dependency-preprocessors/src/preprocessors/read-only-atoms'
12
12
  import assert from 'minimalistic-assert'
13
13
 
14
- import createDependencies from './dependencies'
15
-
16
14
  const createIOC = ({ adapters, config, debug }) => {
17
15
  const { createLogger, unsafeStorage, performance = {} } = adapters
18
16
  const {
@@ -52,7 +50,7 @@ const createIOC = ({ adapters, config, debug }) => {
52
50
  debuggerPreprocessor({ debug, unsafeStorage }),
53
51
  ].filter(Boolean)
54
52
 
55
- const nodes = createDependencies({ adapters, config })
53
+ const nodes = []
56
54
 
57
55
  const registerMultiple = (dependencies) => {
58
56
  nodes.push(...dependencies)
@@ -1,13 +1,17 @@
1
1
  import { EXODUS_KEY_IDS } from '@exodus/keychain/module'
2
+ import sodium from '@exodus/sodium-crypto'
3
+
4
+ const WALLET_INFO_KEY = EXODUS_KEY_IDS.WALLET_INFO
2
5
 
3
6
  const createUnlockEncryptedStorage = ({ keychain }) => {
4
7
  return async (encryptedStorage) => {
5
- // should the key id be part of a `config` dep?
6
- const sodiumEncryptor = keychain.createSodiumEncryptor(EXODUS_KEY_IDS.WALLET_INFO)
8
+ // Fusion might write on storage even after keychain is locked, so we get keys
9
+ // directly instead of creating encryptor that does not preserves it anymore
10
+ const { privateKey } = await keychain.exportKey(WALLET_INFO_KEY, { exportPrivate: true })
7
11
 
8
12
  await encryptedStorage.unlock({
9
- encrypt: (data) => sodiumEncryptor.encryptSecretBox({ data }),
10
- decrypt: (data) => sodiumEncryptor.decryptSecretBox({ data }),
13
+ encrypt: (data) => sodium.encryptSecret(data, privateKey),
14
+ decrypt: (data) => sodium.decryptSecret(data, privateKey),
11
15
  })
12
16
  }
13
17
  }