@mocanetwork/airkit 1.6.0-beta.4 → 1.6.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/airkit.cjs.js +138 -96
- package/dist/airkit.esm.js +138 -96
- package/dist/airkit.umd.js +138 -96
- package/dist/types/airService.d.ts +4 -15
- package/dist/types/authMessageService.d.ts +2 -1
- package/dist/types/common/air/messaging/auth.d.ts +12 -5
- package/dist/types/common/air/messaging/const.d.ts +2 -1
- package/dist/types/common/air/messaging/credential.d.ts +13 -3
- package/dist/types/common/air/messaging/recovery.d.ts +8 -2
- package/dist/types/common/air/messaging/types.d.ts +3 -0
- package/dist/types/common/air/messaging/wallet.d.ts +8 -2
- package/dist/types/common/const.d.ts +29 -2
- package/dist/types/credentialMessageService.d.ts +3 -8
- package/dist/types/error.d.ts +1 -1
- package/dist/types/interfaces.d.ts +3 -0
- package/dist/types/recoveryMessageService.d.ts +3 -7
- package/dist/types/walletMessageService.d.ts +2 -1
- package/dist/types/windowService.d.ts +2 -1
- package/package.json +1 -1
package/dist/airkit.esm.js
CHANGED
|
@@ -95,7 +95,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
95
95
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
var version = "1.6.0
|
|
98
|
+
var version = "1.6.0";
|
|
99
99
|
var airkitPackage = {
|
|
100
100
|
version: version};
|
|
101
101
|
|
|
@@ -106,6 +106,8 @@ const AirAuthMessageTypes = {
|
|
|
106
106
|
LOGIN_REQUEST: "air_auth_login_request",
|
|
107
107
|
LOGIN_RESPONSE: "air_auth_login_response",
|
|
108
108
|
LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
|
|
109
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_auth_update_session_config_request",
|
|
110
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_auth_update_session_config_response",
|
|
109
111
|
USER_INFO_REQUEST: "air_auth_user_info_request",
|
|
110
112
|
USER_INFO_RESPONSE: "air_auth_user_info_response",
|
|
111
113
|
PARTNER_USER_INFO_REQUEST: "air_auth_partner_user_info_request",
|
|
@@ -139,6 +141,8 @@ const AirCredentialMessageTypes = {
|
|
|
139
141
|
INITIALIZATION_REQUEST: "air_credential_initialization_request",
|
|
140
142
|
INITIALIZATION_RESPONSE: "air_credential_initialization_response",
|
|
141
143
|
CREDENTIAL_IFRAME_VISIBILITY_REQUEST: "air_credential_iframe_visibility_request",
|
|
144
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_credential_update_session_config_request",
|
|
145
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_credential_update_session_config_response",
|
|
142
146
|
LOGOUT_REQUEST: "air_credential_logout_request",
|
|
143
147
|
LOGOUT_RESPONSE: "air_credential_logout_response",
|
|
144
148
|
// New credential operation message types
|
|
@@ -155,6 +159,8 @@ const AirRecoveryMessageTypes = {
|
|
|
155
159
|
INITIALIZATION_RESPONSE: "air_recovery_initialization_response",
|
|
156
160
|
RECOVERY_INITIALIZED: "air_recovery_initialized",
|
|
157
161
|
RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
|
|
162
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
|
|
163
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
|
|
158
164
|
LOGOUT_REQUEST: "air_recovery_logout_request",
|
|
159
165
|
LOGOUT_RESPONSE: "air_recovery_logout_response"
|
|
160
166
|
};
|
|
@@ -166,6 +172,8 @@ const AirWalletMessageTypes = {
|
|
|
166
172
|
CLOSE_MODAL_REQUEST: "air_close_modal_request",
|
|
167
173
|
CLOSE_MODAL_RESPONSE: "air_close_modal_response",
|
|
168
174
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
175
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_wallet_update_session_config_request",
|
|
176
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_wallet_update_session_config_response",
|
|
169
177
|
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
170
178
|
WALLET_LOGIN_RESPONSE: "air_wallet_login_response",
|
|
171
179
|
SETUP_OR_UPDATE_MFA_REQUEST: "air_setup_mfa_request",
|
|
@@ -712,7 +720,7 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
712
720
|
class TransactionRejectedRpcError extends ProviderRpcError {
|
|
713
721
|
constructor(message) {
|
|
714
722
|
// Remove the "Version: viem@x.x.x" suffix if present
|
|
715
|
-
const cleanMessage = message.replace(/\nVersion:.*$/,
|
|
723
|
+
const cleanMessage = message.replace(/\nVersion:.*$/, "");
|
|
716
724
|
super(cleanMessage);
|
|
717
725
|
this.code = -32003;
|
|
718
726
|
this.name = "TransactionRejectedRpcError";
|
|
@@ -1866,7 +1874,7 @@ class AirWalletProvider {
|
|
|
1866
1874
|
if (!loginResult) {
|
|
1867
1875
|
throw new UnauthorizedProviderError("User is not logged in");
|
|
1868
1876
|
}
|
|
1869
|
-
if (method === "eth_accounts" &&
|
|
1877
|
+
if ((method === "eth_accounts" || method === "eth_requestAccounts") &&
|
|
1870
1878
|
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this) &&
|
|
1871
1879
|
loginResult?.abstractAccountAddress) {
|
|
1872
1880
|
return [loginResult.abstractAccountAddress];
|
|
@@ -1932,6 +1940,7 @@ const ALLOWED_AUTH_MESSAGES = [
|
|
|
1932
1940
|
AirAuthMessageTypes.SETUP_WALLET_REQUEST,
|
|
1933
1941
|
AirAuthMessageTypes.SETUP_RECOVERY_REQUEST,
|
|
1934
1942
|
AirAuthMessageTypes.LOGOUT_RESPONSE,
|
|
1943
|
+
AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
1935
1944
|
AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
|
|
1936
1945
|
AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE,
|
|
1937
1946
|
AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE,
|
|
@@ -1959,6 +1968,11 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
1959
1968
|
});
|
|
1960
1969
|
return response;
|
|
1961
1970
|
}
|
|
1971
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
1972
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
1973
|
+
await this.sendMessage({ type: AirAuthMessageTypes.UPDATE_SESSION_CONFIG_REQUEST, payload });
|
|
1974
|
+
return response;
|
|
1975
|
+
}
|
|
1962
1976
|
async sendLoginRequest(payload) {
|
|
1963
1977
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.LOGIN_RESPONSE)));
|
|
1964
1978
|
await this.sendMessage({ type: AirAuthMessageTypes.LOGIN_REQUEST, payload });
|
|
@@ -2032,6 +2046,7 @@ var _a$2, _CredentialMessageService_instance;
|
|
|
2032
2046
|
const ALLOWED_CREDENTIAL_MESSAGES = [
|
|
2033
2047
|
AirCredentialMessageTypes.INITIALIZATION_RESPONSE,
|
|
2034
2048
|
AirCredentialMessageTypes.CREDENTIAL_IFRAME_VISIBILITY_REQUEST,
|
|
2049
|
+
AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
2035
2050
|
AirCredentialMessageTypes.LOGOUT_RESPONSE,
|
|
2036
2051
|
AirCredentialMessageTypes.ISSUE_CREDENTIAL_RESPONSE,
|
|
2037
2052
|
AirCredentialMessageTypes.VERIFY_CREDENTIAL_RESPONSE,
|
|
@@ -2057,6 +2072,14 @@ class CredentialMessageService extends MessageServiceBase {
|
|
|
2057
2072
|
});
|
|
2058
2073
|
return response;
|
|
2059
2074
|
}
|
|
2075
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2076
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2077
|
+
await this.sendMessage({
|
|
2078
|
+
type: AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_REQUEST,
|
|
2079
|
+
payload,
|
|
2080
|
+
});
|
|
2081
|
+
return response;
|
|
2082
|
+
}
|
|
2060
2083
|
async logout() {
|
|
2061
2084
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.LOGOUT_RESPONSE)));
|
|
2062
2085
|
await this.sendMessage({
|
|
@@ -2180,6 +2203,14 @@ class RecoveryMessageService extends MessageServiceBase {
|
|
|
2180
2203
|
async onInitialized() {
|
|
2181
2204
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.RECOVERY_INITIALIZED)));
|
|
2182
2205
|
}
|
|
2206
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2207
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2208
|
+
await this.sendMessage({
|
|
2209
|
+
type: AirRecoveryMessageTypes.UPDATE_SESSION_CONFIG_REQUEST,
|
|
2210
|
+
payload,
|
|
2211
|
+
});
|
|
2212
|
+
return response;
|
|
2213
|
+
}
|
|
2183
2214
|
async logout() {
|
|
2184
2215
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.LOGOUT_RESPONSE)));
|
|
2185
2216
|
await this.sendMessage({ type: AirRecoveryMessageTypes.LOGOUT_REQUEST });
|
|
@@ -2199,6 +2230,7 @@ var _a, _WalletMessageService_instance;
|
|
|
2199
2230
|
const ALLOWED_WALLET_MESSAGES = [
|
|
2200
2231
|
AirWalletMessageTypes.INITIALIZATION_RESPONSE,
|
|
2201
2232
|
AirWalletMessageTypes.WALLET_INITIALIZED,
|
|
2233
|
+
AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
2202
2234
|
AirWalletMessageTypes.WALLET_LOGIN_RESPONSE,
|
|
2203
2235
|
AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE,
|
|
2204
2236
|
AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE,
|
|
@@ -2250,6 +2282,11 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2250
2282
|
onInitialized() {
|
|
2251
2283
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.WALLET_INITIALIZED)));
|
|
2252
2284
|
}
|
|
2285
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2286
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2287
|
+
await this.sendMessage({ type: AirWalletMessageTypes.UPDATE_SESSION_CONFIG_REQUEST, payload });
|
|
2288
|
+
return response;
|
|
2289
|
+
}
|
|
2253
2290
|
async sendLoginRequest() {
|
|
2254
2291
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.WALLET_LOGIN_RESPONSE)));
|
|
2255
2292
|
await this.sendMessage({
|
|
@@ -2457,7 +2494,7 @@ class WindowService {
|
|
|
2457
2494
|
]);
|
|
2458
2495
|
return (await response).data;
|
|
2459
2496
|
}
|
|
2460
|
-
async openAndInitializeWalletServiceWindow({ url, windowId, partnerId, enableLogging, onRetry, sdkVersion, enableAutomation, }) {
|
|
2497
|
+
async openAndInitializeWalletServiceWindow({ url, windowId, sessionId, partnerId, enableLogging, onRetry, sdkVersion, enableAutomation, }) {
|
|
2461
2498
|
if (this.windowControllers.has(windowId)) {
|
|
2462
2499
|
throw new Error("Window controller already exists");
|
|
2463
2500
|
}
|
|
@@ -2475,6 +2512,7 @@ class WindowService {
|
|
|
2475
2512
|
try {
|
|
2476
2513
|
channel = new MessageChannel();
|
|
2477
2514
|
const { payload } = await this.sendWindowInitializationRequest(windowId, {
|
|
2515
|
+
sessionId,
|
|
2478
2516
|
partnerId,
|
|
2479
2517
|
enableLogging,
|
|
2480
2518
|
sdkVersion,
|
|
@@ -2514,7 +2552,7 @@ class WindowService {
|
|
|
2514
2552
|
}
|
|
2515
2553
|
var WindowService$1 = WindowService.instance;
|
|
2516
2554
|
|
|
2517
|
-
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized,
|
|
2555
|
+
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_sessionId, _AirService_sessionConfig, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airEventListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _AirService_assertInitialized, _AirService_assertLoggedIn, _AirService_ensureCredential, _AirService_initializeCredentials, _AirService_subscribeToCredentialEvents, _AirService_cleanUpCredential, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_subscribeToWalletEvents, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_createLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet, _AirService_ensureRecovery, _AirService_initializeRecovery, _AirService_subscribeToRecoveryEvents, _AirService_cleanUpRecovery;
|
|
2518
2556
|
const airKitVersion = airkitPackage.version;
|
|
2519
2557
|
class AirService {
|
|
2520
2558
|
constructor({ partnerId }) {
|
|
@@ -2523,11 +2561,13 @@ class AirService {
|
|
|
2523
2561
|
_AirService_buildEnv.set(this, void 0);
|
|
2524
2562
|
_AirService_enableLogging.set(this, false);
|
|
2525
2563
|
_AirService_partnerId.set(this, void 0);
|
|
2564
|
+
_AirService_sessionId.set(this, void 0);
|
|
2565
|
+
_AirService_sessionConfig.set(this, void 0);
|
|
2526
2566
|
//#modalZIndex: number; TODO implement z index overwrite
|
|
2527
2567
|
_AirService_authMessagingService.set(this, void 0);
|
|
2528
2568
|
_AirService_authIframeController.set(this, void 0);
|
|
2529
2569
|
_AirService_isAuthInitialized.set(this, false);
|
|
2530
|
-
|
|
2570
|
+
_AirService_airEventListener.set(this, []);
|
|
2531
2571
|
_AirService_walletMessagingService.set(this, void 0);
|
|
2532
2572
|
_AirService_walletIframeController.set(this, void 0);
|
|
2533
2573
|
_AirService_walletInitialization.set(this, void 0);
|
|
@@ -2577,15 +2617,17 @@ class AirService {
|
|
|
2577
2617
|
shouldEnableAutomation() {
|
|
2578
2618
|
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
|
|
2579
2619
|
}
|
|
2580
|
-
async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, }) {
|
|
2620
|
+
async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, }) {
|
|
2581
2621
|
if (!__classPrivateFieldGet(this, _AirService_partnerId, "f"))
|
|
2582
|
-
throw new
|
|
2622
|
+
throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
|
|
2583
2623
|
if (__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2584
|
-
return;
|
|
2624
|
+
return __classPrivateFieldGet(this, _AirService_loginResult, "f") ?? null;
|
|
2585
2625
|
__classPrivateFieldSet(this, _AirService_buildEnv, buildEnv, "f");
|
|
2586
2626
|
__classPrivateFieldSet(this, _AirService_enableLogging, enableLogging, "f");
|
|
2627
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
2587
2628
|
const { authUrl } = AIR_URLS[buildEnv];
|
|
2588
2629
|
configureLogLevel(buildEnv, enableLogging);
|
|
2630
|
+
__classPrivateFieldSet(this, _AirService_sessionId, randomId(), "f");
|
|
2589
2631
|
const authIframeOrigin = new URL(authUrl).origin;
|
|
2590
2632
|
__classPrivateFieldSet(this, _AirService_authIframeController, new IframeController("air-auth", authUrl), "f");
|
|
2591
2633
|
try {
|
|
@@ -2635,12 +2677,14 @@ class AirService {
|
|
|
2635
2677
|
if (ev.data === AirAuthMessageTypes.AUTH_SETUP_COMPLETED) {
|
|
2636
2678
|
window.removeEventListener("message", handleAuthMessage);
|
|
2637
2679
|
const { payload } = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendInitializationRequest({
|
|
2680
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
2638
2681
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
2639
2682
|
skipRehydration,
|
|
2640
2683
|
partnerDAppUrl: window.location.href,
|
|
2641
2684
|
sdkVersion: airKitVersion,
|
|
2642
2685
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
2643
2686
|
enableAutomation: this.shouldEnableAutomation(),
|
|
2687
|
+
sessionConfig,
|
|
2644
2688
|
});
|
|
2645
2689
|
if (payload.success === true) {
|
|
2646
2690
|
resolve(payload);
|
|
@@ -2666,13 +2710,12 @@ class AirService {
|
|
|
2666
2710
|
catch (error) {
|
|
2667
2711
|
log.debug("Error initializing auth service", error);
|
|
2668
2712
|
await this.cleanUp();
|
|
2669
|
-
throw error;
|
|
2713
|
+
throw AirServiceError.from(error);
|
|
2670
2714
|
}
|
|
2671
2715
|
return null;
|
|
2672
2716
|
}
|
|
2673
2717
|
async login(options) {
|
|
2674
|
-
|
|
2675
|
-
throw new Error("Service is not initialized");
|
|
2718
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2676
2719
|
if (__classPrivateFieldGet(this, _AirService_loginResult, "f"))
|
|
2677
2720
|
return __classPrivateFieldGet(this, _AirService_loginResult, "f");
|
|
2678
2721
|
const { payload } = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendLoginRequest({
|
|
@@ -2689,38 +2732,24 @@ class AirService {
|
|
|
2689
2732
|
* @experimental This method is experimental and will change in the future.
|
|
2690
2733
|
*/
|
|
2691
2734
|
async deploySmartAccount() {
|
|
2692
|
-
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2693
|
-
throw new Error("Service is not initialized");
|
|
2694
2735
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2700
|
-
}
|
|
2701
|
-
return { txHash: payload.txHash };
|
|
2702
|
-
}
|
|
2703
|
-
catch (error) {
|
|
2704
|
-
throw AirServiceError.from(error);
|
|
2736
|
+
log.info("deploySmartAccount");
|
|
2737
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendDeploySmartAccountRequest();
|
|
2738
|
+
if (payload.success === false) {
|
|
2739
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2705
2740
|
}
|
|
2741
|
+
return { txHash: payload.txHash };
|
|
2706
2742
|
}
|
|
2707
2743
|
/**
|
|
2708
2744
|
* @experimental This method is experimental and will change in the future.
|
|
2709
2745
|
*/
|
|
2710
2746
|
async isSmartAccountDeployed() {
|
|
2711
|
-
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2712
|
-
throw new Error("Service is not initialized");
|
|
2713
2747
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2718
|
-
}
|
|
2719
|
-
return payload.isDeployed;
|
|
2720
|
-
}
|
|
2721
|
-
catch (error) {
|
|
2722
|
-
throw AirServiceError.from(error);
|
|
2748
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendIsSmartAccountDeployedRequest();
|
|
2749
|
+
if (payload.success === false) {
|
|
2750
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2723
2751
|
}
|
|
2752
|
+
return payload.isDeployed;
|
|
2724
2753
|
}
|
|
2725
2754
|
getProvider() {
|
|
2726
2755
|
return this.provider;
|
|
@@ -2772,8 +2801,7 @@ class AirService {
|
|
|
2772
2801
|
}
|
|
2773
2802
|
}
|
|
2774
2803
|
async getUserInfo() {
|
|
2775
|
-
|
|
2776
|
-
throw new Error("User not logged in");
|
|
2804
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2777
2805
|
const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
2778
2806
|
if (info.payload.success === false) {
|
|
2779
2807
|
throw new AirServiceError(info.payload.errorName, info.payload.errorMessage);
|
|
@@ -2790,11 +2818,37 @@ class AirService {
|
|
|
2790
2818
|
},
|
|
2791
2819
|
};
|
|
2792
2820
|
}
|
|
2821
|
+
async updateSessionConfig(config) {
|
|
2822
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2823
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, config, "f");
|
|
2824
|
+
const resultsPromise = [__classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendUpdateSessionConfigRequest(config)];
|
|
2825
|
+
if (__classPrivateFieldGet(this, _AirService_walletInitialization, "f")) {
|
|
2826
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_walletInitialization, "f")
|
|
2827
|
+
.then(() => __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2828
|
+
.catch(() => null));
|
|
2829
|
+
}
|
|
2830
|
+
if (__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")) {
|
|
2831
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")
|
|
2832
|
+
.then(() => __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2833
|
+
.catch(() => null));
|
|
2834
|
+
}
|
|
2835
|
+
if (__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")) {
|
|
2836
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")
|
|
2837
|
+
.then(() => __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2838
|
+
.catch(() => null));
|
|
2839
|
+
}
|
|
2840
|
+
const results = await Promise.all(resultsPromise);
|
|
2841
|
+
for (const result of results) {
|
|
2842
|
+
if (result && result.payload.success === false) {
|
|
2843
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
const sessionConfig = { locale: results[0].payload.locale };
|
|
2847
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
2848
|
+
return sessionConfig;
|
|
2849
|
+
}
|
|
2793
2850
|
async goToPartner(partnerUrl) {
|
|
2794
|
-
|
|
2795
|
-
throw new Error("Service is not initialized");
|
|
2796
|
-
if (!this.isLoggedIn)
|
|
2797
|
-
throw new Error("No active session to generate token");
|
|
2851
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2798
2852
|
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendCrossPartnerTokenRequest(partnerUrl);
|
|
2799
2853
|
if (result.payload.success === false) {
|
|
2800
2854
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
@@ -2804,35 +2858,24 @@ class AirService {
|
|
|
2804
2858
|
};
|
|
2805
2859
|
}
|
|
2806
2860
|
async startRecovery(payload) {
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
catch (error) {
|
|
2814
|
-
throw AirServiceError.from(error);
|
|
2861
|
+
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendAccountRecoveryRequest(payload);
|
|
2862
|
+
if (result.payload.success === false) {
|
|
2863
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2815
2864
|
}
|
|
2816
2865
|
}
|
|
2817
2866
|
async getAccessToken() {
|
|
2818
|
-
|
|
2819
|
-
throw new Error("Service is not initialized");
|
|
2820
|
-
if (!this.isLoggedIn)
|
|
2821
|
-
throw new Error("No active session to get partner access token");
|
|
2867
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2822
2868
|
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerAccessTokenRequest();
|
|
2823
2869
|
if (result.payload.success !== true) {
|
|
2824
2870
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2825
2871
|
}
|
|
2826
2872
|
if (!result.payload.partnerAccessToken) {
|
|
2827
|
-
throw new
|
|
2873
|
+
throw new AirServiceError("UNAUTHORIZED", "Partner access token not found in response");
|
|
2828
2874
|
}
|
|
2829
2875
|
return { token: result.payload.partnerAccessToken };
|
|
2830
2876
|
}
|
|
2831
2877
|
async logout() {
|
|
2832
|
-
|
|
2833
|
-
throw new Error("Service is not initialized");
|
|
2834
|
-
if (!this.isLoggedIn)
|
|
2835
|
-
throw new Error("No active session to logout");
|
|
2878
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2836
2879
|
// Clear up credentials first to avoid issues with wallet and auth messaging services
|
|
2837
2880
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
|
|
2838
2881
|
await Promise.all([
|
|
@@ -2844,33 +2887,21 @@ class AirService {
|
|
|
2844
2887
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
|
|
2845
2888
|
}
|
|
2846
2889
|
async cleanUp() {
|
|
2890
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
|
|
2891
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this);
|
|
2847
2892
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this);
|
|
2848
2893
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpAuth).call(this);
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
this
|
|
2894
|
+
__classPrivateFieldSet(this, _AirService_airEventListener, [], "f");
|
|
2895
|
+
__classPrivateFieldSet(this, _AirService_sessionId, undefined, "f");
|
|
2896
|
+
__classPrivateFieldSet(this, _AirService_buildEnv, undefined, "f");
|
|
2852
2897
|
}
|
|
2853
|
-
/**
|
|
2854
|
-
* Register an event listener for Air service events.
|
|
2855
|
-
*
|
|
2856
|
-
* Available events:
|
|
2857
|
-
* - "initialized": Service initialization completed
|
|
2858
|
-
* - "logged_in": User successfully logged in
|
|
2859
|
-
* - "logged_out": User logged out
|
|
2860
|
-
* - "wallet_initialized": Wallet initialization completed
|
|
2861
|
-
*
|
|
2862
|
-
* @param listener The event listener function
|
|
2863
|
-
*/
|
|
2864
2898
|
on(listener) {
|
|
2865
|
-
if (__classPrivateFieldGet(this,
|
|
2866
|
-
__classPrivateFieldGet(this,
|
|
2899
|
+
if (__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener) < 0)
|
|
2900
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").push(listener);
|
|
2867
2901
|
}
|
|
2868
2902
|
off(listener) {
|
|
2869
|
-
if (__classPrivateFieldGet(this,
|
|
2870
|
-
__classPrivateFieldGet(this,
|
|
2871
|
-
}
|
|
2872
|
-
clearEventListeners() {
|
|
2873
|
-
__classPrivateFieldSet(this, _AirService_airAuthListener, [], "f");
|
|
2903
|
+
if (__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener) >= 0)
|
|
2904
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").splice(__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener), 1);
|
|
2874
2905
|
}
|
|
2875
2906
|
async preloadCredential() {
|
|
2876
2907
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
|
|
@@ -2903,9 +2934,15 @@ class AirService {
|
|
|
2903
2934
|
return payload.verificationResult;
|
|
2904
2935
|
}
|
|
2905
2936
|
}
|
|
2906
|
-
_AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _AirService_enableLogging = new WeakMap(), _AirService_partnerId = new WeakMap(), _AirService_authMessagingService = new WeakMap(), _AirService_authIframeController = new WeakMap(), _AirService_isAuthInitialized = new WeakMap(),
|
|
2907
|
-
if (!this
|
|
2908
|
-
throw new
|
|
2937
|
+
_AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _AirService_enableLogging = new WeakMap(), _AirService_partnerId = new WeakMap(), _AirService_sessionId = new WeakMap(), _AirService_sessionConfig = new WeakMap(), _AirService_authMessagingService = new WeakMap(), _AirService_authIframeController = new WeakMap(), _AirService_isAuthInitialized = new WeakMap(), _AirService_airEventListener = new WeakMap(), _AirService_walletMessagingService = new WeakMap(), _AirService_walletIframeController = new WeakMap(), _AirService_walletInitialization = new WeakMap(), _AirService_walletLoggedInResult = new WeakMap(), _AirService_airWalletProvider = new WeakMap(), _AirService_recoveryInitialization = new WeakMap(), _AirService_recoveryMessagingService = new WeakMap(), _AirService_recoveryIframeController = new WeakMap(), _AirService_credentialsInitialization = new WeakMap(), _AirService_credentialMessagingService = new WeakMap(), _AirService_credentialIframeController = new WeakMap(), _AirService_instances = new WeakSet(), _AirService_assertInitialized = function _AirService_assertInitialized() {
|
|
2938
|
+
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2939
|
+
throw new AirServiceError("NOT_INITIALIZED", "Service is not initialized");
|
|
2940
|
+
}, _AirService_assertLoggedIn = function _AirService_assertLoggedIn() {
|
|
2941
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2942
|
+
if (!this.isLoggedIn)
|
|
2943
|
+
throw new AirServiceError("NOT_LOGGED_IN", "User not logged in");
|
|
2944
|
+
}, _AirService_ensureCredential = async function _AirService_ensureCredential() {
|
|
2945
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2909
2946
|
void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2910
2947
|
try {
|
|
2911
2948
|
if (!__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f"))
|
|
@@ -2915,11 +2952,11 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2915
2952
|
catch (error) {
|
|
2916
2953
|
__classPrivateFieldSet(this, _AirService_credentialsInitialization, null, "f");
|
|
2917
2954
|
log.error("Error ensuring credentials", error);
|
|
2918
|
-
throw error;
|
|
2955
|
+
throw AirServiceError.from(error);
|
|
2919
2956
|
}
|
|
2920
2957
|
}, _AirService_initializeCredentials = async function _AirService_initializeCredentials() {
|
|
2921
2958
|
if (__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")) {
|
|
2922
|
-
throw new
|
|
2959
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing credentials");
|
|
2923
2960
|
}
|
|
2924
2961
|
const { credentialUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
2925
2962
|
const credentialIframeOrigin = new URL(credentialUrl).origin;
|
|
@@ -2932,11 +2969,13 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2932
2969
|
if (ev.data === AirCredentialMessageTypes.SERVICE_STARTED) {
|
|
2933
2970
|
window.removeEventListener("message", handleCredentialMessage);
|
|
2934
2971
|
const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendInitializationRequest({
|
|
2972
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
2935
2973
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
2936
2974
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
2937
2975
|
sdkVersion: airKitVersion,
|
|
2938
2976
|
partnerDAppUrl: window.location.href,
|
|
2939
2977
|
enableAutomation: this.shouldEnableAutomation(),
|
|
2978
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
2940
2979
|
});
|
|
2941
2980
|
if (payload.success === true) {
|
|
2942
2981
|
resolve();
|
|
@@ -2964,7 +3003,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2964
3003
|
if (closeDApp) {
|
|
2965
3004
|
window.close();
|
|
2966
3005
|
}
|
|
2967
|
-
throw error;
|
|
3006
|
+
throw AirServiceError.from(error);
|
|
2968
3007
|
}
|
|
2969
3008
|
}, _AirService_subscribeToCredentialEvents = function _AirService_subscribeToCredentialEvents() {
|
|
2970
3009
|
__classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").messages$.subscribe(async (message) => {
|
|
@@ -2989,8 +3028,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2989
3028
|
await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").close();
|
|
2990
3029
|
__classPrivateFieldSet(this, _AirService_credentialsInitialization, undefined, "f");
|
|
2991
3030
|
}, _AirService_ensureWallet = async function _AirService_ensureWallet(option) {
|
|
2992
|
-
|
|
2993
|
-
throw new Error("Service not initialized");
|
|
3031
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2994
3032
|
if (!__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
2995
3033
|
__classPrivateFieldSet(this, _AirService_walletInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeWallet).call(this, option), "f");
|
|
2996
3034
|
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
@@ -3004,7 +3042,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3004
3042
|
catch (error) {
|
|
3005
3043
|
__classPrivateFieldSet(this, _AirService_walletInitialization, null, "f");
|
|
3006
3044
|
log.error("Error initializing wallet", error);
|
|
3007
|
-
throw error;
|
|
3045
|
+
throw AirServiceError.from(error);
|
|
3008
3046
|
}
|
|
3009
3047
|
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
3010
3048
|
return __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f");
|
|
@@ -3015,7 +3053,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3015
3053
|
return __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, walletLoginResult.payload);
|
|
3016
3054
|
}, _AirService_initializeWallet = async function _AirService_initializeWallet(option) {
|
|
3017
3055
|
if (__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
3018
|
-
throw new
|
|
3056
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing");
|
|
3019
3057
|
const { walletUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
3020
3058
|
const walletIframeOrigin = new URL(walletUrl).origin;
|
|
3021
3059
|
try {
|
|
@@ -3026,10 +3064,12 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3026
3064
|
if (ev.data === AirWalletMessageTypes.SERVICE_STARTED) {
|
|
3027
3065
|
window.removeEventListener("message", handleWalletMessage);
|
|
3028
3066
|
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendInitializationRequest({
|
|
3067
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3029
3068
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3030
3069
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3031
3070
|
sdkVersion: airKitVersion,
|
|
3032
3071
|
enableAutomation: this.shouldEnableAutomation(),
|
|
3072
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
3033
3073
|
});
|
|
3034
3074
|
if (payload.success === true) {
|
|
3035
3075
|
resolve();
|
|
@@ -3065,7 +3105,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3065
3105
|
catch (error) {
|
|
3066
3106
|
log.error("Error initializing wallet", error);
|
|
3067
3107
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this);
|
|
3068
|
-
throw error;
|
|
3108
|
+
throw AirServiceError.from(error);
|
|
3069
3109
|
}
|
|
3070
3110
|
}, _AirService_subscribeToWalletEvents = function _AirService_subscribeToWalletEvents() {
|
|
3071
3111
|
__classPrivateFieldGet(this, _AirService_walletMessagingService, "f").messages$.subscribe(async (msg) => {
|
|
@@ -3094,6 +3134,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3094
3134
|
const { windowController, port } = await WindowService$1.openAndInitializeWalletServiceWindow({
|
|
3095
3135
|
url: msg.payload.url,
|
|
3096
3136
|
windowId: msg.payload.windowId,
|
|
3137
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3097
3138
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3098
3139
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3099
3140
|
sdkVersion: airKitVersion,
|
|
@@ -3112,7 +3153,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3112
3153
|
}
|
|
3113
3154
|
});
|
|
3114
3155
|
}, _AirService_triggerEventListeners = function _AirService_triggerEventListeners(data) {
|
|
3115
|
-
__classPrivateFieldGet(this,
|
|
3156
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").forEach((listener) => {
|
|
3116
3157
|
listener(data);
|
|
3117
3158
|
});
|
|
3118
3159
|
}, _AirService_triggerAirAuthInitialized = function _AirService_triggerAirAuthInitialized(result) {
|
|
@@ -3175,8 +3216,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3175
3216
|
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, undefined, "f");
|
|
3176
3217
|
__classPrivateFieldSet(this, _AirService_walletInitialization, undefined, "f");
|
|
3177
3218
|
}, _AirService_ensureRecovery = async function _AirService_ensureRecovery() {
|
|
3178
|
-
|
|
3179
|
-
throw new Error("Service not initialized");
|
|
3219
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
3180
3220
|
if (!__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")) {
|
|
3181
3221
|
__classPrivateFieldSet(this, _AirService_recoveryInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeRecovery).call(this), "f");
|
|
3182
3222
|
}
|
|
@@ -3186,11 +3226,11 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3186
3226
|
catch (error) {
|
|
3187
3227
|
__classPrivateFieldSet(this, _AirService_recoveryInitialization, null, "f");
|
|
3188
3228
|
log.error("Error initializing recovery", error);
|
|
3189
|
-
throw error;
|
|
3229
|
+
throw AirServiceError.from(error);
|
|
3190
3230
|
}
|
|
3191
3231
|
}, _AirService_initializeRecovery = async function _AirService_initializeRecovery() {
|
|
3192
3232
|
if (__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f"))
|
|
3193
|
-
throw new
|
|
3233
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing");
|
|
3194
3234
|
const { recoveryUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
3195
3235
|
const recoveryIframeOrigin = new URL(recoveryUrl).origin;
|
|
3196
3236
|
try {
|
|
@@ -3201,10 +3241,12 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3201
3241
|
if (ev.data === AirRecoveryMessageTypes.SERVICE_STARTED) {
|
|
3202
3242
|
window.removeEventListener("message", handleRecoveryMessage);
|
|
3203
3243
|
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendInitializationRequest({
|
|
3244
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3204
3245
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3205
3246
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3206
3247
|
sdkVersion: airKitVersion,
|
|
3207
3248
|
enableAutomation: this.shouldEnableAutomation(),
|
|
3249
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
3208
3250
|
});
|
|
3209
3251
|
if (payload.success === true) {
|
|
3210
3252
|
resolve();
|
|
@@ -3228,7 +3270,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3228
3270
|
catch (error) {
|
|
3229
3271
|
log.error("Error initializing recovery", error);
|
|
3230
3272
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this);
|
|
3231
|
-
throw error;
|
|
3273
|
+
throw AirServiceError.from(error);
|
|
3232
3274
|
}
|
|
3233
3275
|
}, _AirService_subscribeToRecoveryEvents = function _AirService_subscribeToRecoveryEvents() {
|
|
3234
3276
|
__classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").messages$.subscribe(async (message) => {
|