@secretenvs/contracts 1.7.0 → 3.0.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 +28 -79
- package/dist/index.d.cts +14 -53
- package/dist/index.d.ts +14 -53
- package/dist/index.js +27 -67
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,37 +44,26 @@ __export(index_exports, {
|
|
|
44
44
|
ErrorCode: () => ErrorCode,
|
|
45
45
|
ExpiringSecretDto: () => ExpiringSecretDto,
|
|
46
46
|
ListVersionsQuery: () => ListVersionsQuery,
|
|
47
|
-
LoginInput: () => LoginInput,
|
|
48
|
-
MAX_AUTH_CODE_LENGTH: () => MAX_AUTH_CODE_LENGTH,
|
|
49
47
|
MAX_BULK_VARIABLES: () => MAX_BULK_VARIABLES,
|
|
50
48
|
MAX_KEY_LENGTH: () => MAX_KEY_LENGTH,
|
|
51
49
|
MAX_NAME_LENGTH: () => MAX_NAME_LENGTH,
|
|
52
|
-
MAX_PASSWORD_LENGTH: () => MAX_PASSWORD_LENGTH,
|
|
53
50
|
MAX_VALUE_BYTES: () => MAX_VALUE_BYTES,
|
|
54
51
|
MAX_VERSIONS_LIMIT: () => MAX_VERSIONS_LIMIT,
|
|
55
|
-
MIN_PASSWORD_LENGTH: () => MIN_PASSWORD_LENGTH,
|
|
56
52
|
MemberDto: () => MemberDto,
|
|
57
53
|
PaginatedVersionsResponse: () => PaginatedVersionsResponse,
|
|
58
54
|
ProjectDto: () => ProjectDto,
|
|
59
55
|
ProjectRole: () => ProjectRole,
|
|
60
56
|
ProjectSummaryDto: () => ProjectSummaryDto,
|
|
61
|
-
RECOVERY_CODE_COUNT: () => RECOVERY_CODE_COUNT,
|
|
62
|
-
RecoveryCodesDto: () => RecoveryCodesDto,
|
|
63
|
-
RegisterInput: () => RegisterInput,
|
|
64
57
|
ResolvedVariableDto: () => ResolvedVariableDto,
|
|
65
58
|
ResolvedVariablesResponse: () => ResolvedVariablesResponse,
|
|
66
59
|
SLUG_REGEX: () => SLUG_REGEX,
|
|
67
60
|
SdkEnvironmentDto: () => SdkEnvironmentDto,
|
|
61
|
+
SdkMeDto: () => SdkMeDto,
|
|
68
62
|
SdkProjectDto: () => SdkProjectDto,
|
|
69
63
|
SharedVariableMetaDto: () => SharedVariableMetaDto,
|
|
70
64
|
TOKEN_PREFIX: () => TOKEN_PREFIX,
|
|
71
|
-
TOTP_DIGITS: () => TOTP_DIGITS,
|
|
72
65
|
TokenAccess: () => TokenAccess,
|
|
73
66
|
TokenDto: () => TokenDto,
|
|
74
|
-
TwoFactorConfirmInput: () => TwoFactorConfirmInput,
|
|
75
|
-
TwoFactorEnableInput: () => TwoFactorEnableInput,
|
|
76
|
-
TwoFactorSetupDto: () => TwoFactorSetupDto,
|
|
77
|
-
TwoFactorSetupInput: () => TwoFactorSetupInput,
|
|
78
67
|
UpdateEnvironmentInput: () => UpdateEnvironmentInput,
|
|
79
68
|
UpdateMemberInput: () => UpdateMemberInput,
|
|
80
69
|
UpdateProjectInput: () => UpdateProjectInput,
|
|
@@ -101,16 +90,11 @@ var MAX_NAME_LENGTH = 64;
|
|
|
101
90
|
var MAX_BULK_VARIABLES = 500;
|
|
102
91
|
var EXPIRING_SOON_DAYS = 7;
|
|
103
92
|
var EXPIRY_REMINDER_DAYS = [30, 7, 1];
|
|
104
|
-
var MIN_PASSWORD_LENGTH = 12;
|
|
105
|
-
var MAX_PASSWORD_LENGTH = 256;
|
|
106
93
|
var DEFAULT_VERSIONS_LIMIT = 20;
|
|
107
94
|
var MAX_VERSIONS_LIMIT = 100;
|
|
108
95
|
var CSRF_HEADER_NAME = "x-requested-with";
|
|
109
96
|
var CSRF_HEADER_VALUE = "secretenvs-web";
|
|
110
97
|
var TOKEN_PREFIX = "svt_";
|
|
111
|
-
var TOTP_DIGITS = 6;
|
|
112
|
-
var RECOVERY_CODE_COUNT = 10;
|
|
113
|
-
var MAX_AUTH_CODE_LENGTH = 32;
|
|
114
98
|
|
|
115
99
|
// src/enums.ts
|
|
116
100
|
var import_zod = require("zod");
|
|
@@ -121,7 +105,6 @@ var ErrorCode = import_zod.z.enum([
|
|
|
121
105
|
"VALIDATION_ERROR",
|
|
122
106
|
"BAD_REQUEST",
|
|
123
107
|
"UNAUTHENTICATED",
|
|
124
|
-
"MFA_REQUIRED",
|
|
125
108
|
"FORBIDDEN",
|
|
126
109
|
"NOT_FOUND",
|
|
127
110
|
"CONFLICT",
|
|
@@ -146,47 +129,19 @@ var variableValue = import_zod2.z.string().refine(
|
|
|
146
129
|
var secretExpiry = isoDate.refine((value) => Date.parse(value) > Date.now(), {
|
|
147
130
|
message: "Expiry must be in the future"
|
|
148
131
|
}).nullable();
|
|
149
|
-
var password = import_zod2.z.string().min(MIN_PASSWORD_LENGTH).max(MAX_PASSWORD_LENGTH);
|
|
150
|
-
var RegisterInput = import_zod2.z.object({ email, name, password }).strict();
|
|
151
|
-
var authCode = import_zod2.z.string().trim().min(1, "Enter your code").max(MAX_AUTH_CODE_LENGTH);
|
|
152
|
-
var LoginInput = import_zod2.z.object({
|
|
153
|
-
email,
|
|
154
|
-
password: import_zod2.z.string().min(1).max(MAX_PASSWORD_LENGTH),
|
|
155
|
-
code: authCode.optional()
|
|
156
|
-
}).strict();
|
|
157
132
|
var UserDto = import_zod2.z.object({
|
|
158
133
|
id,
|
|
159
134
|
email,
|
|
160
135
|
name,
|
|
161
136
|
createdAt: isoDate,
|
|
162
|
-
twoFactorEnabled: import_zod2.z.boolean(),
|
|
163
|
-
// Name the user gave the authenticator app at setup; null while 2FA is off.
|
|
164
|
-
twoFactorAppName: import_zod2.z.string().nullable(),
|
|
165
137
|
// 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()
|
|
138
|
+
isSuperAdmin: import_zod2.z.boolean()
|
|
172
139
|
}).strict();
|
|
173
140
|
var AuthOptionsDto = import_zod2.z.object({
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
// Where people manage their SIAM account; null when it is not configured or SIAM is off.
|
|
141
|
+
// Where people manage their SIAM account (name, email, password, two-factor); null when the
|
|
142
|
+
// server does not say.
|
|
177
143
|
profileUrl: import_zod2.z.string().nullable()
|
|
178
144
|
}).strict();
|
|
179
|
-
var TwoFactorSetupDto = import_zod2.z.object({ secret: import_zod2.z.string(), otpauthUri: import_zod2.z.string() }).strict();
|
|
180
|
-
var TwoFactorSetupInput = import_zod2.z.object({ password: import_zod2.z.string().min(1).max(MAX_PASSWORD_LENGTH) }).strict();
|
|
181
|
-
var TwoFactorEnableInput = import_zod2.z.object({
|
|
182
|
-
appName: import_zod2.z.string().trim().min(1, "Enter the app name").max(MAX_NAME_LENGTH),
|
|
183
|
-
code: import_zod2.z.string().trim().regex(/^\d{6}$/, "Enter the 6-digit code")
|
|
184
|
-
}).strict();
|
|
185
|
-
var TwoFactorConfirmInput = import_zod2.z.object({
|
|
186
|
-
password: import_zod2.z.string().min(1).max(MAX_PASSWORD_LENGTH),
|
|
187
|
-
code: authCode
|
|
188
|
-
}).strict();
|
|
189
|
-
var RecoveryCodesDto = import_zod2.z.object({ recoveryCodes: import_zod2.z.array(import_zod2.z.string()) }).strict();
|
|
190
145
|
var CreateProjectInput = import_zod2.z.object({ name, slug, description: import_zod2.z.string().max(500).optional() }).strict();
|
|
191
146
|
var UpdateProjectInput = import_zod2.z.object({
|
|
192
147
|
name: name.optional(),
|
|
@@ -325,6 +280,7 @@ var SdkProjectDto = import_zod2.z.object({
|
|
|
325
280
|
role: ProjectRole,
|
|
326
281
|
environments: import_zod2.z.array(SdkEnvironmentDto)
|
|
327
282
|
}).strict();
|
|
283
|
+
var SdkMeDto = import_zod2.z.object({ id, email, name }).strict();
|
|
328
284
|
var adminPerson = import_zod2.z.object({ id, name, email }).strict();
|
|
329
285
|
var AdminProjectDto = ProjectDto.extend({
|
|
330
286
|
owner: adminPerson.nullable(),
|
|
@@ -339,22 +295,13 @@ var AdminUserDto = import_zod2.z.object({
|
|
|
339
295
|
// Null while the account is enabled.
|
|
340
296
|
disabledAt: isoDate.nullable(),
|
|
341
297
|
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
298
|
projectCount: import_zod2.z.number().int().min(0)
|
|
345
299
|
}).strict();
|
|
346
300
|
var AdminUserDetailDto = AdminUserDto.extend({
|
|
347
301
|
// Every project the user is a member of, with their role there.
|
|
348
302
|
projects: import_zod2.z.array(import_zod2.z.object({ id, name, slug, role: ProjectRole }).strict())
|
|
349
303
|
});
|
|
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
|
-
);
|
|
304
|
+
var AdminUpdateUserInput = import_zod2.z.object({ disabled: import_zod2.z.boolean() }).strict();
|
|
358
305
|
var CreateTokenInput = import_zod2.z.object({
|
|
359
306
|
name,
|
|
360
307
|
access: TokenAccess,
|
|
@@ -410,8 +357,9 @@ var apiEnvironmentSchema = import_zod3.z.object({
|
|
|
410
357
|
// Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
|
|
411
358
|
// that endpoint off.
|
|
412
359
|
CRON_SECRET: import_zod3.z.string().min(32).max(256).optional(),
|
|
413
|
-
// Sign-in through SIAM (https://siam.ankityadav.net.in/docs)
|
|
414
|
-
//
|
|
360
|
+
// Sign-in through SIAM (https://siam.ankityadav.net.in/docs) is the only way in, so the four
|
|
361
|
+
// IAM_* values below are required (see the refinement). The one exception is local
|
|
362
|
+
// development with DEV_SIAM_STUB, and NODE_ENV=test, where tests inject their own SIAM.
|
|
415
363
|
IAM_BASE_URL: import_zod3.z.url().optional(),
|
|
416
364
|
IAM_CLIENT_ID: import_zod3.z.string().min(1).max(256).optional(),
|
|
417
365
|
IAM_CLIENT_SECRET: import_zod3.z.string().min(1).max(512).optional(),
|
|
@@ -427,7 +375,10 @@ var apiEnvironmentSchema = import_zod3.z.object({
|
|
|
427
375
|
IAM_REQUIRED_PERMISSION: import_zod3.z.string().min(1).max(128).optional(),
|
|
428
376
|
// Link a SIAM sign-in to an existing local account with the same email. Off by default,
|
|
429
377
|
// 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()
|
|
378
|
+
IAM_LINK_BY_EMAIL: import_zod3.z.enum(["true", "false"]).optional(),
|
|
379
|
+
// Local development only: replaces SIAM with a built-in stand-in that signs in one fixed
|
|
380
|
+
// fake user without asking for anything. Refused outside NODE_ENV=development.
|
|
381
|
+
DEV_SIAM_STUB: import_zod3.z.enum(["true", "false"]).optional()
|
|
431
382
|
}).strict().superRefine((environment, context) => {
|
|
432
383
|
const names = [
|
|
433
384
|
"IAM_BASE_URL",
|
|
@@ -435,20 +386,29 @@ var apiEnvironmentSchema = import_zod3.z.object({
|
|
|
435
386
|
"IAM_CLIENT_SECRET",
|
|
436
387
|
"IAM_REDIRECT_URI"
|
|
437
388
|
];
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
|
|
389
|
+
const stub = environment.DEV_SIAM_STUB === "true";
|
|
390
|
+
if (stub && environment.NODE_ENV !== "development") {
|
|
391
|
+
context.addIssue({
|
|
392
|
+
code: "custom",
|
|
393
|
+
path: ["DEV_SIAM_STUB"],
|
|
394
|
+
message: "Only allowed when NODE_ENV is development"
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (stub || environment.NODE_ENV === "test") return;
|
|
398
|
+
for (const name2 of names) {
|
|
399
|
+
if (environment[name2] === void 0) {
|
|
441
400
|
context.addIssue({
|
|
442
401
|
code: "custom",
|
|
443
402
|
path: [name2],
|
|
444
|
-
message: "Required
|
|
403
|
+
message: "Required: SIAM is the only way to sign in"
|
|
445
404
|
});
|
|
446
405
|
}
|
|
447
406
|
}
|
|
448
407
|
}).transform((environment) => ({
|
|
449
408
|
...environment,
|
|
450
409
|
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"
|
|
410
|
+
IAM_LINK_BY_EMAIL: environment.IAM_LINK_BY_EMAIL === "true",
|
|
411
|
+
DEV_SIAM_STUB: environment.DEV_SIAM_STUB === "true"
|
|
452
412
|
}));
|
|
453
413
|
// Annotate the CommonJS export names for ESM import in node:
|
|
454
414
|
0 && (module.exports = {
|
|
@@ -476,37 +436,26 @@ var apiEnvironmentSchema = import_zod3.z.object({
|
|
|
476
436
|
ErrorCode,
|
|
477
437
|
ExpiringSecretDto,
|
|
478
438
|
ListVersionsQuery,
|
|
479
|
-
LoginInput,
|
|
480
|
-
MAX_AUTH_CODE_LENGTH,
|
|
481
439
|
MAX_BULK_VARIABLES,
|
|
482
440
|
MAX_KEY_LENGTH,
|
|
483
441
|
MAX_NAME_LENGTH,
|
|
484
|
-
MAX_PASSWORD_LENGTH,
|
|
485
442
|
MAX_VALUE_BYTES,
|
|
486
443
|
MAX_VERSIONS_LIMIT,
|
|
487
|
-
MIN_PASSWORD_LENGTH,
|
|
488
444
|
MemberDto,
|
|
489
445
|
PaginatedVersionsResponse,
|
|
490
446
|
ProjectDto,
|
|
491
447
|
ProjectRole,
|
|
492
448
|
ProjectSummaryDto,
|
|
493
|
-
RECOVERY_CODE_COUNT,
|
|
494
|
-
RecoveryCodesDto,
|
|
495
|
-
RegisterInput,
|
|
496
449
|
ResolvedVariableDto,
|
|
497
450
|
ResolvedVariablesResponse,
|
|
498
451
|
SLUG_REGEX,
|
|
499
452
|
SdkEnvironmentDto,
|
|
453
|
+
SdkMeDto,
|
|
500
454
|
SdkProjectDto,
|
|
501
455
|
SharedVariableMetaDto,
|
|
502
456
|
TOKEN_PREFIX,
|
|
503
|
-
TOTP_DIGITS,
|
|
504
457
|
TokenAccess,
|
|
505
458
|
TokenDto,
|
|
506
|
-
TwoFactorConfirmInput,
|
|
507
|
-
TwoFactorEnableInput,
|
|
508
|
-
TwoFactorSetupDto,
|
|
509
|
-
TwoFactorSetupInput,
|
|
510
459
|
UpdateEnvironmentInput,
|
|
511
460
|
UpdateMemberInput,
|
|
512
461
|
UpdateProjectInput,
|
package/dist/index.d.cts
CHANGED
|
@@ -8,16 +8,11 @@ declare const MAX_NAME_LENGTH = 64;
|
|
|
8
8
|
declare const MAX_BULK_VARIABLES = 500;
|
|
9
9
|
declare const EXPIRING_SOON_DAYS = 7;
|
|
10
10
|
declare const EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
|
|
11
|
-
declare const MIN_PASSWORD_LENGTH = 12;
|
|
12
|
-
declare const MAX_PASSWORD_LENGTH = 256;
|
|
13
11
|
declare const DEFAULT_VERSIONS_LIMIT = 20;
|
|
14
12
|
declare const MAX_VERSIONS_LIMIT = 100;
|
|
15
13
|
declare const CSRF_HEADER_NAME = "x-requested-with";
|
|
16
14
|
declare const CSRF_HEADER_VALUE = "secretenvs-web";
|
|
17
15
|
declare const TOKEN_PREFIX = "svt_";
|
|
18
|
-
declare const TOTP_DIGITS = 6;
|
|
19
|
-
declare const RECOVERY_CODE_COUNT = 10;
|
|
20
|
-
declare const MAX_AUTH_CODE_LENGTH = 32;
|
|
21
16
|
|
|
22
17
|
declare const ProjectRole: z.ZodEnum<{
|
|
23
18
|
OWNER: "OWNER";
|
|
@@ -41,7 +36,6 @@ declare const ErrorCode: z.ZodEnum<{
|
|
|
41
36
|
VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
42
37
|
BAD_REQUEST: "BAD_REQUEST";
|
|
43
38
|
UNAUTHENTICATED: "UNAUTHENTICATED";
|
|
44
|
-
MFA_REQUIRED: "MFA_REQUIRED";
|
|
45
39
|
FORBIDDEN: "FORBIDDEN";
|
|
46
40
|
NOT_FOUND: "NOT_FOUND";
|
|
47
41
|
CONFLICT: "CONFLICT";
|
|
@@ -50,58 +44,18 @@ declare const ErrorCode: z.ZodEnum<{
|
|
|
50
44
|
}>;
|
|
51
45
|
type ErrorCode = z.infer<typeof ErrorCode>;
|
|
52
46
|
|
|
53
|
-
declare const RegisterInput: z.ZodObject<{
|
|
54
|
-
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
55
|
-
name: z.ZodString;
|
|
56
|
-
password: z.ZodString;
|
|
57
|
-
}, z.core.$strict>;
|
|
58
|
-
type RegisterInput = z.infer<typeof RegisterInput>;
|
|
59
|
-
declare const LoginInput: z.ZodObject<{
|
|
60
|
-
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
61
|
-
password: z.ZodString;
|
|
62
|
-
code: z.ZodOptional<z.ZodString>;
|
|
63
|
-
}, z.core.$strict>;
|
|
64
|
-
type LoginInput = z.infer<typeof LoginInput>;
|
|
65
47
|
declare const UserDto: z.ZodObject<{
|
|
66
48
|
id: z.ZodUUID;
|
|
67
49
|
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
68
50
|
name: z.ZodString;
|
|
69
51
|
createdAt: z.ZodISODateTime;
|
|
70
|
-
twoFactorEnabled: z.ZodBoolean;
|
|
71
|
-
twoFactorAppName: z.ZodNullable<z.ZodString>;
|
|
72
52
|
isSuperAdmin: z.ZodBoolean;
|
|
73
|
-
managedBySiam: z.ZodBoolean;
|
|
74
|
-
hasPassword: z.ZodBoolean;
|
|
75
53
|
}, z.core.$strict>;
|
|
76
54
|
type UserDto = z.infer<typeof UserDto>;
|
|
77
55
|
declare const AuthOptionsDto: z.ZodObject<{
|
|
78
|
-
siam: z.ZodBoolean;
|
|
79
56
|
profileUrl: z.ZodNullable<z.ZodString>;
|
|
80
57
|
}, z.core.$strict>;
|
|
81
58
|
type AuthOptionsDto = z.infer<typeof AuthOptionsDto>;
|
|
82
|
-
declare const TwoFactorSetupDto: z.ZodObject<{
|
|
83
|
-
secret: z.ZodString;
|
|
84
|
-
otpauthUri: z.ZodString;
|
|
85
|
-
}, z.core.$strict>;
|
|
86
|
-
type TwoFactorSetupDto = z.infer<typeof TwoFactorSetupDto>;
|
|
87
|
-
declare const TwoFactorSetupInput: z.ZodObject<{
|
|
88
|
-
password: z.ZodString;
|
|
89
|
-
}, z.core.$strict>;
|
|
90
|
-
type TwoFactorSetupInput = z.infer<typeof TwoFactorSetupInput>;
|
|
91
|
-
declare const TwoFactorEnableInput: z.ZodObject<{
|
|
92
|
-
appName: z.ZodString;
|
|
93
|
-
code: z.ZodString;
|
|
94
|
-
}, z.core.$strict>;
|
|
95
|
-
type TwoFactorEnableInput = z.infer<typeof TwoFactorEnableInput>;
|
|
96
|
-
declare const TwoFactorConfirmInput: z.ZodObject<{
|
|
97
|
-
password: z.ZodString;
|
|
98
|
-
code: z.ZodString;
|
|
99
|
-
}, z.core.$strict>;
|
|
100
|
-
type TwoFactorConfirmInput = z.infer<typeof TwoFactorConfirmInput>;
|
|
101
|
-
declare const RecoveryCodesDto: z.ZodObject<{
|
|
102
|
-
recoveryCodes: z.ZodArray<z.ZodString>;
|
|
103
|
-
}, z.core.$strict>;
|
|
104
|
-
type RecoveryCodesDto = z.infer<typeof RecoveryCodesDto>;
|
|
105
59
|
declare const CreateProjectInput: z.ZodObject<{
|
|
106
60
|
name: z.ZodString;
|
|
107
61
|
slug: z.ZodString;
|
|
@@ -374,6 +328,12 @@ declare const SdkProjectDto: z.ZodObject<{
|
|
|
374
328
|
}, z.core.$strict>>;
|
|
375
329
|
}, z.core.$strict>;
|
|
376
330
|
type SdkProjectDto = z.infer<typeof SdkProjectDto>;
|
|
331
|
+
declare const SdkMeDto: z.ZodObject<{
|
|
332
|
+
id: z.ZodUUID;
|
|
333
|
+
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
334
|
+
name: z.ZodString;
|
|
335
|
+
}, z.core.$strict>;
|
|
336
|
+
type SdkMeDto = z.infer<typeof SdkMeDto>;
|
|
377
337
|
declare const AdminProjectDto: z.ZodObject<{
|
|
378
338
|
id: z.ZodUUID;
|
|
379
339
|
name: z.ZodString;
|
|
@@ -398,7 +358,6 @@ declare const AdminUserDto: z.ZodObject<{
|
|
|
398
358
|
createdAt: z.ZodISODateTime;
|
|
399
359
|
disabledAt: z.ZodNullable<z.ZodISODateTime>;
|
|
400
360
|
isSuperAdmin: z.ZodBoolean;
|
|
401
|
-
managedBySiam: z.ZodBoolean;
|
|
402
361
|
projectCount: z.ZodNumber;
|
|
403
362
|
}, z.core.$strict>;
|
|
404
363
|
type AdminUserDto = z.infer<typeof AdminUserDto>;
|
|
@@ -409,7 +368,6 @@ declare const AdminUserDetailDto: z.ZodObject<{
|
|
|
409
368
|
createdAt: z.ZodISODateTime;
|
|
410
369
|
disabledAt: z.ZodNullable<z.ZodISODateTime>;
|
|
411
370
|
isSuperAdmin: z.ZodBoolean;
|
|
412
|
-
managedBySiam: z.ZodBoolean;
|
|
413
371
|
projectCount: z.ZodNumber;
|
|
414
372
|
projects: z.ZodArray<z.ZodObject<{
|
|
415
373
|
id: z.ZodUUID;
|
|
@@ -425,9 +383,7 @@ declare const AdminUserDetailDto: z.ZodObject<{
|
|
|
425
383
|
}, z.core.$strict>;
|
|
426
384
|
type AdminUserDetailDto = z.infer<typeof AdminUserDetailDto>;
|
|
427
385
|
declare const AdminUpdateUserInput: z.ZodObject<{
|
|
428
|
-
|
|
429
|
-
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
430
|
-
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
386
|
+
disabled: z.ZodBoolean;
|
|
431
387
|
}, z.core.$strict>;
|
|
432
388
|
type AdminUpdateUserInput = z.infer<typeof AdminUpdateUserInput>;
|
|
433
389
|
declare const CreateTokenInput: z.ZodObject<{
|
|
@@ -480,7 +436,6 @@ declare const ApiErrorBody: z.ZodObject<{
|
|
|
480
436
|
VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
481
437
|
BAD_REQUEST: "BAD_REQUEST";
|
|
482
438
|
UNAUTHENTICATED: "UNAUTHENTICATED";
|
|
483
|
-
MFA_REQUIRED: "MFA_REQUIRED";
|
|
484
439
|
FORBIDDEN: "FORBIDDEN";
|
|
485
440
|
NOT_FOUND: "NOT_FOUND";
|
|
486
441
|
CONFLICT: "CONFLICT";
|
|
@@ -521,9 +476,14 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
|
|
|
521
476
|
true: "true";
|
|
522
477
|
false: "false";
|
|
523
478
|
}>>;
|
|
479
|
+
DEV_SIAM_STUB: z.ZodOptional<z.ZodEnum<{
|
|
480
|
+
true: "true";
|
|
481
|
+
false: "false";
|
|
482
|
+
}>>;
|
|
524
483
|
}, z.core.$strict>, z.ZodTransform<{
|
|
525
484
|
COOKIE_SECURE: boolean;
|
|
526
485
|
IAM_LINK_BY_EMAIL: boolean;
|
|
486
|
+
DEV_SIAM_STUB: boolean;
|
|
527
487
|
NODE_ENV: "development" | "test" | "production";
|
|
528
488
|
HOST: string;
|
|
529
489
|
PORT: number;
|
|
@@ -557,7 +517,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
|
|
|
557
517
|
IAM_PROFILE_URL?: string | undefined;
|
|
558
518
|
IAM_REQUIRED_PERMISSION?: string | undefined;
|
|
559
519
|
IAM_LINK_BY_EMAIL?: "true" | "false" | undefined;
|
|
520
|
+
DEV_SIAM_STUB?: "true" | "false" | undefined;
|
|
560
521
|
}>>;
|
|
561
522
|
type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
|
|
562
523
|
|
|
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,
|
|
524
|
+
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, MAX_BULK_VARIABLES, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_VALUE_BYTES, MAX_VERSIONS_LIMIT, MemberDto, PaginatedVersionsResponse, ProjectDto, ProjectRole, ProjectSummaryDto, ResolvedVariableDto, ResolvedVariablesResponse, SLUG_REGEX, SdkEnvironmentDto, SdkMeDto, SdkProjectDto, SharedVariableMetaDto, TOKEN_PREFIX, TokenAccess, TokenDto, UpdateEnvironmentInput, UpdateMemberInput, UpdateProjectInput, UpdateSharedVariableInput, UpdateVariableInput, UserDto, VARIABLE_KEY_REGEX, VariableMetaDto, VariableVersionMetaDto, VariableVersionValueDto, VariableWithValueDto, VersionChangeType, apiEnvironmentSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,16 +8,11 @@ declare const MAX_NAME_LENGTH = 64;
|
|
|
8
8
|
declare const MAX_BULK_VARIABLES = 500;
|
|
9
9
|
declare const EXPIRING_SOON_DAYS = 7;
|
|
10
10
|
declare const EXPIRY_REMINDER_DAYS: readonly [30, 7, 1];
|
|
11
|
-
declare const MIN_PASSWORD_LENGTH = 12;
|
|
12
|
-
declare const MAX_PASSWORD_LENGTH = 256;
|
|
13
11
|
declare const DEFAULT_VERSIONS_LIMIT = 20;
|
|
14
12
|
declare const MAX_VERSIONS_LIMIT = 100;
|
|
15
13
|
declare const CSRF_HEADER_NAME = "x-requested-with";
|
|
16
14
|
declare const CSRF_HEADER_VALUE = "secretenvs-web";
|
|
17
15
|
declare const TOKEN_PREFIX = "svt_";
|
|
18
|
-
declare const TOTP_DIGITS = 6;
|
|
19
|
-
declare const RECOVERY_CODE_COUNT = 10;
|
|
20
|
-
declare const MAX_AUTH_CODE_LENGTH = 32;
|
|
21
16
|
|
|
22
17
|
declare const ProjectRole: z.ZodEnum<{
|
|
23
18
|
OWNER: "OWNER";
|
|
@@ -41,7 +36,6 @@ declare const ErrorCode: z.ZodEnum<{
|
|
|
41
36
|
VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
42
37
|
BAD_REQUEST: "BAD_REQUEST";
|
|
43
38
|
UNAUTHENTICATED: "UNAUTHENTICATED";
|
|
44
|
-
MFA_REQUIRED: "MFA_REQUIRED";
|
|
45
39
|
FORBIDDEN: "FORBIDDEN";
|
|
46
40
|
NOT_FOUND: "NOT_FOUND";
|
|
47
41
|
CONFLICT: "CONFLICT";
|
|
@@ -50,58 +44,18 @@ declare const ErrorCode: z.ZodEnum<{
|
|
|
50
44
|
}>;
|
|
51
45
|
type ErrorCode = z.infer<typeof ErrorCode>;
|
|
52
46
|
|
|
53
|
-
declare const RegisterInput: z.ZodObject<{
|
|
54
|
-
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
55
|
-
name: z.ZodString;
|
|
56
|
-
password: z.ZodString;
|
|
57
|
-
}, z.core.$strict>;
|
|
58
|
-
type RegisterInput = z.infer<typeof RegisterInput>;
|
|
59
|
-
declare const LoginInput: z.ZodObject<{
|
|
60
|
-
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
61
|
-
password: z.ZodString;
|
|
62
|
-
code: z.ZodOptional<z.ZodString>;
|
|
63
|
-
}, z.core.$strict>;
|
|
64
|
-
type LoginInput = z.infer<typeof LoginInput>;
|
|
65
47
|
declare const UserDto: z.ZodObject<{
|
|
66
48
|
id: z.ZodUUID;
|
|
67
49
|
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
68
50
|
name: z.ZodString;
|
|
69
51
|
createdAt: z.ZodISODateTime;
|
|
70
|
-
twoFactorEnabled: z.ZodBoolean;
|
|
71
|
-
twoFactorAppName: z.ZodNullable<z.ZodString>;
|
|
72
52
|
isSuperAdmin: z.ZodBoolean;
|
|
73
|
-
managedBySiam: z.ZodBoolean;
|
|
74
|
-
hasPassword: z.ZodBoolean;
|
|
75
53
|
}, z.core.$strict>;
|
|
76
54
|
type UserDto = z.infer<typeof UserDto>;
|
|
77
55
|
declare const AuthOptionsDto: z.ZodObject<{
|
|
78
|
-
siam: z.ZodBoolean;
|
|
79
56
|
profileUrl: z.ZodNullable<z.ZodString>;
|
|
80
57
|
}, z.core.$strict>;
|
|
81
58
|
type AuthOptionsDto = z.infer<typeof AuthOptionsDto>;
|
|
82
|
-
declare const TwoFactorSetupDto: z.ZodObject<{
|
|
83
|
-
secret: z.ZodString;
|
|
84
|
-
otpauthUri: z.ZodString;
|
|
85
|
-
}, z.core.$strict>;
|
|
86
|
-
type TwoFactorSetupDto = z.infer<typeof TwoFactorSetupDto>;
|
|
87
|
-
declare const TwoFactorSetupInput: z.ZodObject<{
|
|
88
|
-
password: z.ZodString;
|
|
89
|
-
}, z.core.$strict>;
|
|
90
|
-
type TwoFactorSetupInput = z.infer<typeof TwoFactorSetupInput>;
|
|
91
|
-
declare const TwoFactorEnableInput: z.ZodObject<{
|
|
92
|
-
appName: z.ZodString;
|
|
93
|
-
code: z.ZodString;
|
|
94
|
-
}, z.core.$strict>;
|
|
95
|
-
type TwoFactorEnableInput = z.infer<typeof TwoFactorEnableInput>;
|
|
96
|
-
declare const TwoFactorConfirmInput: z.ZodObject<{
|
|
97
|
-
password: z.ZodString;
|
|
98
|
-
code: z.ZodString;
|
|
99
|
-
}, z.core.$strict>;
|
|
100
|
-
type TwoFactorConfirmInput = z.infer<typeof TwoFactorConfirmInput>;
|
|
101
|
-
declare const RecoveryCodesDto: z.ZodObject<{
|
|
102
|
-
recoveryCodes: z.ZodArray<z.ZodString>;
|
|
103
|
-
}, z.core.$strict>;
|
|
104
|
-
type RecoveryCodesDto = z.infer<typeof RecoveryCodesDto>;
|
|
105
59
|
declare const CreateProjectInput: z.ZodObject<{
|
|
106
60
|
name: z.ZodString;
|
|
107
61
|
slug: z.ZodString;
|
|
@@ -374,6 +328,12 @@ declare const SdkProjectDto: z.ZodObject<{
|
|
|
374
328
|
}, z.core.$strict>>;
|
|
375
329
|
}, z.core.$strict>;
|
|
376
330
|
type SdkProjectDto = z.infer<typeof SdkProjectDto>;
|
|
331
|
+
declare const SdkMeDto: z.ZodObject<{
|
|
332
|
+
id: z.ZodUUID;
|
|
333
|
+
email: z.ZodPipe<z.ZodString, z.ZodEmail>;
|
|
334
|
+
name: z.ZodString;
|
|
335
|
+
}, z.core.$strict>;
|
|
336
|
+
type SdkMeDto = z.infer<typeof SdkMeDto>;
|
|
377
337
|
declare const AdminProjectDto: z.ZodObject<{
|
|
378
338
|
id: z.ZodUUID;
|
|
379
339
|
name: z.ZodString;
|
|
@@ -398,7 +358,6 @@ declare const AdminUserDto: z.ZodObject<{
|
|
|
398
358
|
createdAt: z.ZodISODateTime;
|
|
399
359
|
disabledAt: z.ZodNullable<z.ZodISODateTime>;
|
|
400
360
|
isSuperAdmin: z.ZodBoolean;
|
|
401
|
-
managedBySiam: z.ZodBoolean;
|
|
402
361
|
projectCount: z.ZodNumber;
|
|
403
362
|
}, z.core.$strict>;
|
|
404
363
|
type AdminUserDto = z.infer<typeof AdminUserDto>;
|
|
@@ -409,7 +368,6 @@ declare const AdminUserDetailDto: z.ZodObject<{
|
|
|
409
368
|
createdAt: z.ZodISODateTime;
|
|
410
369
|
disabledAt: z.ZodNullable<z.ZodISODateTime>;
|
|
411
370
|
isSuperAdmin: z.ZodBoolean;
|
|
412
|
-
managedBySiam: z.ZodBoolean;
|
|
413
371
|
projectCount: z.ZodNumber;
|
|
414
372
|
projects: z.ZodArray<z.ZodObject<{
|
|
415
373
|
id: z.ZodUUID;
|
|
@@ -425,9 +383,7 @@ declare const AdminUserDetailDto: z.ZodObject<{
|
|
|
425
383
|
}, z.core.$strict>;
|
|
426
384
|
type AdminUserDetailDto = z.infer<typeof AdminUserDetailDto>;
|
|
427
385
|
declare const AdminUpdateUserInput: z.ZodObject<{
|
|
428
|
-
|
|
429
|
-
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
430
|
-
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
386
|
+
disabled: z.ZodBoolean;
|
|
431
387
|
}, z.core.$strict>;
|
|
432
388
|
type AdminUpdateUserInput = z.infer<typeof AdminUpdateUserInput>;
|
|
433
389
|
declare const CreateTokenInput: z.ZodObject<{
|
|
@@ -480,7 +436,6 @@ declare const ApiErrorBody: z.ZodObject<{
|
|
|
480
436
|
VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
481
437
|
BAD_REQUEST: "BAD_REQUEST";
|
|
482
438
|
UNAUTHENTICATED: "UNAUTHENTICATED";
|
|
483
|
-
MFA_REQUIRED: "MFA_REQUIRED";
|
|
484
439
|
FORBIDDEN: "FORBIDDEN";
|
|
485
440
|
NOT_FOUND: "NOT_FOUND";
|
|
486
441
|
CONFLICT: "CONFLICT";
|
|
@@ -521,9 +476,14 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
|
|
|
521
476
|
true: "true";
|
|
522
477
|
false: "false";
|
|
523
478
|
}>>;
|
|
479
|
+
DEV_SIAM_STUB: z.ZodOptional<z.ZodEnum<{
|
|
480
|
+
true: "true";
|
|
481
|
+
false: "false";
|
|
482
|
+
}>>;
|
|
524
483
|
}, z.core.$strict>, z.ZodTransform<{
|
|
525
484
|
COOKIE_SECURE: boolean;
|
|
526
485
|
IAM_LINK_BY_EMAIL: boolean;
|
|
486
|
+
DEV_SIAM_STUB: boolean;
|
|
527
487
|
NODE_ENV: "development" | "test" | "production";
|
|
528
488
|
HOST: string;
|
|
529
489
|
PORT: number;
|
|
@@ -557,7 +517,8 @@ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
|
|
|
557
517
|
IAM_PROFILE_URL?: string | undefined;
|
|
558
518
|
IAM_REQUIRED_PERMISSION?: string | undefined;
|
|
559
519
|
IAM_LINK_BY_EMAIL?: "true" | "false" | undefined;
|
|
520
|
+
DEV_SIAM_STUB?: "true" | "false" | undefined;
|
|
560
521
|
}>>;
|
|
561
522
|
type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
|
|
562
523
|
|
|
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,
|
|
524
|
+
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, MAX_BULK_VARIABLES, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_VALUE_BYTES, MAX_VERSIONS_LIMIT, MemberDto, PaginatedVersionsResponse, ProjectDto, ProjectRole, ProjectSummaryDto, ResolvedVariableDto, ResolvedVariablesResponse, SLUG_REGEX, SdkEnvironmentDto, SdkMeDto, SdkProjectDto, SharedVariableMetaDto, TOKEN_PREFIX, TokenAccess, TokenDto, UpdateEnvironmentInput, UpdateMemberInput, UpdateProjectInput, UpdateSharedVariableInput, UpdateVariableInput, UserDto, VARIABLE_KEY_REGEX, VariableMetaDto, VariableVersionMetaDto, VariableVersionValueDto, VariableWithValueDto, VersionChangeType, apiEnvironmentSchema };
|
package/dist/index.js
CHANGED
|
@@ -10,16 +10,11 @@ var MAX_NAME_LENGTH = 64;
|
|
|
10
10
|
var MAX_BULK_VARIABLES = 500;
|
|
11
11
|
var EXPIRING_SOON_DAYS = 7;
|
|
12
12
|
var EXPIRY_REMINDER_DAYS = [30, 7, 1];
|
|
13
|
-
var MIN_PASSWORD_LENGTH = 12;
|
|
14
|
-
var MAX_PASSWORD_LENGTH = 256;
|
|
15
13
|
var DEFAULT_VERSIONS_LIMIT = 20;
|
|
16
14
|
var MAX_VERSIONS_LIMIT = 100;
|
|
17
15
|
var CSRF_HEADER_NAME = "x-requested-with";
|
|
18
16
|
var CSRF_HEADER_VALUE = "secretenvs-web";
|
|
19
17
|
var TOKEN_PREFIX = "svt_";
|
|
20
|
-
var TOTP_DIGITS = 6;
|
|
21
|
-
var RECOVERY_CODE_COUNT = 10;
|
|
22
|
-
var MAX_AUTH_CODE_LENGTH = 32;
|
|
23
18
|
|
|
24
19
|
// src/enums.ts
|
|
25
20
|
import { z } from "zod";
|
|
@@ -30,7 +25,6 @@ var ErrorCode = z.enum([
|
|
|
30
25
|
"VALIDATION_ERROR",
|
|
31
26
|
"BAD_REQUEST",
|
|
32
27
|
"UNAUTHENTICATED",
|
|
33
|
-
"MFA_REQUIRED",
|
|
34
28
|
"FORBIDDEN",
|
|
35
29
|
"NOT_FOUND",
|
|
36
30
|
"CONFLICT",
|
|
@@ -55,47 +49,19 @@ var variableValue = z2.string().refine(
|
|
|
55
49
|
var secretExpiry = isoDate.refine((value) => Date.parse(value) > Date.now(), {
|
|
56
50
|
message: "Expiry must be in the future"
|
|
57
51
|
}).nullable();
|
|
58
|
-
var password = z2.string().min(MIN_PASSWORD_LENGTH).max(MAX_PASSWORD_LENGTH);
|
|
59
|
-
var RegisterInput = z2.object({ email, name, password }).strict();
|
|
60
|
-
var authCode = z2.string().trim().min(1, "Enter your code").max(MAX_AUTH_CODE_LENGTH);
|
|
61
|
-
var LoginInput = z2.object({
|
|
62
|
-
email,
|
|
63
|
-
password: z2.string().min(1).max(MAX_PASSWORD_LENGTH),
|
|
64
|
-
code: authCode.optional()
|
|
65
|
-
}).strict();
|
|
66
52
|
var UserDto = z2.object({
|
|
67
53
|
id,
|
|
68
54
|
email,
|
|
69
55
|
name,
|
|
70
56
|
createdAt: isoDate,
|
|
71
|
-
twoFactorEnabled: z2.boolean(),
|
|
72
|
-
// Name the user gave the authenticator app at setup; null while 2FA is off.
|
|
73
|
-
twoFactorAppName: z2.string().nullable(),
|
|
74
57
|
// 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()
|
|
58
|
+
isSuperAdmin: z2.boolean()
|
|
81
59
|
}).strict();
|
|
82
60
|
var AuthOptionsDto = z2.object({
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
// Where people manage their SIAM account; null when it is not configured or SIAM is off.
|
|
61
|
+
// Where people manage their SIAM account (name, email, password, two-factor); null when the
|
|
62
|
+
// server does not say.
|
|
86
63
|
profileUrl: z2.string().nullable()
|
|
87
64
|
}).strict();
|
|
88
|
-
var TwoFactorSetupDto = z2.object({ secret: z2.string(), otpauthUri: z2.string() }).strict();
|
|
89
|
-
var TwoFactorSetupInput = z2.object({ password: z2.string().min(1).max(MAX_PASSWORD_LENGTH) }).strict();
|
|
90
|
-
var TwoFactorEnableInput = z2.object({
|
|
91
|
-
appName: z2.string().trim().min(1, "Enter the app name").max(MAX_NAME_LENGTH),
|
|
92
|
-
code: z2.string().trim().regex(/^\d{6}$/, "Enter the 6-digit code")
|
|
93
|
-
}).strict();
|
|
94
|
-
var TwoFactorConfirmInput = z2.object({
|
|
95
|
-
password: z2.string().min(1).max(MAX_PASSWORD_LENGTH),
|
|
96
|
-
code: authCode
|
|
97
|
-
}).strict();
|
|
98
|
-
var RecoveryCodesDto = z2.object({ recoveryCodes: z2.array(z2.string()) }).strict();
|
|
99
65
|
var CreateProjectInput = z2.object({ name, slug, description: z2.string().max(500).optional() }).strict();
|
|
100
66
|
var UpdateProjectInput = z2.object({
|
|
101
67
|
name: name.optional(),
|
|
@@ -234,6 +200,7 @@ var SdkProjectDto = z2.object({
|
|
|
234
200
|
role: ProjectRole,
|
|
235
201
|
environments: z2.array(SdkEnvironmentDto)
|
|
236
202
|
}).strict();
|
|
203
|
+
var SdkMeDto = z2.object({ id, email, name }).strict();
|
|
237
204
|
var adminPerson = z2.object({ id, name, email }).strict();
|
|
238
205
|
var AdminProjectDto = ProjectDto.extend({
|
|
239
206
|
owner: adminPerson.nullable(),
|
|
@@ -248,22 +215,13 @@ var AdminUserDto = z2.object({
|
|
|
248
215
|
// Null while the account is enabled.
|
|
249
216
|
disabledAt: isoDate.nullable(),
|
|
250
217
|
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
218
|
projectCount: z2.number().int().min(0)
|
|
254
219
|
}).strict();
|
|
255
220
|
var AdminUserDetailDto = AdminUserDto.extend({
|
|
256
221
|
// Every project the user is a member of, with their role there.
|
|
257
222
|
projects: z2.array(z2.object({ id, name, slug, role: ProjectRole }).strict())
|
|
258
223
|
});
|
|
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
|
+
var AdminUpdateUserInput = z2.object({ disabled: z2.boolean() }).strict();
|
|
267
225
|
var CreateTokenInput = z2.object({
|
|
268
226
|
name,
|
|
269
227
|
access: TokenAccess,
|
|
@@ -319,8 +277,9 @@ var apiEnvironmentSchema = z3.object({
|
|
|
319
277
|
// Shared secret for the daily expiry-reminder call (see docs/DEPLOYMENT.md). Unset turns
|
|
320
278
|
// that endpoint off.
|
|
321
279
|
CRON_SECRET: z3.string().min(32).max(256).optional(),
|
|
322
|
-
// Sign-in through SIAM (https://siam.ankityadav.net.in/docs)
|
|
323
|
-
//
|
|
280
|
+
// Sign-in through SIAM (https://siam.ankityadav.net.in/docs) is the only way in, so the four
|
|
281
|
+
// IAM_* values below are required (see the refinement). The one exception is local
|
|
282
|
+
// development with DEV_SIAM_STUB, and NODE_ENV=test, where tests inject their own SIAM.
|
|
324
283
|
IAM_BASE_URL: z3.url().optional(),
|
|
325
284
|
IAM_CLIENT_ID: z3.string().min(1).max(256).optional(),
|
|
326
285
|
IAM_CLIENT_SECRET: z3.string().min(1).max(512).optional(),
|
|
@@ -336,7 +295,10 @@ var apiEnvironmentSchema = z3.object({
|
|
|
336
295
|
IAM_REQUIRED_PERMISSION: z3.string().min(1).max(128).optional(),
|
|
337
296
|
// Link a SIAM sign-in to an existing local account with the same email. Off by default,
|
|
338
297
|
// 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()
|
|
298
|
+
IAM_LINK_BY_EMAIL: z3.enum(["true", "false"]).optional(),
|
|
299
|
+
// Local development only: replaces SIAM with a built-in stand-in that signs in one fixed
|
|
300
|
+
// fake user without asking for anything. Refused outside NODE_ENV=development.
|
|
301
|
+
DEV_SIAM_STUB: z3.enum(["true", "false"]).optional()
|
|
340
302
|
}).strict().superRefine((environment, context) => {
|
|
341
303
|
const names = [
|
|
342
304
|
"IAM_BASE_URL",
|
|
@@ -344,20 +306,29 @@ var apiEnvironmentSchema = z3.object({
|
|
|
344
306
|
"IAM_CLIENT_SECRET",
|
|
345
307
|
"IAM_REDIRECT_URI"
|
|
346
308
|
];
|
|
347
|
-
const
|
|
348
|
-
if (
|
|
349
|
-
|
|
309
|
+
const stub = environment.DEV_SIAM_STUB === "true";
|
|
310
|
+
if (stub && environment.NODE_ENV !== "development") {
|
|
311
|
+
context.addIssue({
|
|
312
|
+
code: "custom",
|
|
313
|
+
path: ["DEV_SIAM_STUB"],
|
|
314
|
+
message: "Only allowed when NODE_ENV is development"
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
if (stub || environment.NODE_ENV === "test") return;
|
|
318
|
+
for (const name2 of names) {
|
|
319
|
+
if (environment[name2] === void 0) {
|
|
350
320
|
context.addIssue({
|
|
351
321
|
code: "custom",
|
|
352
322
|
path: [name2],
|
|
353
|
-
message: "Required
|
|
323
|
+
message: "Required: SIAM is the only way to sign in"
|
|
354
324
|
});
|
|
355
325
|
}
|
|
356
326
|
}
|
|
357
327
|
}).transform((environment) => ({
|
|
358
328
|
...environment,
|
|
359
329
|
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"
|
|
330
|
+
IAM_LINK_BY_EMAIL: environment.IAM_LINK_BY_EMAIL === "true",
|
|
331
|
+
DEV_SIAM_STUB: environment.DEV_SIAM_STUB === "true"
|
|
361
332
|
}));
|
|
362
333
|
export {
|
|
363
334
|
AddMemberInput,
|
|
@@ -384,37 +355,26 @@ export {
|
|
|
384
355
|
ErrorCode,
|
|
385
356
|
ExpiringSecretDto,
|
|
386
357
|
ListVersionsQuery,
|
|
387
|
-
LoginInput,
|
|
388
|
-
MAX_AUTH_CODE_LENGTH,
|
|
389
358
|
MAX_BULK_VARIABLES,
|
|
390
359
|
MAX_KEY_LENGTH,
|
|
391
360
|
MAX_NAME_LENGTH,
|
|
392
|
-
MAX_PASSWORD_LENGTH,
|
|
393
361
|
MAX_VALUE_BYTES,
|
|
394
362
|
MAX_VERSIONS_LIMIT,
|
|
395
|
-
MIN_PASSWORD_LENGTH,
|
|
396
363
|
MemberDto,
|
|
397
364
|
PaginatedVersionsResponse,
|
|
398
365
|
ProjectDto,
|
|
399
366
|
ProjectRole,
|
|
400
367
|
ProjectSummaryDto,
|
|
401
|
-
RECOVERY_CODE_COUNT,
|
|
402
|
-
RecoveryCodesDto,
|
|
403
|
-
RegisterInput,
|
|
404
368
|
ResolvedVariableDto,
|
|
405
369
|
ResolvedVariablesResponse,
|
|
406
370
|
SLUG_REGEX,
|
|
407
371
|
SdkEnvironmentDto,
|
|
372
|
+
SdkMeDto,
|
|
408
373
|
SdkProjectDto,
|
|
409
374
|
SharedVariableMetaDto,
|
|
410
375
|
TOKEN_PREFIX,
|
|
411
|
-
TOTP_DIGITS,
|
|
412
376
|
TokenAccess,
|
|
413
377
|
TokenDto,
|
|
414
|
-
TwoFactorConfirmInput,
|
|
415
|
-
TwoFactorEnableInput,
|
|
416
|
-
TwoFactorSetupDto,
|
|
417
|
-
TwoFactorSetupInput,
|
|
418
378
|
UpdateEnvironmentInput,
|
|
419
379
|
UpdateMemberInput,
|
|
420
380
|
UpdateProjectInput,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secretenvs/contracts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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",
|