@embarkai/ui-kit 0.6.10 → 0.6.11
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/iframe/index.html +1 -1
- package/dist/iframe/main.js +2 -2
- package/dist/index.cjs +33 -8
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +33 -7
- package/package.json +1 -1
package/dist/iframe/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<meta http-equiv="X-Content-Type-Options" content="nosniff" />
|
|
16
16
|
<meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
|
|
17
17
|
|
|
18
|
-
<title>embarkAI Secure Wallet - iframe version 0.6.
|
|
18
|
+
<title>embarkAI Secure Wallet - iframe version 0.6.11</title>
|
|
19
19
|
|
|
20
20
|
<!-- Styles will be injected by build process -->
|
|
21
21
|
<style>
|
package/dist/iframe/main.js
CHANGED
|
@@ -2765,7 +2765,7 @@ function createAccountAbstractionError(params) {
|
|
|
2765
2765
|
|
|
2766
2766
|
// src/iframe/lib/sdk-version.ts
|
|
2767
2767
|
var SDK_VERSION_HEADER = "X-Embark-SDK-Version";
|
|
2768
|
-
var IFRAME_SDK_VERSION = `iframe-${"0.6.
|
|
2768
|
+
var IFRAME_SDK_VERSION = `iframe-${"0.6.11"}`;
|
|
2769
2769
|
function sdkVersionHeaders() {
|
|
2770
2770
|
return { [SDK_VERSION_HEADER]: IFRAME_SDK_VERSION };
|
|
2771
2771
|
}
|
|
@@ -8746,7 +8746,7 @@ var UserPolicyAPI = class extends TokenRefreshApiClient {
|
|
|
8746
8746
|
};
|
|
8747
8747
|
|
|
8748
8748
|
// src/iframe/main.ts
|
|
8749
|
-
var IFRAME_VERSION = "0.6.
|
|
8749
|
+
var IFRAME_VERSION = "0.6.11";
|
|
8750
8750
|
function walletOwnerOf(data) {
|
|
8751
8751
|
const owner = data?.walletOwner;
|
|
8752
8752
|
return typeof owner === "string" && /^0x[0-9a-fA-F]{40}$/.test(owner) ? owner : void 0;
|
package/dist/index.cjs
CHANGED
|
@@ -333,7 +333,7 @@ var import_auth, UI_KIT_VERSION;
|
|
|
333
333
|
var init_sdk_version = __esm({
|
|
334
334
|
"src/internal/lib/sdk-version.ts"() {
|
|
335
335
|
import_auth = require("@embarkai/core/auth");
|
|
336
|
-
UI_KIT_VERSION = "0.6.
|
|
336
|
+
UI_KIT_VERSION = "0.6.11";
|
|
337
337
|
if (UI_KIT_VERSION) (0, import_auth.setSdkVersion)(UI_KIT_VERSION);
|
|
338
338
|
}
|
|
339
339
|
});
|
|
@@ -10137,6 +10137,11 @@ function useAutoConnect() {
|
|
|
10137
10137
|
if (!hasHydrated) return;
|
|
10138
10138
|
if (autoConnectAttemptedRef.current) return;
|
|
10139
10139
|
setIsLoading(true);
|
|
10140
|
+
const startedAt = Date.now();
|
|
10141
|
+
const run = (attempt) => tryAutoConnect(attempt).catch((error) => {
|
|
10142
|
+
console.warn("[UI-KIT][AutoConnect] Auto-connect failed:", error);
|
|
10143
|
+
setIsLoading(false);
|
|
10144
|
+
});
|
|
10140
10145
|
const tryAutoConnect = async (attempt) => {
|
|
10141
10146
|
console.log("[AUTOCONNECT] attempt", attempt);
|
|
10142
10147
|
if (address || session) {
|
|
@@ -10154,9 +10159,11 @@ function useAutoConnect() {
|
|
|
10154
10159
|
} catch (iframeError) {
|
|
10155
10160
|
console.error("[UI-KIT][AutoConnect] Failed to initialize iframe:", iframeError);
|
|
10156
10161
|
setIsIframeReady(false);
|
|
10157
|
-
if (
|
|
10158
|
-
setTimeout(() =>
|
|
10162
|
+
if (Date.now() - startedAt < IFRAME_RETRY_DEADLINE_MS) {
|
|
10163
|
+
setTimeout(() => run(attempt + 1), 500);
|
|
10164
|
+
return;
|
|
10159
10165
|
}
|
|
10166
|
+
setIsLoading(false);
|
|
10160
10167
|
return;
|
|
10161
10168
|
}
|
|
10162
10169
|
const { ensureValidToken: ensureValidToken2, restoreDappSessionFromIframe: restoreDappSessionFromIframe2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
@@ -10248,11 +10255,11 @@ function useAutoConnect() {
|
|
|
10248
10255
|
}
|
|
10249
10256
|
};
|
|
10250
10257
|
autoConnectAttemptedRef.current = true;
|
|
10251
|
-
|
|
10258
|
+
run(0);
|
|
10252
10259
|
}, [hasHydrated]);
|
|
10253
10260
|
return null;
|
|
10254
10261
|
}
|
|
10255
|
-
var import_react11;
|
|
10262
|
+
var import_react11, IFRAME_RETRY_DEADLINE_MS;
|
|
10256
10263
|
var init_useAutoConnect = __esm({
|
|
10257
10264
|
"src/internal/hooks/useAutoConnect.ts"() {
|
|
10258
10265
|
init_ProviderContext();
|
|
@@ -10260,6 +10267,7 @@ var init_useAutoConnect = __esm({
|
|
|
10260
10267
|
import_react11 = require("react");
|
|
10261
10268
|
init_post_login_backup();
|
|
10262
10269
|
init_useLayoutDataStore();
|
|
10270
|
+
IFRAME_RETRY_DEADLINE_MS = 1e4;
|
|
10263
10271
|
}
|
|
10264
10272
|
});
|
|
10265
10273
|
|
|
@@ -34195,7 +34203,7 @@ var init_package = __esm({
|
|
|
34195
34203
|
"package.json"() {
|
|
34196
34204
|
package_default = {
|
|
34197
34205
|
name: "@embarkai/ui-kit",
|
|
34198
|
-
version: "0.6.
|
|
34206
|
+
version: "0.6.11",
|
|
34199
34207
|
description: "React UI components and hooks for embarkAI authentication and Account Abstraction",
|
|
34200
34208
|
type: "module",
|
|
34201
34209
|
main: "./dist/index.cjs",
|
|
@@ -35314,6 +35322,7 @@ var init_iframe_manager = __esm({
|
|
|
35314
35322
|
// 5 minutes (for user interactions like consent)
|
|
35315
35323
|
ENSURE_BACKUP_TIMEOUT = 15e3;
|
|
35316
35324
|
// silent backup, no user interaction
|
|
35325
|
+
READY_TIMEOUT = 15e3;
|
|
35317
35326
|
NONCE_EXPIRY = 3e5;
|
|
35318
35327
|
// 5 minutes
|
|
35319
35328
|
HEARTBEAT_INTERVAL = 5 * 60 * 1e3;
|
|
@@ -35393,8 +35402,12 @@ var init_iframe_manager = __esm({
|
|
|
35393
35402
|
this.messageListener = this.handleMessage.bind(this);
|
|
35394
35403
|
window.addEventListener("message", this.messageListener);
|
|
35395
35404
|
document.body.appendChild(this.iframe);
|
|
35396
|
-
|
|
35397
|
-
|
|
35405
|
+
try {
|
|
35406
|
+
await this.withinReadyTimeout(this.readyPromise.then(() => this.authenticateSDK()));
|
|
35407
|
+
} catch (error) {
|
|
35408
|
+
this.destroy();
|
|
35409
|
+
throw error;
|
|
35410
|
+
}
|
|
35398
35411
|
(0, import_auth28.setDappSessionRecovery)(async (userId) => {
|
|
35399
35412
|
const pair = await this.getDappTokens();
|
|
35400
35413
|
return pair && pair.userId === userId ? pair : null;
|
|
@@ -35410,6 +35423,18 @@ var init_iframe_manager = __esm({
|
|
|
35410
35423
|
setOnWalletReady(callback) {
|
|
35411
35424
|
this.onWalletReadyCallback = callback;
|
|
35412
35425
|
}
|
|
35426
|
+
withinReadyTimeout(handshake) {
|
|
35427
|
+
handshake.catch(() => {
|
|
35428
|
+
});
|
|
35429
|
+
let timer;
|
|
35430
|
+
const timeout = new Promise((_, reject) => {
|
|
35431
|
+
timer = setTimeout(
|
|
35432
|
+
() => reject(new Error(`Iframe did not become ready in ${this.READY_TIMEOUT} ms: ${this.iframeUrl}`)),
|
|
35433
|
+
this.READY_TIMEOUT
|
|
35434
|
+
);
|
|
35435
|
+
});
|
|
35436
|
+
return Promise.race([handshake, timeout]).finally(() => clearTimeout(timer));
|
|
35437
|
+
}
|
|
35413
35438
|
/**
|
|
35414
35439
|
* Authenticate SDK with iframe to establish secure channel
|
|
35415
35440
|
*/
|
package/dist/index.d.cts
CHANGED
|
@@ -851,6 +851,7 @@ declare class IframeManager {
|
|
|
851
851
|
private providerConnections;
|
|
852
852
|
private readonly REQUEST_TIMEOUT;
|
|
853
853
|
private readonly ENSURE_BACKUP_TIMEOUT;
|
|
854
|
+
private readonly READY_TIMEOUT;
|
|
854
855
|
private readonly NONCE_EXPIRY;
|
|
855
856
|
private readonly HEARTBEAT_INTERVAL;
|
|
856
857
|
private heartbeatInterval?;
|
|
@@ -875,6 +876,7 @@ declare class IframeManager {
|
|
|
875
876
|
* Set the onWalletReady callback
|
|
876
877
|
*/
|
|
877
878
|
setOnWalletReady(callback: (status: WalletReadyStatus) => void): void;
|
|
879
|
+
private withinReadyTimeout;
|
|
878
880
|
/**
|
|
879
881
|
* Authenticate SDK with iframe to establish secure channel
|
|
880
882
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -851,6 +851,7 @@ declare class IframeManager {
|
|
|
851
851
|
private providerConnections;
|
|
852
852
|
private readonly REQUEST_TIMEOUT;
|
|
853
853
|
private readonly ENSURE_BACKUP_TIMEOUT;
|
|
854
|
+
private readonly READY_TIMEOUT;
|
|
854
855
|
private readonly NONCE_EXPIRY;
|
|
855
856
|
private readonly HEARTBEAT_INTERVAL;
|
|
856
857
|
private heartbeatInterval?;
|
|
@@ -875,6 +876,7 @@ declare class IframeManager {
|
|
|
875
876
|
* Set the onWalletReady callback
|
|
876
877
|
*/
|
|
877
878
|
setOnWalletReady(callback: (status: WalletReadyStatus) => void): void;
|
|
879
|
+
private withinReadyTimeout;
|
|
878
880
|
/**
|
|
879
881
|
* Authenticate SDK with iframe to establish secure channel
|
|
880
882
|
*/
|
package/dist/index.js
CHANGED
|
@@ -323,7 +323,7 @@ import { getSdkVersion, sdkVersionHeaders, setSdkVersion } from "@embarkai/core/
|
|
|
323
323
|
var UI_KIT_VERSION;
|
|
324
324
|
var init_sdk_version = __esm({
|
|
325
325
|
"src/internal/lib/sdk-version.ts"() {
|
|
326
|
-
UI_KIT_VERSION = "0.6.
|
|
326
|
+
UI_KIT_VERSION = "0.6.11";
|
|
327
327
|
if (UI_KIT_VERSION) setSdkVersion(UI_KIT_VERSION);
|
|
328
328
|
}
|
|
329
329
|
});
|
|
@@ -10140,6 +10140,11 @@ function useAutoConnect() {
|
|
|
10140
10140
|
if (!hasHydrated) return;
|
|
10141
10141
|
if (autoConnectAttemptedRef.current) return;
|
|
10142
10142
|
setIsLoading(true);
|
|
10143
|
+
const startedAt = Date.now();
|
|
10144
|
+
const run = (attempt) => tryAutoConnect(attempt).catch((error) => {
|
|
10145
|
+
console.warn("[UI-KIT][AutoConnect] Auto-connect failed:", error);
|
|
10146
|
+
setIsLoading(false);
|
|
10147
|
+
});
|
|
10143
10148
|
const tryAutoConnect = async (attempt) => {
|
|
10144
10149
|
console.log("[AUTOCONNECT] attempt", attempt);
|
|
10145
10150
|
if (address || session) {
|
|
@@ -10157,9 +10162,11 @@ function useAutoConnect() {
|
|
|
10157
10162
|
} catch (iframeError) {
|
|
10158
10163
|
console.error("[UI-KIT][AutoConnect] Failed to initialize iframe:", iframeError);
|
|
10159
10164
|
setIsIframeReady(false);
|
|
10160
|
-
if (
|
|
10161
|
-
setTimeout(() =>
|
|
10165
|
+
if (Date.now() - startedAt < IFRAME_RETRY_DEADLINE_MS) {
|
|
10166
|
+
setTimeout(() => run(attempt + 1), 500);
|
|
10167
|
+
return;
|
|
10162
10168
|
}
|
|
10169
|
+
setIsLoading(false);
|
|
10163
10170
|
return;
|
|
10164
10171
|
}
|
|
10165
10172
|
const { ensureValidToken: ensureValidToken2, restoreDappSessionFromIframe: restoreDappSessionFromIframe2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
@@ -10251,16 +10258,18 @@ function useAutoConnect() {
|
|
|
10251
10258
|
}
|
|
10252
10259
|
};
|
|
10253
10260
|
autoConnectAttemptedRef.current = true;
|
|
10254
|
-
|
|
10261
|
+
run(0);
|
|
10255
10262
|
}, [hasHydrated]);
|
|
10256
10263
|
return null;
|
|
10257
10264
|
}
|
|
10265
|
+
var IFRAME_RETRY_DEADLINE_MS;
|
|
10258
10266
|
var init_useAutoConnect = __esm({
|
|
10259
10267
|
"src/internal/hooks/useAutoConnect.ts"() {
|
|
10260
10268
|
init_ProviderContext();
|
|
10261
10269
|
init_SessionContext();
|
|
10262
10270
|
init_post_login_backup();
|
|
10263
10271
|
init_useLayoutDataStore();
|
|
10272
|
+
IFRAME_RETRY_DEADLINE_MS = 1e4;
|
|
10264
10273
|
}
|
|
10265
10274
|
});
|
|
10266
10275
|
|
|
@@ -34126,7 +34135,7 @@ var init_package = __esm({
|
|
|
34126
34135
|
"package.json"() {
|
|
34127
34136
|
package_default = {
|
|
34128
34137
|
name: "@embarkai/ui-kit",
|
|
34129
|
-
version: "0.6.
|
|
34138
|
+
version: "0.6.11",
|
|
34130
34139
|
description: "React UI components and hooks for embarkAI authentication and Account Abstraction",
|
|
34131
34140
|
type: "module",
|
|
34132
34141
|
main: "./dist/index.cjs",
|
|
@@ -35248,6 +35257,7 @@ var init_iframe_manager = __esm({
|
|
|
35248
35257
|
// 5 minutes (for user interactions like consent)
|
|
35249
35258
|
ENSURE_BACKUP_TIMEOUT = 15e3;
|
|
35250
35259
|
// silent backup, no user interaction
|
|
35260
|
+
READY_TIMEOUT = 15e3;
|
|
35251
35261
|
NONCE_EXPIRY = 3e5;
|
|
35252
35262
|
// 5 minutes
|
|
35253
35263
|
HEARTBEAT_INTERVAL = 5 * 60 * 1e3;
|
|
@@ -35327,8 +35337,12 @@ var init_iframe_manager = __esm({
|
|
|
35327
35337
|
this.messageListener = this.handleMessage.bind(this);
|
|
35328
35338
|
window.addEventListener("message", this.messageListener);
|
|
35329
35339
|
document.body.appendChild(this.iframe);
|
|
35330
|
-
|
|
35331
|
-
|
|
35340
|
+
try {
|
|
35341
|
+
await this.withinReadyTimeout(this.readyPromise.then(() => this.authenticateSDK()));
|
|
35342
|
+
} catch (error) {
|
|
35343
|
+
this.destroy();
|
|
35344
|
+
throw error;
|
|
35345
|
+
}
|
|
35332
35346
|
setDappSessionRecovery(async (userId) => {
|
|
35333
35347
|
const pair = await this.getDappTokens();
|
|
35334
35348
|
return pair && pair.userId === userId ? pair : null;
|
|
@@ -35344,6 +35358,18 @@ var init_iframe_manager = __esm({
|
|
|
35344
35358
|
setOnWalletReady(callback) {
|
|
35345
35359
|
this.onWalletReadyCallback = callback;
|
|
35346
35360
|
}
|
|
35361
|
+
withinReadyTimeout(handshake) {
|
|
35362
|
+
handshake.catch(() => {
|
|
35363
|
+
});
|
|
35364
|
+
let timer;
|
|
35365
|
+
const timeout = new Promise((_, reject) => {
|
|
35366
|
+
timer = setTimeout(
|
|
35367
|
+
() => reject(new Error(`Iframe did not become ready in ${this.READY_TIMEOUT} ms: ${this.iframeUrl}`)),
|
|
35368
|
+
this.READY_TIMEOUT
|
|
35369
|
+
);
|
|
35370
|
+
});
|
|
35371
|
+
return Promise.race([handshake, timeout]).finally(() => clearTimeout(timer));
|
|
35372
|
+
}
|
|
35347
35373
|
/**
|
|
35348
35374
|
* Authenticate SDK with iframe to establish secure channel
|
|
35349
35375
|
*/
|