@nibgate/sdk 0.2.6 → 0.2.7
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/SKILL.md +14 -19
- package/dist/nibgate.js +27 -5
- package/dist/nibgate.js.map +2 -2
- package/dist/nibgate.min.js +2 -2
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/evm-gateway.js +3 -1
- package/src/browser/gateway.js +30 -4
- package/src/core/resource.js +1 -1
package/src/browser/gateway.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { stringifyJson } from './json.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let cachedCircleModule = null;
|
|
4
|
+
|
|
5
|
+
async function getCircleClient(options = {}) {
|
|
6
|
+
if (cachedCircleModule) return cachedCircleModule;
|
|
7
|
+
|
|
8
|
+
if (options.clientModule) {
|
|
9
|
+
cachedCircleModule = options.clientModule;
|
|
10
|
+
return cachedCircleModule;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const moduleUrl = options.clientModuleUrl || '@circle-fin/x402-batching/client';
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
cachedCircleModule = await import(moduleUrl);
|
|
17
|
+
return cachedCircleModule;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (!options.clientModuleUrl) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Could not load @circle-fin/x402-batching/client from node_modules. ` +
|
|
22
|
+
`Provide a clientModuleUrl option (e.g. "https://esm.sh/@circle-fin/x402-batching@3.2.0/client?bundle") ` +
|
|
23
|
+
`to load from CDN. Original error: ${error.message}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Could not load Circle Gateway client from CDN: ${error.message}. ` +
|
|
28
|
+
`Check that ${options.clientModuleUrl} is reachable.`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
4
32
|
|
|
5
33
|
function encodeBase64(value) {
|
|
6
34
|
const text = typeof value === 'string' ? value : stringifyJson(value);
|
|
@@ -19,9 +47,7 @@ export async function createCircleGatewayBrowserAdapter(options = {}) {
|
|
|
19
47
|
throw new Error('Circle Gateway browser adapter requires an EVM signer with address and signTypedData.');
|
|
20
48
|
}
|
|
21
49
|
|
|
22
|
-
const circleClientModule =
|
|
23
|
-
? await runtimeImport(options.clientModuleUrl)
|
|
24
|
-
: await runtimeImport('@circle-fin/x402-batching/client'));
|
|
50
|
+
const circleClientModule = await getCircleClient(options);
|
|
25
51
|
const { BatchEvmScheme } = circleClientModule;
|
|
26
52
|
const scheme = new BatchEvmScheme(signer);
|
|
27
53
|
const network = options.network || options.chainId && `eip155:${options.chainId}` || 'eip155:5042002';
|
package/src/core/resource.js
CHANGED
|
@@ -161,7 +161,7 @@ export function validateResourceMetadata(resource = {}, options = {}) {
|
|
|
161
161
|
const normalized = normalizeResource(resource);
|
|
162
162
|
const warnings = [];
|
|
163
163
|
const errors = [];
|
|
164
|
-
const required = options.required || ['id'];
|
|
164
|
+
const required = options.required || ['id', 'type'];
|
|
165
165
|
const recommended = options.recommended || ['title', 'url', 'description', 'imageUrl', 'tags'];
|
|
166
166
|
|
|
167
167
|
for (const field of required) {
|