@mocanetwork/airkit 0.5.0 → 0.6.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/airkit.cjs.js +2637 -2565
- package/dist/airkit.esm.js +2645 -2383
- package/dist/airkit.umd.js +2852 -0
- package/dist/types/airService.d.ts +12 -11
- package/dist/types/airWalletProvider.d.ts +13 -0
- package/dist/types/common/air/error.d.ts +8 -0
- package/dist/types/common/custom.d.ts +6 -0
- package/dist/types/common/provider/error.d.ts +16 -0
- package/dist/types/common/provider/types.d.ts +24 -0
- package/dist/types/common/realm/error.d.ts +0 -0
- package/dist/types/common/realm/messaging/auth.d.ts +14 -15
- package/dist/types/common/realm/messaging/provider.d.ts +32 -0
- package/dist/types/common/realm/messaging/types.d.ts +29 -10
- package/dist/types/common/realm/partner/config.d.ts +0 -32
- package/dist/types/common/realm/smart-session/types.d.ts +1 -1
- package/dist/types/common/realm/user/types.d.ts +0 -28
- package/dist/types/common/utils.d.ts +16 -0
- package/dist/types/error.d.ts +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/interfaces.d.ts +18 -181
- package/dist/types/messageService.d.ts +18 -20
- package/dist/types/utils.d.ts +3 -21
- package/package.json +7 -15
- package/dist/airkit.umd.min.js +0 -2
- package/dist/airkit.umd.min.js.LICENSE.txt +0 -12
- package/dist/lib.cjs/common/src/error.js +0 -25
- package/dist/lib.cjs/common/src/realm/messaging/auth.js +0 -28
- package/dist/lib.cjs/common/src/realm/messaging/types.js +0 -21
- package/dist/lib.cjs/ws-embed/src/PopupHandler.js +0 -64
- package/dist/lib.cjs/ws-embed/src/airService.js +0 -398
- package/dist/lib.cjs/ws-embed/src/baseProvider.js +0 -178
- package/dist/lib.cjs/ws-embed/src/communicationProvider.js +0 -346
- package/dist/lib.cjs/ws-embed/src/embed.js +0 -750
- package/dist/lib.cjs/ws-embed/src/error.js +0 -21
- package/dist/lib.cjs/ws-embed/src/iframeController.js +0 -68
- package/dist/lib.cjs/ws-embed/src/inPageProvider.js +0 -307
- package/dist/lib.cjs/ws-embed/src/index.js +0 -20
- package/dist/lib.cjs/ws-embed/src/interfaces.js +0 -29
- package/dist/lib.cjs/ws-embed/src/isStream.js +0 -20
- package/dist/lib.cjs/ws-embed/src/loglevel.js +0 -7
- package/dist/lib.cjs/ws-embed/src/messageService.js +0 -269
- package/dist/lib.cjs/ws-embed/src/messages.js +0 -22
- package/dist/lib.cjs/ws-embed/src/siteMetadata.js +0 -77
- package/dist/lib.cjs/ws-embed/src/utils.js +0 -95
- package/dist/lib.esm/common/src/error.js +0 -23
- package/dist/lib.esm/common/src/realm/messaging/auth.js +0 -26
- package/dist/lib.esm/common/src/realm/messaging/types.js +0 -19
- package/dist/lib.esm/ws-embed/src/PopupHandler.js +0 -62
- package/dist/lib.esm/ws-embed/src/airService.js +0 -396
- package/dist/lib.esm/ws-embed/src/baseProvider.js +0 -176
- package/dist/lib.esm/ws-embed/src/communicationProvider.js +0 -344
- package/dist/lib.esm/ws-embed/src/embed.js +0 -745
- package/dist/lib.esm/ws-embed/src/error.js +0 -18
- package/dist/lib.esm/ws-embed/src/iframeController.js +0 -66
- package/dist/lib.esm/ws-embed/src/inPageProvider.js +0 -302
- package/dist/lib.esm/ws-embed/src/index.js +0 -5
- package/dist/lib.esm/ws-embed/src/interfaces.js +0 -21
- package/dist/lib.esm/ws-embed/src/isStream.js +0 -15
- package/dist/lib.esm/ws-embed/src/loglevel.js +0 -5
- package/dist/lib.esm/ws-embed/src/messageService.js +0 -267
- package/dist/lib.esm/ws-embed/src/messages.js +0 -20
- package/dist/lib.esm/ws-embed/src/siteMetadata.js +0 -75
- package/dist/lib.esm/ws-embed/src/utils.js +0 -88
- package/dist/types/PopupHandler.d.ts +0 -24
- package/dist/types/baseProvider.d.ts +0 -66
- package/dist/types/communicationProvider.d.ts +0 -82
- package/dist/types/embed.d.ts +0 -55
- package/dist/types/inPageProvider.d.ts +0 -106
- package/dist/types/isStream.d.ts +0 -4
- package/dist/types/messages.d.ts +0 -19
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import { AirIdDetails } from "@mocanetwork/common/src/realm/user/types";
|
|
1
2
|
import { Hex } from "./common/realm/smart-session/hex";
|
|
2
3
|
import { ActionPolicyInfo, Call } from "./common/realm/smart-session/types";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
4
|
+
import AirWalletProvider from "./airWalletProvider";
|
|
5
|
+
import { AirEventListener, AirLoginResult, AirPartnerUserDetails, AirUserDetails, AirWalletInitializedResult, BUILD_ENV_TYPE, ClaimAirIdOptions } from "./interfaces";
|
|
5
6
|
declare class AirService {
|
|
6
7
|
#private;
|
|
7
8
|
constructor({ partnerId }: {
|
|
8
9
|
partnerId: string;
|
|
10
|
+
modalZIndex?: number;
|
|
9
11
|
});
|
|
10
|
-
get buildEnv():
|
|
11
|
-
get isAirAuth(): boolean;
|
|
12
|
+
get buildEnv(): BUILD_ENV_TYPE;
|
|
12
13
|
get isInitialized(): boolean;
|
|
13
14
|
get isLoggedIn(): boolean;
|
|
14
15
|
get isWalletLoaded(): boolean;
|
|
15
16
|
init({ buildEnv, enableLogging, skipRehydration, }: {
|
|
16
|
-
buildEnv:
|
|
17
|
+
buildEnv: BUILD_ENV_TYPE;
|
|
17
18
|
enableLogging: boolean;
|
|
18
19
|
skipRehydration: boolean;
|
|
19
20
|
}): Promise<AirLoginResult | null>;
|
|
@@ -38,17 +39,17 @@ declare class AirService {
|
|
|
38
39
|
*/
|
|
39
40
|
executeAction(params: {
|
|
40
41
|
sessionData: string;
|
|
41
|
-
call: Call;
|
|
42
42
|
sessionOwnerPrivateKey: `0x${string}`;
|
|
43
|
-
|
|
43
|
+
call: Call;
|
|
44
|
+
}): Promise<void>;
|
|
44
45
|
/**
|
|
45
46
|
* @experimental This method is experimental and will change in the future.
|
|
46
47
|
*/
|
|
47
|
-
revokePermission(permissionId: Hex): Promise<
|
|
48
|
+
revokePermission(permissionId: Hex): Promise<void>;
|
|
48
49
|
logout(): Promise<void>;
|
|
49
|
-
getProvider(): Promise<
|
|
50
|
-
preloadWallet(): Promise<
|
|
51
|
-
claimAirId(options?: ClaimAirIdOptions): Promise<
|
|
50
|
+
getProvider(): Promise<AirWalletProvider>;
|
|
51
|
+
preloadWallet(): Promise<AirWalletInitializedResult>;
|
|
52
|
+
claimAirId(options?: ClaimAirIdOptions): Promise<AirIdDetails | null>;
|
|
52
53
|
getUserInfo(): Promise<AirUserDetails>;
|
|
53
54
|
getPartnerUserInfo(): Promise<AirPartnerUserDetails>;
|
|
54
55
|
on(listener: AirEventListener): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EIP1193EventMap, EIP1193Provider } from "@mocanetwork/common/src/provider/types";
|
|
2
|
+
declare class AirWalletProvider implements EIP1193Provider {
|
|
3
|
+
#private;
|
|
4
|
+
chainId: string;
|
|
5
|
+
constructor(walletIframe: HTMLIFrameElement);
|
|
6
|
+
request(request: {
|
|
7
|
+
method: string;
|
|
8
|
+
params?: unknown[];
|
|
9
|
+
}): Promise<unknown>;
|
|
10
|
+
on<EventName extends keyof EIP1193EventMap>(eventName: EventName, listener: EIP1193EventMap[EventName]): void;
|
|
11
|
+
removeListener<EventName extends keyof EIP1193EventMap>(eventName: EventName, listener: EIP1193EventMap[EventName]): void;
|
|
12
|
+
}
|
|
13
|
+
export default AirWalletProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseError } from "../error";
|
|
2
|
+
export type AirErrorName = "USER_CANCELLED" | "CONFIG_ERROR" | "SERVER_ERROR" | "CLIENT_ERROR" | "UNKNOWN_ERROR";
|
|
3
|
+
export declare class AirError extends BaseError<AirErrorName> {
|
|
4
|
+
}
|
|
5
|
+
export declare class AirHttpError extends AirError {
|
|
6
|
+
readonly response: unknown;
|
|
7
|
+
constructor(name: AirErrorName, message: string, response?: unknown, options?: Record<string, unknown>);
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class ProviderRpcError extends Error {
|
|
2
|
+
readonly code: number;
|
|
3
|
+
readonly data?: unknown;
|
|
4
|
+
constructor(message: string, code: number, data?: unknown);
|
|
5
|
+
}
|
|
6
|
+
export declare const ProviderRpcPraseError: ProviderRpcError;
|
|
7
|
+
export declare const ProviderRpcInvalidRequestError: ProviderRpcError;
|
|
8
|
+
export declare const ProviderRpcMethodNotFoundError: ProviderRpcError;
|
|
9
|
+
export declare const ProviderRpcInvalidParamsError: ProviderRpcError;
|
|
10
|
+
export declare const ProviderRpcInternalError: ProviderRpcError;
|
|
11
|
+
export declare const ProviderRpcUserRejectedRequestError: ProviderRpcError;
|
|
12
|
+
export declare const ProviderRpcUnauthorizedError: ProviderRpcError;
|
|
13
|
+
export declare const ProviderRpcUnsupportedMethodError: ProviderRpcError;
|
|
14
|
+
export declare const ProviderRpcDisconnectedError: ProviderRpcError;
|
|
15
|
+
export declare const ProviderRpcChainDisconnectedError: ProviderRpcError;
|
|
16
|
+
export declare function ensureProviderRpcError(value: unknown): ProviderRpcError;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ProviderRpcError } from "./error";
|
|
2
|
+
export type ProviderConnectInfo = {
|
|
3
|
+
chainId: string;
|
|
4
|
+
};
|
|
5
|
+
export type ProviderMessage = {
|
|
6
|
+
type: string;
|
|
7
|
+
data: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type EIP1193EventMap = {
|
|
10
|
+
accountsChanged(accounts: string[]): void;
|
|
11
|
+
chainChanged(chainId: string): void;
|
|
12
|
+
connect(connectInfo: ProviderConnectInfo): void;
|
|
13
|
+
disconnect(error: ProviderRpcError): void;
|
|
14
|
+
message(message: ProviderMessage): void;
|
|
15
|
+
};
|
|
16
|
+
export type EIP1193Request = {
|
|
17
|
+
method: string;
|
|
18
|
+
params?: Array<unknown> | undefined;
|
|
19
|
+
};
|
|
20
|
+
export interface EIP1193Provider {
|
|
21
|
+
request(request: EIP1193Request): Promise<unknown>;
|
|
22
|
+
on<EventName extends keyof EIP1193EventMap>(event: EventName, listener: EIP1193EventMap[EventName]): void;
|
|
23
|
+
removeListener<EventName extends keyof EIP1193EventMap>(event: EventName, listener: EIP1193EventMap[EventName]): void;
|
|
24
|
+
}
|
|
File without changes
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AirErrorName } from "../error/types";
|
|
1
|
+
import { AirErrorName } from "../../air/error";
|
|
3
2
|
import { AirIdDetails, GlobalId } from "../user/types";
|
|
4
3
|
export declare const AirAuthMessageTypes: {
|
|
5
|
-
readonly
|
|
4
|
+
readonly AUTH_SETUP_COMPLETED: "air_auth_setup_completed";
|
|
5
|
+
readonly INITIALIZATION_REQUEST: "air_auth_initialization_request";
|
|
6
|
+
readonly INITIALIZATION_RESPONSE: "air_auth_initialization_response";
|
|
6
7
|
readonly LOGIN_REQUEST: "air_auth_login_request";
|
|
7
8
|
readonly LOGIN_RESPONSE: "air_auth_login_response";
|
|
8
9
|
readonly LOGIN_WALLET_RESPONSE: "air_auth_login_wallet_response";
|
|
@@ -14,8 +15,6 @@ export declare const AirAuthMessageTypes: {
|
|
|
14
15
|
readonly REFRESH_TOKEN_RESPONSE: "air_auth_refresh_token_response";
|
|
15
16
|
readonly WALLET_TOKEN_REQUEST: "air_auth_wallet_token_request";
|
|
16
17
|
readonly WALLET_TOKEN_RESPONSE: "air_auth_wallet_token_response";
|
|
17
|
-
readonly INITIALIZATION_REQUEST: "air_auth_initialization_request";
|
|
18
|
-
readonly INITIALIZATION_RESPONSE: "air_auth_initialization_response";
|
|
19
18
|
readonly INIT_WALLET_COMMUNICATION: "air_auth_init_wallet_communication";
|
|
20
19
|
readonly IFRAME_VISIBILITY_REQUEST: "air_auth_iframe_visibility_request";
|
|
21
20
|
readonly SETUP_WALLET_REQUEST: "air_auth_setup_wallet_request";
|
|
@@ -35,7 +34,7 @@ type AirAuthMessageBaseWithoutPayload<TType extends AirAuthMessageType> = {
|
|
|
35
34
|
};
|
|
36
35
|
export type AirAuthError = {
|
|
37
36
|
success: false;
|
|
38
|
-
errorName:
|
|
37
|
+
errorName: AirErrorName;
|
|
39
38
|
errorMessage?: string;
|
|
40
39
|
};
|
|
41
40
|
export type AirAuthSuccess = {
|
|
@@ -74,21 +73,21 @@ type AirAuthWalletTokenResponsePayload = {
|
|
|
74
73
|
accessToken: string;
|
|
75
74
|
walletToken: string;
|
|
76
75
|
} | AirAuthError;
|
|
77
|
-
type
|
|
76
|
+
export type AirAuthInitializationSuccess = (AirAuthSuccess & {
|
|
78
77
|
rehydrated: true;
|
|
79
78
|
}) | (Pick<AirAuthSuccess, "success"> & {
|
|
80
79
|
rehydrated: false;
|
|
81
|
-
})
|
|
80
|
+
});
|
|
81
|
+
type AirAuthInitializationResponsePayload = AirAuthInitializationSuccess | AirAuthError;
|
|
82
82
|
type AirAuthLoginRequestPayload = {
|
|
83
83
|
partnerLoginToken?: string;
|
|
84
|
-
web3AuthJwt?: string;
|
|
85
84
|
};
|
|
86
85
|
type AirAuthSetupWalletSuccessPayload = {
|
|
87
86
|
success: true;
|
|
88
87
|
};
|
|
89
88
|
type AirAuthSetupWalletErrorPayload = {
|
|
90
89
|
success: false;
|
|
91
|
-
errorName:
|
|
90
|
+
errorName: AirErrorName;
|
|
92
91
|
errorMessage: string;
|
|
93
92
|
};
|
|
94
93
|
type AirAuthSetupWalletResponsePayload = AirAuthSetupWalletSuccessPayload | AirAuthSetupWalletErrorPayload;
|
|
@@ -107,6 +106,11 @@ type AirAuthSignSiweMessageErrorPayload = {
|
|
|
107
106
|
errorMessage: string;
|
|
108
107
|
};
|
|
109
108
|
type AirAuthSignSiweMessageResponsePayload = AirAuthSignSiweMessageSuccessPayload | AirAuthSignSiweMessageErrorPayload;
|
|
109
|
+
export type AirAuthInitializationRequestMessage = AirAuthMessageBase<"air_auth_initialization_request", {
|
|
110
|
+
partnerId: string;
|
|
111
|
+
skipRehydration?: boolean;
|
|
112
|
+
}>;
|
|
113
|
+
export type AirAuthInitializationResponseMessage = AirAuthMessageBase<"air_auth_initialization_response", AirAuthInitializationResponsePayload>;
|
|
110
114
|
export type AirAuthLoginRequestMessage = AirAuthMessageBase<"air_auth_login_request", AirAuthLoginRequestPayload>;
|
|
111
115
|
export type AirAuthLoginResponseToEmbedMessage = AirAuthMessageBase<"air_auth_login_response", AirAuthLoginResponseToEmbedPayload>;
|
|
112
116
|
export type AirAuthLoginResponseToWalletServiceMessage = AirAuthMessageBase<"air_auth_login_wallet_response", AirAuthLoginResponseToWalletPayload>;
|
|
@@ -118,11 +122,6 @@ export type AirAuthRefreshTokenRequestMessage = AirAuthMessageBaseWithoutPayload
|
|
|
118
122
|
export type AirAuthRefreshTokenResponseMessage = AirAuthMessageBase<"air_auth_refresh_token_response", AirAuthRefreshTokenResponsePayload>;
|
|
119
123
|
export type AirAuthWalletTokenRequestMessage = AirAuthMessageBase<"air_auth_wallet_token_request", AirAuthWalletTokenRequestPayload>;
|
|
120
124
|
export type AirAuthWalletTokenResponseMessage = AirAuthMessageBase<"air_auth_wallet_token_response", AirAuthWalletTokenResponsePayload>;
|
|
121
|
-
export type AirAuthInitializationResponseMessage = AirAuthMessageBase<"air_auth_initialization_response", AirAuthInitializationResponsePayload>;
|
|
122
|
-
export type AirAuthInitializationRequestMessage = AirAuthMessageBase<"air_auth_initialization_request", {
|
|
123
|
-
partnerId: string;
|
|
124
|
-
skipRehydration?: boolean;
|
|
125
|
-
}>;
|
|
126
125
|
export type AirAuthSetupCompletedMessage = AirAuthMessageBaseWithoutPayload<"air_auth_setup_completed">;
|
|
127
126
|
export type AirAuthInitWalletCommunicationMessage = AirAuthMessageBaseWithoutPayload<"air_auth_init_wallet_communication">;
|
|
128
127
|
export type AirAuthSetupWalletRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_setup_wallet_request">;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EIP1193Request } from "../../provider/types";
|
|
2
|
+
export declare const enum AirWalletProviderMessageTypes {
|
|
3
|
+
REQUEST = "JRPC_REQUEST",
|
|
4
|
+
RESPONSE = "JRPC_RESPONSE"
|
|
5
|
+
}
|
|
6
|
+
export type AirWalletProviderMessageRequest = {
|
|
7
|
+
type: AirWalletProviderMessageTypes.REQUEST;
|
|
8
|
+
payload: EIP1193Request & {
|
|
9
|
+
requestId: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type AirWalletProviderMessageSuccessResponse = {
|
|
13
|
+
type: AirWalletProviderMessageTypes.RESPONSE;
|
|
14
|
+
success: true;
|
|
15
|
+
payload: {
|
|
16
|
+
requestId: string;
|
|
17
|
+
method: string;
|
|
18
|
+
response: unknown;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type AirWalletProviderMessageErrorResponse = {
|
|
22
|
+
type: AirWalletProviderMessageTypes.RESPONSE;
|
|
23
|
+
success: false;
|
|
24
|
+
payload: {
|
|
25
|
+
requestId: string;
|
|
26
|
+
method: string;
|
|
27
|
+
errorCode: number;
|
|
28
|
+
errorMessage: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type AirWalletProviderMessageResponse = AirWalletProviderMessageSuccessResponse | AirWalletProviderMessageErrorResponse;
|
|
32
|
+
export type AirWalletProviderMessage = AirWalletProviderMessageRequest | AirWalletProviderMessageResponse;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { Hex } from "viem";
|
|
2
|
-
import { AirErrorName } from "
|
|
2
|
+
import { AirErrorName } from "../../air/error";
|
|
3
3
|
import { ActionPolicyInfo, Call } from "../smart-session/types";
|
|
4
4
|
export declare const AirMessageTypes: {
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
5
|
+
readonly SERVICE_STARTED: "air_service_started";
|
|
6
|
+
readonly INITIALIZATION_REQUEST: "air_initialization_request";
|
|
7
|
+
readonly INITIALIZATION_RESPONSE: "air_initialization_response";
|
|
8
|
+
readonly INIT_AUTH_COMMUNICATION: "air_init_auth_communication";
|
|
9
|
+
readonly WALLET_INITIALIZED: "air_wallet_initialized";
|
|
7
10
|
readonly LOGIN_REQUEST: "air_login_request";
|
|
8
11
|
readonly CLAIM_REQUEST: "air_claim_request";
|
|
9
12
|
readonly LOGIN_CLAIM_STATE: "air_login_claim_state";
|
|
10
13
|
readonly CLOSE_MODAL: "air_close_modal";
|
|
11
|
-
readonly INIT_AUTH_COMMUNICATION: "air_init_auth_communication";
|
|
12
14
|
readonly DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request";
|
|
13
15
|
readonly DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response";
|
|
14
16
|
readonly GRANT_PERMISSIONS_REQUEST: "air_grant_permissions_request";
|
|
@@ -17,6 +19,7 @@ export declare const AirMessageTypes: {
|
|
|
17
19
|
readonly EXECUTE_ACTION_RESPONSE: "air_execute_action_response";
|
|
18
20
|
readonly REVOKE_PERMISSIONS_REQUEST: "air_revoke_permissions_request";
|
|
19
21
|
readonly REVOKE_PERMISSIONS_RESPONSE: "air_revoke_permissions_response";
|
|
22
|
+
readonly WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request";
|
|
20
23
|
};
|
|
21
24
|
export declare const AirLoginClaimStates: {
|
|
22
25
|
readonly CONNECTED: "connected";
|
|
@@ -36,14 +39,27 @@ type AirMessageBase<TType extends AirMessageType, TPayload> = {
|
|
|
36
39
|
type AirMessageBaseWithoutPayload<TType extends AirMessageType> = {
|
|
37
40
|
type: TType;
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
isRehydrationSuccessful: boolean;
|
|
42
|
-
}>;
|
|
43
|
-
export type AirServiceInitializedErrorMessage = AirMessageBase<"air_service_initialized_error", {
|
|
42
|
+
type AirErrorPayload = {
|
|
43
|
+
success: false;
|
|
44
44
|
errorName: AirErrorName;
|
|
45
45
|
errorMessage?: string;
|
|
46
|
+
};
|
|
47
|
+
type AirInitializationResponsePayload = {
|
|
48
|
+
success: true;
|
|
49
|
+
} | AirErrorPayload;
|
|
50
|
+
export type AirWalletInitializationSuccess = {
|
|
51
|
+
success: true;
|
|
52
|
+
addresses: {
|
|
53
|
+
aa: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
type AirWalletInitializedPayload = AirWalletInitializationSuccess | AirErrorPayload;
|
|
57
|
+
export type AirInitializationRequestMessage = AirMessageBase<"air_initialization_request", {
|
|
58
|
+
partnerId: string;
|
|
59
|
+
enableLogging: boolean;
|
|
46
60
|
}>;
|
|
61
|
+
export type AirInitializationResponseMessage = AirMessageBase<"air_initialization_response", AirInitializationResponsePayload>;
|
|
62
|
+
export type AirWalletInitializedMessage = AirMessageBase<"air_wallet_initialized", AirWalletInitializedPayload>;
|
|
47
63
|
export type AirLoginRequestMessage = AirMessageBase<"air_login_request", {
|
|
48
64
|
token?: string;
|
|
49
65
|
skipClaimFlow: boolean;
|
|
@@ -138,6 +154,9 @@ export type AirExecuteActionResponseMessage = AirMessageBase<"air_execute_action
|
|
|
138
154
|
errorName: AirErrorName;
|
|
139
155
|
errorMessage?: string;
|
|
140
156
|
}>;
|
|
141
|
-
export type
|
|
157
|
+
export type AirWalletIframeVisibilityRequestMessage = AirMessageBase<"air_wallet_iframe_visibility_request", {
|
|
158
|
+
visible: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
export type AirMessage = AirInitializationRequestMessage | AirInitializationResponseMessage | AirWalletInitializedMessage | AirLoginRequestMessage | AirClaimRequestMessage | AirLoginClaimStateMessage | AirCloseModalMessage | AirInitAuthCommunicationMessage | AirDeploySmartAccountRequestMessage | AirDeploySmartAccountResponseMessage | AirGrantPermissionsRequestMessage | AirGrantPermissionsResponseMessage | AirRevokePermissionsRequestMessage | AirRevokePermissionsResponseMessage | AirExecuteActionRequestMessage | AirExecuteActionResponseMessage | AirWalletIframeVisibilityRequestMessage;
|
|
142
161
|
export type AirLoginClaimStatePayload = AirLoginClaimStateMessage["payload"];
|
|
143
162
|
export {};
|
|
@@ -8,37 +8,6 @@ export type RealmPartnerConfigStyle = {
|
|
|
8
8
|
hideModalOverlay?: boolean;
|
|
9
9
|
passwordlessButtonVariant?: "inline" | "standalone";
|
|
10
10
|
};
|
|
11
|
-
export declare const REALM_LOGIN_PROVIDER: {
|
|
12
|
-
readonly REALM_CUSTOM_AUTH: "realm_custom_auth";
|
|
13
|
-
readonly DEMO_CUSTOM_AUTH: "demo_custom_auth";
|
|
14
|
-
readonly GOOGLE: "google";
|
|
15
|
-
readonly FACEBOOK: "facebook";
|
|
16
|
-
readonly REDDIT: "reddit";
|
|
17
|
-
readonly DISCORD: "discord";
|
|
18
|
-
readonly TWITCH: "twitch";
|
|
19
|
-
readonly APPLE: "apple";
|
|
20
|
-
readonly LINE: "line";
|
|
21
|
-
readonly GITHUB: "github";
|
|
22
|
-
readonly KAKAO: "kakao";
|
|
23
|
-
readonly LINKEDIN: "linkedin";
|
|
24
|
-
readonly TWITTER: "twitter";
|
|
25
|
-
readonly WEIBO: "weibo";
|
|
26
|
-
readonly WECHAT: "wechat";
|
|
27
|
-
readonly FARCASTER: "farcaster";
|
|
28
|
-
readonly EMAIL_PASSWORDLESS: "email_passwordless";
|
|
29
|
-
readonly SMS_PASSWORDLESS: "sms_passwordless";
|
|
30
|
-
readonly WEBAUTHN: "webauthn";
|
|
31
|
-
readonly JWT: "jwt";
|
|
32
|
-
readonly PASSKEYS: "passkeys";
|
|
33
|
-
readonly AUTHENTICATOR: "authenticator";
|
|
34
|
-
};
|
|
35
|
-
export type REALM_LOGIN_PROVIDER_TYPE = (typeof REALM_LOGIN_PROVIDER)[keyof typeof REALM_LOGIN_PROVIDER];
|
|
36
|
-
export type RealmCustomAuthConfig = {
|
|
37
|
-
name: REALM_LOGIN_PROVIDER_TYPE;
|
|
38
|
-
verifier: string;
|
|
39
|
-
verifierSubIdentifier: string;
|
|
40
|
-
verifierIdField: string;
|
|
41
|
-
};
|
|
42
11
|
export declare const REALM_LOGIN_METHODS: readonly ["passwordless", "passwordlessToggle", "google", "wallet", "passkey"];
|
|
43
12
|
export type RealmLoginMethod = (typeof REALM_LOGIN_METHODS)[number];
|
|
44
13
|
export type RealmPartnerConfig = {
|
|
@@ -63,7 +32,6 @@ export type RealmPartnerConfig = {
|
|
|
63
32
|
localeUrls?: Record<string, string>;
|
|
64
33
|
authLocaleUrls?: Record<string, string>;
|
|
65
34
|
sessionTime?: number;
|
|
66
|
-
customAuth?: RealmCustomAuthConfig;
|
|
67
35
|
allowSessionIdLogin?: boolean;
|
|
68
36
|
loginMethods?: RealmLoginMethod[];
|
|
69
37
|
skipPartnerLinkingConfirmation?: boolean;
|
|
@@ -16,7 +16,7 @@ export type Prettify<T> = {
|
|
|
16
16
|
type KeyofUnion<type> = type extends type ? keyof type : never;
|
|
17
17
|
export type UnionEvaluate<type> = type extends object ? Prettify<type> : type;
|
|
18
18
|
export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Prettify<item & {
|
|
19
|
-
[key in Exclude<keys, keyof item>]?: fallback extends object ?
|
|
19
|
+
[key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined;
|
|
20
20
|
}> : never;
|
|
21
21
|
export type SpendingLimitPolicyData = {
|
|
22
22
|
/** The address of the token to be included in the policy */
|
|
@@ -3,16 +3,6 @@ export type AuthCredentials = {
|
|
|
3
3
|
refreshToken: string;
|
|
4
4
|
partnerAccessToken: string;
|
|
5
5
|
};
|
|
6
|
-
export type RealmDetailsV1 = {
|
|
7
|
-
name?: string;
|
|
8
|
-
node: string;
|
|
9
|
-
status: "not_minted" | "minting" | "minted";
|
|
10
|
-
tokenId?: string;
|
|
11
|
-
imageUrl?: string;
|
|
12
|
-
eoaAddress?: string;
|
|
13
|
-
abstractAccountAddress?: string;
|
|
14
|
-
partnerUserId?: string;
|
|
15
|
-
};
|
|
16
6
|
export type AirIdDetails = {
|
|
17
7
|
id: string;
|
|
18
8
|
name?: string;
|
|
@@ -21,18 +11,10 @@ export type AirIdDetails = {
|
|
|
21
11
|
tokenId?: string;
|
|
22
12
|
imageUrl?: string;
|
|
23
13
|
};
|
|
24
|
-
export type MintTransaction = {
|
|
25
|
-
id: string;
|
|
26
|
-
transactionHash: string;
|
|
27
|
-
};
|
|
28
14
|
export type GlobalId = {
|
|
29
15
|
id: string;
|
|
30
16
|
abstractAccountAddress?: string;
|
|
31
17
|
};
|
|
32
|
-
export type RealmUserV1 = {
|
|
33
|
-
realmId: RealmDetailsV1;
|
|
34
|
-
mintTransaction?: MintTransaction;
|
|
35
|
-
};
|
|
36
18
|
export type LoggedInLoginResponse = {
|
|
37
19
|
status: "logged_in";
|
|
38
20
|
} & AuthCredentials & {
|
|
@@ -43,12 +25,6 @@ type PartnerLinkageRequiredLoginResponse = {
|
|
|
43
25
|
} & AuthCredentials & {
|
|
44
26
|
user: GlobalId;
|
|
45
27
|
};
|
|
46
|
-
export type LoggedInLoginV1Response = {
|
|
47
|
-
status: "logged_in";
|
|
48
|
-
} & AuthCredentials & RealmUserV1;
|
|
49
|
-
type PartnerLinkageRequiredLoginV1Response = {
|
|
50
|
-
status: "partner_linkage_required";
|
|
51
|
-
} & AuthCredentials & RealmUserV1;
|
|
52
28
|
type EmailRequiredLoginResponse = {
|
|
53
29
|
status: "email_required";
|
|
54
30
|
};
|
|
@@ -60,10 +36,6 @@ type LoginRequiredLoginResponse = {
|
|
|
60
36
|
status: "login_required";
|
|
61
37
|
};
|
|
62
38
|
export type LoginResponse = LoggedInLoginResponse | PartnerLinkageRequiredLoginResponse | EmailRequiredLoginResponse | EmailVerificationRequiredLoginResponse | LoginRequiredLoginResponse;
|
|
63
|
-
export type LoginV1Response = LoggedInLoginV1Response | PartnerLinkageRequiredLoginV1Response | EmailRequiredLoginResponse | EmailVerificationRequiredLoginResponse | LoginRequiredLoginResponse;
|
|
64
|
-
export type MeResponseV1 = {
|
|
65
|
-
realmId: RealmDetailsV1;
|
|
66
|
-
};
|
|
67
39
|
export type MeResponse = {
|
|
68
40
|
user: GlobalId & {
|
|
69
41
|
email?: string;
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
import { AirIdDetails } from "./realm/user/types";
|
|
2
2
|
export declare const parseAirId: (airIdDetail?: Omit<AirIdDetails, "id">) => string | undefined;
|
|
3
|
+
export declare function promiseCreator<T>(): {
|
|
4
|
+
resolve: ((value: T | PromiseLike<T>) => void) | null;
|
|
5
|
+
reject: ((reason?: string) => void) | null;
|
|
6
|
+
promise: Promise<T>;
|
|
7
|
+
};
|
|
8
|
+
export declare const isMain: boolean;
|
|
9
|
+
export declare const getIFrameOrigin: () => string;
|
|
10
|
+
export declare const isUnsafeOrigin: (origin: string) => boolean;
|
|
11
|
+
export declare const isParentHttps: (origin: string) => boolean;
|
|
12
|
+
export declare const formatPublicKey: (publicKey: string) => string;
|
|
13
|
+
export declare const setPartnerTheme: (theme: string, partnerId: string, configApiUrl: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a random number. Don't use for cryptographic purposes.
|
|
16
|
+
* @returns a random number
|
|
17
|
+
*/
|
|
18
|
+
export declare const randomId: () => string;
|
package/dist/types/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { AirErrorName } from "./common/air/error";
|
|
1
2
|
import { BaseError } from "./common/error";
|
|
2
|
-
import { AirErrorName } from "./common/realm/error/types";
|
|
3
3
|
type AirServiceErrorName = AirErrorName | "NOT_INITIALISED" | "ALREADY_INITIALISED" | "NOT_LOGGED_IN" | "NOT_CONNECTED";
|
|
4
4
|
export declare class AirServiceError extends BaseError<AirServiceErrorName> {
|
|
5
5
|
static from(error: unknown): AirServiceError;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as AirService } from "./airService";
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as AirInPageProvider } from "./inPageProvider";
|
|
2
|
+
export { default as AirWalletProvider } from "./airWalletProvider";
|
|
4
3
|
export * from "./interfaces";
|