@solana-mobile/mobile-wallet-adapter-walletlib 1.3.0 → 1.4.0-beta2

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/esm/index.js CHANGED
@@ -54,6 +54,46 @@ function resolve(request, response) {
54
54
  SolanaMobileWalletAdapterWalletLib$1.resolve(JSON.stringify(request), JSON.stringify(response));
55
55
  }
56
56
 
57
+ /******************************************************************************
58
+ Copyright (c) Microsoft Corporation.
59
+
60
+ Permission to use, copy, modify, and/or distribute this software for any
61
+ purpose with or without fee is hereby granted.
62
+
63
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
64
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
65
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
66
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
67
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
68
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
69
+ PERFORMANCE OF THIS SOFTWARE.
70
+ ***************************************************************************** */
71
+
72
+ function __awaiter(thisArg, _arguments, P, generator) {
73
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
74
+ return new (P || (P = Promise))(function (resolve, reject) {
75
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
76
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
77
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
78
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
79
+ });
80
+ }
81
+
82
+ var SolanaMWAWalletLibErrorCode;
83
+ (function (SolanaMWAWalletLibErrorCode) {
84
+ SolanaMWAWalletLibErrorCode["ERROR_INTENT_DATA_NOT_FOUND"] = "ERROR_INTENT_DATA_NOT_FOUND";
85
+ SolanaMWAWalletLibErrorCode["ERROR_SESSION_ALREADY_CREATED"] = "ERROR_SESSION_ALREADY_CREATED";
86
+ SolanaMWAWalletLibErrorCode["ERROR_UNSUPPORTED_ASSOCIATION_URI"] = "ERROR_UNSUPPORTED_ASSOCIATION_URI";
87
+ SolanaMWAWalletLibErrorCode["ERROR_UNSUPPORTED_ASSOCIATION_TYPE"] = "ERROR_UNSUPPORTED_ASSOCIATION_TYPE";
88
+ })(SolanaMWAWalletLibErrorCode || (SolanaMWAWalletLibErrorCode = {}));
89
+ class SolanaMWAWalletLibError extends Error {
90
+ constructor(code, message) {
91
+ super(message);
92
+ this.name = 'SolanaMWAWalletLibError';
93
+ this.code = code;
94
+ }
95
+ }
96
+
57
97
  const LINKING_ERROR$1 = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` +
58
98
  '- You rebuilt the app after installing the package\n' +
59
99
  '- If you are using Lerna workspaces\n' +
@@ -69,28 +109,31 @@ const SolanaMobileWalletAdapterWalletLib = Platform.OS === 'android' && NativeMo
69
109
  : LINKING_ERROR$1);
70
110
  },
71
111
  });
72
- const MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME = 'MobileWalletAdapterServiceRequestBridge';
73
- function useMobileWalletAdapterSession(walletName, config, associationUri, handleRequest, handleSessionEvent) {
74
- // Start native event listeners
75
- useEffect(() => {
76
- const mwaEventEmitter = new NativeEventEmitter();
77
- const listener = mwaEventEmitter.addListener(MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME, (nativeEvent) => {
78
- if (isMWARequest(nativeEvent)) {
79
- handleRequest(nativeEvent);
80
- }
81
- else if (isMWASessionEvent(nativeEvent)) {
82
- handleSessionEvent(nativeEvent);
83
- }
84
- else {
85
- console.warn('Unexpected native event type');
86
- }
87
- });
88
- initializeScenario(walletName, config, associationUri);
89
- return () => {
90
- listener.remove();
91
- };
92
- }, []);
112
+ function handleError(e) {
113
+ if (e instanceof Error) {
114
+ const { code, message } = e;
115
+ if (code && code in SolanaMWAWalletLibErrorCode) {
116
+ throw new SolanaMWAWalletLibError(code, message);
117
+ }
118
+ }
119
+ throw e;
93
120
  }
121
+ function initializeMobileWalletAdapterSession(walletName, config) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ try {
124
+ return yield initializeScenario(walletName, config);
125
+ }
126
+ catch (e) {
127
+ handleError(e);
128
+ }
129
+ });
130
+ }
131
+ // Create Scenario and establish session with dapp
132
+ function initializeScenario(walletName, walletConfig) {
133
+ return SolanaMobileWalletAdapterWalletLib.createScenario(walletName, JSON.stringify(walletConfig));
134
+ }
135
+
136
+ const MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME = 'MobileWalletAdapterServiceRequestBridge';
94
137
  function initializeMWAEventListener(handleRequest, handleSessionEvent) {
95
138
  const mwaEventEmitter = new NativeEventEmitter();
96
139
  const listener = mwaEventEmitter.addListener(MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME, (nativeEvent) => {
@@ -106,13 +149,6 @@ function initializeMWAEventListener(handleRequest, handleSessionEvent) {
106
149
  });
107
150
  return listener;
108
151
  }
109
- function initializeMobileWalletAdapterSession(walletName, config, associationUri) {
110
- initializeScenario(walletName, config, associationUri);
111
- }
112
- // Create Scenario and establish session with dapp
113
- function initializeScenario(walletName, walletConfig, associationUri) {
114
- SolanaMobileWalletAdapterWalletLib.createScenario(walletName, associationUri, JSON.stringify(walletConfig));
115
- }
116
152
  function isMWARequest(nativeEvent) {
117
153
  return Object.values(MWARequestType).includes(nativeEvent.__type);
118
154
  }
@@ -120,29 +156,24 @@ function isMWASessionEvent(nativeEvent) {
120
156
  return Object.values(MWASessionEventType).includes(nativeEvent.__type);
121
157
  }
122
158
 
123
- /******************************************************************************
124
- Copyright (c) Microsoft Corporation.
125
-
126
- Permission to use, copy, modify, and/or distribute this software for any
127
- purpose with or without fee is hereby granted.
128
-
129
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
130
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
131
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
132
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
133
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
134
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
135
- PERFORMANCE OF THIS SOFTWARE.
136
- ***************************************************************************** */
137
-
138
- function __awaiter(thisArg, _arguments, P, generator) {
139
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
140
- return new (P || (P = Promise))(function (resolve, reject) {
141
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
142
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
143
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
144
- step((generator = generator.apply(thisArg, _arguments || [])).next());
145
- });
159
+ function useMobileWalletAdapterSession(walletName, config, handleRequest, handleSessionEvent) {
160
+ useEffect(() => {
161
+ function startSession() {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ try {
164
+ yield initializeMobileWalletAdapterSession(walletName, config);
165
+ }
166
+ catch (e) {
167
+ console.error(e);
168
+ }
169
+ });
170
+ }
171
+ const listener = initializeMWAEventListener(handleRequest, handleSessionEvent);
172
+ startSession();
173
+ return () => {
174
+ listener.remove();
175
+ };
176
+ }, []);
146
177
  }
147
178
 
148
179
  const LINKING_ERROR = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` +
@@ -181,4 +212,4 @@ function getUidForPackage(packageName) {
181
212
  });
182
213
  }
183
214
 
184
- export { MWARequestFailReason, MWARequestType, MWASessionEventType, getCallingPackage, getCallingPackageUid, getUidForPackage, initializeMWAEventListener, initializeMobileWalletAdapterSession, resolve, useMobileWalletAdapterSession, verifyCallingPackage };
215
+ export { MWARequestFailReason, MWARequestType, MWASessionEventType, SolanaMWAWalletLibError, SolanaMWAWalletLibErrorCode, getCallingPackage, getCallingPackageUid, getUidForPackage, initializeMWAEventListener, initializeMobileWalletAdapterSession, resolve, useMobileWalletAdapterSession, verifyCallingPackage };
@@ -54,6 +54,46 @@ function resolve(request, response) {
54
54
  SolanaMobileWalletAdapterWalletLib$1.resolve(JSON.stringify(request), JSON.stringify(response));
55
55
  }
56
56
 
57
+ /******************************************************************************
58
+ Copyright (c) Microsoft Corporation.
59
+
60
+ Permission to use, copy, modify, and/or distribute this software for any
61
+ purpose with or without fee is hereby granted.
62
+
63
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
64
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
65
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
66
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
67
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
68
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
69
+ PERFORMANCE OF THIS SOFTWARE.
70
+ ***************************************************************************** */
71
+
72
+ function __awaiter(thisArg, _arguments, P, generator) {
73
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
74
+ return new (P || (P = Promise))(function (resolve, reject) {
75
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
76
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
77
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
78
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
79
+ });
80
+ }
81
+
82
+ var SolanaMWAWalletLibErrorCode;
83
+ (function (SolanaMWAWalletLibErrorCode) {
84
+ SolanaMWAWalletLibErrorCode["ERROR_INTENT_DATA_NOT_FOUND"] = "ERROR_INTENT_DATA_NOT_FOUND";
85
+ SolanaMWAWalletLibErrorCode["ERROR_SESSION_ALREADY_CREATED"] = "ERROR_SESSION_ALREADY_CREATED";
86
+ SolanaMWAWalletLibErrorCode["ERROR_UNSUPPORTED_ASSOCIATION_URI"] = "ERROR_UNSUPPORTED_ASSOCIATION_URI";
87
+ SolanaMWAWalletLibErrorCode["ERROR_UNSUPPORTED_ASSOCIATION_TYPE"] = "ERROR_UNSUPPORTED_ASSOCIATION_TYPE";
88
+ })(SolanaMWAWalletLibErrorCode || (SolanaMWAWalletLibErrorCode = {}));
89
+ class SolanaMWAWalletLibError extends Error {
90
+ constructor(code, message) {
91
+ super(message);
92
+ this.name = 'SolanaMWAWalletLibError';
93
+ this.code = code;
94
+ }
95
+ }
96
+
57
97
  const LINKING_ERROR$1 = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` +
58
98
  '- You rebuilt the app after installing the package\n' +
59
99
  '- If you are using Lerna workspaces\n' +
@@ -69,28 +109,31 @@ const SolanaMobileWalletAdapterWalletLib = Platform.OS === 'android' && NativeMo
69
109
  : LINKING_ERROR$1);
70
110
  },
71
111
  });
72
- const MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME = 'MobileWalletAdapterServiceRequestBridge';
73
- function useMobileWalletAdapterSession(walletName, config, associationUri, handleRequest, handleSessionEvent) {
74
- // Start native event listeners
75
- useEffect(() => {
76
- const mwaEventEmitter = new NativeEventEmitter();
77
- const listener = mwaEventEmitter.addListener(MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME, (nativeEvent) => {
78
- if (isMWARequest(nativeEvent)) {
79
- handleRequest(nativeEvent);
80
- }
81
- else if (isMWASessionEvent(nativeEvent)) {
82
- handleSessionEvent(nativeEvent);
83
- }
84
- else {
85
- console.warn('Unexpected native event type');
86
- }
87
- });
88
- initializeScenario(walletName, config, associationUri);
89
- return () => {
90
- listener.remove();
91
- };
92
- }, []);
112
+ function handleError(e) {
113
+ if (e instanceof Error) {
114
+ const { code, message } = e;
115
+ if (code && code in SolanaMWAWalletLibErrorCode) {
116
+ throw new SolanaMWAWalletLibError(code, message);
117
+ }
118
+ }
119
+ throw e;
93
120
  }
121
+ function initializeMobileWalletAdapterSession(walletName, config) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ try {
124
+ return yield initializeScenario(walletName, config);
125
+ }
126
+ catch (e) {
127
+ handleError(e);
128
+ }
129
+ });
130
+ }
131
+ // Create Scenario and establish session with dapp
132
+ function initializeScenario(walletName, walletConfig) {
133
+ return SolanaMobileWalletAdapterWalletLib.createScenario(walletName, JSON.stringify(walletConfig));
134
+ }
135
+
136
+ const MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME = 'MobileWalletAdapterServiceRequestBridge';
94
137
  function initializeMWAEventListener(handleRequest, handleSessionEvent) {
95
138
  const mwaEventEmitter = new NativeEventEmitter();
96
139
  const listener = mwaEventEmitter.addListener(MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME, (nativeEvent) => {
@@ -106,13 +149,6 @@ function initializeMWAEventListener(handleRequest, handleSessionEvent) {
106
149
  });
107
150
  return listener;
108
151
  }
109
- function initializeMobileWalletAdapterSession(walletName, config, associationUri) {
110
- initializeScenario(walletName, config, associationUri);
111
- }
112
- // Create Scenario and establish session with dapp
113
- function initializeScenario(walletName, walletConfig, associationUri) {
114
- SolanaMobileWalletAdapterWalletLib.createScenario(walletName, associationUri, JSON.stringify(walletConfig));
115
- }
116
152
  function isMWARequest(nativeEvent) {
117
153
  return Object.values(MWARequestType).includes(nativeEvent.__type);
118
154
  }
@@ -120,29 +156,24 @@ function isMWASessionEvent(nativeEvent) {
120
156
  return Object.values(MWASessionEventType).includes(nativeEvent.__type);
121
157
  }
122
158
 
123
- /******************************************************************************
124
- Copyright (c) Microsoft Corporation.
125
-
126
- Permission to use, copy, modify, and/or distribute this software for any
127
- purpose with or without fee is hereby granted.
128
-
129
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
130
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
131
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
132
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
133
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
134
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
135
- PERFORMANCE OF THIS SOFTWARE.
136
- ***************************************************************************** */
137
-
138
- function __awaiter(thisArg, _arguments, P, generator) {
139
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
140
- return new (P || (P = Promise))(function (resolve, reject) {
141
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
142
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
143
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
144
- step((generator = generator.apply(thisArg, _arguments || [])).next());
145
- });
159
+ function useMobileWalletAdapterSession(walletName, config, handleRequest, handleSessionEvent) {
160
+ useEffect(() => {
161
+ function startSession() {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ try {
164
+ yield initializeMobileWalletAdapterSession(walletName, config);
165
+ }
166
+ catch (e) {
167
+ console.error(e);
168
+ }
169
+ });
170
+ }
171
+ const listener = initializeMWAEventListener(handleRequest, handleSessionEvent);
172
+ startSession();
173
+ return () => {
174
+ listener.remove();
175
+ };
176
+ }, []);
146
177
  }
147
178
 
148
179
  const LINKING_ERROR = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` +
@@ -181,4 +212,4 @@ function getUidForPackage(packageName) {
181
212
  });
182
213
  }
183
214
 
184
- export { MWARequestFailReason, MWARequestType, MWASessionEventType, getCallingPackage, getCallingPackageUid, getUidForPackage, initializeMWAEventListener, initializeMobileWalletAdapterSession, resolve, useMobileWalletAdapterSession, verifyCallingPackage };
215
+ export { MWARequestFailReason, MWARequestType, MWASessionEventType, SolanaMWAWalletLibError, SolanaMWAWalletLibErrorCode, getCallingPackage, getCallingPackageUid, getUidForPackage, initializeMWAEventListener, initializeMobileWalletAdapterSession, resolve, useMobileWalletAdapterSession, verifyCallingPackage };
@@ -98,7 +98,7 @@ type AuthorizeDappRequest = Readonly<{
98
98
  appIdentity?: AppIdentity;
99
99
  features?: IdentifierArray;
100
100
  addresses?: [
101
- String
101
+ string
102
102
  ];
103
103
  signInPayload?: SignInPayload;
104
104
  }> & IMWARequest;
@@ -151,7 +151,7 @@ type InvalidSignaturesResponse = Readonly<{
151
151
  }>;
152
152
  /* Authorize Dapp */
153
153
  type AuthorizedAccount = Readonly<{
154
- publicKey: Base64EncodedAddress;
154
+ publicKey: Uint8Array;
155
155
  accountLabel?: string;
156
156
  icon?: string;
157
157
  chains?: IdentifierArray;
@@ -196,6 +196,7 @@ declare function resolve(request: DeauthorizeDappRequest, response: DeauthorizeD
196
196
  declare function resolve(request: SignMessagesRequest, response: SignMessagesResponse): void;
197
197
  declare function resolve(request: SignTransactionsRequest, response: SignTransactionsResponse): void;
198
198
  declare function resolve(request: SignAndSendTransactionsRequest, response: SignAndSendTransactionsResponse): void;
199
+ type MWASessionId = string;
199
200
  interface MobileWalletAdapterConfig {
200
201
  maxTransactionsPerSigningRequest: number;
201
202
  maxMessagesPerSigningRequest: number;
@@ -203,12 +204,22 @@ interface MobileWalletAdapterConfig {
203
204
  noConnectionWarningTimeoutMs: number;
204
205
  optionalFeatures: IdentifierArray;
205
206
  }
206
- declare function useMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig, associationUri: string, handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): void;
207
+ declare function initializeMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig): Promise<MWASessionId>;
208
+ declare function useMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig, handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): void;
207
209
  declare function initializeMWAEventListener(handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): EmitterSubscription;
208
- declare function initializeMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig, associationUri: string): void;
209
210
  declare function getCallingPackage(): Promise<string | undefined>;
210
211
  declare function verifyCallingPackage(clientIdentityUri: string): Promise<any>;
211
212
  declare function getCallingPackageUid(): Promise<any>;
212
213
  declare function getUidForPackage(packageName: string): Promise<any>;
213
- export { MWASessionEventType, IMWASessionEvent, SessionStartEvent, SessionReadyEvent, SessionTerminatedEvent, SessionServingClientsEvent, SessionServingCompleteEvent, SessionCompleteEvent, SessionErrorEvent, SessionTeardownCompleteEvent, LowPowerNoConnectionEvent, MWASessionEvent, SignInPayload, Base64EncodedAddress, 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, MobileWalletAdapterConfig, useMobileWalletAdapterSession, initializeMWAEventListener, initializeMobileWalletAdapterSession, getCallingPackage, verifyCallingPackage, getCallingPackageUid, getUidForPackage };
214
+ declare enum SolanaMWAWalletLibErrorCode {
215
+ ERROR_INTENT_DATA_NOT_FOUND = "ERROR_INTENT_DATA_NOT_FOUND",
216
+ ERROR_SESSION_ALREADY_CREATED = "ERROR_SESSION_ALREADY_CREATED",
217
+ ERROR_UNSUPPORTED_ASSOCIATION_URI = "ERROR_UNSUPPORTED_ASSOCIATION_URI",
218
+ ERROR_UNSUPPORTED_ASSOCIATION_TYPE = "ERROR_UNSUPPORTED_ASSOCIATION_TYPE"
219
+ }
220
+ declare class SolanaMWAWalletLibError extends Error {
221
+ code: SolanaMWAWalletLibErrorCode;
222
+ constructor(code: SolanaMWAWalletLibErrorCode, message: string);
223
+ }
224
+ export { MWASessionEventType, IMWASessionEvent, SessionStartEvent, SessionReadyEvent, SessionTerminatedEvent, SessionServingClientsEvent, SessionServingCompleteEvent, SessionCompleteEvent, SessionErrorEvent, SessionTeardownCompleteEvent, LowPowerNoConnectionEvent, MWASessionEvent, SignInPayload, Base64EncodedAddress, 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 };
214
225
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/mwaSessionEvents.ts","../../src/resolve.ts","../../src/useMobileWalletAdapterSession.ts","../../src/useDigitalAssetLinks.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.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":""}
@@ -98,7 +98,7 @@ type AuthorizeDappRequest = Readonly<{
98
98
  appIdentity?: AppIdentity;
99
99
  features?: IdentifierArray;
100
100
  addresses?: [
101
- String
101
+ string
102
102
  ];
103
103
  signInPayload?: SignInPayload;
104
104
  }> & IMWARequest;
@@ -151,7 +151,7 @@ type InvalidSignaturesResponse = Readonly<{
151
151
  }>;
152
152
  /* Authorize Dapp */
153
153
  type AuthorizedAccount = Readonly<{
154
- publicKey: Base64EncodedAddress;
154
+ publicKey: Uint8Array;
155
155
  accountLabel?: string;
156
156
  icon?: string;
157
157
  chains?: IdentifierArray;
@@ -196,6 +196,7 @@ declare function resolve(request: DeauthorizeDappRequest, response: DeauthorizeD
196
196
  declare function resolve(request: SignMessagesRequest, response: SignMessagesResponse): void;
197
197
  declare function resolve(request: SignTransactionsRequest, response: SignTransactionsResponse): void;
198
198
  declare function resolve(request: SignAndSendTransactionsRequest, response: SignAndSendTransactionsResponse): void;
199
+ type MWASessionId = string;
199
200
  interface MobileWalletAdapterConfig {
200
201
  maxTransactionsPerSigningRequest: number;
201
202
  maxMessagesPerSigningRequest: number;
@@ -203,12 +204,22 @@ interface MobileWalletAdapterConfig {
203
204
  noConnectionWarningTimeoutMs: number;
204
205
  optionalFeatures: IdentifierArray;
205
206
  }
206
- declare function useMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig, associationUri: string, handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): void;
207
+ declare function initializeMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig): Promise<MWASessionId>;
208
+ declare function useMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig, handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): void;
207
209
  declare function initializeMWAEventListener(handleRequest: (request: MWARequest) => void, handleSessionEvent: (sessionEvent: MWASessionEvent) => void): EmitterSubscription;
208
- declare function initializeMobileWalletAdapterSession(walletName: string, config: MobileWalletAdapterConfig, associationUri: string): void;
209
210
  declare function getCallingPackage(): Promise<string | undefined>;
210
211
  declare function verifyCallingPackage(clientIdentityUri: string): Promise<any>;
211
212
  declare function getCallingPackageUid(): Promise<any>;
212
213
  declare function getUidForPackage(packageName: string): Promise<any>;
213
- export { MWASessionEventType, IMWASessionEvent, SessionStartEvent, SessionReadyEvent, SessionTerminatedEvent, SessionServingClientsEvent, SessionServingCompleteEvent, SessionCompleteEvent, SessionErrorEvent, SessionTeardownCompleteEvent, LowPowerNoConnectionEvent, MWASessionEvent, SignInPayload, Base64EncodedAddress, 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, MobileWalletAdapterConfig, useMobileWalletAdapterSession, initializeMWAEventListener, initializeMobileWalletAdapterSession, getCallingPackage, verifyCallingPackage, getCallingPackageUid, getUidForPackage };
214
+ declare enum SolanaMWAWalletLibErrorCode {
215
+ ERROR_INTENT_DATA_NOT_FOUND = "ERROR_INTENT_DATA_NOT_FOUND",
216
+ ERROR_SESSION_ALREADY_CREATED = "ERROR_SESSION_ALREADY_CREATED",
217
+ ERROR_UNSUPPORTED_ASSOCIATION_URI = "ERROR_UNSUPPORTED_ASSOCIATION_URI",
218
+ ERROR_UNSUPPORTED_ASSOCIATION_TYPE = "ERROR_UNSUPPORTED_ASSOCIATION_TYPE"
219
+ }
220
+ declare class SolanaMWAWalletLibError extends Error {
221
+ code: SolanaMWAWalletLibErrorCode;
222
+ constructor(code: SolanaMWAWalletLibErrorCode, message: string);
223
+ }
224
+ export { MWASessionEventType, IMWASessionEvent, SessionStartEvent, SessionReadyEvent, SessionTerminatedEvent, SessionServingClientsEvent, SessionServingCompleteEvent, SessionCompleteEvent, SessionErrorEvent, SessionTeardownCompleteEvent, LowPowerNoConnectionEvent, MWASessionEvent, SignInPayload, Base64EncodedAddress, 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 };
214
225
  //# sourceMappingURL=index.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/mwaSessionEvents.ts","../../src/resolve.ts","../../src/useMobileWalletAdapterSession.ts","../../src/useDigitalAssetLinks.ts"],"names":[],"mappings":""}
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":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solana-mobile/mobile-wallet-adapter-walletlib",
3
3
  "description": "A React Native wrapper of the Solana Mobile, Mobile Wallet Adapter Wallet Library. Wallet apps can use this to handle dapp requests for signing and sending.",
4
- "version": "1.3.0",
4
+ "version": "1.4.0-beta2",
5
5
  "author": "Michael Sulistio <mike.sulistio@solanamobile.com>",
6
6
  "repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
7
7
  "license": "Apache-2.0",