@solana-mobile/mobile-wallet-adapter-protocol 0.0.1-alpha.6 → 0.9.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/README.md +11 -5
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/solanamobile/mobilewalletadapter/reactnative/SolanaMobileWalletAdapterModule.kt +29 -32
- package/lib/cjs/index.browser.js +121 -80
- package/lib/cjs/index.js +121 -80
- package/lib/cjs/index.native.js +60 -62
- package/lib/esm/index.browser.mjs +119 -73
- package/lib/esm/index.mjs +119 -73
- package/lib/types/index.browser.d.mts +76 -54
- package/lib/types/index.browser.d.mts.map +1 -1
- package/lib/types/index.browser.d.ts +76 -54
- package/lib/types/index.browser.d.ts.map +1 -1
- package/lib/types/index.d.mts +76 -54
- package/lib/types/index.d.mts.map +1 -1
- package/lib/types/index.d.ts +76 -54
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.native.d.ts +76 -54
- package/lib/types/index.native.d.ts.map +1 -1
- package/package.json +5 -4
|
@@ -1,57 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
2
|
+
declare const SolanaMobileWalletAdapterErrorCode: {
|
|
3
|
+
readonly ERROR_ASSOCIATION_PORT_OUT_OF_RANGE: "ERROR_ASSOCIATION_PORT_OUT_OF_RANGE";
|
|
4
|
+
readonly ERROR_FORBIDDEN_WALLET_BASE_URL: "ERROR_FORBIDDEN_WALLET_BASE_URL";
|
|
5
|
+
readonly ERROR_SECURE_CONTEXT_REQUIRED: "ERROR_SECURE_CONTEXT_REQUIRED";
|
|
6
|
+
readonly ERROR_SESSION_CLOSED: "ERROR_SESSION_CLOSED";
|
|
7
|
+
readonly ERROR_WALLET_NOT_FOUND: "ERROR_WALLET_NOT_FOUND";
|
|
8
|
+
};
|
|
9
|
+
type SolanaMobileWalletAdapterErrorCodeEnum = (typeof SolanaMobileWalletAdapterErrorCode)[keyof typeof SolanaMobileWalletAdapterErrorCode];
|
|
10
|
+
type ErrorDataTypeMap = {
|
|
11
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_PORT_OUT_OF_RANGE]: {
|
|
12
|
+
port: number;
|
|
13
|
+
};
|
|
14
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL]: undefined;
|
|
15
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_SECURE_CONTEXT_REQUIRED]: undefined;
|
|
16
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED]: {
|
|
17
|
+
closeEvent: CloseEvent;
|
|
18
|
+
};
|
|
19
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND]: undefined;
|
|
20
|
+
};
|
|
21
|
+
declare class SolanaMobileWalletAdapterError<TErrorCode extends SolanaMobileWalletAdapterErrorCodeEnum> extends Error {
|
|
22
|
+
data: ErrorDataTypeMap[TErrorCode] | undefined;
|
|
23
|
+
code: TErrorCode;
|
|
24
|
+
constructor(...args: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
25
|
+
code: TErrorCode,
|
|
26
|
+
message: string,
|
|
27
|
+
data: ErrorDataTypeMap[TErrorCode]
|
|
28
|
+
] : [
|
|
29
|
+
code: TErrorCode,
|
|
30
|
+
message: string
|
|
31
|
+
]);
|
|
21
32
|
}
|
|
22
33
|
type JSONRPCErrorCode = number;
|
|
23
34
|
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
24
|
-
declare const
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
35
|
+
declare const SolanaMobileWalletAdapterProtocolErrorCode: {
|
|
36
|
+
readonly ERROR_AUTHORIZATION_FAILED: -1;
|
|
37
|
+
readonly ERROR_INVALID_PAYLOADS: -2;
|
|
38
|
+
readonly ERROR_NOT_SIGNED: -3;
|
|
39
|
+
readonly ERROR_NOT_SUBMITTED: -4;
|
|
40
|
+
readonly ERROR_TOO_MANY_PAYLOADS: -5;
|
|
30
41
|
readonly ERROR_ATTEST_ORIGIN_ANDROID: -100;
|
|
31
42
|
};
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
[
|
|
43
|
+
type SolanaMobileWalletAdapterProtocolErrorCodeEnum = (typeof SolanaMobileWalletAdapterProtocolErrorCode)[keyof typeof SolanaMobileWalletAdapterProtocolErrorCode];
|
|
44
|
+
type ProtocolErrorDataTypeMap = {
|
|
45
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_AUTHORIZATION_FAILED]: undefined;
|
|
46
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_INVALID_PAYLOADS]: undefined;
|
|
47
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SIGNED]: undefined;
|
|
48
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SUBMITTED]: undefined;
|
|
49
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_TOO_MANY_PAYLOADS]: undefined;
|
|
50
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_ATTEST_ORIGIN_ANDROID]: {
|
|
35
51
|
attest_origin_uri: string;
|
|
36
52
|
challenge: string;
|
|
37
53
|
context: string;
|
|
38
54
|
};
|
|
39
55
|
};
|
|
40
|
-
declare class
|
|
41
|
-
data:
|
|
42
|
-
code:
|
|
56
|
+
declare class SolanaMobileWalletAdapterProtocolError<TErrorCode extends SolanaMobileWalletAdapterProtocolErrorCodeEnum> extends Error {
|
|
57
|
+
data: ProtocolErrorDataTypeMap[TErrorCode] | undefined;
|
|
58
|
+
code: TErrorCode | JSONRPCErrorCode;
|
|
43
59
|
jsonRpcMessageId: number;
|
|
44
|
-
constructor(...args:
|
|
60
|
+
constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
45
61
|
jsonRpcMessageId: number,
|
|
46
|
-
code:
|
|
62
|
+
code: TErrorCode | JSONRPCErrorCode,
|
|
47
63
|
message: string,
|
|
48
|
-
data:
|
|
64
|
+
data: ProtocolErrorDataTypeMap[TErrorCode]
|
|
49
65
|
] : [
|
|
50
66
|
jsonRpcMessageId: number,
|
|
51
|
-
code:
|
|
67
|
+
code: TErrorCode | JSONRPCErrorCode,
|
|
52
68
|
message: string
|
|
53
69
|
]);
|
|
54
70
|
}
|
|
71
|
+
type Account = Readonly<{
|
|
72
|
+
address: Base64EncodedAddress;
|
|
73
|
+
label?: string;
|
|
74
|
+
}>;
|
|
55
75
|
/**
|
|
56
76
|
* Properties that wallets may present to users when an app
|
|
57
77
|
* asks for authorization to execute privileged methods (see
|
|
@@ -74,21 +94,25 @@ type AssociationKeypair = CryptoKeyPair;
|
|
|
74
94
|
* use it later to invoke privileged methods.
|
|
75
95
|
*/
|
|
76
96
|
type AuthorizationResult = Readonly<{
|
|
97
|
+
accounts: Account[];
|
|
77
98
|
auth_token: AuthToken;
|
|
78
|
-
pub_key: string;
|
|
79
99
|
wallet_uri_base: string;
|
|
80
100
|
}>;
|
|
81
101
|
type AuthToken = string;
|
|
82
|
-
type
|
|
102
|
+
type Base64EncodedAddress = string;
|
|
103
|
+
type Base64EncodedSignature = string;
|
|
83
104
|
type Base64EncodedMessage = string;
|
|
84
105
|
type Base64EncodedSignedMessage = string;
|
|
85
106
|
type Base64EncodedSignedTransaction = string;
|
|
86
107
|
type Base64EncodedTransaction = string;
|
|
108
|
+
type Cluster = "devnet" | "testnet" | "mainnet-beta";
|
|
109
|
+
type Finality = "confirmed" | "finalized" | "processed";
|
|
87
110
|
type WalletAssociationConfig = Readonly<{
|
|
88
111
|
baseUri?: string;
|
|
89
112
|
}>;
|
|
90
113
|
interface AuthorizeAPI {
|
|
91
114
|
authorize(params: {
|
|
115
|
+
cluster: Cluster;
|
|
92
116
|
identity: AppIdentity;
|
|
93
117
|
}): Promise<AuthorizationResult>;
|
|
94
118
|
}
|
|
@@ -107,37 +131,35 @@ interface DeauthorizeAPI {
|
|
|
107
131
|
interface ReauthorizeAPI {
|
|
108
132
|
reauthorize(params: {
|
|
109
133
|
auth_token: AuthToken;
|
|
110
|
-
}): Promise<
|
|
111
|
-
auth_token: AuthToken;
|
|
112
|
-
}>>;
|
|
134
|
+
}): Promise<AuthorizationResult>;
|
|
113
135
|
}
|
|
114
|
-
interface
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
interface SignMessagesAPI {
|
|
137
|
+
signMessages(params: {
|
|
138
|
+
addresses: Base64EncodedAddress[];
|
|
117
139
|
payloads: Base64EncodedMessage[];
|
|
118
140
|
}): Promise<Readonly<{
|
|
119
141
|
signed_payloads: Base64EncodedSignedMessage[];
|
|
120
142
|
}>>;
|
|
121
143
|
}
|
|
122
|
-
interface
|
|
123
|
-
|
|
124
|
-
auth_token: AuthToken;
|
|
144
|
+
interface SignTransactionsAPI {
|
|
145
|
+
signTransactions(params: {
|
|
125
146
|
payloads: Base64EncodedTransaction[];
|
|
126
147
|
}): Promise<Readonly<{
|
|
127
148
|
signed_payloads: Base64EncodedSignedTransaction[];
|
|
128
149
|
}>>;
|
|
129
150
|
}
|
|
130
|
-
interface
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
interface SignAndSendTransactionsAPI {
|
|
152
|
+
signAndSendTransactions(params: {
|
|
153
|
+
options?: Readonly<{
|
|
154
|
+
min_context_slot?: number;
|
|
155
|
+
}>;
|
|
134
156
|
payloads: Base64EncodedTransaction[];
|
|
135
157
|
}): Promise<Readonly<{
|
|
136
|
-
signatures:
|
|
158
|
+
signatures: Base64EncodedSignature[];
|
|
137
159
|
}>>;
|
|
138
160
|
}
|
|
139
|
-
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI,
|
|
161
|
+
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI {
|
|
140
162
|
}
|
|
141
163
|
declare function transact<TReturn>(callback: (wallet: MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
142
|
-
export {
|
|
164
|
+
export { SolanaMobileWalletAdapterErrorCode, SolanaMobileWalletAdapterError, SolanaMobileWalletAdapterProtocolErrorCode, SolanaMobileWalletAdapterProtocolError, transact, Account, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, Base64EncodedAddress, Cluster, Finality, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI, MobileWallet };
|
|
143
165
|
//# sourceMappingURL=index.browser.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/errors.ts","../../src/createHelloReq.ts","../../src/generateAssociationKeypair.ts","../../src/generateECDHKeypair.ts","../../src/parseHelloRsp.ts","../../src/jsonRpcMessage.ts","../../src/associationPort.ts","../../src/arrayBufferToBase64String.ts","../../src/getStringWithURLUnsafeBase64CharactersReplaced.ts","../../src/getAssociateAndroidIntentURL.ts","../../src/startSession.ts","../../src/types.ts","../../src/transact.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.browser.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/errors.ts","../../src/createHelloReq.ts","../../src/createSequenceNumberVector.ts","../../src/generateAssociationKeypair.ts","../../src/generateECDHKeypair.ts","../../src/parseHelloRsp.ts","../../src/jsonRpcMessage.ts","../../src/associationPort.ts","../../src/arrayBufferToBase64String.ts","../../src/getStringWithURLUnsafeBase64CharactersReplaced.ts","../../src/getAssociateAndroidIntentURL.ts","../../src/startSession.ts","../../src/types.ts","../../src/transact.ts"],"names":[],"mappings":""}
|
|
@@ -1,57 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
2
|
+
declare const SolanaMobileWalletAdapterErrorCode: {
|
|
3
|
+
readonly ERROR_ASSOCIATION_PORT_OUT_OF_RANGE: "ERROR_ASSOCIATION_PORT_OUT_OF_RANGE";
|
|
4
|
+
readonly ERROR_FORBIDDEN_WALLET_BASE_URL: "ERROR_FORBIDDEN_WALLET_BASE_URL";
|
|
5
|
+
readonly ERROR_SECURE_CONTEXT_REQUIRED: "ERROR_SECURE_CONTEXT_REQUIRED";
|
|
6
|
+
readonly ERROR_SESSION_CLOSED: "ERROR_SESSION_CLOSED";
|
|
7
|
+
readonly ERROR_WALLET_NOT_FOUND: "ERROR_WALLET_NOT_FOUND";
|
|
8
|
+
};
|
|
9
|
+
type SolanaMobileWalletAdapterErrorCodeEnum = (typeof SolanaMobileWalletAdapterErrorCode)[keyof typeof SolanaMobileWalletAdapterErrorCode];
|
|
10
|
+
type ErrorDataTypeMap = {
|
|
11
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_PORT_OUT_OF_RANGE]: {
|
|
12
|
+
port: number;
|
|
13
|
+
};
|
|
14
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL]: undefined;
|
|
15
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_SECURE_CONTEXT_REQUIRED]: undefined;
|
|
16
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED]: {
|
|
17
|
+
closeEvent: CloseEvent;
|
|
18
|
+
};
|
|
19
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND]: undefined;
|
|
20
|
+
};
|
|
21
|
+
declare class SolanaMobileWalletAdapterError<TErrorCode extends SolanaMobileWalletAdapterErrorCodeEnum> extends Error {
|
|
22
|
+
data: ErrorDataTypeMap[TErrorCode] | undefined;
|
|
23
|
+
code: TErrorCode;
|
|
24
|
+
constructor(...args: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
25
|
+
code: TErrorCode,
|
|
26
|
+
message: string,
|
|
27
|
+
data: ErrorDataTypeMap[TErrorCode]
|
|
28
|
+
] : [
|
|
29
|
+
code: TErrorCode,
|
|
30
|
+
message: string
|
|
31
|
+
]);
|
|
21
32
|
}
|
|
22
33
|
type JSONRPCErrorCode = number;
|
|
23
34
|
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
24
|
-
declare const
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
35
|
+
declare const SolanaMobileWalletAdapterProtocolErrorCode: {
|
|
36
|
+
readonly ERROR_AUTHORIZATION_FAILED: -1;
|
|
37
|
+
readonly ERROR_INVALID_PAYLOADS: -2;
|
|
38
|
+
readonly ERROR_NOT_SIGNED: -3;
|
|
39
|
+
readonly ERROR_NOT_SUBMITTED: -4;
|
|
40
|
+
readonly ERROR_TOO_MANY_PAYLOADS: -5;
|
|
30
41
|
readonly ERROR_ATTEST_ORIGIN_ANDROID: -100;
|
|
31
42
|
};
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
[
|
|
43
|
+
type SolanaMobileWalletAdapterProtocolErrorCodeEnum = (typeof SolanaMobileWalletAdapterProtocolErrorCode)[keyof typeof SolanaMobileWalletAdapterProtocolErrorCode];
|
|
44
|
+
type ProtocolErrorDataTypeMap = {
|
|
45
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_AUTHORIZATION_FAILED]: undefined;
|
|
46
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_INVALID_PAYLOADS]: undefined;
|
|
47
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SIGNED]: undefined;
|
|
48
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SUBMITTED]: undefined;
|
|
49
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_TOO_MANY_PAYLOADS]: undefined;
|
|
50
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_ATTEST_ORIGIN_ANDROID]: {
|
|
35
51
|
attest_origin_uri: string;
|
|
36
52
|
challenge: string;
|
|
37
53
|
context: string;
|
|
38
54
|
};
|
|
39
55
|
};
|
|
40
|
-
declare class
|
|
41
|
-
data:
|
|
42
|
-
code:
|
|
56
|
+
declare class SolanaMobileWalletAdapterProtocolError<TErrorCode extends SolanaMobileWalletAdapterProtocolErrorCodeEnum> extends Error {
|
|
57
|
+
data: ProtocolErrorDataTypeMap[TErrorCode] | undefined;
|
|
58
|
+
code: TErrorCode | JSONRPCErrorCode;
|
|
43
59
|
jsonRpcMessageId: number;
|
|
44
|
-
constructor(...args:
|
|
60
|
+
constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
45
61
|
jsonRpcMessageId: number,
|
|
46
|
-
code:
|
|
62
|
+
code: TErrorCode | JSONRPCErrorCode,
|
|
47
63
|
message: string,
|
|
48
|
-
data:
|
|
64
|
+
data: ProtocolErrorDataTypeMap[TErrorCode]
|
|
49
65
|
] : [
|
|
50
66
|
jsonRpcMessageId: number,
|
|
51
|
-
code:
|
|
67
|
+
code: TErrorCode | JSONRPCErrorCode,
|
|
52
68
|
message: string
|
|
53
69
|
]);
|
|
54
70
|
}
|
|
71
|
+
type Account = Readonly<{
|
|
72
|
+
address: Base64EncodedAddress;
|
|
73
|
+
label?: string;
|
|
74
|
+
}>;
|
|
55
75
|
/**
|
|
56
76
|
* Properties that wallets may present to users when an app
|
|
57
77
|
* asks for authorization to execute privileged methods (see
|
|
@@ -74,21 +94,25 @@ type AssociationKeypair = CryptoKeyPair;
|
|
|
74
94
|
* use it later to invoke privileged methods.
|
|
75
95
|
*/
|
|
76
96
|
type AuthorizationResult = Readonly<{
|
|
97
|
+
accounts: Account[];
|
|
77
98
|
auth_token: AuthToken;
|
|
78
|
-
pub_key: string;
|
|
79
99
|
wallet_uri_base: string;
|
|
80
100
|
}>;
|
|
81
101
|
type AuthToken = string;
|
|
82
|
-
type
|
|
102
|
+
type Base64EncodedAddress = string;
|
|
103
|
+
type Base64EncodedSignature = string;
|
|
83
104
|
type Base64EncodedMessage = string;
|
|
84
105
|
type Base64EncodedSignedMessage = string;
|
|
85
106
|
type Base64EncodedSignedTransaction = string;
|
|
86
107
|
type Base64EncodedTransaction = string;
|
|
108
|
+
type Cluster = "devnet" | "testnet" | "mainnet-beta";
|
|
109
|
+
type Finality = "confirmed" | "finalized" | "processed";
|
|
87
110
|
type WalletAssociationConfig = Readonly<{
|
|
88
111
|
baseUri?: string;
|
|
89
112
|
}>;
|
|
90
113
|
interface AuthorizeAPI {
|
|
91
114
|
authorize(params: {
|
|
115
|
+
cluster: Cluster;
|
|
92
116
|
identity: AppIdentity;
|
|
93
117
|
}): Promise<AuthorizationResult>;
|
|
94
118
|
}
|
|
@@ -107,37 +131,35 @@ interface DeauthorizeAPI {
|
|
|
107
131
|
interface ReauthorizeAPI {
|
|
108
132
|
reauthorize(params: {
|
|
109
133
|
auth_token: AuthToken;
|
|
110
|
-
}): Promise<
|
|
111
|
-
auth_token: AuthToken;
|
|
112
|
-
}>>;
|
|
134
|
+
}): Promise<AuthorizationResult>;
|
|
113
135
|
}
|
|
114
|
-
interface
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
interface SignMessagesAPI {
|
|
137
|
+
signMessages(params: {
|
|
138
|
+
addresses: Base64EncodedAddress[];
|
|
117
139
|
payloads: Base64EncodedMessage[];
|
|
118
140
|
}): Promise<Readonly<{
|
|
119
141
|
signed_payloads: Base64EncodedSignedMessage[];
|
|
120
142
|
}>>;
|
|
121
143
|
}
|
|
122
|
-
interface
|
|
123
|
-
|
|
124
|
-
auth_token: AuthToken;
|
|
144
|
+
interface SignTransactionsAPI {
|
|
145
|
+
signTransactions(params: {
|
|
125
146
|
payloads: Base64EncodedTransaction[];
|
|
126
147
|
}): Promise<Readonly<{
|
|
127
148
|
signed_payloads: Base64EncodedSignedTransaction[];
|
|
128
149
|
}>>;
|
|
129
150
|
}
|
|
130
|
-
interface
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
interface SignAndSendTransactionsAPI {
|
|
152
|
+
signAndSendTransactions(params: {
|
|
153
|
+
options?: Readonly<{
|
|
154
|
+
min_context_slot?: number;
|
|
155
|
+
}>;
|
|
134
156
|
payloads: Base64EncodedTransaction[];
|
|
135
157
|
}): Promise<Readonly<{
|
|
136
|
-
signatures:
|
|
158
|
+
signatures: Base64EncodedSignature[];
|
|
137
159
|
}>>;
|
|
138
160
|
}
|
|
139
|
-
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI,
|
|
161
|
+
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI {
|
|
140
162
|
}
|
|
141
163
|
declare function transact<TReturn>(callback: (wallet: MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
142
|
-
export {
|
|
164
|
+
export { SolanaMobileWalletAdapterErrorCode, SolanaMobileWalletAdapterError, SolanaMobileWalletAdapterProtocolErrorCode, SolanaMobileWalletAdapterProtocolError, transact, Account, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, Base64EncodedAddress, Cluster, Finality, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI, MobileWallet };
|
|
143
165
|
//# sourceMappingURL=index.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/errors.ts","../../src/createHelloReq.ts","../../src/generateAssociationKeypair.ts","../../src/generateECDHKeypair.ts","../../src/parseHelloRsp.ts","../../src/jsonRpcMessage.ts","../../src/associationPort.ts","../../src/arrayBufferToBase64String.ts","../../src/getStringWithURLUnsafeBase64CharactersReplaced.ts","../../src/getAssociateAndroidIntentURL.ts","../../src/startSession.ts","../../src/types.ts","../../src/transact.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/errors.ts","../../src/createHelloReq.ts","../../src/createSequenceNumberVector.ts","../../src/generateAssociationKeypair.ts","../../src/generateECDHKeypair.ts","../../src/parseHelloRsp.ts","../../src/jsonRpcMessage.ts","../../src/associationPort.ts","../../src/arrayBufferToBase64String.ts","../../src/getStringWithURLUnsafeBase64CharactersReplaced.ts","../../src/getAssociateAndroidIntentURL.ts","../../src/startSession.ts","../../src/types.ts","../../src/transact.ts"],"names":[],"mappings":""}
|
package/lib/types/index.d.mts
CHANGED
|
@@ -1,57 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
2
|
+
declare const SolanaMobileWalletAdapterErrorCode: {
|
|
3
|
+
readonly ERROR_ASSOCIATION_PORT_OUT_OF_RANGE: "ERROR_ASSOCIATION_PORT_OUT_OF_RANGE";
|
|
4
|
+
readonly ERROR_FORBIDDEN_WALLET_BASE_URL: "ERROR_FORBIDDEN_WALLET_BASE_URL";
|
|
5
|
+
readonly ERROR_SECURE_CONTEXT_REQUIRED: "ERROR_SECURE_CONTEXT_REQUIRED";
|
|
6
|
+
readonly ERROR_SESSION_CLOSED: "ERROR_SESSION_CLOSED";
|
|
7
|
+
readonly ERROR_WALLET_NOT_FOUND: "ERROR_WALLET_NOT_FOUND";
|
|
8
|
+
};
|
|
9
|
+
type SolanaMobileWalletAdapterErrorCodeEnum = (typeof SolanaMobileWalletAdapterErrorCode)[keyof typeof SolanaMobileWalletAdapterErrorCode];
|
|
10
|
+
type ErrorDataTypeMap = {
|
|
11
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_PORT_OUT_OF_RANGE]: {
|
|
12
|
+
port: number;
|
|
13
|
+
};
|
|
14
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL]: undefined;
|
|
15
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_SECURE_CONTEXT_REQUIRED]: undefined;
|
|
16
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED]: {
|
|
17
|
+
closeEvent: CloseEvent;
|
|
18
|
+
};
|
|
19
|
+
[SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND]: undefined;
|
|
20
|
+
};
|
|
21
|
+
declare class SolanaMobileWalletAdapterError<TErrorCode extends SolanaMobileWalletAdapterErrorCodeEnum> extends Error {
|
|
22
|
+
data: ErrorDataTypeMap[TErrorCode] | undefined;
|
|
23
|
+
code: TErrorCode;
|
|
24
|
+
constructor(...args: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
25
|
+
code: TErrorCode,
|
|
26
|
+
message: string,
|
|
27
|
+
data: ErrorDataTypeMap[TErrorCode]
|
|
28
|
+
] : [
|
|
29
|
+
code: TErrorCode,
|
|
30
|
+
message: string
|
|
31
|
+
]);
|
|
21
32
|
}
|
|
22
33
|
type JSONRPCErrorCode = number;
|
|
23
34
|
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
24
|
-
declare const
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
35
|
+
declare const SolanaMobileWalletAdapterProtocolErrorCode: {
|
|
36
|
+
readonly ERROR_AUTHORIZATION_FAILED: -1;
|
|
37
|
+
readonly ERROR_INVALID_PAYLOADS: -2;
|
|
38
|
+
readonly ERROR_NOT_SIGNED: -3;
|
|
39
|
+
readonly ERROR_NOT_SUBMITTED: -4;
|
|
40
|
+
readonly ERROR_TOO_MANY_PAYLOADS: -5;
|
|
30
41
|
readonly ERROR_ATTEST_ORIGIN_ANDROID: -100;
|
|
31
42
|
};
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
[
|
|
43
|
+
type SolanaMobileWalletAdapterProtocolErrorCodeEnum = (typeof SolanaMobileWalletAdapterProtocolErrorCode)[keyof typeof SolanaMobileWalletAdapterProtocolErrorCode];
|
|
44
|
+
type ProtocolErrorDataTypeMap = {
|
|
45
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_AUTHORIZATION_FAILED]: undefined;
|
|
46
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_INVALID_PAYLOADS]: undefined;
|
|
47
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SIGNED]: undefined;
|
|
48
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SUBMITTED]: undefined;
|
|
49
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_TOO_MANY_PAYLOADS]: undefined;
|
|
50
|
+
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_ATTEST_ORIGIN_ANDROID]: {
|
|
35
51
|
attest_origin_uri: string;
|
|
36
52
|
challenge: string;
|
|
37
53
|
context: string;
|
|
38
54
|
};
|
|
39
55
|
};
|
|
40
|
-
declare class
|
|
41
|
-
data:
|
|
42
|
-
code:
|
|
56
|
+
declare class SolanaMobileWalletAdapterProtocolError<TErrorCode extends SolanaMobileWalletAdapterProtocolErrorCodeEnum> extends Error {
|
|
57
|
+
data: ProtocolErrorDataTypeMap[TErrorCode] | undefined;
|
|
58
|
+
code: TErrorCode | JSONRPCErrorCode;
|
|
43
59
|
jsonRpcMessageId: number;
|
|
44
|
-
constructor(...args:
|
|
60
|
+
constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
45
61
|
jsonRpcMessageId: number,
|
|
46
|
-
code:
|
|
62
|
+
code: TErrorCode | JSONRPCErrorCode,
|
|
47
63
|
message: string,
|
|
48
|
-
data:
|
|
64
|
+
data: ProtocolErrorDataTypeMap[TErrorCode]
|
|
49
65
|
] : [
|
|
50
66
|
jsonRpcMessageId: number,
|
|
51
|
-
code:
|
|
67
|
+
code: TErrorCode | JSONRPCErrorCode,
|
|
52
68
|
message: string
|
|
53
69
|
]);
|
|
54
70
|
}
|
|
71
|
+
type Account = Readonly<{
|
|
72
|
+
address: Base64EncodedAddress;
|
|
73
|
+
label?: string;
|
|
74
|
+
}>;
|
|
55
75
|
/**
|
|
56
76
|
* Properties that wallets may present to users when an app
|
|
57
77
|
* asks for authorization to execute privileged methods (see
|
|
@@ -74,21 +94,25 @@ type AssociationKeypair = CryptoKeyPair;
|
|
|
74
94
|
* use it later to invoke privileged methods.
|
|
75
95
|
*/
|
|
76
96
|
type AuthorizationResult = Readonly<{
|
|
97
|
+
accounts: Account[];
|
|
77
98
|
auth_token: AuthToken;
|
|
78
|
-
pub_key: string;
|
|
79
99
|
wallet_uri_base: string;
|
|
80
100
|
}>;
|
|
81
101
|
type AuthToken = string;
|
|
82
|
-
type
|
|
102
|
+
type Base64EncodedAddress = string;
|
|
103
|
+
type Base64EncodedSignature = string;
|
|
83
104
|
type Base64EncodedMessage = string;
|
|
84
105
|
type Base64EncodedSignedMessage = string;
|
|
85
106
|
type Base64EncodedSignedTransaction = string;
|
|
86
107
|
type Base64EncodedTransaction = string;
|
|
108
|
+
type Cluster = "devnet" | "testnet" | "mainnet-beta";
|
|
109
|
+
type Finality = "confirmed" | "finalized" | "processed";
|
|
87
110
|
type WalletAssociationConfig = Readonly<{
|
|
88
111
|
baseUri?: string;
|
|
89
112
|
}>;
|
|
90
113
|
interface AuthorizeAPI {
|
|
91
114
|
authorize(params: {
|
|
115
|
+
cluster: Cluster;
|
|
92
116
|
identity: AppIdentity;
|
|
93
117
|
}): Promise<AuthorizationResult>;
|
|
94
118
|
}
|
|
@@ -107,37 +131,35 @@ interface DeauthorizeAPI {
|
|
|
107
131
|
interface ReauthorizeAPI {
|
|
108
132
|
reauthorize(params: {
|
|
109
133
|
auth_token: AuthToken;
|
|
110
|
-
}): Promise<
|
|
111
|
-
auth_token: AuthToken;
|
|
112
|
-
}>>;
|
|
134
|
+
}): Promise<AuthorizationResult>;
|
|
113
135
|
}
|
|
114
|
-
interface
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
interface SignMessagesAPI {
|
|
137
|
+
signMessages(params: {
|
|
138
|
+
addresses: Base64EncodedAddress[];
|
|
117
139
|
payloads: Base64EncodedMessage[];
|
|
118
140
|
}): Promise<Readonly<{
|
|
119
141
|
signed_payloads: Base64EncodedSignedMessage[];
|
|
120
142
|
}>>;
|
|
121
143
|
}
|
|
122
|
-
interface
|
|
123
|
-
|
|
124
|
-
auth_token: AuthToken;
|
|
144
|
+
interface SignTransactionsAPI {
|
|
145
|
+
signTransactions(params: {
|
|
125
146
|
payloads: Base64EncodedTransaction[];
|
|
126
147
|
}): Promise<Readonly<{
|
|
127
148
|
signed_payloads: Base64EncodedSignedTransaction[];
|
|
128
149
|
}>>;
|
|
129
150
|
}
|
|
130
|
-
interface
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
interface SignAndSendTransactionsAPI {
|
|
152
|
+
signAndSendTransactions(params: {
|
|
153
|
+
options?: Readonly<{
|
|
154
|
+
min_context_slot?: number;
|
|
155
|
+
}>;
|
|
134
156
|
payloads: Base64EncodedTransaction[];
|
|
135
157
|
}): Promise<Readonly<{
|
|
136
|
-
signatures:
|
|
158
|
+
signatures: Base64EncodedSignature[];
|
|
137
159
|
}>>;
|
|
138
160
|
}
|
|
139
|
-
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI,
|
|
161
|
+
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI {
|
|
140
162
|
}
|
|
141
163
|
declare function transact<TReturn>(callback: (wallet: MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
142
|
-
export {
|
|
164
|
+
export { SolanaMobileWalletAdapterErrorCode, SolanaMobileWalletAdapterError, SolanaMobileWalletAdapterProtocolErrorCode, SolanaMobileWalletAdapterProtocolError, transact, Account, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, Base64EncodedAddress, Cluster, Finality, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI, MobileWallet };
|
|
143
165
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/errors.ts","../../src/createHelloReq.ts","../../src/generateAssociationKeypair.ts","../../src/generateECDHKeypair.ts","../../src/parseHelloRsp.ts","../../src/jsonRpcMessage.ts","../../src/associationPort.ts","../../src/arrayBufferToBase64String.ts","../../src/getStringWithURLUnsafeBase64CharactersReplaced.ts","../../src/getAssociateAndroidIntentURL.ts","../../src/startSession.ts","../../src/types.ts","../../src/transact.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/errors.ts","../../src/createHelloReq.ts","../../src/createSequenceNumberVector.ts","../../src/generateAssociationKeypair.ts","../../src/generateECDHKeypair.ts","../../src/parseHelloRsp.ts","../../src/jsonRpcMessage.ts","../../src/associationPort.ts","../../src/arrayBufferToBase64String.ts","../../src/getStringWithURLUnsafeBase64CharactersReplaced.ts","../../src/getAssociateAndroidIntentURL.ts","../../src/startSession.ts","../../src/types.ts","../../src/transact.ts"],"names":[],"mappings":""}
|