@mocanetwork/airkit 1.0.0 → 1.1.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.
@@ -1,7 +1,6 @@
1
1
  import { Hex } from "./common/realm/smart-session/hex";
2
2
  import { ActionPolicyInfo, Call } from "./common/realm/smart-session/types";
3
- import AirWalletProvider from "./airWalletProvider";
4
- import { AirEventListener, AirLoginResult, AirUserDetails, AirWalletInitializedResult, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult } from "./interfaces";
3
+ import { AirEventListener, AirLoginResult, AirUserDetails, AirWalletInitializedResult, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult, EIP1193Provider } from "./interfaces";
5
4
  declare class AirService {
6
5
  #private;
7
6
  constructor({ partnerId }: {
@@ -12,12 +11,12 @@ declare class AirService {
12
11
  get isInitialized(): boolean;
13
12
  get isLoggedIn(): boolean;
14
13
  get isWalletInitialized(): boolean;
14
+ get provider(): EIP1193Provider;
15
15
  init({ buildEnv, enableLogging, skipRehydration, }: {
16
16
  buildEnv: BUILD_ENV_TYPE;
17
17
  enableLogging: boolean;
18
18
  skipRehydration: boolean;
19
19
  }): Promise<AirLoginResult | null>;
20
- cleanUp(): Promise<void>;
21
20
  login(options?: {
22
21
  authToken?: string;
23
22
  }): Promise<AirLoginResult>;
@@ -51,11 +50,15 @@ declare class AirService {
51
50
  * @experimental This method is experimental and will change in the future.
52
51
  */
53
52
  isSmartAccountDeployed(): Promise<boolean>;
54
- logout(): Promise<void>;
55
- getProvider(): Promise<AirWalletProvider>;
53
+ getProvider(): EIP1193Provider;
56
54
  preloadWallet(): Promise<AirWalletInitializedResult>;
57
55
  claimAirId(options?: ClaimAirIdOptions): Promise<ClaimAirIdResult>;
58
56
  getUserInfo(): Promise<AirUserDetails>;
57
+ goToPartner(partnerUrl: string): Promise<{
58
+ urlWithToken: string;
59
+ }>;
60
+ logout(): Promise<void>;
61
+ cleanUp(): Promise<void>;
59
62
  on(listener: AirEventListener): void;
60
63
  off(listener: AirEventListener): void;
61
64
  clearEventListeners(): void;
@@ -1,13 +1,21 @@
1
1
  import { EIP1193EventMap, EIP1193Provider } from "@mocanetwork/common/src/provider/types";
2
+ import { AirWalletInitializedResult } from "./interfaces";
3
+ import { IframeController } from "./iframeController";
2
4
  declare class AirWalletProvider implements EIP1193Provider {
3
5
  #private;
4
6
  chainId: string;
5
- constructor(walletIframe: HTMLIFrameElement);
7
+ constructor({ isLoggedIn, ensureWallet, getWalletIframeController, }: {
8
+ isLoggedIn: () => boolean;
9
+ ensureWallet: () => Promise<AirWalletInitializedResult>;
10
+ getWalletIframeController: () => IframeController;
11
+ });
6
12
  request(request: {
7
13
  method: string;
8
14
  params?: unknown[];
9
15
  }): 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;
16
+ on<T extends keyof EIP1193EventMap>(eventName: T, listener: EIP1193EventMap[T]): void;
17
+ removeListener<T extends keyof EIP1193EventMap>(eventName: T, listener: EIP1193EventMap[T]): void;
18
+ removeAllListeners(): void;
19
+ listenProviderEventMessage: () => void;
12
20
  }
13
21
  export default AirWalletProvider;
@@ -0,0 +1,138 @@
1
+ /*** Authentication Errors ***/
2
+ export declare enum AuthErrorName {
3
+ UNAUTHORIZED = "UNAUTHORIZED",
4
+ INVALID_TOKEN = "INVALID_TOKEN",
5
+ TOKEN_EXPIRED = "TOKEN_EXPIRED",
6
+ INVALID_CREDENTIALS = "INVALID_CREDENTIALS"
7
+ }
8
+ /*** Partner Access Token Errors ***/
9
+ export declare enum PartnerAccessTokenErrorName {
10
+ PARTNER_ACCESS_TOKEN_INVALID = "PARTNER_ACCESS_TOKEN_INVALID",
11
+ USER_MISMATCH = "USER_MISMATCH"
12
+ }
13
+ /*** Realm ID Errors ***/
14
+ export declare enum RealmIDErrorName {
15
+ REALM_ID_NOT_FOUND = "REALM_ID_NOT_FOUND",
16
+ REALM_ID_INVALID_NAME = "REALM_ID_INVALID_NAME",
17
+ REALM_ID_ALREADY_EXISTS = "REALM_ID_ALREADY_EXISTS",
18
+ REALM_ID_DUPLICATE_PARTNER_USER = "REALM_ID_DUPLICATE_PARTNER_USER"
19
+ }
20
+ /*** Parameter Errors ***/
21
+ export declare enum ParameterErrorName {
22
+ INVALID_PARAMETER = "INVALID_PARAMETER"
23
+ }
24
+ /*** Server Errors ***/
25
+ export declare enum ServerErrorName {
26
+ INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"
27
+ }
28
+ /*** Passkey Errors ***/
29
+ export declare enum PasskeyErrorName {
30
+ PASSKEY_REGISTRATION_FAILED = "PASSKEY_REGISTRATION_FAILED",
31
+ PASSKEY_AUTHENTICATION_FAILED = "PASSKEY_AUTHENTICATION_FAILED",
32
+ PASSKEY_LIMIT_EXCEEDED = "PASSKEY_LIMIT_EXCEEDED",
33
+ PASSKEY_NOT_FOUND = "PASSKEY_NOT_FOUND",
34
+ PASSKEY_UNAUTHORIZED = "PASSKEY_UNAUTHORIZED",
35
+ PASSKEY_CHALLENGE_INVALID = "PASSKEY_CHALLENGE_INVALID"
36
+ }
37
+ /*** Passwordless Authentication Errors ***/
38
+ export declare enum PasswordlessErrorName {
39
+ PASSWORDLESS_CODE_EXPIRED = "PASSWORDLESS_CODE_EXPIRED",
40
+ PASSWORDLESS_INVALID_CODE = "PASSWORDLESS_INVALID_CODE",
41
+ PASSWORDLESS_MAX_ATTEMPTS = "PASSWORDLESS_MAX_ATTEMPTS",
42
+ PASSWORDLESS_HOURLY_LIMIT = "PASSWORDLESS_HOURLY_LIMIT",
43
+ PASSWORDLESS_LOCK_EXCEEDED = "PASSWORDLESS_LOCK_EXCEEDED"
44
+ }
45
+ /*** Authentication Wallet Errors ***/
46
+ export declare enum AuthWalletErrorName {
47
+ AUTH_WALLET_LOCK_EXCEEDED = "AUTH_WALLET_LOCK_EXCEEDED",
48
+ AUTH_WALLET_NONCE_EXPIRED_OR_INVALID = "AUTH_WALLET_NONCE_EXPIRED_OR_INVALID",
49
+ AUTH_WALLET_ADDRESS_MISMATCH = "AUTH_WALLET_ADDRESS_MISMATCH",
50
+ AUTH_WALLET_SIGNATURE_VERIFICATION_FAILED = "AUTH_WALLET_SIGNATURE_VERIFICATION_FAILED"
51
+ }
52
+ /*** Wallet Linking Errors ***/
53
+ export declare enum WalletLinkErrorName {
54
+ LINK_WALLET_ALREADY_LINKED = "LINK_WALLET_ALREADY_LINKED",
55
+ LINK_WALLET_LINKED_OTHER_ACCOUNT = "LINK_WALLET_LINKED_OTHER_ACCOUNT",
56
+ LINK_EMAIL_LINKED_OTHER_ACCOUNT = "LINK_EMAIL_LINKED_OTHER_ACCOUNT"
57
+ }
58
+ /*** Intent Errors ***/
59
+ export declare enum IntentErrorName {
60
+ INTENT_INVALID = "INTENT_INVALID",
61
+ INTENT_LOCK_EXCEEDED = "INTENT_LOCK_EXCEEDED",
62
+ INTENT_REQUIRED = "INTENT_REQUIRED",
63
+ INTENT_UNSUPPORTED_TYPE = "INTENT_UNSUPPORTED_TYPE"
64
+ }
65
+ /*** Privy Errors ***/
66
+ export declare enum PrivyErrorName {
67
+ WALLET_PROVIDER_ERROR = "WALLET_PROVIDER_ERROR"
68
+ }
69
+ /*** Air ID Errors ***/
70
+ export declare enum AirIDErrorName {
71
+ AIR_ID_MINT_TRANSACTION_NOT_FOUND = "AIR_ID_MINT_TRANSACTION_NOT_FOUND",
72
+ AIR_ID_ON_CHAIN_TRANSACTION_NOT_FOUND = "AIR_ID_ON_CHAIN_TRANSACTION_NOT_FOUND",
73
+ AIR_ID_NOT_FOUND = "AIR_ID_NOT_FOUND",
74
+ AIR_ID_INVALID_OR_DISABLED_CONFIGURATION = "AIR_ID_INVALID_OR_DISABLED_CONFIGURATION",
75
+ AIR_ID_RPC_URL_NOT_CONFIGURED = "AIR_ID_RPC_URL_NOT_CONFIGURED",
76
+ AIR_ID_INVALID_STATUS = "AIR_ID_INVALID_STATUS",
77
+ AIR_ID_PARTNER_ELIGIBILITY_CHECK_FAILED = "AIR_ID_PARTNER_ELIGIBILITY_CHECK_FAILED",
78
+ AIR_ID_PARTNER_ELIGIBILITY_CHECK_TIMEOUT = "AIR_ID_PARTNER_ELIGIBILITY_CHECK_TIMEOUT",
79
+ AIR_ID_MULTIPLE_AIR_IDS_FOUND = "AIR_ID_MULTIPLE_AIR_IDS_FOUND",
80
+ AIR_ID_NAME_RESERVED = "AIR_ID_NAME_RESERVED",
81
+ AIR_ID_NAME_PROFANITY = "AIR_ID_NAME_PROFANITY",
82
+ AIR_ID_USER_ALREADY_HAS_AIR_ID = "AIR_ID_USER_ALREADY_HAS_AIR_ID",
83
+ AIR_ID_NAME_ALREADY_EXISTS = "AIR_ID_NAME_ALREADY_EXISTS",
84
+ AIR_ID_INVALID_MINT_NAME = "AIR_ID_INVALID_MINT_NAME",
85
+ AIR_ID_MINT_TRANSACTION_HASH_MISMATCH = "AIR_ID_MINT_TRANSACTION_HASH_MISMATCH"
86
+ }
87
+ export declare const Codes: {
88
+ AIR_ID_MINT_TRANSACTION_NOT_FOUND: AirIDErrorName.AIR_ID_MINT_TRANSACTION_NOT_FOUND;
89
+ AIR_ID_ON_CHAIN_TRANSACTION_NOT_FOUND: AirIDErrorName.AIR_ID_ON_CHAIN_TRANSACTION_NOT_FOUND;
90
+ AIR_ID_NOT_FOUND: AirIDErrorName.AIR_ID_NOT_FOUND;
91
+ AIR_ID_INVALID_OR_DISABLED_CONFIGURATION: AirIDErrorName.AIR_ID_INVALID_OR_DISABLED_CONFIGURATION;
92
+ AIR_ID_RPC_URL_NOT_CONFIGURED: AirIDErrorName.AIR_ID_RPC_URL_NOT_CONFIGURED;
93
+ AIR_ID_INVALID_STATUS: AirIDErrorName.AIR_ID_INVALID_STATUS;
94
+ AIR_ID_PARTNER_ELIGIBILITY_CHECK_FAILED: AirIDErrorName.AIR_ID_PARTNER_ELIGIBILITY_CHECK_FAILED;
95
+ AIR_ID_PARTNER_ELIGIBILITY_CHECK_TIMEOUT: AirIDErrorName.AIR_ID_PARTNER_ELIGIBILITY_CHECK_TIMEOUT;
96
+ AIR_ID_MULTIPLE_AIR_IDS_FOUND: AirIDErrorName.AIR_ID_MULTIPLE_AIR_IDS_FOUND;
97
+ AIR_ID_NAME_RESERVED: AirIDErrorName.AIR_ID_NAME_RESERVED;
98
+ AIR_ID_NAME_PROFANITY: AirIDErrorName.AIR_ID_NAME_PROFANITY;
99
+ AIR_ID_USER_ALREADY_HAS_AIR_ID: AirIDErrorName.AIR_ID_USER_ALREADY_HAS_AIR_ID;
100
+ AIR_ID_NAME_ALREADY_EXISTS: AirIDErrorName.AIR_ID_NAME_ALREADY_EXISTS;
101
+ AIR_ID_INVALID_MINT_NAME: AirIDErrorName.AIR_ID_INVALID_MINT_NAME;
102
+ AIR_ID_MINT_TRANSACTION_HASH_MISMATCH: AirIDErrorName.AIR_ID_MINT_TRANSACTION_HASH_MISMATCH;
103
+ WALLET_PROVIDER_ERROR: PrivyErrorName.WALLET_PROVIDER_ERROR;
104
+ INTENT_INVALID: IntentErrorName.INTENT_INVALID;
105
+ INTENT_LOCK_EXCEEDED: IntentErrorName.INTENT_LOCK_EXCEEDED;
106
+ INTENT_REQUIRED: IntentErrorName.INTENT_REQUIRED;
107
+ INTENT_UNSUPPORTED_TYPE: IntentErrorName.INTENT_UNSUPPORTED_TYPE;
108
+ LINK_WALLET_ALREADY_LINKED: WalletLinkErrorName.LINK_WALLET_ALREADY_LINKED;
109
+ LINK_WALLET_LINKED_OTHER_ACCOUNT: WalletLinkErrorName.LINK_WALLET_LINKED_OTHER_ACCOUNT;
110
+ LINK_EMAIL_LINKED_OTHER_ACCOUNT: WalletLinkErrorName.LINK_EMAIL_LINKED_OTHER_ACCOUNT;
111
+ AUTH_WALLET_LOCK_EXCEEDED: AuthWalletErrorName.AUTH_WALLET_LOCK_EXCEEDED;
112
+ AUTH_WALLET_NONCE_EXPIRED_OR_INVALID: AuthWalletErrorName.AUTH_WALLET_NONCE_EXPIRED_OR_INVALID;
113
+ AUTH_WALLET_ADDRESS_MISMATCH: AuthWalletErrorName.AUTH_WALLET_ADDRESS_MISMATCH;
114
+ AUTH_WALLET_SIGNATURE_VERIFICATION_FAILED: AuthWalletErrorName.AUTH_WALLET_SIGNATURE_VERIFICATION_FAILED;
115
+ PASSWORDLESS_CODE_EXPIRED: PasswordlessErrorName.PASSWORDLESS_CODE_EXPIRED;
116
+ PASSWORDLESS_INVALID_CODE: PasswordlessErrorName.PASSWORDLESS_INVALID_CODE;
117
+ PASSWORDLESS_MAX_ATTEMPTS: PasswordlessErrorName.PASSWORDLESS_MAX_ATTEMPTS;
118
+ PASSWORDLESS_HOURLY_LIMIT: PasswordlessErrorName.PASSWORDLESS_HOURLY_LIMIT;
119
+ PASSWORDLESS_LOCK_EXCEEDED: PasswordlessErrorName.PASSWORDLESS_LOCK_EXCEEDED;
120
+ PASSKEY_REGISTRATION_FAILED: PasskeyErrorName.PASSKEY_REGISTRATION_FAILED;
121
+ PASSKEY_AUTHENTICATION_FAILED: PasskeyErrorName.PASSKEY_AUTHENTICATION_FAILED;
122
+ PASSKEY_LIMIT_EXCEEDED: PasskeyErrorName.PASSKEY_LIMIT_EXCEEDED;
123
+ PASSKEY_NOT_FOUND: PasskeyErrorName.PASSKEY_NOT_FOUND;
124
+ PASSKEY_UNAUTHORIZED: PasskeyErrorName.PASSKEY_UNAUTHORIZED;
125
+ PASSKEY_CHALLENGE_INVALID: PasskeyErrorName.PASSKEY_CHALLENGE_INVALID;
126
+ INTERNAL_SERVER_ERROR: ServerErrorName.INTERNAL_SERVER_ERROR;
127
+ INVALID_PARAMETER: ParameterErrorName.INVALID_PARAMETER;
128
+ REALM_ID_NOT_FOUND: RealmIDErrorName.REALM_ID_NOT_FOUND;
129
+ REALM_ID_INVALID_NAME: RealmIDErrorName.REALM_ID_INVALID_NAME;
130
+ REALM_ID_ALREADY_EXISTS: RealmIDErrorName.REALM_ID_ALREADY_EXISTS;
131
+ REALM_ID_DUPLICATE_PARTNER_USER: RealmIDErrorName.REALM_ID_DUPLICATE_PARTNER_USER;
132
+ PARTNER_ACCESS_TOKEN_INVALID: PartnerAccessTokenErrorName.PARTNER_ACCESS_TOKEN_INVALID;
133
+ USER_MISMATCH: PartnerAccessTokenErrorName.USER_MISMATCH;
134
+ UNAUTHORIZED: AuthErrorName.UNAUTHORIZED;
135
+ INVALID_TOKEN: AuthErrorName.INVALID_TOKEN;
136
+ TOKEN_EXPIRED: AuthErrorName.TOKEN_EXPIRED;
137
+ INVALID_CREDENTIALS: AuthErrorName.INVALID_CREDENTIALS;
138
+ };
@@ -1,8 +1,9 @@
1
- import { BaseError } from "../error";
2
- export type AirErrorName = "USER_CANCELLED" | "CONFIG_ERROR" | "SERVER_ERROR" | "CLIENT_ERROR" | "UNKNOWN_ERROR" | "PERMISSION_NOT_ENABLED" | "SMART_ACCOUNT_NOT_DEPLOYED";
1
+ import { BaseError } from "../../error";
2
+ import { AirErrorName } from "./types";
3
3
  export declare class AirError extends BaseError<AirErrorName> {
4
4
  }
5
5
  export declare class AirHttpError extends AirError {
6
6
  readonly response: unknown;
7
7
  constructor(name: AirErrorName, message: string, response?: unknown, options?: Record<string, unknown>);
8
8
  }
9
+ export declare const isAirErrorName: (name: string) => name is AirErrorName;
@@ -0,0 +1,3 @@
1
+ import { Codes } from "./codes";
2
+ export declare const AirClientUserErrors: readonly ["USER_CANCELLED", "CONFIG_ERROR", "CLIENT_ERROR", "UNKNOWN_ERROR", "PERMISSION_NOT_ENABLED", "SMART_ACCOUNT_NOT_DEPLOYED"];
3
+ export type AirErrorName = (typeof AirClientUserErrors)[number] | (typeof Codes)[keyof typeof Codes];
@@ -1,4 +1,3 @@
1
- import { ProviderRpcError } from "./error";
2
1
  export type ProviderConnectInfo = {
3
2
  chainId: string;
4
3
  };
@@ -6,6 +5,11 @@ export type ProviderMessage = {
6
5
  type: string;
7
6
  data: unknown;
8
7
  };
8
+ export type ProviderRpcError = {
9
+ code: number;
10
+ name: string;
11
+ message: string;
12
+ };
9
13
  export type EIP1193EventMap = {
10
14
  accountsChanged(accounts: string[]): void;
11
15
  chainChanged(chainId: string): void;
@@ -13,6 +17,7 @@ export type EIP1193EventMap = {
13
17
  disconnect(error: ProviderRpcError): void;
14
18
  message(message: ProviderMessage): void;
15
19
  };
20
+ export type EIP1193Event = keyof EIP1193EventMap;
16
21
  export type EIP1193Request = {
17
22
  method: string;
18
23
  params?: Array<unknown> | undefined;
@@ -1,5 +1,5 @@
1
- import { AirErrorName } from "../../air/error";
2
- import { AirIdDetails, GlobalId } from "../user/types";
1
+ import { AirErrorName } from "../../air/error/types";
2
+ import { AirIdDetails, GlobalId, MFASetup } from "../user/types";
3
3
  export declare const AirAuthMessageTypes: {
4
4
  readonly AUTH_SETUP_COMPLETED: "air_auth_setup_completed";
5
5
  readonly INITIALIZATION_REQUEST: "air_auth_initialization_request";
@@ -7,6 +7,8 @@ export declare const AirAuthMessageTypes: {
7
7
  readonly LOGIN_REQUEST: "air_auth_login_request";
8
8
  readonly LOGIN_RESPONSE: "air_auth_login_response";
9
9
  readonly LOGIN_WALLET_RESPONSE: "air_auth_login_wallet_response";
10
+ readonly USER_INFO_REQUEST: "air_auth_user_info_request";
11
+ readonly USER_INFO_RESPONSE: "air_auth_user_info_response";
10
12
  readonly PARTNER_USER_INFO_REQUEST: "air_auth_partner_user_info_request";
11
13
  readonly PARTNER_USER_INFO_RESPONSE: "air_auth_partner_user_info_response";
12
14
  readonly REFRESH_TOKEN_REQUEST: "air_auth_refresh_token_request";
@@ -19,8 +21,11 @@ export declare const AirAuthMessageTypes: {
19
21
  readonly SETUP_WALLET_RESPONSE: "air_auth_setup_wallet_response";
20
22
  readonly SIGN_SIWE_MESSAGE_REQUEST: "air_auth_sign_siwe_message_request";
21
23
  readonly SIGN_SIWE_MESSAGE_RESPONSE: "air_auth_sign_siwe_message_response";
24
+ readonly CROSS_PARTNER_TOKEN_REQUEST: "air_auth_cross_partner_token_request";
25
+ readonly CROSS_PARTNER_TOKEN_RESPONSE: "air_auth_cross_partner_token_response";
22
26
  readonly LOGOUT_REQUEST: "air_auth_logout_request";
23
27
  readonly LOGOUT_RESPONSE: "air_auth_logout_response";
28
+ readonly RESET_WALLET_COMMUNICATION: "air_auth_reset_wallet_communication";
24
29
  };
25
30
  export type AirAuthMessageType = (typeof AirAuthMessageTypes)[keyof typeof AirAuthMessageTypes];
26
31
  type AirAuthMessageBase<TType extends AirAuthMessageType, TPayload> = {
@@ -30,90 +35,84 @@ type AirAuthMessageBase<TType extends AirAuthMessageType, TPayload> = {
30
35
  type AirAuthMessageBaseWithoutPayload<TType extends AirAuthMessageType> = {
31
36
  type: TType;
32
37
  };
38
+ export type AirAuthSuccess = {
39
+ success: true;
40
+ };
33
41
  export type AirAuthError = {
34
42
  success: false;
35
43
  errorName: AirErrorName;
36
44
  errorMessage?: string;
37
45
  };
38
- export type AirAuthSuccess = {
39
- success: true;
46
+ export type AirAuthLoginSuccess = AirAuthSuccess & {
40
47
  email?: string;
41
48
  partnerAccessToken: string;
42
- } & GlobalId;
43
- export type AirAuthSuccessTokens = {
44
- success: true;
49
+ } & GlobalId & MFASetup;
50
+ export type AirAuthSuccessTokens = AirAuthSuccess & {
45
51
  accessToken: string;
46
52
  partnerAccessToken: string;
47
53
  };
48
- export type AirAuthUserDetailsSuccess = {
49
- success: true;
54
+ export type AirAuthUserInfoResponsePayload = (AirAuthSuccess & GlobalId & {
50
55
  email?: string;
51
56
  airIds: AirIdDetails[];
52
- } & GlobalId;
53
- export type AirAuthPartnerUserDetailsSuccess = {
54
- success: true;
57
+ }) | AirAuthError;
58
+ export type AirAuthPartnerUserDetailsSuccess = AirAuthSuccess & {
55
59
  partnerId: string;
56
60
  partnerUserId: string;
57
61
  airId?: AirIdDetails;
58
62
  user: GlobalId & {
59
63
  email?: string;
60
- };
64
+ } & MFASetup;
61
65
  };
62
- export type AirAuthSuccessWithAirIdsAndTokens = AirAuthUserDetailsSuccess & AirAuthSuccessTokens;
63
- type AirAuthLoginResponseToEmbedPayload = AirAuthSuccess | AirAuthError;
64
- type AirAuthLoginResponseToWalletPayload = AirAuthSuccessWithAirIdsAndTokens | AirAuthError;
66
+ export type AirAuthSuccessWithAirIdAndTokens = AirAuthPartnerUserDetailsSuccess & AirAuthSuccessTokens;
67
+ type AirAuthLoginResponseToEmbedPayload = AirAuthLoginSuccess | AirAuthError;
68
+ type AirAuthLoginResponseToWalletPayload = AirAuthSuccessWithAirIdAndTokens | AirAuthError;
65
69
  type AirAuthRefreshTokenResponsePayload = AirAuthSuccessTokens | AirAuthError;
66
70
  type AirAuthPartnerUserInfoResponsePayload = AirAuthPartnerUserDetailsSuccess | AirAuthError;
67
71
  type AirAuthWalletTokenRequestPayload = {
68
72
  nonce: string;
69
73
  partnerId: string;
70
74
  };
71
- type AirAuthWalletTokenResponsePayload = {
72
- success: true;
75
+ type AirAuthWalletTokenResponsePayload = (AirAuthPartnerUserDetailsSuccess & {
73
76
  accessToken: string;
74
77
  walletToken: string;
75
- } | AirAuthError;
76
- export type AirAuthInitializationSuccess = (AirAuthSuccess & {
78
+ }) | AirAuthError;
79
+ export type AirAuthInitializationSuccess = (AirAuthLoginSuccess & {
77
80
  rehydrated: true;
78
- }) | (Pick<AirAuthSuccess, "success"> & {
81
+ }) | (AirAuthSuccess & {
79
82
  rehydrated: false;
80
83
  });
81
84
  type AirAuthInitializationResponsePayload = AirAuthInitializationSuccess | AirAuthError;
82
85
  type AirAuthLoginRequestPayload = {
83
86
  partnerLoginToken?: string;
84
87
  };
85
- type AirAuthSetupWalletSuccessPayload = {
86
- success: true;
87
- };
88
- type AirAuthSetupWalletErrorPayload = {
89
- success: false;
90
- errorName: AirErrorName;
91
- errorMessage: string;
92
- };
93
- type AirAuthSetupWalletResponsePayload = AirAuthSetupWalletSuccessPayload | AirAuthSetupWalletErrorPayload;
88
+ type AirAuthSetupWalletResponsePayload = AirAuthSuccess | AirAuthError;
94
89
  type AirAuthSignSiweMessageRequestPayload = {
95
90
  wallet: string;
96
91
  };
97
- export type AirAuthSignSiweMessageSuccessPayload = {
98
- success: true;
92
+ export type AirAuthSignSiweMessageSuccessPayload = AirAuthSuccess & {
99
93
  address: string;
100
94
  message: string;
101
95
  signature: string;
102
96
  };
103
- type AirAuthSignSiweMessageErrorPayload = {
104
- success: false;
105
- errorName: AirErrorName;
106
- errorMessage: string;
97
+ type AirAuthSignSiweMessageResponsePayload = AirAuthSignSiweMessageSuccessPayload | AirAuthError;
98
+ type AirAuthCrossPartnerTokenRequestPayload = {
99
+ targetPartnerUrl: string;
100
+ };
101
+ export type AirAuthCrossPartnerTokenSuccessPayload = AirAuthSuccess & {
102
+ urlWithToken: string;
107
103
  };
108
- type AirAuthSignSiweMessageResponsePayload = AirAuthSignSiweMessageSuccessPayload | AirAuthSignSiweMessageErrorPayload;
109
- export type AirAuthInitializationRequestMessage = AirAuthMessageBase<"air_auth_initialization_request", {
104
+ export type AirAuthInitializationRequestPayload = {
110
105
  partnerId: string;
106
+ partnerDAppUrl?: string;
111
107
  skipRehydration?: boolean;
112
- }>;
108
+ };
109
+ export type AirAuthInitializationRequestMessage = AirAuthMessageBase<"air_auth_initialization_request", AirAuthInitializationRequestPayload>;
113
110
  export type AirAuthInitializationResponseMessage = AirAuthMessageBase<"air_auth_initialization_response", AirAuthInitializationResponsePayload>;
114
111
  export type AirAuthLoginRequestMessage = AirAuthMessageBase<"air_auth_login_request", AirAuthLoginRequestPayload>;
115
112
  export type AirAuthLoginResponseToEmbedMessage = AirAuthMessageBase<"air_auth_login_response", AirAuthLoginResponseToEmbedPayload>;
116
113
  export type AirAuthLoginResponseToWalletServiceMessage = AirAuthMessageBase<"air_auth_login_wallet_response", AirAuthLoginResponseToWalletPayload>;
114
+ export type AirAuthUserInfoRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_user_info_request">;
115
+ export type AirAuthUserInfoResponseMessage = AirAuthMessageBase<"air_auth_user_info_response", AirAuthUserInfoResponsePayload>;
117
116
  export type AirAuthPartnerUserInfoRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_partner_user_info_request">;
118
117
  export type AirAuthPartnerUserInfoResponseMessage = AirAuthMessageBase<"air_auth_partner_user_info_response", AirAuthPartnerUserInfoResponsePayload>;
119
118
  export type AirAuthRefreshTokenRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_refresh_token_request">;
@@ -126,10 +125,13 @@ export type AirAuthSetupWalletRequestMessage = AirAuthMessageBaseWithoutPayload<
126
125
  export type AirAuthSetupWalletResponseMessage = AirAuthMessageBase<"air_auth_setup_wallet_response", AirAuthSetupWalletResponsePayload>;
127
126
  export type AirAuthSignSiweMessageRequestMessage = AirAuthMessageBase<"air_auth_sign_siwe_message_request", AirAuthSignSiweMessageRequestPayload>;
128
127
  export type AirAuthSignSiweMessageResponseMessage = AirAuthMessageBase<"air_auth_sign_siwe_message_response", AirAuthSignSiweMessageResponsePayload>;
128
+ export type AirAuthCrossPartnerTokenRequestMessage = AirAuthMessageBase<"air_auth_cross_partner_token_request", AirAuthCrossPartnerTokenRequestPayload>;
129
+ export type AirAuthCrossPartnerTokenResponseMessage = AirAuthMessageBase<"air_auth_cross_partner_token_response", AirAuthCrossPartnerTokenSuccessPayload | AirAuthError>;
129
130
  export type AirAuthLogoutRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_logout_request">;
130
131
  export type AirAuthLogoutResponseMessage = AirAuthMessageBaseWithoutPayload<"air_auth_logout_response">;
132
+ export type AirAuthResetWalletCommunicationRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_reset_wallet_communication">;
131
133
  export type AirAuthIframeVisibilityRequestMessage = AirAuthMessageBase<"air_auth_iframe_visibility_request", {
132
134
  visible: boolean;
133
135
  }>;
134
- export type AirAuthMessage = AirAuthSetupCompletedMessage | AirAuthInitializationRequestMessage | AirAuthInitializationResponseMessage | AirAuthLoginRequestMessage | AirAuthLoginResponseToEmbedMessage | AirAuthLoginResponseToWalletServiceMessage | AirAuthPartnerUserInfoRequestMessage | AirAuthPartnerUserInfoResponseMessage | AirAuthRefreshTokenRequestMessage | AirAuthRefreshTokenResponseMessage | AirAuthWalletTokenRequestMessage | AirAuthWalletTokenResponseMessage | AirAuthInitWalletCommunicationMessage | AirAuthSetupWalletRequestMessage | AirAuthSetupWalletResponseMessage | AirAuthSignSiweMessageRequestMessage | AirAuthSignSiweMessageResponseMessage | AirAuthLogoutRequestMessage | AirAuthLogoutResponseMessage | AirAuthIframeVisibilityRequestMessage;
136
+ export type AirAuthMessage = AirAuthSetupCompletedMessage | AirAuthInitializationRequestMessage | AirAuthInitializationResponseMessage | AirAuthLoginRequestMessage | AirAuthLoginResponseToEmbedMessage | AirAuthLoginResponseToWalletServiceMessage | AirAuthUserInfoRequestMessage | AirAuthUserInfoResponseMessage | AirAuthPartnerUserInfoRequestMessage | AirAuthPartnerUserInfoResponseMessage | AirAuthRefreshTokenRequestMessage | AirAuthRefreshTokenResponseMessage | AirAuthWalletTokenRequestMessage | AirAuthWalletTokenResponseMessage | AirAuthInitWalletCommunicationMessage | AirAuthSetupWalletRequestMessage | AirAuthSetupWalletResponseMessage | AirAuthSignSiweMessageRequestMessage | AirAuthSignSiweMessageResponseMessage | AirAuthCrossPartnerTokenRequestMessage | AirAuthCrossPartnerTokenResponseMessage | AirAuthLogoutRequestMessage | AirAuthLogoutResponseMessage | AirAuthIframeVisibilityRequestMessage | AirAuthResetWalletCommunicationRequestMessage;
135
137
  export {};
@@ -1,7 +1,8 @@
1
- import { EIP1193Request } from "../../provider/types";
1
+ import { EIP1193Request, EIP1193EventMap } from "../../provider/types";
2
2
  export declare const enum AirWalletProviderMessageTypes {
3
3
  REQUEST = "JRPC_REQUEST",
4
- RESPONSE = "JRPC_RESPONSE"
4
+ RESPONSE = "JRPC_RESPONSE",
5
+ EVENT = "JRPC_EVENT"
5
6
  }
6
7
  export type AirWalletProviderMessageRequest = {
7
8
  type: AirWalletProviderMessageTypes.REQUEST;
@@ -29,4 +30,21 @@ export type AirWalletProviderMessageErrorResponse = {
29
30
  };
30
31
  };
31
32
  export type AirWalletProviderMessageResponse = AirWalletProviderMessageSuccessResponse | AirWalletProviderMessageErrorResponse;
32
- export type AirWalletProviderMessage = AirWalletProviderMessageRequest | AirWalletProviderMessageResponse;
33
+ export type AirWalletProviderMessageBaseEvent<T extends keyof EIP1193EventMap, TPayload> = {
34
+ type: AirWalletProviderMessageTypes.EVENT;
35
+ payload: {
36
+ event: T;
37
+ data: TPayload;
38
+ };
39
+ };
40
+ export type AirWalletProviderMessageEvent = AirWalletProviderMessageBaseEvent<"accountsChanged", string[]> | AirWalletProviderMessageBaseEvent<"chainChanged", string> | AirWalletProviderMessageBaseEvent<"connect", {
41
+ chainId: string;
42
+ }> | AirWalletProviderMessageBaseEvent<"disconnect", {
43
+ code: number;
44
+ name: string;
45
+ message: string;
46
+ }> | AirWalletProviderMessageBaseEvent<"message", {
47
+ type: string;
48
+ data: unknown;
49
+ }>;
50
+ export type AirWalletProviderMessage = AirWalletProviderMessageRequest | AirWalletProviderMessageResponse | AirWalletProviderMessageEvent;
@@ -1,7 +1,7 @@
1
1
  import type { Hex } from "viem";
2
- import { AirErrorName } from "../../air/error";
3
2
  import { ActionPolicyInfo, Call } from "../smart-session/types";
4
- import { AirIdDetails } from "../user/types";
3
+ import { AirIdDetails, MFASetup } from "../user/types";
4
+ import { AirErrorName } from "../../air/error/types";
5
5
  export declare const AirMessageTypes: {
6
6
  readonly SERVICE_STARTED: "air_service_started";
7
7
  readonly INITIALIZATION_REQUEST: "air_initialization_request";
@@ -23,6 +23,7 @@ export declare const AirMessageTypes: {
23
23
  readonly IS_SMART_ACCOUNT_DEPLOYED_RESPONSE: "air_is_smart_account_deployed_response";
24
24
  readonly LOGOUT_REQUEST: "air_logout_request";
25
25
  readonly LOGOUT_RESPONSE: "air_logout_response";
26
+ readonly SETUP_MFA_REQUEST: "air_setup_mfa_request";
26
27
  };
27
28
  export type AirMessageType = (typeof AirMessageTypes)[keyof typeof AirMessageTypes];
28
29
  type AirMessageBase<TType extends AirMessageType, TPayload> = {
@@ -45,11 +46,11 @@ export type AirInitializationRequestMessage = AirMessageBase<"air_initialization
45
46
  enableLogging: boolean;
46
47
  }>;
47
48
  export type AirInitializationResponseMessage = AirMessageBase<"air_initialization_response", AirInitializationResponsePayload>;
48
- export type AirWalletInitializationSuccess = {
49
+ export type AirWalletInitializationSuccess = MFASetup & {
49
50
  success: true;
50
51
  addresses: {
51
52
  aa: string;
52
- };
53
+ } | null;
53
54
  };
54
55
  type AirWalletInitializedPayload = AirWalletInitializationSuccess | AirErrorPayload;
55
56
  export type AirWalletInitializedMessage = AirMessageBase<"air_wallet_initialized", AirWalletInitializedPayload>;
@@ -63,7 +64,9 @@ export type AirClaimIdSuccess = {
63
64
  };
64
65
  export type AirClaimIdResponsePayload = AirClaimIdSuccess | AirErrorPayload;
65
66
  export type AirClaimIdResponseMessage = AirMessageBase<"air_claim_id_response", AirClaimIdResponsePayload>;
66
- export type AirInitAuthCommunicationMessage = AirMessageBaseWithoutPayload<"air_init_auth_communication">;
67
+ export type AirInitAuthCommunicationMessage = AirMessageBase<"air_init_auth_communication", {
68
+ skipWalletLogin: boolean;
69
+ }>;
67
70
  export type AirIsSmartAccountDeployedResponseMessage = AirMessageBase<"air_is_smart_account_deployed_response", {
68
71
  success: true;
69
72
  isDeployed: boolean;
@@ -128,5 +131,6 @@ export type AirLogoutResponseMessage = AirMessageBase<"air_logout_response", {
128
131
  errorName: AirErrorName;
129
132
  errorMessage?: string;
130
133
  }>;
131
- export type AirMessage = AirInitializationRequestMessage | AirInitializationResponseMessage | AirWalletInitializedMessage | AirClaimIdRequestMessage | AirClaimIdResponseMessage | AirInitAuthCommunicationMessage | AirIsSmartAccountDeployedRequestMessage | AirIsSmartAccountDeployedResponseMessage | AirDeploySmartAccountRequestMessage | AirDeploySmartAccountResponseMessage | AirGrantPermissionsRequestMessage | AirGrantPermissionsResponseMessage | AirRevokePermissionsRequestMessage | AirRevokePermissionsResponseMessage | AirExecuteActionRequestMessage | AirExecuteActionResponseMessage | AirWalletIframeVisibilityRequestMessage | AirLogoutRequestMessage | AirLogoutResponseMessage;
134
+ export type AirSetupMfaRequestMessage = AirMessageBaseWithoutPayload<"air_setup_mfa_request">;
135
+ export type AirMessage = AirInitializationRequestMessage | AirInitializationResponseMessage | AirWalletInitializedMessage | AirClaimIdRequestMessage | AirClaimIdResponseMessage | AirInitAuthCommunicationMessage | AirIsSmartAccountDeployedRequestMessage | AirIsSmartAccountDeployedResponseMessage | AirDeploySmartAccountRequestMessage | AirDeploySmartAccountResponseMessage | AirGrantPermissionsRequestMessage | AirGrantPermissionsResponseMessage | AirRevokePermissionsRequestMessage | AirRevokePermissionsResponseMessage | AirExecuteActionRequestMessage | AirExecuteActionResponseMessage | AirWalletIframeVisibilityRequestMessage | AirSetupMfaRequestMessage | AirLogoutRequestMessage | AirLogoutResponseMessage;
132
136
  export {};
@@ -4,36 +4,29 @@ export type RealmIdValidation = {
4
4
  maxLength: number;
5
5
  };
6
6
  export type RealmPartnerConfigStyle = {
7
- hideCloseIcon?: boolean;
8
- hideModalOverlay?: boolean;
9
7
  passwordlessButtonVariant?: "inline" | "standalone";
8
+ airLogoTheme?: "default" | "reverse" | "dark_only" | "light_only";
9
+ transactionDetailsExpanded?: boolean;
10
10
  };
11
11
  export declare const REALM_LOGIN_METHODS: readonly ["passwordless", "passwordlessToggle", "google", "wallet", "passkey"];
12
12
  export type RealmLoginMethod = (typeof REALM_LOGIN_METHODS)[number];
13
13
  export type RealmPartnerConfig = {
14
14
  partnerId: string;
15
15
  node: string;
16
- gating: "none" | "jwt" | "invite";
17
- apiUrl: string;
16
+ gating: "none" | "jwt";
18
17
  theme?: string;
19
18
  chainId: string;
20
19
  allowedDomains?: string[];
21
20
  publicKey?: string;
22
21
  jwksUrl?: string;
23
22
  realmIdValidation: RealmIdValidation;
24
- allowConnectOnly: boolean;
25
- cyberConnectAppId?: string;
26
23
  style?: RealmPartnerConfigStyle;
24
+ loginMethods?: RealmLoginMethod[];
27
25
  walletLoginMethods?: RealmLoginWalletId[];
28
- walletSignupMethods?: RealmLoginWalletId[];
29
26
  recommendedWallets?: RealmLoginWalletId[];
30
27
  defaultLanguage?: string;
31
28
  supportedLocales?: string[];
32
- localeUrls?: Record<string, string>;
33
29
  authLocaleUrls?: Record<string, string>;
34
30
  walletLocaleUrls?: Record<string, string>;
35
- sessionTime?: number;
36
- allowSessionIdLogin?: boolean;
37
- loginMethods?: RealmLoginMethod[];
38
- skipPartnerLinkingConfirmation?: boolean;
31
+ allowUnverifiedEmails?: boolean;
39
32
  };
@@ -6,8 +6,8 @@ export type AirIdDetails = {
6
6
  id: string;
7
7
  name?: string;
8
8
  node: string;
9
- status: "not_minted" | "minting" | "minted";
10
- tokenId?: string;
9
+ status: "minting" | "minted";
10
+ chainId: number;
11
11
  imageUrl?: string;
12
12
  };
13
13
  export type GlobalId = {
@@ -26,6 +26,7 @@ type PartnerLinkageRequiredLoginResponse = {
26
26
  };
27
27
  type EmailRequiredLoginResponse = {
28
28
  status: "email_required";
29
+ intentId?: string;
29
30
  };
30
31
  type EmailVerificationRequiredLoginResponse = {
31
32
  status: "email_verification_required";
@@ -34,12 +35,15 @@ type EmailVerificationRequiredLoginResponse = {
34
35
  type LoginRequiredLoginResponse = {
35
36
  status: "login_required";
36
37
  };
38
+ export type MFASetup = {
39
+ isMFASetup: boolean;
40
+ };
37
41
  export type LoginResponse = LoggedInLoginResponse | PartnerLinkageRequiredLoginResponse | EmailRequiredLoginResponse | EmailVerificationRequiredLoginResponse | LoginRequiredLoginResponse;
38
42
  export type UserResponse = {
39
43
  user: GlobalId & {
40
44
  email?: string;
41
45
  airIds: Omit<AirIdDetails, "id">[];
42
- };
46
+ } & MFASetup;
43
47
  };
44
48
  export type PartnerUserResponse = {
45
49
  partnerId: string;
@@ -12,8 +12,6 @@ export interface RealmLoginWallet {
12
12
  export declare const WALLET_MAP: Record<string, RealmLoginWallet>;
13
13
  export declare const WALLET_RDNS_MAP: Record<string, RealmLoginWallet>;
14
14
  export type RealmLoginWalletId = keyof typeof WALLET_MAP;
15
- export declare const DEFAULT_LOGIN_METHODS: Array<RealmLoginWalletId>;
16
- export declare const DEFAULT_SIGNUP_METHODS: Array<RealmLoginWalletId>;
17
15
  export declare const DEFAULT_RECOMMENDED_WALLETS: Array<RealmLoginWalletId>;
18
16
  export type WalletToken = {
19
17
  type: "wallet" | string;
@@ -1,5 +1,6 @@
1
1
  import { AirIdDetails } from "./realm/user/types";
2
- export declare const parseAirId: (airIdDetail?: Omit<AirIdDetails, "id">) => string | undefined;
2
+ export declare const parseAirId: (airIdDetails?: Omit<AirIdDetails, "id">) => string | undefined;
3
+ export declare const includeId: (airIdDetails?: Omit<AirIdDetails, "id">) => AirIdDetails | undefined;
3
4
  export declare function promiseCreator<T>(): {
4
5
  resolve: (value: T | PromiseLike<T>) => void;
5
6
  reject: (reason?: string) => void;