@sparkvault/sdk-mobile 10.3.0 → 10.5.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.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Design-system values for the identity dialog.
3
+ *
4
+ * The dialog is a SparkVault surface, so it paints with the design system's
5
+ * palette (packages/design-system/tokens): Action Blue for interaction on
6
+ * slate neutrals. React Native cannot read those CSS files and the published
7
+ * package cannot import them, so the values the dialog uses are mirrored
8
+ * here. tests/ds-tokens.test.ts holds each DS value to the token it names in
9
+ * the token CSS, and refuses a hex color anywhere else in the SDK's source and
10
+ * an rgba() whose color is not the design system's. DARK_TEXT is the app's,
11
+ * not the design system's, and is held to the app's palette instead.
12
+ */
13
+ /** The design-system token each mirrored value is. */
14
+ export declare const DS_TOKEN_SOURCES: Readonly<{
15
+ readonly white: "--color-white";
16
+ readonly slate50: "--color-slate-50";
17
+ readonly slate200: "--color-slate-200";
18
+ readonly slate400: "--color-slate-400";
19
+ readonly slate500: "--color-slate-500";
20
+ readonly slate700: "--color-slate-700";
21
+ readonly slate800: "--color-slate-800";
22
+ readonly slate900: "--color-slate-900";
23
+ readonly action: "--color-action";
24
+ readonly actionBg: "--color-action-bg";
25
+ readonly btnPrimary: "--color-btn-primary";
26
+ readonly error: "--color-error";
27
+ readonly modalOverlay: "--color-modal-overlay";
28
+ }>;
29
+ export type DsToken = keyof typeof DS_TOKEN_SOURCES;
30
+ /** The design system's values for {@link DS_TOKEN_SOURCES}. */
31
+ export declare const DS: Readonly<Record<DsToken, string>>;
32
+ /**
33
+ * Text tiers on the dark card (slate-900) the design system does not define:
34
+ * its Action Blue and its error hues as text fall under AA there (error-500
35
+ * measures 4.47:1). Each is its hue lifted in OKLCH lightness, the tiers
36
+ * SparkVault's mobile app paints its dark theme with
37
+ * (apps/mobile/src/theme/palettes.ts), so the dialog matches the app around
38
+ * it: Action Blue 7.45:1 and error 6.45:1 on the card. The app's dialog
39
+ * appearance test (apps/mobile/tests/identityDialog.appearance.test.tsx)
40
+ * reads its expected inks from that palette, so the two cannot drift.
41
+ */
42
+ export declare const DARK_TEXT: Readonly<{
43
+ action: "#7aa9f0";
44
+ error: "#f87171";
45
+ }>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Design-system values for the identity dialog.
3
+ *
4
+ * The dialog is a SparkVault surface, so it paints with the design system's
5
+ * palette (packages/design-system/tokens): Action Blue for interaction on
6
+ * slate neutrals. React Native cannot read those CSS files and the published
7
+ * package cannot import them, so the values the dialog uses are mirrored
8
+ * here. tests/ds-tokens.test.ts holds each DS value to the token it names in
9
+ * the token CSS, and refuses a hex color anywhere else in the SDK's source and
10
+ * an rgba() whose color is not the design system's. DARK_TEXT is the app's,
11
+ * not the design system's, and is held to the app's palette instead.
12
+ */
13
+ /** The design-system token each mirrored value is. */
14
+ export const DS_TOKEN_SOURCES = Object.freeze({
15
+ white: '--color-white',
16
+ slate50: '--color-slate-50',
17
+ slate200: '--color-slate-200',
18
+ slate400: '--color-slate-400',
19
+ slate500: '--color-slate-500',
20
+ slate700: '--color-slate-700',
21
+ slate800: '--color-slate-800',
22
+ slate900: '--color-slate-900',
23
+ action: '--color-action',
24
+ actionBg: '--color-action-bg',
25
+ btnPrimary: '--color-btn-primary',
26
+ error: '--color-error',
27
+ modalOverlay: '--color-modal-overlay',
28
+ });
29
+ /** The design system's values for {@link DS_TOKEN_SOURCES}. */
30
+ export const DS = Object.freeze({
31
+ white: '#ffffff',
32
+ slate50: '#f8fafc',
33
+ slate200: '#e2e8f0',
34
+ slate400: '#94a3b8',
35
+ slate500: '#64748b',
36
+ slate700: '#334155',
37
+ slate800: '#1e293b',
38
+ slate900: '#0f172a',
39
+ action: '#216bde',
40
+ actionBg: '#eef4fe',
41
+ btnPrimary: '#0a4eb1',
42
+ error: '#b02b27',
43
+ modalOverlay: 'rgba(15, 23, 42, 0.6)',
44
+ });
45
+ /**
46
+ * Text tiers on the dark card (slate-900) the design system does not define:
47
+ * its Action Blue and its error hues as text fall under AA there (error-500
48
+ * measures 4.47:1). Each is its hue lifted in OKLCH lightness, the tiers
49
+ * SparkVault's mobile app paints its dark theme with
50
+ * (apps/mobile/src/theme/palettes.ts), so the dialog matches the app around
51
+ * it: Action Blue 7.45:1 and error 6.45:1 on the card. The app's dialog
52
+ * appearance test (apps/mobile/tests/identityDialog.appearance.test.tsx)
53
+ * reads its expected inks from that palette, so the two cannot drift.
54
+ */
55
+ export const DARK_TEXT = Object.freeze({
56
+ action: '#7aa9f0',
57
+ error: '#f87171',
58
+ });
59
+ //# sourceMappingURL=ds-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ds-tokens.js","sourceRoot":"","sources":["../src/ds-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,kBAAkB;IAC3B,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,mBAAmB;IAC7B,MAAM,EAAE,gBAAgB;IACxB,QAAQ,EAAE,mBAAmB;IAC7B,UAAU,EAAE,qBAAqB;IACjC,KAAK,EAAE,eAAe;IACtB,YAAY,EAAE,uBAAuB;CAC7B,CAAC,CAAC;AAIZ,+DAA+D;AAC/D,MAAM,CAAC,MAAM,EAAE,GAAsC,MAAM,CAAC,MAAM,CAAC;IACjE,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,SAAS;IACnB,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,YAAY,EAAE,uBAAuB;CACtC,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;CACjB,CAAC,CAAC"}
@@ -8,6 +8,13 @@ export interface SparkVaultIdentityDialogProps {
8
8
  * also creates an account (a new identity goes on to signup) says so here.
9
9
  */
10
10
  title?: string;
11
+ /**
12
+ * The host's appearance. The dialog draws in it, as does its keyboard on
13
+ * iOS (an Android keyboard keeps its own theme), so a host that follows the
14
+ * system's light or dark passes the scheme it is drawn in. Without one, the
15
+ * Identity account's branding theme decides, light when it names none.
16
+ */
17
+ colorScheme?: 'light' | 'dark';
11
18
  initialIdentity?: string;
12
19
  initialIdentityType?: IdentityType;
13
20
  onSuccess(result: IdentityVerifyResult & {
@@ -16,4 +23,4 @@ export interface SparkVaultIdentityDialogProps {
16
23
  onCancel(): void;
17
24
  onError?(error: Error): void;
18
25
  }
19
- export declare function SparkVaultIdentityDialog({ client, visible, title, initialIdentity, initialIdentityType, onSuccess, onCancel, onError, }: SparkVaultIdentityDialogProps): import("react").JSX.Element;
26
+ export declare function SparkVaultIdentityDialog({ client, visible, title, colorScheme, initialIdentity, initialIdentityType, onSuccess, onCancel, onError, }: SparkVaultIdentityDialogProps): import("react").JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { ActivityIndicator, Image, KeyboardAvoidingView, Linking, Modal, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, View, } from 'react-native';
3
+ import { AccessibilityInfo, ActivityIndicator, Image, KeyboardAvoidingView, Linking, Modal, Pressable, ScrollView, StyleSheet, Text, TextInput, View, } from 'react-native';
4
4
  import { SMS_CONSENT, TERMS_URL } from './app-sdk/consent-lines.js';
5
+ import { DARK_TEXT, DS } from './ds-tokens.js';
5
6
  import { identityKeyboardType, inferIdentityType, parseIdentity } from './identity-input.js';
6
7
  /**
7
8
  * Sign-in here is one-time code only. Passkeys are an Identity Product method
@@ -17,7 +18,7 @@ const SUPPORTED_METHODS = new Set(['otp_email', 'otp_sms', 'otp_voice']);
17
18
  * its last digit lands.
18
19
  */
19
20
  const CODE_LENGTH = 6;
20
- export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', initialIdentity, initialIdentityType, onSuccess, onCancel, onError, }) {
21
+ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', colorScheme, initialIdentity, initialIdentityType, onSuccess, onCancel, onError, }) {
21
22
  const [step, setStep] = useState('loading');
22
23
  const [config, setConfig] = useState(null);
23
24
  const [identity, setIdentity] = useState(initialIdentity ?? '');
@@ -27,7 +28,8 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
27
28
  const [expiresAt, setExpiresAt] = useState(null);
28
29
  const [pin, setPin] = useState('');
29
30
  const [countdown, setCountdown] = useState('');
30
- const [isBusy, setIsBusy] = useState(false);
31
+ /** The request running: every control waits for it, and only its own button spins. */
32
+ const [pending, setPending] = useState(null);
31
33
  const [error, setError] = useState('');
32
34
  /** The branding logo's own proportions, once the image has reported them. */
33
35
  const [measuredLogo, setMeasuredLogo] = useState(null);
@@ -50,9 +52,10 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
50
52
  const onSuccessRef = useRef(onSuccess);
51
53
  const onCancelRef = useRef(onCancel);
52
54
  const onErrorRef = useRef(onError);
55
+ const isBusy = pending !== null;
53
56
  const codeEditable = !isBusy && countdown !== 'Expired';
54
57
  const branding = config?.branding;
55
- const effectiveTheme = branding?.themeMode ?? 'light';
58
+ const effectiveTheme = colorScheme ?? branding?.themeMode ?? 'light';
56
59
  const colors = effectiveTheme === 'dark' ? darkColors : lightColors;
57
60
  const allowedTypes = useMemo(() => normalizeAllowedTypes(config), [config]);
58
61
  const visibleMethods = useMemo(() => getMethodsForIdentity(config, identityType), [config, identityType]);
@@ -61,12 +64,49 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
61
64
  onCancelRef.current = onCancel;
62
65
  onErrorRef.current = onError;
63
66
  }, [onCancel, onError, onSuccess]);
64
- useEffect(() => {
65
- if (!visible) {
66
- sessionRef.current += 1;
67
- return;
67
+ // An error appears where VoiceOver's focus is not (beside a field, or as a
68
+ // refused code hands focus back to the code field), and iOS speaks no text
69
+ // that appears: each one is announced, queued behind what VoiceOver is
70
+ // reading so the focus move does not cut it off.
71
+ const showError = useCallback((message) => {
72
+ setError(message);
73
+ AccessibilityInfo.announceForAccessibilityWithOptions(`Error: ${message}`, { queue: true });
74
+ }, []);
75
+ const reportError = useCallback((err, fallback) => {
76
+ const nextError = asError(err, fallback);
77
+ showError(nextError.message);
78
+ onErrorRef.current?.(nextError);
79
+ }, [showError]);
80
+ // The sign-in options, for an opening and for Try again alike: the
81
+ // identifier step once they offer a way to sign in, else the error step,
82
+ // with one set of words for a failure that carries none. An answer for a
83
+ // session that has ended (hidden, cancelled, opened again) lands nowhere.
84
+ const loadConfig = useCallback(async (sessionId) => {
85
+ try {
86
+ const nextConfig = await client.products.identity.getConfig();
87
+ if (!isActiveSession(sessionRef, sessionId))
88
+ return;
89
+ setConfig(nextConfig);
90
+ const nextAllowedTypes = normalizeAllowedTypes(nextConfig);
91
+ setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
92
+ if (nextAllowedTypes.length > 0) {
93
+ setStep('identity');
94
+ }
95
+ else {
96
+ showError('No supported sign-in methods are enabled for this app.');
97
+ setStep('error');
98
+ }
68
99
  }
69
- let cancelled = false;
100
+ catch (err) {
101
+ if (!isActiveSession(sessionRef, sessionId))
102
+ return;
103
+ reportError(err, 'Failed to load sign-in options');
104
+ setStep('error');
105
+ }
106
+ }, [client, initialIdentity, initialIdentityType, reportError, showError]);
107
+ useEffect(() => {
108
+ if (!visible)
109
+ return undefined;
70
110
  const sessionId = sessionRef.current + 1;
71
111
  sessionRef.current = sessionId;
72
112
  verifyingRef.current = false;
@@ -75,7 +115,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
75
115
  // running (a host that hid the dialog on success is exchanging the
76
116
  // token), and its finally, of another session, never clears the busy
77
117
  // state it set.
78
- setIsBusy(false);
118
+ setPending(null);
79
119
  setStep('loading');
80
120
  setError('');
81
121
  setPin('');
@@ -85,33 +125,13 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
85
125
  setBrokenLogoUri(null);
86
126
  setIdentity(initialIdentity ?? '');
87
127
  setIdentityType(initialIdentityType ?? 'email');
88
- client.products.identity.getConfig()
89
- .then((nextConfig) => {
90
- if (cancelled || !isActiveSession(sessionRef, sessionId))
91
- return;
92
- setConfig(nextConfig);
93
- const nextAllowedTypes = normalizeAllowedTypes(nextConfig);
94
- setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
95
- if (nextAllowedTypes.length > 0) {
96
- setStep('identity');
97
- }
98
- else {
99
- setError('No supported sign-in methods are enabled for this app.');
100
- setStep('error');
101
- }
102
- })
103
- .catch((err) => {
104
- if (cancelled || !isActiveSession(sessionRef, sessionId))
105
- return;
106
- const nextError = asError(err);
107
- setError(nextError.message);
108
- setStep('error');
109
- onErrorRef.current?.(nextError);
110
- });
128
+ void loadConfig(sessionId);
129
+ // Hiding the dialog, opening it again and unmounting it each end this
130
+ // session: whatever it still has running lands nowhere.
111
131
  return () => {
112
- cancelled = true;
132
+ sessionRef.current += 1;
113
133
  };
114
- }, [client, initialIdentity, initialIdentityType, visible]);
134
+ }, [initialIdentity, initialIdentityType, loadConfig, visible]);
115
135
  useEffect(() => {
116
136
  if (!expiresAt || step !== 'otp') {
117
137
  setCountdown('');
@@ -141,19 +161,14 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
141
161
  return;
142
162
  await onSuccessRef.current({ ...result, jwks });
143
163
  }, [client]);
144
- const reportError = useCallback((err, fallback) => {
145
- const nextError = asError(err, fallback);
146
- setError(nextError.message);
147
- onErrorRef.current?.(nextError);
148
- }, []);
149
164
  const handleCancel = useCallback(() => {
150
165
  sessionRef.current += 1;
151
- setIsBusy(false);
166
+ setPending(null);
152
167
  onCancelRef.current();
153
168
  }, []);
154
169
  const sendOtp = useCallback(async (method, targetIdentity = identity, targetIdentityType = identityType) => {
155
170
  const sessionId = sessionRef.current;
156
- setIsBusy(true);
171
+ setPending('send');
157
172
  setError('');
158
173
  setSelectedMethod(method);
159
174
  try {
@@ -176,7 +191,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
176
191
  }
177
192
  finally {
178
193
  if (isActiveSession(sessionRef, sessionId)) {
179
- setIsBusy(false);
194
+ setPending(null);
180
195
  }
181
196
  }
182
197
  }, [client, identity, identityType, reportError]);
@@ -185,14 +200,14 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
185
200
  return;
186
201
  const parsed = parseIdentity(identity, allowedTypes);
187
202
  if (!parsed.ok) {
188
- setError(parsed.error);
203
+ showError(parsed.error);
189
204
  return;
190
205
  }
191
206
  const normalizedIdentity = parsed.identity;
192
207
  const nextIdentityType = parsed.identityType;
193
208
  const availableMethods = getMethodsForIdentity(config, nextIdentityType);
194
209
  if (availableMethods.length === 0) {
195
- setError('No supported sign-in methods are enabled for this identity type.');
210
+ showError('No supported sign-in methods are enabled for this identity type.');
196
211
  return;
197
212
  }
198
213
  setIdentity(normalizedIdentity);
@@ -205,7 +220,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
205
220
  return;
206
221
  }
207
222
  setStep('methods');
208
- }, [allowedTypes, config, identity, isBusy, sendOtp]);
223
+ }, [allowedTypes, config, identity, isBusy, sendOtp, showError]);
209
224
  // Takes the code as entered rather than the pin state: a code completed by
210
225
  // the keystroke that is being handled has not reached that state yet.
211
226
  const verifyCode = useCallback(async (code) => {
@@ -213,7 +228,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
213
228
  return;
214
229
  verifyingRef.current = true;
215
230
  const sessionId = sessionRef.current;
216
- setIsBusy(true);
231
+ setPending('verify');
217
232
  setError('');
218
233
  try {
219
234
  const result = await client.products.identity.verifyOtp({
@@ -242,7 +257,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
242
257
  // meanwhile starts its next opening clear (the open effect).
243
258
  if (isActiveSession(sessionRef, sessionId)) {
244
259
  verifyingRef.current = false;
245
- setIsBusy(false);
260
+ setPending(null);
246
261
  }
247
262
  }
248
263
  }, [client, finishWithToken, identity, kindling, reportError]);
@@ -265,37 +280,16 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
265
280
  const handleRetryConfig = useCallback(() => {
266
281
  const sessionId = sessionRef.current + 1;
267
282
  sessionRef.current = sessionId;
268
- setIsBusy(true);
283
+ setPending('config');
269
284
  setConfig(null);
270
285
  setError('');
271
286
  setStep('loading');
272
- client.products.identity.getConfig()
273
- .then((nextConfig) => {
274
- if (!isActiveSession(sessionRef, sessionId))
275
- return;
276
- setConfig(nextConfig);
277
- const nextAllowedTypes = normalizeAllowedTypes(nextConfig);
278
- setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
279
- if (nextAllowedTypes.length > 0) {
280
- setStep('identity');
281
- }
282
- else {
283
- setError('No supported sign-in methods are enabled for this app.');
284
- setStep('error');
285
- }
286
- })
287
- .catch((err) => {
288
- if (!isActiveSession(sessionRef, sessionId))
289
- return;
290
- reportError(err, 'Failed to load sign-in options');
291
- setStep('error');
292
- })
293
- .finally(() => {
287
+ void loadConfig(sessionId).finally(() => {
294
288
  if (isActiveSession(sessionRef, sessionId)) {
295
- setIsBusy(false);
289
+ setPending(null);
296
290
  }
297
291
  });
298
- }, [client, initialIdentity, initialIdentityType, reportError]);
292
+ }, [loadConfig]);
299
293
  const companyName = branding?.companyName || 'SparkVault';
300
294
  // A logo speaks for the brand on its own, so it replaces the company name
301
295
  // rather than sitting beside it, drawn at its own proportions and the full
@@ -304,7 +298,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
304
298
  // the header is never blank.
305
299
  const logoUri = resolveLogoUri(branding, effectiveTheme, brokenLogoUri);
306
300
  const logoAspectRatio = measuredLogo?.uri === logoUri ? measuredLogo.aspectRatio : null;
307
- return (_jsx(Modal, { visible: visible, transparent: true, animationType: "fade", onRequestClose: handleCancel, children: _jsx(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: [styles.backdrop, { backgroundColor: colors.backdrop }], children: _jsx(ScrollView, { contentContainerStyle: styles.scrollContent, keyboardShouldPersistTaps: "handled", children: _jsxs(View, { style: [styles.card, { backgroundColor: colors.card, borderColor: colors.border }], children: [_jsxs(View, { style: styles.header, children: [_jsx(View, { style: styles.brand, children: logoUri ? (_jsx(Image, { source: { uri: logoUri }, style: logoAspectRatio === null
301
+ return (_jsx(Modal, { visible: visible, transparent: true, animationType: "fade", onRequestClose: handleCancel, children: _jsx(KeyboardAvoidingView, { behavior: "padding", style: [styles.backdrop, { backgroundColor: colors.backdrop }], children: _jsx(ScrollView, { contentContainerStyle: styles.scrollContent, keyboardShouldPersistTaps: "handled", children: _jsxs(View, { style: [styles.card, { backgroundColor: colors.card, borderColor: colors.border }], children: [_jsxs(View, { style: styles.header, children: [_jsx(View, { style: styles.brand, children: logoUri ? (_jsx(Image, { source: { uri: logoUri }, style: logoAspectRatio === null
308
302
  ? styles.logoUnmeasured
309
303
  : [styles.logo, { aspectRatio: logoAspectRatio }], resizeMode: "contain", accessibilityRole: "image", accessibilityLabel: companyName, onLoad: (event) => {
310
304
  const { width, height } = event.nativeEvent.source;
@@ -324,7 +318,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
324
318
  if (allowedTypes.length > 1) {
325
319
  setIdentityType(inferIdentityType(value));
326
320
  }
327
- }, placeholder: identityPlaceholder(allowedTypes), placeholderTextColor: colors.placeholder, autoCapitalize: "none", autoCorrect: false, autoComplete: identityType === 'phone' ? 'tel' : 'email', keyboardType: identityKeyboardType(allowedTypes), autoFocus: true, returnKeyType: "go",
321
+ }, placeholder: identityPlaceholder(allowedTypes), placeholderTextColor: colors.muted, autoCapitalize: "none", autoCorrect: false, autoComplete: identityType === 'phone' ? 'tel' : 'email', keyboardType: identityKeyboardType(allowedTypes), keyboardAppearance: effectiveTheme, autoFocus: true, returnKeyType: "go",
328
322
  // Go sends without dismissing the keyboard, and the field
329
323
  // stays editable through the send (iOS ends the editing of
330
324
  // a field made not editable, and the keyboard goes with
@@ -338,14 +332,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
338
332
  color: colors.text,
339
333
  backgroundColor: colors.input,
340
334
  },
341
- ] }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : null, allowedTypes.includes('phone') ? _jsx(SmsConsent, { colors: colors }) : null, _jsx(PrimaryButton, { label: "Continue", colors: colors, disabled: !identity.trim() || isBusy, loading: isBusy, onPress: handleIdentitySubmit })] })), step === 'methods' && (_jsxs(View, { style: styles.body, children: [_jsx(Text, { style: [styles.title, { color: colors.text }], children: "Choose a method" }), identity ? _jsx(Text, { style: [styles.subtitle, { color: colors.muted }], children: identity }) : null, _jsx(View, { style: styles.methodList, children: visibleMethods.map((method) => (_jsxs(Pressable, { accessibilityRole: "button", onPress: () => sendOtp(method), disabled: isBusy, style: ({ pressed }) => [
342
- styles.methodButton,
343
- {
344
- borderColor: colors.border,
345
- backgroundColor: pressed ? colors.pressed : colors.input,
346
- opacity: isBusy ? 0.6 : 1,
347
- },
348
- ], children: [_jsx(Text, { style: [styles.methodTitle, { color: colors.text }], children: methodTitle(method) }), _jsx(Text, { style: [styles.methodDescription, { color: colors.muted }], children: methodDescription(method) })] }, method))) }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : null, allowedTypes.length > 0 ? (_jsx(TextButton, { label: changeIdentityLabel(identityType), colors: colors, onPress: handleChangeIdentity, disabled: isBusy })) : null] })), step === 'otp' && (_jsxs(View, { style: styles.body, children: [_jsx(Text, { style: [styles.title, { color: colors.text }], children: otpTitle(selectedMethod) }), _jsxs(Text, { style: [styles.subtitle, { color: colors.muted }], children: ["Enter the ", CODE_LENGTH, "-digit code sent to ", '\n', _jsx(Text, { style: { color: colors.text, fontWeight: '700' }, children: identity })] }), _jsx(TextInput, { ref: codeInputRef, value: pin, onChangeText: (value) => {
335
+ ] }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : null, allowedTypes.includes('phone') ? _jsx(SmsConsent, { colors: colors }) : null, _jsx(PrimaryButton, { label: "Continue", colors: colors, disabled: !identity.trim() || isBusy, loading: pending === 'send', onPress: handleIdentitySubmit })] })), step === 'methods' && (_jsxs(View, { style: styles.body, children: [_jsx(Text, { style: [styles.title, { color: colors.text }], children: "Choose a method" }), identity ? _jsx(Text, { style: [styles.subtitle, { color: colors.muted }], children: identity }) : null, _jsx(View, { style: styles.methodList, children: visibleMethods.map((method) => (_jsx(MethodChoice, { method: method, colors: colors, disabled: isBusy, loading: pending === 'send' && selectedMethod === method, onPress: () => void sendOtp(method) }, method))) }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : null, allowedTypes.length > 0 ? (_jsx(TextButton, { label: changeIdentityLabel(identityType), colors: colors, onPress: handleChangeIdentity, disabled: isBusy })) : null] })), step === 'otp' && (_jsxs(View, { style: styles.body, children: [_jsx(Text, { style: [styles.title, { color: colors.text }], children: otpTitle(selectedMethod) }), _jsxs(Text, { style: [styles.subtitle, { color: colors.muted }], children: ["Enter the ", CODE_LENGTH, "-digit code sent to ", '\n', _jsx(Text, { style: { color: colors.text, fontWeight: '700' }, children: identity })] }), _jsx(TextInput, { ref: codeInputRef, value: pin, onChangeText: (value) => {
349
336
  const code = value.replace(/\D/g, '').slice(0, CODE_LENGTH);
350
337
  setPin(code);
351
338
  setError('');
@@ -353,7 +340,7 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
353
340
  // pasted or filled in from iOS's code suggestion.
354
341
  if (code.length === CODE_LENGTH)
355
342
  void verifyCode(code);
356
- }, accessibilityLabel: "Verification code", placeholder: '0'.repeat(CODE_LENGTH), placeholderTextColor: colors.placeholder, keyboardType: "number-pad",
343
+ }, accessibilityLabel: "Verification code", placeholder: '0'.repeat(CODE_LENGTH), placeholderTextColor: colors.muted, keyboardType: "number-pad", keyboardAppearance: effectiveTheme,
357
344
  // iOS offers the code from Messages and Mail above the
358
345
  // keyboard (Android's SMS code autofill reads the same hint).
359
346
  autoComplete: "one-time-code", autoFocus: true, maxLength: CODE_LENGTH, editable: codeEditable, style: [
@@ -363,22 +350,48 @@ export function SparkVaultIdentityDialog({ client, visible, title = 'Sign in', i
363
350
  color: colors.text,
364
351
  backgroundColor: colors.input,
365
352
  },
366
- ] }), _jsx(Text, { style: [styles.countdown, { color: countdown === 'Expired' ? colors.error : colors.muted }], children: countdown === 'Expired' ? 'Code expired' : `Expires in ${countdown}` }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : null, _jsx(PrimaryButton, { label: "Verify", colors: colors, disabled: pin.length !== CODE_LENGTH || isBusy || countdown === 'Expired', loading: isBusy, onPress: () => void verifyCode(pin) }), _jsx(TextButton, { label: "Resend code", colors: colors, onPress: handleResend, disabled: isBusy }), _jsx(TextButton, { label: changeIdentityLabel(identityType), colors: colors, onPress: handleChangeIdentity, disabled: isBusy })] })), step === 'error' && (_jsxs(View, { style: styles.body, children: [_jsx(Text, { style: [styles.title, { color: colors.text }], children: "Sign-in unavailable" }), _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }), _jsx(PrimaryButton, { label: "Try Again", colors: colors, disabled: isBusy, loading: isBusy, onPress: handleRetryConfig })] }))] }) }) }) }));
353
+ ] }), _jsx(Text, { style: [styles.countdown, { color: countdown === 'Expired' ? colors.error : colors.muted }], children: countdown === 'Expired' ? 'Code expired' : `Expires in ${countdown}` }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : null, _jsx(PrimaryButton, { label: "Verify", colors: colors, disabled: pin.length !== CODE_LENGTH || isBusy || countdown === 'Expired', loading: pending === 'verify', onPress: () => void verifyCode(pin) }), _jsx(TextButton, { label: "Resend code", colors: colors, onPress: handleResend, disabled: isBusy, loading: pending === 'send' }), _jsx(TextButton, { label: changeIdentityLabel(identityType), colors: colors, onPress: handleChangeIdentity, disabled: isBusy })] })), step === 'error' && (_jsxs(View, { style: styles.body, children: [_jsx(Text, { style: [styles.title, { color: colors.text }], children: "Sign-in unavailable" }), _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }), _jsx(PrimaryButton, { label: "Try again", colors: colors, disabled: isBusy, loading: pending === 'config', onPress: handleRetryConfig })] }))] }) }) }) }));
367
354
  }
368
355
  function isActiveSession(sessionRef, sessionId) {
369
356
  return sessionRef.current === sessionId;
370
357
  }
358
+ /**
359
+ * A filled button: a white label on the primary fill, and while it cannot be
360
+ * pressed (nothing to send yet, or a request running) a muted label on a
361
+ * quiet slate ground, as SparkVault's app draws its own. While its own
362
+ * request runs a spinner takes the label's place, and VoiceOver still hears
363
+ * the label, and that it is busy.
364
+ */
371
365
  function PrimaryButton({ label, colors, disabled, loading, onPress, }) {
372
- return (_jsx(Pressable, { accessibilityRole: "button", onPress: onPress, disabled: disabled, style: ({ pressed }) => [
366
+ const ink = disabled ? colors.muted : colors.buttonText;
367
+ return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { busy: loading }, onPress: onPress, disabled: disabled, style: ({ pressed }) => [
373
368
  styles.primaryButton,
374
369
  {
375
- backgroundColor: disabled ? colors.muted : colors.primary,
370
+ backgroundColor: disabled ? colors.border : colors.buttonPrimary,
376
371
  opacity: pressed && !disabled ? 0.9 : 1,
377
372
  },
378
- ], children: loading ? (_jsx(ActivityIndicator, { color: colors.primaryText })) : (_jsx(Text, { style: [styles.primaryButtonText, { color: colors.primaryText }], children: label })) }));
373
+ ], children: loading ? (_jsx(ActivityIndicator, { color: ink })) : (_jsx(Text, { style: [styles.primaryButtonText, { color: ink }], children: label })) }));
379
374
  }
380
- function TextButton({ label, colors, disabled, onPress, }) {
381
- return (_jsx(Pressable, { accessibilityRole: "button", onPress: onPress, disabled: disabled, style: styles.textButton, children: _jsx(Text, { style: [styles.textButtonLabel, { color: disabled ? colors.muted : colors.primary }], children: label }) }));
375
+ /** A link-styled button, spinning in its label's place while its own request runs, as PrimaryButton does. */
376
+ function TextButton({ label, colors, disabled, loading, onPress, }) {
377
+ const ink = disabled ? colors.muted : colors.primary;
378
+ return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { busy: loading }, onPress: onPress, disabled: disabled, style: styles.textButton, children: loading ? (_jsx(ActivityIndicator, { color: ink })) : (_jsx(Text, { style: [styles.textButtonLabel, { color: ink }], children: label })) }));
379
+ }
380
+ /**
381
+ * One way to get the code, on the choice a phone number with several gets:
382
+ * its name, and beneath it how the code comes. While its own code is sent a
383
+ * spinner stands at its end, and VoiceOver still hears its name, and that it
384
+ * is busy, as PrimaryButton does.
385
+ */
386
+ function MethodChoice({ method, colors, disabled, loading, onPress, }) {
387
+ return (_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: methodTitle(method), accessibilityHint: methodDescription(method), accessibilityState: { busy: loading }, onPress: onPress, disabled: disabled, style: ({ pressed }) => [
388
+ styles.methodButton,
389
+ {
390
+ borderColor: colors.border,
391
+ backgroundColor: pressed ? colors.pressed : colors.input,
392
+ opacity: disabled ? 0.6 : 1,
393
+ },
394
+ ], children: [_jsxs(View, { style: styles.methodText, children: [_jsx(Text, { style: [styles.methodTitle, { color: colors.text }], children: methodTitle(method) }), _jsx(Text, { style: [styles.methodDescription, { color: colors.muted }], children: methodDescription(method) })] }), loading ? _jsx(ActivityIndicator, { color: colors.primary }) : null] }));
382
395
  }
383
396
  /**
384
397
  * The SMS and voice consent under a field that takes a phone number, in the
@@ -484,32 +497,38 @@ function asError(value, fallback = 'Something went wrong') {
484
497
  return new Error(fallback);
485
498
  }
486
499
  const lightColors = {
487
- backdrop: 'rgba(15, 23, 42, 0.42)',
488
- card: '#ffffff',
489
- input: '#ffffff',
490
- pressed: '#f8fafc',
491
- text: '#0f172a',
492
- muted: '#64748b',
493
- placeholder: '#94a3b8',
494
- border: '#e2e8f0',
495
- primary: '#2563eb',
496
- primaryText: '#ffffff',
497
- primarySoft: '#dbeafe',
498
- error: '#dc2626',
500
+ backdrop: DS.modalOverlay,
501
+ card: DS.white,
502
+ input: DS.white,
503
+ pressed: DS.slate200,
504
+ text: DS.slate900,
505
+ // 4.76:1 on the card and a field.
506
+ muted: DS.slate500,
507
+ border: DS.slate200,
508
+ primary: DS.action,
509
+ // Action Blue on it measures 4.50:1.
510
+ primarySoft: DS.actionBg,
511
+ buttonPrimary: DS.btnPrimary,
512
+ buttonText: DS.white,
513
+ error: DS.error,
499
514
  };
500
515
  const darkColors = {
501
- backdrop: 'rgba(2, 6, 23, 0.72)',
502
- card: '#0f172a',
503
- input: '#111827',
504
- pressed: '#1e293b',
505
- text: '#f8fafc',
506
- muted: '#94a3b8',
507
- placeholder: '#64748b',
508
- border: '#334155',
509
- primary: '#60a5fa',
510
- primaryText: '#0f172a',
511
- primarySoft: '#172554',
512
- error: '#f87171',
516
+ // Black at 70%, the web identity dialog's dark scrim: the slate card
517
+ // stands off a dark host behind it.
518
+ backdrop: 'rgba(0, 0, 0, 0.7)',
519
+ card: DS.slate900,
520
+ input: DS.slate800,
521
+ pressed: DS.slate700,
522
+ text: DS.slate50,
523
+ // 6.96:1 on the card, 5.71:1 on a field.
524
+ muted: DS.slate400,
525
+ border: DS.slate700,
526
+ primary: DARK_TEXT.action,
527
+ primarySoft: DS.slate800,
528
+ // Action Blue itself, not its dark text tier: white on it measures 4.97:1.
529
+ buttonPrimary: DS.action,
530
+ buttonText: DS.white,
531
+ error: DARK_TEXT.error,
513
532
  };
514
533
  const styles = StyleSheet.create({
515
534
  backdrop: {
@@ -527,9 +546,10 @@ const styles = StyleSheet.create({
527
546
  width: '100%',
528
547
  maxWidth: 420,
529
548
  alignSelf: 'center',
530
- shadowColor: '#000000',
531
- shadowOffset: { width: 0, height: 16 },
532
- shadowOpacity: 0.18,
549
+ // The design system's popover shadow (--shadow-popover).
550
+ shadowColor: DS.slate900,
551
+ shadowOffset: { width: 0, height: 8 },
552
+ shadowOpacity: 0.12,
533
553
  shadowRadius: 24,
534
554
  elevation: 12,
535
555
  },
@@ -628,6 +648,8 @@ const styles = StyleSheet.create({
628
648
  countdown: {
629
649
  fontSize: 13,
630
650
  textAlign: 'center',
651
+ // Ticks each second: tabular figures hold the centered line still.
652
+ fontVariant: ['tabular-nums'],
631
653
  },
632
654
  error: {
633
655
  fontSize: 13,
@@ -664,10 +686,16 @@ const styles = StyleSheet.create({
664
686
  gap: 10,
665
687
  },
666
688
  methodButton: {
689
+ flexDirection: 'row',
690
+ alignItems: 'center',
691
+ gap: 12,
667
692
  borderWidth: 1,
668
693
  borderRadius: 8,
669
694
  padding: 14,
670
695
  },
696
+ methodText: {
697
+ flex: 1,
698
+ },
671
699
  methodTitle: {
672
700
  fontSize: 15,
673
701
  fontWeight: '800',