@empire-builder-kit/runtime 1.0.0-beta.8 → 1.0.0-rc.1
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/NOTICE +6 -0
- package/package.json +93 -3
- package/src/api-contract/artifacts.d.ts +67 -0
- package/src/api-contract/artifacts.js +349 -0
- package/src/api-contract/artifacts.js.map +1 -0
- package/src/api-contract/client.d.ts +79 -0
- package/src/api-contract/client.js +561 -0
- package/src/api-contract/client.js.map +1 -0
- package/src/api-contract/errors.d.ts +7 -0
- package/src/api-contract/errors.js +11 -0
- package/src/api-contract/errors.js.map +1 -0
- package/src/api-contract/index.d.ts +9 -0
- package/src/api-contract/index.js +10 -0
- package/src/api-contract/index.js.map +1 -0
- package/src/api-contract/operation.d.ts +118 -0
- package/src/api-contract/operation.js +609 -0
- package/src/api-contract/operation.js.map +1 -0
- package/src/api-contract/schema.d.ts +81 -0
- package/src/api-contract/schema.js +313 -0
- package/src/api-contract/schema.js.map +1 -0
- package/src/api-contract/server.d.ts +77 -0
- package/src/api-contract/server.js +466 -0
- package/src/api-contract/server.js.map +1 -0
- package/src/async-work/contract.d.ts +17 -0
- package/src/async-work/contract.js +105 -0
- package/src/async-work/contract.js.map +1 -0
- package/src/async-work/idempotency.d.ts +123 -0
- package/src/async-work/idempotency.js +167 -0
- package/src/async-work/idempotency.js.map +1 -0
- package/src/async-work/index.d.ts +8 -0
- package/src/async-work/index.js +9 -0
- package/src/async-work/index.js.map +1 -0
- package/src/async-work/provider.d.ts +90 -0
- package/src/async-work/provider.js +155 -0
- package/src/async-work/provider.js.map +1 -0
- package/src/async-work/recovery.d.ts +103 -0
- package/src/async-work/recovery.js +291 -0
- package/src/async-work/recovery.js.map +1 -0
- package/src/async-work/schedule.d.ts +117 -0
- package/src/async-work/schedule.js +279 -0
- package/src/async-work/schedule.js.map +1 -0
- package/src/async-work/sqs.d.ts +133 -0
- package/src/async-work/sqs.js +280 -0
- package/src/async-work/sqs.js.map +1 -0
- package/src/async-work/webhook.d.ts +60 -0
- package/src/async-work/webhook.js +178 -0
- package/src/async-work/webhook.js.map +1 -0
- package/src/async-work/workflow.d.ts +98 -0
- package/src/async-work/workflow.js +225 -0
- package/src/async-work/workflow.js.map +1 -0
- package/src/auth-backend.d.ts +12 -2
- package/src/auth-backend.js +30 -18
- package/src/auth-backend.js.map +1 -1
- package/src/authorization/admission.d.ts +30 -0
- package/src/authorization/admission.js +87 -0
- package/src/authorization/admission.js.map +1 -0
- package/src/authorization/approval.d.ts +99 -0
- package/src/authorization/approval.js +249 -0
- package/src/authorization/approval.js.map +1 -0
- package/src/authorization/audit.d.ts +35 -0
- package/src/authorization/audit.js +35 -0
- package/src/authorization/audit.js.map +1 -0
- package/src/authorization/delegation.d.ts +149 -0
- package/src/authorization/delegation.js +401 -0
- package/src/authorization/delegation.js.map +1 -0
- package/src/authorization/errors.d.ts +32 -0
- package/src/authorization/errors.js +153 -0
- package/src/authorization/errors.js.map +1 -0
- package/src/authorization/evaluator.d.ts +39 -0
- package/src/authorization/evaluator.js +199 -0
- package/src/authorization/evaluator.js.map +1 -0
- package/src/authorization/index.d.ts +14 -0
- package/src/authorization/index.js +15 -0
- package/src/authorization/index.js.map +1 -0
- package/src/authorization/machine-token.d.ts +87 -0
- package/src/authorization/machine-token.js +201 -0
- package/src/authorization/machine-token.js.map +1 -0
- package/src/authorization/machine.d.ts +32 -0
- package/src/authorization/machine.js +41 -0
- package/src/authorization/machine.js.map +1 -0
- package/src/authorization/model.d.ts +112 -0
- package/src/authorization/model.js +112 -0
- package/src/authorization/model.js.map +1 -0
- package/src/canonical-json.cjs +157 -0
- package/src/canonical-json.d.cts +26 -0
- package/src/canonical-json.d.ts +18 -0
- package/src/canonical-json.js +125 -0
- package/src/canonical-json.js.map +1 -0
- package/src/configuration/contract.d.ts +107 -0
- package/src/configuration/contract.js +461 -0
- package/src/configuration/contract.js.map +1 -0
- package/src/configuration/index.d.ts +3 -0
- package/src/configuration/index.js +4 -0
- package/src/configuration/index.js.map +1 -0
- package/src/configuration/provider.d.ts +59 -0
- package/src/configuration/provider.js +198 -0
- package/src/configuration/provider.js.map +1 -0
- package/src/configuration/rollout-evaluator.cjs +54 -0
- package/src/configuration/rollout-evaluator.d.cts +26 -0
- package/src/configuration/rollout-evaluator.d.ts +18 -0
- package/src/configuration/rollout-evaluator.js +38 -0
- package/src/configuration/rollout-evaluator.js.map +1 -0
- package/src/configuration/rollout-key.cjs +38 -0
- package/src/configuration/rollout-key.d.cts +14 -0
- package/src/configuration/rollout-key.d.ts +10 -0
- package/src/configuration/rollout-key.js +26 -0
- package/src/configuration/rollout-key.js.map +1 -0
- package/src/configuration/rollout.d.ts +60 -0
- package/src/configuration/rollout.js +42 -0
- package/src/configuration/rollout.js.map +1 -0
- package/src/data-lifecycle/contract.d.ts +33 -0
- package/src/data-lifecycle/contract.js +118 -0
- package/src/data-lifecycle/contract.js.map +1 -0
- package/src/data-lifecycle/event.d.ts +28 -0
- package/src/data-lifecycle/event.js +76 -0
- package/src/data-lifecycle/event.js.map +1 -0
- package/src/data-lifecycle/evidence.d.ts +65 -0
- package/src/data-lifecycle/evidence.js +162 -0
- package/src/data-lifecycle/evidence.js.map +1 -0
- package/src/data-lifecycle/holds.d.ts +29 -0
- package/src/data-lifecycle/holds.js +124 -0
- package/src/data-lifecycle/holds.js.map +1 -0
- package/src/data-lifecycle/index.d.ts +8 -0
- package/src/data-lifecycle/index.js +9 -0
- package/src/data-lifecycle/index.js.map +1 -0
- package/src/data-lifecycle/policy.d.ts +16 -0
- package/src/data-lifecycle/policy.js +79 -0
- package/src/data-lifecycle/policy.js.map +1 -0
- package/src/data-lifecycle/restore.d.ts +90 -0
- package/src/data-lifecycle/restore.js +336 -0
- package/src/data-lifecycle/restore.js.map +1 -0
- package/src/data-lifecycle/retention.d.ts +57 -0
- package/src/data-lifecycle/retention.js +232 -0
- package/src/data-lifecycle/retention.js.map +1 -0
- package/src/data-lifecycle/rights.d.ts +171 -0
- package/src/data-lifecycle/rights.js +533 -0
- package/src/data-lifecycle/rights.js.map +1 -0
- package/src/database.d.ts +36 -0
- package/src/database.js +119 -0
- package/src/database.js.map +1 -0
- package/src/deterministic-order.cjs +16 -0
- package/src/deterministic-order.d.cts +9 -0
- package/src/deterministic-order.d.ts +7 -0
- package/src/deterministic-order.js +10 -0
- package/src/deterministic-order.js.map +1 -0
- package/src/events.d.ts +28 -19
- package/src/events.js +171 -66
- package/src/events.js.map +1 -1
- package/src/index.d.ts +7 -1
- package/src/index.js +24 -0
- package/src/index.js.map +1 -1
- package/src/lambda.d.ts +8 -2
- package/src/lambda.js +100 -39
- package/src/lambda.js.map +1 -1
- package/src/logging.d.ts +95 -36
- package/src/logging.js +460 -62
- package/src/logging.js.map +1 -1
- package/src/observability.d.ts +80 -18
- package/src/observability.js +252 -61
- package/src/observability.js.map +1 -1
- package/src/performance/index.d.ts +1 -0
- package/src/performance/index.js +2 -0
- package/src/performance/index.js.map +1 -0
- package/src/performance/protected-load-endpoint.d.ts +140 -0
- package/src/performance/protected-load-endpoint.js +462 -0
- package/src/performance/protected-load-endpoint.js.map +1 -0
- package/src/rds-global-ca-bundle.d.ts +1 -0
- package/src/rds-global-ca-bundle.js +2742 -0
- package/src/rds-global-ca-bundle.js.map +1 -0
- package/src/reliability/burn.d.ts +39 -0
- package/src/reliability/burn.js +102 -0
- package/src/reliability/burn.js.map +1 -0
- package/src/reliability/contract.d.ts +5 -0
- package/src/reliability/contract.js +317 -0
- package/src/reliability/contract.js.map +1 -0
- package/src/reliability/incident.d.ts +16 -0
- package/src/reliability/incident.js +562 -0
- package/src/reliability/incident.js.map +1 -0
- package/src/reliability/index.d.ts +5 -0
- package/src/reliability/index.js +6 -0
- package/src/reliability/index.js.map +1 -0
- package/src/reliability/model.d.ts +191 -0
- package/src/reliability/model.fixtures.d.ts +2 -0
- package/src/reliability/model.fixtures.js +57 -0
- package/src/reliability/model.fixtures.js.map +1 -0
- package/src/reliability/model.js +2 -0
- package/src/reliability/model.js.map +1 -0
- package/src/reliability/slo.d.ts +9 -0
- package/src/reliability/slo.js +74 -0
- package/src/reliability/slo.js.map +1 -0
- package/src/request-context.d.ts +57 -15
- package/src/request-context.js +116 -36
- package/src/request-context.js.map +1 -1
- package/src/safe-reference.cjs +57 -0
- package/src/safe-reference.d.cts +25 -0
- package/src/safe-reference.d.ts +11 -0
- package/src/safe-reference.js +46 -0
- package/src/safe-reference.js.map +1 -0
- package/src/secrets/contract.d.ts +99 -0
- package/src/secrets/contract.js +238 -0
- package/src/secrets/contract.js.map +1 -0
- package/src/secrets/index.d.ts +4 -0
- package/src/secrets/index.js +5 -0
- package/src/secrets/index.js.map +1 -0
- package/src/secrets/observability.d.ts +14 -0
- package/src/secrets/observability.js +100 -0
- package/src/secrets/observability.js.map +1 -0
- package/src/secrets/personal.d.ts +48 -0
- package/src/secrets/personal.js +332 -0
- package/src/secrets/personal.js.map +1 -0
- package/src/secrets/resolver.d.ts +125 -0
- package/src/secrets/resolver.js +602 -0
- package/src/secrets/resolver.js.map +1 -0
- package/src/secrets/sensitive-patterns.cjs +84 -0
- package/src/secrets/sensitive-patterns.d.cts +62 -0
- package/src/secrets/sensitive-patterns.d.ts +40 -0
- package/src/secrets/sensitive-patterns.js +60 -0
- package/src/secrets/sensitive-patterns.js.map +1 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ConfigurationDeclaration, type ConfigurationValue } from './contract.js';
|
|
2
|
+
export declare const CONFIGURATION_EVALUATION_REASONS: readonly ["STATIC", "CACHED", "STALE", "DEFAULT", "ERROR"];
|
|
3
|
+
export declare const CONFIGURATION_ERROR_CATEGORIES: readonly ["FLAG_NOT_FOUND", "TYPE_MISMATCH", "PROVIDER_UNAVAILABLE", "TIMEOUT", "CANCELLED", "INVALID_CONTEXT"];
|
|
4
|
+
export type ConfigurationEvaluationReason = (typeof CONFIGURATION_EVALUATION_REASONS)[number];
|
|
5
|
+
export type ConfigurationErrorCategory = (typeof CONFIGURATION_ERROR_CATEGORIES)[number];
|
|
6
|
+
export type ConfigurationContextValue = boolean | number | string;
|
|
7
|
+
export type ConfigurationEvaluationContext = Readonly<Record<string, ConfigurationContextValue>>;
|
|
8
|
+
export interface ConfigurationEvaluationDetails<Value extends ConfigurationValue> {
|
|
9
|
+
errorCategory?: ConfigurationErrorCategory;
|
|
10
|
+
flagKey: string;
|
|
11
|
+
providerName: string;
|
|
12
|
+
providerVersion?: string;
|
|
13
|
+
reason: ConfigurationEvaluationReason;
|
|
14
|
+
value: Value;
|
|
15
|
+
variant?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ConfigurationEvaluationTelemetry {
|
|
18
|
+
cacheState: 'fresh' | 'stale' | 'miss';
|
|
19
|
+
errorCategory?: ConfigurationErrorCategory;
|
|
20
|
+
key: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
reason: ConfigurationEvaluationReason;
|
|
23
|
+
}
|
|
24
|
+
export interface ConfigurationSnapshot {
|
|
25
|
+
loadedAt: number;
|
|
26
|
+
values: Readonly<Record<string, ConfigurationValue>>;
|
|
27
|
+
variants?: Readonly<Record<string, string>>;
|
|
28
|
+
version: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ConfigurationSnapshotLoader {
|
|
31
|
+
load(signal: AbortSignal): Promise<ConfigurationSnapshot>;
|
|
32
|
+
}
|
|
33
|
+
export interface LocalConfigurationProviderOptions {
|
|
34
|
+
initialSnapshot?: ConfigurationSnapshot;
|
|
35
|
+
loader?: ConfigurationSnapshotLoader;
|
|
36
|
+
now?: () => number;
|
|
37
|
+
onEvaluation?: (event: ConfigurationEvaluationTelemetry) => void;
|
|
38
|
+
providerName?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare class LocalConfigurationProvider {
|
|
41
|
+
readonly metadata: Readonly<{
|
|
42
|
+
name: string;
|
|
43
|
+
}>;
|
|
44
|
+
private readonly declarations;
|
|
45
|
+
private readonly loader?;
|
|
46
|
+
private readonly now;
|
|
47
|
+
private readonly onEvaluation?;
|
|
48
|
+
private readonly providerName;
|
|
49
|
+
private snapshot?;
|
|
50
|
+
constructor(declarationsInput: readonly ConfigurationDeclaration[], options: LocalConfigurationProviderOptions);
|
|
51
|
+
private emit;
|
|
52
|
+
private fallback;
|
|
53
|
+
private refresh;
|
|
54
|
+
resolveEvaluation<Value extends ConfigurationValue>(flagKey: string, defaultValue: Value, context?: ConfigurationEvaluationContext, callerSignal?: AbortSignal): Promise<ConfigurationEvaluationDetails<Value>>;
|
|
55
|
+
resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context?: ConfigurationEvaluationContext, signal?: AbortSignal): Promise<ConfigurationEvaluationDetails<boolean>>;
|
|
56
|
+
resolveNumberEvaluation(flagKey: string, defaultValue: number, context?: ConfigurationEvaluationContext, signal?: AbortSignal): Promise<ConfigurationEvaluationDetails<number>>;
|
|
57
|
+
resolveStringEvaluation(flagKey: string, defaultValue: string, context?: ConfigurationEvaluationContext, signal?: AbortSignal): Promise<ConfigurationEvaluationDetails<string>>;
|
|
58
|
+
resolveObjectEvaluation<Value extends ConfigurationValue>(flagKey: string, defaultValue: Value, context?: ConfigurationEvaluationContext, signal?: AbortSignal): Promise<ConfigurationEvaluationDetails<Value>>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { configurationValueMatchesDeclaration, defineConfiguration, } from './contract.js';
|
|
3
|
+
export const CONFIGURATION_EVALUATION_REASONS = [
|
|
4
|
+
'STATIC',
|
|
5
|
+
'CACHED',
|
|
6
|
+
'STALE',
|
|
7
|
+
'DEFAULT',
|
|
8
|
+
'ERROR',
|
|
9
|
+
];
|
|
10
|
+
export const CONFIGURATION_ERROR_CATEGORIES = [
|
|
11
|
+
'FLAG_NOT_FOUND',
|
|
12
|
+
'TYPE_MISMATCH',
|
|
13
|
+
'PROVIDER_UNAVAILABLE',
|
|
14
|
+
'TIMEOUT',
|
|
15
|
+
'CANCELLED',
|
|
16
|
+
'INVALID_CONTEXT',
|
|
17
|
+
];
|
|
18
|
+
const SAFE_CONTEXT_KEY = /^[A-Za-z][A-Za-z0-9._-]{0,63}$/;
|
|
19
|
+
const MAX_CONTEXT_ENTRIES = 16;
|
|
20
|
+
const MAX_CONTEXT_STRING_LENGTH = 256;
|
|
21
|
+
const DEFAULT_PROVIDER_NAME = 'ebk-local';
|
|
22
|
+
const SAFE_PROVIDER_NAME = /^[A-Za-z][A-Za-z0-9._-]{0,63}$/;
|
|
23
|
+
function contextIsValid(context) {
|
|
24
|
+
const entries = Object.entries(context);
|
|
25
|
+
return (entries.length <= MAX_CONTEXT_ENTRIES &&
|
|
26
|
+
entries.every(([key, value]) => SAFE_CONTEXT_KEY.test(key) &&
|
|
27
|
+
(typeof value !== 'string' ||
|
|
28
|
+
value.length <= MAX_CONTEXT_STRING_LENGTH) &&
|
|
29
|
+
(typeof value !== 'number' || Number.isFinite(value))));
|
|
30
|
+
}
|
|
31
|
+
function timeoutSignal(timeoutMs, callerSignal) {
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
let didTimeOut = false;
|
|
34
|
+
const timer = setTimeout(() => {
|
|
35
|
+
didTimeOut = true;
|
|
36
|
+
controller.abort();
|
|
37
|
+
}, timeoutMs);
|
|
38
|
+
const cancel = () => controller.abort();
|
|
39
|
+
callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.addEventListener('abort', cancel, { once: true });
|
|
40
|
+
return {
|
|
41
|
+
dispose() {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.removeEventListener('abort', cancel);
|
|
44
|
+
},
|
|
45
|
+
signal: controller.signal,
|
|
46
|
+
timedOut: () => didTimeOut,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export class LocalConfigurationProvider {
|
|
50
|
+
constructor(declarationsInput, options) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const declarations = defineConfiguration(declarationsInput);
|
|
53
|
+
if (declarations.some((declaration) => !['local', 'appconfig'].includes(declaration.provider) ||
|
|
54
|
+
declaration.class === 'secret')) {
|
|
55
|
+
throw new Error('LocalConfigurationProvider accepts only local or AppConfig non-secret declarations.');
|
|
56
|
+
}
|
|
57
|
+
if (!options.loader && !options.initialSnapshot) {
|
|
58
|
+
throw new Error('LocalConfigurationProvider requires an initial snapshot or loader.');
|
|
59
|
+
}
|
|
60
|
+
const providerName = (_a = options.providerName) !== null && _a !== void 0 ? _a : DEFAULT_PROVIDER_NAME;
|
|
61
|
+
if (!SAFE_PROVIDER_NAME.test(providerName)) {
|
|
62
|
+
throw new Error('LocalConfigurationProvider providerName must be a bounded machine-safe identifier.');
|
|
63
|
+
}
|
|
64
|
+
this.declarations = new Map(declarations.map((declaration) => [declaration.key, declaration]));
|
|
65
|
+
this.loader = options.loader;
|
|
66
|
+
this.now = (_b = options.now) !== null && _b !== void 0 ? _b : Date.now;
|
|
67
|
+
this.onEvaluation = options.onEvaluation;
|
|
68
|
+
this.providerName = providerName;
|
|
69
|
+
this.metadata = { name: providerName };
|
|
70
|
+
this.snapshot = options.initialSnapshot;
|
|
71
|
+
}
|
|
72
|
+
emit(details, cacheState) {
|
|
73
|
+
var _a;
|
|
74
|
+
(_a = this.onEvaluation) === null || _a === void 0 ? void 0 : _a.call(this, Object.assign(Object.assign({ cacheState }, (details.errorCategory
|
|
75
|
+
? { errorCategory: details.errorCategory }
|
|
76
|
+
: {})), { key: details.flagKey, provider: this.providerName, reason: details.reason }));
|
|
77
|
+
}
|
|
78
|
+
fallback(declaration, flagKey, defaultValue, errorCategory, cacheState) {
|
|
79
|
+
const fallback = (declaration === null || declaration === void 0 ? void 0 : declaration.safeFallback) !== undefined
|
|
80
|
+
? declaration.safeFallback
|
|
81
|
+
: defaultValue;
|
|
82
|
+
const details = {
|
|
83
|
+
errorCategory,
|
|
84
|
+
flagKey,
|
|
85
|
+
providerName: this.providerName,
|
|
86
|
+
reason: errorCategory === 'FLAG_NOT_FOUND' ? 'DEFAULT' : 'ERROR',
|
|
87
|
+
value: fallback,
|
|
88
|
+
};
|
|
89
|
+
this.emit(details, cacheState);
|
|
90
|
+
return details;
|
|
91
|
+
}
|
|
92
|
+
refresh(declaration, callerSignal) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
if (!this.loader) {
|
|
95
|
+
return this.snapshot
|
|
96
|
+
? { cancelled: false, snapshot: this.snapshot, timedOut: false }
|
|
97
|
+
: { cancelled: false, timedOut: false };
|
|
98
|
+
}
|
|
99
|
+
const boundedSignal = timeoutSignal(declaration.cache.timeoutMs, callerSignal);
|
|
100
|
+
try {
|
|
101
|
+
const snapshot = yield this.loader.load(boundedSignal.signal);
|
|
102
|
+
if (snapshot.version.trim().length === 0 ||
|
|
103
|
+
!Number.isFinite(snapshot.loadedAt) ||
|
|
104
|
+
snapshot.loadedAt > this.now()) {
|
|
105
|
+
return { cancelled: false, timedOut: false };
|
|
106
|
+
}
|
|
107
|
+
this.snapshot = snapshot;
|
|
108
|
+
return { cancelled: false, snapshot, timedOut: false };
|
|
109
|
+
}
|
|
110
|
+
catch (_a) {
|
|
111
|
+
return {
|
|
112
|
+
cancelled: (callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.aborted) === true,
|
|
113
|
+
timedOut: boundedSignal.timedOut(),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
boundedSignal.dispose();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
resolveEvaluation(flagKey_1, defaultValue_1) {
|
|
122
|
+
return __awaiter(this, arguments, void 0, function* (flagKey, defaultValue, context = {}, callerSignal) {
|
|
123
|
+
var _a;
|
|
124
|
+
const declaration = this.declarations.get(flagKey);
|
|
125
|
+
if (!declaration) {
|
|
126
|
+
return this.fallback(undefined, flagKey, defaultValue, 'FLAG_NOT_FOUND', 'miss');
|
|
127
|
+
}
|
|
128
|
+
if (!contextIsValid(context) ||
|
|
129
|
+
(callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.aborted) ||
|
|
130
|
+
!configurationValueMatchesDeclaration(defaultValue, declaration)) {
|
|
131
|
+
return this.fallback(declaration, flagKey, defaultValue, (callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.aborted)
|
|
132
|
+
? 'CANCELLED'
|
|
133
|
+
: !contextIsValid(context)
|
|
134
|
+
? 'INVALID_CONTEXT'
|
|
135
|
+
: 'TYPE_MISMATCH', this.snapshot ? 'stale' : 'miss');
|
|
136
|
+
}
|
|
137
|
+
const age = this.snapshot
|
|
138
|
+
? Math.max(0, this.now() - this.snapshot.loadedAt)
|
|
139
|
+
: Number.POSITIVE_INFINITY;
|
|
140
|
+
let snapshot = this.snapshot;
|
|
141
|
+
let refreshFailed = false;
|
|
142
|
+
let refreshCancelled = false;
|
|
143
|
+
let refreshTimedOut = false;
|
|
144
|
+
if (!snapshot || age >= declaration.cache.refreshAfterMs) {
|
|
145
|
+
const refreshed = yield this.refresh(declaration, callerSignal);
|
|
146
|
+
if (refreshed.snapshot) {
|
|
147
|
+
snapshot = refreshed.snapshot;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
refreshFailed = true;
|
|
151
|
+
refreshCancelled = refreshed.cancelled;
|
|
152
|
+
refreshTimedOut = refreshed.timedOut;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!snapshot) {
|
|
156
|
+
return this.fallback(declaration, flagKey, defaultValue, refreshCancelled
|
|
157
|
+
? 'CANCELLED'
|
|
158
|
+
: refreshTimedOut
|
|
159
|
+
? 'TIMEOUT'
|
|
160
|
+
: 'PROVIDER_UNAVAILABLE', 'miss');
|
|
161
|
+
}
|
|
162
|
+
const snapshotAge = Math.max(0, this.now() - snapshot.loadedAt);
|
|
163
|
+
if (snapshotAge > declaration.cache.maxStaleMs) {
|
|
164
|
+
return this.fallback(declaration, flagKey, defaultValue, refreshCancelled
|
|
165
|
+
? 'CANCELLED'
|
|
166
|
+
: refreshTimedOut
|
|
167
|
+
? 'TIMEOUT'
|
|
168
|
+
: 'PROVIDER_UNAVAILABLE', 'stale');
|
|
169
|
+
}
|
|
170
|
+
const value = snapshot.values[flagKey];
|
|
171
|
+
if (value === undefined ||
|
|
172
|
+
!configurationValueMatchesDeclaration(value, declaration)) {
|
|
173
|
+
return this.fallback(declaration, flagKey, defaultValue, value === undefined ? 'FLAG_NOT_FOUND' : 'TYPE_MISMATCH', snapshotAge >= declaration.cache.refreshAfterMs ? 'stale' : 'fresh');
|
|
174
|
+
}
|
|
175
|
+
const cacheState = snapshotAge >= declaration.cache.refreshAfterMs ? 'stale' : 'fresh';
|
|
176
|
+
const details = Object.assign(Object.assign(Object.assign({}, (refreshFailed
|
|
177
|
+
? { errorCategory: 'PROVIDER_UNAVAILABLE' }
|
|
178
|
+
: {})), { flagKey, providerName: this.providerName, providerVersion: snapshot.version, reason: refreshFailed ? 'STALE' : this.loader ? 'CACHED' : 'STATIC', value: value }), (((_a = snapshot.variants) === null || _a === void 0 ? void 0 : _a[flagKey])
|
|
179
|
+
? { variant: snapshot.variants[flagKey] }
|
|
180
|
+
: {}));
|
|
181
|
+
this.emit(details, cacheState);
|
|
182
|
+
return details;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
resolveBooleanEvaluation(flagKey, defaultValue, context, signal) {
|
|
186
|
+
return this.resolveEvaluation(flagKey, defaultValue, context, signal);
|
|
187
|
+
}
|
|
188
|
+
resolveNumberEvaluation(flagKey, defaultValue, context, signal) {
|
|
189
|
+
return this.resolveEvaluation(flagKey, defaultValue, context, signal);
|
|
190
|
+
}
|
|
191
|
+
resolveStringEvaluation(flagKey, defaultValue, context, signal) {
|
|
192
|
+
return this.resolveEvaluation(flagKey, defaultValue, context, signal);
|
|
193
|
+
}
|
|
194
|
+
resolveObjectEvaluation(flagKey, defaultValue, context, signal) {
|
|
195
|
+
return this.resolveEvaluation(flagKey, defaultValue, context, signal);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../../packages/runtime/src/configuration/provider.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,oCAAoC,EACpC,mBAAmB,GAGpB,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,SAAS;IACT,OAAO;CACC,CAAC;AACX,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,gBAAgB;IAChB,eAAe;IACf,sBAAsB;IACtB,SAAS;IACT,WAAW;IACX,iBAAiB;CACT,CAAC;AAkDX,MAAM,gBAAgB,GAAG,gCAAgC,CAAC;AAC1D,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAC1C,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAE5D,SAAS,cAAc,CAAC,OAAuC;IAC7D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,CACL,OAAO,CAAC,MAAM,IAAI,mBAAmB;QACrC,OAAO,CAAC,KAAK,CACX,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;YAC1B,CAAC,OAAO,KAAK,KAAK,QAAQ;gBACxB,KAAK,CAAC,MAAM,IAAI,yBAAyB,CAAC;YAC5C,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACxD,CACF,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,SAAiB,EACjB,YAA0B;IAE1B,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,IAAI,UAAU,GAAG,KAAK,CAAC;IACv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YAC/B,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;IAED,wBAAwB,CACtB,OAAe,EACf,YAAqB,EACrB,OAAwC,EACxC,MAAoB;QAEpB,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,uBAAuB,CACrB,OAAe,EACf,YAAoB,EACpB,OAAwC,EACxC,MAAoB;QAEpB,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,uBAAuB,CACrB,OAAe,EACf,YAAoB,EACpB,OAAwC,EACxC,MAAoB;QAEpB,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,uBAAuB,CACrB,OAAe,EACf,YAAmB,EACnB,OAAwC,EACxC,MAAoB;QAEpB,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// @generated from packages/runtime/src/configuration/rollout-evaluator.ts by tools/runtime/generate-shared-authorities.mjs
|
|
2
|
+
// Do not edit this artifact directly.
|
|
3
|
+
'use strict';
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
exports.evaluatePercentageRolloutValue = evaluatePercentageRolloutValue;
|
|
6
|
+
exports.evaluatePseudonymousPercentageRolloutValue =
|
|
7
|
+
evaluatePseudonymousPercentageRolloutValue;
|
|
8
|
+
const node_crypto_1 = require('node:crypto');
|
|
9
|
+
const safe_reference_js_1 = require('../safe-reference.cjs');
|
|
10
|
+
const PSEUDONYMOUS_STABLE_KEY = /^psk_v1_[a-f0-9]{64}$/;
|
|
11
|
+
const OPERATIONAL_STABLE_KEY = /^opk_v1_[a-f0-9]{64}$/;
|
|
12
|
+
/**
|
|
13
|
+
* Sole authored implementation of deterministic percentage assignment.
|
|
14
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
15
|
+
*/
|
|
16
|
+
function evaluatePercentageRolloutValue(input, keyContract) {
|
|
17
|
+
const acceptsStableKey =
|
|
18
|
+
keyContract === 'pseudonymous'
|
|
19
|
+
? PSEUDONYMOUS_STABLE_KEY.test(input?.stableKey)
|
|
20
|
+
: keyContract === 'pseudonymous-or-operational' &&
|
|
21
|
+
(PSEUDONYMOUS_STABLE_KEY.test(input?.stableKey) ||
|
|
22
|
+
OPERATIONAL_STABLE_KEY.test(input?.stableKey));
|
|
23
|
+
if (
|
|
24
|
+
(keyContract !== 'pseudonymous' &&
|
|
25
|
+
keyContract !== 'pseudonymous-or-operational') ||
|
|
26
|
+
typeof input?.enabled !== 'boolean' ||
|
|
27
|
+
!Number.isInteger(input?.percentage) ||
|
|
28
|
+
input.percentage < 0 ||
|
|
29
|
+
input.percentage > 100 ||
|
|
30
|
+
!(0, safe_reference_js_1.isBoundedSafeReference)(input?.rolloutId) ||
|
|
31
|
+
!(0, safe_reference_js_1.isBoundedSafeReference)(input?.version) ||
|
|
32
|
+
!acceptsStableKey
|
|
33
|
+
) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
'Percentage rollout requires bounded configuration identity and a derived stable key.',
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const hash = (0, node_crypto_1.createHash)('sha256')
|
|
39
|
+
.update(
|
|
40
|
+
`${input.rolloutId}\u0000${input.version}\u0000${input.stableKey}`,
|
|
41
|
+
'utf8',
|
|
42
|
+
)
|
|
43
|
+
.digest();
|
|
44
|
+
const bucket = hash.readUInt32BE(0) % 10_000;
|
|
45
|
+
return {
|
|
46
|
+
assigned: input.enabled && bucket < input.percentage * 100,
|
|
47
|
+
bucket,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function evaluatePseudonymousPercentageRolloutValue(input) {
|
|
51
|
+
return evaluatePercentageRolloutValue(input, 'pseudonymous');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Object.freeze(module.exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @generated from packages/runtime/src/configuration/rollout-evaluator.ts by tools/runtime/generate-shared-authorities.mjs
|
|
2
|
+
// Do not edit this artifact directly.
|
|
3
|
+
export interface PercentageRolloutValueInput {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
percentage: number;
|
|
6
|
+
rolloutId: string;
|
|
7
|
+
stableKey: string;
|
|
8
|
+
version: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PercentageRolloutValueEvaluation {
|
|
11
|
+
assigned: boolean;
|
|
12
|
+
bucket: number;
|
|
13
|
+
}
|
|
14
|
+
export type PercentageRolloutKeyContract =
|
|
15
|
+
'pseudonymous' | 'pseudonymous-or-operational';
|
|
16
|
+
/**
|
|
17
|
+
* Sole authored implementation of deterministic percentage assignment.
|
|
18
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function evaluatePercentageRolloutValue(
|
|
21
|
+
input: PercentageRolloutValueInput,
|
|
22
|
+
keyContract: PercentageRolloutKeyContract,
|
|
23
|
+
): PercentageRolloutValueEvaluation;
|
|
24
|
+
export declare function evaluatePseudonymousPercentageRolloutValue(
|
|
25
|
+
input: PercentageRolloutValueInput,
|
|
26
|
+
): PercentageRolloutValueEvaluation;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface PercentageRolloutValueInput {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
percentage: number;
|
|
4
|
+
rolloutId: string;
|
|
5
|
+
stableKey: string;
|
|
6
|
+
version: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PercentageRolloutValueEvaluation {
|
|
9
|
+
assigned: boolean;
|
|
10
|
+
bucket: number;
|
|
11
|
+
}
|
|
12
|
+
export type PercentageRolloutKeyContract = 'pseudonymous' | 'pseudonymous-or-operational';
|
|
13
|
+
/**
|
|
14
|
+
* Sole authored implementation of deterministic percentage assignment.
|
|
15
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function evaluatePercentageRolloutValue(input: PercentageRolloutValueInput, keyContract: PercentageRolloutKeyContract): PercentageRolloutValueEvaluation;
|
|
18
|
+
export declare function evaluatePseudonymousPercentageRolloutValue(input: PercentageRolloutValueInput): PercentageRolloutValueEvaluation;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { isBoundedSafeReference } from '../safe-reference.js';
|
|
3
|
+
const PSEUDONYMOUS_STABLE_KEY = /^psk_v1_[a-f0-9]{64}$/;
|
|
4
|
+
const OPERATIONAL_STABLE_KEY = /^opk_v1_[a-f0-9]{64}$/;
|
|
5
|
+
/**
|
|
6
|
+
* Sole authored implementation of deterministic percentage assignment.
|
|
7
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
8
|
+
*/
|
|
9
|
+
export function evaluatePercentageRolloutValue(input, keyContract) {
|
|
10
|
+
const acceptsStableKey = keyContract === 'pseudonymous'
|
|
11
|
+
? PSEUDONYMOUS_STABLE_KEY.test(input === null || input === void 0 ? void 0 : input.stableKey)
|
|
12
|
+
: keyContract === 'pseudonymous-or-operational' &&
|
|
13
|
+
(PSEUDONYMOUS_STABLE_KEY.test(input === null || input === void 0 ? void 0 : input.stableKey) ||
|
|
14
|
+
OPERATIONAL_STABLE_KEY.test(input === null || input === void 0 ? void 0 : input.stableKey));
|
|
15
|
+
if ((keyContract !== 'pseudonymous' &&
|
|
16
|
+
keyContract !== 'pseudonymous-or-operational') ||
|
|
17
|
+
typeof (input === null || input === void 0 ? void 0 : input.enabled) !== 'boolean' ||
|
|
18
|
+
!Number.isInteger(input === null || input === void 0 ? void 0 : input.percentage) ||
|
|
19
|
+
input.percentage < 0 ||
|
|
20
|
+
input.percentage > 100 ||
|
|
21
|
+
!isBoundedSafeReference(input === null || input === void 0 ? void 0 : input.rolloutId) ||
|
|
22
|
+
!isBoundedSafeReference(input === null || input === void 0 ? void 0 : input.version) ||
|
|
23
|
+
!acceptsStableKey) {
|
|
24
|
+
throw new Error('Percentage rollout requires bounded configuration identity and a derived stable key.');
|
|
25
|
+
}
|
|
26
|
+
const hash = createHash('sha256')
|
|
27
|
+
.update(`${input.rolloutId}\u0000${input.version}\u0000${input.stableKey}`, 'utf8')
|
|
28
|
+
.digest();
|
|
29
|
+
const bucket = hash.readUInt32BE(0) % 10000;
|
|
30
|
+
return {
|
|
31
|
+
assigned: input.enabled && bucket < input.percentage * 100,
|
|
32
|
+
bucket,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function evaluatePseudonymousPercentageRolloutValue(input) {
|
|
36
|
+
return evaluatePercentageRolloutValue(input, 'pseudonymous');
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=rollout-evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollout-evaluator.js","sourceRoot":"","sources":["../../../../../packages/runtime/src/configuration/rollout-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAkB9D,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AACxD,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAkC,EAClC,WAAyC;IAEzC,MAAM,gBAAgB,GACpB,WAAW,KAAK,cAAc;QAC5B,CAAC,CAAC,uBAAuB,CAAC,IAAI,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;QAChD,CAAC,CAAC,WAAW,KAAK,6BAA6B;YAC7C,CAAC,uBAAuB,CAAC,IAAI,CAAC,KAAK,aAAL,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ated from packages/runtime/src/configuration/rollout-key.ts by tools/runtime/generate-shared-authorities.mjs
|
|
2
|
+
// Do not edit this artifact directly.
|
|
3
|
+
'use strict';
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
exports.derivePseudonymousStableKeyValue = derivePseudonymousStableKeyValue;
|
|
6
|
+
const node_crypto_1 = require('node:crypto');
|
|
7
|
+
const safe_reference_js_1 = require('../safe-reference.cjs');
|
|
8
|
+
/**
|
|
9
|
+
* Sole authored implementation of pseudonymous rollout-key derivation.
|
|
10
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
11
|
+
*/
|
|
12
|
+
function derivePseudonymousStableKeyValue(input) {
|
|
13
|
+
const supportedSecret =
|
|
14
|
+
typeof input?.secret === 'string' || input?.secret instanceof Uint8Array;
|
|
15
|
+
const secret =
|
|
16
|
+
typeof input?.secret === 'string'
|
|
17
|
+
? Buffer.from(input.secret, 'utf8')
|
|
18
|
+
: supportedSecret
|
|
19
|
+
? Buffer.from(input.secret)
|
|
20
|
+
: Buffer.alloc(0);
|
|
21
|
+
if (
|
|
22
|
+
!(0, safe_reference_js_1.isBoundedSafeReference)(input?.namespace) ||
|
|
23
|
+
typeof input?.subjectId !== 'string' ||
|
|
24
|
+
input.subjectId.length === 0 ||
|
|
25
|
+
input.subjectId.length > 512 ||
|
|
26
|
+
!supportedSecret ||
|
|
27
|
+
secret.byteLength < 32
|
|
28
|
+
) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
'Pseudonymous stable-key derivation requires a bounded namespace and subject plus a deployment-held secret of at least 32 bytes.',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return `psk_v1_${(0, node_crypto_1.createHmac)('sha256', secret)
|
|
34
|
+
.update(`${input.namespace}\u0000${input.subjectId}`, 'utf8')
|
|
35
|
+
.digest('hex')}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Object.freeze(module.exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @generated from packages/runtime/src/configuration/rollout-key.ts by tools/runtime/generate-shared-authorities.mjs
|
|
2
|
+
// Do not edit this artifact directly.
|
|
3
|
+
export interface PseudonymousStableKeyValueInput {
|
|
4
|
+
namespace: string;
|
|
5
|
+
secret: string | Uint8Array;
|
|
6
|
+
subjectId: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sole authored implementation of pseudonymous rollout-key derivation.
|
|
10
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function derivePseudonymousStableKeyValue(
|
|
13
|
+
input: PseudonymousStableKeyValueInput,
|
|
14
|
+
): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PseudonymousStableKeyValueInput {
|
|
2
|
+
namespace: string;
|
|
3
|
+
secret: string | Uint8Array;
|
|
4
|
+
subjectId: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Sole authored implementation of pseudonymous rollout-key derivation.
|
|
8
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function derivePseudonymousStableKeyValue(input: PseudonymousStableKeyValueInput): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createHmac } from 'node:crypto';
|
|
2
|
+
import { isBoundedSafeReference } from '../safe-reference.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sole authored implementation of pseudonymous rollout-key derivation.
|
|
5
|
+
* Runtime ESM consumes this source; the CommonJS peer is generated from it.
|
|
6
|
+
*/
|
|
7
|
+
export function derivePseudonymousStableKeyValue(input) {
|
|
8
|
+
const supportedSecret = typeof (input === null || input === void 0 ? void 0 : input.secret) === 'string' || (input === null || input === void 0 ? void 0 : input.secret) instanceof Uint8Array;
|
|
9
|
+
const secret = typeof (input === null || input === void 0 ? void 0 : input.secret) === 'string'
|
|
10
|
+
? Buffer.from(input.secret, 'utf8')
|
|
11
|
+
: supportedSecret
|
|
12
|
+
? Buffer.from(input.secret)
|
|
13
|
+
: Buffer.alloc(0);
|
|
14
|
+
if (!isBoundedSafeReference(input === null || input === void 0 ? void 0 : input.namespace) ||
|
|
15
|
+
typeof (input === null || input === void 0 ? void 0 : input.subjectId) !== 'string' ||
|
|
16
|
+
input.subjectId.length === 0 ||
|
|
17
|
+
input.subjectId.length > 512 ||
|
|
18
|
+
!supportedSecret ||
|
|
19
|
+
secret.byteLength < 32) {
|
|
20
|
+
throw new Error('Pseudonymous stable-key derivation requires a bounded namespace and subject plus a deployment-held secret of at least 32 bytes.');
|
|
21
|
+
}
|
|
22
|
+
return `psk_v1_${createHmac('sha256', secret)
|
|
23
|
+
.update(`${input.namespace}\u0000${input.subjectId}`, 'utf8')
|
|
24
|
+
.digest('hex')}`;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=rollout-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollout-key.js","sourceRoot":"","sources":["../../../../../packages/runtime/src/configuration/rollout-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAQ9D;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC9C,KAAsC;IAEtC,MAAM,eAAe,GACnB,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA,KAAK,QAAQ,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,aAAY,UAAU,CAAC;IAC3E,MAAM,MAAM,GACV,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA,KAAK,QAAQ;QAC/B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;QACnC,CAAC,CAAC,eAAe;YACf,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxB,IACE,CAAC,sBAAsB,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;QACzC,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAA,KAAK,QAAQ;QACpC,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAC5B,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,GAAG;QAC5B,CAAC,eAAe;QAChB,MAAM,CAAC,UAAU,GAAG,EAAE,EACtB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,iIAAiI,CAClI,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC;SAC1C,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,SAAS,KAAK,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
declare const pseudonymousStableKeyBrand: unique symbol;
|
|
2
|
+
declare const operationalRolloutStableKeyBrand: unique symbol;
|
|
3
|
+
export type PseudonymousStableKey = string & {
|
|
4
|
+
readonly [pseudonymousStableKeyBrand]: true;
|
|
5
|
+
};
|
|
6
|
+
export type OperationalRolloutStableKey = string & {
|
|
7
|
+
readonly [operationalRolloutStableKeyBrand]: true;
|
|
8
|
+
};
|
|
9
|
+
export type RolloutStableKey = OperationalRolloutStableKey | PseudonymousStableKey;
|
|
10
|
+
export interface PseudonymousStableKeyDerivationInput {
|
|
11
|
+
namespace: string;
|
|
12
|
+
secret: string | Uint8Array;
|
|
13
|
+
subjectId: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OperationalRolloutStableKeyDerivationInput {
|
|
16
|
+
kind: 'job' | 'lambda' | 'next-server' | 'service';
|
|
17
|
+
slice: string;
|
|
18
|
+
workload: string;
|
|
19
|
+
}
|
|
20
|
+
export interface PercentageRolloutInput {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
percentage: number;
|
|
23
|
+
rolloutId: string;
|
|
24
|
+
stableKey: RolloutStableKey;
|
|
25
|
+
version: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PercentageRolloutEvaluation {
|
|
28
|
+
assigned: boolean;
|
|
29
|
+
bucket: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Establishes the only supported raw-subject boundary for rollout targeting.
|
|
33
|
+
* The namespace separates products/uses, while the deployment-held secret
|
|
34
|
+
* prevents the resulting stable key from revealing or enumerating subjects.
|
|
35
|
+
*/
|
|
36
|
+
export declare const derivePseudonymousStableKey: (input: PseudonymousStableKeyDerivationInput) => PseudonymousStableKey;
|
|
37
|
+
/**
|
|
38
|
+
* Derives a stable key only for a declared operational workload identity.
|
|
39
|
+
* This explicit boundary is intentionally separate from authenticated-subject
|
|
40
|
+
* HMAC derivation. Generator-compatible names describe deployment topology;
|
|
41
|
+
* their vocabulary is not used to infer whether they identify a person.
|
|
42
|
+
*/
|
|
43
|
+
export declare function deriveOperationalRolloutStableKey(input: OperationalRolloutStableKeyDerivationInput): OperationalRolloutStableKey;
|
|
44
|
+
/**
|
|
45
|
+
* Evaluates one derived subject or operational identity against a stable
|
|
46
|
+
* 10,000-bucket rollout.
|
|
47
|
+
*
|
|
48
|
+
* The assignment is independent of process, host type, and evaluation order.
|
|
49
|
+
* The branded stableKey can only be produced at an explicit subject or
|
|
50
|
+
* non-personal workload derivation boundary.
|
|
51
|
+
*/
|
|
52
|
+
export declare function evaluatePercentageRollout(input: PercentageRolloutInput): PercentageRolloutEvaluation;
|
|
53
|
+
/**
|
|
54
|
+
* Uses the shared bucket evaluator while retaining the stricter
|
|
55
|
+
* authenticated-subject key boundary required by release controllers.
|
|
56
|
+
*/
|
|
57
|
+
export declare const evaluatePseudonymousPercentageRollout: (input: Omit<PercentageRolloutInput, "stableKey"> & {
|
|
58
|
+
stableKey: PseudonymousStableKey;
|
|
59
|
+
}) => PercentageRolloutEvaluation;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { evaluatePercentageRolloutValue, evaluatePseudonymousPercentageRolloutValue, } from './rollout-evaluator.js';
|
|
3
|
+
import { derivePseudonymousStableKeyValue } from './rollout-key.js';
|
|
4
|
+
const OPERATIONAL_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
5
|
+
/**
|
|
6
|
+
* Establishes the only supported raw-subject boundary for rollout targeting.
|
|
7
|
+
* The namespace separates products/uses, while the deployment-held secret
|
|
8
|
+
* prevents the resulting stable key from revealing or enumerating subjects.
|
|
9
|
+
*/
|
|
10
|
+
export const derivePseudonymousStableKey = derivePseudonymousStableKeyValue;
|
|
11
|
+
/**
|
|
12
|
+
* Derives a stable key only for a declared operational workload identity.
|
|
13
|
+
* This explicit boundary is intentionally separate from authenticated-subject
|
|
14
|
+
* HMAC derivation. Generator-compatible names describe deployment topology;
|
|
15
|
+
* their vocabulary is not used to infer whether they identify a person.
|
|
16
|
+
*/
|
|
17
|
+
export function deriveOperationalRolloutStableKey(input) {
|
|
18
|
+
if (!OPERATIONAL_NAME.test(input.slice) ||
|
|
19
|
+
!OPERATIONAL_NAME.test(input.workload)) {
|
|
20
|
+
throw new Error('Operational rollout identity requires declared generator-compatible Slice, host-kind, and workload names.');
|
|
21
|
+
}
|
|
22
|
+
return `opk_v1_${createHash('sha256')
|
|
23
|
+
.update(`ebk-operational-rollout-v1\u0000${input.slice}\u0000${input.kind}\u0000${input.workload}`, 'utf8')
|
|
24
|
+
.digest('hex')}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Evaluates one derived subject or operational identity against a stable
|
|
28
|
+
* 10,000-bucket rollout.
|
|
29
|
+
*
|
|
30
|
+
* The assignment is independent of process, host type, and evaluation order.
|
|
31
|
+
* The branded stableKey can only be produced at an explicit subject or
|
|
32
|
+
* non-personal workload derivation boundary.
|
|
33
|
+
*/
|
|
34
|
+
export function evaluatePercentageRollout(input) {
|
|
35
|
+
return evaluatePercentageRolloutValue(input, 'pseudonymous-or-operational');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Uses the shared bucket evaluator while retaining the stricter
|
|
39
|
+
* authenticated-subject key boundary required by release controllers.
|
|
40
|
+
*/
|
|
41
|
+
export const evaluatePseudonymousPercentageRollout = evaluatePseudonymousPercentageRolloutValue;
|
|
42
|
+
//# sourceMappingURL=rollout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollout.js","sourceRoot":"","sources":["../../../../../packages/runtime/src/configuration/rollout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,GAC3C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AAyCpE,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,gCAEjB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAC/C,KAAiD;IAEjD,IACE,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACnC,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EACtC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC;SAClC,MAAM,CACL,mCAAmC,KAAK,CAAC,KAAK,SAAS,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,QAAQ,EAAE,EAC1F,MAAM,CACP;SACA,MAAM,CAAC,KAAK,CAAC,EAAiC,CAAC;AACpD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAA6B;IAE7B,OAAO,8BAA8B,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAChD,0CAIgC,CAAC"}
|