@edge-markets/connect-node 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/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.js CHANGED
@@ -500,6 +500,7 @@ function fromBase64Url(value) {
500
500
  var import_node_fs = __toESM(require("fs"));
501
501
  var import_node_https = __toESM(require("https"));
502
502
  var import_node_tls = __toESM(require("tls"));
503
+ var import_undici = require("undici");
503
504
  var CERT_PATTERN = /-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g;
504
505
  function normalizeCaBundle(ca) {
505
506
  if (!ca) return [];
@@ -537,9 +538,7 @@ function createHttpsAgent(config) {
537
538
  }
538
539
  function createUndiciDispatcher(config) {
539
540
  const ca = buildServerCaBundle(config.ca);
540
- const moduleName = "undici";
541
- const { Agent } = require(moduleName);
542
- return new Agent({
541
+ return new import_undici.Agent({
543
542
  connect: {
544
543
  cert: config.cert,
545
544
  key: config.key,
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,
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.10.1",
4
4
  "description": "Server SDK for EDGE Connect token exchange and API calls",
5
5
  "author": "Edge Markets",
6
6
  "license": "MIT",
@@ -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
  }