agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
45 lines • 2.19 kB
JavaScript
;
/**
* strategies/doorError — a sign-in door's construction refusal, re-raised as a
* boot refusal naming the ENV key. The door names the option it refused
* (`SignInDoorConfigError.option`); this maps it — never a regex over text.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.addressRefusalLimits = exports.doorRefusal = void 0;
const errors_js_1 = require("../../../hosting/signin/errors.js");
const config_js_1 = require("./config.js");
const ENV_FOR_OPTION = {
publicUrl: 'IDENTITY_PUBLIC_URL',
hours: 'IDENTITY_SIGN_IN_HOURS',
idleMinutes: 'IDENTITY_SIGN_IN_IDLE_MINUTES',
max: 'IDENTITY_SIGN_IN_MAX',
perAccount: 'IDENTITY_SIGN_IN_MAX',
trustedProxies: 'IDENTITY_TRUSTED_PROXIES',
};
/** Re-raise a door/store construction refusal as an {@link IdentityConfigError}. */
function doorRefusal(strategy, err) {
if (err instanceof config_js_1.IdentityConfigError)
return err;
const option = err instanceof errors_js_1.SignInDoorConfigError || err instanceof errors_js_1.MemorySignInsConfigError
? err.option
: undefined;
const text = err instanceof Error ? err.message.replace(/^\[(hosting|identity)\] /, '') : String(err);
return new config_js_1.IdentityConfigError(`${strategy} cannot start: ${text}`, option === undefined ? undefined : ENV_FOR_OPTION[option]);
}
exports.doorRefusal = doorRefusal;
/**
* `IDENTITY_SIGN_IN_ADDRESS_REFUSE_AFTER` as the door's `limits` fragment —
* absent when unset (the default: an address is only delayed), refused at boot
* when 0 (a refusal after no failures would refuse everybody).
*/
function addressRefusalLimits(value) {
if (value === undefined)
return undefined;
if (value < 1) {
throw new config_js_1.IdentityConfigError('IDENTITY_SIGN_IN_ADDRESS_REFUSE_AFTER is the number of failed sign-ins from one address ' +
'after which it is refused, at least 1. Leave it unset to only delay (the default).', 'IDENTITY_SIGN_IN_ADDRESS_REFUSE_AFTER');
}
return { refuseAddressAfter: value };
}
exports.addressRefusalLimits = addressRefusalLimits;
//# sourceMappingURL=doorError.js.map