@solana-mobile/mobile-wallet-adapter-protocol 0.0.1-alpha.1 → 0.0.1-alpha.3
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/README.md +5 -5
- package/lib/cjs/index.browser.js +53 -40
- package/lib/cjs/index.js +53 -40
- package/lib/cjs/index.native.js +41 -28
- package/lib/esm/index.browser.mjs +53 -40
- package/lib/esm/index.mjs +53 -40
- package/lib/types/index.browser.d.mts +85 -78
- package/lib/types/index.browser.d.mts.map +1 -1
- package/lib/types/index.browser.d.ts +85 -78
- package/lib/types/index.browser.d.ts.map +1 -1
- package/lib/types/index.d.mts +85 -78
- package/lib/types/index.d.mts.map +1 -1
- package/lib/types/index.d.ts +85 -78
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.native.d.ts +85 -78
- package/lib/types/index.native.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,17 +9,17 @@ If you are simply looking to integrate a JavaScript application with mobile wall
|
|
|
9
9
|
Use this API to start a session:
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import {
|
|
12
|
+
import {transact} from '@solana-mobile/mobile-wallet-adapter-protocol';
|
|
13
13
|
|
|
14
|
-
await
|
|
14
|
+
await transact(async (wallet) => {
|
|
15
15
|
/* ... */
|
|
16
16
|
});
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
The callback you provide will be called once a session has been established with a wallet. It will recieve the `MobileWallet` API as an argument. You can call protocol-specified methods using this function. Whatever you return from this callback will be returned by `
|
|
19
|
+
The callback you provide will be called once a session has been established with a wallet. It will recieve the `MobileWallet` API as an argument. You can call protocol-specified methods using this function. Whatever you return from this callback will be returned by `transact`.
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
const signedPayloads = await
|
|
22
|
+
const signedPayloads = await transact(async (wallet) => {
|
|
23
23
|
const {signed_payloads} = await wallet('sign_message', {
|
|
24
24
|
auth_token,
|
|
25
25
|
payloads: [/* ... */],
|
|
@@ -36,7 +36,7 @@ You can catch exceptions at any level. See `errors.ts` for a list of exceptions
|
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
38
|
try {
|
|
39
|
-
await
|
|
39
|
+
await transact(async (wallet) => {
|
|
40
40
|
try {
|
|
41
41
|
await wallet('sign_transaction', /* ... */);
|
|
42
42
|
} catch (e) {
|
package/lib/cjs/index.browser.js
CHANGED
|
@@ -2,42 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
/******************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
|
|
20
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
33
|
-
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
34
|
-
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
35
|
-
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
36
|
-
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
37
|
-
return response;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
5
|
class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
|
|
42
6
|
constructor() {
|
|
43
7
|
super('The mobile wallet adapter protocol must be used in a secure context (`https`).');
|
|
@@ -100,6 +64,54 @@ class SolanaMobileWalletAdapterProtocolJsonRpcError extends Error {
|
|
|
100
64
|
}
|
|
101
65
|
}
|
|
102
66
|
|
|
67
|
+
/******************************************************************************
|
|
68
|
+
Copyright (c) Microsoft Corporation.
|
|
69
|
+
|
|
70
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
71
|
+
purpose with or without fee is hereby granted.
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
74
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
75
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
76
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
77
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
78
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
79
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
80
|
+
***************************************************************************** */
|
|
81
|
+
|
|
82
|
+
function __rest(s, e) {
|
|
83
|
+
var t = {};
|
|
84
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
85
|
+
t[p] = s[p];
|
|
86
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
87
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
88
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
89
|
+
t[p[i]] = s[p[i]];
|
|
90
|
+
}
|
|
91
|
+
return t;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
95
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
96
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
97
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
98
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
99
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
100
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
107
|
+
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
108
|
+
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
109
|
+
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
110
|
+
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
111
|
+
return response;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
103
115
|
function generateAssociationKeypair() {
|
|
104
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
117
|
return yield crypto.subtle.generateKey({
|
|
@@ -342,7 +354,7 @@ function assertSecureContext() {
|
|
|
342
354
|
throw new SolanaMobileWalletAdapterSecureContextRequiredError();
|
|
343
355
|
}
|
|
344
356
|
}
|
|
345
|
-
function
|
|
357
|
+
function transact(callback, config) {
|
|
346
358
|
return __awaiter(this, void 0, void 0, function* () {
|
|
347
359
|
assertSecureContext();
|
|
348
360
|
const associationKeypair = yield generateAssociationKeypair();
|
|
@@ -416,7 +428,8 @@ function withLocalWallet(callback, config) {
|
|
|
416
428
|
case 'hello_req_sent': {
|
|
417
429
|
const sharedSecret = yield parseHelloRsp(responseBuffer, state.associationPublicKey, state.ecdhPrivateKey);
|
|
418
430
|
state = { __type: 'connected', sharedSecret };
|
|
419
|
-
const
|
|
431
|
+
const walletAPI = (_a) => __awaiter(this, void 0, void 0, function* () {
|
|
432
|
+
var { method } = _a, params = __rest(_a, ["method"]);
|
|
420
433
|
const id = nextJsonRpcMessageId++;
|
|
421
434
|
socket.send(yield encryptJsonRpcMessage({
|
|
422
435
|
id,
|
|
@@ -429,7 +442,7 @@ function withLocalWallet(callback, config) {
|
|
|
429
442
|
});
|
|
430
443
|
});
|
|
431
444
|
try {
|
|
432
|
-
resolve(yield callback(
|
|
445
|
+
resolve(yield callback(walletAPI));
|
|
433
446
|
}
|
|
434
447
|
catch (e) {
|
|
435
448
|
reject(e);
|
|
@@ -476,4 +489,4 @@ exports.SolanaMobileWalletAdapterProtocolSessionClosedError = SolanaMobileWallet
|
|
|
476
489
|
exports.SolanaMobileWalletAdapterProtocolSessionEstablishmentError = SolanaMobileWalletAdapterProtocolSessionEstablishmentError;
|
|
477
490
|
exports.SolanaMobileWalletAdapterSecureContextRequiredError = SolanaMobileWalletAdapterSecureContextRequiredError;
|
|
478
491
|
exports.SolanaMobileWalletAdapterWalletNotInstalledError = SolanaMobileWalletAdapterWalletNotInstalledError;
|
|
479
|
-
exports.
|
|
492
|
+
exports.transact = transact;
|
package/lib/cjs/index.js
CHANGED
|
@@ -2,42 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
/******************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
|
|
20
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
33
|
-
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
34
|
-
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
35
|
-
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
36
|
-
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
37
|
-
return response;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
5
|
class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
|
|
42
6
|
constructor() {
|
|
43
7
|
super('The mobile wallet adapter protocol must be used in a secure context (`https`).');
|
|
@@ -100,6 +64,54 @@ class SolanaMobileWalletAdapterProtocolJsonRpcError extends Error {
|
|
|
100
64
|
}
|
|
101
65
|
}
|
|
102
66
|
|
|
67
|
+
/******************************************************************************
|
|
68
|
+
Copyright (c) Microsoft Corporation.
|
|
69
|
+
|
|
70
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
71
|
+
purpose with or without fee is hereby granted.
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
74
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
75
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
76
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
77
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
78
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
79
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
80
|
+
***************************************************************************** */
|
|
81
|
+
|
|
82
|
+
function __rest(s, e) {
|
|
83
|
+
var t = {};
|
|
84
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
85
|
+
t[p] = s[p];
|
|
86
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
87
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
88
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
89
|
+
t[p[i]] = s[p[i]];
|
|
90
|
+
}
|
|
91
|
+
return t;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
95
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
96
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
97
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
98
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
99
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
100
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
107
|
+
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
108
|
+
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
109
|
+
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
110
|
+
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
111
|
+
return response;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
103
115
|
function generateAssociationKeypair() {
|
|
104
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
117
|
return yield crypto.subtle.generateKey({
|
|
@@ -342,7 +354,7 @@ function assertSecureContext() {
|
|
|
342
354
|
throw new SolanaMobileWalletAdapterSecureContextRequiredError();
|
|
343
355
|
}
|
|
344
356
|
}
|
|
345
|
-
function
|
|
357
|
+
function transact(callback, config) {
|
|
346
358
|
return __awaiter(this, void 0, void 0, function* () {
|
|
347
359
|
assertSecureContext();
|
|
348
360
|
const associationKeypair = yield generateAssociationKeypair();
|
|
@@ -416,7 +428,8 @@ function withLocalWallet(callback, config) {
|
|
|
416
428
|
case 'hello_req_sent': {
|
|
417
429
|
const sharedSecret = yield parseHelloRsp(responseBuffer, state.associationPublicKey, state.ecdhPrivateKey);
|
|
418
430
|
state = { __type: 'connected', sharedSecret };
|
|
419
|
-
const
|
|
431
|
+
const walletAPI = (_a) => __awaiter(this, void 0, void 0, function* () {
|
|
432
|
+
var { method } = _a, params = __rest(_a, ["method"]);
|
|
420
433
|
const id = nextJsonRpcMessageId++;
|
|
421
434
|
socket.send(yield encryptJsonRpcMessage({
|
|
422
435
|
id,
|
|
@@ -429,7 +442,7 @@ function withLocalWallet(callback, config) {
|
|
|
429
442
|
});
|
|
430
443
|
});
|
|
431
444
|
try {
|
|
432
|
-
resolve(yield callback(
|
|
445
|
+
resolve(yield callback(walletAPI));
|
|
433
446
|
}
|
|
434
447
|
catch (e) {
|
|
435
448
|
reject(e);
|
|
@@ -476,4 +489,4 @@ exports.SolanaMobileWalletAdapterProtocolSessionClosedError = SolanaMobileWallet
|
|
|
476
489
|
exports.SolanaMobileWalletAdapterProtocolSessionEstablishmentError = SolanaMobileWalletAdapterProtocolSessionEstablishmentError;
|
|
477
490
|
exports.SolanaMobileWalletAdapterSecureContextRequiredError = SolanaMobileWalletAdapterSecureContextRequiredError;
|
|
478
491
|
exports.SolanaMobileWalletAdapterWalletNotInstalledError = SolanaMobileWalletAdapterWalletNotInstalledError;
|
|
479
|
-
exports.
|
|
492
|
+
exports.transact = transact;
|
package/lib/cjs/index.native.js
CHANGED
|
@@ -4,31 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
|
|
7
|
-
/******************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
|
|
22
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
23
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
24
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
26
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
27
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
28
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
7
|
class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
|
|
33
8
|
constructor() {
|
|
34
9
|
super('The mobile wallet adapter protocol must be used in a secure context (`https`).');
|
|
@@ -91,6 +66,43 @@ class SolanaMobileWalletAdapterProtocolJsonRpcError extends Error {
|
|
|
91
66
|
}
|
|
92
67
|
}
|
|
93
68
|
|
|
69
|
+
/******************************************************************************
|
|
70
|
+
Copyright (c) Microsoft Corporation.
|
|
71
|
+
|
|
72
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
73
|
+
purpose with or without fee is hereby granted.
|
|
74
|
+
|
|
75
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
76
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
77
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
78
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
79
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
80
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
81
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
82
|
+
***************************************************************************** */
|
|
83
|
+
|
|
84
|
+
function __rest(s, e) {
|
|
85
|
+
var t = {};
|
|
86
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
87
|
+
t[p] = s[p];
|
|
88
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
89
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
90
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
91
|
+
t[p[i]] = s[p[i]];
|
|
92
|
+
}
|
|
93
|
+
return t;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
97
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
98
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
99
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
100
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
101
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
102
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
94
106
|
const LINKING_ERROR = `The package 'solana-mobile-wallet-adapter-protocol' doesn't seem to be linked. Make sure: \n\n` +
|
|
95
107
|
'- You rebuilt the app after installing the package\n' +
|
|
96
108
|
'- If you are using Lerna workspaces\n' +
|
|
@@ -106,11 +118,12 @@ const SolanaMobileWalletAdapter = reactNative.Platform.OS === 'android' && react
|
|
|
106
118
|
: LINKING_ERROR);
|
|
107
119
|
},
|
|
108
120
|
});
|
|
109
|
-
function
|
|
121
|
+
function transact(callback, config) {
|
|
110
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
123
|
try {
|
|
112
124
|
yield SolanaMobileWalletAdapter.startSession(config);
|
|
113
|
-
return yield callback((
|
|
125
|
+
return yield callback((_a) => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
var { method } = _a, params = __rest(_a, ["method"]);
|
|
114
127
|
try {
|
|
115
128
|
return yield SolanaMobileWalletAdapter.invoke(method, params);
|
|
116
129
|
}
|
|
@@ -138,4 +151,4 @@ exports.SolanaMobileWalletAdapterProtocolSessionClosedError = SolanaMobileWallet
|
|
|
138
151
|
exports.SolanaMobileWalletAdapterProtocolSessionEstablishmentError = SolanaMobileWalletAdapterProtocolSessionEstablishmentError;
|
|
139
152
|
exports.SolanaMobileWalletAdapterSecureContextRequiredError = SolanaMobileWalletAdapterSecureContextRequiredError;
|
|
140
153
|
exports.SolanaMobileWalletAdapterWalletNotInstalledError = SolanaMobileWalletAdapterWalletNotInstalledError;
|
|
141
|
-
exports.
|
|
154
|
+
exports.transact = transact;
|
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
|
|
16
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
29
|
-
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
30
|
-
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
31
|
-
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
32
|
-
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
33
|
-
return response;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
1
|
class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
|
|
38
2
|
constructor() {
|
|
39
3
|
super('The mobile wallet adapter protocol must be used in a secure context (`https`).');
|
|
@@ -96,6 +60,54 @@ class SolanaMobileWalletAdapterProtocolJsonRpcError extends Error {
|
|
|
96
60
|
}
|
|
97
61
|
}
|
|
98
62
|
|
|
63
|
+
/******************************************************************************
|
|
64
|
+
Copyright (c) Microsoft Corporation.
|
|
65
|
+
|
|
66
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
67
|
+
purpose with or without fee is hereby granted.
|
|
68
|
+
|
|
69
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
70
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
71
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
72
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
73
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
74
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
75
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
76
|
+
***************************************************************************** */
|
|
77
|
+
|
|
78
|
+
function __rest(s, e) {
|
|
79
|
+
var t = {};
|
|
80
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
81
|
+
t[p] = s[p];
|
|
82
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
83
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
84
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
85
|
+
t[p[i]] = s[p[i]];
|
|
86
|
+
}
|
|
87
|
+
return t;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
91
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
92
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
93
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
94
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
95
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
96
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
103
|
+
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
104
|
+
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
105
|
+
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
106
|
+
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
107
|
+
return response;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
99
111
|
function generateAssociationKeypair() {
|
|
100
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
113
|
return yield crypto.subtle.generateKey({
|
|
@@ -338,7 +350,7 @@ function assertSecureContext() {
|
|
|
338
350
|
throw new SolanaMobileWalletAdapterSecureContextRequiredError();
|
|
339
351
|
}
|
|
340
352
|
}
|
|
341
|
-
function
|
|
353
|
+
function transact(callback, config) {
|
|
342
354
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
355
|
assertSecureContext();
|
|
344
356
|
const associationKeypair = yield generateAssociationKeypair();
|
|
@@ -412,7 +424,8 @@ function withLocalWallet(callback, config) {
|
|
|
412
424
|
case 'hello_req_sent': {
|
|
413
425
|
const sharedSecret = yield parseHelloRsp(responseBuffer, state.associationPublicKey, state.ecdhPrivateKey);
|
|
414
426
|
state = { __type: 'connected', sharedSecret };
|
|
415
|
-
const
|
|
427
|
+
const walletAPI = (_a) => __awaiter(this, void 0, void 0, function* () {
|
|
428
|
+
var { method } = _a, params = __rest(_a, ["method"]);
|
|
416
429
|
const id = nextJsonRpcMessageId++;
|
|
417
430
|
socket.send(yield encryptJsonRpcMessage({
|
|
418
431
|
id,
|
|
@@ -425,7 +438,7 @@ function withLocalWallet(callback, config) {
|
|
|
425
438
|
});
|
|
426
439
|
});
|
|
427
440
|
try {
|
|
428
|
-
resolve(yield callback(
|
|
441
|
+
resolve(yield callback(walletAPI));
|
|
429
442
|
}
|
|
430
443
|
catch (e) {
|
|
431
444
|
reject(e);
|
|
@@ -463,4 +476,4 @@ function withLocalWallet(callback, config) {
|
|
|
463
476
|
});
|
|
464
477
|
}
|
|
465
478
|
|
|
466
|
-
export { SolanaMobileWalletAdapterForbiddenWalletBaseURLError, SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError, SolanaMobileWalletAdapterProtocolError, SolanaMobileWalletAdapterProtocolJsonRpcError, SolanaMobileWalletAdapterProtocolReauthorizeError, SolanaMobileWalletAdapterProtocolSessionClosedError, SolanaMobileWalletAdapterProtocolSessionEstablishmentError, SolanaMobileWalletAdapterSecureContextRequiredError, SolanaMobileWalletAdapterWalletNotInstalledError,
|
|
479
|
+
export { SolanaMobileWalletAdapterForbiddenWalletBaseURLError, SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError, SolanaMobileWalletAdapterProtocolError, SolanaMobileWalletAdapterProtocolJsonRpcError, SolanaMobileWalletAdapterProtocolReauthorizeError, SolanaMobileWalletAdapterProtocolSessionClosedError, SolanaMobileWalletAdapterProtocolSessionEstablishmentError, SolanaMobileWalletAdapterSecureContextRequiredError, SolanaMobileWalletAdapterWalletNotInstalledError, transact };
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
|
|
16
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
29
|
-
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
30
|
-
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
31
|
-
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
32
|
-
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
33
|
-
return response;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
1
|
class SolanaMobileWalletAdapterSecureContextRequiredError extends Error {
|
|
38
2
|
constructor() {
|
|
39
3
|
super('The mobile wallet adapter protocol must be used in a secure context (`https`).');
|
|
@@ -96,6 +60,54 @@ class SolanaMobileWalletAdapterProtocolJsonRpcError extends Error {
|
|
|
96
60
|
}
|
|
97
61
|
}
|
|
98
62
|
|
|
63
|
+
/******************************************************************************
|
|
64
|
+
Copyright (c) Microsoft Corporation.
|
|
65
|
+
|
|
66
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
67
|
+
purpose with or without fee is hereby granted.
|
|
68
|
+
|
|
69
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
70
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
71
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
72
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
73
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
74
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
75
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
76
|
+
***************************************************************************** */
|
|
77
|
+
|
|
78
|
+
function __rest(s, e) {
|
|
79
|
+
var t = {};
|
|
80
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
81
|
+
t[p] = s[p];
|
|
82
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
83
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
84
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
85
|
+
t[p[i]] = s[p[i]];
|
|
86
|
+
}
|
|
87
|
+
return t;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
91
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
92
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
93
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
94
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
95
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
96
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const publicKeyBuffer = yield crypto.subtle.exportKey('raw', ecdhPublicKey);
|
|
103
|
+
const signatureBuffer = yield crypto.subtle.sign({ hash: 'SHA-256', name: 'ECDSA' }, associationKeypairPrivateKey, publicKeyBuffer);
|
|
104
|
+
const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
|
|
105
|
+
response.set(new Uint8Array(publicKeyBuffer), 0);
|
|
106
|
+
response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
|
|
107
|
+
return response;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
99
111
|
function generateAssociationKeypair() {
|
|
100
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
113
|
return yield crypto.subtle.generateKey({
|
|
@@ -338,7 +350,7 @@ function assertSecureContext() {
|
|
|
338
350
|
throw new SolanaMobileWalletAdapterSecureContextRequiredError();
|
|
339
351
|
}
|
|
340
352
|
}
|
|
341
|
-
function
|
|
353
|
+
function transact(callback, config) {
|
|
342
354
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
355
|
assertSecureContext();
|
|
344
356
|
const associationKeypair = yield generateAssociationKeypair();
|
|
@@ -412,7 +424,8 @@ function withLocalWallet(callback, config) {
|
|
|
412
424
|
case 'hello_req_sent': {
|
|
413
425
|
const sharedSecret = yield parseHelloRsp(responseBuffer, state.associationPublicKey, state.ecdhPrivateKey);
|
|
414
426
|
state = { __type: 'connected', sharedSecret };
|
|
415
|
-
const
|
|
427
|
+
const walletAPI = (_a) => __awaiter(this, void 0, void 0, function* () {
|
|
428
|
+
var { method } = _a, params = __rest(_a, ["method"]);
|
|
416
429
|
const id = nextJsonRpcMessageId++;
|
|
417
430
|
socket.send(yield encryptJsonRpcMessage({
|
|
418
431
|
id,
|
|
@@ -425,7 +438,7 @@ function withLocalWallet(callback, config) {
|
|
|
425
438
|
});
|
|
426
439
|
});
|
|
427
440
|
try {
|
|
428
|
-
resolve(yield callback(
|
|
441
|
+
resolve(yield callback(walletAPI));
|
|
429
442
|
}
|
|
430
443
|
catch (e) {
|
|
431
444
|
reject(e);
|
|
@@ -463,4 +476,4 @@ function withLocalWallet(callback, config) {
|
|
|
463
476
|
});
|
|
464
477
|
}
|
|
465
478
|
|
|
466
|
-
export { SolanaMobileWalletAdapterForbiddenWalletBaseURLError, SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError, SolanaMobileWalletAdapterProtocolError, SolanaMobileWalletAdapterProtocolJsonRpcError, SolanaMobileWalletAdapterProtocolReauthorizeError, SolanaMobileWalletAdapterProtocolSessionClosedError, SolanaMobileWalletAdapterProtocolSessionEstablishmentError, SolanaMobileWalletAdapterSecureContextRequiredError, SolanaMobileWalletAdapterWalletNotInstalledError,
|
|
479
|
+
export { SolanaMobileWalletAdapterForbiddenWalletBaseURLError, SolanaMobileWalletAdapterProtocolAssociationPortOutOfRangeError, SolanaMobileWalletAdapterProtocolError, SolanaMobileWalletAdapterProtocolJsonRpcError, SolanaMobileWalletAdapterProtocolReauthorizeError, SolanaMobileWalletAdapterProtocolSessionClosedError, SolanaMobileWalletAdapterProtocolSessionEstablishmentError, SolanaMobileWalletAdapterSecureContextRequiredError, SolanaMobileWalletAdapterWalletNotInstalledError, transact };
|