@secretenvs/contracts 1.4.0 → 1.5.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
@@ -33,8 +33,11 @@ __export(index_exports, {
33
33
  CreateVariableInput: () => CreateVariableInput,
34
34
  CreatedTokenDto: () => CreatedTokenDto,
35
35
  DEFAULT_VERSIONS_LIMIT: () => DEFAULT_VERSIONS_LIMIT,
36
+ EXPIRING_SOON_DAYS: () => EXPIRING_SOON_DAYS,
37
+ EXPIRY_REMINDER_DAYS: () => EXPIRY_REMINDER_DAYS,
36
38
  EnvironmentDto: () => EnvironmentDto,
37
39
  ErrorCode: () => ErrorCode,
40
+ ExpiringSecretDto: () => ExpiringSecretDto,
38
41
  ListVersionsQuery: () => ListVersionsQuery,
39
42
  LoginInput: () => LoginInput,
40
43
  MAX_AUTH_CODE_LENGTH: () => MAX_AUTH_CODE_LENGTH,
@@ -91,6 +94,8 @@ var MAX_KEY_LENGTH = 128;
91
94
  var MAX_VALUE_BYTES = 64 * 1024;
92
95
  var MAX_NAME_LENGTH = 64;
93
96
  var MAX_BULK_VARIABLES = 500;
97
+ var EXPIRING_SOON_DAYS = 7;
98
+ var EXPIRY_REMINDER_DAYS = [30, 7, 1];
94
99
  var MIN_PASSWORD_LENGTH = 12;
95
100
  var MAX_PASSWORD_LENGTH = 256;
96
101
  var DEFAULT_VERSIONS_LIMIT = 20;
@@ -133,6 +138,9 @@ var variableValue = import_zod2.z.string().refine(
133
138
  message: `Value must be at most ${MAX_VALUE_BYTES} bytes`
134
139
  }
135
140
  );
141
+ var secretExpiry = isoDate.refine((value) => Date.parse(value) > Date.now(), {
142
+ message: "Expiry must be in the future"
143
+ }).nullable();
136
144
  var password = import_zod2.z.string().min(MIN_PASSWORD_LENGTH).max(MAX_PASSWORD_LENGTH);
137
145
  var RegisterInput = import_zod2.z.object({ email, name, password }).strict();
138
146
  var authCode = import_zod2.z.string().trim().min(1, "Enter your code").max(MAX_AUTH_CODE_LENGTH);
@@ -164,13 +172,16 @@ var RecoveryCodesDto = import_zod2.z.object({ recoveryCodes: import_zod2.z.array
164
172
  var CreateProjectInput = import_zod2.z.object({ name, slug, description: import_zod2.z.string().max(500).optional() }).strict();
165
173
  var UpdateProjectInput = import_zod2.z.object({
166
174
  name: name.optional(),
167
- description: import_zod2.z.string().max(500).nullable().optional()
175
+ description: import_zod2.z.string().max(500).nullable().optional(),
176
+ disabled: import_zod2.z.boolean().optional()
168
177
  }).strict();
169
178
  var ProjectDto = import_zod2.z.object({
170
179
  id,
171
180
  name,
172
181
  slug,
173
182
  description: import_zod2.z.string().nullable(),
183
+ // Null while the project is enabled.
184
+ disabledAt: isoDate.nullable(),
174
185
  createdAt: isoDate,
175
186
  updatedAt: isoDate
176
187
  }).strict();
@@ -191,19 +202,33 @@ var EnvironmentDto = import_zod2.z.object({
191
202
  createdAt: isoDate,
192
203
  updatedAt: isoDate
193
204
  }).strict();
194
- var CreateVariableInput = import_zod2.z.object({ key: variableKey, value: variableValue }).strict();
195
- var UpdateVariableInput = import_zod2.z.object({ value: variableValue }).strict();
205
+ var CreateVariableInput = import_zod2.z.object({
206
+ key: variableKey,
207
+ value: variableValue,
208
+ expiresAt: secretExpiry.optional()
209
+ }).strict();
210
+ var UpdateVariableInput = import_zod2.z.object({
211
+ value: variableValue.optional(),
212
+ expiresAt: secretExpiry.optional()
213
+ }).strict().refine(
214
+ (input) => input.value !== void 0 || input.expiresAt !== void 0,
215
+ {
216
+ message: "Provide value and/or expiresAt"
217
+ }
218
+ );
196
219
  var VariableMetaDto = import_zod2.z.object({
197
220
  id,
198
221
  key: variableKey,
199
222
  currentVersion: import_zod2.z.number().int().min(1),
223
+ // Null when the secret never expires.
224
+ expiresAt: isoDate.nullable(),
200
225
  updatedAt: isoDate
201
226
  }).strict();
202
227
  var VariableWithValueDto = VariableMetaDto.extend({
203
228
  value: import_zod2.z.string()
204
229
  });
205
230
  var BulkUpsertVariablesInput = import_zod2.z.object({
206
- variables: import_zod2.z.array(CreateVariableInput).min(1).max(MAX_BULK_VARIABLES).refine(
231
+ variables: import_zod2.z.array(CreateVariableInput.omit({ expiresAt: true })).min(1).max(MAX_BULK_VARIABLES).refine(
207
232
  (items) => new Set(items.map((item) => item.key)).size === items.length,
208
233
  { message: "Duplicate keys are not allowed" }
209
234
  )
@@ -214,17 +239,39 @@ var BulkUpsertVariablesResponse = import_zod2.z.object({
214
239
  unchanged: import_zod2.z.number().int().min(0)
215
240
  }).strict();
216
241
  var environmentIds = import_zod2.z.array(id).max(100);
217
- var CreateSharedVariableInput = import_zod2.z.object({ key: variableKey, value: variableValue, environmentIds }).strict();
242
+ var CreateSharedVariableInput = import_zod2.z.object({
243
+ key: variableKey,
244
+ value: variableValue,
245
+ environmentIds,
246
+ expiresAt: secretExpiry.optional()
247
+ }).strict();
218
248
  var UpdateSharedVariableInput = import_zod2.z.object({
219
249
  value: variableValue.optional(),
220
- environmentIds: environmentIds.optional()
250
+ environmentIds: environmentIds.optional(),
251
+ expiresAt: secretExpiry.optional()
221
252
  }).strict().refine(
222
- (input) => input.value !== void 0 || input.environmentIds !== void 0,
253
+ (input) => input.value !== void 0 || input.environmentIds !== void 0 || input.expiresAt !== void 0,
223
254
  {
224
- message: "Provide value and/or environmentIds"
255
+ message: "Provide value, environmentIds and/or expiresAt"
225
256
  }
226
257
  );
227
258
  var SharedVariableMetaDto = VariableMetaDto.extend({ environmentIds });
259
+ var ExpiringSecretDto = import_zod2.z.object({
260
+ // The reminder's own id, stable for as long as that stage lasts.
261
+ reminderId: id,
262
+ // Days before the expiry the reminder was raised for; 0 once the secret expired.
263
+ threshold: import_zod2.z.number().int().min(0),
264
+ // When the reminder was logged.
265
+ raisedAt: isoDate,
266
+ // The secret.
267
+ id,
268
+ key: variableKey,
269
+ kind: import_zod2.z.enum(["environment", "shared"]),
270
+ expiresAt: isoDate,
271
+ project: import_zod2.z.object({ id, slug, name }).strict(),
272
+ // Null for a shared variable, which belongs to the project rather than one environment.
273
+ environment: import_zod2.z.object({ id, slug, name }).strict().nullable()
274
+ }).strict();
228
275
  var ListVersionsQuery = import_zod2.z.object({
229
276
  cursor: import_zod2.z.string().min(1).max(256).optional(),
230
277
  limit: import_zod2.z.coerce.number().int().min(1).max(MAX_VERSIONS_LIMIT).default(20)
@@ -311,7 +358,10 @@ var apiEnvironmentSchema = import_zod3.z.object({
311
358
  COOKIE_SECURE: import_zod3.z.enum(["true", "false"]).optional(),
312
359
  VARIABLE_HISTORY_LIMIT: import_zod3.z.coerce.number().int().min(1).max(500).default(50),
313
360
  // 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)
361
+ TRUST_PROXY: import_zod3.z.coerce.number().int().min(0).max(10).default(0),
362
+ // Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
363
+ // that endpoint off.
364
+ CRON_SECRET: import_zod3.z.string().min(32).max(256).optional()
315
365
  }).strict().transform((environment) => ({
316
366
  ...environment,
317
367
  COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
@@ -331,8 +381,11 @@ var apiEnvironmentSchema = import_zod3.z.object({
331
381
  CreateVariableInput,
332
382
  CreatedTokenDto,
333
383
  DEFAULT_VERSIONS_LIMIT,
384
+ EXPIRING_SOON_DAYS,
385
+ EXPIRY_REMINDER_DAYS,
334
386
  EnvironmentDto,
335
387
  ErrorCode,
388
+ ExpiringSecretDto,
336
389
  ListVersionsQuery,
337
390
  LoginInput,
338
391
  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;
@@ -101,6 +103,7 @@ type CreateProjectInput = z.infer<typeof CreateProjectInput>;
101
103
  declare const UpdateProjectInput: z.ZodObject<{
102
104
  name: z.ZodOptional<z.ZodString>;
103
105
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
+ disabled: z.ZodOptional<z.ZodBoolean>;
104
107
  }, z.core.$strict>;
105
108
  type UpdateProjectInput = z.infer<typeof UpdateProjectInput>;
106
109
  declare const ProjectDto: z.ZodObject<{
@@ -108,6 +111,7 @@ declare const ProjectDto: z.ZodObject<{
108
111
  name: z.ZodString;
109
112
  slug: z.ZodString;
110
113
  description: z.ZodNullable<z.ZodString>;
114
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
111
115
  createdAt: z.ZodISODateTime;
112
116
  updatedAt: z.ZodISODateTime;
113
117
  }, z.core.$strict>;
@@ -117,6 +121,7 @@ declare const ProjectSummaryDto: z.ZodObject<{
117
121
  name: z.ZodString;
118
122
  slug: z.ZodString;
119
123
  description: z.ZodNullable<z.ZodString>;
124
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
120
125
  createdAt: z.ZodISODateTime;
121
126
  updatedAt: z.ZodISODateTime;
122
127
  role: z.ZodEnum<{
@@ -182,16 +187,19 @@ type EnvironmentDto = z.infer<typeof EnvironmentDto>;
182
187
  declare const CreateVariableInput: z.ZodObject<{
183
188
  key: z.ZodString;
184
189
  value: z.ZodString;
190
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
185
191
  }, z.core.$strict>;
186
192
  type CreateVariableInput = z.infer<typeof CreateVariableInput>;
187
193
  declare const UpdateVariableInput: z.ZodObject<{
188
- value: z.ZodString;
194
+ value: z.ZodOptional<z.ZodString>;
195
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
189
196
  }, z.core.$strict>;
190
197
  type UpdateVariableInput = z.infer<typeof UpdateVariableInput>;
191
198
  declare const VariableMetaDto: z.ZodObject<{
192
199
  id: z.ZodUUID;
193
200
  key: z.ZodString;
194
201
  currentVersion: z.ZodNumber;
202
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
195
203
  updatedAt: z.ZodISODateTime;
196
204
  }, z.core.$strict>;
197
205
  type VariableMetaDto = z.infer<typeof VariableMetaDto>;
@@ -199,14 +207,15 @@ declare const VariableWithValueDto: z.ZodObject<{
199
207
  id: z.ZodUUID;
200
208
  key: z.ZodString;
201
209
  currentVersion: z.ZodNumber;
210
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
202
211
  updatedAt: z.ZodISODateTime;
203
212
  value: z.ZodString;
204
213
  }, z.core.$strict>;
205
214
  type VariableWithValueDto = z.infer<typeof VariableWithValueDto>;
206
215
  declare const BulkUpsertVariablesInput: z.ZodObject<{
207
216
  variables: z.ZodArray<z.ZodObject<{
208
- key: z.ZodString;
209
217
  value: z.ZodString;
218
+ key: z.ZodString;
210
219
  }, z.core.$strict>>;
211
220
  }, z.core.$strict>;
212
221
  type BulkUpsertVariablesInput = z.infer<typeof BulkUpsertVariablesInput>;
@@ -220,21 +229,47 @@ declare const CreateSharedVariableInput: z.ZodObject<{
220
229
  key: z.ZodString;
221
230
  value: z.ZodString;
222
231
  environmentIds: z.ZodArray<z.ZodUUID>;
232
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
223
233
  }, z.core.$strict>;
224
234
  type CreateSharedVariableInput = z.infer<typeof CreateSharedVariableInput>;
225
235
  declare const UpdateSharedVariableInput: z.ZodObject<{
226
236
  value: z.ZodOptional<z.ZodString>;
227
237
  environmentIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
238
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
228
239
  }, z.core.$strict>;
229
240
  type UpdateSharedVariableInput = z.infer<typeof UpdateSharedVariableInput>;
230
241
  declare const SharedVariableMetaDto: z.ZodObject<{
231
242
  id: z.ZodUUID;
232
243
  key: z.ZodString;
233
244
  currentVersion: z.ZodNumber;
245
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
234
246
  updatedAt: z.ZodISODateTime;
235
247
  environmentIds: z.ZodArray<z.ZodUUID>;
236
248
  }, z.core.$strict>;
237
249
  type SharedVariableMetaDto = z.infer<typeof SharedVariableMetaDto>;
250
+ declare const ExpiringSecretDto: z.ZodObject<{
251
+ reminderId: z.ZodUUID;
252
+ threshold: z.ZodNumber;
253
+ raisedAt: z.ZodISODateTime;
254
+ id: z.ZodUUID;
255
+ key: z.ZodString;
256
+ kind: z.ZodEnum<{
257
+ environment: "environment";
258
+ shared: "shared";
259
+ }>;
260
+ expiresAt: z.ZodISODateTime;
261
+ project: z.ZodObject<{
262
+ id: z.ZodUUID;
263
+ slug: z.ZodString;
264
+ name: z.ZodString;
265
+ }, z.core.$strict>;
266
+ environment: z.ZodNullable<z.ZodObject<{
267
+ id: z.ZodUUID;
268
+ slug: z.ZodString;
269
+ name: z.ZodString;
270
+ }, z.core.$strict>>;
271
+ }, z.core.$strict>;
272
+ type ExpiringSecretDto = z.infer<typeof ExpiringSecretDto>;
238
273
  declare const ListVersionsQuery: z.ZodObject<{
239
274
  cursor: z.ZodOptional<z.ZodString>;
240
275
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -411,6 +446,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
411
446
  }>>;
412
447
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
413
448
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
449
+ CRON_SECRET: z.ZodOptional<z.ZodString>;
414
450
  }, z.core.$strict>, z.ZodTransform<{
415
451
  COOKIE_SECURE: boolean;
416
452
  NODE_ENV: "development" | "test" | "production";
@@ -421,6 +457,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
421
457
  MASTER_KEY: string;
422
458
  VARIABLE_HISTORY_LIMIT: number;
423
459
  TRUST_PROXY: number;
460
+ CRON_SECRET?: string | undefined;
424
461
  }, {
425
462
  NODE_ENV: "development" | "test" | "production";
426
463
  HOST: string;
@@ -431,7 +468,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
431
468
  VARIABLE_HISTORY_LIMIT: number;
432
469
  TRUST_PROXY: number;
433
470
  COOKIE_SECURE?: "true" | "false" | undefined;
471
+ CRON_SECRET?: string | undefined;
434
472
  }>>;
435
473
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
436
474
 
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 };
475
+ export { AddMemberInput, 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;
@@ -101,6 +103,7 @@ type CreateProjectInput = z.infer<typeof CreateProjectInput>;
101
103
  declare const UpdateProjectInput: z.ZodObject<{
102
104
  name: z.ZodOptional<z.ZodString>;
103
105
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
+ disabled: z.ZodOptional<z.ZodBoolean>;
104
107
  }, z.core.$strict>;
105
108
  type UpdateProjectInput = z.infer<typeof UpdateProjectInput>;
106
109
  declare const ProjectDto: z.ZodObject<{
@@ -108,6 +111,7 @@ declare const ProjectDto: z.ZodObject<{
108
111
  name: z.ZodString;
109
112
  slug: z.ZodString;
110
113
  description: z.ZodNullable<z.ZodString>;
114
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
111
115
  createdAt: z.ZodISODateTime;
112
116
  updatedAt: z.ZodISODateTime;
113
117
  }, z.core.$strict>;
@@ -117,6 +121,7 @@ declare const ProjectSummaryDto: z.ZodObject<{
117
121
  name: z.ZodString;
118
122
  slug: z.ZodString;
119
123
  description: z.ZodNullable<z.ZodString>;
124
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
120
125
  createdAt: z.ZodISODateTime;
121
126
  updatedAt: z.ZodISODateTime;
122
127
  role: z.ZodEnum<{
@@ -182,16 +187,19 @@ type EnvironmentDto = z.infer<typeof EnvironmentDto>;
182
187
  declare const CreateVariableInput: z.ZodObject<{
183
188
  key: z.ZodString;
184
189
  value: z.ZodString;
190
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
185
191
  }, z.core.$strict>;
186
192
  type CreateVariableInput = z.infer<typeof CreateVariableInput>;
187
193
  declare const UpdateVariableInput: z.ZodObject<{
188
- value: z.ZodString;
194
+ value: z.ZodOptional<z.ZodString>;
195
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
189
196
  }, z.core.$strict>;
190
197
  type UpdateVariableInput = z.infer<typeof UpdateVariableInput>;
191
198
  declare const VariableMetaDto: z.ZodObject<{
192
199
  id: z.ZodUUID;
193
200
  key: z.ZodString;
194
201
  currentVersion: z.ZodNumber;
202
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
195
203
  updatedAt: z.ZodISODateTime;
196
204
  }, z.core.$strict>;
197
205
  type VariableMetaDto = z.infer<typeof VariableMetaDto>;
@@ -199,14 +207,15 @@ declare const VariableWithValueDto: z.ZodObject<{
199
207
  id: z.ZodUUID;
200
208
  key: z.ZodString;
201
209
  currentVersion: z.ZodNumber;
210
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
202
211
  updatedAt: z.ZodISODateTime;
203
212
  value: z.ZodString;
204
213
  }, z.core.$strict>;
205
214
  type VariableWithValueDto = z.infer<typeof VariableWithValueDto>;
206
215
  declare const BulkUpsertVariablesInput: z.ZodObject<{
207
216
  variables: z.ZodArray<z.ZodObject<{
208
- key: z.ZodString;
209
217
  value: z.ZodString;
218
+ key: z.ZodString;
210
219
  }, z.core.$strict>>;
211
220
  }, z.core.$strict>;
212
221
  type BulkUpsertVariablesInput = z.infer<typeof BulkUpsertVariablesInput>;
@@ -220,21 +229,47 @@ declare const CreateSharedVariableInput: z.ZodObject<{
220
229
  key: z.ZodString;
221
230
  value: z.ZodString;
222
231
  environmentIds: z.ZodArray<z.ZodUUID>;
232
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
223
233
  }, z.core.$strict>;
224
234
  type CreateSharedVariableInput = z.infer<typeof CreateSharedVariableInput>;
225
235
  declare const UpdateSharedVariableInput: z.ZodObject<{
226
236
  value: z.ZodOptional<z.ZodString>;
227
237
  environmentIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
238
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
228
239
  }, z.core.$strict>;
229
240
  type UpdateSharedVariableInput = z.infer<typeof UpdateSharedVariableInput>;
230
241
  declare const SharedVariableMetaDto: z.ZodObject<{
231
242
  id: z.ZodUUID;
232
243
  key: z.ZodString;
233
244
  currentVersion: z.ZodNumber;
245
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
234
246
  updatedAt: z.ZodISODateTime;
235
247
  environmentIds: z.ZodArray<z.ZodUUID>;
236
248
  }, z.core.$strict>;
237
249
  type SharedVariableMetaDto = z.infer<typeof SharedVariableMetaDto>;
250
+ declare const ExpiringSecretDto: z.ZodObject<{
251
+ reminderId: z.ZodUUID;
252
+ threshold: z.ZodNumber;
253
+ raisedAt: z.ZodISODateTime;
254
+ id: z.ZodUUID;
255
+ key: z.ZodString;
256
+ kind: z.ZodEnum<{
257
+ environment: "environment";
258
+ shared: "shared";
259
+ }>;
260
+ expiresAt: z.ZodISODateTime;
261
+ project: z.ZodObject<{
262
+ id: z.ZodUUID;
263
+ slug: z.ZodString;
264
+ name: z.ZodString;
265
+ }, z.core.$strict>;
266
+ environment: z.ZodNullable<z.ZodObject<{
267
+ id: z.ZodUUID;
268
+ slug: z.ZodString;
269
+ name: z.ZodString;
270
+ }, z.core.$strict>>;
271
+ }, z.core.$strict>;
272
+ type ExpiringSecretDto = z.infer<typeof ExpiringSecretDto>;
238
273
  declare const ListVersionsQuery: z.ZodObject<{
239
274
  cursor: z.ZodOptional<z.ZodString>;
240
275
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -411,6 +446,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
411
446
  }>>;
412
447
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
413
448
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
449
+ CRON_SECRET: z.ZodOptional<z.ZodString>;
414
450
  }, z.core.$strict>, z.ZodTransform<{
415
451
  COOKIE_SECURE: boolean;
416
452
  NODE_ENV: "development" | "test" | "production";
@@ -421,6 +457,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
421
457
  MASTER_KEY: string;
422
458
  VARIABLE_HISTORY_LIMIT: number;
423
459
  TRUST_PROXY: number;
460
+ CRON_SECRET?: string | undefined;
424
461
  }, {
425
462
  NODE_ENV: "development" | "test" | "production";
426
463
  HOST: string;
@@ -431,7 +468,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
431
468
  VARIABLE_HISTORY_LIMIT: number;
432
469
  TRUST_PROXY: number;
433
470
  COOKIE_SECURE?: "true" | "false" | undefined;
471
+ CRON_SECRET?: string | undefined;
434
472
  }>>;
435
473
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
436
474
 
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 };
475
+ export { AddMemberInput, 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);
@@ -81,13 +86,16 @@ var RecoveryCodesDto = z2.object({ recoveryCodes: z2.array(z2.string()) }).stric
81
86
  var CreateProjectInput = z2.object({ name, slug, description: z2.string().max(500).optional() }).strict();
82
87
  var UpdateProjectInput = z2.object({
83
88
  name: name.optional(),
84
- description: z2.string().max(500).nullable().optional()
89
+ description: z2.string().max(500).nullable().optional(),
90
+ disabled: z2.boolean().optional()
85
91
  }).strict();
86
92
  var ProjectDto = z2.object({
87
93
  id,
88
94
  name,
89
95
  slug,
90
96
  description: z2.string().nullable(),
97
+ // Null while the project is enabled.
98
+ disabledAt: isoDate.nullable(),
91
99
  createdAt: isoDate,
92
100
  updatedAt: isoDate
93
101
  }).strict();
@@ -108,19 +116,33 @@ var EnvironmentDto = z2.object({
108
116
  createdAt: isoDate,
109
117
  updatedAt: isoDate
110
118
  }).strict();
111
- var CreateVariableInput = z2.object({ key: variableKey, value: variableValue }).strict();
112
- var UpdateVariableInput = z2.object({ value: variableValue }).strict();
119
+ var CreateVariableInput = z2.object({
120
+ key: variableKey,
121
+ value: variableValue,
122
+ expiresAt: secretExpiry.optional()
123
+ }).strict();
124
+ var UpdateVariableInput = z2.object({
125
+ value: variableValue.optional(),
126
+ expiresAt: secretExpiry.optional()
127
+ }).strict().refine(
128
+ (input) => input.value !== void 0 || input.expiresAt !== void 0,
129
+ {
130
+ message: "Provide value and/or expiresAt"
131
+ }
132
+ );
113
133
  var VariableMetaDto = z2.object({
114
134
  id,
115
135
  key: variableKey,
116
136
  currentVersion: z2.number().int().min(1),
137
+ // Null when the secret never expires.
138
+ expiresAt: isoDate.nullable(),
117
139
  updatedAt: isoDate
118
140
  }).strict();
119
141
  var VariableWithValueDto = VariableMetaDto.extend({
120
142
  value: z2.string()
121
143
  });
122
144
  var BulkUpsertVariablesInput = z2.object({
123
- variables: z2.array(CreateVariableInput).min(1).max(MAX_BULK_VARIABLES).refine(
145
+ variables: z2.array(CreateVariableInput.omit({ expiresAt: true })).min(1).max(MAX_BULK_VARIABLES).refine(
124
146
  (items) => new Set(items.map((item) => item.key)).size === items.length,
125
147
  { message: "Duplicate keys are not allowed" }
126
148
  )
@@ -131,17 +153,39 @@ var BulkUpsertVariablesResponse = z2.object({
131
153
  unchanged: z2.number().int().min(0)
132
154
  }).strict();
133
155
  var environmentIds = z2.array(id).max(100);
134
- var CreateSharedVariableInput = z2.object({ key: variableKey, value: variableValue, environmentIds }).strict();
156
+ var CreateSharedVariableInput = z2.object({
157
+ key: variableKey,
158
+ value: variableValue,
159
+ environmentIds,
160
+ expiresAt: secretExpiry.optional()
161
+ }).strict();
135
162
  var UpdateSharedVariableInput = z2.object({
136
163
  value: variableValue.optional(),
137
- environmentIds: environmentIds.optional()
164
+ environmentIds: environmentIds.optional(),
165
+ expiresAt: secretExpiry.optional()
138
166
  }).strict().refine(
139
- (input) => input.value !== void 0 || input.environmentIds !== void 0,
167
+ (input) => input.value !== void 0 || input.environmentIds !== void 0 || input.expiresAt !== void 0,
140
168
  {
141
- message: "Provide value and/or environmentIds"
169
+ message: "Provide value, environmentIds and/or expiresAt"
142
170
  }
143
171
  );
144
172
  var SharedVariableMetaDto = VariableMetaDto.extend({ environmentIds });
173
+ var ExpiringSecretDto = z2.object({
174
+ // The reminder's own id, stable for as long as that stage lasts.
175
+ reminderId: id,
176
+ // Days before the expiry the reminder was raised for; 0 once the secret expired.
177
+ threshold: z2.number().int().min(0),
178
+ // When the reminder was logged.
179
+ raisedAt: isoDate,
180
+ // The secret.
181
+ id,
182
+ key: variableKey,
183
+ kind: z2.enum(["environment", "shared"]),
184
+ expiresAt: isoDate,
185
+ project: z2.object({ id, slug, name }).strict(),
186
+ // Null for a shared variable, which belongs to the project rather than one environment.
187
+ environment: z2.object({ id, slug, name }).strict().nullable()
188
+ }).strict();
145
189
  var ListVersionsQuery = z2.object({
146
190
  cursor: z2.string().min(1).max(256).optional(),
147
191
  limit: z2.coerce.number().int().min(1).max(MAX_VERSIONS_LIMIT).default(20)
@@ -228,7 +272,10 @@ var apiEnvironmentSchema = z3.object({
228
272
  COOKIE_SECURE: z3.enum(["true", "false"]).optional(),
229
273
  VARIABLE_HISTORY_LIMIT: z3.coerce.number().int().min(1).max(500).default(50),
230
274
  // 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)
275
+ TRUST_PROXY: z3.coerce.number().int().min(0).max(10).default(0),
276
+ // Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
277
+ // that endpoint off.
278
+ CRON_SECRET: z3.string().min(32).max(256).optional()
232
279
  }).strict().transform((environment) => ({
233
280
  ...environment,
234
281
  COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
@@ -247,8 +294,11 @@ export {
247
294
  CreateVariableInput,
248
295
  CreatedTokenDto,
249
296
  DEFAULT_VERSIONS_LIMIT,
297
+ EXPIRING_SOON_DAYS,
298
+ EXPIRY_REMINDER_DAYS,
250
299
  EnvironmentDto,
251
300
  ErrorCode,
301
+ ExpiringSecretDto,
252
302
  ListVersionsQuery,
253
303
  LoginInput,
254
304
  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.5.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",