@block-auth.io/core 0.4.0 → 0.4.2
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/LICENSE +15 -0
- package/dist/index.cjs +283 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.js +283 -35
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -939,6 +939,7 @@ var resetWeb3 = () => $web3.set({ ...initial6 });
|
|
|
939
939
|
var UI = "blockauth-ui";
|
|
940
940
|
var SESSION = "blockauth-session";
|
|
941
941
|
var EXTERNAL_SERVICE = "blockauth-connected";
|
|
942
|
+
var DEVICE_SESSION_ID = "blockauth-device-session-id";
|
|
942
943
|
var BLOCKAUTH_STORAGE_KEYS = [
|
|
943
944
|
SESSION,
|
|
944
945
|
UI,
|
|
@@ -1014,6 +1015,21 @@ var BrowserBase = class {
|
|
|
1014
1015
|
this.getExternalService();
|
|
1015
1016
|
}
|
|
1016
1017
|
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Stable id for this browser, generated once and persisted in localStorage
|
|
1020
|
+
* (every tab of this browser shares it, and it survives logout). Lets the
|
|
1021
|
+
* server scope a signout to just this browser instead of every device
|
|
1022
|
+
* signed in with the same account.
|
|
1023
|
+
*/
|
|
1024
|
+
getDeviceSessionId() {
|
|
1025
|
+
const storage = getStorage();
|
|
1026
|
+
if (!storage) return "";
|
|
1027
|
+
const existing = storage.getItem(DEVICE_SESSION_ID);
|
|
1028
|
+
if (existing) return existing;
|
|
1029
|
+
const generated = typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1030
|
+
storage.setItem(DEVICE_SESSION_ID, generated);
|
|
1031
|
+
return generated;
|
|
1032
|
+
}
|
|
1017
1033
|
/**
|
|
1018
1034
|
* Obtains the current UI configuration using localStorage as the
|
|
1019
1035
|
* source of truth, seeding the default if none is stored.
|
|
@@ -1071,7 +1087,8 @@ var BrowserBase = class {
|
|
|
1071
1087
|
const storage = getStorage();
|
|
1072
1088
|
if (!storage) return { ...EXTERNAL_SERVICE_CONFIG };
|
|
1073
1089
|
const currentConfig = storage.getItem(EXTERNAL_SERVICE);
|
|
1074
|
-
if (currentConfig)
|
|
1090
|
+
if (currentConfig)
|
|
1091
|
+
return JSON.parse(currentConfig);
|
|
1075
1092
|
storage.setItem(EXTERNAL_SERVICE, JSON.stringify(EXTERNAL_SERVICE_CONFIG));
|
|
1076
1093
|
return JSON.parse(
|
|
1077
1094
|
storage.getItem(EXTERNAL_SERVICE)
|
|
@@ -1161,8 +1178,10 @@ var BrowserBase = class {
|
|
|
1161
1178
|
if (!storage) return "en";
|
|
1162
1179
|
const lang = storage.getItem("lang");
|
|
1163
1180
|
if (lang) return lang;
|
|
1164
|
-
|
|
1165
|
-
|
|
1181
|
+
const nav = typeof navigator !== "undefined" ? navigator.language : "";
|
|
1182
|
+
const detected = (nav || "").toLowerCase().startsWith("es") ? "es" : "en";
|
|
1183
|
+
storage.setItem("lang", detected);
|
|
1184
|
+
return detected;
|
|
1166
1185
|
}
|
|
1167
1186
|
setLang(lang) {
|
|
1168
1187
|
getStorage()?.setItem("lang", lang);
|
|
@@ -1326,13 +1345,14 @@ function rejectTxn(args) {
|
|
|
1326
1345
|
args.wsc.emit("user:txns:update", { token: args.token, state: "cancelled" });
|
|
1327
1346
|
}
|
|
1328
1347
|
function acceptTxn(args) {
|
|
1329
|
-
const { wsc, token, lifetime, providerSlug, userParams } = args;
|
|
1348
|
+
const { wsc, token, lifetime, providerSlug, userParams, sessionId } = args;
|
|
1330
1349
|
wsc.emit("provider:signin", {
|
|
1331
1350
|
token,
|
|
1332
1351
|
lifetime,
|
|
1333
1352
|
state: "approved",
|
|
1334
1353
|
providerSlug,
|
|
1335
|
-
userParams: userParams ?? {}
|
|
1354
|
+
userParams: userParams ?? {},
|
|
1355
|
+
sessionId
|
|
1336
1356
|
});
|
|
1337
1357
|
}
|
|
1338
1358
|
function reportTxn(args) {
|
|
@@ -1778,7 +1798,7 @@ function connectBlockAuth() {
|
|
|
1778
1798
|
|
|
1779
1799
|
// src/auth/logout.ts
|
|
1780
1800
|
async function performLogout(args) {
|
|
1781
|
-
const { wsc, token, apiKey } = args;
|
|
1801
|
+
const { wsc, token, apiKey, sessionId } = args;
|
|
1782
1802
|
await new Promise((resolve) => {
|
|
1783
1803
|
let done = false;
|
|
1784
1804
|
const finish = () => {
|
|
@@ -1788,13 +1808,12 @@ async function performLogout(args) {
|
|
|
1788
1808
|
}
|
|
1789
1809
|
};
|
|
1790
1810
|
wsc.ws?.once?.("signout", finish);
|
|
1791
|
-
wsc.emit("signout", { token, apiKey });
|
|
1811
|
+
wsc.emit("signout", { token, apiKey, sessionId });
|
|
1792
1812
|
setTimeout(finish, 1500);
|
|
1793
1813
|
});
|
|
1794
1814
|
if (typeof localStorage !== "undefined") {
|
|
1795
1815
|
localStorage.setItem("blockauth-logged-out", "true");
|
|
1796
1816
|
}
|
|
1797
|
-
browserBase.reset("all");
|
|
1798
1817
|
resetWs();
|
|
1799
1818
|
resetUi();
|
|
1800
1819
|
resetWallet();
|
|
@@ -2062,6 +2081,7 @@ function createBlockAuthClient(config3) {
|
|
|
2062
2081
|
}
|
|
2063
2082
|
if (config3.google) configureGoogle(config3.google);
|
|
2064
2083
|
if (config3.microsoft) configureMicrosoft(config3.microsoft);
|
|
2084
|
+
setApiKey(config3.apiKey);
|
|
2065
2085
|
function userToken() {
|
|
2066
2086
|
const s = browserBase.getSession();
|
|
2067
2087
|
const ext = browserBase.getExternalService();
|
|
@@ -2075,7 +2095,8 @@ function createBlockAuthClient(config3) {
|
|
|
2075
2095
|
$openModals,
|
|
2076
2096
|
$user
|
|
2077
2097
|
},
|
|
2078
|
-
|
|
2098
|
+
/** App apiKey from client config (also seeded into $ws). */
|
|
2099
|
+
apiKey: config3.apiKey,
|
|
2079
2100
|
connect: (...a) => provider.connect(...a),
|
|
2080
2101
|
disconnect: () => provider.disconnect(),
|
|
2081
2102
|
signin: () => provider.signin(),
|
|
@@ -2100,11 +2121,23 @@ function createBlockAuthClient(config3) {
|
|
|
2100
2121
|
signupGoogle: async (flow = "auth-code") => {
|
|
2101
2122
|
const res = await signInWithGoogle(flow);
|
|
2102
2123
|
const signature = res.code ?? res.accessToken;
|
|
2103
|
-
await emitOauthSignup({
|
|
2124
|
+
await emitOauthSignup({
|
|
2125
|
+
wsc: provider.wsc,
|
|
2126
|
+
providerSlug: "google",
|
|
2127
|
+
signature,
|
|
2128
|
+
mode: flow,
|
|
2129
|
+
getIp
|
|
2130
|
+
});
|
|
2104
2131
|
},
|
|
2105
2132
|
signupMicrosoft: async () => {
|
|
2106
2133
|
const res = await signInWithMicrosoft();
|
|
2107
|
-
await emitOauthSignup({
|
|
2134
|
+
await emitOauthSignup({
|
|
2135
|
+
wsc: provider.wsc,
|
|
2136
|
+
providerSlug: "microsoft",
|
|
2137
|
+
signature: res.accessToken,
|
|
2138
|
+
mode: "popup",
|
|
2139
|
+
getIp
|
|
2140
|
+
});
|
|
2108
2141
|
}
|
|
2109
2142
|
},
|
|
2110
2143
|
// signin transaction + logout
|
|
@@ -2115,18 +2148,29 @@ function createBlockAuthClient(config3) {
|
|
|
2115
2148
|
service: $ui.get().serviceName ?? "blockauth",
|
|
2116
2149
|
apiKey: config3.apiKey
|
|
2117
2150
|
}),
|
|
2118
|
-
cancelTxns: () => cancelTxns({
|
|
2151
|
+
cancelTxns: () => cancelTxns({
|
|
2152
|
+
wsc: provider.wsc,
|
|
2153
|
+
token: userToken()
|
|
2154
|
+
}),
|
|
2119
2155
|
// transaction accept/reject
|
|
2120
2156
|
txns: {
|
|
2121
|
-
reject: () => rejectTxn({
|
|
2157
|
+
reject: () => rejectTxn({
|
|
2158
|
+
wsc: provider.wsc,
|
|
2159
|
+
token: userToken()
|
|
2160
|
+
}),
|
|
2122
2161
|
accept: (opts) => acceptTxn({
|
|
2123
2162
|
wsc: provider.wsc,
|
|
2124
2163
|
token: userToken(),
|
|
2125
2164
|
lifetime: opts.lifetime,
|
|
2126
2165
|
providerSlug: $ui.get().serviceName ?? "blockauth",
|
|
2127
|
-
userParams: opts.userParams
|
|
2166
|
+
userParams: opts.userParams,
|
|
2167
|
+
sessionId: browserBase.getDeviceSessionId()
|
|
2128
2168
|
}),
|
|
2129
|
-
report: (slug) => reportTxn({
|
|
2169
|
+
report: (slug) => reportTxn({
|
|
2170
|
+
wsc: provider.wsc,
|
|
2171
|
+
token: userToken(),
|
|
2172
|
+
report: slug
|
|
2173
|
+
})
|
|
2130
2174
|
},
|
|
2131
2175
|
// account restore: resolves when the backend answers; expired
|
|
2132
2176
|
// restorations surface the restorationExpired modal, other failures
|
|
@@ -2135,7 +2179,12 @@ function createBlockAuthClient(config3) {
|
|
|
2135
2179
|
// full deletion-state teardown after the user confirms the
|
|
2136
2180
|
// restoration-expired modal.
|
|
2137
2181
|
finalizeRestorationExpired: () => finalizeAfterRestorationExpired(),
|
|
2138
|
-
logout: () => performLogout({
|
|
2182
|
+
logout: () => performLogout({
|
|
2183
|
+
wsc: provider.wsc,
|
|
2184
|
+
token: userToken(),
|
|
2185
|
+
apiKey: config3.apiKey,
|
|
2186
|
+
sessionId: browserBase.getDeviceSessionId()
|
|
2187
|
+
}),
|
|
2139
2188
|
// modals (stack — supports overlaying signin on top of signup)
|
|
2140
2189
|
openModal,
|
|
2141
2190
|
closeModal,
|
|
@@ -2149,16 +2198,20 @@ function createBlockAuthClient(config3) {
|
|
|
2149
2198
|
}
|
|
2150
2199
|
|
|
2151
2200
|
// src/runtime/authRuntime.ts
|
|
2201
|
+
var SIGNIN_TIMEOUT_MS = 15e3;
|
|
2152
2202
|
function createAuthRuntime(client, callbacks = {}) {
|
|
2153
2203
|
const provider = client.provider;
|
|
2154
2204
|
const hookState = {
|
|
2155
2205
|
isUnsignTimeoutSet: false,
|
|
2156
2206
|
isSigned: false,
|
|
2157
2207
|
isSigning: false,
|
|
2158
|
-
|
|
2208
|
+
isLoggingOut: false,
|
|
2209
|
+
lastCheckedDid: null,
|
|
2210
|
+
signinAttemptId: 0
|
|
2159
2211
|
};
|
|
2160
2212
|
let getUserTxnsInterval = null;
|
|
2161
2213
|
let unsignTimeout = null;
|
|
2214
|
+
let signinTimeout = null;
|
|
2162
2215
|
const wsc = () => provider.wsc;
|
|
2163
2216
|
const onSuccess = callbacks.onSuccess ?? (async (_address) => {
|
|
2164
2217
|
});
|
|
@@ -2187,33 +2240,88 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2187
2240
|
await onError();
|
|
2188
2241
|
};
|
|
2189
2242
|
const _onLogout = async () => {
|
|
2243
|
+
if (hookState.isLoggingOut) return applyLocalLogout();
|
|
2244
|
+
hookState.isLoggingOut = true;
|
|
2190
2245
|
resetUser();
|
|
2246
|
+
if (typeof localStorage !== "undefined") {
|
|
2247
|
+
localStorage.setItem("blockauth-logged-out", "true");
|
|
2248
|
+
}
|
|
2191
2249
|
try {
|
|
2192
2250
|
if (provider && provider.wsc) {
|
|
2193
2251
|
const s = browserBase.getSession();
|
|
2194
2252
|
const ext = browserBase.getExternalService();
|
|
2195
2253
|
const _token = ext.service !== "blockauth" ? ext.token : s.token;
|
|
2196
|
-
const _apiKey = $ws.get().apiKey;
|
|
2254
|
+
const _apiKey = $ws.get().apiKey ?? client.apiKey;
|
|
2255
|
+
const _sessionId = browserBase.getDeviceSessionId();
|
|
2197
2256
|
await new Promise((resolve) => {
|
|
2198
2257
|
const timeout = setTimeout(resolve, 3e3);
|
|
2199
2258
|
wsc().ws.once("signout", () => {
|
|
2200
2259
|
clearTimeout(timeout);
|
|
2201
2260
|
resolve();
|
|
2202
2261
|
});
|
|
2203
|
-
wsc().emit("signout", {
|
|
2262
|
+
wsc().emit("signout", {
|
|
2263
|
+
token: _token,
|
|
2264
|
+
apiKey: _apiKey,
|
|
2265
|
+
sessionId: _sessionId
|
|
2266
|
+
});
|
|
2204
2267
|
});
|
|
2205
2268
|
}
|
|
2206
2269
|
} catch {
|
|
2207
2270
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2271
|
+
await applyLocalLogout();
|
|
2272
|
+
};
|
|
2273
|
+
let logoutInFlight = null;
|
|
2274
|
+
const applyLocalLogout = async () => {
|
|
2275
|
+
if (logoutInFlight) return logoutInFlight;
|
|
2276
|
+
logoutInFlight = (async () => {
|
|
2277
|
+
hookState.isLoggingOut = true;
|
|
2278
|
+
if (unsignTimeout) {
|
|
2279
|
+
clearTimeout(unsignTimeout);
|
|
2280
|
+
unsignTimeout = null;
|
|
2281
|
+
}
|
|
2282
|
+
hookState.isUnsignTimeoutSet = false;
|
|
2283
|
+
if (signinTimeout) {
|
|
2284
|
+
clearTimeout(signinTimeout);
|
|
2285
|
+
signinTimeout = null;
|
|
2286
|
+
}
|
|
2287
|
+
if (getUserTxnsInterval) {
|
|
2288
|
+
clearInterval(getUserTxnsInterval);
|
|
2289
|
+
getUserTxnsInterval = null;
|
|
2290
|
+
}
|
|
2291
|
+
hookState.isSigning = false;
|
|
2292
|
+
hookState.isSigned = false;
|
|
2293
|
+
setIsSigned(false);
|
|
2294
|
+
setIsSigning(false);
|
|
2295
|
+
setIsSigningLoader(false);
|
|
2296
|
+
setIsAcceptingTxn(false);
|
|
2297
|
+
setIsSignedFirstCheck(true);
|
|
2298
|
+
resetUser();
|
|
2299
|
+
if (typeof localStorage !== "undefined") {
|
|
2300
|
+
localStorage.setItem("blockauth-logged-out", "true");
|
|
2301
|
+
}
|
|
2302
|
+
const serviceName = browserBase.getExternalService().service;
|
|
2303
|
+
setIsServiceConnected(false);
|
|
2304
|
+
setWaitingForSuccessLogInSince(0);
|
|
2305
|
+
setServiceIcon(imgUrlByService(serviceName));
|
|
2306
|
+
setServiceName(serviceName);
|
|
2307
|
+
try {
|
|
2308
|
+
await onLogout();
|
|
2309
|
+
} finally {
|
|
2310
|
+
hookState.isLoggingOut = false;
|
|
2311
|
+
}
|
|
2312
|
+
})().finally(() => {
|
|
2313
|
+
logoutInFlight = null;
|
|
2314
|
+
});
|
|
2315
|
+
return logoutInFlight;
|
|
2316
|
+
};
|
|
2317
|
+
const onStorageLogout = (event) => {
|
|
2318
|
+
if (event.key !== "blockauth-logged-out" || event.newValue !== "true") {
|
|
2319
|
+
return;
|
|
2210
2320
|
}
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
setServiceName(serviceName);
|
|
2216
|
-
await onLogout();
|
|
2321
|
+
if (hookState.isLoggingOut || !hookState.isSigned) return;
|
|
2322
|
+
void applyLocalLogout().catch((err) => {
|
|
2323
|
+
console.error("[sdk] applyLocalLogout failed (storage event):", err);
|
|
2324
|
+
});
|
|
2217
2325
|
};
|
|
2218
2326
|
const deletion = createDeletionService({ provider });
|
|
2219
2327
|
const handleUserDeleted = (forAddress = null) => {
|
|
@@ -2304,7 +2412,7 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2304
2412
|
};
|
|
2305
2413
|
const signinUnsigned = async () => {
|
|
2306
2414
|
setIsSignedFirstCheck(true);
|
|
2307
|
-
if (!hookState.isSigned
|
|
2415
|
+
if (!hookState.isSigned) {
|
|
2308
2416
|
const ext = browserBase.getExternalService();
|
|
2309
2417
|
if (ext.connected && typeof localStorage !== "undefined") {
|
|
2310
2418
|
localStorage.setItem("blockauth-logged-out", "true");
|
|
@@ -2325,11 +2433,18 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2325
2433
|
browserBase.clearBrowserState({ keepExtensionInstalled: keepInstalled });
|
|
2326
2434
|
const result = message.items.at(0);
|
|
2327
2435
|
onSignup(result);
|
|
2328
|
-
|
|
2436
|
+
if (result?.isNewAccount) {
|
|
2437
|
+
setIsSignedFirstCheck(true);
|
|
2438
|
+
} else {
|
|
2439
|
+
void isUserSignedIn();
|
|
2440
|
+
}
|
|
2329
2441
|
};
|
|
2330
2442
|
const onProviderSignin = (data) => {
|
|
2331
2443
|
const { success, message } = data;
|
|
2332
|
-
if (!success)
|
|
2444
|
+
if (!success) {
|
|
2445
|
+
void _onError();
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2333
2448
|
if (message.items.length <= 0) return;
|
|
2334
2449
|
if (typeof localStorage !== "undefined") {
|
|
2335
2450
|
localStorage.removeItem("blockauth-logged-out");
|
|
@@ -2356,6 +2471,14 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2356
2471
|
if (success) {
|
|
2357
2472
|
setIsSigning(true);
|
|
2358
2473
|
hookState.isSigning = true;
|
|
2474
|
+
const attemptId = ++hookState.signinAttemptId;
|
|
2475
|
+
if (signinTimeout) clearTimeout(signinTimeout);
|
|
2476
|
+
signinTimeout = setTimeout(() => {
|
|
2477
|
+
signinTimeout = null;
|
|
2478
|
+
if (hookState.isSigning && hookState.signinAttemptId === attemptId) {
|
|
2479
|
+
void signinUnsigned();
|
|
2480
|
+
}
|
|
2481
|
+
}, SIGNIN_TIMEOUT_MS);
|
|
2359
2482
|
const s = browserBase.getSession();
|
|
2360
2483
|
const externalService = browserBase.getExternalService();
|
|
2361
2484
|
let token = s.token;
|
|
@@ -2475,6 +2598,21 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2475
2598
|
const onSdkSignRefresh = () => {
|
|
2476
2599
|
void isUserSignedIn();
|
|
2477
2600
|
};
|
|
2601
|
+
const onSdkSessionInvalidated = (data) => {
|
|
2602
|
+
const apiKey = data?.apiKey ?? data?.message?.apiKey;
|
|
2603
|
+
const clientApiKey = $ws.get().apiKey ?? client.apiKey;
|
|
2604
|
+
if (!apiKey || !clientApiKey || apiKey !== clientApiKey) return;
|
|
2605
|
+
const sessionId = data?.sessionId ?? data?.message?.sessionId;
|
|
2606
|
+
if (sessionId != null && String(sessionId) !== String(browserBase.getDeviceSessionId()))
|
|
2607
|
+
return;
|
|
2608
|
+
if (hookState.isLoggingOut || !hookState.isSigned) return;
|
|
2609
|
+
void applyLocalLogout().catch((err) => {
|
|
2610
|
+
console.error(
|
|
2611
|
+
"[sdk] applyLocalLogout failed (session invalidated):",
|
|
2612
|
+
err
|
|
2613
|
+
);
|
|
2614
|
+
});
|
|
2615
|
+
};
|
|
2478
2616
|
const onSdkUserRolesChanged = async (data) => {
|
|
2479
2617
|
const { success, message } = data || {};
|
|
2480
2618
|
if (!success || !message?.address) return;
|
|
@@ -2493,7 +2631,9 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2493
2631
|
if (data.message?.session) {
|
|
2494
2632
|
const session = data.message.session;
|
|
2495
2633
|
const keepInstalled = browserBase.getUI().installed;
|
|
2496
|
-
browserBase.clearBrowserState({
|
|
2634
|
+
browserBase.clearBrowserState({
|
|
2635
|
+
keepExtensionInstalled: keepInstalled
|
|
2636
|
+
});
|
|
2497
2637
|
browserBase.setSession({
|
|
2498
2638
|
did: session.did,
|
|
2499
2639
|
token: session.token,
|
|
@@ -2528,11 +2668,15 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2528
2668
|
}
|
|
2529
2669
|
setDid(_did);
|
|
2530
2670
|
setToken(_token);
|
|
2531
|
-
setApiKey($ws.get().apiKey);
|
|
2671
|
+
setApiKey(client.apiKey ?? $ws.get().apiKey);
|
|
2532
2672
|
setIsServiceConnected(externalService.connected);
|
|
2533
2673
|
setServiceName(externalService.service);
|
|
2534
2674
|
setServiceIcon(imgUrlByService(externalService.service));
|
|
2535
|
-
await provider.connect(
|
|
2675
|
+
await provider.connect(
|
|
2676
|
+
client.wsConnectTimeout ?? 300,
|
|
2677
|
+
"",
|
|
2678
|
+
client.wsConnectRetries ?? 3
|
|
2679
|
+
);
|
|
2536
2680
|
const isConnected = await provider.isConnected();
|
|
2537
2681
|
if (!isConnected) {
|
|
2538
2682
|
setIsCheckingAppActive(false);
|
|
@@ -2563,8 +2707,12 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2563
2707
|
wsc().on("signin:unsigned", onSigninUnsigned);
|
|
2564
2708
|
wsc().on("signin:onDeletion", onSigninOnDeletion);
|
|
2565
2709
|
wsc().on("sdk:sign:refresh", onSdkSignRefresh);
|
|
2710
|
+
wsc().on("sdk:session:invalidated", onSdkSessionInvalidated);
|
|
2566
2711
|
wsc().on("sdk:user:roles:changed", onSdkUserRolesChanged);
|
|
2567
2712
|
wsc().on("sdk:restore", onSdkRestore);
|
|
2713
|
+
if (typeof window !== "undefined") {
|
|
2714
|
+
window.addEventListener("storage", onStorageLogout);
|
|
2715
|
+
}
|
|
2568
2716
|
const { domain, signinCallbackUrl, config: config3 } = await provider.app();
|
|
2569
2717
|
setUiConfig({ domain, signinCallbackUrl, config: config3 });
|
|
2570
2718
|
setReady(true);
|
|
@@ -2576,6 +2724,11 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2576
2724
|
unsignTimeout = null;
|
|
2577
2725
|
}
|
|
2578
2726
|
hookState.isUnsignTimeoutSet = false;
|
|
2727
|
+
if (signinTimeout) {
|
|
2728
|
+
clearTimeout(signinTimeout);
|
|
2729
|
+
signinTimeout = null;
|
|
2730
|
+
}
|
|
2731
|
+
hookState.isSigning = false;
|
|
2579
2732
|
if (getUserTxnsInterval) {
|
|
2580
2733
|
clearInterval(getUserTxnsInterval);
|
|
2581
2734
|
getUserTxnsInterval = null;
|
|
@@ -2595,9 +2748,13 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2595
2748
|
w.off("signin:unsigned", onSigninUnsigned);
|
|
2596
2749
|
w.off("signin:onDeletion", onSigninOnDeletion);
|
|
2597
2750
|
w.off("sdk:sign:refresh", onSdkSignRefresh);
|
|
2751
|
+
w.off("sdk:session:invalidated", onSdkSessionInvalidated);
|
|
2598
2752
|
w.off("sdk:user:roles:changed", onSdkUserRolesChanged);
|
|
2599
2753
|
w.off("sdk:restore", onSdkRestore);
|
|
2600
2754
|
}
|
|
2755
|
+
if (typeof window !== "undefined") {
|
|
2756
|
+
window.removeEventListener("storage", onStorageLogout);
|
|
2757
|
+
}
|
|
2601
2758
|
provider.disconnect();
|
|
2602
2759
|
};
|
|
2603
2760
|
const logout = async () => {
|
|
@@ -2646,8 +2803,99 @@ var TEXTS = {
|
|
|
2646
2803
|
webTypeAll: { es: "Todos", en: "All" },
|
|
2647
2804
|
login: { es: "Iniciar sesi\xF3n", en: "Log In" },
|
|
2648
2805
|
lastStep: { es: "Completa el \xFAltimo paso", en: "Complete the last step" },
|
|
2649
|
-
footerFirst: {
|
|
2650
|
-
|
|
2806
|
+
footerFirst: {
|
|
2807
|
+
es: "\xBFEsperando un registro aburrido?",
|
|
2808
|
+
en: "Expecting a boring signup?"
|
|
2809
|
+
},
|
|
2810
|
+
footerSecond: {
|
|
2811
|
+
es: "Di adi\xF3s a las contrase\xF1as",
|
|
2812
|
+
en: "Say goodbye to passwords"
|
|
2813
|
+
},
|
|
2814
|
+
permissionsRequired: {
|
|
2815
|
+
es: "Permisos requeridos",
|
|
2816
|
+
en: "Permissions required"
|
|
2817
|
+
},
|
|
2818
|
+
solicitedData: { es: "Datos solicitados", en: "Solicited data" },
|
|
2819
|
+
reject: { es: "RECHAZAR", en: "REJECT" },
|
|
2820
|
+
accept: { es: "ACEPTAR", en: "ACCEPT" },
|
|
2821
|
+
iAuthorizeThe: { es: "Autorizo la", en: "I authorize the" },
|
|
2822
|
+
privacyPolicy: { es: "Pol\xEDtica de Privacidad", en: "Privacy Policy" },
|
|
2823
|
+
andThe: { es: "y los", en: "and the" },
|
|
2824
|
+
termsAndConditions: {
|
|
2825
|
+
es: "T\xE9rminos y Condiciones",
|
|
2826
|
+
en: "Terms and Conditions"
|
|
2827
|
+
},
|
|
2828
|
+
configureSessionTime: {
|
|
2829
|
+
es: "Quiero configurar el tiempo de mi sesi\xF3n",
|
|
2830
|
+
en: "I want to configure my session time"
|
|
2831
|
+
},
|
|
2832
|
+
solicitsTo: { es: "solicita a", en: "solicits to" },
|
|
2833
|
+
required: { es: "Requerido", en: "Required" },
|
|
2834
|
+
optional: { es: "Opcional", en: "Optional" },
|
|
2835
|
+
fillRequiredFields: {
|
|
2836
|
+
es: "Completa los campos requeridos para continuar",
|
|
2837
|
+
en: "Fill required fields to continue"
|
|
2838
|
+
},
|
|
2839
|
+
noTransactionsFound: {
|
|
2840
|
+
es: "No se encontraron transacciones",
|
|
2841
|
+
en: "No transactions found"
|
|
2842
|
+
},
|
|
2843
|
+
noAppKeyFound: {
|
|
2844
|
+
es: "No se encontr\xF3 la clave de la aplicaci\xF3n",
|
|
2845
|
+
en: "No application key found"
|
|
2846
|
+
},
|
|
2847
|
+
noContractAddressFound: {
|
|
2848
|
+
es: "No se encontr\xF3 la direcci\xF3n del contrato",
|
|
2849
|
+
en: "No contract address found"
|
|
2850
|
+
},
|
|
2851
|
+
noTransactionsParamsFound: {
|
|
2852
|
+
es: "No se encontraron par\xE1metros de la transacci\xF3n",
|
|
2853
|
+
en: "No transaction params found"
|
|
2854
|
+
},
|
|
2855
|
+
somethingWentWrong: { es: "Algo sali\xF3 mal", en: "Something went wrong" },
|
|
2856
|
+
permTemporalIdentity: {
|
|
2857
|
+
es: "Acceso temporal a tu identidad",
|
|
2858
|
+
en: "Temporal access to identity"
|
|
2859
|
+
},
|
|
2860
|
+
permAuthorisedApps: {
|
|
2861
|
+
es: "Acceso a la lista de aplicaciones autorizadas",
|
|
2862
|
+
en: "Access to the list of authorised apps"
|
|
2863
|
+
},
|
|
2864
|
+
permOnlyThisTxn: {
|
|
2865
|
+
es: "Solo se firmar\xE1 esta transacci\xF3n",
|
|
2866
|
+
en: "Only this transaction will be signed"
|
|
2867
|
+
},
|
|
2868
|
+
firstName: { es: "Nombre", en: "First Name" },
|
|
2869
|
+
lastName: { es: "Apellido", en: "Last Name" },
|
|
2870
|
+
secondLastName: { es: "Segundo apellido", en: "Second Last Name" },
|
|
2871
|
+
email: { es: "Correo electr\xF3nico", en: "Email" },
|
|
2872
|
+
phone: { es: "Tel\xE9fono", en: "Phone" },
|
|
2873
|
+
onlyLettersAllowed: {
|
|
2874
|
+
es: "Solo se permiten letras y espacios",
|
|
2875
|
+
en: "Only letters and spaces allowed"
|
|
2876
|
+
},
|
|
2877
|
+
enterValidEmail: {
|
|
2878
|
+
es: "Introduce un correo electr\xF3nico v\xE1lido (ej. nombre@dominio.com)",
|
|
2879
|
+
en: "Enter a valid email (e.g. name@domain.com)"
|
|
2880
|
+
},
|
|
2881
|
+
enterValidPhone: {
|
|
2882
|
+
es: "Introduce un n\xFAmero de tel\xE9fono v\xE1lido",
|
|
2883
|
+
en: "Enter a valid phone number"
|
|
2884
|
+
},
|
|
2885
|
+
helpUsReport: {
|
|
2886
|
+
es: "Ay\xFAdanos a mejorar y reporta el error aqu\xED",
|
|
2887
|
+
en: "Help us get better and report the error here"
|
|
2888
|
+
},
|
|
2889
|
+
thanksForReport: {
|
|
2890
|
+
es: "\xA1Gracias por reportar el error!",
|
|
2891
|
+
en: "Thanks for reporting the error!"
|
|
2892
|
+
},
|
|
2893
|
+
report: { es: "REPORTAR", en: "REPORT" },
|
|
2894
|
+
close: { es: "Cerrar", en: "Close" },
|
|
2895
|
+
modalWillCloseIn: {
|
|
2896
|
+
es: "Este modal se cerrar\xE1 en...",
|
|
2897
|
+
en: "This modal will close in..."
|
|
2898
|
+
}
|
|
2651
2899
|
};
|
|
2652
2900
|
function t(key, locale = "en") {
|
|
2653
2901
|
const entry = TEXTS[key];
|