@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.umd.js
CHANGED
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
var version = "1.6.0
|
|
104
|
+
var version = "1.6.0";
|
|
105
105
|
var airkitPackage = {
|
|
106
106
|
version: version};
|
|
107
107
|
|
|
@@ -112,6 +112,8 @@
|
|
|
112
112
|
LOGIN_REQUEST: "air_auth_login_request",
|
|
113
113
|
LOGIN_RESPONSE: "air_auth_login_response",
|
|
114
114
|
LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
|
|
115
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_auth_update_session_config_request",
|
|
116
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_auth_update_session_config_response",
|
|
115
117
|
USER_INFO_REQUEST: "air_auth_user_info_request",
|
|
116
118
|
USER_INFO_RESPONSE: "air_auth_user_info_response",
|
|
117
119
|
PARTNER_USER_INFO_REQUEST: "air_auth_partner_user_info_request",
|
|
@@ -145,6 +147,8 @@
|
|
|
145
147
|
INITIALIZATION_REQUEST: "air_credential_initialization_request",
|
|
146
148
|
INITIALIZATION_RESPONSE: "air_credential_initialization_response",
|
|
147
149
|
CREDENTIAL_IFRAME_VISIBILITY_REQUEST: "air_credential_iframe_visibility_request",
|
|
150
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_credential_update_session_config_request",
|
|
151
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_credential_update_session_config_response",
|
|
148
152
|
LOGOUT_REQUEST: "air_credential_logout_request",
|
|
149
153
|
LOGOUT_RESPONSE: "air_credential_logout_response",
|
|
150
154
|
// New credential operation message types
|
|
@@ -161,6 +165,8 @@
|
|
|
161
165
|
INITIALIZATION_RESPONSE: "air_recovery_initialization_response",
|
|
162
166
|
RECOVERY_INITIALIZED: "air_recovery_initialized",
|
|
163
167
|
RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
|
|
168
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
|
|
169
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
|
|
164
170
|
LOGOUT_REQUEST: "air_recovery_logout_request",
|
|
165
171
|
LOGOUT_RESPONSE: "air_recovery_logout_response"
|
|
166
172
|
};
|
|
@@ -172,6 +178,8 @@
|
|
|
172
178
|
CLOSE_MODAL_REQUEST: "air_close_modal_request",
|
|
173
179
|
CLOSE_MODAL_RESPONSE: "air_close_modal_response",
|
|
174
180
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
181
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_wallet_update_session_config_request",
|
|
182
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_wallet_update_session_config_response",
|
|
175
183
|
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
176
184
|
WALLET_LOGIN_RESPONSE: "air_wallet_login_response",
|
|
177
185
|
SETUP_OR_UPDATE_MFA_REQUEST: "air_setup_mfa_request",
|
|
@@ -718,7 +726,7 @@
|
|
|
718
726
|
class TransactionRejectedRpcError extends ProviderRpcError {
|
|
719
727
|
constructor(message) {
|
|
720
728
|
// Remove the "Version: viem@x.x.x" suffix if present
|
|
721
|
-
const cleanMessage = message.replace(/\nVersion:.*$/,
|
|
729
|
+
const cleanMessage = message.replace(/\nVersion:.*$/, "");
|
|
722
730
|
super(cleanMessage);
|
|
723
731
|
this.code = -32003;
|
|
724
732
|
this.name = "TransactionRejectedRpcError";
|
|
@@ -1872,7 +1880,7 @@
|
|
|
1872
1880
|
if (!loginResult) {
|
|
1873
1881
|
throw new UnauthorizedProviderError("User is not logged in");
|
|
1874
1882
|
}
|
|
1875
|
-
if (method === "eth_accounts" &&
|
|
1883
|
+
if ((method === "eth_accounts" || method === "eth_requestAccounts") &&
|
|
1876
1884
|
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this) &&
|
|
1877
1885
|
loginResult?.abstractAccountAddress) {
|
|
1878
1886
|
return [loginResult.abstractAccountAddress];
|
|
@@ -1938,6 +1946,7 @@
|
|
|
1938
1946
|
AirAuthMessageTypes.SETUP_WALLET_REQUEST,
|
|
1939
1947
|
AirAuthMessageTypes.SETUP_RECOVERY_REQUEST,
|
|
1940
1948
|
AirAuthMessageTypes.LOGOUT_RESPONSE,
|
|
1949
|
+
AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
1941
1950
|
AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
|
|
1942
1951
|
AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE,
|
|
1943
1952
|
AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE,
|
|
@@ -1965,6 +1974,11 @@
|
|
|
1965
1974
|
});
|
|
1966
1975
|
return response;
|
|
1967
1976
|
}
|
|
1977
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
1978
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
1979
|
+
await this.sendMessage({ type: AirAuthMessageTypes.UPDATE_SESSION_CONFIG_REQUEST, payload });
|
|
1980
|
+
return response;
|
|
1981
|
+
}
|
|
1968
1982
|
async sendLoginRequest(payload) {
|
|
1969
1983
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.LOGIN_RESPONSE)));
|
|
1970
1984
|
await this.sendMessage({ type: AirAuthMessageTypes.LOGIN_REQUEST, payload });
|
|
@@ -2038,6 +2052,7 @@
|
|
|
2038
2052
|
const ALLOWED_CREDENTIAL_MESSAGES = [
|
|
2039
2053
|
AirCredentialMessageTypes.INITIALIZATION_RESPONSE,
|
|
2040
2054
|
AirCredentialMessageTypes.CREDENTIAL_IFRAME_VISIBILITY_REQUEST,
|
|
2055
|
+
AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
2041
2056
|
AirCredentialMessageTypes.LOGOUT_RESPONSE,
|
|
2042
2057
|
AirCredentialMessageTypes.ISSUE_CREDENTIAL_RESPONSE,
|
|
2043
2058
|
AirCredentialMessageTypes.VERIFY_CREDENTIAL_RESPONSE,
|
|
@@ -2063,6 +2078,14 @@
|
|
|
2063
2078
|
});
|
|
2064
2079
|
return response;
|
|
2065
2080
|
}
|
|
2081
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2082
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2083
|
+
await this.sendMessage({
|
|
2084
|
+
type: AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_REQUEST,
|
|
2085
|
+
payload,
|
|
2086
|
+
});
|
|
2087
|
+
return response;
|
|
2088
|
+
}
|
|
2066
2089
|
async logout() {
|
|
2067
2090
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.LOGOUT_RESPONSE)));
|
|
2068
2091
|
await this.sendMessage({
|
|
@@ -2186,6 +2209,14 @@
|
|
|
2186
2209
|
async onInitialized() {
|
|
2187
2210
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.RECOVERY_INITIALIZED)));
|
|
2188
2211
|
}
|
|
2212
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2213
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2214
|
+
await this.sendMessage({
|
|
2215
|
+
type: AirRecoveryMessageTypes.UPDATE_SESSION_CONFIG_REQUEST,
|
|
2216
|
+
payload,
|
|
2217
|
+
});
|
|
2218
|
+
return response;
|
|
2219
|
+
}
|
|
2189
2220
|
async logout() {
|
|
2190
2221
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.LOGOUT_RESPONSE)));
|
|
2191
2222
|
await this.sendMessage({ type: AirRecoveryMessageTypes.LOGOUT_REQUEST });
|
|
@@ -2205,6 +2236,7 @@
|
|
|
2205
2236
|
const ALLOWED_WALLET_MESSAGES = [
|
|
2206
2237
|
AirWalletMessageTypes.INITIALIZATION_RESPONSE,
|
|
2207
2238
|
AirWalletMessageTypes.WALLET_INITIALIZED,
|
|
2239
|
+
AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
2208
2240
|
AirWalletMessageTypes.WALLET_LOGIN_RESPONSE,
|
|
2209
2241
|
AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE,
|
|
2210
2242
|
AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE,
|
|
@@ -2256,6 +2288,11 @@
|
|
|
2256
2288
|
onInitialized() {
|
|
2257
2289
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.WALLET_INITIALIZED)));
|
|
2258
2290
|
}
|
|
2291
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2292
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2293
|
+
await this.sendMessage({ type: AirWalletMessageTypes.UPDATE_SESSION_CONFIG_REQUEST, payload });
|
|
2294
|
+
return response;
|
|
2295
|
+
}
|
|
2259
2296
|
async sendLoginRequest() {
|
|
2260
2297
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.WALLET_LOGIN_RESPONSE)));
|
|
2261
2298
|
await this.sendMessage({
|
|
@@ -2463,7 +2500,7 @@
|
|
|
2463
2500
|
]);
|
|
2464
2501
|
return (await response).data;
|
|
2465
2502
|
}
|
|
2466
|
-
async openAndInitializeWalletServiceWindow({ url, windowId, partnerId, enableLogging, onRetry, sdkVersion, enableAutomation, }) {
|
|
2503
|
+
async openAndInitializeWalletServiceWindow({ url, windowId, sessionId, partnerId, enableLogging, onRetry, sdkVersion, enableAutomation, }) {
|
|
2467
2504
|
if (this.windowControllers.has(windowId)) {
|
|
2468
2505
|
throw new Error("Window controller already exists");
|
|
2469
2506
|
}
|
|
@@ -2481,6 +2518,7 @@
|
|
|
2481
2518
|
try {
|
|
2482
2519
|
channel = new MessageChannel();
|
|
2483
2520
|
const { payload } = await this.sendWindowInitializationRequest(windowId, {
|
|
2521
|
+
sessionId,
|
|
2484
2522
|
partnerId,
|
|
2485
2523
|
enableLogging,
|
|
2486
2524
|
sdkVersion,
|
|
@@ -2520,7 +2558,7 @@
|
|
|
2520
2558
|
}
|
|
2521
2559
|
var WindowService$1 = WindowService.instance;
|
|
2522
2560
|
|
|
2523
|
-
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized,
|
|
2561
|
+
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;
|
|
2524
2562
|
const airKitVersion = airkitPackage.version;
|
|
2525
2563
|
class AirService {
|
|
2526
2564
|
constructor({ partnerId }) {
|
|
@@ -2529,11 +2567,13 @@
|
|
|
2529
2567
|
_AirService_buildEnv.set(this, void 0);
|
|
2530
2568
|
_AirService_enableLogging.set(this, false);
|
|
2531
2569
|
_AirService_partnerId.set(this, void 0);
|
|
2570
|
+
_AirService_sessionId.set(this, void 0);
|
|
2571
|
+
_AirService_sessionConfig.set(this, void 0);
|
|
2532
2572
|
//#modalZIndex: number; TODO implement z index overwrite
|
|
2533
2573
|
_AirService_authMessagingService.set(this, void 0);
|
|
2534
2574
|
_AirService_authIframeController.set(this, void 0);
|
|
2535
2575
|
_AirService_isAuthInitialized.set(this, false);
|
|
2536
|
-
|
|
2576
|
+
_AirService_airEventListener.set(this, []);
|
|
2537
2577
|
_AirService_walletMessagingService.set(this, void 0);
|
|
2538
2578
|
_AirService_walletIframeController.set(this, void 0);
|
|
2539
2579
|
_AirService_walletInitialization.set(this, void 0);
|
|
@@ -2583,15 +2623,17 @@
|
|
|
2583
2623
|
shouldEnableAutomation() {
|
|
2584
2624
|
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
|
|
2585
2625
|
}
|
|
2586
|
-
async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, }) {
|
|
2626
|
+
async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, }) {
|
|
2587
2627
|
if (!__classPrivateFieldGet(this, _AirService_partnerId, "f"))
|
|
2588
|
-
throw new
|
|
2628
|
+
throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
|
|
2589
2629
|
if (__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2590
|
-
return;
|
|
2630
|
+
return __classPrivateFieldGet(this, _AirService_loginResult, "f") ?? null;
|
|
2591
2631
|
__classPrivateFieldSet(this, _AirService_buildEnv, buildEnv, "f");
|
|
2592
2632
|
__classPrivateFieldSet(this, _AirService_enableLogging, enableLogging, "f");
|
|
2633
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
2593
2634
|
const { authUrl } = AIR_URLS[buildEnv];
|
|
2594
2635
|
configureLogLevel(buildEnv, enableLogging);
|
|
2636
|
+
__classPrivateFieldSet(this, _AirService_sessionId, randomId(), "f");
|
|
2595
2637
|
const authIframeOrigin = new URL(authUrl).origin;
|
|
2596
2638
|
__classPrivateFieldSet(this, _AirService_authIframeController, new IframeController("air-auth", authUrl), "f");
|
|
2597
2639
|
try {
|
|
@@ -2641,12 +2683,14 @@
|
|
|
2641
2683
|
if (ev.data === AirAuthMessageTypes.AUTH_SETUP_COMPLETED) {
|
|
2642
2684
|
window.removeEventListener("message", handleAuthMessage);
|
|
2643
2685
|
const { payload } = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendInitializationRequest({
|
|
2686
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
2644
2687
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
2645
2688
|
skipRehydration,
|
|
2646
2689
|
partnerDAppUrl: window.location.href,
|
|
2647
2690
|
sdkVersion: airKitVersion,
|
|
2648
2691
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
2649
2692
|
enableAutomation: this.shouldEnableAutomation(),
|
|
2693
|
+
sessionConfig,
|
|
2650
2694
|
});
|
|
2651
2695
|
if (payload.success === true) {
|
|
2652
2696
|
resolve(payload);
|
|
@@ -2672,13 +2716,12 @@
|
|
|
2672
2716
|
catch (error) {
|
|
2673
2717
|
log.debug("Error initializing auth service", error);
|
|
2674
2718
|
await this.cleanUp();
|
|
2675
|
-
throw error;
|
|
2719
|
+
throw AirServiceError.from(error);
|
|
2676
2720
|
}
|
|
2677
2721
|
return null;
|
|
2678
2722
|
}
|
|
2679
2723
|
async login(options) {
|
|
2680
|
-
|
|
2681
|
-
throw new Error("Service is not initialized");
|
|
2724
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2682
2725
|
if (__classPrivateFieldGet(this, _AirService_loginResult, "f"))
|
|
2683
2726
|
return __classPrivateFieldGet(this, _AirService_loginResult, "f");
|
|
2684
2727
|
const { payload } = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendLoginRequest({
|
|
@@ -2695,38 +2738,24 @@
|
|
|
2695
2738
|
* @experimental This method is experimental and will change in the future.
|
|
2696
2739
|
*/
|
|
2697
2740
|
async deploySmartAccount() {
|
|
2698
|
-
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2699
|
-
throw new Error("Service is not initialized");
|
|
2700
2741
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2706
|
-
}
|
|
2707
|
-
return { txHash: payload.txHash };
|
|
2708
|
-
}
|
|
2709
|
-
catch (error) {
|
|
2710
|
-
throw AirServiceError.from(error);
|
|
2742
|
+
log.info("deploySmartAccount");
|
|
2743
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendDeploySmartAccountRequest();
|
|
2744
|
+
if (payload.success === false) {
|
|
2745
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2711
2746
|
}
|
|
2747
|
+
return { txHash: payload.txHash };
|
|
2712
2748
|
}
|
|
2713
2749
|
/**
|
|
2714
2750
|
* @experimental This method is experimental and will change in the future.
|
|
2715
2751
|
*/
|
|
2716
2752
|
async isSmartAccountDeployed() {
|
|
2717
|
-
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2718
|
-
throw new Error("Service is not initialized");
|
|
2719
2753
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2724
|
-
}
|
|
2725
|
-
return payload.isDeployed;
|
|
2726
|
-
}
|
|
2727
|
-
catch (error) {
|
|
2728
|
-
throw AirServiceError.from(error);
|
|
2754
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendIsSmartAccountDeployedRequest();
|
|
2755
|
+
if (payload.success === false) {
|
|
2756
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2729
2757
|
}
|
|
2758
|
+
return payload.isDeployed;
|
|
2730
2759
|
}
|
|
2731
2760
|
getProvider() {
|
|
2732
2761
|
return this.provider;
|
|
@@ -2778,8 +2807,7 @@
|
|
|
2778
2807
|
}
|
|
2779
2808
|
}
|
|
2780
2809
|
async getUserInfo() {
|
|
2781
|
-
|
|
2782
|
-
throw new Error("User not logged in");
|
|
2810
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2783
2811
|
const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
2784
2812
|
if (info.payload.success === false) {
|
|
2785
2813
|
throw new AirServiceError(info.payload.errorName, info.payload.errorMessage);
|
|
@@ -2796,11 +2824,37 @@
|
|
|
2796
2824
|
},
|
|
2797
2825
|
};
|
|
2798
2826
|
}
|
|
2827
|
+
async updateSessionConfig(config) {
|
|
2828
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2829
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, config, "f");
|
|
2830
|
+
const resultsPromise = [__classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendUpdateSessionConfigRequest(config)];
|
|
2831
|
+
if (__classPrivateFieldGet(this, _AirService_walletInitialization, "f")) {
|
|
2832
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_walletInitialization, "f")
|
|
2833
|
+
.then(() => __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2834
|
+
.catch(() => null));
|
|
2835
|
+
}
|
|
2836
|
+
if (__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")) {
|
|
2837
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")
|
|
2838
|
+
.then(() => __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2839
|
+
.catch(() => null));
|
|
2840
|
+
}
|
|
2841
|
+
if (__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")) {
|
|
2842
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")
|
|
2843
|
+
.then(() => __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2844
|
+
.catch(() => null));
|
|
2845
|
+
}
|
|
2846
|
+
const results = await Promise.all(resultsPromise);
|
|
2847
|
+
for (const result of results) {
|
|
2848
|
+
if (result && result.payload.success === false) {
|
|
2849
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
const sessionConfig = { locale: results[0].payload.locale };
|
|
2853
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
2854
|
+
return sessionConfig;
|
|
2855
|
+
}
|
|
2799
2856
|
async goToPartner(partnerUrl) {
|
|
2800
|
-
|
|
2801
|
-
throw new Error("Service is not initialized");
|
|
2802
|
-
if (!this.isLoggedIn)
|
|
2803
|
-
throw new Error("No active session to generate token");
|
|
2857
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2804
2858
|
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendCrossPartnerTokenRequest(partnerUrl);
|
|
2805
2859
|
if (result.payload.success === false) {
|
|
2806
2860
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
@@ -2810,35 +2864,24 @@
|
|
|
2810
2864
|
};
|
|
2811
2865
|
}
|
|
2812
2866
|
async startRecovery(payload) {
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2817
|
-
}
|
|
2818
|
-
}
|
|
2819
|
-
catch (error) {
|
|
2820
|
-
throw AirServiceError.from(error);
|
|
2867
|
+
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendAccountRecoveryRequest(payload);
|
|
2868
|
+
if (result.payload.success === false) {
|
|
2869
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2821
2870
|
}
|
|
2822
2871
|
}
|
|
2823
2872
|
async getAccessToken() {
|
|
2824
|
-
|
|
2825
|
-
throw new Error("Service is not initialized");
|
|
2826
|
-
if (!this.isLoggedIn)
|
|
2827
|
-
throw new Error("No active session to get partner access token");
|
|
2873
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2828
2874
|
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerAccessTokenRequest();
|
|
2829
2875
|
if (result.payload.success !== true) {
|
|
2830
2876
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2831
2877
|
}
|
|
2832
2878
|
if (!result.payload.partnerAccessToken) {
|
|
2833
|
-
throw new
|
|
2879
|
+
throw new AirServiceError("UNAUTHORIZED", "Partner access token not found in response");
|
|
2834
2880
|
}
|
|
2835
2881
|
return { token: result.payload.partnerAccessToken };
|
|
2836
2882
|
}
|
|
2837
2883
|
async logout() {
|
|
2838
|
-
|
|
2839
|
-
throw new Error("Service is not initialized");
|
|
2840
|
-
if (!this.isLoggedIn)
|
|
2841
|
-
throw new Error("No active session to logout");
|
|
2884
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2842
2885
|
// Clear up credentials first to avoid issues with wallet and auth messaging services
|
|
2843
2886
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
|
|
2844
2887
|
await Promise.all([
|
|
@@ -2850,33 +2893,21 @@
|
|
|
2850
2893
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
|
|
2851
2894
|
}
|
|
2852
2895
|
async cleanUp() {
|
|
2896
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
|
|
2897
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this);
|
|
2853
2898
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this);
|
|
2854
2899
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpAuth).call(this);
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
this
|
|
2900
|
+
__classPrivateFieldSet(this, _AirService_airEventListener, [], "f");
|
|
2901
|
+
__classPrivateFieldSet(this, _AirService_sessionId, undefined, "f");
|
|
2902
|
+
__classPrivateFieldSet(this, _AirService_buildEnv, undefined, "f");
|
|
2858
2903
|
}
|
|
2859
|
-
/**
|
|
2860
|
-
* Register an event listener for Air service events.
|
|
2861
|
-
*
|
|
2862
|
-
* Available events:
|
|
2863
|
-
* - "initialized": Service initialization completed
|
|
2864
|
-
* - "logged_in": User successfully logged in
|
|
2865
|
-
* - "logged_out": User logged out
|
|
2866
|
-
* - "wallet_initialized": Wallet initialization completed
|
|
2867
|
-
*
|
|
2868
|
-
* @param listener The event listener function
|
|
2869
|
-
*/
|
|
2870
2904
|
on(listener) {
|
|
2871
|
-
if (__classPrivateFieldGet(this,
|
|
2872
|
-
__classPrivateFieldGet(this,
|
|
2905
|
+
if (__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener) < 0)
|
|
2906
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").push(listener);
|
|
2873
2907
|
}
|
|
2874
2908
|
off(listener) {
|
|
2875
|
-
if (__classPrivateFieldGet(this,
|
|
2876
|
-
__classPrivateFieldGet(this,
|
|
2877
|
-
}
|
|
2878
|
-
clearEventListeners() {
|
|
2879
|
-
__classPrivateFieldSet(this, _AirService_airAuthListener, [], "f");
|
|
2909
|
+
if (__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener) >= 0)
|
|
2910
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").splice(__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener), 1);
|
|
2880
2911
|
}
|
|
2881
2912
|
async preloadCredential() {
|
|
2882
2913
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
|
|
@@ -2909,9 +2940,15 @@
|
|
|
2909
2940
|
return payload.verificationResult;
|
|
2910
2941
|
}
|
|
2911
2942
|
}
|
|
2912
|
-
_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(),
|
|
2913
|
-
if (!this
|
|
2914
|
-
throw new
|
|
2943
|
+
_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() {
|
|
2944
|
+
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2945
|
+
throw new AirServiceError("NOT_INITIALIZED", "Service is not initialized");
|
|
2946
|
+
}, _AirService_assertLoggedIn = function _AirService_assertLoggedIn() {
|
|
2947
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2948
|
+
if (!this.isLoggedIn)
|
|
2949
|
+
throw new AirServiceError("NOT_LOGGED_IN", "User not logged in");
|
|
2950
|
+
}, _AirService_ensureCredential = async function _AirService_ensureCredential() {
|
|
2951
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2915
2952
|
void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2916
2953
|
try {
|
|
2917
2954
|
if (!__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f"))
|
|
@@ -2921,11 +2958,11 @@
|
|
|
2921
2958
|
catch (error) {
|
|
2922
2959
|
__classPrivateFieldSet(this, _AirService_credentialsInitialization, null, "f");
|
|
2923
2960
|
log.error("Error ensuring credentials", error);
|
|
2924
|
-
throw error;
|
|
2961
|
+
throw AirServiceError.from(error);
|
|
2925
2962
|
}
|
|
2926
2963
|
}, _AirService_initializeCredentials = async function _AirService_initializeCredentials() {
|
|
2927
2964
|
if (__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")) {
|
|
2928
|
-
throw new
|
|
2965
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing credentials");
|
|
2929
2966
|
}
|
|
2930
2967
|
const { credentialUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
2931
2968
|
const credentialIframeOrigin = new URL(credentialUrl).origin;
|
|
@@ -2938,11 +2975,13 @@
|
|
|
2938
2975
|
if (ev.data === AirCredentialMessageTypes.SERVICE_STARTED) {
|
|
2939
2976
|
window.removeEventListener("message", handleCredentialMessage);
|
|
2940
2977
|
const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendInitializationRequest({
|
|
2978
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
2941
2979
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
2942
2980
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
2943
2981
|
sdkVersion: airKitVersion,
|
|
2944
2982
|
partnerDAppUrl: window.location.href,
|
|
2945
2983
|
enableAutomation: this.shouldEnableAutomation(),
|
|
2984
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
2946
2985
|
});
|
|
2947
2986
|
if (payload.success === true) {
|
|
2948
2987
|
resolve();
|
|
@@ -2970,7 +3009,7 @@
|
|
|
2970
3009
|
if (closeDApp) {
|
|
2971
3010
|
window.close();
|
|
2972
3011
|
}
|
|
2973
|
-
throw error;
|
|
3012
|
+
throw AirServiceError.from(error);
|
|
2974
3013
|
}
|
|
2975
3014
|
}, _AirService_subscribeToCredentialEvents = function _AirService_subscribeToCredentialEvents() {
|
|
2976
3015
|
__classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").messages$.subscribe(async (message) => {
|
|
@@ -2995,8 +3034,7 @@
|
|
|
2995
3034
|
await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").close();
|
|
2996
3035
|
__classPrivateFieldSet(this, _AirService_credentialsInitialization, undefined, "f");
|
|
2997
3036
|
}, _AirService_ensureWallet = async function _AirService_ensureWallet(option) {
|
|
2998
|
-
|
|
2999
|
-
throw new Error("Service not initialized");
|
|
3037
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
3000
3038
|
if (!__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
3001
3039
|
__classPrivateFieldSet(this, _AirService_walletInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeWallet).call(this, option), "f");
|
|
3002
3040
|
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
@@ -3010,7 +3048,7 @@
|
|
|
3010
3048
|
catch (error) {
|
|
3011
3049
|
__classPrivateFieldSet(this, _AirService_walletInitialization, null, "f");
|
|
3012
3050
|
log.error("Error initializing wallet", error);
|
|
3013
|
-
throw error;
|
|
3051
|
+
throw AirServiceError.from(error);
|
|
3014
3052
|
}
|
|
3015
3053
|
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
3016
3054
|
return __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f");
|
|
@@ -3021,7 +3059,7 @@
|
|
|
3021
3059
|
return __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, walletLoginResult.payload);
|
|
3022
3060
|
}, _AirService_initializeWallet = async function _AirService_initializeWallet(option) {
|
|
3023
3061
|
if (__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
3024
|
-
throw new
|
|
3062
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing");
|
|
3025
3063
|
const { walletUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
3026
3064
|
const walletIframeOrigin = new URL(walletUrl).origin;
|
|
3027
3065
|
try {
|
|
@@ -3032,10 +3070,12 @@
|
|
|
3032
3070
|
if (ev.data === AirWalletMessageTypes.SERVICE_STARTED) {
|
|
3033
3071
|
window.removeEventListener("message", handleWalletMessage);
|
|
3034
3072
|
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendInitializationRequest({
|
|
3073
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3035
3074
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3036
3075
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3037
3076
|
sdkVersion: airKitVersion,
|
|
3038
3077
|
enableAutomation: this.shouldEnableAutomation(),
|
|
3078
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
3039
3079
|
});
|
|
3040
3080
|
if (payload.success === true) {
|
|
3041
3081
|
resolve();
|
|
@@ -3071,7 +3111,7 @@
|
|
|
3071
3111
|
catch (error) {
|
|
3072
3112
|
log.error("Error initializing wallet", error);
|
|
3073
3113
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this);
|
|
3074
|
-
throw error;
|
|
3114
|
+
throw AirServiceError.from(error);
|
|
3075
3115
|
}
|
|
3076
3116
|
}, _AirService_subscribeToWalletEvents = function _AirService_subscribeToWalletEvents() {
|
|
3077
3117
|
__classPrivateFieldGet(this, _AirService_walletMessagingService, "f").messages$.subscribe(async (msg) => {
|
|
@@ -3100,6 +3140,7 @@
|
|
|
3100
3140
|
const { windowController, port } = await WindowService$1.openAndInitializeWalletServiceWindow({
|
|
3101
3141
|
url: msg.payload.url,
|
|
3102
3142
|
windowId: msg.payload.windowId,
|
|
3143
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3103
3144
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3104
3145
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3105
3146
|
sdkVersion: airKitVersion,
|
|
@@ -3118,7 +3159,7 @@
|
|
|
3118
3159
|
}
|
|
3119
3160
|
});
|
|
3120
3161
|
}, _AirService_triggerEventListeners = function _AirService_triggerEventListeners(data) {
|
|
3121
|
-
__classPrivateFieldGet(this,
|
|
3162
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").forEach((listener) => {
|
|
3122
3163
|
listener(data);
|
|
3123
3164
|
});
|
|
3124
3165
|
}, _AirService_triggerAirAuthInitialized = function _AirService_triggerAirAuthInitialized(result) {
|
|
@@ -3181,8 +3222,7 @@
|
|
|
3181
3222
|
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, undefined, "f");
|
|
3182
3223
|
__classPrivateFieldSet(this, _AirService_walletInitialization, undefined, "f");
|
|
3183
3224
|
}, _AirService_ensureRecovery = async function _AirService_ensureRecovery() {
|
|
3184
|
-
|
|
3185
|
-
throw new Error("Service not initialized");
|
|
3225
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
3186
3226
|
if (!__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")) {
|
|
3187
3227
|
__classPrivateFieldSet(this, _AirService_recoveryInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeRecovery).call(this), "f");
|
|
3188
3228
|
}
|
|
@@ -3192,11 +3232,11 @@
|
|
|
3192
3232
|
catch (error) {
|
|
3193
3233
|
__classPrivateFieldSet(this, _AirService_recoveryInitialization, null, "f");
|
|
3194
3234
|
log.error("Error initializing recovery", error);
|
|
3195
|
-
throw error;
|
|
3235
|
+
throw AirServiceError.from(error);
|
|
3196
3236
|
}
|
|
3197
3237
|
}, _AirService_initializeRecovery = async function _AirService_initializeRecovery() {
|
|
3198
3238
|
if (__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f"))
|
|
3199
|
-
throw new
|
|
3239
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing");
|
|
3200
3240
|
const { recoveryUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
3201
3241
|
const recoveryIframeOrigin = new URL(recoveryUrl).origin;
|
|
3202
3242
|
try {
|
|
@@ -3207,10 +3247,12 @@
|
|
|
3207
3247
|
if (ev.data === AirRecoveryMessageTypes.SERVICE_STARTED) {
|
|
3208
3248
|
window.removeEventListener("message", handleRecoveryMessage);
|
|
3209
3249
|
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendInitializationRequest({
|
|
3250
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3210
3251
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3211
3252
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3212
3253
|
sdkVersion: airKitVersion,
|
|
3213
3254
|
enableAutomation: this.shouldEnableAutomation(),
|
|
3255
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
3214
3256
|
});
|
|
3215
3257
|
if (payload.success === true) {
|
|
3216
3258
|
resolve();
|
|
@@ -3234,7 +3276,7 @@
|
|
|
3234
3276
|
catch (error) {
|
|
3235
3277
|
log.error("Error initializing recovery", error);
|
|
3236
3278
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this);
|
|
3237
|
-
throw error;
|
|
3279
|
+
throw AirServiceError.from(error);
|
|
3238
3280
|
}
|
|
3239
3281
|
}, _AirService_subscribeToRecoveryEvents = function _AirService_subscribeToRecoveryEvents() {
|
|
3240
3282
|
__classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").messages$.subscribe(async (message) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AirAuthStartRecoveryRequestPayload } from "@mocanetwork/common/src/air/messaging/auth";
|
|
2
|
-
import { AirEventListener, AirLoginResult, AirUserDetails, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult, CredentialVerificationResult, EIP1193Provider } from "./interfaces";
|
|
2
|
+
import { AirEventListener, AirLoginResult, AirSessionConfig, AirUserDetails, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult, CredentialVerificationResult, EIP1193Provider } from "./interfaces";
|
|
3
3
|
declare class AirService {
|
|
4
4
|
#private;
|
|
5
5
|
constructor({ partnerId }: {
|
|
@@ -13,11 +13,11 @@ declare class AirService {
|
|
|
13
13
|
get isWalletInitialized(): boolean;
|
|
14
14
|
get provider(): EIP1193Provider;
|
|
15
15
|
private shouldEnableAutomation;
|
|
16
|
-
init({ buildEnv, enableLogging, skipRehydration, }: {
|
|
16
|
+
init({ buildEnv, enableLogging, skipRehydration, sessionConfig, }: {
|
|
17
17
|
buildEnv: BUILD_ENV_TYPE;
|
|
18
18
|
enableLogging: boolean;
|
|
19
19
|
skipRehydration: boolean;
|
|
20
|
-
|
|
20
|
+
sessionConfig?: Partial<AirSessionConfig>;
|
|
21
21
|
}): Promise<AirLoginResult | null>;
|
|
22
22
|
login(options?: {
|
|
23
23
|
authToken?: string;
|
|
@@ -53,6 +53,7 @@ declare class AirService {
|
|
|
53
53
|
targetCurrencyCode?: string;
|
|
54
54
|
}): Promise<void>;
|
|
55
55
|
getUserInfo(): Promise<AirUserDetails>;
|
|
56
|
+
updateSessionConfig(config: Partial<AirSessionConfig>): Promise<AirSessionConfig>;
|
|
56
57
|
goToPartner(partnerUrl: string): Promise<{
|
|
57
58
|
urlWithToken: string;
|
|
58
59
|
}>;
|
|
@@ -62,20 +63,8 @@ declare class AirService {
|
|
|
62
63
|
}>;
|
|
63
64
|
logout(): Promise<void>;
|
|
64
65
|
cleanUp(): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Register an event listener for Air service events.
|
|
67
|
-
*
|
|
68
|
-
* Available events:
|
|
69
|
-
* - "initialized": Service initialization completed
|
|
70
|
-
* - "logged_in": User successfully logged in
|
|
71
|
-
* - "logged_out": User logged out
|
|
72
|
-
* - "wallet_initialized": Wallet initialization completed
|
|
73
|
-
*
|
|
74
|
-
* @param listener The event listener function
|
|
75
|
-
*/
|
|
76
66
|
on(listener: AirEventListener): void;
|
|
77
67
|
off(listener: AirEventListener): void;
|
|
78
|
-
clearEventListeners(): void;
|
|
79
68
|
preloadCredential(): Promise<void>;
|
|
80
69
|
issueCredential({ authToken, issuerDid, credentialId, credentialSubject, }: {
|
|
81
70
|
authToken: string;
|