@multiplatform.one/web3 7.33.1 → 7.34.0
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 +24 -6
- package/dist/cjs/phantom/crypto.cjs +108 -0
- package/dist/cjs/phantom/crypto.native.js +224 -0
- package/dist/cjs/phantom/crypto.native.js.map +1 -0
- package/dist/cjs/phantom/index.cjs +16 -1
- package/dist/cjs/phantom/index.native.js +16 -1
- package/dist/cjs/phantom/index.native.js.map +1 -1
- package/dist/cjs/phantom/solana.cjs +309 -0
- package/dist/cjs/phantom/solana.native.js +466 -0
- package/dist/cjs/phantom/solana.native.js.map +1 -0
- package/dist/cjs/phantom/urls.cjs +68 -3
- package/dist/cjs/phantom/urls.native.js +92 -4
- package/dist/cjs/phantom/urls.native.js.map +1 -1
- package/dist/esm/phantom/crypto.mjs +67 -0
- package/dist/esm/phantom/crypto.mjs.map +1 -0
- package/dist/esm/phantom/crypto.native.js +180 -0
- package/dist/esm/phantom/crypto.native.js.map +1 -0
- package/dist/esm/phantom/index.mjs +4 -2
- package/dist/esm/phantom/index.mjs.map +1 -1
- package/dist/esm/phantom/index.native.js +4 -2
- package/dist/esm/phantom/index.native.js.map +1 -1
- package/dist/esm/phantom/solana.mjs +271 -0
- package/dist/esm/phantom/solana.mjs.map +1 -0
- package/dist/esm/phantom/solana.native.js +425 -0
- package/dist/esm/phantom/solana.native.js.map +1 -0
- package/dist/esm/phantom/urls.mjs +53 -3
- package/dist/esm/phantom/urls.mjs.map +1 -1
- package/dist/esm/phantom/urls.native.js +77 -4
- package/dist/esm/phantom/urls.native.js.map +1 -1
- package/dist/jsx/phantom/crypto.mjs +67 -0
- package/dist/jsx/phantom/crypto.mjs.map +1 -0
- package/dist/jsx/phantom/crypto.native.js +224 -0
- package/dist/jsx/phantom/crypto.native.js.map +1 -0
- package/dist/jsx/phantom/index.mjs +4 -2
- package/dist/jsx/phantom/index.mjs.map +1 -1
- package/dist/jsx/phantom/index.native.js +16 -1
- package/dist/jsx/phantom/index.native.js.map +1 -1
- package/dist/jsx/phantom/solana.mjs +271 -0
- package/dist/jsx/phantom/solana.mjs.map +1 -0
- package/dist/jsx/phantom/solana.native.js +466 -0
- package/dist/jsx/phantom/solana.native.js.map +1 -0
- package/dist/jsx/phantom/urls.mjs +53 -3
- package/dist/jsx/phantom/urls.mjs.map +1 -1
- package/dist/jsx/phantom/urls.native.js +92 -4
- package/dist/jsx/phantom/urls.native.js.map +1 -1
- package/package.json +7 -6
- package/src/phantom/crypto.spec.ts +61 -0
- package/src/phantom/crypto.ts +88 -0
- package/src/phantom/index.ts +38 -5
- package/src/phantom/solana.spec.ts +262 -0
- package/src/phantom/solana.ts +374 -0
- package/src/phantom/urls.spec.ts +101 -10
- package/src/phantom/urls.ts +119 -4
- package/types/phantom/crypto.d.ts +27 -0
- package/types/phantom/crypto.d.ts.map +1 -0
- package/types/phantom/index.d.ts +3 -1
- package/types/phantom/index.d.ts.map +1 -1
- package/types/phantom/solana.d.ts +113 -0
- package/types/phantom/solana.d.ts.map +1 -0
- package/types/phantom/urls.d.ts +46 -2
- package/types/phantom/urls.d.ts.map +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { hsalsa, xsalsa20poly1305 } from "@noble/ciphers/salsa";
|
|
2
|
+
import { x25519 } from "@noble/curves/ed25519";
|
|
3
|
+
import bs58 from "bs58";
|
|
4
|
+
class PhantomDecryptError extends Error {
|
|
5
|
+
constructor(message = "could not decrypt Phantom's response with this session's key") {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "PhantomDecryptError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function randomBytes(length) {
|
|
11
|
+
const bytes = new Uint8Array(length);
|
|
12
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
13
|
+
return bytes;
|
|
14
|
+
}
|
|
15
|
+
function generateBoxKeyPair() {
|
|
16
|
+
const secretKey = randomBytes(32);
|
|
17
|
+
return {
|
|
18
|
+
secretKey,
|
|
19
|
+
publicKey: x25519.getPublicKey(secretKey)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function boxKeyPairFromSecretKey(secretKey) {
|
|
23
|
+
return {
|
|
24
|
+
secretKey,
|
|
25
|
+
publicKey: x25519.getPublicKey(secretKey)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const sigma = new Uint32Array([1634760805, 857760878, 2036477234, 1797285236]);
|
|
29
|
+
function toWords(bytes) {
|
|
30
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
31
|
+
const words = new Uint32Array(bytes.length / 4);
|
|
32
|
+
for (let i = 0; i < words.length; i += 1) words[i] = view.getUint32(i * 4, true);
|
|
33
|
+
return words;
|
|
34
|
+
}
|
|
35
|
+
function fromWords(words) {
|
|
36
|
+
const bytes = new Uint8Array(words.length * 4);
|
|
37
|
+
const view = new DataView(bytes.buffer);
|
|
38
|
+
for (let i = 0; i < words.length; i += 1) view.setUint32(i * 4, words[i], true);
|
|
39
|
+
return bytes;
|
|
40
|
+
}
|
|
41
|
+
function sharedSecret(theirPublicKey, mySecretKey) {
|
|
42
|
+
const point = x25519.getSharedSecret(mySecretKey, theirPublicKey);
|
|
43
|
+
const out = new Uint32Array(8);
|
|
44
|
+
hsalsa(sigma, toWords(point), new Uint32Array(4), out);
|
|
45
|
+
return fromWords(out);
|
|
46
|
+
}
|
|
47
|
+
function encryptPayload(value, secret, nonce = randomBytes(24)) {
|
|
48
|
+
const plaintext = new TextEncoder().encode(JSON.stringify(value));
|
|
49
|
+
const sealed = xsalsa20poly1305(secret, nonce).encrypt(plaintext);
|
|
50
|
+
return {
|
|
51
|
+
nonce: bs58.encode(nonce),
|
|
52
|
+
payload: bs58.encode(sealed)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function decryptPayload(data, nonce, secret) {
|
|
56
|
+
let opened;
|
|
57
|
+
try {
|
|
58
|
+
opened = xsalsa20poly1305(secret, bs58.decode(nonce)).decrypt(bs58.decode(data));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
throw Object.assign(new PhantomDecryptError(), {
|
|
61
|
+
cause: error
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return JSON.parse(new TextDecoder().decode(opened));
|
|
65
|
+
}
|
|
66
|
+
export { PhantomDecryptError, boxKeyPairFromSecretKey, decryptPayload, encryptPayload, generateBoxKeyPair, sharedSecret };
|
|
67
|
+
//# sourceMappingURL=crypto.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hsalsa","xsalsa20poly1305","x25519","bs58","PhantomDecryptError","Error","constructor","message","name","randomBytes","length","bytes","Uint8Array","globalThis","crypto","getRandomValues","generateBoxKeyPair","secretKey","publicKey","getPublicKey","boxKeyPairFromSecretKey","sigma","Uint32Array","toWords","view","DataView","buffer","byteOffset","byteLength","words","i","getUint32","fromWords","setUint32","sharedSecret","theirPublicKey","mySecretKey","point","getSharedSecret","out","encryptPayload","value","secret","nonce","plaintext","TextEncoder","encode","JSON","stringify","sealed","encrypt","payload","decryptPayload","data","opened","decode","decrypt","error","Object","assign","cause","parse","TextDecoder"],"sources":["../../../src/phantom/crypto.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,EAAQC,gBAAA,QAAwB;AACzC,SAASC,MAAA,QAAc;AACvB,OAAOC,IAAA,MAAU;AAcV,MAAMC,mBAAA,SAA4BC,KAAA,CAAM;EAC7CC,YAAYC,OAAA,GAAU,gEAAgE;IACpF,MAAMA,OAAO;IACb,KAAKC,IAAA,GAAO;EACd;AACF;AAEA,SAASC,YAAYC,MAAA,EAA4B;EAC/C,MAAMC,KAAA,GAAQ,IAAIC,UAAA,CAAWF,MAAM;EACnCG,UAAA,CAAWC,MAAA,CAAOC,eAAA,CAAgBJ,KAAK;EACvC,OAAOA,KAAA;AACT;AAGO,SAASK,mBAAA,EAAiC;EAC/C,MAAMC,SAAA,GAAYR,WAAA,CAAY,EAAE;EAChC,O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,MAAMI,GAAA,GAAM,IAAIjB,WAAA,CAAY,CAAC;EAC7BtB,MAAA,CAAOqB,KAAA,EAAOE,OAAA,CAAQc,KAAK,GAAG,IAAIf,WAAA,CAAY,CAAC,GAAGiB,GAAG;EACrD,OAAOP,SAAA,CAAUO,GAAG;AACtB;AAGO,SAASC,eACdC,KAAA,EACAC,MAAA,EACAC,KAAA,GAAoBlC,WAAA,CAAY,EAAE,GAChB;EAClB,MAAMmC,SAAA,GAAY,IAAIC,WAAA,CAAY,EAAEC,MAAA,CAAOC,IAAA,CAAKC,SAAA,CAAUP,KAAK,CAAC;EAChE,MAAMQ,MAAA,GAAShD,gBAAA,CAAiByC,MAAA,EAAQC,KAAK,EAAEO,OAAA,CAAQN,SAAS;EAChE,OAAO;IAAED,KAAA,EAAOxC,IAAA,CAAK2C,MAAA,CAAOH,KAAK;IAAGQ,OAAA,EAAShD,IAAA,CAAK2C,MAAA,CAAOG,MAAM;EAAE;AACnE;AAGO,SAASG,eAA4BC,IAAA,EAAcV,KAAA,EAAeD,MAAA,EAAuB;EAC9F,IAAIY,MAAA;EACJ,IAAI;IACFA,MAAA,GAASrD,gBAAA,CAAiByC,MAAA,EAAQvC,IAAA,CAAKoD,MAAA,CAAOZ,KAAK,CAAC,EAAEa,OAAA,CAAQrD,IAAA,CAAKoD,MAAA,CAAOF,IAAI,CAAC;EACjF,SAASI,KAAA,EAAO;IACd,MAAMC,MAAA,CAAOC,MAAA,CAAO,IAAIvD,mBAAA,CAAoB,GAAG;MAAEwD,KAAA,EAAOH;IAAM,CAAC;EACjE;EACA,OAAOV,IAAA,CAAKc,KAAA,CAAM,IAAIC,WAAA,CAAY,EAAEP,MAAA,CAAOD,MAAM,CAAC;AACpD","ignoreList":[]}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
36
|
+
var crypto_exports = {};
|
|
37
|
+
__export(crypto_exports, {
|
|
38
|
+
PhantomDecryptError: () => PhantomDecryptError,
|
|
39
|
+
boxKeyPairFromSecretKey: () => boxKeyPairFromSecretKey,
|
|
40
|
+
decryptPayload: () => decryptPayload,
|
|
41
|
+
encryptPayload: () => encryptPayload,
|
|
42
|
+
generateBoxKeyPair: () => generateBoxKeyPair,
|
|
43
|
+
sharedSecret: () => sharedSecret
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(crypto_exports);
|
|
46
|
+
var import_salsa = require("@noble/ciphers/salsa");
|
|
47
|
+
var import_ed25519 = require("@noble/curves/ed25519");
|
|
48
|
+
var import_bs58 = __toESM(require("bs58"));
|
|
49
|
+
function _assert_this_initialized(self) {
|
|
50
|
+
if (self === void 0) {
|
|
51
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
52
|
+
}
|
|
53
|
+
return self;
|
|
54
|
+
}
|
|
55
|
+
function _call_super(_this, derived, args) {
|
|
56
|
+
derived = _get_prototype_of(derived);
|
|
57
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
58
|
+
}
|
|
59
|
+
function _class_call_check(instance, Constructor) {
|
|
60
|
+
if (!(instance instanceof Constructor)) {
|
|
61
|
+
throw new TypeError("Cannot call a class as a function");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function _construct(Parent, args, Class) {
|
|
65
|
+
if (_is_native_reflect_construct()) {
|
|
66
|
+
_construct = Reflect.construct;
|
|
67
|
+
} else {
|
|
68
|
+
_construct = function construct(Parent2, args2, Class2) {
|
|
69
|
+
var a = [null];
|
|
70
|
+
a.push.apply(a, args2);
|
|
71
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
72
|
+
var instance = new Constructor();
|
|
73
|
+
if (Class2) _set_prototype_of(instance, Class2.prototype);
|
|
74
|
+
return instance;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return _construct.apply(null, arguments);
|
|
78
|
+
}
|
|
79
|
+
function _get_prototype_of(o) {
|
|
80
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
81
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
82
|
+
};
|
|
83
|
+
return _get_prototype_of(o);
|
|
84
|
+
}
|
|
85
|
+
function _inherits(subClass, superClass) {
|
|
86
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
87
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
88
|
+
}
|
|
89
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
90
|
+
constructor: {
|
|
91
|
+
value: subClass,
|
|
92
|
+
writable: true,
|
|
93
|
+
configurable: true
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
97
|
+
}
|
|
98
|
+
function _is_native_function(fn) {
|
|
99
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
100
|
+
}
|
|
101
|
+
function _possible_constructor_return(self, call) {
|
|
102
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
103
|
+
return call;
|
|
104
|
+
}
|
|
105
|
+
return _assert_this_initialized(self);
|
|
106
|
+
}
|
|
107
|
+
function _set_prototype_of(o, p) {
|
|
108
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
109
|
+
o2.__proto__ = p2;
|
|
110
|
+
return o2;
|
|
111
|
+
};
|
|
112
|
+
return _set_prototype_of(o, p);
|
|
113
|
+
}
|
|
114
|
+
function _type_of(obj) {
|
|
115
|
+
"@swc/helpers - typeof";
|
|
116
|
+
|
|
117
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
118
|
+
}
|
|
119
|
+
function _wrap_native_super(Class) {
|
|
120
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */new Map() : void 0;
|
|
121
|
+
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
122
|
+
if (Class2 === null || !_is_native_function(Class2)) return Class2;
|
|
123
|
+
if (typeof Class2 !== "function") {
|
|
124
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
125
|
+
}
|
|
126
|
+
if (typeof _cache !== "undefined") {
|
|
127
|
+
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
128
|
+
_cache.set(Class2, Wrapper);
|
|
129
|
+
}
|
|
130
|
+
function Wrapper() {
|
|
131
|
+
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
132
|
+
}
|
|
133
|
+
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
134
|
+
constructor: {
|
|
135
|
+
value: Wrapper,
|
|
136
|
+
enumerable: false,
|
|
137
|
+
writable: true,
|
|
138
|
+
configurable: true
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return _set_prototype_of(Wrapper, Class2);
|
|
142
|
+
};
|
|
143
|
+
return _wrap_native_super(Class);
|
|
144
|
+
}
|
|
145
|
+
function _is_native_reflect_construct() {
|
|
146
|
+
try {
|
|
147
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
148
|
+
} catch (_) {}
|
|
149
|
+
return (_is_native_reflect_construct = function () {
|
|
150
|
+
return !!result;
|
|
151
|
+
})();
|
|
152
|
+
}
|
|
153
|
+
var PhantomDecryptError = /* @__PURE__ */function (Error1) {
|
|
154
|
+
"use strict";
|
|
155
|
+
|
|
156
|
+
_inherits(PhantomDecryptError2, Error1);
|
|
157
|
+
function PhantomDecryptError2() {
|
|
158
|
+
var message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "could not decrypt Phantom's response with this session's key";
|
|
159
|
+
_class_call_check(this, PhantomDecryptError2);
|
|
160
|
+
var _this;
|
|
161
|
+
_this = _call_super(this, PhantomDecryptError2, [message]);
|
|
162
|
+
_this.name = "PhantomDecryptError";
|
|
163
|
+
return _this;
|
|
164
|
+
}
|
|
165
|
+
return PhantomDecryptError2;
|
|
166
|
+
}(_wrap_native_super(Error));
|
|
167
|
+
function randomBytes(length) {
|
|
168
|
+
var bytes = new Uint8Array(length);
|
|
169
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
170
|
+
return bytes;
|
|
171
|
+
}
|
|
172
|
+
function generateBoxKeyPair() {
|
|
173
|
+
var secretKey = randomBytes(32);
|
|
174
|
+
return {
|
|
175
|
+
secretKey,
|
|
176
|
+
publicKey: import_ed25519.x25519.getPublicKey(secretKey)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function boxKeyPairFromSecretKey(secretKey) {
|
|
180
|
+
return {
|
|
181
|
+
secretKey,
|
|
182
|
+
publicKey: import_ed25519.x25519.getPublicKey(secretKey)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
var sigma = new Uint32Array([1634760805, 857760878, 2036477234, 1797285236]);
|
|
186
|
+
function toWords(bytes) {
|
|
187
|
+
var view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
188
|
+
var words = new Uint32Array(bytes.length / 4);
|
|
189
|
+
for (var i = 0; i < words.length; i += 1) words[i] = view.getUint32(i * 4, true);
|
|
190
|
+
return words;
|
|
191
|
+
}
|
|
192
|
+
function fromWords(words) {
|
|
193
|
+
var bytes = new Uint8Array(words.length * 4);
|
|
194
|
+
var view = new DataView(bytes.buffer);
|
|
195
|
+
for (var i = 0; i < words.length; i += 1) view.setUint32(i * 4, words[i], true);
|
|
196
|
+
return bytes;
|
|
197
|
+
}
|
|
198
|
+
function sharedSecret(theirPublicKey, mySecretKey) {
|
|
199
|
+
var point = import_ed25519.x25519.getSharedSecret(mySecretKey, theirPublicKey);
|
|
200
|
+
var out = new Uint32Array(8);
|
|
201
|
+
(0, import_salsa.hsalsa)(sigma, toWords(point), new Uint32Array(4), out);
|
|
202
|
+
return fromWords(out);
|
|
203
|
+
}
|
|
204
|
+
function encryptPayload(value, secret) {
|
|
205
|
+
var nonce = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : randomBytes(24);
|
|
206
|
+
var plaintext = new TextEncoder().encode(JSON.stringify(value));
|
|
207
|
+
var sealed = (0, import_salsa.xsalsa20poly1305)(secret, nonce).encrypt(plaintext);
|
|
208
|
+
return {
|
|
209
|
+
nonce: import_bs58.default.encode(nonce),
|
|
210
|
+
payload: import_bs58.default.encode(sealed)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function decryptPayload(data, nonce, secret) {
|
|
214
|
+
var opened;
|
|
215
|
+
try {
|
|
216
|
+
opened = (0, import_salsa.xsalsa20poly1305)(secret, import_bs58.default.decode(nonce)).decrypt(import_bs58.default.decode(data));
|
|
217
|
+
} catch (error) {
|
|
218
|
+
throw Object.assign(new PhantomDecryptError(), {
|
|
219
|
+
cause: error
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return JSON.parse(new TextDecoder().decode(opened));
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=crypto.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","crypto_exports","PhantomDecryptError","boxKeyPairFromSecretKey","decryptPayload","encryptPayload","generateBoxKeyPair","sharedSecret","module","exports","import_salsa","require","import_ed25519","import_bs58","_assert_this_initialized","self","ReferenceError","_call_super","_this","derived","args","_get_prototype_of","_possible_constructor_return","_is_native_reflect_construct","Reflect","construct","constructor","apply","_class_call_check","instance","Constructor","TypeError"],"sources":["../../../src/phantom/crypto.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAS;;AACT,IAAAA,QAAS,GAAAC,MAAA,CAAAC,MAAc;AACvB,IAAAC,SAAO,GAAAF,MAAU,CAAAG,cAAA;AAcV,IAAAC,gBAAM,GAAAJ,MAAA,CAAAK,wBAAkC;AAAA,IAC7CC,iBAAY,GAAUN,MAAA,CAAAO,mBAAA;AACpB,IAAAC,YAAM,GAAOR,MAAA,CAAAS,cAAA;AACb,IAAAC,YAAY,GAA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ASA,mBAAY;EACtCC,uBAAoB,EAAAA,CAAA,KAAMA,uBAAqB;EAC/CC,cAAO,EAAAA,CAAA,KAAAA,cAAA;EACTC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAOOC,kBAAS,EAAaA,CAAA,KAAAA,kBAA4B;EACvDC,YAAM,EAAQA,CAAA,KAAAA;AACd;AACAC,MAAA,CAAAC,OAAO,GAAOT,YAAa,CAAAC,cAAO;AAClC,IAAAS,YAAO,GAAUC,OAAG;AACtB,IAAAC,cAAA,GAAAD,OAAA;AAGO,IAAAE,WAAS,GAAAlB,OACd,CAAAgB,OACA,OACA;AAEA,SAAMG,wBAAgBA,CAAAC,IAAc;EACpC,IAAAA,IAAM,UAAS;IACf,MAAO,IAAEC,cAAY,4DAA4C;EACnE;EAGO,OAASD,IAAA;AACd;AACA,SAAIE,YAAAC,KAAA,EAAAC,OAAA,EAAAC,IAAA;EACFD,OAAA,GAAAE,iBAAS,CAAiBF,OAAA,CAAQ;EACpC,OAAAG,4BAAgB,CAAAJ,KAAA,EAAAK,4BAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,OAAA,EAAAC,IAAA,QAAAC,iBAAA,CAAAH,KAAA,EAAAQ,WAAA,IAAAP,OAAA,CAAAQ,KAAA,CAAAT,KAAA,EAAAE,IAAA;AACd;AAA+D,SACjEQ,kBAAAC,QAAA,EAAAC,WAAA;EACA,MAAAD,QAAY,YAAUC,WAAc;IACtC,UAAAC,SAAA","ignoreList":[]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { boxKeyPairFromSecretKey, decryptPayload, encryptPayload, generateBoxKeyPair, PhantomDecryptError, sharedSecret } from "./crypto.mjs";
|
|
1
2
|
import { connectPhantomEvm, discoverPhantomEthereumProvider, openInPhantom, phantomEthereumProvider, phantomEvmRoute, PhantomNotInjectedError } from "./evm.mjs";
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import { phantomDeeplink, PhantomNotConnectedError, sendSolanaTransaction } from "./solana.mjs";
|
|
4
|
+
import { parsePhantomRedirect, phantomBrowseUrl, phantomConnectUrl, phantomMethodUrl, phantomUniversalLinkBase, stripPhantomRedirect } from "./urls.mjs";
|
|
5
|
+
export { PhantomDecryptError, PhantomNotConnectedError, PhantomNotInjectedError, boxKeyPairFromSecretKey, connectPhantomEvm, decryptPayload, discoverPhantomEthereumProvider, encryptPayload, generateBoxKeyPair, openInPhantom, parsePhantomRedirect, phantomBrowseUrl, phantomConnectUrl, phantomDeeplink, phantomEthereumProvider, phantomEvmRoute, phantomMethodUrl, phantomUniversalLinkBase, sendSolanaTransaction, sharedSecret, stripPhantomRedirect };
|
|
4
6
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["connectPhantomEvm","discoverPhantomEthereumProvider","openInPhantom","phantomEthereumProvider","phantomEvmRoute","PhantomNotInjectedError","phantomBrowseUrl","phantomUniversalLinkBase"],"sources":["../../../src/phantom/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["boxKeyPairFromSecretKey","decryptPayload","encryptPayload","generateBoxKeyPair","PhantomDecryptError","sharedSecret","connectPhantomEvm","discoverPhantomEthereumProvider","openInPhantom","phantomEthereumProvider","phantomEvmRoute","PhantomNotInjectedError","phantomDeeplink","PhantomNotConnectedError","sendSolanaTransaction","parsePhantomRedirect","phantomBrowseUrl","phantomConnectUrl","phantomMethodUrl","phantomUniversalLinkBase","stripPhantomRedirect"],"sources":["../../../src/phantom/index.ts"],"sourcesContent":[null],"mappings":"AAKA,SACEA,uBAAA,EACAC,cAAA,EACAC,cAAA,EACAC,kBAAA,EACAC,mBAAA,EACAC,YAAA,QAGK;AACP,SACEC,iBAAA,EACAC,+BAAA,EACAC,aAAA,EACAC,uBAAA,EACAC,eAAA,EACAC,uBAAA,QAIK;AACP,SACEC,eAAA,EACAC,wBAAA,EACAC,qBAAA,QAMK;AACP,SACEC,oBAAA,EACAC,gBAAA,EACAC,iBAAA,EACAC,gBAAA,EACAC,wBAAA,EACAC,oBAAA,QAMK","ignoreList":[]}
|
|
@@ -24,16 +24,31 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
24
24
|
}), mod);
|
|
25
25
|
var phantom_exports = {};
|
|
26
26
|
__export(phantom_exports, {
|
|
27
|
+
PhantomDecryptError: () => import_crypto.PhantomDecryptError,
|
|
28
|
+
PhantomNotConnectedError: () => import_solana.PhantomNotConnectedError,
|
|
27
29
|
PhantomNotInjectedError: () => import_evm.PhantomNotInjectedError,
|
|
30
|
+
boxKeyPairFromSecretKey: () => import_crypto.boxKeyPairFromSecretKey,
|
|
28
31
|
connectPhantomEvm: () => import_evm.connectPhantomEvm,
|
|
32
|
+
decryptPayload: () => import_crypto.decryptPayload,
|
|
29
33
|
discoverPhantomEthereumProvider: () => import_evm.discoverPhantomEthereumProvider,
|
|
34
|
+
encryptPayload: () => import_crypto.encryptPayload,
|
|
35
|
+
generateBoxKeyPair: () => import_crypto.generateBoxKeyPair,
|
|
30
36
|
openInPhantom: () => import_evm.openInPhantom,
|
|
37
|
+
parsePhantomRedirect: () => import_urls.parsePhantomRedirect,
|
|
31
38
|
phantomBrowseUrl: () => import_urls.phantomBrowseUrl,
|
|
39
|
+
phantomConnectUrl: () => import_urls.phantomConnectUrl,
|
|
40
|
+
phantomDeeplink: () => import_solana.phantomDeeplink,
|
|
32
41
|
phantomEthereumProvider: () => import_evm.phantomEthereumProvider,
|
|
33
42
|
phantomEvmRoute: () => import_evm.phantomEvmRoute,
|
|
34
|
-
|
|
43
|
+
phantomMethodUrl: () => import_urls.phantomMethodUrl,
|
|
44
|
+
phantomUniversalLinkBase: () => import_urls.phantomUniversalLinkBase,
|
|
45
|
+
sendSolanaTransaction: () => import_solana.sendSolanaTransaction,
|
|
46
|
+
sharedSecret: () => import_crypto.sharedSecret,
|
|
47
|
+
stripPhantomRedirect: () => import_urls.stripPhantomRedirect
|
|
35
48
|
});
|
|
36
49
|
module.exports = __toCommonJS(phantom_exports);
|
|
50
|
+
var import_crypto = require("./crypto.native.js");
|
|
37
51
|
var import_evm = require("./evm.native.js");
|
|
52
|
+
var import_solana = require("./solana.native.js");
|
|
38
53
|
var import_urls = require("./urls.native.js");
|
|
39
54
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable"],"sources":["../../../src/phantom/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","phantom_exports","PhantomDecryptError","import_crypto","PhantomNotConnectedError","import_solana","PhantomNotInjectedError","import_evm","boxKeyPairFromSecretKey","connectPhantomEvm","decryptPayload","discoverPhantomEthereumProvider","encryptPayload","generateBoxKeyPair"],"sources":["../../../src/phantom/index.ts"],"sourcesContent":[null],"mappings":"AAKA;;AAAA,IACEA,SAAA,GAAAC,MAAA,CAAAC,cAAA;AAAA,IACAC,gBAAA,GAAAF,MAAA,CAAAG,wBAAA;AAAA,IACAC,iBAAA,GAAAJ,MAAA,CAAAK,mBAAA;AAAA,IACAC,YAAA,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AAAA,IACAC,QAAA,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EACA,SAAAC,IAAA,IAAAD,GAAA,EAAAZ,SAGK,CAAAW,MAAA,EAAAE,IAAA;IAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA;AACP;AAAA,IACEC,WAAA,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;EACA,IAAAF,IAAA,WAAAA,IAAA,wBAAAA,IAAA;IACA,SAAAG,GAAA,IAAAhB,iBAAA,CAAAa,IAAA,GACA,KAAAX,YAAA,CAAAe,IAAA,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,EACAnB,SAAA,CAAAiB,EAAA,EAAAI,GAAA;MAAAP,GAAA,EAAAA,CAAA,KAAAI,IAAA,CAAAG,GAAA;MAAAN,UAAA,IAAAK,IAAA,GAAAjB,gBAAA,CAAAe,IAAA,EAAAG,GAAA,MAAAD,IAAA,CAAAL;IAAA;EACA;EAAA,OAIKE,EAAA;AACP;AAAA,IACEM,YAAA,GAAAC,GAAA,IAAAR,WAAA,CAAAhB,SAAA;EAAAyB,KAAA;AAAA,IAAAD,GAAA;AAAA,IACAE,eAAA;AAAAhB,QACA,CAAAgB,eAAA;EAAAC,mBAMK,EAAAA,CAAA,KAAAC,aAAA,CAAAD,mBAAA;EACPE,wBAAA,EAAAA,CAAA,KAAAC,aAAA,CAAAD,wBAAA;EACEE,uBAAA,EAAAA,CAAA,KAAAC,UAAA,CAAAD,uBAAA;EACAE,uBAAA,EAAAA,CAAA,KAAAL,aAAA,CAAAK,uBAAA;EACAC,iBAAA,EAAAA,CAAA,KAAAF,UAAA,CAAAE,iBAAA;EACAC,cAAA,EAAAA,CAAA,KAAAP,aAAA,CAAAO,cAAA;EACAC,+BAAA,EAAAA,CAAA,KAAAJ,UAAA,CAAAI,+BAAA;EACAC,cAAA,EAAAA,CAAA,KAAAT,aAAA,CAAAS,cAAA;EAAAC,kBAMK,EAAAA,CAAA,KAAAV,aAAA,CAAAU,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import bs58 from "bs58";
|
|
2
|
+
import { boxKeyPairFromSecretKey, decryptPayload, generateBoxKeyPair, sharedSecret } from "./crypto.mjs";
|
|
3
|
+
import { parsePhantomRedirect, phantomConnectUrl, phantomMethodUrl, stripPhantomRedirect } from "./urls.mjs";
|
|
4
|
+
class PhantomNotConnectedError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("no Phantom deeplink session: call connect() first");
|
|
7
|
+
this.name = "PhantomNotConnectedError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const defaultStorageKey = "mpo.web3.phantom.deeplink";
|
|
11
|
+
function defaultStorage() {
|
|
12
|
+
const storage = globalThis.localStorage;
|
|
13
|
+
if (!storage) throw new Error("phantomDeeplink: no localStorage here; pass `storage`");
|
|
14
|
+
return storage;
|
|
15
|
+
}
|
|
16
|
+
function currentHref() {
|
|
17
|
+
const href = globalThis.location?.href;
|
|
18
|
+
if (!href) throw new Error("phantomDeeplink: no location here; pass `redirectLink`");
|
|
19
|
+
return href;
|
|
20
|
+
}
|
|
21
|
+
function phantomDeeplink(config) {
|
|
22
|
+
const storageKey = config.storageKey ?? defaultStorageKey;
|
|
23
|
+
const storage = () => config.storage ?? defaultStorage();
|
|
24
|
+
const now = config.now ?? Date.now;
|
|
25
|
+
const navigate = config.navigate ?? (url => globalThis.location.assign(url));
|
|
26
|
+
const redirectLink = () => config.redirectLink ?? stripPhantomRedirect(currentHref());
|
|
27
|
+
const load = () => {
|
|
28
|
+
const raw = storage().getItem(storageKey);
|
|
29
|
+
if (!raw) return void 0;
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(raw);
|
|
32
|
+
} catch {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const save = record => storage().setItem(storageKey, JSON.stringify(record));
|
|
37
|
+
const connected = () => {
|
|
38
|
+
const record = load();
|
|
39
|
+
if (!record?.session || !record.phantomEncryptionPublicKey) throw new PhantomNotConnectedError();
|
|
40
|
+
return record;
|
|
41
|
+
};
|
|
42
|
+
const methodUrl = (record, method, payload) => {
|
|
43
|
+
const keyPair = boxKeyPairFromSecretKey(bs58.decode(record.dappSecretKey));
|
|
44
|
+
return phantomMethodUrl({
|
|
45
|
+
method,
|
|
46
|
+
payload,
|
|
47
|
+
session: record.session,
|
|
48
|
+
dappEncryptionPublicKey: keyPair.publicKey,
|
|
49
|
+
sharedSecret: sharedSecret(bs58.decode(record.phantomEncryptionPublicKey), keyPair.secretKey),
|
|
50
|
+
redirectLink: redirectLink(),
|
|
51
|
+
base: config.base
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const request = (method, payload) => {
|
|
55
|
+
const record = connected();
|
|
56
|
+
const url = methodUrl(record, method, payload);
|
|
57
|
+
save({
|
|
58
|
+
...record,
|
|
59
|
+
pending: {
|
|
60
|
+
method,
|
|
61
|
+
at: now()
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
navigate(url);
|
|
65
|
+
return url;
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
get publicKey() {
|
|
69
|
+
return load()?.publicKey;
|
|
70
|
+
},
|
|
71
|
+
get connected() {
|
|
72
|
+
const record = load();
|
|
73
|
+
return !!(record?.session && record.phantomEncryptionPublicKey);
|
|
74
|
+
},
|
|
75
|
+
get pending() {
|
|
76
|
+
return load()?.pending;
|
|
77
|
+
},
|
|
78
|
+
connect() {
|
|
79
|
+
const keyPair = generateBoxKeyPair();
|
|
80
|
+
const url = phantomConnectUrl({
|
|
81
|
+
appUrl: config.appUrl,
|
|
82
|
+
dappEncryptionPublicKey: keyPair.publicKey,
|
|
83
|
+
redirectLink: redirectLink(),
|
|
84
|
+
cluster: config.cluster,
|
|
85
|
+
base: config.base
|
|
86
|
+
});
|
|
87
|
+
save({
|
|
88
|
+
dappSecretKey: bs58.encode(keyPair.secretKey),
|
|
89
|
+
cluster: config.cluster,
|
|
90
|
+
pending: {
|
|
91
|
+
method: "connect",
|
|
92
|
+
at: now()
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
navigate(url);
|
|
96
|
+
return url;
|
|
97
|
+
},
|
|
98
|
+
signTransaction(serializedTransaction) {
|
|
99
|
+
return request("signTransaction", {
|
|
100
|
+
transaction: bs58.encode(serializedTransaction)
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
signAllTransactions(serializedTransactions) {
|
|
104
|
+
return request("signAllTransactions", {
|
|
105
|
+
transactions: serializedTransactions.map(tx => bs58.encode(tx))
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
signAndSendTransaction(serializedTransaction, sendOptions) {
|
|
109
|
+
return request("signAndSendTransaction", {
|
|
110
|
+
transaction: bs58.encode(serializedTransaction),
|
|
111
|
+
...(sendOptions ? {
|
|
112
|
+
sendOptions
|
|
113
|
+
} : {})
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
signMessage(message, display) {
|
|
117
|
+
const bytes = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
118
|
+
return request("signMessage", {
|
|
119
|
+
message: bs58.encode(bytes),
|
|
120
|
+
...(display ? {
|
|
121
|
+
display
|
|
122
|
+
} : {})
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
disconnect() {
|
|
126
|
+
const url = methodUrl(connected(), "disconnect", {});
|
|
127
|
+
storage().removeItem(storageKey);
|
|
128
|
+
navigate(url);
|
|
129
|
+
return url;
|
|
130
|
+
},
|
|
131
|
+
handleRedirect(href) {
|
|
132
|
+
const params = parsePhantomRedirect(href ?? currentHref());
|
|
133
|
+
if (!params) return void 0;
|
|
134
|
+
const record = load();
|
|
135
|
+
const method = record?.pending?.method;
|
|
136
|
+
if (params.errorCode) {
|
|
137
|
+
if (record) save({
|
|
138
|
+
...record,
|
|
139
|
+
pending: void 0
|
|
140
|
+
});
|
|
141
|
+
return {
|
|
142
|
+
ok: false,
|
|
143
|
+
method,
|
|
144
|
+
errorCode: params.errorCode,
|
|
145
|
+
errorMessage: params.errorMessage ?? ""
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (!record || !params.data || !params.nonce) {
|
|
149
|
+
return {
|
|
150
|
+
ok: false,
|
|
151
|
+
method,
|
|
152
|
+
errorCode: "-32603",
|
|
153
|
+
errorMessage: "Phantom answered, but this browser holds no matching request"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const secretKey = bs58.decode(record.dappSecretKey);
|
|
157
|
+
const phantomKey = method === "connect" ? params.phantomEncryptionPublicKey : record.phantomEncryptionPublicKey;
|
|
158
|
+
if (!phantomKey) {
|
|
159
|
+
return {
|
|
160
|
+
ok: false,
|
|
161
|
+
method,
|
|
162
|
+
errorCode: "-32603",
|
|
163
|
+
errorMessage: "Phantom's answer carries no encryption key"
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const data = decryptPayload(params.data, params.nonce, sharedSecret(bs58.decode(phantomKey), secretKey));
|
|
167
|
+
switch (method) {
|
|
168
|
+
case "connect":
|
|
169
|
+
{
|
|
170
|
+
const publicKey = String(data.public_key);
|
|
171
|
+
const session = String(data.session);
|
|
172
|
+
save({
|
|
173
|
+
...record,
|
|
174
|
+
phantomEncryptionPublicKey: phantomKey,
|
|
175
|
+
publicKey,
|
|
176
|
+
session,
|
|
177
|
+
pending: void 0
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
ok: true,
|
|
181
|
+
method,
|
|
182
|
+
publicKey,
|
|
183
|
+
session
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
case "signTransaction":
|
|
187
|
+
save({
|
|
188
|
+
...record,
|
|
189
|
+
pending: void 0
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
ok: true,
|
|
193
|
+
method,
|
|
194
|
+
transaction: bs58.decode(String(data.transaction))
|
|
195
|
+
};
|
|
196
|
+
case "signAllTransactions":
|
|
197
|
+
save({
|
|
198
|
+
...record,
|
|
199
|
+
pending: void 0
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
ok: true,
|
|
203
|
+
method,
|
|
204
|
+
transactions: data.transactions.map(tx => bs58.decode(tx))
|
|
205
|
+
};
|
|
206
|
+
case "signAndSendTransaction":
|
|
207
|
+
save({
|
|
208
|
+
...record,
|
|
209
|
+
pending: void 0
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
ok: true,
|
|
213
|
+
method,
|
|
214
|
+
signature: String(data.signature)
|
|
215
|
+
};
|
|
216
|
+
case "signMessage":
|
|
217
|
+
save({
|
|
218
|
+
...record,
|
|
219
|
+
pending: void 0
|
|
220
|
+
});
|
|
221
|
+
return {
|
|
222
|
+
ok: true,
|
|
223
|
+
method,
|
|
224
|
+
signature: bs58.decode(String(data.signature))
|
|
225
|
+
};
|
|
226
|
+
default:
|
|
227
|
+
return {
|
|
228
|
+
ok: false,
|
|
229
|
+
method,
|
|
230
|
+
errorCode: "-32603",
|
|
231
|
+
errorMessage: "Phantom answered a request this browser did not make"
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
forget() {
|
|
236
|
+
storage().removeItem(storageKey);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function toBase64(bytes) {
|
|
241
|
+
let binary = "";
|
|
242
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
243
|
+
return btoa(binary);
|
|
244
|
+
}
|
|
245
|
+
async function sendSolanaTransaction(rpcUrl, signedTransaction, options = {}) {
|
|
246
|
+
const response = await (options.fetch ?? fetch)(rpcUrl, {
|
|
247
|
+
method: "POST",
|
|
248
|
+
headers: {
|
|
249
|
+
"content-type": "application/json"
|
|
250
|
+
},
|
|
251
|
+
body: JSON.stringify({
|
|
252
|
+
jsonrpc: "2.0",
|
|
253
|
+
id: 1,
|
|
254
|
+
method: "sendTransaction",
|
|
255
|
+
params: [toBase64(signedTransaction), {
|
|
256
|
+
encoding: "base64",
|
|
257
|
+
skipPreflight: options.skipPreflight ?? false
|
|
258
|
+
}]
|
|
259
|
+
})
|
|
260
|
+
});
|
|
261
|
+
const body = await response.json();
|
|
262
|
+
if (body.error) {
|
|
263
|
+
throw Object.assign(new Error(`sendTransaction failed: ${body.error.message}`), {
|
|
264
|
+
code: body.error.code
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
if (typeof body.result !== "string") throw new Error("sendTransaction returned no signature");
|
|
268
|
+
return body.result;
|
|
269
|
+
}
|
|
270
|
+
export { PhantomNotConnectedError, phantomDeeplink, sendSolanaTransaction };
|
|
271
|
+
//# sourceMappingURL=solana.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["bs58","boxKeyPairFromSecretKey","decryptPayload","generateBoxKeyPair","sharedSecret","parsePhantomRedirect","phantomConnectUrl","phantomMethodUrl","stripPhantomRedirect","PhantomNotConnectedError","Error","constructor","name","defaultStorageKey","defaultStorage","storage","globalThis","localStorage","currentHref","href","location","phantomDeeplink","config","storageKey","now","Date","navigate","url","assign","redirectLink","load","raw","getItem","JSON","parse","save","record","setItem","stringify","connected","session","phantomEncryptionPublicKey","methodUrl","method","payload","keyPair","decode","dappSecretKey","dappEncryptionPublicKey","publicKey","secretKey","base","request","pending","at","connect","appUrl","cluster","encode","signTransaction","serializedTransaction","transaction","signAllTransactions","serializedTransactions","transactions","map","tx","signAndSendTransaction","sendOptions","signMessage","message","display","bytes","TextEncoder","disconnect","removeItem","handleRedirect","params","errorCode","ok","errorMessage","data","nonce","phantomKey","String","public_key","signature","forget","toBase64","binary","byte","fromCharCode","btoa","sendSolanaTransaction","rpcUrl","signedTransaction","options","response","fetch","headers","body","jsonrpc","id","encoding","skipPreflight","json","error","Object","code","result"],"sources":["../../../src/phantom/solana.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,IAAA,MAAU;AACjB,SACEC,uBAAA,EACAC,cAAA,EACAC,kBAAA,EACAC,YAAA,QACK;AACP,SACEC,oBAAA,EACAC,iBAAA,EACAC,gBAAA,EACAC,oBAAA,QAGK;AA6DA,MAAMC,wBAAA,SAAiCC,KAAA,CAAM;EAClDC,YAAA,EAAc;IACZ,MAAM,mDAAmD;IACzD,KAAKC,IAAA,GAAO;EACd;AACF;AAoCA,MAAMC,iBAAA,GAAoB;AAE1B,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