@reown/appkit-controllers 1.7.20-turbo-fix.0 → 1.7.20

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.
Files changed (41) hide show
  1. package/dist/esm/exports/features.js +2 -0
  2. package/dist/esm/exports/features.js.map +1 -0
  3. package/dist/esm/exports/testing.js +17 -0
  4. package/dist/esm/exports/testing.js.map +1 -1
  5. package/dist/esm/src/controllers/BlockchainApiController.js +1 -5
  6. package/dist/esm/src/controllers/BlockchainApiController.js.map +1 -1
  7. package/dist/esm/src/controllers/EventsController.js +6 -1
  8. package/dist/esm/src/controllers/EventsController.js.map +1 -1
  9. package/dist/esm/src/controllers/ExchangeController.js +1 -1
  10. package/dist/esm/src/controllers/ExchangeController.js.map +1 -1
  11. package/dist/esm/src/features/reown-authentication/ReownAuthentication.js +290 -0
  12. package/dist/esm/src/features/reown-authentication/ReownAuthentication.js.map +1 -0
  13. package/dist/esm/src/features/reown-authentication/ReownAuthenticationMessenger.js +55 -0
  14. package/dist/esm/src/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
  15. package/dist/esm/src/features/reown-authentication/index.js +3 -0
  16. package/dist/esm/src/features/reown-authentication/index.js.map +1 -0
  17. package/dist/esm/src/utils/ConstantsUtil.js +6 -3
  18. package/dist/esm/src/utils/ConstantsUtil.js.map +1 -1
  19. package/dist/esm/src/utils/SIWXUtil.js +2 -0
  20. package/dist/esm/src/utils/SIWXUtil.js.map +1 -1
  21. package/dist/esm/tests/controllers/BlockchainApiController.test.js +1 -1
  22. package/dist/esm/tests/controllers/BlockchainApiController.test.js.map +1 -1
  23. package/dist/esm/tests/controllers/ExchangeController.test.js +1 -1
  24. package/dist/esm/tests/controllers/ExchangeController.test.js.map +1 -1
  25. package/dist/esm/tests/features/ReownAuthentication.test.js +911 -0
  26. package/dist/esm/tests/features/ReownAuthentication.test.js.map +1 -0
  27. package/dist/esm/tests/utils/SIWXUtil.test.js +18 -2
  28. package/dist/esm/tests/utils/SIWXUtil.test.js.map +1 -1
  29. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  30. package/dist/types/exports/features.d.ts +1 -0
  31. package/dist/types/exports/testing.d.ts +6 -0
  32. package/dist/types/src/controllers/BlockchainApiController.d.ts +1 -3
  33. package/dist/types/src/controllers/OptionsController.d.ts +3 -1
  34. package/dist/types/src/features/reown-authentication/ReownAuthentication.d.ts +187 -0
  35. package/dist/types/src/features/reown-authentication/ReownAuthenticationMessenger.d.ts +15 -0
  36. package/dist/types/src/features/reown-authentication/index.d.ts +2 -0
  37. package/dist/types/src/utils/ChainControllerUtil.d.ts +1 -1
  38. package/dist/types/src/utils/ConstantsUtil.d.ts +4 -1
  39. package/dist/types/src/utils/TypeUtil.d.ts +15 -1
  40. package/dist/types/tests/features/ReownAuthentication.test.d.ts +1 -0
  41. package/package.json +8 -3
@@ -0,0 +1 @@
1
+ export * from '../src/features/reown-authentication/index.js';
@@ -1,4 +1,5 @@
1
1
  import type { CaipNetwork, ChainNamespace } from '@reown/appkit-common';
2
+ import type { SIWXSession } from '@reown/appkit-controllers';
2
3
  import { type AccountControllerState, type AdapterNetworkState, type ChainAdapter, type ChainControllerState } from '../exports/index.js';
3
4
  export declare const extendedMainnet: CaipNetwork;
4
5
  export declare function mockChainControllerState(state: Partial<Omit<ChainControllerState, 'chains'> & {
@@ -12,3 +13,8 @@ export declare function updateChainsMap(namespace: ChainNamespace, state: Partia
12
13
  networkState?: Partial<AdapterNetworkState>;
13
14
  }): void;
14
15
  export declare function mockAccountControllerState(state: AccountControllerState): void;
16
+ type MockSessionReplaces = {
17
+ [K in keyof SIWXSession]?: Partial<SIWXSession[K]>;
18
+ };
19
+ export declare function mockSession(replaces?: MockSessionReplaces): SIWXSession;
20
+ export {};
@@ -21,9 +21,7 @@ export declare const BlockchainApiController: {
21
21
  http: CaipNetworkId[];
22
22
  ws: CaipNetworkId[];
23
23
  }>;
24
- fetchIdentity({ address, caipNetworkId }: BlockchainApiIdentityRequest & {
25
- caipNetworkId: CaipNetworkId;
26
- }): Promise<BlockchainApiIdentityResponse>;
24
+ fetchIdentity({ address }: BlockchainApiIdentityRequest): Promise<BlockchainApiIdentityResponse>;
27
25
  fetchTransactions({ account, cursor, signal, cache, chainId }: BlockchainApiTransactionsRequest): Promise<BlockchainApiTransactionsResponse | {
28
26
  data: never[];
29
27
  next: undefined;
@@ -1508,6 +1508,7 @@ export declare const OptionsController: {
1508
1508
  readonly walletFeaturesOrder?: readonly WalletFeature[] | undefined;
1509
1509
  readonly collapseWallets?: boolean | undefined;
1510
1510
  readonly pay?: boolean | undefined;
1511
+ readonly reownAuthentication?: boolean | undefined;
1511
1512
  } | undefined;
1512
1513
  readonly siwx?: {
1513
1514
  readonly createMessage: (input: import("../utils/SIWXUtil.js").SIWXMessage.Input) => Promise<import("../utils/SIWXUtil.js").SIWXMessage>;
@@ -1531,7 +1532,7 @@ export declare const OptionsController: {
1531
1532
  */
1532
1533
  | undefined;
1533
1534
  readonly defaultAccountTypes: {
1534
- readonly eip155?: "smartAccount" | "eoa" | undefined;
1535
+ readonly eip155?: "eoa" | "smartAccount" | undefined;
1535
1536
  readonly solana?: "eoa" | undefined;
1536
1537
  readonly bip122?: "payment" | "ordinal" | "stx" | undefined;
1537
1538
  readonly polkadot?: "eoa" | undefined;
@@ -1578,6 +1579,7 @@ export declare const OptionsController: {
1578
1579
  readonly reownBranding?: boolean | undefined;
1579
1580
  readonly multiWallet?: boolean | undefined;
1580
1581
  readonly emailCapture?: boolean | readonly "required"[] | undefined;
1582
+ readonly reownAuthentication?: boolean | undefined;
1581
1583
  readonly payWithExchange?: boolean | undefined;
1582
1584
  readonly payments?: boolean | undefined;
1583
1585
  readonly onramp?: false | readonly "meld"[] | undefined;
@@ -0,0 +1,187 @@
1
+ import { type CaipNetworkId, type ChainNamespace } from '@reown/appkit-common';
2
+ import type { SIWXConfig, SIWXMessage, SIWXSession } from '../../utils/SIWXUtil.js';
3
+ /**
4
+ * This is the configuration for using SIWX with Reown Authentication service.
5
+ * It allows you to authenticate and capture user sessions through the Cloud Dashboard.
6
+ */
7
+ export declare class ReownAuthentication implements SIWXConfig {
8
+ private readonly localAuthStorageKey;
9
+ private readonly localNonceStorageKey;
10
+ private readonly messenger;
11
+ private required;
12
+ private otpUuid;
13
+ private listeners;
14
+ constructor(params?: ReownAuthentication.ConstructorParams);
15
+ createMessage(input: SIWXMessage.Input): Promise<SIWXMessage>;
16
+ addSession(session: SIWXSession): Promise<void>;
17
+ getSessions(chainId: CaipNetworkId, address: string): Promise<SIWXSession[]>;
18
+ revokeSession(_chainId: CaipNetworkId, _address: string): Promise<void>;
19
+ setSessions(sessions: SIWXSession[]): Promise<void>;
20
+ getRequired(): boolean;
21
+ getSessionAccount(): Promise<Omit<ReownAuthentication.SessionAccount, "appKitAccount">>;
22
+ setSessionAccountMetadata(metadata?: object | null): Promise<unknown>;
23
+ on<Event extends keyof ReownAuthentication.Events>(event: Event, callback: ReownAuthentication.Listener<Event>): () => void;
24
+ removeAllListeners(): void;
25
+ requestEmailOtp({ email, account }: {
26
+ email: string;
27
+ account: string;
28
+ }): Promise<{
29
+ uuid: string | null;
30
+ }>;
31
+ confirmEmailOtp({ code }: {
32
+ code: string;
33
+ }): Promise<null>;
34
+ private request;
35
+ private getStorageToken;
36
+ private setStorageToken;
37
+ private clearStorageTokens;
38
+ private getNonce;
39
+ private getClientId;
40
+ private getWalletInfo;
41
+ private getSDKProperties;
42
+ private emit;
43
+ private setAppKitAccountUser;
44
+ }
45
+ export declare namespace ReownAuthentication {
46
+ type ConstructorParams = {
47
+ /**
48
+ * The key to use for storing the session token in local storage.
49
+ * @default '@appkit/siwx-auth-token'
50
+ */
51
+ localAuthStorageKey?: string;
52
+ /**
53
+ * The key to use for storing the nonce token in local storage.
54
+ * @default '@appkit/siwx-nonce-token'
55
+ */
56
+ localNonceStorageKey?: string;
57
+ /**
58
+ * If false the wallet stays connected when user denies the signature request.
59
+ * @default true
60
+ */
61
+ required?: boolean;
62
+ };
63
+ type AvailableRequestHeaders = {
64
+ nonce: {
65
+ 'x-nonce-jwt': string;
66
+ };
67
+ auth: {
68
+ Authorization: string;
69
+ };
70
+ otp: {
71
+ 'x-otp'?: string;
72
+ };
73
+ };
74
+ type RequestParams<Key extends keyof Requests[Method], Method extends Methods> = {
75
+ method: Method;
76
+ key: Key;
77
+ } & Pick<Requests[Method][Key], 'query' | 'body' | 'headers'>;
78
+ type RequestResponse<Method extends Methods, Key extends RequestKeys<Method>> = Requests[Method][Key]['response'];
79
+ type Request<Body, Response, Query extends Record<string, unknown> | undefined = undefined, Headers extends (keyof AvailableRequestHeaders)[] | undefined = undefined> = (Response extends undefined ? {
80
+ response?: never;
81
+ } : {
82
+ response: Response;
83
+ }) & (Body extends undefined ? {
84
+ body?: never;
85
+ } : {
86
+ body: Body;
87
+ }) & (Query extends undefined ? {
88
+ query?: never;
89
+ } : {
90
+ query: Query;
91
+ }) & (Headers extends undefined ? {
92
+ headers?: never;
93
+ } : {
94
+ headers: Headers;
95
+ });
96
+ type Requests = {
97
+ GET: {
98
+ nonce: Request<undefined, {
99
+ nonce: string;
100
+ token: string;
101
+ }>;
102
+ me: Request<undefined, Omit<SessionAccount, 'appKitAccount'>, {
103
+ includeAppKitAccount?: boolean;
104
+ }, [
105
+ 'auth'
106
+ ]>;
107
+ };
108
+ POST: {
109
+ authenticate: Request<{
110
+ data?: SIWXMessage.Data;
111
+ message: string;
112
+ signature: string;
113
+ clientId?: string | null;
114
+ walletInfo?: WalletInfo;
115
+ }, {
116
+ token: string;
117
+ }, undefined, [
118
+ 'nonce',
119
+ 'otp'
120
+ ]>;
121
+ 'sign-out': Request<undefined, never, never, ['auth']>;
122
+ otp: Request<{
123
+ email: string;
124
+ account: string;
125
+ }, {
126
+ uuid: string | null;
127
+ }>;
128
+ };
129
+ PUT: {
130
+ 'account-metadata': Request<{
131
+ metadata: object | null;
132
+ }, unknown, undefined, ['auth']>;
133
+ otp: Request<{
134
+ code: string;
135
+ }, null, undefined, ['otp']>;
136
+ };
137
+ };
138
+ type Methods = 'GET' | 'POST' | 'PUT';
139
+ type RequestKeys<Method extends Methods> = keyof Requests[Method];
140
+ type WalletInfo = {
141
+ type: 'walletconnect' | 'extension' | 'unknown';
142
+ name: string | undefined;
143
+ icon: string | undefined;
144
+ } | {
145
+ type: 'social';
146
+ social: string;
147
+ identifier: string;
148
+ };
149
+ type Events = {
150
+ sessionChanged: SIWXSession | undefined;
151
+ };
152
+ type Listener<Event extends keyof Events> = (event: Events[Event]) => void;
153
+ type EventListeners = {
154
+ [Key in keyof Events]: Listener<Key>[];
155
+ };
156
+ type SessionAccount = {
157
+ aud: string;
158
+ iss: string;
159
+ exp: number;
160
+ projectIdKey: string;
161
+ sub: string;
162
+ address: string;
163
+ chainId: number | string;
164
+ chainNamespace: ChainNamespace;
165
+ caip2Network: string;
166
+ uri: string;
167
+ domain: string;
168
+ projectUuid: string;
169
+ profileUuid: string;
170
+ nonce: string;
171
+ email?: string;
172
+ appKitAccount?: {
173
+ uuid: string;
174
+ caip2_chain: string;
175
+ address: string;
176
+ profile_uuid: string;
177
+ created_at: string;
178
+ is_main_account: boolean;
179
+ verification_status: null;
180
+ connection_method: object | null;
181
+ metadata: object;
182
+ last_signed_in_at: string;
183
+ signed_up_at: string;
184
+ updated_at: string;
185
+ };
186
+ };
187
+ }
@@ -0,0 +1,15 @@
1
+ import type { SIWXMessage } from '../../utils/SIWXUtil.js';
2
+ export declare class ReownAuthenticationMessenger {
3
+ resources?: SIWXMessage['resources'];
4
+ protected getNonce: (params: SIWXMessage.Input) => Promise<SIWXMessage['nonce']>;
5
+ constructor(params: ReownAuthenticationMessenger.ConstructorParams);
6
+ createMessage(input: SIWXMessage.Input): Promise<SIWXMessage>;
7
+ private stringify;
8
+ private getNetworkName;
9
+ private stringifyDate;
10
+ }
11
+ export declare namespace ReownAuthenticationMessenger {
12
+ interface ConstructorParams {
13
+ getNonce: (params: SIWXMessage.Input) => Promise<SIWXMessage['nonce']>;
14
+ }
15
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ReownAuthentication.js';
2
+ export * from './ReownAuthenticationMessenger.js';
@@ -17,7 +17,7 @@ export declare function getActiveNetworkTokenAddress(): string;
17
17
  * @param namespace - The namespace of the account
18
18
  * @returns The preferred account type
19
19
  */
20
- export declare function getPreferredAccountType(namespace: ChainNamespace | undefined): "payment" | "ordinal" | "stx" | "smartAccount" | "eoa" | undefined;
20
+ export declare function getPreferredAccountType(namespace: ChainNamespace | undefined): "eoa" | "smartAccount" | "payment" | "ordinal" | "stx" | undefined;
21
21
  /**
22
22
  * Get the active CAIP network for a given chain namespace, if no namespace is provided, it returns the active CAIP network
23
23
  * @param chainNamespace - The chain namespace to get the active CAIP network for
@@ -50,6 +50,7 @@ export declare const ConstantsUtil: {
50
50
  emailCapture: boolean;
51
51
  payWithExchange: boolean;
52
52
  payments: boolean;
53
+ reownAuthentication: boolean;
53
54
  };
54
55
  DEFAULT_REMOTE_FEATURES_DISABLED: {
55
56
  readonly email: false;
@@ -59,12 +60,13 @@ export declare const ConstantsUtil: {
59
60
  readonly activity: false;
60
61
  readonly reownBranding: false;
61
62
  readonly emailCapture: false;
63
+ readonly reownAuthentication: false;
62
64
  };
63
65
  DEFAULT_FEATURES: {
64
66
  receive: true;
65
67
  send: true;
66
68
  emailShowWallets: true;
67
- connectorTypeOrder: ("walletConnect" | "recent" | "injected" | "featured" | "custom" | "external" | "recommended")[];
69
+ connectorTypeOrder: ("custom" | "walletConnect" | "recent" | "injected" | "featured" | "external" | "recommended")[];
68
70
  analytics: true;
69
71
  allWallets: true;
70
72
  legalCheckbox: false;
@@ -73,6 +75,7 @@ export declare const ConstantsUtil: {
73
75
  walletFeaturesOrder: ("swaps" | "onramp" | "receive" | "send")[];
74
76
  connectMethodsOrder: undefined;
75
77
  pay: false;
78
+ reownAuthentication: false;
76
79
  };
77
80
  DEFAULT_SOCIALS: SocialProvider[];
78
81
  DEFAULT_ACCOUNT_TYPES: {
@@ -345,6 +345,7 @@ export type Event = {
345
345
  properties: {
346
346
  method: 'qrcode' | 'mobile' | 'browser' | 'email';
347
347
  name: string;
348
+ reconnect?: boolean;
348
349
  };
349
350
  } | {
350
351
  type: 'track';
@@ -606,6 +607,7 @@ export type Event = {
606
607
  event: 'SOCIAL_LOGIN_SUCCESS';
607
608
  properties: {
608
609
  provider: SocialProvider;
610
+ reconnect?: boolean;
609
611
  };
610
612
  } | {
611
613
  type: 'track';
@@ -971,6 +973,7 @@ export type RemoteFeatures = {
971
973
  reownBranding?: boolean;
972
974
  multiWallet?: boolean;
973
975
  emailCapture?: EmailCaptureOptions[] | boolean;
976
+ reownAuthentication?: boolean;
974
977
  payWithExchange?: boolean;
975
978
  payments?: boolean;
976
979
  onramp?: OnRampProvider[] | false;
@@ -1067,6 +1070,11 @@ export type Features = {
1067
1070
  * @type {boolean}
1068
1071
  */
1069
1072
  pay?: boolean;
1073
+ /**
1074
+ * @description Enable or disable the ReownAuthentication SIWX feature. Disabled by default.
1075
+ * @type {boolean}
1076
+ */
1077
+ reownAuthentication?: boolean;
1070
1078
  };
1071
1079
  export type FeaturesKeys = Exclude<keyof Features, 'swaps' | 'onramp' | 'email' | 'socials' | 'history'>;
1072
1080
  export type WalletGuideType = 'get-started' | 'explore';
@@ -1098,7 +1106,7 @@ export type ConnectionStatus = 'connected' | 'disconnected' | 'connecting' | 're
1098
1106
  export type PreferredAccountTypes = {
1099
1107
  [Key in keyof NamespaceTypeMap]?: NamespaceTypeMap[Key];
1100
1108
  };
1101
- export type FeatureID = 'multi_wallet' | 'activity' | 'onramp' | 'swap' | 'social_login' | 'reown_branding' | 'email_capture' | 'fund_from_exchange' | 'payments';
1109
+ export type FeatureID = 'multi_wallet' | 'activity' | 'onramp' | 'swap' | 'social_login' | 'reown_branding' | 'email_capture' | 'fund_from_exchange' | 'payments' | 'reown_authentication';
1102
1110
  export interface BaseFeature<T extends FeatureID, C extends string[] | null> {
1103
1111
  id: T;
1104
1112
  isEnabled: boolean;
@@ -1169,6 +1177,12 @@ export type FeatureConfigMap = {
1169
1177
  returnType: boolean;
1170
1178
  isLegacy: false;
1171
1179
  };
1180
+ reownAuthentication: {
1181
+ apiFeatureName: 'reown_authentication';
1182
+ localFeatureName: 'reownAuthentication';
1183
+ returnType: boolean;
1184
+ isLegacy: false;
1185
+ };
1172
1186
  };
1173
1187
  export type FeatureKey = keyof FeatureConfigMap;
1174
1188
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reown/appkit-controllers",
3
- "version": "1.7.20-turbo-fix.0",
3
+ "version": "1.7.20",
4
4
  "sideEffects": false,
5
5
  "type": "module",
6
6
  "main": "./dist/esm/exports/index.js",
@@ -35,6 +35,11 @@
35
35
  "types": "./dist/types/exports/testing.d.ts",
36
36
  "import": "./dist/esm/exports/testing.js",
37
37
  "default": "./dist/esm/exports/testing.js"
38
+ },
39
+ "./features": {
40
+ "types": "./dist/types/exports/features.d.ts",
41
+ "import": "./dist/esm/exports/features.js",
42
+ "default": "./dist/esm/exports/features.js"
38
43
  }
39
44
  },
40
45
  "typesVersions": {
@@ -51,8 +56,8 @@
51
56
  "@walletconnect/universal-provider": "2.21.7",
52
57
  "valtio": "2.1.5",
53
58
  "viem": ">=2.33.3",
54
- "@reown/appkit-common": "1.7.20-turbo-fix.0",
55
- "@reown/appkit-wallet": "1.7.20-turbo-fix.0"
59
+ "@reown/appkit-common": "1.7.20",
60
+ "@reown/appkit-wallet": "1.7.20"
56
61
  },
57
62
  "devDependencies": {
58
63
  "@vitest/coverage-v8": "2.1.9",