@secretenvs/contracts 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -21,6 +21,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AddMemberInput: () => AddMemberInput,
24
+ AdminProjectDto: () => AdminProjectDto,
25
+ AdminUpdateUserInput: () => AdminUpdateUserInput,
26
+ AdminUserDetailDto: () => AdminUserDetailDto,
27
+ AdminUserDto: () => AdminUserDto,
24
28
  ApiErrorBody: () => ApiErrorBody,
25
29
  BulkUpsertVariablesInput: () => BulkUpsertVariablesInput,
26
30
  BulkUpsertVariablesResponse: () => BulkUpsertVariablesResponse,
@@ -33,8 +37,11 @@ __export(index_exports, {
33
37
  CreateVariableInput: () => CreateVariableInput,
34
38
  CreatedTokenDto: () => CreatedTokenDto,
35
39
  DEFAULT_VERSIONS_LIMIT: () => DEFAULT_VERSIONS_LIMIT,
40
+ EXPIRING_SOON_DAYS: () => EXPIRING_SOON_DAYS,
41
+ EXPIRY_REMINDER_DAYS: () => EXPIRY_REMINDER_DAYS,
36
42
  EnvironmentDto: () => EnvironmentDto,
37
43
  ErrorCode: () => ErrorCode,
44
+ ExpiringSecretDto: () => ExpiringSecretDto,
38
45
  ListVersionsQuery: () => ListVersionsQuery,
39
46
  LoginInput: () => LoginInput,
40
47
  MAX_AUTH_CODE_LENGTH: () => MAX_AUTH_CODE_LENGTH,
@@ -91,6 +98,8 @@ var MAX_KEY_LENGTH = 128;
91
98
  var MAX_VALUE_BYTES = 64 * 1024;
92
99
  var MAX_NAME_LENGTH = 64;
93
100
  var MAX_BULK_VARIABLES = 500;
101
+ var EXPIRING_SOON_DAYS = 7;
102
+ var EXPIRY_REMINDER_DAYS = [30, 7, 1];
94
103
  var MIN_PASSWORD_LENGTH = 12;
95
104
  var MAX_PASSWORD_LENGTH = 256;
96
105
  var DEFAULT_VERSIONS_LIMIT = 20;
@@ -133,6 +142,9 @@ var variableValue = import_zod2.z.string().refine(
133
142
  message: `Value must be at most ${MAX_VALUE_BYTES} bytes`
134
143
  }
135
144
  );
145
+ var secretExpiry = isoDate.refine((value) => Date.parse(value) > Date.now(), {
146
+ message: "Expiry must be in the future"
147
+ }).nullable();
136
148
  var password = import_zod2.z.string().min(MIN_PASSWORD_LENGTH).max(MAX_PASSWORD_LENGTH);
137
149
  var RegisterInput = import_zod2.z.object({ email, name, password }).strict();
138
150
  var authCode = import_zod2.z.string().trim().min(1, "Enter your code").max(MAX_AUTH_CODE_LENGTH);
@@ -148,7 +160,9 @@ var UserDto = import_zod2.z.object({
148
160
  createdAt: isoDate,
149
161
  twoFactorEnabled: import_zod2.z.boolean(),
150
162
  // Name the user gave the authenticator app at setup; null while 2FA is off.
151
- twoFactorAppName: import_zod2.z.string().nullable()
163
+ twoFactorAppName: import_zod2.z.string().nullable(),
164
+ // Whether the account may use the /admin pages (set directly in the database).
165
+ isSuperAdmin: import_zod2.z.boolean()
152
166
  }).strict();
153
167
  var TwoFactorSetupDto = import_zod2.z.object({ secret: import_zod2.z.string(), otpauthUri: import_zod2.z.string() }).strict();
154
168
  var TwoFactorSetupInput = import_zod2.z.object({ password: import_zod2.z.string().min(1).max(MAX_PASSWORD_LENGTH) }).strict();
@@ -164,13 +178,16 @@ var RecoveryCodesDto = import_zod2.z.object({ recoveryCodes: import_zod2.z.array
164
178
  var CreateProjectInput = import_zod2.z.object({ name, slug, description: import_zod2.z.string().max(500).optional() }).strict();
165
179
  var UpdateProjectInput = import_zod2.z.object({
166
180
  name: name.optional(),
167
- description: import_zod2.z.string().max(500).nullable().optional()
181
+ description: import_zod2.z.string().max(500).nullable().optional(),
182
+ disabled: import_zod2.z.boolean().optional()
168
183
  }).strict();
169
184
  var ProjectDto = import_zod2.z.object({
170
185
  id,
171
186
  name,
172
187
  slug,
173
188
  description: import_zod2.z.string().nullable(),
189
+ // Null while the project is enabled.
190
+ disabledAt: isoDate.nullable(),
174
191
  createdAt: isoDate,
175
192
  updatedAt: isoDate
176
193
  }).strict();
@@ -191,19 +208,33 @@ var EnvironmentDto = import_zod2.z.object({
191
208
  createdAt: isoDate,
192
209
  updatedAt: isoDate
193
210
  }).strict();
194
- var CreateVariableInput = import_zod2.z.object({ key: variableKey, value: variableValue }).strict();
195
- var UpdateVariableInput = import_zod2.z.object({ value: variableValue }).strict();
211
+ var CreateVariableInput = import_zod2.z.object({
212
+ key: variableKey,
213
+ value: variableValue,
214
+ expiresAt: secretExpiry.optional()
215
+ }).strict();
216
+ var UpdateVariableInput = import_zod2.z.object({
217
+ value: variableValue.optional(),
218
+ expiresAt: secretExpiry.optional()
219
+ }).strict().refine(
220
+ (input) => input.value !== void 0 || input.expiresAt !== void 0,
221
+ {
222
+ message: "Provide value and/or expiresAt"
223
+ }
224
+ );
196
225
  var VariableMetaDto = import_zod2.z.object({
197
226
  id,
198
227
  key: variableKey,
199
228
  currentVersion: import_zod2.z.number().int().min(1),
229
+ // Null when the secret never expires.
230
+ expiresAt: isoDate.nullable(),
200
231
  updatedAt: isoDate
201
232
  }).strict();
202
233
  var VariableWithValueDto = VariableMetaDto.extend({
203
234
  value: import_zod2.z.string()
204
235
  });
205
236
  var BulkUpsertVariablesInput = import_zod2.z.object({
206
- variables: import_zod2.z.array(CreateVariableInput).min(1).max(MAX_BULK_VARIABLES).refine(
237
+ variables: import_zod2.z.array(CreateVariableInput.omit({ expiresAt: true })).min(1).max(MAX_BULK_VARIABLES).refine(
207
238
  (items) => new Set(items.map((item) => item.key)).size === items.length,
208
239
  { message: "Duplicate keys are not allowed" }
209
240
  )
@@ -214,17 +245,39 @@ var BulkUpsertVariablesResponse = import_zod2.z.object({
214
245
  unchanged: import_zod2.z.number().int().min(0)
215
246
  }).strict();
216
247
  var environmentIds = import_zod2.z.array(id).max(100);
217
- var CreateSharedVariableInput = import_zod2.z.object({ key: variableKey, value: variableValue, environmentIds }).strict();
248
+ var CreateSharedVariableInput = import_zod2.z.object({
249
+ key: variableKey,
250
+ value: variableValue,
251
+ environmentIds,
252
+ expiresAt: secretExpiry.optional()
253
+ }).strict();
218
254
  var UpdateSharedVariableInput = import_zod2.z.object({
219
255
  value: variableValue.optional(),
220
- environmentIds: environmentIds.optional()
256
+ environmentIds: environmentIds.optional(),
257
+ expiresAt: secretExpiry.optional()
221
258
  }).strict().refine(
222
- (input) => input.value !== void 0 || input.environmentIds !== void 0,
259
+ (input) => input.value !== void 0 || input.environmentIds !== void 0 || input.expiresAt !== void 0,
223
260
  {
224
- message: "Provide value and/or environmentIds"
261
+ message: "Provide value, environmentIds and/or expiresAt"
225
262
  }
226
263
  );
227
264
  var SharedVariableMetaDto = VariableMetaDto.extend({ environmentIds });
265
+ var ExpiringSecretDto = import_zod2.z.object({
266
+ // The reminder's own id, stable for as long as that stage lasts.
267
+ reminderId: id,
268
+ // Days before the expiry the reminder was raised for; 0 once the secret expired.
269
+ threshold: import_zod2.z.number().int().min(0),
270
+ // When the reminder was logged.
271
+ raisedAt: isoDate,
272
+ // The secret.
273
+ id,
274
+ key: variableKey,
275
+ kind: import_zod2.z.enum(["environment", "shared"]),
276
+ expiresAt: isoDate,
277
+ project: import_zod2.z.object({ id, slug, name }).strict(),
278
+ // Null for a shared variable, which belongs to the project rather than one environment.
279
+ environment: import_zod2.z.object({ id, slug, name }).strict().nullable()
280
+ }).strict();
228
281
  var ListVersionsQuery = import_zod2.z.object({
229
282
  cursor: import_zod2.z.string().min(1).max(256).optional(),
230
283
  limit: import_zod2.z.coerce.number().int().min(1).max(MAX_VERSIONS_LIMIT).default(20)
@@ -260,6 +313,34 @@ var SdkProjectDto = import_zod2.z.object({
260
313
  role: ProjectRole,
261
314
  environments: import_zod2.z.array(SdkEnvironmentDto)
262
315
  }).strict();
316
+ var adminPerson = import_zod2.z.object({ id, name, email }).strict();
317
+ var AdminProjectDto = ProjectDto.extend({
318
+ owner: adminPerson.nullable(),
319
+ memberCount: import_zod2.z.number().int().min(0),
320
+ environmentCount: import_zod2.z.number().int().min(0)
321
+ });
322
+ var AdminUserDto = import_zod2.z.object({
323
+ id,
324
+ email,
325
+ name,
326
+ createdAt: isoDate,
327
+ // Null while the account is enabled.
328
+ disabledAt: isoDate.nullable(),
329
+ isSuperAdmin: import_zod2.z.boolean(),
330
+ projectCount: import_zod2.z.number().int().min(0)
331
+ }).strict();
332
+ var AdminUserDetailDto = AdminUserDto.extend({
333
+ // Every project the user is a member of, with their role there.
334
+ projects: import_zod2.z.array(import_zod2.z.object({ id, name, slug, role: ProjectRole }).strict())
335
+ });
336
+ var AdminUpdateUserInput = import_zod2.z.object({
337
+ name: name.optional(),
338
+ email: email.optional(),
339
+ disabled: import_zod2.z.boolean().optional()
340
+ }).strict().refine(
341
+ (input) => input.name !== void 0 || input.email !== void 0 || input.disabled !== void 0,
342
+ { message: "Provide name, email and/or disabled" }
343
+ );
263
344
  var CreateTokenInput = import_zod2.z.object({
264
345
  name,
265
346
  access: TokenAccess,
@@ -311,7 +392,10 @@ var apiEnvironmentSchema = import_zod3.z.object({
311
392
  COOKIE_SECURE: import_zod3.z.enum(["true", "false"]).optional(),
312
393
  VARIABLE_HISTORY_LIMIT: import_zod3.z.coerce.number().int().min(1).max(500).default(50),
313
394
  // Reverse-proxy hops in front of the API (Express `trust proxy`); 0 trusts none.
314
- TRUST_PROXY: import_zod3.z.coerce.number().int().min(0).max(10).default(0)
395
+ TRUST_PROXY: import_zod3.z.coerce.number().int().min(0).max(10).default(0),
396
+ // Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
397
+ // that endpoint off.
398
+ CRON_SECRET: import_zod3.z.string().min(32).max(256).optional()
315
399
  }).strict().transform((environment) => ({
316
400
  ...environment,
317
401
  COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
@@ -319,6 +403,10 @@ var apiEnvironmentSchema = import_zod3.z.object({
319
403
  // Annotate the CommonJS export names for ESM import in node:
320
404
  0 && (module.exports = {
321
405
  AddMemberInput,
406
+ AdminProjectDto,
407
+ AdminUpdateUserInput,
408
+ AdminUserDetailDto,
409
+ AdminUserDto,
322
410
  ApiErrorBody,
323
411
  BulkUpsertVariablesInput,
324
412
  BulkUpsertVariablesResponse,
@@ -331,8 +419,11 @@ var apiEnvironmentSchema = import_zod3.z.object({
331
419
  CreateVariableInput,
332
420
  CreatedTokenDto,
333
421
  DEFAULT_VERSIONS_LIMIT,
422
+ EXPIRING_SOON_DAYS,
423
+ EXPIRY_REMINDER_DAYS,
334
424
  EnvironmentDto,
335
425
  ErrorCode,
426
+ ExpiringSecretDto,
336
427
  ListVersionsQuery,
337
428
  LoginInput,
338
429
  MAX_AUTH_CODE_LENGTH,
package/dist/index.d.cts CHANGED
@@ -6,6 +6,8 @@ declare const MAX_KEY_LENGTH = 128;
6
6
  declare const MAX_VALUE_BYTES: number;
7
7
  declare const MAX_NAME_LENGTH = 64;
8
8
  declare const MAX_BULK_VARIABLES = 500;
9
+ declare const EXPIRING_SOON_DAYS = 7;
10
+ declare const EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
9
11
  declare const MIN_PASSWORD_LENGTH = 12;
10
12
  declare const MAX_PASSWORD_LENGTH = 256;
11
13
  declare const DEFAULT_VERSIONS_LIMIT = 20;
@@ -67,6 +69,7 @@ declare const UserDto: z.ZodObject<{
67
69
  createdAt: z.ZodISODateTime;
68
70
  twoFactorEnabled: z.ZodBoolean;
69
71
  twoFactorAppName: z.ZodNullable<z.ZodString>;
72
+ isSuperAdmin: z.ZodBoolean;
70
73
  }, z.core.$strict>;
71
74
  type UserDto = z.infer<typeof UserDto>;
72
75
  declare const TwoFactorSetupDto: z.ZodObject<{
@@ -101,6 +104,7 @@ type CreateProjectInput = z.infer<typeof CreateProjectInput>;
101
104
  declare const UpdateProjectInput: z.ZodObject<{
102
105
  name: z.ZodOptional<z.ZodString>;
103
106
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
+ disabled: z.ZodOptional<z.ZodBoolean>;
104
108
  }, z.core.$strict>;
105
109
  type UpdateProjectInput = z.infer<typeof UpdateProjectInput>;
106
110
  declare const ProjectDto: z.ZodObject<{
@@ -108,6 +112,7 @@ declare const ProjectDto: z.ZodObject<{
108
112
  name: z.ZodString;
109
113
  slug: z.ZodString;
110
114
  description: z.ZodNullable<z.ZodString>;
115
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
111
116
  createdAt: z.ZodISODateTime;
112
117
  updatedAt: z.ZodISODateTime;
113
118
  }, z.core.$strict>;
@@ -117,6 +122,7 @@ declare const ProjectSummaryDto: z.ZodObject<{
117
122
  name: z.ZodString;
118
123
  slug: z.ZodString;
119
124
  description: z.ZodNullable<z.ZodString>;
125
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
120
126
  createdAt: z.ZodISODateTime;
121
127
  updatedAt: z.ZodISODateTime;
122
128
  role: z.ZodEnum<{
@@ -182,16 +188,19 @@ type EnvironmentDto = z.infer<typeof EnvironmentDto>;
182
188
  declare const CreateVariableInput: z.ZodObject<{
183
189
  key: z.ZodString;
184
190
  value: z.ZodString;
191
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
185
192
  }, z.core.$strict>;
186
193
  type CreateVariableInput = z.infer<typeof CreateVariableInput>;
187
194
  declare const UpdateVariableInput: z.ZodObject<{
188
- value: z.ZodString;
195
+ value: z.ZodOptional<z.ZodString>;
196
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
189
197
  }, z.core.$strict>;
190
198
  type UpdateVariableInput = z.infer<typeof UpdateVariableInput>;
191
199
  declare const VariableMetaDto: z.ZodObject<{
192
200
  id: z.ZodUUID;
193
201
  key: z.ZodString;
194
202
  currentVersion: z.ZodNumber;
203
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
195
204
  updatedAt: z.ZodISODateTime;
196
205
  }, z.core.$strict>;
197
206
  type VariableMetaDto = z.infer<typeof VariableMetaDto>;
@@ -199,14 +208,15 @@ declare const VariableWithValueDto: z.ZodObject<{
199
208
  id: z.ZodUUID;
200
209
  key: z.ZodString;
201
210
  currentVersion: z.ZodNumber;
211
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
202
212
  updatedAt: z.ZodISODateTime;
203
213
  value: z.ZodString;
204
214
  }, z.core.$strict>;
205
215
  type VariableWithValueDto = z.infer<typeof VariableWithValueDto>;
206
216
  declare const BulkUpsertVariablesInput: z.ZodObject<{
207
217
  variables: z.ZodArray<z.ZodObject<{
208
- key: z.ZodString;
209
218
  value: z.ZodString;
219
+ key: z.ZodString;
210
220
  }, z.core.$strict>>;
211
221
  }, z.core.$strict>;
212
222
  type BulkUpsertVariablesInput = z.infer<typeof BulkUpsertVariablesInput>;
@@ -220,21 +230,47 @@ declare const CreateSharedVariableInput: z.ZodObject<{
220
230
  key: z.ZodString;
221
231
  value: z.ZodString;
222
232
  environmentIds: z.ZodArray<z.ZodUUID>;
233
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
223
234
  }, z.core.$strict>;
224
235
  type CreateSharedVariableInput = z.infer<typeof CreateSharedVariableInput>;
225
236
  declare const UpdateSharedVariableInput: z.ZodObject<{
226
237
  value: z.ZodOptional<z.ZodString>;
227
238
  environmentIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
239
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
228
240
  }, z.core.$strict>;
229
241
  type UpdateSharedVariableInput = z.infer<typeof UpdateSharedVariableInput>;
230
242
  declare const SharedVariableMetaDto: z.ZodObject<{
231
243
  id: z.ZodUUID;
232
244
  key: z.ZodString;
233
245
  currentVersion: z.ZodNumber;
246
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
234
247
  updatedAt: z.ZodISODateTime;
235
248
  environmentIds: z.ZodArray<z.ZodUUID>;
236
249
  }, z.core.$strict>;
237
250
  type SharedVariableMetaDto = z.infer<typeof SharedVariableMetaDto>;
251
+ declare const ExpiringSecretDto: z.ZodObject<{
252
+ reminderId: z.ZodUUID;
253
+ threshold: z.ZodNumber;
254
+ raisedAt: z.ZodISODateTime;
255
+ id: z.ZodUUID;
256
+ key: z.ZodString;
257
+ kind: z.ZodEnum<{
258
+ environment: "environment";
259
+ shared: "shared";
260
+ }>;
261
+ expiresAt: z.ZodISODateTime;
262
+ project: z.ZodObject<{
263
+ id: z.ZodUUID;
264
+ slug: z.ZodString;
265
+ name: z.ZodString;
266
+ }, z.core.$strict>;
267
+ environment: z.ZodNullable<z.ZodObject<{
268
+ id: z.ZodUUID;
269
+ slug: z.ZodString;
270
+ name: z.ZodString;
271
+ }, z.core.$strict>>;
272
+ }, z.core.$strict>;
273
+ type ExpiringSecretDto = z.infer<typeof ExpiringSecretDto>;
238
274
  declare const ListVersionsQuery: z.ZodObject<{
239
275
  cursor: z.ZodOptional<z.ZodString>;
240
276
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -331,6 +367,60 @@ declare const SdkProjectDto: z.ZodObject<{
331
367
  }, z.core.$strict>>;
332
368
  }, z.core.$strict>;
333
369
  type SdkProjectDto = z.infer<typeof SdkProjectDto>;
370
+ declare const AdminProjectDto: z.ZodObject<{
371
+ id: z.ZodUUID;
372
+ name: z.ZodString;
373
+ slug: z.ZodString;
374
+ description: z.ZodNullable<z.ZodString>;
375
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
376
+ createdAt: z.ZodISODateTime;
377
+ updatedAt: z.ZodISODateTime;
378
+ owner: z.ZodNullable<z.ZodObject<{
379
+ id: z.ZodUUID;
380
+ name: z.ZodString;
381
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
382
+ }, z.core.$strict>>;
383
+ memberCount: z.ZodNumber;
384
+ environmentCount: z.ZodNumber;
385
+ }, z.core.$strict>;
386
+ type AdminProjectDto = z.infer<typeof AdminProjectDto>;
387
+ declare const AdminUserDto: z.ZodObject<{
388
+ id: z.ZodUUID;
389
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
390
+ name: z.ZodString;
391
+ createdAt: z.ZodISODateTime;
392
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
393
+ isSuperAdmin: z.ZodBoolean;
394
+ projectCount: z.ZodNumber;
395
+ }, z.core.$strict>;
396
+ type AdminUserDto = z.infer<typeof AdminUserDto>;
397
+ declare const AdminUserDetailDto: z.ZodObject<{
398
+ id: z.ZodUUID;
399
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
400
+ name: z.ZodString;
401
+ createdAt: z.ZodISODateTime;
402
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
403
+ isSuperAdmin: z.ZodBoolean;
404
+ projectCount: z.ZodNumber;
405
+ projects: z.ZodArray<z.ZodObject<{
406
+ id: z.ZodUUID;
407
+ name: z.ZodString;
408
+ slug: z.ZodString;
409
+ role: z.ZodEnum<{
410
+ OWNER: "OWNER";
411
+ ADMIN: "ADMIN";
412
+ EDITOR: "EDITOR";
413
+ VIEWER: "VIEWER";
414
+ }>;
415
+ }, z.core.$strict>>;
416
+ }, z.core.$strict>;
417
+ type AdminUserDetailDto = z.infer<typeof AdminUserDetailDto>;
418
+ declare const AdminUpdateUserInput: z.ZodObject<{
419
+ name: z.ZodOptional<z.ZodString>;
420
+ email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
421
+ disabled: z.ZodOptional<z.ZodBoolean>;
422
+ }, z.core.$strict>;
423
+ type AdminUpdateUserInput = z.infer<typeof AdminUpdateUserInput>;
334
424
  declare const CreateTokenInput: z.ZodObject<{
335
425
  name: z.ZodString;
336
426
  access: z.ZodEnum<{
@@ -411,6 +501,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
411
501
  }>>;
412
502
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
413
503
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
504
+ CRON_SECRET: z.ZodOptional<z.ZodString>;
414
505
  }, z.core.$strict>, z.ZodTransform<{
415
506
  COOKIE_SECURE: boolean;
416
507
  NODE_ENV: "development" | "test" | "production";
@@ -421,6 +512,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
421
512
  MASTER_KEY: string;
422
513
  VARIABLE_HISTORY_LIMIT: number;
423
514
  TRUST_PROXY: number;
515
+ CRON_SECRET?: string | undefined;
424
516
  }, {
425
517
  NODE_ENV: "development" | "test" | "production";
426
518
  HOST: string;
@@ -431,7 +523,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
431
523
  VARIABLE_HISTORY_LIMIT: number;
432
524
  TRUST_PROXY: number;
433
525
  COOKIE_SECURE?: "true" | "false" | undefined;
526
+ CRON_SECRET?: string | undefined;
434
527
  }>>;
435
528
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
436
529
 
437
- export { AddMemberInput, type ApiEnvironment, ApiErrorBody, BulkUpsertVariablesInput, BulkUpsertVariablesResponse, CSRF_HEADER_NAME, CSRF_HEADER_VALUE, CreateEnvironmentInput, CreateProjectInput, CreateSharedVariableInput, CreateTokenInput, CreateVariableInput, CreatedTokenDto, DEFAULT_VERSIONS_LIMIT, EnvironmentDto, ErrorCode, ListVersionsQuery, LoginInput, MAX_AUTH_CODE_LENGTH, MAX_BULK_VARIABLES, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_PASSWORD_LENGTH, MAX_VALUE_BYTES, MAX_VERSIONS_LIMIT, MIN_PASSWORD_LENGTH, MemberDto, PaginatedVersionsResponse, ProjectDto, ProjectRole, ProjectSummaryDto, RECOVERY_CODE_COUNT, RecoveryCodesDto, RegisterInput, ResolvedVariableDto, ResolvedVariablesResponse, SLUG_REGEX, SdkEnvironmentDto, SdkProjectDto, SharedVariableMetaDto, TOKEN_PREFIX, TOTP_DIGITS, TokenAccess, TokenDto, TwoFactorConfirmInput, TwoFactorEnableInput, TwoFactorSetupDto, TwoFactorSetupInput, UpdateEnvironmentInput, UpdateMemberInput, UpdateProjectInput, UpdateSharedVariableInput, UpdateVariableInput, UserDto, VARIABLE_KEY_REGEX, VariableMetaDto, VariableVersionMetaDto, VariableVersionValueDto, VariableWithValueDto, VersionChangeType, apiEnvironmentSchema };
530
+ export { AddMemberInput, AdminProjectDto, AdminUpdateUserInput, AdminUserDetailDto, AdminUserDto, type ApiEnvironment, ApiErrorBody, BulkUpsertVariablesInput, BulkUpsertVariablesResponse, CSRF_HEADER_NAME, CSRF_HEADER_VALUE, CreateEnvironmentInput, CreateProjectInput, CreateSharedVariableInput, CreateTokenInput, CreateVariableInput, CreatedTokenDto, DEFAULT_VERSIONS_LIMIT, EXPIRING_SOON_DAYS, EXPIRY_REMINDER_DAYS, EnvironmentDto, ErrorCode, ExpiringSecretDto, ListVersionsQuery, LoginInput, MAX_AUTH_CODE_LENGTH, MAX_BULK_VARIABLES, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_PASSWORD_LENGTH, MAX_VALUE_BYTES, MAX_VERSIONS_LIMIT, MIN_PASSWORD_LENGTH, MemberDto, PaginatedVersionsResponse, ProjectDto, ProjectRole, ProjectSummaryDto, RECOVERY_CODE_COUNT, RecoveryCodesDto, RegisterInput, ResolvedVariableDto, ResolvedVariablesResponse, SLUG_REGEX, SdkEnvironmentDto, SdkProjectDto, SharedVariableMetaDto, TOKEN_PREFIX, TOTP_DIGITS, TokenAccess, TokenDto, TwoFactorConfirmInput, TwoFactorEnableInput, TwoFactorSetupDto, TwoFactorSetupInput, UpdateEnvironmentInput, UpdateMemberInput, UpdateProjectInput, UpdateSharedVariableInput, UpdateVariableInput, UserDto, VARIABLE_KEY_REGEX, VariableMetaDto, VariableVersionMetaDto, VariableVersionValueDto, VariableWithValueDto, VersionChangeType, apiEnvironmentSchema };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ declare const MAX_KEY_LENGTH = 128;
6
6
  declare const MAX_VALUE_BYTES: number;
7
7
  declare const MAX_NAME_LENGTH = 64;
8
8
  declare const MAX_BULK_VARIABLES = 500;
9
+ declare const EXPIRING_SOON_DAYS = 7;
10
+ declare const EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
9
11
  declare const MIN_PASSWORD_LENGTH = 12;
10
12
  declare const MAX_PASSWORD_LENGTH = 256;
11
13
  declare const DEFAULT_VERSIONS_LIMIT = 20;
@@ -67,6 +69,7 @@ declare const UserDto: z.ZodObject<{
67
69
  createdAt: z.ZodISODateTime;
68
70
  twoFactorEnabled: z.ZodBoolean;
69
71
  twoFactorAppName: z.ZodNullable<z.ZodString>;
72
+ isSuperAdmin: z.ZodBoolean;
70
73
  }, z.core.$strict>;
71
74
  type UserDto = z.infer<typeof UserDto>;
72
75
  declare const TwoFactorSetupDto: z.ZodObject<{
@@ -101,6 +104,7 @@ type CreateProjectInput = z.infer<typeof CreateProjectInput>;
101
104
  declare const UpdateProjectInput: z.ZodObject<{
102
105
  name: z.ZodOptional<z.ZodString>;
103
106
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
+ disabled: z.ZodOptional<z.ZodBoolean>;
104
108
  }, z.core.$strict>;
105
109
  type UpdateProjectInput = z.infer<typeof UpdateProjectInput>;
106
110
  declare const ProjectDto: z.ZodObject<{
@@ -108,6 +112,7 @@ declare const ProjectDto: z.ZodObject<{
108
112
  name: z.ZodString;
109
113
  slug: z.ZodString;
110
114
  description: z.ZodNullable<z.ZodString>;
115
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
111
116
  createdAt: z.ZodISODateTime;
112
117
  updatedAt: z.ZodISODateTime;
113
118
  }, z.core.$strict>;
@@ -117,6 +122,7 @@ declare const ProjectSummaryDto: z.ZodObject<{
117
122
  name: z.ZodString;
118
123
  slug: z.ZodString;
119
124
  description: z.ZodNullable<z.ZodString>;
125
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
120
126
  createdAt: z.ZodISODateTime;
121
127
  updatedAt: z.ZodISODateTime;
122
128
  role: z.ZodEnum<{
@@ -182,16 +188,19 @@ type EnvironmentDto = z.infer<typeof EnvironmentDto>;
182
188
  declare const CreateVariableInput: z.ZodObject<{
183
189
  key: z.ZodString;
184
190
  value: z.ZodString;
191
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
185
192
  }, z.core.$strict>;
186
193
  type CreateVariableInput = z.infer<typeof CreateVariableInput>;
187
194
  declare const UpdateVariableInput: z.ZodObject<{
188
- value: z.ZodString;
195
+ value: z.ZodOptional<z.ZodString>;
196
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
189
197
  }, z.core.$strict>;
190
198
  type UpdateVariableInput = z.infer<typeof UpdateVariableInput>;
191
199
  declare const VariableMetaDto: z.ZodObject<{
192
200
  id: z.ZodUUID;
193
201
  key: z.ZodString;
194
202
  currentVersion: z.ZodNumber;
203
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
195
204
  updatedAt: z.ZodISODateTime;
196
205
  }, z.core.$strict>;
197
206
  type VariableMetaDto = z.infer<typeof VariableMetaDto>;
@@ -199,14 +208,15 @@ declare const VariableWithValueDto: z.ZodObject<{
199
208
  id: z.ZodUUID;
200
209
  key: z.ZodString;
201
210
  currentVersion: z.ZodNumber;
211
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
202
212
  updatedAt: z.ZodISODateTime;
203
213
  value: z.ZodString;
204
214
  }, z.core.$strict>;
205
215
  type VariableWithValueDto = z.infer<typeof VariableWithValueDto>;
206
216
  declare const BulkUpsertVariablesInput: z.ZodObject<{
207
217
  variables: z.ZodArray<z.ZodObject<{
208
- key: z.ZodString;
209
218
  value: z.ZodString;
219
+ key: z.ZodString;
210
220
  }, z.core.$strict>>;
211
221
  }, z.core.$strict>;
212
222
  type BulkUpsertVariablesInput = z.infer<typeof BulkUpsertVariablesInput>;
@@ -220,21 +230,47 @@ declare const CreateSharedVariableInput: z.ZodObject<{
220
230
  key: z.ZodString;
221
231
  value: z.ZodString;
222
232
  environmentIds: z.ZodArray<z.ZodUUID>;
233
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
223
234
  }, z.core.$strict>;
224
235
  type CreateSharedVariableInput = z.infer<typeof CreateSharedVariableInput>;
225
236
  declare const UpdateSharedVariableInput: z.ZodObject<{
226
237
  value: z.ZodOptional<z.ZodString>;
227
238
  environmentIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
239
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
228
240
  }, z.core.$strict>;
229
241
  type UpdateSharedVariableInput = z.infer<typeof UpdateSharedVariableInput>;
230
242
  declare const SharedVariableMetaDto: z.ZodObject<{
231
243
  id: z.ZodUUID;
232
244
  key: z.ZodString;
233
245
  currentVersion: z.ZodNumber;
246
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
234
247
  updatedAt: z.ZodISODateTime;
235
248
  environmentIds: z.ZodArray<z.ZodUUID>;
236
249
  }, z.core.$strict>;
237
250
  type SharedVariableMetaDto = z.infer<typeof SharedVariableMetaDto>;
251
+ declare const ExpiringSecretDto: z.ZodObject<{
252
+ reminderId: z.ZodUUID;
253
+ threshold: z.ZodNumber;
254
+ raisedAt: z.ZodISODateTime;
255
+ id: z.ZodUUID;
256
+ key: z.ZodString;
257
+ kind: z.ZodEnum<{
258
+ environment: "environment";
259
+ shared: "shared";
260
+ }>;
261
+ expiresAt: z.ZodISODateTime;
262
+ project: z.ZodObject<{
263
+ id: z.ZodUUID;
264
+ slug: z.ZodString;
265
+ name: z.ZodString;
266
+ }, z.core.$strict>;
267
+ environment: z.ZodNullable<z.ZodObject<{
268
+ id: z.ZodUUID;
269
+ slug: z.ZodString;
270
+ name: z.ZodString;
271
+ }, z.core.$strict>>;
272
+ }, z.core.$strict>;
273
+ type ExpiringSecretDto = z.infer<typeof ExpiringSecretDto>;
238
274
  declare const ListVersionsQuery: z.ZodObject<{
239
275
  cursor: z.ZodOptional<z.ZodString>;
240
276
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -331,6 +367,60 @@ declare const SdkProjectDto: z.ZodObject<{
331
367
  }, z.core.$strict>>;
332
368
  }, z.core.$strict>;
333
369
  type SdkProjectDto = z.infer<typeof SdkProjectDto>;
370
+ declare const AdminProjectDto: z.ZodObject<{
371
+ id: z.ZodUUID;
372
+ name: z.ZodString;
373
+ slug: z.ZodString;
374
+ description: z.ZodNullable<z.ZodString>;
375
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
376
+ createdAt: z.ZodISODateTime;
377
+ updatedAt: z.ZodISODateTime;
378
+ owner: z.ZodNullable<z.ZodObject<{
379
+ id: z.ZodUUID;
380
+ name: z.ZodString;
381
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
382
+ }, z.core.$strict>>;
383
+ memberCount: z.ZodNumber;
384
+ environmentCount: z.ZodNumber;
385
+ }, z.core.$strict>;
386
+ type AdminProjectDto = z.infer<typeof AdminProjectDto>;
387
+ declare const AdminUserDto: z.ZodObject<{
388
+ id: z.ZodUUID;
389
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
390
+ name: z.ZodString;
391
+ createdAt: z.ZodISODateTime;
392
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
393
+ isSuperAdmin: z.ZodBoolean;
394
+ projectCount: z.ZodNumber;
395
+ }, z.core.$strict>;
396
+ type AdminUserDto = z.infer<typeof AdminUserDto>;
397
+ declare const AdminUserDetailDto: z.ZodObject<{
398
+ id: z.ZodUUID;
399
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
400
+ name: z.ZodString;
401
+ createdAt: z.ZodISODateTime;
402
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
403
+ isSuperAdmin: z.ZodBoolean;
404
+ projectCount: z.ZodNumber;
405
+ projects: z.ZodArray<z.ZodObject<{
406
+ id: z.ZodUUID;
407
+ name: z.ZodString;
408
+ slug: z.ZodString;
409
+ role: z.ZodEnum<{
410
+ OWNER: "OWNER";
411
+ ADMIN: "ADMIN";
412
+ EDITOR: "EDITOR";
413
+ VIEWER: "VIEWER";
414
+ }>;
415
+ }, z.core.$strict>>;
416
+ }, z.core.$strict>;
417
+ type AdminUserDetailDto = z.infer<typeof AdminUserDetailDto>;
418
+ declare const AdminUpdateUserInput: z.ZodObject<{
419
+ name: z.ZodOptional<z.ZodString>;
420
+ email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
421
+ disabled: z.ZodOptional<z.ZodBoolean>;
422
+ }, z.core.$strict>;
423
+ type AdminUpdateUserInput = z.infer<typeof AdminUpdateUserInput>;
334
424
  declare const CreateTokenInput: z.ZodObject<{
335
425
  name: z.ZodString;
336
426
  access: z.ZodEnum<{
@@ -411,6 +501,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
411
501
  }>>;
412
502
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
413
503
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
504
+ CRON_SECRET: z.ZodOptional<z.ZodString>;
414
505
  }, z.core.$strict>, z.ZodTransform<{
415
506
  COOKIE_SECURE: boolean;
416
507
  NODE_ENV: "development" | "test" | "production";
@@ -421,6 +512,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
421
512
  MASTER_KEY: string;
422
513
  VARIABLE_HISTORY_LIMIT: number;
423
514
  TRUST_PROXY: number;
515
+ CRON_SECRET?: string | undefined;
424
516
  }, {
425
517
  NODE_ENV: "development" | "test" | "production";
426
518
  HOST: string;
@@ -431,7 +523,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
431
523
  VARIABLE_HISTORY_LIMIT: number;
432
524
  TRUST_PROXY: number;
433
525
  COOKIE_SECURE?: "true" | "false" | undefined;
526
+ CRON_SECRET?: string | undefined;
434
527
  }>>;
435
528
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
436
529
 
437
- export { AddMemberInput, type ApiEnvironment, ApiErrorBody, BulkUpsertVariablesInput, BulkUpsertVariablesResponse, CSRF_HEADER_NAME, CSRF_HEADER_VALUE, CreateEnvironmentInput, CreateProjectInput, CreateSharedVariableInput, CreateTokenInput, CreateVariableInput, CreatedTokenDto, DEFAULT_VERSIONS_LIMIT, EnvironmentDto, ErrorCode, ListVersionsQuery, LoginInput, MAX_AUTH_CODE_LENGTH, MAX_BULK_VARIABLES, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_PASSWORD_LENGTH, MAX_VALUE_BYTES, MAX_VERSIONS_LIMIT, MIN_PASSWORD_LENGTH, MemberDto, PaginatedVersionsResponse, ProjectDto, ProjectRole, ProjectSummaryDto, RECOVERY_CODE_COUNT, RecoveryCodesDto, RegisterInput, ResolvedVariableDto, ResolvedVariablesResponse, SLUG_REGEX, SdkEnvironmentDto, SdkProjectDto, SharedVariableMetaDto, TOKEN_PREFIX, TOTP_DIGITS, TokenAccess, TokenDto, TwoFactorConfirmInput, TwoFactorEnableInput, TwoFactorSetupDto, TwoFactorSetupInput, UpdateEnvironmentInput, UpdateMemberInput, UpdateProjectInput, UpdateSharedVariableInput, UpdateVariableInput, UserDto, VARIABLE_KEY_REGEX, VariableMetaDto, VariableVersionMetaDto, VariableVersionValueDto, VariableWithValueDto, VersionChangeType, apiEnvironmentSchema };
530
+ export { AddMemberInput, AdminProjectDto, AdminUpdateUserInput, AdminUserDetailDto, AdminUserDto, type ApiEnvironment, ApiErrorBody, BulkUpsertVariablesInput, BulkUpsertVariablesResponse, CSRF_HEADER_NAME, CSRF_HEADER_VALUE, CreateEnvironmentInput, CreateProjectInput, CreateSharedVariableInput, CreateTokenInput, CreateVariableInput, CreatedTokenDto, DEFAULT_VERSIONS_LIMIT, EXPIRING_SOON_DAYS, EXPIRY_REMINDER_DAYS, EnvironmentDto, ErrorCode, ExpiringSecretDto, ListVersionsQuery, LoginInput, MAX_AUTH_CODE_LENGTH, MAX_BULK_VARIABLES, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_PASSWORD_LENGTH, MAX_VALUE_BYTES, MAX_VERSIONS_LIMIT, MIN_PASSWORD_LENGTH, MemberDto, PaginatedVersionsResponse, ProjectDto, ProjectRole, ProjectSummaryDto, RECOVERY_CODE_COUNT, RecoveryCodesDto, RegisterInput, ResolvedVariableDto, ResolvedVariablesResponse, SLUG_REGEX, SdkEnvironmentDto, SdkProjectDto, SharedVariableMetaDto, TOKEN_PREFIX, TOTP_DIGITS, TokenAccess, TokenDto, TwoFactorConfirmInput, TwoFactorEnableInput, TwoFactorSetupDto, TwoFactorSetupInput, UpdateEnvironmentInput, UpdateMemberInput, UpdateProjectInput, UpdateSharedVariableInput, UpdateVariableInput, UserDto, VARIABLE_KEY_REGEX, VariableMetaDto, VariableVersionMetaDto, VariableVersionValueDto, VariableWithValueDto, VersionChangeType, apiEnvironmentSchema };
package/dist/index.js CHANGED
@@ -8,6 +8,8 @@ var MAX_KEY_LENGTH = 128;
8
8
  var MAX_VALUE_BYTES = 64 * 1024;
9
9
  var MAX_NAME_LENGTH = 64;
10
10
  var MAX_BULK_VARIABLES = 500;
11
+ var EXPIRING_SOON_DAYS = 7;
12
+ var EXPIRY_REMINDER_DAYS = [30, 7, 1];
11
13
  var MIN_PASSWORD_LENGTH = 12;
12
14
  var MAX_PASSWORD_LENGTH = 256;
13
15
  var DEFAULT_VERSIONS_LIMIT = 20;
@@ -50,6 +52,9 @@ var variableValue = z2.string().refine(
50
52
  message: `Value must be at most ${MAX_VALUE_BYTES} bytes`
51
53
  }
52
54
  );
55
+ var secretExpiry = isoDate.refine((value) => Date.parse(value) > Date.now(), {
56
+ message: "Expiry must be in the future"
57
+ }).nullable();
53
58
  var password = z2.string().min(MIN_PASSWORD_LENGTH).max(MAX_PASSWORD_LENGTH);
54
59
  var RegisterInput = z2.object({ email, name, password }).strict();
55
60
  var authCode = z2.string().trim().min(1, "Enter your code").max(MAX_AUTH_CODE_LENGTH);
@@ -65,7 +70,9 @@ var UserDto = z2.object({
65
70
  createdAt: isoDate,
66
71
  twoFactorEnabled: z2.boolean(),
67
72
  // Name the user gave the authenticator app at setup; null while 2FA is off.
68
- twoFactorAppName: z2.string().nullable()
73
+ twoFactorAppName: z2.string().nullable(),
74
+ // Whether the account may use the /admin pages (set directly in the database).
75
+ isSuperAdmin: z2.boolean()
69
76
  }).strict();
70
77
  var TwoFactorSetupDto = z2.object({ secret: z2.string(), otpauthUri: z2.string() }).strict();
71
78
  var TwoFactorSetupInput = z2.object({ password: z2.string().min(1).max(MAX_PASSWORD_LENGTH) }).strict();
@@ -81,13 +88,16 @@ var RecoveryCodesDto = z2.object({ recoveryCodes: z2.array(z2.string()) }).stric
81
88
  var CreateProjectInput = z2.object({ name, slug, description: z2.string().max(500).optional() }).strict();
82
89
  var UpdateProjectInput = z2.object({
83
90
  name: name.optional(),
84
- description: z2.string().max(500).nullable().optional()
91
+ description: z2.string().max(500).nullable().optional(),
92
+ disabled: z2.boolean().optional()
85
93
  }).strict();
86
94
  var ProjectDto = z2.object({
87
95
  id,
88
96
  name,
89
97
  slug,
90
98
  description: z2.string().nullable(),
99
+ // Null while the project is enabled.
100
+ disabledAt: isoDate.nullable(),
91
101
  createdAt: isoDate,
92
102
  updatedAt: isoDate
93
103
  }).strict();
@@ -108,19 +118,33 @@ var EnvironmentDto = z2.object({
108
118
  createdAt: isoDate,
109
119
  updatedAt: isoDate
110
120
  }).strict();
111
- var CreateVariableInput = z2.object({ key: variableKey, value: variableValue }).strict();
112
- var UpdateVariableInput = z2.object({ value: variableValue }).strict();
121
+ var CreateVariableInput = z2.object({
122
+ key: variableKey,
123
+ value: variableValue,
124
+ expiresAt: secretExpiry.optional()
125
+ }).strict();
126
+ var UpdateVariableInput = z2.object({
127
+ value: variableValue.optional(),
128
+ expiresAt: secretExpiry.optional()
129
+ }).strict().refine(
130
+ (input) => input.value !== void 0 || input.expiresAt !== void 0,
131
+ {
132
+ message: "Provide value and/or expiresAt"
133
+ }
134
+ );
113
135
  var VariableMetaDto = z2.object({
114
136
  id,
115
137
  key: variableKey,
116
138
  currentVersion: z2.number().int().min(1),
139
+ // Null when the secret never expires.
140
+ expiresAt: isoDate.nullable(),
117
141
  updatedAt: isoDate
118
142
  }).strict();
119
143
  var VariableWithValueDto = VariableMetaDto.extend({
120
144
  value: z2.string()
121
145
  });
122
146
  var BulkUpsertVariablesInput = z2.object({
123
- variables: z2.array(CreateVariableInput).min(1).max(MAX_BULK_VARIABLES).refine(
147
+ variables: z2.array(CreateVariableInput.omit({ expiresAt: true })).min(1).max(MAX_BULK_VARIABLES).refine(
124
148
  (items) => new Set(items.map((item) => item.key)).size === items.length,
125
149
  { message: "Duplicate keys are not allowed" }
126
150
  )
@@ -131,17 +155,39 @@ var BulkUpsertVariablesResponse = z2.object({
131
155
  unchanged: z2.number().int().min(0)
132
156
  }).strict();
133
157
  var environmentIds = z2.array(id).max(100);
134
- var CreateSharedVariableInput = z2.object({ key: variableKey, value: variableValue, environmentIds }).strict();
158
+ var CreateSharedVariableInput = z2.object({
159
+ key: variableKey,
160
+ value: variableValue,
161
+ environmentIds,
162
+ expiresAt: secretExpiry.optional()
163
+ }).strict();
135
164
  var UpdateSharedVariableInput = z2.object({
136
165
  value: variableValue.optional(),
137
- environmentIds: environmentIds.optional()
166
+ environmentIds: environmentIds.optional(),
167
+ expiresAt: secretExpiry.optional()
138
168
  }).strict().refine(
139
- (input) => input.value !== void 0 || input.environmentIds !== void 0,
169
+ (input) => input.value !== void 0 || input.environmentIds !== void 0 || input.expiresAt !== void 0,
140
170
  {
141
- message: "Provide value and/or environmentIds"
171
+ message: "Provide value, environmentIds and/or expiresAt"
142
172
  }
143
173
  );
144
174
  var SharedVariableMetaDto = VariableMetaDto.extend({ environmentIds });
175
+ var ExpiringSecretDto = z2.object({
176
+ // The reminder's own id, stable for as long as that stage lasts.
177
+ reminderId: id,
178
+ // Days before the expiry the reminder was raised for; 0 once the secret expired.
179
+ threshold: z2.number().int().min(0),
180
+ // When the reminder was logged.
181
+ raisedAt: isoDate,
182
+ // The secret.
183
+ id,
184
+ key: variableKey,
185
+ kind: z2.enum(["environment", "shared"]),
186
+ expiresAt: isoDate,
187
+ project: z2.object({ id, slug, name }).strict(),
188
+ // Null for a shared variable, which belongs to the project rather than one environment.
189
+ environment: z2.object({ id, slug, name }).strict().nullable()
190
+ }).strict();
145
191
  var ListVersionsQuery = z2.object({
146
192
  cursor: z2.string().min(1).max(256).optional(),
147
193
  limit: z2.coerce.number().int().min(1).max(MAX_VERSIONS_LIMIT).default(20)
@@ -177,6 +223,34 @@ var SdkProjectDto = z2.object({
177
223
  role: ProjectRole,
178
224
  environments: z2.array(SdkEnvironmentDto)
179
225
  }).strict();
226
+ var adminPerson = z2.object({ id, name, email }).strict();
227
+ var AdminProjectDto = ProjectDto.extend({
228
+ owner: adminPerson.nullable(),
229
+ memberCount: z2.number().int().min(0),
230
+ environmentCount: z2.number().int().min(0)
231
+ });
232
+ var AdminUserDto = z2.object({
233
+ id,
234
+ email,
235
+ name,
236
+ createdAt: isoDate,
237
+ // Null while the account is enabled.
238
+ disabledAt: isoDate.nullable(),
239
+ isSuperAdmin: z2.boolean(),
240
+ projectCount: z2.number().int().min(0)
241
+ }).strict();
242
+ var AdminUserDetailDto = AdminUserDto.extend({
243
+ // Every project the user is a member of, with their role there.
244
+ projects: z2.array(z2.object({ id, name, slug, role: ProjectRole }).strict())
245
+ });
246
+ var AdminUpdateUserInput = z2.object({
247
+ name: name.optional(),
248
+ email: email.optional(),
249
+ disabled: z2.boolean().optional()
250
+ }).strict().refine(
251
+ (input) => input.name !== void 0 || input.email !== void 0 || input.disabled !== void 0,
252
+ { message: "Provide name, email and/or disabled" }
253
+ );
180
254
  var CreateTokenInput = z2.object({
181
255
  name,
182
256
  access: TokenAccess,
@@ -228,13 +302,20 @@ var apiEnvironmentSchema = z3.object({
228
302
  COOKIE_SECURE: z3.enum(["true", "false"]).optional(),
229
303
  VARIABLE_HISTORY_LIMIT: z3.coerce.number().int().min(1).max(500).default(50),
230
304
  // Reverse-proxy hops in front of the API (Express `trust proxy`); 0 trusts none.
231
- TRUST_PROXY: z3.coerce.number().int().min(0).max(10).default(0)
305
+ TRUST_PROXY: z3.coerce.number().int().min(0).max(10).default(0),
306
+ // Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
307
+ // that endpoint off.
308
+ CRON_SECRET: z3.string().min(32).max(256).optional()
232
309
  }).strict().transform((environment) => ({
233
310
  ...environment,
234
311
  COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
235
312
  }));
236
313
  export {
237
314
  AddMemberInput,
315
+ AdminProjectDto,
316
+ AdminUpdateUserInput,
317
+ AdminUserDetailDto,
318
+ AdminUserDto,
238
319
  ApiErrorBody,
239
320
  BulkUpsertVariablesInput,
240
321
  BulkUpsertVariablesResponse,
@@ -247,8 +328,11 @@ export {
247
328
  CreateVariableInput,
248
329
  CreatedTokenDto,
249
330
  DEFAULT_VERSIONS_LIMIT,
331
+ EXPIRING_SOON_DAYS,
332
+ EXPIRY_REMINDER_DAYS,
250
333
  EnvironmentDto,
251
334
  ErrorCode,
335
+ ExpiringSecretDto,
252
336
  ListVersionsQuery,
253
337
  LoginInput,
254
338
  MAX_AUTH_CODE_LENGTH,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secretenvs/contracts",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Shared Zod schemas, types and constants for the SecretEnvs API, SDK and CLI.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ankityadavpurson/secretenvs#readme",