@nauth-toolkit/oidc-provider 0.6.1 → 0.7.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.
@@ -8,9 +8,8 @@ type ProviderCtor = new (issuer: string, configuration?: Configuration) => Provi
8
8
  *
9
9
  * Node supports `require(esm)` unflagged from ^20.19 and ^22.12, and the package has
10
10
  * no top-level await, so the synchronous path works on every currently supported
11
- * runtime. The dynamic-import fallback covers Node 22.0–22.11, and is built through
12
- * `Function` so TypeScript does not rewrite it back into a `require` — the same
13
- * technique `JwtService` already uses for the ESM-only `jose`.
11
+ * runtime. `loadESM` covers Node 22.0–22.11, and any host whose `require` refuses ESM
12
+ * regardless of the runtime — Jest's does, so tests always take that path.
14
13
  */
15
14
  export declare function loadProviderCtor(): Promise<ProviderCtor>;
16
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../src/create-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,uEAAuE;AACvE,KAAK,YAAY,GAAG,KAAK,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa,KAAK,QAAQ,CAAC;AA4BpF;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAS9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwG/G"}
1
+ {"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../src/create-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,uEAAuE;AACvE,KAAK,YAAY,GAAG,KAAK,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa,KAAK,QAAQ,CAAC;AA4BpF;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAM9D;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwG/G"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadProviderCtor = loadProviderCtor;
4
4
  exports.createNAuthOIDCProvider = createNAuthOIDCProvider;
5
+ const load_esm_1 = require("./load-esm");
5
6
  const storage_adapter_1 = require("./storage.adapter");
6
7
  const find_account_1 = require("./find-account");
7
8
  /** Every route `oidc-provider` serves, so all of them can be prefixed together. */
@@ -26,21 +27,30 @@ const ROUTE_NAMES = [
26
27
  *
27
28
  * Node supports `require(esm)` unflagged from ^20.19 and ^22.12, and the package has
28
29
  * no top-level await, so the synchronous path works on every currently supported
29
- * runtime. The dynamic-import fallback covers Node 22.0–22.11, and is built through
30
- * `Function` so TypeScript does not rewrite it back into a `require` — the same
31
- * technique `JwtService` already uses for the ESM-only `jose`.
30
+ * runtime. `loadESM` covers Node 22.0–22.11, and any host whose `require` refuses ESM
31
+ * regardless of the runtime — Jest's does, so tests always take that path.
32
32
  */
33
33
  async function loadProviderCtor() {
34
34
  try {
35
- const mod = require('oidc-provider');
36
- return (mod.default ?? mod);
35
+ return unwrapProviderCtor(require('oidc-provider'));
37
36
  }
38
37
  catch {
39
- const nativeImport = new Function('m', 'return import(m)');
40
- const mod = (await nativeImport('oidc-provider'));
41
- return (mod.default ?? mod);
38
+ return unwrapProviderCtor(await (0, load_esm_1.loadESM)('oidc-provider'));
42
39
  }
43
40
  }
41
+ /**
42
+ * Take the constructor out of a module namespace, however it was loaded.
43
+ *
44
+ * `require(esm)` and `import()` agree on the shape here, but a CommonJS interop layer
45
+ * in between may not, so the default export is unwrapped when present.
46
+ *
47
+ * @param mod - The loaded `oidc-provider` module namespace
48
+ * @returns The `Provider` constructor
49
+ */
50
+ function unwrapProviderCtor(mod) {
51
+ const namespace = mod;
52
+ return (namespace.default ?? namespace);
53
+ }
44
54
  /**
45
55
  * Create an `oidc-provider` instance wired to nauth's storage and users.
46
56
  *
@@ -1 +1 @@
1
- {"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src/create-provider.ts"],"names":[],"mappings":";;AA4CA,4CASC;AA+BD,0DAwGC;AA1LD,uDAA6D;AAC7D,iDAAmD;AAcnD,mFAAmF;AACnF,MAAM,WAAW,GAAG;IAClB,CAAC,eAAe,EAAE,OAAO,CAAC;IAC1B,CAAC,OAAO,EAAE,QAAQ,CAAC;IACnB,CAAC,MAAM,EAAE,OAAO,CAAC;IACjB,CAAC,UAAU,EAAE,KAAK,CAAC;IACnB,CAAC,eAAe,EAAE,sBAAsB,CAAC;IACzC,CAAC,YAAY,EAAE,mBAAmB,CAAC;IACnC,CAAC,aAAa,EAAE,cAAc,CAAC;IAC/B,CAAC,sBAAsB,EAAE,cAAc,CAAC;IACxC,CAAC,mBAAmB,EAAE,SAAS,CAAC;IAChC,CAAC,8BAA8B,EAAE,UAAU,CAAC;IAC5C,CAAC,cAAc,EAAE,MAAM,CAAC;IACxB,CAAC,4BAA4B,EAAE,cAAc,CAAC;IAC9C,CAAC,WAAW,EAAE,YAAY,CAAC;IAC3B,CAAC,YAAY,EAAE,aAAa,CAAC;CACrB,CAAC;AAEX;;;;;;;;GAQG;AACI,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC;QACH,MAAM,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QAE9B,yEAAyE;QACzE,EAAE;QACF,iFAAiF;QACjF,4EAA4E;QAC5E,kFAAkF;QAClF,+EAA+E;QAC/E,mEAAmE;QACnE,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC;QAE1F,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAA6B,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,GAAG,OAAO,CAAC,kBAAkB;KAC9B,CAAC;IAEF,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEzD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Load an ESM-only dependency from this CommonJS build.
3
+ *
4
+ * The import is built through `Function` so TypeScript does not rewrite it back into a
5
+ * `require`, which is the only way to reach a genuine dynamic `import()` from CommonJS
6
+ * output. Under Jest — which runs with `--experimental-vm-modules` here — that import is
7
+ * serviced by the test runner, so the module is instantiated *inside the test's realm*.
8
+ * That matters for `oidc-provider`: it type-checks the configuration object it is handed,
9
+ * and a config built in one realm fails those checks in another. Loading it through
10
+ * Node's own `require`/`createRequire` instead puts it in the main realm and breaks with
11
+ * `features.attestClientAuth must be an own property`.
12
+ *
13
+ * The body carries a unique comment on every call because V8 caches compiled `Function`
14
+ * bodies by source text. Two Jest test files evaluating byte-identical source share one
15
+ * compiled function, and with it the module-resolution context of whichever file ran
16
+ * first; once that file's environment is torn down, the other fails with "Test
17
+ * environment has been torn down". Which file loses depends only on execution order, so
18
+ * it reproduces on CI's shared workers but seldom on a dev machine with more cores.
19
+ * Making each body unique forces a fresh compile bound to the calling context.
20
+ *
21
+ * @param specifier - The package to load
22
+ * @returns The module namespace, exactly as the host resolves it (no `default`
23
+ * unwrapping — that differs per package, so it is left to the caller)
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const client = await loadESM<typeof import('openid-client')>('openid-client');
28
+ * ```
29
+ */
30
+ export declare function loadESM<T>(specifier: string): Promise<T>;
31
+ //# sourceMappingURL=load-esm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-esm.d.ts","sourceRoot":"","sources":["../../src/load-esm.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAMxD"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadESM = loadESM;
4
+ /** Counter feeding the per-call cache-buster below. */
5
+ let loadCounter = 0;
6
+ /**
7
+ * Load an ESM-only dependency from this CommonJS build.
8
+ *
9
+ * The import is built through `Function` so TypeScript does not rewrite it back into a
10
+ * `require`, which is the only way to reach a genuine dynamic `import()` from CommonJS
11
+ * output. Under Jest — which runs with `--experimental-vm-modules` here — that import is
12
+ * serviced by the test runner, so the module is instantiated *inside the test's realm*.
13
+ * That matters for `oidc-provider`: it type-checks the configuration object it is handed,
14
+ * and a config built in one realm fails those checks in another. Loading it through
15
+ * Node's own `require`/`createRequire` instead puts it in the main realm and breaks with
16
+ * `features.attestClientAuth must be an own property`.
17
+ *
18
+ * The body carries a unique comment on every call because V8 caches compiled `Function`
19
+ * bodies by source text. Two Jest test files evaluating byte-identical source share one
20
+ * compiled function, and with it the module-resolution context of whichever file ran
21
+ * first; once that file's environment is torn down, the other fails with "Test
22
+ * environment has been torn down". Which file loses depends only on execution order, so
23
+ * it reproduces on CI's shared workers but seldom on a dev machine with more cores.
24
+ * Making each body unique forces a fresh compile bound to the calling context.
25
+ *
26
+ * @param specifier - The package to load
27
+ * @returns The module namespace, exactly as the host resolves it (no `default`
28
+ * unwrapping — that differs per package, so it is left to the caller)
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const client = await loadESM<typeof import('openid-client')>('openid-client');
33
+ * ```
34
+ */
35
+ function loadESM(specifier) {
36
+ loadCounter += 1;
37
+ const cacheBuster = `${loadCounter}_${Math.random().toString(36).slice(2)}`;
38
+ const nativeImport = new Function('m', `return import(m); /* ${cacheBuster} */`);
39
+ return nativeImport(specifier);
40
+ }
41
+ //# sourceMappingURL=load-esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-esm.js","sourceRoot":"","sources":["../../src/load-esm.ts"],"names":[],"mappings":";;AAgCA,0BAMC;AAtCD,uDAAuD;AACvD,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAgB,OAAO,CAAI,SAAiB;IAC1C,WAAW,IAAI,CAAC,CAAC;IACjB,MAAM,WAAW,GAAG,GAAG,WAAW,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,MAAM,YAAY,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,wBAAwB,WAAW,KAAK,CAA8B,CAAC;IAE9G,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nauth-toolkit/oidc-provider",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "OpenID Connect provider for nauth-toolkit, backed by the OpenID Certified oidc-provider library",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -35,10 +35,10 @@
35
35
  "format:check": "prettier --check \"src/**/*.ts\" \"nestjs/**/*.ts\""
36
36
  },
37
37
  "peerDependencies": {
38
- "@nauth-toolkit/core": "^0.6.1",
38
+ "@nauth-toolkit/core": "^0.7.1",
39
39
  "oidc-provider": "^9.0.0",
40
40
  "@nestjs/common": "^9.0.0 || ^10.0.0 || ^11.0.0",
41
- "@nauth-toolkit/nestjs": "^0.6.1"
41
+ "@nauth-toolkit/nestjs": "^0.7.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^22.0.0",