@circle-fin/provider-cctp-v2 1.10.0 → 1.10.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @circle-fin/provider-cctp-v2
2
2
 
3
+ ## 1.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Make the SDK safe to bundle and run in browsers/client-side apps.
8
+
9
+ - Browser requests omit Node-only headers that would cause CORS failures, including EarnKit’s SDK-version header.
10
+ - Solana operations in App Kit, Adapter Solana Kit, and Gateway work in a browser without requiring a consumer-provided `Buffer` polyfill.
11
+ - Supplying a `kitKey` or Circle Wallets `apiKey` in a browser now fails early. Keep those secrets on the server and forward a prepared transaction or other safe result to the client.
12
+
3
13
  ## 1.10.0
4
14
 
5
15
  ### Minor Changes
package/index.cjs CHANGED
@@ -4510,6 +4510,27 @@ const swapTokenEnumSchema = zod.z.enum([
4510
4510
  * }
4511
4511
  * ```
4512
4512
  */ const isNodeEnvironment = ()=>typeof process !== 'undefined' && typeof process.versions === 'object' && typeof process.versions.node === 'string';
4513
+ /**
4514
+ * Return the SDK User-Agent request header only when running in Node.js.
4515
+ *
4516
+ * Browsers forbid manually setting `User-Agent`, and a custom fallback header
4517
+ * can trigger CORS preflight. Non-Node server runtimes also omit this optional
4518
+ * attribution header because they cannot set it reliably.
4519
+ *
4520
+ * @returns A User-Agent header in Node.js, or an empty object otherwise.
4521
+ *
4522
+ * @example
4523
+ * ```typescript
4524
+ * import { getNodeUserAgentHeader } from '@core/utils'
4525
+ *
4526
+ * const headers = {
4527
+ * 'Content-Type': 'application/json',
4528
+ * ...getNodeUserAgentHeader(),
4529
+ * }
4530
+ * ```
4531
+ */ const getNodeUserAgentHeader = ()=>isNodeEnvironment() ? {
4532
+ 'User-Agent': getUserAgent()
4533
+ } : {};
4513
4534
  /**
4514
4535
  * Detect the runtime environment and return a shortened identifier.
4515
4536
  *
@@ -6934,13 +6955,12 @@ class KitError extends Error {
6934
6955
  headers: {
6935
6956
  ...DEFAULT_CONFIG$1.headers,
6936
6957
  ...config.headers ?? {},
6937
- // In browser environments, directly setting the 'User-Agent' or similar headers is restricted and may be ignored or cause errors.
6938
- // This is why we use the 'X-User-Agent' header instead.
6939
- ...typeof window === 'undefined' ? {
6940
- 'User-Agent': getUserAgent()
6941
- } : {
6942
- 'X-User-Agent': getUserAgent()
6943
- }
6958
+ // Browsers forbid setting a user-agent request header, and the custom
6959
+ // fallback header the SDK used instead trips CORS preflight against the
6960
+ // Circle APIs (it isn't in their `Access-Control-Allow-Headers`),
6961
+ // blocking the request. So send the SDK user agent only in Node;
6962
+ // browsers omit it entirely.
6963
+ ...getNodeUserAgentHeader()
6944
6964
  }
6945
6965
  };
6946
6966
  let lastError;
@@ -9255,7 +9275,13 @@ const FAST_TIER_FINALITY_THRESHOLD = 1000;
9255
9275
  /**
9256
9276
  * The ASCII "cctp-forward" magic, hex-encoded (no `0x`), that a forward-friendly
9257
9277
  * hookData must start with.
9258
- */ const CCTP_FORWARD_MAGIC_HEX = Buffer.from(CCTP_FORWARD_MAGIC_PREFIX, 'ascii').toString('hex');
9278
+ *
9279
+ * Encoded with `TextEncoder` (a browser-safe Web API) rather than `Buffer.from`
9280
+ * so this module-level constant does not reference the Node `Buffer` global at
9281
+ * import time. App Kit inlines this provider into its bundle without a Buffer polyfill, and a
9282
+ * bare `Buffer` here crashes browser bundles (e.g. Vite) on load — even for apps
9283
+ * that never touch the prepaid FORWARD path. Mirrors `buildForwardingHookData`.
9284
+ */ const CCTP_FORWARD_MAGIC_HEX = Array.from(new TextEncoder().encode(CCTP_FORWARD_MAGIC_PREFIX)).map((byte)=>byte.toString(16).padStart(2, '0')).join('');
9259
9285
  /**
9260
9286
  * Determine whether a hookData blob begins with the `cctp-forward` envelope.
9261
9287
  *
@@ -12926,7 +12952,7 @@ const mockAttestationMessage = {
12926
12952
  return step;
12927
12953
  }
12928
12954
 
12929
- var version = "1.10.0";
12955
+ var version = "1.10.1";
12930
12956
  var pkg = {
12931
12957
  version: version};
12932
12958
 
package/index.mjs CHANGED
@@ -4503,6 +4503,27 @@ const swapTokenEnumSchema = z.enum([
4503
4503
  * }
4504
4504
  * ```
4505
4505
  */ const isNodeEnvironment = ()=>typeof process !== 'undefined' && typeof process.versions === 'object' && typeof process.versions.node === 'string';
4506
+ /**
4507
+ * Return the SDK User-Agent request header only when running in Node.js.
4508
+ *
4509
+ * Browsers forbid manually setting `User-Agent`, and a custom fallback header
4510
+ * can trigger CORS preflight. Non-Node server runtimes also omit this optional
4511
+ * attribution header because they cannot set it reliably.
4512
+ *
4513
+ * @returns A User-Agent header in Node.js, or an empty object otherwise.
4514
+ *
4515
+ * @example
4516
+ * ```typescript
4517
+ * import { getNodeUserAgentHeader } from '@core/utils'
4518
+ *
4519
+ * const headers = {
4520
+ * 'Content-Type': 'application/json',
4521
+ * ...getNodeUserAgentHeader(),
4522
+ * }
4523
+ * ```
4524
+ */ const getNodeUserAgentHeader = ()=>isNodeEnvironment() ? {
4525
+ 'User-Agent': getUserAgent()
4526
+ } : {};
4506
4527
  /**
4507
4528
  * Detect the runtime environment and return a shortened identifier.
4508
4529
  *
@@ -6927,13 +6948,12 @@ class KitError extends Error {
6927
6948
  headers: {
6928
6949
  ...DEFAULT_CONFIG$1.headers,
6929
6950
  ...config.headers ?? {},
6930
- // In browser environments, directly setting the 'User-Agent' or similar headers is restricted and may be ignored or cause errors.
6931
- // This is why we use the 'X-User-Agent' header instead.
6932
- ...typeof window === 'undefined' ? {
6933
- 'User-Agent': getUserAgent()
6934
- } : {
6935
- 'X-User-Agent': getUserAgent()
6936
- }
6951
+ // Browsers forbid setting a user-agent request header, and the custom
6952
+ // fallback header the SDK used instead trips CORS preflight against the
6953
+ // Circle APIs (it isn't in their `Access-Control-Allow-Headers`),
6954
+ // blocking the request. So send the SDK user agent only in Node;
6955
+ // browsers omit it entirely.
6956
+ ...getNodeUserAgentHeader()
6937
6957
  }
6938
6958
  };
6939
6959
  let lastError;
@@ -9248,7 +9268,13 @@ const FAST_TIER_FINALITY_THRESHOLD = 1000;
9248
9268
  /**
9249
9269
  * The ASCII "cctp-forward" magic, hex-encoded (no `0x`), that a forward-friendly
9250
9270
  * hookData must start with.
9251
- */ const CCTP_FORWARD_MAGIC_HEX = Buffer.from(CCTP_FORWARD_MAGIC_PREFIX, 'ascii').toString('hex');
9271
+ *
9272
+ * Encoded with `TextEncoder` (a browser-safe Web API) rather than `Buffer.from`
9273
+ * so this module-level constant does not reference the Node `Buffer` global at
9274
+ * import time. App Kit inlines this provider into its bundle without a Buffer polyfill, and a
9275
+ * bare `Buffer` here crashes browser bundles (e.g. Vite) on load — even for apps
9276
+ * that never touch the prepaid FORWARD path. Mirrors `buildForwardingHookData`.
9277
+ */ const CCTP_FORWARD_MAGIC_HEX = Array.from(new TextEncoder().encode(CCTP_FORWARD_MAGIC_PREFIX)).map((byte)=>byte.toString(16).padStart(2, '0')).join('');
9252
9278
  /**
9253
9279
  * Determine whether a hookData blob begins with the `cctp-forward` envelope.
9254
9280
  *
@@ -12919,7 +12945,7 @@ const mockAttestationMessage = {
12919
12945
  return step;
12920
12946
  }
12921
12947
 
12922
- var version = "1.10.0";
12948
+ var version = "1.10.1";
12923
12949
  var pkg = {
12924
12950
  version: version};
12925
12951
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@circle-fin/provider-cctp-v2",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Circle's official Cross-Chain Transfer Protocol v2 provider for native USDC bridging",
5
5
  "keywords": [
6
6
  "circle",