@buildersgarden/siwa 0.0.8 → 0.0.9
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/erc8128.d.ts +9 -0
- package/dist/erc8128.js +23 -0
- package/dist/keystore.d.ts +3 -2
- package/dist/keystore.js +3 -2
- package/package.json +1 -1
package/dist/erc8128.d.ts
CHANGED
|
@@ -93,3 +93,12 @@ export declare function expressToFetchRequest(req: {
|
|
|
93
93
|
headers: Record<string, string | string[] | undefined>;
|
|
94
94
|
rawBody?: string;
|
|
95
95
|
}): Request;
|
|
96
|
+
/**
|
|
97
|
+
* Normalize a Next.js/serverless Request for ERC-8128 verification.
|
|
98
|
+
*
|
|
99
|
+
* Behind reverse proxies (Vercel, Railway, Cloudflare), the request URL
|
|
100
|
+
* may reflect internal routing instead of the public origin. This helper
|
|
101
|
+
* reads X-Forwarded-Host / X-Forwarded-Proto headers and reconstructs
|
|
102
|
+
* the URL to match what the agent signed.
|
|
103
|
+
*/
|
|
104
|
+
export declare function nextjsToFetchRequest(req: Request): Request;
|
package/dist/erc8128.js
CHANGED
|
@@ -226,6 +226,29 @@ export function expressToFetchRequest(req) {
|
|
|
226
226
|
body: hasBody ? (req.rawBody ?? null) : null,
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Normalize a Next.js/serverless Request for ERC-8128 verification.
|
|
231
|
+
*
|
|
232
|
+
* Behind reverse proxies (Vercel, Railway, Cloudflare), the request URL
|
|
233
|
+
* may reflect internal routing instead of the public origin. This helper
|
|
234
|
+
* reads X-Forwarded-Host / X-Forwarded-Proto headers and reconstructs
|
|
235
|
+
* the URL to match what the agent signed.
|
|
236
|
+
*/
|
|
237
|
+
export function nextjsToFetchRequest(req) {
|
|
238
|
+
const forwardedHost = req.headers.get('x-forwarded-host') || req.headers.get('host');
|
|
239
|
+
const forwardedProto = req.headers.get('x-forwarded-proto') || 'https';
|
|
240
|
+
if (!forwardedHost)
|
|
241
|
+
return req; // no proxy headers, return as-is
|
|
242
|
+
const url = new URL(req.url);
|
|
243
|
+
const publicUrl = `${forwardedProto}://${forwardedHost}${url.pathname}${url.search}`;
|
|
244
|
+
return new Request(publicUrl, {
|
|
245
|
+
method: req.method,
|
|
246
|
+
headers: req.headers,
|
|
247
|
+
body: req.body,
|
|
248
|
+
// @ts-ignore - duplex required for streaming bodies in Node 18+
|
|
249
|
+
duplex: 'half',
|
|
250
|
+
});
|
|
251
|
+
}
|
|
229
252
|
/**
|
|
230
253
|
* Lazily create a viem PublicClient from an RPC URL.
|
|
231
254
|
*/
|
package/dist/keystore.d.ts
CHANGED
|
@@ -76,11 +76,12 @@ export declare function getAddress(config?: KeystoreConfig): Promise<string | nu
|
|
|
76
76
|
*/
|
|
77
77
|
export declare function signMessage(message: string, config?: KeystoreConfig): Promise<SignResult>;
|
|
78
78
|
/**
|
|
79
|
-
* Sign a raw hex message via the keyring proxy
|
|
79
|
+
* Sign a raw hex message via the keyring proxy.
|
|
80
80
|
*
|
|
81
81
|
* Used internally by the ERC-8128 signer — the signature base bytes are
|
|
82
82
|
* passed as a hex string and signed with `{ raw: true }` so the proxy
|
|
83
|
-
*
|
|
83
|
+
* interprets them as raw bytes (not UTF-8). Note: the proxy still applies
|
|
84
|
+
* EIP-191 personal_sign wrapping (viem `signMessage({ message: { raw } })`).
|
|
84
85
|
*/
|
|
85
86
|
export declare function signRawMessage(rawHex: string, config?: KeystoreConfig): Promise<SignResult>;
|
|
86
87
|
/**
|
package/dist/keystore.js
CHANGED
|
@@ -81,11 +81,12 @@ export async function signMessage(message, config = {}) {
|
|
|
81
81
|
return { signature: data.signature, address: data.address };
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Sign a raw hex message via the keyring proxy
|
|
84
|
+
* Sign a raw hex message via the keyring proxy.
|
|
85
85
|
*
|
|
86
86
|
* Used internally by the ERC-8128 signer — the signature base bytes are
|
|
87
87
|
* passed as a hex string and signed with `{ raw: true }` so the proxy
|
|
88
|
-
*
|
|
88
|
+
* interprets them as raw bytes (not UTF-8). Note: the proxy still applies
|
|
89
|
+
* EIP-191 personal_sign wrapping (viem `signMessage({ message: { raw } })`).
|
|
89
90
|
*/
|
|
90
91
|
export async function signRawMessage(rawHex, config = {}) {
|
|
91
92
|
const data = await proxyRequest(config, "/sign-message", {
|