accounts 0.7.2 → 0.8.0
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 +23 -0
- package/README.md +19 -20
- package/dist/cli/Provider.d.ts +1 -1
- package/dist/cli/Provider.d.ts.map +1 -1
- package/dist/cli/Provider.js +4 -1
- package/dist/cli/Provider.js.map +1 -1
- package/dist/cli/keyring.js +1 -1
- package/dist/cli/keyring.js.map +1 -1
- package/dist/core/Account.d.ts +2 -0
- package/dist/core/Account.d.ts.map +1 -1
- package/dist/core/Account.js.map +1 -1
- package/dist/core/Adapter.d.ts +9 -1
- package/dist/core/Adapter.d.ts.map +1 -1
- package/dist/core/Dialog.d.ts +16 -1
- package/dist/core/Dialog.d.ts.map +1 -1
- package/dist/core/Dialog.js +40 -3
- package/dist/core/Dialog.js.map +1 -1
- package/dist/core/Messenger.d.ts +15 -0
- package/dist/core/Messenger.d.ts.map +1 -1
- package/dist/core/Messenger.js.map +1 -1
- package/dist/core/Provider.d.ts +2 -0
- package/dist/core/Provider.d.ts.map +1 -1
- package/dist/core/Provider.js +24 -6
- package/dist/core/Provider.js.map +1 -1
- package/dist/core/Remote.d.ts +7 -1
- package/dist/core/Remote.d.ts.map +1 -1
- package/dist/core/Remote.js +18 -2
- package/dist/core/Remote.js.map +1 -1
- package/dist/core/Schema.d.ts +17 -3
- package/dist/core/Schema.d.ts.map +1 -1
- package/dist/core/Store.d.ts +2 -0
- package/dist/core/Store.d.ts.map +1 -1
- package/dist/core/Store.js +12 -7
- package/dist/core/Store.js.map +1 -1
- package/dist/core/TrustedHosts.d.ts.map +1 -1
- package/dist/core/TrustedHosts.js +2 -0
- package/dist/core/TrustedHosts.js.map +1 -1
- package/dist/core/WebAuthnCeremony.d.ts +8 -0
- package/dist/core/WebAuthnCeremony.d.ts.map +1 -1
- package/dist/core/WebAuthnCeremony.js.map +1 -1
- package/dist/core/adapters/dialog.d.ts +3 -1
- package/dist/core/adapters/dialog.d.ts.map +1 -1
- package/dist/core/adapters/dialog.js +8 -5
- package/dist/core/adapters/dialog.js.map +1 -1
- package/dist/core/adapters/local.js +4 -4
- package/dist/core/adapters/local.js.map +1 -1
- package/dist/core/adapters/webAuthn.d.ts.map +1 -1
- package/dist/core/adapters/webAuthn.js +7 -2
- package/dist/core/adapters/webAuthn.js.map +1 -1
- package/dist/core/zod/rpc.d.ts +17 -7
- package/dist/core/zod/rpc.d.ts.map +1 -1
- package/dist/core/zod/rpc.js +5 -1
- package/dist/core/zod/rpc.js.map +1 -1
- package/dist/react/Remote.d.ts +2 -0
- package/dist/react/Remote.d.ts.map +1 -1
- package/dist/react/Remote.js +69 -0
- package/dist/react/Remote.js.map +1 -1
- package/dist/react-native/Provider.d.ts.map +1 -1
- package/dist/react-native/Provider.js +4 -1
- package/dist/react-native/Provider.js.map +1 -1
- package/dist/react-native/adapter.d.ts +1 -1
- package/dist/react-native/adapter.d.ts.map +1 -1
- package/dist/react-native/adapter.js +2 -0
- package/dist/react-native/adapter.js.map +1 -1
- package/dist/server/CliAuth.d.ts +82 -11
- package/dist/server/CliAuth.d.ts.map +1 -1
- package/dist/server/CliAuth.js +82 -11
- package/dist/server/CliAuth.js.map +1 -1
- package/dist/server/internal/handlers/codeAuth.d.ts +2 -2
- package/dist/server/internal/handlers/codeAuth.js +2 -2
- package/dist/server/internal/handlers/relay.d.ts.map +1 -1
- package/dist/server/internal/handlers/relay.js +182 -88
- package/dist/server/internal/handlers/relay.js.map +1 -1
- package/dist/server/internal/handlers/utils.d.ts +2 -2
- package/dist/server/internal/handlers/utils.d.ts.map +1 -1
- package/dist/server/internal/handlers/utils.js +7 -2
- package/dist/server/internal/handlers/utils.js.map +1 -1
- package/dist/server/internal/handlers/webAuthn.d.ts +2 -0
- package/dist/server/internal/handlers/webAuthn.d.ts.map +1 -1
- package/dist/server/internal/handlers/webAuthn.js +20 -9
- package/dist/server/internal/handlers/webAuthn.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/Provider.test.ts +3 -1
- package/src/cli/Provider.ts +4 -2
- package/src/cli/keyring.ts +1 -1
- package/src/core/Account.ts +2 -0
- package/src/core/Adapter.ts +9 -1
- package/src/core/Dialog.browser.test.ts +3 -3
- package/src/core/Dialog.ts +51 -4
- package/src/core/Messenger.ts +12 -0
- package/src/core/Provider.ts +46 -18
- package/src/core/Remote.ts +26 -4
- package/src/core/Store.ts +12 -4
- package/src/core/TrustedHosts.ts +1 -0
- package/src/core/WebAuthnCeremony.ts +8 -0
- package/src/core/adapters/dialog.ts +10 -5
- package/src/core/adapters/local.ts +4 -4
- package/src/core/adapters/webAuthn.ts +7 -2
- package/src/core/zod/rpc.ts +5 -1
- package/src/react/Remote.ts +76 -0
- package/src/react-native/Provider.ts +9 -1
- package/src/react-native/adapter.ts +3 -1
- package/src/server/CliAuth.ts +82 -11
- package/src/server/internal/handlers/codeAuth.ts +2 -2
- package/src/server/internal/handlers/relay.test.ts +351 -1
- package/src/server/internal/handlers/relay.ts +207 -93
- package/src/server/internal/handlers/utils.ts +8 -2
- package/src/server/internal/handlers/webAuthn.ts +24 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webAuthn.js","sourceRoot":"","sources":["../../../../src/server/internal/handlers/webAuthn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,IAAI,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EACL,cAAc,EACd,YAAY,GAEb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAgB,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAyB;IAChD,MAAM,EAAE,YAAY,GAAG,GAAG,EAAE,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,IAA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AAM,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAA4B,CAAA;IAC9E,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE;QACzD,OAAO;QACP,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/cli/Provider.test.ts
CHANGED
|
@@ -156,11 +156,13 @@ describe('Provider.create', () => {
|
|
|
156
156
|
open: async (url) => {
|
|
157
157
|
opened.push(url)
|
|
158
158
|
const code = new URL(url).searchParams.get('code')!
|
|
159
|
-
|
|
159
|
+
console.log('[DEBUG test open] authorizing code', code)
|
|
160
|
+
const res = await fetch(`${server.url}/cli-auth`, {
|
|
160
161
|
body: JSON.stringify(await authorize(code)),
|
|
161
162
|
headers: { 'content-type': 'application/json' },
|
|
162
163
|
method: 'POST',
|
|
163
164
|
})
|
|
165
|
+
console.log('[DEBUG test open] authorize response', res.status, await res.clone().text())
|
|
164
166
|
},
|
|
165
167
|
host: `${server.url}/cli-auth`,
|
|
166
168
|
})
|
package/src/cli/Provider.ts
CHANGED
|
@@ -7,7 +7,9 @@ import { cli } from './adapter.js'
|
|
|
7
7
|
*/
|
|
8
8
|
export function create(options: create.Options): create.ReturnType {
|
|
9
9
|
const {
|
|
10
|
-
|
|
10
|
+
// TODO: use the new host
|
|
11
|
+
// host = 'https://wallet-next.tempo.xyz/remote/auth/cli',
|
|
12
|
+
host = 'https://wallet.tempo.xyz/cli-auth',
|
|
11
13
|
keysPath,
|
|
12
14
|
open,
|
|
13
15
|
pollIntervalMs,
|
|
@@ -32,7 +34,7 @@ export declare namespace create {
|
|
|
32
34
|
CoreProvider.create.Options & cli.Options,
|
|
33
35
|
'adapter' | 'authorizeAccessKey' | 'host'
|
|
34
36
|
> & {
|
|
35
|
-
/** Host URL for the device-code flow. @default "https://wallet.tempo.xyz/
|
|
37
|
+
/** Host URL for the device-code flow. @default "https://wallet-next.tempo.xyz/remote/auth/cli" */
|
|
36
38
|
host?: string | undefined
|
|
37
39
|
}
|
|
38
40
|
export type ReturnType = CoreProvider.create.ReturnType
|
package/src/cli/keyring.ts
CHANGED
|
@@ -185,7 +185,7 @@ function parse(text: string): readonly Entry[] {
|
|
|
185
185
|
|
|
186
186
|
function stringify(keys: readonly Entry[]) {
|
|
187
187
|
return [
|
|
188
|
-
'# Tempo
|
|
188
|
+
'# Tempo connect keys — managed by `tempo connect`',
|
|
189
189
|
'# Do not edit manually.',
|
|
190
190
|
'',
|
|
191
191
|
...keys.flatMap((key) => [
|
package/src/core/Account.ts
CHANGED
|
@@ -11,6 +11,8 @@ import type * as core_Store from './Store.js'
|
|
|
11
11
|
export type Store = {
|
|
12
12
|
/** Account address. */
|
|
13
13
|
address: Address
|
|
14
|
+
/** Display label used during registration (e.g. email). */
|
|
15
|
+
label?: string | undefined
|
|
14
16
|
} & OneOf<
|
|
15
17
|
| {}
|
|
16
18
|
| Pick<TempoAccount.Account, 'keyType' | 'sign'>
|
package/src/core/Adapter.ts
CHANGED
|
@@ -151,10 +151,14 @@ export declare namespace createAccount {
|
|
|
151
151
|
}
|
|
152
152
|
type ReturnType = {
|
|
153
153
|
accounts: readonly Store.Account[]
|
|
154
|
+
/** Email associated with the account. */
|
|
155
|
+
email?: string | null | undefined
|
|
154
156
|
/** Signed key authorization, if an access key was granted. */
|
|
155
157
|
keyAuthorization?: KeyAuthorization.Rpc | undefined
|
|
156
158
|
/** Signature over the digest, if one was provided. */
|
|
157
159
|
signature?: Hex | undefined
|
|
160
|
+
/** Username associated with the account. */
|
|
161
|
+
username?: string | null | undefined
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
164
|
|
|
@@ -177,10 +181,14 @@ export declare namespace loadAccounts {
|
|
|
177
181
|
type ReturnType = {
|
|
178
182
|
/** Loaded accounts. */
|
|
179
183
|
accounts: readonly Store.Account[]
|
|
184
|
+
/** Email associated with the account. */
|
|
185
|
+
email?: string | null | undefined
|
|
180
186
|
/** Signed key authorization, if an access key was granted. */
|
|
181
187
|
keyAuthorization?: KeyAuthorization.Rpc | undefined
|
|
182
188
|
/** Signature over the digest, if one was provided. */
|
|
183
189
|
signature?: Hex | undefined
|
|
190
|
+
/** Username associated with the account. */
|
|
191
|
+
username?: string | null | undefined
|
|
184
192
|
}
|
|
185
193
|
}
|
|
186
194
|
|
|
@@ -207,7 +215,7 @@ export declare namespace authorizeAccessKey {
|
|
|
207
215
|
/** Access key address. Alternative to `publicKey` when the caller already knows the derived address. */
|
|
208
216
|
address?: Address | undefined
|
|
209
217
|
/** Chain ID the key authorization is scoped to. Defaults to the active chain. */
|
|
210
|
-
chainId?:
|
|
218
|
+
chainId?: bigint | undefined
|
|
211
219
|
/** Unix timestamp (seconds) when the key expires. */
|
|
212
220
|
expiry: number
|
|
213
221
|
/** Key type of the external public key. Required when `publicKey` or `address` is provided. */
|
|
@@ -4,7 +4,7 @@ import * as Dialog from './Dialog.js'
|
|
|
4
4
|
import * as Storage from './Storage.js'
|
|
5
5
|
import * as Store from './Store.js'
|
|
6
6
|
|
|
7
|
-
const host = 'https://wallet.tempo.xyz/
|
|
7
|
+
const host = 'https://wallet-next.tempo.xyz/remote'
|
|
8
8
|
|
|
9
9
|
function setup() {
|
|
10
10
|
const store = Store.create({
|
|
@@ -64,7 +64,7 @@ describe('Dialog.iframe', () => {
|
|
|
64
64
|
test('behavior: iframe src points to host', () => {
|
|
65
65
|
setup()
|
|
66
66
|
const iframe = document.querySelector('dialog[data-tempo-wallet] iframe') as HTMLIFrameElement
|
|
67
|
-
expect(iframe.src).toMatchInlineSnapshot(`"https://wallet.tempo.xyz/
|
|
67
|
+
expect(iframe.src).toMatchInlineSnapshot(`"https://wallet-next.tempo.xyz/remote"`)
|
|
68
68
|
expect(iframe.src).toContain(host)
|
|
69
69
|
})
|
|
70
70
|
|
|
@@ -194,7 +194,7 @@ describe('Dialog.iframe', () => {
|
|
|
194
194
|
setup()
|
|
195
195
|
const dialog = document.querySelector('dialog[data-tempo-wallet]') as HTMLDialogElement
|
|
196
196
|
expect(dialog.getAttribute('role')).toBe('dialog')
|
|
197
|
-
expect(dialog.getAttribute('aria-label')).toBe('Tempo
|
|
197
|
+
expect(dialog.getAttribute('aria-label')).toBe('Tempo Wallet')
|
|
198
198
|
})
|
|
199
199
|
})
|
|
200
200
|
|
package/src/core/Dialog.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type Instance = {
|
|
|
21
21
|
open: () => void
|
|
22
22
|
/** Sync the pending request queue to the remote auth app. */
|
|
23
23
|
syncRequests: (requests: readonly Store.QueuedRequest[]) => Promise<void>
|
|
24
|
+
/** Update the visual theme at runtime. */
|
|
25
|
+
syncTheme: (theme: Theme | undefined) => void
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/** The setup function a dialog must implement. */
|
|
@@ -28,13 +30,36 @@ export type SetupFn = (parameters: SetupFn.Parameters) => Instance
|
|
|
28
30
|
|
|
29
31
|
export declare namespace SetupFn {
|
|
30
32
|
type Parameters = {
|
|
31
|
-
/** URL of the Tempo
|
|
33
|
+
/** URL of the Tempo Wallet app. */
|
|
32
34
|
host: string
|
|
33
35
|
/** Reactive state store. */
|
|
34
36
|
store: Store.Store
|
|
37
|
+
/** Visual theme overrides applied to the embed. */
|
|
38
|
+
theme?: Theme | undefined
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
/** Visual theme configuration for the dialog embed. */
|
|
43
|
+
export type Theme = {
|
|
44
|
+
/** Accent color — a preset name or a hex color (e.g. `'#6366f1'`). */
|
|
45
|
+
accent?: 'blue' | 'red' | 'amber' | 'green' | 'purple' | 'invert' | (string & {}) | undefined
|
|
46
|
+
/** Border radius preset. */
|
|
47
|
+
radius?: 'none' | 'small' | 'medium' | 'large' | 'full' | undefined
|
|
48
|
+
/** Font family — a bundled name (`'Pilat'`, `'TT Norms'`) or a Google Font. */
|
|
49
|
+
font?: string | undefined
|
|
50
|
+
/** Color scheme — controls light/dark appearance. Defaults to `'light dark'` (follows OS). */
|
|
51
|
+
scheme?: 'light' | 'dark' | undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Serializes theme options onto a URL's search params. */
|
|
55
|
+
function applyThemeParams(url: URL, theme: Theme | undefined) {
|
|
56
|
+
if (!theme) return
|
|
57
|
+
if (theme.accent) url.searchParams.set('accent', theme.accent)
|
|
58
|
+
if (theme.radius) url.searchParams.set('radius', theme.radius)
|
|
59
|
+
if (theme.font) url.searchParams.set('font', theme.font)
|
|
60
|
+
if (theme.scheme) url.searchParams.set('scheme', theme.scheme)
|
|
61
|
+
}
|
|
62
|
+
|
|
38
63
|
export const defaultSize = { height: 440, width: 360 }
|
|
39
64
|
|
|
40
65
|
/** Creates a dialog from metadata and a setup function. */
|
|
@@ -86,6 +111,7 @@ export function iframe(): Dialog {
|
|
|
86
111
|
|
|
87
112
|
fallback?.destroy()
|
|
88
113
|
fallback = popup()(parameters)
|
|
114
|
+
cached.instance.syncTheme(parameters.theme)
|
|
89
115
|
return cached.instance
|
|
90
116
|
}
|
|
91
117
|
|
|
@@ -109,13 +135,14 @@ export function iframe(): Dialog {
|
|
|
109
135
|
hostUrl.searchParams.set('iconDark', referrer.icon.dark)
|
|
110
136
|
}
|
|
111
137
|
}
|
|
138
|
+
applyThemeParams(hostUrl, parameters.theme)
|
|
112
139
|
|
|
113
140
|
const root = document.createElement('dialog')
|
|
114
141
|
root.dataset.tempoWallet = ''
|
|
115
142
|
|
|
116
143
|
root.setAttribute('role', 'dialog')
|
|
117
144
|
root.setAttribute('aria-closed', 'true')
|
|
118
|
-
root.setAttribute('aria-label', 'Tempo
|
|
145
|
+
root.setAttribute('aria-label', 'Tempo Wallet')
|
|
119
146
|
root.setAttribute('hidden', 'until-found')
|
|
120
147
|
|
|
121
148
|
Object.assign(root.style, {
|
|
@@ -139,13 +166,13 @@ export function iframe(): Dialog {
|
|
|
139
166
|
)
|
|
140
167
|
frame.setAttribute('allowtransparency', 'true')
|
|
141
168
|
frame.setAttribute('tabindex', '0')
|
|
142
|
-
frame.setAttribute('title', 'Tempo
|
|
169
|
+
frame.setAttribute('title', 'Tempo Wallet')
|
|
143
170
|
frame.src = hostUrl.toString()
|
|
144
171
|
|
|
145
172
|
Object.assign(frame.style, {
|
|
146
173
|
backgroundColor: 'transparent',
|
|
147
174
|
border: '0',
|
|
148
|
-
colorScheme: 'light dark',
|
|
175
|
+
colorScheme: parameters.theme?.scheme ?? 'light dark',
|
|
149
176
|
height: '100%',
|
|
150
177
|
left: '0',
|
|
151
178
|
position: 'fixed',
|
|
@@ -183,6 +210,11 @@ export function iframe(): Dialog {
|
|
|
183
210
|
m.waitForReady().then((result) => {
|
|
184
211
|
readyResult = result
|
|
185
212
|
if (result.colorScheme) frame.style.colorScheme = result.colorScheme
|
|
213
|
+
// Ask the wallet to verify the SDK's stored accounts are still valid.
|
|
214
|
+
syncAccounts(m)
|
|
215
|
+
})
|
|
216
|
+
m.on('sync', ({ valid }) => {
|
|
217
|
+
if (valid === false) store?.setState({ accessKeys: [], accounts: [], activeAccount: 0 })
|
|
186
218
|
})
|
|
187
219
|
m.on('switch-mode', () => {
|
|
188
220
|
hideDialog()
|
|
@@ -362,6 +394,10 @@ export function iframe(): Dialog {
|
|
|
362
394
|
})
|
|
363
395
|
}
|
|
364
396
|
},
|
|
397
|
+
syncTheme(theme) {
|
|
398
|
+
frame.style.colorScheme = theme?.scheme ?? 'light dark'
|
|
399
|
+
messenger.send('theme', theme ?? {})
|
|
400
|
+
},
|
|
365
401
|
}
|
|
366
402
|
|
|
367
403
|
cached = { host, instance }
|
|
@@ -452,6 +488,7 @@ export function popup(options: popup.Options = {}): Dialog {
|
|
|
452
488
|
hostUrl.searchParams.set('iconDark', referrer.icon.dark)
|
|
453
489
|
}
|
|
454
490
|
}
|
|
491
|
+
applyThemeParams(hostUrl, parameters.theme)
|
|
455
492
|
|
|
456
493
|
const left = (window.innerWidth - size.width) / 2 + window.screenX
|
|
457
494
|
const top = window.screenY + 100
|
|
@@ -485,6 +522,7 @@ export function popup(options: popup.Options = {}): Dialog {
|
|
|
485
522
|
requests,
|
|
486
523
|
})
|
|
487
524
|
},
|
|
525
|
+
syncTheme() {},
|
|
488
526
|
}
|
|
489
527
|
})
|
|
490
528
|
}
|
|
@@ -503,6 +541,7 @@ export function noop(): Dialog {
|
|
|
503
541
|
close() {},
|
|
504
542
|
destroy() {},
|
|
505
543
|
async syncRequests() {},
|
|
544
|
+
syncTheme() {},
|
|
506
545
|
}))
|
|
507
546
|
}
|
|
508
547
|
|
|
@@ -559,6 +598,14 @@ function handleBlur(store: Store.Store) {
|
|
|
559
598
|
}))
|
|
560
599
|
}
|
|
561
600
|
|
|
601
|
+
/** Sends stored account addresses to the wallet for session validation. */
|
|
602
|
+
function syncAccounts(messenger: Messenger.Bridge) {
|
|
603
|
+
if (!store) return
|
|
604
|
+
const { accounts } = store.getState()
|
|
605
|
+
if (accounts.length === 0) return
|
|
606
|
+
messenger.send('sync', { addresses: accounts.map((a) => a.address) })
|
|
607
|
+
}
|
|
608
|
+
|
|
562
609
|
/** Returns the active account from the store, or `undefined` if none. */
|
|
563
610
|
function getAccount(store: Store.Store): { address: string } | undefined {
|
|
564
611
|
const { accounts, activeAccount } = store.getState()
|
package/src/core/Messenger.ts
CHANGED
|
@@ -64,6 +64,18 @@ export type Schema = [
|
|
|
64
64
|
topic: 'switch-mode'
|
|
65
65
|
payload: { mode: 'popup' }
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
topic: 'sync'
|
|
69
|
+
payload: { addresses?: readonly string[] | undefined; valid?: boolean | undefined }
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
topic: 'theme'
|
|
73
|
+
payload: {
|
|
74
|
+
accent?: string | undefined
|
|
75
|
+
radius?: string | undefined
|
|
76
|
+
font?: string | undefined
|
|
77
|
+
}
|
|
78
|
+
},
|
|
67
79
|
]
|
|
68
80
|
|
|
69
81
|
/** Union of all topic strings. */
|
package/src/core/Provider.ts
CHANGED
|
@@ -50,6 +50,7 @@ export function create(options: create.Options = {}): create.ReturnType {
|
|
|
50
50
|
const {
|
|
51
51
|
adapter = dialog(),
|
|
52
52
|
chains = [tempo, tempoModerato, tempoDevnet],
|
|
53
|
+
maxAccounts,
|
|
53
54
|
persistCredentials,
|
|
54
55
|
testnet,
|
|
55
56
|
storage = typeof window !== 'undefined' ? Storage.idb() : Storage.memory(),
|
|
@@ -71,6 +72,7 @@ export function create(options: create.Options = {}): create.ReturnType {
|
|
|
71
72
|
|
|
72
73
|
const store = Store.create({
|
|
73
74
|
chainId: defaultChain.id,
|
|
75
|
+
maxAccounts,
|
|
74
76
|
persistCredentials,
|
|
75
77
|
storage,
|
|
76
78
|
})
|
|
@@ -138,10 +140,10 @@ export function create(options: create.Options = {}): create.ReturnType {
|
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
/** Resolves the `feePayer` field from a transaction request into an absolute URL string or `undefined`. */
|
|
141
|
-
function resolveFeePayer(feePayer: string | boolean | undefined): string | undefined {
|
|
143
|
+
function resolveFeePayer(feePayer: string | boolean | undefined): string | false | undefined {
|
|
144
|
+
if (feePayer === false) return false
|
|
142
145
|
const url = (() => {
|
|
143
146
|
if (typeof feePayer === 'string') return feePayer
|
|
144
|
-
if (feePayer === false) return undefined
|
|
145
147
|
return feePayerConfig?.url
|
|
146
148
|
})()
|
|
147
149
|
if (!url) return undefined
|
|
@@ -499,27 +501,49 @@ export function create(options: create.Options = {}): create.ReturnType {
|
|
|
499
501
|
const authorizeAccessKey =
|
|
500
502
|
capabilities?.authorizeAccessKey ?? options.authorizeAccessKey?.()
|
|
501
503
|
|
|
502
|
-
const { keyAuthorization, accounts, signature } =
|
|
503
|
-
|
|
504
|
-
|
|
504
|
+
const { keyAuthorization, accounts, email, signature, username } =
|
|
505
|
+
await (async () => {
|
|
506
|
+
if (capabilities?.method === 'register') {
|
|
507
|
+
// If a stored account already has this label, sign in
|
|
508
|
+
// with its credential instead of creating a new one.
|
|
509
|
+
const existing = capabilities.name
|
|
510
|
+
? store
|
|
511
|
+
.getState()
|
|
512
|
+
.accounts.find(
|
|
513
|
+
(a) =>
|
|
514
|
+
'credential' in a &&
|
|
515
|
+
a.label?.toLowerCase() === capabilities.name!.toLowerCase(),
|
|
516
|
+
)
|
|
517
|
+
: undefined
|
|
518
|
+
if (existing && 'credential' in existing)
|
|
519
|
+
return await actions.loadAccounts(
|
|
520
|
+
{
|
|
521
|
+
credentialId: existing.credential?.id,
|
|
522
|
+
digest: capabilities.digest,
|
|
523
|
+
authorizeAccessKey,
|
|
524
|
+
},
|
|
525
|
+
request,
|
|
526
|
+
)
|
|
527
|
+
return await actions.createAccount(
|
|
528
|
+
{
|
|
529
|
+
digest: capabilities.digest,
|
|
530
|
+
authorizeAccessKey,
|
|
531
|
+
name: capabilities.name ?? 'default',
|
|
532
|
+
userId: capabilities.userId ?? Hex.random(16),
|
|
533
|
+
},
|
|
534
|
+
request,
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
return await actions.loadAccounts(
|
|
505
538
|
{
|
|
506
|
-
|
|
539
|
+
credentialId: capabilities?.credentialId,
|
|
540
|
+
digest: capabilities?.digest,
|
|
507
541
|
authorizeAccessKey,
|
|
508
|
-
|
|
509
|
-
userId: capabilities.userId,
|
|
542
|
+
selectAccount: capabilities?.selectAccount,
|
|
510
543
|
},
|
|
511
544
|
request,
|
|
512
545
|
)
|
|
513
|
-
|
|
514
|
-
{
|
|
515
|
-
credentialId: capabilities?.credentialId,
|
|
516
|
-
digest: capabilities?.digest,
|
|
517
|
-
authorizeAccessKey,
|
|
518
|
-
selectAccount: capabilities?.selectAccount,
|
|
519
|
-
},
|
|
520
|
-
request,
|
|
521
|
-
)
|
|
522
|
-
})()
|
|
546
|
+
})()
|
|
523
547
|
|
|
524
548
|
store.setState({ accounts: resolveAccounts(accounts), activeAccount: 0 })
|
|
525
549
|
|
|
@@ -539,6 +563,8 @@ export function create(options: create.Options = {}): create.ReturnType {
|
|
|
539
563
|
}
|
|
540
564
|
: {}),
|
|
541
565
|
...(signature && capabilities?.digest ? { signature } : {}),
|
|
566
|
+
...(email !== undefined ? { email } : {}),
|
|
567
|
+
...(username !== undefined ? { username } : {}),
|
|
542
568
|
}
|
|
543
569
|
: {},
|
|
544
570
|
})),
|
|
@@ -686,6 +712,8 @@ export declare namespace create {
|
|
|
686
712
|
chains?: readonly [Chain, ...Chain[]] | undefined
|
|
687
713
|
/** Fee payer configuration. @see {@link Client.fromChainId.Options.feePayer} */
|
|
688
714
|
feePayer?: Client.fromChainId.Options['feePayer']
|
|
715
|
+
/** Maximum number of accounts to persist. Oldest accounts are evicted when exceeded (LRU). */
|
|
716
|
+
maxAccounts?: number | undefined
|
|
689
717
|
/** Enable Machine Payment Protocol (mppx) support. @default false */
|
|
690
718
|
mpp?: boolean | undefined
|
|
691
719
|
/** Whether to persist credentials and access keys to storage. When `false`, only account addresses are persisted. @default true */
|
package/src/core/Remote.ts
CHANGED
|
@@ -70,7 +70,7 @@ export type Remote = {
|
|
|
70
70
|
* Signals readiness to the host and begins accepting requests.
|
|
71
71
|
* Call this after the remote context is fully initialized.
|
|
72
72
|
*/
|
|
73
|
-
ready: (options?:
|
|
73
|
+
ready: (options?: ready.Options | undefined) => void
|
|
74
74
|
/**
|
|
75
75
|
* Reject an RPC request.
|
|
76
76
|
*/
|
|
@@ -101,6 +101,13 @@ export declare namespace onUserRequest {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
export declare namespace ready {
|
|
105
|
+
type Options = Messenger.ReadyOptions & {
|
|
106
|
+
/** Authenticated account addresses. When provided, the wallet responds to SDK sync requests. */
|
|
107
|
+
accounts?: readonly string[] | undefined
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
104
111
|
export declare namespace respond {
|
|
105
112
|
type Options = {
|
|
106
113
|
/** Error to respond with (takes precedence over result). */
|
|
@@ -144,8 +151,12 @@ export function create(options: create.Options): Remote {
|
|
|
144
151
|
const index = state.accounts.findIndex(
|
|
145
152
|
(a) => a.address.toLowerCase() === account.address.toLowerCase(),
|
|
146
153
|
)
|
|
147
|
-
if (index
|
|
148
|
-
|
|
154
|
+
if (index < 0) {
|
|
155
|
+
messenger.send('sync', { valid: false })
|
|
156
|
+
for (const r of requests) if (r.status === 'pending') this.reject(r.request)
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
if (index !== state.activeAccount) provider.store.setState({ activeAccount: index })
|
|
149
160
|
}
|
|
150
161
|
|
|
151
162
|
const pending = requests.find((r) => r.status === 'pending')
|
|
@@ -183,7 +194,18 @@ export function create(options: create.Options): Remote {
|
|
|
183
194
|
},
|
|
184
195
|
|
|
185
196
|
ready(options) {
|
|
186
|
-
|
|
197
|
+
const { accounts, ...readyOptions } = options ?? {}
|
|
198
|
+
messenger.ready({ ...readyOptions, trustedHosts })
|
|
199
|
+
|
|
200
|
+
// Respond to account sync requests from the SDK.
|
|
201
|
+
if (accounts)
|
|
202
|
+
messenger.on('sync', ({ addresses }) => {
|
|
203
|
+
if (!addresses) return
|
|
204
|
+
const valid = addresses.some((a) =>
|
|
205
|
+
accounts.some((b) => a.toLowerCase() === b.toLowerCase()),
|
|
206
|
+
)
|
|
207
|
+
messenger.send('sync', { valid })
|
|
208
|
+
})
|
|
187
209
|
|
|
188
210
|
if (typeof window !== 'undefined') {
|
|
189
211
|
const params = new URLSearchParams(window.location.search)
|
package/src/core/Store.ts
CHANGED
|
@@ -34,6 +34,8 @@ export type Store = Mutate<
|
|
|
34
34
|
export type Options = {
|
|
35
35
|
/** Initial chain ID. */
|
|
36
36
|
chainId: number
|
|
37
|
+
/** Maximum number of accounts to persist. Oldest accounts are evicted when exceeded (LRU). */
|
|
38
|
+
maxAccounts?: number | undefined
|
|
37
39
|
/** Whether to persist credentials and access keys to storage. When `false`, only account addresses are persisted. @default true */
|
|
38
40
|
persistCredentials?: boolean | undefined
|
|
39
41
|
/** Storage adapter for persistence. */
|
|
@@ -64,6 +66,7 @@ export type QueuedRequest<result = unknown> = OneOf<
|
|
|
64
66
|
export function create(options: Options): Store {
|
|
65
67
|
const {
|
|
66
68
|
chainId,
|
|
69
|
+
maxAccounts,
|
|
67
70
|
persistCredentials = true,
|
|
68
71
|
storage = typeof window !== 'undefined'
|
|
69
72
|
? Storage.idb({ key: 'tempo' })
|
|
@@ -99,13 +102,18 @@ export function create(options: Options): Store {
|
|
|
99
102
|
}
|
|
100
103
|
},
|
|
101
104
|
name: 'store',
|
|
102
|
-
partialize: (state) =>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
partialize: (state) => {
|
|
106
|
+
const accounts =
|
|
107
|
+
maxAccounts && state.accounts.length > maxAccounts
|
|
108
|
+
? state.accounts.slice(0, maxAccounts)
|
|
109
|
+
: state.accounts
|
|
110
|
+
return {
|
|
111
|
+
accounts,
|
|
105
112
|
activeAccount: state.activeAccount,
|
|
106
113
|
...(persistCredentials ? { accessKeys: state.accessKeys } : {}),
|
|
107
114
|
chainId: state.chainId,
|
|
108
|
-
}
|
|
115
|
+
} as unknown as State
|
|
116
|
+
},
|
|
109
117
|
storage,
|
|
110
118
|
version: 0,
|
|
111
119
|
},
|
package/src/core/TrustedHosts.ts
CHANGED
|
@@ -15,6 +15,7 @@ export const hosts: Record<string, readonly string[]> = _hosts
|
|
|
15
15
|
* (e.g. `*.workers.dev` matches `foo.workers.dev`).
|
|
16
16
|
*/
|
|
17
17
|
export function match(trustedHosts: readonly string[], hostname: string) {
|
|
18
|
+
if (hostname.endsWith('.local')) return true
|
|
18
19
|
return trustedHosts.some((pattern) => {
|
|
19
20
|
if (pattern.startsWith('*.'))
|
|
20
21
|
return hostname.endsWith(pattern.slice(1)) && hostname.length > pattern.length - 1
|
|
@@ -47,6 +47,10 @@ export declare namespace verifyRegistration {
|
|
|
47
47
|
credentialId: string
|
|
48
48
|
/** The credential's public key (uncompressed P256, hex-encoded). */
|
|
49
49
|
publicKey: Hex
|
|
50
|
+
/** Email associated with the account. */
|
|
51
|
+
email?: string | null | undefined
|
|
52
|
+
/** Username associated with the account. */
|
|
53
|
+
username?: string | null | undefined
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -72,6 +76,10 @@ export declare namespace verifyAuthentication {
|
|
|
72
76
|
publicKey: Hex
|
|
73
77
|
/** User identifier from the authenticator's `userHandle` (discoverable/conditional flows). */
|
|
74
78
|
userId?: string | undefined
|
|
79
|
+
/** Email associated with the account. */
|
|
80
|
+
email?: string | null | undefined
|
|
81
|
+
/** Username associated with the account. */
|
|
82
|
+
username?: string | null | undefined
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
85
|
|
|
@@ -27,10 +27,13 @@ import * as Rpc from '../zod/rpc.js'
|
|
|
27
27
|
export function dialog(options: dialog.Options = {}): Adapter.Adapter {
|
|
28
28
|
const {
|
|
29
29
|
dialog = Dialog.isInsecureContext() ? Dialog.popup() : Dialog.iframe(),
|
|
30
|
+
// TODO: use the new host
|
|
31
|
+
// host = 'https://wallet-next.tempo.xyz/remote',
|
|
30
32
|
host = 'https://wallet.tempo.xyz/embed',
|
|
31
33
|
icon = 'data:image/svg+xml,<svg width="269" height="269" viewBox="0 0 269 269" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="269" height="269" fill="black"/><path d="M123.273 190.794H93.445L121.09 105.318H85.7334L93.445 80.2642H191.95L184.238 105.318H150.773L123.273 190.794Z" fill="white"/></svg>',
|
|
32
34
|
name = 'Tempo Wallet',
|
|
33
35
|
rdns = 'xyz.tempo',
|
|
36
|
+
theme,
|
|
34
37
|
} = options
|
|
35
38
|
|
|
36
39
|
if (typeof window !== 'undefined' && !window.isSecureContext)
|
|
@@ -169,7 +172,7 @@ export function dialog(options: dialog.Options = {}): Adapter.Adapter {
|
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
174
|
|
|
172
|
-
const dialogInstance = dialog({ host, store })
|
|
175
|
+
const dialogInstance = dialog({ host, store, theme })
|
|
173
176
|
|
|
174
177
|
// Sync store → dialog: whenever the request queue changes, notify
|
|
175
178
|
// listeners and sync pending requests to the dialog.
|
|
@@ -286,7 +289,7 @@ export function dialog(options: dialog.Options = {}): Adapter.Adapter {
|
|
|
286
289
|
const prepared = await prepareTransactionRequest(client, {
|
|
287
290
|
account,
|
|
288
291
|
...rest,
|
|
289
|
-
...(feePayer ? { feePayer:
|
|
292
|
+
...(typeof feePayer !== 'undefined' ? { feePayer: !!feePayer as never } : {}),
|
|
290
293
|
keyAuthorization,
|
|
291
294
|
type: 'tempo',
|
|
292
295
|
})
|
|
@@ -316,7 +319,7 @@ export function dialog(options: dialog.Options = {}): Adapter.Adapter {
|
|
|
316
319
|
const prepared = await prepareTransactionRequest(client, {
|
|
317
320
|
account,
|
|
318
321
|
...rest,
|
|
319
|
-
...(feePayer ? { feePayer:
|
|
322
|
+
...(typeof feePayer !== 'undefined' ? { feePayer: !!feePayer as never } : {}),
|
|
320
323
|
keyAuthorization,
|
|
321
324
|
type: 'tempo',
|
|
322
325
|
})
|
|
@@ -346,7 +349,7 @@ export function dialog(options: dialog.Options = {}): Adapter.Adapter {
|
|
|
346
349
|
const prepared = await prepareTransactionRequest(client, {
|
|
347
350
|
account,
|
|
348
351
|
...rest,
|
|
349
|
-
...(feePayer ? { feePayer:
|
|
352
|
+
...(typeof feePayer !== 'undefined' ? { feePayer: !!feePayer as never } : {}),
|
|
350
353
|
keyAuthorization,
|
|
351
354
|
type: 'tempo',
|
|
352
355
|
})
|
|
@@ -404,7 +407,7 @@ export declare namespace dialog {
|
|
|
404
407
|
type Options = {
|
|
405
408
|
/** Dialog to use for the embed app. @default `Dialog.iframe()` (or `Dialog.popup()` in Safari/insecure contexts) */
|
|
406
409
|
dialog?: Dialog.Dialog | undefined
|
|
407
|
-
/** URL of the embed app. @default `'https://wallet.tempo.xyz/
|
|
410
|
+
/** URL of the embed app. @default `'https://wallet-next.tempo.xyz/remote'` */
|
|
408
411
|
host?: string | undefined
|
|
409
412
|
/** Data URI of the provider icon. */
|
|
410
413
|
icon?: `data:image/${string}` | undefined
|
|
@@ -412,5 +415,7 @@ export declare namespace dialog {
|
|
|
412
415
|
name?: string | undefined
|
|
413
416
|
/** Reverse DNS identifier. @default `'xyz.tempo'` */
|
|
414
417
|
rdns?: string | undefined
|
|
418
|
+
/** Visual theme overrides for the wallet dialog. */
|
|
419
|
+
theme?: Dialog.Theme | undefined
|
|
415
420
|
}
|
|
416
421
|
}
|