@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/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Block-Auth (block-auth.io)
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -947,6 +947,7 @@ var resetWeb3 = () => $web3.set({ ...initial6 });
|
|
|
947
947
|
var UI = "blockauth-ui";
|
|
948
948
|
var SESSION = "blockauth-session";
|
|
949
949
|
var EXTERNAL_SERVICE = "blockauth-connected";
|
|
950
|
+
var DEVICE_SESSION_ID = "blockauth-device-session-id";
|
|
950
951
|
var BLOCKAUTH_STORAGE_KEYS = [
|
|
951
952
|
SESSION,
|
|
952
953
|
UI,
|
|
@@ -1022,6 +1023,21 @@ var BrowserBase = class {
|
|
|
1022
1023
|
this.getExternalService();
|
|
1023
1024
|
}
|
|
1024
1025
|
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Stable id for this browser, generated once and persisted in localStorage
|
|
1028
|
+
* (every tab of this browser shares it, and it survives logout). Lets the
|
|
1029
|
+
* server scope a signout to just this browser instead of every device
|
|
1030
|
+
* signed in with the same account.
|
|
1031
|
+
*/
|
|
1032
|
+
getDeviceSessionId() {
|
|
1033
|
+
const storage = getStorage();
|
|
1034
|
+
if (!storage) return "";
|
|
1035
|
+
const existing = storage.getItem(DEVICE_SESSION_ID);
|
|
1036
|
+
if (existing) return existing;
|
|
1037
|
+
const generated = typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1038
|
+
storage.setItem(DEVICE_SESSION_ID, generated);
|
|
1039
|
+
return generated;
|
|
1040
|
+
}
|
|
1025
1041
|
/**
|
|
1026
1042
|
* Obtains the current UI configuration using localStorage as the
|
|
1027
1043
|
* source of truth, seeding the default if none is stored.
|
|
@@ -1079,7 +1095,8 @@ var BrowserBase = class {
|
|
|
1079
1095
|
const storage = getStorage();
|
|
1080
1096
|
if (!storage) return { ...EXTERNAL_SERVICE_CONFIG };
|
|
1081
1097
|
const currentConfig = storage.getItem(EXTERNAL_SERVICE);
|
|
1082
|
-
if (currentConfig)
|
|
1098
|
+
if (currentConfig)
|
|
1099
|
+
return JSON.parse(currentConfig);
|
|
1083
1100
|
storage.setItem(EXTERNAL_SERVICE, JSON.stringify(EXTERNAL_SERVICE_CONFIG));
|
|
1084
1101
|
return JSON.parse(
|
|
1085
1102
|
storage.getItem(EXTERNAL_SERVICE)
|
|
@@ -1169,8 +1186,10 @@ var BrowserBase = class {
|
|
|
1169
1186
|
if (!storage) return "en";
|
|
1170
1187
|
const lang = storage.getItem("lang");
|
|
1171
1188
|
if (lang) return lang;
|
|
1172
|
-
|
|
1173
|
-
|
|
1189
|
+
const nav = typeof navigator !== "undefined" ? navigator.language : "";
|
|
1190
|
+
const detected = (nav || "").toLowerCase().startsWith("es") ? "es" : "en";
|
|
1191
|
+
storage.setItem("lang", detected);
|
|
1192
|
+
return detected;
|
|
1174
1193
|
}
|
|
1175
1194
|
setLang(lang) {
|
|
1176
1195
|
getStorage()?.setItem("lang", lang);
|
|
@@ -1334,13 +1353,14 @@ function rejectTxn(args) {
|
|
|
1334
1353
|
args.wsc.emit("user:txns:update", { token: args.token, state: "cancelled" });
|
|
1335
1354
|
}
|
|
1336
1355
|
function acceptTxn(args) {
|
|
1337
|
-
const { wsc, token, lifetime, providerSlug, userParams } = args;
|
|
1356
|
+
const { wsc, token, lifetime, providerSlug, userParams, sessionId } = args;
|
|
1338
1357
|
wsc.emit("provider:signin", {
|
|
1339
1358
|
token,
|
|
1340
1359
|
lifetime,
|
|
1341
1360
|
state: "approved",
|
|
1342
1361
|
providerSlug,
|
|
1343
|
-
userParams: userParams ?? {}
|
|
1362
|
+
userParams: userParams ?? {},
|
|
1363
|
+
sessionId
|
|
1344
1364
|
});
|
|
1345
1365
|
}
|
|
1346
1366
|
function reportTxn(args) {
|
|
@@ -1786,7 +1806,7 @@ function connectBlockAuth() {
|
|
|
1786
1806
|
|
|
1787
1807
|
// src/auth/logout.ts
|
|
1788
1808
|
async function performLogout(args) {
|
|
1789
|
-
const { wsc, token, apiKey } = args;
|
|
1809
|
+
const { wsc, token, apiKey, sessionId } = args;
|
|
1790
1810
|
await new Promise((resolve) => {
|
|
1791
1811
|
let done = false;
|
|
1792
1812
|
const finish = () => {
|
|
@@ -1796,13 +1816,12 @@ async function performLogout(args) {
|
|
|
1796
1816
|
}
|
|
1797
1817
|
};
|
|
1798
1818
|
wsc.ws?.once?.("signout", finish);
|
|
1799
|
-
wsc.emit("signout", { token, apiKey });
|
|
1819
|
+
wsc.emit("signout", { token, apiKey, sessionId });
|
|
1800
1820
|
setTimeout(finish, 1500);
|
|
1801
1821
|
});
|
|
1802
1822
|
if (typeof localStorage !== "undefined") {
|
|
1803
1823
|
localStorage.setItem("blockauth-logged-out", "true");
|
|
1804
1824
|
}
|
|
1805
|
-
browserBase.reset("all");
|
|
1806
1825
|
resetWs();
|
|
1807
1826
|
resetUi();
|
|
1808
1827
|
resetWallet();
|
|
@@ -2070,6 +2089,7 @@ function createBlockAuthClient(config3) {
|
|
|
2070
2089
|
}
|
|
2071
2090
|
if (config3.google) configureGoogle(config3.google);
|
|
2072
2091
|
if (config3.microsoft) configureMicrosoft(config3.microsoft);
|
|
2092
|
+
setApiKey(config3.apiKey);
|
|
2073
2093
|
function userToken() {
|
|
2074
2094
|
const s = browserBase.getSession();
|
|
2075
2095
|
const ext = browserBase.getExternalService();
|
|
@@ -2083,7 +2103,8 @@ function createBlockAuthClient(config3) {
|
|
|
2083
2103
|
$openModals,
|
|
2084
2104
|
$user
|
|
2085
2105
|
},
|
|
2086
|
-
|
|
2106
|
+
/** App apiKey from client config (also seeded into $ws). */
|
|
2107
|
+
apiKey: config3.apiKey,
|
|
2087
2108
|
connect: (...a) => provider.connect(...a),
|
|
2088
2109
|
disconnect: () => provider.disconnect(),
|
|
2089
2110
|
signin: () => provider.signin(),
|
|
@@ -2108,11 +2129,23 @@ function createBlockAuthClient(config3) {
|
|
|
2108
2129
|
signupGoogle: async (flow = "auth-code") => {
|
|
2109
2130
|
const res = await signInWithGoogle(flow);
|
|
2110
2131
|
const signature = res.code ?? res.accessToken;
|
|
2111
|
-
await emitOauthSignup({
|
|
2132
|
+
await emitOauthSignup({
|
|
2133
|
+
wsc: provider.wsc,
|
|
2134
|
+
providerSlug: "google",
|
|
2135
|
+
signature,
|
|
2136
|
+
mode: flow,
|
|
2137
|
+
getIp
|
|
2138
|
+
});
|
|
2112
2139
|
},
|
|
2113
2140
|
signupMicrosoft: async () => {
|
|
2114
2141
|
const res = await signInWithMicrosoft();
|
|
2115
|
-
await emitOauthSignup({
|
|
2142
|
+
await emitOauthSignup({
|
|
2143
|
+
wsc: provider.wsc,
|
|
2144
|
+
providerSlug: "microsoft",
|
|
2145
|
+
signature: res.accessToken,
|
|
2146
|
+
mode: "popup",
|
|
2147
|
+
getIp
|
|
2148
|
+
});
|
|
2116
2149
|
}
|
|
2117
2150
|
},
|
|
2118
2151
|
// signin transaction + logout
|
|
@@ -2123,18 +2156,29 @@ function createBlockAuthClient(config3) {
|
|
|
2123
2156
|
service: $ui.get().serviceName ?? "blockauth",
|
|
2124
2157
|
apiKey: config3.apiKey
|
|
2125
2158
|
}),
|
|
2126
|
-
cancelTxns: () => cancelTxns({
|
|
2159
|
+
cancelTxns: () => cancelTxns({
|
|
2160
|
+
wsc: provider.wsc,
|
|
2161
|
+
token: userToken()
|
|
2162
|
+
}),
|
|
2127
2163
|
// transaction accept/reject
|
|
2128
2164
|
txns: {
|
|
2129
|
-
reject: () => rejectTxn({
|
|
2165
|
+
reject: () => rejectTxn({
|
|
2166
|
+
wsc: provider.wsc,
|
|
2167
|
+
token: userToken()
|
|
2168
|
+
}),
|
|
2130
2169
|
accept: (opts) => acceptTxn({
|
|
2131
2170
|
wsc: provider.wsc,
|
|
2132
2171
|
token: userToken(),
|
|
2133
2172
|
lifetime: opts.lifetime,
|
|
2134
2173
|
providerSlug: $ui.get().serviceName ?? "blockauth",
|
|
2135
|
-
userParams: opts.userParams
|
|
2174
|
+
userParams: opts.userParams,
|
|
2175
|
+
sessionId: browserBase.getDeviceSessionId()
|
|
2136
2176
|
}),
|
|
2137
|
-
report: (slug) => reportTxn({
|
|
2177
|
+
report: (slug) => reportTxn({
|
|
2178
|
+
wsc: provider.wsc,
|
|
2179
|
+
token: userToken(),
|
|
2180
|
+
report: slug
|
|
2181
|
+
})
|
|
2138
2182
|
},
|
|
2139
2183
|
// account restore: resolves when the backend answers; expired
|
|
2140
2184
|
// restorations surface the restorationExpired modal, other failures
|
|
@@ -2143,7 +2187,12 @@ function createBlockAuthClient(config3) {
|
|
|
2143
2187
|
// full deletion-state teardown after the user confirms the
|
|
2144
2188
|
// restoration-expired modal.
|
|
2145
2189
|
finalizeRestorationExpired: () => finalizeAfterRestorationExpired(),
|
|
2146
|
-
logout: () => performLogout({
|
|
2190
|
+
logout: () => performLogout({
|
|
2191
|
+
wsc: provider.wsc,
|
|
2192
|
+
token: userToken(),
|
|
2193
|
+
apiKey: config3.apiKey,
|
|
2194
|
+
sessionId: browserBase.getDeviceSessionId()
|
|
2195
|
+
}),
|
|
2147
2196
|
// modals (stack — supports overlaying signin on top of signup)
|
|
2148
2197
|
openModal,
|
|
2149
2198
|
closeModal,
|
|
@@ -2157,16 +2206,20 @@ function createBlockAuthClient(config3) {
|
|
|
2157
2206
|
}
|
|
2158
2207
|
|
|
2159
2208
|
// src/runtime/authRuntime.ts
|
|
2209
|
+
var SIGNIN_TIMEOUT_MS = 15e3;
|
|
2160
2210
|
function createAuthRuntime(client, callbacks = {}) {
|
|
2161
2211
|
const provider = client.provider;
|
|
2162
2212
|
const hookState = {
|
|
2163
2213
|
isUnsignTimeoutSet: false,
|
|
2164
2214
|
isSigned: false,
|
|
2165
2215
|
isSigning: false,
|
|
2166
|
-
|
|
2216
|
+
isLoggingOut: false,
|
|
2217
|
+
lastCheckedDid: null,
|
|
2218
|
+
signinAttemptId: 0
|
|
2167
2219
|
};
|
|
2168
2220
|
let getUserTxnsInterval = null;
|
|
2169
2221
|
let unsignTimeout = null;
|
|
2222
|
+
let signinTimeout = null;
|
|
2170
2223
|
const wsc = () => provider.wsc;
|
|
2171
2224
|
const onSuccess = callbacks.onSuccess ?? (async (_address) => {
|
|
2172
2225
|
});
|
|
@@ -2195,33 +2248,88 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2195
2248
|
await onError();
|
|
2196
2249
|
};
|
|
2197
2250
|
const _onLogout = async () => {
|
|
2251
|
+
if (hookState.isLoggingOut) return applyLocalLogout();
|
|
2252
|
+
hookState.isLoggingOut = true;
|
|
2198
2253
|
resetUser();
|
|
2254
|
+
if (typeof localStorage !== "undefined") {
|
|
2255
|
+
localStorage.setItem("blockauth-logged-out", "true");
|
|
2256
|
+
}
|
|
2199
2257
|
try {
|
|
2200
2258
|
if (provider && provider.wsc) {
|
|
2201
2259
|
const s = browserBase.getSession();
|
|
2202
2260
|
const ext = browserBase.getExternalService();
|
|
2203
2261
|
const _token = ext.service !== "blockauth" ? ext.token : s.token;
|
|
2204
|
-
const _apiKey = $ws.get().apiKey;
|
|
2262
|
+
const _apiKey = $ws.get().apiKey ?? client.apiKey;
|
|
2263
|
+
const _sessionId = browserBase.getDeviceSessionId();
|
|
2205
2264
|
await new Promise((resolve) => {
|
|
2206
2265
|
const timeout = setTimeout(resolve, 3e3);
|
|
2207
2266
|
wsc().ws.once("signout", () => {
|
|
2208
2267
|
clearTimeout(timeout);
|
|
2209
2268
|
resolve();
|
|
2210
2269
|
});
|
|
2211
|
-
wsc().emit("signout", {
|
|
2270
|
+
wsc().emit("signout", {
|
|
2271
|
+
token: _token,
|
|
2272
|
+
apiKey: _apiKey,
|
|
2273
|
+
sessionId: _sessionId
|
|
2274
|
+
});
|
|
2212
2275
|
});
|
|
2213
2276
|
}
|
|
2214
2277
|
} catch {
|
|
2215
2278
|
}
|
|
2216
|
-
|
|
2217
|
-
|
|
2279
|
+
await applyLocalLogout();
|
|
2280
|
+
};
|
|
2281
|
+
let logoutInFlight = null;
|
|
2282
|
+
const applyLocalLogout = async () => {
|
|
2283
|
+
if (logoutInFlight) return logoutInFlight;
|
|
2284
|
+
logoutInFlight = (async () => {
|
|
2285
|
+
hookState.isLoggingOut = true;
|
|
2286
|
+
if (unsignTimeout) {
|
|
2287
|
+
clearTimeout(unsignTimeout);
|
|
2288
|
+
unsignTimeout = null;
|
|
2289
|
+
}
|
|
2290
|
+
hookState.isUnsignTimeoutSet = false;
|
|
2291
|
+
if (signinTimeout) {
|
|
2292
|
+
clearTimeout(signinTimeout);
|
|
2293
|
+
signinTimeout = null;
|
|
2294
|
+
}
|
|
2295
|
+
if (getUserTxnsInterval) {
|
|
2296
|
+
clearInterval(getUserTxnsInterval);
|
|
2297
|
+
getUserTxnsInterval = null;
|
|
2298
|
+
}
|
|
2299
|
+
hookState.isSigning = false;
|
|
2300
|
+
hookState.isSigned = false;
|
|
2301
|
+
setIsSigned(false);
|
|
2302
|
+
setIsSigning(false);
|
|
2303
|
+
setIsSigningLoader(false);
|
|
2304
|
+
setIsAcceptingTxn(false);
|
|
2305
|
+
setIsSignedFirstCheck(true);
|
|
2306
|
+
resetUser();
|
|
2307
|
+
if (typeof localStorage !== "undefined") {
|
|
2308
|
+
localStorage.setItem("blockauth-logged-out", "true");
|
|
2309
|
+
}
|
|
2310
|
+
const serviceName = browserBase.getExternalService().service;
|
|
2311
|
+
setIsServiceConnected(false);
|
|
2312
|
+
setWaitingForSuccessLogInSince(0);
|
|
2313
|
+
setServiceIcon(imgUrlByService(serviceName));
|
|
2314
|
+
setServiceName(serviceName);
|
|
2315
|
+
try {
|
|
2316
|
+
await onLogout();
|
|
2317
|
+
} finally {
|
|
2318
|
+
hookState.isLoggingOut = false;
|
|
2319
|
+
}
|
|
2320
|
+
})().finally(() => {
|
|
2321
|
+
logoutInFlight = null;
|
|
2322
|
+
});
|
|
2323
|
+
return logoutInFlight;
|
|
2324
|
+
};
|
|
2325
|
+
const onStorageLogout = (event) => {
|
|
2326
|
+
if (event.key !== "blockauth-logged-out" || event.newValue !== "true") {
|
|
2327
|
+
return;
|
|
2218
2328
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
setServiceName(serviceName);
|
|
2224
|
-
await onLogout();
|
|
2329
|
+
if (hookState.isLoggingOut || !hookState.isSigned) return;
|
|
2330
|
+
void applyLocalLogout().catch((err) => {
|
|
2331
|
+
console.error("[sdk] applyLocalLogout failed (storage event):", err);
|
|
2332
|
+
});
|
|
2225
2333
|
};
|
|
2226
2334
|
const deletion = createDeletionService({ provider });
|
|
2227
2335
|
const handleUserDeleted = (forAddress = null) => {
|
|
@@ -2312,7 +2420,7 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2312
2420
|
};
|
|
2313
2421
|
const signinUnsigned = async () => {
|
|
2314
2422
|
setIsSignedFirstCheck(true);
|
|
2315
|
-
if (!hookState.isSigned
|
|
2423
|
+
if (!hookState.isSigned) {
|
|
2316
2424
|
const ext = browserBase.getExternalService();
|
|
2317
2425
|
if (ext.connected && typeof localStorage !== "undefined") {
|
|
2318
2426
|
localStorage.setItem("blockauth-logged-out", "true");
|
|
@@ -2333,11 +2441,18 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2333
2441
|
browserBase.clearBrowserState({ keepExtensionInstalled: keepInstalled });
|
|
2334
2442
|
const result = message.items.at(0);
|
|
2335
2443
|
onSignup(result);
|
|
2336
|
-
|
|
2444
|
+
if (result?.isNewAccount) {
|
|
2445
|
+
setIsSignedFirstCheck(true);
|
|
2446
|
+
} else {
|
|
2447
|
+
void isUserSignedIn();
|
|
2448
|
+
}
|
|
2337
2449
|
};
|
|
2338
2450
|
const onProviderSignin = (data) => {
|
|
2339
2451
|
const { success, message } = data;
|
|
2340
|
-
if (!success)
|
|
2452
|
+
if (!success) {
|
|
2453
|
+
void _onError();
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2341
2456
|
if (message.items.length <= 0) return;
|
|
2342
2457
|
if (typeof localStorage !== "undefined") {
|
|
2343
2458
|
localStorage.removeItem("blockauth-logged-out");
|
|
@@ -2364,6 +2479,14 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2364
2479
|
if (success) {
|
|
2365
2480
|
setIsSigning(true);
|
|
2366
2481
|
hookState.isSigning = true;
|
|
2482
|
+
const attemptId = ++hookState.signinAttemptId;
|
|
2483
|
+
if (signinTimeout) clearTimeout(signinTimeout);
|
|
2484
|
+
signinTimeout = setTimeout(() => {
|
|
2485
|
+
signinTimeout = null;
|
|
2486
|
+
if (hookState.isSigning && hookState.signinAttemptId === attemptId) {
|
|
2487
|
+
void signinUnsigned();
|
|
2488
|
+
}
|
|
2489
|
+
}, SIGNIN_TIMEOUT_MS);
|
|
2367
2490
|
const s = browserBase.getSession();
|
|
2368
2491
|
const externalService = browserBase.getExternalService();
|
|
2369
2492
|
let token = s.token;
|
|
@@ -2483,6 +2606,21 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2483
2606
|
const onSdkSignRefresh = () => {
|
|
2484
2607
|
void isUserSignedIn();
|
|
2485
2608
|
};
|
|
2609
|
+
const onSdkSessionInvalidated = (data) => {
|
|
2610
|
+
const apiKey = data?.apiKey ?? data?.message?.apiKey;
|
|
2611
|
+
const clientApiKey = $ws.get().apiKey ?? client.apiKey;
|
|
2612
|
+
if (!apiKey || !clientApiKey || apiKey !== clientApiKey) return;
|
|
2613
|
+
const sessionId = data?.sessionId ?? data?.message?.sessionId;
|
|
2614
|
+
if (sessionId != null && String(sessionId) !== String(browserBase.getDeviceSessionId()))
|
|
2615
|
+
return;
|
|
2616
|
+
if (hookState.isLoggingOut || !hookState.isSigned) return;
|
|
2617
|
+
void applyLocalLogout().catch((err) => {
|
|
2618
|
+
console.error(
|
|
2619
|
+
"[sdk] applyLocalLogout failed (session invalidated):",
|
|
2620
|
+
err
|
|
2621
|
+
);
|
|
2622
|
+
});
|
|
2623
|
+
};
|
|
2486
2624
|
const onSdkUserRolesChanged = async (data) => {
|
|
2487
2625
|
const { success, message } = data || {};
|
|
2488
2626
|
if (!success || !message?.address) return;
|
|
@@ -2501,7 +2639,9 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2501
2639
|
if (data.message?.session) {
|
|
2502
2640
|
const session = data.message.session;
|
|
2503
2641
|
const keepInstalled = browserBase.getUI().installed;
|
|
2504
|
-
browserBase.clearBrowserState({
|
|
2642
|
+
browserBase.clearBrowserState({
|
|
2643
|
+
keepExtensionInstalled: keepInstalled
|
|
2644
|
+
});
|
|
2505
2645
|
browserBase.setSession({
|
|
2506
2646
|
did: session.did,
|
|
2507
2647
|
token: session.token,
|
|
@@ -2536,11 +2676,15 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2536
2676
|
}
|
|
2537
2677
|
setDid(_did);
|
|
2538
2678
|
setToken(_token);
|
|
2539
|
-
setApiKey($ws.get().apiKey);
|
|
2679
|
+
setApiKey(client.apiKey ?? $ws.get().apiKey);
|
|
2540
2680
|
setIsServiceConnected(externalService.connected);
|
|
2541
2681
|
setServiceName(externalService.service);
|
|
2542
2682
|
setServiceIcon(imgUrlByService(externalService.service));
|
|
2543
|
-
await provider.connect(
|
|
2683
|
+
await provider.connect(
|
|
2684
|
+
client.wsConnectTimeout ?? 300,
|
|
2685
|
+
"",
|
|
2686
|
+
client.wsConnectRetries ?? 3
|
|
2687
|
+
);
|
|
2544
2688
|
const isConnected = await provider.isConnected();
|
|
2545
2689
|
if (!isConnected) {
|
|
2546
2690
|
setIsCheckingAppActive(false);
|
|
@@ -2571,8 +2715,12 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2571
2715
|
wsc().on("signin:unsigned", onSigninUnsigned);
|
|
2572
2716
|
wsc().on("signin:onDeletion", onSigninOnDeletion);
|
|
2573
2717
|
wsc().on("sdk:sign:refresh", onSdkSignRefresh);
|
|
2718
|
+
wsc().on("sdk:session:invalidated", onSdkSessionInvalidated);
|
|
2574
2719
|
wsc().on("sdk:user:roles:changed", onSdkUserRolesChanged);
|
|
2575
2720
|
wsc().on("sdk:restore", onSdkRestore);
|
|
2721
|
+
if (typeof window !== "undefined") {
|
|
2722
|
+
window.addEventListener("storage", onStorageLogout);
|
|
2723
|
+
}
|
|
2576
2724
|
const { domain, signinCallbackUrl, config: config3 } = await provider.app();
|
|
2577
2725
|
setUiConfig({ domain, signinCallbackUrl, config: config3 });
|
|
2578
2726
|
setReady(true);
|
|
@@ -2584,6 +2732,11 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2584
2732
|
unsignTimeout = null;
|
|
2585
2733
|
}
|
|
2586
2734
|
hookState.isUnsignTimeoutSet = false;
|
|
2735
|
+
if (signinTimeout) {
|
|
2736
|
+
clearTimeout(signinTimeout);
|
|
2737
|
+
signinTimeout = null;
|
|
2738
|
+
}
|
|
2739
|
+
hookState.isSigning = false;
|
|
2587
2740
|
if (getUserTxnsInterval) {
|
|
2588
2741
|
clearInterval(getUserTxnsInterval);
|
|
2589
2742
|
getUserTxnsInterval = null;
|
|
@@ -2603,9 +2756,13 @@ function createAuthRuntime(client, callbacks = {}) {
|
|
|
2603
2756
|
w.off("signin:unsigned", onSigninUnsigned);
|
|
2604
2757
|
w.off("signin:onDeletion", onSigninOnDeletion);
|
|
2605
2758
|
w.off("sdk:sign:refresh", onSdkSignRefresh);
|
|
2759
|
+
w.off("sdk:session:invalidated", onSdkSessionInvalidated);
|
|
2606
2760
|
w.off("sdk:user:roles:changed", onSdkUserRolesChanged);
|
|
2607
2761
|
w.off("sdk:restore", onSdkRestore);
|
|
2608
2762
|
}
|
|
2763
|
+
if (typeof window !== "undefined") {
|
|
2764
|
+
window.removeEventListener("storage", onStorageLogout);
|
|
2765
|
+
}
|
|
2609
2766
|
provider.disconnect();
|
|
2610
2767
|
};
|
|
2611
2768
|
const logout = async () => {
|
|
@@ -2654,8 +2811,99 @@ var TEXTS = {
|
|
|
2654
2811
|
webTypeAll: { es: "Todos", en: "All" },
|
|
2655
2812
|
login: { es: "Iniciar sesi\xF3n", en: "Log In" },
|
|
2656
2813
|
lastStep: { es: "Completa el \xFAltimo paso", en: "Complete the last step" },
|
|
2657
|
-
footerFirst: {
|
|
2658
|
-
|
|
2814
|
+
footerFirst: {
|
|
2815
|
+
es: "\xBFEsperando un registro aburrido?",
|
|
2816
|
+
en: "Expecting a boring signup?"
|
|
2817
|
+
},
|
|
2818
|
+
footerSecond: {
|
|
2819
|
+
es: "Di adi\xF3s a las contrase\xF1as",
|
|
2820
|
+
en: "Say goodbye to passwords"
|
|
2821
|
+
},
|
|
2822
|
+
permissionsRequired: {
|
|
2823
|
+
es: "Permisos requeridos",
|
|
2824
|
+
en: "Permissions required"
|
|
2825
|
+
},
|
|
2826
|
+
solicitedData: { es: "Datos solicitados", en: "Solicited data" },
|
|
2827
|
+
reject: { es: "RECHAZAR", en: "REJECT" },
|
|
2828
|
+
accept: { es: "ACEPTAR", en: "ACCEPT" },
|
|
2829
|
+
iAuthorizeThe: { es: "Autorizo la", en: "I authorize the" },
|
|
2830
|
+
privacyPolicy: { es: "Pol\xEDtica de Privacidad", en: "Privacy Policy" },
|
|
2831
|
+
andThe: { es: "y los", en: "and the" },
|
|
2832
|
+
termsAndConditions: {
|
|
2833
|
+
es: "T\xE9rminos y Condiciones",
|
|
2834
|
+
en: "Terms and Conditions"
|
|
2835
|
+
},
|
|
2836
|
+
configureSessionTime: {
|
|
2837
|
+
es: "Quiero configurar el tiempo de mi sesi\xF3n",
|
|
2838
|
+
en: "I want to configure my session time"
|
|
2839
|
+
},
|
|
2840
|
+
solicitsTo: { es: "solicita a", en: "solicits to" },
|
|
2841
|
+
required: { es: "Requerido", en: "Required" },
|
|
2842
|
+
optional: { es: "Opcional", en: "Optional" },
|
|
2843
|
+
fillRequiredFields: {
|
|
2844
|
+
es: "Completa los campos requeridos para continuar",
|
|
2845
|
+
en: "Fill required fields to continue"
|
|
2846
|
+
},
|
|
2847
|
+
noTransactionsFound: {
|
|
2848
|
+
es: "No se encontraron transacciones",
|
|
2849
|
+
en: "No transactions found"
|
|
2850
|
+
},
|
|
2851
|
+
noAppKeyFound: {
|
|
2852
|
+
es: "No se encontr\xF3 la clave de la aplicaci\xF3n",
|
|
2853
|
+
en: "No application key found"
|
|
2854
|
+
},
|
|
2855
|
+
noContractAddressFound: {
|
|
2856
|
+
es: "No se encontr\xF3 la direcci\xF3n del contrato",
|
|
2857
|
+
en: "No contract address found"
|
|
2858
|
+
},
|
|
2859
|
+
noTransactionsParamsFound: {
|
|
2860
|
+
es: "No se encontraron par\xE1metros de la transacci\xF3n",
|
|
2861
|
+
en: "No transaction params found"
|
|
2862
|
+
},
|
|
2863
|
+
somethingWentWrong: { es: "Algo sali\xF3 mal", en: "Something went wrong" },
|
|
2864
|
+
permTemporalIdentity: {
|
|
2865
|
+
es: "Acceso temporal a tu identidad",
|
|
2866
|
+
en: "Temporal access to identity"
|
|
2867
|
+
},
|
|
2868
|
+
permAuthorisedApps: {
|
|
2869
|
+
es: "Acceso a la lista de aplicaciones autorizadas",
|
|
2870
|
+
en: "Access to the list of authorised apps"
|
|
2871
|
+
},
|
|
2872
|
+
permOnlyThisTxn: {
|
|
2873
|
+
es: "Solo se firmar\xE1 esta transacci\xF3n",
|
|
2874
|
+
en: "Only this transaction will be signed"
|
|
2875
|
+
},
|
|
2876
|
+
firstName: { es: "Nombre", en: "First Name" },
|
|
2877
|
+
lastName: { es: "Apellido", en: "Last Name" },
|
|
2878
|
+
secondLastName: { es: "Segundo apellido", en: "Second Last Name" },
|
|
2879
|
+
email: { es: "Correo electr\xF3nico", en: "Email" },
|
|
2880
|
+
phone: { es: "Tel\xE9fono", en: "Phone" },
|
|
2881
|
+
onlyLettersAllowed: {
|
|
2882
|
+
es: "Solo se permiten letras y espacios",
|
|
2883
|
+
en: "Only letters and spaces allowed"
|
|
2884
|
+
},
|
|
2885
|
+
enterValidEmail: {
|
|
2886
|
+
es: "Introduce un correo electr\xF3nico v\xE1lido (ej. nombre@dominio.com)",
|
|
2887
|
+
en: "Enter a valid email (e.g. name@domain.com)"
|
|
2888
|
+
},
|
|
2889
|
+
enterValidPhone: {
|
|
2890
|
+
es: "Introduce un n\xFAmero de tel\xE9fono v\xE1lido",
|
|
2891
|
+
en: "Enter a valid phone number"
|
|
2892
|
+
},
|
|
2893
|
+
helpUsReport: {
|
|
2894
|
+
es: "Ay\xFAdanos a mejorar y reporta el error aqu\xED",
|
|
2895
|
+
en: "Help us get better and report the error here"
|
|
2896
|
+
},
|
|
2897
|
+
thanksForReport: {
|
|
2898
|
+
es: "\xA1Gracias por reportar el error!",
|
|
2899
|
+
en: "Thanks for reporting the error!"
|
|
2900
|
+
},
|
|
2901
|
+
report: { es: "REPORTAR", en: "REPORT" },
|
|
2902
|
+
close: { es: "Cerrar", en: "Close" },
|
|
2903
|
+
modalWillCloseIn: {
|
|
2904
|
+
es: "Este modal se cerrar\xE1 en...",
|
|
2905
|
+
en: "This modal will close in..."
|
|
2906
|
+
}
|
|
2659
2907
|
};
|
|
2660
2908
|
function t(key, locale = "en") {
|
|
2661
2909
|
const entry = TEXTS[key];
|