@reown/appkit-common-react-native 2.0.0-alpha.4 → 2.0.0-alpha.6
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/lib/commonjs/adapters/BitcoinBaseAdapter.js +10 -0
- package/lib/commonjs/adapters/BitcoinBaseAdapter.js.map +1 -0
- package/lib/commonjs/adapters/EvmAdapter.js +2 -2
- package/lib/commonjs/adapters/EvmAdapter.js.map +1 -1
- package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -1
- package/lib/commonjs/index.js +9 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/index.js +4 -4
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/{siwe → siwx}/config.js.map +1 -1
- package/lib/commonjs/types/{siwe → siwx}/index.js +22 -0
- package/lib/commonjs/types/siwx/index.js.map +1 -0
- package/lib/commonjs/types/{siwe → siwx}/message.js.map +1 -1
- package/lib/commonjs/types/siwx/storage.js +6 -0
- package/lib/commonjs/types/siwx/storage.js.map +1 -0
- package/lib/commonjs/types/siwx/verifier.js +35 -0
- package/lib/commonjs/types/siwx/verifier.js.map +1 -0
- package/lib/commonjs/types/storage.js +22 -0
- package/lib/commonjs/types/storage.js.map +1 -1
- package/lib/commonjs/types/wallet/connector.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +10 -17
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/adapters/BitcoinBaseAdapter.js +5 -0
- package/lib/module/adapters/BitcoinBaseAdapter.js.map +1 -0
- package/lib/module/adapters/EvmAdapter.js +2 -2
- package/lib/module/adapters/EvmAdapter.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/index.js +2 -2
- package/lib/module/types/{siwe → siwx}/config.js.map +1 -1
- package/lib/module/types/siwx/index.js +7 -0
- package/lib/module/types/siwx/index.js.map +1 -0
- package/lib/module/types/{siwe → siwx}/message.js.map +1 -1
- package/lib/module/types/siwx/storage.js +4 -0
- package/lib/module/types/siwx/storage.js.map +1 -0
- package/lib/module/types/siwx/verifier.js +30 -0
- package/lib/module/types/siwx/verifier.js.map +1 -0
- package/lib/module/types/storage.js +18 -0
- package/lib/module/types/storage.js.map +1 -1
- package/lib/module/types/wallet/connector.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +10 -17
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/typescript/adapters/BitcoinBaseAdapter.d.ts +5 -0
- package/lib/typescript/adapters/BitcoinBaseAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts +1 -1
- package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -1
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +1 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/api/events.d.ts +7 -5
- package/lib/typescript/types/api/events.d.ts.map +1 -1
- package/lib/typescript/types/api/wallet-api.d.ts +1 -0
- package/lib/typescript/types/api/wallet-api.d.ts.map +1 -1
- package/lib/typescript/types/blockchain/balance.d.ts +1 -1
- package/lib/typescript/types/blockchain/balance.d.ts.map +1 -1
- package/lib/typescript/types/blockchain/network.d.ts +1 -1
- package/lib/typescript/types/blockchain/network.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +1 -1
- package/lib/typescript/types/siwx/config.d.ts +73 -0
- package/lib/typescript/types/siwx/config.d.ts.map +1 -0
- package/lib/typescript/types/siwx/index.d.ts +5 -0
- package/lib/typescript/types/siwx/index.d.ts.map +1 -0
- package/lib/typescript/types/siwx/message.d.ts +92 -0
- package/lib/typescript/types/siwx/message.d.ts.map +1 -0
- package/lib/typescript/types/siwx/storage.d.ts +41 -0
- package/lib/typescript/types/siwx/storage.d.ts.map +1 -0
- package/lib/typescript/types/siwx/verifier.d.ts +28 -0
- package/lib/typescript/types/siwx/verifier.d.ts.map +1 -0
- package/lib/typescript/types/storage.d.ts +32 -0
- package/lib/typescript/types/storage.d.ts.map +1 -1
- package/lib/typescript/types/wallet/connection.d.ts +1 -0
- package/lib/typescript/types/wallet/connection.d.ts.map +1 -1
- package/lib/typescript/types/wallet/connector.d.ts +0 -2
- package/lib/typescript/types/wallet/connector.d.ts.map +1 -1
- package/lib/typescript/types/wallet/wallet-info.d.ts +1 -0
- package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +9 -14
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/adapters/BitcoinBaseAdapter.ts +5 -0
- package/src/adapters/EvmAdapter.ts +2 -2
- package/src/adapters/SolanaBaseAdapter.ts +1 -0
- package/src/index.ts +1 -0
- package/src/types/api/events.ts +9 -8
- package/src/types/api/wallet-api.ts +1 -0
- package/src/types/blockchain/balance.ts +1 -1
- package/src/types/blockchain/network.ts +1 -1
- package/src/types/index.ts +2 -2
- package/src/types/siwx/config.ts +73 -0
- package/src/types/siwx/index.ts +4 -0
- package/src/types/siwx/message.ts +92 -0
- package/src/types/siwx/storage.ts +44 -0
- package/src/types/siwx/verifier.ts +32 -0
- package/src/types/storage.ts +34 -0
- package/src/types/wallet/connection.ts +1 -0
- package/src/types/wallet/connector.ts +0 -2
- package/src/types/wallet/wallet-info.ts +1 -0
- package/src/utils/ConstantsUtil.ts +11 -17
- package/lib/commonjs/types/siwe/index.js.map +0 -1
- package/lib/module/types/siwe/index.js +0 -6
- package/lib/module/types/siwe/index.js.map +0 -1
- package/lib/typescript/types/siwe/config.d.ts +0 -31
- package/lib/typescript/types/siwe/config.d.ts.map +0 -1
- package/lib/typescript/types/siwe/index.d.ts +0 -3
- package/lib/typescript/types/siwe/index.d.ts.map +0 -1
- package/lib/typescript/types/siwe/message.d.ts +0 -57
- package/lib/typescript/types/siwe/message.d.ts.map +0 -1
- package/src/types/siwe/config.ts +0 -44
- package/src/types/siwe/index.ts +0 -3
- package/src/types/siwe/message.ts +0 -62
- /package/lib/commonjs/types/{siwe → siwx}/config.js +0 -0
- /package/lib/commonjs/types/{siwe → siwx}/message.js +0 -0
- /package/lib/module/types/{siwe → siwx}/config.js +0 -0
- /package/lib/module/types/{siwe → siwx}/message.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-common-react-native",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.6",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"types": "lib/typescript/index.d.ts",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -35,13 +35,14 @@
|
|
|
35
35
|
"repository": "https://github.com/reown-com/appkit-react-native",
|
|
36
36
|
"author": "Reown (https://discord.gg/reown)",
|
|
37
37
|
"homepage": "https://reown.com/appkit",
|
|
38
|
-
"license": "
|
|
38
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
39
39
|
"bugs": {
|
|
40
40
|
"url": "https://github.com/reown-com/appkit-react-native/issues"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"registry": "https://registry.npmjs.org/",
|
|
44
|
-
"access": "public"
|
|
44
|
+
"access": "public",
|
|
45
|
+
"provenance": true
|
|
45
46
|
},
|
|
46
47
|
"eslintIgnore": [
|
|
47
48
|
"node_modules/",
|
|
@@ -71,7 +71,7 @@ function encodeERC20Function(method: string, params: any[]): string {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export abstract class EVMAdapter extends BlockchainAdapter {
|
|
74
|
-
async signMessage(address: string, message: string,
|
|
74
|
+
async signMessage(address: string, message: string, chainId?: string): Promise<string> {
|
|
75
75
|
const provider = this.getProvider();
|
|
76
76
|
|
|
77
77
|
if (!provider) {
|
|
@@ -83,7 +83,7 @@ export abstract class EVMAdapter extends BlockchainAdapter {
|
|
|
83
83
|
method: 'personal_sign',
|
|
84
84
|
params: [message, address]
|
|
85
85
|
},
|
|
86
|
-
`eip155:${
|
|
86
|
+
`eip155:${chainId}`
|
|
87
87
|
);
|
|
88
88
|
|
|
89
89
|
return signature as string;
|
|
@@ -3,4 +3,5 @@ import { BlockchainAdapter } from './BlockchainAdapter';
|
|
|
3
3
|
export abstract class SolanaBaseAdapter extends BlockchainAdapter {
|
|
4
4
|
abstract signTransaction(data: any): Promise<string | null>;
|
|
5
5
|
abstract sendTransaction(data: any): Promise<string | null>;
|
|
6
|
+
abstract signMessage(address: string, message: string, chainId?: string): Promise<string>;
|
|
6
7
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,5 +13,6 @@ export { bitcoin, bitcoinTestnet } from './networks/bitcoin';
|
|
|
13
13
|
export { BlockchainAdapter } from './adapters/BlockchainAdapter';
|
|
14
14
|
export { EVMAdapter } from './adapters/EvmAdapter';
|
|
15
15
|
export { SolanaBaseAdapter } from './adapters/SolanaBaseAdapter';
|
|
16
|
+
export { BitcoinBaseAdapter } from './adapters/BitcoinBaseAdapter';
|
|
16
17
|
|
|
17
18
|
export * from './types';
|
package/src/types/api/events.ts
CHANGED
|
@@ -21,10 +21,9 @@ export type EventName =
|
|
|
21
21
|
| 'EMAIL_EDIT'
|
|
22
22
|
| 'EMAIL_EDIT_COMPLETE'
|
|
23
23
|
| 'EMAIL_UPGRADE_FROM_MODAL'
|
|
24
|
-
| '
|
|
25
|
-
| '
|
|
26
|
-
| '
|
|
27
|
-
| 'SIWE_AUTH_ERROR'
|
|
24
|
+
| 'SIWX_AUTH_SUCCESS'
|
|
25
|
+
| 'SIWX_AUTH_ERROR'
|
|
26
|
+
| 'CLICK_CANCEL_SIWX'
|
|
28
27
|
| 'CLICK_TRANSACTIONS'
|
|
29
28
|
| 'ERROR_FETCH_TRANSACTIONS'
|
|
30
29
|
| 'LOAD_MORE_TRANSACTIONS'
|
|
@@ -152,7 +151,8 @@ export type Event =
|
|
|
152
151
|
}
|
|
153
152
|
| {
|
|
154
153
|
type: 'track';
|
|
155
|
-
|
|
154
|
+
address?: string;
|
|
155
|
+
event: 'CLICK_SIGN_SIWX_MESSAGE';
|
|
156
156
|
properties: {
|
|
157
157
|
network: string;
|
|
158
158
|
isSmartAccount: boolean;
|
|
@@ -160,7 +160,7 @@ export type Event =
|
|
|
160
160
|
}
|
|
161
161
|
| {
|
|
162
162
|
type: 'track';
|
|
163
|
-
event: '
|
|
163
|
+
event: 'CLICK_CANCEL_SIWX';
|
|
164
164
|
properties: {
|
|
165
165
|
network: string;
|
|
166
166
|
isSmartAccount: boolean;
|
|
@@ -168,7 +168,7 @@ export type Event =
|
|
|
168
168
|
}
|
|
169
169
|
| {
|
|
170
170
|
type: 'track';
|
|
171
|
-
event: '
|
|
171
|
+
event: 'SIWX_AUTH_SUCCESS';
|
|
172
172
|
properties: {
|
|
173
173
|
network: string;
|
|
174
174
|
isSmartAccount: boolean;
|
|
@@ -176,10 +176,11 @@ export type Event =
|
|
|
176
176
|
}
|
|
177
177
|
| {
|
|
178
178
|
type: 'track';
|
|
179
|
-
event: '
|
|
179
|
+
event: 'SIWX_AUTH_ERROR';
|
|
180
180
|
properties: {
|
|
181
181
|
network: string;
|
|
182
182
|
isSmartAccount: boolean;
|
|
183
|
+
message?: string;
|
|
183
184
|
};
|
|
184
185
|
}
|
|
185
186
|
| {
|
|
@@ -11,7 +11,7 @@ export interface Balance {
|
|
|
11
11
|
numeric: string;
|
|
12
12
|
};
|
|
13
13
|
chainId?: string;
|
|
14
|
-
address?: CaipAddress; // contract address
|
|
14
|
+
address?: CaipAddress | string; // contract address
|
|
15
15
|
value?: number; //total value of the amount in currency
|
|
16
16
|
price?: number; //price of the token in currency
|
|
17
17
|
iconUrl?: string;
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { CaipNetworkId } from '../common';
|
|
2
|
+
import type { SIWXSession, SIWXMessage } from './message';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This interface represents the SIWX configuration plugin, which is used to create and manage SIWX messages and sessions.
|
|
6
|
+
* You may use it to create a custom implementation following your needs, but watch close for the methods requirements.
|
|
7
|
+
*/
|
|
8
|
+
export interface SIWXConfig {
|
|
9
|
+
/**
|
|
10
|
+
* This method will be called to create a new message to be signed by the user.
|
|
11
|
+
*
|
|
12
|
+
* Constraints:
|
|
13
|
+
* - The message MUST be unique and contain all the necessary information to verify the user's identity.
|
|
14
|
+
* - SIWXMessage.toString() method MUST be implemented to return the message string.
|
|
15
|
+
*
|
|
16
|
+
* @param input SIWXMessage.Input
|
|
17
|
+
* @returns SIWXMessage
|
|
18
|
+
*/
|
|
19
|
+
createMessage: (input: SIWXMessage.Input) => Promise<SIWXMessage>;
|
|
20
|
+
/**
|
|
21
|
+
* This method will be called to store a new single session.
|
|
22
|
+
*
|
|
23
|
+
* Constraints:
|
|
24
|
+
* - This method MUST verify if the session is valid and store it in the storage successfully.
|
|
25
|
+
*
|
|
26
|
+
* @param session SIWXSession
|
|
27
|
+
*/
|
|
28
|
+
addSession: (session: SIWXSession) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* This method will be called to revoke all the sessions stored for a specific chain and address.
|
|
31
|
+
*
|
|
32
|
+
* Constraints:
|
|
33
|
+
* - This method MUST delete all the sessions stored for the specific chain and address successfully.
|
|
34
|
+
*
|
|
35
|
+
* @param chainId CaipNetworkId
|
|
36
|
+
* @param address string
|
|
37
|
+
*/
|
|
38
|
+
revokeSession: (chainId: CaipNetworkId, address: string) => Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* This method will be called to replace all the sessions in the storage with the new ones.
|
|
41
|
+
*
|
|
42
|
+
* Constraints:
|
|
43
|
+
* - This method MUST verify all the sessions before storing them in the storage;
|
|
44
|
+
* - This method MUST replace all the sessions in the storage with the new ones succesfully otherwise it MUST throw an error.
|
|
45
|
+
*
|
|
46
|
+
* @param sessions SIWXSession[]
|
|
47
|
+
*/
|
|
48
|
+
setSessions: (sessions: SIWXSession[]) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* This method will be called to get all the sessions stored for a specific chain and address.
|
|
51
|
+
*
|
|
52
|
+
* Constraints:
|
|
53
|
+
* - This method MUST return only sessions that are verified and valid;
|
|
54
|
+
* - This method MUST NOT return expired sessions.
|
|
55
|
+
*
|
|
56
|
+
* @param chainId CaipNetworkId
|
|
57
|
+
* @param address string
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
getSessions: (chainId: CaipNetworkId, address: string) => Promise<SIWXSession[]>;
|
|
61
|
+
/**
|
|
62
|
+
* This method determines whether the wallet stays connected when the user denies the signature request.
|
|
63
|
+
*
|
|
64
|
+
* @returns {boolean}
|
|
65
|
+
*/
|
|
66
|
+
getRequired?: () => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* This flag determines whether the session should be cleared when the user disconnects.
|
|
69
|
+
*
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
signOutOnDisconnect?: boolean;
|
|
73
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { CaipNetworkId } from '../common';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This interface represents a SIWX session, which is used to store the user's identity information.
|
|
5
|
+
*/
|
|
6
|
+
export interface SIWXSession {
|
|
7
|
+
data: SIWXMessage.Data;
|
|
8
|
+
message: string;
|
|
9
|
+
signature: string;
|
|
10
|
+
cacao?: Cacao;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* This interface represents a SIWX message, which is used to create a message to be signed by the user.
|
|
14
|
+
* This must contain the necessary information to verify the user's identity and how to generate the string message.
|
|
15
|
+
*/
|
|
16
|
+
export interface SIWXMessage extends SIWXMessage.Data, SIWXMessage.Methods {}
|
|
17
|
+
export declare namespace SIWXMessage {
|
|
18
|
+
/**
|
|
19
|
+
* This interface represents the SIWX message data, which is used to create a message to be signed by the user.
|
|
20
|
+
*/
|
|
21
|
+
interface Data extends Input, Metadata, Identifier {}
|
|
22
|
+
/**
|
|
23
|
+
* This interface represents the SIWX message input.
|
|
24
|
+
* Here must contain what is different for each user of the application.
|
|
25
|
+
*/
|
|
26
|
+
interface Input {
|
|
27
|
+
accountAddress: string;
|
|
28
|
+
chainId: CaipNetworkId;
|
|
29
|
+
notBefore?: Timestamp;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* This interface represents the SIWX message metadata.
|
|
33
|
+
* Here must contain the main data related to the app.
|
|
34
|
+
*/
|
|
35
|
+
interface Metadata {
|
|
36
|
+
domain: string;
|
|
37
|
+
uri: string;
|
|
38
|
+
version: string;
|
|
39
|
+
nonce: string;
|
|
40
|
+
statement?: string;
|
|
41
|
+
resources?: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* This interface represents the SIWX message identifier.
|
|
45
|
+
* Here must contain the request id and the timestamps.
|
|
46
|
+
*/
|
|
47
|
+
interface Identifier {
|
|
48
|
+
requestId?: string;
|
|
49
|
+
issuedAt?: Timestamp;
|
|
50
|
+
expirationTime?: Timestamp;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* This interface represents the SIWX message methods.
|
|
54
|
+
* Here must contain the method to generate the message string and any other method performed by the SIWX message.
|
|
55
|
+
*/
|
|
56
|
+
interface Methods {
|
|
57
|
+
toString: () => string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The timestamp is a UTC string representing the time in ISO 8601 format.
|
|
61
|
+
*/
|
|
62
|
+
type Timestamp = string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface CacaoHeader {
|
|
66
|
+
t: 'caip122';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface CacaoPayload {
|
|
70
|
+
domain: string;
|
|
71
|
+
aud: string;
|
|
72
|
+
nonce: string;
|
|
73
|
+
iss: string;
|
|
74
|
+
version?: string;
|
|
75
|
+
iat?: string;
|
|
76
|
+
nbf?: string;
|
|
77
|
+
exp?: string;
|
|
78
|
+
statement?: string;
|
|
79
|
+
requestId?: string;
|
|
80
|
+
resources?: string[];
|
|
81
|
+
type?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface Cacao {
|
|
85
|
+
h: CacaoHeader;
|
|
86
|
+
p: CacaoPayload;
|
|
87
|
+
s: {
|
|
88
|
+
t: 'eip191' | 'eip1271';
|
|
89
|
+
s: string;
|
|
90
|
+
m?: string;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CaipNetworkId } from '../common';
|
|
2
|
+
import type { SIWXSession } from './message';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This is the interface for a SIWX storage.
|
|
6
|
+
*/
|
|
7
|
+
export interface SIWXStorage {
|
|
8
|
+
/**
|
|
9
|
+
* Adds a new session for the storage.
|
|
10
|
+
* This method should not verify the session, only store it.
|
|
11
|
+
*
|
|
12
|
+
* @param session SIWXSession
|
|
13
|
+
* @returns Promise<void>
|
|
14
|
+
*/
|
|
15
|
+
add(session: SIWXSession): Promise<void>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a session from the storage.
|
|
19
|
+
*
|
|
20
|
+
* @param chainId CaipNetworkId
|
|
21
|
+
* @param address string
|
|
22
|
+
* @returns Promise<void>
|
|
23
|
+
*/
|
|
24
|
+
delete(chainId: CaipNetworkId, address: string): Promise<void>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Gets a list of sessions for a given chainId and address.
|
|
28
|
+
* This method should not verify sessions, only return the sessions that are stored.
|
|
29
|
+
*
|
|
30
|
+
* @param chainId CaipNetworkId
|
|
31
|
+
* @param address string
|
|
32
|
+
* @returns Promise<SIWXSession[]>
|
|
33
|
+
*/
|
|
34
|
+
get(chainId: CaipNetworkId, address: string): Promise<SIWXSession[]>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Replaces the current sessions with the new list of sessions.
|
|
38
|
+
* This method should not verify sessions, only store them.
|
|
39
|
+
*
|
|
40
|
+
* @param sessions SIWXSession[]
|
|
41
|
+
* @returns Promise<void>
|
|
42
|
+
*/
|
|
43
|
+
set(sessions: SIWXSession[]): Promise<void>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ChainNamespace } from '../common';
|
|
2
|
+
import type { SIWXSession } from './message';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This is the base class for a SIWX verifier.
|
|
6
|
+
*/
|
|
7
|
+
export abstract class SIWXVerifier {
|
|
8
|
+
/**
|
|
9
|
+
* The chain namespace that this verifier should verify.
|
|
10
|
+
*/
|
|
11
|
+
public abstract readonly chainNamespace: ChainNamespace;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This method should return true if the verifier should verify the session.
|
|
15
|
+
* By default it will check by the chain namespace, but you may override it for a specific requirement.
|
|
16
|
+
*
|
|
17
|
+
* @param session SIWXSession
|
|
18
|
+
* @returns boolean
|
|
19
|
+
*/
|
|
20
|
+
public shouldVerify(session: SIWXSession): boolean {
|
|
21
|
+
return session.data.chainId.startsWith(this.chainNamespace);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This method should verify the session.
|
|
26
|
+
* You must implement this method with the verification logic.
|
|
27
|
+
*
|
|
28
|
+
* @param session SIWXSession
|
|
29
|
+
* @returns Promise<boolean> - If `true` means the session is valid.
|
|
30
|
+
*/
|
|
31
|
+
abstract verify(session: SIWXSession): Promise<boolean>;
|
|
32
|
+
}
|
package/src/types/storage.ts
CHANGED
|
@@ -28,3 +28,37 @@ export interface Storage {
|
|
|
28
28
|
*/
|
|
29
29
|
removeItem(key: string): Promise<void>;
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
export interface SafeStorageItems {
|
|
33
|
+
'WALLETCONNECT_DEEPLINK_CHOICE': string; //dont change this one
|
|
34
|
+
'@appkit/recent_wallet': string;
|
|
35
|
+
'@appkit/connected_connectors': string;
|
|
36
|
+
'@appkit/onramp_preferred_country': string;
|
|
37
|
+
'@appkit/onramp_countries': string;
|
|
38
|
+
'@appkit/onramp_service_providers': string;
|
|
39
|
+
'@appkit/onramp_fiat_limits': string;
|
|
40
|
+
'@appkit/onramp_fiat_currencies': string;
|
|
41
|
+
'@appkit/onramp_preferred_fiat_currency': string;
|
|
42
|
+
'@appkit/onramp_countries_defaults': string;
|
|
43
|
+
'@appkit/active_namespace': string;
|
|
44
|
+
'@appkit/coinbase_connector/session': string;
|
|
45
|
+
'@appkit/siwx-auth-token': string;
|
|
46
|
+
'@appkit/siwx-nonce-token': string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const SafeStorageKeys = {
|
|
50
|
+
WC_DEEPLINK: 'WALLETCONNECT_DEEPLINK_CHOICE', //dont change this one
|
|
51
|
+
RECENT_WALLET: '@appkit/recent_wallet',
|
|
52
|
+
CONNECTED_CONNECTORS: '@appkit/connected_connectors',
|
|
53
|
+
ONRAMP_PREFERRED_COUNTRY: '@appkit/onramp_preferred_country',
|
|
54
|
+
ONRAMP_COUNTRIES: '@appkit/onramp_countries',
|
|
55
|
+
ONRAMP_SERVICE_PROVIDERS: '@appkit/onramp_service_providers',
|
|
56
|
+
ONRAMP_FIAT_LIMITS: '@appkit/onramp_fiat_limits',
|
|
57
|
+
ONRAMP_FIAT_CURRENCIES: '@appkit/onramp_fiat_currencies',
|
|
58
|
+
ONRAMP_PREFERRED_FIAT_CURRENCY: '@appkit/onramp_preferred_fiat_currency',
|
|
59
|
+
ONRAMP_COUNTRIES_DEFAULTS: '@appkit/onramp_countries_defaults',
|
|
60
|
+
ACTIVE_NAMESPACE: '@appkit/active_namespace',
|
|
61
|
+
COINBASE_CONNECTOR_SESSION: '@appkit/coinbase_connector/session',
|
|
62
|
+
SIWX_AUTH_TOKEN: '@appkit/siwx-auth-token',
|
|
63
|
+
SIWX_NONCE_TOKEN: '@appkit/siwx-nonce-token'
|
|
64
|
+
} as const;
|
|
@@ -4,7 +4,6 @@ import type { AppKitNetwork } from '../blockchain/network';
|
|
|
4
4
|
import type { Provider } from '../blockchain/adapter';
|
|
5
5
|
import type { WalletInfo, Metadata } from './wallet-info';
|
|
6
6
|
import type { ConnectionProperties } from './connection';
|
|
7
|
-
import type { AppKitSIWEClient } from '../siwe';
|
|
8
7
|
import type { Storage } from '../storage';
|
|
9
8
|
import type { WcWallet } from '../api/wallet-api';
|
|
10
9
|
|
|
@@ -31,7 +30,6 @@ export type ConnectOptions = {
|
|
|
31
30
|
namespaces?: ProposalNamespaces;
|
|
32
31
|
defaultNetwork?: AppKitNetwork;
|
|
33
32
|
universalLink?: string;
|
|
34
|
-
siweConfig?: AppKitSIWEClient;
|
|
35
33
|
};
|
|
36
34
|
|
|
37
35
|
export type ConnectorInitOptions = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const ConstantsUtil = {
|
|
2
|
-
VERSION: '2.0.0-alpha.
|
|
2
|
+
VERSION: '2.0.0-alpha.6',
|
|
3
3
|
|
|
4
4
|
EIP155: 'eip155',
|
|
5
5
|
ADD_CHAIN_METHOD: 'wallet_addEthereumChain',
|
|
@@ -16,6 +16,16 @@ export const ConstantsUtil = {
|
|
|
16
16
|
SECURE_SITE_ICON: `https://secure.reown.com/images/favicon.png`,
|
|
17
17
|
REOWN_URL: `https://reown.com`,
|
|
18
18
|
|
|
19
|
+
CHAIN_NAME_MAP: {
|
|
20
|
+
eip155: 'EVM Networks',
|
|
21
|
+
solana: 'Solana',
|
|
22
|
+
polkadot: 'Polkadot',
|
|
23
|
+
bip122: 'Bitcoin',
|
|
24
|
+
cosmos: 'Cosmos',
|
|
25
|
+
sui: 'Sui',
|
|
26
|
+
stacks: 'Stacks'
|
|
27
|
+
},
|
|
28
|
+
|
|
19
29
|
USDT_CONTRACT_ADDRESSES: [
|
|
20
30
|
// Mainnet
|
|
21
31
|
'0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
@@ -64,21 +74,5 @@ export const ConstantsUtil = {
|
|
|
64
74
|
app_store: 'https://apps.apple.com/app/id1580902717',
|
|
65
75
|
android_app_id: 'com.solflare.mobile',
|
|
66
76
|
ios_schema: 'solflare://'
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// Storage Keys
|
|
70
|
-
STORAGE_KEYS: {
|
|
71
|
-
WC_DEEPLINK: 'WALLETCONNECT_DEEPLINK_CHOICE', //dont change this one
|
|
72
|
-
RECENT_WALLET: '@appkit/recent_wallet',
|
|
73
|
-
CONNECTED_CONNECTORS: '@appkit/connected_connectors',
|
|
74
|
-
ONRAMP_PREFERRED_COUNTRY: '@appkit/onramp_preferred_country',
|
|
75
|
-
ONRAMP_COUNTRIES: '@appkit/onramp_countries',
|
|
76
|
-
ONRAMP_SERVICE_PROVIDERS: '@appkit/onramp_service_providers',
|
|
77
|
-
ONRAMP_FIAT_LIMITS: '@appkit/onramp_fiat_limits',
|
|
78
|
-
ONRAMP_FIAT_CURRENCIES: '@appkit/onramp_fiat_currencies',
|
|
79
|
-
ONRAMP_PREFERRED_FIAT_CURRENCY: '@appkit/onramp_preferred_fiat_currency',
|
|
80
|
-
ONRAMP_COUNTRIES_DEFAULTS: '@appkit/onramp_countries_defaults',
|
|
81
|
-
ACTIVE_NAMESPACE: '@appkit/active_namespace',
|
|
82
|
-
COINBASE_CONNECTOR_SESSION: '@appkit/coinbase_connector/session'
|
|
83
77
|
}
|
|
84
78
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_config","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_message"],"sourceRoot":"../../../../src","sources":["types/siwe/index.ts"],"mappings":";;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/siwe/index.ts"],"mappings":";;AAAA;AACA,cAAc,UAAU;AACxB,cAAc,WAAW","ignoreList":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { SIWESession, SIWECreateMessageArgs, SIWEMessageArgs, SIWEVerifyMessageArgs } from './message';
|
|
2
|
-
export interface SIWEClientMethods {
|
|
3
|
-
getNonce: (address?: string) => Promise<string>;
|
|
4
|
-
createMessage: (args: SIWECreateMessageArgs) => string;
|
|
5
|
-
verifyMessage: (args: SIWEVerifyMessageArgs) => Promise<boolean>;
|
|
6
|
-
getSession: () => Promise<SIWESession | null>;
|
|
7
|
-
signOut: () => Promise<boolean>;
|
|
8
|
-
getMessageParams?: () => Promise<SIWEMessageArgs>;
|
|
9
|
-
onSignIn?: (session?: SIWESession) => void;
|
|
10
|
-
onSignOut?: () => void;
|
|
11
|
-
}
|
|
12
|
-
export interface SIWEConfig extends SIWEClientMethods {
|
|
13
|
-
enabled?: boolean;
|
|
14
|
-
nonceRefetchIntervalMs?: number;
|
|
15
|
-
sessionRefetchIntervalMs?: number;
|
|
16
|
-
signOutOnDisconnect?: boolean;
|
|
17
|
-
signOutOnAccountChange?: boolean;
|
|
18
|
-
signOutOnNetworkChange?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface AppKitSIWEClient extends SIWEClientMethods {
|
|
21
|
-
signIn: () => Promise<SIWESession | undefined>;
|
|
22
|
-
options: {
|
|
23
|
-
enabled: boolean;
|
|
24
|
-
nonceRefetchIntervalMs: number;
|
|
25
|
-
sessionRefetchIntervalMs: number;
|
|
26
|
-
signOutOnDisconnect: boolean;
|
|
27
|
-
signOutOnAccountChange: boolean;
|
|
28
|
-
signOutOnNetworkChange: boolean;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/types/siwe/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACtB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,aAAa,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,MAAM,CAAC;IACvD,aAAa,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC9C,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,UAAW,SAAQ,iBAAiB;IAEnD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,MAAM,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IAC/C,OAAO,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,sBAAsB,EAAE,MAAM,CAAC;QAC/B,wBAAwB,EAAE,MAAM,CAAC;QACjC,mBAAmB,EAAE,OAAO,CAAC;QAC7B,sBAAsB,EAAE,OAAO,CAAC;QAChC,sBAAsB,EAAE,OAAO,CAAC;KACjC,CAAC;CACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/siwe/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { CaipAddress, CaipNetworkId } from '../common';
|
|
2
|
-
export interface SIWESession {
|
|
3
|
-
address: string;
|
|
4
|
-
chainId: number;
|
|
5
|
-
}
|
|
6
|
-
interface CacaoHeader {
|
|
7
|
-
t: 'caip122';
|
|
8
|
-
}
|
|
9
|
-
export interface SIWECreateMessageArgs {
|
|
10
|
-
domain: string;
|
|
11
|
-
nonce: string;
|
|
12
|
-
uri: string;
|
|
13
|
-
address: CaipAddress;
|
|
14
|
-
version: '1';
|
|
15
|
-
type?: CacaoHeader['t'];
|
|
16
|
-
nbf?: string;
|
|
17
|
-
exp?: string;
|
|
18
|
-
statement?: string;
|
|
19
|
-
requestId?: string;
|
|
20
|
-
resources?: string[];
|
|
21
|
-
expiry?: number;
|
|
22
|
-
iat?: string;
|
|
23
|
-
}
|
|
24
|
-
export type SIWEMessageArgs = {
|
|
25
|
-
chains: CaipNetworkId[];
|
|
26
|
-
methods?: string[];
|
|
27
|
-
} & Omit<SIWECreateMessageArgs, 'address' | 'nonce' | 'version'>;
|
|
28
|
-
interface CacaoPayload {
|
|
29
|
-
domain: string;
|
|
30
|
-
aud: string;
|
|
31
|
-
nonce: string;
|
|
32
|
-
iss: string;
|
|
33
|
-
version?: string;
|
|
34
|
-
iat?: string;
|
|
35
|
-
nbf?: string;
|
|
36
|
-
exp?: string;
|
|
37
|
-
statement?: string;
|
|
38
|
-
requestId?: string;
|
|
39
|
-
resources?: string[];
|
|
40
|
-
type?: string;
|
|
41
|
-
}
|
|
42
|
-
interface Cacao {
|
|
43
|
-
h: CacaoHeader;
|
|
44
|
-
p: CacaoPayload;
|
|
45
|
-
s: {
|
|
46
|
-
t: 'eip191' | 'eip1271';
|
|
47
|
-
s: string;
|
|
48
|
-
m?: string;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export interface SIWEVerifyMessageArgs {
|
|
52
|
-
message: string;
|
|
53
|
-
signature: string;
|
|
54
|
-
cacao?: Cacao;
|
|
55
|
-
}
|
|
56
|
-
export {};
|
|
57
|
-
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/types/siwe/message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,WAAW;IACnB,CAAC,EAAE,SAAS,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,IAAI,CAAC,qBAAqB,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAEjE,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,KAAK;IACb,CAAC,EAAE,WAAW,CAAC;IACf,CAAC,EAAE,YAAY,CAAC;IAChB,CAAC,EAAE;QACD,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;QACxB,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,CAAC,EAAE,MAAM,CAAC;KACZ,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf"}
|