apinow-sdk 0.28.2 → 0.28.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/dist/index.d.ts +1 -1
- package/dist/index.js +17 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { x402Client, wrapFetchWithPayment } from '@x402/fetch';
|
|
2
2
|
import { registerExactEvmScheme } from '@x402/evm/exact/client';
|
|
3
3
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
|
-
const APINOW_BASE = 'https://apinow.fun';
|
|
5
|
-
export const APINOW_SDK_VERSION = '0.28.
|
|
4
|
+
const APINOW_BASE = 'https://www.apinow.fun';
|
|
5
|
+
export const APINOW_SDK_VERSION = '0.28.3';
|
|
6
|
+
/**
|
|
7
|
+
* Default base URL. In a browser we prefer the current origin so that
|
|
8
|
+
* signed-auth writes stay same-origin and don't hit a CORS preflight
|
|
9
|
+
* (which then explodes on any apex↔www redirect the host performs).
|
|
10
|
+
* In Node we fall back to the canonical www host.
|
|
11
|
+
*/
|
|
12
|
+
function resolveDefaultBaseUrl() {
|
|
13
|
+
if (typeof globalThis !== 'undefined') {
|
|
14
|
+
const w = globalThis.window;
|
|
15
|
+
if (w?.location?.origin)
|
|
16
|
+
return w.location.origin;
|
|
17
|
+
}
|
|
18
|
+
return APINOW_BASE;
|
|
19
|
+
}
|
|
6
20
|
function isServerConfig(c) {
|
|
7
21
|
return 'privateKey' in c && typeof c.privateKey === 'string';
|
|
8
22
|
}
|
|
@@ -49,7 +63,7 @@ async function followRedirects(res) {
|
|
|
49
63
|
}
|
|
50
64
|
export function createClient(config) {
|
|
51
65
|
const server = isServerConfig(config);
|
|
52
|
-
const baseUrl = config.baseUrl ??
|
|
66
|
+
const baseUrl = config.baseUrl ?? resolveDefaultBaseUrl();
|
|
53
67
|
const customFetch = config.fetch;
|
|
54
68
|
// Resolve address + signer from whichever config shape the caller passed.
|
|
55
69
|
const account = server ? privateKeyToAccount(config.privateKey) : null;
|
package/package.json
CHANGED