@cloud-copilot/iam-simulate
Version:
Simulate evaluation of AWS IAM policies
46 lines • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextKeyImpl = exports.RequestContextImpl = void 0;
class RequestContextImpl {
context = new Map();
constructor(values) {
for (const key in values) {
this.context.set(key.toLowerCase(), new ContextKeyImpl(key, values[key]));
}
}
contextKeyExists(name) {
return this.context.has(name.toLowerCase());
}
contextKeyValue(name) {
return this.context.get(name.toLowerCase());
}
}
exports.RequestContextImpl = RequestContextImpl;
class ContextKeyImpl {
name;
_val;
constructor(name, _val) {
this.name = name;
this._val = _val;
}
isStringValue() {
return typeof this._val === 'string';
}
isArrayValue() {
return Array.isArray(this._val);
}
get values() {
if (Array.isArray(this._val)) {
return this._val;
}
throw new Error(`ContextKey ${this.name} is not an array`);
}
get value() {
if (typeof this._val === 'string') {
return this._val;
}
throw new Error(`ContextKey ${this.name} is not a string`);
}
}
exports.ContextKeyImpl = ContextKeyImpl;
//# sourceMappingURL=requestContext.js.map