@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.
@@ -1,57 +1,77 @@
1
- declare class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
2
- constructor();
3
- }
4
- declare class SolanaMobileWalletAdapterForbiddenWalletBaseURLError extends Error {
5
- constructor();
6
- }
7
- declare class SolanaMobileWalletAdapterWalletNotInstalledError extends Error {
8
- constructor();
9
- }
10
- declare class SolanaMobileWalletAdapterProtocolSessionEstablishmentError extends Error {
11
- constructor(port: number);
12
- }
13
- declare class SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError extends Error {
14
- constructor(port: number);
15
- }
16
- declare class SolanaMobileWalletAdapterProtocolSessionClosedError extends Error {
17
- constructor(code: number, reason: string);
18
- }
19
- declare class SolanaMobileWalletAdapterProtocolReauthorizeError extends Error {
20
- constructor();
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 SolanaMobileWalletAdapterProtocolError: {
25
- readonly ERROR_REAUTHORIZE: -1;
26
- readonly ERROR_AUTHORIZATION_FAILED: -2;
27
- readonly ERROR_INVALID_PAYLOAD: -3;
28
- readonly ERROR_NOT_SIGNED: -4;
29
- readonly ERROR_NOT_COMMITTED: -5;
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 SolanaMobileWalletAdapterProtocolErrorEnum = (typeof SolanaMobileWalletAdapterProtocolError)[keyof typeof SolanaMobileWalletAdapterProtocolError];
33
- type ErrorDataTypeMap = {
34
- [SolanaMobileWalletAdapterProtocolError.ERROR_ATTEST_ORIGIN_ANDROID]: {
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 SolanaMobileWalletAdapterProtocolJsonRpcError<TErrorCode extends keyof ErrorDataTypeMap> extends Error {
41
- data: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? ErrorDataTypeMap[TErrorCode] : undefined;
42
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode;
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: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
60
+ constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
45
61
  jsonRpcMessageId: number,
46
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode,
62
+ code: TErrorCode | JSONRPCErrorCode,
47
63
  message: string,
48
- data: ErrorDataTypeMap[TErrorCode]
64
+ data: ProtocolErrorDataTypeMap[TErrorCode]
49
65
  ] : [
50
66
  jsonRpcMessageId: number,
51
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode,
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 Base58EncodedSignature = string;
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<Readonly<{
111
- auth_token: AuthToken;
112
- }>>;
134
+ }): Promise<AuthorizationResult>;
113
135
  }
114
- interface SignMessageAPI {
115
- signMessage(params: {
116
- auth_token: AuthToken;
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 SignTransactionAPI {
123
- signTransaction(params: {
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 SignAndSendTransactionAPI {
131
- signAndSendTransaction(params: {
132
- auth_token: AuthToken;
133
- commitment: "confirmed" | "finalized" | "processed";
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: Base58EncodedSignature[];
158
+ signatures: Base64EncodedSignature[];
137
159
  }>>;
138
160
  }
139
- interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessageAPI, SignTransactionAPI, SignAndSendTransactionAPI {
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 { SolanaMobileWalletAdapterSecureContextRequiredError, SolanaMobileWalletAdapterForbiddenWalletBaseURLError, SolanaMobileWalletAdapterWalletNotInstalledError, SolanaMobileWalletAdapterProtocolSessionEstablishmentError, SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError, SolanaMobileWalletAdapterProtocolSessionClosedError, SolanaMobileWalletAdapterProtocolReauthorizeError, SolanaMobileWalletAdapterProtocolError, SolanaMobileWalletAdapterProtocolJsonRpcError, transact, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessageAPI, SignTransactionAPI, SignAndSendTransactionAPI, MobileWallet };
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
- declare class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
2
- constructor();
3
- }
4
- declare class SolanaMobileWalletAdapterForbiddenWalletBaseURLError extends Error {
5
- constructor();
6
- }
7
- declare class SolanaMobileWalletAdapterWalletNotInstalledError extends Error {
8
- constructor();
9
- }
10
- declare class SolanaMobileWalletAdapterProtocolSessionEstablishmentError extends Error {
11
- constructor(port: number);
12
- }
13
- declare class SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError extends Error {
14
- constructor(port: number);
15
- }
16
- declare class SolanaMobileWalletAdapterProtocolSessionClosedError extends Error {
17
- constructor(code: number, reason: string);
18
- }
19
- declare class SolanaMobileWalletAdapterProtocolReauthorizeError extends Error {
20
- constructor();
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 SolanaMobileWalletAdapterProtocolError: {
25
- readonly ERROR_REAUTHORIZE: -1;
26
- readonly ERROR_AUTHORIZATION_FAILED: -2;
27
- readonly ERROR_INVALID_PAYLOAD: -3;
28
- readonly ERROR_NOT_SIGNED: -4;
29
- readonly ERROR_NOT_COMMITTED: -5;
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 SolanaMobileWalletAdapterProtocolErrorEnum = (typeof SolanaMobileWalletAdapterProtocolError)[keyof typeof SolanaMobileWalletAdapterProtocolError];
33
- type ErrorDataTypeMap = {
34
- [SolanaMobileWalletAdapterProtocolError.ERROR_ATTEST_ORIGIN_ANDROID]: {
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 SolanaMobileWalletAdapterProtocolJsonRpcError<TErrorCode extends keyof ErrorDataTypeMap> extends Error {
41
- data: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? ErrorDataTypeMap[TErrorCode] : undefined;
42
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode;
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: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
60
+ constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
45
61
  jsonRpcMessageId: number,
46
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode,
62
+ code: TErrorCode | JSONRPCErrorCode,
47
63
  message: string,
48
- data: ErrorDataTypeMap[TErrorCode]
64
+ data: ProtocolErrorDataTypeMap[TErrorCode]
49
65
  ] : [
50
66
  jsonRpcMessageId: number,
51
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode,
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 Base58EncodedSignature = string;
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<Readonly<{
111
- auth_token: AuthToken;
112
- }>>;
134
+ }): Promise<AuthorizationResult>;
113
135
  }
114
- interface SignMessageAPI {
115
- signMessage(params: {
116
- auth_token: AuthToken;
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 SignTransactionAPI {
123
- signTransaction(params: {
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 SignAndSendTransactionAPI {
131
- signAndSendTransaction(params: {
132
- auth_token: AuthToken;
133
- commitment: "confirmed" | "finalized" | "processed";
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: Base58EncodedSignature[];
158
+ signatures: Base64EncodedSignature[];
137
159
  }>>;
138
160
  }
139
- interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessageAPI, SignTransactionAPI, SignAndSendTransactionAPI {
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 { SolanaMobileWalletAdapterSecureContextRequiredError, SolanaMobileWalletAdapterForbiddenWalletBaseURLError, SolanaMobileWalletAdapterWalletNotInstalledError, SolanaMobileWalletAdapterProtocolSessionEstablishmentError, SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError, SolanaMobileWalletAdapterProtocolSessionClosedError, SolanaMobileWalletAdapterProtocolReauthorizeError, SolanaMobileWalletAdapterProtocolError, SolanaMobileWalletAdapterProtocolJsonRpcError, transact, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessageAPI, SignTransactionAPI, SignAndSendTransactionAPI, MobileWallet };
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":""}
@@ -1,57 +1,77 @@
1
- declare class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
2
- constructor();
3
- }
4
- declare class SolanaMobileWalletAdapterForbiddenWalletBaseURLError extends Error {
5
- constructor();
6
- }
7
- declare class SolanaMobileWalletAdapterWalletNotInstalledError extends Error {
8
- constructor();
9
- }
10
- declare class SolanaMobileWalletAdapterProtocolSessionEstablishmentError extends Error {
11
- constructor(port: number);
12
- }
13
- declare class SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError extends Error {
14
- constructor(port: number);
15
- }
16
- declare class SolanaMobileWalletAdapterProtocolSessionClosedError extends Error {
17
- constructor(code: number, reason: string);
18
- }
19
- declare class SolanaMobileWalletAdapterProtocolReauthorizeError extends Error {
20
- constructor();
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 SolanaMobileWalletAdapterProtocolError: {
25
- readonly ERROR_REAUTHORIZE: -1;
26
- readonly ERROR_AUTHORIZATION_FAILED: -2;
27
- readonly ERROR_INVALID_PAYLOAD: -3;
28
- readonly ERROR_NOT_SIGNED: -4;
29
- readonly ERROR_NOT_COMMITTED: -5;
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 SolanaMobileWalletAdapterProtocolErrorEnum = (typeof SolanaMobileWalletAdapterProtocolError)[keyof typeof SolanaMobileWalletAdapterProtocolError];
33
- type ErrorDataTypeMap = {
34
- [SolanaMobileWalletAdapterProtocolError.ERROR_ATTEST_ORIGIN_ANDROID]: {
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 SolanaMobileWalletAdapterProtocolJsonRpcError<TErrorCode extends keyof ErrorDataTypeMap> extends Error {
41
- data: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? ErrorDataTypeMap[TErrorCode] : undefined;
42
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode;
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: ErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
60
+ constructor(...args: ProtocolErrorDataTypeMap[TErrorCode] extends Record<string, unknown> ? [
45
61
  jsonRpcMessageId: number,
46
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode,
62
+ code: TErrorCode | JSONRPCErrorCode,
47
63
  message: string,
48
- data: ErrorDataTypeMap[TErrorCode]
64
+ data: ProtocolErrorDataTypeMap[TErrorCode]
49
65
  ] : [
50
66
  jsonRpcMessageId: number,
51
- code: SolanaMobileWalletAdapterProtocolErrorEnum | JSONRPCErrorCode,
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 Base58EncodedSignature = string;
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<Readonly<{
111
- auth_token: AuthToken;
112
- }>>;
134
+ }): Promise<AuthorizationResult>;
113
135
  }
114
- interface SignMessageAPI {
115
- signMessage(params: {
116
- auth_token: AuthToken;
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 SignTransactionAPI {
123
- signTransaction(params: {
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 SignAndSendTransactionAPI {
131
- signAndSendTransaction(params: {
132
- auth_token: AuthToken;
133
- commitment: "confirmed" | "finalized" | "processed";
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: Base58EncodedSignature[];
158
+ signatures: Base64EncodedSignature[];
137
159
  }>>;
138
160
  }
139
- interface MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessageAPI, SignTransactionAPI, SignAndSendTransactionAPI {
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 { SolanaMobileWalletAdapterSecureContextRequiredError, SolanaMobileWalletAdapterForbiddenWalletBaseURLError, SolanaMobileWalletAdapterWalletNotInstalledError, SolanaMobileWalletAdapterProtocolSessionEstablishmentError, SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError, SolanaMobileWalletAdapterProtocolSessionClosedError, SolanaMobileWalletAdapterProtocolReauthorizeError, SolanaMobileWalletAdapterProtocolError, SolanaMobileWalletAdapterProtocolJsonRpcError, transact, AppIdentity, AssociationKeypair, AuthorizationResult, AuthToken, WalletAssociationConfig, AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, SignMessageAPI, SignTransactionAPI, SignAndSendTransactionAPI, MobileWallet };
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":""}