accounts 0.5.7 → 0.5.8
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 +7 -0
- package/dist/core/Dialog.d.ts.map +1 -1
- package/dist/core/Dialog.js +10 -0
- package/dist/core/Dialog.js.map +1 -1
- package/dist/core/Provider.js +1 -1
- package/dist/core/Provider.js.map +1 -1
- package/dist/react-native/Provider.d.ts +12 -0
- package/dist/react-native/Provider.d.ts.map +1 -0
- package/dist/react-native/Provider.js +16 -0
- package/dist/react-native/Provider.js.map +1 -0
- package/dist/react-native/adapter.d.ts +29 -0
- package/dist/react-native/adapter.d.ts.map +1 -0
- package/dist/react-native/adapter.js +314 -0
- package/dist/react-native/adapter.js.map +1 -0
- package/dist/react-native/index.d.ts +4 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +4 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/storage.d.ts +12 -0
- package/dist/react-native/storage.d.ts.map +1 -0
- package/dist/react-native/storage.js +53 -0
- package/dist/react-native/storage.js.map +1 -0
- package/package.json +20 -1
- package/src/core/Dialog.ts +12 -0
- package/src/core/Provider.ts +1 -1
- package/src/react-native/Provider.ts +28 -0
- package/src/react-native/adapter.ts +441 -0
- package/src/react-native/index.ts +3 -0
- package/src/react-native/storage.ts +65 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/react-native/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,MAAM,EACN,GAAG,EACH,IAAI,EACJ,QAAQ,IAAI,aAAa,EACzB,SAAS,EACT,WAAW,GACZ,MAAM,IAAI,CAAA;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,E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AC,CAAC,CAAA;IAChF,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;IACjD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;IAC3C,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;AACvB,CAAC;AAED,SAAS,oBAAoB,CAC3B,OAA6B,EAC7B,OAAe,EACf,OAA4B;IAE5B,OAAO,cAAc,OAAO,CAAC,WAAW,EAAE,IAAI,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AACxF,CAAC;AAED,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO,IAAI,aAAa,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;AAC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react-native/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-native/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Storage from '../core/Storage.js';
|
|
2
|
+
/** Creates a storage adapter backed by `expo-secure-store`. For private key material. */
|
|
3
|
+
export declare function secureStorage(options?: secureStorage.Options): Storage.Storage;
|
|
4
|
+
export declare namespace secureStorage {
|
|
5
|
+
type Options = Storage.from.Options;
|
|
6
|
+
}
|
|
7
|
+
/** Creates a storage adapter backed by `@react-native-async-storage/async-storage`. */
|
|
8
|
+
export declare function asyncStorage(options?: asyncStorage.Options): Storage.Storage;
|
|
9
|
+
export declare namespace asyncStorage {
|
|
10
|
+
type Options = Storage.from.Options;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/react-native/storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAE7C,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,OAAO,GAAE,aAAa,CAAC,OAAY,GAAG,OAAO,CAAC,OAAO,CAwBlF;AAED,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAA;CACpC;AAED,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,OAAO,GAAE,YAAY,CAAC,OAAY,GAAG,OAAO,CAAC,OAAO,CAwBhF;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;IACpC,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAA;CACpC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Json } from 'ox';
|
|
2
|
+
import * as Storage from '../core/Storage.js';
|
|
3
|
+
/** Creates a storage adapter backed by `expo-secure-store`. For private key material. */
|
|
4
|
+
export function secureStorage(options = {}) {
|
|
5
|
+
return Storage.from({
|
|
6
|
+
async getItem(name) {
|
|
7
|
+
const { getItemAsync } = await import('expo-secure-store');
|
|
8
|
+
const raw = await getItemAsync(name);
|
|
9
|
+
if (raw === null)
|
|
10
|
+
return null;
|
|
11
|
+
try {
|
|
12
|
+
return Json.parse(raw);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
async setItem(name, value) {
|
|
19
|
+
const { setItemAsync } = await import('expo-secure-store');
|
|
20
|
+
await setItemAsync(name, Json.stringify(value));
|
|
21
|
+
},
|
|
22
|
+
async removeItem(name) {
|
|
23
|
+
const { deleteItemAsync } = await import('expo-secure-store');
|
|
24
|
+
await deleteItemAsync(name);
|
|
25
|
+
},
|
|
26
|
+
}, options);
|
|
27
|
+
}
|
|
28
|
+
/** Creates a storage adapter backed by `@react-native-async-storage/async-storage`. */
|
|
29
|
+
export function asyncStorage(options = {}) {
|
|
30
|
+
return Storage.from({
|
|
31
|
+
async getItem(name) {
|
|
32
|
+
const AsyncStorage = (await import('@react-native-async-storage/async-storage')).default;
|
|
33
|
+
const raw = await AsyncStorage.getItem(name);
|
|
34
|
+
if (raw === null)
|
|
35
|
+
return null;
|
|
36
|
+
try {
|
|
37
|
+
return Json.parse(raw);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
async setItem(name, value) {
|
|
44
|
+
const AsyncStorage = (await import('@react-native-async-storage/async-storage')).default;
|
|
45
|
+
await AsyncStorage.setItem(name, Json.stringify(value));
|
|
46
|
+
},
|
|
47
|
+
async removeItem(name) {
|
|
48
|
+
const AsyncStorage = (await import('@react-native-async-storage/async-storage')).default;
|
|
49
|
+
await AsyncStorage.removeItem(name);
|
|
50
|
+
},
|
|
51
|
+
}, options);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/react-native/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAE7C,yFAAyF;AACzF,M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AC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACxB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK;YACvB,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC,OAAO,CAAA;YACxF,MAAM,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QACzD,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,IAAI;YACnB,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC,OAAO,CAAA;YACxF,MAAM,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACrC,CAAC;KACF,EACD,OAAO,CACR,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "accounts",
|
|
3
3
|
"description": "Tempo Accounts SDK",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.8",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"hono": "^4.12.12",
|
|
8
8
|
"idb-keyval": "^6.2.2",
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"zustand": "^5.0.11"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
+
"@react-native-async-storage/async-storage": "^3.0.2",
|
|
17
18
|
"@wagmi/core": ">=2",
|
|
19
|
+
"expo-secure-store": "^55.0.12",
|
|
20
|
+
"expo-web-browser": "^55.0.13",
|
|
18
21
|
"react": ">=18",
|
|
19
22
|
"viem": ">=2.43.3"
|
|
20
23
|
},
|
|
@@ -27,6 +30,15 @@
|
|
|
27
30
|
},
|
|
28
31
|
"viem": {
|
|
29
32
|
"optional": true
|
|
33
|
+
},
|
|
34
|
+
"expo-web-browser": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"expo-secure-store": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"@react-native-async-storage/async-storage": {
|
|
41
|
+
"optional": true
|
|
30
42
|
}
|
|
31
43
|
},
|
|
32
44
|
"repository": {
|
|
@@ -46,6 +58,7 @@
|
|
|
46
58
|
".": {
|
|
47
59
|
"types": "./dist/index.d.ts",
|
|
48
60
|
"src": "./src/index.ts",
|
|
61
|
+
"react-native": "./dist/index.js",
|
|
49
62
|
"default": "./dist/index.js"
|
|
50
63
|
},
|
|
51
64
|
"./server": {
|
|
@@ -67,6 +80,12 @@
|
|
|
67
80
|
"types": "./dist/wagmi/index.d.ts",
|
|
68
81
|
"src": "./src/wagmi/index.ts",
|
|
69
82
|
"default": "./dist/wagmi/index.js"
|
|
83
|
+
},
|
|
84
|
+
"./react-native": {
|
|
85
|
+
"types": "./dist/react-native/index.d.ts",
|
|
86
|
+
"src": "./src/react-native/index.ts",
|
|
87
|
+
"react-native": "./dist/react-native/index.js",
|
|
88
|
+
"default": "./dist/react-native/index.js"
|
|
70
89
|
}
|
|
71
90
|
}
|
|
72
91
|
}
|
package/src/core/Dialog.ts
CHANGED
|
@@ -75,7 +75,19 @@ export function iframe(): Dialog {
|
|
|
75
75
|
|
|
76
76
|
// Reuse existing iframe if the host matches — just swap the store/fallback refs.
|
|
77
77
|
if (cached && cached.host === host) {
|
|
78
|
+
const oldStore = store
|
|
78
79
|
store = parameters.store
|
|
80
|
+
|
|
81
|
+
// Migrate in-flight requests so responses land in the current store.
|
|
82
|
+
if (oldStore && oldStore !== store) {
|
|
83
|
+
const pending = oldStore.getState().requestQueue.filter((q) => q.status === 'pending')
|
|
84
|
+
if (pending.length > 0)
|
|
85
|
+
store.setState((x) => ({
|
|
86
|
+
...x,
|
|
87
|
+
requestQueue: [...x.requestQueue, ...pending],
|
|
88
|
+
}))
|
|
89
|
+
}
|
|
90
|
+
|
|
79
91
|
fallback?.destroy()
|
|
80
92
|
fallback = popup()(parameters)
|
|
81
93
|
return cached.instance
|
package/src/core/Provider.ts
CHANGED
|
@@ -607,7 +607,7 @@ export function create(options: create.Options = {}): create.ReturnType {
|
|
|
607
607
|
},
|
|
608
608
|
)
|
|
609
609
|
|
|
610
|
-
if (typeof window !== 'undefined') {
|
|
610
|
+
if (typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') {
|
|
611
611
|
const rdns =
|
|
612
612
|
adapter.rdns ?? `com.${(adapter.name ?? 'Injected Wallet').toLowerCase().replace(/\s+/g, '')}`
|
|
613
613
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as CoreProvider from '../core/Provider.js'
|
|
2
|
+
import { reactNative } from './adapter.js'
|
|
3
|
+
|
|
4
|
+
/** Creates a provider for React Native apps using system browser authentication. */
|
|
5
|
+
export function create(options: create.Options): create.ReturnType {
|
|
6
|
+
const { host = 'https://wallet.tempo.xyz', redirectUri, open, secureStorage, ...rest } = options
|
|
7
|
+
|
|
8
|
+
return CoreProvider.create({
|
|
9
|
+
...rest,
|
|
10
|
+
adapter: reactNative({
|
|
11
|
+
host,
|
|
12
|
+
redirectUri,
|
|
13
|
+
...(open ? { open } : {}),
|
|
14
|
+
...(secureStorage ? { secureStorage } : {}),
|
|
15
|
+
}),
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare namespace create {
|
|
20
|
+
export type Options = Omit<
|
|
21
|
+
CoreProvider.create.Options & reactNative.Options,
|
|
22
|
+
'adapter' | 'host'
|
|
23
|
+
> & {
|
|
24
|
+
/** Host URL for the mobile auth page. @default "https://wallet.tempo.xyz" */
|
|
25
|
+
host?: string | undefined
|
|
26
|
+
}
|
|
27
|
+
export type ReturnType = CoreProvider.create.ReturnType
|
|
28
|
+
}
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Address as core_Address,
|
|
3
|
+
Base64,
|
|
4
|
+
Hex,
|
|
5
|
+
P256,
|
|
6
|
+
Provider as core_Provider,
|
|
7
|
+
PublicKey,
|
|
8
|
+
RpcResponse,
|
|
9
|
+
} from 'ox'
|
|
10
|
+
import { KeyAuthorization } from 'ox/tempo'
|
|
11
|
+
import { prepareTransactionRequest } from 'viem/actions'
|
|
12
|
+
import { Account as TempoAccount, Secp256k1 } from 'viem/tempo'
|
|
13
|
+
|
|
14
|
+
import * as AccessKey from '../core/AccessKey.js'
|
|
15
|
+
import * as Adapter from '../core/Adapter.js'
|
|
16
|
+
import type * as Storage from '../core/Storage.js'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a React Native adapter that authorizes access keys via the system browser.
|
|
20
|
+
*
|
|
21
|
+
* Authentication opens a browser session and completes via a redirect callback
|
|
22
|
+
* that returns the signed key authorization.
|
|
23
|
+
*/
|
|
24
|
+
export function reactNative(options: reactNative.Options): Adapter.Adapter {
|
|
25
|
+
const { name = 'Tempo Mobile', rdns = 'xyz.tempo.mobile' } = options
|
|
26
|
+
|
|
27
|
+
return Adapter.define({ name, rdns }, ({ getAccount, getClient, store }) => {
|
|
28
|
+
async function loadManagedKey(
|
|
29
|
+
address: Adapter.authorizeAccessKey.ReturnType['rootAddress'],
|
|
30
|
+
parameters: loadManagedKey.Options = {},
|
|
31
|
+
): Promise<ManagedKeyEntry | undefined> {
|
|
32
|
+
const { keyType } = parameters
|
|
33
|
+
const { secureStorage } = options
|
|
34
|
+
if (!secureStorage) return undefined
|
|
35
|
+
|
|
36
|
+
const { chainId } = store.getState()
|
|
37
|
+
const storageKey = managedKeyStorageKey(address, chainId, keyType)
|
|
38
|
+
const entry = await secureStorage.getItem<ManagedKeyEntry>(storageKey)
|
|
39
|
+
if (!entry) return undefined
|
|
40
|
+
|
|
41
|
+
const deserialized = KeyAuthorization.deserialize(entry.keyAuthorization)
|
|
42
|
+
if (!deserialized.signature) throw new Error('Managed access key is missing a signature.')
|
|
43
|
+
const keyAuthorization = deserialized as KeyAuthorization.Signed
|
|
44
|
+
AccessKey.save({
|
|
45
|
+
address,
|
|
46
|
+
keyAuthorization,
|
|
47
|
+
privateKey: entry.key,
|
|
48
|
+
store,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return entry
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function resolveManagedKey(
|
|
55
|
+
resolveOptions: {
|
|
56
|
+
address?: Adapter.authorizeAccessKey.ReturnType['rootAddress'] | undefined
|
|
57
|
+
keyType?: Adapter.authorizeAccessKey.Parameters['keyType'] | undefined
|
|
58
|
+
} = {},
|
|
59
|
+
): Promise<resolveManagedKey.ReturnType> {
|
|
60
|
+
const { address, keyType } = resolveOptions
|
|
61
|
+
|
|
62
|
+
const requestedKeyType = keyType === 'p256' || keyType === 'secp256k1' ? keyType : undefined
|
|
63
|
+
const entry = address
|
|
64
|
+
? await loadManagedKey(address, requestedKeyType ? { keyType: requestedKeyType } : {})
|
|
65
|
+
: undefined
|
|
66
|
+
if (entry) {
|
|
67
|
+
const account =
|
|
68
|
+
entry.keyType === 'p256'
|
|
69
|
+
? TempoAccount.fromP256(entry.key, { access: address })
|
|
70
|
+
: TempoAccount.fromSecp256k1(entry.key, { access: address })
|
|
71
|
+
return {
|
|
72
|
+
account,
|
|
73
|
+
key: entry.key,
|
|
74
|
+
keyAddress: entry.keyAddress,
|
|
75
|
+
keyType: entry.keyType,
|
|
76
|
+
publicKey: account.publicKey,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const nextKeyType = requestedKeyType === 'p256' ? 'p256' : 'secp256k1'
|
|
81
|
+
const key = nextKeyType === 'p256' ? P256.randomPrivateKey() : Secp256k1.randomPrivateKey()
|
|
82
|
+
const account =
|
|
83
|
+
nextKeyType === 'p256'
|
|
84
|
+
? TempoAccount.fromP256(key, address ? { access: address } : undefined)
|
|
85
|
+
: TempoAccount.fromSecp256k1(key, address ? { access: address } : undefined)
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
account,
|
|
89
|
+
key,
|
|
90
|
+
keyAddress: core_Address.fromPublicKey(PublicKey.from(account.publicKey)),
|
|
91
|
+
keyType: nextKeyType,
|
|
92
|
+
publicKey: account.publicKey,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function saveManagedKey(
|
|
97
|
+
address: Adapter.authorizeAccessKey.ReturnType['rootAddress'],
|
|
98
|
+
managedKey: Awaited<ReturnType<typeof resolveManagedKey>>,
|
|
99
|
+
keyAuthorization: KeyAuthorization.Signed,
|
|
100
|
+
) {
|
|
101
|
+
if (!managedKey) return
|
|
102
|
+
|
|
103
|
+
AccessKey.save({
|
|
104
|
+
address,
|
|
105
|
+
keyAuthorization,
|
|
106
|
+
privateKey: managedKey.key,
|
|
107
|
+
store,
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const { secureStorage } = options
|
|
111
|
+
if (!secureStorage) return
|
|
112
|
+
|
|
113
|
+
const { chainId } = store.getState()
|
|
114
|
+
const storageKey = managedKeyStorageKey(address, chainId, managedKey.keyType)
|
|
115
|
+
const entry: ManagedKeyEntry = {
|
|
116
|
+
chainId,
|
|
117
|
+
expiry: keyAuthorization.expiry ?? 0,
|
|
118
|
+
key: managedKey.key,
|
|
119
|
+
keyAddress: managedKey.keyAddress,
|
|
120
|
+
keyAuthorization: KeyAuthorization.serialize(keyAuthorization),
|
|
121
|
+
keyType: managedKey.keyType,
|
|
122
|
+
walletAddress: address,
|
|
123
|
+
}
|
|
124
|
+
await secureStorage.setItem(storageKey, entry)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function withManagedAccessKey<result>(
|
|
128
|
+
fn: (
|
|
129
|
+
account: TempoAccount.Account,
|
|
130
|
+
keyAuthorization?: KeyAuthorization.Signed | undefined,
|
|
131
|
+
) => Promise<result>,
|
|
132
|
+
) {
|
|
133
|
+
const rootAddress = store.getState().accounts[store.getState().activeAccount]?.address
|
|
134
|
+
if (rootAddress) await loadManagedKey(rootAddress)
|
|
135
|
+
|
|
136
|
+
const account = getAccount({ signable: true })
|
|
137
|
+
const keyAuthorization = AccessKey.getPending(account, { store })
|
|
138
|
+
try {
|
|
139
|
+
const result = await fn(account, keyAuthorization ?? undefined)
|
|
140
|
+
AccessKey.removePending(account, { store })
|
|
141
|
+
return result
|
|
142
|
+
} catch (error) {
|
|
143
|
+
AccessKey.remove(account, { store })
|
|
144
|
+
throw error
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function authorize(request: {
|
|
149
|
+
account?: Adapter.authorizeAccessKey.ReturnType['rootAddress'] | undefined
|
|
150
|
+
authorizeAccessKey: Adapter.authorizeAccessKey.Parameters | undefined
|
|
151
|
+
method: 'wallet_authorizeAccessKey' | 'wallet_connect'
|
|
152
|
+
}) {
|
|
153
|
+
const { host, redirectUri, open = defaultOpen } = options
|
|
154
|
+
const { account, authorizeAccessKey, method } = request
|
|
155
|
+
|
|
156
|
+
const managedKey =
|
|
157
|
+
authorizeAccessKey && !authorizeAccessKey.publicKey && !authorizeAccessKey.address
|
|
158
|
+
? await resolveManagedKey({
|
|
159
|
+
...(account ? { address: account } : {}),
|
|
160
|
+
...(authorizeAccessKey.keyType ? { keyType: authorizeAccessKey.keyType } : {}),
|
|
161
|
+
})
|
|
162
|
+
: undefined
|
|
163
|
+
|
|
164
|
+
const publicKey = authorizeAccessKey?.publicKey ?? managedKey?.publicKey
|
|
165
|
+
const keyType = authorizeAccessKey?.keyType ?? managedKey?.keyType
|
|
166
|
+
|
|
167
|
+
if (!publicKey)
|
|
168
|
+
throw new RpcResponse.InvalidParamsError({
|
|
169
|
+
message:
|
|
170
|
+
method === 'wallet_connect'
|
|
171
|
+
? '`wallet_connect` on the React Native adapter requires `capabilities.authorizeAccessKey`.'
|
|
172
|
+
: '`wallet_authorizeAccessKey` on the React Native adapter requires key parameters.',
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
const state = Base64.fromBytes(Hex.toBytes(Hex.random(16)), { pad: false, url: true })
|
|
176
|
+
const authUrl = buildAuthUrl(host, {
|
|
177
|
+
callback: redirectUri,
|
|
178
|
+
chainId: store.getState().chainId,
|
|
179
|
+
...(typeof authorizeAccessKey?.expiry !== 'undefined'
|
|
180
|
+
? { expiry: authorizeAccessKey.expiry }
|
|
181
|
+
: {}),
|
|
182
|
+
...(keyType ? { keyType } : {}),
|
|
183
|
+
...(authorizeAccessKey?.limits
|
|
184
|
+
? { limits: authorizeAccessKey.limits.map((l) => ({ ...l, limit: String(l.limit) })) }
|
|
185
|
+
: {}),
|
|
186
|
+
pubKey: publicKey,
|
|
187
|
+
state,
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const callbackUrl = await open(authUrl, redirectUri)
|
|
191
|
+
if (!callbackUrl) throw new AuthCancelledError()
|
|
192
|
+
|
|
193
|
+
const params = new URL(callbackUrl).searchParams
|
|
194
|
+
const returnedState = params.get('state')
|
|
195
|
+
if (returnedState !== state) throw new StateMismatchError()
|
|
196
|
+
|
|
197
|
+
const accountAddress = params.get('accountAddress')
|
|
198
|
+
if (!accountAddress) throw new Error('Missing accountAddress in callback.')
|
|
199
|
+
|
|
200
|
+
const keyAuthorizationHex = params.get('keyAuthorization')
|
|
201
|
+
if (!keyAuthorizationHex) throw new Error('Missing keyAuthorization in callback.')
|
|
202
|
+
|
|
203
|
+
const keyAuthorization = KeyAuthorization.deserialize(keyAuthorizationHex as Hex.Hex)
|
|
204
|
+
if (!keyAuthorization.signature)
|
|
205
|
+
throw new Error('Key authorization in callback is missing a signature.')
|
|
206
|
+
const signed = keyAuthorization as KeyAuthorization.Signed
|
|
207
|
+
|
|
208
|
+
if (managedKey)
|
|
209
|
+
await saveManagedKey(accountAddress as core_Address.Address, managedKey, signed)
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
accountAddress: accountAddress as core_Address.Address,
|
|
213
|
+
keyAuthorization: signed,
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
actions: {
|
|
219
|
+
async authorizeAccessKey(parameters) {
|
|
220
|
+
const { accounts, activeAccount } = store.getState()
|
|
221
|
+
const account = accounts[activeAccount]?.address
|
|
222
|
+
const result = await authorize({
|
|
223
|
+
...(account ? { account } : {}),
|
|
224
|
+
authorizeAccessKey: parameters,
|
|
225
|
+
method: 'wallet_authorizeAccessKey',
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
if (!account)
|
|
229
|
+
store.setState({
|
|
230
|
+
accounts: [{ address: result.accountAddress }],
|
|
231
|
+
activeAccount: 0,
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
keyAuthorization: KeyAuthorization.toRpc(result.keyAuthorization),
|
|
236
|
+
rootAddress: result.accountAddress,
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
async createAccount(params, request) {
|
|
240
|
+
return this.loadAccounts(params, request)
|
|
241
|
+
},
|
|
242
|
+
async loadAccounts(parameters) {
|
|
243
|
+
if (parameters?.digest)
|
|
244
|
+
throw unsupported(
|
|
245
|
+
'`wallet_connect` digest signing not supported by React Native adapter.',
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
const result = await authorize({
|
|
249
|
+
authorizeAccessKey: parameters?.authorizeAccessKey,
|
|
250
|
+
method: 'wallet_connect',
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
accounts: [
|
|
255
|
+
{
|
|
256
|
+
address: result.accountAddress,
|
|
257
|
+
capabilities: {},
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
keyAuthorization: KeyAuthorization.toRpc(result.keyAuthorization),
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
async revokeAccessKey() {
|
|
264
|
+
throw unsupported('`wallet_revokeAccessKey` not supported by React Native adapter.')
|
|
265
|
+
},
|
|
266
|
+
async sendTransaction(parameters) {
|
|
267
|
+
const { feePayer, ...rest } = parameters
|
|
268
|
+
const client = getClient(typeof feePayer === 'string' ? { feePayer } : {})
|
|
269
|
+
const { account, prepared } = await withManagedAccessKey(
|
|
270
|
+
async (account, keyAuthorization) => ({
|
|
271
|
+
account,
|
|
272
|
+
prepared: await prepareTransactionRequest(client, {
|
|
273
|
+
account,
|
|
274
|
+
...rest,
|
|
275
|
+
...(feePayer ? { feePayer: true } : {}),
|
|
276
|
+
...(keyAuthorization ? { keyAuthorization } : {}),
|
|
277
|
+
type: 'tempo',
|
|
278
|
+
} as never),
|
|
279
|
+
}),
|
|
280
|
+
)
|
|
281
|
+
const signed = await account.signTransaction(prepared as never)
|
|
282
|
+
return await client.request({
|
|
283
|
+
method: 'eth_sendRawTransaction' as never,
|
|
284
|
+
params: [signed],
|
|
285
|
+
})
|
|
286
|
+
},
|
|
287
|
+
async sendTransactionSync(parameters) {
|
|
288
|
+
const { feePayer, ...rest } = parameters
|
|
289
|
+
const client = getClient(typeof feePayer === 'string' ? { feePayer } : {})
|
|
290
|
+
const { account, prepared } = await withManagedAccessKey(
|
|
291
|
+
async (account, keyAuthorization) => ({
|
|
292
|
+
account,
|
|
293
|
+
prepared: await prepareTransactionRequest(client, {
|
|
294
|
+
account,
|
|
295
|
+
...rest,
|
|
296
|
+
...(feePayer ? { feePayer: true } : {}),
|
|
297
|
+
...(keyAuthorization ? { keyAuthorization } : {}),
|
|
298
|
+
type: 'tempo',
|
|
299
|
+
} as never),
|
|
300
|
+
}),
|
|
301
|
+
)
|
|
302
|
+
const signed = await account.signTransaction(prepared as never)
|
|
303
|
+
return await client.request({
|
|
304
|
+
method: 'eth_sendRawTransactionSync' as never,
|
|
305
|
+
params: [signed],
|
|
306
|
+
})
|
|
307
|
+
},
|
|
308
|
+
async signPersonalMessage({ address, data }) {
|
|
309
|
+
await loadManagedKey(address)
|
|
310
|
+
const account = getAccount({ address, signable: true })
|
|
311
|
+
return await account.signMessage({ message: { raw: data } })
|
|
312
|
+
},
|
|
313
|
+
async signTransaction(parameters) {
|
|
314
|
+
const { feePayer, ...rest } = parameters
|
|
315
|
+
const client = getClient(typeof feePayer === 'string' ? { feePayer } : {})
|
|
316
|
+
const { account, prepared } = await withManagedAccessKey(
|
|
317
|
+
async (account, keyAuthorization) => ({
|
|
318
|
+
account,
|
|
319
|
+
prepared: await prepareTransactionRequest(client, {
|
|
320
|
+
account,
|
|
321
|
+
...rest,
|
|
322
|
+
...(feePayer ? { feePayer: true } : {}),
|
|
323
|
+
...(keyAuthorization ? { keyAuthorization } : {}),
|
|
324
|
+
type: 'tempo',
|
|
325
|
+
} as never),
|
|
326
|
+
}),
|
|
327
|
+
)
|
|
328
|
+
return await account.signTransaction(prepared as never)
|
|
329
|
+
},
|
|
330
|
+
async signTypedData({ address, data }) {
|
|
331
|
+
await loadManagedKey(address)
|
|
332
|
+
const account = getAccount({ address, signable: true })
|
|
333
|
+
return await account.signTypedData(JSON.parse(data) as never)
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export declare namespace reactNative {
|
|
341
|
+
export type Options = {
|
|
342
|
+
/** Host URL for the mobile auth page. @default "https://wallet.tempo.xyz" */
|
|
343
|
+
host: string
|
|
344
|
+
/** Provider display name. @default "Tempo Mobile" */
|
|
345
|
+
name?: string | undefined
|
|
346
|
+
/**
|
|
347
|
+
* Browser opener override. Opens the auth URL and returns the callback URL.
|
|
348
|
+
* @default Uses `expo-web-browser`'s `openAuthSessionAsync`.
|
|
349
|
+
*/
|
|
350
|
+
open?: ((url: string, redirectUri: string) => Promise<string | null>) | undefined
|
|
351
|
+
/** Redirect URI for the auth callback (e.g. your app's deep link scheme). */
|
|
352
|
+
redirectUri: string
|
|
353
|
+
/** Reverse-DNS provider identifier. @default "xyz.tempo.mobile" */
|
|
354
|
+
rdns?: string | undefined
|
|
355
|
+
/** Secure storage adapter for persisting managed access keys. */
|
|
356
|
+
secureStorage?: Storage.Storage | undefined
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
declare namespace resolveManagedKey {
|
|
361
|
+
type ReturnType = {
|
|
362
|
+
account: TempoAccount.Account
|
|
363
|
+
key: Hex.Hex
|
|
364
|
+
keyAddress: core_Address.Address
|
|
365
|
+
keyType: 'secp256k1' | 'p256'
|
|
366
|
+
publicKey: Hex.Hex
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
declare namespace loadManagedKey {
|
|
371
|
+
type Options = {
|
|
372
|
+
keyType?: 'secp256k1' | 'p256' | undefined
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Entry shape persisted to secure storage for managed access keys. */
|
|
377
|
+
type ManagedKeyEntry = {
|
|
378
|
+
chainId: number
|
|
379
|
+
expiry: number
|
|
380
|
+
key: Hex.Hex
|
|
381
|
+
keyAddress: core_Address.Address
|
|
382
|
+
keyAuthorization: Hex.Hex
|
|
383
|
+
keyType: 'secp256k1' | 'p256'
|
|
384
|
+
walletAddress: core_Address.Address
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
class AuthCancelledError extends Error {
|
|
388
|
+
constructor() {
|
|
389
|
+
super('Authentication was cancelled by the user.')
|
|
390
|
+
this.name = 'AuthCancelledError'
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
class StateMismatchError extends Error {
|
|
395
|
+
constructor() {
|
|
396
|
+
super('State parameter mismatch — possible CSRF attack.')
|
|
397
|
+
this.name = 'StateMismatchError'
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
async function defaultOpen(url: string, redirectUri: string): Promise<string | null> {
|
|
402
|
+
const { openAuthSessionAsync } = await import('expo-web-browser')
|
|
403
|
+
const result = await openAuthSessionAsync(url, redirectUri)
|
|
404
|
+
if (result.type !== 'success') return null
|
|
405
|
+
return result.url
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function buildAuthUrl(
|
|
409
|
+
host: string,
|
|
410
|
+
params: {
|
|
411
|
+
callback: string
|
|
412
|
+
chainId: number
|
|
413
|
+
expiry?: number | undefined
|
|
414
|
+
keyType?: string | undefined
|
|
415
|
+
limits?: readonly { token: string; limit: string }[] | undefined
|
|
416
|
+
pubKey: Hex.Hex
|
|
417
|
+
state: string
|
|
418
|
+
},
|
|
419
|
+
): string {
|
|
420
|
+
const url = new URL('/mobile-auth', host)
|
|
421
|
+
url.searchParams.set('pubKey', params.pubKey)
|
|
422
|
+
if (params.keyType) url.searchParams.set('keyType', params.keyType)
|
|
423
|
+
url.searchParams.set('chainId', String(params.chainId))
|
|
424
|
+
if (typeof params.expiry !== 'undefined') url.searchParams.set('expiry', String(params.expiry))
|
|
425
|
+
if (params.limits) url.searchParams.set('limits', JSON.stringify(params.limits))
|
|
426
|
+
url.searchParams.set('callback', params.callback)
|
|
427
|
+
url.searchParams.set('state', params.state)
|
|
428
|
+
return url.toString()
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function managedKeyStorageKey(
|
|
432
|
+
address: core_Address.Address,
|
|
433
|
+
chainId: number,
|
|
434
|
+
keyType?: string | undefined,
|
|
435
|
+
): string {
|
|
436
|
+
return `managedKey.${address.toLowerCase()}.${chainId}${keyType ? `.${keyType}` : ''}`
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function unsupported(message: string) {
|
|
440
|
+
return new core_Provider.UnsupportedMethodError({ message })
|
|
441
|
+
}
|