diff --git a/README.md b/README.md index c9fbd0d..ae09977 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # iam-policies -> [![NPM](https://img.shields.io/npm/v/iam-policies.svg)](https://www.npmjs.com/package/iam-policies) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Build Status](https://travis-ci.com/roggervalf/iam-policies.svg?branch=master)](https://travis-ci.com/github/roggervalf/iam-policies) [![NPM downloads](https://img.shields.io/npm/dm/iam-policies)](https://www.npmjs.com/package/iam-policies) [![Coverage Status](https://coveralls.io/repos/github/roggervalf/iam-policies/badge.svg?branch=master)](https://coveralls.io/github/roggervalf/iam-policies?branch=master) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![NPM](https://img.shields.io/npm/v/iam-policies.svg)](https://www.npmjs.com/package/iam-policies) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Build Status](https://travis-ci.com/roggervalf/iam-policies.svg?branch=master)](https://travis-ci.com/github/roggervalf/iam-policies) [![NPM downloads](https://img.shields.io/npm/dm/iam-policies)](https://www.npmjs.com/package/iam-policies) [![Coverage Status](https://coveralls.io/repos/github/roggervalf/iam-policies/badge.svg?branch=master)](https://coveralls.io/github/roggervalf/iam-policies?branch=master) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) ## About diff --git a/dist/main.d.ts b/dist/main.d.ts index 21bdb71..3509fa3 100644 --- a/dist/main.d.ts +++ b/dist/main.d.ts @@ -1,3 +1,51 @@ +/** + * Apply the context value in a string. + * + * @param {string} str Pattern string, containing context path. + * @param {object} context Object to get values from path. + * @returns {string} Returns a string with embedded context values. + * @example + * ```javascript + * const context = { + * user: { id: 456, bestFriends: [123, 532, 987] } + * }; + * applyContext('secrets:${user.id}:*', context) + * // => 'secrets:456:*' + * + * applyContext('secrets:${user.bestFriends}:*', context) + * // => 'secrets:{123,532,987}:*' + * + * applyContext('secrets:${company.address}:account', context) + * // => 'secrets:undefined:account' + * ``` + */ +declare function applyContext(str: string, context?: T): string; + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @since 3.1.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * const object = { 'a': [{ 'b': { 'c': 3 } }] } + * + * getValueFromPath(object, 'a[0].b.c') + * // => 3 + * + * getValueFromPath(object, ['a', '0', 'b', 'c']) + * // => 3 + * + * getValueFromPath(object, 'a.b.c', 'default') + * // => 'default' + */ +declare function getValueFromPath(object: U, path: Array | string, defaultValue?: unknown): any; + declare type EffectBlock = 'allow' | 'deny'; declare type Patterns = string[] | string; interface PrincipalMap { @@ -27,16 +75,7 @@ interface OptionalResourceBlock { interface OptionalNotResourceBlock { notResource?: Patterns; } -declare type ConditionKey = string | number | boolean; -interface Context { - [key: string]: ConditionKey | Context | string[] | number[]; -} -interface ConditionMap { - [key: string]: ConditionKey[] | ConditionKey; -} -interface ConditionBlock { - [key: string]: ConditionMap; -} +declare type ConditionBlock = Record>; interface StatementInterface { sid?: string; effect?: EffectBlock; @@ -46,29 +85,29 @@ declare type Resolver = (data: any, expected: any) => boolean; interface ConditionResolver { [key: string]: Resolver; } -interface MatchConditionInterface { - context?: Context; +interface MatchConditionInterface { + context?: T; conditionResolver?: ConditionResolver; } -interface MatchActionBasedInterface extends MatchConditionInterface { +interface MatchActionBasedInterface extends MatchConditionInterface { action: string; } -interface MatchIdentityBasedInterface extends MatchActionBasedInterface { +interface MatchIdentityBasedInterface extends MatchActionBasedInterface { resource: string; } -interface MatchResourceBasedInterface extends MatchActionBasedInterface { +interface MatchResourceBasedInterface extends MatchActionBasedInterface { principal?: string; principalType?: string; resource?: string; } -interface EvaluateActionBasedInterface { +interface EvaluateActionBasedInterface { action: string; - context?: Context; + context?: T; } -interface EvaluateIdentityBasedInterface extends EvaluateActionBasedInterface { +interface EvaluateIdentityBasedInterface extends EvaluateActionBasedInterface { resource: string; } -interface EvaluateResourceBasedInterface extends EvaluateActionBasedInterface { +interface EvaluateResourceBasedInterface extends EvaluateActionBasedInterface { principal?: string; principalType?: string; resource?: string; @@ -87,83 +126,35 @@ interface ProxyOptions { }; } -/** - * Apply the context value in a string. - * - * @param {string} str Pattern string, containing context path. - * @param {object} context Object to get values from path. - * @returns {string} Returns a string with embedded context values. - * @example - * ```javascript - * const context = { - * user: { id: 456, bestFriends: [123, 532, 987] } - * }; - * applyContext('secrets:${user.id}:*', context) - * // => 'secrets:456:*' - * - * applyContext('secrets:${user.bestFriends}:*', context) - * // => 'secrets:{123,532,987}:*' - * - * applyContext('secrets:${company.address}:account', context) - * // => 'secrets:undefined:account' - * ``` - */ -declare function applyContext(str: string, context?: Context): string; - -/** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @since 3.1.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * const object = { 'a': [{ 'b': { 'c': 3 } }] } - * - * getValueFromPath(object, 'a[0].b.c') - * // => 3 - * - * getValueFromPath(object, ['a', '0', 'b', 'c']) - * // => 3 - * - * getValueFromPath(object, 'a.b.c', 'default') - * // => 'default' - */ -declare function getValueFromPath(object: Record, path: Array | string, defaultValue?: unknown): any; - -declare abstract class Statement { +declare abstract class Statement { protected sid: string; protected readonly condition?: ConditionBlock; effect: EffectBlock; constructor({ sid, effect, condition }: StatementInterface); - matchConditions(this: Statement, { context, conditionResolver }: MatchConditionInterface): boolean; + matchConditions(this: Statement, { context, conditionResolver }: MatchConditionInterface): boolean; } -declare class ActionBased extends Statement { +declare class ActionBased extends Statement { private action?; private notAction?; private statement; constructor(action: ActionBasedType); - getStatement(this: ActionBased): ActionBasedType; - matches(this: ActionBased, { action, context, conditionResolver }: MatchActionBasedInterface): boolean; + getStatement(this: ActionBased): ActionBasedType; + matches(this: ActionBased, { action, context, conditionResolver }: MatchActionBasedInterface): boolean; private checkAndAssignActions; private matchActions; private matchNotActions; } -declare class IdentityBased extends Statement { +declare class IdentityBased extends Statement { private resource?; private action?; private notResource?; private notAction?; private statement; constructor(identity: IdentityBasedType); - getStatement(this: IdentityBased): IdentityBasedType; - matches(this: IdentityBased, { action, resource, context, conditionResolver }: MatchIdentityBasedInterface): boolean; + getStatement(this: IdentityBased): IdentityBasedType; + matches(this: IdentityBased, { action, resource, context, conditionResolver }: MatchIdentityBasedInterface): boolean; private checkAndAssignActions; private checkAndAssignResources; private matchActions; @@ -172,7 +163,7 @@ declare class IdentityBased extends Statement { private matchNotResources; } -declare class ResourceBased extends Statement { +declare class ResourceBased extends Statement { private principal?; private resource?; private action?; @@ -183,8 +174,8 @@ declare class ResourceBased extends Statement { private hasPrincipals; private hasResources; constructor(identity: ResourceBasedType); - getStatement(this: ResourceBased): ResourceBasedType; - matches(this: ResourceBased, { principal, action, resource, principalType, context, conditionResolver }: MatchResourceBasedInterface): boolean; + getStatement(this: ResourceBased): ResourceBasedType; + matches(this: ResourceBased, { principal, action, resource, principalType, context, conditionResolver }: MatchResourceBasedInterface): boolean; private matchPrincipalAndNotPrincipal; private matchResourceAndNotResource; private checkAndAssignActions; @@ -198,63 +189,63 @@ declare class ResourceBased extends Statement { private matchNotResources; } -declare class Policy { - protected context?: Context; +declare class Policy { + protected context?: T; protected conditionResolver?: ConditionResolver; - constructor({ context, conditionResolver }: MatchConditionInterface); - setContext(this: Policy, context: Context): void; - getContext(this: Policy): Context | undefined; - setConditionResolver(this: Policy, conditionResolver: ConditionResolver): void; - getConditionResolver(this: Policy): ConditionResolver | undefined; + constructor({ context, conditionResolver }: MatchConditionInterface); + setContext(this: Policy, context: T): void; + getContext(this: Policy): T | undefined; + setConditionResolver(this: Policy, conditionResolver: ConditionResolver): void; + getConditionResolver(this: Policy): ConditionResolver | undefined; } -interface ActionBasedPolicyInterface { +interface ActionBasedPolicyInterface { statements: ActionBasedType[]; conditionResolver?: ConditionResolver; - context?: Context; + context?: T; } -declare class ActionBasedPolicy extends Policy { +declare class ActionBasedPolicy extends Policy { private denyStatements; private allowStatements; private statements; - constructor({ statements, conditionResolver, context }: ActionBasedPolicyInterface); - getStatements(this: ActionBasedPolicy): ActionBasedType[]; - evaluate(this: ActionBasedPolicy, { action, context }: EvaluateActionBasedInterface): boolean; - can(this: ActionBasedPolicy, { action, context }: EvaluateActionBasedInterface): boolean; - cannot(this: ActionBasedPolicy, { action, context }: EvaluateActionBasedInterface): boolean; - generateProxy(this: ActionBasedPolicy, obj: T, options?: ProxyOptions): T; + constructor({ statements, conditionResolver, context }: ActionBasedPolicyInterface); + getStatements(this: ActionBasedPolicy): ActionBasedType[]; + evaluate(this: ActionBasedPolicy, { action, context }: EvaluateActionBasedInterface): boolean; + can(this: ActionBasedPolicy, { action, context }: EvaluateActionBasedInterface): boolean; + cannot(this: ActionBasedPolicy, { action, context }: EvaluateActionBasedInterface): boolean; + generateProxy(this: ActionBasedPolicy, obj: U, options?: ProxyOptions): U; } -interface IdentityBasedPolicyInterface { +interface IdentityBasedPolicyInterface { statements: IdentityBasedType[]; conditionResolver?: ConditionResolver; - context?: Context; + context?: T; } -declare class IdentityBasedPolicy extends Policy { +declare class IdentityBasedPolicy extends Policy { private denyStatements; private allowStatements; private statements; - constructor({ statements, conditionResolver, context }: IdentityBasedPolicyInterface); - getStatements(this: IdentityBasedPolicy): IdentityBasedType[]; - evaluate(this: IdentityBasedPolicy, { action, resource, context }: EvaluateIdentityBasedInterface): boolean; - can(this: IdentityBasedPolicy, { action, resource, context }: EvaluateIdentityBasedInterface): boolean; - cannot(this: IdentityBasedPolicy, { action, resource, context }: EvaluateIdentityBasedInterface): boolean; + constructor({ statements, conditionResolver, context }: IdentityBasedPolicyInterface); + getStatements(this: IdentityBasedPolicy): IdentityBasedType[]; + evaluate(this: IdentityBasedPolicy, { action, resource, context }: EvaluateIdentityBasedInterface): boolean; + can(this: IdentityBasedPolicy, { action, resource, context }: EvaluateIdentityBasedInterface): boolean; + cannot(this: IdentityBasedPolicy, { action, resource, context }: EvaluateIdentityBasedInterface): boolean; } -interface ResourceBasedPolicyInterface { +interface ResourceBasedPolicyInterface { statements: ResourceBasedType[]; conditionResolver?: ConditionResolver; - context?: Context; + context?: T; } -declare class ResourceBasedPolicy extends Policy { +declare class ResourceBasedPolicy extends Policy { private denyStatements; private allowStatements; private statements; - constructor({ statements, conditionResolver, context }: ResourceBasedPolicyInterface); - getStatements(this: ResourceBasedPolicy): ResourceBasedType[]; - evaluate(this: ResourceBasedPolicy, { principal, action, resource, principalType, context }: EvaluateResourceBasedInterface): boolean; - can(this: ResourceBasedPolicy, { principal, action, resource, principalType, context }: EvaluateResourceBasedInterface): boolean; - cannot(this: ResourceBasedPolicy, { principal, action, resource, principalType, context }: EvaluateResourceBasedInterface): boolean; + constructor({ statements, conditionResolver, context }: ResourceBasedPolicyInterface); + getStatements(this: ResourceBasedPolicy): ResourceBasedType[]; + evaluate(this: ResourceBasedPolicy, { principal, action, resource, principalType, context }: EvaluateResourceBasedInterface): boolean; + can(this: ResourceBasedPolicy, { principal, action, resource, principalType, context }: EvaluateResourceBasedInterface): boolean; + cannot(this: ResourceBasedPolicy, { principal, action, resource, principalType, context }: EvaluateResourceBasedInterface): boolean; } export { ActionBased, ActionBasedPolicy, ActionBasedPolicyInterface, IdentityBased, IdentityBasedPolicy, ResourceBased, ResourceBasedPolicy, applyContext, getValueFromPath }; diff --git a/dist/main.es.js.map b/dist/main.es.js.map index 491f372..b1021cd 100644 --- a/dist/main.es.js.map +++ b/dist/main.es.js.map @@ -1 +1 @@ -{"version":3,"file":"main.es.js","sources":["../src/utils/getTag.ts","../src/utils/isSymbol.ts","../src/utils/toKey.ts","../src/utils/isKey.ts","../src/utils/memoize.ts","../src/utils/memoizeCapped.ts","../src/utils/stringToPath.ts","../src/utils/getValueFromPath.ts","../src/utils/applyContext.ts","../src/utils/decomposeString.ts","../src/Matcher.ts","../src/utils/mersenneTwister.ts","../src/utils/generateUUID.ts","../src/Statement.ts","../src/ActionBasedStatement.ts","../src/IdentityBasedStatement.ts","../src/ResourceBasedStatement.ts","../src/Policy.ts","../src/ActionBasedPolicy.ts","../src/IdentityBasedPolicy.ts","../src/ResourceBasedPolicy.ts"],"sourcesContent":["/**\n * Gets the `toStringTag` of `value`.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n * @example\n * ```javascript\n * getTag(1)\n * // => '[object Number]'\n *\n * getTag(null)\n * // => '[object Null]'\n * ```\n */\nexport function getTag(value: unknown): string {\n return Object.prototype.toString.call(value);\n}\n","import { getTag } from './getTag';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @since 3.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n * ```javascript\n * isSymbol(Symbol())\n * // => true\n *\n * isSymbol('abc')\n * // => false\n * ```\n */\nexport function isSymbol(value?: unknown): value is symbol {\n const type = typeof value;\n return (\n type === 'symbol' ||\n (type === 'object' && value !== null && getTag(value) === '[object Symbol]')\n );\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used as references for various `Number` constants. */\nconst INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n * @example\n *\n * toKey(Symbol.iterator)\n * // => true\n *\n * toKey('abc')\n * // => false\n */\nexport function toKey(value: unknown): string | symbol {\n if (typeof value === 'string' || isSymbol(value)) {\n return value;\n }\n\n return value === 0 && 1 / value === -INFINITY ? '-0' : `${value}`;\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used to match property names within property paths. */\nconst reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\nconst reIsPlainProp = /^\\w*$/; //matches any word character (alphanumeric and underscore)\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n * @example\n * ```javascript\n * isKey(1)\n * // => true\n *\n * isKey('example[test]')\n * // => false\n *\n * isKey('a.b')\n * // => false\n *\n * const obj = {\n * '[a]': 5,\n * 'b.c': true\n * };\n *\n * isKey('[a]', obj)\n * // => true\n *\n * isKey('b.c', obj)\n * // => true\n * ```\n */\nexport function isKey(\n value: unknown,\n object?: Record\n): boolean {\n const type = typeof value;\n if (\n type === 'number' ||\n type === 'boolean' ||\n value === null ||\n value === undefined ||\n isSymbol(value)\n ) {\n return true;\n }\n if (typeof value === 'string') {\n return (\n reIsPlainProp.test(value) ||\n !reIsDeepProp.test(value) ||\n (object !== null && value in Object(object))\n );\n }\n return false;\n}\n","import { MemoizeInterface } from '../types';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * @since 3.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n * ```javascript\n * const object = { 'a': 1, 'b': 2 }\n * const other = { 'c': 3, 'd': 4 }\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(other)\n * // => [3, 4]\n *\n * object.a = 2\n * values(object)\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n * ```\n */\nexport function memoize(\n func: (...args: unknown[]) => any,\n resolver?: (...args: unknown[]) => any\n): MemoizeInterface {\n const memoized = function (\n this: (...args: unknown[]) => any,\n ...args: unknown[]\n ): MemoizeInterface {\n const key = resolver ? resolver.apply(this, args) : args[0];\n const cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = func.apply(this, args);\n cache.set(key, result);\n return result;\n };\n memoized.cache = new Map();\n return memoized;\n}\n\n/*const memoize = (fn: Function): Function => {\n const cache = {};\n return (...args): any => {\n const stringifiedArgs = JSON.stringify(args);\n const result = (cache[stringifiedArgs] =\n typeof cache[stringifiedArgs] === 'undefined'\n ? fn(...args)\n : cache[stringifiedArgs]);\n return result;\n };\n};*/\n","import { memoize } from './memoize';\nimport { MemoizeInterface } from '../types';\n\n/** Used as the maximum memoize cache size. */\nexport const MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @since 3.1.0\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nexport function memoizeCapped(\n func: (...args: any) => unknown\n): MemoizeInterface {\n const result = memoize(func, (key: unknown) => {\n const { cache } = result;\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n return result;\n}\n","import { memoizeCapped } from './memoizeCapped';\n\nconst charCodeOfDot = '.'.charCodeAt(0);\nconst reEscapeChar = /\\\\(\\\\)?/g;\nconst rePropName = RegExp(\n // Match anything that isn't a dot or bracket.\n '[^.[\\\\]]+' +\n '|' +\n // Or match property names within brackets.\n '\\\\[(?:' +\n // Match a non-string expression.\n '([^\"\\'][^[]*)' +\n '|' +\n // Or match strings (supports escaping characters).\n '([\"\\'])((?:(?!\\\\x02)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\x02' +\n ')\\\\]' +\n '|' +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n '(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))',\n 'g'\n);\n\n/**\n * Converts `string` to a property path array.\n *\n * @since 3.1.0\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nexport const stringToPath = memoizeCapped((string: string) => {\n const result = [];\n if (string.charCodeAt(0) === charCodeOfDot) {\n result.push('');\n }\n string.replace(\n rePropName,\n (\n match: string,\n expression: string,\n quote: string,\n subString: string\n ): string => {\n let key = match;\n if (quote) {\n key = subString.replace(reEscapeChar, '$1');\n } else if (expression) {\n key = expression.trim();\n }\n result.push(key);\n return '';\n }\n );\n return result;\n});\n","import { toKey } from './toKey';\nimport { isKey } from './isKey';\nimport { stringToPath } from './stringToPath';\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nexport function castPath(\n value: unknown,\n object: Record\n): Array {\n if (Array.isArray(value)) {\n return value;\n }\n\n return isKey(value, object) ? [value] : stringToPath(value);\n}\n\n/**\n * The base implementation of `get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nexport function baseGet(\n object: Record,\n path: Array | string\n): any {\n const newPath = castPath(path, object);\n\n let index = 0;\n const length = newPath.length;\n\n let value: any = object;\n while (value instanceof Object && index < length) {\n value = value[toKey(newPath[index++])];\n }\n\n return index && index === length ? value : undefined;\n}\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @since 3.1.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * const object = { 'a': [{ 'b': { 'c': 3 } }] }\n *\n * getValueFromPath(object, 'a[0].b.c')\n * // => 3\n *\n * getValueFromPath(object, ['a', '0', 'b', 'c'])\n * // => 3\n *\n * getValueFromPath(object, 'a.b.c', 'default')\n * // => 'default'\n */\nexport function getValueFromPath(\n object: Record,\n path: Array | string,\n defaultValue?: unknown\n): any {\n const result = object === null ? undefined : baseGet(object, path);\n\n return result === undefined ? defaultValue : result;\n}\n","import { Context } from '../types';\nimport { getValueFromPath } from './getValueFromPath';\n\nconst reDelimiters = /\\${([^}]*)}/g;\nconst trim = / +(?= )|^\\s+|\\s+$/g;\n\nconst specialTrim = (str: string): string => str.replace(trim, '');\n\n/**\n * Apply the context value in a string.\n *\n * @param {string} str Pattern string, containing context path.\n * @param {object} context Object to get values from path.\n * @returns {string} Returns a string with embedded context values.\n * @example\n * ```javascript\n * const context = {\n * user: { id: 456, bestFriends: [123, 532, 987] }\n * };\n * applyContext('secrets:${user.id}:*', context)\n * // => 'secrets:456:*'\n *\n * applyContext('secrets:${user.bestFriends}:*', context)\n * // => 'secrets:{123,532,987}:*'\n *\n * applyContext('secrets:${company.address}:account', context)\n * // => 'secrets:undefined:account'\n * ```\n */\nexport function applyContext(str: string, context?: Context): string {\n if (!context) return str;\n\n return specialTrim(\n str.replace(reDelimiters, (_, path: string) => {\n const value = getValueFromPath(context, path);\n if (Array.isArray(value)) return `{${value}}`;\n if (value instanceof Object) return 'undefined';\n\n return String(value);\n })\n );\n}\n","import { DecomposeString } from '../types';\n\n/**\n * Get index range where separators are found.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {number[]} Returns the beginning and final index for those matches.\n * @example\n * ```javascript\n * getIndexRange('first', 'Second', 'firstAndSecond')\n * // => [0, 8]\n *\n * getIndexRange('First', 'Second', '++FirstAndSecond**')\n * // => [2, 10]\n * ```\n */\nfunction getIndexRange(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): number[] {\n const beginningIndex = str.indexOf(initialSeparator);\n const finalIndex = str.indexOf(finalSeparator, beginningIndex + 1);\n\n if (beginningIndex >= 0 && finalIndex > 0) {\n return [beginningIndex, finalIndex];\n }\n\n return [-1, -1];\n}\n\n/**\n * Object returned by decomposeString function\n *\n * @typedef {Object} DecomposedString\n * @property {number} start Beginning index for first separator match\n * @property {number} end Final index for second separator match\n * @property {string} pre Substring before first separator\n * @property {string} body Substring between separators\n * @property {string} post Substring after second separator\n */\n\n/**\n * Decompose string in pre, body and post strings by using separators.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {DecomposedString} Returns a decompose string.\n * @example\n * ```javascript\n * decomposeString('first', 'Second', 'firstAndSecond')\n * // => { start: 0, end: 8, pre: '', body: 'And', post: '' }\n *\n * decomposeString('First', 'Second', '++FirstAndSecond**')\n * // => { start: 2, end: 10, pre: '++', body: 'And', post: '**' }\n * ```\n */\nexport function decomposeString(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): DecomposeString {\n const [beginningIndex, finalIndex] = getIndexRange(\n initialSeparator,\n finalSeparator,\n str\n );\n\n return {\n start: beginningIndex,\n end: finalIndex,\n pre: beginningIndex >= 0 ? str.slice(0, beginningIndex) : '',\n body:\n beginningIndex >= 0\n ? str.slice(beginningIndex + initialSeparator.length, finalIndex)\n : '',\n post:\n beginningIndex >= 0 ? str.slice(finalIndex + finalSeparator.length) : ''\n };\n}\n","import { decomposeString } from './utils/decomposeString';\n\nexport class Matcher {\n private readonly pattern: string;\n private readonly maxLength: number;\n private readonly set: (string | RegExp)[];\n private readonly empty: boolean;\n\n constructor(pattern: string, maxLength = 1024 * 64) {\n this.set = [];\n this.pattern = pattern.trim();\n this.maxLength = maxLength;\n this.empty = !this.pattern ? true : false;\n\n const set = this.braceExpand();\n this.set = set.map((val) => this.parse(val));\n this.set = this.set.filter((s) => {\n return Boolean(s);\n });\n }\n\n match(this: Matcher, str: string): boolean {\n if (this.empty) return str === '';\n\n return this.set.some((pattern) => this.matchOne(str, pattern));\n }\n\n private braceExpand(): string[] {\n const pattern = this.pattern;\n if (!pattern.match(/{.*}/)) {\n return [pattern];\n }\n\n return this.expand(pattern, true);\n }\n\n private parse(pattern: string): string | RegExp {\n if (pattern.length > this.maxLength) {\n throw new TypeError('Pattern is too long');\n }\n let regExp;\n let hasSpecialCharacter = false;\n if (pattern === '') return '';\n\n const re = pattern.replace(/\\*/g, () => {\n hasSpecialCharacter = true;\n return '.+?';\n });\n\n // skip the regexp for non-* patterns\n // unescape anything in it, though, so that it'll be\n // an exact match.\n if (!hasSpecialCharacter) {\n return pattern.replace(/\\\\(.)/g, '$1');\n }\n\n try {\n regExp = new RegExp('^' + re + '$');\n } catch (error) {\n // If it was an invalid regular expression, then it can't match\n // anything.\n return new RegExp('$.');\n }\n\n return regExp;\n }\n\n private expand(str: string, isTop?: boolean): string[] {\n const expansions = [] as string[];\n const balance = decomposeString('{', '}', str);\n if (balance.start < 0 || /\\$$/.test(balance.pre)) return [str];\n\n const parts = balance.body.split(',');\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = balance.pre;\n const postParts = balance.post.length\n ? this.expand(balance.post, false)\n : [''];\n\n parts.forEach((part: string) => {\n postParts.forEach((postPart) => {\n const expansion = pre + part + postPart;\n if (!isTop || expansion) expansions.push(expansion);\n });\n });\n\n return expansions;\n }\n\n private matchOne(str: string, pattern: string | RegExp): boolean {\n if (typeof pattern === 'string') {\n return str === pattern;\n }\n\n return Boolean(str.match(pattern));\n }\n}\n","/*\n https://github.com/banksean wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace\n so it's better encapsulated. Now you can have multiple random number generators\n and they won't stomp all over each other's state.\n If you want to use this as a substitute for Math.random(), use the random()\n method like so:\n var m = new MersenneTwister();\n var randomNumber = m.random();\n You can also call the other genrand_{foo}() methods on the instance.\n If you want to use a specific seed in order to get a repeatable random\n sequence, pass an integer into the constructor:\n var m = new MersenneTwister(123);\n and that will always produce the same random sequence.\n Sean McCullough (banksean@gmail.com)\n*/\n\n/*\n A C-program for MT19937, with initialization improved 2002/1/26.\n Coded by Takuji Nishimura and Makoto Matsumoto.\n Before using, initialize the state by using init_seed(seed)\n or init_by_array(init_key, key_length).\n Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,\n All rights reserved.\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n 3. The names of its contributors may not be used to endorse or promote\n products derived from this software without specific prior written\n permission.\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n Any feedback is very welcome.\n http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)\n*/\n\nexport class MersenneTwister {\n private readonly N: number;\n private readonly M: number;\n private readonly MATRIX_A: number;\n private readonly UPPER_MASK: number;\n private readonly LOWER_MASK: number;\n private readonly mt: number[];\n private mti: number;\n\n constructor(seed?: number | number[]) {\n /* Period parameters */\n this.N = 624;\n this.M = 397;\n this.MATRIX_A = 0x9908b0df; /* constant vector a */\n this.UPPER_MASK = 0x80000000; /* most significant w-r bits */\n this.LOWER_MASK = 0x7fffffff; /* least significant r bits */\n\n this.mt = new Array(this.N); /* the array for the state vector */\n this.mti = this.N + 1; /* mti==N+1 means mt[N] is not initialized */\n\n if (Array.isArray(seed)) {\n if (seed.length > 0) this.initByArray(seed, seed.length);\n } else {\n if (seed === undefined) {\n this.initSeed(new Date().getTime());\n } else {\n this.initSeed(seed);\n }\n }\n }\n\n /* initializes mt[N] with a seed */\n /* origin name init_genrand */\n initSeed(seed: number): void {\n this.mt[0] = seed >>> 0;\n for (this.mti = 1; this.mti < this.N; this.mti++) {\n const s = this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30);\n this.mt[this.mti] =\n ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) +\n (s & 0x0000ffff) * 1812433253 +\n this.mti;\n /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n /* In the previous versions, MSBs of the seed affect */\n /* only MSBs of the array mt[]. */\n /* 2002/01/09 modified by Makoto Matsumoto */\n this.mt[this.mti] >>>= 0;\n /* for >32 bit machines */\n }\n }\n\n /* initialize by an array with array-length */\n /* init_key is the array for initializing keys */\n /* key_length is its length */\n /* slight change for C++, 2004/2/26 */\n initByArray(initKey: number[], keyLength: number): void {\n this.initSeed(19650218);\n let i = 1;\n let j = 0;\n let k = this.N > keyLength ? this.N : keyLength;\n for (; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1664525) << 16) +\n (s & 0x0000ffff) * 1664525)) +\n initKey[j] +\n j; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n j++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n if (j >= keyLength) j = 0;\n }\n for (k = this.N - 1; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) +\n (s & 0x0000ffff) * 1566083941)) -\n i; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n }\n\n this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */\n }\n\n /* generates a random number on [0,0xffffffff]-interval */\n /* origin name genrand_int32 */\n randomInt32(): number {\n let y;\n const mag01 = [0x0, this.MATRIX_A];\n /* mag01[x] = x * MATRIX_A for x=0,1 */\n\n if (this.mti >= this.N) {\n /* generate N words at one time */\n let kk;\n\n if (this.mti === this.N + 1)\n /* if init_seed() has not been called, */\n this.initSeed(5489); /* a default initial seed is used */\n\n for (kk = 0; kk < this.N - this.M; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] = this.mt[kk + this.M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this.N - 1; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] =\n this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n y =\n (this.mt[this.N - 1] & this.UPPER_MASK) |\n (this.mt[0] & this.LOWER_MASK);\n this.mt[this.N - 1] = this.mt[this.M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this.mti = 0;\n }\n\n y = this.mt[this.mti++];\n\n /* Tempering */\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /* generates a random number on [0,0x7fffffff]-interval */\n /* origin name genrand_int31 */\n randomInt31(): number {\n return this.randomInt32() >>> 1;\n }\n\n /* generates a random number on [0,1]-real-interval */\n /* origin name genrand_real1 */\n randomReal1(): number {\n return this.randomInt32() * (1.0 / 4294967295.0);\n /* divided by 2^32-1 */\n }\n\n /* generates a random number on [0,1)-real-interval */\n /* origin name genrand_real2 */\n randomReal2(): number {\n return this.randomInt32() * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on (0,1)-real-interval */\n /* origin name genrand_real3 */\n randomReal3(): number {\n return (this.randomInt32() + 0.5) * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on [0,1) with 53-bit resolution*/\n /* origin name genrand_res53 */\n randomRes53(): number {\n const a = this.randomInt32() >>> 5;\n const b = this.randomInt32() >>> 6;\n return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);\n }\n}\n\n/* These real versions are due to Isaku Wada, 2002/01/09 added */\n","import { MersenneTwister } from './mersenneTwister';\n\nconst replacePlaceholders = (mersenne: MersenneTwister) => (\n placeholder: string\n): string => {\n const random = Math.floor(mersenne.randomReal2() * 16);\n\n const value = placeholder === 'x' ? random : (random & 0x3) | 0x8;\n return value.toString(16);\n};\n\n/**\n * Generate a uuid.\n *\n * @private\n * @since 3.5.0\n * @returns {string} Returns the generated uuid.\n * @example\n * ```javascript\n * generateUUID()\n * // => 49e71c40-9b21-4371-9699-2def33f62e66\n *\n * generateUUID()\n * // => da94f128-4247-48e3-bc73-d0cae46b5093\n * ```\n */\nexport function generateUUID(): string {\n const mersenne = new MersenneTwister();\n const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\n return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders(mersenne));\n}\n","import {\n EffectBlock,\n ConditionBlock,\n StatementInterface,\n MatchConditionInterface\n} from './types';\nimport { getValueFromPath } from './utils/getValueFromPath';\nimport { generateUUID } from './utils/generateUUID';\n\nabstract class Statement {\n protected sid: string;\n protected readonly condition?: ConditionBlock;\n effect: EffectBlock;\n\n constructor({ sid, effect = 'allow', condition }: StatementInterface) {\n if (!sid) {\n this.sid = generateUUID();\n } else {\n this.sid = sid;\n }\n this.effect = effect;\n this.condition = condition;\n }\n\n matchConditions(\n this: Statement,\n { context, conditionResolver }: MatchConditionInterface\n ): boolean {\n const { condition: conditions } = this;\n return conditionResolver && conditions && context\n ? Object.keys(conditions).every((condition) =>\n Object.keys(conditions[condition]).every((path) => {\n const conditionValues = conditions[condition][path];\n if (conditionValues instanceof Array) {\n return conditionValues.some((value) =>\n conditionResolver[condition](\n getValueFromPath(context, path),\n value\n )\n );\n }\n return conditionResolver[condition](\n getValueFromPath(context, path),\n conditionValues\n );\n })\n )\n : true;\n }\n}\n\nexport { Statement };\n","import { ActionBasedType, Context, MatchActionBasedInterface } from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ActionBased extends Statement {\n private action?: string[];\n private notAction?: string[];\n private statement: ActionBasedType;\n\n constructor(action: ActionBasedType) {\n super(action);\n this.checkAndAssignActions(action);\n this.statement = { ...action, sid: this.sid };\n }\n\n getStatement(this: ActionBased): ActionBasedType {\n return this.statement;\n }\n\n matches(\n this: ActionBased,\n { action, context, conditionResolver }: MatchActionBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(action: ActionBasedType): void {\n const hasAction = 'action' in action;\n const hasNotAction = 'notAction' in action;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ActionBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in action) {\n this.action =\n typeof action.action === 'string' ? [action.action] : action.action;\n } else {\n this.notAction =\n typeof action.notAction === 'string'\n ? [action.notAction]\n : action.notAction;\n }\n }\n\n private matchActions(action: string, context?: Context): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: Context): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n}\n\nexport { ActionBased };\n","import {\n Context,\n IdentityBasedType,\n MatchIdentityBasedInterface\n} from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass IdentityBased extends Statement {\n private resource?: string[];\n private action?: string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: IdentityBasedType;\n\n constructor(identity: IdentityBasedType) {\n super(identity);\n this.checkAndAssignActions(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: IdentityBased): IdentityBasedType {\n return this.statement;\n }\n\n matches(\n this: IdentityBased,\n {\n action,\n resource,\n context,\n conditionResolver\n }: MatchIdentityBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(identity: IdentityBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'IdentityBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignResources(identity: IdentityBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'IdentityBased statement should have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n } else {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n }\n }\n\n private matchActions(action: string, context?: Context): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: Context): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: Context): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: Context): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { IdentityBased };\n","import {\n PrincipalMap,\n Context,\n MatchResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ResourceBased extends Statement {\n private principal?: PrincipalMap | string[];\n private resource?: string[];\n private action?: string[];\n private notPrincipal?: PrincipalMap | string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: ResourceBasedType;\n private hasPrincipals: boolean;\n private hasResources: boolean;\n\n constructor(identity: ResourceBasedType) {\n super(identity);\n this.hasPrincipals = false;\n this.hasResources = false;\n this.checkAndAssignActions(identity);\n this.checkAndAssignPrincipals(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: ResourceBased): ResourceBasedType {\n return this.statement;\n }\n\n matches(\n this: ResourceBased,\n {\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver\n }: MatchResourceBasedInterface\n ): boolean {\n return (\n this.matchPrincipalAndNotPrincipal(principal, principalType, context) &&\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResourceAndNotResource(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n /*valueComing principal noPrincipal\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchPrincipalAndNotPrincipal(\n principal?: string,\n principalType?: string,\n context?: Context\n ): boolean {\n if (principal) {\n if (this.hasPrincipals)\n return (\n this.matchPrincipals(principal, principalType, context) &&\n this.matchNotPrincipals(principal, principalType, context)\n );\n return false;\n }\n if (this.hasPrincipals) return false;\n return true;\n }\n\n /*valueComing resource noResource\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchResourceAndNotResource(\n resource?: string,\n context?: Context\n ): boolean {\n if (resource) {\n if (this.hasResources)\n return (\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context)\n );\n return false;\n }\n if (this.hasResources) return false;\n return true;\n }\n\n private checkAndAssignActions(identity: ResourceBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ResourceBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignPrincipals(identity: ResourceBasedType): void {\n const hasPrincipal = 'principal' in identity;\n const hasNotPrincipal = 'notPrincipal' in identity;\n if (hasPrincipal && hasNotPrincipal) {\n throw new TypeError(\n 'ResourceBased statement could have a principal or a notPrincipal attribute, no both'\n );\n }\n if ('principal' in identity) {\n this.principal =\n typeof identity.principal === 'string'\n ? [identity.principal]\n : identity.principal;\n this.hasPrincipals = true;\n } else if ('notPrincipal' in identity) {\n this.notPrincipal =\n typeof identity.notPrincipal === 'string'\n ? [identity.notPrincipal]\n : identity.notPrincipal;\n this.hasPrincipals = true;\n }\n }\n\n private checkAndAssignResources(identity: ResourceBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'ResourceBased statement could have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n this.hasResources = true;\n } else if ('notResource' in identity) {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n this.hasResources = true;\n }\n }\n\n private matchPrincipals(\n principal: string,\n principalType?: string,\n context?: Context\n ): boolean {\n if (this.principal) {\n if (this.principal instanceof Array) {\n return principalType\n ? false\n : this.principal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.principal[principalType];\n if (principalValues instanceof Array) {\n return principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return false;\n }\n }\n return true;\n }\n\n private matchNotPrincipals(\n principal: string,\n principalType?: string,\n context?: Context\n ): boolean {\n if (this.notPrincipal) {\n if (this.notPrincipal instanceof Array) {\n return principalType\n ? true\n : !this.notPrincipal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.notPrincipal[principalType];\n if (principalValues instanceof Array) {\n return !principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return !new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return true;\n }\n }\n return true;\n }\n\n private matchActions(action: string, context?: Context): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: Context): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: Context): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: Context): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { ResourceBased };\n","import { MatchConditionInterface, ConditionResolver, Context } from './types';\n\nclass Policy {\n protected context?: Context;\n protected conditionResolver?: ConditionResolver;\n\n constructor({ context, conditionResolver }: MatchConditionInterface) {\n this.context = context;\n this.conditionResolver = conditionResolver;\n }\n\n setContext(this: Policy, context: Context): void {\n this.context = context;\n }\n\n getContext(this: Policy): Context | undefined {\n return this.context;\n }\n\n setConditionResolver(\n this: Policy,\n conditionResolver: ConditionResolver\n ): void {\n this.conditionResolver = conditionResolver;\n }\n\n getConditionResolver(this: Policy): ConditionResolver | undefined {\n return this.conditionResolver;\n }\n}\n\nexport { Policy };\n","import {\n ActionBasedType,\n ConditionResolver,\n Context,\n EvaluateActionBasedInterface,\n ProxyOptions\n} from './types';\nimport { ActionBased } from './ActionBasedStatement';\nimport { Policy } from './Policy';\n\nexport interface ActionBasedPolicyInterface {\n statements: ActionBasedType[];\n conditionResolver?: ConditionResolver;\n context?: Context;\n}\n\nexport class ActionBasedPolicy extends Policy {\n private denyStatements: ActionBased[];\n private allowStatements: ActionBased[];\n private statements: ActionBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ActionBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ActionBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ActionBasedPolicy): ActionBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n const args = { action, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n generateProxy(\n this: ActionBasedPolicy,\n obj: T,\n options: ProxyOptions = {}\n ): T {\n const { get = {}, set = {} } = options;\n const { allow: allowGet = true, propertyMap: propertyMapGet = {} } = get;\n const { allow: allowSet = true, propertyMap: propertyMapSet = {} } = set;\n const handler = {\n ...(allowGet\n ? {\n get: (target: T, prop: U): any => {\n if (prop in target) {\n if (typeof prop === 'string') {\n const property = propertyMapGet[prop] || prop;\n if (this.evaluate({ action: property })) return target[prop];\n throw new Error(`Unauthorize to get ${prop} property`);\n }\n }\n return target[prop];\n }\n }\n : {}),\n ...(allowSet\n ? {\n set: (target: T, prop: U, value: any): boolean => {\n if (typeof prop === 'string') {\n const property = propertyMapSet[prop] || prop;\n if (this.evaluate({ action: property })) {\n target[prop] = value;\n return true;\n } else throw new Error(`Unauthorize to set ${prop} property`);\n }\n return true;\n }\n }\n : {})\n };\n\n return new Proxy(obj, handler);\n }\n}\n","import {\n ConditionResolver,\n Context,\n EvaluateIdentityBasedInterface,\n IdentityBasedType\n} from './types';\nimport { IdentityBased } from './IdentityBasedStatement';\nimport { Policy } from './Policy';\n\ninterface IdentityBasedPolicyInterface {\n statements: IdentityBasedType[];\n conditionResolver?: ConditionResolver;\n context?: Context;\n}\n\nexport class IdentityBasedPolicy extends Policy {\n private denyStatements: IdentityBased[];\n private allowStatements: IdentityBased[];\n private statements: IdentityBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: IdentityBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new IdentityBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: IdentityBasedPolicy): IdentityBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n const args = { action, resource, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n","import {\n ConditionResolver,\n Context,\n EvaluateResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { ResourceBased } from './ResourceBasedStatement';\nimport { Policy } from './Policy';\n\ninterface ResourceBasedPolicyInterface {\n statements: ResourceBasedType[];\n conditionResolver?: ConditionResolver;\n context?: Context;\n}\n\nexport class ResourceBasedPolicy extends Policy {\n private denyStatements: ResourceBased[];\n private allowStatements: ResourceBased[];\n private statements: ResourceBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ResourceBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ResourceBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ResourceBasedPolicy): ResourceBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n const args = { principal, action, resource, principalType, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;SAgBgB,MAAM,CAAC,KAAc;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/C;;AChBA;;;;;;;;;;;;;;;;SAgBgB,QAAQ,CAAC,KAAe;IACtC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,QACE,IAAI,KAAK,QAAQ;SAChB,IAAI,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,EAC5E;AACJ;;ACtBA;AACA,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;AAEvB;;;;;;;;;;;;;;;SAegB,KAAK,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QAChD,OAAO,KAAK,CAAC;KACd;IAED,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;AACpE;;ACxBA;AACA,MAAM,YAAY,GAAG,kDAAkD,CAAC;AACxE,MAAM,aAAa,GAAG,OAAO,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA+BgB,KAAK,CACnB,KAAc,E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,GAAG,CAED,EACE,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EACwB;QAEjC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KACjC,CAAC,CAAC,OAAO,CAAC;YACR,SAAS;YACT,MAAM;YACN,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAC,CACH,CAAC;KACH;IAED,MAAM,CAEJ,EACE,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EACwB;QAEjC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,KAChC,CAAC,CAAC,OAAO,CAAC;YACR,SAAS;YACT,MAAM;YACN,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAC,CACH,CAAC;KACH;;;;;"} \ No newline at end of file +{"version":3,"file":"main.es.js","sources":["../src/utils/getTag.ts","../src/utils/isSymbol.ts","../src/utils/toKey.ts","../src/utils/isKey.ts","../src/utils/memoize.ts","../src/utils/memoizeCapped.ts","../src/utils/stringToPath.ts","../src/utils/getValueFromPath.ts","../src/utils/applyContext.ts","../src/utils/decomposeString.ts","../src/Matcher.ts","../src/utils/mersenneTwister.ts","../src/utils/generateUUID.ts","../src/Statement.ts","../src/ActionBasedStatement.ts","../src/IdentityBasedStatement.ts","../src/ResourceBasedStatement.ts","../src/Policy.ts","../src/ActionBasedPolicy.ts","../src/IdentityBasedPolicy.ts","../src/ResourceBasedPolicy.ts"],"sourcesContent":["/**\n * Gets the `toStringTag` of `value`.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n * @example\n * ```javascript\n * getTag(1)\n * // => '[object Number]'\n *\n * getTag(null)\n * // => '[object Null]'\n * ```\n */\nexport function getTag(value: unknown): string {\n return Object.prototype.toString.call(value);\n}\n","import { getTag } from './getTag';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @since 3.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n * ```javascript\n * isSymbol(Symbol())\n * // => true\n *\n * isSymbol('abc')\n * // => false\n * ```\n */\nexport function isSymbol(value?: unknown): value is symbol {\n const type = typeof value;\n return (\n type === 'symbol' ||\n (type === 'object' && value !== null && getTag(value) === '[object Symbol]')\n );\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used as references for various `Number` constants. */\nconst INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n * @example\n *\n * toKey(Symbol.iterator)\n * // => true\n *\n * toKey('abc')\n * // => false\n */\nexport function toKey(value: unknown): string | symbol {\n if (typeof value === 'string' || isSymbol(value)) {\n return value;\n }\n\n return value === 0 && 1 / value === -INFINITY ? '-0' : `${value}`;\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used to match property names within property paths. */\nconst reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\nconst reIsPlainProp = /^\\w*$/; //matches any word character (alphanumeric and underscore)\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n * @example\n * ```javascript\n * isKey(1)\n * // => true\n *\n * isKey('example[test]')\n * // => false\n *\n * isKey('a.b')\n * // => false\n *\n * const obj = {\n * '[a]': 5,\n * 'b.c': true\n * };\n *\n * isKey('[a]', obj)\n * // => true\n *\n * isKey('b.c', obj)\n * // => true\n * ```\n */\nexport function isKey(value: unknown, object?: T): boolean {\n const type = typeof value;\n if (\n type === 'number' ||\n type === 'boolean' ||\n value === null ||\n value === undefined ||\n isSymbol(value)\n ) {\n return true;\n }\n if (typeof value === 'string') {\n return (\n reIsPlainProp.test(value) ||\n !reIsDeepProp.test(value) ||\n (object !== null && value in Object(object))\n );\n }\n return false;\n}\n","import { MemoizeInterface } from '../types';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * @since 3.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n * ```javascript\n * const object = { 'a': 1, 'b': 2 }\n * const other = { 'c': 3, 'd': 4 }\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(other)\n * // => [3, 4]\n *\n * object.a = 2\n * values(object)\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n * ```\n */\nexport function memoize(\n func: (...args: unknown[]) => any,\n resolver?: (...args: unknown[]) => any\n): MemoizeInterface {\n const memoized = function (\n this: (...args: unknown[]) => any,\n ...args: unknown[]\n ): MemoizeInterface {\n const key = resolver ? resolver.apply(this, args) : args[0];\n const cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = func.apply(this, args);\n cache.set(key, result);\n return result;\n };\n memoized.cache = new Map();\n return memoized;\n}\n\n/*const memoize = (fn: Function): Function => {\n const cache = {};\n return (...args): any => {\n const stringifiedArgs = JSON.stringify(args);\n const result = (cache[stringifiedArgs] =\n typeof cache[stringifiedArgs] === 'undefined'\n ? fn(...args)\n : cache[stringifiedArgs]);\n return result;\n };\n};*/\n","import { memoize } from './memoize';\nimport { MemoizeInterface } from '../types';\n\n/** Used as the maximum memoize cache size. */\nexport const MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @since 3.1.0\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nexport function memoizeCapped(\n func: (...args: any) => unknown\n): MemoizeInterface {\n const result = memoize(func, (key: unknown) => {\n const { cache } = result;\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n return result;\n}\n","import { memoizeCapped } from './memoizeCapped';\n\nconst charCodeOfDot = '.'.charCodeAt(0);\nconst reEscapeChar = /\\\\(\\\\)?/g;\nconst rePropName = RegExp(\n // Match anything that isn't a dot or bracket.\n '[^.[\\\\]]+' +\n '|' +\n // Or match property names within brackets.\n '\\\\[(?:' +\n // Match a non-string expression.\n '([^\"\\'][^[]*)' +\n '|' +\n // Or match strings (supports escaping characters).\n '([\"\\'])((?:(?!\\\\x02)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\x02' +\n ')\\\\]' +\n '|' +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n '(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))',\n 'g'\n);\n\n/**\n * Converts `string` to a property path array.\n *\n * @since 3.1.0\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nexport const stringToPath = memoizeCapped((string: string) => {\n const result = [];\n if (string.charCodeAt(0) === charCodeOfDot) {\n result.push('');\n }\n string.replace(\n rePropName,\n (\n match: string,\n expression: string,\n quote: string,\n subString: string\n ): string => {\n let key = match;\n if (quote) {\n key = subString.replace(reEscapeChar, '$1');\n } else if (expression) {\n key = expression.trim();\n }\n result.push(key);\n return '';\n }\n );\n return result;\n});\n","import { toKey } from './toKey';\nimport { isKey } from './isKey';\nimport { stringToPath } from './stringToPath';\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nexport function castPath(\n value: unknown,\n object: U\n): Array {\n if (Array.isArray(value)) {\n return value;\n }\n\n return isKey(value, object) ? [value] : stringToPath(value);\n}\n\n/**\n * The base implementation of `get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nexport function baseGet(\n object: U,\n path: Array | string\n): any {\n const newPath = castPath(path, object);\n\n let index = 0;\n const length = newPath.length;\n\n let value: any = object;\n while (value instanceof Object && index < length) {\n value = value[toKey(newPath[index++])];\n }\n\n return index && index === length ? value : undefined;\n}\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @since 3.1.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * const object = { 'a': [{ 'b': { 'c': 3 } }] }\n *\n * getValueFromPath(object, 'a[0].b.c')\n * // => 3\n *\n * getValueFromPath(object, ['a', '0', 'b', 'c'])\n * // => 3\n *\n * getValueFromPath(object, 'a.b.c', 'default')\n * // => 'default'\n */\nexport function getValueFromPath(\n object: U,\n path: Array | string,\n defaultValue?: unknown\n): any {\n const result = object === null ? undefined : baseGet(object, path);\n\n return result === undefined ? defaultValue : result;\n}\n","import { getValueFromPath } from './getValueFromPath';\n\nconst reDelimiters = /\\${([^}]*)}/g;\nconst trim = / +(?= )|^\\s+|\\s+$/g;\n\nconst specialTrim = (str: string): string => str.replace(trim, '');\n\n/**\n * Apply the context value in a string.\n *\n * @param {string} str Pattern string, containing context path.\n * @param {object} context Object to get values from path.\n * @returns {string} Returns a string with embedded context values.\n * @example\n * ```javascript\n * const context = {\n * user: { id: 456, bestFriends: [123, 532, 987] }\n * };\n * applyContext('secrets:${user.id}:*', context)\n * // => 'secrets:456:*'\n *\n * applyContext('secrets:${user.bestFriends}:*', context)\n * // => 'secrets:{123,532,987}:*'\n *\n * applyContext('secrets:${company.address}:account', context)\n * // => 'secrets:undefined:account'\n * ```\n */\nexport function applyContext(\n str: string,\n context?: T\n): string {\n if (!context) return str;\n\n return specialTrim(\n str.replace(reDelimiters, (_, path: string) => {\n const value = getValueFromPath(context, path);\n if (Array.isArray(value)) return `{${value}}`;\n if (value instanceof Object) return 'undefined';\n\n return String(value);\n })\n );\n}\n","import { DecomposeString } from '../types';\n\n/**\n * Get index range where separators are found.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {number[]} Returns the beginning and final index for those matches.\n * @example\n * ```javascript\n * getIndexRange('first', 'Second', 'firstAndSecond')\n * // => [0, 8]\n *\n * getIndexRange('First', 'Second', '++FirstAndSecond**')\n * // => [2, 10]\n * ```\n */\nfunction getIndexRange(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): number[] {\n const beginningIndex = str.indexOf(initialSeparator);\n const finalIndex = str.indexOf(finalSeparator, beginningIndex + 1);\n\n if (beginningIndex >= 0 && finalIndex > 0) {\n return [beginningIndex, finalIndex];\n }\n\n return [-1, -1];\n}\n\n/**\n * Object returned by decomposeString function\n *\n * @typedef {Object} DecomposedString\n * @property {number} start Beginning index for first separator match\n * @property {number} end Final index for second separator match\n * @property {string} pre Substring before first separator\n * @property {string} body Substring between separators\n * @property {string} post Substring after second separator\n */\n\n/**\n * Decompose string in pre, body and post strings by using separators.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {DecomposedString} Returns a decompose string.\n * @example\n * ```javascript\n * decomposeString('first', 'Second', 'firstAndSecond')\n * // => { start: 0, end: 8, pre: '', body: 'And', post: '' }\n *\n * decomposeString('First', 'Second', '++FirstAndSecond**')\n * // => { start: 2, end: 10, pre: '++', body: 'And', post: '**' }\n * ```\n */\nexport function decomposeString(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): DecomposeString {\n const [beginningIndex, finalIndex] = getIndexRange(\n initialSeparator,\n finalSeparator,\n str\n );\n\n return {\n start: beginningIndex,\n end: finalIndex,\n pre: beginningIndex >= 0 ? str.slice(0, beginningIndex) : '',\n body:\n beginningIndex >= 0\n ? str.slice(beginningIndex + initialSeparator.length, finalIndex)\n : '',\n post:\n beginningIndex >= 0 ? str.slice(finalIndex + finalSeparator.length) : ''\n };\n}\n","import { decomposeString } from './utils/decomposeString';\n\nexport class Matcher {\n private readonly pattern: string;\n private readonly maxLength: number;\n private readonly set: (string | RegExp)[];\n private readonly empty: boolean;\n\n constructor(pattern: string, maxLength = 1024 * 64) {\n this.set = [];\n this.pattern = pattern.trim();\n this.maxLength = maxLength;\n this.empty = !this.pattern ? true : false;\n\n const set = this.braceExpand();\n this.set = set.map((val) => this.parse(val));\n this.set = this.set.filter((s) => {\n return Boolean(s);\n });\n }\n\n match(this: Matcher, str: string): boolean {\n if (this.empty) return str === '';\n\n return this.set.some((pattern) => this.matchOne(str, pattern));\n }\n\n private braceExpand(): string[] {\n const pattern = this.pattern;\n if (!pattern.match(/{.*}/)) {\n return [pattern];\n }\n\n return this.expand(pattern, true);\n }\n\n private parse(pattern: string): string | RegExp {\n if (pattern.length > this.maxLength) {\n throw new TypeError('Pattern is too long');\n }\n let regExp;\n let hasSpecialCharacter = false;\n if (pattern === '') return '';\n\n const re = pattern.replace(/\\*/g, () => {\n hasSpecialCharacter = true;\n return '.+?';\n });\n\n // skip the regexp for non-* patterns\n // unescape anything in it, though, so that it'll be\n // an exact match.\n if (!hasSpecialCharacter) {\n return pattern.replace(/\\\\(.)/g, '$1');\n }\n\n try {\n regExp = new RegExp('^' + re + '$');\n } catch (error) {\n // If it was an invalid regular expression, then it can't match\n // anything.\n return new RegExp('$.');\n }\n\n return regExp;\n }\n\n private expand(str: string, isTop?: boolean): string[] {\n const expansions = [] as string[];\n const balance = decomposeString('{', '}', str);\n if (balance.start < 0 || /\\$$/.test(balance.pre)) return [str];\n\n const parts = balance.body.split(',');\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = balance.pre;\n const postParts = balance.post.length\n ? this.expand(balance.post, false)\n : [''];\n\n parts.forEach((part: string) => {\n postParts.forEach((postPart) => {\n const expansion = pre + part + postPart;\n if (!isTop || expansion) expansions.push(expansion);\n });\n });\n\n return expansions;\n }\n\n private matchOne(str: string, pattern: string | RegExp): boolean {\n if (typeof pattern === 'string') {\n return str === pattern;\n }\n\n return Boolean(str.match(pattern));\n }\n}\n","/*\n https://github.com/banksean wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace\n so it's better encapsulated. Now you can have multiple random number generators\n and they won't stomp all over each other's state.\n If you want to use this as a substitute for Math.random(), use the random()\n method like so:\n var m = new MersenneTwister();\n var randomNumber = m.random();\n You can also call the other genrand_{foo}() methods on the instance.\n If you want to use a specific seed in order to get a repeatable random\n sequence, pass an integer into the constructor:\n var m = new MersenneTwister(123);\n and that will always produce the same random sequence.\n Sean McCullough (banksean@gmail.com)\n*/\n\n/*\n A C-program for MT19937, with initialization improved 2002/1/26.\n Coded by Takuji Nishimura and Makoto Matsumoto.\n Before using, initialize the state by using init_seed(seed)\n or init_by_array(init_key, key_length).\n Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,\n All rights reserved.\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n 3. The names of its contributors may not be used to endorse or promote\n products derived from this software without specific prior written\n permission.\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n Any feedback is very welcome.\n http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)\n*/\n\nexport class MersenneTwister {\n private readonly N: number;\n private readonly M: number;\n private readonly MATRIX_A: number;\n private readonly UPPER_MASK: number;\n private readonly LOWER_MASK: number;\n private readonly mt: number[];\n private mti: number;\n\n constructor(seed?: number | number[]) {\n /* Period parameters */\n this.N = 624;\n this.M = 397;\n this.MATRIX_A = 0x9908b0df; /* constant vector a */\n this.UPPER_MASK = 0x80000000; /* most significant w-r bits */\n this.LOWER_MASK = 0x7fffffff; /* least significant r bits */\n\n this.mt = new Array(this.N); /* the array for the state vector */\n this.mti = this.N + 1; /* mti==N+1 means mt[N] is not initialized */\n\n if (Array.isArray(seed)) {\n if (seed.length > 0) this.initByArray(seed, seed.length);\n } else {\n if (seed === undefined) {\n this.initSeed(new Date().getTime());\n } else {\n this.initSeed(seed);\n }\n }\n }\n\n /* initializes mt[N] with a seed */\n /* origin name init_genrand */\n initSeed(seed: number): void {\n this.mt[0] = seed >>> 0;\n for (this.mti = 1; this.mti < this.N; this.mti++) {\n const s = this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30);\n this.mt[this.mti] =\n ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) +\n (s & 0x0000ffff) * 1812433253 +\n this.mti;\n /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n /* In the previous versions, MSBs of the seed affect */\n /* only MSBs of the array mt[]. */\n /* 2002/01/09 modified by Makoto Matsumoto */\n this.mt[this.mti] >>>= 0;\n /* for >32 bit machines */\n }\n }\n\n /* initialize by an array with array-length */\n /* init_key is the array for initializing keys */\n /* key_length is its length */\n /* slight change for C++, 2004/2/26 */\n initByArray(initKey: number[], keyLength: number): void {\n this.initSeed(19650218);\n let i = 1;\n let j = 0;\n let k = this.N > keyLength ? this.N : keyLength;\n for (; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1664525) << 16) +\n (s & 0x0000ffff) * 1664525)) +\n initKey[j] +\n j; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n j++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n if (j >= keyLength) j = 0;\n }\n for (k = this.N - 1; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) +\n (s & 0x0000ffff) * 1566083941)) -\n i; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n }\n\n this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */\n }\n\n /* generates a random number on [0,0xffffffff]-interval */\n /* origin name genrand_int32 */\n randomInt32(): number {\n let y;\n const mag01 = [0x0, this.MATRIX_A];\n /* mag01[x] = x * MATRIX_A for x=0,1 */\n\n if (this.mti >= this.N) {\n /* generate N words at one time */\n let kk;\n\n if (this.mti === this.N + 1)\n /* if init_seed() has not been called, */\n this.initSeed(5489); /* a default initial seed is used */\n\n for (kk = 0; kk < this.N - this.M; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] = this.mt[kk + this.M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this.N - 1; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] =\n this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n y =\n (this.mt[this.N - 1] & this.UPPER_MASK) |\n (this.mt[0] & this.LOWER_MASK);\n this.mt[this.N - 1] = this.mt[this.M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this.mti = 0;\n }\n\n y = this.mt[this.mti++];\n\n /* Tempering */\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /* generates a random number on [0,0x7fffffff]-interval */\n /* origin name genrand_int31 */\n randomInt31(): number {\n return this.randomInt32() >>> 1;\n }\n\n /* generates a random number on [0,1]-real-interval */\n /* origin name genrand_real1 */\n randomReal1(): number {\n return this.randomInt32() * (1.0 / 4294967295.0);\n /* divided by 2^32-1 */\n }\n\n /* generates a random number on [0,1)-real-interval */\n /* origin name genrand_real2 */\n randomReal2(): number {\n return this.randomInt32() * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on (0,1)-real-interval */\n /* origin name genrand_real3 */\n randomReal3(): number {\n return (this.randomInt32() + 0.5) * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on [0,1) with 53-bit resolution*/\n /* origin name genrand_res53 */\n randomRes53(): number {\n const a = this.randomInt32() >>> 5;\n const b = this.randomInt32() >>> 6;\n return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);\n }\n}\n\n/* These real versions are due to Isaku Wada, 2002/01/09 added */\n","import { MersenneTwister } from './mersenneTwister';\n\nconst replacePlaceholders = (mersenne: MersenneTwister) => (\n placeholder: string\n): string => {\n const random = Math.floor(mersenne.randomReal2() * 16);\n\n const value = placeholder === 'x' ? random : (random & 0x3) | 0x8;\n return value.toString(16);\n};\n\n/**\n * Generate a uuid.\n *\n * @private\n * @since 3.5.0\n * @returns {string} Returns the generated uuid.\n * @example\n * ```javascript\n * generateUUID()\n * // => 49e71c40-9b21-4371-9699-2def33f62e66\n *\n * generateUUID()\n * // => da94f128-4247-48e3-bc73-d0cae46b5093\n * ```\n */\nexport function generateUUID(): string {\n const mersenne = new MersenneTwister();\n const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\n return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders(mersenne));\n}\n","import {\n EffectBlock,\n ConditionBlock,\n StatementInterface,\n MatchConditionInterface\n} from './types';\nimport { getValueFromPath } from './utils/getValueFromPath';\nimport { generateUUID } from './utils/generateUUID';\n\nabstract class Statement {\n protected sid: string;\n protected readonly condition?: ConditionBlock;\n effect: EffectBlock;\n\n constructor({ sid, effect = 'allow', condition }: StatementInterface) {\n if (!sid) {\n this.sid = generateUUID();\n } else {\n this.sid = sid;\n }\n this.effect = effect;\n this.condition = condition;\n }\n\n matchConditions(\n this: Statement,\n { context, conditionResolver }: MatchConditionInterface\n ): boolean {\n const { condition: conditions } = this;\n return conditionResolver && conditions && context\n ? Object.keys(conditions).every((condition) =>\n Object.keys(conditions[condition]).every((path) => {\n const conditionValues = conditions[condition][path];\n if (conditionValues instanceof Array) {\n return conditionValues.some((value) =>\n conditionResolver[condition](\n getValueFromPath(context, path),\n value\n )\n );\n }\n return conditionResolver[condition](\n getValueFromPath(context, path),\n conditionValues\n );\n })\n )\n : true;\n }\n}\n\nexport { Statement };\n","import { ActionBasedType, MatchActionBasedInterface } from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ActionBased extends Statement {\n private action?: string[];\n private notAction?: string[];\n private statement: ActionBasedType;\n\n constructor(action: ActionBasedType) {\n super(action);\n this.checkAndAssignActions(action);\n this.statement = { ...action, sid: this.sid };\n }\n\n getStatement(this: ActionBased): ActionBasedType {\n return this.statement;\n }\n\n matches(\n this: ActionBased,\n { action, context, conditionResolver }: MatchActionBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(action: ActionBasedType): void {\n const hasAction = 'action' in action;\n const hasNotAction = 'notAction' in action;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ActionBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in action) {\n this.action =\n typeof action.action === 'string' ? [action.action] : action.action;\n } else {\n this.notAction =\n typeof action.notAction === 'string'\n ? [action.notAction]\n : action.notAction;\n }\n }\n\n private matchActions(action: string, context?: T): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: T): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n}\n\nexport { ActionBased };\n","import { IdentityBasedType, MatchIdentityBasedInterface } from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass IdentityBased extends Statement {\n private resource?: string[];\n private action?: string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: IdentityBasedType;\n\n constructor(identity: IdentityBasedType) {\n super(identity);\n this.checkAndAssignActions(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: IdentityBased): IdentityBasedType {\n return this.statement;\n }\n\n matches(\n this: IdentityBased,\n {\n action,\n resource,\n context,\n conditionResolver\n }: MatchIdentityBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(identity: IdentityBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'IdentityBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignResources(identity: IdentityBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'IdentityBased statement should have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n } else {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n }\n }\n\n private matchActions(action: string, context?: T): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: T): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: T): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: T): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { IdentityBased };\n","import {\n PrincipalMap,\n MatchResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ResourceBased extends Statement {\n private principal?: PrincipalMap | string[];\n private resource?: string[];\n private action?: string[];\n private notPrincipal?: PrincipalMap | string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: ResourceBasedType;\n private hasPrincipals: boolean;\n private hasResources: boolean;\n\n constructor(identity: ResourceBasedType) {\n super(identity);\n this.hasPrincipals = false;\n this.hasResources = false;\n this.checkAndAssignActions(identity);\n this.checkAndAssignPrincipals(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: ResourceBased): ResourceBasedType {\n return this.statement;\n }\n\n matches(\n this: ResourceBased,\n {\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver\n }: MatchResourceBasedInterface\n ): boolean {\n return (\n this.matchPrincipalAndNotPrincipal(principal, principalType, context) &&\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResourceAndNotResource(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n /*valueComing principal noPrincipal\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchPrincipalAndNotPrincipal(\n principal?: string,\n principalType?: string,\n context?: T\n ): boolean {\n if (principal) {\n if (this.hasPrincipals)\n return (\n this.matchPrincipals(principal, principalType, context) &&\n this.matchNotPrincipals(principal, principalType, context)\n );\n return false;\n }\n if (this.hasPrincipals) return false;\n return true;\n }\n\n /*valueComing resource noResource\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchResourceAndNotResource(resource?: string, context?: T): boolean {\n if (resource) {\n if (this.hasResources)\n return (\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context)\n );\n return false;\n }\n if (this.hasResources) return false;\n return true;\n }\n\n private checkAndAssignActions(identity: ResourceBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ResourceBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignPrincipals(identity: ResourceBasedType): void {\n const hasPrincipal = 'principal' in identity;\n const hasNotPrincipal = 'notPrincipal' in identity;\n if (hasPrincipal && hasNotPrincipal) {\n throw new TypeError(\n 'ResourceBased statement could have a principal or a notPrincipal attribute, no both'\n );\n }\n if ('principal' in identity) {\n this.principal =\n typeof identity.principal === 'string'\n ? [identity.principal]\n : identity.principal;\n this.hasPrincipals = true;\n } else if ('notPrincipal' in identity) {\n this.notPrincipal =\n typeof identity.notPrincipal === 'string'\n ? [identity.notPrincipal]\n : identity.notPrincipal;\n this.hasPrincipals = true;\n }\n }\n\n private checkAndAssignResources(identity: ResourceBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'ResourceBased statement could have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n this.hasResources = true;\n } else if ('notResource' in identity) {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n this.hasResources = true;\n }\n }\n\n private matchPrincipals(\n principal: string,\n principalType?: string,\n context?: T\n ): boolean {\n if (this.principal) {\n if (this.principal instanceof Array) {\n return principalType\n ? false\n : this.principal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.principal[principalType];\n if (principalValues instanceof Array) {\n return principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return false;\n }\n }\n return true;\n }\n\n private matchNotPrincipals(\n principal: string,\n principalType?: string,\n context?: T\n ): boolean {\n if (this.notPrincipal) {\n if (this.notPrincipal instanceof Array) {\n return principalType\n ? true\n : !this.notPrincipal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.notPrincipal[principalType];\n if (principalValues instanceof Array) {\n return !principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return !new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return true;\n }\n }\n return true;\n }\n\n private matchActions(action: string, context?: T): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: T): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: T): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: T): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { ResourceBased };\n","import { MatchConditionInterface, ConditionResolver } from './types';\n\nclass Policy {\n protected context?: T;\n protected conditionResolver?: ConditionResolver;\n\n constructor({ context, conditionResolver }: MatchConditionInterface) {\n this.context = context;\n this.conditionResolver = conditionResolver;\n }\n\n setContext(this: Policy, context: T): void {\n this.context = context;\n }\n\n getContext(this: Policy): T | undefined {\n return this.context;\n }\n\n setConditionResolver(\n this: Policy,\n conditionResolver: ConditionResolver\n ): void {\n this.conditionResolver = conditionResolver;\n }\n\n getConditionResolver(this: Policy): ConditionResolver | undefined {\n return this.conditionResolver;\n }\n}\n\nexport { Policy };\n","import {\n ActionBasedType,\n ConditionResolver,\n EvaluateActionBasedInterface,\n ProxyOptions\n} from './types';\nimport { ActionBased } from './ActionBasedStatement';\nimport { Policy } from './Policy';\n\nexport interface ActionBasedPolicyInterface {\n statements: ActionBasedType[];\n conditionResolver?: ConditionResolver;\n context?: T;\n}\n\nexport class ActionBasedPolicy extends Policy {\n private denyStatements: ActionBased[];\n private allowStatements: ActionBased[];\n private statements: ActionBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ActionBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ActionBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ActionBasedPolicy): ActionBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n const args = { action, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n generateProxy(\n this: ActionBasedPolicy,\n obj: U,\n options: ProxyOptions = {}\n ): U {\n const { get = {}, set = {} } = options;\n const { allow: allowGet = true, propertyMap: propertyMapGet = {} } = get;\n const { allow: allowSet = true, propertyMap: propertyMapSet = {} } = set;\n const handler = {\n ...(allowGet\n ? {\n get: (target: U, prop: W): any => {\n if (prop in target) {\n if (typeof prop === 'string') {\n const property = propertyMapGet[prop] || prop;\n if (this.evaluate({ action: property })) return target[prop];\n throw new Error(`Unauthorize to get ${prop} property`);\n }\n }\n return target[prop];\n }\n }\n : {}),\n ...(allowSet\n ? {\n set: (target: U, prop: W, value: any): boolean => {\n if (typeof prop === 'string') {\n const property = propertyMapSet[prop] || prop;\n if (this.evaluate({ action: property })) {\n target[prop] = value;\n return true;\n } else throw new Error(`Unauthorize to set ${prop} property`);\n }\n return true;\n }\n }\n : {})\n };\n\n return new Proxy(obj, handler);\n }\n}\n","import {\n ConditionResolver,\n EvaluateIdentityBasedInterface,\n IdentityBasedType\n} from './types';\nimport { IdentityBased } from './IdentityBasedStatement';\nimport { Policy } from './Policy';\n\ninterface IdentityBasedPolicyInterface {\n statements: IdentityBasedType[];\n conditionResolver?: ConditionResolver;\n context?: T;\n}\n\nexport class IdentityBasedPolicy extends Policy {\n private denyStatements: IdentityBased[];\n private allowStatements: IdentityBased[];\n private statements: IdentityBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: IdentityBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new IdentityBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: IdentityBasedPolicy): IdentityBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n const args = { action, resource, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n","import {\n ConditionResolver,\n EvaluateResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { ResourceBased } from './ResourceBasedStatement';\nimport { Policy } from './Policy';\n\ninterface ResourceBasedPolicyInterface {\n statements: ResourceBasedType[];\n conditionResolver?: ConditionResolver;\n context?: T;\n}\n\nexport class ResourceBasedPolicy extends Policy {\n private denyStatements: ResourceBased[];\n private allowStatements: ResourceBased[];\n private statements: ResourceBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ResourceBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ResourceBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ResourceBasedPolicy): ResourceBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n const args = { principal, action, resource, principalType, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;SAgBgB,MAAM,CAAC,KAAc;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/C;;AChBA;;;;;;;;;;;;;;;;SAgBgB,QAAQ,CAAC,KAAe;IACtC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,QACE,IAAI,KAAK,QAAQ;SAChB,IAAI,KAAK,QAAQ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AkB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;QAC5E,IAAI,CAAC,UAAU,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,SAAS,KACjD,SAAS,CAAC,YAAY,EAAE,CACzB,CAAC;KACH;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;KACxB;IAED,QAAQ,CAEN,EACE,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EAC2B;QAEpC,MAAM,IAAI,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;QACrE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KAC7C;IAED,GAAG,CAED,EACE,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EAC2B;QAEpC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KACjC,CAAC,CAAC,OAAO,CAAC;YACR,SAAS;YACT,MAAM;YACN,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAC,CACH,CAAC;KACH;IAED,MAAM,CAEJ,EACE,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EAC2B;QAEpC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,KAChC,CAAC,CAAC,OAAO,CAAC;YACR,SAAS;YACT,MAAM;YACN,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAC,CACH,CAAC;KACH;;;;;"} \ No newline at end of file diff --git a/dist/main.js.map b/dist/main.js.map index 526c87a..161b61e 100644 --- a/dist/main.js.map +++ b/dist/main.js.map @@ -1 +1 @@ -{"version":3,"file":"main.js","sources":["../src/utils/getTag.ts","../src/utils/isSymbol.ts","../src/utils/toKey.ts","../src/utils/isKey.ts","../src/utils/memoize.ts","../src/utils/memoizeCapped.ts","../src/utils/stringToPath.ts","../src/utils/getValueFromPath.ts","../src/utils/applyContext.ts","../src/utils/decomposeString.ts","../src/Matcher.ts","../src/utils/mersenneTwister.ts","../src/utils/generateUUID.ts","../src/Statement.ts","../src/ActionBasedStatement.ts","../src/IdentityBasedStatement.ts","../src/ResourceBasedStatement.ts","../src/Policy.ts","../src/ActionBasedPolicy.ts","../src/IdentityBasedPolicy.ts","../src/ResourceBasedPolicy.ts"],"sourcesContent":["/**\n * Gets the `toStringTag` of `value`.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n * @example\n * ```javascript\n * getTag(1)\n * // => '[object Number]'\n *\n * getTag(null)\n * // => '[object Null]'\n * ```\n */\nexport function getTag(value: unknown): string {\n return Object.prototype.toString.call(value);\n}\n","import { getTag } from './getTag';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @since 3.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n * ```javascript\n * isSymbol(Symbol())\n * // => true\n *\n * isSymbol('abc')\n * // => false\n * ```\n */\nexport function isSymbol(value?: unknown): value is symbol {\n const type = typeof value;\n return (\n type === 'symbol' ||\n (type === 'object' && value !== null && getTag(value) === '[object Symbol]')\n );\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used as references for various `Number` constants. */\nconst INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n * @example\n *\n * toKey(Symbol.iterator)\n * // => true\n *\n * toKey('abc')\n * // => false\n */\nexport function toKey(value: unknown): string | symbol {\n if (typeof value === 'string' || isSymbol(value)) {\n return value;\n }\n\n return value === 0 && 1 / value === -INFINITY ? '-0' : `${value}`;\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used to match property names within property paths. */\nconst reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\nconst reIsPlainProp = /^\\w*$/; //matches any word character (alphanumeric and underscore)\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n * @example\n * ```javascript\n * isKey(1)\n * // => true\n *\n * isKey('example[test]')\n * // => false\n *\n * isKey('a.b')\n * // => false\n *\n * const obj = {\n * '[a]': 5,\n * 'b.c': true\n * };\n *\n * isKey('[a]', obj)\n * // => true\n *\n * isKey('b.c', obj)\n * // => true\n * ```\n */\nexport function isKey(\n value: unknown,\n object?: Record\n): boolean {\n const type = typeof value;\n if (\n type === 'number' ||\n type === 'boolean' ||\n value === null ||\n value === undefined ||\n isSymbol(value)\n ) {\n return true;\n }\n if (typeof value === 'string') {\n return (\n reIsPlainProp.test(value) ||\n !reIsDeepProp.test(value) ||\n (object !== null && value in Object(object))\n );\n }\n return false;\n}\n","import { MemoizeInterface } from '../types';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * @since 3.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n * ```javascript\n * const object = { 'a': 1, 'b': 2 }\n * const other = { 'c': 3, 'd': 4 }\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(other)\n * // => [3, 4]\n *\n * object.a = 2\n * values(object)\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n * ```\n */\nexport function memoize(\n func: (...args: unknown[]) => any,\n resolver?: (...args: unknown[]) => any\n): MemoizeInterface {\n const memoized = function (\n this: (...args: unknown[]) => any,\n ...args: unknown[]\n ): MemoizeInterface {\n const key = resolver ? resolver.apply(this, args) : args[0];\n const cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = func.apply(this, args);\n cache.set(key, result);\n return result;\n };\n memoized.cache = new Map();\n return memoized;\n}\n\n/*const memoize = (fn: Function): Function => {\n const cache = {};\n return (...args): any => {\n const stringifiedArgs = JSON.stringify(args);\n const result = (cache[stringifiedArgs] =\n typeof cache[stringifiedArgs] === 'undefined'\n ? fn(...args)\n : cache[stringifiedArgs]);\n return result;\n };\n};*/\n","import { memoize } from './memoize';\nimport { MemoizeInterface } from '../types';\n\n/** Used as the maximum memoize cache size. */\nexport const MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @since 3.1.0\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nexport function memoizeCapped(\n func: (...args: any) => unknown\n): MemoizeInterface {\n const result = memoize(func, (key: unknown) => {\n const { cache } = result;\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n return result;\n}\n","import { memoizeCapped } from './memoizeCapped';\n\nconst charCodeOfDot = '.'.charCodeAt(0);\nconst reEscapeChar = /\\\\(\\\\)?/g;\nconst rePropName = RegExp(\n // Match anything that isn't a dot or bracket.\n '[^.[\\\\]]+' +\n '|' +\n // Or match property names within brackets.\n '\\\\[(?:' +\n // Match a non-string expression.\n '([^\"\\'][^[]*)' +\n '|' +\n // Or match strings (supports escaping characters).\n '([\"\\'])((?:(?!\\\\x02)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\x02' +\n ')\\\\]' +\n '|' +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n '(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))',\n 'g'\n);\n\n/**\n * Converts `string` to a property path array.\n *\n * @since 3.1.0\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nexport const stringToPath = memoizeCapped((string: string) => {\n const result = [];\n if (string.charCodeAt(0) === charCodeOfDot) {\n result.push('');\n }\n string.replace(\n rePropName,\n (\n match: string,\n expression: string,\n quote: string,\n subString: string\n ): string => {\n let key = match;\n if (quote) {\n key = subString.replace(reEscapeChar, '$1');\n } else if (expression) {\n key = expression.trim();\n }\n result.push(key);\n return '';\n }\n );\n return result;\n});\n","import { toKey } from './toKey';\nimport { isKey } from './isKey';\nimport { stringToPath } from './stringToPath';\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nexport function castPath(\n value: unknown,\n object: Record\n): Array {\n if (Array.isArray(value)) {\n return value;\n }\n\n return isKey(value, object) ? [value] : stringToPath(value);\n}\n\n/**\n * The base implementation of `get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nexport function baseGet(\n object: Record,\n path: Array | string\n): any {\n const newPath = castPath(path, object);\n\n let index = 0;\n const length = newPath.length;\n\n let value: any = object;\n while (value instanceof Object && index < length) {\n value = value[toKey(newPath[index++])];\n }\n\n return index && index === length ? value : undefined;\n}\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @since 3.1.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * const object = { 'a': [{ 'b': { 'c': 3 } }] }\n *\n * getValueFromPath(object, 'a[0].b.c')\n * // => 3\n *\n * getValueFromPath(object, ['a', '0', 'b', 'c'])\n * // => 3\n *\n * getValueFromPath(object, 'a.b.c', 'default')\n * // => 'default'\n */\nexport function getValueFromPath(\n object: Record,\n path: Array | string,\n defaultValue?: unknown\n): any {\n const result = object === null ? undefined : baseGet(object, path);\n\n return result === undefined ? defaultValue : result;\n}\n","import { Context } from '../types';\nimport { getValueFromPath } from './getValueFromPath';\n\nconst reDelimiters = /\\${([^}]*)}/g;\nconst trim = / +(?= )|^\\s+|\\s+$/g;\n\nconst specialTrim = (str: string): string => str.replace(trim, '');\n\n/**\n * Apply the context value in a string.\n *\n * @param {string} str Pattern string, containing context path.\n * @param {object} context Object to get values from path.\n * @returns {string} Returns a string with embedded context values.\n * @example\n * ```javascript\n * const context = {\n * user: { id: 456, bestFriends: [123, 532, 987] }\n * };\n * applyContext('secrets:${user.id}:*', context)\n * // => 'secrets:456:*'\n *\n * applyContext('secrets:${user.bestFriends}:*', context)\n * // => 'secrets:{123,532,987}:*'\n *\n * applyContext('secrets:${company.address}:account', context)\n * // => 'secrets:undefined:account'\n * ```\n */\nexport function applyContext(str: string, context?: Context): string {\n if (!context) return str;\n\n return specialTrim(\n str.replace(reDelimiters, (_, path: string) => {\n const value = getValueFromPath(context, path);\n if (Array.isArray(value)) return `{${value}}`;\n if (value instanceof Object) return 'undefined';\n\n return String(value);\n })\n );\n}\n","import { DecomposeString } from '../types';\n\n/**\n * Get index range where separators are found.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {number[]} Returns the beginning and final index for those matches.\n * @example\n * ```javascript\n * getIndexRange('first', 'Second', 'firstAndSecond')\n * // => [0, 8]\n *\n * getIndexRange('First', 'Second', '++FirstAndSecond**')\n * // => [2, 10]\n * ```\n */\nfunction getIndexRange(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): number[] {\n const beginningIndex = str.indexOf(initialSeparator);\n const finalIndex = str.indexOf(finalSeparator, beginningIndex + 1);\n\n if (beginningIndex >= 0 && finalIndex > 0) {\n return [beginningIndex, finalIndex];\n }\n\n return [-1, -1];\n}\n\n/**\n * Object returned by decomposeString function\n *\n * @typedef {Object} DecomposedString\n * @property {number} start Beginning index for first separator match\n * @property {number} end Final index for second separator match\n * @property {string} pre Substring before first separator\n * @property {string} body Substring between separators\n * @property {string} post Substring after second separator\n */\n\n/**\n * Decompose string in pre, body and post strings by using separators.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {DecomposedString} Returns a decompose string.\n * @example\n * ```javascript\n * decomposeString('first', 'Second', 'firstAndSecond')\n * // => { start: 0, end: 8, pre: '', body: 'And', post: '' }\n *\n * decomposeString('First', 'Second', '++FirstAndSecond**')\n * // => { start: 2, end: 10, pre: '++', body: 'And', post: '**' }\n * ```\n */\nexport function decomposeString(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): DecomposeString {\n const [beginningIndex, finalIndex] = getIndexRange(\n initialSeparator,\n finalSeparator,\n str\n );\n\n return {\n start: beginningIndex,\n end: finalIndex,\n pre: beginningIndex >= 0 ? str.slice(0, beginningIndex) : '',\n body:\n beginningIndex >= 0\n ? str.slice(beginningIndex + initialSeparator.length, finalIndex)\n : '',\n post:\n beginningIndex >= 0 ? str.slice(finalIndex + finalSeparator.length) : ''\n };\n}\n","import { decomposeString } from './utils/decomposeString';\n\nexport class Matcher {\n private readonly pattern: string;\n private readonly maxLength: number;\n private readonly set: (string | RegExp)[];\n private readonly empty: boolean;\n\n constructor(pattern: string, maxLength = 1024 * 64) {\n this.set = [];\n this.pattern = pattern.trim();\n this.maxLength = maxLength;\n this.empty = !this.pattern ? true : false;\n\n const set = this.braceExpand();\n this.set = set.map((val) => this.parse(val));\n this.set = this.set.filter((s) => {\n return Boolean(s);\n });\n }\n\n match(this: Matcher, str: string): boolean {\n if (this.empty) return str === '';\n\n return this.set.some((pattern) => this.matchOne(str, pattern));\n }\n\n private braceExpand(): string[] {\n const pattern = this.pattern;\n if (!pattern.match(/{.*}/)) {\n return [pattern];\n }\n\n return this.expand(pattern, true);\n }\n\n private parse(pattern: string): string | RegExp {\n if (pattern.length > this.maxLength) {\n throw new TypeError('Pattern is too long');\n }\n let regExp;\n let hasSpecialCharacter = false;\n if (pattern === '') return '';\n\n const re = pattern.replace(/\\*/g, () => {\n hasSpecialCharacter = true;\n return '.+?';\n });\n\n // skip the regexp for non-* patterns\n // unescape anything in it, though, so that it'll be\n // an exact match.\n if (!hasSpecialCharacter) {\n return pattern.replace(/\\\\(.)/g, '$1');\n }\n\n try {\n regExp = new RegExp('^' + re + '$');\n } catch (error) {\n // If it was an invalid regular expression, then it can't match\n // anything.\n return new RegExp('$.');\n }\n\n return regExp;\n }\n\n private expand(str: string, isTop?: boolean): string[] {\n const expansions = [] as string[];\n const balance = decomposeString('{', '}', str);\n if (balance.start < 0 || /\\$$/.test(balance.pre)) return [str];\n\n const parts = balance.body.split(',');\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = balance.pre;\n const postParts = balance.post.length\n ? this.expand(balance.post, false)\n : [''];\n\n parts.forEach((part: string) => {\n postParts.forEach((postPart) => {\n const expansion = pre + part + postPart;\n if (!isTop || expansion) expansions.push(expansion);\n });\n });\n\n return expansions;\n }\n\n private matchOne(str: string, pattern: string | RegExp): boolean {\n if (typeof pattern === 'string') {\n return str === pattern;\n }\n\n return Boolean(str.match(pattern));\n }\n}\n","/*\n https://github.com/banksean wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace\n so it's better encapsulated. Now you can have multiple random number generators\n and they won't stomp all over each other's state.\n If you want to use this as a substitute for Math.random(), use the random()\n method like so:\n var m = new MersenneTwister();\n var randomNumber = m.random();\n You can also call the other genrand_{foo}() methods on the instance.\n If you want to use a specific seed in order to get a repeatable random\n sequence, pass an integer into the constructor:\n var m = new MersenneTwister(123);\n and that will always produce the same random sequence.\n Sean McCullough (banksean@gmail.com)\n*/\n\n/*\n A C-program for MT19937, with initialization improved 2002/1/26.\n Coded by Takuji Nishimura and Makoto Matsumoto.\n Before using, initialize the state by using init_seed(seed)\n or init_by_array(init_key, key_length).\n Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,\n All rights reserved.\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n 3. The names of its contributors may not be used to endorse or promote\n products derived from this software without specific prior written\n permission.\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n Any feedback is very welcome.\n http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)\n*/\n\nexport class MersenneTwister {\n private readonly N: number;\n private readonly M: number;\n private readonly MATRIX_A: number;\n private readonly UPPER_MASK: number;\n private readonly LOWER_MASK: number;\n private readonly mt: number[];\n private mti: number;\n\n constructor(seed?: number | number[]) {\n /* Period parameters */\n this.N = 624;\n this.M = 397;\n this.MATRIX_A = 0x9908b0df; /* constant vector a */\n this.UPPER_MASK = 0x80000000; /* most significant w-r bits */\n this.LOWER_MASK = 0x7fffffff; /* least significant r bits */\n\n this.mt = new Array(this.N); /* the array for the state vector */\n this.mti = this.N + 1; /* mti==N+1 means mt[N] is not initialized */\n\n if (Array.isArray(seed)) {\n if (seed.length > 0) this.initByArray(seed, seed.length);\n } else {\n if (seed === undefined) {\n this.initSeed(new Date().getTime());\n } else {\n this.initSeed(seed);\n }\n }\n }\n\n /* initializes mt[N] with a seed */\n /* origin name init_genrand */\n initSeed(seed: number): void {\n this.mt[0] = seed >>> 0;\n for (this.mti = 1; this.mti < this.N; this.mti++) {\n const s = this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30);\n this.mt[this.mti] =\n ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) +\n (s & 0x0000ffff) * 1812433253 +\n this.mti;\n /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n /* In the previous versions, MSBs of the seed affect */\n /* only MSBs of the array mt[]. */\n /* 2002/01/09 modified by Makoto Matsumoto */\n this.mt[this.mti] >>>= 0;\n /* for >32 bit machines */\n }\n }\n\n /* initialize by an array with array-length */\n /* init_key is the array for initializing keys */\n /* key_length is its length */\n /* slight change for C++, 2004/2/26 */\n initByArray(initKey: number[], keyLength: number): void {\n this.initSeed(19650218);\n let i = 1;\n let j = 0;\n let k = this.N > keyLength ? this.N : keyLength;\n for (; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1664525) << 16) +\n (s & 0x0000ffff) * 1664525)) +\n initKey[j] +\n j; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n j++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n if (j >= keyLength) j = 0;\n }\n for (k = this.N - 1; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) +\n (s & 0x0000ffff) * 1566083941)) -\n i; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n }\n\n this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */\n }\n\n /* generates a random number on [0,0xffffffff]-interval */\n /* origin name genrand_int32 */\n randomInt32(): number {\n let y;\n const mag01 = [0x0, this.MATRIX_A];\n /* mag01[x] = x * MATRIX_A for x=0,1 */\n\n if (this.mti >= this.N) {\n /* generate N words at one time */\n let kk;\n\n if (this.mti === this.N + 1)\n /* if init_seed() has not been called, */\n this.initSeed(5489); /* a default initial seed is used */\n\n for (kk = 0; kk < this.N - this.M; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] = this.mt[kk + this.M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this.N - 1; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] =\n this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n y =\n (this.mt[this.N - 1] & this.UPPER_MASK) |\n (this.mt[0] & this.LOWER_MASK);\n this.mt[this.N - 1] = this.mt[this.M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this.mti = 0;\n }\n\n y = this.mt[this.mti++];\n\n /* Tempering */\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /* generates a random number on [0,0x7fffffff]-interval */\n /* origin name genrand_int31 */\n randomInt31(): number {\n return this.randomInt32() >>> 1;\n }\n\n /* generates a random number on [0,1]-real-interval */\n /* origin name genrand_real1 */\n randomReal1(): number {\n return this.randomInt32() * (1.0 / 4294967295.0);\n /* divided by 2^32-1 */\n }\n\n /* generates a random number on [0,1)-real-interval */\n /* origin name genrand_real2 */\n randomReal2(): number {\n return this.randomInt32() * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on (0,1)-real-interval */\n /* origin name genrand_real3 */\n randomReal3(): number {\n return (this.randomInt32() + 0.5) * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on [0,1) with 53-bit resolution*/\n /* origin name genrand_res53 */\n randomRes53(): number {\n const a = this.randomInt32() >>> 5;\n const b = this.randomInt32() >>> 6;\n return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);\n }\n}\n\n/* These real versions are due to Isaku Wada, 2002/01/09 added */\n","import { MersenneTwister } from './mersenneTwister';\n\nconst replacePlaceholders = (mersenne: MersenneTwister) => (\n placeholder: string\n): string => {\n const random = Math.floor(mersenne.randomReal2() * 16);\n\n const value = placeholder === 'x' ? random : (random & 0x3) | 0x8;\n return value.toString(16);\n};\n\n/**\n * Generate a uuid.\n *\n * @private\n * @since 3.5.0\n * @returns {string} Returns the generated uuid.\n * @example\n * ```javascript\n * generateUUID()\n * // => 49e71c40-9b21-4371-9699-2def33f62e66\n *\n * generateUUID()\n * // => da94f128-4247-48e3-bc73-d0cae46b5093\n * ```\n */\nexport function generateUUID(): string {\n const mersenne = new MersenneTwister();\n const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\n return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders(mersenne));\n}\n","import {\n EffectBlock,\n ConditionBlock,\n StatementInterface,\n MatchConditionInterface\n} from './types';\nimport { getValueFromPath } from './utils/getValueFromPath';\nimport { generateUUID } from './utils/generateUUID';\n\nabstract class Statement {\n protected sid: string;\n protected readonly condition?: ConditionBlock;\n effect: EffectBlock;\n\n constructor({ sid, effect = 'allow', condition }: StatementInterface) {\n if (!sid) {\n this.sid = generateUUID();\n } else {\n this.sid = sid;\n }\n this.effect = effect;\n this.condition = condition;\n }\n\n matchConditions(\n this: Statement,\n { context, conditionResolver }: MatchConditionInterface\n ): boolean {\n const { condition: conditions } = this;\n return conditionResolver && conditions && context\n ? Object.keys(conditions).every((condition) =>\n Object.keys(conditions[condition]).every((path) => {\n const conditionValues = conditions[condition][path];\n if (conditionValues instanceof Array) {\n return conditionValues.some((value) =>\n conditionResolver[condition](\n getValueFromPath(context, path),\n value\n )\n );\n }\n return conditionResolver[condition](\n getValueFromPath(context, path),\n conditionValues\n );\n })\n )\n : true;\n }\n}\n\nexport { Statement };\n","import { ActionBasedType, Context, MatchActionBasedInterface } from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ActionBased extends Statement {\n private action?: string[];\n private notAction?: string[];\n private statement: ActionBasedType;\n\n constructor(action: ActionBasedType) {\n super(action);\n this.checkAndAssignActions(action);\n this.statement = { ...action, sid: this.sid };\n }\n\n getStatement(this: ActionBased): ActionBasedType {\n return this.statement;\n }\n\n matches(\n this: ActionBased,\n { action, context, conditionResolver }: MatchActionBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(action: ActionBasedType): void {\n const hasAction = 'action' in action;\n const hasNotAction = 'notAction' in action;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ActionBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in action) {\n this.action =\n typeof action.action === 'string' ? [action.action] : action.action;\n } else {\n this.notAction =\n typeof action.notAction === 'string'\n ? [action.notAction]\n : action.notAction;\n }\n }\n\n private matchActions(action: string, context?: Context): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: Context): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n}\n\nexport { ActionBased };\n","import {\n Context,\n IdentityBasedType,\n MatchIdentityBasedInterface\n} from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass IdentityBased extends Statement {\n private resource?: string[];\n private action?: string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: IdentityBasedType;\n\n constructor(identity: IdentityBasedType) {\n super(identity);\n this.checkAndAssignActions(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: IdentityBased): IdentityBasedType {\n return this.statement;\n }\n\n matches(\n this: IdentityBased,\n {\n action,\n resource,\n context,\n conditionResolver\n }: MatchIdentityBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(identity: IdentityBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'IdentityBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignResources(identity: IdentityBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'IdentityBased statement should have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n } else {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n }\n }\n\n private matchActions(action: string, context?: Context): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: Context): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: Context): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: Context): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { IdentityBased };\n","import {\n PrincipalMap,\n Context,\n MatchResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ResourceBased extends Statement {\n private principal?: PrincipalMap | string[];\n private resource?: string[];\n private action?: string[];\n private notPrincipal?: PrincipalMap | string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: ResourceBasedType;\n private hasPrincipals: boolean;\n private hasResources: boolean;\n\n constructor(identity: ResourceBasedType) {\n super(identity);\n this.hasPrincipals = false;\n this.hasResources = false;\n this.checkAndAssignActions(identity);\n this.checkAndAssignPrincipals(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: ResourceBased): ResourceBasedType {\n return this.statement;\n }\n\n matches(\n this: ResourceBased,\n {\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver\n }: MatchResourceBasedInterface\n ): boolean {\n return (\n this.matchPrincipalAndNotPrincipal(principal, principalType, context) &&\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResourceAndNotResource(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n /*valueComing principal noPrincipal\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchPrincipalAndNotPrincipal(\n principal?: string,\n principalType?: string,\n context?: Context\n ): boolean {\n if (principal) {\n if (this.hasPrincipals)\n return (\n this.matchPrincipals(principal, principalType, context) &&\n this.matchNotPrincipals(principal, principalType, context)\n );\n return false;\n }\n if (this.hasPrincipals) return false;\n return true;\n }\n\n /*valueComing resource noResource\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchResourceAndNotResource(\n resource?: string,\n context?: Context\n ): boolean {\n if (resource) {\n if (this.hasResources)\n return (\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context)\n );\n return false;\n }\n if (this.hasResources) return false;\n return true;\n }\n\n private checkAndAssignActions(identity: ResourceBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ResourceBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignPrincipals(identity: ResourceBasedType): void {\n const hasPrincipal = 'principal' in identity;\n const hasNotPrincipal = 'notPrincipal' in identity;\n if (hasPrincipal && hasNotPrincipal) {\n throw new TypeError(\n 'ResourceBased statement could have a principal or a notPrincipal attribute, no both'\n );\n }\n if ('principal' in identity) {\n this.principal =\n typeof identity.principal === 'string'\n ? [identity.principal]\n : identity.principal;\n this.hasPrincipals = true;\n } else if ('notPrincipal' in identity) {\n this.notPrincipal =\n typeof identity.notPrincipal === 'string'\n ? [identity.notPrincipal]\n : identity.notPrincipal;\n this.hasPrincipals = true;\n }\n }\n\n private checkAndAssignResources(identity: ResourceBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'ResourceBased statement could have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n this.hasResources = true;\n } else if ('notResource' in identity) {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n this.hasResources = true;\n }\n }\n\n private matchPrincipals(\n principal: string,\n principalType?: string,\n context?: Context\n ): boolean {\n if (this.principal) {\n if (this.principal instanceof Array) {\n return principalType\n ? false\n : this.principal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.principal[principalType];\n if (principalValues instanceof Array) {\n return principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return false;\n }\n }\n return true;\n }\n\n private matchNotPrincipals(\n principal: string,\n principalType?: string,\n context?: Context\n ): boolean {\n if (this.notPrincipal) {\n if (this.notPrincipal instanceof Array) {\n return principalType\n ? true\n : !this.notPrincipal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.notPrincipal[principalType];\n if (principalValues instanceof Array) {\n return !principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return !new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return true;\n }\n }\n return true;\n }\n\n private matchActions(action: string, context?: Context): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: Context): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: Context): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: Context): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { ResourceBased };\n","import { MatchConditionInterface, ConditionResolver, Context } from './types';\n\nclass Policy {\n protected context?: Context;\n protected conditionResolver?: ConditionResolver;\n\n constructor({ context, conditionResolver }: MatchConditionInterface) {\n this.context = context;\n this.conditionResolver = conditionResolver;\n }\n\n setContext(this: Policy, context: Context): void {\n this.context = context;\n }\n\n getContext(this: Policy): Context | undefined {\n return this.context;\n }\n\n setConditionResolver(\n this: Policy,\n conditionResolver: ConditionResolver\n ): void {\n this.conditionResolver = conditionResolver;\n }\n\n getConditionResolver(this: Policy): ConditionResolver | undefined {\n return this.conditionResolver;\n }\n}\n\nexport { Policy };\n","import {\n ActionBasedType,\n ConditionResolver,\n Context,\n EvaluateActionBasedInterface,\n ProxyOptions\n} from './types';\nimport { ActionBased } from './ActionBasedStatement';\nimport { Policy } from './Policy';\n\nexport interface ActionBasedPolicyInterface {\n statements: ActionBasedType[];\n conditionResolver?: ConditionResolver;\n context?: Context;\n}\n\nexport class ActionBasedPolicy extends Policy {\n private denyStatements: ActionBased[];\n private allowStatements: ActionBased[];\n private statements: ActionBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ActionBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ActionBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ActionBasedPolicy): ActionBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n const args = { action, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n generateProxy(\n this: ActionBasedPolicy,\n obj: T,\n options: ProxyOptions = {}\n ): T {\n const { get = {}, set = {} } = options;\n const { allow: allowGet = true, propertyMap: propertyMapGet = {} } = get;\n const { allow: allowSet = true, propertyMap: propertyMapSet = {} } = set;\n const handler = {\n ...(allowGet\n ? {\n get: (target: T, prop: U): any => {\n if (prop in target) {\n if (typeof prop === 'string') {\n const property = propertyMapGet[prop] || prop;\n if (this.evaluate({ action: property })) return target[prop];\n throw new Error(`Unauthorize to get ${prop} property`);\n }\n }\n return target[prop];\n }\n }\n : {}),\n ...(allowSet\n ? {\n set: (target: T, prop: U, value: any): boolean => {\n if (typeof prop === 'string') {\n const property = propertyMapSet[prop] || prop;\n if (this.evaluate({ action: property })) {\n target[prop] = value;\n return true;\n } else throw new Error(`Unauthorize to set ${prop} property`);\n }\n return true;\n }\n }\n : {})\n };\n\n return new Proxy(obj, handler);\n }\n}\n","import {\n ConditionResolver,\n Context,\n EvaluateIdentityBasedInterface,\n IdentityBasedType\n} from './types';\nimport { IdentityBased } from './IdentityBasedStatement';\nimport { Policy } from './Policy';\n\ninterface IdentityBasedPolicyInterface {\n statements: IdentityBasedType[];\n conditionResolver?: ConditionResolver;\n context?: Context;\n}\n\nexport class IdentityBasedPolicy extends Policy {\n private denyStatements: IdentityBased[];\n private allowStatements: IdentityBased[];\n private statements: IdentityBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: IdentityBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new IdentityBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: IdentityBasedPolicy): IdentityBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n const args = { action, resource, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n","import {\n ConditionResolver,\n Context,\n EvaluateResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { ResourceBased } from './ResourceBasedStatement';\nimport { Policy } from './Policy';\n\ninterface ResourceBasedPolicyInterface {\n statements: ResourceBasedType[];\n conditionResolver?: ConditionResolver;\n context?: Context;\n}\n\nexport class ResourceBasedPolicy extends Policy {\n private denyStatements: ResourceBased[];\n private allowStatements: ResourceBased[];\n private statements: ResourceBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ResourceBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ResourceBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ResourceBasedPolicy): ResourceBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n const args = { principal, action, resource, principalType, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;SAgBgB,MAAM,CAAC,KAAc;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/C;;AChBA;;;;;;;;;;;;;;;;SAgBgB,QAAQ,CAAC,KAAe;IACtC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,QACE,IAAI,KAAK,QAAQ;SAChB,IAAI,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,EAC5E;AACJ;;ACtBA;AACA,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;AAEvB;;;;;;;;;;;;;;;SAegB,KAAK,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QAChD,OAAO,KAAK,CAAC;KACd;IAED,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;AACpE;;ACxBA;AACA,MAAM,YAAY,GAAG,kDAAkD,CAAC;AACxE,MAAM,aAAa,GAAG,OAAO,C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AAC,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KAC7C;IAED,GAAG,CAED,EACE,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EACwB;QAEjC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KACjC,CAAC,CAAC,OAAO,CAAC;YACR,SAAS;YACT,MAAM;YACN,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAC,CACH,CAAC;KACH;IAED,MAAM,CAEJ,EACE,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EACwB;QAEjC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,KAChC,CAAC,CAAC,OAAO,CAAC;YACR,SAAS;YACT,MAAM;YACN,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAC,CACH,CAAC;KACH;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"main.js","sources":["../src/utils/getTag.ts","../src/utils/isSymbol.ts","../src/utils/toKey.ts","../src/utils/isKey.ts","../src/utils/memoize.ts","../src/utils/memoizeCapped.ts","../src/utils/stringToPath.ts","../src/utils/getValueFromPath.ts","../src/utils/applyContext.ts","../src/utils/decomposeString.ts","../src/Matcher.ts","../src/utils/mersenneTwister.ts","../src/utils/generateUUID.ts","../src/Statement.ts","../src/ActionBasedStatement.ts","../src/IdentityBasedStatement.ts","../src/ResourceBasedStatement.ts","../src/Policy.ts","../src/ActionBasedPolicy.ts","../src/IdentityBasedPolicy.ts","../src/ResourceBasedPolicy.ts"],"sourcesContent":["/**\n * Gets the `toStringTag` of `value`.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n * @example\n * ```javascript\n * getTag(1)\n * // => '[object Number]'\n *\n * getTag(null)\n * // => '[object Null]'\n * ```\n */\nexport function getTag(value: unknown): string {\n return Object.prototype.toString.call(value);\n}\n","import { getTag } from './getTag';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @since 3.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n * ```javascript\n * isSymbol(Symbol())\n * // => true\n *\n * isSymbol('abc')\n * // => false\n * ```\n */\nexport function isSymbol(value?: unknown): value is symbol {\n const type = typeof value;\n return (\n type === 'symbol' ||\n (type === 'object' && value !== null && getTag(value) === '[object Symbol]')\n );\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used as references for various `Number` constants. */\nconst INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n * @example\n *\n * toKey(Symbol.iterator)\n * // => true\n *\n * toKey('abc')\n * // => false\n */\nexport function toKey(value: unknown): string | symbol {\n if (typeof value === 'string' || isSymbol(value)) {\n return value;\n }\n\n return value === 0 && 1 / value === -INFINITY ? '-0' : `${value}`;\n}\n","import { isSymbol } from './isSymbol';\n\n/** Used to match property names within property paths. */\nconst reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\nconst reIsPlainProp = /^\\w*$/; //matches any word character (alphanumeric and underscore)\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @since 3.1.0\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n * @example\n * ```javascript\n * isKey(1)\n * // => true\n *\n * isKey('example[test]')\n * // => false\n *\n * isKey('a.b')\n * // => false\n *\n * const obj = {\n * '[a]': 5,\n * 'b.c': true\n * };\n *\n * isKey('[a]', obj)\n * // => true\n *\n * isKey('b.c', obj)\n * // => true\n * ```\n */\nexport function isKey(value: unknown, object?: T): boolean {\n const type = typeof value;\n if (\n type === 'number' ||\n type === 'boolean' ||\n value === null ||\n value === undefined ||\n isSymbol(value)\n ) {\n return true;\n }\n if (typeof value === 'string') {\n return (\n reIsPlainProp.test(value) ||\n !reIsDeepProp.test(value) ||\n (object !== null && value in Object(object))\n );\n }\n return false;\n}\n","import { MemoizeInterface } from '../types';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * @since 3.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n * ```javascript\n * const object = { 'a': 1, 'b': 2 }\n * const other = { 'c': 3, 'd': 4 }\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(other)\n * // => [3, 4]\n *\n * object.a = 2\n * values(object)\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n * ```\n */\nexport function memoize(\n func: (...args: unknown[]) => any,\n resolver?: (...args: unknown[]) => any\n): MemoizeInterface {\n const memoized = function (\n this: (...args: unknown[]) => any,\n ...args: unknown[]\n ): MemoizeInterface {\n const key = resolver ? resolver.apply(this, args) : args[0];\n const cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = func.apply(this, args);\n cache.set(key, result);\n return result;\n };\n memoized.cache = new Map();\n return memoized;\n}\n\n/*const memoize = (fn: Function): Function => {\n const cache = {};\n return (...args): any => {\n const stringifiedArgs = JSON.stringify(args);\n const result = (cache[stringifiedArgs] =\n typeof cache[stringifiedArgs] === 'undefined'\n ? fn(...args)\n : cache[stringifiedArgs]);\n return result;\n };\n};*/\n","import { memoize } from './memoize';\nimport { MemoizeInterface } from '../types';\n\n/** Used as the maximum memoize cache size. */\nexport const MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @since 3.1.0\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nexport function memoizeCapped(\n func: (...args: any) => unknown\n): MemoizeInterface {\n const result = memoize(func, (key: unknown) => {\n const { cache } = result;\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n return result;\n}\n","import { memoizeCapped } from './memoizeCapped';\n\nconst charCodeOfDot = '.'.charCodeAt(0);\nconst reEscapeChar = /\\\\(\\\\)?/g;\nconst rePropName = RegExp(\n // Match anything that isn't a dot or bracket.\n '[^.[\\\\]]+' +\n '|' +\n // Or match property names within brackets.\n '\\\\[(?:' +\n // Match a non-string expression.\n '([^\"\\'][^[]*)' +\n '|' +\n // Or match strings (supports escaping characters).\n '([\"\\'])((?:(?!\\\\x02)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\x02' +\n ')\\\\]' +\n '|' +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n '(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))',\n 'g'\n);\n\n/**\n * Converts `string` to a property path array.\n *\n * @since 3.1.0\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nexport const stringToPath = memoizeCapped((string: string) => {\n const result = [];\n if (string.charCodeAt(0) === charCodeOfDot) {\n result.push('');\n }\n string.replace(\n rePropName,\n (\n match: string,\n expression: string,\n quote: string,\n subString: string\n ): string => {\n let key = match;\n if (quote) {\n key = subString.replace(reEscapeChar, '$1');\n } else if (expression) {\n key = expression.trim();\n }\n result.push(key);\n return '';\n }\n );\n return result;\n});\n","import { toKey } from './toKey';\nimport { isKey } from './isKey';\nimport { stringToPath } from './stringToPath';\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nexport function castPath(\n value: unknown,\n object: U\n): Array {\n if (Array.isArray(value)) {\n return value;\n }\n\n return isKey(value, object) ? [value] : stringToPath(value);\n}\n\n/**\n * The base implementation of `get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nexport function baseGet(\n object: U,\n path: Array | string\n): any {\n const newPath = castPath(path, object);\n\n let index = 0;\n const length = newPath.length;\n\n let value: any = object;\n while (value instanceof Object && index < length) {\n value = value[toKey(newPath[index++])];\n }\n\n return index && index === length ? value : undefined;\n}\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @since 3.1.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * const object = { 'a': [{ 'b': { 'c': 3 } }] }\n *\n * getValueFromPath(object, 'a[0].b.c')\n * // => 3\n *\n * getValueFromPath(object, ['a', '0', 'b', 'c'])\n * // => 3\n *\n * getValueFromPath(object, 'a.b.c', 'default')\n * // => 'default'\n */\nexport function getValueFromPath(\n object: U,\n path: Array | string,\n defaultValue?: unknown\n): any {\n const result = object === null ? undefined : baseGet(object, path);\n\n return result === undefined ? defaultValue : result;\n}\n","import { getValueFromPath } from './getValueFromPath';\n\nconst reDelimiters = /\\${([^}]*)}/g;\nconst trim = / +(?= )|^\\s+|\\s+$/g;\n\nconst specialTrim = (str: string): string => str.replace(trim, '');\n\n/**\n * Apply the context value in a string.\n *\n * @param {string} str Pattern string, containing context path.\n * @param {object} context Object to get values from path.\n * @returns {string} Returns a string with embedded context values.\n * @example\n * ```javascript\n * const context = {\n * user: { id: 456, bestFriends: [123, 532, 987] }\n * };\n * applyContext('secrets:${user.id}:*', context)\n * // => 'secrets:456:*'\n *\n * applyContext('secrets:${user.bestFriends}:*', context)\n * // => 'secrets:{123,532,987}:*'\n *\n * applyContext('secrets:${company.address}:account', context)\n * // => 'secrets:undefined:account'\n * ```\n */\nexport function applyContext(\n str: string,\n context?: T\n): string {\n if (!context) return str;\n\n return specialTrim(\n str.replace(reDelimiters, (_, path: string) => {\n const value = getValueFromPath(context, path);\n if (Array.isArray(value)) return `{${value}}`;\n if (value instanceof Object) return 'undefined';\n\n return String(value);\n })\n );\n}\n","import { DecomposeString } from '../types';\n\n/**\n * Get index range where separators are found.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {number[]} Returns the beginning and final index for those matches.\n * @example\n * ```javascript\n * getIndexRange('first', 'Second', 'firstAndSecond')\n * // => [0, 8]\n *\n * getIndexRange('First', 'Second', '++FirstAndSecond**')\n * // => [2, 10]\n * ```\n */\nfunction getIndexRange(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): number[] {\n const beginningIndex = str.indexOf(initialSeparator);\n const finalIndex = str.indexOf(finalSeparator, beginningIndex + 1);\n\n if (beginningIndex >= 0 && finalIndex > 0) {\n return [beginningIndex, finalIndex];\n }\n\n return [-1, -1];\n}\n\n/**\n * Object returned by decomposeString function\n *\n * @typedef {Object} DecomposedString\n * @property {number} start Beginning index for first separator match\n * @property {number} end Final index for second separator match\n * @property {string} pre Substring before first separator\n * @property {string} body Substring between separators\n * @property {string} post Substring after second separator\n */\n\n/**\n * Decompose string in pre, body and post strings by using separators.\n *\n * @private\n * @since 3.1.1\n * @param {string} initialSeparator First string to be found.\n * @param {string} finalSeparator Second string to be found.\n * @param {string} str String to be decomposed.\n * @returns {DecomposedString} Returns a decompose string.\n * @example\n * ```javascript\n * decomposeString('first', 'Second', 'firstAndSecond')\n * // => { start: 0, end: 8, pre: '', body: 'And', post: '' }\n *\n * decomposeString('First', 'Second', '++FirstAndSecond**')\n * // => { start: 2, end: 10, pre: '++', body: 'And', post: '**' }\n * ```\n */\nexport function decomposeString(\n initialSeparator: string,\n finalSeparator: string,\n str: string\n): DecomposeString {\n const [beginningIndex, finalIndex] = getIndexRange(\n initialSeparator,\n finalSeparator,\n str\n );\n\n return {\n start: beginningIndex,\n end: finalIndex,\n pre: beginningIndex >= 0 ? str.slice(0, beginningIndex) : '',\n body:\n beginningIndex >= 0\n ? str.slice(beginningIndex + initialSeparator.length, finalIndex)\n : '',\n post:\n beginningIndex >= 0 ? str.slice(finalIndex + finalSeparator.length) : ''\n };\n}\n","import { decomposeString } from './utils/decomposeString';\n\nexport class Matcher {\n private readonly pattern: string;\n private readonly maxLength: number;\n private readonly set: (string | RegExp)[];\n private readonly empty: boolean;\n\n constructor(pattern: string, maxLength = 1024 * 64) {\n this.set = [];\n this.pattern = pattern.trim();\n this.maxLength = maxLength;\n this.empty = !this.pattern ? true : false;\n\n const set = this.braceExpand();\n this.set = set.map((val) => this.parse(val));\n this.set = this.set.filter((s) => {\n return Boolean(s);\n });\n }\n\n match(this: Matcher, str: string): boolean {\n if (this.empty) return str === '';\n\n return this.set.some((pattern) => this.matchOne(str, pattern));\n }\n\n private braceExpand(): string[] {\n const pattern = this.pattern;\n if (!pattern.match(/{.*}/)) {\n return [pattern];\n }\n\n return this.expand(pattern, true);\n }\n\n private parse(pattern: string): string | RegExp {\n if (pattern.length > this.maxLength) {\n throw new TypeError('Pattern is too long');\n }\n let regExp;\n let hasSpecialCharacter = false;\n if (pattern === '') return '';\n\n const re = pattern.replace(/\\*/g, () => {\n hasSpecialCharacter = true;\n return '.+?';\n });\n\n // skip the regexp for non-* patterns\n // unescape anything in it, though, so that it'll be\n // an exact match.\n if (!hasSpecialCharacter) {\n return pattern.replace(/\\\\(.)/g, '$1');\n }\n\n try {\n regExp = new RegExp('^' + re + '$');\n } catch (error) {\n // If it was an invalid regular expression, then it can't match\n // anything.\n return new RegExp('$.');\n }\n\n return regExp;\n }\n\n private expand(str: string, isTop?: boolean): string[] {\n const expansions = [] as string[];\n const balance = decomposeString('{', '}', str);\n if (balance.start < 0 || /\\$$/.test(balance.pre)) return [str];\n\n const parts = balance.body.split(',');\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = balance.pre;\n const postParts = balance.post.length\n ? this.expand(balance.post, false)\n : [''];\n\n parts.forEach((part: string) => {\n postParts.forEach((postPart) => {\n const expansion = pre + part + postPart;\n if (!isTop || expansion) expansions.push(expansion);\n });\n });\n\n return expansions;\n }\n\n private matchOne(str: string, pattern: string | RegExp): boolean {\n if (typeof pattern === 'string') {\n return str === pattern;\n }\n\n return Boolean(str.match(pattern));\n }\n}\n","/*\n https://github.com/banksean wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace\n so it's better encapsulated. Now you can have multiple random number generators\n and they won't stomp all over each other's state.\n If you want to use this as a substitute for Math.random(), use the random()\n method like so:\n var m = new MersenneTwister();\n var randomNumber = m.random();\n You can also call the other genrand_{foo}() methods on the instance.\n If you want to use a specific seed in order to get a repeatable random\n sequence, pass an integer into the constructor:\n var m = new MersenneTwister(123);\n and that will always produce the same random sequence.\n Sean McCullough (banksean@gmail.com)\n*/\n\n/*\n A C-program for MT19937, with initialization improved 2002/1/26.\n Coded by Takuji Nishimura and Makoto Matsumoto.\n Before using, initialize the state by using init_seed(seed)\n or init_by_array(init_key, key_length).\n Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,\n All rights reserved.\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n 3. The names of its contributors may not be used to endorse or promote\n products derived from this software without specific prior written\n permission.\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n Any feedback is very welcome.\n http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)\n*/\n\nexport class MersenneTwister {\n private readonly N: number;\n private readonly M: number;\n private readonly MATRIX_A: number;\n private readonly UPPER_MASK: number;\n private readonly LOWER_MASK: number;\n private readonly mt: number[];\n private mti: number;\n\n constructor(seed?: number | number[]) {\n /* Period parameters */\n this.N = 624;\n this.M = 397;\n this.MATRIX_A = 0x9908b0df; /* constant vector a */\n this.UPPER_MASK = 0x80000000; /* most significant w-r bits */\n this.LOWER_MASK = 0x7fffffff; /* least significant r bits */\n\n this.mt = new Array(this.N); /* the array for the state vector */\n this.mti = this.N + 1; /* mti==N+1 means mt[N] is not initialized */\n\n if (Array.isArray(seed)) {\n if (seed.length > 0) this.initByArray(seed, seed.length);\n } else {\n if (seed === undefined) {\n this.initSeed(new Date().getTime());\n } else {\n this.initSeed(seed);\n }\n }\n }\n\n /* initializes mt[N] with a seed */\n /* origin name init_genrand */\n initSeed(seed: number): void {\n this.mt[0] = seed >>> 0;\n for (this.mti = 1; this.mti < this.N; this.mti++) {\n const s = this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30);\n this.mt[this.mti] =\n ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) +\n (s & 0x0000ffff) * 1812433253 +\n this.mti;\n /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n /* In the previous versions, MSBs of the seed affect */\n /* only MSBs of the array mt[]. */\n /* 2002/01/09 modified by Makoto Matsumoto */\n this.mt[this.mti] >>>= 0;\n /* for >32 bit machines */\n }\n }\n\n /* initialize by an array with array-length */\n /* init_key is the array for initializing keys */\n /* key_length is its length */\n /* slight change for C++, 2004/2/26 */\n initByArray(initKey: number[], keyLength: number): void {\n this.initSeed(19650218);\n let i = 1;\n let j = 0;\n let k = this.N > keyLength ? this.N : keyLength;\n for (; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1664525) << 16) +\n (s & 0x0000ffff) * 1664525)) +\n initKey[j] +\n j; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n j++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n if (j >= keyLength) j = 0;\n }\n for (k = this.N - 1; k; k--) {\n const s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);\n this.mt[i] =\n (this.mt[i] ^\n (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) +\n (s & 0x0000ffff) * 1566083941)) -\n i; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n if (i >= this.N) {\n this.mt[0] = this.mt[this.N - 1];\n i = 1;\n }\n }\n\n this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */\n }\n\n /* generates a random number on [0,0xffffffff]-interval */\n /* origin name genrand_int32 */\n randomInt32(): number {\n let y;\n const mag01 = [0x0, this.MATRIX_A];\n /* mag01[x] = x * MATRIX_A for x=0,1 */\n\n if (this.mti >= this.N) {\n /* generate N words at one time */\n let kk;\n\n if (this.mti === this.N + 1)\n /* if init_seed() has not been called, */\n this.initSeed(5489); /* a default initial seed is used */\n\n for (kk = 0; kk < this.N - this.M; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] = this.mt[kk + this.M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this.N - 1; kk++) {\n y =\n (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);\n this.mt[kk] =\n this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n y =\n (this.mt[this.N - 1] & this.UPPER_MASK) |\n (this.mt[0] & this.LOWER_MASK);\n this.mt[this.N - 1] = this.mt[this.M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this.mti = 0;\n }\n\n y = this.mt[this.mti++];\n\n /* Tempering */\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /* generates a random number on [0,0x7fffffff]-interval */\n /* origin name genrand_int31 */\n randomInt31(): number {\n return this.randomInt32() >>> 1;\n }\n\n /* generates a random number on [0,1]-real-interval */\n /* origin name genrand_real1 */\n randomReal1(): number {\n return this.randomInt32() * (1.0 / 4294967295.0);\n /* divided by 2^32-1 */\n }\n\n /* generates a random number on [0,1)-real-interval */\n /* origin name genrand_real2 */\n randomReal2(): number {\n return this.randomInt32() * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on (0,1)-real-interval */\n /* origin name genrand_real3 */\n randomReal3(): number {\n return (this.randomInt32() + 0.5) * (1.0 / 4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on [0,1) with 53-bit resolution*/\n /* origin name genrand_res53 */\n randomRes53(): number {\n const a = this.randomInt32() >>> 5;\n const b = this.randomInt32() >>> 6;\n return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);\n }\n}\n\n/* These real versions are due to Isaku Wada, 2002/01/09 added */\n","import { MersenneTwister } from './mersenneTwister';\n\nconst replacePlaceholders = (mersenne: MersenneTwister) => (\n placeholder: string\n): string => {\n const random = Math.floor(mersenne.randomReal2() * 16);\n\n const value = placeholder === 'x' ? random : (random & 0x3) | 0x8;\n return value.toString(16);\n};\n\n/**\n * Generate a uuid.\n *\n * @private\n * @since 3.5.0\n * @returns {string} Returns the generated uuid.\n * @example\n * ```javascript\n * generateUUID()\n * // => 49e71c40-9b21-4371-9699-2def33f62e66\n *\n * generateUUID()\n * // => da94f128-4247-48e3-bc73-d0cae46b5093\n * ```\n */\nexport function generateUUID(): string {\n const mersenne = new MersenneTwister();\n const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\n return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders(mersenne));\n}\n","import {\n EffectBlock,\n ConditionBlock,\n StatementInterface,\n MatchConditionInterface\n} from './types';\nimport { getValueFromPath } from './utils/getValueFromPath';\nimport { generateUUID } from './utils/generateUUID';\n\nabstract class Statement {\n protected sid: string;\n protected readonly condition?: ConditionBlock;\n effect: EffectBlock;\n\n constructor({ sid, effect = 'allow', condition }: StatementInterface) {\n if (!sid) {\n this.sid = generateUUID();\n } else {\n this.sid = sid;\n }\n this.effect = effect;\n this.condition = condition;\n }\n\n matchConditions(\n this: Statement,\n { context, conditionResolver }: MatchConditionInterface\n ): boolean {\n const { condition: conditions } = this;\n return conditionResolver && conditions && context\n ? Object.keys(conditions).every((condition) =>\n Object.keys(conditions[condition]).every((path) => {\n const conditionValues = conditions[condition][path];\n if (conditionValues instanceof Array) {\n return conditionValues.some((value) =>\n conditionResolver[condition](\n getValueFromPath(context, path),\n value\n )\n );\n }\n return conditionResolver[condition](\n getValueFromPath(context, path),\n conditionValues\n );\n })\n )\n : true;\n }\n}\n\nexport { Statement };\n","import { ActionBasedType, MatchActionBasedInterface } from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ActionBased extends Statement {\n private action?: string[];\n private notAction?: string[];\n private statement: ActionBasedType;\n\n constructor(action: ActionBasedType) {\n super(action);\n this.checkAndAssignActions(action);\n this.statement = { ...action, sid: this.sid };\n }\n\n getStatement(this: ActionBased): ActionBasedType {\n return this.statement;\n }\n\n matches(\n this: ActionBased,\n { action, context, conditionResolver }: MatchActionBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(action: ActionBasedType): void {\n const hasAction = 'action' in action;\n const hasNotAction = 'notAction' in action;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ActionBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in action) {\n this.action =\n typeof action.action === 'string' ? [action.action] : action.action;\n } else {\n this.notAction =\n typeof action.notAction === 'string'\n ? [action.notAction]\n : action.notAction;\n }\n }\n\n private matchActions(action: string, context?: T): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: T): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n}\n\nexport { ActionBased };\n","import { IdentityBasedType, MatchIdentityBasedInterface } from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass IdentityBased extends Statement {\n private resource?: string[];\n private action?: string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: IdentityBasedType;\n\n constructor(identity: IdentityBasedType) {\n super(identity);\n this.checkAndAssignActions(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: IdentityBased): IdentityBasedType {\n return this.statement;\n }\n\n matches(\n this: IdentityBased,\n {\n action,\n resource,\n context,\n conditionResolver\n }: MatchIdentityBasedInterface\n ): boolean {\n return (\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n private checkAndAssignActions(identity: IdentityBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'IdentityBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignResources(identity: IdentityBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'IdentityBased statement should have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n } else {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n }\n }\n\n private matchActions(action: string, context?: T): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: T): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: T): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: T): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { IdentityBased };\n","import {\n PrincipalMap,\n MatchResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { Matcher } from './Matcher';\nimport { Statement } from './Statement';\nimport { applyContext } from './utils/applyContext';\n\nclass ResourceBased extends Statement {\n private principal?: PrincipalMap | string[];\n private resource?: string[];\n private action?: string[];\n private notPrincipal?: PrincipalMap | string[];\n private notResource?: string[];\n private notAction?: string[];\n private statement: ResourceBasedType;\n private hasPrincipals: boolean;\n private hasResources: boolean;\n\n constructor(identity: ResourceBasedType) {\n super(identity);\n this.hasPrincipals = false;\n this.hasResources = false;\n this.checkAndAssignActions(identity);\n this.checkAndAssignPrincipals(identity);\n this.checkAndAssignResources(identity);\n this.statement = { ...identity, sid: this.sid };\n }\n\n getStatement(this: ResourceBased): ResourceBasedType {\n return this.statement;\n }\n\n matches(\n this: ResourceBased,\n {\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver\n }: MatchResourceBasedInterface\n ): boolean {\n return (\n this.matchPrincipalAndNotPrincipal(principal, principalType, context) &&\n this.matchActions(action, context) &&\n this.matchNotActions(action, context) &&\n this.matchResourceAndNotResource(resource, context) &&\n this.matchConditions({ context, conditionResolver })\n );\n }\n\n /*valueComing principal noPrincipal\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchPrincipalAndNotPrincipal(\n principal?: string,\n principalType?: string,\n context?: T\n ): boolean {\n if (principal) {\n if (this.hasPrincipals)\n return (\n this.matchPrincipals(principal, principalType, context) &&\n this.matchNotPrincipals(principal, principalType, context)\n );\n return false;\n }\n if (this.hasPrincipals) return false;\n return true;\n }\n\n /*valueComing resource noResource\n true false false false\n true true false true or false\n true false true true or false\n false false false true\n false true false false\n false false true false*/\n private matchResourceAndNotResource(resource?: string, context?: T): boolean {\n if (resource) {\n if (this.hasResources)\n return (\n this.matchResources(resource, context) &&\n this.matchNotResources(resource, context)\n );\n return false;\n }\n if (this.hasResources) return false;\n return true;\n }\n\n private checkAndAssignActions(identity: ResourceBasedType): void {\n const hasAction = 'action' in identity;\n const hasNotAction = 'notAction' in identity;\n if (hasAction && hasNotAction) {\n throw new TypeError(\n 'ResourceBased statement should have an action or a notAction attribute, no both'\n );\n }\n if ('action' in identity) {\n this.action =\n typeof identity.action === 'string'\n ? [identity.action]\n : identity.action;\n } else {\n this.notAction =\n typeof identity.notAction === 'string'\n ? [identity.notAction]\n : identity.notAction;\n }\n }\n\n private checkAndAssignPrincipals(identity: ResourceBasedType): void {\n const hasPrincipal = 'principal' in identity;\n const hasNotPrincipal = 'notPrincipal' in identity;\n if (hasPrincipal && hasNotPrincipal) {\n throw new TypeError(\n 'ResourceBased statement could have a principal or a notPrincipal attribute, no both'\n );\n }\n if ('principal' in identity) {\n this.principal =\n typeof identity.principal === 'string'\n ? [identity.principal]\n : identity.principal;\n this.hasPrincipals = true;\n } else if ('notPrincipal' in identity) {\n this.notPrincipal =\n typeof identity.notPrincipal === 'string'\n ? [identity.notPrincipal]\n : identity.notPrincipal;\n this.hasPrincipals = true;\n }\n }\n\n private checkAndAssignResources(identity: ResourceBasedType): void {\n const hasResource = 'resource' in identity;\n const hasNotResource = 'notResource' in identity;\n if (hasResource && hasNotResource) {\n throw new TypeError(\n 'ResourceBased statement could have a resource or a notResource attribute, no both'\n );\n }\n if ('resource' in identity) {\n this.resource =\n typeof identity.resource === 'string'\n ? [identity.resource]\n : identity.resource;\n this.hasResources = true;\n } else if ('notResource' in identity) {\n this.notResource =\n typeof identity.notResource === 'string'\n ? [identity.notResource]\n : identity.notResource;\n this.hasResources = true;\n }\n }\n\n private matchPrincipals(\n principal: string,\n principalType?: string,\n context?: T\n ): boolean {\n if (this.principal) {\n if (this.principal instanceof Array) {\n return principalType\n ? false\n : this.principal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.principal[principalType];\n if (principalValues instanceof Array) {\n return principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return false;\n }\n }\n return true;\n }\n\n private matchNotPrincipals(\n principal: string,\n principalType?: string,\n context?: T\n ): boolean {\n if (this.notPrincipal) {\n if (this.notPrincipal instanceof Array) {\n return principalType\n ? true\n : !this.notPrincipal.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n } else {\n if (principalType) {\n const principalValues = this.notPrincipal[principalType];\n if (principalValues instanceof Array) {\n return !principalValues.some((a) =>\n new Matcher(applyContext(a, context)).match(principal)\n );\n }\n return !new Matcher(applyContext(principalValues, context)).match(\n principal\n );\n }\n return true;\n }\n }\n return true;\n }\n\n private matchActions(action: string, context?: T): boolean {\n return this.action\n ? this.action.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchNotActions(action: string, context?: T): boolean {\n return this.notAction\n ? !this.notAction.some((a) =>\n new Matcher(applyContext(a, context)).match(action)\n )\n : true;\n }\n\n private matchResources(resource: string, context?: T): boolean {\n return this.resource\n ? this.resource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n\n private matchNotResources(resource: string, context?: T): boolean {\n return this.notResource\n ? !this.notResource.some((a) =>\n new Matcher(applyContext(a, context)).match(resource)\n )\n : true;\n }\n}\n\nexport { ResourceBased };\n","import { MatchConditionInterface, ConditionResolver } from './types';\n\nclass Policy {\n protected context?: T;\n protected conditionResolver?: ConditionResolver;\n\n constructor({ context, conditionResolver }: MatchConditionInterface) {\n this.context = context;\n this.conditionResolver = conditionResolver;\n }\n\n setContext(this: Policy, context: T): void {\n this.context = context;\n }\n\n getContext(this: Policy): T | undefined {\n return this.context;\n }\n\n setConditionResolver(\n this: Policy,\n conditionResolver: ConditionResolver\n ): void {\n this.conditionResolver = conditionResolver;\n }\n\n getConditionResolver(this: Policy): ConditionResolver | undefined {\n return this.conditionResolver;\n }\n}\n\nexport { Policy };\n","import {\n ActionBasedType,\n ConditionResolver,\n EvaluateActionBasedInterface,\n ProxyOptions\n} from './types';\nimport { ActionBased } from './ActionBasedStatement';\nimport { Policy } from './Policy';\n\nexport interface ActionBasedPolicyInterface {\n statements: ActionBasedType[];\n conditionResolver?: ConditionResolver;\n context?: T;\n}\n\nexport class ActionBasedPolicy extends Policy {\n private denyStatements: ActionBased[];\n private allowStatements: ActionBased[];\n private statements: ActionBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ActionBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ActionBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ActionBasedPolicy): ActionBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n const args = { action, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ActionBasedPolicy,\n { action, context }: EvaluateActionBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n context: context || this.context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n generateProxy(\n this: ActionBasedPolicy,\n obj: U,\n options: ProxyOptions = {}\n ): U {\n const { get = {}, set = {} } = options;\n const { allow: allowGet = true, propertyMap: propertyMapGet = {} } = get;\n const { allow: allowSet = true, propertyMap: propertyMapSet = {} } = set;\n const handler = {\n ...(allowGet\n ? {\n get: (target: U, prop: W): any => {\n if (prop in target) {\n if (typeof prop === 'string') {\n const property = propertyMapGet[prop] || prop;\n if (this.evaluate({ action: property })) return target[prop];\n throw new Error(`Unauthorize to get ${prop} property`);\n }\n }\n return target[prop];\n }\n }\n : {}),\n ...(allowSet\n ? {\n set: (target: U, prop: W, value: any): boolean => {\n if (typeof prop === 'string') {\n const property = propertyMapSet[prop] || prop;\n if (this.evaluate({ action: property })) {\n target[prop] = value;\n return true;\n } else throw new Error(`Unauthorize to set ${prop} property`);\n }\n return true;\n }\n }\n : {})\n };\n\n return new Proxy(obj, handler);\n }\n}\n","import {\n ConditionResolver,\n EvaluateIdentityBasedInterface,\n IdentityBasedType\n} from './types';\nimport { IdentityBased } from './IdentityBasedStatement';\nimport { Policy } from './Policy';\n\ninterface IdentityBasedPolicyInterface {\n statements: IdentityBasedType[];\n conditionResolver?: ConditionResolver;\n context?: T;\n}\n\nexport class IdentityBasedPolicy extends Policy {\n private denyStatements: IdentityBased[];\n private allowStatements: IdentityBased[];\n private statements: IdentityBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: IdentityBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new IdentityBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: IdentityBasedPolicy): IdentityBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n const args = { action, resource, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: IdentityBasedPolicy,\n { action, resource, context }: EvaluateIdentityBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n action,\n resource,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n","import {\n ConditionResolver,\n EvaluateResourceBasedInterface,\n ResourceBasedType\n} from './types';\nimport { ResourceBased } from './ResourceBasedStatement';\nimport { Policy } from './Policy';\n\ninterface ResourceBasedPolicyInterface {\n statements: ResourceBasedType[];\n conditionResolver?: ConditionResolver;\n context?: T;\n}\n\nexport class ResourceBasedPolicy extends Policy {\n private denyStatements: ResourceBased[];\n private allowStatements: ResourceBased[];\n private statements: ResourceBasedType[];\n\n constructor({\n statements,\n conditionResolver,\n context\n }: ResourceBasedPolicyInterface) {\n super({ context, conditionResolver });\n const statementInstances = statements.map(\n (statement) => new ResourceBased(statement)\n );\n this.allowStatements = statementInstances.filter(\n (s) => s.effect === 'allow'\n );\n this.denyStatements = statementInstances.filter((s) => s.effect === 'deny');\n this.statements = statementInstances.map((statement) =>\n statement.getStatement()\n );\n }\n\n getStatements(this: ResourceBasedPolicy): ResourceBasedType[] {\n return this.statements;\n }\n\n evaluate(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n const args = { principal, action, resource, principalType, context };\n return !this.cannot(args) && this.can(args);\n }\n\n can(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.allowStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n\n cannot(\n this: ResourceBasedPolicy,\n {\n principal,\n action,\n resource,\n principalType,\n context\n }: EvaluateResourceBasedInterface\n ): boolean {\n return this.denyStatements.some((s) =>\n s.matches({\n principal,\n action,\n resource,\n principalType,\n context,\n conditionResolver: this.conditionResolver\n })\n );\n }\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;SAgBgB,MAAM,CAAC,KAAc;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/C;;AChBA;;;;;;;;;;;;;;;;SAgBgB,QAAQ,CAAC,KAAe;IACtC,MAAM,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 No newline at end of file diff --git a/src/ActionBasedPolicy.test.ts b/src/ActionBasedPolicy.test.ts index 79301f1..1d416d5 100644 --- a/src/ActionBasedPolicy.test.ts +++ b/src/ActionBasedPolicy.test.ts @@ -145,6 +145,13 @@ describe('ActionBasedPolicy Class', () => { describe('when match based on conditions', () => { it('returns true or false', () => { + class User { + constructor(public info = { id: 456, age: 19 }) {} + get user() { + return this.info; + } + } + const conditionResolver = { greaterThan: (data: number, expected: number): boolean => { return data > expected; @@ -183,7 +190,7 @@ describe('ActionBasedPolicy Class', () => { expect( policy.evaluate({ action: 'write', - context: { user: { id: 456, age: 19 } } + context: new User() }) ).toBe(true); }); diff --git a/src/ActionBasedPolicy.ts b/src/ActionBasedPolicy.ts index eb2e52f..bc36bd1 100644 --- a/src/ActionBasedPolicy.ts +++ b/src/ActionBasedPolicy.ts @@ -1,29 +1,28 @@ import { ActionBasedType, ConditionResolver, - Context, EvaluateActionBasedInterface, ProxyOptions } from './types'; import { ActionBased } from './ActionBasedStatement'; import { Policy } from './Policy'; -export interface ActionBasedPolicyInterface { +export interface ActionBasedPolicyInterface { statements: ActionBasedType[]; conditionResolver?: ConditionResolver; - context?: Context; + context?: T; } -export class ActionBasedPolicy extends Policy { - private denyStatements: ActionBased[]; - private allowStatements: ActionBased[]; +export class ActionBasedPolicy extends Policy { + private denyStatements: ActionBased[]; + private allowStatements: ActionBased[]; private statements: ActionBasedType[]; constructor({ statements, conditionResolver, context - }: ActionBasedPolicyInterface) { + }: ActionBasedPolicyInterface) { super({ context, conditionResolver }); const statementInstances = statements.map( (statement) => new ActionBased(statement) @@ -37,21 +36,21 @@ export class ActionBasedPolicy extends Policy { ); } - getStatements(this: ActionBasedPolicy): ActionBasedType[] { + getStatements(this: ActionBasedPolicy): ActionBasedType[] { return this.statements; } evaluate( - this: ActionBasedPolicy, - { action, context }: EvaluateActionBasedInterface + this: ActionBasedPolicy, + { action, context }: EvaluateActionBasedInterface ): boolean { const args = { action, context }; return !this.cannot(args) && this.can(args); } can( - this: ActionBasedPolicy, - { action, context }: EvaluateActionBasedInterface + this: ActionBasedPolicy, + { action, context }: EvaluateActionBasedInterface ): boolean { return this.allowStatements.some((s) => s.matches({ @@ -63,8 +62,8 @@ export class ActionBasedPolicy extends Policy { } cannot( - this: ActionBasedPolicy, - { action, context }: EvaluateActionBasedInterface + this: ActionBasedPolicy, + { action, context }: EvaluateActionBasedInterface ): boolean { return this.denyStatements.some((s) => s.matches({ @@ -75,18 +74,18 @@ export class ActionBasedPolicy extends Policy { ); } - generateProxy( - this: ActionBasedPolicy, - obj: T, + generateProxy( + this: ActionBasedPolicy, + obj: U, options: ProxyOptions = {} - ): T { + ): U { const { get = {}, set = {} } = options; const { allow: allowGet = true, propertyMap: propertyMapGet = {} } = get; const { allow: allowSet = true, propertyMap: propertyMapSet = {} } = set; const handler = { ...(allowGet ? { - get: (target: T, prop: U): any => { + get: (target: U, prop: W): any => { if (prop in target) { if (typeof prop === 'string') { const property = propertyMapGet[prop] || prop; @@ -100,7 +99,7 @@ export class ActionBasedPolicy extends Policy { : {}), ...(allowSet ? { - set: (target: T, prop: U, value: any): boolean => { + set: (target: U, prop: W, value: any): boolean => { if (typeof prop === 'string') { const property = propertyMapSet[prop] || prop; if (this.evaluate({ action: property })) { diff --git a/src/ActionBasedStatement.ts b/src/ActionBasedStatement.ts index ad31a2e..c777ff6 100644 --- a/src/ActionBasedStatement.ts +++ b/src/ActionBasedStatement.ts @@ -1,9 +1,9 @@ -import { ActionBasedType, Context, MatchActionBasedInterface } from './types'; +import { ActionBasedType, MatchActionBasedInterface } from './types'; import { Matcher } from './Matcher'; import { Statement } from './Statement'; import { applyContext } from './utils/applyContext'; -class ActionBased extends Statement { +class ActionBased extends Statement { private action?: string[]; private notAction?: string[]; private statement: ActionBasedType; @@ -14,13 +14,13 @@ class ActionBased extends Statement { this.statement = { ...action, sid: this.sid }; } - getStatement(this: ActionBased): ActionBasedType { + getStatement(this: ActionBased): ActionBasedType { return this.statement; } matches( - this: ActionBased, - { action, context, conditionResolver }: MatchActionBasedInterface + this: ActionBased, + { action, context, conditionResolver }: MatchActionBasedInterface ): boolean { return ( this.matchActions(action, context) && @@ -48,7 +48,7 @@ class ActionBased extends Statement { } } - private matchActions(action: string, context?: Context): boolean { + private matchActions(action: string, context?: T): boolean { return this.action ? this.action.some((a) => new Matcher(applyContext(a, context)).match(action) @@ -56,7 +56,7 @@ class ActionBased extends Statement { : true; } - private matchNotActions(action: string, context?: Context): boolean { + private matchNotActions(action: string, context?: T): boolean { return this.notAction ? !this.notAction.some((a) => new Matcher(applyContext(a, context)).match(action) diff --git a/src/IdentityBasedPolicy.ts b/src/IdentityBasedPolicy.ts index b00d075..5d84410 100644 --- a/src/IdentityBasedPolicy.ts +++ b/src/IdentityBasedPolicy.ts @@ -1,28 +1,27 @@ import { ConditionResolver, - Context, EvaluateIdentityBasedInterface, IdentityBasedType } from './types'; import { IdentityBased } from './IdentityBasedStatement'; import { Policy } from './Policy'; -interface IdentityBasedPolicyInterface { +interface IdentityBasedPolicyInterface { statements: IdentityBasedType[]; conditionResolver?: ConditionResolver; - context?: Context; + context?: T; } -export class IdentityBasedPolicy extends Policy { - private denyStatements: IdentityBased[]; - private allowStatements: IdentityBased[]; +export class IdentityBasedPolicy extends Policy { + private denyStatements: IdentityBased[]; + private allowStatements: IdentityBased[]; private statements: IdentityBasedType[]; constructor({ statements, conditionResolver, context - }: IdentityBasedPolicyInterface) { + }: IdentityBasedPolicyInterface) { super({ context, conditionResolver }); const statementInstances = statements.map( (statement) => new IdentityBased(statement) @@ -36,21 +35,21 @@ export class IdentityBasedPolicy extends Policy { ); } - getStatements(this: IdentityBasedPolicy): IdentityBasedType[] { + getStatements(this: IdentityBasedPolicy): IdentityBasedType[] { return this.statements; } evaluate( - this: IdentityBasedPolicy, - { action, resource, context }: EvaluateIdentityBasedInterface + this: IdentityBasedPolicy, + { action, resource, context }: EvaluateIdentityBasedInterface ): boolean { const args = { action, resource, context }; return !this.cannot(args) && this.can(args); } can( - this: IdentityBasedPolicy, - { action, resource, context }: EvaluateIdentityBasedInterface + this: IdentityBasedPolicy, + { action, resource, context }: EvaluateIdentityBasedInterface ): boolean { return this.allowStatements.some((s) => s.matches({ @@ -63,8 +62,8 @@ export class IdentityBasedPolicy extends Policy { } cannot( - this: IdentityBasedPolicy, - { action, resource, context }: EvaluateIdentityBasedInterface + this: IdentityBasedPolicy, + { action, resource, context }: EvaluateIdentityBasedInterface ): boolean { return this.denyStatements.some((s) => s.matches({ diff --git a/src/IdentityBasedStatement.ts b/src/IdentityBasedStatement.ts index 825d093..24fed64 100644 --- a/src/IdentityBasedStatement.ts +++ b/src/IdentityBasedStatement.ts @@ -1,13 +1,9 @@ -import { - Context, - IdentityBasedType, - MatchIdentityBasedInterface -} from './types'; +import { IdentityBasedType, MatchIdentityBasedInterface } from './types'; import { Matcher } from './Matcher'; import { Statement } from './Statement'; import { applyContext } from './utils/applyContext'; -class IdentityBased extends Statement { +class IdentityBased extends Statement { private resource?: string[]; private action?: string[]; private notResource?: string[]; @@ -21,18 +17,18 @@ class IdentityBased extends Statement { this.statement = { ...identity, sid: this.sid }; } - getStatement(this: IdentityBased): IdentityBasedType { + getStatement(this: IdentityBased): IdentityBasedType { return this.statement; } matches( - this: IdentityBased, + this: IdentityBased, { action, resource, context, conditionResolver - }: MatchIdentityBasedInterface + }: MatchIdentityBasedInterface ): boolean { return ( this.matchActions(action, context) && @@ -85,7 +81,7 @@ class IdentityBased extends Statement { } } - private matchActions(action: string, context?: Context): boolean { + private matchActions(action: string, context?: T): boolean { return this.action ? this.action.some((a) => new Matcher(applyContext(a, context)).match(action) @@ -93,7 +89,7 @@ class IdentityBased extends Statement { : true; } - private matchNotActions(action: string, context?: Context): boolean { + private matchNotActions(action: string, context?: T): boolean { return this.notAction ? !this.notAction.some((a) => new Matcher(applyContext(a, context)).match(action) @@ -101,7 +97,7 @@ class IdentityBased extends Statement { : true; } - private matchResources(resource: string, context?: Context): boolean { + private matchResources(resource: string, context?: T): boolean { return this.resource ? this.resource.some((a) => new Matcher(applyContext(a, context)).match(resource) @@ -109,7 +105,7 @@ class IdentityBased extends Statement { : true; } - private matchNotResources(resource: string, context?: Context): boolean { + private matchNotResources(resource: string, context?: T): boolean { return this.notResource ? !this.notResource.some((a) => new Matcher(applyContext(a, context)).match(resource) diff --git a/src/Policy.ts b/src/Policy.ts index 14e39b5..d98aab6 100644 --- a/src/Policy.ts +++ b/src/Policy.ts @@ -1,30 +1,30 @@ -import { MatchConditionInterface, ConditionResolver, Context } from './types'; +import { MatchConditionInterface, ConditionResolver } from './types'; -class Policy { - protected context?: Context; +class Policy { + protected context?: T; protected conditionResolver?: ConditionResolver; - constructor({ context, conditionResolver }: MatchConditionInterface) { + constructor({ context, conditionResolver }: MatchConditionInterface) { this.context = context; this.conditionResolver = conditionResolver; } - setContext(this: Policy, context: Context): void { + setContext(this: Policy, context: T): void { this.context = context; } - getContext(this: Policy): Context | undefined { + getContext(this: Policy): T | undefined { return this.context; } setConditionResolver( - this: Policy, + this: Policy, conditionResolver: ConditionResolver ): void { this.conditionResolver = conditionResolver; } - getConditionResolver(this: Policy): ConditionResolver | undefined { + getConditionResolver(this: Policy): ConditionResolver | undefined { return this.conditionResolver; } } diff --git a/src/ResourceBasedPolicy.ts b/src/ResourceBasedPolicy.ts index 8d9b02f..3793053 100644 --- a/src/ResourceBasedPolicy.ts +++ b/src/ResourceBasedPolicy.ts @@ -1,28 +1,27 @@ import { ConditionResolver, - Context, EvaluateResourceBasedInterface, ResourceBasedType } from './types'; import { ResourceBased } from './ResourceBasedStatement'; import { Policy } from './Policy'; -interface ResourceBasedPolicyInterface { +interface ResourceBasedPolicyInterface { statements: ResourceBasedType[]; conditionResolver?: ConditionResolver; - context?: Context; + context?: T; } -export class ResourceBasedPolicy extends Policy { - private denyStatements: ResourceBased[]; - private allowStatements: ResourceBased[]; +export class ResourceBasedPolicy extends Policy { + private denyStatements: ResourceBased[]; + private allowStatements: ResourceBased[]; private statements: ResourceBasedType[]; constructor({ statements, conditionResolver, context - }: ResourceBasedPolicyInterface) { + }: ResourceBasedPolicyInterface) { super({ context, conditionResolver }); const statementInstances = statements.map( (statement) => new ResourceBased(statement) @@ -36,33 +35,33 @@ export class ResourceBasedPolicy extends Policy { ); } - getStatements(this: ResourceBasedPolicy): ResourceBasedType[] { + getStatements(this: ResourceBasedPolicy): ResourceBasedType[] { return this.statements; } evaluate( - this: ResourceBasedPolicy, + this: ResourceBasedPolicy, { principal, action, resource, principalType, context - }: EvaluateResourceBasedInterface + }: EvaluateResourceBasedInterface ): boolean { const args = { principal, action, resource, principalType, context }; return !this.cannot(args) && this.can(args); } can( - this: ResourceBasedPolicy, + this: ResourceBasedPolicy, { principal, action, resource, principalType, context - }: EvaluateResourceBasedInterface + }: EvaluateResourceBasedInterface ): boolean { return this.allowStatements.some((s) => s.matches({ @@ -77,14 +76,14 @@ export class ResourceBasedPolicy extends Policy { } cannot( - this: ResourceBasedPolicy, + this: ResourceBasedPolicy, { principal, action, resource, principalType, context - }: EvaluateResourceBasedInterface + }: EvaluateResourceBasedInterface ): boolean { return this.denyStatements.some((s) => s.matches({ diff --git a/src/ResourceBasedStatement.ts b/src/ResourceBasedStatement.ts index becf3d1..0073c4d 100644 --- a/src/ResourceBasedStatement.ts +++ b/src/ResourceBasedStatement.ts @@ -1,6 +1,5 @@ import { PrincipalMap, - Context, MatchResourceBasedInterface, ResourceBasedType } from './types'; @@ -8,7 +7,7 @@ import { Matcher } from './Matcher'; import { Statement } from './Statement'; import { applyContext } from './utils/applyContext'; -class ResourceBased extends Statement { +class ResourceBased extends Statement { private principal?: PrincipalMap | string[]; private resource?: string[]; private action?: string[]; @@ -29,12 +28,12 @@ class ResourceBased extends Statement { this.statement = { ...identity, sid: this.sid }; } - getStatement(this: ResourceBased): ResourceBasedType { + getStatement(this: ResourceBased): ResourceBasedType { return this.statement; } matches( - this: ResourceBased, + this: ResourceBased, { principal, action, @@ -42,7 +41,7 @@ class ResourceBased extends Statement { principalType, context, conditionResolver - }: MatchResourceBasedInterface + }: MatchResourceBasedInterface ): boolean { return ( this.matchPrincipalAndNotPrincipal(principal, principalType, context) && @@ -63,7 +62,7 @@ class ResourceBased extends Statement { private matchPrincipalAndNotPrincipal( principal?: string, principalType?: string, - context?: Context + context?: T ): boolean { if (principal) { if (this.hasPrincipals) @@ -84,10 +83,7 @@ class ResourceBased extends Statement { false false false true false true false false false false true false*/ - private matchResourceAndNotResource( - resource?: string, - context?: Context - ): boolean { + private matchResourceAndNotResource(resource?: string, context?: T): boolean { if (resource) { if (this.hasResources) return ( @@ -170,7 +166,7 @@ class ResourceBased extends Statement { private matchPrincipals( principal: string, principalType?: string, - context?: Context + context?: T ): boolean { if (this.principal) { if (this.principal instanceof Array) { @@ -200,7 +196,7 @@ class ResourceBased extends Statement { private matchNotPrincipals( principal: string, principalType?: string, - context?: Context + context?: T ): boolean { if (this.notPrincipal) { if (this.notPrincipal instanceof Array) { @@ -227,7 +223,7 @@ class ResourceBased extends Statement { return true; } - private matchActions(action: string, context?: Context): boolean { + private matchActions(action: string, context?: T): boolean { return this.action ? this.action.some((a) => new Matcher(applyContext(a, context)).match(action) @@ -235,7 +231,7 @@ class ResourceBased extends Statement { : true; } - private matchNotActions(action: string, context?: Context): boolean { + private matchNotActions(action: string, context?: T): boolean { return this.notAction ? !this.notAction.some((a) => new Matcher(applyContext(a, context)).match(action) @@ -243,7 +239,7 @@ class ResourceBased extends Statement { : true; } - private matchResources(resource: string, context?: Context): boolean { + private matchResources(resource: string, context?: T): boolean { return this.resource ? this.resource.some((a) => new Matcher(applyContext(a, context)).match(resource) @@ -251,7 +247,7 @@ class ResourceBased extends Statement { : true; } - private matchNotResources(resource: string, context?: Context): boolean { + private matchNotResources(resource: string, context?: T): boolean { return this.notResource ? !this.notResource.some((a) => new Matcher(applyContext(a, context)).match(resource) diff --git a/src/Statement.ts b/src/Statement.ts index ed8a1ef..747ea90 100644 --- a/src/Statement.ts +++ b/src/Statement.ts @@ -7,7 +7,7 @@ import { import { getValueFromPath } from './utils/getValueFromPath'; import { generateUUID } from './utils/generateUUID'; -abstract class Statement { +abstract class Statement { protected sid: string; protected readonly condition?: ConditionBlock; effect: EffectBlock; @@ -23,8 +23,8 @@ abstract class Statement { } matchConditions( - this: Statement, - { context, conditionResolver }: MatchConditionInterface + this: Statement, + { context, conditionResolver }: MatchConditionInterface ): boolean { const { condition: conditions } = this; return conditionResolver && conditions && context diff --git a/src/types.ts b/src/types.ts index 995a348..34c3cc0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -39,17 +39,11 @@ interface OptionalNotResourceBlock { export type ConditionKey = string | number | boolean; -export interface Context { - [key: string]: ConditionKey | Context | string[] | number[]; -} - export interface ConditionMap { [key: string]: ConditionKey[] | ConditionKey; } -export interface ConditionBlock { - [key: string]: ConditionMap; -} +export type ConditionBlock = Record>; export interface StatementInterface { sid?: string; @@ -71,37 +65,40 @@ export interface ConditionResolver { [key: string]: Resolver; } -export interface MatchConditionInterface { - context?: Context; +export interface MatchConditionInterface { + context?: T; conditionResolver?: ConditionResolver; } -export interface MatchActionBasedInterface extends MatchConditionInterface { +export interface MatchActionBasedInterface + extends MatchConditionInterface { action: string; } -export interface MatchIdentityBasedInterface extends MatchActionBasedInterface { +export interface MatchIdentityBasedInterface + extends MatchActionBasedInterface { resource: string; } -export interface MatchResourceBasedInterface extends MatchActionBasedInterface { +export interface MatchResourceBasedInterface + extends MatchActionBasedInterface { principal?: string; principalType?: string; resource?: string; } -export interface EvaluateActionBasedInterface { +export interface EvaluateActionBasedInterface { action: string; - context?: Context; + context?: T; } -export interface EvaluateIdentityBasedInterface - extends EvaluateActionBasedInterface { +export interface EvaluateIdentityBasedInterface + extends EvaluateActionBasedInterface { resource: string; } -export interface EvaluateResourceBasedInterface - extends EvaluateActionBasedInterface { +export interface EvaluateResourceBasedInterface + extends EvaluateActionBasedInterface { principal?: string; principalType?: string; resource?: string; diff --git a/src/utils/applyContext.ts b/src/utils/applyContext.ts index 7f7f704..bf95894 100644 --- a/src/utils/applyContext.ts +++ b/src/utils/applyContext.ts @@ -1,4 +1,3 @@ -import { Context } from '../types'; import { getValueFromPath } from './getValueFromPath'; const reDelimiters = /\${([^}]*)}/g; @@ -27,7 +26,10 @@ const specialTrim = (str: string): string => str.replace(trim, ''); * // => 'secrets:undefined:account' * ``` */ -export function applyContext(str: string, context?: Context): string { +export function applyContext( + str: string, + context?: T +): string { if (!context) return str; return specialTrim( diff --git a/src/utils/getValueFromPath.test.ts b/src/utils/getValueFromPath.test.ts index 726aa23..da28235 100644 --- a/src/utils/getValueFromPath.test.ts +++ b/src/utils/getValueFromPath.test.ts @@ -17,7 +17,52 @@ describe('getValueFromPath', () => { }); }); - describe('when object is not null', () => { + describe('when object is class instance', () => { + describe('when path exist', () => { + it('should get value from existed string path', () => { + class User { + bestFriends?: number[]; + age?: number; + firstName: string; + private lastName: string; + constructor(firstName, lastName, bestFriends?, age?) { + this.age = age; + this.bestFriends = bestFriends; + this.firstName = firstName; + this.lastName = lastName; + } + get upperLastName(): string { + return this.lastName.toUpperCase(); + } + } + const context = new User('John', 'Wick', [123, 532]); + + expect(getValueFromPath(context, 'bestFriends')).toEqual([123, 532]); + expect(getValueFromPath(context, 'firstName')).toBe('John'); + expect(getValueFromPath(context, 'upperLastName')).toEqual('WICK'); + }); + }); + + describe('when path does not exist', () => { + describe('when non default param is passed', () => { + it('should get undefined', () => { + class User { + firstName: string; + constructor(firstName) { + this.firstName = firstName; + } + } + const context = new User('John'); + + expect(getValueFromPath(context, 'user.id.pets')).toBe(undefined); + expect(getValueFromPath(context, 'company')).toBe(undefined); + expect(getValueFromPath(context, 'company.address')).toBe(undefined); + }); + }); + }); + }); + + describe('when object is a json object', () => { describe('when path exist', () => { it('should get value from existed string path', () => { const context = { diff --git a/src/utils/getValueFromPath.ts b/src/utils/getValueFromPath.ts index 891e525..cabb636 100644 --- a/src/utils/getValueFromPath.ts +++ b/src/utils/getValueFromPath.ts @@ -10,9 +10,9 @@ import { stringToPath } from './stringToPath'; * @param {Object} [object] The object to query keys on. * @returns {Array} Returns the cast property path array. */ -export function castPath( +export function castPath( value: unknown, - object: Record + object: U ): Array { if (Array.isArray(value)) { return value; @@ -29,8 +29,8 @@ export function castPath( * @param {Array|string} path The path of the property to get. * @returns {*} Returns the resolved value. */ -export function baseGet( - object: Record, +export function baseGet( + object: U, path: Array | string ): any { const newPath = castPath(path, object); @@ -69,8 +69,8 @@ export function baseGet( * getValueFromPath(object, 'a.b.c', 'default') * // => 'default' */ -export function getValueFromPath( - object: Record, +export function getValueFromPath( + object: U, path: Array | string, defaultValue?: unknown ): any { diff --git a/src/utils/isKey.ts b/src/utils/isKey.ts index 31e31c9..568b2a0 100644 --- a/src/utils/isKey.ts +++ b/src/utils/isKey.ts @@ -35,10 +35,7 @@ const reIsPlainProp = /^\w*$/; //matches any word character (alphanumeric and un * // => true * ``` */ -export function isKey( - value: unknown, - object?: Record -): boolean { +export function isKey(value: unknown, object?: T): boolean { const type = typeof value; if ( type === 'number' || diff --git a/www/src/docs/en.md b/www/src/docs/en.md index d2cc8ee..9f1ab66 100644 --- a/www/src/docs/en.md +++ b/www/src/docs/en.md @@ -5,7 +5,7 @@ date: "14-08-2020" # iam-policies -> [![NPM](https://img.shields.io/npm/v/iam-policies.svg)](https://www.npmjs.com/package/iam-policies) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Build Status](https://travis-ci.com/roggervalf/iam-policies.svg?branch=master)](https://travis-ci.com/github/roggervalf/iam-policies) [![NPM downloads](https://img.shields.io/npm/dm/iam-policies)](https://www.npmjs.com/package/iam-policies) [![Coverage Status](https://coveralls.io/repos/github/roggervalf/iam-policies/badge.svg?branch=master)](https://coveralls.io/github/roggervalf/iam-policies?branch=master) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![NPM](https://img.shields.io/npm/v/iam-policies.svg)](https://www.npmjs.com/package/iam-policies) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Build Status](https://travis-ci.com/roggervalf/iam-policies.svg?branch=master)](https://travis-ci.com/github/roggervalf/iam-policies) [![NPM downloads](https://img.shields.io/npm/dm/iam-policies)](https://www.npmjs.com/package/iam-policies) [![Coverage Status](https://coveralls.io/repos/github/roggervalf/iam-policies/badge.svg?branch=master)](https://coveralls.io/github/roggervalf/iam-policies?branch=master) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) ## About @@ -406,19 +406,19 @@ const actionBasedPolicy = new ActionBasedPolicy({ ### Properties -| Name | Type | Default | Required | Description | -| ---------------------------------------------------------------- | --------------------------------------------------------------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `statements` | object[] | undefined | `true` | The **_statements_** is the main element for a policy.
The statements element can contain an array of individual statements. | -| `statements[]`
`.sid` | string | _uuid_ | `false` | The **_sid_** element should be a unique identifier.
It is automatically generated with a uuid in case it is undefined. | -| `statements[]`
`.effect` | string | allow | `false` | The **_effect_** element specifies whether the statement results in an allow or an explicit deny.
Valid values for Effect are `allow` and `deny`. | -| `statements[]`
`.action` | string or string[] | undefined | `false` | The **_action_** element describes the specific action or actions that will be allowed or denied.
Each statement must include either an `action` or `notAction` element. | -| `statements[]`
`.notAction` | string or string[] | undefined | `false` | The **_notAction_** element is an advanced policy element that explicitly matches everything except the specified list of actions.
Each statement must include either an `action` or `notAction` element.
Using `notAction` can result in a shorter policy by listing only a few actions that should not match, rather than including a long list of actions that will match.
When using `notAction`, you should keep in mind that actions specified in this element are the only actions in that are limited.
This, in turn, means that all of the applicable actions or services that are not listed are allowed if you use the Allow effect.
In addition, such unlisted actions or services are denied if you use the `deny` effect.
When you use `notAction` with the `resource` element, you provide scope for the policy. | -| `statements[]`
`.condition` | object | undefined | `false` | The **_condition_** element (or Condition block) lets you specify conditions for when a policy is in effect.
In the `condition` element, you build expressions in which you use condition operators (equal, less than, etc.) to match the condition keys and values in the policy against keys and values in the request context. | -| `statements[]`
`.condition["conditionType"]` | object | undefined | `false` | The **_conditionType_** name should be replaced with a custom string attribute for a specific condition that should be match with one conditionResolver element. | -| `statements[]`
`.condition["conditionType"]["conditionKey"]` | (string or number or boolean) or
(string or number or boolean)[] | undefined | `false` | The **_conditionKey_** should be a custom string path attribute for a specific context attribute.
Note: attributes must be separated but dots (`.`). | -| `conditionResolver` | object | undefined | `false` | The **_conditionResolver_** should contain a function in each attribute to resolve an specific embedded condition in our statements. | -| `conditionResolver["conditionKey"]` | function | undefined | `false` | The **_conditionKey_** should match with a function name that will be used as a resolver in condition evaluation.
There are 2 parameters for this function: **data** (first parameter) that will be evaluated with **expected** (second parameter), returning a **true** or **false**. | -| `context` | object | undefined | `false` | The **_context_** has those properties that will be embedded in our statements. | +| Name | Type | Default | Required | Description | +| ---------------------------------------------------------------- | ------------------ | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `statements` | object[] | undefined | `true` | The **_statements_** is the main element for a policy.
The statements element can contain an array of individual statements. | +| `statements[]`
`.sid` | string | _uuid_ | `false` | The **_sid_** element should be a unique identifier.
It is automatically generated with a uuid in case it is undefined. | +| `statements[]`
`.effect` | string | allow | `false` | The **_effect_** element specifies whether the statement results in an allow or an explicit deny.
Valid values for Effect are `allow` and `deny`. | +| `statements[]`
`.action` | string or string[] | undefined | `false` | The **_action_** element describes the specific action or actions that will be allowed or denied.
Each statement must include either an `action` or `notAction` element. | +| `statements[]`
`.notAction` | string or string[] | undefined | `false` | The **_notAction_** element is an advanced policy element that explicitly matches everything except the specified list of actions.
Each statement must include either an `action` or `notAction` element.
Using `notAction` can result in a shorter policy by listing only a few actions that should not match, rather than including a long list of actions that will match.
When using `notAction`, you should keep in mind that actions specified in this element are the only actions in that are limited.
This, in turn, means that all of the applicable actions or services that are not listed are allowed if you use the Allow effect.
In addition, such unlisted actions or services are denied if you use the `deny` effect.
When you use `notAction` with the `resource` element, you provide scope for the policy. | +| `statements[]`
`.condition` | object | undefined | `false` | The **_condition_** element (or Condition block) lets you specify conditions for when a policy is in effect.
In the `condition` element, you build expressions in which you use condition operators (equal, less than, etc.) to match the condition keys and values in the policy against keys and values in the request context. | +| `statements[]`
`.condition["conditionType"]` | object | undefined | `false` | The **_conditionType_** name should be replaced with a custom string attribute for a specific condition that should be match with one conditionResolver element. | +| `statements[]`
`.condition["conditionType"]["conditionKey"]` | any | undefined | `false` | The **_conditionKey_** should be a custom string path attribute for a specific context attribute.
Note: attributes must be separated but dots (`.`). | +| `conditionResolver` | object | undefined | `false` | The **_conditionResolver_** should contain a function in each attribute to resolve an specific embedded condition in our statements. | +| `conditionResolver["conditionKey"]` | function | undefined | `false` | The **_conditionKey_** should match with a function name that will be used as a resolver in condition evaluation.
There are 2 parameters for this function: **data** (first parameter) that will be evaluated with **expected** (second parameter), returning a **true** or **false**. | +| `context` | object | undefined | `false` | The **_context_** has those properties that will be embedded in our statements. | ### Methods @@ -507,21 +507,21 @@ const identityBasedPolicy = new IdentityBasedPolicy({ ### Properties -| Name | Type | Default | Required | Description | -| ---------------------------------------------------------------- | --------------------------------------------------------------------- | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `statements` | object[] | undefined | `true` | The **_statements_** element is the main element for a policy. The statements element can contain an array of individual statements. | -| `statements[]`
`.sid` | string | _uuid_ | `false` | The **_sid_** element should be a unique identifier.
It is automatically generated with a uuid in case it is undefined. | -| `statements[]`
`.effect` | string | allow | `false` | The **_effect_** element specifies whether the statement results in an allow or an explicit deny.
Valid values for Effect are `allow` and `deny`. | -| `statements[]`
`.action` | string or string[] | undefined | `false` | The **_action_** element describes the specific action or actions that will be allowed or denied.
Statements must include either an `action` or `notAction` element. | -| `statements[]`
`.notAction` | string or string[] | undefined | `false` | The **_notAction_** element is an advanced policy element that explicitly matches everything except the specified list of actions.
Statements must include either an `action` or `notAction` element.
Using `notAction` can result in a shorter policy by listing only a few actions that should not match, rather than including a long list of actions that will match.
When using `notAction`, you should keep in mind that actions specified in this element are the only actions in that are limited.
This, in turn, means that all of the applicable actions or services that are not listed are allowed if you use the Allow effect.
In addition, such unlisted actions or services are denied if you use the `deny` effect.
When you use `notAction` with the `resource` element, you provide scope for the policy. | -| `statements[]`
`.resource` | string or string[] | undefined | `true` | The **_resource_** element specifies the object or objects that the statement covers.
Each statement must include either a `resource` or a `notResource` element. | -| `statements[]`
`.notResource` | string or string[] | undefined | `true` | The **_notResource_** element is an advanced policy element that explicitly matches every resource except those specified.
Each statement must include either an `resource` or `notResource` element.
Using `notResource` can result in a shorter policy by listing only a few resources that should not match, rather than including a long list of resources that will match. | -| `statements[]`
`.condition` | object | undefined | `false` | The **_condition_** element (or Condition block) lets you specify conditions for when a policy is in effect.
In the `condition` element, you build expressions in which you use condition operators (equal, less than, etc.) to match the condition keys and values in the policy against keys and values in the request context. | -| `statements[]`
`.condition["conditionType"]` | object | undefined | `false` | The **_conditionType_** name should be replaced with a custom string attribute for a specific condition that should be match with one conditionResolver element. | -| `statements[]`
`.condition["conditionType"]["conditionKey"]` | (string or number or boolean) or
(string or number or boolean)[] | undefined | `false` | The **_conditionKey_** should be a custom string path attribute for a specific context attribute.
Note: attributes must be separated but dots (`.`). | -| `conditionResolver` | object | undefined | `false` | The **_conditionResolver_** should contain a function in each attribute to resolve an specific embedded condition in our statements. | -| `conditionResolver["conditionKey"]` | function | undefined | `false` | The **_conditionKey_** should match with a function name that will be used as a resolver in condition evaluation.
There are 2 parameters for this function: **data** (first parameter) that will be evaluated with **expected** (second parameter), returning a **true** or **false**. | -| `context` | object | undefined | `false` | The **_context_** has those properties that will be embedded in our statements. | +| Name | Type | Default | Required | Description | +| ---------------------------------------------------------------- | ------------------ | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `statements` | object[] | undefined | `true` | The **_statements_** element is the main element for a policy. The statements element can contain an array of individual statements. | +| `statements[]`
`.sid` | string | _uuid_ | `false` | The **_sid_** element should be a unique identifier.
It is automatically generated with a uuid in case it is undefined. | +| `statements[]`
`.effect` | string | allow | `false` | The **_effect_** element specifies whether the statement results in an allow or an explicit deny.
Valid values for Effect are `allow` and `deny`. | +| `statements[]`
`.action` | string or string[] | undefined | `false` | The **_action_** element describes the specific action or actions that will be allowed or denied.
Statements must include either an `action` or `notAction` element. | +| `statements[]`
`.notAction` | string or string[] | undefined | `false` | The **_notAction_** element is an advanced policy element that explicitly matches everything except the specified list of actions.
Statements must include either an `action` or `notAction` element.
Using `notAction` can result in a shorter policy by listing only a few actions that should not match, rather than including a long list of actions that will match.
When using `notAction`, you should keep in mind that actions specified in this element are the only actions in that are limited.
This, in turn, means that all of the applicable actions or services that are not listed are allowed if you use the Allow effect.
In addition, such unlisted actions or services are denied if you use the `deny` effect.
When you use `notAction` with the `resource` element, you provide scope for the policy. | +| `statements[]`
`.resource` | string or string[] | undefined | `true` | The **_resource_** element specifies the object or objects that the statement covers.
Each statement must include either a `resource` or a `notResource` element. | +| `statements[]`
`.notResource` | string or string[] | undefined | `true` | The **_notResource_** element is an advanced policy element that explicitly matches every resource except those specified.
Each statement must include either an `resource` or `notResource` element.
Using `notResource` can result in a shorter policy by listing only a few resources that should not match, rather than including a long list of resources that will match. | +| `statements[]`
`.condition` | object | undefined | `false` | The **_condition_** element (or Condition block) lets you specify conditions for when a policy is in effect.
In the `condition` element, you build expressions in which you use condition operators (equal, less than, etc.) to match the condition keys and values in the policy against keys and values in the request context. | +| `statements[]`
`.condition["conditionType"]` | object | undefined | `false` | The **_conditionType_** name should be replaced with a custom string attribute for a specific condition that should be match with one conditionResolver element. | +| `statements[]`
`.condition["conditionType"]["conditionKey"]` | any | undefined | `false` | The **_conditionKey_** should be a custom string path attribute for a specific context attribute.
Note: attributes must be separated but dots (`.`). | +| `conditionResolver` | object | undefined | `false` | The **_conditionResolver_** should contain a function in each attribute to resolve an specific embedded condition in our statements. | +| `conditionResolver["conditionKey"]` | function | undefined | `false` | The **_conditionKey_** should match with a function name that will be used as a resolver in condition evaluation.
There are 2 parameters for this function: **data** (first parameter) that will be evaluated with **expected** (second parameter), returning a **true** or **false**. | +| `context` | object | undefined | `false` | The **_context_** has those properties that will be embedded in our statements. | ### Methods @@ -597,23 +597,23 @@ const resourceBasedPolicy = new ResourceBasedPolicy({ ### Properties -| Name | Type | Default | Required | Description | -| ---------------------------------------------------------------- | --------------------------------------------------------------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `statements` | object[] | undefined | `true` | The **_statements_** element is the main element for a policy.
The statements element can contain an array of individual statements. | -| `statements[]`
`.sid` | string | _uuid_ | `false` | The **_sid_** element should be a unique identifier.
It is automatically generated with a uuid in case it is undefined. | -| `statements[]`
`.effect` | string | allow | `false` | The **_effect_** element specifies whether the statement results in an allow or an explicit deny.
Valid values for Effect are `allow` and `deny`. | -| `statements[]`
`.principal` | string or string[] | undefined | `false` | The **_principal_** element in a policy to specify the principal that is allowed or denied access to a resource.
Each statement could include either an `principal` or `notPrincipal`. | -| `statements[]`
`.notPrincipal` | string or string[] | undefined | `false` | The **_notPrincipal_** element specifies the principal that is not allowed or denied access to a resource.
The `notPrincipal` element enables you to specify an exception to a list of principals.
Use this element to deny access to all principals except the one named in the `notPrincipal` element.
Each statement could include either an `principal` or `notPrincipal` element. | -| `statements[]`
`.action` | string or string[] | undefined | `false` | The **_action_** element describes the specific action or actions that will be allowed or denied.
Each statement must include either an `action` or `notAction` element. | -| `statements[]`
`.notAction` | string or string[] | undefined | `false` | The **_notAction_** element is an advanced policy element that explicitly matches everything except the specified list of actions.
Each statement must include either an `action` or `notAction` element.
Using `notAction` can result in a shorter policy by listing only a few actions that should not match, rather than including a long list of actions that will match.
When using `notAction`, you should keep in mind that actions specified in this element are the only actions in that are limited.
This, in turn, means that all of the applicable actions or services that are not listed are allowed if you use the Allow effect.
In addition, such unlisted actions or services are denied if you use the `deny` effect.
When you use `notAction` with the `resource` element, you provide scope for the policy. | -| `statements[]`
`.resource` | string or string[] | undefined | `true` | The **_resource_** element specifies the object or objects that the statement covers.
Each statement could include either a `resource` or a `notResource` element. | -| `statements[]`
`.notResource` | string or string[] | undefined | `true` | The **_notResource_** element is an advanced policy element that explicitly matches every resource except those specified.
Each statement could include either an `resource` or `notResource` element.
Using `notResource` can result in a shorter policy by listing only a few resources that should not match, rather than including a long list of resources that will match. | -| `statements[]`
`.condition` | object | undefined | `false` | The **_condition_** element (or Condition block) lets you specify conditions for when a policy is in effect.
In the `condition` element, you build expressions in which you use condition operators (equal, less than, etc.) to match the condition keys and values in the policy against keys and values in the request context. | -| `statements[]`
`.condition["conditionType"]` | object | undefined | `false` | The **_conditionType_** name should be replaced with a custom string attribute for a specific condition that should be match with one conditionResolver element. | -| `statements[]`
`.condition["conditionType"]["conditionKey"]` | (string or number or boolean) or
(string or number or boolean)[] | undefined | `false` | The **_conditionKey_** should be a custom string path attribute for a specific context attribute.
Note: attributes must be separated but dots (`.`). | -| `conditionResolver` | object | undefined | `false` | The **_conditionResolver_** should contain a function in each attribute to resolve an specific embedded condition in our statements. | -| `conditionResolver["conditionKey"]` | function | undefined | `false` | The **_conditionKey_** should match with a function name that will be used as a resolver in condition evaluation.
There are 2 parameters for this function: **data** (first parameter) that will be evaluated with **expected** (second parameter), returning a **true** or **false**. | -| `context` | object | undefined | `false` | The **_context_** has those properties that will be embedded in our statements. | +| Name | Type | Default | Required | Description | +| ---------------------------------------------------------------- | ------------------ | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `statements` | object[] | undefined | `true` | The **_statements_** element is the main element for a policy.
The statements element can contain an array of individual statements. | +| `statements[]`
`.sid` | string | _uuid_ | `false` | The **_sid_** element should be a unique identifier.
It is automatically generated with a uuid in case it is undefined. | +| `statements[]`
`.effect` | string | allow | `false` | The **_effect_** element specifies whether the statement results in an allow or an explicit deny.
Valid values for Effect are `allow` and `deny`. | +| `statements[]`
`.principal` | string or string[] | undefined | `false` | The **_principal_** element in a policy to specify the principal that is allowed or denied access to a resource.
Each statement could include either an `principal` or `notPrincipal`. | +| `statements[]`
`.notPrincipal` | string or string[] | undefined | `false` | The **_notPrincipal_** element specifies the principal that is not allowed or denied access to a resource.
The `notPrincipal` element enables you to specify an exception to a list of principals.
Use this element to deny access to all principals except the one named in the `notPrincipal` element.
Each statement could include either an `principal` or `notPrincipal` element. | +| `statements[]`
`.action` | string or string[] | undefined | `false` | The **_action_** element describes the specific action or actions that will be allowed or denied.
Each statement must include either an `action` or `notAction` element. | +| `statements[]`
`.notAction` | string or string[] | undefined | `false` | The **_notAction_** element is an advanced policy element that explicitly matches everything except the specified list of actions.
Each statement must include either an `action` or `notAction` element.
Using `notAction` can result in a shorter policy by listing only a few actions that should not match, rather than including a long list of actions that will match.
When using `notAction`, you should keep in mind that actions specified in this element are the only actions in that are limited.
This, in turn, means that all of the applicable actions or services that are not listed are allowed if you use the Allow effect.
In addition, such unlisted actions or services are denied if you use the `deny` effect.
When you use `notAction` with the `resource` element, you provide scope for the policy. | +| `statements[]`
`.resource` | string or string[] | undefined | `true` | The **_resource_** element specifies the object or objects that the statement covers.
Each statement could include either a `resource` or a `notResource` element. | +| `statements[]`
`.notResource` | string or string[] | undefined | `true` | The **_notResource_** element is an advanced policy element that explicitly matches every resource except those specified.
Each statement could include either an `resource` or `notResource` element.
Using `notResource` can result in a shorter policy by listing only a few resources that should not match, rather than including a long list of resources that will match. | +| `statements[]`
`.condition` | object | undefined | `false` | The **_condition_** element (or Condition block) lets you specify conditions for when a policy is in effect.
In the `condition` element, you build expressions in which you use condition operators (equal, less than, etc.) to match the condition keys and values in the policy against keys and values in the request context. | +| `statements[]`
`.condition["conditionType"]` | object | undefined | `false` | The **_conditionType_** name should be replaced with a custom string attribute for a specific condition that should be match with one conditionResolver element. | +| `statements[]`
`.condition["conditionType"]["conditionKey"]` | any | undefined | `false` | The **_conditionKey_** should be a custom string path attribute for a specific context attribute.
Note: attributes must be separated but dots (`.`). | +| `conditionResolver` | object | undefined | `false` | The **_conditionResolver_** should contain a function in each attribute to resolve an specific embedded condition in our statements. | +| `conditionResolver["conditionKey"]` | function | undefined | `false` | The **_conditionKey_** should match with a function name that will be used as a resolver in condition evaluation.
There are 2 parameters for this function: **data** (first parameter) that will be evaluated with **expected** (second parameter), returning a **true** or **false**. | +| `context` | object | undefined | `false` | The **_context_** has those properties that will be embedded in our statements. | ### Methods diff --git a/www/src/docs/zh-CN.md b/www/src/docs/zh-CN.md index 3483ec3..1b16ad9 100644 --- a/www/src/docs/zh-CN.md +++ b/www/src/docs/zh-CN.md @@ -5,7 +5,7 @@ date: "14-08-2020" # iam-policies -> [![NPM](https://img.shields.io/npm/v/iam-policies.svg)](https://www.npmjs.com/package/iam-policies) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Build Status](https://travis-ci.com/roggervalf/iam-policies.svg?branch=master)](https://travis-ci.com/github/roggervalf/iam-policies) [![NPM downloads](https://img.shields.io/npm/dm/iam-policies)](https://www.npmjs.com/package/iam-policies) [![Coverage Status](https://coveralls.io/repos/github/roggervalf/iam-policies/badge.svg?branch=master)](https://coveralls.io/github/roggervalf/iam-policies?branch=master) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![NPM](https://img.shields.io/npm/v/iam-policies.svg)](https://www.npmjs.com/package/iam-policies) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Build Status](https://travis-ci.com/roggervalf/iam-policies.svg?branch=master)](https://travis-ci.com/github/roggervalf/iam-policies) [![NPM downloads](https://img.shields.io/npm/dm/iam-policies)](https://www.npmjs.com/package/iam-policies) [![Coverage Status](https://coveralls.io/repos/github/roggervalf/iam-policies/badge.svg?branch=master)](https://coveralls.io/github/roggervalf/iam-policies?branch=master) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) ## 介绍