@blimu/backend 1.2.0 → 1.2.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.
Files changed (88) hide show
  1. package/README.md +67 -58
  2. package/dist/client.cjs +164 -14
  3. package/dist/client.cjs.map +1 -1
  4. package/dist/client.d.mts +36 -2
  5. package/dist/client.d.ts +36 -2
  6. package/dist/client.mjs +161 -11
  7. package/dist/client.mjs.map +1 -1
  8. package/dist/index.cjs +530 -236
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.mts +265 -108
  11. package/dist/index.d.ts +265 -108
  12. package/dist/index.mjs +518 -226
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/{schema-BbKn_i-U.d.mts → schema-CdEZKE7E.d.mts} +162 -39
  15. package/dist/{schema-BbKn_i-U.d.ts → schema-CdEZKE7E.d.ts} +162 -39
  16. package/dist/schema.cjs.map +1 -1
  17. package/dist/schema.d.mts +2 -1
  18. package/dist/schema.d.ts +2 -1
  19. package/dist/services/auth_jwks.cjs +69 -0
  20. package/dist/services/auth_jwks.cjs.map +1 -0
  21. package/dist/services/auth_jwks.d.mts +13 -0
  22. package/dist/services/auth_jwks.d.ts +13 -0
  23. package/dist/services/auth_jwks.mjs +44 -0
  24. package/dist/services/auth_jwks.mjs.map +1 -0
  25. package/dist/services/bulk_resources.cjs +47 -0
  26. package/dist/services/bulk_resources.cjs.map +1 -0
  27. package/dist/services/bulk_resources.d.mts +11 -0
  28. package/dist/services/bulk_resources.d.ts +11 -0
  29. package/dist/services/bulk_resources.mjs +22 -0
  30. package/dist/services/bulk_resources.mjs.map +1 -0
  31. package/dist/services/bulk_roles.cjs +47 -0
  32. package/dist/services/bulk_roles.cjs.map +1 -0
  33. package/dist/services/bulk_roles.d.mts +11 -0
  34. package/dist/services/bulk_roles.d.ts +11 -0
  35. package/dist/services/bulk_roles.mjs +22 -0
  36. package/dist/services/bulk_roles.mjs.map +1 -0
  37. package/dist/services/entitlements.cjs +71 -0
  38. package/dist/services/entitlements.cjs.map +1 -0
  39. package/dist/services/entitlements.d.mts +13 -0
  40. package/dist/services/entitlements.d.ts +13 -0
  41. package/dist/services/entitlements.mjs +46 -0
  42. package/dist/services/entitlements.mjs.map +1 -0
  43. package/dist/services/oauth.cjs +142 -0
  44. package/dist/services/oauth.cjs.map +1 -0
  45. package/dist/services/oauth.d.mts +19 -0
  46. package/dist/services/oauth.d.ts +19 -0
  47. package/dist/services/oauth.mjs +117 -0
  48. package/dist/services/oauth.mjs.map +1 -0
  49. package/dist/services/plans.cjs +69 -0
  50. package/dist/services/plans.cjs.map +1 -0
  51. package/dist/services/plans.d.mts +13 -0
  52. package/dist/services/plans.d.ts +13 -0
  53. package/dist/services/plans.mjs +44 -0
  54. package/dist/services/plans.mjs.map +1 -0
  55. package/dist/services/resource_members.cjs +47 -0
  56. package/dist/services/resource_members.cjs.map +1 -0
  57. package/dist/services/resource_members.d.mts +11 -0
  58. package/dist/services/resource_members.d.ts +11 -0
  59. package/dist/services/resource_members.mjs +22 -0
  60. package/dist/services/resource_members.mjs.map +1 -0
  61. package/dist/services/resources.cjs +93 -0
  62. package/dist/services/resources.cjs.map +1 -0
  63. package/dist/services/resources.d.mts +15 -0
  64. package/dist/services/resources.d.ts +15 -0
  65. package/dist/services/resources.mjs +68 -0
  66. package/dist/services/resources.mjs.map +1 -0
  67. package/dist/services/roles.cjs +70 -0
  68. package/dist/services/roles.cjs.map +1 -0
  69. package/dist/services/roles.d.mts +13 -0
  70. package/dist/services/roles.d.ts +13 -0
  71. package/dist/services/roles.mjs +45 -0
  72. package/dist/services/roles.mjs.map +1 -0
  73. package/dist/services/usage.cjs +95 -0
  74. package/dist/services/usage.cjs.map +1 -0
  75. package/dist/services/usage.d.mts +15 -0
  76. package/dist/services/usage.d.ts +15 -0
  77. package/dist/services/usage.mjs +70 -0
  78. package/dist/services/usage.mjs.map +1 -0
  79. package/dist/services/users.cjs +104 -0
  80. package/dist/services/users.cjs.map +1 -0
  81. package/dist/services/users.d.mts +16 -0
  82. package/dist/services/users.d.ts +16 -0
  83. package/dist/services/users.mjs +79 -0
  84. package/dist/services/users.mjs.map +1 -0
  85. package/dist/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +5 -4
  87. package/dist/client-B-ZYoU15.d.mts +0 -95
  88. package/dist/client-GKBT3WCg.d.ts +0 -95
package/dist/index.cjs CHANGED
@@ -29,14 +29,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
30
 
31
31
  // src/index.ts
32
- var src_exports = {};
33
- __export(src_exports, {
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ AuthJwksService: () => AuthJwksService,
34
35
  Blimu: () => Blimu,
35
36
  BlimuError: () => BlimuError,
36
37
  BulkResourcesService: () => BulkResourcesService,
37
38
  BulkRolesService: () => BulkRolesService,
38
39
  EntitlementsService: () => EntitlementsService,
39
- FetchError: () => import_fetch10.FetchError,
40
+ FetchError: () => import_fetch.FetchError,
40
41
  PlansService: () => PlansService,
41
42
  ResourceMembersService: () => ResourceMembersService,
42
43
  ResourcesService: () => ResourcesService,
@@ -49,15 +50,16 @@ __export(src_exports, {
49
50
  isNotUndefined: () => isNotUndefined,
50
51
  listAll: () => listAll,
51
52
  paginate: () => paginate,
52
- parseNDJSONStream: () => import_fetch12.parseNDJSONStream,
53
- parseSSEStream: () => import_fetch12.parseSSEStream,
53
+ parseNDJSONStream: () => import_fetch3.parseNDJSONStream,
54
+ parseSSEStream: () => import_fetch3.parseSSEStream,
55
+ verifyOAuthToken: () => verifyOAuthToken,
54
56
  verifyToken: () => verifyToken
55
57
  });
56
- module.exports = __toCommonJS(src_exports);
58
+ module.exports = __toCommonJS(index_exports);
57
59
 
58
60
  // src/client.ts
59
- var import_fetch10 = require("@blimu/fetch");
60
- var import_fetch11 = require("@blimu/fetch");
61
+ var import_fetch = require("@blimu/fetch");
62
+ var import_fetch2 = require("@blimu/fetch");
61
63
 
62
64
  // src/auth-strategies.ts
63
65
  function buildAuthStrategies(cfg) {
@@ -73,11 +75,46 @@ function buildAuthStrategies(cfg) {
73
75
  return authStrategies;
74
76
  }
75
77
 
76
- // src/services/bulk_resources.ts
77
- var import_fetch = require("@blimu/fetch");
78
-
79
- // src/schema.ts
80
- var schema_exports = {};
78
+ // src/services/auth_jwks.ts
79
+ var AuthJwksService = class {
80
+ constructor(core) {
81
+ this.core = core;
82
+ }
83
+ /**
84
+ * GET /v1/auth/.well-known/jwks.json*
85
+ * @summary Get JSON Web Key Set for environment (Public)*
86
+ * @description Returns the public keys used to verify JWT tokens issued by this environment. Authenticate using either x-api-key header (secretKey) or x-blimu-publishable-key header (publishableKey).*/
87
+ getJwks(init) {
88
+ return this.core.request({
89
+ method: "GET",
90
+ path: `/v1/auth/.well-known/jwks.json`,
91
+ ...init ?? {}
92
+ });
93
+ }
94
+ /**
95
+ * GET /v1/auth/.well-known/public-key.pem*
96
+ * @summary Get environment public key (PEM)*
97
+ * @description Returns the public key in PEM format for verifying JWT tokens. Authenticate with x-api-key or x-blimu-publishable-key.*/
98
+ getPublicKeyPem(init) {
99
+ return this.core.request({
100
+ method: "GET",
101
+ path: `/v1/auth/.well-known/public-key.pem`,
102
+ ...init ?? {}
103
+ });
104
+ }
105
+ /**
106
+ * GET /v1/auth/oauth/.well-known/jwks.json*
107
+ * @summary Get JSON Web Key Set for OAuth app (Public)*
108
+ * @description Returns the public key for a specific OAuth app to verify JWT tokens. This is a public endpoint following OAuth2/OIDC standards. Provide client_id to get keys for a specific OAuth app, or use authenticated endpoint for environment keys.*/
109
+ getOAuthAppJwks(query, init) {
110
+ return this.core.request({
111
+ method: "GET",
112
+ path: `/v1/auth/oauth/.well-known/jwks.json`,
113
+ query,
114
+ ...init ?? {}
115
+ });
116
+ }
117
+ };
81
118
 
82
119
  // src/services/bulk_resources.ts
83
120
  var BulkResourcesService = class {
@@ -99,7 +136,6 @@ var BulkResourcesService = class {
99
136
  };
100
137
 
101
138
  // src/services/bulk_roles.ts
102
- var import_fetch2 = require("@blimu/fetch");
103
139
  var BulkRolesService = class {
104
140
  constructor(core) {
105
141
  this.core = core;
@@ -119,7 +155,6 @@ var BulkRolesService = class {
119
155
  };
120
156
 
121
157
  // src/services/entitlements.ts
122
- var import_fetch3 = require("@blimu/fetch");
123
158
  var EntitlementsService = class {
124
159
  constructor(core) {
125
160
  this.core = core;
@@ -162,8 +197,121 @@ var EntitlementsService = class {
162
197
  }
163
198
  };
164
199
 
200
+ // src/services/oauth.ts
201
+ var OauthService = class {
202
+ constructor(core) {
203
+ this.core = core;
204
+ }
205
+ /**
206
+ * GET /v1/oauth/authorize*
207
+ * @summary Check consent requirement*
208
+ * @description Checks if user consent is required for the OAuth2 app and requested scopes.*/
209
+ checkConsentRequired(query, init) {
210
+ return this.core.request({
211
+ method: "GET",
212
+ path: `/v1/oauth/authorize`,
213
+ query,
214
+ ...init ?? {}
215
+ });
216
+ }
217
+ /**
218
+ * POST /v1/oauth/authorize*
219
+ * @summary Authorize OAuth2 application*
220
+ * @description Handles user consent approval/denial. Validates auto_approved flag against consent requirements.*/
221
+ authorize(body, init) {
222
+ return this.core.request({
223
+ method: "POST",
224
+ path: `/v1/oauth/authorize`,
225
+ body,
226
+ ...init ?? {}
227
+ });
228
+ }
229
+ /**
230
+ * POST /v1/oauth/device/authorize*
231
+ * @summary Authorize or deny device code*
232
+ * @description Allows an authenticated user to authorize or deny a device code request. Requires valid user session.*/
233
+ authorizeDeviceCode(body, init) {
234
+ return this.core.request({
235
+ method: "POST",
236
+ path: `/v1/oauth/device/authorize`,
237
+ body,
238
+ ...init ?? {}
239
+ });
240
+ }
241
+ /**
242
+ * POST /v1/oauth/device/code*
243
+ * @summary Request device authorization codes*
244
+ * @description Initiates device authorization flow. Returns device_code (for polling) and user_code (for user entry).*/
245
+ requestDeviceCode(body, init) {
246
+ return this.core.request({
247
+ method: "POST",
248
+ path: `/v1/oauth/device/code`,
249
+ body,
250
+ ...init ?? {}
251
+ });
252
+ }
253
+ /**
254
+ * GET /v1/oauth/device/code/{user_code}*
255
+ * @summary Get device code information*
256
+ * @description Returns device code information including app name, scopes, and consent requirement status.*/
257
+ getDeviceCodeInfo(user_code, init) {
258
+ return this.core.request({
259
+ method: "GET",
260
+ path: `/v1/oauth/device/code/${encodeURIComponent(user_code)}`,
261
+ ...init ?? {}
262
+ });
263
+ }
264
+ /**
265
+ * POST /v1/oauth/device/token*
266
+ * @summary Poll for device authorization tokens*
267
+ * @description Client polls this endpoint to exchange device_code for tokens once user has authorized.*/
268
+ exchangeDeviceCode(body, init) {
269
+ return this.core.request({
270
+ method: "POST",
271
+ path: `/v1/oauth/device/token`,
272
+ body,
273
+ ...init ?? {}
274
+ });
275
+ }
276
+ /**
277
+ * POST /v1/oauth/introspect*
278
+ * @summary Introspect token*
279
+ * @description Validates a token and returns metadata. Requires client authentication.*/
280
+ introspect(body, init) {
281
+ return this.core.request({
282
+ method: "POST",
283
+ path: `/v1/oauth/introspect`,
284
+ body,
285
+ ...init ?? {}
286
+ });
287
+ }
288
+ /**
289
+ * POST /v1/oauth/revoke*
290
+ * @summary Revoke token*
291
+ * @description Revokes an access or refresh token. Requires client authentication.*/
292
+ revoke(body, init) {
293
+ return this.core.request({
294
+ method: "POST",
295
+ path: `/v1/oauth/revoke`,
296
+ body,
297
+ ...init ?? {}
298
+ });
299
+ }
300
+ /**
301
+ * POST /v1/oauth/token*
302
+ * @summary Token endpoint*
303
+ * @description Issues access and refresh tokens. Supports authorization_code and refresh_token (always available per OAuth2 spec).*/
304
+ token(body, init) {
305
+ return this.core.request({
306
+ method: "POST",
307
+ path: `/v1/oauth/token`,
308
+ body,
309
+ ...init ?? {}
310
+ });
311
+ }
312
+ };
313
+
165
314
  // src/services/plans.ts
166
- var import_fetch4 = require("@blimu/fetch");
167
315
  var PlansService = class {
168
316
  constructor(core) {
169
317
  this.core = core;
@@ -205,7 +353,6 @@ var PlansService = class {
205
353
  };
206
354
 
207
355
  // src/services/resource_members.ts
208
- var import_fetch5 = require("@blimu/fetch");
209
356
  var ResourceMembersService = class {
210
357
  constructor(core) {
211
358
  this.core = core;
@@ -225,7 +372,6 @@ var ResourceMembersService = class {
225
372
  };
226
373
 
227
374
  // src/services/resources.ts
228
- var import_fetch6 = require("@blimu/fetch");
229
375
  var ResourcesService = class {
230
376
  constructor(core) {
231
377
  this.core = core;
@@ -291,7 +437,6 @@ var ResourcesService = class {
291
437
  };
292
438
 
293
439
  // src/services/roles.ts
294
- var import_fetch7 = require("@blimu/fetch");
295
440
  var RolesService = class {
296
441
  constructor(core) {
297
442
  this.core = core;
@@ -334,7 +479,6 @@ var RolesService = class {
334
479
  };
335
480
 
336
481
  // src/services/usage.ts
337
- var import_fetch8 = require("@blimu/fetch");
338
482
  var UsageService = class {
339
483
  constructor(core) {
340
484
  this.core = core;
@@ -402,7 +546,6 @@ var UsageService = class {
402
546
  };
403
547
 
404
548
  // src/services/users.ts
405
- var import_fetch9 = require("@blimu/fetch");
406
549
  var UsersService = class {
407
550
  constructor(core) {
408
551
  this.core = core;
@@ -480,9 +623,11 @@ var UsersService = class {
480
623
 
481
624
  // src/client.ts
482
625
  var Blimu = class {
626
+ authJwks;
483
627
  bulkResources;
484
628
  bulkRoles;
485
629
  entitlements;
630
+ oauth;
486
631
  plans;
487
632
  resourceMembers;
488
633
  resources;
@@ -493,14 +638,16 @@ var Blimu = class {
493
638
  const restCfg = { ...options ?? {} };
494
639
  delete restCfg.apiKey;
495
640
  const authStrategies = buildAuthStrategies(options ?? {});
496
- const core = new import_fetch10.FetchClient({
641
+ const core = new import_fetch.FetchClient({
497
642
  ...restCfg,
498
643
  baseURL: options?.baseURL ?? "https://api.blimu.dev",
499
644
  ...authStrategies.length > 0 ? { authStrategies } : {}
500
645
  });
646
+ this.authJwks = new AuthJwksService(core);
501
647
  this.bulkResources = new BulkResourcesService(core);
502
648
  this.bulkRoles = new BulkRolesService(core);
503
649
  this.entitlements = new EntitlementsService(core);
650
+ this.oauth = new OauthService(core);
504
651
  this.plans = new PlansService(core);
505
652
  this.resourceMembers = new ResourceMembersService(core);
506
653
  this.resources = new ResourcesService(core);
@@ -509,13 +656,13 @@ var Blimu = class {
509
656
  this.users = new UsersService(core);
510
657
  }
511
658
  };
512
- var BlimuError = import_fetch10.FetchError;
659
+ var BlimuError = import_fetch.FetchError;
513
660
 
514
661
  // src/index.ts
515
- __reExport(src_exports, require("@blimu/fetch"), module.exports);
662
+ __reExport(index_exports, require("@blimu/fetch"), module.exports);
516
663
 
517
664
  // src/utils.ts
518
- var import_fetch12 = require("@blimu/fetch");
665
+ var import_fetch3 = require("@blimu/fetch");
519
666
  async function* paginate(fetchPage, initialQuery = {}, pageSize = 100) {
520
667
  let offset = Number(initialQuery.offset ?? 0);
521
668
  const limit = Number(initialQuery.limit ?? pageSize);
@@ -541,19 +688,37 @@ function isNotUndefined(arr) {
541
688
  );
542
689
  }
543
690
 
691
+ // src/schema.ts
692
+ var schema_exports = {};
693
+
544
694
  // src/schema.zod.ts
545
695
  var schema_zod_exports = {};
546
696
  __export(schema_zod_exports, {
697
+ AuthJwksGetOAuthAppJwksQuerySchema: () => AuthJwksGetOAuthAppJwksQuerySchema,
698
+ AuthorizeRequestSchema: () => AuthorizeRequestSchema,
547
699
  BalanceResponseSchema: () => BalanceResponseSchema,
548
700
  CheckLimitResponseSchema: () => CheckLimitResponseSchema,
701
+ ConsentCheckResponseSchema: () => ConsentCheckResponseSchema,
702
+ DeviceAuthorizeRequestSchema: () => DeviceAuthorizeRequestSchema,
703
+ DeviceAuthorizeResponseSchema: () => DeviceAuthorizeResponseSchema,
704
+ DeviceCodeInfoResponseSchema: () => DeviceCodeInfoResponseSchema,
705
+ DeviceCodeRequestSchema: () => DeviceCodeRequestSchema,
706
+ DeviceCodeResponseSchema: () => DeviceCodeResponseSchema,
707
+ DeviceTokenRequestSchema: () => DeviceTokenRequestSchema,
549
708
  EntitlementCheckBodySchema: () => EntitlementCheckBodySchema,
550
709
  EntitlementCheckResultSchema: () => EntitlementCheckResultSchema,
710
+ EntitlementTypeSchema: () => EntitlementTypeSchema,
551
711
  EntitlementsListForResourceQuerySchema: () => EntitlementsListForResourceQuerySchema,
552
712
  EntitlementsListForTenantQuerySchema: () => EntitlementsListForTenantQuerySchema,
553
713
  EntitlementsListResultSchema: () => EntitlementsListResultSchema,
714
+ IntrospectionRequestSchema: () => IntrospectionRequestSchema,
715
+ IntrospectionResponseSchema: () => IntrospectionResponseSchema,
716
+ JWKSchema: () => JWKSchema,
717
+ OauthCheckConsentRequiredQuerySchema: () => OauthCheckConsentRequiredQuerySchema,
554
718
  PlanAssignBodySchema: () => PlanAssignBodySchema,
555
719
  PlanDeleteResponseSchema: () => PlanDeleteResponseSchema,
556
720
  PlanResponseSchema: () => PlanResponseSchema,
721
+ PlanTypeSchema: () => PlanTypeSchema,
557
722
  ResourceBulkCreateBodySchema: () => ResourceBulkCreateBodySchema,
558
723
  ResourceBulkResultSchema: () => ResourceBulkResultSchema,
559
724
  ResourceCreateBodySchema: () => ResourceCreateBodySchema,
@@ -561,20 +726,25 @@ __export(schema_zod_exports, {
561
726
  ResourceMemberListSchema: () => ResourceMemberListSchema,
562
727
  ResourceMembersListQuerySchema: () => ResourceMembersListQuerySchema,
563
728
  ResourceSchema: () => ResourceSchema,
729
+ ResourceTypeSchema: () => ResourceTypeSchema,
564
730
  ResourceUpdateBodySchema: () => ResourceUpdateBodySchema,
565
731
  ResourcesListQuerySchema: () => ResourcesListQuerySchema,
732
+ RevocationRequestSchema: () => RevocationRequestSchema,
566
733
  RoleBulkCreateBodySchema: () => RoleBulkCreateBodySchema,
567
734
  RoleBulkResultSchema: () => RoleBulkResultSchema,
568
735
  RoleCreateBodySchema: () => RoleCreateBodySchema,
569
736
  RoleListSchema: () => RoleListSchema,
570
737
  RoleSchema: () => RoleSchema,
571
738
  RolesListQuerySchema: () => RolesListQuerySchema,
739
+ TokenRequestSchema: () => TokenRequestSchema,
740
+ TokenResponseSchema: () => TokenResponseSchema,
572
741
  TransactionHistoryResponseSchema: () => TransactionHistoryResponseSchema,
573
742
  UsageCheckBodySchema: () => UsageCheckBodySchema,
574
743
  UsageConsumeBodySchema: () => UsageConsumeBodySchema,
575
744
  UsageCreditBodySchema: () => UsageCreditBodySchema,
576
745
  UsageGetBalanceQuerySchema: () => UsageGetBalanceQuerySchema,
577
746
  UsageGetTransactionHistoryQuerySchema: () => UsageGetTransactionHistoryQuerySchema,
747
+ UsageLimitTypeSchema: () => UsageLimitTypeSchema,
578
748
  UsageWalletResponseSchema: () => UsageWalletResponseSchema,
579
749
  UserCreateBodySchema: () => UserCreateBodySchema,
580
750
  UserListSchema: () => UserListSchema,
@@ -584,6 +754,32 @@ __export(schema_zod_exports, {
584
754
  UsersListQuerySchema: () => UsersListQuerySchema
585
755
  });
586
756
  var import_zod = require("zod");
757
+ var EntitlementTypeSchema = import_zod.z.string();
758
+ var PlanTypeSchema = import_zod.z.string();
759
+ var ResourceTypeSchema = import_zod.z.string();
760
+ var UsageLimitTypeSchema = import_zod.z.string();
761
+ var AuthorizeRequestSchema = import_zod.z.object({
762
+ /** Action to take: allow or deny */
763
+ action: import_zod.z.enum(["allow", "deny"]),
764
+ /** True if consent was auto-approved (not required or previously granted) */
765
+ auto_approved: import_zod.z.boolean().optional(),
766
+ /** OAuth2 client ID */
767
+ client_id: import_zod.z.string(),
768
+ /** PKCE code challenge */
769
+ code_challenge: import_zod.z.string().optional(),
770
+ /** PKCE code challenge method */
771
+ code_challenge_method: import_zod.z.string().optional(),
772
+ /** Redirect URI */
773
+ redirect_uri: import_zod.z.string(),
774
+ /** Response type (typically "code") */
775
+ response_type: import_zod.z.string(),
776
+ /** Space-separated list of scopes */
777
+ scope: import_zod.z.string().optional(),
778
+ /** State parameter for CSRF protection */
779
+ state: import_zod.z.string().optional(),
780
+ /** True if user explicitly clicked Allow, false if auto-approved */
781
+ user_action: import_zod.z.boolean().optional()
782
+ });
587
783
  var BalanceResponseSchema = import_zod.z.object({ balance: import_zod.z.number() });
588
784
  var CheckLimitResponseSchema = import_zod.z.object({
589
785
  allowed: import_zod.z.boolean(),
@@ -591,9 +787,216 @@ var CheckLimitResponseSchema = import_zod.z.object({
591
787
  remaining: import_zod.z.number().optional(),
592
788
  requested: import_zod.z.number()
593
789
  });
790
+ var ConsentCheckResponseSchema = import_zod.z.object({
791
+ /** Whether user consent is required */
792
+ consent_required: import_zod.z.boolean(),
793
+ /** Whether consent was previously granted for this app and scopes */
794
+ previously_granted: import_zod.z.boolean()
795
+ });
796
+ var DeviceAuthorizeRequestSchema = import_zod.z.object({
797
+ /** Action to take: allow or deny */
798
+ action: import_zod.z.enum(["allow", "deny"]),
799
+ /** True if consent was auto-approved (not required or previously granted) */
800
+ auto_approved: import_zod.z.boolean().optional(),
801
+ /** True if user explicitly clicked Allow, false if auto-approved */
802
+ user_action: import_zod.z.boolean().optional(),
803
+ /** The user code displayed to the user */
804
+ user_code: import_zod.z.string()
805
+ });
806
+ var DeviceAuthorizeResponseSchema = import_zod.z.object({
807
+ /** Whether the authorization was successful */
808
+ success: import_zod.z.boolean()
809
+ });
810
+ var DeviceCodeInfoResponseSchema = import_zod.z.object({
811
+ /** The name of the OAuth2 application */
812
+ appName: import_zod.z.string(),
813
+ /** Whether the user has already granted consent for this app and scopes */
814
+ previouslyGranted: import_zod.z.boolean(),
815
+ /** Whether the app requires user consent */
816
+ requireConsent: import_zod.z.boolean(),
817
+ /** The scopes requested by the device code */
818
+ scopes: import_zod.z.string().array()
819
+ });
820
+ var DeviceCodeRequestSchema = import_zod.z.object({
821
+ /** OAuth2 client ID */
822
+ client_id: import_zod.z.string(),
823
+ /** PKCE code challenge (base64url encoded SHA256 hash) */
824
+ code_challenge: import_zod.z.string().optional(),
825
+ /** PKCE code challenge method */
826
+ code_challenge_method: import_zod.z.enum(["S256", "plain"]).optional(),
827
+ /** Space-separated list of scopes */
828
+ scope: import_zod.z.string().optional()
829
+ });
830
+ var DeviceCodeResponseSchema = import_zod.z.object({
831
+ /** Device verification code (for polling) */
832
+ device_code: import_zod.z.string(),
833
+ /** Device code expiration time in seconds */
834
+ expires_in: import_zod.z.number(),
835
+ /** Minimum polling interval in seconds */
836
+ interval: import_zod.z.number(),
837
+ /** User verification code (short, human-readable) */
838
+ user_code: import_zod.z.string(),
839
+ /** Verification URI for user */
840
+ verification_uri: import_zod.z.string(),
841
+ /** Complete verification URI with user code */
842
+ verification_uri_complete: import_zod.z.string()
843
+ });
844
+ var DeviceTokenRequestSchema = import_zod.z.object({
845
+ /** OAuth2 client ID */
846
+ client_id: import_zod.z.string(),
847
+ /** PKCE code verifier (if challenge was provided) */
848
+ code_verifier: import_zod.z.string().optional(),
849
+ /** Device code from authorization response */
850
+ device_code: import_zod.z.string(),
851
+ /** Grant type (must be device_code) */
852
+ grant_type: import_zod.z.enum([
853
+ "urn:ietf:params:oauth:grant-type:device_code"
854
+ ])
855
+ });
856
+ var IntrospectionRequestSchema = import_zod.z.object({
857
+ /** The token to introspect */
858
+ token: import_zod.z.string(),
859
+ /** Hint about token type */
860
+ token_type_hint: import_zod.z.enum(["access_token", "refresh_token"]).optional()
861
+ });
862
+ var IntrospectionResponseSchema = import_zod.z.object({
863
+ /** Whether the token is active */
864
+ active: import_zod.z.boolean(),
865
+ /** Client ID */
866
+ client_id: import_zod.z.string().optional(),
867
+ /** Environment ID */
868
+ environment_id: import_zod.z.string().optional(),
869
+ /** Token expiration timestamp */
870
+ exp: import_zod.z.number().optional(),
871
+ /** Token issued at timestamp */
872
+ iat: import_zod.z.number().optional(),
873
+ /** Space-separated list of scopes */
874
+ scope: import_zod.z.string().optional(),
875
+ /** Subject (user ID) */
876
+ sub: import_zod.z.string().optional(),
877
+ /** Token type */
878
+ token_type: import_zod.z.string().optional(),
879
+ /** Username or user ID */
880
+ username: import_zod.z.string().optional()
881
+ });
882
+ var JWKSchema = import_zod.z.object({
883
+ keys: import_zod.z.object({
884
+ alg: import_zod.z.string(),
885
+ e: import_zod.z.string(),
886
+ kid: import_zod.z.string(),
887
+ kty: import_zod.z.string(),
888
+ n: import_zod.z.string(),
889
+ use: import_zod.z.string()
890
+ }).array()
891
+ });
892
+ var PlanDeleteResponseSchema = import_zod.z.object({ success: import_zod.z.boolean() });
893
+ var ResourceMemberListSchema = import_zod.z.object({
894
+ items: import_zod.z.object({
895
+ inherited: import_zod.z.boolean(),
896
+ role: import_zod.z.string(),
897
+ user: import_zod.z.object({
898
+ avatarUrl: import_zod.z.string().nullable(),
899
+ createdAt: import_zod.z.iso.datetime(),
900
+ email: import_zod.z.email(),
901
+ emailVerified: import_zod.z.boolean(),
902
+ firstName: import_zod.z.string().nullable(),
903
+ id: import_zod.z.string(),
904
+ lastLoginAt: import_zod.z.iso.datetime().nullable(),
905
+ lastName: import_zod.z.string().nullable(),
906
+ lookupKey: import_zod.z.string().nullable(),
907
+ updatedAt: import_zod.z.iso.datetime()
908
+ }),
909
+ userId: import_zod.z.string()
910
+ }).array(),
911
+ limit: import_zod.z.number(),
912
+ page: import_zod.z.number(),
913
+ total: import_zod.z.number()
914
+ });
915
+ var RevocationRequestSchema = import_zod.z.object({
916
+ /** The token to revoke */
917
+ token: import_zod.z.string(),
918
+ /** Hint about token type */
919
+ token_type_hint: import_zod.z.enum(["access_token", "refresh_token"]).optional()
920
+ });
921
+ var TokenRequestSchema = import_zod.z.object({
922
+ /** OAuth2 client ID */
923
+ client_id: import_zod.z.string(),
924
+ /** OAuth2 client secret (required for confidential clients) */
925
+ client_secret: import_zod.z.string().optional(),
926
+ /** Authorization code (required for authorization_code grant) */
927
+ code: import_zod.z.string().optional(),
928
+ /** PKCE code verifier (if challenge was provided) */
929
+ code_verifier: import_zod.z.string().optional(),
930
+ /** OAuth2 grant type */
931
+ grant_type: import_zod.z.enum(["authorization_code", "refresh_token"]),
932
+ /** Redirect URI (required for authorization_code grant) */
933
+ redirect_uri: import_zod.z.string().optional(),
934
+ /** Refresh token (required for refresh_token grant) */
935
+ refresh_token: import_zod.z.string().optional(),
936
+ /** Space-separated list of scopes (optional for refresh) */
937
+ scope: import_zod.z.string().optional()
938
+ });
939
+ var TokenResponseSchema = import_zod.z.object({
940
+ /** Access token (JWT) */
941
+ access_token: import_zod.z.string(),
942
+ /** Access token expiration time in seconds */
943
+ expires_in: import_zod.z.number(),
944
+ /** Refresh token (for obtaining new access tokens) */
945
+ refresh_token: import_zod.z.string(),
946
+ /** Space-separated list of granted scopes */
947
+ scope: import_zod.z.string().optional(),
948
+ /** Token type */
949
+ token_type: import_zod.z.string()
950
+ });
951
+ var UserSchema = import_zod.z.object({
952
+ avatarUrl: import_zod.z.string().nullable(),
953
+ createdAt: import_zod.z.iso.datetime(),
954
+ email: import_zod.z.email(),
955
+ emailVerified: import_zod.z.boolean(),
956
+ firstName: import_zod.z.string().nullable(),
957
+ id: import_zod.z.string(),
958
+ lastLoginAt: import_zod.z.iso.datetime().nullable(),
959
+ lastName: import_zod.z.string().nullable(),
960
+ lookupKey: import_zod.z.string().nullable(),
961
+ updatedAt: import_zod.z.iso.datetime()
962
+ });
963
+ var UserCreateBodySchema = import_zod.z.object({
964
+ avatarUrl: import_zod.z.url().optional(),
965
+ email: import_zod.z.email(),
966
+ firstName: import_zod.z.string().nullable().optional(),
967
+ lastName: import_zod.z.string().nullable().optional(),
968
+ lookupKey: import_zod.z.string(),
969
+ newUser: import_zod.z.boolean().nullable().optional(),
970
+ password: import_zod.z.string().nullable().optional()
971
+ });
972
+ var UserListSchema = import_zod.z.object({
973
+ items: import_zod.z.object({
974
+ avatarUrl: import_zod.z.string().nullable(),
975
+ createdAt: import_zod.z.iso.datetime(),
976
+ email: import_zod.z.email(),
977
+ emailVerified: import_zod.z.boolean(),
978
+ firstName: import_zod.z.string().nullable(),
979
+ id: import_zod.z.string(),
980
+ lastLoginAt: import_zod.z.iso.datetime().nullable(),
981
+ lastName: import_zod.z.string().nullable(),
982
+ lookupKey: import_zod.z.string().nullable(),
983
+ updatedAt: import_zod.z.iso.datetime()
984
+ }).array(),
985
+ limit: import_zod.z.number(),
986
+ page: import_zod.z.number(),
987
+ total: import_zod.z.number()
988
+ });
989
+ var UserUpdateBodySchema = import_zod.z.object({
990
+ avatarUrl: import_zod.z.url().nullable().optional(),
991
+ email: import_zod.z.email().optional(),
992
+ firstName: import_zod.z.string().nullable().optional(),
993
+ lastName: import_zod.z.string().nullable().optional(),
994
+ lookupKey: import_zod.z.string().optional(),
995
+ password: import_zod.z.string().optional()
996
+ });
594
997
  var EntitlementCheckBodySchema = import_zod.z.object({
595
998
  amount: import_zod.z.number().int().optional(),
596
- entitlement: import_zod.z.string(),
999
+ entitlement: EntitlementTypeSchema,
597
1000
  resourceId: import_zod.z.string(),
598
1001
  userId: import_zod.z.string()
599
1002
  });
@@ -603,15 +1006,15 @@ var EntitlementCheckResultSchema = import_zod.z.object({
603
1006
  allowed: import_zod.z.boolean(),
604
1007
  current: import_zod.z.number().optional(),
605
1008
  limit: import_zod.z.number().optional(),
606
- plan: import_zod.z.string().nullable().optional(),
1009
+ plan: PlanTypeSchema.optional(),
607
1010
  reason: import_zod.z.string().optional(),
608
1011
  remaining: import_zod.z.number().optional(),
609
1012
  scope: import_zod.z.string().optional()
610
1013
  }).nullable().optional(),
611
1014
  plans: import_zod.z.object({
612
1015
  allowed: import_zod.z.boolean(),
613
- allowedPlans: import_zod.z.string().array().optional(),
614
- plan: import_zod.z.string().nullable().optional(),
1016
+ allowedPlans: PlanTypeSchema.array().optional(),
1017
+ plan: PlanTypeSchema.optional(),
615
1018
  reason: import_zod.z.string().optional()
616
1019
  }).nullable().optional(),
617
1020
  roles: import_zod.z.object({
@@ -621,30 +1024,29 @@ var EntitlementCheckResultSchema = import_zod.z.object({
621
1024
  userRoles: import_zod.z.string().array().optional()
622
1025
  }).nullable().optional()
623
1026
  });
1027
+ var PlanAssignBodySchema = import_zod.z.object({ planKey: PlanTypeSchema });
624
1028
  var EntitlementsListResultSchema = import_zod.z.object({
625
1029
  results: import_zod.z.object({
626
1030
  entitlements: import_zod.z.object({
627
1031
  allowed: import_zod.z.boolean(),
628
1032
  allowedByPlan: import_zod.z.boolean(),
629
1033
  allowedByRole: import_zod.z.boolean(),
630
- allowedPlans: import_zod.z.string().array().optional(),
1034
+ allowedPlans: PlanTypeSchema.array().optional(),
631
1035
  allowedRoles: import_zod.z.string().array(),
632
- currentPlan: import_zod.z.string().optional(),
1036
+ currentPlan: PlanTypeSchema.optional(),
633
1037
  currentRole: import_zod.z.string().optional(),
634
- entitlement: import_zod.z.string()
1038
+ entitlement: EntitlementTypeSchema
635
1039
  }).array(),
636
1040
  resourceId: import_zod.z.string(),
637
- resourceType: import_zod.z.string()
1041
+ resourceType: ResourceTypeSchema
638
1042
  }).array()
639
1043
  });
640
- var PlanAssignBodySchema = import_zod.z.object({ planKey: import_zod.z.string() });
641
- var PlanDeleteResponseSchema = import_zod.z.object({ success: import_zod.z.boolean() });
642
1044
  var PlanResponseSchema = import_zod.z.object({
643
1045
  createdAt: import_zod.z.iso.datetime(),
644
1046
  environmentId: import_zod.z.string(),
645
- planKey: import_zod.z.string(),
1047
+ planKey: PlanTypeSchema,
646
1048
  resourceId: import_zod.z.string(),
647
- resourceType: import_zod.z.string(),
1049
+ resourceType: ResourceTypeSchema,
648
1050
  updatedAt: import_zod.z.iso.datetime()
649
1051
  });
650
1052
  var ResourceSchema = import_zod.z.object({
@@ -653,9 +1055,9 @@ var ResourceSchema = import_zod.z.object({
653
1055
  name: import_zod.z.string().nullable(),
654
1056
  parents: import_zod.z.object({
655
1057
  id: import_zod.z.string(),
656
- type: import_zod.z.string()
1058
+ type: ResourceTypeSchema
657
1059
  }).array().optional(),
658
- type: import_zod.z.string()
1060
+ type: ResourceTypeSchema
659
1061
  });
660
1062
  var ResourceBulkCreateBodySchema = import_zod.z.object({
661
1063
  resources: import_zod.z.object({
@@ -663,7 +1065,7 @@ var ResourceBulkCreateBodySchema = import_zod.z.object({
663
1065
  name: import_zod.z.string().optional(),
664
1066
  parents: import_zod.z.object({
665
1067
  id: import_zod.z.string(),
666
- type: import_zod.z.string()
1068
+ type: ResourceTypeSchema
667
1069
  }).array().optional(),
668
1070
  roles: import_zod.z.object({
669
1071
  role: import_zod.z.string(),
@@ -675,7 +1077,7 @@ var ResourceBulkResultSchema = import_zod.z.object({
675
1077
  created: import_zod.z.object({
676
1078
  environmentId: import_zod.z.string(),
677
1079
  id: import_zod.z.string(),
678
- type: import_zod.z.string()
1080
+ type: ResourceTypeSchema
679
1081
  }).array(),
680
1082
  errors: import_zod.z.object({
681
1083
  error: import_zod.z.string(),
@@ -685,7 +1087,7 @@ var ResourceBulkResultSchema = import_zod.z.object({
685
1087
  name: import_zod.z.string().optional(),
686
1088
  parents: import_zod.z.object({
687
1089
  id: import_zod.z.string(),
688
- type: import_zod.z.string()
1090
+ type: ResourceTypeSchema
689
1091
  }).array().optional(),
690
1092
  roles: import_zod.z.object({
691
1093
  role: import_zod.z.string(),
@@ -705,55 +1107,33 @@ var ResourceCreateBodySchema = import_zod.z.object({
705
1107
  name: import_zod.z.string().optional(),
706
1108
  parents: import_zod.z.object({
707
1109
  id: import_zod.z.string(),
708
- type: import_zod.z.string()
1110
+ type: ResourceTypeSchema
709
1111
  }).array().optional(),
710
1112
  roles: import_zod.z.object({
711
1113
  role: import_zod.z.string(),
712
1114
  userId: import_zod.z.string()
713
1115
  }).array().optional()
714
1116
  });
715
- var ResourceMemberListSchema = import_zod.z.object({
716
- items: import_zod.z.object({
717
- inherited: import_zod.z.boolean(),
718
- role: import_zod.z.string(),
719
- user: import_zod.z.object({
720
- avatarUrl: import_zod.z.string().nullable(),
721
- createdAt: import_zod.z.iso.datetime(),
722
- email: import_zod.z.email(),
723
- emailVerified: import_zod.z.boolean(),
724
- firstName: import_zod.z.string().nullable(),
725
- id: import_zod.z.string(),
726
- lastLoginAt: import_zod.z.iso.datetime().nullable(),
727
- lastName: import_zod.z.string().nullable(),
728
- lookupKey: import_zod.z.string().nullable(),
729
- updatedAt: import_zod.z.iso.datetime()
730
- }),
731
- userId: import_zod.z.string()
732
- }).array(),
733
- limit: import_zod.z.number(),
734
- page: import_zod.z.number(),
735
- total: import_zod.z.number()
736
- });
737
1117
  var ResourceUpdateBodySchema = import_zod.z.object({
738
1118
  name: import_zod.z.string().optional(),
739
1119
  /** Creates relationships with other resources. Parent resources must already exist. */
740
1120
  parents: import_zod.z.object({
741
1121
  id: import_zod.z.string(),
742
- type: import_zod.z.string()
1122
+ type: ResourceTypeSchema
743
1123
  }).array().optional()
744
1124
  });
745
1125
  var RoleSchema = import_zod.z.object({
746
1126
  createdAt: import_zod.z.string(),
747
1127
  environmentId: import_zod.z.string(),
748
1128
  resourceId: import_zod.z.string(),
749
- resourceType: import_zod.z.string(),
1129
+ resourceType: ResourceTypeSchema,
750
1130
  role: import_zod.z.string(),
751
1131
  userId: import_zod.z.string()
752
1132
  });
753
1133
  var RoleBulkCreateBodySchema = import_zod.z.object({
754
1134
  roles: import_zod.z.object({
755
1135
  resourceId: import_zod.z.string(),
756
- resourceType: import_zod.z.string(),
1136
+ resourceType: ResourceTypeSchema,
757
1137
  role: import_zod.z.string(),
758
1138
  userId: import_zod.z.string()
759
1139
  }).array()
@@ -763,7 +1143,7 @@ var RoleBulkResultSchema = import_zod.z.object({
763
1143
  createdAt: import_zod.z.string(),
764
1144
  environmentId: import_zod.z.string(),
765
1145
  resourceId: import_zod.z.string(),
766
- resourceType: import_zod.z.string(),
1146
+ resourceType: ResourceTypeSchema,
767
1147
  role: import_zod.z.string(),
768
1148
  userId: import_zod.z.string()
769
1149
  }).array(),
@@ -772,7 +1152,7 @@ var RoleBulkResultSchema = import_zod.z.object({
772
1152
  index: import_zod.z.number(),
773
1153
  role: import_zod.z.object({
774
1154
  resourceId: import_zod.z.string(),
775
- resourceType: import_zod.z.string(),
1155
+ resourceType: ResourceTypeSchema,
776
1156
  role: import_zod.z.string(),
777
1157
  userId: import_zod.z.string()
778
1158
  })
@@ -786,7 +1166,7 @@ var RoleBulkResultSchema = import_zod.z.object({
786
1166
  });
787
1167
  var RoleCreateBodySchema = import_zod.z.object({
788
1168
  resourceId: import_zod.z.string(),
789
- resourceType: import_zod.z.string(),
1169
+ resourceType: ResourceTypeSchema,
790
1170
  role: import_zod.z.string()
791
1171
  });
792
1172
  var RoleListSchema = import_zod.z.object({
@@ -796,43 +1176,58 @@ var RoleListSchema = import_zod.z.object({
796
1176
  createdAt: import_zod.z.string(),
797
1177
  environmentId: import_zod.z.string(),
798
1178
  resourceId: import_zod.z.string(),
799
- resourceType: import_zod.z.string(),
1179
+ resourceType: ResourceTypeSchema,
800
1180
  role: import_zod.z.string(),
801
1181
  userId: import_zod.z.string()
802
1182
  }).array(),
803
1183
  total: import_zod.z.number()
804
1184
  });
1185
+ var UserResourceListSchema = import_zod.z.array(
1186
+ import_zod.z.object({
1187
+ inherited: import_zod.z.boolean(),
1188
+ resource: import_zod.z.object({
1189
+ id: import_zod.z.string(),
1190
+ name: import_zod.z.string(),
1191
+ parents: import_zod.z.object({
1192
+ id: import_zod.z.string(),
1193
+ type: ResourceTypeSchema
1194
+ }).array(),
1195
+ type: ResourceTypeSchema
1196
+ }).catchall(import_zod.z.unknown()),
1197
+ role: import_zod.z.string()
1198
+ })
1199
+ );
805
1200
  var TransactionHistoryResponseSchema = import_zod.z.object({
806
1201
  items: import_zod.z.object({
807
1202
  amount: import_zod.z.number().int(),
808
1203
  createdAt: import_zod.z.iso.datetime(),
809
1204
  environmentId: import_zod.z.string(),
810
1205
  id: import_zod.z.string(),
811
- limitType: import_zod.z.string(),
1206
+ limitType: UsageLimitTypeSchema,
812
1207
  resourceId: import_zod.z.string(),
813
- resourceType: import_zod.z.string(),
1208
+ resourceType: ResourceTypeSchema,
814
1209
  tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable()
815
1210
  }).array()
816
1211
  });
817
1212
  var UsageCheckBodySchema = import_zod.z.object({
818
1213
  amount: import_zod.z.number().int(),
819
- limitType: import_zod.z.string(),
1214
+ limitType: UsageLimitTypeSchema,
820
1215
  period: import_zod.z.enum(["monthly", "yearly", "lifetime"]),
821
1216
  resourceId: import_zod.z.string(),
822
- resourceType: import_zod.z.string()
1217
+ resourceType: ResourceTypeSchema
823
1218
  });
824
1219
  var UsageConsumeBodySchema = import_zod.z.object({
825
1220
  amount: import_zod.z.number().int(),
826
- limitType: import_zod.z.string(),
1221
+ limitType: UsageLimitTypeSchema,
827
1222
  resourceId: import_zod.z.string(),
828
- resourceType: import_zod.z.string(),
1223
+ resourceType: ResourceTypeSchema,
829
1224
  tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
830
1225
  });
831
1226
  var UsageCreditBodySchema = import_zod.z.object({
832
1227
  amount: import_zod.z.number().int(),
833
- limitType: import_zod.z.string(),
1228
+ limitType: UsageLimitTypeSchema,
834
1229
  resourceId: import_zod.z.string(),
835
- resourceType: import_zod.z.string(),
1230
+ resourceType: ResourceTypeSchema,
836
1231
  tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
837
1232
  });
838
1233
  var UsageWalletResponseSchema = import_zod.z.object({
@@ -840,78 +1235,21 @@ var UsageWalletResponseSchema = import_zod.z.object({
840
1235
  createdAt: import_zod.z.iso.datetime(),
841
1236
  environmentId: import_zod.z.string(),
842
1237
  id: import_zod.z.string(),
843
- limitType: import_zod.z.string(),
1238
+ limitType: UsageLimitTypeSchema,
844
1239
  resourceId: import_zod.z.string(),
845
- resourceType: import_zod.z.string(),
1240
+ resourceType: ResourceTypeSchema,
846
1241
  tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable()
847
1242
  });
848
- var UserSchema = import_zod.z.object({
849
- avatarUrl: import_zod.z.string().nullable(),
850
- createdAt: import_zod.z.iso.datetime(),
851
- email: import_zod.z.email(),
852
- emailVerified: import_zod.z.boolean(),
853
- firstName: import_zod.z.string().nullable(),
854
- id: import_zod.z.string(),
855
- lastLoginAt: import_zod.z.iso.datetime().nullable(),
856
- lastName: import_zod.z.string().nullable(),
857
- lookupKey: import_zod.z.string().nullable(),
858
- updatedAt: import_zod.z.iso.datetime()
859
- });
860
- var UserCreateBodySchema = import_zod.z.object({
861
- avatarUrl: import_zod.z.url().optional(),
862
- email: import_zod.z.email(),
863
- firstName: import_zod.z.string().nullable().optional(),
864
- lastName: import_zod.z.string().nullable().optional(),
865
- lookupKey: import_zod.z.string(),
866
- newUser: import_zod.z.boolean().nullable().optional(),
867
- password: import_zod.z.string().nullable().optional()
868
- });
869
- var UserListSchema = import_zod.z.object({
870
- items: import_zod.z.object({
871
- avatarUrl: import_zod.z.string().nullable(),
872
- createdAt: import_zod.z.iso.datetime(),
873
- email: import_zod.z.email(),
874
- emailVerified: import_zod.z.boolean(),
875
- firstName: import_zod.z.string().nullable(),
876
- id: import_zod.z.string(),
877
- lastLoginAt: import_zod.z.iso.datetime().nullable(),
878
- lastName: import_zod.z.string().nullable(),
879
- lookupKey: import_zod.z.string().nullable(),
880
- updatedAt: import_zod.z.iso.datetime()
881
- }).array(),
882
- limit: import_zod.z.number(),
883
- page: import_zod.z.number(),
884
- total: import_zod.z.number()
885
- });
886
- var UserResourceListSchema = import_zod.z.array(
887
- import_zod.z.object({
888
- inherited: import_zod.z.boolean(),
889
- resource: import_zod.z.object({
890
- id: import_zod.z.string(),
891
- name: import_zod.z.string(),
892
- parents: import_zod.z.object({
893
- id: import_zod.z.string(),
894
- type: import_zod.z.string()
895
- }).array(),
896
- type: import_zod.z.string()
897
- }).catchall(import_zod.z.unknown()),
898
- role: import_zod.z.string()
899
- })
900
- );
901
- var UserUpdateBodySchema = import_zod.z.object({
902
- avatarUrl: import_zod.z.url().nullable().optional(),
903
- email: import_zod.z.email().optional(),
904
- firstName: import_zod.z.string().nullable().optional(),
905
- lastName: import_zod.z.string().nullable().optional(),
906
- lookupKey: import_zod.z.string().optional(),
907
- password: import_zod.z.string().optional()
908
- });
909
1243
  var ResourceListSchema = import_zod.z.object({
910
1244
  items: ResourceSchema.array(),
911
1245
  limit: import_zod.z.number(),
912
1246
  page: import_zod.z.number(),
913
1247
  total: import_zod.z.number()
914
1248
  });
1249
+ var AuthJwksGetOAuthAppJwksQuerySchema = import_zod.z.object({
1250
+ /** OAuth app client ID to get public keys for */
1251
+ client_id: import_zod.z.string().optional()
1252
+ });
915
1253
  var EntitlementsListForResourceQuerySchema = import_zod.z.object({
916
1254
  /** The unique identifier of the user */
917
1255
  userId: import_zod.z.string()
@@ -920,6 +1258,14 @@ var EntitlementsListForTenantQuerySchema = import_zod.z.object({
920
1258
  /** The unique identifier of the user */
921
1259
  userId: import_zod.z.string()
922
1260
  });
1261
+ var OauthCheckConsentRequiredQuerySchema = import_zod.z.object({
1262
+ /** OAuth2 client ID */
1263
+ client_id: import_zod.z.string(),
1264
+ /** Redirect URI */
1265
+ redirect_uri: import_zod.z.string().optional(),
1266
+ /** Space-separated list of scopes */
1267
+ scope: import_zod.z.string().optional()
1268
+ });
923
1269
  var ResourceMembersListQuerySchema = import_zod.z.object({
924
1270
  /** Number of items per page (minimum: 1, maximum: 100) */
925
1271
  limit: import_zod.z.number().optional(),
@@ -944,7 +1290,7 @@ var RolesListQuerySchema = import_zod.z.object({
944
1290
  /** Filter roles by specific resource ID */
945
1291
  resourceId: import_zod.z.string().optional(),
946
1292
  /** Filter roles by resource type */
947
- resourceType: import_zod.z.string().optional(),
1293
+ resourceType: ResourceTypeSchema.optional(),
948
1294
  /** Filter by role name */
949
1295
  role: import_zod.z.string().optional()
950
1296
  });
@@ -972,40 +1318,14 @@ var UsersListQuerySchema = import_zod.z.object({
972
1318
  // src/token-verifier.ts
973
1319
  var crypto = __toESM(require("crypto"));
974
1320
  var jwt = __toESM(require("jsonwebtoken"));
1321
+ var import_fetch4 = require("@blimu/fetch");
975
1322
  var TokenVerifier = class {
976
1323
  cache = /* @__PURE__ */ new Map();
977
1324
  cacheTTL;
978
- runtimeApiUrl;
1325
+ baseURL;
979
1326
  constructor(options) {
980
1327
  this.cacheTTL = options?.cacheTTL ?? 60 * 60 * 1e3;
981
- this.runtimeApiUrl = options?.runtimeApiUrl ?? "https://api.blimu.dev";
982
- }
983
- /**
984
- * Fetch JWK Set from runtime-api
985
- */
986
- async fetchJWKSet(endpoint, headers) {
987
- console.log(`[TokenVerifier] \u{1F4E1} Fetching JWK Set from: ${endpoint}`);
988
- if (headers) {
989
- console.log(
990
- `[TokenVerifier] \u{1F4E1} Request headers: ${JSON.stringify(Object.keys(headers).map((k) => `${k}: ${k === "x-api-key" ? "***" : headers[k]}`))}`
991
- );
992
- }
993
- const response = await fetch(endpoint, {
994
- method: "GET",
995
- headers: {
996
- "Content-Type": "application/json",
997
- ...headers
998
- }
999
- });
1000
- console.log(`[TokenVerifier] \u{1F4E1} Response status: ${response.status} ${response.statusText}`);
1001
- if (!response.ok) {
1002
- const errorText = await response.text();
1003
- console.error(`[TokenVerifier] \u274C Failed to fetch JWKs: ${response.status} ${errorText}`);
1004
- throw new import_fetch10.FetchError("Failed to fetch JWKs", response.status, errorText);
1005
- }
1006
- const jwkSet = await response.json();
1007
- console.log(`[TokenVerifier] \u2705 Successfully fetched JWK Set with ${jwkSet.keys.length} keys`);
1008
- return jwkSet;
1328
+ this.baseURL = options?.runtimeApiUrl ?? "https://api.blimu.dev";
1009
1329
  }
1010
1330
  /**
1011
1331
  * Convert JWK to KeyObject
@@ -1024,25 +1344,19 @@ var TokenVerifier = class {
1024
1344
  /**
1025
1345
  * Get public key for a specific key ID
1026
1346
  */
1027
- async getPublicKey(kid, cacheKey, endpoint, headers) {
1347
+ async getPublicKey(kid, cacheKey, fetchJwks) {
1028
1348
  const cached = this.cache.get(cacheKey);
1029
1349
  if (cached && cached.expiresAt > Date.now()) {
1030
- console.log(`[TokenVerifier] \u2705 Using cached key for kid: ${kid}`);
1031
1350
  return cached.key;
1032
1351
  }
1033
- console.log(`[TokenVerifier] \u{1F50D} Cache miss or expired. Fetching new key for kid: ${kid}`);
1034
- const jwkSet = await this.fetchJWKSet(endpoint, headers);
1352
+ const jwkSet = await fetchJwks();
1035
1353
  const jwk = jwkSet.keys.find((k) => k.kid === kid);
1036
1354
  if (!jwk) {
1037
1355
  const availableKids = jwkSet.keys.map((k) => k.kid).join(", ");
1038
- console.error(
1039
- `[TokenVerifier] \u274C Key with kid '${kid}' not found in JWK Set. Available kids: ${availableKids}`
1040
- );
1041
1356
  throw new Error(
1042
1357
  `Key with kid '${kid}' not found in JWK Set. Available kids: ${availableKids}`
1043
1358
  );
1044
1359
  }
1045
- console.log(`[TokenVerifier] \u2705 Found key with kid: ${kid}`);
1046
1360
  const keyObject = this.jwkToKeyObject(jwk);
1047
1361
  this.cache.set(cacheKey, {
1048
1362
  key: keyObject,
@@ -1052,15 +1366,16 @@ var TokenVerifier = class {
1052
1366
  return keyObject;
1053
1367
  }
1054
1368
  /**
1055
- * Verify JWT token using JWKs from runtime-api
1369
+ * Verify JWT token using JWKs from Blimu runtime API.
1370
+ * Supports: environment/session tokens (secretKey) or OAuth app tokens (clientId).
1056
1371
  */
1057
1372
  async verifyToken(options) {
1058
- const { url, secretKey, token, runtimeApiUrl } = options;
1059
- if (!url && !secretKey) {
1060
- throw new Error("Either url or secretKey must be provided");
1061
- }
1062
- if (url && secretKey) {
1063
- throw new Error("Cannot provide both url and secretKey");
1373
+ const { secretKey, clientId, token, runtimeApiUrl } = options;
1374
+ const provided = [secretKey, clientId].filter(Boolean);
1375
+ if (provided.length !== 1) {
1376
+ throw new Error(
1377
+ "Exactly one of secretKey or clientId must be provided. Use secretKey for environment/session tokens, clientId for OAuth app access tokens."
1378
+ );
1064
1379
  }
1065
1380
  const decoded = jwt.decode(token, { complete: true });
1066
1381
  if (!decoded || typeof decoded === "string") {
@@ -1070,67 +1385,38 @@ var TokenVerifier = class {
1070
1385
  if (!header.kid) {
1071
1386
  throw new Error("Token missing kid in header");
1072
1387
  }
1073
- let endpoint;
1388
+ const baseURL = runtimeApiUrl ?? this.baseURL;
1074
1389
  let cacheKey;
1075
- let headers;
1390
+ let fetchJwks;
1076
1391
  if (secretKey) {
1077
- const apiUrl = runtimeApiUrl ?? this.runtimeApiUrl;
1078
- endpoint = `${apiUrl}/v1/auth/.well-known/jwks.json`;
1079
1392
  cacheKey = secretKey;
1080
- headers = {
1081
- "x-api-key": secretKey
1082
- };
1083
- console.log(
1084
- `[TokenVerifier] \u{1F50D} Verifying token with kid: ${header.kid}, endpoint: ${endpoint}`
1085
- );
1393
+ const core = new import_fetch4.FetchClient({
1394
+ baseURL,
1395
+ authStrategies: buildAuthStrategies({ apiKey: secretKey, baseURL })
1396
+ });
1397
+ const authJwks = new AuthJwksService(core);
1398
+ fetchJwks = () => authJwks.getJwks();
1086
1399
  } else {
1087
- endpoint = url;
1088
- cacheKey = url;
1089
- console.log(
1090
- `[TokenVerifier] \u{1F50D} Verifying token with kid: ${header.kid}, endpoint: ${endpoint}`
1091
- );
1400
+ cacheKey = `oauth:${clientId}`;
1401
+ const core = new import_fetch4.FetchClient({ baseURL });
1402
+ const authJwks = new AuthJwksService(core);
1403
+ fetchJwks = () => authJwks.getOAuthAppJwks({ client_id: clientId });
1092
1404
  }
1093
1405
  let publicKey;
1094
1406
  try {
1095
- publicKey = await this.getPublicKey(header.kid, cacheKey, endpoint, headers);
1096
- console.log(`[TokenVerifier] \u2705 Successfully retrieved public key for kid: ${header.kid}`);
1097
- } catch (error) {
1098
- console.error(
1099
- `[TokenVerifier] \u274C Failed to get public key (first attempt): ${error instanceof Error ? error.message : String(error)}`
1100
- );
1407
+ publicKey = await this.getPublicKey(header.kid, cacheKey, fetchJwks);
1408
+ } catch {
1101
1409
  this.clearCache(cacheKey);
1102
- console.log(`[TokenVerifier] \u{1F504} Retrying after cache clear...`);
1103
- try {
1104
- publicKey = await this.getPublicKey(header.kid, cacheKey, endpoint, headers);
1105
- console.log(
1106
- `[TokenVerifier] \u2705 Successfully retrieved public key for kid: ${header.kid} (retry)`
1107
- );
1108
- } catch (retryError) {
1109
- console.error(
1110
- `[TokenVerifier] \u274C Failed to get public key (retry): ${retryError instanceof Error ? retryError.message : String(retryError)}`
1111
- );
1112
- throw retryError;
1113
- }
1114
- }
1115
- try {
1116
- const payload = jwt.verify(token, publicKey, {
1117
- algorithms: ["RS256"]
1118
- });
1119
- console.log(`[TokenVerifier] \u2705 Token verified successfully`);
1120
- return payload;
1121
- } catch (error) {
1122
- console.error(
1123
- `[TokenVerifier] \u274C JWT verification failed: ${error instanceof Error ? error.message : String(error)}`
1124
- );
1125
- throw error;
1410
+ publicKey = await this.getPublicKey(header.kid, cacheKey, fetchJwks);
1126
1411
  }
1412
+ return jwt.verify(token, publicKey, { algorithms: ["RS256"] });
1127
1413
  }
1128
1414
  /**
1129
1415
  * Clear cache (useful for testing or key rotation)
1130
1416
  */
1131
- clearCache(secretKeyOrUrl) {
1132
- if (secretKeyOrUrl) {
1133
- this.cache.delete(secretKeyOrUrl);
1417
+ clearCache(cacheKey) {
1418
+ if (cacheKey) {
1419
+ this.cache.delete(cacheKey);
1134
1420
  } else {
1135
1421
  this.cache.clear();
1136
1422
  }
@@ -1140,8 +1426,15 @@ async function verifyToken(options) {
1140
1426
  const verifier = new TokenVerifier();
1141
1427
  return verifier.verifyToken(options);
1142
1428
  }
1429
+ async function verifyOAuthToken(options) {
1430
+ return verifyToken({
1431
+ ...options,
1432
+ clientId: options.clientId
1433
+ });
1434
+ }
1143
1435
  // Annotate the CommonJS export names for ESM import in node:
1144
1436
  0 && (module.exports = {
1437
+ AuthJwksService,
1145
1438
  Blimu,
1146
1439
  BlimuError,
1147
1440
  BulkResourcesService,
@@ -1162,6 +1455,7 @@ async function verifyToken(options) {
1162
1455
  paginate,
1163
1456
  parseNDJSONStream,
1164
1457
  parseSSEStream,
1458
+ verifyOAuthToken,
1165
1459
  verifyToken,
1166
1460
  ...require("@blimu/fetch")
1167
1461
  });