@armory-sh/client-web3 0.2.21 → 0.2.22-alpha.21.67
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/dist/index.js +36 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -103,6 +103,40 @@ var signWithPrivateKey = async (_privateKey, _domain, _message) => {
|
|
|
103
103
|
"Direct private key signing not implemented. Use wallet provider's signTypedData method instead."
|
|
104
104
|
);
|
|
105
105
|
};
|
|
106
|
+
|
|
107
|
+
// src/bytes.ts
|
|
108
|
+
new TextEncoder();
|
|
109
|
+
var textDecoder = new TextDecoder();
|
|
110
|
+
function getNodeBuffer() {
|
|
111
|
+
if ("Buffer" in globalThis) {
|
|
112
|
+
return globalThis.Buffer;
|
|
113
|
+
}
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
function fromBase64(base64) {
|
|
117
|
+
if (typeof atob === "function") {
|
|
118
|
+
const binary = atob(base64);
|
|
119
|
+
const bytes = new Uint8Array(binary.length);
|
|
120
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
121
|
+
bytes[index] = binary.charCodeAt(index);
|
|
122
|
+
}
|
|
123
|
+
return bytes;
|
|
124
|
+
}
|
|
125
|
+
const nodeBuffer = getNodeBuffer();
|
|
126
|
+
if (nodeBuffer) {
|
|
127
|
+
return Uint8Array.from(nodeBuffer.from(base64, "base64"));
|
|
128
|
+
}
|
|
129
|
+
throw new Error("No base64 decoder available in this runtime");
|
|
130
|
+
}
|
|
131
|
+
function decodeBase64ToUtf8(value) {
|
|
132
|
+
const bytes = fromBase64(value);
|
|
133
|
+
return textDecoder.decode(bytes);
|
|
134
|
+
}
|
|
135
|
+
function normalizeBase64Url(value) {
|
|
136
|
+
return value.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(value.length / 4) * 4, "=");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/protocol.ts
|
|
106
140
|
var detectX402Version = (_response, _fallbackVersion = 2) => {
|
|
107
141
|
return 2;
|
|
108
142
|
};
|
|
@@ -116,8 +150,8 @@ var parsePaymentRequired = async (response, _version) => {
|
|
|
116
150
|
try {
|
|
117
151
|
parsed = JSON.parse(v2Header);
|
|
118
152
|
} catch {
|
|
119
|
-
const normalized =
|
|
120
|
-
const decoded =
|
|
153
|
+
const normalized = normalizeBase64Url(v2Header);
|
|
154
|
+
const decoded = decodeBase64ToUtf8(normalized);
|
|
121
155
|
parsed = JSON.parse(decoded);
|
|
122
156
|
}
|
|
123
157
|
if (!isX402V2PaymentRequired(parsed)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@armory-sh/client-web3",
|
|
3
|
-
"version": "0.2.21",
|
|
3
|
+
"version": "0.2.22-alpha.21.67",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Sawyer Cutler <sawyer@dirtroad.dev>",
|
|
6
6
|
"keywords": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
|
-
"bun": "./
|
|
31
|
+
"bun": "./dist/index.js",
|
|
32
32
|
"default": "./dist/index.js"
|
|
33
33
|
},
|
|
34
34
|
"./dist/*": "./dist/*.js"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"directory": "packages/client-web3"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@armory-sh/base": "0.2.
|
|
49
|
+
"@armory-sh/base": "0.2.26-alpha.21.67",
|
|
50
50
|
"web3": "4.16.0",
|
|
51
51
|
"web3-types": "1.10.0"
|
|
52
52
|
},
|