@sparkvault/sdk-mobile 5.3.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -35
- package/dist/errors.d.ts +11 -3
- package/dist/errors.js +7 -3
- package/dist/errors.js.map +1 -1
- package/dist/identity-dialog.d.ts +2 -7
- package/dist/identity-dialog.js +62 -133
- package/dist/identity-dialog.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ingots.d.ts +6 -0
- package/dist/ingots.js +8 -3
- package/dist/ingots.js.map +1 -1
- package/dist/tus.d.ts +21 -10
- package/dist/tus.js +97 -100
- package/dist/tus.js.map +1 -1
- package/dist/types.d.ts +17 -6
- package/package.json +1 -1
- package/src/errors.ts +11 -6
- package/src/identity-dialog.tsx +89 -181
- package/src/index.ts +1 -0
- package/src/ingots.ts +9 -4
- package/src/tus.ts +176 -126
- package/src/types.ts +17 -6
package/src/identity-dialog.tsx
CHANGED
|
@@ -19,31 +19,30 @@ import type {
|
|
|
19
19
|
IdentityMethodId,
|
|
20
20
|
IdentityType,
|
|
21
21
|
IdentityVerifyResult,
|
|
22
|
-
PasskeyAuthOptions,
|
|
23
|
-
PasskeyCredential,
|
|
24
22
|
} from './types.js';
|
|
25
23
|
|
|
26
|
-
type DialogStep = 'loading' | 'identity' | 'methods' | '
|
|
24
|
+
type DialogStep = 'loading' | 'identity' | 'methods' | 'otp' | 'error';
|
|
27
25
|
type OtpMethod = 'email' | 'sms' | 'voice';
|
|
28
|
-
type SupportedMethodId = '
|
|
29
|
-
|
|
30
|
-
export interface MobilePasskeyProvider {
|
|
31
|
-
isSupported(): boolean | Promise<boolean>;
|
|
32
|
-
authenticate(options: PasskeyAuthOptions): Promise<PasskeyCredential | null>;
|
|
33
|
-
}
|
|
26
|
+
type SupportedMethodId = 'otp_email' | 'otp_sms' | 'otp_voice';
|
|
34
27
|
|
|
35
28
|
export interface SparkVaultIdentityDialogProps {
|
|
36
29
|
client: SparkVaultMobile;
|
|
37
30
|
visible: boolean;
|
|
38
31
|
initialIdentity?: string;
|
|
39
32
|
initialIdentityType?: IdentityType;
|
|
40
|
-
passkeyProvider?: MobilePasskeyProvider;
|
|
41
33
|
onSuccess(result: IdentityVerifyResult & { jwks: IdentityJwks }): void | Promise<void>;
|
|
42
34
|
onCancel(): void;
|
|
43
35
|
onError?(error: Error): void;
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Sign-in here is one-time code only. Passkeys are an Identity Product method
|
|
40
|
+
* on the web, but the native ceremony does not work in the mobile app, so the
|
|
41
|
+
* dialog never offers one: a tenant with `passkey` enabled server-side simply
|
|
42
|
+
* sees the code methods. `products.identity` still exposes the passkey APIs
|
|
43
|
+
* for a host that drives the ceremony itself.
|
|
44
|
+
*/
|
|
45
|
+
const SUPPORTED_METHODS = new Set<IdentityMethodId>(['otp_email', 'otp_sms', 'otp_voice']);
|
|
47
46
|
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
48
47
|
const E164_PHONE_REGEX = /^\+[1-9]\d{7,14}$/;
|
|
49
48
|
|
|
@@ -52,7 +51,6 @@ export function SparkVaultIdentityDialog({
|
|
|
52
51
|
visible,
|
|
53
52
|
initialIdentity,
|
|
54
53
|
initialIdentityType,
|
|
55
|
-
passkeyProvider,
|
|
56
54
|
onSuccess,
|
|
57
55
|
onCancel,
|
|
58
56
|
onError,
|
|
@@ -68,6 +66,10 @@ export function SparkVaultIdentityDialog({
|
|
|
68
66
|
const [countdown, setCountdown] = useState('');
|
|
69
67
|
const [isBusy, setIsBusy] = useState(false);
|
|
70
68
|
const [error, setError] = useState('');
|
|
69
|
+
/** The branding logo's own proportions, once the image has reported them. */
|
|
70
|
+
const [measuredLogo, setMeasuredLogo] = useState<{ uri: string; aspectRatio: number } | null>(null);
|
|
71
|
+
/** A branding logo that failed to load, so the header falls back to the name. */
|
|
72
|
+
const [brokenLogoUri, setBrokenLogoUri] = useState<string | null>(null);
|
|
71
73
|
const sessionRef = useRef(0);
|
|
72
74
|
const onSuccessRef = useRef(onSuccess);
|
|
73
75
|
const onCancelRef = useRef(onCancel);
|
|
@@ -77,15 +79,10 @@ export function SparkVaultIdentityDialog({
|
|
|
77
79
|
const effectiveTheme = branding?.themeMode ?? 'light';
|
|
78
80
|
const colors = effectiveTheme === 'dark' ? darkColors : lightColors;
|
|
79
81
|
const allowedTypes = useMemo(() => normalizeAllowedTypes(config), [config]);
|
|
80
|
-
const
|
|
81
|
-
() => getMethodsForIdentity(config, identityType
|
|
82
|
-
[config, identityType
|
|
83
|
-
);
|
|
84
|
-
const methodsWithoutIdentity = useMemo(
|
|
85
|
-
() => getMethodsWithoutIdentity(config, passkeyProvider),
|
|
86
|
-
[config, passkeyProvider]
|
|
82
|
+
const visibleMethods = useMemo(
|
|
83
|
+
() => getMethodsForIdentity(config, identityType),
|
|
84
|
+
[config, identityType]
|
|
87
85
|
);
|
|
88
|
-
const visibleMethods = allowedTypes.length > 0 ? methodsForIdentity : methodsWithoutIdentity;
|
|
89
86
|
|
|
90
87
|
useEffect(() => {
|
|
91
88
|
onSuccessRef.current = onSuccess;
|
|
@@ -108,6 +105,7 @@ export function SparkVaultIdentityDialog({
|
|
|
108
105
|
setKindling(null);
|
|
109
106
|
setExpiresAt(null);
|
|
110
107
|
setSelectedMethod(null);
|
|
108
|
+
setBrokenLogoUri(null);
|
|
111
109
|
setIdentity(initialIdentity ?? '');
|
|
112
110
|
setIdentityType(initialIdentityType ?? 'email');
|
|
113
111
|
|
|
@@ -119,8 +117,6 @@ export function SparkVaultIdentityDialog({
|
|
|
119
117
|
setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
|
|
120
118
|
if (nextAllowedTypes.length > 0) {
|
|
121
119
|
setStep('identity');
|
|
122
|
-
} else if (getMethodsWithoutIdentity(nextConfig, passkeyProvider).length > 0) {
|
|
123
|
-
setStep('methods');
|
|
124
120
|
} else {
|
|
125
121
|
setError('No supported sign-in methods are enabled for this app.');
|
|
126
122
|
setStep('error');
|
|
@@ -137,7 +133,7 @@ export function SparkVaultIdentityDialog({
|
|
|
137
133
|
return () => {
|
|
138
134
|
cancelled = true;
|
|
139
135
|
};
|
|
140
|
-
}, [client, initialIdentity, initialIdentityType,
|
|
136
|
+
}, [client, initialIdentity, initialIdentityType, visible]);
|
|
141
137
|
|
|
142
138
|
useEffect(() => {
|
|
143
139
|
if (!expiresAt || step !== 'otp') {
|
|
@@ -178,9 +174,6 @@ export function SparkVaultIdentityDialog({
|
|
|
178
174
|
targetIdentity = identity,
|
|
179
175
|
targetIdentityType = identityType
|
|
180
176
|
) => {
|
|
181
|
-
const otpMethod = toOtpMethod(method);
|
|
182
|
-
if (!otpMethod) return;
|
|
183
|
-
|
|
184
177
|
const sessionId = sessionRef.current;
|
|
185
178
|
setIsBusy(true);
|
|
186
179
|
setError('');
|
|
@@ -189,7 +182,7 @@ export function SparkVaultIdentityDialog({
|
|
|
189
182
|
const response = await client.products.identity.sendOtp({
|
|
190
183
|
identity: targetIdentity,
|
|
191
184
|
identityType: targetIdentityType,
|
|
192
|
-
method:
|
|
185
|
+
method: toOtpMethod(method),
|
|
193
186
|
});
|
|
194
187
|
if (!isActiveSession(sessionRef, sessionId)) return;
|
|
195
188
|
setKindling(response.kindling);
|
|
@@ -206,45 +199,6 @@ export function SparkVaultIdentityDialog({
|
|
|
206
199
|
}
|
|
207
200
|
}, [client, identity, identityType, reportError]);
|
|
208
201
|
|
|
209
|
-
const runPasskey = useCallback(async () => {
|
|
210
|
-
if (!passkeyProvider) {
|
|
211
|
-
setError('Passkeys are not available in this app.');
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const sessionId = sessionRef.current;
|
|
216
|
-
setIsBusy(true);
|
|
217
|
-
setError('');
|
|
218
|
-
setSelectedMethod('passkey');
|
|
219
|
-
setStep('passkey');
|
|
220
|
-
|
|
221
|
-
try {
|
|
222
|
-
const supported = await passkeyProvider.isSupported();
|
|
223
|
-
if (!supported) {
|
|
224
|
-
throw new Error('Passkeys are not supported on this device.');
|
|
225
|
-
}
|
|
226
|
-
if (!isActiveSession(sessionRef, sessionId)) return;
|
|
227
|
-
|
|
228
|
-
const challenge = await client.products.identity.getPasskeyAuthOptions();
|
|
229
|
-
if (!isActiveSession(sessionRef, sessionId)) return;
|
|
230
|
-
const credential = await passkeyProvider.authenticate(challenge.options);
|
|
231
|
-
if (!isActiveSession(sessionRef, sessionId)) return;
|
|
232
|
-
if (!credential) {
|
|
233
|
-
throw new Error('Passkey authentication was cancelled.');
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const result = await client.products.identity.completePasskeyAuthentication(credential, challenge.session);
|
|
237
|
-
await finishWithToken(result, sessionId);
|
|
238
|
-
} catch (err) {
|
|
239
|
-
if (!isActiveSession(sessionRef, sessionId)) return;
|
|
240
|
-
reportError(err, 'Passkey authentication failed');
|
|
241
|
-
} finally {
|
|
242
|
-
if (isActiveSession(sessionRef, sessionId)) {
|
|
243
|
-
setIsBusy(false);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}, [client, finishWithToken, passkeyProvider, reportError]);
|
|
247
|
-
|
|
248
202
|
const handleIdentitySubmit = useCallback(async () => {
|
|
249
203
|
if (isBusy) return;
|
|
250
204
|
|
|
@@ -256,7 +210,7 @@ export function SparkVaultIdentityDialog({
|
|
|
256
210
|
|
|
257
211
|
const normalizedIdentity = parsed.identity;
|
|
258
212
|
const nextIdentityType = parsed.identityType;
|
|
259
|
-
const availableMethods = getMethodsForIdentity(config, nextIdentityType
|
|
213
|
+
const availableMethods = getMethodsForIdentity(config, nextIdentityType);
|
|
260
214
|
if (availableMethods.length === 0) {
|
|
261
215
|
setError('No supported sign-in methods are enabled for this identity type.');
|
|
262
216
|
return;
|
|
@@ -265,37 +219,16 @@ export function SparkVaultIdentityDialog({
|
|
|
265
219
|
setIdentity(normalizedIdentity);
|
|
266
220
|
setIdentityType(nextIdentityType);
|
|
267
221
|
setError('');
|
|
268
|
-
setIsBusy(true);
|
|
269
|
-
const sessionId = sessionRef.current;
|
|
270
|
-
|
|
271
|
-
try {
|
|
272
|
-
if (availableMethods.length === 1) {
|
|
273
|
-
if (availableMethods[0] === 'passkey') {
|
|
274
|
-
await runPasskey();
|
|
275
|
-
} else {
|
|
276
|
-
await sendOtp(availableMethods[0], normalizedIdentity, nextIdentityType);
|
|
277
|
-
}
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
setStep('methods');
|
|
282
|
-
} catch (err) {
|
|
283
|
-
if (!isActiveSession(sessionRef, sessionId)) return;
|
|
284
|
-
reportError(err, 'Failed to load sign-in methods');
|
|
285
|
-
} finally {
|
|
286
|
-
if (isActiveSession(sessionRef, sessionId)) {
|
|
287
|
-
setIsBusy(false);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}, [allowedTypes, config, identity, isBusy, passkeyProvider, reportError, runPasskey, sendOtp]);
|
|
291
222
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
223
|
+
// One way in: send that code. Several (a phone with both SMS and voice):
|
|
224
|
+
// let the person choose. sendOtp owns the busy flag and its own failures.
|
|
225
|
+
if (availableMethods.length === 1) {
|
|
226
|
+
await sendOtp(availableMethods[0], normalizedIdentity, nextIdentityType);
|
|
295
227
|
return;
|
|
296
228
|
}
|
|
297
|
-
|
|
298
|
-
|
|
229
|
+
|
|
230
|
+
setStep('methods');
|
|
231
|
+
}, [allowedTypes, config, identity, isBusy, sendOtp]);
|
|
299
232
|
|
|
300
233
|
const handleVerifyOtp = useCallback(async () => {
|
|
301
234
|
if (!kindling || pin.length !== 6) return;
|
|
@@ -349,8 +282,6 @@ export function SparkVaultIdentityDialog({
|
|
|
349
282
|
setIdentityType(resolveInitialIdentityType(initialIdentity, initialIdentityType, nextAllowedTypes));
|
|
350
283
|
if (nextAllowedTypes.length > 0) {
|
|
351
284
|
setStep('identity');
|
|
352
|
-
} else if (getMethodsWithoutIdentity(nextConfig, passkeyProvider).length > 0) {
|
|
353
|
-
setStep('methods');
|
|
354
285
|
} else {
|
|
355
286
|
setError('No supported sign-in methods are enabled for this app.');
|
|
356
287
|
setStep('error');
|
|
@@ -366,10 +297,16 @@ export function SparkVaultIdentityDialog({
|
|
|
366
297
|
setIsBusy(false);
|
|
367
298
|
}
|
|
368
299
|
});
|
|
369
|
-
}, [client, initialIdentity, initialIdentityType,
|
|
300
|
+
}, [client, initialIdentity, initialIdentityType, reportError]);
|
|
370
301
|
|
|
371
|
-
const headerLogo = getHeaderLogo(branding, effectiveTheme);
|
|
372
302
|
const companyName = branding?.companyName || 'SparkVault';
|
|
303
|
+
// A logo speaks for the brand on its own, so it replaces the company name
|
|
304
|
+
// rather than sitting beside it, drawn at its own proportions and the full
|
|
305
|
+
// height of the header instead of squeezed into a square. Only a logo that
|
|
306
|
+
// loads earns that: one that fails falls back to the lettermark and name, so
|
|
307
|
+
// the header is never blank.
|
|
308
|
+
const logoUri = resolveLogoUri(branding, effectiveTheme, brokenLogoUri);
|
|
309
|
+
const logoAspectRatio = measuredLogo?.uri === logoUri ? measuredLogo.aspectRatio : null;
|
|
373
310
|
|
|
374
311
|
return (
|
|
375
312
|
<Modal visible={visible} transparent animationType="fade" onRequestClose={handleCancel}>
|
|
@@ -384,16 +321,39 @@ export function SparkVaultIdentityDialog({
|
|
|
384
321
|
<View style={[styles.card, { backgroundColor: colors.card, borderColor: colors.border }]}>
|
|
385
322
|
<View style={styles.header}>
|
|
386
323
|
<View style={styles.brand}>
|
|
387
|
-
{
|
|
388
|
-
<Image
|
|
324
|
+
{logoUri ? (
|
|
325
|
+
<Image
|
|
326
|
+
source={{ uri: logoUri }}
|
|
327
|
+
style={
|
|
328
|
+
logoAspectRatio === null
|
|
329
|
+
? styles.logoUnmeasured
|
|
330
|
+
: [styles.logo, { aspectRatio: logoAspectRatio }]
|
|
331
|
+
}
|
|
332
|
+
resizeMode="contain"
|
|
333
|
+
accessibilityRole="image"
|
|
334
|
+
accessibilityLabel={companyName}
|
|
335
|
+
onLoad={(event) => {
|
|
336
|
+
const { width, height } = event.nativeEvent.source;
|
|
337
|
+
if (width <= 0 || height <= 0) return;
|
|
338
|
+
const aspectRatio = width / height;
|
|
339
|
+
setMeasuredLogo(current => (
|
|
340
|
+
current?.uri === logoUri && current.aspectRatio === aspectRatio
|
|
341
|
+
? current
|
|
342
|
+
: { uri: logoUri, aspectRatio }
|
|
343
|
+
));
|
|
344
|
+
}}
|
|
345
|
+
onError={() => setBrokenLogoUri(logoUri)}
|
|
346
|
+
/>
|
|
389
347
|
) : (
|
|
390
|
-
|
|
391
|
-
<
|
|
392
|
-
{
|
|
393
|
-
|
|
394
|
-
|
|
348
|
+
<>
|
|
349
|
+
<View style={[styles.logoFallback, { backgroundColor: colors.primarySoft }]}>
|
|
350
|
+
<Text style={[styles.logoFallbackText, { color: colors.primary }]}>
|
|
351
|
+
{companyName.slice(0, 1).toUpperCase()}
|
|
352
|
+
</Text>
|
|
353
|
+
</View>
|
|
354
|
+
<Text style={[styles.companyName, { color: colors.text }]}>{companyName}</Text>
|
|
355
|
+
</>
|
|
395
356
|
)}
|
|
396
|
-
<Text style={[styles.companyName, { color: colors.text }]}>{companyName}</Text>
|
|
397
357
|
</View>
|
|
398
358
|
<Pressable
|
|
399
359
|
accessibilityRole="button"
|
|
@@ -464,7 +424,7 @@ export function SparkVaultIdentityDialog({
|
|
|
464
424
|
<Pressable
|
|
465
425
|
key={method}
|
|
466
426
|
accessibilityRole="button"
|
|
467
|
-
onPress={() =>
|
|
427
|
+
onPress={() => sendOtp(method)}
|
|
468
428
|
disabled={isBusy}
|
|
469
429
|
style={({ pressed }) => [
|
|
470
430
|
styles.methodButton,
|
|
@@ -489,35 +449,6 @@ export function SparkVaultIdentityDialog({
|
|
|
489
449
|
</View>
|
|
490
450
|
)}
|
|
491
451
|
|
|
492
|
-
{step === 'passkey' && (
|
|
493
|
-
<View style={styles.body}>
|
|
494
|
-
<Text style={[styles.title, { color: colors.text }]}>Use your passkey</Text>
|
|
495
|
-
<Text style={[styles.subtitle, { color: colors.muted }]}>
|
|
496
|
-
Confirm this sign-in with your device passkey.
|
|
497
|
-
</Text>
|
|
498
|
-
<View style={[styles.passkeyIcon, { backgroundColor: colors.primarySoft }]}>
|
|
499
|
-
<Text style={styles.passkeyIconText}>🔑</Text>
|
|
500
|
-
</View>
|
|
501
|
-
{isBusy ? <ActivityIndicator color={colors.primary} /> : null}
|
|
502
|
-
{error ? <Text style={[styles.error, { color: colors.error }]}>{error}</Text> : null}
|
|
503
|
-
<PrimaryButton
|
|
504
|
-
label="Try Again"
|
|
505
|
-
colors={colors}
|
|
506
|
-
disabled={isBusy}
|
|
507
|
-
loading={isBusy}
|
|
508
|
-
onPress={runPasskey}
|
|
509
|
-
/>
|
|
510
|
-
{allowedTypes.length > 0 && fallbackOtpMethod(methodsForIdentity) ? (
|
|
511
|
-
<TextButton
|
|
512
|
-
label={fallbackLabel(fallbackOtpMethod(methodsForIdentity)!)}
|
|
513
|
-
colors={colors}
|
|
514
|
-
onPress={() => sendOtp(fallbackOtpMethod(methodsForIdentity)!)}
|
|
515
|
-
disabled={isBusy}
|
|
516
|
-
/>
|
|
517
|
-
) : null}
|
|
518
|
-
</View>
|
|
519
|
-
)}
|
|
520
|
-
|
|
521
452
|
{step === 'otp' && (
|
|
522
453
|
<View style={styles.body}>
|
|
523
454
|
<Text style={[styles.title, { color: colors.text }]}>{otpTitle(selectedMethod)}</Text>
|
|
@@ -662,28 +593,16 @@ function resolveInitialIdentityType(
|
|
|
662
593
|
|
|
663
594
|
function getMethodsForIdentity(
|
|
664
595
|
config: IdentityConfig | null,
|
|
665
|
-
identityType: IdentityType
|
|
666
|
-
passkeyProvider?: MobilePasskeyProvider
|
|
596
|
+
identityType: IdentityType
|
|
667
597
|
): SupportedMethodId[] {
|
|
668
598
|
const configuredMethods = config?.methods ?? ['otp_email'];
|
|
669
599
|
return configuredMethods.filter((method): method is SupportedMethodId => {
|
|
670
600
|
if (!SUPPORTED_METHODS.has(method)) return false;
|
|
671
|
-
if (method === 'passkey') return Boolean(passkeyProvider);
|
|
672
601
|
if (method === 'otp_email') return identityType === 'email';
|
|
673
602
|
return identityType === 'phone';
|
|
674
603
|
});
|
|
675
604
|
}
|
|
676
605
|
|
|
677
|
-
function getMethodsWithoutIdentity(
|
|
678
|
-
config: IdentityConfig | null,
|
|
679
|
-
passkeyProvider?: MobilePasskeyProvider
|
|
680
|
-
): SupportedMethodId[] {
|
|
681
|
-
const configuredMethods = config?.methods ?? [];
|
|
682
|
-
return configuredMethods.filter((method): method is SupportedMethodId => (
|
|
683
|
-
method === 'passkey' && Boolean(passkeyProvider)
|
|
684
|
-
));
|
|
685
|
-
}
|
|
686
|
-
|
|
687
606
|
function parseIdentity(
|
|
688
607
|
value: string,
|
|
689
608
|
allowedTypes: IdentityType[]
|
|
@@ -716,32 +635,19 @@ function parseIdentity(
|
|
|
716
635
|
return { ok: true, identity: phone, identityType: 'phone' };
|
|
717
636
|
}
|
|
718
637
|
|
|
719
|
-
function toOtpMethod(method: SupportedMethodId): OtpMethod
|
|
720
|
-
if (method === 'otp_email') return 'email';
|
|
638
|
+
function toOtpMethod(method: SupportedMethodId): OtpMethod {
|
|
721
639
|
if (method === 'otp_sms') return 'sms';
|
|
722
640
|
if (method === 'otp_voice') return 'voice';
|
|
723
|
-
return
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
function fallbackOtpMethod(methods: SupportedMethodId[]): SupportedMethodId | null {
|
|
727
|
-
return methods.find((method) => method !== 'passkey') ?? null;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function fallbackLabel(method: SupportedMethodId): string {
|
|
731
|
-
if (method === 'otp_sms') return 'Use SMS code instead';
|
|
732
|
-
if (method === 'otp_voice') return 'Use voice call instead';
|
|
733
|
-
return 'Use email code instead';
|
|
641
|
+
return 'email';
|
|
734
642
|
}
|
|
735
643
|
|
|
736
644
|
function methodTitle(method: SupportedMethodId): string {
|
|
737
|
-
if (method === 'passkey') return 'Passkey';
|
|
738
645
|
if (method === 'otp_sms') return 'Text message';
|
|
739
646
|
if (method === 'otp_voice') return 'Voice call';
|
|
740
647
|
return 'Email code';
|
|
741
648
|
}
|
|
742
649
|
|
|
743
650
|
function methodDescription(method: SupportedMethodId): string {
|
|
744
|
-
if (method === 'passkey') return 'Use Face ID, Touch ID, or your device passcode.';
|
|
745
651
|
if (method === 'otp_sms') return 'Receive a one-time code by SMS.';
|
|
746
652
|
if (method === 'otp_voice') return 'Receive a one-time code by phone call.';
|
|
747
653
|
return 'Receive a one-time code by email.';
|
|
@@ -765,11 +671,16 @@ function otpTitle(method: SupportedMethodId | null): string {
|
|
|
765
671
|
return 'Check your email';
|
|
766
672
|
}
|
|
767
673
|
|
|
768
|
-
function
|
|
674
|
+
function resolveLogoUri(
|
|
675
|
+
branding: IdentityConfig['branding'],
|
|
676
|
+
theme: 'light' | 'dark',
|
|
677
|
+
brokenLogoUri: string | null
|
|
678
|
+
): string | null {
|
|
769
679
|
if (!branding) return null;
|
|
770
|
-
|
|
680
|
+
const uri = theme === 'dark'
|
|
771
681
|
? branding.logoDark || branding.logoLight
|
|
772
682
|
: branding.logoLight || branding.logoDark;
|
|
683
|
+
return uri && uri !== brokenLogoUri ? uri : null;
|
|
773
684
|
}
|
|
774
685
|
|
|
775
686
|
function formatCountdown(seconds: number): string {
|
|
@@ -850,9 +761,17 @@ const styles = StyleSheet.create({
|
|
|
850
761
|
alignItems: 'center',
|
|
851
762
|
},
|
|
852
763
|
logo: {
|
|
853
|
-
width
|
|
854
|
-
|
|
855
|
-
|
|
764
|
+
// Height is the header's; width follows the logo's own aspect ratio,
|
|
765
|
+
// bounded by the space left beside the close button.
|
|
766
|
+
height: 40,
|
|
767
|
+
maxWidth: '100%',
|
|
768
|
+
},
|
|
769
|
+
logoUnmeasured: {
|
|
770
|
+
// Before the image reports its shape. A square, not a zero-width box: iOS
|
|
771
|
+
// only loads an image into a non-zero frame, and a box with no width would
|
|
772
|
+
// leave the header permanently empty.
|
|
773
|
+
height: 40,
|
|
774
|
+
width: 40,
|
|
856
775
|
},
|
|
857
776
|
logoFallback: {
|
|
858
777
|
width: 32,
|
|
@@ -965,15 +884,4 @@ const styles = StyleSheet.create({
|
|
|
965
884
|
fontSize: 13,
|
|
966
885
|
lineHeight: 18,
|
|
967
886
|
},
|
|
968
|
-
passkeyIcon: {
|
|
969
|
-
width: 76,
|
|
970
|
-
height: 76,
|
|
971
|
-
borderRadius: 38,
|
|
972
|
-
alignSelf: 'center',
|
|
973
|
-
alignItems: 'center',
|
|
974
|
-
justifyContent: 'center',
|
|
975
|
-
},
|
|
976
|
-
passkeyIconText: {
|
|
977
|
-
fontSize: 34,
|
|
978
|
-
},
|
|
979
887
|
});
|
package/src/index.ts
CHANGED
package/src/ingots.ts
CHANGED
|
@@ -907,11 +907,16 @@ export class MobileIngotsClient {
|
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
909
|
|
|
910
|
+
/**
|
|
911
|
+
* The two typed cancel signals: the adapter's contract (an Error named
|
|
912
|
+
* `AbortError`, see `MobileFileDownloader`) and the SDK's own pre-flight
|
|
913
|
+
* cancellation. Message text is never consulted: a transport failure that
|
|
914
|
+
* merely mentions an abort is retried, not reported as the user's cancel.
|
|
915
|
+
*/
|
|
910
916
|
private isAbortError(err: unknown): boolean {
|
|
911
|
-
return
|
|
912
|
-
err.name === 'AbortError' ||
|
|
913
|
-
err.
|
|
914
|
-
err.message.toLowerCase().includes('cancelled')
|
|
917
|
+
return (
|
|
918
|
+
(err instanceof Error && err.name === 'AbortError') ||
|
|
919
|
+
(err instanceof SparkVaultMobileError && err.code === 'download_cancelled')
|
|
915
920
|
);
|
|
916
921
|
}
|
|
917
922
|
|