@rockerone/xprnkit 0.3.10 → 0.3.12
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.
|
@@ -6,15 +6,18 @@ import { type StoredSessionRef } from "../utils";
|
|
|
6
6
|
import { type IdentityProofStatus } from "../services/identity-proof";
|
|
7
7
|
/**
|
|
8
8
|
* Identity proof data returned from authentication
|
|
9
|
+
* All fields are optional - dev can store whatever they want
|
|
9
10
|
*/
|
|
10
11
|
export type XPRNIdentityProof = {
|
|
11
|
-
actor
|
|
12
|
+
actor?: string;
|
|
12
13
|
/** Public key (optional - not available for browser/WebAuth wallets) */
|
|
13
14
|
publicKey?: string;
|
|
14
15
|
/** JWT token from the identity proof verification */
|
|
15
16
|
token?: string;
|
|
16
17
|
/** Additional data from the verification response */
|
|
17
18
|
data?: any;
|
|
19
|
+
/** Allow any additional fields for custom flows */
|
|
20
|
+
[key: string]: any;
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
20
23
|
* @deprecated Use XPRNIdentityProof instead
|
|
@@ -72,6 +75,12 @@ type XPRNProviderContext = {
|
|
|
72
75
|
connect: (restore?: boolean, onSession?: (session: LinkSession, link: ProtonWebLink | Link) => void, onProfile?: (profile: XPRNProfile) => void, onIdentityProof?: (proof: XPRNIdentityProof) => void, onIdentityProofError?: (error: Error) => void) => void;
|
|
73
76
|
disconnect: () => Promise<void>;
|
|
74
77
|
requestIdentityProof: (success: (res: XPRNIdentityProof) => void, fail: (e: any) => void) => void;
|
|
78
|
+
/** Set identity proof data manually (for custom auth flows) */
|
|
79
|
+
setIdentityProof: (data: XPRNIdentityProof | null) => void;
|
|
80
|
+
/** Clear identity proof and reset status to idle */
|
|
81
|
+
clearIdentityProof: () => void;
|
|
82
|
+
/** Set identity proof status manually (for custom auth flows) */
|
|
83
|
+
setIdentityProofStatus: (status: IdentityProofStatus) => void;
|
|
75
84
|
listStoredSessions: () => StoredSessionRef[];
|
|
76
85
|
switchToSession: (auth: string, chainId: string) => Promise<void>;
|
|
77
86
|
addTransactionError: (rawMessage: string) => void;
|
|
@@ -18,6 +18,9 @@ const XPRNContext = React.createContext({
|
|
|
18
18
|
connect: () => { },
|
|
19
19
|
disconnect: async () => { },
|
|
20
20
|
requestIdentityProof: () => { },
|
|
21
|
+
setIdentityProof: () => { },
|
|
22
|
+
clearIdentityProof: () => { },
|
|
23
|
+
setIdentityProofStatus: () => { },
|
|
21
24
|
listStoredSessions: () => [],
|
|
22
25
|
switchToSession: async () => { },
|
|
23
26
|
addTransactionError: () => { },
|
|
@@ -411,6 +414,11 @@ export const XPRNProvider = ({ children, config, }) => {
|
|
|
411
414
|
connect(true);
|
|
412
415
|
}
|
|
413
416
|
}, [config.restoreSession, connect, session]);
|
|
417
|
+
// Helper to clear identity proof
|
|
418
|
+
const clearIdentityProof = useCallback(() => {
|
|
419
|
+
setIdentityProof(null);
|
|
420
|
+
setIdentityProofStatus("idle");
|
|
421
|
+
}, []);
|
|
414
422
|
const providerValue = useMemo(() => {
|
|
415
423
|
return {
|
|
416
424
|
// Config
|
|
@@ -428,6 +436,10 @@ export const XPRNProvider = ({ children, config, }) => {
|
|
|
428
436
|
connect,
|
|
429
437
|
disconnect,
|
|
430
438
|
requestIdentityProof,
|
|
439
|
+
// Identity proof setters (for custom flows)
|
|
440
|
+
setIdentityProof,
|
|
441
|
+
clearIdentityProof,
|
|
442
|
+
setIdentityProofStatus,
|
|
431
443
|
// Session switching
|
|
432
444
|
listStoredSessions,
|
|
433
445
|
switchToSession,
|
|
@@ -449,6 +461,7 @@ export const XPRNProvider = ({ children, config, }) => {
|
|
|
449
461
|
connect,
|
|
450
462
|
disconnect,
|
|
451
463
|
requestIdentityProof,
|
|
464
|
+
clearIdentityProof,
|
|
452
465
|
listStoredSessions,
|
|
453
466
|
switchToSession,
|
|
454
467
|
addTxError,
|