@block-auth.io/core 0.8.1 → 0.9.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/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -994,6 +994,7 @@ var initial2 = {
|
|
|
994
994
|
isSigningLoader: false,
|
|
995
995
|
isAcceptingTxn: false,
|
|
996
996
|
waitingForSuccessLogInSince: 0,
|
|
997
|
+
isOtpRequired: false,
|
|
997
998
|
isOnDeletion: false,
|
|
998
999
|
deletionAddress: null
|
|
999
1000
|
};
|
|
@@ -1011,6 +1012,7 @@ var setIsSigned = (v) => $ui.setKey("isSigned", v);
|
|
|
1011
1012
|
var setIsSigningLoader = (v) => $ui.setKey("isSigningLoader", v);
|
|
1012
1013
|
var setIsAcceptingTxn = (v) => $ui.setKey("isAcceptingTxn", v);
|
|
1013
1014
|
var setWaitingForSuccessLogInSince = (v) => $ui.setKey("waitingForSuccessLogInSince", v);
|
|
1015
|
+
var setIsOtpRequired = (v) => $ui.setKey("isOtpRequired", v);
|
|
1014
1016
|
var setIsOnDeletion = (v) => $ui.setKey("isOnDeletion", v);
|
|
1015
1017
|
var setDeletionAddress = (v) => $ui.setKey("deletionAddress", v);
|
|
1016
1018
|
var resetUi = () => $ui.set({ ...initial2 });
|
|
@@ -1790,6 +1792,10 @@ function requestExtensionStateSync() {
|
|
|
1790
1792
|
if (typeof document === "undefined") return;
|
|
1791
1793
|
document.dispatchEvent(new CustomEvent("ext:initial"));
|
|
1792
1794
|
}
|
|
1795
|
+
function openExtensionOnTxn() {
|
|
1796
|
+
if (typeof document === "undefined") return;
|
|
1797
|
+
document.dispatchEvent(new CustomEvent("ext:txn"));
|
|
1798
|
+
}
|
|
1793
1799
|
function syncExtensionStateFromStorage() {
|
|
1794
1800
|
const ui = browserBase.getUI();
|
|
1795
1801
|
const state = $extension.get();
|
|
@@ -2504,10 +2510,16 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2504
2510
|
setIsSigning(false);
|
|
2505
2511
|
setIsSigningLoader(false);
|
|
2506
2512
|
setIsAcceptingTxn(false);
|
|
2513
|
+
setIsOtpRequired(false);
|
|
2507
2514
|
closeAllModals();
|
|
2508
2515
|
resetUser();
|
|
2509
2516
|
await onError();
|
|
2510
2517
|
};
|
|
2518
|
+
const awaitOtpInExtension = () => {
|
|
2519
|
+
setIsOtpRequired(true);
|
|
2520
|
+
setIsAcceptingTxn(false);
|
|
2521
|
+
if ($extension.get().installed) openExtensionOnTxn();
|
|
2522
|
+
};
|
|
2511
2523
|
const _onLogout = async () => {
|
|
2512
2524
|
if (hookState.isLoggingOut) return applyLocalLogout();
|
|
2513
2525
|
hookState.isLoggingOut = true;
|
|
@@ -2730,6 +2742,7 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2730
2742
|
};
|
|
2731
2743
|
const settleSigningAttempt = (outcome) => {
|
|
2732
2744
|
setWaitingForSuccessLogInSince(0);
|
|
2745
|
+
setIsOtpRequired(false);
|
|
2733
2746
|
setIsSigning(false);
|
|
2734
2747
|
hookState.isSigning = false;
|
|
2735
2748
|
if (getUserTxnsInterval) {
|
|
@@ -2809,6 +2822,8 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2809
2822
|
captureOwnTxnId(ownTxnItems(message?.items ?? []));
|
|
2810
2823
|
wsc().emit("user:txns", { token });
|
|
2811
2824
|
pollUserTxns(token, () => hookState.isSigning, USER_TXNS_POLL_MS);
|
|
2825
|
+
if (message?.otpExpired) awaitOtpInExtension();
|
|
2826
|
+
else setIsOtpRequired(false);
|
|
2812
2827
|
} else {
|
|
2813
2828
|
setIsSigning(false);
|
|
2814
2829
|
hookState.isSigning = false;
|
|
@@ -2863,6 +2878,10 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2863
2878
|
handleUserDeleted(corruptedAddress);
|
|
2864
2879
|
};
|
|
2865
2880
|
const onSigninExpired = async (_data) => {
|
|
2881
|
+
if (hookState.isSigning) {
|
|
2882
|
+
awaitOtpInExtension();
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2866
2885
|
await _onError();
|
|
2867
2886
|
};
|
|
2868
2887
|
const onSigninUnsigned = async (_data) => {
|
|
@@ -3197,6 +3216,15 @@ var TEXTS = {
|
|
|
3197
3216
|
es: "No se encontraron transacciones",
|
|
3198
3217
|
en: "No transactions found"
|
|
3199
3218
|
},
|
|
3219
|
+
otpExpiredExtension: {
|
|
3220
|
+
es: "Tu verificaci\xF3n ha caducado. Introduce tu c\xF3digo en la extensi\xF3n de Block-Auth para aprobar este acceso.",
|
|
3221
|
+
en: "Your verification has expired. Enter your code in the Block-Auth extension to approve this access."
|
|
3222
|
+
},
|
|
3223
|
+
otpExpiredApp: {
|
|
3224
|
+
es: "Tu verificaci\xF3n ha caducado. Introduce tu c\xF3digo en la app de Block-Auth para aprobar este acceso.",
|
|
3225
|
+
en: "Your verification has expired. Enter your code in the Block-Auth app to approve this access."
|
|
3226
|
+
},
|
|
3227
|
+
openExtension: { es: "Abrir extensi\xF3n", en: "Open extension" },
|
|
3200
3228
|
noAppKeyFound: {
|
|
3201
3229
|
es: "No se encontr\xF3 la clave de la aplicaci\xF3n",
|
|
3202
3230
|
en: "No application key found"
|
|
@@ -3313,6 +3341,7 @@ exports.markSdkPresence = markSdkPresence;
|
|
|
3313
3341
|
exports.oauth = oauth_exports;
|
|
3314
3342
|
exports.onExtensionRemoved = onExtensionRemoved;
|
|
3315
3343
|
exports.onExtensionStatePublished = onExtensionStatePublished;
|
|
3344
|
+
exports.openExtensionOnTxn = openExtensionOnTxn;
|
|
3316
3345
|
exports.openModal = openModal;
|
|
3317
3346
|
exports.probeExtensionPresence = probeExtensionPresence;
|
|
3318
3347
|
exports.reconcileExtensionState = reconcileExtensionState;
|
|
@@ -3340,6 +3369,7 @@ exports.setIsAppActive = setIsAppActive;
|
|
|
3340
3369
|
exports.setIsCheckingAppActive = setIsCheckingAppActive;
|
|
3341
3370
|
exports.setIsLoadingUser = setIsLoadingUser;
|
|
3342
3371
|
exports.setIsOnDeletion = setIsOnDeletion;
|
|
3372
|
+
exports.setIsOtpRequired = setIsOtpRequired;
|
|
3343
3373
|
exports.setIsSdkSignedIn = setIsSdkSignedIn;
|
|
3344
3374
|
exports.setIsServiceConnected = setIsServiceConnected;
|
|
3345
3375
|
exports.setIsSigned = setIsSigned;
|