@bsv/expo-wallet-toolbox 0.22.0 → 0.23.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/README.md +9 -5
  3. package/core/bridge/BrowserBridgeProvider.tsx +273 -0
  4. package/core/bridge/bindings.ts +459 -0
  5. package/core/bridge/conformance.ts +222 -0
  6. package/core/bridge/consent.ts +494 -0
  7. package/core/bridge/consentSheetSource.ts +98 -0
  8. package/core/bridge/dispatcher.ts +621 -0
  9. package/core/bridge/inbox.ts +464 -0
  10. package/core/bridge/index.ts +48 -0
  11. package/core/bridge/loopback/cors.ts +57 -0
  12. package/core/bridge/loopback/endpoints.ts +11 -0
  13. package/core/bridge/loopback/hostCheck.ts +25 -0
  14. package/core/bridge/loopback/index.ts +7 -0
  15. package/core/bridge/loopback/launchProof.ts +166 -0
  16. package/core/bridge/loopback/router.ts +770 -0
  17. package/core/bridge/loopback/routerTypes.ts +115 -0
  18. package/core/bridge/loopback/status.ts +52 -0
  19. package/core/bridge/memoryInboxStore.ts +222 -0
  20. package/core/bridge/permissionPolicy.ts +247 -0
  21. package/core/bridge/policy.ts +72 -0
  22. package/core/bridge/protocol/base64url.ts +64 -0
  23. package/core/bridge/protocol/connectionError.ts +79 -0
  24. package/core/bridge/protocol/constants.ts +21 -0
  25. package/core/bridge/protocol/continuity.ts +21 -0
  26. package/core/bridge/protocol/descriptor.ts +395 -0
  27. package/core/bridge/protocol/envelopes.ts +188 -0
  28. package/core/bridge/protocol/errorCodec.ts +164 -0
  29. package/core/bridge/protocol/json.ts +237 -0
  30. package/core/bridge/protocol/limits.ts +43 -0
  31. package/core/bridge/protocol/methods.ts +55 -0
  32. package/core/bridge/protocol/origin.ts +130 -0
  33. package/core/bridge/runtime.ts +642 -0
  34. package/core/bridge/runtimeFlags.ts +34 -0
  35. package/core/bridge/testing/conformanceCases.ts +149 -0
  36. package/core/bridge/testing/pageClient.ts +44 -0
  37. package/core/bridge/unverifiedManager.ts +97 -0
  38. package/core/bridge/unverifiedOriginator.ts +79 -0
  39. package/core/config.tsx +1 -16
  40. package/core/context/WalletConnectionContext.tsx +7 -1
  41. package/core/context/WalletContext.tsx +258 -133
  42. package/core/context/sessionTeardown.ts +46 -0
  43. package/core/hooks/usePermissionQueue.ts +89 -34
  44. package/core/i18n/translations.tsx +911 -12
  45. package/core/index.ts +15 -0
  46. package/core/services/autoApprovePolicy.ts +7 -1
  47. package/core/services/capWalletArgs.ts +2 -1
  48. package/core/services/permissionPrompts.ts +132 -0
  49. package/core/services/signingPermissionPolicy.ts +230 -2
  50. package/core/services/vault/guard.ts +10 -0
  51. package/core/services/walletArgLimits.ts +17 -2
  52. package/core/storage/encryptedDbImage.ts +325 -0
  53. package/core/toolboxConfig.ts +18 -1
  54. package/package.json +6 -6
  55. package/ui/bridgeSheet/ContextRelay.tsx +86 -0
  56. package/ui/bridgeSheet/relayedContexts.ts +21 -0
  57. package/ui/components/ui/PermissionSheet.tsx +534 -158
  58. package/ui/components/ui/Sheet.tsx +59 -7
  59. package/ui/components/ui/sheetResumeSignal.ts +19 -0
  60. package/ui/exportDatabases.ts +94 -5
  61. package/ui/hooks/useExportWalletData.ts +37 -24
  62. package/ui/importDatabases.ts +123 -28
  63. package/ui/index.ts +4 -0
  64. package/ui/screens/WalletConfigScreen.tsx +13 -1
@@ -1,11 +1,21 @@
1
- import React, { useContext, useState, useCallback, useMemo, useEffect, useRef } from 'react'
2
- import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native'
1
+ import React, { useContext, useState, useCallback, useMemo, useEffect, useRef, useSyncExternalStore } from 'react'
2
+ import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Platform, AppState } from 'react-native'
3
3
  import type { WalletPermissionsManager } from '@bsv/wallet-toolbox-mobile'
4
+ import type { SigningPolicyPermissionsManager } from '../../../core/services/signingPermissionPolicy'
4
5
  import Sheet from './Sheet'
5
6
  import PressableScale from './PressableScale'
6
7
  import { useTranslation } from 'react-i18next'
7
8
  import AmountDisplay from '../wallet/AmountDisplay'
8
9
  import { describeProtocolPrompt } from './protocolPrompt'
10
+ import type { PendingConsent } from '../../../core/bridge/consent'
11
+ import {
12
+ answerConnection,
13
+ connectionFlags,
14
+ getPendingConnections,
15
+ subscribeConsentRequests
16
+ } from '../../../core/bridge/consentSheetSource'
17
+ import { SEEK_FLAG_DISCLOSURE, SEEK_FLAG_KEYS, type SeekFlags } from '../../../core/bridge/permissionPolicy'
18
+ import { hostnameOfUnattested, isUnattestedOriginator } from '../../../core/bridge/unverifiedOriginator'
9
19
  import { describeColorRequest, type ColorPromptType } from './colorPrompt'
10
20
  import {
11
21
  spacing,
@@ -24,6 +34,22 @@ import {
24
34
  // ---------------------------------------------------------------------------
25
35
  const DEV_BTMS_PREVIEW = false
26
36
 
37
+ /** How long Authorize stays inert when a connection or unverified prompt reaches the head (spec 6.4). */
38
+ const managerTokens = new WeakMap<object, number>()
39
+ let managerTokenCount = 0
40
+ /** A stable small number per manager object, '-' for a prompt that has none. */
41
+ function managerToken(manager: unknown): string {
42
+ if (manager === null || typeof manager !== 'object') return '-'
43
+ let n = managerTokens.get(manager)
44
+ if (n === undefined) {
45
+ n = ++managerTokenCount
46
+ managerTokens.set(manager, n)
47
+ }
48
+ return String(n)
49
+ }
50
+
51
+ const TAP_PROTECTION_MS = 700
52
+
27
53
  // ---------------------------------------------------------------------------
28
54
  // @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
29
55
  // etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
@@ -45,7 +71,7 @@ function loadIonicons(): IoniconsComponent {
45
71
  // Types
46
72
  // ---------------------------------------------------------------------------
47
73
 
48
- type PermissionKind = 'protocol' | 'basket' | 'certificate' | 'spending' | 'group' | 'btms' | 'mandala'
74
+ type PermissionKind = 'protocol' | 'basket' | 'certificate' | 'spending' | 'group' | 'btms' | 'mandala' | 'connection'
49
75
 
50
76
  interface GroupProtocol {
51
77
  protocolID: [number, string]
@@ -79,6 +105,8 @@ type GrantedGroupPermissions = Parameters<WalletPermissionsManager['grantGrouped
79
105
  export interface ActivePermission {
80
106
  kind: PermissionKind
81
107
  requestID: string
108
+ /** The manager that raised the request: the one the answer goes to. */
109
+ manager?: SigningPolicyPermissionsManager
82
110
  originator: string
83
111
  title: string
84
112
  description: string
@@ -101,6 +129,23 @@ export interface ActivePermission {
101
129
  * unaffected; only the Allow control reads this.
102
130
  */
103
131
  approvalBlocked?: boolean
132
+ /**
133
+ * The prompt came from a website the wallet could not verify (spec 6.5). `originator` then holds
134
+ * the plain hostname, with the `.<grantTag>.unverified.invalid` suffix already stripped.
135
+ */
136
+ unverified?: boolean
137
+ /** Text the website supplied about itself (a manifest). Shown quoted, after the wallet's own words. */
138
+ siteSays?: string
139
+ /** `connection` only: what the sheet tells the user connecting allows (spec 6.4). */
140
+ connection?: {
141
+ transportId: string
142
+ connectedBefore: boolean
143
+ /** i18n keys, in `SEEK_FLAG_KEYS` order. */
144
+ allows: string[]
145
+ asksFirst: string[]
146
+ /** i18n key of the payments line, absent when the payment flag is off and listed under `allows`. */
147
+ payments?: string
148
+ }
104
149
  }
105
150
 
106
151
  /** Always-visible copy for each color consent type, completing "<app> …". */
@@ -124,6 +169,63 @@ const NO_COLOR_DEPS: ColorPromptDeps = { t: key => key, assetInfo: () => undefin
124
169
  // Helpers
125
170
  // ---------------------------------------------------------------------------
126
171
 
172
+ /**
173
+ * The originator a prompt shows. An unverified site reaches the wallet as
174
+ * `<hostname>.<grantTag>.unverified.invalid`; the user sees the hostname and the badge, never the suffix.
175
+ */
176
+ function presentOriginator(raw: string): { originator: string; unverified: boolean } {
177
+ return isUnattestedOriginator(raw)
178
+ ? { originator: hostnameOfUnattested(raw), unverified: true }
179
+ : { originator: raw, unverified: false }
180
+ }
181
+
182
+ /**
183
+ * What a site said about itself, kept apart from the wallet's own wording for an unverified site.
184
+ * A verified site's text keeps the old inline treatment.
185
+ */
186
+ function siteWords(
187
+ unverified: boolean,
188
+ text: string | undefined,
189
+ own: string
190
+ ): { description: string; siteSays?: string } {
191
+ if (!unverified) return { description: text || own }
192
+ return { description: own, siteSays: text || undefined }
193
+ }
194
+
195
+ /** Builds the `connection` prompt from a pending consent request and the flags that apply to it. */
196
+ function deriveConnection(c: PendingConsent, flags: SeekFlags): ActivePermission {
197
+ const unverified = c.attestation === 'unattested'
198
+ const allows: string[] = []
199
+ const asksFirst: string[] = []
200
+ for (const key of SEEK_FLAG_KEYS) {
201
+ // Payments have their own line below; only a payment flag that is off needs listing.
202
+ if (key === 'seekSpendingPermissions' && flags[key]) continue
203
+ ;(flags[key] ? asksFirst : allows).push(SEEK_FLAG_DISCLOSURE[key][flags[key] ? 'on' : 'off'])
204
+ }
205
+ return {
206
+ kind: 'connection',
207
+ requestID: c.requestId,
208
+ originator: c.origin,
209
+ unverified,
210
+ title: 'Connect Website',
211
+ description: 'wants to connect to your wallet',
212
+ details: [],
213
+ // The manifest group previewed before the sheet (spec 6.12); Connect mints exactly this.
214
+ groupPermissions: c.groupPermissions ?? undefined,
215
+ connection: {
216
+ transportId: c.transportId,
217
+ connectedBefore: c.connectedBefore,
218
+ allows,
219
+ asksFirst,
220
+ payments: flags.seekSpendingPermissions
221
+ ? unverified
222
+ ? 'bridge_payments_unverified'
223
+ : 'bridge_payments_verified'
224
+ : undefined
225
+ }
226
+ }
227
+ }
228
+
127
229
  /**
128
230
  * Derive the human-friendly "what is being asked" description for each
129
231
  * permission type. Technical specifics go into the expandable Details section.
@@ -137,6 +239,9 @@ export function deriveActive(
137
239
  certificateRequests: any[]
138
240
  spendingRequests: any[]
139
241
  groupRequests?: any[]
242
+ /** Pending site-connection requests, with the flags that describe each one. */
243
+ connectionRequests?: PendingConsent[]
244
+ connectionFlags?: (attestation: PendingConsent['attestation']) => SeekFlags
140
245
  btmsRequests: any[]
141
246
  mandalaRequests: any[]
142
247
  protocolAccessModalOpen: boolean
@@ -181,26 +286,38 @@ export function deriveActive(
181
286
  ...formatSats(item.satoshis)
182
287
  })
183
288
  )
289
+ const who = presentOriginator(r.originator || 'Unknown app')
184
290
  return {
185
291
  kind: 'spending',
186
292
  requestID: r.requestID,
187
- originator: r.originator || 'Unknown app',
293
+ manager: r.manager,
294
+ originator: who.originator,
295
+ unverified: who.unverified,
188
296
  title: 'Spending Authorization',
189
- description: r.description || 'wants to spend from your wallet',
297
+ ...siteWords(who.unverified, r.description, 'wants to spend from your wallet'),
190
298
  amount: r.authorizationAmount,
191
299
  renewal: r.renewal,
192
300
  details: lineItemDetails
193
301
  }
194
302
  }
195
303
 
304
+ // A website asking to connect. Core-owned, so it is not one of the manager queues above.
305
+ if (ctx.connectionRequests && ctx.connectionRequests.length > 0 && ctx.connectionFlags) {
306
+ const c = ctx.connectionRequests[0]
307
+ return deriveConnection(c, ctx.connectionFlags(c.attestation))
308
+ }
309
+
196
310
  // A site's grouped request (its manifest's metanet.groupPermissions) is the
197
311
  // whole set it will use, asked once when it connects.
198
312
  if (ctx.groupRequests && ctx.groupRequests.length > 0) {
199
313
  const r = ctx.groupRequests[0]
314
+ const who = presentOriginator(r.originator)
200
315
  return {
201
316
  kind: 'group',
202
317
  requestID: r.requestID,
203
- originator: r.originator,
318
+ manager: r.manager,
319
+ originator: who.originator,
320
+ unverified: who.unverified,
204
321
  title: 'Permissions',
205
322
  description: 'wants these permissions',
206
323
  details: [],
@@ -218,12 +335,15 @@ export function deriveActive(
218
335
  if (certType) details.push({ label: 'Certificate type', value: certType })
219
336
  if (verifier) details.push({ label: 'Verifier', value: truncate(verifier, 20) })
220
337
 
338
+ const who = presentOriginator(r.originator || 'Unknown app')
221
339
  return {
222
340
  kind: 'certificate',
223
341
  requestID: r.requestID,
224
- originator: r.originator || 'Unknown app',
342
+ manager: r.manager,
343
+ originator: who.originator,
344
+ unverified: who.unverified,
225
345
  title: r.renewal ? 'Certificate Access Renewal' : 'Certificate Access',
226
- description: r.description || 'wants to access certificate information',
346
+ ...siteWords(who.unverified, r.description, 'wants to access certificate information'),
227
347
  renewal: r.renewal,
228
348
  fields: fieldsArray.length > 0 ? fieldsArray : undefined,
229
349
  details
@@ -240,12 +360,18 @@ export function deriveActive(
240
360
  if (prompt.counterpartyLabel) details.push({ label: 'Shared with', value: prompt.counterpartyLabel })
241
361
  if (prompt.keyIDLabel) details.push({ label: 'Key ID', value: truncate(prompt.keyIDLabel, 40) })
242
362
  if (prompt.askEveryTime) details.push({ label: 'Approval', value: 'This signature only' })
363
+ const who = presentOriginator(r.originator || 'Unknown app')
243
364
  return {
244
365
  kind: 'protocol',
245
366
  requestID: r.requestID,
246
- originator: r.originator || 'Unknown app',
367
+ manager: r.manager,
368
+ originator: who.originator,
369
+ unverified: who.unverified,
247
370
  title: r.renewal ? `${prompt.title} Renewal` : prompt.title,
248
- description: prompt.description ?? (r.description || 'wants to use a cryptographic protocol'),
371
+ // The wallet's own wording for a known protocol; otherwise whatever the site said.
372
+ ...(prompt.description !== undefined
373
+ ? { description: prompt.description, siteSays: who.unverified ? r.description || undefined : undefined }
374
+ : siteWords(who.unverified, r.description, 'wants to use a cryptographic protocol')),
249
375
  renewal: r.renewal,
250
376
  details
251
377
  }
@@ -253,12 +379,15 @@ export function deriveActive(
253
379
 
254
380
  if (ctx.basketAccessModalOpen && ctx.basketRequests.length > 0) {
255
381
  const r = ctx.basketRequests[0]
382
+ const who = presentOriginator(r.originator || 'Unknown app')
256
383
  return {
257
384
  kind: 'basket',
258
385
  requestID: r.requestID,
259
- originator: r.originator || 'Unknown app',
386
+ manager: r.manager,
387
+ originator: who.originator,
388
+ unverified: who.unverified,
260
389
  title: r.renewal ? 'Basket Access Renewal' : 'Basket Access',
261
- description: r.reason || 'wants to access a transaction basket',
390
+ ...siteWords(who.unverified, r.reason, 'wants to access a transaction basket'),
262
391
  renewal: r.renewal,
263
392
  details: r.basket ? [{ label: 'Basket', value: r.basket }] : []
264
393
  }
@@ -306,7 +435,7 @@ export function deriveActive(
306
435
  kind: 'btms',
307
436
  // btms requests are resolved via advanceBtmsQueue, not permissionsManager — use a sentinel requestID
308
437
  requestID: '',
309
- originator: r.originator || 'Unknown app',
438
+ ...presentOriginator(r.originator || 'Unknown app'),
310
439
  title: 'Token Spend Request',
311
440
  description,
312
441
  details
@@ -323,7 +452,7 @@ export function deriveActive(
323
452
  return {
324
453
  kind: 'mandala',
325
454
  requestID: '',
326
- originator: r.originator || 'Unknown app',
455
+ ...presentOriginator(r.originator || 'Unknown app'),
327
456
  title: 'Token Request',
328
457
  description: 'wants to use your tokens, but this request could not be read — deny it.',
329
458
  details: [],
@@ -336,7 +465,7 @@ export function deriveActive(
336
465
  kind: 'mandala',
337
466
  // mandala requests are resolved via advanceMandalaQueue, not permissionsManager — use a sentinel requestID
338
467
  requestID: '',
339
- originator: r.originator || 'Unknown app',
468
+ ...presentOriginator(r.originator || 'Unknown app'),
340
469
  title: view.title,
341
470
  description,
342
471
  details: view.lines,
@@ -347,18 +476,134 @@ export function deriveActive(
347
476
  return null
348
477
  }
349
478
 
479
+ /** The browser named on a verified connection. Only Safari attests today; anything else is generic. */
480
+ function browserName(transportId: string, t: (key: string) => string): string {
481
+ return /^safari/i.test(transportId) ? 'Safari' : t('bridge_browser_generic')
482
+ }
483
+
350
484
  function truncate(str: string, max: number): string {
351
485
  if (!str) return ''
352
486
  return str.length > max ? str.slice(0, max - 1) + '\u2026' : str
353
487
  }
354
488
 
355
- /** Map permission kind to the themed accent color key. */
489
+ /**
490
+ * The permissions a site asks for as read-only sections (spending with its amount, protocols, baskets,
491
+ * certificates). No checkbox and no switch: the set is granted or refused as a whole. Shared by the
492
+ * group sheet and the merged Connect sheet (spec 6.12).
493
+ */
494
+ function GroupPermissionSections({ group, unverified }: { group: GroupPermissions; unverified?: boolean }) {
495
+ const { t } = useTranslation()
496
+ const { colors } = useTheme()
497
+ // A manifest's own words for an unverified site are shown as the site's quote (spec 6.5).
498
+ const quoted = (text: string) => (unverified ? `\u201C${text}\u201D` : text)
499
+ return (
500
+ <>
501
+ {group.spendingAuthorization && (
502
+ <View style={[styles.groupSection, { borderColor: colors.separator }]}>
503
+ <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>{t('spending_section')}</Text>
504
+ <View style={styles.groupRow}>
505
+ <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>
506
+ <AmountDisplay>{group.spendingAuthorization.amount}</AmountDisplay>
507
+ </Text>
508
+ {group.spendingAuthorization.description && (
509
+ <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>
510
+ {quoted(group.spendingAuthorization.description)}
511
+ </Text>
512
+ )}
513
+ </View>
514
+ </View>
515
+ )}
516
+ {group.protocolPermissions && group.protocolPermissions.length > 0 && (
517
+ <View style={[styles.groupSection, { borderColor: colors.separator }]}>
518
+ <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>{t('protocols_section')}</Text>
519
+ {group.protocolPermissions.map((p, i) => (
520
+ <View key={i} style={styles.groupRow}>
521
+ <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>
522
+ {describeProtocolPrompt(p.protocolID[1], p.counterparty).protocolLabel}
523
+ </Text>
524
+ {p.description && (
525
+ <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>{quoted(p.description)}</Text>
526
+ )}
527
+ </View>
528
+ ))}
529
+ </View>
530
+ )}
531
+ {group.basketAccess && group.basketAccess.length > 0 && (
532
+ <View style={[styles.groupSection, { borderColor: colors.separator }]}>
533
+ <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>{t('baskets_section')}</Text>
534
+ {group.basketAccess.map((b, i) => (
535
+ <View key={i} style={styles.groupRow}>
536
+ <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>{b.basket}</Text>
537
+ {b.description && (
538
+ <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>{quoted(b.description)}</Text>
539
+ )}
540
+ </View>
541
+ ))}
542
+ </View>
543
+ )}
544
+ {group.certificateAccess && group.certificateAccess.length > 0 && (
545
+ <View style={[styles.groupSection, { borderColor: colors.separator }]}>
546
+ <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>{t('certificates_section')}</Text>
547
+ {group.certificateAccess.map((c, i) => (
548
+ <View key={i} style={styles.groupRow}>
549
+ <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>{c.type}</Text>
550
+ {c.description && (
551
+ <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>{quoted(c.description)}</Text>
552
+ )}
553
+ {c.fields && c.fields.length > 0 && (
554
+ <Text style={[styles.groupRowDesc, { color: colors.textTertiary }]}>Fields: {c.fields.join(', ')}</Text>
555
+ )}
556
+ </View>
557
+ ))}
558
+ </View>
559
+ )}
560
+ </>
561
+ )
562
+ }
356
563
 
357
564
  // ---------------------------------------------------------------------------
358
565
  // Component
359
566
  // ---------------------------------------------------------------------------
360
567
 
361
- const PermissionSheet: React.FC = () => {
568
+ /**
569
+ * True while any permission sheet is open or queued (every manager queue, the BTMS and mandala queues and
570
+ * the website connection requests). The Safari bridge's done screen stays hidden while this is true, and a
571
+ * later sheet replaces it (spec 6.12).
572
+ */
573
+ export function usePermissionSheetBusy(): boolean {
574
+ const {
575
+ protocolRequests,
576
+ basketRequests,
577
+ certificateRequests,
578
+ spendingRequests,
579
+ groupRequests,
580
+ btmsRequests,
581
+ mandalaRequests
582
+ } = useContext(WalletContext)
583
+ const connections = useSyncExternalStore(subscribeConsentRequests, getPendingConnections, getPendingConnections)
584
+ return (
585
+ (protocolRequests?.length ?? 0) +
586
+ (basketRequests?.length ?? 0) +
587
+ (certificateRequests?.length ?? 0) +
588
+ (spendingRequests?.length ?? 0) +
589
+ (groupRequests?.length ?? 0) +
590
+ (btmsRequests?.length ?? 0) +
591
+ (mandalaRequests?.length ?? 0) +
592
+ connections.length >
593
+ 0
594
+ )
595
+ }
596
+
597
+ interface PermissionSheetProps {
598
+ /**
599
+ * Whether a backdrop tap or a swipe down answers the prompt as a rejection. Default true. The Android bridge's overlay
600
+ * root passes false: there an outside tap does nothing and only the Reject button rejects. Per instance, so a main-tree
601
+ * sheet mounted at the same time is unaffected.
602
+ */
603
+ backdropDismisses?: boolean
604
+ }
605
+
606
+ const PermissionSheet: React.FC<PermissionSheetProps> = ({ backdropDismisses = true }) => {
362
607
  const { t } = useTranslation()
363
608
  const { colors } = useTheme()
364
609
  const Ionicons = loadIonicons()
@@ -378,7 +623,6 @@ const PermissionSheet: React.FC = () => {
378
623
  advanceGroupQueue,
379
624
  advanceBtmsQueue,
380
625
  advanceMandalaQueue,
381
- managers,
382
626
  settings,
383
627
  mandala
384
628
  } = useContext(WalletContext)
@@ -423,16 +667,14 @@ const PermissionSheet: React.FC = () => {
423
667
  [t, colorAssets]
424
668
  )
425
669
 
426
- const {
427
- protocolAccessModalOpen,
428
- setProtocolAccessModalOpen,
429
- basketAccessModalOpen,
430
- setBasketAccessModalOpen,
431
- certificateAccessModalOpen,
432
- setCertificateAccessModalOpen,
433
- spendingAuthorizationModalOpen,
434
- setSpendingAuthorizationModalOpen
435
- } = useContext(UserContext)
670
+ const { protocolAccessModalOpen, basketAccessModalOpen, certificateAccessModalOpen, spendingAuthorizationModalOpen } =
671
+ useContext(UserContext)
672
+
673
+ const connectionRequests = useSyncExternalStore(
674
+ subscribeConsentRequests,
675
+ getPendingConnections,
676
+ getPendingConnections
677
+ )
436
678
 
437
679
  const [detailsExpanded, setDetailsExpanded] = useState(false)
438
680
  const [granted, setGranted] = useState(false)
@@ -441,6 +683,26 @@ const PermissionSheet: React.FC = () => {
441
683
  // can be flushed synchronously if a higher-priority request preempts.
442
684
  const pendingGrantRef = useRef<(() => void) | null>(null)
443
685
 
686
+ // Whether the request a pending answer was meant for is still in its queue.
687
+ // A withdrawal (profile switch, logout) empties the queues, and the new
688
+ // wallet's manager can then raise a request with the very same ID, so a
689
+ // request is the same one only if it also came from the same manager.
690
+ const queuesRef = useRef({ protocolRequests, basketRequests, certificateRequests, spendingRequests, groupRequests })
691
+ queuesRef.current = { protocolRequests, basketRequests, certificateRequests, spendingRequests, groupRequests }
692
+ const stillQueued = useCallback((request: ActivePermission): boolean => {
693
+ // Connection requests live in the consent store; ids there are never reused.
694
+ if (request.kind === 'connection') return getPendingConnections().some(c => c.requestId === request.requestID)
695
+ const q = queuesRef.current
696
+ const list: any[] | undefined = {
697
+ protocol: q.protocolRequests,
698
+ basket: q.basketRequests,
699
+ certificate: q.certificateRequests,
700
+ spending: q.spendingRequests,
701
+ group: q.groupRequests
702
+ }[request.kind as 'protocol' | 'basket' | 'certificate' | 'spending' | 'group']
703
+ return !!list?.some(r => r.requestID === request.requestID && r.manager === request.manager)
704
+ }, [])
705
+
444
706
  // Clear the pending grant timer (or flush it) on unmount to prevent stale handler calls.
445
707
  useEffect(() => {
446
708
  return () => {
@@ -455,6 +717,21 @@ const PermissionSheet: React.FC = () => {
455
717
  }
456
718
  }, [])
457
719
 
720
+ // React Native pauses JS timers while the app is backgrounded, so a grant waiting out its 400 ms would
721
+ // leave the page's call hanging if the user leaves right after tapping. Answer at once instead.
722
+ useEffect(() => {
723
+ const sub = AppState.addEventListener('change', state => {
724
+ if (state === 'active' || pendingGrantRef.current === null) return
725
+ if (grantTimerRef.current !== null) {
726
+ clearTimeout(grantTimerRef.current)
727
+ grantTimerRef.current = null
728
+ }
729
+ pendingGrantRef.current()
730
+ pendingGrantRef.current = null
731
+ })
732
+ return () => sub.remove()
733
+ }, [])
734
+
458
735
  // Derive what (if anything) we should show.
459
736
  const active = useMemo(
460
737
  () =>
@@ -465,6 +742,8 @@ const PermissionSheet: React.FC = () => {
465
742
  certificateRequests,
466
743
  spendingRequests,
467
744
  groupRequests,
745
+ connectionRequests,
746
+ connectionFlags,
468
747
  btmsRequests,
469
748
  mandalaRequests,
470
749
  protocolAccessModalOpen,
@@ -481,6 +760,7 @@ const PermissionSheet: React.FC = () => {
481
760
  certificateRequests,
482
761
  spendingRequests,
483
762
  groupRequests,
763
+ connectionRequests,
484
764
  btmsRequests,
485
765
  mandalaRequests,
486
766
  protocolAccessModalOpen,
@@ -521,12 +801,35 @@ const PermissionSheet: React.FC = () => {
521
801
  setGranted(false)
522
802
  }, [activeRequestID])
523
803
 
804
+ // Tap protection (spec 6.4): a connection or unverified prompt cannot be approved for the first
805
+ // 700 ms it is at the head of the queue, so a tap aimed at the previous sheet cannot land on it.
806
+ // Keyed on the head's identity, so a request queueing behind it does not restart the window.
807
+ const needsTapDelay = active !== null && (active.kind === 'connection' || active.unverified === true)
808
+ // The manager is part of the identity: a replacement manager restarts its request counters, so a
809
+ // re-raised prompt can repeat the kind, id, originator and description of the one before it.
810
+ const headKey = active
811
+ ? `${active.kind}|${managerToken(active.manager)}|${active.requestID}|${active.originator}|${active.description}`
812
+ : ''
813
+ const [armedKey, setArmedKey] = useState('')
814
+ useEffect(() => {
815
+ // A new head, or none, is never armed from an earlier head's window.
816
+ setArmedKey('')
817
+ if (!needsTapDelay) return
818
+ const timer = setTimeout(() => setArmedKey(headKey), TAP_PROTECTION_MS)
819
+ return () => clearTimeout(timer)
820
+ }, [needsTapDelay, headKey])
821
+ const tapLocked = needsTapDelay && armedKey !== headKey
822
+
524
823
  // ---- Deny ----
525
824
  const handleDeny = useCallback(async () => {
526
825
  if (granted) return
527
826
  if (!active) return
528
827
  haptics.warning()
529
- if (active.kind === 'btms') {
828
+ if (active.kind === 'connection') {
829
+ await answerConnection(active.requestID, false).catch((e: unknown) =>
830
+ console.warn('[bridge] connection decline failed', e)
831
+ )
832
+ } else if (active.kind === 'btms') {
530
833
  // BTMS uses its own promise-based resolution — no permissionsManager.denyPermission
531
834
  advanceBtmsQueue(false)
532
835
  } else if (active.kind === 'mandala') {
@@ -537,52 +840,48 @@ const PermissionSheet: React.FC = () => {
537
840
  // then asked for on its own when used. A hard deny would make the
538
841
  // site's waitForAuthentication throw.
539
842
  try {
540
- await managers.permissionsManager?.dismissGroupedPermission(active.requestID)
843
+ await active.manager?.dismissGroupedPermission(active.requestID)
541
844
  } catch {
542
845
  // Already settled (e.g. the site went away) -- nothing left to answer.
543
846
  }
544
- advanceGroupQueue()
847
+ if (stillQueued(active)) advanceGroupQueue(active.requestID)
545
848
  } else {
546
849
  try {
547
- await managers.permissionsManager?.denyPermission(active.requestID)
850
+ await active.manager?.denyPermission(active.requestID)
548
851
  } catch {
549
852
  // User denial is expected -- not an error condition
550
853
  }
551
- switch (active.kind) {
552
- case 'protocol':
553
- advanceProtocolQueue()
554
- setProtocolAccessModalOpen(false)
555
- break
556
- case 'basket':
557
- advanceBasketQueue()
558
- setBasketAccessModalOpen(false)
559
- break
560
- case 'certificate':
561
- advanceCertificateQueue()
562
- setCertificateAccessModalOpen(false)
563
- break
564
- case 'spending':
565
- advanceSpendingQueue()
566
- setSpendingAuthorizationModalOpen(false)
567
- break
854
+ // The answer went to the manager that raised the request; the queue
855
+ // loses it only if it is still the same one (see stillQueued).
856
+ if (stillQueued(active)) {
857
+ switch (active.kind) {
858
+ case 'protocol':
859
+ advanceProtocolQueue(active.requestID)
860
+ break
861
+ case 'basket':
862
+ advanceBasketQueue(active.requestID)
863
+ break
864
+ case 'certificate':
865
+ advanceCertificateQueue(active.requestID)
866
+ break
867
+ case 'spending':
868
+ advanceSpendingQueue(active.requestID)
869
+ break
870
+ }
568
871
  }
569
872
  }
570
873
  setDetailsExpanded(false)
571
874
  }, [
572
875
  granted,
573
876
  active,
574
- managers.permissionsManager,
877
+ stillQueued,
575
878
  advanceProtocolQueue,
576
879
  advanceBasketQueue,
577
880
  advanceCertificateQueue,
578
881
  advanceSpendingQueue,
579
882
  advanceGroupQueue,
580
883
  advanceBtmsQueue,
581
- advanceMandalaQueue,
582
- setProtocolAccessModalOpen,
583
- setBasketAccessModalOpen,
584
- setCertificateAccessModalOpen,
585
- setSpendingAuthorizationModalOpen
884
+ advanceMandalaQueue
586
885
  ])
587
886
 
588
887
  // ---- Grant ----
@@ -595,46 +894,55 @@ const PermissionSheet: React.FC = () => {
595
894
  // Clear the pending ref so flush-on-preempt guards don't double-fire.
596
895
  pendingGrantRef.current = null
597
896
 
598
- if (request.kind === 'btms') {
897
+ if (request.kind === 'connection') {
898
+ // The store drops the answer if the request is gone or the wallet has changed.
899
+ answerConnection(request.requestID, true).catch((e: unknown) =>
900
+ console.warn('[bridge] connection approval failed', e)
901
+ )
902
+ } else if (request.kind === 'btms') {
599
903
  advanceBtmsQueue(true)
600
904
  } else if (request.kind === 'mandala') {
601
905
  advanceMandalaQueue(true)
906
+ } else if (!stillQueued(request)) {
907
+ // Withdrawn while the checkmark showed (a profile switch or logout
908
+ // emptied the queue): the manager that raised it is gone and what is
909
+ // queued now is not this request. Answer nothing, drop nothing.
602
910
  } else if (request.kind === 'group') {
603
911
  // Grants exactly the set shown. The manager mints the permission
604
912
  // tokens, then resolves the site's waitForAuthentication; if minting
605
913
  // fails it rejects that call itself.
606
- managers.permissionsManager
914
+ request.manager
607
915
  ?.grantGroupedPermission({
608
916
  requestID: request.requestID,
609
917
  // The manager's own request object, passed back unchanged.
610
918
  granted: (request.groupPermissions ?? {}) as GrantedGroupPermissions
611
919
  })
612
920
  .catch((error: unknown) => console.warn('[permissions] grouped grant failed', error))
613
- advanceGroupQueue()
921
+ advanceGroupQueue(request.requestID)
614
922
  } else if (request.kind === 'spending') {
615
- managers.permissionsManager?.grantPermission({
616
- requestID: request.requestID,
617
- ephemeral: true,
618
- amount: request.amount
619
- })
620
- advanceSpendingQueue()
621
- setSpendingAuthorizationModalOpen(false)
923
+ request.manager
924
+ ?.grantPermission({
925
+ requestID: request.requestID,
926
+ ephemeral: true,
927
+ amount: request.amount
928
+ })
929
+ .catch((error: unknown) => console.warn('[permissions] grant failed', error))
930
+ advanceSpendingQueue(request.requestID)
622
931
  } else {
623
- managers.permissionsManager?.grantPermission({
624
- requestID: request.requestID
625
- })
932
+ request.manager
933
+ ?.grantPermission({
934
+ requestID: request.requestID
935
+ })
936
+ .catch((error: unknown) => console.warn('[permissions] grant failed', error))
626
937
  switch (request.kind) {
627
938
  case 'protocol':
628
- advanceProtocolQueue()
629
- setProtocolAccessModalOpen(false)
939
+ advanceProtocolQueue(request.requestID)
630
940
  break
631
941
  case 'basket':
632
- advanceBasketQueue()
633
- setBasketAccessModalOpen(false)
942
+ advanceBasketQueue(request.requestID)
634
943
  break
635
944
  case 'certificate':
636
- advanceCertificateQueue()
637
- setCertificateAccessModalOpen(false)
945
+ advanceCertificateQueue(request.requestID)
638
946
  break
639
947
  }
640
948
  }
@@ -644,18 +952,14 @@ const PermissionSheet: React.FC = () => {
644
952
  setGranted(false)
645
953
  },
646
954
  [
647
- managers.permissionsManager,
955
+ stillQueued,
648
956
  advanceProtocolQueue,
649
957
  advanceBasketQueue,
650
958
  advanceCertificateQueue,
651
959
  advanceSpendingQueue,
652
960
  advanceGroupQueue,
653
961
  advanceBtmsQueue,
654
- advanceMandalaQueue,
655
- setProtocolAccessModalOpen,
656
- setBasketAccessModalOpen,
657
- setCertificateAccessModalOpen,
658
- setSpendingAuthorizationModalOpen
962
+ advanceMandalaQueue
659
963
  ]
660
964
  )
661
965
 
@@ -663,7 +967,7 @@ const PermissionSheet: React.FC = () => {
663
967
  // XR-040: belt-and-braces alongside the Allow button's own `disabled` —
664
968
  // a token consent message this sheet could not read in full must never
665
969
  // be approvable, from any call path.
666
- if (!active || granted || active.approvalBlocked) return
970
+ if (!active || granted || active.approvalBlocked || tapLocked) return
667
971
  haptics.success()
668
972
  setGranted(true)
669
973
  if (grantTimerRef.current !== null) {
@@ -677,10 +981,10 @@ const PermissionSheet: React.FC = () => {
677
981
  grantTimerRef.current = null
678
982
  pendingFn()
679
983
  }, 400)
680
- }, [active, granted, executeGrant])
984
+ }, [active, granted, tapLocked, executeGrant])
681
985
 
682
986
  return (
683
- <Sheet visible={visible} onClose={handleDeny} heightPercent={0.92} fitContent>
987
+ <Sheet visible={visible} onClose={handleDeny} dismissible={backdropDismisses} heightPercent={0.92} fitContent>
684
988
  {active && (
685
989
  <View>
686
990
  <View style={styles.content}>
@@ -696,10 +1000,37 @@ const PermissionSheet: React.FC = () => {
696
1000
  {(active.originator[0] ?? '?').toUpperCase()}
697
1001
  </Text>
698
1002
  </View>
699
- <Text style={[styles.originator, { color: colors.textPrimary }]} numberOfLines={1}>
700
- {active.originator}
701
- </Text>
1003
+ <View style={styles.originatorText}>
1004
+ <Text
1005
+ style={[
1006
+ styles.originator,
1007
+ active.unverified || active.kind === 'connection' ? styles.originatorMono : null,
1008
+ { color: colors.textPrimary }
1009
+ ]}
1010
+ numberOfLines={1}
1011
+ testID="bridge-connect-origin"
1012
+ >
1013
+ {active.originator}
1014
+ </Text>
1015
+ {active.kind === 'connection' && active.connection && !active.unverified && (
1016
+ <Text style={[styles.originatorSub, { color: colors.textSecondary }]} numberOfLines={1}>
1017
+ {t('bridge_verified_by', { browser: browserName(active.connection.transportId, t) })}
1018
+ </Text>
1019
+ )}
1020
+ </View>
1021
+ {active.unverified && (
1022
+ <View style={[styles.unverifiedBadge, { backgroundColor: colors.warning + '26' }]}>
1023
+ <Text style={[styles.unverifiedBadgeText, { color: colors.warning }]}>
1024
+ {t('bridge_badge_unverified')}
1025
+ </Text>
1026
+ </View>
1027
+ )}
702
1028
  </View>
1029
+ {active.unverified && (
1030
+ <Text style={[styles.channelNote, { color: colors.textSecondary }]}>
1031
+ {t('bridge_unverified_channel')}
1032
+ </Text>
1033
+ )}
703
1034
 
704
1035
  {/* -------- Renewal badge -------- */}
705
1036
  {active.renewal && (
@@ -708,82 +1039,53 @@ const PermissionSheet: React.FC = () => {
708
1039
  </View>
709
1040
  )}
710
1041
 
711
- {/* -------- Group permissions list -------- */}
712
- {active.kind === 'group' && active.groupPermissions && (
1042
+ {/* -------- Site connection: what connecting allows, in the wallet's words -------- */}
1043
+ {active.kind === 'connection' && active.connection && (
713
1044
  <ScrollView style={styles.groupScroll} bounces={false}>
714
- {active.groupPermissions.spendingAuthorization && (
715
- <View style={[styles.groupSection, { borderColor: colors.separator }]}>
716
- <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>
717
- {t('spending_section')}
1045
+ <Text style={[styles.connectHeader, { color: colors.textSecondary }]}>{t('bridge_allows_header')}</Text>
1046
+ {['bridge_allows_sign_in', ...active.connection.allows].map(key => (
1047
+ <Text key={key} style={[styles.connectItem, { color: colors.textPrimary }]}>
1048
+ {'\u2022'} {t(key)}
1049
+ </Text>
1050
+ ))}
1051
+ {active.connection.asksFirst.length > 0 && (
1052
+ <>
1053
+ <Text style={[styles.connectHeader, { color: colors.textSecondary }]}>
1054
+ {t('bridge_asks_header')}
718
1055
  </Text>
719
- <View style={styles.groupRow}>
720
- <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>
721
- <AmountDisplay>{active.groupPermissions.spendingAuthorization.amount}</AmountDisplay>
1056
+ {active.connection.asksFirst.map(key => (
1057
+ <Text key={key} style={[styles.connectItem, { color: colors.textPrimary }]}>
1058
+ {'\u2022'} {t(key)}
722
1059
  </Text>
723
- {active.groupPermissions.spendingAuthorization.description && (
724
- <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>
725
- {active.groupPermissions.spendingAuthorization.description}
726
- </Text>
727
- )}
728
- </View>
729
- </View>
730
- )}
731
- {active.groupPermissions.protocolPermissions &&
732
- active.groupPermissions.protocolPermissions.length > 0 && (
733
- <View style={[styles.groupSection, { borderColor: colors.separator }]}>
734
- <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>
735
- {t('protocols_section')}
736
- </Text>
737
- {active.groupPermissions.protocolPermissions.map((p, i) => (
738
- <View key={i} style={styles.groupRow}>
739
- <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>
740
- {describeProtocolPrompt(p.protocolID[1], p.counterparty).protocolLabel}
741
- </Text>
742
- {p.description && (
743
- <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>{p.description}</Text>
744
- )}
745
- </View>
746
- ))}
747
- </View>
748
- )}
749
- {active.groupPermissions.basketAccess && active.groupPermissions.basketAccess.length > 0 && (
750
- <View style={[styles.groupSection, { borderColor: colors.separator }]}>
751
- <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>
752
- {t('baskets_section')}
753
- </Text>
754
- {active.groupPermissions.basketAccess.map((b, i) => (
755
- <View key={i} style={styles.groupRow}>
756
- <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>{b.basket}</Text>
757
- {b.description && (
758
- <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>{b.description}</Text>
759
- )}
760
- </View>
761
1060
  ))}
762
- </View>
1061
+ </>
763
1062
  )}
764
- {active.groupPermissions.certificateAccess && active.groupPermissions.certificateAccess.length > 0 && (
765
- <View style={[styles.groupSection, { borderColor: colors.separator }]}>
766
- <Text style={[styles.groupSectionTitle, { color: colors.textSecondary }]}>
767
- {t('certificates_section')}
768
- </Text>
769
- {active.groupPermissions.certificateAccess.map((c, i) => (
770
- <View key={i} style={styles.groupRow}>
771
- <Text style={[styles.groupRowLabel, { color: colors.textPrimary }]}>{c.type}</Text>
772
- {c.description && (
773
- <Text style={[styles.groupRowDesc, { color: colors.textSecondary }]}>{c.description}</Text>
774
- )}
775
- {c.fields && c.fields.length > 0 && (
776
- <Text style={[styles.groupRowDesc, { color: colors.textTertiary }]}>
777
- Fields: {c.fields.join(', ')}
778
- </Text>
779
- )}
780
- </View>
781
- ))}
782
- </View>
1063
+ {active.connection.payments && (
1064
+ <Text style={[styles.connectNote, { color: colors.textPrimary }]}>
1065
+ {t(active.connection.payments)}
1066
+ </Text>
1067
+ )}
1068
+ <Text style={[styles.connectNote, { color: colors.textSecondary }]}>
1069
+ {t(active.unverified ? 'bridge_remember_unverified' : 'bridge_remember_verified')}
1070
+ </Text>
1071
+ {active.unverified && active.connection.connectedBefore && (
1072
+ <Text style={[styles.connectNote, { color: colors.textPrimary }]}>
1073
+ {t('bridge_connected_before')}
1074
+ </Text>
1075
+ )}
1076
+ {active.groupPermissions && (
1077
+ <GroupPermissionSections group={active.groupPermissions} unverified={active.unverified} />
783
1078
  )}
784
1079
  </ScrollView>
785
1080
  )}
786
1081
 
1082
+ {/* -------- Group permissions list -------- */}
1083
+ {active.kind === 'group' && active.groupPermissions && (
1084
+ <ScrollView style={styles.groupScroll} bounces={false}>
1085
+ <GroupPermissionSections group={active.groupPermissions} unverified={active.unverified} />
1086
+ </ScrollView>
1087
+ )}
1088
+
787
1089
  {/* -------- Expandable details (scrollable if tall) -------- */}
788
1090
  {active.kind !== 'group' && (active.details.length > 0 || (active.fields && active.fields.length > 0)) && (
789
1091
  <View style={styles.detailsSection}>
@@ -854,6 +1156,17 @@ const PermissionSheet: React.FC = () => {
854
1156
  <View style={styles.askBlock}>
855
1157
  <Text style={[styles.description, { color: colors.textSecondary }]}>{active.description}</Text>
856
1158
 
1159
+ {active.siteSays ? (
1160
+ <View style={[styles.siteSays, { borderColor: colors.separator }]}>
1161
+ <Text style={[styles.siteSaysLabel, { color: colors.textTertiary }]}>{t('bridge_site_says')}</Text>
1162
+ <Text style={[styles.siteSaysText, { color: colors.textSecondary }]}>
1163
+ {'\u201C'}
1164
+ {active.siteSays}
1165
+ {'\u201D'}
1166
+ </Text>
1167
+ </View>
1168
+ ) : null}
1169
+
857
1170
  {active.kind === 'spending' && active.amount != null && (
858
1171
  <Text style={[styles.amountValue, { color: colors.textPrimary }]}>
859
1172
  {amountParts.value}
@@ -874,8 +1187,11 @@ const PermissionSheet: React.FC = () => {
874
1187
  ]}
875
1188
  onPress={handleDeny}
876
1189
  disabled={granted}
1190
+ testID="bridge-deny"
877
1191
  >
878
- <Text style={[styles.buttonDenyText, { color: colors.textPrimary }]}>{t('reject')}</Text>
1192
+ <Text style={[styles.buttonDenyText, { color: colors.textPrimary }]}>
1193
+ {t(active.kind === 'connection' ? 'bridge_dont_connect' : 'reject')}
1194
+ </Text>
879
1195
  </PressableScale>
880
1196
 
881
1197
  {/* Accent-filled and the only shadowed element in the drawer, so the
@@ -884,12 +1200,15 @@ const PermissionSheet: React.FC = () => {
884
1200
  <PressableScale
885
1201
  style={[styles.buttonAllow, { backgroundColor: colors.accent }]}
886
1202
  onPress={handleGrant}
887
- disabled={granted || active.approvalBlocked}
1203
+ disabled={granted || active.approvalBlocked || tapLocked}
1204
+ testID="bridge-approve"
888
1205
  >
889
1206
  {granted ? (
890
1207
  <Ionicons name="checkmark" size={22} color={colors.textOnAccent} />
891
1208
  ) : (
892
- <Text style={[styles.buttonAllowText, { color: colors.textOnAccent }]}>{t('authorize')}</Text>
1209
+ <Text style={[styles.buttonAllowText, { color: colors.textOnAccent }]}>
1210
+ {t(active.kind === 'connection' ? 'bridge_connect' : 'authorize')}
1211
+ </Text>
893
1212
  )}
894
1213
  </PressableScale>
895
1214
  </View>
@@ -929,11 +1248,68 @@ const styles = StyleSheet.create({
929
1248
  fontSize: 17,
930
1249
  fontWeight: '700'
931
1250
  },
1251
+ originatorText: {
1252
+ flex: 1
1253
+ },
932
1254
  originator: {
933
1255
  fontSize: 15,
934
1256
  fontWeight: '600',
935
- letterSpacing: -0.1,
936
- flex: 1
1257
+ letterSpacing: -0.1
1258
+ },
1259
+ // The raw origin is the identity being asked about, so it is set in a face where lookalike
1260
+ // characters stay distinct.
1261
+ originatorMono: {
1262
+ fontFamily: Platform.select({ ios: 'Menlo', default: 'monospace' }),
1263
+ fontSize: 14,
1264
+ letterSpacing: 0
1265
+ },
1266
+ originatorSub: {
1267
+ ...typography.caption1,
1268
+ marginTop: 1
1269
+ },
1270
+ unverifiedBadge: {
1271
+ paddingHorizontal: spacing.sm,
1272
+ paddingVertical: spacing.xs,
1273
+ borderRadius: radii.sm,
1274
+ marginLeft: spacing.sm
1275
+ },
1276
+ unverifiedBadgeText: {
1277
+ ...typography.caption1,
1278
+ fontWeight: '700'
1279
+ },
1280
+ channelNote: {
1281
+ ...typography.footnote,
1282
+ marginBottom: spacing.md
1283
+ },
1284
+ connectHeader: {
1285
+ ...typography.caption1,
1286
+ fontWeight: '600',
1287
+ marginTop: spacing.sm,
1288
+ marginBottom: spacing.xs
1289
+ },
1290
+ connectItem: {
1291
+ ...typography.footnote,
1292
+ marginLeft: spacing.sm,
1293
+ marginTop: 2
1294
+ },
1295
+ connectNote: {
1296
+ ...typography.footnote,
1297
+ marginTop: spacing.md
1298
+ },
1299
+ siteSays: {
1300
+ borderLeftWidth: 2,
1301
+ paddingLeft: spacing.md,
1302
+ marginTop: spacing.lg,
1303
+ alignSelf: 'stretch'
1304
+ },
1305
+ siteSaysLabel: {
1306
+ ...typography.caption1,
1307
+ fontWeight: '600',
1308
+ marginBottom: 2
1309
+ },
1310
+ siteSaysText: {
1311
+ ...typography.footnote,
1312
+ fontStyle: 'italic'
937
1313
  },
938
1314
 
939
1315
  // Renewal badge