@mocanetwork/airkit 1.9.0-beta.2 → 1.9.0-beta.3
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 +107 -6
- package/dist/airkit.esm.js +107 -6
- package/dist/airkit.umd.js +107 -6
- package/dist/types/airService.d.ts +4 -1
- package/dist/types/airWalletProvider.d.ts +3 -1
- package/dist/types/common/air/messaging/messageServiceBase.d.ts +1 -1
- package/dist/types/common/air/messaging/recovery.d.ts +24 -1
- package/dist/types/common/realm/user/types.d.ts +5 -0
- package/dist/types/common/utils.d.ts +9 -0
- package/dist/types/interfaces.d.ts +10 -0
- package/dist/types/recoveryMessageService.d.ts +8 -1
- package/package.json +1 -1
package/dist/airkit.cjs.js
CHANGED
|
@@ -97,7 +97,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
97
97
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
var version = "1.9.0-beta.
|
|
100
|
+
var version = "1.9.0-beta.3";
|
|
101
101
|
var airkitPackage = {
|
|
102
102
|
version: version};
|
|
103
103
|
|
|
@@ -177,6 +177,12 @@ const AirRecoveryMessageTypes = {
|
|
|
177
177
|
RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
|
|
178
178
|
UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
|
|
179
179
|
UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
|
|
180
|
+
GET_AGENT_KEYS_REQUEST: "air_recovery_get_agent_keys_request",
|
|
181
|
+
GET_AGENT_KEYS_RESPONSE: "air_recovery_get_agent_keys_response",
|
|
182
|
+
REGISTER_AGENT_KEY_REQUEST: "air_recovery_register_agent_key_request",
|
|
183
|
+
REGISTER_AGENT_KEY_RESPONSE: "air_recovery_register_agent_key_response",
|
|
184
|
+
REMOVE_AGENT_KEY_REQUEST: "air_recovery_remove_agent_key_request",
|
|
185
|
+
REMOVE_AGENT_KEY_RESPONSE: "air_recovery_remove_agent_key_response",
|
|
180
186
|
LOGOUT_REQUEST: "air_recovery_logout_request",
|
|
181
187
|
LOGOUT_RESPONSE: "air_recovery_logout_response"
|
|
182
188
|
};
|
|
@@ -2012,7 +2018,7 @@ class ProviderMessageService extends MessageServiceBase {
|
|
|
2012
2018
|
_a$4 = ProviderMessageService;
|
|
2013
2019
|
_ProviderMessageService_instance = { value: void 0 };
|
|
2014
2020
|
|
|
2015
|
-
var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_emit;
|
|
2021
|
+
var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_currentChainId, _AirWalletProvider_emit, _AirWalletProvider_getAddressForCurrentChain, _AirWalletProvider_parseChainId;
|
|
2016
2022
|
class AirWalletProvider {
|
|
2017
2023
|
constructor({ ensureWallet, isWalletInitialized, getLoginResult, }) {
|
|
2018
2024
|
_AirWalletProvider_instances.add(this);
|
|
@@ -2021,11 +2027,18 @@ class AirWalletProvider {
|
|
|
2021
2027
|
_AirWalletProvider_getLoginResult.set(this, void 0);
|
|
2022
2028
|
_AirWalletProvider_ensureWallet.set(this, void 0);
|
|
2023
2029
|
_AirWalletProvider_eventListeners.set(this, void 0);
|
|
2030
|
+
_AirWalletProvider_currentChainId.set(this, null);
|
|
2024
2031
|
this.startEventMessageListening = async (walletIframe) => {
|
|
2025
2032
|
await __classPrivateFieldGet(this, _AirWalletProvider_providerMessageService, "f").open(walletIframe);
|
|
2026
2033
|
__classPrivateFieldGet(this, _AirWalletProvider_providerMessageService, "f").messages$
|
|
2027
2034
|
.pipe(filter((msg) => msg.type === AirWalletProviderMessageTypes.EVENT))
|
|
2028
2035
|
.subscribe((message) => {
|
|
2036
|
+
if (message.payload.event === "chainChanged") {
|
|
2037
|
+
const parsedChainId = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, message.payload.data);
|
|
2038
|
+
if (parsedChainId !== null) {
|
|
2039
|
+
__classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId, "f");
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2029
2042
|
__classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_emit).call(this, message.payload.event, ...[message.payload.data]);
|
|
2030
2043
|
});
|
|
2031
2044
|
};
|
|
@@ -2061,10 +2074,13 @@ class AirWalletProvider {
|
|
|
2061
2074
|
if (!loginResult) {
|
|
2062
2075
|
throw new UnauthorizedProviderError("User is not logged in");
|
|
2063
2076
|
}
|
|
2077
|
+
// Early return optimization: return cached address from login result if wallet not yet initialized
|
|
2064
2078
|
if ((method === "eth_accounts" || method === "eth_requestAccounts") &&
|
|
2065
|
-
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this)
|
|
2066
|
-
loginResult
|
|
2067
|
-
|
|
2079
|
+
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this)) {
|
|
2080
|
+
const address = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_getAddressForCurrentChain).call(this, loginResult);
|
|
2081
|
+
if (address) {
|
|
2082
|
+
return [address];
|
|
2083
|
+
}
|
|
2068
2084
|
}
|
|
2069
2085
|
const skipWalletLoginMethods = ["eth_chainId"];
|
|
2070
2086
|
try {
|
|
@@ -2086,6 +2102,12 @@ class AirWalletProvider {
|
|
|
2086
2102
|
if (!response.success) {
|
|
2087
2103
|
throw ensureProviderRpcError(response.payload);
|
|
2088
2104
|
}
|
|
2105
|
+
if (method === "eth_chainId") {
|
|
2106
|
+
const parsedChainId = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, response.payload.response);
|
|
2107
|
+
if (parsedChainId !== null) {
|
|
2108
|
+
__classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId, "f");
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2089
2111
|
return response.payload.response;
|
|
2090
2112
|
}
|
|
2091
2113
|
on(eventName, listener) {
|
|
@@ -2109,7 +2131,7 @@ class AirWalletProvider {
|
|
|
2109
2131
|
}, "f");
|
|
2110
2132
|
}
|
|
2111
2133
|
}
|
|
2112
|
-
_AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
|
|
2134
|
+
_AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_currentChainId = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
|
|
2113
2135
|
(__classPrivateFieldGet(this, _AirWalletProvider_eventListeners, "f")[eventName] || []).forEach((listener) => {
|
|
2114
2136
|
try {
|
|
2115
2137
|
return listener(...args);
|
|
@@ -2118,6 +2140,32 @@ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_is
|
|
|
2118
2140
|
log.warn(error);
|
|
2119
2141
|
}
|
|
2120
2142
|
});
|
|
2143
|
+
}, _AirWalletProvider_getAddressForCurrentChain = function _AirWalletProvider_getAddressForCurrentChain(loginResult) {
|
|
2144
|
+
const currentChainId = __classPrivateFieldGet(this, _AirWalletProvider_currentChainId, "f");
|
|
2145
|
+
// If we have the new addresses array and current chainId, look up by chain
|
|
2146
|
+
if (loginResult.abstractAccountAddresses && currentChainId !== null) {
|
|
2147
|
+
const chainIdStr = String(currentChainId);
|
|
2148
|
+
const addressEntry = loginResult.abstractAccountAddresses.find((entry) => entry.chainIds.includes(chainIdStr));
|
|
2149
|
+
if (addressEntry) {
|
|
2150
|
+
return addressEntry.address;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
// Fallback to legacy single address (backward compatibility)
|
|
2154
|
+
return loginResult.abstractAccountAddress;
|
|
2155
|
+
}, _AirWalletProvider_parseChainId = function _AirWalletProvider_parseChainId(chainId) {
|
|
2156
|
+
if (typeof chainId === "number") {
|
|
2157
|
+
return Number.isFinite(chainId) ? chainId : null;
|
|
2158
|
+
}
|
|
2159
|
+
if (typeof chainId === "bigint") {
|
|
2160
|
+
return Number(chainId);
|
|
2161
|
+
}
|
|
2162
|
+
if (typeof chainId !== "string" || !chainId) {
|
|
2163
|
+
return null;
|
|
2164
|
+
}
|
|
2165
|
+
const parsed = chainId.startsWith("0x")
|
|
2166
|
+
? parseInt(chainId, 16)
|
|
2167
|
+
: parseInt(chainId, 10);
|
|
2168
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
2121
2169
|
};
|
|
2122
2170
|
|
|
2123
2171
|
var _a$3, _AuthMessageService_instance;
|
|
@@ -2431,6 +2479,29 @@ class RecoveryMessageService extends MessageServiceBase {
|
|
|
2431
2479
|
await this.sendMessage({ type: AirRecoveryMessageTypes.LOGOUT_REQUEST });
|
|
2432
2480
|
return response;
|
|
2433
2481
|
}
|
|
2482
|
+
async sendGetAgentKeysRequest() {
|
|
2483
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.GET_AGENT_KEYS_RESPONSE)));
|
|
2484
|
+
await this.sendMessage({
|
|
2485
|
+
type: AirRecoveryMessageTypes.GET_AGENT_KEYS_REQUEST,
|
|
2486
|
+
});
|
|
2487
|
+
return response;
|
|
2488
|
+
}
|
|
2489
|
+
async sendRegisterAgentKeyRequest(payload) {
|
|
2490
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.REGISTER_AGENT_KEY_RESPONSE)));
|
|
2491
|
+
await this.sendMessage({
|
|
2492
|
+
type: AirRecoveryMessageTypes.REGISTER_AGENT_KEY_REQUEST,
|
|
2493
|
+
payload,
|
|
2494
|
+
});
|
|
2495
|
+
return response;
|
|
2496
|
+
}
|
|
2497
|
+
async sendRemoveAgentKeyRequest(payload) {
|
|
2498
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.REMOVE_AGENT_KEY_RESPONSE)));
|
|
2499
|
+
await this.sendMessage({
|
|
2500
|
+
type: AirRecoveryMessageTypes.REMOVE_AGENT_KEY_REQUEST,
|
|
2501
|
+
payload,
|
|
2502
|
+
});
|
|
2503
|
+
return response;
|
|
2504
|
+
}
|
|
2434
2505
|
async open(element) {
|
|
2435
2506
|
await this._open({ window: element.contentWindow, origin: new URL(element.src).origin });
|
|
2436
2507
|
}
|
|
@@ -3097,6 +3168,35 @@ class AirService {
|
|
|
3097
3168
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
3098
3169
|
}
|
|
3099
3170
|
}
|
|
3171
|
+
async getAgentKeys() {
|
|
3172
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3173
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendGetAgentKeysRequest();
|
|
3174
|
+
if (payload.success === false) {
|
|
3175
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3176
|
+
}
|
|
3177
|
+
return payload.agentKeys;
|
|
3178
|
+
}
|
|
3179
|
+
async registerAgentKey(publicKey) {
|
|
3180
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3181
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendRegisterAgentKeyRequest({
|
|
3182
|
+
publicKey,
|
|
3183
|
+
});
|
|
3184
|
+
if (payload.success === false) {
|
|
3185
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3186
|
+
}
|
|
3187
|
+
return {
|
|
3188
|
+
id: payload.id,
|
|
3189
|
+
publicKey: payload.publicKey,
|
|
3190
|
+
createdAt: payload.createdAt,
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
async removeAgentKey(id) {
|
|
3194
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3195
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendRemoveAgentKeyRequest({ id });
|
|
3196
|
+
if (payload.success === false) {
|
|
3197
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3100
3200
|
async getUserInfo() {
|
|
3101
3201
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
3102
3202
|
const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
@@ -3489,6 +3589,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3489
3589
|
isLoggedIn: true,
|
|
3490
3590
|
id: payload.id,
|
|
3491
3591
|
abstractAccountAddress: payload.abstractAccountAddress,
|
|
3592
|
+
abstractAccountAddresses: payload.abstractAccountAddresses,
|
|
3492
3593
|
token: payload.partnerAccessToken,
|
|
3493
3594
|
isMFASetup: payload.activeMfaMethods.length > 0,
|
|
3494
3595
|
};
|
package/dist/airkit.esm.js
CHANGED
|
@@ -95,7 +95,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
95
95
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
var version = "1.9.0-beta.
|
|
98
|
+
var version = "1.9.0-beta.3";
|
|
99
99
|
var airkitPackage = {
|
|
100
100
|
version: version};
|
|
101
101
|
|
|
@@ -175,6 +175,12 @@ const AirRecoveryMessageTypes = {
|
|
|
175
175
|
RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
|
|
176
176
|
UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
|
|
177
177
|
UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
|
|
178
|
+
GET_AGENT_KEYS_REQUEST: "air_recovery_get_agent_keys_request",
|
|
179
|
+
GET_AGENT_KEYS_RESPONSE: "air_recovery_get_agent_keys_response",
|
|
180
|
+
REGISTER_AGENT_KEY_REQUEST: "air_recovery_register_agent_key_request",
|
|
181
|
+
REGISTER_AGENT_KEY_RESPONSE: "air_recovery_register_agent_key_response",
|
|
182
|
+
REMOVE_AGENT_KEY_REQUEST: "air_recovery_remove_agent_key_request",
|
|
183
|
+
REMOVE_AGENT_KEY_RESPONSE: "air_recovery_remove_agent_key_response",
|
|
178
184
|
LOGOUT_REQUEST: "air_recovery_logout_request",
|
|
179
185
|
LOGOUT_RESPONSE: "air_recovery_logout_response"
|
|
180
186
|
};
|
|
@@ -2010,7 +2016,7 @@ class ProviderMessageService extends MessageServiceBase {
|
|
|
2010
2016
|
_a$4 = ProviderMessageService;
|
|
2011
2017
|
_ProviderMessageService_instance = { value: void 0 };
|
|
2012
2018
|
|
|
2013
|
-
var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_emit;
|
|
2019
|
+
var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_currentChainId, _AirWalletProvider_emit, _AirWalletProvider_getAddressForCurrentChain, _AirWalletProvider_parseChainId;
|
|
2014
2020
|
class AirWalletProvider {
|
|
2015
2021
|
constructor({ ensureWallet, isWalletInitialized, getLoginResult, }) {
|
|
2016
2022
|
_AirWalletProvider_instances.add(this);
|
|
@@ -2019,11 +2025,18 @@ class AirWalletProvider {
|
|
|
2019
2025
|
_AirWalletProvider_getLoginResult.set(this, void 0);
|
|
2020
2026
|
_AirWalletProvider_ensureWallet.set(this, void 0);
|
|
2021
2027
|
_AirWalletProvider_eventListeners.set(this, void 0);
|
|
2028
|
+
_AirWalletProvider_currentChainId.set(this, null);
|
|
2022
2029
|
this.startEventMessageListening = async (walletIframe) => {
|
|
2023
2030
|
await __classPrivateFieldGet(this, _AirWalletProvider_providerMessageService, "f").open(walletIframe);
|
|
2024
2031
|
__classPrivateFieldGet(this, _AirWalletProvider_providerMessageService, "f").messages$
|
|
2025
2032
|
.pipe(filter((msg) => msg.type === AirWalletProviderMessageTypes.EVENT))
|
|
2026
2033
|
.subscribe((message) => {
|
|
2034
|
+
if (message.payload.event === "chainChanged") {
|
|
2035
|
+
const parsedChainId = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, message.payload.data);
|
|
2036
|
+
if (parsedChainId !== null) {
|
|
2037
|
+
__classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId, "f");
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2027
2040
|
__classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_emit).call(this, message.payload.event, ...[message.payload.data]);
|
|
2028
2041
|
});
|
|
2029
2042
|
};
|
|
@@ -2059,10 +2072,13 @@ class AirWalletProvider {
|
|
|
2059
2072
|
if (!loginResult) {
|
|
2060
2073
|
throw new UnauthorizedProviderError("User is not logged in");
|
|
2061
2074
|
}
|
|
2075
|
+
// Early return optimization: return cached address from login result if wallet not yet initialized
|
|
2062
2076
|
if ((method === "eth_accounts" || method === "eth_requestAccounts") &&
|
|
2063
|
-
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this)
|
|
2064
|
-
loginResult
|
|
2065
|
-
|
|
2077
|
+
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this)) {
|
|
2078
|
+
const address = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_getAddressForCurrentChain).call(this, loginResult);
|
|
2079
|
+
if (address) {
|
|
2080
|
+
return [address];
|
|
2081
|
+
}
|
|
2066
2082
|
}
|
|
2067
2083
|
const skipWalletLoginMethods = ["eth_chainId"];
|
|
2068
2084
|
try {
|
|
@@ -2084,6 +2100,12 @@ class AirWalletProvider {
|
|
|
2084
2100
|
if (!response.success) {
|
|
2085
2101
|
throw ensureProviderRpcError(response.payload);
|
|
2086
2102
|
}
|
|
2103
|
+
if (method === "eth_chainId") {
|
|
2104
|
+
const parsedChainId = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, response.payload.response);
|
|
2105
|
+
if (parsedChainId !== null) {
|
|
2106
|
+
__classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId, "f");
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2087
2109
|
return response.payload.response;
|
|
2088
2110
|
}
|
|
2089
2111
|
on(eventName, listener) {
|
|
@@ -2107,7 +2129,7 @@ class AirWalletProvider {
|
|
|
2107
2129
|
}, "f");
|
|
2108
2130
|
}
|
|
2109
2131
|
}
|
|
2110
|
-
_AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
|
|
2132
|
+
_AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_currentChainId = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
|
|
2111
2133
|
(__classPrivateFieldGet(this, _AirWalletProvider_eventListeners, "f")[eventName] || []).forEach((listener) => {
|
|
2112
2134
|
try {
|
|
2113
2135
|
return listener(...args);
|
|
@@ -2116,6 +2138,32 @@ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_is
|
|
|
2116
2138
|
log.warn(error);
|
|
2117
2139
|
}
|
|
2118
2140
|
});
|
|
2141
|
+
}, _AirWalletProvider_getAddressForCurrentChain = function _AirWalletProvider_getAddressForCurrentChain(loginResult) {
|
|
2142
|
+
const currentChainId = __classPrivateFieldGet(this, _AirWalletProvider_currentChainId, "f");
|
|
2143
|
+
// If we have the new addresses array and current chainId, look up by chain
|
|
2144
|
+
if (loginResult.abstractAccountAddresses && currentChainId !== null) {
|
|
2145
|
+
const chainIdStr = String(currentChainId);
|
|
2146
|
+
const addressEntry = loginResult.abstractAccountAddresses.find((entry) => entry.chainIds.includes(chainIdStr));
|
|
2147
|
+
if (addressEntry) {
|
|
2148
|
+
return addressEntry.address;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
// Fallback to legacy single address (backward compatibility)
|
|
2152
|
+
return loginResult.abstractAccountAddress;
|
|
2153
|
+
}, _AirWalletProvider_parseChainId = function _AirWalletProvider_parseChainId(chainId) {
|
|
2154
|
+
if (typeof chainId === "number") {
|
|
2155
|
+
return Number.isFinite(chainId) ? chainId : null;
|
|
2156
|
+
}
|
|
2157
|
+
if (typeof chainId === "bigint") {
|
|
2158
|
+
return Number(chainId);
|
|
2159
|
+
}
|
|
2160
|
+
if (typeof chainId !== "string" || !chainId) {
|
|
2161
|
+
return null;
|
|
2162
|
+
}
|
|
2163
|
+
const parsed = chainId.startsWith("0x")
|
|
2164
|
+
? parseInt(chainId, 16)
|
|
2165
|
+
: parseInt(chainId, 10);
|
|
2166
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
2119
2167
|
};
|
|
2120
2168
|
|
|
2121
2169
|
var _a$3, _AuthMessageService_instance;
|
|
@@ -2429,6 +2477,29 @@ class RecoveryMessageService extends MessageServiceBase {
|
|
|
2429
2477
|
await this.sendMessage({ type: AirRecoveryMessageTypes.LOGOUT_REQUEST });
|
|
2430
2478
|
return response;
|
|
2431
2479
|
}
|
|
2480
|
+
async sendGetAgentKeysRequest() {
|
|
2481
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.GET_AGENT_KEYS_RESPONSE)));
|
|
2482
|
+
await this.sendMessage({
|
|
2483
|
+
type: AirRecoveryMessageTypes.GET_AGENT_KEYS_REQUEST,
|
|
2484
|
+
});
|
|
2485
|
+
return response;
|
|
2486
|
+
}
|
|
2487
|
+
async sendRegisterAgentKeyRequest(payload) {
|
|
2488
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.REGISTER_AGENT_KEY_RESPONSE)));
|
|
2489
|
+
await this.sendMessage({
|
|
2490
|
+
type: AirRecoveryMessageTypes.REGISTER_AGENT_KEY_REQUEST,
|
|
2491
|
+
payload,
|
|
2492
|
+
});
|
|
2493
|
+
return response;
|
|
2494
|
+
}
|
|
2495
|
+
async sendRemoveAgentKeyRequest(payload) {
|
|
2496
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.REMOVE_AGENT_KEY_RESPONSE)));
|
|
2497
|
+
await this.sendMessage({
|
|
2498
|
+
type: AirRecoveryMessageTypes.REMOVE_AGENT_KEY_REQUEST,
|
|
2499
|
+
payload,
|
|
2500
|
+
});
|
|
2501
|
+
return response;
|
|
2502
|
+
}
|
|
2432
2503
|
async open(element) {
|
|
2433
2504
|
await this._open({ window: element.contentWindow, origin: new URL(element.src).origin });
|
|
2434
2505
|
}
|
|
@@ -3095,6 +3166,35 @@ class AirService {
|
|
|
3095
3166
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
3096
3167
|
}
|
|
3097
3168
|
}
|
|
3169
|
+
async getAgentKeys() {
|
|
3170
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3171
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendGetAgentKeysRequest();
|
|
3172
|
+
if (payload.success === false) {
|
|
3173
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3174
|
+
}
|
|
3175
|
+
return payload.agentKeys;
|
|
3176
|
+
}
|
|
3177
|
+
async registerAgentKey(publicKey) {
|
|
3178
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3179
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendRegisterAgentKeyRequest({
|
|
3180
|
+
publicKey,
|
|
3181
|
+
});
|
|
3182
|
+
if (payload.success === false) {
|
|
3183
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3184
|
+
}
|
|
3185
|
+
return {
|
|
3186
|
+
id: payload.id,
|
|
3187
|
+
publicKey: payload.publicKey,
|
|
3188
|
+
createdAt: payload.createdAt,
|
|
3189
|
+
};
|
|
3190
|
+
}
|
|
3191
|
+
async removeAgentKey(id) {
|
|
3192
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3193
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendRemoveAgentKeyRequest({ id });
|
|
3194
|
+
if (payload.success === false) {
|
|
3195
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3098
3198
|
async getUserInfo() {
|
|
3099
3199
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
3100
3200
|
const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
@@ -3487,6 +3587,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3487
3587
|
isLoggedIn: true,
|
|
3488
3588
|
id: payload.id,
|
|
3489
3589
|
abstractAccountAddress: payload.abstractAccountAddress,
|
|
3590
|
+
abstractAccountAddresses: payload.abstractAccountAddresses,
|
|
3490
3591
|
token: payload.partnerAccessToken,
|
|
3491
3592
|
isMFASetup: payload.activeMfaMethods.length > 0,
|
|
3492
3593
|
};
|
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.9.0-beta.
|
|
104
|
+
var version = "1.9.0-beta.3";
|
|
105
105
|
var airkitPackage = {
|
|
106
106
|
version: version};
|
|
107
107
|
|
|
@@ -181,6 +181,12 @@
|
|
|
181
181
|
RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
|
|
182
182
|
UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
|
|
183
183
|
UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
|
|
184
|
+
GET_AGENT_KEYS_REQUEST: "air_recovery_get_agent_keys_request",
|
|
185
|
+
GET_AGENT_KEYS_RESPONSE: "air_recovery_get_agent_keys_response",
|
|
186
|
+
REGISTER_AGENT_KEY_REQUEST: "air_recovery_register_agent_key_request",
|
|
187
|
+
REGISTER_AGENT_KEY_RESPONSE: "air_recovery_register_agent_key_response",
|
|
188
|
+
REMOVE_AGENT_KEY_REQUEST: "air_recovery_remove_agent_key_request",
|
|
189
|
+
REMOVE_AGENT_KEY_RESPONSE: "air_recovery_remove_agent_key_response",
|
|
184
190
|
LOGOUT_REQUEST: "air_recovery_logout_request",
|
|
185
191
|
LOGOUT_RESPONSE: "air_recovery_logout_response"
|
|
186
192
|
};
|
|
@@ -2016,7 +2022,7 @@
|
|
|
2016
2022
|
_a$4 = ProviderMessageService;
|
|
2017
2023
|
_ProviderMessageService_instance = { value: void 0 };
|
|
2018
2024
|
|
|
2019
|
-
var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_emit;
|
|
2025
|
+
var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_currentChainId, _AirWalletProvider_emit, _AirWalletProvider_getAddressForCurrentChain, _AirWalletProvider_parseChainId;
|
|
2020
2026
|
class AirWalletProvider {
|
|
2021
2027
|
constructor({ ensureWallet, isWalletInitialized, getLoginResult, }) {
|
|
2022
2028
|
_AirWalletProvider_instances.add(this);
|
|
@@ -2025,11 +2031,18 @@
|
|
|
2025
2031
|
_AirWalletProvider_getLoginResult.set(this, void 0);
|
|
2026
2032
|
_AirWalletProvider_ensureWallet.set(this, void 0);
|
|
2027
2033
|
_AirWalletProvider_eventListeners.set(this, void 0);
|
|
2034
|
+
_AirWalletProvider_currentChainId.set(this, null);
|
|
2028
2035
|
this.startEventMessageListening = async (walletIframe) => {
|
|
2029
2036
|
await __classPrivateFieldGet(this, _AirWalletProvider_providerMessageService, "f").open(walletIframe);
|
|
2030
2037
|
__classPrivateFieldGet(this, _AirWalletProvider_providerMessageService, "f").messages$
|
|
2031
2038
|
.pipe(filter((msg) => msg.type === AirWalletProviderMessageTypes.EVENT))
|
|
2032
2039
|
.subscribe((message) => {
|
|
2040
|
+
if (message.payload.event === "chainChanged") {
|
|
2041
|
+
const parsedChainId = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, message.payload.data);
|
|
2042
|
+
if (parsedChainId !== null) {
|
|
2043
|
+
__classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId, "f");
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2033
2046
|
__classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_emit).call(this, message.payload.event, ...[message.payload.data]);
|
|
2034
2047
|
});
|
|
2035
2048
|
};
|
|
@@ -2065,10 +2078,13 @@
|
|
|
2065
2078
|
if (!loginResult) {
|
|
2066
2079
|
throw new UnauthorizedProviderError("User is not logged in");
|
|
2067
2080
|
}
|
|
2081
|
+
// Early return optimization: return cached address from login result if wallet not yet initialized
|
|
2068
2082
|
if ((method === "eth_accounts" || method === "eth_requestAccounts") &&
|
|
2069
|
-
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this)
|
|
2070
|
-
loginResult
|
|
2071
|
-
|
|
2083
|
+
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this)) {
|
|
2084
|
+
const address = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_getAddressForCurrentChain).call(this, loginResult);
|
|
2085
|
+
if (address) {
|
|
2086
|
+
return [address];
|
|
2087
|
+
}
|
|
2072
2088
|
}
|
|
2073
2089
|
const skipWalletLoginMethods = ["eth_chainId"];
|
|
2074
2090
|
try {
|
|
@@ -2090,6 +2106,12 @@
|
|
|
2090
2106
|
if (!response.success) {
|
|
2091
2107
|
throw ensureProviderRpcError(response.payload);
|
|
2092
2108
|
}
|
|
2109
|
+
if (method === "eth_chainId") {
|
|
2110
|
+
const parsedChainId = __classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, response.payload.response);
|
|
2111
|
+
if (parsedChainId !== null) {
|
|
2112
|
+
__classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId, "f");
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2093
2115
|
return response.payload.response;
|
|
2094
2116
|
}
|
|
2095
2117
|
on(eventName, listener) {
|
|
@@ -2113,7 +2135,7 @@
|
|
|
2113
2135
|
}, "f");
|
|
2114
2136
|
}
|
|
2115
2137
|
}
|
|
2116
|
-
_AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
|
|
2138
|
+
_AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_currentChainId = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
|
|
2117
2139
|
(__classPrivateFieldGet(this, _AirWalletProvider_eventListeners, "f")[eventName] || []).forEach((listener) => {
|
|
2118
2140
|
try {
|
|
2119
2141
|
return listener(...args);
|
|
@@ -2122,6 +2144,32 @@
|
|
|
2122
2144
|
log.warn(error);
|
|
2123
2145
|
}
|
|
2124
2146
|
});
|
|
2147
|
+
}, _AirWalletProvider_getAddressForCurrentChain = function _AirWalletProvider_getAddressForCurrentChain(loginResult) {
|
|
2148
|
+
const currentChainId = __classPrivateFieldGet(this, _AirWalletProvider_currentChainId, "f");
|
|
2149
|
+
// If we have the new addresses array and current chainId, look up by chain
|
|
2150
|
+
if (loginResult.abstractAccountAddresses && currentChainId !== null) {
|
|
2151
|
+
const chainIdStr = String(currentChainId);
|
|
2152
|
+
const addressEntry = loginResult.abstractAccountAddresses.find((entry) => entry.chainIds.includes(chainIdStr));
|
|
2153
|
+
if (addressEntry) {
|
|
2154
|
+
return addressEntry.address;
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
// Fallback to legacy single address (backward compatibility)
|
|
2158
|
+
return loginResult.abstractAccountAddress;
|
|
2159
|
+
}, _AirWalletProvider_parseChainId = function _AirWalletProvider_parseChainId(chainId) {
|
|
2160
|
+
if (typeof chainId === "number") {
|
|
2161
|
+
return Number.isFinite(chainId) ? chainId : null;
|
|
2162
|
+
}
|
|
2163
|
+
if (typeof chainId === "bigint") {
|
|
2164
|
+
return Number(chainId);
|
|
2165
|
+
}
|
|
2166
|
+
if (typeof chainId !== "string" || !chainId) {
|
|
2167
|
+
return null;
|
|
2168
|
+
}
|
|
2169
|
+
const parsed = chainId.startsWith("0x")
|
|
2170
|
+
? parseInt(chainId, 16)
|
|
2171
|
+
: parseInt(chainId, 10);
|
|
2172
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
2125
2173
|
};
|
|
2126
2174
|
|
|
2127
2175
|
var _a$3, _AuthMessageService_instance;
|
|
@@ -2435,6 +2483,29 @@
|
|
|
2435
2483
|
await this.sendMessage({ type: AirRecoveryMessageTypes.LOGOUT_REQUEST });
|
|
2436
2484
|
return response;
|
|
2437
2485
|
}
|
|
2486
|
+
async sendGetAgentKeysRequest() {
|
|
2487
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.GET_AGENT_KEYS_RESPONSE)));
|
|
2488
|
+
await this.sendMessage({
|
|
2489
|
+
type: AirRecoveryMessageTypes.GET_AGENT_KEYS_REQUEST,
|
|
2490
|
+
});
|
|
2491
|
+
return response;
|
|
2492
|
+
}
|
|
2493
|
+
async sendRegisterAgentKeyRequest(payload) {
|
|
2494
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.REGISTER_AGENT_KEY_RESPONSE)));
|
|
2495
|
+
await this.sendMessage({
|
|
2496
|
+
type: AirRecoveryMessageTypes.REGISTER_AGENT_KEY_REQUEST,
|
|
2497
|
+
payload,
|
|
2498
|
+
});
|
|
2499
|
+
return response;
|
|
2500
|
+
}
|
|
2501
|
+
async sendRemoveAgentKeyRequest(payload) {
|
|
2502
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.REMOVE_AGENT_KEY_RESPONSE)));
|
|
2503
|
+
await this.sendMessage({
|
|
2504
|
+
type: AirRecoveryMessageTypes.REMOVE_AGENT_KEY_REQUEST,
|
|
2505
|
+
payload,
|
|
2506
|
+
});
|
|
2507
|
+
return response;
|
|
2508
|
+
}
|
|
2438
2509
|
async open(element) {
|
|
2439
2510
|
await this._open({ window: element.contentWindow, origin: new URL(element.src).origin });
|
|
2440
2511
|
}
|
|
@@ -3101,6 +3172,35 @@
|
|
|
3101
3172
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
3102
3173
|
}
|
|
3103
3174
|
}
|
|
3175
|
+
async getAgentKeys() {
|
|
3176
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3177
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendGetAgentKeysRequest();
|
|
3178
|
+
if (payload.success === false) {
|
|
3179
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3180
|
+
}
|
|
3181
|
+
return payload.agentKeys;
|
|
3182
|
+
}
|
|
3183
|
+
async registerAgentKey(publicKey) {
|
|
3184
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3185
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendRegisterAgentKeyRequest({
|
|
3186
|
+
publicKey,
|
|
3187
|
+
});
|
|
3188
|
+
if (payload.success === false) {
|
|
3189
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3190
|
+
}
|
|
3191
|
+
return {
|
|
3192
|
+
id: payload.id,
|
|
3193
|
+
publicKey: payload.publicKey,
|
|
3194
|
+
createdAt: payload.createdAt,
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3197
|
+
async removeAgentKey(id) {
|
|
3198
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
|
|
3199
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendRemoveAgentKeyRequest({ id });
|
|
3200
|
+
if (payload.success === false) {
|
|
3201
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3104
3204
|
async getUserInfo() {
|
|
3105
3205
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
3106
3206
|
const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
@@ -3493,6 +3593,7 @@
|
|
|
3493
3593
|
isLoggedIn: true,
|
|
3494
3594
|
id: payload.id,
|
|
3495
3595
|
abstractAccountAddress: payload.abstractAccountAddress,
|
|
3596
|
+
abstractAccountAddresses: payload.abstractAccountAddresses,
|
|
3496
3597
|
token: payload.partnerAccessToken,
|
|
3497
3598
|
isMFASetup: payload.activeMfaMethods.length > 0,
|
|
3498
3599
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AirAuthStartRecoveryRequestPayload } from "@mocanetwork/common/src/air/messaging/auth";
|
|
2
2
|
import { Token } from "@mocanetwork/common/src/types";
|
|
3
|
-
import { AirEventListener, AirLoginResult, AirSessionConfig, AirUserDetails, BUILD_ENV, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult, CredentialNetwork, CredentialVerificationResult, EIP1193Provider, ShowSwapUIOptions, ShowTransferUIOptions, ShowTransferUIResult } from "./interfaces";
|
|
3
|
+
import { AgentPublicKey, AirEventListener, AirLoginResult, AirSessionConfig, AirUserDetails, BUILD_ENV, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult, CredentialNetwork, CredentialVerificationResult, EIP1193Provider, ShowSwapUIOptions, ShowTransferUIOptions, ShowTransferUIResult } from "./interfaces";
|
|
4
4
|
declare class AirService {
|
|
5
5
|
#private;
|
|
6
6
|
constructor({ partnerId }: {
|
|
@@ -73,6 +73,9 @@ declare class AirService {
|
|
|
73
73
|
* @experimental This feature has not been officially released and might change in the future.
|
|
74
74
|
*/
|
|
75
75
|
showReceiveUI(): Promise<void>;
|
|
76
|
+
getAgentKeys(): Promise<AgentPublicKey[]>;
|
|
77
|
+
registerAgentKey(publicKey: string): Promise<AgentPublicKey>;
|
|
78
|
+
removeAgentKey(id: string): Promise<void>;
|
|
76
79
|
getUserInfo(): Promise<AirUserDetails>;
|
|
77
80
|
updateSessionConfig(config: Partial<AirSessionConfig>): Promise<AirSessionConfig>;
|
|
78
81
|
goToPartner(partnerUrl: string): Promise<{
|
|
@@ -4,7 +4,9 @@ declare class AirWalletProvider implements EIP1193Provider {
|
|
|
4
4
|
#private;
|
|
5
5
|
constructor({ ensureWallet, isWalletInitialized, getLoginResult, }: {
|
|
6
6
|
isWalletInitialized: () => boolean;
|
|
7
|
-
ensureWallet: (
|
|
7
|
+
ensureWallet: (option?: {
|
|
8
|
+
skipWalletLogin: boolean;
|
|
9
|
+
}) => Promise<AirWalletInitializedResult>;
|
|
8
10
|
getLoginResult: () => AirLoginResult;
|
|
9
11
|
});
|
|
10
12
|
request(request: AirProviderParameters): Promise<unknown>;
|
|
@@ -27,7 +27,7 @@ export declare abstract class MessageServiceBase<TMessage extends AirMessageBase
|
|
|
27
27
|
type: T;
|
|
28
28
|
payload: {
|
|
29
29
|
success: false;
|
|
30
|
-
errorName: import("../error/codes").AuthErrorName | import("../error/codes").PartnerAccessTokenErrorName | import("../error/codes").RealmIDErrorName | import("../error/codes").ParameterErrorName | import("../error/codes").ServerErrorName | import("../error/codes").PasskeyErrorName | import("../error/codes").PasswordlessErrorName | import("../error/codes").AuthWalletErrorName | import("../error/codes").WalletLinkErrorName | import("../error/codes").IntentErrorName | import("../error/codes").PrivyErrorName | import("../error/codes").AirIDErrorName | import("../error/codes").WindowErrorName
|
|
30
|
+
errorName: "USER_CANCELLED" | "CONFIG_ERROR" | "CLIENT_ERROR" | "UNKNOWN_ERROR" | "PERMISSION_NOT_ENABLED" | "SMART_ACCOUNT_NOT_DEPLOYED" | "ACCOUNT_DELETION_PENDING" | "SWAP_TO_ONRAMP" | "USER_REJECTED" | import("../error/codes").AuthErrorName | import("../error/codes").PartnerAccessTokenErrorName | import("../error/codes").RealmIDErrorName | import("../error/codes").ParameterErrorName | import("../error/codes").ServerErrorName | import("../error/codes").PasskeyErrorName | import("../error/codes").PasswordlessErrorName | import("../error/codes").AuthWalletErrorName | import("../error/codes").WalletLinkErrorName | import("../error/codes").IntentErrorName | import("../error/codes").PrivyErrorName | import("../error/codes").AirIDErrorName | import("../error/codes").WindowErrorName;
|
|
31
31
|
errorMessage: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
@@ -7,6 +7,12 @@ export declare const AirRecoveryMessageTypes: {
|
|
|
7
7
|
readonly RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request";
|
|
8
8
|
readonly UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request";
|
|
9
9
|
readonly UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response";
|
|
10
|
+
readonly GET_AGENT_KEYS_REQUEST: "air_recovery_get_agent_keys_request";
|
|
11
|
+
readonly GET_AGENT_KEYS_RESPONSE: "air_recovery_get_agent_keys_response";
|
|
12
|
+
readonly REGISTER_AGENT_KEY_REQUEST: "air_recovery_register_agent_key_request";
|
|
13
|
+
readonly REGISTER_AGENT_KEY_RESPONSE: "air_recovery_register_agent_key_response";
|
|
14
|
+
readonly REMOVE_AGENT_KEY_REQUEST: "air_recovery_remove_agent_key_request";
|
|
15
|
+
readonly REMOVE_AGENT_KEY_RESPONSE: "air_recovery_remove_agent_key_response";
|
|
10
16
|
readonly LOGOUT_REQUEST: "air_recovery_logout_request";
|
|
11
17
|
readonly LOGOUT_RESPONSE: "air_recovery_logout_response";
|
|
12
18
|
};
|
|
@@ -30,6 +36,23 @@ export type AirRecoveryIframeVisibilityRequestMessage = AirRecoveryMessageBase<"
|
|
|
30
36
|
}>;
|
|
31
37
|
export type AirRecoveryUpdateSessionConfigRequestMessage = AirRecoveryMessageBase<"air_recovery_update_session_config_request", Partial<SessionConfig>>;
|
|
32
38
|
export type AirRecoveryUpdateSessionConfigResponseMessage = AirRecoveryMessageBase<"air_recovery_update_session_config_response", (AirMessageSuccessPayload & SessionConfig) | AirMessageErrorPayload>;
|
|
39
|
+
export type AgentPublicKey = {
|
|
40
|
+
id: string;
|
|
41
|
+
publicKey: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
};
|
|
44
|
+
export type AirGetAgentKeysRequestMessage = AirRecoveryMessageBaseWithoutPayload<"air_recovery_get_agent_keys_request">;
|
|
45
|
+
export type AirGetAgentKeysResponseMessage = AirRecoveryMessageBase<"air_recovery_get_agent_keys_response", (AirMessageSuccessPayload & {
|
|
46
|
+
agentKeys: AgentPublicKey[];
|
|
47
|
+
}) | AirMessageErrorPayload>;
|
|
48
|
+
export type AirRegisterAgentKeyRequestMessage = AirRecoveryMessageBase<"air_recovery_register_agent_key_request", {
|
|
49
|
+
publicKey: string;
|
|
50
|
+
}>;
|
|
51
|
+
export type AirRegisterAgentKeyResponseMessage = AirRecoveryMessageBase<"air_recovery_register_agent_key_response", (AirMessageSuccessPayload & AgentPublicKey) | AirMessageErrorPayload>;
|
|
52
|
+
export type AirRemoveAgentKeyRequestMessage = AirRecoveryMessageBase<"air_recovery_remove_agent_key_request", {
|
|
53
|
+
id: string;
|
|
54
|
+
}>;
|
|
55
|
+
export type AirRemoveAgentKeyResponseMessage = AirRecoveryMessageBase<"air_recovery_remove_agent_key_response", AirMessageSuccessPayload | AirMessageErrorPayload>;
|
|
33
56
|
export type AirLogoutRequestMessage = AirRecoveryMessageBaseWithoutPayload<"air_recovery_logout_request">;
|
|
34
57
|
export type AirLogoutResponseMessage = AirRecoveryMessageBase<"air_recovery_logout_response", AirMessageSuccessPayload | AirMessageErrorPayload>;
|
|
35
|
-
export type AirRecoveryMessage = AirInitializationRequestMessage | AirInitializationResponseMessage | AirRecoveryInitializedMessage | AirRecoveryIframeVisibilityRequestMessage | AirRecoveryUpdateSessionConfigRequestMessage | AirRecoveryUpdateSessionConfigResponseMessage | AirLogoutRequestMessage | AirLogoutResponseMessage;
|
|
58
|
+
export type AirRecoveryMessage = AirInitializationRequestMessage | AirInitializationResponseMessage | AirRecoveryInitializedMessage | AirRecoveryIframeVisibilityRequestMessage | AirRecoveryUpdateSessionConfigRequestMessage | AirRecoveryUpdateSessionConfigResponseMessage | AirGetAgentKeysRequestMessage | AirGetAgentKeysResponseMessage | AirRegisterAgentKeyRequestMessage | AirRegisterAgentKeyResponseMessage | AirRemoveAgentKeyRequestMessage | AirRemoveAgentKeyResponseMessage | AirLogoutRequestMessage | AirLogoutResponseMessage;
|
|
@@ -10,9 +10,14 @@ export type AirIdDetails = {
|
|
|
10
10
|
chainId: number;
|
|
11
11
|
imageUrl?: string;
|
|
12
12
|
};
|
|
13
|
+
export type AbstractAccountAddressEntry = {
|
|
14
|
+
readonly address: string;
|
|
15
|
+
readonly chainIds: readonly string[];
|
|
16
|
+
};
|
|
13
17
|
export type GlobalId = {
|
|
14
18
|
id: string;
|
|
15
19
|
abstractAccountAddress?: string;
|
|
20
|
+
abstractAccountAddresses?: readonly AbstractAccountAddressEntry[];
|
|
16
21
|
signerQuorumId?: string | null;
|
|
17
22
|
};
|
|
18
23
|
export type LoggedInLoginResponse = {
|
|
@@ -6,6 +6,15 @@ export type PromiseHandle<T> = {
|
|
|
6
6
|
export declare function promiseCreator<T>(): PromiseHandle<T>;
|
|
7
7
|
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
8
8
|
export declare const formatPublicKey: (publicKey: string) => string;
|
|
9
|
+
export type PublicKeyValidationResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
format: 'pem' | 'base64';
|
|
12
|
+
normalizedKey: string;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function validateAndNormalizePublicKey(input: string): PublicKeyValidationResult;
|
|
9
18
|
/**
|
|
10
19
|
* Returns a random number. Don't use for cryptographic purposes.
|
|
11
20
|
* @returns a random number
|
|
@@ -39,10 +39,15 @@ export type AirSessionConfig = {
|
|
|
39
39
|
currency: SupportedCurrencyCode;
|
|
40
40
|
};
|
|
41
41
|
export type CredentialNetwork = "devnet" | "testnet";
|
|
42
|
+
export type AbstractAccountAddressEntry = {
|
|
43
|
+
readonly address: string;
|
|
44
|
+
readonly chainIds: readonly string[];
|
|
45
|
+
};
|
|
42
46
|
export type AirLoginResult = {
|
|
43
47
|
isLoggedIn: boolean;
|
|
44
48
|
id: string;
|
|
45
49
|
abstractAccountAddress?: string;
|
|
50
|
+
abstractAccountAddresses?: readonly AbstractAccountAddressEntry[];
|
|
46
51
|
token: string;
|
|
47
52
|
isMFASetup: boolean;
|
|
48
53
|
};
|
|
@@ -53,6 +58,11 @@ export type AirWalletInitializedResult = {
|
|
|
53
58
|
export type ClaimAirIdResult = {
|
|
54
59
|
airId: AirIdDetails;
|
|
55
60
|
};
|
|
61
|
+
export type AgentPublicKey = {
|
|
62
|
+
id: string;
|
|
63
|
+
publicKey: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
};
|
|
56
66
|
export type AirEventOnInitialized = {
|
|
57
67
|
event: "initialized";
|
|
58
68
|
result: AirInitializationResult;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageServiceBase } from "./common/air/messaging/messageServiceBase";
|
|
2
|
-
import { AirInitializationRequestMessage, AirRecoveryMessage, AirRecoveryUpdateSessionConfigRequestMessage } from "./common/air/messaging/recovery";
|
|
2
|
+
import { AirGetAgentKeysResponseMessage, AirInitializationRequestMessage, AirRecoveryMessage, AirRegisterAgentKeyResponseMessage, AirRemoveAgentKeyResponseMessage, AirRecoveryUpdateSessionConfigRequestMessage } from "./common/air/messaging/recovery";
|
|
3
3
|
export declare class RecoveryMessageService extends MessageServiceBase<AirRecoveryMessage> {
|
|
4
4
|
#private;
|
|
5
5
|
static create(): RecoveryMessageService;
|
|
@@ -7,6 +7,13 @@ export declare class RecoveryMessageService extends MessageServiceBase<AirRecove
|
|
|
7
7
|
onInitialized(): Promise<import("./common/air/messaging/recovery").AirRecoveryInitializedMessage>;
|
|
8
8
|
sendUpdateSessionConfigRequest(payload?: AirRecoveryUpdateSessionConfigRequestMessage["payload"]): Promise<import("./common/air/messaging/recovery").AirRecoveryUpdateSessionConfigResponseMessage>;
|
|
9
9
|
logout(): Promise<import("./common/air/messaging/recovery").AirLogoutResponseMessage>;
|
|
10
|
+
sendGetAgentKeysRequest(): Promise<AirGetAgentKeysResponseMessage>;
|
|
11
|
+
sendRegisterAgentKeyRequest(payload: {
|
|
12
|
+
publicKey: string;
|
|
13
|
+
}): Promise<AirRegisterAgentKeyResponseMessage>;
|
|
14
|
+
sendRemoveAgentKeyRequest(payload: {
|
|
15
|
+
id: string;
|
|
16
|
+
}): Promise<AirRemoveAgentKeyResponseMessage>;
|
|
10
17
|
open(element: HTMLIFrameElement): Promise<void>;
|
|
11
18
|
close(): Promise<void>;
|
|
12
19
|
}
|