@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/README.md
CHANGED
|
@@ -63,7 +63,6 @@ The SDK depends on `tweetnacl` for Ed25519 Identity JWT verification and declare
|
|
|
63
63
|
| `fetch` | No | Falls back to `globalThis.fetch`; throws if neither exists |
|
|
64
64
|
| `fileReader` | Only for `ingots.uploadFromUri` | Throws on first upload-from-URI call |
|
|
65
65
|
| `fileDownloader` | Only for `ingots.downloadToFile` | Throws on first file-download call |
|
|
66
|
-
| `passkeyProvider` | Only for passkey sign-in UI | Passkey is hidden from the Identity dialog |
|
|
67
66
|
| `logger` | No | No-op logger |
|
|
68
67
|
|
|
69
68
|
## Modules
|
|
@@ -81,46 +80,16 @@ The SDK depends on `tweetnacl` for Ed25519 Identity JWT verification and declare
|
|
|
81
80
|
|
|
82
81
|
## Identity Dialog
|
|
83
82
|
|
|
84
|
-
`SparkVaultIdentityDialog` is the mobile equivalent of the web SDK Identity popup. It fetches Identity Product config, derives email/phone input from enabled delivery methods, offers enabled
|
|
83
|
+
`SparkVaultIdentityDialog` is the mobile equivalent of the web SDK Identity popup. It fetches Identity Product config, derives email/phone input from enabled delivery methods, offers the enabled one-time-code methods (`otp_email`, `otp_sms`, `otp_voice`), applies configured branding and light/dark mode, and returns the raw signed Identity JWT plus JWKS metadata. Configured branding drives the header: a logo replaces the company name and is drawn at its own proportions; without one (or if it fails to load) the header shows the company lettermark and name.
|
|
84
|
+
|
|
85
|
+
Sign-in is code-only. The native passkey ceremony does not work in the mobile app, so the dialog never offers `passkey` even when the tenant has it enabled; `products.identity` still exposes the passkey APIs for a host that drives the ceremony itself.
|
|
85
86
|
|
|
86
87
|
```tsx
|
|
87
|
-
import
|
|
88
|
-
import {
|
|
89
|
-
SparkVaultIdentityDialog,
|
|
90
|
-
type MobilePasskeyProvider,
|
|
91
|
-
} from '@sparkvault/sdk-mobile/identity-dialog';
|
|
92
|
-
|
|
93
|
-
const passkeyProvider: MobilePasskeyProvider = {
|
|
94
|
-
isSupported: () => Passkey.isSupported(),
|
|
95
|
-
authenticate: async (options) => {
|
|
96
|
-
const credential = await Passkey.get({
|
|
97
|
-
challenge: options.challenge,
|
|
98
|
-
timeout: options.timeout,
|
|
99
|
-
rpId: options.rpId,
|
|
100
|
-
userVerification: options.userVerification,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
return credential
|
|
104
|
-
? {
|
|
105
|
-
id: credential.id,
|
|
106
|
-
rawId: credential.rawId,
|
|
107
|
-
type: 'public-key',
|
|
108
|
-
response: {
|
|
109
|
-
clientDataJSON: credential.response.clientDataJSON,
|
|
110
|
-
authenticatorData: credential.response.authenticatorData,
|
|
111
|
-
signature: credential.response.signature,
|
|
112
|
-
// Required: the server resolves the SVID from the userHandle.
|
|
113
|
-
userHandle: credential.response.userHandle,
|
|
114
|
-
},
|
|
115
|
-
}
|
|
116
|
-
: null;
|
|
117
|
-
},
|
|
118
|
-
};
|
|
88
|
+
import { SparkVaultIdentityDialog } from '@sparkvault/sdk-mobile/identity-dialog';
|
|
119
89
|
|
|
120
90
|
<SparkVaultIdentityDialog
|
|
121
91
|
client={sparkVault}
|
|
122
92
|
visible={visible}
|
|
123
|
-
passkeyProvider={passkeyProvider}
|
|
124
93
|
onCancel={() => setVisible(false)}
|
|
125
94
|
onSuccess={async (result) => {
|
|
126
95
|
await sparkVault.products.identity.verifyIdentityToken(result.token, { jwks: result.jwks });
|
package/dist/errors.d.ts
CHANGED
|
@@ -70,9 +70,10 @@ export declare class TusUploadError extends SparkVaultMobileError {
|
|
|
70
70
|
readonly fileSize: number | null;
|
|
71
71
|
readonly phase: 'create' | 'upload' | 'network' | 'timeout' | 'cancelled' | 'stalled' | 'unknown';
|
|
72
72
|
/**
|
|
73
|
-
* True when Forge no longer has the session
|
|
74
|
-
*
|
|
75
|
-
*
|
|
73
|
+
* True when Forge no longer has the session (it answered a status
|
|
74
|
+
* `isSessionGone` recognises: expired or terminated), or the session
|
|
75
|
+
* cannot carry this file. The persisted session is worthless, so the
|
|
76
|
+
* caller starts a fresh upload instead of retrying it.
|
|
76
77
|
*/
|
|
77
78
|
readonly sessionLost: boolean;
|
|
78
79
|
constructor(message: string, options?: {
|
|
@@ -83,6 +84,13 @@ export declare class TusUploadError extends SparkVaultMobileError {
|
|
|
83
84
|
phase?: TusUploadError['phase'];
|
|
84
85
|
sessionLost?: boolean;
|
|
85
86
|
});
|
|
87
|
+
/**
|
|
88
|
+
* Wrap an error the SDK did not produce (a `fileReader` read, an
|
|
89
|
+
* `onSessionCreated` hook) so every upload failure is a `TusUploadError`.
|
|
90
|
+
* Carries no HTTP status: none was received, and a status is something
|
|
91
|
+
* callers act on (a lost session, a rejected key), so it is only ever set
|
|
92
|
+
* by the request that actually saw it.
|
|
93
|
+
*/
|
|
86
94
|
static fromError(error: Error, context: {
|
|
87
95
|
filename?: string;
|
|
88
96
|
fileSize?: number;
|
package/dist/errors.js
CHANGED
|
@@ -110,12 +110,16 @@ export class TusUploadError extends SparkVaultMobileError {
|
|
|
110
110
|
this.sessionLost = options.sessionLost ?? false;
|
|
111
111
|
Object.setPrototypeOf(this, TusUploadError.prototype);
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Wrap an error the SDK did not produce (a `fileReader` read, an
|
|
115
|
+
* `onSessionCreated` hook) so every upload failure is a `TusUploadError`.
|
|
116
|
+
* Carries no HTTP status: none was received, and a status is something
|
|
117
|
+
* callers act on (a lost session, a rejected key), so it is only ever set
|
|
118
|
+
* by the request that actually saw it.
|
|
119
|
+
*/
|
|
113
120
|
static fromError(error, context) {
|
|
114
|
-
const statusMatch = error.message.match(/(\d{3})/);
|
|
115
|
-
const httpStatus = statusMatch ? parseInt(statusMatch[1], 10) : null;
|
|
116
121
|
return new TusUploadError(error.message, {
|
|
117
122
|
cause: error,
|
|
118
|
-
httpStatus,
|
|
119
123
|
filename: context.filename,
|
|
120
124
|
fileSize: context.fileSize,
|
|
121
125
|
phase: context.phase ?? 'unknown',
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAMA,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,CAAC;AACtD,CAAC;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAM9C,YACE,OAAe,EACf,UAKI,EAAE;QAEN,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,kBAAkB,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/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obilePasskeyProvider {
|
|
4
|
-
isSupported(): boolean | Promise<boolean>;
|
|
5
|
-
authenticate(options: PasskeyAuthOptions): Promise<PasskeyCredential | null>;
|
|
6
|
-
}
|
|
2
|
+
import type { IdentityJwks, IdentityType, IdentityVerifyResult } from './types.js';
|
|
7
3
|
export interface SparkVaultIdentityDialogProps {
|
|
8
4
|
client: SparkVaultMobile;
|
|
9
5
|
visible: boolean;
|
|
10
6
|
initialIdentity?: string;
|
|
11
7
|
initialIdentityType?: IdentityType;
|
|
12
|
-
passkeyProvider?: MobilePasskeyProvider;
|
|
13
8
|
onSuccess(result: IdentityVerifyResult & {
|
|
14
9
|
jwks: IdentityJwks;
|
|
15
10
|
}): void | Promise<void>;
|
|
16
11
|
onCancel(): void;
|
|
17
12
|
onError?(error: Error): void;
|
|
18
13
|
}
|
|
19
|
-
export declare function SparkVaultIdentityDialog({ client, visible, initialIdentity, initialIdentityType,
|
|
14
|
+
export declare function SparkVaultIdentityDialog({ client, visible, initialIdentity, initialIdentityType, onSuccess, onCancel, onError, }: SparkVaultIdentityDialogProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/identity-dialog.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
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
3
|
import { ActivityIndicator, Image, KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, View, } from 'react-native';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Sign-in here is one-time code only. Passkeys are an Identity Product method
|
|
6
|
+
* on the web, but the native ceremony does not work in the mobile app, so the
|
|
7
|
+
* dialog never offers one: a tenant with `passkey` enabled server-side simply
|
|
8
|
+
* sees the code methods. `products.identity` still exposes the passkey APIs
|
|
9
|
+
* for a host that drives the ceremony itself.
|
|
10
|
+
*/
|
|
11
|
+
const SUPPORTED_METHODS = new Set(['otp_email', 'otp_sms', 'otp_voice']);
|
|
5
12
|
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
6
13
|
const E164_PHONE_REGEX = /^\+[1-9]\d{7,14}$/;
|
|
7
|
-
export function SparkVaultIdentityDialog({ client, visible, initialIdentity, initialIdentityType,
|
|
14
|
+
export function SparkVaultIdentityDialog({ client, visible, initialIdentity, initialIdentityType, onSuccess, onCancel, onError, }) {
|
|
8
15
|
const [step, setStep] = useState('loading');
|
|
9
16
|
const [config, setConfig] = useState(null);
|
|
10
17
|
const [identity, setIdentity] = useState(initialIdentity ?? '');
|
|
@@ -16,6 +23,10 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
16
23
|
const [countdown, setCountdown] = useState('');
|
|
17
24
|
const [isBusy, setIsBusy] = useState(false);
|
|
18
25
|
const [error, setError] = useState('');
|
|
26
|
+
/** The branding logo's own proportions, once the image has reported them. */
|
|
27
|
+
const [measuredLogo, setMeasuredLogo] = useState(null);
|
|
28
|
+
/** A branding logo that failed to load, so the header falls back to the name. */
|
|
29
|
+
const [brokenLogoUri, setBrokenLogoUri] = useState(null);
|
|
19
30
|
const sessionRef = useRef(0);
|
|
20
31
|
const onSuccessRef = useRef(onSuccess);
|
|
21
32
|
const onCancelRef = useRef(onCancel);
|
|
@@ -24,9 +35,7 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
24
35
|
const effectiveTheme = branding?.themeMode ?? 'light';
|
|
25
36
|
const colors = effectiveTheme === 'dark' ? darkColors : lightColors;
|
|
26
37
|
const allowedTypes = useMemo(() => normalizeAllowedTypes(config), [config]);
|
|
27
|
-
const
|
|
28
|
-
const methodsWithoutIdentity = useMemo(() => getMethodsWithoutIdentity(config, passkeyProvider), [config, passkeyProvider]);
|
|
29
|
-
const visibleMethods = allowedTypes.length > 0 ? methodsForIdentity : methodsWithoutIdentity;
|
|
38
|
+
const visibleMethods = useMemo(() => getMethodsForIdentity(config, identityType), [config, identityType]);
|
|
30
39
|
useEffect(() => {
|
|
31
40
|
onSuccessRef.current = onSuccess;
|
|
32
41
|
onCancelRef.current = onCancel;
|
|
@@ -46,6 +55,7 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
46
55
|
setKindling(null);
|
|
47
56
|
setExpiresAt(null);
|
|
48
57
|
setSelectedMethod(null);
|
|
58
|
+
setBrokenLogoUri(null);
|
|
49
59
|
setIdentity(initialIdentity ?? '');
|
|
50
60
|
setIdentityType(initialIdentityType ?? 'email');
|
|
51
61
|
client.products.identity.getConfig()
|
|
@@ -58,9 +68,6 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
58
68
|
if (nextAllowedTypes.length > 0) {
|
|
59
69
|
setStep('identity');
|
|
60
70
|
}
|
|
61
|
-
else if (getMethodsWithoutIdentity(nextConfig, passkeyProvider).length > 0) {
|
|
62
|
-
setStep('methods');
|
|
63
|
-
}
|
|
64
71
|
else {
|
|
65
72
|
setError('No supported sign-in methods are enabled for this app.');
|
|
66
73
|
setStep('error');
|
|
@@ -77,7 +84,7 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
77
84
|
return () => {
|
|
78
85
|
cancelled = true;
|
|
79
86
|
};
|
|
80
|
-
}, [client, initialIdentity, initialIdentityType,
|
|
87
|
+
}, [client, initialIdentity, initialIdentityType, visible]);
|
|
81
88
|
useEffect(() => {
|
|
82
89
|
if (!expiresAt || step !== 'otp') {
|
|
83
90
|
setCountdown('');
|
|
@@ -108,9 +115,6 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
108
115
|
onCancelRef.current();
|
|
109
116
|
}, []);
|
|
110
117
|
const sendOtp = useCallback(async (method, targetIdentity = identity, targetIdentityType = identityType) => {
|
|
111
|
-
const otpMethod = toOtpMethod(method);
|
|
112
|
-
if (!otpMethod)
|
|
113
|
-
return;
|
|
114
118
|
const sessionId = sessionRef.current;
|
|
115
119
|
setIsBusy(true);
|
|
116
120
|
setError('');
|
|
@@ -119,7 +123,7 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
119
123
|
const response = await client.products.identity.sendOtp({
|
|
120
124
|
identity: targetIdentity,
|
|
121
125
|
identityType: targetIdentityType,
|
|
122
|
-
method:
|
|
126
|
+
method: toOtpMethod(method),
|
|
123
127
|
});
|
|
124
128
|
if (!isActiveSession(sessionRef, sessionId))
|
|
125
129
|
return;
|
|
@@ -139,46 +143,6 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
}, [client, identity, identityType, reportError]);
|
|
142
|
-
const runPasskey = useCallback(async () => {
|
|
143
|
-
if (!passkeyProvider) {
|
|
144
|
-
setError('Passkeys are not available in this app.');
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const sessionId = sessionRef.current;
|
|
148
|
-
setIsBusy(true);
|
|
149
|
-
setError('');
|
|
150
|
-
setSelectedMethod('passkey');
|
|
151
|
-
setStep('passkey');
|
|
152
|
-
try {
|
|
153
|
-
const supported = await passkeyProvider.isSupported();
|
|
154
|
-
if (!supported) {
|
|
155
|
-
throw new Error('Passkeys are not supported on this device.');
|
|
156
|
-
}
|
|
157
|
-
if (!isActiveSession(sessionRef, sessionId))
|
|
158
|
-
return;
|
|
159
|
-
const challenge = await client.products.identity.getPasskeyAuthOptions();
|
|
160
|
-
if (!isActiveSession(sessionRef, sessionId))
|
|
161
|
-
return;
|
|
162
|
-
const credential = await passkeyProvider.authenticate(challenge.options);
|
|
163
|
-
if (!isActiveSession(sessionRef, sessionId))
|
|
164
|
-
return;
|
|
165
|
-
if (!credential) {
|
|
166
|
-
throw new Error('Passkey authentication was cancelled.');
|
|
167
|
-
}
|
|
168
|
-
const result = await client.products.identity.completePasskeyAuthentication(credential, challenge.session);
|
|
169
|
-
await finishWithToken(result, sessionId);
|
|
170
|
-
}
|
|
171
|
-
catch (err) {
|
|
172
|
-
if (!isActiveSession(sessionRef, sessionId))
|
|
173
|
-
return;
|
|
174
|
-
reportError(err, 'Passkey authentication failed');
|
|
175
|
-
}
|
|
176
|
-
finally {
|
|
177
|
-
if (isActiveSession(sessionRef, sessionId)) {
|
|
178
|
-
setIsBusy(false);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}, [client, finishWithToken, passkeyProvider, reportError]);
|
|
182
146
|
const handleIdentitySubmit = useCallback(async () => {
|
|
183
147
|
if (isBusy)
|
|
184
148
|
return;
|
|
@@ -189,7 +153,7 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
189
153
|
}
|
|
190
154
|
const normalizedIdentity = parsed.identity;
|
|
191
155
|
const nextIdentityType = parsed.identityType;
|
|
192
|
-
const availableMethods = getMethodsForIdentity(config, nextIdentityType
|
|
156
|
+
const availableMethods = getMethodsForIdentity(config, nextIdentityType);
|
|
193
157
|
if (availableMethods.length === 0) {
|
|
194
158
|
setError('No supported sign-in methods are enabled for this identity type.');
|
|
195
159
|
return;
|
|
@@ -197,38 +161,14 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
197
161
|
setIdentity(normalizedIdentity);
|
|
198
162
|
setIdentityType(nextIdentityType);
|
|
199
163
|
setError('');
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (availableMethods[0] === 'passkey') {
|
|
205
|
-
await runPasskey();
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
await sendOtp(availableMethods[0], normalizedIdentity, nextIdentityType);
|
|
209
|
-
}
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
setStep('methods');
|
|
213
|
-
}
|
|
214
|
-
catch (err) {
|
|
215
|
-
if (!isActiveSession(sessionRef, sessionId))
|
|
216
|
-
return;
|
|
217
|
-
reportError(err, 'Failed to load sign-in methods');
|
|
218
|
-
}
|
|
219
|
-
finally {
|
|
220
|
-
if (isActiveSession(sessionRef, sessionId)) {
|
|
221
|
-
setIsBusy(false);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}, [allowedTypes, config, identity, isBusy, passkeyProvider, reportError, runPasskey, sendOtp]);
|
|
225
|
-
const handleMethodSelect = useCallback(async (method) => {
|
|
226
|
-
if (method === 'passkey') {
|
|
227
|
-
await runPasskey();
|
|
164
|
+
// One way in: send that code. Several (a phone with both SMS and voice):
|
|
165
|
+
// let the person choose. sendOtp owns the busy flag and its own failures.
|
|
166
|
+
if (availableMethods.length === 1) {
|
|
167
|
+
await sendOtp(availableMethods[0], normalizedIdentity, nextIdentityType);
|
|
228
168
|
return;
|
|
229
169
|
}
|
|
230
|
-
|
|
231
|
-
}, [
|
|
170
|
+
setStep('methods');
|
|
171
|
+
}, [allowedTypes, config, identity, isBusy, sendOtp]);
|
|
232
172
|
const handleVerifyOtp = useCallback(async () => {
|
|
233
173
|
if (!kindling || pin.length !== 6)
|
|
234
174
|
return;
|
|
@@ -284,9 +224,6 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
284
224
|
if (nextAllowedTypes.length > 0) {
|
|
285
225
|
setStep('identity');
|
|
286
226
|
}
|
|
287
|
-
else if (getMethodsWithoutIdentity(nextConfig, passkeyProvider).length > 0) {
|
|
288
|
-
setStep('methods');
|
|
289
|
-
}
|
|
290
227
|
else {
|
|
291
228
|
setError('No supported sign-in methods are enabled for this app.');
|
|
292
229
|
setStep('error');
|
|
@@ -303,10 +240,26 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
303
240
|
setIsBusy(false);
|
|
304
241
|
}
|
|
305
242
|
});
|
|
306
|
-
}, [client, initialIdentity, initialIdentityType,
|
|
307
|
-
const headerLogo = getHeaderLogo(branding, effectiveTheme);
|
|
243
|
+
}, [client, initialIdentity, initialIdentityType, reportError]);
|
|
308
244
|
const companyName = branding?.companyName || 'SparkVault';
|
|
309
|
-
|
|
245
|
+
// A logo speaks for the brand on its own, so it replaces the company name
|
|
246
|
+
// rather than sitting beside it, drawn at its own proportions and the full
|
|
247
|
+
// height of the header instead of squeezed into a square. Only a logo that
|
|
248
|
+
// loads earns that: one that fails falls back to the lettermark and name, so
|
|
249
|
+
// the header is never blank.
|
|
250
|
+
const logoUri = resolveLogoUri(branding, effectiveTheme, brokenLogoUri);
|
|
251
|
+
const logoAspectRatio = measuredLogo?.uri === logoUri ? measuredLogo.aspectRatio : null;
|
|
252
|
+
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
|
|
253
|
+
? styles.logoUnmeasured
|
|
254
|
+
: [styles.logo, { aspectRatio: logoAspectRatio }], resizeMode: "contain", accessibilityRole: "image", accessibilityLabel: companyName, onLoad: (event) => {
|
|
255
|
+
const { width, height } = event.nativeEvent.source;
|
|
256
|
+
if (width <= 0 || height <= 0)
|
|
257
|
+
return;
|
|
258
|
+
const aspectRatio = width / height;
|
|
259
|
+
setMeasuredLogo(current => (current?.uri === logoUri && current.aspectRatio === aspectRatio
|
|
260
|
+
? current
|
|
261
|
+
: { uri: logoUri, aspectRatio }));
|
|
262
|
+
}, onError: () => setBrokenLogoUri(logoUri) })) : (_jsxs(_Fragment, { children: [_jsx(View, { style: [styles.logoFallback, { backgroundColor: colors.primarySoft }], children: _jsx(Text, { style: [styles.logoFallbackText, { color: colors.primary }], children: companyName.slice(0, 1).toUpperCase() }) }), _jsx(Text, { style: [styles.companyName, { color: colors.text }], children: companyName })] })) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close identity verification", onPress: handleCancel, hitSlop: 12, style: styles.closeButton, children: _jsx(Text, { style: [styles.closeText, { color: colors.muted }], children: "\u2715" }) })] }), step === 'loading' && (_jsxs(View, { style: styles.centerContent, children: [_jsx(ActivityIndicator, { color: colors.primary }), _jsx(Text, { style: [styles.mutedText, { color: colors.muted }], children: "Loading sign-in options..." })] })), step === 'identity' && (_jsxs(View, { style: styles.body, children: [_jsx(Text, { style: [styles.title, { color: colors.text }], children: "Sign in" }), _jsx(Text, { style: [styles.subtitle, { color: colors.muted }], children: identitySubtitle(allowedTypes) }), _jsx(TextInput, { value: identity, onChangeText: (value) => {
|
|
310
263
|
setIdentity(value);
|
|
311
264
|
setError('');
|
|
312
265
|
if (allowedTypes.length > 1) {
|
|
@@ -319,14 +272,14 @@ export function SparkVaultIdentityDialog({ client, visible, initialIdentity, ini
|
|
|
319
272
|
color: colors.text,
|
|
320
273
|
backgroundColor: colors.input,
|
|
321
274
|
},
|
|
322
|
-
] }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : 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: () =>
|
|
275
|
+
] }), error ? _jsx(Text, { style: [styles.error, { color: colors.error }], children: error }) : 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 }) => [
|
|
323
276
|
styles.methodButton,
|
|
324
277
|
{
|
|
325
278
|
borderColor: colors.border,
|
|
326
279
|
backgroundColor: pressed ? colors.pressed : colors.input,
|
|
327
280
|
opacity: isBusy ? 0.6 : 1,
|
|
328
281
|
},
|
|
329
|
-
], 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: "Use a different identity", colors: colors, onPress: () => setStep('identity') })) : null] })), step === '
|
|
282
|
+
], 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: "Use a different identity", colors: colors, onPress: () => setStep('identity') })) : 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 6-digit code sent to ", '\n', _jsx(Text, { style: { color: colors.text, fontWeight: '700' }, children: identity })] }), _jsx(TextInput, { value: pin, onChangeText: (value) => {
|
|
330
283
|
setPin(value.replace(/\D/g, '').slice(0, 6));
|
|
331
284
|
setError('');
|
|
332
285
|
}, placeholder: "000000", placeholderTextColor: colors.placeholder, keyboardType: "number-pad", maxLength: 6, editable: !isBusy && countdown !== 'Expired', style: [
|
|
@@ -367,22 +320,16 @@ function resolveInitialIdentityType(identity, explicitType, allowedTypes) {
|
|
|
367
320
|
return 'phone';
|
|
368
321
|
return allowedTypes.includes('email') ? 'email' : 'phone';
|
|
369
322
|
}
|
|
370
|
-
function getMethodsForIdentity(config, identityType
|
|
323
|
+
function getMethodsForIdentity(config, identityType) {
|
|
371
324
|
const configuredMethods = config?.methods ?? ['otp_email'];
|
|
372
325
|
return configuredMethods.filter((method) => {
|
|
373
326
|
if (!SUPPORTED_METHODS.has(method))
|
|
374
327
|
return false;
|
|
375
|
-
if (method === 'passkey')
|
|
376
|
-
return Boolean(passkeyProvider);
|
|
377
328
|
if (method === 'otp_email')
|
|
378
329
|
return identityType === 'email';
|
|
379
330
|
return identityType === 'phone';
|
|
380
331
|
});
|
|
381
332
|
}
|
|
382
|
-
function getMethodsWithoutIdentity(config, passkeyProvider) {
|
|
383
|
-
const configuredMethods = config?.methods ?? [];
|
|
384
|
-
return configuredMethods.filter((method) => (method === 'passkey' && Boolean(passkeyProvider)));
|
|
385
|
-
}
|
|
386
333
|
function parseIdentity(value, allowedTypes) {
|
|
387
334
|
const trimmed = value.trim();
|
|
388
335
|
if (!trimmed) {
|
|
@@ -409,27 +356,13 @@ function parseIdentity(value, allowedTypes) {
|
|
|
409
356
|
return { ok: true, identity: phone, identityType: 'phone' };
|
|
410
357
|
}
|
|
411
358
|
function toOtpMethod(method) {
|
|
412
|
-
if (method === 'otp_email')
|
|
413
|
-
return 'email';
|
|
414
359
|
if (method === 'otp_sms')
|
|
415
360
|
return 'sms';
|
|
416
361
|
if (method === 'otp_voice')
|
|
417
362
|
return 'voice';
|
|
418
|
-
return
|
|
419
|
-
}
|
|
420
|
-
function fallbackOtpMethod(methods) {
|
|
421
|
-
return methods.find((method) => method !== 'passkey') ?? null;
|
|
422
|
-
}
|
|
423
|
-
function fallbackLabel(method) {
|
|
424
|
-
if (method === 'otp_sms')
|
|
425
|
-
return 'Use SMS code instead';
|
|
426
|
-
if (method === 'otp_voice')
|
|
427
|
-
return 'Use voice call instead';
|
|
428
|
-
return 'Use email code instead';
|
|
363
|
+
return 'email';
|
|
429
364
|
}
|
|
430
365
|
function methodTitle(method) {
|
|
431
|
-
if (method === 'passkey')
|
|
432
|
-
return 'Passkey';
|
|
433
366
|
if (method === 'otp_sms')
|
|
434
367
|
return 'Text message';
|
|
435
368
|
if (method === 'otp_voice')
|
|
@@ -437,8 +370,6 @@ function methodTitle(method) {
|
|
|
437
370
|
return 'Email code';
|
|
438
371
|
}
|
|
439
372
|
function methodDescription(method) {
|
|
440
|
-
if (method === 'passkey')
|
|
441
|
-
return 'Use Face ID, Touch ID, or your device passcode.';
|
|
442
373
|
if (method === 'otp_sms')
|
|
443
374
|
return 'Receive a one-time code by SMS.';
|
|
444
375
|
if (method === 'otp_voice')
|
|
@@ -466,12 +397,13 @@ function otpTitle(method) {
|
|
|
466
397
|
return 'Check your phone';
|
|
467
398
|
return 'Check your email';
|
|
468
399
|
}
|
|
469
|
-
function
|
|
400
|
+
function resolveLogoUri(branding, theme, brokenLogoUri) {
|
|
470
401
|
if (!branding)
|
|
471
402
|
return null;
|
|
472
|
-
|
|
403
|
+
const uri = theme === 'dark'
|
|
473
404
|
? branding.logoDark || branding.logoLight
|
|
474
405
|
: branding.logoLight || branding.logoDark;
|
|
406
|
+
return uri && uri !== brokenLogoUri ? uri : null;
|
|
475
407
|
}
|
|
476
408
|
function formatCountdown(seconds) {
|
|
477
409
|
const minutes = Math.floor(seconds / 60);
|
|
@@ -549,9 +481,17 @@ const styles = StyleSheet.create({
|
|
|
549
481
|
alignItems: 'center',
|
|
550
482
|
},
|
|
551
483
|
logo: {
|
|
552
|
-
width
|
|
553
|
-
|
|
554
|
-
|
|
484
|
+
// Height is the header's; width follows the logo's own aspect ratio,
|
|
485
|
+
// bounded by the space left beside the close button.
|
|
486
|
+
height: 40,
|
|
487
|
+
maxWidth: '100%',
|
|
488
|
+
},
|
|
489
|
+
logoUnmeasured: {
|
|
490
|
+
// Before the image reports its shape. A square, not a zero-width box: iOS
|
|
491
|
+
// only loads an image into a non-zero frame, and a box with no width would
|
|
492
|
+
// leave the header permanently empty.
|
|
493
|
+
height: 40,
|
|
494
|
+
width: 40,
|
|
555
495
|
},
|
|
556
496
|
logoFallback: {
|
|
557
497
|
width: 32,
|
|
@@ -664,16 +604,5 @@ const styles = StyleSheet.create({
|
|
|
664
604
|
fontSize: 13,
|
|
665
605
|
lineHeight: 18,
|
|
666
606
|
},
|
|
667
|
-
passkeyIcon: {
|
|
668
|
-
width: 76,
|
|
669
|
-
height: 76,
|
|
670
|
-
borderRadius: 38,
|
|
671
|
-
alignSelf: 'center',
|
|
672
|
-
alignItems: 'center',
|
|
673
|
-
justifyContent: 'center',
|
|
674
|
-
},
|
|
675
|
-
passkeyIconText: {
|
|
676
|
-
fontSize: 34,
|
|
677
|
-
},
|
|
678
607
|
});
|
|
679
608
|
//# sourceMappingURL=identity-dialog.js.map
|