@secretenvs/contracts 1.3.1 → 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,17 +172,23 @@ 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();
177
- var ProjectSummaryDto = ProjectDto.extend({ role: ProjectRole });
188
+ var ProjectSummaryDto = ProjectDto.extend({
189
+ role: ProjectRole,
190
+ joinedAt: isoDate
191
+ });
178
192
  var AddMemberInput = import_zod2.z.object({ email, role: ProjectRole }).strict();
179
193
  var UpdateMemberInput = import_zod2.z.object({ role: ProjectRole }).strict();
180
194
  var MemberDto = import_zod2.z.object({ userId: id, email, name, role: ProjectRole, createdAt: isoDate }).strict();
@@ -188,19 +202,33 @@ var EnvironmentDto = import_zod2.z.object({
188
202
  createdAt: isoDate,
189
203
  updatedAt: isoDate
190
204
  }).strict();
191
- var CreateVariableInput = import_zod2.z.object({ key: variableKey, value: variableValue }).strict();
192
- 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
+ );
193
219
  var VariableMetaDto = import_zod2.z.object({
194
220
  id,
195
221
  key: variableKey,
196
222
  currentVersion: import_zod2.z.number().int().min(1),
223
+ // Null when the secret never expires.
224
+ expiresAt: isoDate.nullable(),
197
225
  updatedAt: isoDate
198
226
  }).strict();
199
227
  var VariableWithValueDto = VariableMetaDto.extend({
200
228
  value: import_zod2.z.string()
201
229
  });
202
230
  var BulkUpsertVariablesInput = import_zod2.z.object({
203
- 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(
204
232
  (items) => new Set(items.map((item) => item.key)).size === items.length,
205
233
  { message: "Duplicate keys are not allowed" }
206
234
  )
@@ -211,17 +239,39 @@ var BulkUpsertVariablesResponse = import_zod2.z.object({
211
239
  unchanged: import_zod2.z.number().int().min(0)
212
240
  }).strict();
213
241
  var environmentIds = import_zod2.z.array(id).max(100);
214
- 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();
215
248
  var UpdateSharedVariableInput = import_zod2.z.object({
216
249
  value: variableValue.optional(),
217
- environmentIds: environmentIds.optional()
250
+ environmentIds: environmentIds.optional(),
251
+ expiresAt: secretExpiry.optional()
218
252
  }).strict().refine(
219
- (input) => input.value !== void 0 || input.environmentIds !== void 0,
253
+ (input) => input.value !== void 0 || input.environmentIds !== void 0 || input.expiresAt !== void 0,
220
254
  {
221
- message: "Provide value and/or environmentIds"
255
+ message: "Provide value, environmentIds and/or expiresAt"
222
256
  }
223
257
  );
224
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();
225
275
  var ListVersionsQuery = import_zod2.z.object({
226
276
  cursor: import_zod2.z.string().min(1).max(256).optional(),
227
277
  limit: import_zod2.z.coerce.number().int().min(1).max(MAX_VERSIONS_LIMIT).default(20)
@@ -308,7 +358,10 @@ var apiEnvironmentSchema = import_zod3.z.object({
308
358
  COOKIE_SECURE: import_zod3.z.enum(["true", "false"]).optional(),
309
359
  VARIABLE_HISTORY_LIMIT: import_zod3.z.coerce.number().int().min(1).max(500).default(50),
310
360
  // Reverse-proxy hops in front of the API (Express `trust proxy`); 0 trusts none.
311
- 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()
312
365
  }).strict().transform((environment) => ({
313
366
  ...environment,
314
367
  COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
@@ -328,8 +381,11 @@ var apiEnvironmentSchema = import_zod3.z.object({
328
381
  CreateVariableInput,
329
382
  CreatedTokenDto,
330
383
  DEFAULT_VERSIONS_LIMIT,
384
+ EXPIRING_SOON_DAYS,
385
+ EXPIRY_REMINDER_DAYS,
331
386
  EnvironmentDto,
332
387
  ErrorCode,
388
+ ExpiringSecretDto,
333
389
  ListVersionsQuery,
334
390
  LoginInput,
335
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<{
@@ -125,6 +130,7 @@ declare const ProjectSummaryDto: z.ZodObject<{
125
130
  EDITOR: "EDITOR";
126
131
  VIEWER: "VIEWER";
127
132
  }>;
133
+ joinedAt: z.ZodISODateTime;
128
134
  }, z.core.$strict>;
129
135
  type ProjectSummaryDto = z.infer<typeof ProjectSummaryDto>;
130
136
  declare const AddMemberInput: z.ZodObject<{
@@ -181,16 +187,19 @@ type EnvironmentDto = z.infer<typeof EnvironmentDto>;
181
187
  declare const CreateVariableInput: z.ZodObject<{
182
188
  key: z.ZodString;
183
189
  value: z.ZodString;
190
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
184
191
  }, z.core.$strict>;
185
192
  type CreateVariableInput = z.infer<typeof CreateVariableInput>;
186
193
  declare const UpdateVariableInput: z.ZodObject<{
187
- value: z.ZodString;
194
+ value: z.ZodOptional<z.ZodString>;
195
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
188
196
  }, z.core.$strict>;
189
197
  type UpdateVariableInput = z.infer<typeof UpdateVariableInput>;
190
198
  declare const VariableMetaDto: z.ZodObject<{
191
199
  id: z.ZodUUID;
192
200
  key: z.ZodString;
193
201
  currentVersion: z.ZodNumber;
202
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
194
203
  updatedAt: z.ZodISODateTime;
195
204
  }, z.core.$strict>;
196
205
  type VariableMetaDto = z.infer<typeof VariableMetaDto>;
@@ -198,14 +207,15 @@ declare const VariableWithValueDto: z.ZodObject<{
198
207
  id: z.ZodUUID;
199
208
  key: z.ZodString;
200
209
  currentVersion: z.ZodNumber;
210
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
201
211
  updatedAt: z.ZodISODateTime;
202
212
  value: z.ZodString;
203
213
  }, z.core.$strict>;
204
214
  type VariableWithValueDto = z.infer<typeof VariableWithValueDto>;
205
215
  declare const BulkUpsertVariablesInput: z.ZodObject<{
206
216
  variables: z.ZodArray<z.ZodObject<{
207
- key: z.ZodString;
208
217
  value: z.ZodString;
218
+ key: z.ZodString;
209
219
  }, z.core.$strict>>;
210
220
  }, z.core.$strict>;
211
221
  type BulkUpsertVariablesInput = z.infer<typeof BulkUpsertVariablesInput>;
@@ -219,21 +229,47 @@ declare const CreateSharedVariableInput: z.ZodObject<{
219
229
  key: z.ZodString;
220
230
  value: z.ZodString;
221
231
  environmentIds: z.ZodArray<z.ZodUUID>;
232
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
222
233
  }, z.core.$strict>;
223
234
  type CreateSharedVariableInput = z.infer<typeof CreateSharedVariableInput>;
224
235
  declare const UpdateSharedVariableInput: z.ZodObject<{
225
236
  value: z.ZodOptional<z.ZodString>;
226
237
  environmentIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
238
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
227
239
  }, z.core.$strict>;
228
240
  type UpdateSharedVariableInput = z.infer<typeof UpdateSharedVariableInput>;
229
241
  declare const SharedVariableMetaDto: z.ZodObject<{
230
242
  id: z.ZodUUID;
231
243
  key: z.ZodString;
232
244
  currentVersion: z.ZodNumber;
245
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
233
246
  updatedAt: z.ZodISODateTime;
234
247
  environmentIds: z.ZodArray<z.ZodUUID>;
235
248
  }, z.core.$strict>;
236
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>;
237
273
  declare const ListVersionsQuery: z.ZodObject<{
238
274
  cursor: z.ZodOptional<z.ZodString>;
239
275
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -410,6 +446,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
410
446
  }>>;
411
447
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
412
448
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
449
+ CRON_SECRET: z.ZodOptional<z.ZodString>;
413
450
  }, z.core.$strict>, z.ZodTransform<{
414
451
  COOKIE_SECURE: boolean;
415
452
  NODE_ENV: "development" | "test" | "production";
@@ -420,6 +457,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
420
457
  MASTER_KEY: string;
421
458
  VARIABLE_HISTORY_LIMIT: number;
422
459
  TRUST_PROXY: number;
460
+ CRON_SECRET?: string | undefined;
423
461
  }, {
424
462
  NODE_ENV: "development" | "test" | "production";
425
463
  HOST: string;
@@ -430,7 +468,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
430
468
  VARIABLE_HISTORY_LIMIT: number;
431
469
  TRUST_PROXY: number;
432
470
  COOKIE_SECURE?: "true" | "false" | undefined;
471
+ CRON_SECRET?: string | undefined;
433
472
  }>>;
434
473
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
435
474
 
436
- 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<{
@@ -125,6 +130,7 @@ declare const ProjectSummaryDto: z.ZodObject<{
125
130
  EDITOR: "EDITOR";
126
131
  VIEWER: "VIEWER";
127
132
  }>;
133
+ joinedAt: z.ZodISODateTime;
128
134
  }, z.core.$strict>;
129
135
  type ProjectSummaryDto = z.infer<typeof ProjectSummaryDto>;
130
136
  declare const AddMemberInput: z.ZodObject<{
@@ -181,16 +187,19 @@ type EnvironmentDto = z.infer<typeof EnvironmentDto>;
181
187
  declare const CreateVariableInput: z.ZodObject<{
182
188
  key: z.ZodString;
183
189
  value: z.ZodString;
190
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
184
191
  }, z.core.$strict>;
185
192
  type CreateVariableInput = z.infer<typeof CreateVariableInput>;
186
193
  declare const UpdateVariableInput: z.ZodObject<{
187
- value: z.ZodString;
194
+ value: z.ZodOptional<z.ZodString>;
195
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
188
196
  }, z.core.$strict>;
189
197
  type UpdateVariableInput = z.infer<typeof UpdateVariableInput>;
190
198
  declare const VariableMetaDto: z.ZodObject<{
191
199
  id: z.ZodUUID;
192
200
  key: z.ZodString;
193
201
  currentVersion: z.ZodNumber;
202
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
194
203
  updatedAt: z.ZodISODateTime;
195
204
  }, z.core.$strict>;
196
205
  type VariableMetaDto = z.infer<typeof VariableMetaDto>;
@@ -198,14 +207,15 @@ declare const VariableWithValueDto: z.ZodObject<{
198
207
  id: z.ZodUUID;
199
208
  key: z.ZodString;
200
209
  currentVersion: z.ZodNumber;
210
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
201
211
  updatedAt: z.ZodISODateTime;
202
212
  value: z.ZodString;
203
213
  }, z.core.$strict>;
204
214
  type VariableWithValueDto = z.infer<typeof VariableWithValueDto>;
205
215
  declare const BulkUpsertVariablesInput: z.ZodObject<{
206
216
  variables: z.ZodArray<z.ZodObject<{
207
- key: z.ZodString;
208
217
  value: z.ZodString;
218
+ key: z.ZodString;
209
219
  }, z.core.$strict>>;
210
220
  }, z.core.$strict>;
211
221
  type BulkUpsertVariablesInput = z.infer<typeof BulkUpsertVariablesInput>;
@@ -219,21 +229,47 @@ declare const CreateSharedVariableInput: z.ZodObject<{
219
229
  key: z.ZodString;
220
230
  value: z.ZodString;
221
231
  environmentIds: z.ZodArray<z.ZodUUID>;
232
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
222
233
  }, z.core.$strict>;
223
234
  type CreateSharedVariableInput = z.infer<typeof CreateSharedVariableInput>;
224
235
  declare const UpdateSharedVariableInput: z.ZodObject<{
225
236
  value: z.ZodOptional<z.ZodString>;
226
237
  environmentIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
238
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
227
239
  }, z.core.$strict>;
228
240
  type UpdateSharedVariableInput = z.infer<typeof UpdateSharedVariableInput>;
229
241
  declare const SharedVariableMetaDto: z.ZodObject<{
230
242
  id: z.ZodUUID;
231
243
  key: z.ZodString;
232
244
  currentVersion: z.ZodNumber;
245
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
233
246
  updatedAt: z.ZodISODateTime;
234
247
  environmentIds: z.ZodArray<z.ZodUUID>;
235
248
  }, z.core.$strict>;
236
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>;
237
273
  declare const ListVersionsQuery: z.ZodObject<{
238
274
  cursor: z.ZodOptional<z.ZodString>;
239
275
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -410,6 +446,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
410
446
  }>>;
411
447
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
412
448
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
449
+ CRON_SECRET: z.ZodOptional<z.ZodString>;
413
450
  }, z.core.$strict>, z.ZodTransform<{
414
451
  COOKIE_SECURE: boolean;
415
452
  NODE_ENV: "development" | "test" | "production";
@@ -420,6 +457,7 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
420
457
  MASTER_KEY: string;
421
458
  VARIABLE_HISTORY_LIMIT: number;
422
459
  TRUST_PROXY: number;
460
+ CRON_SECRET?: string | undefined;
423
461
  }, {
424
462
  NODE_ENV: "development" | "test" | "production";
425
463
  HOST: string;
@@ -430,7 +468,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
430
468
  VARIABLE_HISTORY_LIMIT: number;
431
469
  TRUST_PROXY: number;
432
470
  COOKIE_SECURE?: "true" | "false" | undefined;
471
+ CRON_SECRET?: string | undefined;
433
472
  }>>;
434
473
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
435
474
 
436
- 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,17 +86,23 @@ 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();
94
- var ProjectSummaryDto = ProjectDto.extend({ role: ProjectRole });
102
+ var ProjectSummaryDto = ProjectDto.extend({
103
+ role: ProjectRole,
104
+ joinedAt: isoDate
105
+ });
95
106
  var AddMemberInput = z2.object({ email, role: ProjectRole }).strict();
96
107
  var UpdateMemberInput = z2.object({ role: ProjectRole }).strict();
97
108
  var MemberDto = z2.object({ userId: id, email, name, role: ProjectRole, createdAt: isoDate }).strict();
@@ -105,19 +116,33 @@ var EnvironmentDto = z2.object({
105
116
  createdAt: isoDate,
106
117
  updatedAt: isoDate
107
118
  }).strict();
108
- var CreateVariableInput = z2.object({ key: variableKey, value: variableValue }).strict();
109
- 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
+ );
110
133
  var VariableMetaDto = z2.object({
111
134
  id,
112
135
  key: variableKey,
113
136
  currentVersion: z2.number().int().min(1),
137
+ // Null when the secret never expires.
138
+ expiresAt: isoDate.nullable(),
114
139
  updatedAt: isoDate
115
140
  }).strict();
116
141
  var VariableWithValueDto = VariableMetaDto.extend({
117
142
  value: z2.string()
118
143
  });
119
144
  var BulkUpsertVariablesInput = z2.object({
120
- 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(
121
146
  (items) => new Set(items.map((item) => item.key)).size === items.length,
122
147
  { message: "Duplicate keys are not allowed" }
123
148
  )
@@ -128,17 +153,39 @@ var BulkUpsertVariablesResponse = z2.object({
128
153
  unchanged: z2.number().int().min(0)
129
154
  }).strict();
130
155
  var environmentIds = z2.array(id).max(100);
131
- 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();
132
162
  var UpdateSharedVariableInput = z2.object({
133
163
  value: variableValue.optional(),
134
- environmentIds: environmentIds.optional()
164
+ environmentIds: environmentIds.optional(),
165
+ expiresAt: secretExpiry.optional()
135
166
  }).strict().refine(
136
- (input) => input.value !== void 0 || input.environmentIds !== void 0,
167
+ (input) => input.value !== void 0 || input.environmentIds !== void 0 || input.expiresAt !== void 0,
137
168
  {
138
- message: "Provide value and/or environmentIds"
169
+ message: "Provide value, environmentIds and/or expiresAt"
139
170
  }
140
171
  );
141
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();
142
189
  var ListVersionsQuery = z2.object({
143
190
  cursor: z2.string().min(1).max(256).optional(),
144
191
  limit: z2.coerce.number().int().min(1).max(MAX_VERSIONS_LIMIT).default(20)
@@ -225,7 +272,10 @@ var apiEnvironmentSchema = z3.object({
225
272
  COOKIE_SECURE: z3.enum(["true", "false"]).optional(),
226
273
  VARIABLE_HISTORY_LIMIT: z3.coerce.number().int().min(1).max(500).default(50),
227
274
  // Reverse-proxy hops in front of the API (Express `trust proxy`); 0 trusts none.
228
- 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()
229
279
  }).strict().transform((environment) => ({
230
280
  ...environment,
231
281
  COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
@@ -244,8 +294,11 @@ export {
244
294
  CreateVariableInput,
245
295
  CreatedTokenDto,
246
296
  DEFAULT_VERSIONS_LIMIT,
297
+ EXPIRING_SOON_DAYS,
298
+ EXPIRY_REMINDER_DAYS,
247
299
  EnvironmentDto,
248
300
  ErrorCode,
301
+ ExpiringSecretDto,
249
302
  ListVersionsQuery,
250
303
  LoginInput,
251
304
  MAX_AUTH_CODE_LENGTH,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secretenvs/contracts",
3
- "version": "1.3.1",
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",