@cloud-copilot/iam-simulate
Version:
Simulate evaluation of AWS IAM policies
39 lines • 1.06 kB
JavaScript
export class RequestContextImpl {
constructor(values) {
this.context = new Map();
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());
}
}
export class ContextKeyImpl {
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`);
}
}
//# sourceMappingURL=requestContext.js.map