@solana-mobile/wallet-adapter-mobile 0.0.1-alpha.3 → 0.0.1-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.browser.js +22 -26
- package/lib/cjs/index.js +22 -26
- package/lib/cjs/index.native.js +22 -26
- package/lib/esm/index.browser.mjs +22 -26
- package/lib/esm/index.mjs +22 -26
- package/package.json +3 -3
package/lib/cjs/index.browser.js
CHANGED
|
@@ -63,7 +63,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
63
63
|
}
|
|
64
64
|
get publicKey() {
|
|
65
65
|
if (this._publicKey == null && this._authorizationResult != null) {
|
|
66
|
-
this._publicKey = new web3_js.PublicKey(this._authorizationResult.
|
|
66
|
+
this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
|
|
67
67
|
}
|
|
68
68
|
return this._publicKey ? this._publicKey : null;
|
|
69
69
|
}
|
|
@@ -98,8 +98,8 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
try {
|
|
101
|
-
yield this.transact((
|
|
102
|
-
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield
|
|
101
|
+
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield wallet.authorize({ identity: this._appIdentity });
|
|
103
103
|
try {
|
|
104
104
|
this._publicKey = new web3_js.PublicKey(base58PublicKey);
|
|
105
105
|
}
|
|
@@ -107,9 +107,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
107
107
|
throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
|
|
108
108
|
}
|
|
109
109
|
this.handleAuthorizationResult({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
auth_token,
|
|
111
|
+
pub_key: base58PublicKey,
|
|
112
|
+
wallet_uri_base: wallet_uri_base,
|
|
113
113
|
}); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
114
114
|
this.emit('connect',
|
|
115
115
|
// Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
|
|
@@ -131,15 +131,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
131
131
|
yield this._authorizationResultCache.set(authorizationResult);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
performReauthorization(
|
|
134
|
+
performReauthorization(wallet, currentAuthorizationResult) {
|
|
135
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
136
|
try {
|
|
137
|
-
const { auth_token } = yield
|
|
138
|
-
|
|
139
|
-
auth_token: currentAuthorizationResult.authToken,
|
|
137
|
+
const { auth_token } = yield wallet.reauthorize({
|
|
138
|
+
auth_token: currentAuthorizationResult.auth_token,
|
|
140
139
|
});
|
|
141
|
-
if (currentAuthorizationResult.
|
|
142
|
-
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), {
|
|
140
|
+
if (currentAuthorizationResult.auth_token !== auth_token) {
|
|
141
|
+
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
143
142
|
}
|
|
144
143
|
return auth_token;
|
|
145
144
|
}
|
|
@@ -160,7 +159,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
160
159
|
transact(callback) {
|
|
161
160
|
var _a;
|
|
162
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.
|
|
162
|
+
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
164
163
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
165
164
|
return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
|
|
166
165
|
});
|
|
@@ -176,10 +175,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
176
175
|
try {
|
|
177
176
|
const authorizationResult = this.assertIsAuthorized();
|
|
178
177
|
try {
|
|
179
|
-
return yield this.transact((
|
|
180
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
181
|
-
const signedTransactions = yield
|
|
182
|
-
method: 'sign_transaction',
|
|
178
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
180
|
+
const signedTransactions = yield wallet.signTransaction({
|
|
183
181
|
auth_token: freshAuthToken,
|
|
184
182
|
transactions,
|
|
185
183
|
});
|
|
@@ -201,10 +199,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
201
199
|
try {
|
|
202
200
|
const authorizationResult = this.assertIsAuthorized();
|
|
203
201
|
try {
|
|
204
|
-
return yield this.transact((
|
|
205
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
206
|
-
const signatures = yield
|
|
207
|
-
method: 'sign_and_send_transaction',
|
|
202
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
204
|
+
const signatures = yield wallet.signAndSendTransaction({
|
|
208
205
|
auth_token: freshAuthToken,
|
|
209
206
|
fee_payer: this.publicKey || undefined,
|
|
210
207
|
connection,
|
|
@@ -240,12 +237,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
240
237
|
try {
|
|
241
238
|
const authorizationResult = this.assertIsAuthorized();
|
|
242
239
|
try {
|
|
243
|
-
return yield this.transact((
|
|
244
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
245
|
-
const [signedMessage] = yield
|
|
246
|
-
method: 'sign_message',
|
|
240
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
242
|
+
const [signedMessage] = yield wallet.signMessage({
|
|
247
243
|
auth_token: freshAuthToken,
|
|
248
|
-
|
|
244
|
+
payloads: [message],
|
|
249
245
|
});
|
|
250
246
|
const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
|
|
251
247
|
return signature;
|
package/lib/cjs/index.js
CHANGED
|
@@ -63,7 +63,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
63
63
|
}
|
|
64
64
|
get publicKey() {
|
|
65
65
|
if (this._publicKey == null && this._authorizationResult != null) {
|
|
66
|
-
this._publicKey = new web3_js.PublicKey(this._authorizationResult.
|
|
66
|
+
this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
|
|
67
67
|
}
|
|
68
68
|
return this._publicKey ? this._publicKey : null;
|
|
69
69
|
}
|
|
@@ -98,8 +98,8 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
try {
|
|
101
|
-
yield this.transact((
|
|
102
|
-
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield
|
|
101
|
+
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield wallet.authorize({ identity: this._appIdentity });
|
|
103
103
|
try {
|
|
104
104
|
this._publicKey = new web3_js.PublicKey(base58PublicKey);
|
|
105
105
|
}
|
|
@@ -107,9 +107,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
107
107
|
throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
|
|
108
108
|
}
|
|
109
109
|
this.handleAuthorizationResult({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
auth_token,
|
|
111
|
+
pub_key: base58PublicKey,
|
|
112
|
+
wallet_uri_base: wallet_uri_base,
|
|
113
113
|
}); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
114
114
|
this.emit('connect',
|
|
115
115
|
// Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
|
|
@@ -131,15 +131,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
131
131
|
yield this._authorizationResultCache.set(authorizationResult);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
performReauthorization(
|
|
134
|
+
performReauthorization(wallet, currentAuthorizationResult) {
|
|
135
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
136
|
try {
|
|
137
|
-
const { auth_token } = yield
|
|
138
|
-
|
|
139
|
-
auth_token: currentAuthorizationResult.authToken,
|
|
137
|
+
const { auth_token } = yield wallet.reauthorize({
|
|
138
|
+
auth_token: currentAuthorizationResult.auth_token,
|
|
140
139
|
});
|
|
141
|
-
if (currentAuthorizationResult.
|
|
142
|
-
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), {
|
|
140
|
+
if (currentAuthorizationResult.auth_token !== auth_token) {
|
|
141
|
+
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
143
142
|
}
|
|
144
143
|
return auth_token;
|
|
145
144
|
}
|
|
@@ -160,7 +159,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
160
159
|
transact(callback) {
|
|
161
160
|
var _a;
|
|
162
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.
|
|
162
|
+
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
164
163
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
165
164
|
return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
|
|
166
165
|
});
|
|
@@ -176,10 +175,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
176
175
|
try {
|
|
177
176
|
const authorizationResult = this.assertIsAuthorized();
|
|
178
177
|
try {
|
|
179
|
-
return yield this.transact((
|
|
180
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
181
|
-
const signedTransactions = yield
|
|
182
|
-
method: 'sign_transaction',
|
|
178
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
180
|
+
const signedTransactions = yield wallet.signTransaction({
|
|
183
181
|
auth_token: freshAuthToken,
|
|
184
182
|
transactions,
|
|
185
183
|
});
|
|
@@ -201,10 +199,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
201
199
|
try {
|
|
202
200
|
const authorizationResult = this.assertIsAuthorized();
|
|
203
201
|
try {
|
|
204
|
-
return yield this.transact((
|
|
205
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
206
|
-
const signatures = yield
|
|
207
|
-
method: 'sign_and_send_transaction',
|
|
202
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
204
|
+
const signatures = yield wallet.signAndSendTransaction({
|
|
208
205
|
auth_token: freshAuthToken,
|
|
209
206
|
fee_payer: this.publicKey || undefined,
|
|
210
207
|
connection,
|
|
@@ -240,12 +237,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
240
237
|
try {
|
|
241
238
|
const authorizationResult = this.assertIsAuthorized();
|
|
242
239
|
try {
|
|
243
|
-
return yield this.transact((
|
|
244
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
245
|
-
const [signedMessage] = yield
|
|
246
|
-
method: 'sign_message',
|
|
240
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
242
|
+
const [signedMessage] = yield wallet.signMessage({
|
|
247
243
|
auth_token: freshAuthToken,
|
|
248
|
-
|
|
244
|
+
payloads: [message],
|
|
249
245
|
});
|
|
250
246
|
const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
|
|
251
247
|
return signature;
|
package/lib/cjs/index.native.js
CHANGED
|
@@ -66,7 +66,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
66
66
|
}
|
|
67
67
|
get publicKey() {
|
|
68
68
|
if (this._publicKey == null && this._authorizationResult != null) {
|
|
69
|
-
this._publicKey = new web3_js.PublicKey(this._authorizationResult.
|
|
69
|
+
this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
|
|
70
70
|
}
|
|
71
71
|
return this._publicKey ? this._publicKey : null;
|
|
72
72
|
}
|
|
@@ -101,8 +101,8 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
try {
|
|
104
|
-
yield this.transact((
|
|
105
|
-
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield
|
|
104
|
+
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield wallet.authorize({ identity: this._appIdentity });
|
|
106
106
|
try {
|
|
107
107
|
this._publicKey = new web3_js.PublicKey(base58PublicKey);
|
|
108
108
|
}
|
|
@@ -110,9 +110,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
110
110
|
throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
|
|
111
111
|
}
|
|
112
112
|
this.handleAuthorizationResult({
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
auth_token,
|
|
114
|
+
pub_key: base58PublicKey,
|
|
115
|
+
wallet_uri_base: wallet_uri_base,
|
|
116
116
|
}); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
117
117
|
this.emit('connect',
|
|
118
118
|
// Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
|
|
@@ -134,15 +134,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
134
134
|
yield this._authorizationResultCache.set(authorizationResult);
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
-
performReauthorization(
|
|
137
|
+
performReauthorization(wallet, currentAuthorizationResult) {
|
|
138
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
139
|
try {
|
|
140
|
-
const { auth_token } = yield
|
|
141
|
-
|
|
142
|
-
auth_token: currentAuthorizationResult.authToken,
|
|
140
|
+
const { auth_token } = yield wallet.reauthorize({
|
|
141
|
+
auth_token: currentAuthorizationResult.auth_token,
|
|
143
142
|
});
|
|
144
|
-
if (currentAuthorizationResult.
|
|
145
|
-
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), {
|
|
143
|
+
if (currentAuthorizationResult.auth_token !== auth_token) {
|
|
144
|
+
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
146
145
|
}
|
|
147
146
|
return auth_token;
|
|
148
147
|
}
|
|
@@ -163,7 +162,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
163
162
|
transact(callback) {
|
|
164
163
|
var _a;
|
|
165
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.
|
|
165
|
+
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
167
166
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
168
167
|
return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
|
|
169
168
|
});
|
|
@@ -179,10 +178,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
179
178
|
try {
|
|
180
179
|
const authorizationResult = this.assertIsAuthorized();
|
|
181
180
|
try {
|
|
182
|
-
return yield this.transact((
|
|
183
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
184
|
-
const signedTransactions = yield
|
|
185
|
-
method: 'sign_transaction',
|
|
181
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
183
|
+
const signedTransactions = yield wallet.signTransaction({
|
|
186
184
|
auth_token: freshAuthToken,
|
|
187
185
|
transactions,
|
|
188
186
|
});
|
|
@@ -204,10 +202,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
204
202
|
try {
|
|
205
203
|
const authorizationResult = this.assertIsAuthorized();
|
|
206
204
|
try {
|
|
207
|
-
return yield this.transact((
|
|
208
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
209
|
-
const signatures = yield
|
|
210
|
-
method: 'sign_and_send_transaction',
|
|
205
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
207
|
+
const signatures = yield wallet.signAndSendTransaction({
|
|
211
208
|
auth_token: freshAuthToken,
|
|
212
209
|
fee_payer: this.publicKey || undefined,
|
|
213
210
|
connection,
|
|
@@ -243,12 +240,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
243
240
|
try {
|
|
244
241
|
const authorizationResult = this.assertIsAuthorized();
|
|
245
242
|
try {
|
|
246
|
-
return yield this.transact((
|
|
247
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
248
|
-
const [signedMessage] = yield
|
|
249
|
-
method: 'sign_message',
|
|
243
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
245
|
+
const [signedMessage] = yield wallet.signMessage({
|
|
250
246
|
auth_token: freshAuthToken,
|
|
251
|
-
|
|
247
|
+
payloads: [message],
|
|
252
248
|
});
|
|
253
249
|
const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
|
|
254
250
|
return signature;
|
|
@@ -59,7 +59,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
59
59
|
}
|
|
60
60
|
get publicKey() {
|
|
61
61
|
if (this._publicKey == null && this._authorizationResult != null) {
|
|
62
|
-
this._publicKey = new PublicKey(this._authorizationResult.
|
|
62
|
+
this._publicKey = new PublicKey(this._authorizationResult.pub_key);
|
|
63
63
|
}
|
|
64
64
|
return this._publicKey ? this._publicKey : null;
|
|
65
65
|
}
|
|
@@ -94,8 +94,8 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
try {
|
|
97
|
-
yield this.transact((
|
|
98
|
-
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield
|
|
97
|
+
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield wallet.authorize({ identity: this._appIdentity });
|
|
99
99
|
try {
|
|
100
100
|
this._publicKey = new PublicKey(base58PublicKey);
|
|
101
101
|
}
|
|
@@ -103,9 +103,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
103
103
|
throw new WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
|
|
104
104
|
}
|
|
105
105
|
this.handleAuthorizationResult({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
auth_token,
|
|
107
|
+
pub_key: base58PublicKey,
|
|
108
|
+
wallet_uri_base: wallet_uri_base,
|
|
109
109
|
}); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
110
110
|
this.emit('connect',
|
|
111
111
|
// Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
|
|
@@ -127,15 +127,14 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
127
127
|
yield this._authorizationResultCache.set(authorizationResult);
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
performReauthorization(
|
|
130
|
+
performReauthorization(wallet, currentAuthorizationResult) {
|
|
131
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
132
|
try {
|
|
133
|
-
const { auth_token } = yield
|
|
134
|
-
|
|
135
|
-
auth_token: currentAuthorizationResult.authToken,
|
|
133
|
+
const { auth_token } = yield wallet.reauthorize({
|
|
134
|
+
auth_token: currentAuthorizationResult.auth_token,
|
|
136
135
|
});
|
|
137
|
-
if (currentAuthorizationResult.
|
|
138
|
-
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), {
|
|
136
|
+
if (currentAuthorizationResult.auth_token !== auth_token) {
|
|
137
|
+
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
139
138
|
}
|
|
140
139
|
return auth_token;
|
|
141
140
|
}
|
|
@@ -156,7 +155,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
156
155
|
transact(callback) {
|
|
157
156
|
var _a;
|
|
158
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.
|
|
158
|
+
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
160
159
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
161
160
|
return yield transact(callback, config);
|
|
162
161
|
});
|
|
@@ -172,10 +171,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
172
171
|
try {
|
|
173
172
|
const authorizationResult = this.assertIsAuthorized();
|
|
174
173
|
try {
|
|
175
|
-
return yield this.transact((
|
|
176
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
177
|
-
const signedTransactions = yield
|
|
178
|
-
method: 'sign_transaction',
|
|
174
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
176
|
+
const signedTransactions = yield wallet.signTransaction({
|
|
179
177
|
auth_token: freshAuthToken,
|
|
180
178
|
transactions,
|
|
181
179
|
});
|
|
@@ -197,10 +195,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
197
195
|
try {
|
|
198
196
|
const authorizationResult = this.assertIsAuthorized();
|
|
199
197
|
try {
|
|
200
|
-
return yield this.transact((
|
|
201
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
202
|
-
const signatures = yield
|
|
203
|
-
method: 'sign_and_send_transaction',
|
|
198
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
200
|
+
const signatures = yield wallet.signAndSendTransaction({
|
|
204
201
|
auth_token: freshAuthToken,
|
|
205
202
|
fee_payer: this.publicKey || undefined,
|
|
206
203
|
connection,
|
|
@@ -236,12 +233,11 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
236
233
|
try {
|
|
237
234
|
const authorizationResult = this.assertIsAuthorized();
|
|
238
235
|
try {
|
|
239
|
-
return yield this.transact((
|
|
240
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
241
|
-
const [signedMessage] = yield
|
|
242
|
-
method: 'sign_message',
|
|
236
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
238
|
+
const [signedMessage] = yield wallet.signMessage({
|
|
243
239
|
auth_token: freshAuthToken,
|
|
244
|
-
|
|
240
|
+
payloads: [message],
|
|
245
241
|
});
|
|
246
242
|
const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
|
|
247
243
|
return signature;
|
package/lib/esm/index.mjs
CHANGED
|
@@ -59,7 +59,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
59
59
|
}
|
|
60
60
|
get publicKey() {
|
|
61
61
|
if (this._publicKey == null && this._authorizationResult != null) {
|
|
62
|
-
this._publicKey = new PublicKey(this._authorizationResult.
|
|
62
|
+
this._publicKey = new PublicKey(this._authorizationResult.pub_key);
|
|
63
63
|
}
|
|
64
64
|
return this._publicKey ? this._publicKey : null;
|
|
65
65
|
}
|
|
@@ -94,8 +94,8 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
try {
|
|
97
|
-
yield this.transact((
|
|
98
|
-
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield
|
|
97
|
+
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield wallet.authorize({ identity: this._appIdentity });
|
|
99
99
|
try {
|
|
100
100
|
this._publicKey = new PublicKey(base58PublicKey);
|
|
101
101
|
}
|
|
@@ -103,9 +103,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
103
103
|
throw new WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
|
|
104
104
|
}
|
|
105
105
|
this.handleAuthorizationResult({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
auth_token,
|
|
107
|
+
pub_key: base58PublicKey,
|
|
108
|
+
wallet_uri_base: wallet_uri_base,
|
|
109
109
|
}); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
110
110
|
this.emit('connect',
|
|
111
111
|
// Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
|
|
@@ -127,15 +127,14 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
127
127
|
yield this._authorizationResultCache.set(authorizationResult);
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
performReauthorization(
|
|
130
|
+
performReauthorization(wallet, currentAuthorizationResult) {
|
|
131
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
132
|
try {
|
|
133
|
-
const { auth_token } = yield
|
|
134
|
-
|
|
135
|
-
auth_token: currentAuthorizationResult.authToken,
|
|
133
|
+
const { auth_token } = yield wallet.reauthorize({
|
|
134
|
+
auth_token: currentAuthorizationResult.auth_token,
|
|
136
135
|
});
|
|
137
|
-
if (currentAuthorizationResult.
|
|
138
|
-
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), {
|
|
136
|
+
if (currentAuthorizationResult.auth_token !== auth_token) {
|
|
137
|
+
this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
139
138
|
}
|
|
140
139
|
return auth_token;
|
|
141
140
|
}
|
|
@@ -156,7 +155,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
156
155
|
transact(callback) {
|
|
157
156
|
var _a;
|
|
158
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.
|
|
158
|
+
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
160
159
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
161
160
|
return yield transact(callback, config);
|
|
162
161
|
});
|
|
@@ -172,10 +171,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
172
171
|
try {
|
|
173
172
|
const authorizationResult = this.assertIsAuthorized();
|
|
174
173
|
try {
|
|
175
|
-
return yield this.transact((
|
|
176
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
177
|
-
const signedTransactions = yield
|
|
178
|
-
method: 'sign_transaction',
|
|
174
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
176
|
+
const signedTransactions = yield wallet.signTransaction({
|
|
179
177
|
auth_token: freshAuthToken,
|
|
180
178
|
transactions,
|
|
181
179
|
});
|
|
@@ -197,10 +195,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
197
195
|
try {
|
|
198
196
|
const authorizationResult = this.assertIsAuthorized();
|
|
199
197
|
try {
|
|
200
|
-
return yield this.transact((
|
|
201
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
202
|
-
const signatures = yield
|
|
203
|
-
method: 'sign_and_send_transaction',
|
|
198
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
200
|
+
const signatures = yield wallet.signAndSendTransaction({
|
|
204
201
|
auth_token: freshAuthToken,
|
|
205
202
|
fee_payer: this.publicKey || undefined,
|
|
206
203
|
connection,
|
|
@@ -236,12 +233,11 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
236
233
|
try {
|
|
237
234
|
const authorizationResult = this.assertIsAuthorized();
|
|
238
235
|
try {
|
|
239
|
-
return yield this.transact((
|
|
240
|
-
const freshAuthToken = yield this.performReauthorization(
|
|
241
|
-
const [signedMessage] = yield
|
|
242
|
-
method: 'sign_message',
|
|
236
|
+
return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
const freshAuthToken = yield this.performReauthorization(wallet, authorizationResult);
|
|
238
|
+
const [signedMessage] = yield wallet.signMessage({
|
|
243
239
|
auth_token: freshAuthToken,
|
|
244
|
-
|
|
240
|
+
payloads: [message],
|
|
245
241
|
});
|
|
246
242
|
const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
|
|
247
243
|
return signature;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana-mobile/wallet-adapter-mobile",
|
|
3
3
|
"description": "An adapter for mobile wallet apps that conform to the Solana Mobile Wallet Adapter protocol",
|
|
4
|
-
"version": "0.0.1-alpha.
|
|
4
|
+
"version": "0.0.1-alpha.6",
|
|
5
5
|
"author": "Steven Luscher <steven.luscher@solanamobile.com>",
|
|
6
6
|
"repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@react-native-async-storage/async-storage": "^1.17.7",
|
|
44
|
-
"@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^0.0.1-alpha.
|
|
44
|
+
"@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^0.0.1-alpha.6",
|
|
45
45
|
"@solana/wallet-adapter-base": "^0.9.8",
|
|
46
46
|
"@solana/web3.js": "^1.20.0"
|
|
47
47
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"agadoo": "^2.0.0",
|
|
50
50
|
"shx": "^0.3.4"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "8cef0e0dd72e01cd522b16b6e486a26abe1e032b"
|
|
53
53
|
}
|