@block-auth.io/core 0.7.0 → 0.8.1
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 +37 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +36 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1931,6 +1931,12 @@ function resetExtensionSyncModuleState() {
|
|
|
1931
1931
|
activeDiscovery = null;
|
|
1932
1932
|
activeProbe = null;
|
|
1933
1933
|
}
|
|
1934
|
+
function onSessionBridged(event) {
|
|
1935
|
+
const did = event.detail?.did;
|
|
1936
|
+
if (!did) return;
|
|
1937
|
+
void browserBase.setSession({ did, serviceName: "blockauth" });
|
|
1938
|
+
setDid(did);
|
|
1939
|
+
}
|
|
1934
1940
|
function startExtensionSync() {
|
|
1935
1941
|
if (typeof document === "undefined") {
|
|
1936
1942
|
return () => {
|
|
@@ -1938,6 +1944,7 @@ function startExtensionSync() {
|
|
|
1938
1944
|
}
|
|
1939
1945
|
let cancelled = false;
|
|
1940
1946
|
const retryTimeouts = [];
|
|
1947
|
+
document.addEventListener("blockauth:session-bridged", onSessionBridged);
|
|
1941
1948
|
markSdkPresence();
|
|
1942
1949
|
discoverExtensionOnce().then(() => {
|
|
1943
1950
|
if (cancelled || appearsExtensionInstalled()) return;
|
|
@@ -1979,6 +1986,7 @@ function startExtensionSync() {
|
|
|
1979
1986
|
retryTimeouts.forEach(clearTimeout);
|
|
1980
1987
|
clearSdkPresence();
|
|
1981
1988
|
resetExtensionSyncModuleState();
|
|
1989
|
+
document.removeEventListener("blockauth:session-bridged", onSessionBridged);
|
|
1982
1990
|
document.removeEventListener("blockauth:sync", onSync);
|
|
1983
1991
|
document.removeEventListener("blockauth:gone", onGone);
|
|
1984
1992
|
window.removeEventListener("storage", onStorage);
|
|
@@ -2587,16 +2595,9 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2587
2595
|
console.error("[sdk] applyLocalLogout failed (storage event):", err);
|
|
2588
2596
|
});
|
|
2589
2597
|
};
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
void browserBase.setSession({
|
|
2594
|
-
did,
|
|
2595
|
-
serviceName: "blockauth",
|
|
2596
|
-
apiUrl: client.apiUrl
|
|
2597
|
-
});
|
|
2598
|
-
setDid(did);
|
|
2599
|
-
}
|
|
2598
|
+
let sessionBridged = false;
|
|
2599
|
+
const onExtensionSessionBridged = () => {
|
|
2600
|
+
sessionBridged = true;
|
|
2600
2601
|
void wsc().refreshAuth();
|
|
2601
2602
|
};
|
|
2602
2603
|
const deletion = createDeletionService({ provider });
|
|
@@ -2996,6 +2997,12 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2996
2997
|
setIsServiceConnected(isLoggedOut ? false : externalService.connected);
|
|
2997
2998
|
setServiceName(externalService.service);
|
|
2998
2999
|
setServiceIcon(imgUrlByService(externalService.service));
|
|
3000
|
+
if (typeof document !== "undefined") {
|
|
3001
|
+
document.addEventListener(
|
|
3002
|
+
"blockauth:session-bridged",
|
|
3003
|
+
onExtensionSessionBridged
|
|
3004
|
+
);
|
|
3005
|
+
}
|
|
2999
3006
|
await provider.connect(
|
|
3000
3007
|
client.wsConnectTimeout ?? 300,
|
|
3001
3008
|
"",
|
|
@@ -3007,6 +3014,7 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
3007
3014
|
setIsSignedFirstCheck(true);
|
|
3008
3015
|
return;
|
|
3009
3016
|
}
|
|
3017
|
+
if (sessionBridged) await wsc().refreshAuth();
|
|
3010
3018
|
const { success, message } = await provider.signin();
|
|
3011
3019
|
setIsCheckingAppActive(false);
|
|
3012
3020
|
if (!success) {
|
|
@@ -3037,12 +3045,6 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
3037
3045
|
if (typeof window !== "undefined") {
|
|
3038
3046
|
window.addEventListener("storage", onStorageLogout);
|
|
3039
3047
|
}
|
|
3040
|
-
if (typeof document !== "undefined") {
|
|
3041
|
-
document.addEventListener(
|
|
3042
|
-
"blockauth:session-bridged",
|
|
3043
|
-
onExtensionSessionBridged
|
|
3044
|
-
);
|
|
3045
|
-
}
|
|
3046
3048
|
const { domain, signinCallbackUrl, config: config3 } = await provider.app();
|
|
3047
3049
|
setUiConfig({ domain, signinCallbackUrl, config: config3 });
|
|
3048
3050
|
setReady(true);
|
|
@@ -3120,13 +3122,30 @@ __export(utils_exports, {
|
|
|
3120
3122
|
BLOCKAUTH_STORAGE_KEYS: () => BLOCKAUTH_STORAGE_KEYS,
|
|
3121
3123
|
browserBase: () => browserBase,
|
|
3122
3124
|
cleanUrl: () => cleanUrl,
|
|
3125
|
+
getExtensionStoreUrl: () => getExtensionStoreUrl,
|
|
3123
3126
|
getIp: () => getIp,
|
|
3124
3127
|
getUTCDateString: () => getUTCDateString,
|
|
3125
3128
|
imgUrlByService: () => imgUrlByService,
|
|
3129
|
+
isFirefox: () => isFirefox,
|
|
3126
3130
|
isValidImgUrl: () => isValidImgUrl,
|
|
3127
3131
|
secsToText: () => secsToText
|
|
3128
3132
|
});
|
|
3129
3133
|
|
|
3134
|
+
// src/utils/browserAgent.ts
|
|
3135
|
+
var CHROME_STORE_URL = "https://chromewebstore.google.com/detail/block-auth-one/jhjjpmjhiamddbfhogknjibkacajkpdg";
|
|
3136
|
+
var FIREFOX_STORE_URL = "https://addons.mozilla.org/es-ES/firefox/addon/block-auth-one/";
|
|
3137
|
+
function isFirefox() {
|
|
3138
|
+
try {
|
|
3139
|
+
if (typeof navigator === "undefined") return false;
|
|
3140
|
+
return /firefox/i.test(navigator.userAgent || "");
|
|
3141
|
+
} catch {
|
|
3142
|
+
return false;
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
function getExtensionStoreUrl() {
|
|
3146
|
+
return isFirefox() ? FIREFOX_STORE_URL : CHROME_STORE_URL;
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3130
3149
|
// src/i18n/texts.ts
|
|
3131
3150
|
var TEXTS = {
|
|
3132
3151
|
edit: { es: "Editar", en: "Edit" },
|
|
@@ -3271,6 +3290,7 @@ exports.deepLinkFor = deepLinkFor;
|
|
|
3271
3290
|
exports.discoverExtensionOnce = discoverExtensionOnce;
|
|
3272
3291
|
exports.fetchUserProfile = fetchUserProfile;
|
|
3273
3292
|
exports.finalizeAfterRestorationExpired = finalizeAfterRestorationExpired;
|
|
3293
|
+
exports.getExtensionStoreUrl = getExtensionStoreUrl;
|
|
3274
3294
|
exports.getUserRoleNames = getUserRoleNames;
|
|
3275
3295
|
exports.getUserRoleSlugs = getUserRoleSlugs;
|
|
3276
3296
|
exports.getUserRoles = getUserRoles;
|
|
@@ -3282,6 +3302,7 @@ exports.hasRole = hasRole;
|
|
|
3282
3302
|
exports.hasRoleBySlug = hasRoleBySlug;
|
|
3283
3303
|
exports.isExtensionPresent = isExtensionPresent;
|
|
3284
3304
|
exports.isExtensionStateComplete = isExtensionStateComplete;
|
|
3305
|
+
exports.isFirefox = isFirefox;
|
|
3285
3306
|
exports.isModalOpen = isModalOpen;
|
|
3286
3307
|
exports.isRestorationExpiredMessage = isRestorationExpiredMessage;
|
|
3287
3308
|
exports.isSdkPage = isSdkPage;
|