@norskvideo/ctl-product-template-schema 0.1.75 → 0.1.76
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/package.json +1 -1
- package/secrets/config.d.ts +6 -0
- package/secrets/config.js +12 -5
- package/secrets/index.d.ts +1 -1
- package/secrets/index.js +1 -1
package/package.json
CHANGED
package/secrets/config.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ export type SecretProvidersConfig = z.infer<typeof SecretProvidersConfigSchema>;
|
|
|
24
24
|
/** The env variable naming the profile to use. Unset, empty or `production`
|
|
25
25
|
* is the config's root. */
|
|
26
26
|
export declare const SECRETS_PROFILE_ENV = "NORSK_SECRETS_PROFILE";
|
|
27
|
+
/** The root of the config, and the profile a process has when none is named. */
|
|
28
|
+
export declare const PRODUCTION_SECRETS_PROFILE = "production";
|
|
29
|
+
/** The profile this process resolves with: `production` unless
|
|
30
|
+
* NORSK_SECRETS_PROFILE names another. A fleet agrees on one, so a worker
|
|
31
|
+
* reports it and norsk-mgr places only on workers reporting its own. */
|
|
32
|
+
export declare function activeSecretsProfile(env: Record<string, string | undefined>): string;
|
|
27
33
|
/** A profile: any top-level key but the root's own. It redirects provider
|
|
28
34
|
* names; `norsk` (held by ctl) and `plain` (a literal) are not providers it
|
|
29
35
|
* can move. */
|
package/secrets/config.js
CHANGED
|
@@ -32,7 +32,14 @@ const ROOT_KEYS = new Set(Object.keys(SecretProvidersConfigSchema.shape));
|
|
|
32
32
|
/** The env variable naming the profile to use. Unset, empty or `production`
|
|
33
33
|
* is the config's root. */
|
|
34
34
|
export const SECRETS_PROFILE_ENV = "NORSK_SECRETS_PROFILE";
|
|
35
|
-
|
|
35
|
+
/** The root of the config, and the profile a process has when none is named. */
|
|
36
|
+
export const PRODUCTION_SECRETS_PROFILE = "production";
|
|
37
|
+
/** The profile this process resolves with: `production` unless
|
|
38
|
+
* NORSK_SECRETS_PROFILE names another. A fleet agrees on one, so a worker
|
|
39
|
+
* reports it and norsk-mgr places only on workers reporting its own. */
|
|
40
|
+
export function activeSecretsProfile(env) {
|
|
41
|
+
return env[SECRETS_PROFILE_ENV] || PRODUCTION_SECRETS_PROFILE;
|
|
42
|
+
}
|
|
36
43
|
/** What a profile may point a provider name at: one store, configured. */
|
|
37
44
|
const RedirectSchema = z.union([
|
|
38
45
|
z.strictObject({ file: z.strictObject({ dir: z.string().min(1) }) }),
|
|
@@ -104,8 +111,8 @@ export function secretsProfileNotice(opts) {
|
|
|
104
111
|
return ok(`secrets profile '${selected.value.name}' is active (config ${source.value.where}): ${redirects || "no redirects"}`);
|
|
105
112
|
}
|
|
106
113
|
function selectProfile(env, profiles, where) {
|
|
107
|
-
const name = env
|
|
108
|
-
if (
|
|
114
|
+
const name = activeSecretsProfile(env);
|
|
115
|
+
if (name === PRODUCTION_SECRETS_PROFILE)
|
|
109
116
|
return ok(undefined);
|
|
110
117
|
const redirects = profiles[name];
|
|
111
118
|
if (!redirects) {
|
|
@@ -173,9 +180,9 @@ function readConfig(opts) {
|
|
|
173
180
|
root[key] = value;
|
|
174
181
|
continue;
|
|
175
182
|
}
|
|
176
|
-
if (!PROVIDER_NAME.test(key) || key ===
|
|
183
|
+
if (!PROVIDER_NAME.test(key) || key === PRODUCTION_SECRETS_PROFILE) {
|
|
177
184
|
return err(`secret provider config ${where} is invalid: '${key}' is neither a setting (${[...ROOT_KEYS].join(", ")}) ` +
|
|
178
|
-
`nor a profile name (lower case, not '${
|
|
185
|
+
`nor a profile name (lower case, not '${PRODUCTION_SECRETS_PROFILE}', which is the root)`);
|
|
179
186
|
}
|
|
180
187
|
const profile = SecretProfileSchema.safeParse(value);
|
|
181
188
|
if (!profile.success) {
|
package/secrets/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SecretResolver } from "./resolver.js";
|
|
2
2
|
export { isSecretReference, parseSecretReference, SECRET_PLACEHOLDER, SECRET_REFERENCE_PREFIX, type SecretReference, secretReference, } from "../secret-references.js";
|
|
3
|
-
export { type LoadSecretProvidersOptions, loadSecretProviders, RESERVED_PROVIDER_NAMES, SECRETS_PROFILE_ENV, SecretProfileSchema, type SecretProvidersConfig, SecretProvidersConfigSchema, secretsProfileNotice, } from "./config.js";
|
|
3
|
+
export { activeSecretsProfile, type LoadSecretProvidersOptions, loadSecretProviders, PRODUCTION_SECRETS_PROFILE, RESERVED_PROVIDER_NAMES, SECRETS_PROFILE_ENV, SecretProfileSchema, type SecretProvidersConfig, SecretProvidersConfigSchema, secretsProfileNotice, } from "./config.js";
|
|
4
4
|
export { type DelegateOptions, delegateResolver } from "./delegate.js";
|
|
5
5
|
export { deobfuscate, isObfuscated, OBFUSCATED_PREFIX, obfuscate } from "./obfuscation.js";
|
|
6
6
|
export type { SecretProvider, SecretProviders, SecretResolutionError } from "./provider.js";
|
package/secrets/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { delegateResolver } from "./delegate.js";
|
|
|
10
10
|
import { localResolver } from "./resolver.js";
|
|
11
11
|
import { SECRETS_TOKEN_ENV, SECRETS_URL_ENV } from "./wire.js";
|
|
12
12
|
export { isSecretReference, parseSecretReference, SECRET_PLACEHOLDER, SECRET_REFERENCE_PREFIX, secretReference, } from "../secret-references.js";
|
|
13
|
-
export { loadSecretProviders, RESERVED_PROVIDER_NAMES, SECRETS_PROFILE_ENV, SecretProfileSchema, SecretProvidersConfigSchema, secretsProfileNotice, } from "./config.js";
|
|
13
|
+
export { activeSecretsProfile, loadSecretProviders, PRODUCTION_SECRETS_PROFILE, RESERVED_PROVIDER_NAMES, SECRETS_PROFILE_ENV, SecretProfileSchema, SecretProvidersConfigSchema, secretsProfileNotice, } from "./config.js";
|
|
14
14
|
export { delegateResolver } from "./delegate.js";
|
|
15
15
|
export { deobfuscate, isObfuscated, OBFUSCATED_PREFIX, obfuscate } from "./obfuscation.js";
|
|
16
16
|
export { awsSecretProvider } from "./providers/aws.js";
|