@solana-mobile/mobile-wallet-adapter-walletlib 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +202 -196
  3. package/android/build.gradle +151 -151
  4. package/android/gradle/wrapper/gradle-wrapper.properties +5 -5
  5. package/android/gradle.properties +5 -5
  6. package/android/gradlew +185 -185
  7. package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/Extensions.kt +98 -98
  8. package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/JsonSerializationUtils.kt +156 -156
  9. package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/MobileWalletAdapterWalletLibReactNativePackage.kt +18 -18
  10. package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/SolanaMobileWalletAdapterWalletLibModule.kt +691 -691
  11. package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterConfig.kt +59 -59
  12. package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterRequest.kt +97 -97
  13. package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterResponse.kt +68 -68
  14. package/lib/esm/index.js +119 -194
  15. package/lib/esm/index.js.map +1 -0
  16. package/lib/esm/index.native.js +119 -194
  17. package/lib/esm/index.native.js.map +1 -0
  18. package/lib/esm/package.json +1 -3
  19. package/lib/types/index.d.ts +124 -112
  20. package/lib/types/index.d.ts.map +1 -1
  21. package/package.json +49 -46
  22. package/lib/types/index.native.d.ts +0 -226
  23. package/lib/types/index.native.d.ts.map +0 -1
@@ -1,226 +0,0 @@
1
- import { IdentifierArray } from "@wallet-standard/core";
2
- import { TransactionVersion } from "@solana/web3.js";
3
- import { EmitterSubscription } from "react-native";
4
- /**
5
- * Mobile Wallet Adapter Session Events are notifications and events
6
- * about the underlying session between the wallet and the dApp.
7
- */
8
- declare enum MWASessionEventType {
9
- SessionStartEvent = "SESSION_START",
10
- SessionReadyEvent = "SESSION_READY",
11
- SessionTerminatedEvent = "SESSION_TERMINATED",
12
- SessionServingClientsEvent = "SESSION_SERVING_CLIENTS",
13
- SessionServingCompleteEvent = "SESSION_SERVING_COMPLETE",
14
- SessionCompleteEvent = "SESSION_COMPLETE",
15
- SessionErrorEvent = "SESSION_ERROR",
16
- SessionTeardownCompleteEvent = "SESSION_TEARDOWN_COMPLETE",
17
- LowPowerNoConnectionEvent = "LOW_POWER_NO_CONNECTION"
18
- }
19
- interface IMWASessionEvent {
20
- __type: MWASessionEventType;
21
- sessionId: string;
22
- }
23
- type SessionStartEvent = Readonly<{
24
- __type: MWASessionEventType.SessionStartEvent;
25
- }> & IMWASessionEvent;
26
- type SessionReadyEvent = Readonly<{
27
- __type: MWASessionEventType.SessionReadyEvent;
28
- }> & IMWASessionEvent;
29
- type SessionTerminatedEvent = Readonly<{
30
- __type: MWASessionEventType.SessionTerminatedEvent;
31
- }> & IMWASessionEvent;
32
- type SessionServingClientsEvent = Readonly<{
33
- __type: MWASessionEventType.SessionServingClientsEvent;
34
- }> & IMWASessionEvent;
35
- type SessionServingCompleteEvent = Readonly<{
36
- __type: MWASessionEventType.SessionServingCompleteEvent;
37
- }> & IMWASessionEvent;
38
- type SessionCompleteEvent = Readonly<{
39
- __type: MWASessionEventType.SessionCompleteEvent;
40
- }> & IMWASessionEvent;
41
- type SessionErrorEvent = Readonly<{
42
- __type: MWASessionEventType.SessionErrorEvent;
43
- }> & IMWASessionEvent;
44
- type SessionTeardownCompleteEvent = Readonly<{
45
- __type: MWASessionEventType.SessionTeardownCompleteEvent;
46
- }> & IMWASessionEvent;
47
- type LowPowerNoConnectionEvent = Readonly<{
48
- __type: MWASessionEventType.LowPowerNoConnectionEvent;
49
- }> & IMWASessionEvent;
50
- type MWASessionEvent = SessionStartEvent | SessionReadyEvent | SessionTerminatedEvent | SessionServingClientsEvent | SessionServingCompleteEvent | SessionCompleteEvent | SessionErrorEvent | SessionTeardownCompleteEvent | LowPowerNoConnectionEvent;
51
- type AppIdentity = Readonly<{
52
- identityUri?: string;
53
- iconRelativeUri?: string;
54
- identityName?: string;
55
- }>;
56
- type SignInPayload = Readonly<{
57
- domain?: string;
58
- address?: string;
59
- statement?: string;
60
- uri?: string;
61
- version?: string;
62
- chainId?: string;
63
- nonce?: string;
64
- issuedAt?: string;
65
- expirationTime?: string;
66
- notBefore?: string;
67
- requestId?: string;
68
- resources?: readonly string[];
69
- }>;
70
- type Base64EncodedAddress = string;
71
- type Base64EncodedSignature = string;
72
- type Base64EncodedSignedMessage = string;
73
- /**
74
- * Mobile Wallet Adapter Requests are remote requests coming from
75
- * the dApp for authorization, signing, and sending services.
76
- */
77
- type MWARequest = SignMessagesRequest | SignTransactionsRequest | SignAndSendTransactionsRequest | AuthorizeDappRequest | ReauthorizeDappRequest | DeauthorizeDappRequest;
78
- declare enum MWARequestType {
79
- AuthorizeDappRequest = "AUTHORIZE_DAPP",
80
- ReauthorizeDappRequest = "REAUTHORIZE_DAPP",
81
- DeauthorizeDappRequest = "DEAUTHORIZE_DAPP",
82
- SignMessagesRequest = "SIGN_MESSAGES",
83
- SignTransactionsRequest = "SIGN_TRANSACTIONS",
84
- SignAndSendTransactionsRequest = "SIGN_AND_SEND_TRANSACTIONS"
85
- }
86
- interface IMWARequest {
87
- __type: MWARequestType;
88
- requestId: string;
89
- sessionId: string;
90
- }
91
- interface IVerifiableIdentityRequest {
92
- chain: string;
93
- authorizationScope: Uint8Array;
94
- appIdentity?: AppIdentity;
95
- }
96
- type AuthorizeDappRequest = Readonly<{
97
- __type: MWARequestType.AuthorizeDappRequest;
98
- chain: string;
99
- appIdentity?: AppIdentity;
100
- features?: IdentifierArray;
101
- addresses?: [
102
- string
103
- ];
104
- signInPayload?: SignInPayload;
105
- }> & IMWARequest;
106
- type ReauthorizeDappRequest = Readonly<{
107
- __type: MWARequestType.ReauthorizeDappRequest;
108
- }> & IMWARequest & IVerifiableIdentityRequest;
109
- type DeauthorizeDappRequest = Readonly<{
110
- __type: MWARequestType.DeauthorizeDappRequest;
111
- }> & IMWARequest & IVerifiableIdentityRequest;
112
- type SignMessagesRequest = Readonly<{
113
- __type: MWARequestType.SignMessagesRequest;
114
- payloads: Uint8Array[];
115
- }> & IMWARequest & IVerifiableIdentityRequest;
116
- type SignTransactionsRequest = Readonly<{
117
- __type: MWARequestType.SignTransactionsRequest;
118
- payloads: Uint8Array[];
119
- }> & IMWARequest & IVerifiableIdentityRequest;
120
- type SignAndSendTransactionsRequest = Readonly<{
121
- __type: MWARequestType.SignAndSendTransactionsRequest;
122
- payloads: Uint8Array[];
123
- minContextSlot?: number;
124
- commitment?: string;
125
- skipPreflight?: boolean;
126
- maxRetries?: number;
127
- waitForCommitmentToSendNextTransaction?: boolean;
128
- }> & IMWARequest & IVerifiableIdentityRequest;
129
- /**
130
- * MWA Request Responses
131
- */
132
- type MWAResponse = AuthorizeDappResponse | ReauthorizeDappResponse | DeauthorizeDappResponse | SignMessagesResponse | SignTransactionsResponse | SignAndSendTransactionsResponse;
133
- /* Failure Responses */
134
- declare enum MWARequestFailReason {
135
- UserDeclined = "USER_DECLINED",
136
- TooManyPayloads = "TOO_MANY_PAYLOADS",
137
- InvalidSignatures = "INVALID_SIGNATURES",
138
- AuthorizationNotValid = "AUTHORIZATION_NOT_VALID"
139
- }
140
- type UserDeclinedResponse = Readonly<{
141
- failReason: MWARequestFailReason.UserDeclined;
142
- }>;
143
- type TooManyPayloadsResponse = Readonly<{
144
- failReason: MWARequestFailReason.TooManyPayloads;
145
- }>;
146
- type AuthorizationNotValidResponse = Readonly<{
147
- failReason: MWARequestFailReason.AuthorizationNotValid;
148
- }>;
149
- type InvalidSignaturesResponse = Readonly<{
150
- failReason: MWARequestFailReason.InvalidSignatures;
151
- valid: boolean[];
152
- }>;
153
- /* Authorize Dapp */
154
- type AuthorizedAccount = Readonly<{
155
- publicKey: Uint8Array;
156
- accountLabel?: string;
157
- icon?: string;
158
- chains?: IdentifierArray;
159
- features?: IdentifierArray;
160
- }>;
161
- type SignInResult = Readonly<{
162
- address: Base64EncodedAddress;
163
- signed_message: Base64EncodedSignedMessage;
164
- signature: Base64EncodedSignature;
165
- signature_type?: string;
166
- }>;
167
- type AuthorizeDappCompleteResponse = Readonly<{
168
- accounts: Array<AuthorizedAccount>;
169
- walletUriBase?: string;
170
- authorizationScope?: Uint8Array;
171
- signInResult?: SignInResult;
172
- }>;
173
- type AuthorizeDappResponse = AuthorizeDappCompleteResponse | UserDeclinedResponse;
174
- /* Reauthorize Dapp */
175
- type ReauthorizeDappCompleteResponse = Readonly<{
176
- authorizationScope?: Uint8Array;
177
- }>;
178
- type ReauthorizeDappResponse = ReauthorizeDappCompleteResponse | AuthorizationNotValidResponse;
179
- /* Deauthorize Dapp */
180
- type DeauthorizeDappCompleteResponse = Readonly<{}>;
181
- type DeauthorizeDappResponse = DeauthorizeDappCompleteResponse | AuthorizationNotValidResponse;
182
- /* Sign Transactions/Messages */
183
- type SignPayloadsCompleteResponse = Readonly<{
184
- signedPayloads: Uint8Array[];
185
- }>;
186
- type SignPayloadsFailResponse = UserDeclinedResponse | TooManyPayloadsResponse | AuthorizationNotValidResponse | InvalidSignaturesResponse;
187
- type SignTransactionsResponse = SignPayloadsCompleteResponse | SignPayloadsFailResponse;
188
- type SignMessagesResponse = SignPayloadsCompleteResponse | SignPayloadsFailResponse;
189
- /* Sign and Send Transaction */
190
- type SignAndSendTransactionsCompleteResponse = Readonly<{
191
- signedTransactions: Uint8Array[];
192
- }>;
193
- type SignAndSendTransactionsResponse = SignAndSendTransactionsCompleteResponse | UserDeclinedResponse | TooManyPayloadsResponse | AuthorizationNotValidResponse | InvalidSignaturesResponse;
194
- declare function resolve(request: AuthorizeDappRequest, response: AuthorizeDappResponse): void;
195
- declare function resolve(request: ReauthorizeDappRequest, response: ReauthorizeDappResponse): void;
196
- declare function resolve(request: DeauthorizeDappRequest, response: DeauthorizeDappResponse): void;
197
- declare function resolve(request: SignMessagesRequest, response: SignMessagesResponse): void;
198
- declare function resolve(request: SignTransactionsRequest, response: SignTransactionsResponse): void;
199
- declare function resolve(request: SignAndSendTransactionsRequest, response: SignAndSendTransactionsResponse): void;
200
- type MWASessionId = string;
201
- interface MobileWalletAdapterConfig {
202
- maxTransactionsPerSigningRequest: number;
203
- maxMessagesPerSigningRequest: number;
204
- supportedTransactionVersions: Array<TransactionVersion>;
205
- noConnectionWarningTimeoutMs: number;
206
- optionalFeatures: IdentifierArray;
207
- }
208
- declare function initializeMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig): Promise<MWASessionId>;
209
- declare function useMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig, handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): void;
210
- declare function initializeMWAEventListener(handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): EmitterSubscription;
211
- declare function getCallingPackage(): Promise<string | undefined>;
212
- declare function verifyCallingPackage(clientIdentityUri: string): Promise<any>;
213
- declare function getCallingPackageUid(): Promise<any>;
214
- declare function getUidForPackage(packageName: string): Promise<any>;
215
- declare enum SolanaMWAWalletLibErrorCode {
216
- ERROR_INTENT_DATA_NOT_FOUND = "ERROR_INTENT_DATA_NOT_FOUND",
217
- ERROR_SESSION_ALREADY_CREATED = "ERROR_SESSION_ALREADY_CREATED",
218
- ERROR_UNSUPPORTED_ASSOCIATION_URI = "ERROR_UNSUPPORTED_ASSOCIATION_URI",
219
- ERROR_UNSUPPORTED_ASSOCIATION_TYPE = "ERROR_UNSUPPORTED_ASSOCIATION_TYPE"
220
- }
221
- declare class SolanaMWAWalletLibError extends Error {
222
- code: SolanaMWAWalletLibErrorCode;
223
- constructor(code: SolanaMWAWalletLibErrorCode, message: string);
224
- }
225
- export { MWASessionEventType, IMWASessionEvent, SessionStartEvent, SessionReadyEvent, SessionTerminatedEvent, SessionServingClientsEvent, SessionServingCompleteEvent, SessionCompleteEvent, SessionErrorEvent, SessionTeardownCompleteEvent, LowPowerNoConnectionEvent, MWASessionEvent, SignInPayload, Base64EncodedAddress, Base64EncodedSignature, MWARequest, MWARequestType, AuthorizeDappRequest, ReauthorizeDappRequest, DeauthorizeDappRequest, SignMessagesRequest, SignTransactionsRequest, SignAndSendTransactionsRequest, MWAResponse, MWARequestFailReason, UserDeclinedResponse, TooManyPayloadsResponse, AuthorizationNotValidResponse, InvalidSignaturesResponse, AuthorizedAccount, SignInResult, AuthorizeDappCompleteResponse, AuthorizeDappResponse, ReauthorizeDappCompleteResponse, ReauthorizeDappResponse, DeauthorizeDappCompleteResponse, DeauthorizeDappResponse, SignPayloadsCompleteResponse, SignPayloadsFailResponse, SignTransactionsResponse, SignMessagesResponse, SignAndSendTransactionsCompleteResponse, SignAndSendTransactionsResponse, resolve, useMobileWalletAdapterSession, MWASessionId, MobileWalletAdapterConfig, initializeMobileWalletAdapterSession, initializeMWAEventListener, getCallingPackage, verifyCallingPackage, getCallingPackageUid, getUidForPackage, SolanaMWAWalletLibErrorCode, SolanaMWAWalletLibError };
226
- //# sourceMappingURL=index.native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/mwaSessionEvents.ts","../../src/resolve.ts","../../src/errors.ts","../../src/initializeMobileWalletAdapterSession.ts","../../src/initializeMWAEventListener.ts","../../src/useMobileWalletAdapterSession.ts","../../src/useDigitalAssetLinks.ts"],"names":[],"mappings":""}