@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.
@@ -1,11 +1,11 @@
1
1
  import { type ComponentRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import {
3
+ AccessibilityInfo,
3
4
  ActivityIndicator,
4
5
  Image,
5
6
  KeyboardAvoidingView,
6
7
  Linking,
7
8
  Modal,
8
- Platform,
9
9
  Pressable,
10
10
  ScrollView,
11
11
  StyleSheet,
@@ -15,6 +15,7 @@ import {
15
15
  } from 'react-native';
16
16
  import { SMS_CONSENT, TERMS_URL } from './app-sdk/consent-lines.js';
17
17
  import type { SparkVaultMobile } from './client.js';
18
+ import { DARK_TEXT, DS } from './ds-tokens.js';
18
19
  import { identityKeyboardType, inferIdentityType, parseIdentity } from './identity-input.js';
19
20
  import type {
20
21
  IdentityConfig,
@@ -25,6 +26,8 @@ import type {
25
26
  } from './types.js';
26
27
 
27
28
  type DialogStep = 'loading' | 'identity' | 'methods' | 'otp' | 'error';
29
+ /** A request the dialog makes: loading its options, sending a code, or checking one. */
30
+ type DialogRequest = 'config' | 'send' | 'verify';
28
31
  type OtpMethod = 'email' | 'sms' | 'voice';
29
32
  type SupportedMethodId = 'otp_email' | 'otp_sms' | 'otp_voice';
30
33
 
@@ -36,6 +39,13 @@ export interface SparkVaultIdentityDialogProps {
36
39
  * also creates an account (a new identity goes on to signup) says so here.
37
40
  */
38
41
  title?: string;
42
+ /**
43
+ * The host's appearance. The dialog draws in it, as does its keyboard on
44
+ * iOS (an Android keyboard keeps its own theme), so a host that follows the
45
+ * system's light or dark passes the scheme it is drawn in. Without one, the
46
+ * Identity account's branding theme decides, light when it names none.
47
+ */
48
+ colorScheme?: 'light' | 'dark';
39
49
  initialIdentity?: string;
40
50
  initialIdentityType?: IdentityType;
41
51
  onSuccess(result: IdentityVerifyResult & { jwks: IdentityJwks }): void | Promise<void>;
@@ -63,6 +73,7 @@ export function SparkVaultIdentityDialog({
63
73
  client,
64
74
  visible,
65
75
  title = 'Sign in',
76
+ colorScheme,
66
77
  initialIdentity,
67
78
  initialIdentityType,
68
79
  onSuccess,
@@ -78,7 +89,8 @@ export function SparkVaultIdentityDialog({
78
89
  const [expiresAt, setExpiresAt] = useState<number | null>(null);
79
90
  const [pin, setPin] = useState('');
80
91
  const [countdown, setCountdown] = useState('');
81
- const [isBusy, setIsBusy] = useState(false);
92
+ /** The request running: every control waits for it, and only its own button spins. */
93
+ const [pending, setPending] = useState<DialogRequest | null>(null);
82
94
  const [error, setError] = useState('');
83
95
  /** The branding logo's own proportions, once the image has reported them. */
84
96
  const [measuredLogo, setMeasuredLogo] = useState<{ uri: string; aspectRatio: number } | null>(null);
@@ -102,9 +114,10 @@ export function SparkVaultIdentityDialog({
102
114
  const onCancelRef = useRef(onCancel);
103
115
  const onErrorRef = useRef(onError);
104
116
 
117
+ const isBusy = pending !== null;
105
118
  const codeEditable = !isBusy && countdown !== 'Expired';
106
119
  const branding = config?.branding;
107
- const effectiveTheme = branding?.themeMode ?? 'light';
120
+ const effectiveTheme = colorScheme ?? branding?.themeMode ?? 'light';
108
121
  const colors = effectiveTheme === 'dark' ? darkColors : lightColors;
109
122
  const allowedTypes = useMemo(() => normalizeAllowedTypes(config), [config]);
110
123
  const visibleMethods = useMemo(
@@ -118,13 +131,48 @@ export function SparkVaultIdentityDialog({
118
131
  onErrorRef.current = onError;
119
132
  }, [onCancel, onError, onSuccess]);
120
133
 
121
- useEffect(() => {
122
- if (!visible) {
123
- sessionRef.current += 1;
124
- return;
134
+ // An error appears where VoiceOver's focus is not (beside a field, or as a
135
+ // refused code hands focus back to the code field), and iOS speaks no text
136
+ // that appears: each one is announced, queued behind what VoiceOver is
137
+ // reading so the focus move does not cut it off.
138
+ const showError = useCallback((message: string) => {
139
+ setError(message);
140
+ AccessibilityInfo.announceForAccessibilityWithOptions(`Error: ${message}`, { queue: true });
141
+ }, []);
142
+
143
+ const reportError = useCallback((err: unknown, fallback: string) => {
144
+ const nextError = asError(err, fallback);
145
+ showError(nextError.message);
146
+ onErrorRef.current?.(nextError);
147
+ }, [showError]);
148
+
149
+ // The sign-in options, for an opening and for Try again alike: the
150
+ // identifier step once they offer a way to sign in, else the error step,
151
+ // with one set of words for a failure that carries none. An answer for a
152
+ // session that has ended (hidden, cancelled, opened again) lands nowhere.
153
+ const loadConfig = useCallback(async (sessionId: number) => {
154
+ try {
155
+ const nextConfig = await client.products.identity.getConfig();
156
+ if (!isActiveSession(sessionRef, sessionId)) return;
157
+ setConfig(nextConfig);
158
+ const nextAllowedTypes = normalizeAllowedTypes(nextConfig);
159
+ setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
160
+ if (nextAllowedTypes.length > 0) {
161
+ setStep('identity');
162
+ } else {
163
+ showError('No supported sign-in methods are enabled for this app.');
164
+ setStep('error');
165
+ }
166
+ } catch (err: unknown) {
167
+ if (!isActiveSession(sessionRef, sessionId)) return;
168
+ reportError(err, 'Failed to load sign-in options');
169
+ setStep('error');
125
170
  }
171
+ }, [client, initialIdentity, initialIdentityType, reportError, showError]);
172
+
173
+ useEffect(() => {
174
+ if (!visible) return undefined;
126
175
 
127
- let cancelled = false;
128
176
  const sessionId = sessionRef.current + 1;
129
177
  sessionRef.current = sessionId;
130
178
  verifyingRef.current = false;
@@ -133,7 +181,7 @@ export function SparkVaultIdentityDialog({
133
181
  // running (a host that hid the dialog on success is exchanging the
134
182
  // token), and its finally, of another session, never clears the busy
135
183
  // state it set.
136
- setIsBusy(false);
184
+ setPending(null);
137
185
  setStep('loading');
138
186
  setError('');
139
187
  setPin('');
@@ -144,31 +192,14 @@ export function SparkVaultIdentityDialog({
144
192
  setIdentity(initialIdentity ?? '');
145
193
  setIdentityType(initialIdentityType ?? 'email');
146
194
 
147
- client.products.identity.getConfig()
148
- .then((nextConfig) => {
149
- if (cancelled || !isActiveSession(sessionRef, sessionId)) return;
150
- setConfig(nextConfig);
151
- const nextAllowedTypes = normalizeAllowedTypes(nextConfig);
152
- setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
153
- if (nextAllowedTypes.length > 0) {
154
- setStep('identity');
155
- } else {
156
- setError('No supported sign-in methods are enabled for this app.');
157
- setStep('error');
158
- }
159
- })
160
- .catch((err: unknown) => {
161
- if (cancelled || !isActiveSession(sessionRef, sessionId)) return;
162
- const nextError = asError(err);
163
- setError(nextError.message);
164
- setStep('error');
165
- onErrorRef.current?.(nextError);
166
- });
195
+ void loadConfig(sessionId);
167
196
 
197
+ // Hiding the dialog, opening it again and unmounting it each end this
198
+ // session: whatever it still has running lands nowhere.
168
199
  return () => {
169
- cancelled = true;
200
+ sessionRef.current += 1;
170
201
  };
171
- }, [client, initialIdentity, initialIdentityType, visible]);
202
+ }, [initialIdentity, initialIdentityType, loadConfig, visible]);
172
203
 
173
204
  useEffect(() => {
174
205
  if (!expiresAt || step !== 'otp') {
@@ -202,15 +233,9 @@ export function SparkVaultIdentityDialog({
202
233
  await onSuccessRef.current({ ...result, jwks });
203
234
  }, [client]);
204
235
 
205
- const reportError = useCallback((err: unknown, fallback: string) => {
206
- const nextError = asError(err, fallback);
207
- setError(nextError.message);
208
- onErrorRef.current?.(nextError);
209
- }, []);
210
-
211
236
  const handleCancel = useCallback(() => {
212
237
  sessionRef.current += 1;
213
- setIsBusy(false);
238
+ setPending(null);
214
239
  onCancelRef.current();
215
240
  }, []);
216
241
 
@@ -220,7 +245,7 @@ export function SparkVaultIdentityDialog({
220
245
  targetIdentityType = identityType
221
246
  ) => {
222
247
  const sessionId = sessionRef.current;
223
- setIsBusy(true);
248
+ setPending('send');
224
249
  setError('');
225
250
  setSelectedMethod(method);
226
251
  try {
@@ -239,7 +264,7 @@ export function SparkVaultIdentityDialog({
239
264
  reportError(err, 'Failed to send verification code');
240
265
  } finally {
241
266
  if (isActiveSession(sessionRef, sessionId)) {
242
- setIsBusy(false);
267
+ setPending(null);
243
268
  }
244
269
  }
245
270
  }, [client, identity, identityType, reportError]);
@@ -249,7 +274,7 @@ export function SparkVaultIdentityDialog({
249
274
 
250
275
  const parsed = parseIdentity(identity, allowedTypes);
251
276
  if (!parsed.ok) {
252
- setError(parsed.error);
277
+ showError(parsed.error);
253
278
  return;
254
279
  }
255
280
 
@@ -257,7 +282,7 @@ export function SparkVaultIdentityDialog({
257
282
  const nextIdentityType = parsed.identityType;
258
283
  const availableMethods = getMethodsForIdentity(config, nextIdentityType);
259
284
  if (availableMethods.length === 0) {
260
- setError('No supported sign-in methods are enabled for this identity type.');
285
+ showError('No supported sign-in methods are enabled for this identity type.');
261
286
  return;
262
287
  }
263
288
 
@@ -273,7 +298,7 @@ export function SparkVaultIdentityDialog({
273
298
  }
274
299
 
275
300
  setStep('methods');
276
- }, [allowedTypes, config, identity, isBusy, sendOtp]);
301
+ }, [allowedTypes, config, identity, isBusy, sendOtp, showError]);
277
302
 
278
303
  // Takes the code as entered rather than the pin state: a code completed by
279
304
  // the keystroke that is being handled has not reached that state yet.
@@ -282,7 +307,7 @@ export function SparkVaultIdentityDialog({
282
307
 
283
308
  verifyingRef.current = true;
284
309
  const sessionId = sessionRef.current;
285
- setIsBusy(true);
310
+ setPending('verify');
286
311
  setError('');
287
312
  try {
288
313
  const result = await client.products.identity.verifyOtp({
@@ -308,7 +333,7 @@ export function SparkVaultIdentityDialog({
308
333
  // meanwhile starts its next opening clear (the open effect).
309
334
  if (isActiveSession(sessionRef, sessionId)) {
310
335
  verifyingRef.current = false;
311
- setIsBusy(false);
336
+ setPending(null);
312
337
  }
313
338
  }
314
339
  }, [client, finishWithToken, identity, kindling, reportError]);
@@ -333,35 +358,17 @@ export function SparkVaultIdentityDialog({
333
358
  const handleRetryConfig = useCallback(() => {
334
359
  const sessionId = sessionRef.current + 1;
335
360
  sessionRef.current = sessionId;
336
- setIsBusy(true);
361
+ setPending('config');
337
362
  setConfig(null);
338
363
  setError('');
339
364
  setStep('loading');
340
365
 
341
- client.products.identity.getConfig()
342
- .then((nextConfig) => {
343
- if (!isActiveSession(sessionRef, sessionId)) return;
344
- setConfig(nextConfig);
345
- const nextAllowedTypes = normalizeAllowedTypes(nextConfig);
346
- setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
347
- if (nextAllowedTypes.length > 0) {
348
- setStep('identity');
349
- } else {
350
- setError('No supported sign-in methods are enabled for this app.');
351
- setStep('error');
352
- }
353
- })
354
- .catch((err: unknown) => {
355
- if (!isActiveSession(sessionRef, sessionId)) return;
356
- reportError(err, 'Failed to load sign-in options');
357
- setStep('error');
358
- })
359
- .finally(() => {
360
- if (isActiveSession(sessionRef, sessionId)) {
361
- setIsBusy(false);
362
- }
363
- });
364
- }, [client, initialIdentity, initialIdentityType, reportError]);
366
+ void loadConfig(sessionId).finally(() => {
367
+ if (isActiveSession(sessionRef, sessionId)) {
368
+ setPending(null);
369
+ }
370
+ });
371
+ }, [loadConfig]);
365
372
 
366
373
  const companyName = branding?.companyName || 'SparkVault';
367
374
  // A logo speaks for the brand on its own, so it replaces the company name
@@ -374,8 +381,12 @@ export function SparkVaultIdentityDialog({
374
381
 
375
382
  return (
376
383
  <Modal visible={visible} transparent animationType="fade" onRequestClose={handleCancel}>
384
+ {/* The card is lifted clear of the keyboard here on both platforms:
385
+ Android's edge-to-edge modal window does not resize for the
386
+ keyboard. Padding, not height, so the scrim this view paints still
387
+ reaches under the keyboard. */}
377
388
  <KeyboardAvoidingView
378
- behavior={Platform.OS === 'ios' ? 'padding' : undefined}
389
+ behavior="padding"
379
390
  style={[styles.backdrop, { backgroundColor: colors.backdrop }]}
380
391
  >
381
392
  <ScrollView
@@ -456,11 +467,12 @@ export function SparkVaultIdentityDialog({
456
467
  }
457
468
  }}
458
469
  placeholder={identityPlaceholder(allowedTypes)}
459
- placeholderTextColor={colors.placeholder}
470
+ placeholderTextColor={colors.muted}
460
471
  autoCapitalize="none"
461
472
  autoCorrect={false}
462
473
  autoComplete={identityType === 'phone' ? 'tel' : 'email'}
463
474
  keyboardType={identityKeyboardType(allowedTypes)}
475
+ keyboardAppearance={effectiveTheme}
464
476
  autoFocus
465
477
  returnKeyType="go"
466
478
  // Go sends without dismissing the keyboard, and the field
@@ -486,7 +498,7 @@ export function SparkVaultIdentityDialog({
486
498
  label="Continue"
487
499
  colors={colors}
488
500
  disabled={!identity.trim() || isBusy}
489
- loading={isBusy}
501
+ loading={pending === 'send'}
490
502
  onPress={handleIdentitySubmit}
491
503
  />
492
504
  </View>
@@ -498,25 +510,14 @@ export function SparkVaultIdentityDialog({
498
510
  {identity ? <Text style={[styles.subtitle, { color: colors.muted }]}>{identity}</Text> : null}
499
511
  <View style={styles.methodList}>
500
512
  {visibleMethods.map((method) => (
501
- <Pressable
513
+ <MethodChoice
502
514
  key={method}
503
- accessibilityRole="button"
504
- onPress={() => sendOtp(method)}
515
+ method={method}
516
+ colors={colors}
505
517
  disabled={isBusy}
506
- style={({ pressed }) => [
507
- styles.methodButton,
508
- {
509
- borderColor: colors.border,
510
- backgroundColor: pressed ? colors.pressed : colors.input,
511
- opacity: isBusy ? 0.6 : 1,
512
- },
513
- ]}
514
- >
515
- <Text style={[styles.methodTitle, { color: colors.text }]}>{methodTitle(method)}</Text>
516
- <Text style={[styles.methodDescription, { color: colors.muted }]}>
517
- {methodDescription(method)}
518
- </Text>
519
- </Pressable>
518
+ loading={pending === 'send' && selectedMethod === method}
519
+ onPress={() => void sendOtp(method)}
520
+ />
520
521
  ))}
521
522
  </View>
522
523
  {error ? <Text style={[styles.error, { color: colors.error }]}>{error}</Text> : null}
@@ -551,8 +552,9 @@ export function SparkVaultIdentityDialog({
551
552
  }}
552
553
  accessibilityLabel="Verification code"
553
554
  placeholder={'0'.repeat(CODE_LENGTH)}
554
- placeholderTextColor={colors.placeholder}
555
+ placeholderTextColor={colors.muted}
555
556
  keyboardType="number-pad"
557
+ keyboardAppearance={effectiveTheme}
556
558
  // iOS offers the code from Messages and Mail above the
557
559
  // keyboard (Android's SMS code autofill reads the same hint).
558
560
  autoComplete="one-time-code"
@@ -576,10 +578,16 @@ export function SparkVaultIdentityDialog({
576
578
  label="Verify"
577
579
  colors={colors}
578
580
  disabled={pin.length !== CODE_LENGTH || isBusy || countdown === 'Expired'}
579
- loading={isBusy}
581
+ loading={pending === 'verify'}
580
582
  onPress={() => void verifyCode(pin)}
581
583
  />
582
- <TextButton label="Resend code" colors={colors} onPress={handleResend} disabled={isBusy} />
584
+ <TextButton
585
+ label="Resend code"
586
+ colors={colors}
587
+ onPress={handleResend}
588
+ disabled={isBusy}
589
+ loading={pending === 'send'}
590
+ />
583
591
  <TextButton
584
592
  label={changeIdentityLabel(identityType)}
585
593
  colors={colors}
@@ -594,10 +602,10 @@ export function SparkVaultIdentityDialog({
594
602
  <Text style={[styles.title, { color: colors.text }]}>Sign-in unavailable</Text>
595
603
  <Text style={[styles.error, { color: colors.error }]}>{error}</Text>
596
604
  <PrimaryButton
597
- label="Try Again"
605
+ label="Try again"
598
606
  colors={colors}
599
607
  disabled={isBusy}
600
- loading={isBusy}
608
+ loading={pending === 'config'}
601
609
  onPress={handleRetryConfig}
602
610
  />
603
611
  </View>
@@ -613,13 +621,13 @@ function isActiveSession(sessionRef: { current: number }, sessionId: number): bo
613
621
  return sessionRef.current === sessionId;
614
622
  }
615
623
 
616
- interface ButtonColors {
617
- primary: string;
618
- primaryText: string;
619
- muted: string;
620
- pressed: string;
621
- }
622
-
624
+ /**
625
+ * A filled button: a white label on the primary fill, and while it cannot be
626
+ * pressed (nothing to send yet, or a request running) a muted label on a
627
+ * quiet slate ground, as SparkVault's app draws its own. While its own
628
+ * request runs a spinner takes the label's place, and VoiceOver still hears
629
+ * the label, and that it is busy.
630
+ */
623
631
  function PrimaryButton({
624
632
  label,
625
633
  colors,
@@ -628,47 +636,110 @@ function PrimaryButton({
628
636
  onPress,
629
637
  }: {
630
638
  label: string;
631
- colors: ButtonColors;
639
+ colors: DialogColors;
632
640
  disabled?: boolean;
633
641
  loading?: boolean;
634
642
  onPress(): void;
635
643
  }) {
644
+ const ink = disabled ? colors.muted : colors.buttonText;
636
645
  return (
637
646
  <Pressable
638
647
  accessibilityRole="button"
648
+ accessibilityLabel={label}
649
+ accessibilityState={{ busy: loading }}
639
650
  onPress={onPress}
640
651
  disabled={disabled}
641
652
  style={({ pressed }) => [
642
653
  styles.primaryButton,
643
654
  {
644
- backgroundColor: disabled ? colors.muted : colors.primary,
655
+ backgroundColor: disabled ? colors.border : colors.buttonPrimary,
645
656
  opacity: pressed && !disabled ? 0.9 : 1,
646
657
  },
647
658
  ]}
648
659
  >
649
660
  {loading ? (
650
- <ActivityIndicator color={colors.primaryText} />
661
+ <ActivityIndicator color={ink} />
651
662
  ) : (
652
- <Text style={[styles.primaryButtonText, { color: colors.primaryText }]}>{label}</Text>
663
+ <Text style={[styles.primaryButtonText, { color: ink }]}>{label}</Text>
653
664
  )}
654
665
  </Pressable>
655
666
  );
656
667
  }
657
668
 
669
+ /** A link-styled button, spinning in its label's place while its own request runs, as PrimaryButton does. */
658
670
  function TextButton({
659
671
  label,
660
672
  colors,
661
673
  disabled,
674
+ loading,
662
675
  onPress,
663
676
  }: {
664
677
  label: string;
665
- colors: ButtonColors;
678
+ colors: DialogColors;
666
679
  disabled?: boolean;
680
+ loading?: boolean;
667
681
  onPress(): void;
668
682
  }) {
683
+ const ink = disabled ? colors.muted : colors.primary;
669
684
  return (
670
- <Pressable accessibilityRole="button" onPress={onPress} disabled={disabled} style={styles.textButton}>
671
- <Text style={[styles.textButtonLabel, { color: disabled ? colors.muted : colors.primary }]}>{label}</Text>
685
+ <Pressable
686
+ accessibilityRole="button"
687
+ accessibilityLabel={label}
688
+ accessibilityState={{ busy: loading }}
689
+ onPress={onPress}
690
+ disabled={disabled}
691
+ style={styles.textButton}
692
+ >
693
+ {loading ? (
694
+ <ActivityIndicator color={ink} />
695
+ ) : (
696
+ <Text style={[styles.textButtonLabel, { color: ink }]}>{label}</Text>
697
+ )}
698
+ </Pressable>
699
+ );
700
+ }
701
+
702
+ /**
703
+ * One way to get the code, on the choice a phone number with several gets:
704
+ * its name, and beneath it how the code comes. While its own code is sent a
705
+ * spinner stands at its end, and VoiceOver still hears its name, and that it
706
+ * is busy, as PrimaryButton does.
707
+ */
708
+ function MethodChoice({
709
+ method,
710
+ colors,
711
+ disabled,
712
+ loading,
713
+ onPress,
714
+ }: {
715
+ method: SupportedMethodId;
716
+ colors: DialogColors;
717
+ disabled: boolean;
718
+ loading: boolean;
719
+ onPress(): void;
720
+ }) {
721
+ return (
722
+ <Pressable
723
+ accessibilityRole="button"
724
+ accessibilityLabel={methodTitle(method)}
725
+ accessibilityHint={methodDescription(method)}
726
+ accessibilityState={{ busy: loading }}
727
+ onPress={onPress}
728
+ disabled={disabled}
729
+ style={({ pressed }) => [
730
+ styles.methodButton,
731
+ {
732
+ borderColor: colors.border,
733
+ backgroundColor: pressed ? colors.pressed : colors.input,
734
+ opacity: disabled ? 0.6 : 1,
735
+ },
736
+ ]}
737
+ >
738
+ <View style={styles.methodText}>
739
+ <Text style={[styles.methodTitle, { color: colors.text }]}>{methodTitle(method)}</Text>
740
+ <Text style={[styles.methodDescription, { color: colors.muted }]}>{methodDescription(method)}</Text>
741
+ </View>
742
+ {loading ? <ActivityIndicator color={colors.primary} /> : null}
672
743
  </Pressable>
673
744
  );
674
745
  }
@@ -680,7 +751,7 @@ function TextButton({
680
751
  * A device that cannot open the browser is told where the terms are, beneath
681
752
  * the line in its muted ink: the failure is the link's, never the field's.
682
753
  */
683
- function SmsConsent({ colors }: { colors: ButtonColors }) {
754
+ function SmsConsent({ colors }: { colors: DialogColors }) {
684
755
  const [termsUnopened, setTermsUnopened] = useState(false);
685
756
  const openTerms = () => {
686
757
  Linking.openURL(TERMS_URL).then(() => setTermsUnopened(false), () => setTermsUnopened(true));
@@ -796,34 +867,68 @@ function asError(value: unknown, fallback = 'Something went wrong'): Error {
796
867
  return new Error(fallback);
797
868
  }
798
869
 
799
- const lightColors = {
800
- backdrop: 'rgba(15, 23, 42, 0.42)',
801
- card: '#ffffff',
802
- input: '#ffffff',
803
- pressed: '#f8fafc',
804
- text: '#0f172a',
805
- muted: '#64748b',
806
- placeholder: '#94a3b8',
807
- border: '#e2e8f0',
808
- primary: '#2563eb',
809
- primaryText: '#ffffff',
810
- primarySoft: '#dbeafe',
811
- error: '#dc2626',
870
+ interface DialogColors {
871
+ /** The scrim around the card. */
872
+ backdrop: string;
873
+ card: string;
874
+ /**
875
+ * A field's and a choice row's ground, and pressed, a row's ground under a
876
+ * finger: the app's own field ground and pressed tier, so they stand off
877
+ * the card as the app's do.
878
+ */
879
+ input: string;
880
+ pressed: string;
881
+ text: string;
882
+ /** Secondary copy, and a field's placeholder: AA on the card and on a field. */
883
+ muted: string;
884
+ border: string;
885
+ /**
886
+ * Action Blue as text and glyphs: links, text buttons, the spinner, the
887
+ * lettermark. Never a fill under white text: that is buttonPrimary.
888
+ */
889
+ primary: string;
890
+ /** The lettermark's ground, under primary. */
891
+ primarySoft: string;
892
+ /** A filled button's ground, under buttonText. */
893
+ buttonPrimary: string;
894
+ buttonText: string;
895
+ error: string;
896
+ }
897
+
898
+ const lightColors: DialogColors = {
899
+ backdrop: DS.modalOverlay,
900
+ card: DS.white,
901
+ input: DS.white,
902
+ pressed: DS.slate200,
903
+ text: DS.slate900,
904
+ // 4.76:1 on the card and a field.
905
+ muted: DS.slate500,
906
+ border: DS.slate200,
907
+ primary: DS.action,
908
+ // Action Blue on it measures 4.50:1.
909
+ primarySoft: DS.actionBg,
910
+ buttonPrimary: DS.btnPrimary,
911
+ buttonText: DS.white,
912
+ error: DS.error,
812
913
  };
813
914
 
814
- const darkColors = {
815
- backdrop: 'rgba(2, 6, 23, 0.72)',
816
- card: '#0f172a',
817
- input: '#111827',
818
- pressed: '#1e293b',
819
- text: '#f8fafc',
820
- muted: '#94a3b8',
821
- placeholder: '#64748b',
822
- border: '#334155',
823
- primary: '#60a5fa',
824
- primaryText: '#0f172a',
825
- primarySoft: '#172554',
826
- error: '#f87171',
915
+ const darkColors: DialogColors = {
916
+ // Black at 70%, the web identity dialog's dark scrim: the slate card
917
+ // stands off a dark host behind it.
918
+ backdrop: 'rgba(0, 0, 0, 0.7)',
919
+ card: DS.slate900,
920
+ input: DS.slate800,
921
+ pressed: DS.slate700,
922
+ text: DS.slate50,
923
+ // 6.96:1 on the card, 5.71:1 on a field.
924
+ muted: DS.slate400,
925
+ border: DS.slate700,
926
+ primary: DARK_TEXT.action,
927
+ primarySoft: DS.slate800,
928
+ // Action Blue itself, not its dark text tier: white on it measures 4.97:1.
929
+ buttonPrimary: DS.action,
930
+ buttonText: DS.white,
931
+ error: DARK_TEXT.error,
827
932
  };
828
933
 
829
934
  const styles = StyleSheet.create({
@@ -842,9 +947,10 @@ const styles = StyleSheet.create({
842
947
  width: '100%',
843
948
  maxWidth: 420,
844
949
  alignSelf: 'center',
845
- shadowColor: '#000000',
846
- shadowOffset: { width: 0, height: 16 },
847
- shadowOpacity: 0.18,
950
+ // The design system's popover shadow (--shadow-popover).
951
+ shadowColor: DS.slate900,
952
+ shadowOffset: { width: 0, height: 8 },
953
+ shadowOpacity: 0.12,
848
954
  shadowRadius: 24,
849
955
  elevation: 12,
850
956
  },
@@ -943,6 +1049,8 @@ const styles = StyleSheet.create({
943
1049
  countdown: {
944
1050
  fontSize: 13,
945
1051
  textAlign: 'center',
1052
+ // Ticks each second: tabular figures hold the centered line still.
1053
+ fontVariant: ['tabular-nums'],
946
1054
  },
947
1055
  error: {
948
1056
  fontSize: 13,
@@ -979,10 +1087,16 @@ const styles = StyleSheet.create({
979
1087
  gap: 10,
980
1088
  },
981
1089
  methodButton: {
1090
+ flexDirection: 'row',
1091
+ alignItems: 'center',
1092
+ gap: 12,
982
1093
  borderWidth: 1,
983
1094
  borderRadius: 8,
984
1095
  padding: 14,
985
1096
  },
1097
+ methodText: {
1098
+ flex: 1,
1099
+ },
986
1100
  methodTitle: {
987
1101
  fontSize: 15,
988
1102
  fontWeight: '800',
package/src/index.ts CHANGED
@@ -70,6 +70,7 @@ export type {
70
70
  ListSparksResponse,
71
71
  ShareSparkOptions,
72
72
  Spark,
73
+ SparkLinkActionOptions,
73
74
  SparkResponse,
74
75
  } from './sparks.js';
75
76
  export {