@heyatom/bastion-client 0.1.0 → 0.1.2

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
@@ -6,7 +6,7 @@ Replaces the `src/modules/bastion/` boilerplate every service used to copy by ha
6
6
  - `@heyatom/bastion-client` — framework-free core: `JwksVerifier` (kid-indexed cache, unknown-kid refetch with cooldown, stale-on-error), `BastionHttp` (`POST /auth/client`, `POST /events`, any other route), `ServiceTokenProvider` (single-flight refresh ahead of `exp`), payload types.
7
7
  - `@heyatom/bastion-client/nest` — NestJS: `BastionModule`, `ServiceClientJwtGuard`, `BastionUserGuard`, `BastionAuditService`, `AuditInterceptor`, `@Public()`, `@RequireScope()`, `@Audit()`, `@CurrentClient()`, `@CurrentAdminUser()`.
8
8
 
9
- Ships CJS and ESM. Peer deps: `jose` (always), `@nestjs/common`, `@nestjs/core`, `rxjs`, `reflect-metadata` (for `/nest`).
9
+ Ships CJS and ESM. `jose` v6 is ESM-only, so the CJS build relies on Node's `require(esm)` — Node ≥ 20.19 / 22.12. Peer deps: `jose` (always), `@nestjs/common`, `@nestjs/core`, `rxjs`, `reflect-metadata` (for `/nest`).
10
10
 
11
11
  ## NestJS
12
12
 
@@ -77,4 +77,4 @@ await http.writeAuditEvent(await tokens.getToken(), { event: 'thing.done' });
77
77
 
78
78
  ## Release
79
79
 
80
- Bump `version`, tag `vX.Y.Z`, push the tag. The workflow runs lint/test/build/DI smoke and publishes with provenance (`NPM_TOKEN` secret).
80
+ Bump `version`, tag `vX.Y.Z`, push the tag. The workflow runs lint/test/build/DI smoke and publishes via npm trusted publishing (OIDC, no token; provenance implied).
@@ -49,8 +49,8 @@ let ServiceClientJwtGuard = class ServiceClientJwtGuard {
49
49
  if (payload.serviceSlug !== this.options.serviceSlug) {
50
50
  throw new common_1.ForbiddenException('Token not issued for this service');
51
51
  }
52
- const required = this.reflector.getAllAndOverride(require_scope_decorator_js_1.REQUIRED_SCOPES_KEY, targets) ?? [];
53
- const missing = required.filter((s) => !payload.scopes?.includes(s));
52
+ const required = this.reflector.getAllAndOverride(require_scope_decorator_js_1.REQUIRED_SCOPES_KEY, targets);
53
+ const missing = (Array.isArray(required) ? required : []).filter((s) => !payload.scopes?.includes(s));
54
54
  if (missing.length)
55
55
  throw new common_1.ForbiddenException(`Missing scope: ${missing.join(', ')}`);
56
56
  req.user = payload;
@@ -19,6 +19,6 @@ export interface BastionModuleOptions {
19
19
  acceptedRoles?: string[];
20
20
  }
21
21
  export interface BastionModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
22
- useFactory: (...args: unknown[]) => BastionModuleOptions | Promise<BastionModuleOptions>;
22
+ useFactory: (...args: any[]) => BastionModuleOptions | Promise<BastionModuleOptions>;
23
23
  inject?: unknown[];
24
24
  }
@@ -46,8 +46,8 @@ let ServiceClientJwtGuard = class ServiceClientJwtGuard {
46
46
  if (payload.serviceSlug !== this.options.serviceSlug) {
47
47
  throw new ForbiddenException('Token not issued for this service');
48
48
  }
49
- const required = this.reflector.getAllAndOverride(REQUIRED_SCOPES_KEY, targets) ?? [];
50
- const missing = required.filter((s) => !payload.scopes?.includes(s));
49
+ const required = this.reflector.getAllAndOverride(REQUIRED_SCOPES_KEY, targets);
50
+ const missing = (Array.isArray(required) ? required : []).filter((s) => !payload.scopes?.includes(s));
51
51
  if (missing.length)
52
52
  throw new ForbiddenException(`Missing scope: ${missing.join(', ')}`);
53
53
  req.user = payload;
@@ -19,6 +19,6 @@ export interface BastionModuleOptions {
19
19
  acceptedRoles?: string[];
20
20
  }
21
21
  export interface BastionModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
22
- useFactory: (...args: unknown[]) => BastionModuleOptions | Promise<BastionModuleOptions>;
22
+ useFactory: (...args: any[]) => BastionModuleOptions | Promise<BastionModuleOptions>;
23
23
  inject?: unknown[];
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyatom/bastion-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Consumer SDK for the Bastion identity provider: JWKS verification, service-client auth, audit writes, NestJS guards",
5
5
  "license": "MIT",
6
6
  "author": "Andrea Tombolato <hey@heyatom.dev> (https://heyatom.dev)",
@@ -37,8 +37,15 @@
37
37
  }
38
38
  }
39
39
  },
40
+ "scripts": {
41
+ "build": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > dist/esm/package.json",
42
+ "test": "vitest run",
43
+ "lint": "tsc -p tsconfig.json --noEmit",
44
+ "prepublishOnly": "pnpm lint && pnpm test && pnpm build && pnpm test:di",
45
+ "test:di": "node scripts/di-smoke.cjs"
46
+ },
40
47
  "engines": {
41
- "node": ">=20"
48
+ "node": ">=20.19"
42
49
  },
43
50
  "peerDependencies": {
44
51
  "@nestjs/common": "^11.0.0",
@@ -71,10 +78,14 @@
71
78
  "typescript": "^5.9.3",
72
79
  "vitest": "^3.2.4"
73
80
  },
74
- "scripts": {
75
- "build": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > dist/esm/package.json",
76
- "test": "vitest run",
77
- "lint": "tsc -p tsconfig.json --noEmit",
78
- "test:di": "node scripts/di-smoke.cjs"
81
+ "typesVersions": {
82
+ "*": {
83
+ "nest": [
84
+ "./dist/cjs/nest/index.d.ts"
85
+ ],
86
+ "*": [
87
+ "./dist/cjs/core/index.d.ts"
88
+ ]
89
+ }
79
90
  }
80
- }
91
+ }