@solana-mobile/mobile-wallet-adapter-protocol 0.9.6 → 0.9.8
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/cjs/index.browser.js +2 -2
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/index.native.js +1 -1
- package/lib/esm/{index.browser.mjs → index.browser.js} +2 -2
- package/lib/esm/{index.mjs → index.js} +2 -2
- package/package.json +5 -5
- package/lib/types/index.browser.d.mts +0 -177
- package/lib/types/index.browser.d.mts.map +0 -1
- package/lib/types/index.d.mts +0 -177
- package/lib/types/index.d.mts.map +0 -1
package/lib/cjs/index.browser.js
CHANGED
|
@@ -41,7 +41,7 @@ class SolanaMobileWalletAdapterProtocolError extends Error {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
/******************************************************************************
|
|
45
45
|
Copyright (c) Microsoft Corporation.
|
|
46
46
|
|
|
47
47
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -113,7 +113,7 @@ function encryptJsonRpcMessage(jsonRpcMessage, sharedSecret) {
|
|
|
113
113
|
const sequenceNumberVector = createSequenceNumberVector(jsonRpcMessage.id);
|
|
114
114
|
const initializationVector = new Uint8Array(INITIALIZATION_VECTOR_BYTES);
|
|
115
115
|
crypto.getRandomValues(initializationVector);
|
|
116
|
-
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret,
|
|
116
|
+
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, new TextEncoder().encode(plaintext));
|
|
117
117
|
const response = new Uint8Array(sequenceNumberVector.byteLength + initializationVector.byteLength + ciphertext.byteLength);
|
|
118
118
|
response.set(new Uint8Array(sequenceNumberVector), 0);
|
|
119
119
|
response.set(new Uint8Array(initializationVector), sequenceNumberVector.byteLength);
|
package/lib/cjs/index.js
CHANGED
|
@@ -41,7 +41,7 @@ class SolanaMobileWalletAdapterProtocolError extends Error {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
/******************************************************************************
|
|
45
45
|
Copyright (c) Microsoft Corporation.
|
|
46
46
|
|
|
47
47
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -113,7 +113,7 @@ function encryptJsonRpcMessage(jsonRpcMessage, sharedSecret) {
|
|
|
113
113
|
const sequenceNumberVector = createSequenceNumberVector(jsonRpcMessage.id);
|
|
114
114
|
const initializationVector = new Uint8Array(INITIALIZATION_VECTOR_BYTES);
|
|
115
115
|
crypto.getRandomValues(initializationVector);
|
|
116
|
-
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret,
|
|
116
|
+
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, new TextEncoder().encode(plaintext));
|
|
117
117
|
const response = new Uint8Array(sequenceNumberVector.byteLength + initializationVector.byteLength + ciphertext.byteLength);
|
|
118
118
|
response.set(new Uint8Array(sequenceNumberVector), 0);
|
|
119
119
|
response.set(new Uint8Array(initializationVector), sequenceNumberVector.byteLength);
|
package/lib/cjs/index.native.js
CHANGED
|
@@ -43,7 +43,7 @@ class SolanaMobileWalletAdapterProtocolError extends Error {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
/******************************************************************************
|
|
47
47
|
Copyright (c) Microsoft Corporation.
|
|
48
48
|
|
|
49
49
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -37,7 +37,7 @@ class SolanaMobileWalletAdapterProtocolError extends Error {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
/******************************************************************************
|
|
41
41
|
Copyright (c) Microsoft Corporation.
|
|
42
42
|
|
|
43
43
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -109,7 +109,7 @@ function encryptJsonRpcMessage(jsonRpcMessage, sharedSecret) {
|
|
|
109
109
|
const sequenceNumberVector = createSequenceNumberVector(jsonRpcMessage.id);
|
|
110
110
|
const initializationVector = new Uint8Array(INITIALIZATION_VECTOR_BYTES);
|
|
111
111
|
crypto.getRandomValues(initializationVector);
|
|
112
|
-
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret,
|
|
112
|
+
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, new TextEncoder().encode(plaintext));
|
|
113
113
|
const response = new Uint8Array(sequenceNumberVector.byteLength + initializationVector.byteLength + ciphertext.byteLength);
|
|
114
114
|
response.set(new Uint8Array(sequenceNumberVector), 0);
|
|
115
115
|
response.set(new Uint8Array(initializationVector), sequenceNumberVector.byteLength);
|
|
@@ -37,7 +37,7 @@ class SolanaMobileWalletAdapterProtocolError extends Error {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
/******************************************************************************
|
|
41
41
|
Copyright (c) Microsoft Corporation.
|
|
42
42
|
|
|
43
43
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -109,7 +109,7 @@ function encryptJsonRpcMessage(jsonRpcMessage, sharedSecret) {
|
|
|
109
109
|
const sequenceNumberVector = createSequenceNumberVector(jsonRpcMessage.id);
|
|
110
110
|
const initializationVector = new Uint8Array(INITIALIZATION_VECTOR_BYTES);
|
|
111
111
|
crypto.getRandomValues(initializationVector);
|
|
112
|
-
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret,
|
|
112
|
+
const ciphertext = yield crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, new TextEncoder().encode(plaintext));
|
|
113
113
|
const response = new Uint8Array(sequenceNumberVector.byteLength + initializationVector.byteLength + ciphertext.byteLength);
|
|
114
114
|
response.set(new Uint8Array(sequenceNumberVector), 0);
|
|
115
115
|
response.set(new Uint8Array(initializationVector), sequenceNumberVector.byteLength);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana-mobile/mobile-wallet-adapter-protocol",
|
|
3
3
|
"description": "An implementation of the Solana Mobile Mobile Wallet Adapter protocol. Use this to open a session with a mobile wallet app, and to issue API calls to it.",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.8",
|
|
5
5
|
"author": "Steven Luscher <steven.luscher@solanamobile.com>",
|
|
6
6
|
"repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"main": "lib/cjs/index.js",
|
|
11
11
|
"react-native": "lib/cjs/index.native.js",
|
|
12
|
-
"module": "lib/esm/index.
|
|
12
|
+
"module": "lib/esm/index.js",
|
|
13
13
|
"types": "lib/types/index.d.ts",
|
|
14
14
|
"browser": {
|
|
15
15
|
"./lib/cjs/index.js": "./lib/cjs/index.browser.js",
|
|
16
|
-
"./lib/esm/index.
|
|
16
|
+
"./lib/esm/index.js": "./lib/esm/index.browser.js"
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
19
19
|
"./package.json": "./package.json",
|
|
20
20
|
".": {
|
|
21
|
-
"import": "./lib/esm/index.
|
|
21
|
+
"import": "./lib/esm/index.js",
|
|
22
22
|
"require": "./lib/cjs/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react-native": ">0.69"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "040622228152826e029bc613f7c6b4b14eefb138"
|
|
51
51
|
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { TransactionVersion } from "@solana/web3.js";
|
|
2
|
-
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
3
|
-
declare const SolanaMobileWalletAdapterErrorCode: {
|
|
4
|
-
readonly ERROR_ASSOCIATION_PORT_OUT_OF_RANGE: "ERROR_ASSOCIATION_PORT_OUT_OF_RANGE";
|
|
5
|
-
readonly ERROR_FORBIDDEN_WALLET_BASE_URL: "ERROR_FORBIDDEN_WALLET_BASE_URL";
|
|
6
|
-
readonly ERROR_SECURE_CONTEXT_REQUIRED: "ERROR_SECURE_CONTEXT_REQUIRED";
|
|
7
|
-
readonly ERROR_SESSION_CLOSED: "ERROR_SESSION_CLOSED";
|
|
8
|
-
readonly ERROR_SESSION_TIMEOUT: "ERROR_SESSION_TIMEOUT";
|
|
9
|
-
readonly ERROR_WALLET_NOT_FOUND: "ERROR_WALLET_NOT_FOUND";
|
|
10
|
-
};
|
|
11
|
-
type SolanaMobileWalletAdapterErrorCodeEnum = (typeof SolanaMobileWalletAdapterErrorCode)[keyof typeof SolanaMobileWalletAdapterErrorCode];
|
|
12
|
-
type ErrorDataTypeMap = {
|
|
13
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_PORT_OUT_OF_RANGE]: {
|
|
14
|
-
port: number;
|
|
15
|
-
};
|
|
16
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL]: undefined;
|
|
17
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_SECURE_CONTEXT_REQUIRED]: undefined;
|
|
18
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED]: {
|
|
19
|
-
closeEvent: CloseEvent;
|
|
20
|
-
};
|
|
21
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_TIMEOUT]: undefined;
|
|
22
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND]: undefined;
|
|
23
|
-
};
|
|
24
|
-
declare class SolanaMobileWalletAdapterError<TErrorCode extends SolanaMobileWalletAdapterErrorCodeEnum> extends Error {
|
|
25
|
-
data: ErrorDataTypeMap[TErrorCode] | undefined;
|
|
26
|
-
code: TErrorCode;
|
|
27
|
-
constructor(...args: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
28
|
-
code: TErrorCode,
|
|
29
|
-
message: string,
|
|
30
|
-
data: ErrorDataTypeMap[TErrorCode]
|
|
31
|
-
] : [
|
|
32
|
-
code: TErrorCode,
|
|
33
|
-
message: string
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
type JSONRPCErrorCode = number;
|
|
37
|
-
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
38
|
-
declare const SolanaMobileWalletAdapterProtocolErrorCode: {
|
|
39
|
-
readonly ERROR_AUTHORIZATION_FAILED: -1;
|
|
40
|
-
readonly ERROR_INVALID_PAYLOADS: -2;
|
|
41
|
-
readonly ERROR_NOT_SIGNED: -3;
|
|
42
|
-
readonly ERROR_NOT_SUBMITTED: -4;
|
|
43
|
-
readonly ERROR_TOO_MANY_PAYLOADS: -5;
|
|
44
|
-
readonly ERROR_ATTEST_ORIGIN_ANDROID: -100;
|
|
45
|
-
};
|
|
46
|
-
type SolanaMobileWalletAdapterProtocolErrorCodeEnum = (typeof SolanaMobileWalletAdapterProtocolErrorCode)[keyof typeof SolanaMobileWalletAdapterProtocolErrorCode];
|
|
47
|
-
type ProtocolErrorDataTypeMap = {
|
|
48
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_AUTHORIZATION_FAILED]: undefined;
|
|
49
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_INVALID_PAYLOADS]: undefined;
|
|
50
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SIGNED]: undefined;
|
|
51
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SUBMITTED]: undefined;
|
|
52
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_TOO_MANY_PAYLOADS]: undefined;
|
|
53
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_ATTEST_ORIGIN_ANDROID]: {
|
|
54
|
-
attest_origin_uri: string;
|
|
55
|
-
challenge: string;
|
|
56
|
-
context: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
declare class SolanaMobileWalletAdapterProtocolError<TErrorCode extends SolanaMobileWalletAdapterProtocolErrorCodeEnum> extends Error {
|
|
60
|
-
data: ProtocolErrorDataTypeMap[TErrorCode] | undefined;
|
|
61
|
-
code: TErrorCode | JSONRPCErrorCode;
|
|
62
|
-
jsonRpcMessageId: number;
|
|
63
|
-
constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
64
|
-
jsonRpcMessageId: number,
|
|
65
|
-
code: TErrorCode | JSONRPCErrorCode,
|
|
66
|
-
message: string,
|
|
67
|
-
data: ProtocolErrorDataTypeMap[TErrorCode]
|
|
68
|
-
] : [
|
|
69
|
-
jsonRpcMessageId: number,
|
|
70
|
-
code: TErrorCode | JSONRPCErrorCode,
|
|
71
|
-
message: string
|
|
72
|
-
]);
|
|
73
|
-
}
|
|
74
|
-
type Account = Readonly<{
|
|
75
|
-
address: Base64EncodedAddress;
|
|
76
|
-
label?: string;
|
|
77
|
-
}>;
|
|
78
|
-
/**
|
|
79
|
-
* Properties that wallets may present to users when an app
|
|
80
|
-
* asks for authorization to execute privileged methods (see
|
|
81
|
-
* {@link PrivilegedMethods}).
|
|
82
|
-
*/
|
|
83
|
-
type AppIdentity = Readonly<{
|
|
84
|
-
uri?: string;
|
|
85
|
-
icon?: string;
|
|
86
|
-
name?: string;
|
|
87
|
-
}>;
|
|
88
|
-
/**
|
|
89
|
-
* An ephemeral elliptic-curve keypair on the P-256 curve.
|
|
90
|
-
* This public key is used to create the association token.
|
|
91
|
-
* The private key is used during session establishment.
|
|
92
|
-
*/
|
|
93
|
-
type AssociationKeypair = CryptoKeyPair;
|
|
94
|
-
/**
|
|
95
|
-
* The context returned from a wallet after having authorized a given
|
|
96
|
-
* account for use with a given application. You can cache this and
|
|
97
|
-
* use it later to invoke privileged methods.
|
|
98
|
-
*/
|
|
99
|
-
type AuthorizationResult = Readonly<{
|
|
100
|
-
accounts: Account[];
|
|
101
|
-
auth_token: AuthToken;
|
|
102
|
-
wallet_uri_base: string;
|
|
103
|
-
}>;
|
|
104
|
-
type AuthToken = string;
|
|
105
|
-
type Base64EncodedAddress = string;
|
|
106
|
-
type Base64EncodedSignature = string;
|
|
107
|
-
type Base64EncodedMessage = string;
|
|
108
|
-
type Base64EncodedSignedMessage = string;
|
|
109
|
-
type Base64EncodedSignedTransaction = string;
|
|
110
|
-
type Base64EncodedTransaction = string;
|
|
111
|
-
type Cluster = "devnet" | "testnet" | "mainnet-beta";
|
|
112
|
-
type Finality = "confirmed" | "finalized" | "processed";
|
|
113
|
-
type WalletAssociationConfig = Readonly<{
|
|
114
|
-
baseUri?: string;
|
|
115
|
-
}>;
|
|
116
|
-
interface AuthorizeAPI {
|
|
117
|
-
authorize(params: {
|
|
118
|
-
cluster: Cluster;
|
|
119
|
-
identity: AppIdentity;
|
|
120
|
-
}): Promise<AuthorizationResult>;
|
|
121
|
-
}
|
|
122
|
-
interface CloneAuthorizationAPI {
|
|
123
|
-
cloneAuthorization(params: {
|
|
124
|
-
auth_token: AuthToken;
|
|
125
|
-
}): Promise<Readonly<{
|
|
126
|
-
auth_token: AuthToken;
|
|
127
|
-
}>>;
|
|
128
|
-
}
|
|
129
|
-
interface DeauthorizeAPI {
|
|
130
|
-
deauthorize(params: {
|
|
131
|
-
auth_token: AuthToken;
|
|
132
|
-
}): Promise<Readonly<Record<string, never>>>;
|
|
133
|
-
}
|
|
134
|
-
interface GetCapabilitiesAPI {
|
|
135
|
-
getCapabilities(): Promise<Readonly<{
|
|
136
|
-
supports_clone_authorization: boolean;
|
|
137
|
-
supports_sign_and_send_transactions: boolean;
|
|
138
|
-
max_transactions_per_request: boolean;
|
|
139
|
-
max_messages_per_request: boolean;
|
|
140
|
-
supported_transaction_versions: ReadonlyArray<TransactionVersion>;
|
|
141
|
-
}>>;
|
|
142
|
-
}
|
|
143
|
-
interface ReauthorizeAPI {
|
|
144
|
-
reauthorize(params: {
|
|
145
|
-
auth_token: AuthToken;
|
|
146
|
-
}): Promise<AuthorizationResult>;
|
|
147
|
-
}
|
|
148
|
-
interface SignMessagesAPI {
|
|
149
|
-
signMessages(params: {
|
|
150
|
-
addresses: Base64EncodedAddress[];
|
|
151
|
-
payloads: Base64EncodedMessage[];
|
|
152
|
-
}): Promise<Readonly<{
|
|
153
|
-
signed_payloads: Base64EncodedSignedMessage[];
|
|
154
|
-
}>>;
|
|
155
|
-
}
|
|
156
|
-
interface SignTransactionsAPI {
|
|
157
|
-
signTransactions(params: {
|
|
158
|
-
payloads: Base64EncodedTransaction[];
|
|
159
|
-
}): Promise<Readonly<{
|
|
160
|
-
signed_payloads: Base64EncodedSignedTransaction[];
|
|
161
|
-
}>>;
|
|
162
|
-
}
|
|
163
|
-
interface SignAndSendTransactionsAPI {
|
|
164
|
-
signAndSendTransactions(params: {
|
|
165
|
-
options?: Readonly<{
|
|
166
|
-
min_context_slot?: number;
|
|
167
|
-
}>;
|
|
168
|
-
payloads: Base64EncodedTransaction[];
|
|
169
|
-
}): Promise<Readonly<{
|
|
170
|
-
signatures: Base64EncodedSignature[];
|
|
171
|
-
}>>;
|
|
172
|
-
}
|
|
173
|
-
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI {
|
|
174
|
-
}
|
|
175
|
-
declare function transact<TReturn>(callback: (wallet: MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
176
|
-
export { SolanaMobileWalletAdapterErrorCode, SolanaMobileWalletAdapterError, SolanaMobileWalletAdapterProtocolErrorCode, SolanaMobileWalletAdapterProtocolError, transact, Account, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, Base64EncodedAddress, Base64EncodedTransaction, Cluster, Finality, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI, MobileWallet };
|
|
177
|
-
//# sourceMappingURL=index.browser.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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":""}
|
package/lib/types/index.d.mts
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { TransactionVersion } from "@solana/web3.js";
|
|
2
|
-
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
3
|
-
declare const SolanaMobileWalletAdapterErrorCode: {
|
|
4
|
-
readonly ERROR_ASSOCIATION_PORT_OUT_OF_RANGE: "ERROR_ASSOCIATION_PORT_OUT_OF_RANGE";
|
|
5
|
-
readonly ERROR_FORBIDDEN_WALLET_BASE_URL: "ERROR_FORBIDDEN_WALLET_BASE_URL";
|
|
6
|
-
readonly ERROR_SECURE_CONTEXT_REQUIRED: "ERROR_SECURE_CONTEXT_REQUIRED";
|
|
7
|
-
readonly ERROR_SESSION_CLOSED: "ERROR_SESSION_CLOSED";
|
|
8
|
-
readonly ERROR_SESSION_TIMEOUT: "ERROR_SESSION_TIMEOUT";
|
|
9
|
-
readonly ERROR_WALLET_NOT_FOUND: "ERROR_WALLET_NOT_FOUND";
|
|
10
|
-
};
|
|
11
|
-
type SolanaMobileWalletAdapterErrorCodeEnum = (typeof SolanaMobileWalletAdapterErrorCode)[keyof typeof SolanaMobileWalletAdapterErrorCode];
|
|
12
|
-
type ErrorDataTypeMap = {
|
|
13
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_PORT_OUT_OF_RANGE]: {
|
|
14
|
-
port: number;
|
|
15
|
-
};
|
|
16
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL]: undefined;
|
|
17
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_SECURE_CONTEXT_REQUIRED]: undefined;
|
|
18
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED]: {
|
|
19
|
-
closeEvent: CloseEvent;
|
|
20
|
-
};
|
|
21
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_TIMEOUT]: undefined;
|
|
22
|
-
[SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND]: undefined;
|
|
23
|
-
};
|
|
24
|
-
declare class SolanaMobileWalletAdapterError<TErrorCode extends SolanaMobileWalletAdapterErrorCodeEnum> extends Error {
|
|
25
|
-
data: ErrorDataTypeMap[TErrorCode] | undefined;
|
|
26
|
-
code: TErrorCode;
|
|
27
|
-
constructor(...args: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
28
|
-
code: TErrorCode,
|
|
29
|
-
message: string,
|
|
30
|
-
data: ErrorDataTypeMap[TErrorCode]
|
|
31
|
-
] : [
|
|
32
|
-
code: TErrorCode,
|
|
33
|
-
message: string
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
type JSONRPCErrorCode = number;
|
|
37
|
-
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
38
|
-
declare const SolanaMobileWalletAdapterProtocolErrorCode: {
|
|
39
|
-
readonly ERROR_AUTHORIZATION_FAILED: -1;
|
|
40
|
-
readonly ERROR_INVALID_PAYLOADS: -2;
|
|
41
|
-
readonly ERROR_NOT_SIGNED: -3;
|
|
42
|
-
readonly ERROR_NOT_SUBMITTED: -4;
|
|
43
|
-
readonly ERROR_TOO_MANY_PAYLOADS: -5;
|
|
44
|
-
readonly ERROR_ATTEST_ORIGIN_ANDROID: -100;
|
|
45
|
-
};
|
|
46
|
-
type SolanaMobileWalletAdapterProtocolErrorCodeEnum = (typeof SolanaMobileWalletAdapterProtocolErrorCode)[keyof typeof SolanaMobileWalletAdapterProtocolErrorCode];
|
|
47
|
-
type ProtocolErrorDataTypeMap = {
|
|
48
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_AUTHORIZATION_FAILED]: undefined;
|
|
49
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_INVALID_PAYLOADS]: undefined;
|
|
50
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SIGNED]: undefined;
|
|
51
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_NOT_SUBMITTED]: undefined;
|
|
52
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_TOO_MANY_PAYLOADS]: undefined;
|
|
53
|
-
[SolanaMobileWalletAdapterProtocolErrorCode.ERROR_ATTEST_ORIGIN_ANDROID]: {
|
|
54
|
-
attest_origin_uri: string;
|
|
55
|
-
challenge: string;
|
|
56
|
-
context: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
declare class SolanaMobileWalletAdapterProtocolError<TErrorCode extends SolanaMobileWalletAdapterProtocolErrorCodeEnum> extends Error {
|
|
60
|
-
data: ProtocolErrorDataTypeMap[TErrorCode] | undefined;
|
|
61
|
-
code: TErrorCode | JSONRPCErrorCode;
|
|
62
|
-
jsonRpcMessageId: number;
|
|
63
|
-
constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
|
|
64
|
-
jsonRpcMessageId: number,
|
|
65
|
-
code: TErrorCode | JSONRPCErrorCode,
|
|
66
|
-
message: string,
|
|
67
|
-
data: ProtocolErrorDataTypeMap[TErrorCode]
|
|
68
|
-
] : [
|
|
69
|
-
jsonRpcMessageId: number,
|
|
70
|
-
code: TErrorCode | JSONRPCErrorCode,
|
|
71
|
-
message: string
|
|
72
|
-
]);
|
|
73
|
-
}
|
|
74
|
-
type Account = Readonly<{
|
|
75
|
-
address: Base64EncodedAddress;
|
|
76
|
-
label?: string;
|
|
77
|
-
}>;
|
|
78
|
-
/**
|
|
79
|
-
* Properties that wallets may present to users when an app
|
|
80
|
-
* asks for authorization to execute privileged methods (see
|
|
81
|
-
* {@link PrivilegedMethods}).
|
|
82
|
-
*/
|
|
83
|
-
type AppIdentity = Readonly<{
|
|
84
|
-
uri?: string;
|
|
85
|
-
icon?: string;
|
|
86
|
-
name?: string;
|
|
87
|
-
}>;
|
|
88
|
-
/**
|
|
89
|
-
* An ephemeral elliptic-curve keypair on the P-256 curve.
|
|
90
|
-
* This public key is used to create the association token.
|
|
91
|
-
* The private key is used during session establishment.
|
|
92
|
-
*/
|
|
93
|
-
type AssociationKeypair = CryptoKeyPair;
|
|
94
|
-
/**
|
|
95
|
-
* The context returned from a wallet after having authorized a given
|
|
96
|
-
* account for use with a given application. You can cache this and
|
|
97
|
-
* use it later to invoke privileged methods.
|
|
98
|
-
*/
|
|
99
|
-
type AuthorizationResult = Readonly<{
|
|
100
|
-
accounts: Account[];
|
|
101
|
-
auth_token: AuthToken;
|
|
102
|
-
wallet_uri_base: string;
|
|
103
|
-
}>;
|
|
104
|
-
type AuthToken = string;
|
|
105
|
-
type Base64EncodedAddress = string;
|
|
106
|
-
type Base64EncodedSignature = string;
|
|
107
|
-
type Base64EncodedMessage = string;
|
|
108
|
-
type Base64EncodedSignedMessage = string;
|
|
109
|
-
type Base64EncodedSignedTransaction = string;
|
|
110
|
-
type Base64EncodedTransaction = string;
|
|
111
|
-
type Cluster = "devnet" | "testnet" | "mainnet-beta";
|
|
112
|
-
type Finality = "confirmed" | "finalized" | "processed";
|
|
113
|
-
type WalletAssociationConfig = Readonly<{
|
|
114
|
-
baseUri?: string;
|
|
115
|
-
}>;
|
|
116
|
-
interface AuthorizeAPI {
|
|
117
|
-
authorize(params: {
|
|
118
|
-
cluster: Cluster;
|
|
119
|
-
identity: AppIdentity;
|
|
120
|
-
}): Promise<AuthorizationResult>;
|
|
121
|
-
}
|
|
122
|
-
interface CloneAuthorizationAPI {
|
|
123
|
-
cloneAuthorization(params: {
|
|
124
|
-
auth_token: AuthToken;
|
|
125
|
-
}): Promise<Readonly<{
|
|
126
|
-
auth_token: AuthToken;
|
|
127
|
-
}>>;
|
|
128
|
-
}
|
|
129
|
-
interface DeauthorizeAPI {
|
|
130
|
-
deauthorize(params: {
|
|
131
|
-
auth_token: AuthToken;
|
|
132
|
-
}): Promise<Readonly<Record<string, never>>>;
|
|
133
|
-
}
|
|
134
|
-
interface GetCapabilitiesAPI {
|
|
135
|
-
getCapabilities(): Promise<Readonly<{
|
|
136
|
-
supports_clone_authorization: boolean;
|
|
137
|
-
supports_sign_and_send_transactions: boolean;
|
|
138
|
-
max_transactions_per_request: boolean;
|
|
139
|
-
max_messages_per_request: boolean;
|
|
140
|
-
supported_transaction_versions: ReadonlyArray<TransactionVersion>;
|
|
141
|
-
}>>;
|
|
142
|
-
}
|
|
143
|
-
interface ReauthorizeAPI {
|
|
144
|
-
reauthorize(params: {
|
|
145
|
-
auth_token: AuthToken;
|
|
146
|
-
}): Promise<AuthorizationResult>;
|
|
147
|
-
}
|
|
148
|
-
interface SignMessagesAPI {
|
|
149
|
-
signMessages(params: {
|
|
150
|
-
addresses: Base64EncodedAddress[];
|
|
151
|
-
payloads: Base64EncodedMessage[];
|
|
152
|
-
}): Promise<Readonly<{
|
|
153
|
-
signed_payloads: Base64EncodedSignedMessage[];
|
|
154
|
-
}>>;
|
|
155
|
-
}
|
|
156
|
-
interface SignTransactionsAPI {
|
|
157
|
-
signTransactions(params: {
|
|
158
|
-
payloads: Base64EncodedTransaction[];
|
|
159
|
-
}): Promise<Readonly<{
|
|
160
|
-
signed_payloads: Base64EncodedSignedTransaction[];
|
|
161
|
-
}>>;
|
|
162
|
-
}
|
|
163
|
-
interface SignAndSendTransactionsAPI {
|
|
164
|
-
signAndSendTransactions(params: {
|
|
165
|
-
options?: Readonly<{
|
|
166
|
-
min_context_slot?: number;
|
|
167
|
-
}>;
|
|
168
|
-
payloads: Base64EncodedTransaction[];
|
|
169
|
-
}): Promise<Readonly<{
|
|
170
|
-
signatures: Base64EncodedSignature[];
|
|
171
|
-
}>>;
|
|
172
|
-
}
|
|
173
|
-
interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI {
|
|
174
|
-
}
|
|
175
|
-
declare function transact<TReturn>(callback: (wallet: MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
176
|
-
export { SolanaMobileWalletAdapterErrorCode, SolanaMobileWalletAdapterError, SolanaMobileWalletAdapterProtocolErrorCode, SolanaMobileWalletAdapterProtocolError, transact, Account, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, Base64EncodedAddress, Base64EncodedTransaction, Cluster, Finality, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, SignMessagesAPI, SignTransactionsAPI, SignAndSendTransactionsAPI, MobileWallet };
|
|
177
|
-
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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":""}
|