@rockerone/xprnkit 0.3.8 → 0.3.9
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.
|
@@ -79,7 +79,7 @@ type XPRNProviderContext = {
|
|
|
79
79
|
isIdentityProofRequired: boolean;
|
|
80
80
|
/** True if identity proof is enabled (config.identityProof is defined) */
|
|
81
81
|
isIdentityProofEnabled: boolean;
|
|
82
|
-
connect: (restore?: boolean, onSession?: (session: LinkSession, link: ProtonWebLink | Link) => void, onProfile?: (profile: XPRNProfile) => void) => void;
|
|
82
|
+
connect: (restore?: boolean, onSession?: (session: LinkSession, link: ProtonWebLink | Link) => void, onProfile?: (profile: XPRNProfile) => void, onIdentityProof?: (proof: XPRNIdentityProof) => void, onIdentityProofError?: (error: Error) => void) => void;
|
|
83
83
|
disconnect: () => Promise<void>;
|
|
84
84
|
requestIdentityProof: (success: (res: XPRNIdentityProof) => void, fail: (e: any) => void) => void;
|
|
85
85
|
listStoredSessions: () => StoredSessionRef[];
|
|
@@ -58,6 +58,8 @@ export const XPRNProvider = ({ children, config, }) => {
|
|
|
58
58
|
const errorsStackRef = useRef([]);
|
|
59
59
|
const onSessionRef = useRef();
|
|
60
60
|
const onProfileRef = useRef();
|
|
61
|
+
const onIdentityProofRef = useRef();
|
|
62
|
+
const onIdentityProofErrorRef = useRef();
|
|
61
63
|
const isRestoringRef = useRef(false);
|
|
62
64
|
const isAuthenticatingRef = useRef(false);
|
|
63
65
|
const isSwitchingSessionRef = useRef(false);
|
|
@@ -162,7 +164,7 @@ export const XPRNProvider = ({ children, config, }) => {
|
|
|
162
164
|
// Mark session switch as complete
|
|
163
165
|
isSwitchingSessionRef.current = false;
|
|
164
166
|
}, [link, config.requesterAccount, config.apiMode, identityProofConfig]);
|
|
165
|
-
const connect = useCallback((restoreSession, onSession, onProfile) => {
|
|
167
|
+
const connect = useCallback((restoreSession, onSession, onProfile, onIdentityProof, onIdentityProofError) => {
|
|
166
168
|
ConnectWallet({
|
|
167
169
|
linkOptions: {
|
|
168
170
|
endpoints: config.endpoints,
|
|
@@ -177,6 +179,8 @@ export const XPRNProvider = ({ children, config, }) => {
|
|
|
177
179
|
}).then(res => {
|
|
178
180
|
onSessionRef.current = onSession;
|
|
179
181
|
onProfileRef.current = onProfile;
|
|
182
|
+
onIdentityProofRef.current = onIdentityProof;
|
|
183
|
+
onIdentityProofErrorRef.current = onIdentityProofError;
|
|
180
184
|
if (res.link && res.session) {
|
|
181
185
|
// Update state with new session
|
|
182
186
|
setLink(res.link);
|
|
@@ -278,10 +282,18 @@ export const XPRNProvider = ({ children, config, }) => {
|
|
|
278
282
|
sessionStorage.updateIdentityProofToken(config.requesterAccount, { actor, permission }, chainId, verifyRes.token);
|
|
279
283
|
}
|
|
280
284
|
success(identityProofData);
|
|
285
|
+
// Call connect-level callback if registered
|
|
286
|
+
if (onIdentityProofRef.current) {
|
|
287
|
+
onIdentityProofRef.current(identityProofData);
|
|
288
|
+
}
|
|
281
289
|
}
|
|
282
290
|
catch (error) {
|
|
283
291
|
setIdentityProofStatus("error");
|
|
284
292
|
fail(error);
|
|
293
|
+
// Call connect-level error callback if registered
|
|
294
|
+
if (onIdentityProofErrorRef.current) {
|
|
295
|
+
onIdentityProofErrorRef.current(error instanceof Error ? error : new Error(String(error)));
|
|
296
|
+
}
|
|
285
297
|
}
|
|
286
298
|
finally {
|
|
287
299
|
isAuthenticatingRef.current = false;
|