@blimu/nestjs 1.1.1 → 1.1.4

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.
Files changed (80) hide show
  1. package/dist/__tests__/example.test.cjs +17135 -0
  2. package/dist/__tests__/example.test.cjs.map +1 -0
  3. package/dist/__tests__/example.test.d.cts +2 -0
  4. package/dist/__tests__/example.test.d.ts +2 -0
  5. package/dist/__tests__/example.test.mjs +17134 -0
  6. package/dist/__tests__/example.test.mjs.map +1 -0
  7. package/dist/config/blimu.config.cjs +31 -0
  8. package/dist/config/blimu.config.cjs.map +1 -0
  9. package/dist/config/blimu.config.d.cts +11 -0
  10. package/dist/config/blimu.config.d.ts +8 -6
  11. package/dist/config/blimu.config.mjs +6 -0
  12. package/dist/config/blimu.config.mjs.map +1 -0
  13. package/dist/decorators/entitlement.decorator.cjs +178 -0
  14. package/dist/decorators/entitlement.decorator.cjs.map +1 -0
  15. package/dist/decorators/entitlement.decorator.d.cts +9 -0
  16. package/dist/decorators/entitlement.decorator.d.ts +9 -4
  17. package/dist/decorators/entitlement.decorator.mjs +161 -0
  18. package/dist/decorators/entitlement.decorator.mjs.map +1 -0
  19. package/dist/exceptions/blimu-forbidden.exception.cjs +86 -0
  20. package/dist/exceptions/blimu-forbidden.exception.cjs.map +1 -0
  21. package/dist/exceptions/blimu-forbidden.exception.d.cts +14 -0
  22. package/dist/exceptions/blimu-forbidden.exception.d.ts +6 -4
  23. package/dist/exceptions/blimu-forbidden.exception.mjs +61 -0
  24. package/dist/exceptions/blimu-forbidden.exception.mjs.map +1 -0
  25. package/dist/guards/entitlement.guard.cjs +174 -0
  26. package/dist/guards/entitlement.guard.cjs.map +1 -0
  27. package/dist/guards/entitlement.guard.d.cts +24 -0
  28. package/dist/guards/entitlement.guard.d.ts +12 -12
  29. package/dist/guards/entitlement.guard.mjs +154 -0
  30. package/dist/guards/entitlement.guard.mjs.map +1 -0
  31. package/dist/index.cjs +445 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.cts +9 -0
  34. package/dist/index.d.ts +9 -7
  35. package/dist/index.mjs +420 -0
  36. package/dist/index.mjs.map +1 -0
  37. package/dist/modules/blimu.module.cjs +413 -0
  38. package/dist/modules/blimu.module.cjs.map +1 -0
  39. package/dist/modules/blimu.module.d.cts +14 -0
  40. package/dist/modules/blimu.module.d.ts +11 -8
  41. package/dist/modules/blimu.module.mjs +398 -0
  42. package/dist/modules/blimu.module.mjs.map +1 -0
  43. package/dist/services/index.cjs +93 -0
  44. package/dist/services/index.cjs.map +1 -0
  45. package/dist/services/index.d.cts +2 -0
  46. package/dist/services/index.d.ts +2 -2
  47. package/dist/services/index.mjs +69 -0
  48. package/dist/services/index.mjs.map +1 -0
  49. package/dist/services/jwk.service.cjs +91 -0
  50. package/dist/services/jwk.service.cjs.map +1 -0
  51. package/dist/services/jwk.service.d.cts +12 -0
  52. package/dist/services/jwk.service.d.ts +5 -3
  53. package/dist/services/jwk.service.mjs +69 -0
  54. package/dist/services/jwk.service.mjs.map +1 -0
  55. package/package.json +34 -13
  56. package/dist/config/blimu.config.d.ts.map +0 -1
  57. package/dist/config/blimu.config.js +0 -5
  58. package/dist/config/blimu.config.js.map +0 -1
  59. package/dist/decorators/entitlement.decorator.d.ts.map +0 -1
  60. package/dist/decorators/entitlement.decorator.js +0 -10
  61. package/dist/decorators/entitlement.decorator.js.map +0 -1
  62. package/dist/exceptions/blimu-forbidden.exception.d.ts.map +0 -1
  63. package/dist/exceptions/blimu-forbidden.exception.js +0 -38
  64. package/dist/exceptions/blimu-forbidden.exception.js.map +0 -1
  65. package/dist/guards/entitlement.guard.d.ts.map +0 -1
  66. package/dist/guards/entitlement.guard.js +0 -82
  67. package/dist/guards/entitlement.guard.js.map +0 -1
  68. package/dist/index.d.ts.map +0 -1
  69. package/dist/index.js +0 -23
  70. package/dist/index.js.map +0 -1
  71. package/dist/modules/blimu.module.d.ts.map +0 -1
  72. package/dist/modules/blimu.module.js +0 -91
  73. package/dist/modules/blimu.module.js.map +0 -1
  74. package/dist/services/index.d.ts.map +0 -1
  75. package/dist/services/index.js +0 -18
  76. package/dist/services/index.js.map +0 -1
  77. package/dist/services/jwk.service.d.ts.map +0 -1
  78. package/dist/services/jwk.service.js +0 -59
  79. package/dist/services/jwk.service.js.map +0 -1
  80. package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,445 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __decorateClass = (decorators, target, key, kind) => {
20
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
21
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
+ if (decorator = decorators[i])
23
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
24
+ if (kind && result) __defProp(target, key, result);
25
+ return result;
26
+ };
27
+ var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
28
+
29
+ // src/index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ BLIMU_CONFIG: () => BLIMU_CONFIG,
33
+ BlimuForbiddenException: () => BlimuForbiddenException,
34
+ BlimuModule: () => BlimuModule,
35
+ ENTITLEMENT_KEY: () => ENTITLEMENT_KEY,
36
+ ENTITLEMENT_METADATA_KEY: () => ENTITLEMENT_METADATA_KEY,
37
+ Entitlement: () => Entitlement,
38
+ EntitlementGuard: () => EntitlementGuard,
39
+ JWKService: () => JWKService,
40
+ SetEntitlementMetadata: () => SetEntitlementMetadata
41
+ });
42
+ module.exports = __toCommonJS(index_exports);
43
+
44
+ // src/modules/blimu.module.ts
45
+ var import_common4 = require("@nestjs/common");
46
+
47
+ // src/config/blimu.config.ts
48
+ var BLIMU_CONFIG = /* @__PURE__ */ Symbol("BLIMU_CONFIG");
49
+
50
+ // src/guards/entitlement.guard.ts
51
+ var import_common2 = require("@nestjs/common");
52
+ var import_reflect_metadata = require("reflect-metadata");
53
+
54
+ // src/exceptions/blimu-forbidden.exception.ts
55
+ var import_common = require("@nestjs/common");
56
+ var BlimuForbiddenException = class _BlimuForbiddenException extends import_common.ForbiddenException {
57
+ /**
58
+ * The entitlement check result containing detailed failure information
59
+ */
60
+ entitlementResult;
61
+ /**
62
+ * The entitlement key that was checked
63
+ */
64
+ entitlementKey;
65
+ /**
66
+ * The resource ID that was checked
67
+ */
68
+ resourceId;
69
+ /**
70
+ * The user ID that was checked
71
+ */
72
+ userId;
73
+ constructor(entitlementResult, entitlementKey, resourceId, userId) {
74
+ const message = _BlimuForbiddenException.buildMessage(entitlementResult, entitlementKey);
75
+ super({
76
+ message,
77
+ entitlementResult,
78
+ entitlementKey,
79
+ resourceId,
80
+ userId
81
+ });
82
+ this.entitlementResult = entitlementResult;
83
+ this.entitlementKey = entitlementKey;
84
+ this.resourceId = resourceId;
85
+ this.userId = userId;
86
+ }
87
+ /**
88
+ * Builds a user-friendly error message from the entitlement check result
89
+ */
90
+ static buildMessage(result, entitlementKey) {
91
+ const reasons = [];
92
+ if (result.roles && !result.roles.allowed) {
93
+ reasons.push(
94
+ `Insufficient roles. Required: ${result.roles.allowedRoles?.join(", ") || "unknown"}. User has: ${result.roles.userRoles?.join(", ") || "none"}.`
95
+ );
96
+ }
97
+ if (result.plans && !result.plans.allowed) {
98
+ reasons.push(
99
+ `Plan restriction. Required plans: ${result.plans.allowedPlans?.join(", ") || "unknown"}. Current plan: ${result.plans.plan || "none"}.`
100
+ );
101
+ }
102
+ if (result.limit && !result.limit.allowed) {
103
+ reasons.push(`Usage limit exceeded. ${result.limit.reason || "Limit has been reached"}.`);
104
+ }
105
+ if (reasons.length === 0) {
106
+ return `Access denied for entitlement: ${entitlementKey}`;
107
+ }
108
+ return `Access denied for entitlement "${entitlementKey}": ${reasons.join(" ")}`;
109
+ }
110
+ };
111
+
112
+ // src/guards/entitlement.guard.ts
113
+ var import_backend = require("@blimu/backend");
114
+ var ENTITLEMENT_KEY = "entitlement";
115
+ var ENTITLEMENT_METADATA_KEY = /* @__PURE__ */ Symbol("entitlement");
116
+ var SetEntitlementMetadata = (entitlementKey, getEntitlementInfo) => (0, import_common2.SetMetadata)(ENTITLEMENT_METADATA_KEY, {
117
+ entitlementKey,
118
+ getEntitlementInfo
119
+ });
120
+ var EntitlementGuard = class {
121
+ constructor(config, runtime) {
122
+ this.config = config;
123
+ this.runtime = runtime;
124
+ }
125
+ async canActivate(context) {
126
+ const request = context.switchToHttp().getRequest();
127
+ const handler = context.getHandler();
128
+ const metadata = Reflect.getMetadata(ENTITLEMENT_METADATA_KEY, handler);
129
+ if (!metadata) {
130
+ return true;
131
+ }
132
+ let userId;
133
+ try {
134
+ userId = await this.config.getUserId(request);
135
+ } catch {
136
+ throw new import_common2.ForbiddenException("Failed to extract user ID from request");
137
+ }
138
+ if (!userId) {
139
+ throw new import_common2.ForbiddenException("User ID is required for entitlement check");
140
+ }
141
+ const entitlementInfo = await metadata.getEntitlementInfo(request);
142
+ if (!entitlementInfo?.resourceId) {
143
+ throw new import_common2.ForbiddenException("Resource ID is required for entitlement check");
144
+ }
145
+ try {
146
+ const result = await this.runtime.entitlements.checkEntitlement({
147
+ userId,
148
+ entitlement: metadata.entitlementKey,
149
+ resourceId: entitlementInfo.resourceId,
150
+ ...entitlementInfo.amount !== void 0 ? { amount: entitlementInfo.amount } : {}
151
+ });
152
+ if (!result.allowed) {
153
+ throw new BlimuForbiddenException(
154
+ result,
155
+ metadata.entitlementKey,
156
+ entitlementInfo.resourceId,
157
+ userId
158
+ );
159
+ }
160
+ return true;
161
+ } catch (error) {
162
+ if (error instanceof BlimuForbiddenException || error instanceof import_common2.ForbiddenException) {
163
+ throw error;
164
+ }
165
+ console.error("Entitlement check failed:", error);
166
+ throw new import_common2.ForbiddenException("Failed to verify entitlements");
167
+ }
168
+ }
169
+ };
170
+ EntitlementGuard = __decorateClass([
171
+ (0, import_common2.Injectable)(),
172
+ __decorateParam(0, (0, import_common2.Inject)(BLIMU_CONFIG)),
173
+ __decorateParam(1, (0, import_common2.Inject)(import_backend.Blimu))
174
+ ], EntitlementGuard);
175
+
176
+ // src/services/jwk.service.ts
177
+ var import_common3 = require("@nestjs/common");
178
+ var import_backend2 = require("@blimu/backend");
179
+ var JWKService = class {
180
+ constructor(config) {
181
+ this.config = config;
182
+ this.tokenVerifier = new import_backend2.TokenVerifier({
183
+ runtimeApiUrl: this.config.baseURL
184
+ });
185
+ }
186
+ logger = new import_common3.Logger(JWKService.name);
187
+ tokenVerifier;
188
+ /**
189
+ * Verify JWT token using JWKs from runtime-api
190
+ */
191
+ async verifyToken(token) {
192
+ try {
193
+ this.logger.debug(
194
+ `\u{1F50D} Verifying token. Runtime API URL: ${this.config.baseURL}, API Key prefix: ${this.config.apiKey?.substring(0, 10)}...`
195
+ );
196
+ const result = await this.tokenVerifier.verifyToken({
197
+ secretKey: this.config.apiKey,
198
+ token,
199
+ runtimeApiUrl: this.config.baseURL
200
+ });
201
+ this.logger.debug(`\u2705 Token verified successfully`);
202
+ return result;
203
+ } catch (error) {
204
+ const errorMessage = error instanceof Error ? error.message : String(error);
205
+ this.logger.error(`\u274C Token verification failed: ${errorMessage}`);
206
+ if (error instanceof Error && error.stack) {
207
+ this.logger.error(`Stack trace: ${error.stack}`);
208
+ }
209
+ throw error;
210
+ }
211
+ }
212
+ /**
213
+ * Clear cache (useful for testing or key rotation)
214
+ */
215
+ clearCache() {
216
+ this.tokenVerifier.clearCache(this.config.apiKey);
217
+ this.logger.debug("JWK cache cleared");
218
+ }
219
+ };
220
+ JWKService = __decorateClass([
221
+ (0, import_common3.Injectable)(),
222
+ __decorateParam(0, (0, import_common3.Inject)(BLIMU_CONFIG))
223
+ ], JWKService);
224
+
225
+ // src/modules/blimu.module.ts
226
+ var import_backend3 = require("@blimu/backend");
227
+ var DEFAULT_BASE_URL = "https://api.blimu.dev";
228
+ var BlimuModule = class {
229
+ /**
230
+ * Configure the Blimu module with static configuration
231
+ *
232
+ * @param config - The Blimu configuration object
233
+ * @returns A configured dynamic module
234
+ *
235
+ * @example
236
+ * Basic usage with default Request type:
237
+ * ```typescript
238
+ * @Module({
239
+ * imports: [
240
+ * BlimuModule.forRoot({
241
+ * apiKey: 'your-api-secret-key',
242
+ * baseURL: 'https://api.blimu.dev', // optional
243
+ * environmentId: 'your-environment-id', // optional
244
+ * timeoutMs: 30000, // optional
245
+ * getUserId: (req) => req.user?.id, // required
246
+ * }),
247
+ * ],
248
+ * })
249
+ * export class AppModule {}
250
+ * ```
251
+ *
252
+ * @example
253
+ * Usage with custom request type:
254
+ * ```typescript
255
+ * interface AuthenticatedRequest {
256
+ * user: { id: string; email: string };
257
+ * }
258
+ *
259
+ * @Module({
260
+ * imports: [
261
+ * BlimuModule.forRoot<AuthenticatedRequest>({
262
+ * apiKey: 'your-api-secret-key',
263
+ * getUserId: (req) => req.user.id, // req is typed as AuthenticatedRequest
264
+ * }),
265
+ * ],
266
+ * })
267
+ * export class AppModule {}
268
+ * ```
269
+ */
270
+ static forRoot(config) {
271
+ return {
272
+ ...config.global ? { global: true } : {},
273
+ module: BlimuModule,
274
+ providers: [
275
+ // Register factory providers first so dependencies are available
276
+ {
277
+ provide: BLIMU_CONFIG,
278
+ useValue: {
279
+ apiKey: config.apiKey,
280
+ baseURL: config.baseURL ?? DEFAULT_BASE_URL,
281
+ environmentId: config.environmentId,
282
+ timeoutMs: config.timeoutMs ?? 3e4,
283
+ getUserId: config.getUserId
284
+ }
285
+ },
286
+ {
287
+ provide: import_backend3.Blimu,
288
+ useFactory: (config2) => {
289
+ return new import_backend3.Blimu({
290
+ apiKey: config2.apiKey,
291
+ baseURL: config2.baseURL ?? DEFAULT_BASE_URL,
292
+ timeoutMs: config2.timeoutMs ?? 3e4
293
+ });
294
+ },
295
+ inject: [BLIMU_CONFIG]
296
+ },
297
+ // Register class providers after their dependencies are available
298
+ EntitlementGuard,
299
+ JWKService
300
+ ],
301
+ exports: [EntitlementGuard, import_backend3.Blimu, BLIMU_CONFIG, JWKService]
302
+ };
303
+ }
304
+ /**
305
+ * Configure the Blimu module with async configuration
306
+ *
307
+ * This is useful when you need to load configuration from environment variables,
308
+ * configuration services, or other async sources.
309
+ *
310
+ * @param options - Async configuration options
311
+ * @returns A configured dynamic module
312
+ *
313
+ * @example
314
+ * Using with ConfigService:
315
+ * ```typescript
316
+ * @Module({
317
+ * imports: [
318
+ * ConfigModule.forRoot(),
319
+ * BlimuModule.forRootAsync({
320
+ * useFactory: (configService: ConfigService) => ({
321
+ * apiKey: configService.get('BLIMU_API_SECRET_KEY'),
322
+ * baseURL: configService.get('BLIMU_BASE_URL'),
323
+ * environmentId: configService.get('BLIMU_ENVIRONMENT_ID'),
324
+ * timeoutMs: configService.get('BLIMU_TIMEOUT_MS'),
325
+ * getUserId: (req) => req.user?.id,
326
+ * }),
327
+ * inject: [ConfigService],
328
+ * }),
329
+ * ],
330
+ * })
331
+ * export class AppModule {}
332
+ * ```
333
+ *
334
+ * @example
335
+ * Using with custom request type:
336
+ * ```typescript
337
+ * interface AuthenticatedRequest {
338
+ * user: { id: string; email: string };
339
+ * }
340
+ *
341
+ * @Module({
342
+ * imports: [
343
+ * BlimuModule.forRootAsync<AuthenticatedRequest>({
344
+ * useFactory: (configService: ConfigService) => ({
345
+ * apiKey: configService.get('BLIMU_API_SECRET_KEY'),
346
+ * getUserId: (req) => req.user.id, // req is typed as AuthenticatedRequest
347
+ * }),
348
+ * inject: [ConfigService],
349
+ * }),
350
+ * ],
351
+ * })
352
+ * export class AppModule {}
353
+ * ```
354
+ *
355
+ * @example
356
+ * Using with custom provider:
357
+ * ```typescript
358
+ * @Module({
359
+ * imports: [
360
+ * BlimuModule.forRootAsync({
361
+ * imports: [MyConfigModule],
362
+ * useFactory: async (myConfigService: MyConfigService) => {
363
+ * const config = await myConfigService.getBlimuConfig();
364
+ * return {
365
+ * apiKey: config.apiKey,
366
+ * baseURL: config.baseUrl,
367
+ * environmentId: config.environmentId,
368
+ * getUserId: (req) => req.user?.id,
369
+ * };
370
+ * },
371
+ * inject: [MyConfigService],
372
+ * }),
373
+ * ],
374
+ * })
375
+ * export class AppModule {}
376
+ * ```
377
+ */
378
+ static forRootAsync(options) {
379
+ const additionalImports = options.imports ?? [];
380
+ const module2 = {
381
+ ...options.global ? { global: true } : {},
382
+ module: BlimuModule,
383
+ imports: [...additionalImports],
384
+ providers: [
385
+ // Register factory providers first so dependencies are available
386
+ {
387
+ provide: BLIMU_CONFIG,
388
+ useFactory: async (...args) => {
389
+ const configResult = options.useFactory(...args);
390
+ const config = configResult instanceof Promise ? await configResult : configResult;
391
+ return {
392
+ apiKey: config.apiKey,
393
+ baseURL: config.baseURL ?? DEFAULT_BASE_URL,
394
+ environmentId: config.environmentId,
395
+ timeoutMs: config.timeoutMs ?? 3e4,
396
+ getUserId: config.getUserId
397
+ };
398
+ },
399
+ ...options.inject ? { inject: options.inject } : {}
400
+ },
401
+ {
402
+ provide: import_backend3.Blimu,
403
+ useFactory: (config) => {
404
+ return new import_backend3.Blimu({
405
+ apiKey: config.apiKey,
406
+ baseURL: config.baseURL ?? DEFAULT_BASE_URL,
407
+ timeoutMs: config.timeoutMs ?? 3e4
408
+ });
409
+ },
410
+ inject: [BLIMU_CONFIG]
411
+ },
412
+ // Register class providers after their dependencies are available
413
+ EntitlementGuard,
414
+ JWKService
415
+ ],
416
+ exports: [EntitlementGuard, import_backend3.Blimu, BLIMU_CONFIG, JWKService]
417
+ };
418
+ return module2;
419
+ }
420
+ };
421
+ BlimuModule = __decorateClass([
422
+ (0, import_common4.Module)({})
423
+ ], BlimuModule);
424
+
425
+ // src/decorators/entitlement.decorator.ts
426
+ var import_common5 = require("@nestjs/common");
427
+ var Entitlement = (entitlementKey, getEntitlementInfo) => {
428
+ return (0, import_common5.applyDecorators)(
429
+ SetEntitlementMetadata(entitlementKey, getEntitlementInfo),
430
+ (0, import_common5.UseGuards)(EntitlementGuard)
431
+ );
432
+ };
433
+ // Annotate the CommonJS export names for ESM import in node:
434
+ 0 && (module.exports = {
435
+ BLIMU_CONFIG,
436
+ BlimuForbiddenException,
437
+ BlimuModule,
438
+ ENTITLEMENT_KEY,
439
+ ENTITLEMENT_METADATA_KEY,
440
+ Entitlement,
441
+ EntitlementGuard,
442
+ JWKService,
443
+ SetEntitlementMetadata
444
+ });
445
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/modules/blimu.module.ts","../src/config/blimu.config.ts","../src/guards/entitlement.guard.ts","../src/exceptions/blimu-forbidden.exception.ts","../src/services/jwk.service.ts","../src/decorators/entitlement.decorator.ts"],"sourcesContent":["// Main module\nexport * from './modules/blimu.module';\n\n// Configuration\nexport * from './config/blimu.config';\n\n// Guards\nexport * from './guards/entitlement.guard';\n\n// Decorators\nexport * from './decorators/entitlement.decorator';\n\n// Exceptions\nexport * from './exceptions/blimu-forbidden.exception';\n\n// Services\nexport * from './services';\n","import {\n Module,\n type DynamicModule,\n type Type,\n type ForwardReference,\n type InjectionToken,\n type OptionalFactoryDependency,\n} from '@nestjs/common';\n\nimport { BLIMU_CONFIG, type BlimuConfig } from '../config/blimu.config';\nimport { EntitlementGuard } from 'guards/entitlement.guard';\nimport { JWKService } from 'services/jwk.service';\nimport { Blimu } from '@blimu/backend';\n\nconst DEFAULT_BASE_URL = 'https://api.blimu.dev';\n\n/**\n * Blimu NestJS Module\n *\n * This module provides entitlement checking capabilities and Blimu Runtime SDK integration\n * for NestJS applications. It can be configured synchronously or asynchronously.\n */\n@Module({})\nexport class BlimuModule {\n /**\n * Configure the Blimu module with static configuration\n *\n * @param config - The Blimu configuration object\n * @returns A configured dynamic module\n *\n * @example\n * Basic usage with default Request type:\n * ```typescript\n * @Module({\n * imports: [\n * BlimuModule.forRoot({\n * apiKey: 'your-api-secret-key',\n * baseURL: 'https://api.blimu.dev', // optional\n * environmentId: 'your-environment-id', // optional\n * timeoutMs: 30000, // optional\n * getUserId: (req) => req.user?.id, // required\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n *\n * @example\n * Usage with custom request type:\n * ```typescript\n * interface AuthenticatedRequest {\n * user: { id: string; email: string };\n * }\n *\n * @Module({\n * imports: [\n * BlimuModule.forRoot<AuthenticatedRequest>({\n * apiKey: 'your-api-secret-key',\n * getUserId: (req) => req.user.id, // req is typed as AuthenticatedRequest\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n */\n static forRoot<TRequest = unknown>(config: BlimuConfig<TRequest>): DynamicModule {\n return {\n ...(config.global ? { global: true } : {}),\n module: BlimuModule,\n providers: [\n // Register factory providers first so dependencies are available\n {\n provide: BLIMU_CONFIG,\n useValue: {\n apiKey: config.apiKey,\n baseURL: config.baseURL ?? DEFAULT_BASE_URL,\n environmentId: config.environmentId,\n timeoutMs: config.timeoutMs ?? 30000,\n getUserId: config.getUserId,\n },\n },\n {\n provide: Blimu,\n useFactory: (config: BlimuConfig) => {\n return new Blimu({\n apiKey: config.apiKey,\n baseURL: config.baseURL ?? DEFAULT_BASE_URL,\n timeoutMs: config.timeoutMs ?? 30000,\n });\n },\n inject: [BLIMU_CONFIG],\n },\n // Register class providers after their dependencies are available\n EntitlementGuard,\n JWKService,\n ],\n exports: [EntitlementGuard, Blimu, BLIMU_CONFIG, JWKService],\n };\n }\n\n /**\n * Configure the Blimu module with async configuration\n *\n * This is useful when you need to load configuration from environment variables,\n * configuration services, or other async sources.\n *\n * @param options - Async configuration options\n * @returns A configured dynamic module\n *\n * @example\n * Using with ConfigService:\n * ```typescript\n * @Module({\n * imports: [\n * ConfigModule.forRoot(),\n * BlimuModule.forRootAsync({\n * useFactory: (configService: ConfigService) => ({\n * apiKey: configService.get('BLIMU_API_SECRET_KEY'),\n * baseURL: configService.get('BLIMU_BASE_URL'),\n * environmentId: configService.get('BLIMU_ENVIRONMENT_ID'),\n * timeoutMs: configService.get('BLIMU_TIMEOUT_MS'),\n * getUserId: (req) => req.user?.id,\n * }),\n * inject: [ConfigService],\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n *\n * @example\n * Using with custom request type:\n * ```typescript\n * interface AuthenticatedRequest {\n * user: { id: string; email: string };\n * }\n *\n * @Module({\n * imports: [\n * BlimuModule.forRootAsync<AuthenticatedRequest>({\n * useFactory: (configService: ConfigService) => ({\n * apiKey: configService.get('BLIMU_API_SECRET_KEY'),\n * getUserId: (req) => req.user.id, // req is typed as AuthenticatedRequest\n * }),\n * inject: [ConfigService],\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n *\n * @example\n * Using with custom provider:\n * ```typescript\n * @Module({\n * imports: [\n * BlimuModule.forRootAsync({\n * imports: [MyConfigModule],\n * useFactory: async (myConfigService: MyConfigService) => {\n * const config = await myConfigService.getBlimuConfig();\n * return {\n * apiKey: config.apiKey,\n * baseURL: config.baseUrl,\n * environmentId: config.environmentId,\n * getUserId: (req) => req.user?.id,\n * };\n * },\n * inject: [MyConfigService],\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n */\n static forRootAsync<TRequest = unknown>(options: {\n global?: boolean | undefined;\n useFactory: (...args: unknown[]) => Promise<BlimuConfig<TRequest>> | BlimuConfig<TRequest>;\n inject?: (InjectionToken | OptionalFactoryDependency)[];\n imports?: (\n | Type<unknown>\n | DynamicModule\n | Promise<DynamicModule>\n | ForwardReference<() => Type<unknown>>\n )[];\n }): DynamicModule {\n const additionalImports = options.imports ?? [];\n\n const module = {\n ...(options.global ? { global: true } : {}),\n module: BlimuModule,\n imports: [...additionalImports] as (\n | Type<unknown>\n | DynamicModule\n | Promise<DynamicModule>\n | ForwardReference\n )[],\n providers: [\n // Register factory providers first so dependencies are available\n {\n provide: BLIMU_CONFIG,\n useFactory: async (...args: unknown[]) => {\n const configResult = options.useFactory(...args);\n const config = configResult instanceof Promise ? await configResult : configResult;\n return {\n apiKey: config.apiKey,\n baseURL: config.baseURL ?? DEFAULT_BASE_URL,\n environmentId: config.environmentId,\n timeoutMs: config.timeoutMs ?? 30000,\n getUserId: config.getUserId,\n };\n },\n ...(options.inject ? { inject: options.inject } : {}),\n },\n {\n provide: Blimu,\n useFactory: (config: BlimuConfig) => {\n return new Blimu({\n apiKey: config.apiKey,\n baseURL: config.baseURL ?? DEFAULT_BASE_URL,\n timeoutMs: config.timeoutMs ?? 30000,\n });\n },\n inject: [BLIMU_CONFIG],\n },\n // Register class providers after their dependencies are available\n EntitlementGuard,\n JWKService,\n ],\n exports: [EntitlementGuard, Blimu, BLIMU_CONFIG, JWKService],\n };\n return module;\n }\n}\n","/**\n * Configuration interface for Blimu NestJS integration\n */\nexport interface BlimuConfig<TRequest = unknown> {\n global?: boolean | undefined;\n /**\n * The API secret key for authenticating with Blimu Runtime API\n */\n apiKey: string;\n\n /**\n * The base URL for the Blimu Runtime API\n * @default 'https://api.blimu.dev'\n */\n baseURL?: string | undefined;\n\n /**\n * Environment ID for the Blimu environment\n * This will be used in future versions for environment-specific configurations\n */\n environmentId?: string | undefined;\n\n /**\n * Request timeout in milliseconds\n * @default 30000\n */\n timeoutMs?: number | undefined;\n\n /**\n * Function to extract user ID from the request\n *\n * This function is called by the EntitlementGuard to determine which user\n * to check entitlements for. It should return the user ID as a string.\n *\n * @param request - The incoming HTTP request\n * @returns The user ID as a string, or a Promise that resolves to the user ID\n *\n * @example\n * ```typescript\n * // Extract from JWT token in Authorization header\n * getUserId: (req) => {\n * const token = req.headers.authorization?.replace('Bearer ', '');\n * const decoded = jwt.verify(token, secret);\n * return decoded.sub;\n * }\n *\n * // Extract from request.user (common with Passport.js)\n * getUserId: (req) => req.user?.id\n *\n * // Extract from custom header\n * getUserId: (req) => req.headers['x-user-id']\n * ```\n */\n getUserId: (request: TRequest) => string | Promise<string>;\n}\n\n/**\n * Injection token for Blimu configuration\n */\nexport const BLIMU_CONFIG = Symbol('BLIMU_CONFIG');\n","import {\n type CanActivate,\n type ExecutionContext,\n ForbiddenException,\n Injectable,\n SetMetadata,\n Inject,\n} from '@nestjs/common';\nimport 'reflect-metadata';\n\nimport type { EntitlementType } from '@blimu/types';\nimport { BlimuForbiddenException } from '../exceptions/blimu-forbidden.exception';\nimport { Blimu } from '@blimu/backend';\nimport { BLIMU_CONFIG, type BlimuConfig } from 'config/blimu.config';\n\nexport const ENTITLEMENT_KEY = 'entitlement';\nexport const ENTITLEMENT_METADATA_KEY = Symbol('entitlement');\n\n/**\n * Entitlement information returned by the getEntitlementInfo callback\n */\nexport interface EntitlementInfo {\n resourceId: string;\n amount?: number; // Amount to check against usage limit (for consumption)\n}\n\n/**\n * Metadata interface for entitlement checks\n */\nexport interface EntitlementMetadata<TRequest = unknown> {\n entitlementKey: EntitlementType;\n getEntitlementInfo: (request: TRequest) => EntitlementInfo | Promise<EntitlementInfo>;\n}\n\n/**\n * Sets entitlement metadata for a route handler\n * @internal This is used internally by the @Entitlement decorator\n */\nexport const SetEntitlementMetadata = <TRequest = unknown>(\n entitlementKey: string,\n getEntitlementInfo: (request: TRequest) => EntitlementInfo | Promise<EntitlementInfo>,\n): MethodDecorator =>\n SetMetadata(ENTITLEMENT_METADATA_KEY, {\n entitlementKey,\n getEntitlementInfo,\n } as EntitlementMetadata<TRequest>);\n\n/**\n * Guard that checks if the authenticated user has the required entitlement on a resource\n *\n * This guard automatically:\n * 1. Extracts the user from the request\n * 2. Extracts the resource ID using the provided extractor function\n * 3. Calls the Blimu Runtime API to check entitlements\n * 4. Allows or denies access based on the result\n */\n@Injectable()\nexport class EntitlementGuard<TRequest = unknown> implements CanActivate {\n constructor(\n @Inject(BLIMU_CONFIG)\n private readonly config: BlimuConfig<TRequest>,\n @Inject(Blimu)\n private readonly runtime: Blimu,\n ) {}\n\n async canActivate(context: ExecutionContext): Promise<boolean> {\n const request = context.switchToHttp().getRequest<TRequest>();\n const handler = context.getHandler();\n const metadata = Reflect.getMetadata(ENTITLEMENT_METADATA_KEY, handler) as\n | EntitlementMetadata<TRequest>\n | undefined;\n\n if (!metadata) {\n // No entitlement check required\n return true;\n }\n\n // Extract user ID using the configured getUserId function\n let userId: string;\n try {\n userId = await this.config.getUserId(request);\n } catch {\n throw new ForbiddenException('Failed to extract user ID from request');\n }\n\n if (!userId) {\n throw new ForbiddenException('User ID is required for entitlement check');\n }\n\n // Extract entitlement info from request\n const entitlementInfo = await metadata.getEntitlementInfo(request);\n\n if (!entitlementInfo?.resourceId) {\n throw new ForbiddenException('Resource ID is required for entitlement check');\n }\n\n try {\n // Check entitlement\n const result = await this.runtime.entitlements.checkEntitlement({\n userId,\n entitlement: metadata.entitlementKey,\n resourceId: entitlementInfo.resourceId,\n ...(entitlementInfo.amount !== undefined ? { amount: entitlementInfo.amount } : {}),\n });\n\n if (!result.allowed) {\n throw new BlimuForbiddenException(\n result,\n metadata.entitlementKey,\n entitlementInfo.resourceId,\n userId,\n );\n }\n\n return true;\n } catch (error) {\n if (error instanceof BlimuForbiddenException || error instanceof ForbiddenException) {\n throw error;\n }\n\n // Log the error for debugging but don't expose internal details\n console.error('Entitlement check failed:', error);\n throw new ForbiddenException('Failed to verify entitlements');\n }\n }\n}\n","import { ForbiddenException } from '@nestjs/common';\nimport type { Schema } from '@blimu/backend';\nimport type { EntitlementType } from '@blimu/types';\n/**\n * Custom exception for Blimu entitlement check failures\n *\n * This exception extends NestJS's ForbiddenException and includes\n * the typed EntitlementCheckResult, providing detailed information\n * about why the entitlement check failed (roles, plans, limits, etc.)\n */\nexport class BlimuForbiddenException extends ForbiddenException {\n /**\n * The entitlement check result containing detailed failure information\n */\n public readonly entitlementResult: Schema.EntitlementCheckResult;\n\n /**\n * The entitlement key that was checked\n */\n public readonly entitlementKey: EntitlementType;\n\n /**\n * The resource ID that was checked\n */\n public readonly resourceId: string;\n\n /**\n * The user ID that was checked\n */\n public readonly userId: string;\n\n constructor(\n entitlementResult: Schema.EntitlementCheckResult,\n entitlementKey: EntitlementType,\n resourceId: string,\n userId: string,\n ) {\n // Create a user-friendly message based on the failure reason\n const message = BlimuForbiddenException.buildMessage(entitlementResult, entitlementKey);\n\n super({\n message,\n entitlementResult,\n entitlementKey,\n resourceId,\n userId,\n });\n\n this.entitlementResult = entitlementResult;\n this.entitlementKey = entitlementKey;\n this.resourceId = resourceId;\n this.userId = userId;\n }\n\n /**\n * Builds a user-friendly error message from the entitlement check result\n */\n private static buildMessage(\n result: Schema.EntitlementCheckResult,\n entitlementKey: EntitlementType,\n ): string {\n const reasons: string[] = [];\n\n if (result.roles && !result.roles.allowed) {\n reasons.push(\n `Insufficient roles. Required: ${result.roles.allowedRoles?.join(', ') || 'unknown'}. User has: ${result.roles.userRoles?.join(', ') || 'none'}.`,\n );\n }\n\n if (result.plans && !result.plans.allowed) {\n reasons.push(\n `Plan restriction. Required plans: ${result.plans.allowedPlans?.join(', ') || 'unknown'}. Current plan: ${result.plans.plan || 'none'}.`,\n );\n }\n\n if (result.limit && !result.limit.allowed) {\n reasons.push(`Usage limit exceeded. ${result.limit.reason || 'Limit has been reached'}.`);\n }\n\n if (reasons.length === 0) {\n return `Access denied for entitlement: ${entitlementKey}`;\n }\n\n return `Access denied for entitlement \"${entitlementKey}\": ${reasons.join(' ')}`;\n }\n}\n","import { Inject, Injectable, Logger } from '@nestjs/common';\nimport { TokenVerifier } from '@blimu/backend';\nimport { BLIMU_CONFIG, type BlimuConfig } from '../config/blimu.config';\n\n@Injectable()\nexport class JWKService {\n private readonly logger = new Logger(JWKService.name);\n private readonly tokenVerifier: TokenVerifier;\n\n constructor(@Inject(BLIMU_CONFIG) private readonly config: BlimuConfig) {\n this.tokenVerifier = new TokenVerifier({\n runtimeApiUrl: this.config.baseURL,\n });\n }\n\n /**\n * Verify JWT token using JWKs from runtime-api\n */\n async verifyToken<T = unknown>(token: string): Promise<T> {\n try {\n this.logger.debug(\n `🔍 Verifying token. Runtime API URL: ${this.config.baseURL}, API Key prefix: ${this.config.apiKey?.substring(0, 10)}...`,\n );\n\n const result = await this.tokenVerifier.verifyToken<T>({\n secretKey: this.config.apiKey,\n token,\n runtimeApiUrl: this.config.baseURL,\n });\n\n this.logger.debug(`✅ Token verified successfully`);\n return result;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n this.logger.error(`❌ Token verification failed: ${errorMessage}`);\n if (error instanceof Error && error.stack) {\n this.logger.error(`Stack trace: ${error.stack}`);\n }\n throw error;\n }\n }\n\n /**\n * Clear cache (useful for testing or key rotation)\n */\n clearCache(): void {\n this.tokenVerifier.clearCache(this.config.apiKey);\n this.logger.debug('JWK cache cleared');\n }\n}\n","import { applyDecorators, UseGuards } from '@nestjs/common';\nimport {\n EntitlementGuard,\n SetEntitlementMetadata,\n type EntitlementInfo,\n} from '../guards/entitlement.guard';\nimport type { EntitlementType } from '@blimu/types';\n\n/**\n * Decorator to check if the authenticated user has a specific entitlement on a resource.\n *\n * This decorator combines the entitlement metadata setting and guard application\n * to provide a clean, declarative way to protect routes with entitlement checks.\n *\n * @param entitlementKey - The entitlement key to check (e.g., 'brand:read', 'organization:create_workspace')\n * @param getEntitlementInfo - Function that returns entitlement information including resourceId and optionally amount for usage limits\n *\n * @example\n * Basic usage with path parameter:\n * ```typescript\n * @Get('/:resourceId')\n * @Entitlement('brand:read', (req) => ({ resourceId: req.params.resourceId }))\n * async getBrand(@Param('resourceId') resourceId: string) {\n * // User is guaranteed to have 'brand:read' entitlement on this resource\n * }\n * ```\n *\n * @example\n * Using with typed parameters:\n * ```typescript\n * @Get('/:resourceType/:resourceId')\n * @Entitlement('workspace:delete', (req) => ({ resourceId: req.params.resourceId }))\n * async deleteResource(@Param() params: ResourceParamsDto) {\n * // User is guaranteed to have 'workspace:delete' entitlement\n * }\n * ```\n *\n * @example\n * Complex resource ID extraction:\n * ```typescript\n * @Post('/organizations/:orgId/workspaces')\n * @Entitlement('organization:create_workspace', (req) => {\n * const params = req.params as { orgId: string };\n * return { resourceId: params.orgId };\n * })\n * async createWorkspace(@Param() params: CreateWorkspaceParamsDto, @Body() body: CreateWorkspaceDto) {\n * // User is guaranteed to have 'organization:create_workspace' entitlement on the organization\n * }\n * ```\n *\n * @example\n * With usage limit consumption:\n * ```typescript\n * @Post('/api-calls')\n * @Entitlement('organization:make_api_call', (req) => ({\n * resourceId: req.params.orgId,\n * amount: req.body.apiCallsCount, // Amount to consume from usage limit\n * }))\n * async makeApiCalls(@Param('orgId') orgId: string, @Body() body: { apiCallsCount: number }) {\n * // User is guaranteed to have 'organization:make_api_call' entitlement\n * // and sufficient usage limit balance\n * }\n * ```\n *\n * @example\n * Async entitlement info extraction (e.g., from database):\n * ```typescript\n * @Delete('/items/:itemId')\n * @Entitlement('workspace:delete_item', async (req) => {\n * // You could fetch the workspace ID from your database\n * const item = await itemService.findById(req.params.itemId);\n * return { resourceId: item.workspaceId };\n * })\n * async deleteItem(@Param('itemId') itemId: string) {\n * // User is guaranteed to have 'workspace:delete_item' entitlement on the item's workspace\n * }\n * ```\n *\n * @example\n * Using with custom request type:\n * ```typescript\n * interface AuthenticatedRequest {\n * user: { id: string; email: string };\n * }\n *\n * @Get('/:resourceId')\n * @Entitlement<AuthenticatedRequest>('brand:read', (req) => {\n * // req is typed as AuthenticatedRequest, so req.user is properly typed\n * console.log(req.user.email); // TypeScript knows this exists\n * return { resourceId: req.params.resourceId };\n * })\n * async getBrand(@Param('resourceId') resourceId: string) {\n * // User is guaranteed to have 'brand:read' entitlement on this resource\n * }\n * ```\n */\nexport const Entitlement = <TRequest = unknown>(\n entitlementKey: EntitlementType,\n getEntitlementInfo: (request: TRequest) => EntitlementInfo | Promise<EntitlementInfo>,\n): MethodDecorator => {\n return applyDecorators(\n SetEntitlementMetadata<TRequest>(entitlementKey, getEntitlementInfo),\n UseGuards(EntitlementGuard),\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAOO;;;ACoDA,IAAM,eAAe,uBAAO,cAAc;;;AC3DjD,IAAAC,iBAOO;AACP,8BAAO;;;ACRP,oBAAmC;AAU5B,IAAM,0BAAN,MAAM,iCAAgC,iCAAmB;AAAA;AAAA;AAAA;AAAA,EAI9C;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEhB,YACE,mBACA,gBACA,YACA,QACA;AAEA,UAAM,UAAU,yBAAwB,aAAa,mBAAmB,cAAc;AAEtF,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,SAAK,oBAAoB;AACzB,SAAK,iBAAiB;AACtB,SAAK,aAAa;AAClB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAe,aACb,QACA,gBACQ;AACR,UAAM,UAAoB,CAAC;AAE3B,QAAI,OAAO,SAAS,CAAC,OAAO,MAAM,SAAS;AACzC,cAAQ;AAAA,QACN,iCAAiC,OAAO,MAAM,cAAc,KAAK,IAAI,KAAK,SAAS,eAAe,OAAO,MAAM,WAAW,KAAK,IAAI,KAAK,MAAM;AAAA,MAChJ;AAAA,IACF;AAEA,QAAI,OAAO,SAAS,CAAC,OAAO,MAAM,SAAS;AACzC,cAAQ;AAAA,QACN,qCAAqC,OAAO,MAAM,cAAc,KAAK,IAAI,KAAK,SAAS,mBAAmB,OAAO,MAAM,QAAQ,MAAM;AAAA,MACvI;AAAA,IACF;AAEA,QAAI,OAAO,SAAS,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,sBAAM;AAAA,cACf,QAAQ,OAAO;AAAA,cACf,SAAS,OAAO,WAAW;AAAA,cAC3B,WAAW,OAAO,aAAa;AAAA,YACjC,CAAC;AAAA,UACH;AAAA,UACA,QAAQ,CAAC,YAAY;AAAA,QACvB;AAAA;AAAA,QAEA;AAAA,QACA;AAAA,MACF;AAAA,MACA,SAAS,CAAC,kBAAkB,uBAAO,cAAc,UAAU;AAAA,IAC7D;AACA,WAAOA;AAAA,EACT;AACF;AAjNa,cAAN;AAAA,MADN,uBAAO,CAAC,CAAC;AAAA,GACG;;;AKvBb,IAAAC,iBAA2C;AAgGpC,IAAM,cAAc,CACzB,gBACA,uBACoB;AACpB,aAAO;AAAA,IACL,uBAAiC,gBAAgB,kBAAkB;AAAA,QACnE,0BAAU,gBAAgB;AAAA,EAC5B;AACF;","names":["import_common","import_common","import_common","import_backend","import_backend","config","module","import_common"]}
@@ -0,0 +1,9 @@
1
+ export { BlimuModule } from './modules/blimu.module.cjs';
2
+ export { BLIMU_CONFIG, BlimuConfig } from './config/blimu.config.cjs';
3
+ export { ENTITLEMENT_KEY, ENTITLEMENT_METADATA_KEY, EntitlementGuard, EntitlementInfo, EntitlementMetadata, SetEntitlementMetadata } from './guards/entitlement.guard.cjs';
4
+ export { Entitlement } from './decorators/entitlement.decorator.cjs';
5
+ export { BlimuForbiddenException } from './exceptions/blimu-forbidden.exception.cjs';
6
+ export { JWKService } from './services/jwk.service.cjs';
7
+ import '@nestjs/common';
8
+ import '@blimu/types';
9
+ import '@blimu/backend';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export * from './modules/blimu.module';
2
- export * from './config/blimu.config';
3
- export * from './guards/entitlement.guard';
4
- export * from './decorators/entitlement.decorator';
5
- export * from './exceptions/blimu-forbidden.exception';
6
- export * from './services';
7
- //# sourceMappingURL=index.d.ts.map
1
+ export { BlimuModule } from './modules/blimu.module.js';
2
+ export { BLIMU_CONFIG, BlimuConfig } from './config/blimu.config.js';
3
+ export { ENTITLEMENT_KEY, ENTITLEMENT_METADATA_KEY, EntitlementGuard, EntitlementInfo, EntitlementMetadata, SetEntitlementMetadata } from './guards/entitlement.guard.js';
4
+ export { Entitlement } from './decorators/entitlement.decorator.js';
5
+ export { BlimuForbiddenException } from './exceptions/blimu-forbidden.exception.js';
6
+ export { JWKService } from './services/jwk.service.js';
7
+ import '@nestjs/common';
8
+ import '@blimu/types';
9
+ import '@blimu/backend';