everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
46 lines (45 loc) • 1.47 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
//#region src/services/hosting/secrets.ts
const RESERVED_SECRET_NAMES = /* @__PURE__ */ new Set([
"PORT",
"API_DATABASE_URL",
"AUTH_DATABASE_URL"
]);
const RESERVED_SECRET_PREFIX = "BOS_";
const SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*$/;
function isReservedSecretName(name) {
return RESERVED_SECRET_NAMES.has(name) || name.startsWith("BOS_");
}
function isValidSecretName(name) {
return SECRET_NAME_PATTERN.test(name) && !isReservedSecretName(name);
}
/** The runtime identity a descriptor carries in its `identityEnv`. */
function descriptorRuntime(descriptor) {
return {
account: descriptor.identityEnv.BOS_ACCOUNT,
gateway: descriptor.identityEnv.BOS_GATEWAY
};
}
/**
* Merge resolved stored secrets into a descriptor's `identityEnv`. The
* descriptor's own keys always win — stored values can never shadow the
* platform-composed identity.
*/
function withSecrets(descriptor, stored) {
return {
...descriptor,
identityEnv: {
...stored,
...descriptor.identityEnv
}
};
}
//#endregion
exports.RESERVED_SECRET_NAMES = RESERVED_SECRET_NAMES;
exports.RESERVED_SECRET_PREFIX = RESERVED_SECRET_PREFIX;
exports.SECRET_NAME_PATTERN = SECRET_NAME_PATTERN;
exports.descriptorRuntime = descriptorRuntime;
exports.isReservedSecretName = isReservedSecretName;
exports.isValidSecretName = isValidSecretName;
exports.withSecrets = withSecrets;
//# sourceMappingURL=secrets.cjs.map