@secretenvs/contracts 1.5.0 → 1.7.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,7 +21,12 @@ 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,
29
+ AuthOptionsDto: () => AuthOptionsDto,
25
30
  BulkUpsertVariablesInput: () => BulkUpsertVariablesInput,
26
31
  BulkUpsertVariablesResponse: () => BulkUpsertVariablesResponse,
27
32
  CSRF_HEADER_NAME: () => CSRF_HEADER_NAME,
@@ -156,7 +161,20 @@ var UserDto = import_zod2.z.object({
156
161
  createdAt: isoDate,
157
162
  twoFactorEnabled: import_zod2.z.boolean(),
158
163
  // Name the user gave the authenticator app at setup; null while 2FA is off.
159
- twoFactorAppName: import_zod2.z.string().nullable()
164
+ twoFactorAppName: import_zod2.z.string().nullable(),
165
+ // Whether the account may use the /admin pages (set directly in the database).
166
+ isSuperAdmin: import_zod2.z.boolean(),
167
+ // Linked to a SIAM account: name and email follow SIAM, so they are not edited here.
168
+ managedBySiam: import_zod2.z.boolean(),
169
+ // Has a password of its own. Accounts created through SIAM do not, and SIAM handles their
170
+ // password and two-factor authentication.
171
+ hasPassword: import_zod2.z.boolean()
172
+ }).strict();
173
+ var AuthOptionsDto = import_zod2.z.object({
174
+ // Sign-in through SIAM is configured on this server.
175
+ siam: import_zod2.z.boolean(),
176
+ // Where people manage their SIAM account; null when it is not configured or SIAM is off.
177
+ profileUrl: import_zod2.z.string().nullable()
160
178
  }).strict();
161
179
  var TwoFactorSetupDto = import_zod2.z.object({ secret: import_zod2.z.string(), otpauthUri: import_zod2.z.string() }).strict();
162
180
  var TwoFactorSetupInput = import_zod2.z.object({ password: import_zod2.z.string().min(1).max(MAX_PASSWORD_LENGTH) }).strict();
@@ -307,6 +325,36 @@ var SdkProjectDto = import_zod2.z.object({
307
325
  role: ProjectRole,
308
326
  environments: import_zod2.z.array(SdkEnvironmentDto)
309
327
  }).strict();
328
+ var adminPerson = import_zod2.z.object({ id, name, email }).strict();
329
+ var AdminProjectDto = ProjectDto.extend({
330
+ owner: adminPerson.nullable(),
331
+ memberCount: import_zod2.z.number().int().min(0),
332
+ environmentCount: import_zod2.z.number().int().min(0)
333
+ });
334
+ var AdminUserDto = import_zod2.z.object({
335
+ id,
336
+ email,
337
+ name,
338
+ createdAt: isoDate,
339
+ // Null while the account is enabled.
340
+ disabledAt: isoDate.nullable(),
341
+ isSuperAdmin: import_zod2.z.boolean(),
342
+ // Linked to a SIAM account: its name and email belong to SIAM and cannot be edited here.
343
+ managedBySiam: import_zod2.z.boolean(),
344
+ projectCount: import_zod2.z.number().int().min(0)
345
+ }).strict();
346
+ var AdminUserDetailDto = AdminUserDto.extend({
347
+ // Every project the user is a member of, with their role there.
348
+ projects: import_zod2.z.array(import_zod2.z.object({ id, name, slug, role: ProjectRole }).strict())
349
+ });
350
+ var AdminUpdateUserInput = import_zod2.z.object({
351
+ name: name.optional(),
352
+ email: email.optional(),
353
+ disabled: import_zod2.z.boolean().optional()
354
+ }).strict().refine(
355
+ (input) => input.name !== void 0 || input.email !== void 0 || input.disabled !== void 0,
356
+ { message: "Provide name, email and/or disabled" }
357
+ );
310
358
  var CreateTokenInput = import_zod2.z.object({
311
359
  name,
312
360
  access: TokenAccess,
@@ -361,15 +409,56 @@ var apiEnvironmentSchema = import_zod3.z.object({
361
409
  TRUST_PROXY: import_zod3.z.coerce.number().int().min(0).max(10).default(0),
362
410
  // Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
363
411
  // that endpoint off.
364
- CRON_SECRET: import_zod3.z.string().min(32).max(256).optional()
365
- }).strict().transform((environment) => ({
412
+ CRON_SECRET: import_zod3.z.string().min(32).max(256).optional(),
413
+ // Sign-in through SIAM (https://siam.ankityadav.net.in/docs). The four IAM_* values go
414
+ // together: leave them all unset to keep SIAM sign-in off.
415
+ IAM_BASE_URL: import_zod3.z.url().optional(),
416
+ IAM_CLIENT_ID: import_zod3.z.string().min(1).max(256).optional(),
417
+ IAM_CLIENT_SECRET: import_zod3.z.string().min(1).max(512).optional(),
418
+ IAM_REDIRECT_URI: import_zod3.z.url().optional(),
419
+ // The page where people manage their SIAM account (name, email, password, two-factor). The
420
+ // account page links to it. Optional: without it the page just says to use SIAM.
421
+ IAM_PROFILE_URL: import_zod3.z.url().refine(
422
+ (value) => ["http:", "https:"].includes(new URL(value).protocol),
423
+ "Expected an HTTP(S) URL"
424
+ ).optional(),
425
+ // A SIAM permission the user must hold to get in (e.g. `secretenvs.access`). Unset: any
426
+ // active SIAM account may sign in. A SIAM superadmin always may.
427
+ IAM_REQUIRED_PERMISSION: import_zod3.z.string().min(1).max(128).optional(),
428
+ // Link a SIAM sign-in to an existing local account with the same email. Off by default,
429
+ // because it is only safe when SIAM verifies that people own the email they sign up with.
430
+ IAM_LINK_BY_EMAIL: import_zod3.z.enum(["true", "false"]).optional()
431
+ }).strict().superRefine((environment, context) => {
432
+ const names = [
433
+ "IAM_BASE_URL",
434
+ "IAM_CLIENT_ID",
435
+ "IAM_CLIENT_SECRET",
436
+ "IAM_REDIRECT_URI"
437
+ ];
438
+ const missing = names.filter((name2) => environment[name2] === void 0);
439
+ if (missing.length > 0 && missing.length < names.length) {
440
+ for (const name2 of missing) {
441
+ context.addIssue({
442
+ code: "custom",
443
+ path: [name2],
444
+ message: "Required when any other IAM_* value is set"
445
+ });
446
+ }
447
+ }
448
+ }).transform((environment) => ({
366
449
  ...environment,
367
- COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
450
+ COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true",
451
+ IAM_LINK_BY_EMAIL: environment.IAM_LINK_BY_EMAIL === "true"
368
452
  }));
369
453
  // Annotate the CommonJS export names for ESM import in node:
370
454
  0 && (module.exports = {
371
455
  AddMemberInput,
456
+ AdminProjectDto,
457
+ AdminUpdateUserInput,
458
+ AdminUserDetailDto,
459
+ AdminUserDto,
372
460
  ApiErrorBody,
461
+ AuthOptionsDto,
373
462
  BulkUpsertVariablesInput,
374
463
  BulkUpsertVariablesResponse,
375
464
  CSRF_HEADER_NAME,
package/dist/index.d.cts CHANGED
@@ -69,8 +69,16 @@ declare const UserDto: z.ZodObject<{
69
69
  createdAt: z.ZodISODateTime;
70
70
  twoFactorEnabled: z.ZodBoolean;
71
71
  twoFactorAppName: z.ZodNullable<z.ZodString>;
72
+ isSuperAdmin: z.ZodBoolean;
73
+ managedBySiam: z.ZodBoolean;
74
+ hasPassword: z.ZodBoolean;
72
75
  }, z.core.$strict>;
73
76
  type UserDto = z.infer<typeof UserDto>;
77
+ declare const AuthOptionsDto: z.ZodObject<{
78
+ siam: z.ZodBoolean;
79
+ profileUrl: z.ZodNullable<z.ZodString>;
80
+ }, z.core.$strict>;
81
+ type AuthOptionsDto = z.infer<typeof AuthOptionsDto>;
74
82
  declare const TwoFactorSetupDto: z.ZodObject<{
75
83
  secret: z.ZodString;
76
84
  otpauthUri: z.ZodString;
@@ -366,6 +374,62 @@ declare const SdkProjectDto: z.ZodObject<{
366
374
  }, z.core.$strict>>;
367
375
  }, z.core.$strict>;
368
376
  type SdkProjectDto = z.infer<typeof SdkProjectDto>;
377
+ declare const AdminProjectDto: z.ZodObject<{
378
+ id: z.ZodUUID;
379
+ name: z.ZodString;
380
+ slug: z.ZodString;
381
+ description: z.ZodNullable<z.ZodString>;
382
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
383
+ createdAt: z.ZodISODateTime;
384
+ updatedAt: z.ZodISODateTime;
385
+ owner: z.ZodNullable<z.ZodObject<{
386
+ id: z.ZodUUID;
387
+ name: z.ZodString;
388
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
389
+ }, z.core.$strict>>;
390
+ memberCount: z.ZodNumber;
391
+ environmentCount: z.ZodNumber;
392
+ }, z.core.$strict>;
393
+ type AdminProjectDto = z.infer<typeof AdminProjectDto>;
394
+ declare const AdminUserDto: z.ZodObject<{
395
+ id: z.ZodUUID;
396
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
397
+ name: z.ZodString;
398
+ createdAt: z.ZodISODateTime;
399
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
400
+ isSuperAdmin: z.ZodBoolean;
401
+ managedBySiam: z.ZodBoolean;
402
+ projectCount: z.ZodNumber;
403
+ }, z.core.$strict>;
404
+ type AdminUserDto = z.infer<typeof AdminUserDto>;
405
+ declare const AdminUserDetailDto: z.ZodObject<{
406
+ id: z.ZodUUID;
407
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
408
+ name: z.ZodString;
409
+ createdAt: z.ZodISODateTime;
410
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
411
+ isSuperAdmin: z.ZodBoolean;
412
+ managedBySiam: z.ZodBoolean;
413
+ projectCount: z.ZodNumber;
414
+ projects: z.ZodArray<z.ZodObject<{
415
+ id: z.ZodUUID;
416
+ name: z.ZodString;
417
+ slug: z.ZodString;
418
+ role: z.ZodEnum<{
419
+ OWNER: "OWNER";
420
+ ADMIN: "ADMIN";
421
+ EDITOR: "EDITOR";
422
+ VIEWER: "VIEWER";
423
+ }>;
424
+ }, z.core.$strict>>;
425
+ }, z.core.$strict>;
426
+ type AdminUserDetailDto = z.infer<typeof AdminUserDetailDto>;
427
+ declare const AdminUpdateUserInput: z.ZodObject<{
428
+ name: z.ZodOptional<z.ZodString>;
429
+ email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
430
+ disabled: z.ZodOptional<z.ZodBoolean>;
431
+ }, z.core.$strict>;
432
+ type AdminUpdateUserInput = z.infer<typeof AdminUpdateUserInput>;
369
433
  declare const CreateTokenInput: z.ZodObject<{
370
434
  name: z.ZodString;
371
435
  access: z.ZodEnum<{
@@ -447,8 +511,19 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
447
511
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
448
512
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
449
513
  CRON_SECRET: z.ZodOptional<z.ZodString>;
514
+ IAM_BASE_URL: z.ZodOptional<z.ZodURL>;
515
+ IAM_CLIENT_ID: z.ZodOptional<z.ZodString>;
516
+ IAM_CLIENT_SECRET: z.ZodOptional<z.ZodString>;
517
+ IAM_REDIRECT_URI: z.ZodOptional<z.ZodURL>;
518
+ IAM_PROFILE_URL: z.ZodOptional<z.ZodURL>;
519
+ IAM_REQUIRED_PERMISSION: z.ZodOptional<z.ZodString>;
520
+ IAM_LINK_BY_EMAIL: z.ZodOptional<z.ZodEnum<{
521
+ true: "true";
522
+ false: "false";
523
+ }>>;
450
524
  }, z.core.$strict>, z.ZodTransform<{
451
525
  COOKIE_SECURE: boolean;
526
+ IAM_LINK_BY_EMAIL: boolean;
452
527
  NODE_ENV: "development" | "test" | "production";
453
528
  HOST: string;
454
529
  PORT: number;
@@ -458,6 +533,12 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
458
533
  VARIABLE_HISTORY_LIMIT: number;
459
534
  TRUST_PROXY: number;
460
535
  CRON_SECRET?: string | undefined;
536
+ IAM_BASE_URL?: string | undefined;
537
+ IAM_CLIENT_ID?: string | undefined;
538
+ IAM_CLIENT_SECRET?: string | undefined;
539
+ IAM_REDIRECT_URI?: string | undefined;
540
+ IAM_PROFILE_URL?: string | undefined;
541
+ IAM_REQUIRED_PERMISSION?: string | undefined;
461
542
  }, {
462
543
  NODE_ENV: "development" | "test" | "production";
463
544
  HOST: string;
@@ -469,7 +550,14 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
469
550
  TRUST_PROXY: number;
470
551
  COOKIE_SECURE?: "true" | "false" | undefined;
471
552
  CRON_SECRET?: string | undefined;
553
+ IAM_BASE_URL?: string | undefined;
554
+ IAM_CLIENT_ID?: string | undefined;
555
+ IAM_CLIENT_SECRET?: string | undefined;
556
+ IAM_REDIRECT_URI?: string | undefined;
557
+ IAM_PROFILE_URL?: string | undefined;
558
+ IAM_REQUIRED_PERMISSION?: string | undefined;
559
+ IAM_LINK_BY_EMAIL?: "true" | "false" | undefined;
472
560
  }>>;
473
561
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
474
562
 
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 };
563
+ export { AddMemberInput, AdminProjectDto, AdminUpdateUserInput, AdminUserDetailDto, AdminUserDto, type ApiEnvironment, ApiErrorBody, AuthOptionsDto, 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
@@ -69,8 +69,16 @@ declare const UserDto: z.ZodObject<{
69
69
  createdAt: z.ZodISODateTime;
70
70
  twoFactorEnabled: z.ZodBoolean;
71
71
  twoFactorAppName: z.ZodNullable<z.ZodString>;
72
+ isSuperAdmin: z.ZodBoolean;
73
+ managedBySiam: z.ZodBoolean;
74
+ hasPassword: z.ZodBoolean;
72
75
  }, z.core.$strict>;
73
76
  type UserDto = z.infer<typeof UserDto>;
77
+ declare const AuthOptionsDto: z.ZodObject<{
78
+ siam: z.ZodBoolean;
79
+ profileUrl: z.ZodNullable<z.ZodString>;
80
+ }, z.core.$strict>;
81
+ type AuthOptionsDto = z.infer<typeof AuthOptionsDto>;
74
82
  declare const TwoFactorSetupDto: z.ZodObject<{
75
83
  secret: z.ZodString;
76
84
  otpauthUri: z.ZodString;
@@ -366,6 +374,62 @@ declare const SdkProjectDto: z.ZodObject<{
366
374
  }, z.core.$strict>>;
367
375
  }, z.core.$strict>;
368
376
  type SdkProjectDto = z.infer<typeof SdkProjectDto>;
377
+ declare const AdminProjectDto: z.ZodObject<{
378
+ id: z.ZodUUID;
379
+ name: z.ZodString;
380
+ slug: z.ZodString;
381
+ description: z.ZodNullable<z.ZodString>;
382
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
383
+ createdAt: z.ZodISODateTime;
384
+ updatedAt: z.ZodISODateTime;
385
+ owner: z.ZodNullable<z.ZodObject<{
386
+ id: z.ZodUUID;
387
+ name: z.ZodString;
388
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
389
+ }, z.core.$strict>>;
390
+ memberCount: z.ZodNumber;
391
+ environmentCount: z.ZodNumber;
392
+ }, z.core.$strict>;
393
+ type AdminProjectDto = z.infer<typeof AdminProjectDto>;
394
+ declare const AdminUserDto: z.ZodObject<{
395
+ id: z.ZodUUID;
396
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
397
+ name: z.ZodString;
398
+ createdAt: z.ZodISODateTime;
399
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
400
+ isSuperAdmin: z.ZodBoolean;
401
+ managedBySiam: z.ZodBoolean;
402
+ projectCount: z.ZodNumber;
403
+ }, z.core.$strict>;
404
+ type AdminUserDto = z.infer<typeof AdminUserDto>;
405
+ declare const AdminUserDetailDto: z.ZodObject<{
406
+ id: z.ZodUUID;
407
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
408
+ name: z.ZodString;
409
+ createdAt: z.ZodISODateTime;
410
+ disabledAt: z.ZodNullable<z.ZodISODateTime>;
411
+ isSuperAdmin: z.ZodBoolean;
412
+ managedBySiam: z.ZodBoolean;
413
+ projectCount: z.ZodNumber;
414
+ projects: z.ZodArray<z.ZodObject<{
415
+ id: z.ZodUUID;
416
+ name: z.ZodString;
417
+ slug: z.ZodString;
418
+ role: z.ZodEnum<{
419
+ OWNER: "OWNER";
420
+ ADMIN: "ADMIN";
421
+ EDITOR: "EDITOR";
422
+ VIEWER: "VIEWER";
423
+ }>;
424
+ }, z.core.$strict>>;
425
+ }, z.core.$strict>;
426
+ type AdminUserDetailDto = z.infer<typeof AdminUserDetailDto>;
427
+ declare const AdminUpdateUserInput: z.ZodObject<{
428
+ name: z.ZodOptional<z.ZodString>;
429
+ email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
430
+ disabled: z.ZodOptional<z.ZodBoolean>;
431
+ }, z.core.$strict>;
432
+ type AdminUpdateUserInput = z.infer<typeof AdminUpdateUserInput>;
369
433
  declare const CreateTokenInput: z.ZodObject<{
370
434
  name: z.ZodString;
371
435
  access: z.ZodEnum<{
@@ -447,8 +511,19 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
447
511
  VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
448
512
  TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
449
513
  CRON_SECRET: z.ZodOptional<z.ZodString>;
514
+ IAM_BASE_URL: z.ZodOptional<z.ZodURL>;
515
+ IAM_CLIENT_ID: z.ZodOptional<z.ZodString>;
516
+ IAM_CLIENT_SECRET: z.ZodOptional<z.ZodString>;
517
+ IAM_REDIRECT_URI: z.ZodOptional<z.ZodURL>;
518
+ IAM_PROFILE_URL: z.ZodOptional<z.ZodURL>;
519
+ IAM_REQUIRED_PERMISSION: z.ZodOptional<z.ZodString>;
520
+ IAM_LINK_BY_EMAIL: z.ZodOptional<z.ZodEnum<{
521
+ true: "true";
522
+ false: "false";
523
+ }>>;
450
524
  }, z.core.$strict>, z.ZodTransform<{
451
525
  COOKIE_SECURE: boolean;
526
+ IAM_LINK_BY_EMAIL: boolean;
452
527
  NODE_ENV: "development" | "test" | "production";
453
528
  HOST: string;
454
529
  PORT: number;
@@ -458,6 +533,12 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
458
533
  VARIABLE_HISTORY_LIMIT: number;
459
534
  TRUST_PROXY: number;
460
535
  CRON_SECRET?: string | undefined;
536
+ IAM_BASE_URL?: string | undefined;
537
+ IAM_CLIENT_ID?: string | undefined;
538
+ IAM_CLIENT_SECRET?: string | undefined;
539
+ IAM_REDIRECT_URI?: string | undefined;
540
+ IAM_PROFILE_URL?: string | undefined;
541
+ IAM_REQUIRED_PERMISSION?: string | undefined;
461
542
  }, {
462
543
  NODE_ENV: "development" | "test" | "production";
463
544
  HOST: string;
@@ -469,7 +550,14 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
469
550
  TRUST_PROXY: number;
470
551
  COOKIE_SECURE?: "true" | "false" | undefined;
471
552
  CRON_SECRET?: string | undefined;
553
+ IAM_BASE_URL?: string | undefined;
554
+ IAM_CLIENT_ID?: string | undefined;
555
+ IAM_CLIENT_SECRET?: string | undefined;
556
+ IAM_REDIRECT_URI?: string | undefined;
557
+ IAM_PROFILE_URL?: string | undefined;
558
+ IAM_REQUIRED_PERMISSION?: string | undefined;
559
+ IAM_LINK_BY_EMAIL?: "true" | "false" | undefined;
472
560
  }>>;
473
561
  type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
474
562
 
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 };
563
+ export { AddMemberInput, AdminProjectDto, AdminUpdateUserInput, AdminUserDetailDto, AdminUserDto, type ApiEnvironment, ApiErrorBody, AuthOptionsDto, 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
@@ -70,7 +70,20 @@ var UserDto = z2.object({
70
70
  createdAt: isoDate,
71
71
  twoFactorEnabled: z2.boolean(),
72
72
  // Name the user gave the authenticator app at setup; null while 2FA is off.
73
- 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(),
76
+ // Linked to a SIAM account: name and email follow SIAM, so they are not edited here.
77
+ managedBySiam: z2.boolean(),
78
+ // Has a password of its own. Accounts created through SIAM do not, and SIAM handles their
79
+ // password and two-factor authentication.
80
+ hasPassword: z2.boolean()
81
+ }).strict();
82
+ var AuthOptionsDto = z2.object({
83
+ // Sign-in through SIAM is configured on this server.
84
+ siam: z2.boolean(),
85
+ // Where people manage their SIAM account; null when it is not configured or SIAM is off.
86
+ profileUrl: z2.string().nullable()
74
87
  }).strict();
75
88
  var TwoFactorSetupDto = z2.object({ secret: z2.string(), otpauthUri: z2.string() }).strict();
76
89
  var TwoFactorSetupInput = z2.object({ password: z2.string().min(1).max(MAX_PASSWORD_LENGTH) }).strict();
@@ -221,6 +234,36 @@ var SdkProjectDto = z2.object({
221
234
  role: ProjectRole,
222
235
  environments: z2.array(SdkEnvironmentDto)
223
236
  }).strict();
237
+ var adminPerson = z2.object({ id, name, email }).strict();
238
+ var AdminProjectDto = ProjectDto.extend({
239
+ owner: adminPerson.nullable(),
240
+ memberCount: z2.number().int().min(0),
241
+ environmentCount: z2.number().int().min(0)
242
+ });
243
+ var AdminUserDto = z2.object({
244
+ id,
245
+ email,
246
+ name,
247
+ createdAt: isoDate,
248
+ // Null while the account is enabled.
249
+ disabledAt: isoDate.nullable(),
250
+ isSuperAdmin: z2.boolean(),
251
+ // Linked to a SIAM account: its name and email belong to SIAM and cannot be edited here.
252
+ managedBySiam: z2.boolean(),
253
+ projectCount: z2.number().int().min(0)
254
+ }).strict();
255
+ var AdminUserDetailDto = AdminUserDto.extend({
256
+ // Every project the user is a member of, with their role there.
257
+ projects: z2.array(z2.object({ id, name, slug, role: ProjectRole }).strict())
258
+ });
259
+ var AdminUpdateUserInput = z2.object({
260
+ name: name.optional(),
261
+ email: email.optional(),
262
+ disabled: z2.boolean().optional()
263
+ }).strict().refine(
264
+ (input) => input.name !== void 0 || input.email !== void 0 || input.disabled !== void 0,
265
+ { message: "Provide name, email and/or disabled" }
266
+ );
224
267
  var CreateTokenInput = z2.object({
225
268
  name,
226
269
  access: TokenAccess,
@@ -275,14 +318,55 @@ var apiEnvironmentSchema = z3.object({
275
318
  TRUST_PROXY: z3.coerce.number().int().min(0).max(10).default(0),
276
319
  // Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
277
320
  // that endpoint off.
278
- CRON_SECRET: z3.string().min(32).max(256).optional()
279
- }).strict().transform((environment) => ({
321
+ CRON_SECRET: z3.string().min(32).max(256).optional(),
322
+ // Sign-in through SIAM (https://siam.ankityadav.net.in/docs). The four IAM_* values go
323
+ // together: leave them all unset to keep SIAM sign-in off.
324
+ IAM_BASE_URL: z3.url().optional(),
325
+ IAM_CLIENT_ID: z3.string().min(1).max(256).optional(),
326
+ IAM_CLIENT_SECRET: z3.string().min(1).max(512).optional(),
327
+ IAM_REDIRECT_URI: z3.url().optional(),
328
+ // The page where people manage their SIAM account (name, email, password, two-factor). The
329
+ // account page links to it. Optional: without it the page just says to use SIAM.
330
+ IAM_PROFILE_URL: z3.url().refine(
331
+ (value) => ["http:", "https:"].includes(new URL(value).protocol),
332
+ "Expected an HTTP(S) URL"
333
+ ).optional(),
334
+ // A SIAM permission the user must hold to get in (e.g. `secretenvs.access`). Unset: any
335
+ // active SIAM account may sign in. A SIAM superadmin always may.
336
+ IAM_REQUIRED_PERMISSION: z3.string().min(1).max(128).optional(),
337
+ // Link a SIAM sign-in to an existing local account with the same email. Off by default,
338
+ // because it is only safe when SIAM verifies that people own the email they sign up with.
339
+ IAM_LINK_BY_EMAIL: z3.enum(["true", "false"]).optional()
340
+ }).strict().superRefine((environment, context) => {
341
+ const names = [
342
+ "IAM_BASE_URL",
343
+ "IAM_CLIENT_ID",
344
+ "IAM_CLIENT_SECRET",
345
+ "IAM_REDIRECT_URI"
346
+ ];
347
+ const missing = names.filter((name2) => environment[name2] === void 0);
348
+ if (missing.length > 0 && missing.length < names.length) {
349
+ for (const name2 of missing) {
350
+ context.addIssue({
351
+ code: "custom",
352
+ path: [name2],
353
+ message: "Required when any other IAM_* value is set"
354
+ });
355
+ }
356
+ }
357
+ }).transform((environment) => ({
280
358
  ...environment,
281
- COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
359
+ COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true",
360
+ IAM_LINK_BY_EMAIL: environment.IAM_LINK_BY_EMAIL === "true"
282
361
  }));
283
362
  export {
284
363
  AddMemberInput,
364
+ AdminProjectDto,
365
+ AdminUpdateUserInput,
366
+ AdminUserDetailDto,
367
+ AdminUserDto,
285
368
  ApiErrorBody,
369
+ AuthOptionsDto,
286
370
  BulkUpsertVariablesInput,
287
371
  BulkUpsertVariablesResponse,
288
372
  CSRF_HEADER_NAME,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secretenvs/contracts",
3
- "version": "1.5.0",
3
+ "version": "1.7.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",