@edge-markets/connect-node 1.10.0 → 1.11.0

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/README.md CHANGED
@@ -196,6 +196,40 @@ to Node's default public trust roots instead of replacing them.
196
196
 
197
197
  Do not disable TLS verification and do not set `NODE_TLS_REJECT_UNAUTHORIZED=0`.
198
198
 
199
+ ### Next.js and Vercel Route Handlers
200
+
201
+ `@edge-markets/connect-node` is a Node.js server SDK. In Next.js Route Handlers,
202
+ force the Node runtime before importing or constructing the SDK:
203
+
204
+ ```typescript
205
+ export const runtime = 'nodejs'
206
+
207
+ import { createEdgeConnectServerFromEnv } from '@edge-markets/connect-node'
208
+
209
+ const { server: edge } = createEdgeConnectServerFromEnv({
210
+ requireMtls: true,
211
+ })
212
+ ```
213
+
214
+ Do not import this package from Client Components, browser code, middleware, or
215
+ Edge Runtime handlers. It reads server-only secrets and uses Node TLS APIs for
216
+ mTLS.
217
+
218
+ If you are pinned to an older SDK version and your Next.js/Turbopack build logs
219
+ show `dynamic usage of require is not supported`, externalize the package as an
220
+ app-level mitigation until you can upgrade:
221
+
222
+ ```typescript
223
+ // next.config.ts
224
+ import type { NextConfig } from 'next'
225
+
226
+ const nextConfig: NextConfig = {
227
+ serverExternalPackages: ['@edge-markets/connect-node', 'undici'],
228
+ }
229
+
230
+ export default nextConfig
231
+ ```
232
+
199
233
  ## Token Exchange
200
234
 
201
235
  After EdgeLink completes, exchange the code for tokens:
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as node_https from 'node:https';
2
2
  import { EdgeEnvironment, TransferCategory, Transfer, VerificationSession, TransferType, TransferStatus, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSessionStatusResponse, EdgeTokens, EdgeWebhookEvent, EdgeWebhookEventType } from '@edge-markets/connect';
3
- export { ACTIVE_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
3
+ export { ACTIVE_EDGE_SCOPES, ALL_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_SCOPES, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, RESERVED_EDGE_SCOPES, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
4
4
 
5
5
  type RequestEndpoint = 'connect_api' | 'oauth_token' | 'partner_webhook_sync';
6
6
  interface RequestInfo {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as node_https from 'node:https';
2
2
  import { EdgeEnvironment, TransferCategory, Transfer, VerificationSession, TransferType, TransferStatus, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSessionStatusResponse, EdgeTokens, EdgeWebhookEvent, EdgeWebhookEventType } from '@edge-markets/connect';
3
- export { ACTIVE_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
3
+ export { ACTIVE_EDGE_SCOPES, ALL_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_SCOPES, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, RESERVED_EDGE_SCOPES, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
4
4
 
5
5
  type RequestEndpoint = 'connect_api' | 'oauth_token' | 'partner_webhook_sync';
6
6
  interface RequestInfo {
package/dist/index.js CHANGED
@@ -31,8 +31,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  ACTIVE_EDGE_SCOPES: () => import_connect16.ACTIVE_EDGE_SCOPES,
34
+ ALL_EDGE_SCOPES: () => import_connect16.ALL_EDGE_SCOPES,
34
35
  CONNECT_TRANSFER_DIRECTIONS: () => CONNECT_TRANSFER_DIRECTIONS,
35
36
  EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE: () => import_connect15.EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
37
+ EDGE_SCOPES: () => import_connect16.EDGE_SCOPES,
36
38
  EDGE_WEBHOOK_EVENT_TYPES: () => import_connect16.EDGE_WEBHOOK_EVENT_TYPES,
37
39
  EdgeApiError: () => import_connect15.EdgeApiError,
38
40
  EdgeAuthenticationError: () => import_connect15.EdgeAuthenticationError,
@@ -51,6 +53,7 @@ __export(index_exports, {
51
53
  EdgeValidationError: () => import_connect15.EdgeValidationError,
52
54
  EdgeWebhookInbox: () => EdgeWebhookInbox,
53
55
  EdgeWebhookReconciler: () => EdgeWebhookReconciler,
56
+ RESERVED_EDGE_SCOPES: () => import_connect16.RESERVED_EDGE_SCOPES,
54
57
  TRANSFER_CATEGORIES: () => import_connect16.TRANSFER_CATEGORIES,
55
58
  assertSameTransferIntent: () => assertSameTransferIntent,
56
59
  assertTransferEventMatchesIntent: () => assertTransferEventMatchesIntent,
@@ -500,6 +503,7 @@ function fromBase64Url(value) {
500
503
  var import_node_fs = __toESM(require("fs"));
501
504
  var import_node_https = __toESM(require("https"));
502
505
  var import_node_tls = __toESM(require("tls"));
506
+ var import_undici = require("undici");
503
507
  var CERT_PATTERN = /-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g;
504
508
  function normalizeCaBundle(ca) {
505
509
  if (!ca) return [];
@@ -537,9 +541,7 @@ function createHttpsAgent(config) {
537
541
  }
538
542
  function createUndiciDispatcher(config) {
539
543
  const ca = buildServerCaBundle(config.ca);
540
- const moduleName = "undici";
541
- const { Agent } = require(moduleName);
542
- return new Agent({
544
+ return new import_undici.Agent({
543
545
  connect: {
544
546
  cert: config.cert,
545
547
  key: config.key,
@@ -857,7 +859,15 @@ function getInstanceKey(config) {
857
859
  config.partnerClientId || ""
858
860
  ]);
859
861
  }
860
- var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["connect-staging.edgeboost.io", "connect.edgeboost.io"]);
862
+ var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set([
863
+ "sandbox.connect.staging.edgeboost.io",
864
+ "connect-staging.edgeboost.io",
865
+ "connect.edgeboost.io"
866
+ ]);
867
+ var CONNECT_INGRESS_REQUIRED_MESSAGE = "Edge Connect API requests must go through the mTLS Connect gateway. Set EDGE_API_BASE_URL and EDGE_OAUTH_BASE_URL to the Connect gateway for this environment and configure EDGE_MTLS_CERT and EDGE_MTLS_KEY.";
868
+ var MTLS_REQUIRED_MESSAGE = "Edge Connect rejected this request because no trusted partner mTLS client certificate was presented. Configure the issued EDGE_MTLS_CERT and EDGE_MTLS_KEY and retry through the Connect gateway.";
869
+ var MTLS_CLIENT_UNREGISTERED_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but the certificate is not registered for this partner. Contact EDGE DevRel to bind the certificate fingerprint to your OAuth client ID.";
870
+ var MTLS_CLIENT_MISMATCH_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but it is not bound to the OAuth client ID used by this request. Use the certificate issued for this client ID or contact EDGE DevRel.";
861
871
  function isMtlsEnforcedHost(host) {
862
872
  if (MTLS_ENFORCED_HOSTS.has(host)) {
863
873
  return true;
@@ -870,7 +880,7 @@ function isMtlsEnforcedHost(host) {
870
880
  return false;
871
881
  }
872
882
  function environmentRequiresMtls(environment, apiBaseUrl) {
873
- if (environment === "staging" || environment === "production") {
883
+ if (environment === "sandbox" || environment === "staging" || environment === "production") {
874
884
  return true;
875
885
  }
876
886
  try {
@@ -1488,18 +1498,31 @@ var EdgeConnectServer = class _EdgeConnectServer {
1488
1498
  });
1489
1499
  }
1490
1500
  async handleApiErrorFromBody(error, status, path) {
1501
+ const errorCode = error.error || error.code;
1491
1502
  if (status === 401) {
1492
1503
  return new import_connect5.EdgeAuthenticationError(error.message || "Access token is invalid or expired", error);
1493
1504
  }
1494
1505
  if (status === 403) {
1495
- if (error.error === "consent_required") {
1506
+ if (errorCode === "connect_ingress_required") {
1507
+ return new import_connect5.EdgeApiError("connect_ingress_required", CONNECT_INGRESS_REQUIRED_MESSAGE, status, error);
1508
+ }
1509
+ if (errorCode === "mtls_required") {
1510
+ return new import_connect5.EdgeApiError("mtls_required", MTLS_REQUIRED_MESSAGE, status, error);
1511
+ }
1512
+ if (errorCode === "mtls_client_unregistered") {
1513
+ return new import_connect5.EdgeApiError("mtls_client_unregistered", MTLS_CLIENT_UNREGISTERED_MESSAGE, status, error);
1514
+ }
1515
+ if (errorCode === "mtls_client_mismatch") {
1516
+ return new import_connect5.EdgeApiError("mtls_client_mismatch", MTLS_CLIENT_MISMATCH_MESSAGE, status, error);
1517
+ }
1518
+ if (errorCode === "consent_required") {
1496
1519
  return new import_connect5.EdgeConsentRequiredError(
1497
1520
  this.config.clientId,
1498
1521
  error.consentUrl,
1499
1522
  error.message
1500
1523
  );
1501
1524
  }
1502
- if (error.error === "insufficient_scope" || error.error === "insufficient_consent") {
1525
+ if (errorCode === "insufficient_scope" || errorCode === "insufficient_consent") {
1503
1526
  return new import_connect5.EdgeInsufficientScopeError(
1504
1527
  error.missing_scopes || error.missingScopes || [],
1505
1528
  error.message
@@ -1643,11 +1666,11 @@ function buildMtlsConfig(env, requireMtls, warnings) {
1643
1666
  };
1644
1667
  }
1645
1668
  function inferMtlsRequirement(environment, apiBaseUrl) {
1646
- if (environment === "staging" || environment === "production") return true;
1669
+ if (environment === "sandbox" || environment === "staging" || environment === "production") return true;
1647
1670
  const resolvedApiBaseUrl = apiBaseUrl || (0, import_connect6.getEnvironmentConfig)(environment).apiBaseUrl;
1648
1671
  try {
1649
1672
  const host = new URL(resolvedApiBaseUrl).host;
1650
- return host === "connect-staging.edgeboost.io" || host === "connect.edgeboost.io";
1673
+ return host === "sandbox.connect.staging.edgeboost.io" || host === "connect-staging.edgeboost.io" || host === "connect.edgeboost.io";
1651
1674
  } catch {
1652
1675
  return false;
1653
1676
  }
@@ -1658,7 +1681,7 @@ function createEdgeConnectServerFromEnv(options = {}) {
1658
1681
  const environment = readEnvironment(env);
1659
1682
  const apiBaseUrl = readEnv(env, "EDGE_API_BASE_URL");
1660
1683
  const mtlsRequiredByTarget = inferMtlsRequirement(environment, apiBaseUrl);
1661
- const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ?? false;
1684
+ const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ?? mtlsRequiredByTarget;
1662
1685
  const mtls = buildMtlsConfig(env, requireMtls, warnings);
1663
1686
  const timeout = readTimeout(env, options.timeout);
1664
1687
  const clientId = readFirstEnv(env, ["EDGE_CLIENT_ID", "EDGE_CONNECT_CLIENT_ID"]) || "";
@@ -2659,8 +2682,10 @@ var import_connect16 = require("@edge-markets/connect");
2659
2682
  // Annotate the CommonJS export names for ESM import in node:
2660
2683
  0 && (module.exports = {
2661
2684
  ACTIVE_EDGE_SCOPES,
2685
+ ALL_EDGE_SCOPES,
2662
2686
  CONNECT_TRANSFER_DIRECTIONS,
2663
2687
  EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
2688
+ EDGE_SCOPES,
2664
2689
  EDGE_WEBHOOK_EVENT_TYPES,
2665
2690
  EdgeApiError,
2666
2691
  EdgeAuthenticationError,
@@ -2679,6 +2704,7 @@ var import_connect16 = require("@edge-markets/connect");
2679
2704
  EdgeValidationError,
2680
2705
  EdgeWebhookInbox,
2681
2706
  EdgeWebhookReconciler,
2707
+ RESERVED_EDGE_SCOPES,
2682
2708
  TRANSFER_CATEGORIES,
2683
2709
  assertSameTransferIntent,
2684
2710
  assertTransferEventMatchesIntent,
package/dist/index.mjs CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/edge-connect-server.ts
9
2
  import {
10
3
  EdgeApiError,
@@ -420,6 +413,7 @@ function fromBase64Url(value) {
420
413
  import fs from "fs";
421
414
  import https from "https";
422
415
  import tls from "tls";
416
+ import { Agent as UndiciAgent } from "undici";
423
417
  var CERT_PATTERN = /-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g;
424
418
  function normalizeCaBundle(ca) {
425
419
  if (!ca) return [];
@@ -457,9 +451,7 @@ function createHttpsAgent(config) {
457
451
  }
458
452
  function createUndiciDispatcher(config) {
459
453
  const ca = buildServerCaBundle(config.ca);
460
- const moduleName = "undici";
461
- const { Agent } = __require(moduleName);
462
- return new Agent({
454
+ return new UndiciAgent({
463
455
  connect: {
464
456
  cert: config.cert,
465
457
  key: config.key,
@@ -777,7 +769,15 @@ function getInstanceKey(config) {
777
769
  config.partnerClientId || ""
778
770
  ]);
779
771
  }
780
- var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["connect-staging.edgeboost.io", "connect.edgeboost.io"]);
772
+ var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set([
773
+ "sandbox.connect.staging.edgeboost.io",
774
+ "connect-staging.edgeboost.io",
775
+ "connect.edgeboost.io"
776
+ ]);
777
+ var CONNECT_INGRESS_REQUIRED_MESSAGE = "Edge Connect API requests must go through the mTLS Connect gateway. Set EDGE_API_BASE_URL and EDGE_OAUTH_BASE_URL to the Connect gateway for this environment and configure EDGE_MTLS_CERT and EDGE_MTLS_KEY.";
778
+ var MTLS_REQUIRED_MESSAGE = "Edge Connect rejected this request because no trusted partner mTLS client certificate was presented. Configure the issued EDGE_MTLS_CERT and EDGE_MTLS_KEY and retry through the Connect gateway.";
779
+ var MTLS_CLIENT_UNREGISTERED_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but the certificate is not registered for this partner. Contact EDGE DevRel to bind the certificate fingerprint to your OAuth client ID.";
780
+ var MTLS_CLIENT_MISMATCH_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but it is not bound to the OAuth client ID used by this request. Use the certificate issued for this client ID or contact EDGE DevRel.";
781
781
  function isMtlsEnforcedHost(host) {
782
782
  if (MTLS_ENFORCED_HOSTS.has(host)) {
783
783
  return true;
@@ -790,7 +790,7 @@ function isMtlsEnforcedHost(host) {
790
790
  return false;
791
791
  }
792
792
  function environmentRequiresMtls(environment, apiBaseUrl) {
793
- if (environment === "staging" || environment === "production") {
793
+ if (environment === "sandbox" || environment === "staging" || environment === "production") {
794
794
  return true;
795
795
  }
796
796
  try {
@@ -1408,18 +1408,31 @@ var EdgeConnectServer = class _EdgeConnectServer {
1408
1408
  });
1409
1409
  }
1410
1410
  async handleApiErrorFromBody(error, status, path) {
1411
+ const errorCode = error.error || error.code;
1411
1412
  if (status === 401) {
1412
1413
  return new EdgeAuthenticationError2(error.message || "Access token is invalid or expired", error);
1413
1414
  }
1414
1415
  if (status === 403) {
1415
- if (error.error === "consent_required") {
1416
+ if (errorCode === "connect_ingress_required") {
1417
+ return new EdgeApiError("connect_ingress_required", CONNECT_INGRESS_REQUIRED_MESSAGE, status, error);
1418
+ }
1419
+ if (errorCode === "mtls_required") {
1420
+ return new EdgeApiError("mtls_required", MTLS_REQUIRED_MESSAGE, status, error);
1421
+ }
1422
+ if (errorCode === "mtls_client_unregistered") {
1423
+ return new EdgeApiError("mtls_client_unregistered", MTLS_CLIENT_UNREGISTERED_MESSAGE, status, error);
1424
+ }
1425
+ if (errorCode === "mtls_client_mismatch") {
1426
+ return new EdgeApiError("mtls_client_mismatch", MTLS_CLIENT_MISMATCH_MESSAGE, status, error);
1427
+ }
1428
+ if (errorCode === "consent_required") {
1416
1429
  return new EdgeConsentRequiredError(
1417
1430
  this.config.clientId,
1418
1431
  error.consentUrl,
1419
1432
  error.message
1420
1433
  );
1421
1434
  }
1422
- if (error.error === "insufficient_scope" || error.error === "insufficient_consent") {
1435
+ if (errorCode === "insufficient_scope" || errorCode === "insufficient_consent") {
1423
1436
  return new EdgeInsufficientScopeError(
1424
1437
  error.missing_scopes || error.missingScopes || [],
1425
1438
  error.message
@@ -1563,11 +1576,11 @@ function buildMtlsConfig(env, requireMtls, warnings) {
1563
1576
  };
1564
1577
  }
1565
1578
  function inferMtlsRequirement(environment, apiBaseUrl) {
1566
- if (environment === "staging" || environment === "production") return true;
1579
+ if (environment === "sandbox" || environment === "staging" || environment === "production") return true;
1567
1580
  const resolvedApiBaseUrl = apiBaseUrl || getEnvironmentConfig2(environment).apiBaseUrl;
1568
1581
  try {
1569
1582
  const host = new URL(resolvedApiBaseUrl).host;
1570
- return host === "connect-staging.edgeboost.io" || host === "connect.edgeboost.io";
1583
+ return host === "sandbox.connect.staging.edgeboost.io" || host === "connect-staging.edgeboost.io" || host === "connect.edgeboost.io";
1571
1584
  } catch {
1572
1585
  return false;
1573
1586
  }
@@ -1578,7 +1591,7 @@ function createEdgeConnectServerFromEnv(options = {}) {
1578
1591
  const environment = readEnvironment(env);
1579
1592
  const apiBaseUrl = readEnv(env, "EDGE_API_BASE_URL");
1580
1593
  const mtlsRequiredByTarget = inferMtlsRequirement(environment, apiBaseUrl);
1581
- const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ?? false;
1594
+ const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ?? mtlsRequiredByTarget;
1582
1595
  const mtls = buildMtlsConfig(env, requireMtls, warnings);
1583
1596
  const timeout = readTimeout(env, options.timeout);
1584
1597
  const clientId = readFirstEnv(env, ["EDGE_CLIENT_ID", "EDGE_CONNECT_CLIENT_ID"]) || "";
@@ -2608,6 +2621,9 @@ import {
2608
2621
  } from "@edge-markets/connect";
2609
2622
  import {
2610
2623
  ACTIVE_EDGE_SCOPES,
2624
+ ALL_EDGE_SCOPES,
2625
+ EDGE_SCOPES,
2626
+ RESERVED_EDGE_SCOPES,
2611
2627
  EDGE_WEBHOOK_EVENT_TYPES as EDGE_WEBHOOK_EVENT_TYPES2,
2612
2628
  TRANSFER_CATEGORIES,
2613
2629
  getEnvironmentConfig as getEnvironmentConfig3,
@@ -2615,8 +2631,10 @@ import {
2615
2631
  } from "@edge-markets/connect";
2616
2632
  export {
2617
2633
  ACTIVE_EDGE_SCOPES,
2634
+ ALL_EDGE_SCOPES,
2618
2635
  CONNECT_TRANSFER_DIRECTIONS,
2619
2636
  EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
2637
+ EDGE_SCOPES,
2620
2638
  EDGE_WEBHOOK_EVENT_TYPES2 as EDGE_WEBHOOK_EVENT_TYPES,
2621
2639
  EdgeApiError2 as EdgeApiError,
2622
2640
  EdgeAuthenticationError4 as EdgeAuthenticationError,
@@ -2635,6 +2653,7 @@ export {
2635
2653
  EdgeValidationError13 as EdgeValidationError,
2636
2654
  EdgeWebhookInbox,
2637
2655
  EdgeWebhookReconciler,
2656
+ RESERVED_EDGE_SCOPES,
2638
2657
  TRANSFER_CATEGORIES,
2639
2658
  assertSameTransferIntent,
2640
2659
  assertTransferEventMatchesIntent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edge-markets/connect-node",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Server SDK for EDGE Connect token exchange and API calls",
5
5
  "author": "Edge Markets",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "undici": "^5.29.0",
25
- "@edge-markets/connect": "^1.8.0"
25
+ "@edge-markets/connect": "^1.9.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsup": "^8.0.0",
@@ -55,6 +55,7 @@
55
55
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
56
56
  "typecheck": "tsc --noEmit",
57
57
  "test": "vitest --passWithNoTests",
58
- "test:run": "vitest run --passWithNoTests"
58
+ "test:run": "vitest run --passWithNoTests",
59
+ "test:dist": "pnpm run build && node scripts/check-dist-undici.mjs"
59
60
  }
60
61
  }