@mocanetwork/airkit-connector 1.4.2 → 1.5.0-beta.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/airkitConnector.cjs.js +135 -27
- package/dist/airkitConnector.esm.js +135 -27
- package/dist/airkitConnector.umd.js +135 -27
- package/package.json +2 -2
|
@@ -94,7 +94,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
94
94
|
var e = new Error(message);
|
|
95
95
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
96
96
|
};
|
|
97
|
-
var version$2 = "1.
|
|
97
|
+
var version$2 = "1.5.0-beta.0";
|
|
98
98
|
var airkitPackage = {
|
|
99
99
|
version: version$2
|
|
100
100
|
};
|
|
@@ -105,8 +105,6 @@ const AirAuthMessageTypes = {
|
|
|
105
105
|
LOGIN_REQUEST: "air_auth_login_request",
|
|
106
106
|
LOGIN_RESPONSE: "air_auth_login_response",
|
|
107
107
|
LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
|
|
108
|
-
PASSKEY_LOGIN_REQUEST: "air_auth_passkey_login_request",
|
|
109
|
-
PASSKEY_LOGIN_RESPONSE: "air_auth_passkey_login_response",
|
|
110
108
|
USER_INFO_REQUEST: "air_auth_user_info_request",
|
|
111
109
|
USER_INFO_RESPONSE: "air_auth_user_info_response",
|
|
112
110
|
PARTNER_USER_INFO_REQUEST: "air_auth_partner_user_info_request",
|
|
@@ -127,8 +125,6 @@ const AirAuthMessageTypes = {
|
|
|
127
125
|
CROSS_PARTNER_TOKEN_RESPONSE: "air_auth_cross_partner_token_response",
|
|
128
126
|
PARTNER_ACCESS_TOKEN_REQUEST: "air_auth_partner_access_token_request",
|
|
129
127
|
PARTNER_ACCESS_TOKEN_RESPONSE: "air_auth_partner_access_token_response",
|
|
130
|
-
PRIVY_LOGIN_REQUEST: "air_auth_privy_login_request",
|
|
131
|
-
PRIVY_LOGIN_RESPONSE: "air_auth_privy_login_response",
|
|
132
128
|
CREDENTIAL_SALT_REQUEST: "air_auth_credential_salt_request",
|
|
133
129
|
CREDENTIAL_SALT_RESPONSE: "air_auth_credential_salt_response",
|
|
134
130
|
LOGOUT_REQUEST: "air_auth_logout_request",
|
|
@@ -138,8 +134,14 @@ const AirAuthMessageTypes = {
|
|
|
138
134
|
RESET_RECOVERY_COMMUNICATION: "air_auth_reset_recovery_communication",
|
|
139
135
|
START_RECOVERY_REQUEST: "air_start_recovery_request",
|
|
140
136
|
START_RECOVERY_RESPONSE: "air_start_recovery_response",
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
RECOVERY_REQUEST: "air_auth_recovery_request",
|
|
138
|
+
RECOVERY_RESPONSE: "air_auth_recovery_response",
|
|
139
|
+
LINK_EOA_CREDENTIAL_REQUEST: "air_auth_link_eoa_credential_request",
|
|
140
|
+
LINK_EOA_CREDENTIAL_RESPONSE: "air_auth_link_eoa_credential_response",
|
|
141
|
+
LINKAGE_NONCE_REQUEST: "air_auth_linkage_nonce_request",
|
|
142
|
+
LINKAGE_NONCE_RESPONSE: "air_auth_linkage_nonce_response",
|
|
143
|
+
CREDENTIAL_SIGNERS_REQUEST: "air_auth_credential_signers_request",
|
|
144
|
+
CREDENTIAL_SIGNERS_RESPONSE: "air_auth_credential_signers_response"
|
|
143
145
|
};
|
|
144
146
|
const AirRecoveryMessageTypes = {
|
|
145
147
|
SERVICE_STARTED: "air_recovery_service_started",
|
|
@@ -155,6 +157,8 @@ const AirWalletMessageTypes = {
|
|
|
155
157
|
SERVICE_STARTED: "air_service_started",
|
|
156
158
|
INITIALIZATION_REQUEST: "air_initialization_request",
|
|
157
159
|
INITIALIZATION_RESPONSE: "air_initialization_response",
|
|
160
|
+
CLOSE_MODAL_REQUEST: "air_close_modal_request",
|
|
161
|
+
CLOSE_MODAL_RESPONSE: "air_close_modal_response",
|
|
158
162
|
INIT_AUTH_COMMUNICATION: "air_init_auth_communication",
|
|
159
163
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
160
164
|
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
@@ -165,6 +169,8 @@ const AirWalletMessageTypes = {
|
|
|
165
169
|
CLAIM_ID_RESPONSE: "air_claim_id_response",
|
|
166
170
|
SHOW_SWAP_UI_REQUEST: "air_show_swap_ui_request",
|
|
167
171
|
SHOW_SWAP_UI_RESPONSE: "air_show_swap_ui_response",
|
|
172
|
+
SHOW_ON_RAMP_UI_REQUEST: "air_show_on_ramp_ui_request",
|
|
173
|
+
SHOW_ON_RAMP_UI_RESPONSE: "air_show_on_ramp_ui_response",
|
|
168
174
|
DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
|
|
169
175
|
DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
|
|
170
176
|
WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
|
|
@@ -554,6 +560,8 @@ const configureLogLevel = (environment, enableLogging) => {
|
|
|
554
560
|
level = enableLogging ? log$1.levels.DEBUG : log$1.levels.INFO;
|
|
555
561
|
} else if (environment === "uat") {
|
|
556
562
|
level = enableLogging ? log$1.levels.INFO : log$1.levels.WARN;
|
|
563
|
+
} else if (environment === "sandbox") {
|
|
564
|
+
level = enableLogging ? log$1.levels.WARN : log$1.levels.ERROR;
|
|
557
565
|
} else if (environment === "production") {
|
|
558
566
|
// Be cautious with enabling more than WARN in prod
|
|
559
567
|
level = enableLogging ? log$1.levels.WARN : log$1.levels.ERROR;
|
|
@@ -1626,7 +1634,7 @@ class MessageServiceBase {
|
|
|
1626
1634
|
this._messages$ = this.eventSubject.pipe(map(ev => ev.data));
|
|
1627
1635
|
this._events$.subscribe(event => {
|
|
1628
1636
|
const sentOrReceived = event.origin === window.origin ? "sent" : "received";
|
|
1629
|
-
log$1.debug(`[${this.name}] Message ${sentOrReceived}:`, event.data);
|
|
1637
|
+
log$1.debug(`[${this.name}] Message ${sentOrReceived}:`, JSON.stringify(event.data, bigIntReplacer));
|
|
1630
1638
|
});
|
|
1631
1639
|
const handleMessage = async ev => {
|
|
1632
1640
|
if (this.targetOrigin && ev.origin !== this.targetOrigin || !ev.data || !(ev.data instanceof Object)) return;
|
|
@@ -1717,13 +1725,14 @@ var AirWalletProviderMessageTypes;
|
|
|
1717
1725
|
AirWalletProviderMessageTypes["RESPONSE"] = "JRPC_RESPONSE";
|
|
1718
1726
|
AirWalletProviderMessageTypes["EVENT"] = "JRPC_EVENT";
|
|
1719
1727
|
})(AirWalletProviderMessageTypes || (AirWalletProviderMessageTypes = {}));
|
|
1720
|
-
var _a$
|
|
1728
|
+
var _a$3, _ProviderMessageService_instance;
|
|
1721
1729
|
const ALLOWED_PROVIDER_MESSAGES = [AirWalletProviderMessageTypes.RESPONSE, AirWalletProviderMessageTypes.EVENT];
|
|
1722
1730
|
class ProviderMessageService extends MessageServiceBase {
|
|
1723
1731
|
static create() {
|
|
1724
|
-
if (__classPrivateFieldGet$1(this, _a$
|
|
1725
|
-
|
|
1726
|
-
|
|
1732
|
+
if (!__classPrivateFieldGet$1(this, _a$3, "f", _ProviderMessageService_instance)) {
|
|
1733
|
+
__classPrivateFieldSet(this, _a$3, new _a$3("Embed Service: Provider Channel", ALLOWED_PROVIDER_MESSAGES), "f", _ProviderMessageService_instance);
|
|
1734
|
+
}
|
|
1735
|
+
return __classPrivateFieldGet$1(this, _a$3, "f", _ProviderMessageService_instance);
|
|
1727
1736
|
}
|
|
1728
1737
|
async open(walletIframe) {
|
|
1729
1738
|
const origin = new URL(walletIframe.src).origin;
|
|
@@ -1742,7 +1751,7 @@ class ProviderMessageService extends MessageServiceBase {
|
|
|
1742
1751
|
return response;
|
|
1743
1752
|
}
|
|
1744
1753
|
}
|
|
1745
|
-
_a$
|
|
1754
|
+
_a$3 = ProviderMessageService;
|
|
1746
1755
|
_ProviderMessageService_instance = {
|
|
1747
1756
|
value: void 0
|
|
1748
1757
|
};
|
|
@@ -1853,13 +1862,14 @@ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_is
|
|
|
1853
1862
|
}
|
|
1854
1863
|
});
|
|
1855
1864
|
};
|
|
1856
|
-
var _a$
|
|
1857
|
-
const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION, AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.CREDENTIAL_SALT_RESPONSE, AirAuthMessageTypes.START_RECOVERY_RESPONSE];
|
|
1865
|
+
var _a$2, _AuthMessageService_instance;
|
|
1866
|
+
const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION, AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.CREDENTIAL_SALT_RESPONSE, AirAuthMessageTypes.START_RECOVERY_RESPONSE, AirAuthMessageTypes.LINK_EOA_CREDENTIAL_RESPONSE, AirAuthMessageTypes.LINKAGE_NONCE_RESPONSE, AirAuthMessageTypes.CREDENTIAL_SIGNERS_RESPONSE];
|
|
1858
1867
|
class AuthMessageService extends MessageServiceBase {
|
|
1859
1868
|
static create() {
|
|
1860
|
-
if (__classPrivateFieldGet$1(this, _a$
|
|
1861
|
-
|
|
1862
|
-
|
|
1869
|
+
if (!__classPrivateFieldGet$1(this, _a$2, "f", _AuthMessageService_instance)) {
|
|
1870
|
+
__classPrivateFieldSet(this, _a$2, new _a$2("Embed Service: Auth Channel", ALLOWED_AUTH_MESSAGES), "f", _AuthMessageService_instance);
|
|
1871
|
+
}
|
|
1872
|
+
return __classPrivateFieldGet$1(this, _a$2, "f", _AuthMessageService_instance);
|
|
1863
1873
|
}
|
|
1864
1874
|
async open(authIframe) {
|
|
1865
1875
|
const origin = new URL(authIframe.src).origin;
|
|
@@ -1983,16 +1993,47 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
1983
1993
|
});
|
|
1984
1994
|
return response;
|
|
1985
1995
|
}
|
|
1996
|
+
async sendLinkEoaCredentialRequest(payload) {
|
|
1997
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.LINK_EOA_CREDENTIAL_RESPONSE)));
|
|
1998
|
+
await this.sendMessage({
|
|
1999
|
+
type: AirAuthMessageTypes.LINK_EOA_CREDENTIAL_REQUEST,
|
|
2000
|
+
payload
|
|
2001
|
+
});
|
|
2002
|
+
return response;
|
|
2003
|
+
}
|
|
2004
|
+
async sendCredentialSignersRequest(payload) {
|
|
2005
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.CREDENTIAL_SIGNERS_RESPONSE)));
|
|
2006
|
+
await this.sendMessage({
|
|
2007
|
+
type: AirAuthMessageTypes.CREDENTIAL_SIGNERS_REQUEST,
|
|
2008
|
+
payload
|
|
2009
|
+
});
|
|
2010
|
+
return response;
|
|
2011
|
+
}
|
|
2012
|
+
async sendLinkageNonceRequest(payload) {
|
|
2013
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.LINKAGE_NONCE_RESPONSE)));
|
|
2014
|
+
await this.sendMessage({
|
|
2015
|
+
type: AirAuthMessageTypes.LINKAGE_NONCE_REQUEST,
|
|
2016
|
+
payload
|
|
2017
|
+
});
|
|
2018
|
+
return response;
|
|
2019
|
+
}
|
|
1986
2020
|
}
|
|
1987
|
-
_a$
|
|
2021
|
+
_a$2 = AuthMessageService;
|
|
1988
2022
|
_AuthMessageService_instance = {
|
|
1989
2023
|
value: void 0
|
|
1990
2024
|
};
|
|
1991
2025
|
class IframeController {
|
|
2026
|
+
getZIndex() {
|
|
2027
|
+
if (this.iframeId.includes("air-auth")) return this.AUTH_IFRAME_Z_INDEX;
|
|
2028
|
+
if (this.iframeId.includes("air-wallet")) return this.WALLET_IFRAME_Z_INDEX;
|
|
2029
|
+
if (this.iframeId.includes("air-recovery")) return this.RECOVERY_IFRAME_Z_INDEX;
|
|
2030
|
+
return "9999999"; // Default z-index if not matched
|
|
2031
|
+
}
|
|
1992
2032
|
constructor(iframeUrl, iframeId, state) {
|
|
1993
2033
|
this._iframeElement = null;
|
|
1994
|
-
this.AUTH_IFRAME_Z_INDEX = "
|
|
1995
|
-
this.
|
|
2034
|
+
this.AUTH_IFRAME_Z_INDEX = "9999998";
|
|
2035
|
+
this.WALLET_IFRAME_Z_INDEX = "9999999";
|
|
2036
|
+
this.RECOVERY_IFRAME_Z_INDEX = "999999";
|
|
1996
2037
|
this.state = {
|
|
1997
2038
|
...IframeController.defaultState,
|
|
1998
2039
|
...state
|
|
@@ -2010,7 +2051,7 @@ class IframeController {
|
|
|
2010
2051
|
iframe.allow = "publickey-credentials-get *; publickey-credentials-create *";
|
|
2011
2052
|
iframe.src = this.iframeUrl;
|
|
2012
2053
|
iframe.style.position = "fixed";
|
|
2013
|
-
iframe.style.zIndex = this.
|
|
2054
|
+
iframe.style.zIndex = this.getZIndex();
|
|
2014
2055
|
iframe.style.border = "none";
|
|
2015
2056
|
iframe.style.margin = "0";
|
|
2016
2057
|
iframe.style.padding = "0";
|
|
@@ -2052,13 +2093,14 @@ class IframeController {
|
|
|
2052
2093
|
IframeController.defaultState = {
|
|
2053
2094
|
isVisible: false
|
|
2054
2095
|
};
|
|
2096
|
+
var _a$1, _RecoveryMessageService_instance;
|
|
2055
2097
|
const ALLOWED_RECOVERY_MESSAGES = Object.values(AirRecoveryMessageTypes);
|
|
2056
2098
|
class RecoveryMessageService extends MessageServiceBase {
|
|
2057
2099
|
static create() {
|
|
2058
|
-
if (!
|
|
2059
|
-
|
|
2100
|
+
if (!__classPrivateFieldGet$1(this, _a$1, "f", _RecoveryMessageService_instance)) {
|
|
2101
|
+
__classPrivateFieldSet(this, _a$1, new _a$1("Recovery Service", ALLOWED_RECOVERY_MESSAGES), "f", _RecoveryMessageService_instance);
|
|
2060
2102
|
}
|
|
2061
|
-
return
|
|
2103
|
+
return __classPrivateFieldGet$1(this, _a$1, "f", _RecoveryMessageService_instance);
|
|
2062
2104
|
}
|
|
2063
2105
|
async sendInitializationRequest(payload) {
|
|
2064
2106
|
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.INITIALIZATION_RESPONSE)));
|
|
@@ -2093,8 +2135,12 @@ class RecoveryMessageService extends MessageServiceBase {
|
|
|
2093
2135
|
await super.close();
|
|
2094
2136
|
}
|
|
2095
2137
|
}
|
|
2138
|
+
_a$1 = RecoveryMessageService;
|
|
2139
|
+
_RecoveryMessageService_instance = {
|
|
2140
|
+
value: void 0
|
|
2141
|
+
};
|
|
2096
2142
|
var _a, _WalletMessageService_instance;
|
|
2097
|
-
const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
|
|
2143
|
+
const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
|
|
2098
2144
|
class WalletMessageService extends MessageServiceBase {
|
|
2099
2145
|
static create() {
|
|
2100
2146
|
if (__classPrivateFieldGet$1(this, _a, "f", _WalletMessageService_instance)) throw new Error("WalletMessageService already created");
|
|
@@ -2215,6 +2261,14 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2215
2261
|
});
|
|
2216
2262
|
return response;
|
|
2217
2263
|
}
|
|
2264
|
+
async sendShowOnRampUIRequest(payload) {
|
|
2265
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE)));
|
|
2266
|
+
await this.sendMessage({
|
|
2267
|
+
type: AirWalletMessageTypes.SHOW_ON_RAMP_UI_REQUEST,
|
|
2268
|
+
payload
|
|
2269
|
+
});
|
|
2270
|
+
return response;
|
|
2271
|
+
}
|
|
2218
2272
|
}
|
|
2219
2273
|
_a = WalletMessageService;
|
|
2220
2274
|
_WalletMessageService_instance = {
|
|
@@ -2483,7 +2537,7 @@ class AirService {
|
|
|
2483
2537
|
};
|
|
2484
2538
|
}
|
|
2485
2539
|
shouldEnableAutomation() {
|
|
2486
|
-
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet$1(this, _AirService_buildEnv, "f") !==
|
|
2540
|
+
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet$1(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
|
|
2487
2541
|
}
|
|
2488
2542
|
async init({
|
|
2489
2543
|
buildEnv = BUILD_ENV.PRODUCTION,
|
|
@@ -2567,6 +2621,7 @@ class AirService {
|
|
|
2567
2621
|
__classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthInitialized).call(this, {
|
|
2568
2622
|
rehydrated: result.rehydrated
|
|
2569
2623
|
});
|
|
2624
|
+
if (result.preloadWallet) this.preloadWallet();
|
|
2570
2625
|
// rehydrated auth session
|
|
2571
2626
|
if (result.rehydrated) {
|
|
2572
2627
|
__classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
|
|
@@ -2648,6 +2703,43 @@ class AirService {
|
|
|
2648
2703
|
credentialSalt: result.payload.credentialSalt
|
|
2649
2704
|
};
|
|
2650
2705
|
}
|
|
2706
|
+
/**
|
|
2707
|
+
* @experimental This method is experimental and will change in the future.
|
|
2708
|
+
*/
|
|
2709
|
+
async getLinkageNonce(payload) {
|
|
2710
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2711
|
+
if (!this.isLoggedIn) throw new Error("No active session to get nonce");
|
|
2712
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendLinkageNonceRequest(payload);
|
|
2713
|
+
if (result.payload.success === false) {
|
|
2714
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2715
|
+
}
|
|
2716
|
+
return {
|
|
2717
|
+
nonce: result.payload.nonce
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
/**
|
|
2721
|
+
* @experimental This method is experimental and will change in the future.
|
|
2722
|
+
*/
|
|
2723
|
+
async retrieveCredentialSigners(payload) {
|
|
2724
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2725
|
+
if (!this.isLoggedIn) throw new Error("No active session to retrieve EOA credential");
|
|
2726
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendCredentialSignersRequest(payload);
|
|
2727
|
+
if (result.payload.success === false) {
|
|
2728
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2729
|
+
}
|
|
2730
|
+
return result.payload.credentials;
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* @experimental This method is experimental and will change in the future.
|
|
2734
|
+
*/
|
|
2735
|
+
async linkEoaCredential(payload) {
|
|
2736
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2737
|
+
if (!this.isLoggedIn) throw new Error("No active session to link EOA credential");
|
|
2738
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendLinkEoaCredentialRequest(payload);
|
|
2739
|
+
if (result.payload.success === false) {
|
|
2740
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2651
2743
|
getProvider() {
|
|
2652
2744
|
return this.provider;
|
|
2653
2745
|
}
|
|
@@ -2669,6 +2761,9 @@ class AirService {
|
|
|
2669
2761
|
isMFASetup: true
|
|
2670
2762
|
});
|
|
2671
2763
|
}
|
|
2764
|
+
/**
|
|
2765
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2766
|
+
*/
|
|
2672
2767
|
async claimAirId(options) {
|
|
2673
2768
|
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2674
2769
|
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendClaimIdRequest(options ?? {});
|
|
@@ -2679,6 +2774,9 @@ class AirService {
|
|
|
2679
2774
|
}
|
|
2680
2775
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2681
2776
|
}
|
|
2777
|
+
/**
|
|
2778
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2779
|
+
*/
|
|
2682
2780
|
async showSwapUI() {
|
|
2683
2781
|
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2684
2782
|
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest();
|
|
@@ -2689,6 +2787,16 @@ class AirService {
|
|
|
2689
2787
|
txHash: result.payload.txHash
|
|
2690
2788
|
};
|
|
2691
2789
|
}
|
|
2790
|
+
/**
|
|
2791
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2792
|
+
*/
|
|
2793
|
+
async showOnRampUI(options) {
|
|
2794
|
+
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2795
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowOnRampUIRequest(options);
|
|
2796
|
+
if (result.payload.success === false) {
|
|
2797
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2692
2800
|
async getUserInfo() {
|
|
2693
2801
|
if (!this.isLoggedIn) throw new Error("User not logged in");
|
|
2694
2802
|
const info = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
var e = new Error(message);
|
|
93
93
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
94
94
|
};
|
|
95
|
-
var version$2 = "1.
|
|
95
|
+
var version$2 = "1.5.0-beta.0";
|
|
96
96
|
var airkitPackage = {
|
|
97
97
|
version: version$2
|
|
98
98
|
};
|
|
@@ -103,8 +103,6 @@ const AirAuthMessageTypes = {
|
|
|
103
103
|
LOGIN_REQUEST: "air_auth_login_request",
|
|
104
104
|
LOGIN_RESPONSE: "air_auth_login_response",
|
|
105
105
|
LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
|
|
106
|
-
PASSKEY_LOGIN_REQUEST: "air_auth_passkey_login_request",
|
|
107
|
-
PASSKEY_LOGIN_RESPONSE: "air_auth_passkey_login_response",
|
|
108
106
|
USER_INFO_REQUEST: "air_auth_user_info_request",
|
|
109
107
|
USER_INFO_RESPONSE: "air_auth_user_info_response",
|
|
110
108
|
PARTNER_USER_INFO_REQUEST: "air_auth_partner_user_info_request",
|
|
@@ -125,8 +123,6 @@ const AirAuthMessageTypes = {
|
|
|
125
123
|
CROSS_PARTNER_TOKEN_RESPONSE: "air_auth_cross_partner_token_response",
|
|
126
124
|
PARTNER_ACCESS_TOKEN_REQUEST: "air_auth_partner_access_token_request",
|
|
127
125
|
PARTNER_ACCESS_TOKEN_RESPONSE: "air_auth_partner_access_token_response",
|
|
128
|
-
PRIVY_LOGIN_REQUEST: "air_auth_privy_login_request",
|
|
129
|
-
PRIVY_LOGIN_RESPONSE: "air_auth_privy_login_response",
|
|
130
126
|
CREDENTIAL_SALT_REQUEST: "air_auth_credential_salt_request",
|
|
131
127
|
CREDENTIAL_SALT_RESPONSE: "air_auth_credential_salt_response",
|
|
132
128
|
LOGOUT_REQUEST: "air_auth_logout_request",
|
|
@@ -136,8 +132,14 @@ const AirAuthMessageTypes = {
|
|
|
136
132
|
RESET_RECOVERY_COMMUNICATION: "air_auth_reset_recovery_communication",
|
|
137
133
|
START_RECOVERY_REQUEST: "air_start_recovery_request",
|
|
138
134
|
START_RECOVERY_RESPONSE: "air_start_recovery_response",
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
RECOVERY_REQUEST: "air_auth_recovery_request",
|
|
136
|
+
RECOVERY_RESPONSE: "air_auth_recovery_response",
|
|
137
|
+
LINK_EOA_CREDENTIAL_REQUEST: "air_auth_link_eoa_credential_request",
|
|
138
|
+
LINK_EOA_CREDENTIAL_RESPONSE: "air_auth_link_eoa_credential_response",
|
|
139
|
+
LINKAGE_NONCE_REQUEST: "air_auth_linkage_nonce_request",
|
|
140
|
+
LINKAGE_NONCE_RESPONSE: "air_auth_linkage_nonce_response",
|
|
141
|
+
CREDENTIAL_SIGNERS_REQUEST: "air_auth_credential_signers_request",
|
|
142
|
+
CREDENTIAL_SIGNERS_RESPONSE: "air_auth_credential_signers_response"
|
|
141
143
|
};
|
|
142
144
|
const AirRecoveryMessageTypes = {
|
|
143
145
|
SERVICE_STARTED: "air_recovery_service_started",
|
|
@@ -153,6 +155,8 @@ const AirWalletMessageTypes = {
|
|
|
153
155
|
SERVICE_STARTED: "air_service_started",
|
|
154
156
|
INITIALIZATION_REQUEST: "air_initialization_request",
|
|
155
157
|
INITIALIZATION_RESPONSE: "air_initialization_response",
|
|
158
|
+
CLOSE_MODAL_REQUEST: "air_close_modal_request",
|
|
159
|
+
CLOSE_MODAL_RESPONSE: "air_close_modal_response",
|
|
156
160
|
INIT_AUTH_COMMUNICATION: "air_init_auth_communication",
|
|
157
161
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
158
162
|
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
@@ -163,6 +167,8 @@ const AirWalletMessageTypes = {
|
|
|
163
167
|
CLAIM_ID_RESPONSE: "air_claim_id_response",
|
|
164
168
|
SHOW_SWAP_UI_REQUEST: "air_show_swap_ui_request",
|
|
165
169
|
SHOW_SWAP_UI_RESPONSE: "air_show_swap_ui_response",
|
|
170
|
+
SHOW_ON_RAMP_UI_REQUEST: "air_show_on_ramp_ui_request",
|
|
171
|
+
SHOW_ON_RAMP_UI_RESPONSE: "air_show_on_ramp_ui_response",
|
|
166
172
|
DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
|
|
167
173
|
DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
|
|
168
174
|
WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
|
|
@@ -552,6 +558,8 @@ const configureLogLevel = (environment, enableLogging) => {
|
|
|
552
558
|
level = enableLogging ? log$1.levels.DEBUG : log$1.levels.INFO;
|
|
553
559
|
} else if (environment === "uat") {
|
|
554
560
|
level = enableLogging ? log$1.levels.INFO : log$1.levels.WARN;
|
|
561
|
+
} else if (environment === "sandbox") {
|
|
562
|
+
level = enableLogging ? log$1.levels.WARN : log$1.levels.ERROR;
|
|
555
563
|
} else if (environment === "production") {
|
|
556
564
|
// Be cautious with enabling more than WARN in prod
|
|
557
565
|
level = enableLogging ? log$1.levels.WARN : log$1.levels.ERROR;
|
|
@@ -1624,7 +1632,7 @@ class MessageServiceBase {
|
|
|
1624
1632
|
this._messages$ = this.eventSubject.pipe(map(ev => ev.data));
|
|
1625
1633
|
this._events$.subscribe(event => {
|
|
1626
1634
|
const sentOrReceived = event.origin === window.origin ? "sent" : "received";
|
|
1627
|
-
log$1.debug(`[${this.name}] Message ${sentOrReceived}:`, event.data);
|
|
1635
|
+
log$1.debug(`[${this.name}] Message ${sentOrReceived}:`, JSON.stringify(event.data, bigIntReplacer));
|
|
1628
1636
|
});
|
|
1629
1637
|
const handleMessage = async ev => {
|
|
1630
1638
|
if (this.targetOrigin && ev.origin !== this.targetOrigin || !ev.data || !(ev.data instanceof Object)) return;
|
|
@@ -1715,13 +1723,14 @@ var AirWalletProviderMessageTypes;
|
|
|
1715
1723
|
AirWalletProviderMessageTypes["RESPONSE"] = "JRPC_RESPONSE";
|
|
1716
1724
|
AirWalletProviderMessageTypes["EVENT"] = "JRPC_EVENT";
|
|
1717
1725
|
})(AirWalletProviderMessageTypes || (AirWalletProviderMessageTypes = {}));
|
|
1718
|
-
var _a$
|
|
1726
|
+
var _a$3, _ProviderMessageService_instance;
|
|
1719
1727
|
const ALLOWED_PROVIDER_MESSAGES = [AirWalletProviderMessageTypes.RESPONSE, AirWalletProviderMessageTypes.EVENT];
|
|
1720
1728
|
class ProviderMessageService extends MessageServiceBase {
|
|
1721
1729
|
static create() {
|
|
1722
|
-
if (__classPrivateFieldGet$1(this, _a$
|
|
1723
|
-
|
|
1724
|
-
|
|
1730
|
+
if (!__classPrivateFieldGet$1(this, _a$3, "f", _ProviderMessageService_instance)) {
|
|
1731
|
+
__classPrivateFieldSet(this, _a$3, new _a$3("Embed Service: Provider Channel", ALLOWED_PROVIDER_MESSAGES), "f", _ProviderMessageService_instance);
|
|
1732
|
+
}
|
|
1733
|
+
return __classPrivateFieldGet$1(this, _a$3, "f", _ProviderMessageService_instance);
|
|
1725
1734
|
}
|
|
1726
1735
|
async open(walletIframe) {
|
|
1727
1736
|
const origin = new URL(walletIframe.src).origin;
|
|
@@ -1740,7 +1749,7 @@ class ProviderMessageService extends MessageServiceBase {
|
|
|
1740
1749
|
return response;
|
|
1741
1750
|
}
|
|
1742
1751
|
}
|
|
1743
|
-
_a$
|
|
1752
|
+
_a$3 = ProviderMessageService;
|
|
1744
1753
|
_ProviderMessageService_instance = {
|
|
1745
1754
|
value: void 0
|
|
1746
1755
|
};
|
|
@@ -1851,13 +1860,14 @@ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_is
|
|
|
1851
1860
|
}
|
|
1852
1861
|
});
|
|
1853
1862
|
};
|
|
1854
|
-
var _a$
|
|
1855
|
-
const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION, AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.CREDENTIAL_SALT_RESPONSE, AirAuthMessageTypes.START_RECOVERY_RESPONSE];
|
|
1863
|
+
var _a$2, _AuthMessageService_instance;
|
|
1864
|
+
const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION, AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.CREDENTIAL_SALT_RESPONSE, AirAuthMessageTypes.START_RECOVERY_RESPONSE, AirAuthMessageTypes.LINK_EOA_CREDENTIAL_RESPONSE, AirAuthMessageTypes.LINKAGE_NONCE_RESPONSE, AirAuthMessageTypes.CREDENTIAL_SIGNERS_RESPONSE];
|
|
1856
1865
|
class AuthMessageService extends MessageServiceBase {
|
|
1857
1866
|
static create() {
|
|
1858
|
-
if (__classPrivateFieldGet$1(this, _a$
|
|
1859
|
-
|
|
1860
|
-
|
|
1867
|
+
if (!__classPrivateFieldGet$1(this, _a$2, "f", _AuthMessageService_instance)) {
|
|
1868
|
+
__classPrivateFieldSet(this, _a$2, new _a$2("Embed Service: Auth Channel", ALLOWED_AUTH_MESSAGES), "f", _AuthMessageService_instance);
|
|
1869
|
+
}
|
|
1870
|
+
return __classPrivateFieldGet$1(this, _a$2, "f", _AuthMessageService_instance);
|
|
1861
1871
|
}
|
|
1862
1872
|
async open(authIframe) {
|
|
1863
1873
|
const origin = new URL(authIframe.src).origin;
|
|
@@ -1981,16 +1991,47 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
1981
1991
|
});
|
|
1982
1992
|
return response;
|
|
1983
1993
|
}
|
|
1994
|
+
async sendLinkEoaCredentialRequest(payload) {
|
|
1995
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.LINK_EOA_CREDENTIAL_RESPONSE)));
|
|
1996
|
+
await this.sendMessage({
|
|
1997
|
+
type: AirAuthMessageTypes.LINK_EOA_CREDENTIAL_REQUEST,
|
|
1998
|
+
payload
|
|
1999
|
+
});
|
|
2000
|
+
return response;
|
|
2001
|
+
}
|
|
2002
|
+
async sendCredentialSignersRequest(payload) {
|
|
2003
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.CREDENTIAL_SIGNERS_RESPONSE)));
|
|
2004
|
+
await this.sendMessage({
|
|
2005
|
+
type: AirAuthMessageTypes.CREDENTIAL_SIGNERS_REQUEST,
|
|
2006
|
+
payload
|
|
2007
|
+
});
|
|
2008
|
+
return response;
|
|
2009
|
+
}
|
|
2010
|
+
async sendLinkageNonceRequest(payload) {
|
|
2011
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.LINKAGE_NONCE_RESPONSE)));
|
|
2012
|
+
await this.sendMessage({
|
|
2013
|
+
type: AirAuthMessageTypes.LINKAGE_NONCE_REQUEST,
|
|
2014
|
+
payload
|
|
2015
|
+
});
|
|
2016
|
+
return response;
|
|
2017
|
+
}
|
|
1984
2018
|
}
|
|
1985
|
-
_a$
|
|
2019
|
+
_a$2 = AuthMessageService;
|
|
1986
2020
|
_AuthMessageService_instance = {
|
|
1987
2021
|
value: void 0
|
|
1988
2022
|
};
|
|
1989
2023
|
class IframeController {
|
|
2024
|
+
getZIndex() {
|
|
2025
|
+
if (this.iframeId.includes("air-auth")) return this.AUTH_IFRAME_Z_INDEX;
|
|
2026
|
+
if (this.iframeId.includes("air-wallet")) return this.WALLET_IFRAME_Z_INDEX;
|
|
2027
|
+
if (this.iframeId.includes("air-recovery")) return this.RECOVERY_IFRAME_Z_INDEX;
|
|
2028
|
+
return "9999999"; // Default z-index if not matched
|
|
2029
|
+
}
|
|
1990
2030
|
constructor(iframeUrl, iframeId, state) {
|
|
1991
2031
|
this._iframeElement = null;
|
|
1992
|
-
this.AUTH_IFRAME_Z_INDEX = "
|
|
1993
|
-
this.
|
|
2032
|
+
this.AUTH_IFRAME_Z_INDEX = "9999998";
|
|
2033
|
+
this.WALLET_IFRAME_Z_INDEX = "9999999";
|
|
2034
|
+
this.RECOVERY_IFRAME_Z_INDEX = "999999";
|
|
1994
2035
|
this.state = {
|
|
1995
2036
|
...IframeController.defaultState,
|
|
1996
2037
|
...state
|
|
@@ -2008,7 +2049,7 @@ class IframeController {
|
|
|
2008
2049
|
iframe.allow = "publickey-credentials-get *; publickey-credentials-create *";
|
|
2009
2050
|
iframe.src = this.iframeUrl;
|
|
2010
2051
|
iframe.style.position = "fixed";
|
|
2011
|
-
iframe.style.zIndex = this.
|
|
2052
|
+
iframe.style.zIndex = this.getZIndex();
|
|
2012
2053
|
iframe.style.border = "none";
|
|
2013
2054
|
iframe.style.margin = "0";
|
|
2014
2055
|
iframe.style.padding = "0";
|
|
@@ -2050,13 +2091,14 @@ class IframeController {
|
|
|
2050
2091
|
IframeController.defaultState = {
|
|
2051
2092
|
isVisible: false
|
|
2052
2093
|
};
|
|
2094
|
+
var _a$1, _RecoveryMessageService_instance;
|
|
2053
2095
|
const ALLOWED_RECOVERY_MESSAGES = Object.values(AirRecoveryMessageTypes);
|
|
2054
2096
|
class RecoveryMessageService extends MessageServiceBase {
|
|
2055
2097
|
static create() {
|
|
2056
|
-
if (!
|
|
2057
|
-
|
|
2098
|
+
if (!__classPrivateFieldGet$1(this, _a$1, "f", _RecoveryMessageService_instance)) {
|
|
2099
|
+
__classPrivateFieldSet(this, _a$1, new _a$1("Recovery Service", ALLOWED_RECOVERY_MESSAGES), "f", _RecoveryMessageService_instance);
|
|
2058
2100
|
}
|
|
2059
|
-
return
|
|
2101
|
+
return __classPrivateFieldGet$1(this, _a$1, "f", _RecoveryMessageService_instance);
|
|
2060
2102
|
}
|
|
2061
2103
|
async sendInitializationRequest(payload) {
|
|
2062
2104
|
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.INITIALIZATION_RESPONSE)));
|
|
@@ -2091,8 +2133,12 @@ class RecoveryMessageService extends MessageServiceBase {
|
|
|
2091
2133
|
await super.close();
|
|
2092
2134
|
}
|
|
2093
2135
|
}
|
|
2136
|
+
_a$1 = RecoveryMessageService;
|
|
2137
|
+
_RecoveryMessageService_instance = {
|
|
2138
|
+
value: void 0
|
|
2139
|
+
};
|
|
2094
2140
|
var _a, _WalletMessageService_instance;
|
|
2095
|
-
const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
|
|
2141
|
+
const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
|
|
2096
2142
|
class WalletMessageService extends MessageServiceBase {
|
|
2097
2143
|
static create() {
|
|
2098
2144
|
if (__classPrivateFieldGet$1(this, _a, "f", _WalletMessageService_instance)) throw new Error("WalletMessageService already created");
|
|
@@ -2213,6 +2259,14 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2213
2259
|
});
|
|
2214
2260
|
return response;
|
|
2215
2261
|
}
|
|
2262
|
+
async sendShowOnRampUIRequest(payload) {
|
|
2263
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE)));
|
|
2264
|
+
await this.sendMessage({
|
|
2265
|
+
type: AirWalletMessageTypes.SHOW_ON_RAMP_UI_REQUEST,
|
|
2266
|
+
payload
|
|
2267
|
+
});
|
|
2268
|
+
return response;
|
|
2269
|
+
}
|
|
2216
2270
|
}
|
|
2217
2271
|
_a = WalletMessageService;
|
|
2218
2272
|
_WalletMessageService_instance = {
|
|
@@ -2481,7 +2535,7 @@ class AirService {
|
|
|
2481
2535
|
};
|
|
2482
2536
|
}
|
|
2483
2537
|
shouldEnableAutomation() {
|
|
2484
|
-
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet$1(this, _AirService_buildEnv, "f") !==
|
|
2538
|
+
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet$1(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
|
|
2485
2539
|
}
|
|
2486
2540
|
async init({
|
|
2487
2541
|
buildEnv = BUILD_ENV.PRODUCTION,
|
|
@@ -2565,6 +2619,7 @@ class AirService {
|
|
|
2565
2619
|
__classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthInitialized).call(this, {
|
|
2566
2620
|
rehydrated: result.rehydrated
|
|
2567
2621
|
});
|
|
2622
|
+
if (result.preloadWallet) this.preloadWallet();
|
|
2568
2623
|
// rehydrated auth session
|
|
2569
2624
|
if (result.rehydrated) {
|
|
2570
2625
|
__classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
|
|
@@ -2646,6 +2701,43 @@ class AirService {
|
|
|
2646
2701
|
credentialSalt: result.payload.credentialSalt
|
|
2647
2702
|
};
|
|
2648
2703
|
}
|
|
2704
|
+
/**
|
|
2705
|
+
* @experimental This method is experimental and will change in the future.
|
|
2706
|
+
*/
|
|
2707
|
+
async getLinkageNonce(payload) {
|
|
2708
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2709
|
+
if (!this.isLoggedIn) throw new Error("No active session to get nonce");
|
|
2710
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendLinkageNonceRequest(payload);
|
|
2711
|
+
if (result.payload.success === false) {
|
|
2712
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2713
|
+
}
|
|
2714
|
+
return {
|
|
2715
|
+
nonce: result.payload.nonce
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* @experimental This method is experimental and will change in the future.
|
|
2720
|
+
*/
|
|
2721
|
+
async retrieveCredentialSigners(payload) {
|
|
2722
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2723
|
+
if (!this.isLoggedIn) throw new Error("No active session to retrieve EOA credential");
|
|
2724
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendCredentialSignersRequest(payload);
|
|
2725
|
+
if (result.payload.success === false) {
|
|
2726
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2727
|
+
}
|
|
2728
|
+
return result.payload.credentials;
|
|
2729
|
+
}
|
|
2730
|
+
/**
|
|
2731
|
+
* @experimental This method is experimental and will change in the future.
|
|
2732
|
+
*/
|
|
2733
|
+
async linkEoaCredential(payload) {
|
|
2734
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2735
|
+
if (!this.isLoggedIn) throw new Error("No active session to link EOA credential");
|
|
2736
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendLinkEoaCredentialRequest(payload);
|
|
2737
|
+
if (result.payload.success === false) {
|
|
2738
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2649
2741
|
getProvider() {
|
|
2650
2742
|
return this.provider;
|
|
2651
2743
|
}
|
|
@@ -2667,6 +2759,9 @@ class AirService {
|
|
|
2667
2759
|
isMFASetup: true
|
|
2668
2760
|
});
|
|
2669
2761
|
}
|
|
2762
|
+
/**
|
|
2763
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2764
|
+
*/
|
|
2670
2765
|
async claimAirId(options) {
|
|
2671
2766
|
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2672
2767
|
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendClaimIdRequest(options ?? {});
|
|
@@ -2677,6 +2772,9 @@ class AirService {
|
|
|
2677
2772
|
}
|
|
2678
2773
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2679
2774
|
}
|
|
2775
|
+
/**
|
|
2776
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2777
|
+
*/
|
|
2680
2778
|
async showSwapUI() {
|
|
2681
2779
|
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2682
2780
|
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest();
|
|
@@ -2687,6 +2785,16 @@ class AirService {
|
|
|
2687
2785
|
txHash: result.payload.txHash
|
|
2688
2786
|
};
|
|
2689
2787
|
}
|
|
2788
|
+
/**
|
|
2789
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2790
|
+
*/
|
|
2791
|
+
async showOnRampUI(options) {
|
|
2792
|
+
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2793
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowOnRampUIRequest(options);
|
|
2794
|
+
if (result.payload.success === false) {
|
|
2795
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2690
2798
|
async getUserInfo() {
|
|
2691
2799
|
if (!this.isLoggedIn) throw new Error("User not logged in");
|
|
2692
2800
|
const info = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
var e = new Error(message);
|
|
99
99
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
100
100
|
};
|
|
101
|
-
var version$2 = "1.
|
|
101
|
+
var version$2 = "1.5.0-beta.0";
|
|
102
102
|
var airkitPackage = {
|
|
103
103
|
version: version$2
|
|
104
104
|
};
|
|
@@ -109,8 +109,6 @@
|
|
|
109
109
|
LOGIN_REQUEST: "air_auth_login_request",
|
|
110
110
|
LOGIN_RESPONSE: "air_auth_login_response",
|
|
111
111
|
LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
|
|
112
|
-
PASSKEY_LOGIN_REQUEST: "air_auth_passkey_login_request",
|
|
113
|
-
PASSKEY_LOGIN_RESPONSE: "air_auth_passkey_login_response",
|
|
114
112
|
USER_INFO_REQUEST: "air_auth_user_info_request",
|
|
115
113
|
USER_INFO_RESPONSE: "air_auth_user_info_response",
|
|
116
114
|
PARTNER_USER_INFO_REQUEST: "air_auth_partner_user_info_request",
|
|
@@ -131,8 +129,6 @@
|
|
|
131
129
|
CROSS_PARTNER_TOKEN_RESPONSE: "air_auth_cross_partner_token_response",
|
|
132
130
|
PARTNER_ACCESS_TOKEN_REQUEST: "air_auth_partner_access_token_request",
|
|
133
131
|
PARTNER_ACCESS_TOKEN_RESPONSE: "air_auth_partner_access_token_response",
|
|
134
|
-
PRIVY_LOGIN_REQUEST: "air_auth_privy_login_request",
|
|
135
|
-
PRIVY_LOGIN_RESPONSE: "air_auth_privy_login_response",
|
|
136
132
|
CREDENTIAL_SALT_REQUEST: "air_auth_credential_salt_request",
|
|
137
133
|
CREDENTIAL_SALT_RESPONSE: "air_auth_credential_salt_response",
|
|
138
134
|
LOGOUT_REQUEST: "air_auth_logout_request",
|
|
@@ -142,8 +138,14 @@
|
|
|
142
138
|
RESET_RECOVERY_COMMUNICATION: "air_auth_reset_recovery_communication",
|
|
143
139
|
START_RECOVERY_REQUEST: "air_start_recovery_request",
|
|
144
140
|
START_RECOVERY_RESPONSE: "air_start_recovery_response",
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
RECOVERY_REQUEST: "air_auth_recovery_request",
|
|
142
|
+
RECOVERY_RESPONSE: "air_auth_recovery_response",
|
|
143
|
+
LINK_EOA_CREDENTIAL_REQUEST: "air_auth_link_eoa_credential_request",
|
|
144
|
+
LINK_EOA_CREDENTIAL_RESPONSE: "air_auth_link_eoa_credential_response",
|
|
145
|
+
LINKAGE_NONCE_REQUEST: "air_auth_linkage_nonce_request",
|
|
146
|
+
LINKAGE_NONCE_RESPONSE: "air_auth_linkage_nonce_response",
|
|
147
|
+
CREDENTIAL_SIGNERS_REQUEST: "air_auth_credential_signers_request",
|
|
148
|
+
CREDENTIAL_SIGNERS_RESPONSE: "air_auth_credential_signers_response"
|
|
147
149
|
};
|
|
148
150
|
const AirRecoveryMessageTypes = {
|
|
149
151
|
SERVICE_STARTED: "air_recovery_service_started",
|
|
@@ -159,6 +161,8 @@
|
|
|
159
161
|
SERVICE_STARTED: "air_service_started",
|
|
160
162
|
INITIALIZATION_REQUEST: "air_initialization_request",
|
|
161
163
|
INITIALIZATION_RESPONSE: "air_initialization_response",
|
|
164
|
+
CLOSE_MODAL_REQUEST: "air_close_modal_request",
|
|
165
|
+
CLOSE_MODAL_RESPONSE: "air_close_modal_response",
|
|
162
166
|
INIT_AUTH_COMMUNICATION: "air_init_auth_communication",
|
|
163
167
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
164
168
|
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
@@ -169,6 +173,8 @@
|
|
|
169
173
|
CLAIM_ID_RESPONSE: "air_claim_id_response",
|
|
170
174
|
SHOW_SWAP_UI_REQUEST: "air_show_swap_ui_request",
|
|
171
175
|
SHOW_SWAP_UI_RESPONSE: "air_show_swap_ui_response",
|
|
176
|
+
SHOW_ON_RAMP_UI_REQUEST: "air_show_on_ramp_ui_request",
|
|
177
|
+
SHOW_ON_RAMP_UI_RESPONSE: "air_show_on_ramp_ui_response",
|
|
172
178
|
DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
|
|
173
179
|
DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
|
|
174
180
|
WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
|
|
@@ -558,6 +564,8 @@
|
|
|
558
564
|
level = enableLogging ? log$1.levels.DEBUG : log$1.levels.INFO;
|
|
559
565
|
} else if (environment === "uat") {
|
|
560
566
|
level = enableLogging ? log$1.levels.INFO : log$1.levels.WARN;
|
|
567
|
+
} else if (environment === "sandbox") {
|
|
568
|
+
level = enableLogging ? log$1.levels.WARN : log$1.levels.ERROR;
|
|
561
569
|
} else if (environment === "production") {
|
|
562
570
|
// Be cautious with enabling more than WARN in prod
|
|
563
571
|
level = enableLogging ? log$1.levels.WARN : log$1.levels.ERROR;
|
|
@@ -1630,7 +1638,7 @@
|
|
|
1630
1638
|
this._messages$ = this.eventSubject.pipe(map(ev => ev.data));
|
|
1631
1639
|
this._events$.subscribe(event => {
|
|
1632
1640
|
const sentOrReceived = event.origin === window.origin ? "sent" : "received";
|
|
1633
|
-
log$1.debug(`[${this.name}] Message ${sentOrReceived}:`, event.data);
|
|
1641
|
+
log$1.debug(`[${this.name}] Message ${sentOrReceived}:`, JSON.stringify(event.data, bigIntReplacer));
|
|
1634
1642
|
});
|
|
1635
1643
|
const handleMessage = async ev => {
|
|
1636
1644
|
if (this.targetOrigin && ev.origin !== this.targetOrigin || !ev.data || !(ev.data instanceof Object)) return;
|
|
@@ -1721,13 +1729,14 @@
|
|
|
1721
1729
|
AirWalletProviderMessageTypes["RESPONSE"] = "JRPC_RESPONSE";
|
|
1722
1730
|
AirWalletProviderMessageTypes["EVENT"] = "JRPC_EVENT";
|
|
1723
1731
|
})(AirWalletProviderMessageTypes || (AirWalletProviderMessageTypes = {}));
|
|
1724
|
-
var _a$
|
|
1732
|
+
var _a$3, _ProviderMessageService_instance;
|
|
1725
1733
|
const ALLOWED_PROVIDER_MESSAGES = [AirWalletProviderMessageTypes.RESPONSE, AirWalletProviderMessageTypes.EVENT];
|
|
1726
1734
|
class ProviderMessageService extends MessageServiceBase {
|
|
1727
1735
|
static create() {
|
|
1728
|
-
if (__classPrivateFieldGet$1(this, _a$
|
|
1729
|
-
|
|
1730
|
-
|
|
1736
|
+
if (!__classPrivateFieldGet$1(this, _a$3, "f", _ProviderMessageService_instance)) {
|
|
1737
|
+
__classPrivateFieldSet(this, _a$3, new _a$3("Embed Service: Provider Channel", ALLOWED_PROVIDER_MESSAGES), "f", _ProviderMessageService_instance);
|
|
1738
|
+
}
|
|
1739
|
+
return __classPrivateFieldGet$1(this, _a$3, "f", _ProviderMessageService_instance);
|
|
1731
1740
|
}
|
|
1732
1741
|
async open(walletIframe) {
|
|
1733
1742
|
const origin = new URL(walletIframe.src).origin;
|
|
@@ -1746,7 +1755,7 @@
|
|
|
1746
1755
|
return response;
|
|
1747
1756
|
}
|
|
1748
1757
|
}
|
|
1749
|
-
_a$
|
|
1758
|
+
_a$3 = ProviderMessageService;
|
|
1750
1759
|
_ProviderMessageService_instance = {
|
|
1751
1760
|
value: void 0
|
|
1752
1761
|
};
|
|
@@ -1857,13 +1866,14 @@
|
|
|
1857
1866
|
}
|
|
1858
1867
|
});
|
|
1859
1868
|
};
|
|
1860
|
-
var _a$
|
|
1861
|
-
const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION, AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.CREDENTIAL_SALT_RESPONSE, AirAuthMessageTypes.START_RECOVERY_RESPONSE];
|
|
1869
|
+
var _a$2, _AuthMessageService_instance;
|
|
1870
|
+
const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION, AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.CREDENTIAL_SALT_RESPONSE, AirAuthMessageTypes.START_RECOVERY_RESPONSE, AirAuthMessageTypes.LINK_EOA_CREDENTIAL_RESPONSE, AirAuthMessageTypes.LINKAGE_NONCE_RESPONSE, AirAuthMessageTypes.CREDENTIAL_SIGNERS_RESPONSE];
|
|
1862
1871
|
class AuthMessageService extends MessageServiceBase {
|
|
1863
1872
|
static create() {
|
|
1864
|
-
if (__classPrivateFieldGet$1(this, _a$
|
|
1865
|
-
|
|
1866
|
-
|
|
1873
|
+
if (!__classPrivateFieldGet$1(this, _a$2, "f", _AuthMessageService_instance)) {
|
|
1874
|
+
__classPrivateFieldSet(this, _a$2, new _a$2("Embed Service: Auth Channel", ALLOWED_AUTH_MESSAGES), "f", _AuthMessageService_instance);
|
|
1875
|
+
}
|
|
1876
|
+
return __classPrivateFieldGet$1(this, _a$2, "f", _AuthMessageService_instance);
|
|
1867
1877
|
}
|
|
1868
1878
|
async open(authIframe) {
|
|
1869
1879
|
const origin = new URL(authIframe.src).origin;
|
|
@@ -1987,16 +1997,47 @@
|
|
|
1987
1997
|
});
|
|
1988
1998
|
return response;
|
|
1989
1999
|
}
|
|
2000
|
+
async sendLinkEoaCredentialRequest(payload) {
|
|
2001
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.LINK_EOA_CREDENTIAL_RESPONSE)));
|
|
2002
|
+
await this.sendMessage({
|
|
2003
|
+
type: AirAuthMessageTypes.LINK_EOA_CREDENTIAL_REQUEST,
|
|
2004
|
+
payload
|
|
2005
|
+
});
|
|
2006
|
+
return response;
|
|
2007
|
+
}
|
|
2008
|
+
async sendCredentialSignersRequest(payload) {
|
|
2009
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.CREDENTIAL_SIGNERS_RESPONSE)));
|
|
2010
|
+
await this.sendMessage({
|
|
2011
|
+
type: AirAuthMessageTypes.CREDENTIAL_SIGNERS_REQUEST,
|
|
2012
|
+
payload
|
|
2013
|
+
});
|
|
2014
|
+
return response;
|
|
2015
|
+
}
|
|
2016
|
+
async sendLinkageNonceRequest(payload) {
|
|
2017
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.LINKAGE_NONCE_RESPONSE)));
|
|
2018
|
+
await this.sendMessage({
|
|
2019
|
+
type: AirAuthMessageTypes.LINKAGE_NONCE_REQUEST,
|
|
2020
|
+
payload
|
|
2021
|
+
});
|
|
2022
|
+
return response;
|
|
2023
|
+
}
|
|
1990
2024
|
}
|
|
1991
|
-
_a$
|
|
2025
|
+
_a$2 = AuthMessageService;
|
|
1992
2026
|
_AuthMessageService_instance = {
|
|
1993
2027
|
value: void 0
|
|
1994
2028
|
};
|
|
1995
2029
|
class IframeController {
|
|
2030
|
+
getZIndex() {
|
|
2031
|
+
if (this.iframeId.includes("air-auth")) return this.AUTH_IFRAME_Z_INDEX;
|
|
2032
|
+
if (this.iframeId.includes("air-wallet")) return this.WALLET_IFRAME_Z_INDEX;
|
|
2033
|
+
if (this.iframeId.includes("air-recovery")) return this.RECOVERY_IFRAME_Z_INDEX;
|
|
2034
|
+
return "9999999"; // Default z-index if not matched
|
|
2035
|
+
}
|
|
1996
2036
|
constructor(iframeUrl, iframeId, state) {
|
|
1997
2037
|
this._iframeElement = null;
|
|
1998
|
-
this.AUTH_IFRAME_Z_INDEX = "
|
|
1999
|
-
this.
|
|
2038
|
+
this.AUTH_IFRAME_Z_INDEX = "9999998";
|
|
2039
|
+
this.WALLET_IFRAME_Z_INDEX = "9999999";
|
|
2040
|
+
this.RECOVERY_IFRAME_Z_INDEX = "999999";
|
|
2000
2041
|
this.state = {
|
|
2001
2042
|
...IframeController.defaultState,
|
|
2002
2043
|
...state
|
|
@@ -2014,7 +2055,7 @@
|
|
|
2014
2055
|
iframe.allow = "publickey-credentials-get *; publickey-credentials-create *";
|
|
2015
2056
|
iframe.src = this.iframeUrl;
|
|
2016
2057
|
iframe.style.position = "fixed";
|
|
2017
|
-
iframe.style.zIndex = this.
|
|
2058
|
+
iframe.style.zIndex = this.getZIndex();
|
|
2018
2059
|
iframe.style.border = "none";
|
|
2019
2060
|
iframe.style.margin = "0";
|
|
2020
2061
|
iframe.style.padding = "0";
|
|
@@ -2056,13 +2097,14 @@
|
|
|
2056
2097
|
IframeController.defaultState = {
|
|
2057
2098
|
isVisible: false
|
|
2058
2099
|
};
|
|
2100
|
+
var _a$1, _RecoveryMessageService_instance;
|
|
2059
2101
|
const ALLOWED_RECOVERY_MESSAGES = Object.values(AirRecoveryMessageTypes);
|
|
2060
2102
|
class RecoveryMessageService extends MessageServiceBase {
|
|
2061
2103
|
static create() {
|
|
2062
|
-
if (!
|
|
2063
|
-
|
|
2104
|
+
if (!__classPrivateFieldGet$1(this, _a$1, "f", _RecoveryMessageService_instance)) {
|
|
2105
|
+
__classPrivateFieldSet(this, _a$1, new _a$1("Recovery Service", ALLOWED_RECOVERY_MESSAGES), "f", _RecoveryMessageService_instance);
|
|
2064
2106
|
}
|
|
2065
|
-
return
|
|
2107
|
+
return __classPrivateFieldGet$1(this, _a$1, "f", _RecoveryMessageService_instance);
|
|
2066
2108
|
}
|
|
2067
2109
|
async sendInitializationRequest(payload) {
|
|
2068
2110
|
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.INITIALIZATION_RESPONSE)));
|
|
@@ -2097,8 +2139,12 @@
|
|
|
2097
2139
|
await super.close();
|
|
2098
2140
|
}
|
|
2099
2141
|
}
|
|
2142
|
+
_a$1 = RecoveryMessageService;
|
|
2143
|
+
_RecoveryMessageService_instance = {
|
|
2144
|
+
value: void 0
|
|
2145
|
+
};
|
|
2100
2146
|
var _a, _WalletMessageService_instance;
|
|
2101
|
-
const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
|
|
2147
|
+
const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
|
|
2102
2148
|
class WalletMessageService extends MessageServiceBase {
|
|
2103
2149
|
static create() {
|
|
2104
2150
|
if (__classPrivateFieldGet$1(this, _a, "f", _WalletMessageService_instance)) throw new Error("WalletMessageService already created");
|
|
@@ -2219,6 +2265,14 @@
|
|
|
2219
2265
|
});
|
|
2220
2266
|
return response;
|
|
2221
2267
|
}
|
|
2268
|
+
async sendShowOnRampUIRequest(payload) {
|
|
2269
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE)));
|
|
2270
|
+
await this.sendMessage({
|
|
2271
|
+
type: AirWalletMessageTypes.SHOW_ON_RAMP_UI_REQUEST,
|
|
2272
|
+
payload
|
|
2273
|
+
});
|
|
2274
|
+
return response;
|
|
2275
|
+
}
|
|
2222
2276
|
}
|
|
2223
2277
|
_a = WalletMessageService;
|
|
2224
2278
|
_WalletMessageService_instance = {
|
|
@@ -2487,7 +2541,7 @@
|
|
|
2487
2541
|
};
|
|
2488
2542
|
}
|
|
2489
2543
|
shouldEnableAutomation() {
|
|
2490
|
-
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet$1(this, _AirService_buildEnv, "f") !==
|
|
2544
|
+
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet$1(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
|
|
2491
2545
|
}
|
|
2492
2546
|
async init({
|
|
2493
2547
|
buildEnv = BUILD_ENV.PRODUCTION,
|
|
@@ -2571,6 +2625,7 @@
|
|
|
2571
2625
|
__classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthInitialized).call(this, {
|
|
2572
2626
|
rehydrated: result.rehydrated
|
|
2573
2627
|
});
|
|
2628
|
+
if (result.preloadWallet) this.preloadWallet();
|
|
2574
2629
|
// rehydrated auth session
|
|
2575
2630
|
if (result.rehydrated) {
|
|
2576
2631
|
__classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
|
|
@@ -2652,6 +2707,43 @@
|
|
|
2652
2707
|
credentialSalt: result.payload.credentialSalt
|
|
2653
2708
|
};
|
|
2654
2709
|
}
|
|
2710
|
+
/**
|
|
2711
|
+
* @experimental This method is experimental and will change in the future.
|
|
2712
|
+
*/
|
|
2713
|
+
async getLinkageNonce(payload) {
|
|
2714
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2715
|
+
if (!this.isLoggedIn) throw new Error("No active session to get nonce");
|
|
2716
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendLinkageNonceRequest(payload);
|
|
2717
|
+
if (result.payload.success === false) {
|
|
2718
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2719
|
+
}
|
|
2720
|
+
return {
|
|
2721
|
+
nonce: result.payload.nonce
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* @experimental This method is experimental and will change in the future.
|
|
2726
|
+
*/
|
|
2727
|
+
async retrieveCredentialSigners(payload) {
|
|
2728
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2729
|
+
if (!this.isLoggedIn) throw new Error("No active session to retrieve EOA credential");
|
|
2730
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendCredentialSignersRequest(payload);
|
|
2731
|
+
if (result.payload.success === false) {
|
|
2732
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2733
|
+
}
|
|
2734
|
+
return result.payload.credentials;
|
|
2735
|
+
}
|
|
2736
|
+
/**
|
|
2737
|
+
* @experimental This method is experimental and will change in the future.
|
|
2738
|
+
*/
|
|
2739
|
+
async linkEoaCredential(payload) {
|
|
2740
|
+
if (!__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) throw new Error("Service is not initialized");
|
|
2741
|
+
if (!this.isLoggedIn) throw new Error("No active session to link EOA credential");
|
|
2742
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendLinkEoaCredentialRequest(payload);
|
|
2743
|
+
if (result.payload.success === false) {
|
|
2744
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2655
2747
|
getProvider() {
|
|
2656
2748
|
return this.provider;
|
|
2657
2749
|
}
|
|
@@ -2673,6 +2765,9 @@
|
|
|
2673
2765
|
isMFASetup: true
|
|
2674
2766
|
});
|
|
2675
2767
|
}
|
|
2768
|
+
/**
|
|
2769
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2770
|
+
*/
|
|
2676
2771
|
async claimAirId(options) {
|
|
2677
2772
|
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2678
2773
|
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendClaimIdRequest(options ?? {});
|
|
@@ -2683,6 +2778,9 @@
|
|
|
2683
2778
|
}
|
|
2684
2779
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2685
2780
|
}
|
|
2781
|
+
/**
|
|
2782
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2783
|
+
*/
|
|
2686
2784
|
async showSwapUI() {
|
|
2687
2785
|
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2688
2786
|
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest();
|
|
@@ -2693,6 +2791,16 @@
|
|
|
2693
2791
|
txHash: result.payload.txHash
|
|
2694
2792
|
};
|
|
2695
2793
|
}
|
|
2794
|
+
/**
|
|
2795
|
+
* @experimental This feature has not been officially released and might change in the future.
|
|
2796
|
+
*/
|
|
2797
|
+
async showOnRampUI(options) {
|
|
2798
|
+
await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2799
|
+
const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowOnRampUIRequest(options);
|
|
2800
|
+
if (result.payload.success === false) {
|
|
2801
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2696
2804
|
async getUserInfo() {
|
|
2697
2805
|
if (!this.isLoggedIn) throw new Error("User not logged in");
|
|
2698
2806
|
const info = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mocanetwork/airkit-connector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-beta.0",
|
|
4
4
|
"description": "AirKit wagmi connector to connect with the AirService",
|
|
5
5
|
"main": "dist/airkitConnector.cjs.js",
|
|
6
6
|
"unpkg": "dist/airkitConnector.umd.min.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"pre-commit": "lint-staged --cwd ."
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@mocanetwork/airkit": "^1.
|
|
26
|
+
"@mocanetwork/airkit": "^1.5.0-beta.0",
|
|
27
27
|
"@wagmi/core": "^2.x",
|
|
28
28
|
"loglevel": "^1.8.1",
|
|
29
29
|
"viem": "^2.x"
|