@reown/appkit-solana-react-native 2.0.0-alpha.3 → 2.0.0-alpha.5

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 (47) hide show
  1. package/lib/commonjs/adapter.js +3 -3
  2. package/lib/commonjs/adapter.js.map +1 -1
  3. package/lib/commonjs/connectors/DeeplinkConnector.js +271 -0
  4. package/lib/commonjs/connectors/DeeplinkConnector.js.map +1 -0
  5. package/lib/commonjs/connectors/PhantomConnector.js +15 -230
  6. package/lib/commonjs/connectors/PhantomConnector.js.map +1 -1
  7. package/lib/commonjs/connectors/SolflareConnector.js +36 -0
  8. package/lib/commonjs/connectors/SolflareConnector.js.map +1 -0
  9. package/lib/commonjs/index.js +7 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/providers/{PhantomProvider.js → DeeplinkProvider.js} +155 -154
  12. package/lib/commonjs/providers/DeeplinkProvider.js.map +1 -0
  13. package/lib/module/adapter.js +3 -3
  14. package/lib/module/adapter.js.map +1 -1
  15. package/lib/module/connectors/DeeplinkConnector.js +265 -0
  16. package/lib/module/connectors/DeeplinkConnector.js.map +1 -0
  17. package/lib/module/connectors/PhantomConnector.js +16 -230
  18. package/lib/module/connectors/PhantomConnector.js.map +1 -1
  19. package/lib/module/connectors/SolflareConnector.js +31 -0
  20. package/lib/module/connectors/SolflareConnector.js.map +1 -0
  21. package/lib/module/index.js +1 -0
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/providers/{PhantomProvider.js → DeeplinkProvider.js} +153 -152
  24. package/lib/module/providers/DeeplinkProvider.js.map +1 -0
  25. package/lib/typescript/connectors/DeeplinkConnector.d.ts +30 -0
  26. package/lib/typescript/connectors/DeeplinkConnector.d.ts.map +1 -0
  27. package/lib/typescript/connectors/PhantomConnector.d.ts +8 -23
  28. package/lib/typescript/connectors/PhantomConnector.d.ts.map +1 -1
  29. package/lib/typescript/connectors/SolflareConnector.d.ts +12 -0
  30. package/lib/typescript/connectors/SolflareConnector.d.ts.map +1 -0
  31. package/lib/typescript/index.d.ts +2 -1
  32. package/lib/typescript/index.d.ts.map +1 -1
  33. package/lib/typescript/providers/{PhantomProvider.d.ts → DeeplinkProvider.d.ts} +16 -8
  34. package/lib/typescript/providers/DeeplinkProvider.d.ts.map +1 -0
  35. package/lib/typescript/types.d.ts +27 -32
  36. package/lib/typescript/types.d.ts.map +1 -1
  37. package/package.json +5 -4
  38. package/src/adapter.ts +3 -3
  39. package/src/connectors/DeeplinkConnector.ts +353 -0
  40. package/src/connectors/PhantomConnector.ts +17 -313
  41. package/src/connectors/SolflareConnector.ts +33 -0
  42. package/src/index.ts +2 -1
  43. package/src/providers/{PhantomProvider.ts → DeeplinkProvider.ts} +256 -233
  44. package/src/types.ts +29 -37
  45. package/lib/commonjs/providers/PhantomProvider.js.map +0 -1
  46. package/lib/module/providers/PhantomProvider.js.map +0 -1
  47. package/lib/typescript/providers/PhantomProvider.d.ts.map +0 -1
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SolflareConnector = void 0;
7
+ var _appkitCommonReactNative = require("@reown/appkit-common-react-native");
8
+ var _DeeplinkConnector = require("./DeeplinkConnector");
9
+ const SOLFLARE_BASE_URL = 'https://solflare.com/ul/v1';
10
+ const SOLFLARE_CONNECTOR_STORAGE_KEY = '@appkit/solflare-connector-data';
11
+ const SOLFLARE_DAPP_KEYPAIR_STORAGE_KEY = '@appkit/solflare-dapp-secret-key';
12
+ class SolflareConnector extends _DeeplinkConnector.DeeplinkConnector {
13
+ constructor(config) {
14
+ super({
15
+ type: 'solflare',
16
+ cluster: config?.cluster
17
+ });
18
+ }
19
+ getWalletInfo() {
20
+ return _appkitCommonReactNative.ConstantsUtil.SOLFLARE_CUSTOM_WALLET;
21
+ }
22
+ getBaseUrl() {
23
+ return SOLFLARE_BASE_URL;
24
+ }
25
+ getStorageKey() {
26
+ return SOLFLARE_CONNECTOR_STORAGE_KEY;
27
+ }
28
+ getDappKeypairStorageKey() {
29
+ return SOLFLARE_DAPP_KEYPAIR_STORAGE_KEY;
30
+ }
31
+ getEncryptionKeyFieldName() {
32
+ return 'solflare_encryption_public_key';
33
+ }
34
+ }
35
+ exports.SolflareConnector = SolflareConnector;
36
+ //# sourceMappingURL=SolflareConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_appkitCommonReactNative","require","_DeeplinkConnector","SOLFLARE_BASE_URL","SOLFLARE_CONNECTOR_STORAGE_KEY","SOLFLARE_DAPP_KEYPAIR_STORAGE_KEY","SolflareConnector","DeeplinkConnector","constructor","config","type","cluster","getWalletInfo","ConstantsUtil","SOLFLARE_CUSTOM_WALLET","getBaseUrl","getStorageKey","getDappKeypairStorageKey","getEncryptionKeyFieldName","exports"],"sourceRoot":"../../../src","sources":["connectors/SolflareConnector.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAGA,MAAME,iBAAiB,GAAG,4BAA4B;AACtD,MAAMC,8BAA8B,GAAG,iCAAiC;AACxE,MAAMC,iCAAiC,GAAG,kCAAkC;AAErE,MAAMC,iBAAiB,SAASC,oCAAiB,CAAC;EACvDC,WAAWA,CAACC,MAAgC,EAAE;IAC5C,KAAK,CAAC;MAAEC,IAAI,EAAE,UAAU;MAAEC,OAAO,EAAEF,MAAM,EAAEE;IAAQ,CAAC,CAAC;EACvD;EAESC,aAAaA,CAAA,EAAe;IACnC,OAAOC,sCAAa,CAACC,sBAAsB;EAC7C;EAEUC,UAAUA,CAAA,EAAW;IAC7B,OAAOZ,iBAAiB;EAC1B;EAEUa,aAAaA,CAAA,EAAW;IAChC,OAAOZ,8BAA8B;EACvC;EAEUa,wBAAwBA,CAAA,EAAW;IAC3C,OAAOZ,iCAAiC;EAC1C;EAEUa,yBAAyBA,CAAA,EAAW;IAC5C,OAAO,gCAAgC;EACzC;AACF;AAACC,OAAA,CAAAb,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -15,6 +15,13 @@ Object.defineProperty(exports, "SolanaAdapter", {
15
15
  return _adapter.SolanaAdapter;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "SolflareConnector", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _SolflareConnector.SolflareConnector;
22
+ }
23
+ });
18
24
  var _adapter = require("./adapter");
19
25
  var _PhantomConnector = require("./connectors/PhantomConnector");
26
+ var _SolflareConnector = require("./connectors/SolflareConnector");
20
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_adapter","require","_PhantomConnector"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,iBAAA,GAAAD,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_adapter","require","_PhantomConnector","_SolflareConnector"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA","ignoreList":[]}
@@ -3,15 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SOLANA_SIGNING_METHODS = exports.PhantomProvider = void 0;
6
+ exports.SOLANA_SIGNING_METHODS = exports.DeeplinkProvider = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  var _tweetnacl = _interopRequireDefault(require("tweetnacl"));
9
9
  var _bs = _interopRequireDefault(require("bs58"));
10
10
  var _buffer = require("buffer");
11
11
  var _events = _interopRequireDefault(require("events"));
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- const PHANTOM_BASE_URL = 'https://phantom.app/ul/v1';
14
- const PHANTOM_PROVIDER_STORAGE_KEY = '@appkit/phantom-provider-session';
15
13
  const SOLANA_SIGNING_METHODS = exports.SOLANA_SIGNING_METHODS = {
16
14
  SOLANA_SIGN_TRANSACTION: 'solana_signTransaction',
17
15
  SOLANA_SIGN_MESSAGE: 'solana_signMessage',
@@ -21,11 +19,11 @@ const SOLANA_SIGNING_METHODS = exports.SOLANA_SIGNING_METHODS = {
21
19
  function isValidSolanaSigningMethod(method) {
22
20
  return Object.values(SOLANA_SIGNING_METHODS).includes(method);
23
21
  }
24
- class PhantomProvider extends _events.default {
25
- currentCluster = 'mainnet-beta';
22
+ class DeeplinkProvider extends _events.default {
23
+ sharedKey = null;
26
24
  sessionToken = null;
27
25
  userPublicKey = null;
28
- phantomEncryptionPublicKeyBs58 = null;
26
+ walletEncryptionPublicKeyBs58 = null;
29
27
 
30
28
  // Single subscription management - deep links are sequential by nature
31
29
  activeSubscription = null;
@@ -33,9 +31,13 @@ class PhantomProvider extends _events.default {
33
31
  constructor(config) {
34
32
  super();
35
33
  this.config = config;
34
+ this.currentCluster = config.cluster ?? 'mainnet-beta';
36
35
  this.dappEncryptionKeyPair = config.dappEncryptionKeyPair;
37
36
  this.storage = config.storage;
38
37
  }
38
+ getSessionStorageKey() {
39
+ return `@appkit/${this.config.type}-provider-session`;
40
+ }
39
41
 
40
42
  /**
41
43
  * Cleanup method to be called when the provider is destroyed
@@ -73,9 +75,47 @@ class PhantomProvider extends _events.default {
73
75
  isConnected() {
74
76
  return !!this.sessionToken && !!this.userPublicKey && !!this.dappEncryptionKeyPair;
75
77
  }
78
+ getCurrentCluster() {
79
+ return this.currentCluster;
80
+ }
76
81
  buildUrl(rpcMethod, params) {
77
82
  const query = new URLSearchParams(params).toString();
78
- return `${PHANTOM_BASE_URL}/${rpcMethod}?${query}`;
83
+ return `${this.config.baseUrl}/${rpcMethod}?${query}`;
84
+ }
85
+
86
+ /**
87
+ * Open a deeplink URL and wait for a redirect back to the app. Handles subscription
88
+ * lifecycle and common error extraction from `errorCode`/`errorMessage` query params.
89
+ */
90
+ async openDeeplinkAndWait(deeplinkUrl, processParams, contextLabel) {
91
+ return new Promise((resolve, reject) => {
92
+ const handleDeepLink = async event => {
93
+ try {
94
+ this.cleanupActiveSubscription();
95
+ const fullUrl = event.url;
96
+ if (!fullUrl.startsWith(this.config.appScheme)) {
97
+ return reject(new Error(`${this.config.type} provider: ${contextLabel}: Unexpected redirect URI.`));
98
+ }
99
+ const params = new URLSearchParams(fullUrl.substring(fullUrl.indexOf('?') + 1));
100
+ const errorCode = params.get('errorCode');
101
+ const errorMessage = params.get('errorMessage');
102
+ if (errorCode) {
103
+ return reject(new Error(`${this.config.type} provider: ${contextLabel} Failed: ${errorMessage || 'Unknown error'} (Code: ${errorCode})`));
104
+ }
105
+ const result = await Promise.resolve(processParams(params));
106
+ resolve(result);
107
+ } catch (error) {
108
+ this.cleanupActiveSubscription();
109
+ reject(error);
110
+ }
111
+ };
112
+ const subscription = _reactNative.Linking.addEventListener('url', handleDeepLink);
113
+ this.setActiveSubscription(subscription);
114
+ _reactNative.Linking.openURL(deeplinkUrl).catch(err => {
115
+ this.cleanupActiveSubscription();
116
+ reject(new Error(`${this.config.type} provider: Failed to open wallet for ${contextLabel}: ${err.message}.`));
117
+ });
118
+ });
79
119
  }
80
120
  getRpcMethodName(method) {
81
121
  switch (method) {
@@ -92,73 +132,94 @@ class PhantomProvider extends _events.default {
92
132
  throw new Error(`Unsupported Solana signing method: ${method}`);
93
133
  }
94
134
  }
95
- encryptPayload(payload, phantomPublicKeyBs58ToEncryptFor) {
96
- if (!phantomPublicKeyBs58ToEncryptFor) {
135
+ encryptPayload(payload, walletPublicKeyBs58) {
136
+ if (!walletPublicKeyBs58) {
97
137
  return null;
98
138
  }
99
139
  try {
100
- const phantomPublicKeyBytes = _bs.default.decode(phantomPublicKeyBs58ToEncryptFor);
101
140
  const nonce = _tweetnacl.default.randomBytes(_tweetnacl.default.box.nonceLength);
102
141
  const payloadBytes = _buffer.Buffer.from(JSON.stringify(payload), 'utf8');
103
- const encryptedPayload = _tweetnacl.default.box(payloadBytes, nonce, phantomPublicKeyBytes, this.dappEncryptionKeyPair.secretKey);
142
+ let encryptedPayload;
143
+ if (this.sharedKey) {
144
+ encryptedPayload = _tweetnacl.default.box.after(payloadBytes, nonce, this.sharedKey);
145
+ } else {
146
+ const walletPublicKeyBytes = _bs.default.decode(walletPublicKeyBs58);
147
+ encryptedPayload = _tweetnacl.default.box(payloadBytes, nonce, walletPublicKeyBytes, this.dappEncryptionKeyPair.secretKey);
148
+ }
104
149
  return {
105
150
  nonce: _bs.default.encode(nonce),
106
151
  encryptedPayload: _bs.default.encode(encryptedPayload)
107
152
  };
108
153
  } catch (error) {
154
+ console.warn(`${this.config.type} provider: Failed to encrypt payload.`, error);
109
155
  return null;
110
156
  }
111
157
  }
112
- decryptPayload(encryptedDataBs58, nonceBs58, phantomSenderPublicKeyBs58) {
158
+ decryptPayload(encryptedDataBs58, nonceBs58, walletSenderPublicKeyBs58) {
113
159
  try {
114
- const encryptedDataBytes = _bs.default.decode(encryptedDataBs58);
160
+ const formattedEncryptedDataBs58 = encryptedDataBs58.replace('#', '');
161
+ const encryptedDataBytes = _bs.default.decode(formattedEncryptedDataBs58);
115
162
  const nonceBytes = _bs.default.decode(nonceBs58);
116
- const phantomSenderPublicKeyBytes = _bs.default.decode(phantomSenderPublicKeyBs58);
117
- const decryptedPayloadBytes = _tweetnacl.default.box.open(encryptedDataBytes, nonceBytes, phantomSenderPublicKeyBytes, this.dappEncryptionKeyPair.secretKey);
163
+ let decryptedPayloadBytes;
164
+ if (this.sharedKey) {
165
+ decryptedPayloadBytes = _tweetnacl.default.box.open.after(encryptedDataBytes, nonceBytes, this.sharedKey);
166
+ } else {
167
+ const walletSenderPublicKeyBytes = _bs.default.decode(walletSenderPublicKeyBs58);
168
+ decryptedPayloadBytes = _tweetnacl.default.box.open(encryptedDataBytes, nonceBytes, walletSenderPublicKeyBytes, this.dappEncryptionKeyPair.secretKey);
169
+ }
118
170
  if (!decryptedPayloadBytes) {
119
171
  return null;
120
172
  }
121
173
  return JSON.parse(_buffer.Buffer.from(decryptedPayloadBytes).toString('utf8'));
122
174
  } catch (error) {
175
+ console.warn(`${this.config.type} provider: Failed to decrypt payload.`, error);
123
176
  return null;
124
177
  }
125
178
  }
126
179
  async restoreSession() {
127
180
  try {
128
- const session = await this.storage.getItem(PHANTOM_PROVIDER_STORAGE_KEY);
181
+ const session = await this.storage.getItem(this.getSessionStorageKey());
129
182
  if (session) {
130
183
  this.setSession(session);
184
+
185
+ // Recompute shared key on session restore
186
+ try {
187
+ const walletPublicKeyBytes = _bs.default.decode(session.walletEncryptionPublicKeyBs58);
188
+ this.sharedKey = _tweetnacl.default.box.before(walletPublicKeyBytes, this.dappEncryptionKeyPair.secretKey);
189
+ } catch (e) {
190
+ this.sharedKey = null;
191
+ }
131
192
  return true;
132
193
  }
133
194
  return false;
134
195
  } catch (error) {
135
- // console.error('PhantomProvider: Failed to restore session.', error);
196
+ // console.error(`${this.config.type} provider: Failed to restore session.`, error);
136
197
  await this.clearSessionStorage(); // Clear potentially corrupt data
137
198
 
138
199
  return false;
139
200
  }
140
201
  }
141
202
  async saveSession() {
142
- if (!this.sessionToken || !this.userPublicKey || !this.phantomEncryptionPublicKeyBs58) {
203
+ if (!this.sessionToken || !this.userPublicKey || !this.walletEncryptionPublicKeyBs58) {
143
204
  return; // Cannot save incomplete session
144
205
  }
145
206
  const session = {
146
207
  sessionToken: this.sessionToken,
147
208
  userPublicKey: this.userPublicKey,
148
- phantomEncryptionPublicKeyBs58: this.phantomEncryptionPublicKeyBs58,
209
+ walletEncryptionPublicKeyBs58: this.walletEncryptionPublicKeyBs58,
149
210
  cluster: this.currentCluster
150
211
  };
151
212
  try {
152
- await this.storage.setItem(PHANTOM_PROVIDER_STORAGE_KEY, session);
213
+ await this.storage.setItem(this.getSessionStorageKey(), session);
153
214
  } catch (error) {
154
- // console.error('PhantomProvider: Failed to save session.', error);
215
+ // console.error(`${this.config.type} provider: Failed to save session.`, error);
155
216
  }
156
217
  }
157
218
  async clearSessionStorage() {
158
219
  try {
159
- await this.storage.removeItem(PHANTOM_PROVIDER_STORAGE_KEY);
220
+ await this.storage.removeItem(this.getSessionStorageKey());
160
221
  } catch (error) {
161
- // console.error('PhantomProvider: Failed to clear session storage.', error);
222
+ // console.error(`${this.config.type} provider: Failed to clear session storage.`, error);
162
223
  }
163
224
  }
164
225
  async connect(params) {
@@ -171,60 +232,43 @@ class PhantomProvider extends _events.default {
171
232
  cluster
172
233
  };
173
234
  const url = this.buildUrl('connect', connectDeeplinkParams);
174
- return new Promise((resolve, reject) => {
175
- const handleDeepLink = async event => {
176
- try {
177
- this.cleanupActiveSubscription();
178
- const fullUrl = event.url;
179
- if (fullUrl.startsWith(this.config.appScheme)) {
180
- const responseUrlParams = new URLSearchParams(fullUrl.substring(fullUrl.indexOf('?') + 1));
181
- const errorCode = responseUrlParams.get('errorCode');
182
- const errorMessage = responseUrlParams.get('errorMessage');
183
- if (errorCode) {
184
- return reject(new Error(`Phantom Connection Failed: ${errorMessage || 'Unknown error'} (Code: ${errorCode})`));
185
- }
186
- const responsePayload = {
187
- phantom_encryption_public_key: responseUrlParams.get('phantom_encryption_public_key'),
188
- nonce: responseUrlParams.get('nonce'),
189
- data: responseUrlParams.get('data')
190
- };
191
- if (!responsePayload.phantom_encryption_public_key || !responsePayload.nonce || !responsePayload.data) {
192
- return reject(new Error('Phantom Connect: Invalid response - missing parameters.'));
193
- }
194
- const decryptedData = this.decryptPayload(responsePayload.data, responsePayload.nonce, responsePayload.phantom_encryption_public_key);
195
- if (!decryptedData || !decryptedData.public_key || !decryptedData.session) {
196
- return reject(new Error('Phantom Connect: Failed to decrypt or invalid decrypted data.'));
197
- }
198
- this.userPublicKey = decryptedData.public_key;
199
- this.sessionToken = decryptedData.session;
200
- this.phantomEncryptionPublicKeyBs58 = responsePayload.phantom_encryption_public_key;
235
+ return this.openDeeplinkAndWait(url, responseUrlParams => {
236
+ const responsePayload = {
237
+ wallet_encryption_public_key: responseUrlParams.get(this.config.encryptionKeyFieldName),
238
+ nonce: responseUrlParams.get('nonce'),
239
+ data: responseUrlParams.get('data')
240
+ };
241
+ if (!responsePayload.wallet_encryption_public_key || !responsePayload.nonce || !responsePayload.data) {
242
+ throw new Error(`${this.config.type} provider: Invalid response - missing parameters.`);
243
+ }
244
+ const decryptedData = this.decryptPayload(responsePayload.data, responsePayload.nonce, responsePayload.wallet_encryption_public_key);
245
+ if (!decryptedData || !decryptedData.public_key || !decryptedData.session) {
246
+ throw new Error(`${this.config.type} provider: Failed to decrypt or invalid decrypted data.`);
247
+ }
248
+ this.userPublicKey = decryptedData.public_key;
249
+ this.sessionToken = decryptedData.session;
250
+ this.walletEncryptionPublicKeyBs58 = responsePayload.wallet_encryption_public_key;
201
251
 
202
- // Save session on successful connect
203
- this.saveSession();
204
- resolve({
205
- userPublicKey: this.userPublicKey,
206
- sessionToken: this.sessionToken,
207
- phantomEncryptionPublicKeyBs58: this.phantomEncryptionPublicKeyBs58,
208
- cluster
209
- });
210
- } else {
211
- reject(new Error('Phantom Connect: Unexpected redirect URI.'));
212
- }
213
- } catch (error) {
214
- this.cleanupActiveSubscription();
215
- reject(error);
216
- }
252
+ // Precompute shared key for subsequent communications
253
+ try {
254
+ const walletPublicKeyBytes = _bs.default.decode(this.walletEncryptionPublicKeyBs58);
255
+ this.sharedKey = _tweetnacl.default.box.before(walletPublicKeyBytes, this.dappEncryptionKeyPair.secretKey);
256
+ } catch (e) {
257
+ this.sharedKey = null;
258
+ }
259
+
260
+ // Save session on successful connect
261
+ this.saveSession();
262
+ return {
263
+ userPublicKey: this.userPublicKey,
264
+ sessionToken: this.sessionToken,
265
+ walletEncryptionPublicKeyBs58: this.walletEncryptionPublicKeyBs58,
266
+ cluster
217
267
  };
218
- const subscription = _reactNative.Linking.addEventListener('url', handleDeepLink);
219
- this.setActiveSubscription(subscription);
220
- _reactNative.Linking.openURL(url).catch(err => {
221
- this.cleanupActiveSubscription();
222
- reject(new Error(`Failed to open Phantom wallet: ${err.message}. Is it installed?`));
223
- });
224
- });
268
+ }, 'Connection');
225
269
  }
226
270
  async disconnect() {
227
- if (!this.sessionToken || !this.phantomEncryptionPublicKeyBs58) {
271
+ if (!this.sessionToken || !this.walletEncryptionPublicKeyBs58) {
228
272
  await this.clearSession();
229
273
  this.emit('disconnect');
230
274
  return Promise.resolve();
@@ -232,9 +276,9 @@ class PhantomProvider extends _events.default {
232
276
  const payloadToEncrypt = {
233
277
  session: this.sessionToken
234
278
  };
235
- const encryptedDisconnectPayload = this.encryptPayload(payloadToEncrypt, this.phantomEncryptionPublicKeyBs58);
279
+ const encryptedDisconnectPayload = this.encryptPayload(payloadToEncrypt, this.walletEncryptionPublicKeyBs58);
236
280
  if (!encryptedDisconnectPayload) {
237
- // console.warn('PhantomProvider: Failed to encrypt disconnect payload. Clearing session locally.');
281
+ // console.warn(`${this.config.type} provider: Failed to encrypt disconnect payload. Clearing session locally.`);
238
282
  await this.clearSession();
239
283
  this.emit('disconnect');
240
284
  return Promise.resolve(); // Or reject, depending on desired strictness
@@ -246,53 +290,35 @@ class PhantomProvider extends _events.default {
246
290
  nonce: encryptedDisconnectPayload.nonce
247
291
  };
248
292
  const url = this.buildUrl('disconnect', disconnectDeeplinkParams);
249
- return new Promise((resolve, reject) => {
250
- const handleDeepLink = event => {
251
- try {
252
- this.cleanupActiveSubscription();
253
- if (event.url.startsWith(this.config.appScheme)) {
254
- this.clearSession();
255
- resolve();
256
- } else {
257
- this.clearSession();
258
- reject(new Error('Phantom Disconnect: Unexpected redirect URI.'));
259
- }
260
- } catch (error) {
261
- this.cleanupActiveSubscription();
262
- this.clearSession();
263
- reject(error);
264
- }
265
- };
266
- const subscription = _reactNative.Linking.addEventListener('url', handleDeepLink);
267
- this.setActiveSubscription(subscription);
268
- _reactNative.Linking.openURL(url).catch(err => {
269
- this.cleanupActiveSubscription();
270
- this.clearSession();
271
- reject(new Error(`Failed to open Phantom for disconnection: ${err.message}.`));
272
- });
273
- });
293
+ return this.openDeeplinkAndWait(url, () => {
294
+ this.clearSession();
295
+ }, 'Disconnection');
274
296
  }
275
297
  async clearSession() {
276
298
  this.sessionToken = null;
277
299
  this.userPublicKey = null;
278
- this.phantomEncryptionPublicKeyBs58 = null;
300
+ this.walletEncryptionPublicKeyBs58 = null;
301
+ if (this.sharedKey) {
302
+ this.sharedKey.fill(0);
303
+ }
304
+ this.sharedKey = null;
279
305
  this.cleanupActiveSubscription();
280
306
  await this.clearSessionStorage();
281
307
  }
282
308
  setSession(session) {
283
309
  this.sessionToken = session.sessionToken;
284
310
  this.userPublicKey = session.userPublicKey;
285
- this.phantomEncryptionPublicKeyBs58 = session.phantomEncryptionPublicKeyBs58;
311
+ this.walletEncryptionPublicKeyBs58 = session.walletEncryptionPublicKeyBs58;
286
312
  this.currentCluster = session.cluster;
287
313
  }
288
314
  async request(args, _chainId) {
289
315
  if (!isValidSolanaSigningMethod(args.method)) {
290
- throw new Error(`PhantomProvider: Unsupported method: ${args.method}. Only Solana signing methods are supported.`);
316
+ throw new Error(`${this.config.type} provider: Unsupported method: ${args.method}. Only Solana signing methods are supported.`);
291
317
  }
292
318
  const signingMethod = args.method;
293
319
  const requestParams = args.params;
294
- if (!this.isConnected() || !this.sessionToken || !this.phantomEncryptionPublicKeyBs58) {
295
- throw new Error('PhantomProvider: Not connected or session details missing. Cannot process request.');
320
+ if (!this.isConnected() || !this.sessionToken || !this.walletEncryptionPublicKeyBs58) {
321
+ throw new Error(`${this.config.type} provider: Not connected or session details missing. Cannot process request.`);
296
322
  }
297
323
  const rpcMethodName = this.getRpcMethodName(signingMethod);
298
324
  let deeplinkUrl = '';
@@ -308,9 +334,9 @@ class PhantomProvider extends _events.default {
308
334
  session: this.sessionToken,
309
335
  transaction: typedParams.transaction
310
336
  };
311
- const encryptedData = this.encryptPayload(dataToEncrypt, this.phantomEncryptionPublicKeyBs58);
337
+ const encryptedData = this.encryptPayload(dataToEncrypt, this.walletEncryptionPublicKeyBs58);
312
338
  if (!encryptedData) {
313
- throw new Error(`PhantomProvider: Failed to encrypt payload for ${signingMethod}.`);
339
+ throw new Error(`${this.config.type} provider: Failed to encrypt payload for ${signingMethod}.`);
314
340
  }
315
341
  const signTxDeeplinkParams = {
316
342
  dapp_encryption_public_key: _bs.default.encode(this.dappEncryptionKeyPair.publicKey),
@@ -326,7 +352,7 @@ class PhantomProvider extends _events.default {
326
352
  {
327
353
  const typedParams = requestParams;
328
354
  if (!typedParams || typeof typedParams.message === 'undefined') {
329
- throw new Error(`Missing 'message' in params for ${signingMethod}`);
355
+ throw new Error(`${this.config.type} provider: Missing 'message' in params for ${signingMethod}`);
330
356
  }
331
357
  let messageBs58;
332
358
  if (typedParams.message instanceof Uint8Array) {
@@ -339,16 +365,16 @@ class PhantomProvider extends _events.default {
339
365
  messageBs58 = _bs.default.encode(_buffer.Buffer.from(typedParams.message));
340
366
  }
341
367
  } else {
342
- throw new Error('Invalid message format for signMessage. Expected Uint8Array or string.');
368
+ throw new Error(`${this.config.type} provider: Invalid message format for signMessage. Expected Uint8Array or string.`);
343
369
  }
344
370
  const dataToEncrypt = {
345
371
  message: messageBs58,
346
372
  session: this.sessionToken,
347
373
  display: typedParams.display || 'utf8'
348
374
  };
349
- const encryptedPayloadData = this.encryptPayload(dataToEncrypt, this.phantomEncryptionPublicKeyBs58);
375
+ const encryptedPayloadData = this.encryptPayload(dataToEncrypt, this.walletEncryptionPublicKeyBs58);
350
376
  if (!encryptedPayloadData) {
351
- throw new Error('PhantomProvider: Failed to encrypt payload for signMessage.');
377
+ throw new Error(`${this.config.type} provider: Failed to encrypt payload for signMessage.`);
352
378
  }
353
379
  const signMsgDeeplinkQueryPayload = {
354
380
  dapp_encryption_public_key: _bs.default.encode(this.dappEncryptionKeyPair.publicKey),
@@ -363,15 +389,15 @@ class PhantomProvider extends _events.default {
363
389
  {
364
390
  const typedParams = requestParams;
365
391
  if (!typedParams || !Array.isArray(typedParams.transactions) || !typedParams.transactions.every(t => typeof t === 'string')) {
366
- throw new Error(`Missing or invalid 'transactions' (array of base58 strings) in params for ${signingMethod}`);
392
+ throw new Error(`${this.config.type} provider: Missing or invalid 'transactions' (array of base58 strings) in params for ${signingMethod}`);
367
393
  }
368
394
  const dataToEncrypt = {
369
395
  session: this.sessionToken,
370
396
  transactions: typedParams.transactions
371
397
  };
372
- const encryptedData = this.encryptPayload(dataToEncrypt, this.phantomEncryptionPublicKeyBs58);
398
+ const encryptedData = this.encryptPayload(dataToEncrypt, this.walletEncryptionPublicKeyBs58);
373
399
  if (!encryptedData) {
374
- throw new Error(`PhantomProvider: Failed to encrypt payload for ${signingMethod}.`);
400
+ throw new Error(`${this.config.type} provider: Failed to encrypt payload for ${signingMethod}.`);
375
401
  }
376
402
  const signAllTxDeeplinkParams = {
377
403
  dapp_encryption_public_key: _bs.default.encode(this.dappEncryptionKeyPair.publicKey),
@@ -385,47 +411,22 @@ class PhantomProvider extends _events.default {
385
411
  }
386
412
  default:
387
413
  {
388
- throw new Error(`PhantomProvider: Unhandled signing method: ${signingMethod}`);
414
+ throw new Error(`${this.config.type} provider: Unhandled signing method: ${signingMethod}`);
389
415
  }
390
416
  }
391
- return new Promise((resolve, reject) => {
392
- const handleDeepLink = async event => {
393
- try {
394
- this.cleanupActiveSubscription();
395
- const fullUrl = event.url;
396
- if (fullUrl.startsWith(this.config.appScheme)) {
397
- const responseUrlParams = new URLSearchParams(fullUrl.substring(fullUrl.indexOf('?') + 1));
398
- const errorCode = responseUrlParams.get('errorCode');
399
- const errorMessage = responseUrlParams.get('errorMessage');
400
- if (errorCode) {
401
- return reject(new Error(`Phantom ${signingMethod} Failed: ${errorMessage || 'Unknown error'} (Code: ${errorCode})`));
402
- }
403
- const responseNonce = responseUrlParams.get('nonce');
404
- const responseData = responseUrlParams.get('data');
405
- if (!responseNonce || !responseData) {
406
- return reject(new Error(`Phantom ${signingMethod}: Invalid response - missing nonce or data.`));
407
- }
408
- const decryptedResult = this.decryptPayload(responseData, responseNonce, this.phantomEncryptionPublicKeyBs58);
409
- if (!decryptedResult) {
410
- return reject(new Error(`Phantom ${signingMethod}: Failed to decrypt response or invalid decrypted data.`));
411
- }
412
- resolve(decryptedResult);
413
- } else {
414
- reject(new Error(`Phantom ${signingMethod}: Unexpected redirect URI.`));
415
- }
416
- } catch (error) {
417
- this.cleanupActiveSubscription();
418
- reject(error);
419
- }
420
- };
421
- const subscription = _reactNative.Linking.addEventListener('url', handleDeepLink);
422
- this.setActiveSubscription(subscription);
423
- _reactNative.Linking.openURL(deeplinkUrl).catch(err => {
424
- this.cleanupActiveSubscription();
425
- reject(new Error(`Failed to open Phantom for ${signingMethod}: ${err.message}. Is it installed?`));
426
- });
427
- });
417
+ return this.openDeeplinkAndWait(deeplinkUrl, responseUrlParams => {
418
+ const responseNonce = responseUrlParams.get('nonce');
419
+ const responseData = responseUrlParams.get('data');
420
+ if (!responseNonce || !responseData) {
421
+ throw new Error(`${this.config.type} provider: ${signingMethod}: Invalid response - missing nonce or data.`);
422
+ }
423
+ const decryptedResult = this.decryptPayload(responseData, responseNonce, this.walletEncryptionPublicKeyBs58);
424
+ if (!decryptedResult) {
425
+ throw new Error(`${this.config.type} provider: ${signingMethod}: Failed to decrypt response or invalid decrypted data.`);
426
+ }
427
+ return decryptedResult;
428
+ }, signingMethod);
428
429
  }
429
430
  }
430
- exports.PhantomProvider = PhantomProvider;
431
- //# sourceMappingURL=PhantomProvider.js.map
431
+ exports.DeeplinkProvider = DeeplinkProvider;
432
+ //# sourceMappingURL=DeeplinkProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_tweetnacl","_interopRequireDefault","_bs","_buffer","_events","e","__esModule","default","SOLANA_SIGNING_METHODS","exports","SOLANA_SIGN_TRANSACTION","SOLANA_SIGN_MESSAGE","SOLANA_SIGN_AND_SEND_TRANSACTION","SOLANA_SIGN_ALL_TRANSACTIONS","isValidSolanaSigningMethod","method","Object","values","includes","DeeplinkProvider","EventEmitter","sharedKey","sessionToken","userPublicKey","walletEncryptionPublicKeyBs58","activeSubscription","isOperationPending","constructor","config","currentCluster","cluster","dappEncryptionKeyPair","storage","getSessionStorageKey","type","destroy","cleanupActiveSubscription","removeAllListeners","remove","setActiveSubscription","subscription","getUserPublicKey","isConnected","getCurrentCluster","buildUrl","rpcMethod","params","query","URLSearchParams","toString","baseUrl","openDeeplinkAndWait","deeplinkUrl","processParams","contextLabel","Promise","resolve","reject","handleDeepLink","event","fullUrl","url","startsWith","appScheme","Error","substring","indexOf","errorCode","get","errorMessage","result","error","Linking","addEventListener","openURL","catch","err","message","getRpcMethodName","encryptPayload","payload","walletPublicKeyBs58","nonce","nacl","randomBytes","box","nonceLength","payloadBytes","Buffer","from","JSON","stringify","encryptedPayload","after","walletPublicKeyBytes","bs58","decode","secretKey","encode","console","warn","decryptPayload","encryptedDataBs58","nonceBs58","walletSenderPublicKeyBs58","formattedEncryptedDataBs58","replace","encryptedDataBytes","nonceBytes","decryptedPayloadBytes","open","walletSenderPublicKeyBytes","parse","restoreSession","session","getItem","setSession","before","clearSessionStorage","saveSession","setItem","removeItem","connect","connectDeeplinkParams","app_url","dappUrl","dapp_encryption_public_key","publicKey","redirect_link","responseUrlParams","responsePayload","wallet_encryption_public_key","encryptionKeyFieldName","data","decryptedData","public_key","disconnect","clearSession","emit","payloadToEncrypt","encryptedDisconnectPayload","disconnectDeeplinkParams","fill","request","args","_chainId","signingMethod","requestParams","rpcMethodName","typedParams","transaction","dataToEncrypt","encryptedData","signTxDeeplinkParams","messageBs58","Uint8Array","display","encryptedPayloadData","signMsgDeeplinkQueryPayload","Array","isArray","transactions","every","t","signAllTxDeeplinkParams","responseNonce","responseData","decryptedResult"],"sourceRoot":"../../../src","sources":["providers/DeeplinkProvider.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,GAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAwBA,IAAAK,OAAA,GAAAH,sB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CAACM,IAAI,cAAcgH,aAAa,6CAChD,CAAC;MACH;MACA,MAAMqB,eAAe,GAAG,IAAI,CAAClE,cAAc,CACzCiE,YAAY,EACZD,aAAa,EACb,IAAI,CAAC7I,6BACP,CAAC;MACD,IAAI,CAAC+I,eAAe,EAAE;QACpB,MAAM,IAAIvG,KAAK,CACb,GAAG,IAAI,CAACpC,MAAM,CAACM,IAAI,cAAcgH,aAAa,yDAChD,CAAC;MACH;MAEA,OAAOqB,eAAe;IACxB,CAAC,EACDrB,aACF,CAAC;EACH;AACF;AAACzI,OAAA,CAAAU,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -70,7 +70,7 @@ export class SolanaAdapter extends SolanaBaseAdapter {
70
70
  if (!network) {
71
71
  throw new Error('SolanaAdapter:signTransaction - network is undefined');
72
72
  }
73
- const provider = this.connector.getProvider();
73
+ const provider = this.connector.getProvider('solana');
74
74
  if (!provider) {
75
75
  throw new Error('SolanaAdapter:signTransaction - provider is undefined');
76
76
  }
@@ -123,7 +123,7 @@ export class SolanaAdapter extends SolanaBaseAdapter {
123
123
  if (!this.connector) {
124
124
  throw new Error('SolanaAdapter:sendTransaction - no active connector');
125
125
  }
126
- const provider = this.connector.getProvider();
126
+ const provider = this.connector.getProvider('solana');
127
127
  if (!provider) {
128
128
  throw new Error('SolanaAdapter:sendTransaction - provider is undefined');
129
129
  }
@@ -179,7 +179,7 @@ export class SolanaAdapter extends SolanaBaseAdapter {
179
179
  }
180
180
  async switchNetwork(network) {
181
181
  if (!this.connector) throw new Error('No active connector');
182
- const provider = this.connector.getProvider();
182
+ const provider = this.connector.getProvider('solana');
183
183
  if (!provider) throw new Error('No active provider');
184
184
  try {
185
185
  await this.connector.switchNetwork(network);