@strapi/permissions 4.15.0-alpha.0 → 4.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,275 @@
1
+ import _, { cloneDeep, isArray, has, pick, isNil, isObject } from "lodash/fp";
2
+ import qs from "qs";
3
+ import { hooks } from "@strapi/utils";
4
+ import * as sift from "sift";
5
+ import { AbilityBuilder, Ability } from "@casl/ability";
6
+ const PERMISSION_FIELDS = ["action", "subject", "properties", "conditions"];
7
+ const sanitizePermissionFields = _.pick(PERMISSION_FIELDS);
8
+ const getDefaultPermission = () => ({
9
+ conditions: [],
10
+ properties: {},
11
+ subject: null
12
+ });
13
+ const create = _.pipe(_.pick(PERMISSION_FIELDS), _.merge(getDefaultPermission()));
14
+ const addCondition = _.curry((condition, permission) => {
15
+ const { conditions } = permission;
16
+ const newConditions = Array.isArray(conditions) ? _.uniq(conditions.concat(condition)) : [condition];
17
+ return _.set("conditions", newConditions, permission);
18
+ });
19
+ const getProperty = _.curry(
20
+ (property, permission) => _.get(`properties.${property}`, permission)
21
+ );
22
+ const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
23
+ __proto__: null,
24
+ addCondition,
25
+ create,
26
+ getProperty,
27
+ sanitizePermissionFields
28
+ }, Symbol.toStringTag, { value: "Module" }));
29
+ const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
30
+ __proto__: null,
31
+ permission: index$3
32
+ }, Symbol.toStringTag, { value: "Module" }));
33
+ const createEngineHooks = () => ({
34
+ "before-format::validate.permission": hooks.createAsyncBailHook(),
35
+ "format.permission": hooks.createAsyncSeriesWaterfallHook(),
36
+ "after-format::validate.permission": hooks.createAsyncBailHook(),
37
+ "before-evaluate.permission": hooks.createAsyncSeriesHook(),
38
+ "before-register.permission": hooks.createAsyncSeriesHook()
39
+ });
40
+ const createValidateContext = (permission) => ({
41
+ get permission() {
42
+ return cloneDeep(permission);
43
+ }
44
+ });
45
+ const createBeforeEvaluateContext = (permission) => ({
46
+ get permission() {
47
+ return cloneDeep(permission);
48
+ },
49
+ addCondition(condition) {
50
+ Object.assign(permission, addCondition(condition, permission));
51
+ return this;
52
+ }
53
+ });
54
+ const createWillRegisterContext = ({ permission, options }) => ({
55
+ ...options,
56
+ get permission() {
57
+ return cloneDeep(permission);
58
+ },
59
+ condition: {
60
+ and(rawConditionObject) {
61
+ if (!permission.condition) {
62
+ permission.condition = { $and: [] };
63
+ }
64
+ if (isArray(permission.condition.$and)) {
65
+ permission.condition.$and.push(rawConditionObject);
66
+ }
67
+ return this;
68
+ },
69
+ or(rawConditionObject) {
70
+ if (!permission.condition) {
71
+ permission.condition = { $and: [] };
72
+ }
73
+ if (isArray(permission.condition.$and)) {
74
+ const orClause = permission.condition.$and.find(has("$or"));
75
+ if (orClause) {
76
+ orClause.$or.push(rawConditionObject);
77
+ } else {
78
+ permission.condition.$and.push({ $or: [rawConditionObject] });
79
+ }
80
+ }
81
+ return this;
82
+ }
83
+ }
84
+ });
85
+ const allowedOperations = [
86
+ "$or",
87
+ "$and",
88
+ "$eq",
89
+ "$ne",
90
+ "$in",
91
+ "$nin",
92
+ "$lt",
93
+ "$lte",
94
+ "$gt",
95
+ "$gte",
96
+ "$exists",
97
+ "$elemMatch"
98
+ ];
99
+ const operations = pick(allowedOperations, sift);
100
+ const conditionsMatcher = (conditions) => {
101
+ return sift.createQueryTester(conditions, { operations });
102
+ };
103
+ const buildParametrizedAction = ({ name, params }) => {
104
+ return `${name}?${qs.stringify(params)}`;
105
+ };
106
+ const caslAbilityBuilder = () => {
107
+ const { can, build, ...rest } = new AbilityBuilder(Ability);
108
+ return {
109
+ can(permission) {
110
+ const { action, subject, properties = {}, condition } = permission;
111
+ const { fields } = properties;
112
+ const caslAction = typeof action === "string" ? action : buildParametrizedAction(action);
113
+ return can(
114
+ caslAction,
115
+ isNil(subject) ? "all" : subject,
116
+ fields,
117
+ isObject(condition) ? condition : void 0
118
+ );
119
+ },
120
+ buildParametrizedAction({ name, params }) {
121
+ return `${name}?${qs.stringify(params)}`;
122
+ },
123
+ build() {
124
+ const ability = build({ conditionsMatcher });
125
+ function decorateCan(originalCan) {
126
+ return function(...args) {
127
+ const [action, ...rest2] = args;
128
+ const caslAction = typeof action === "string" ? action : buildParametrizedAction(action);
129
+ return originalCan.apply(ability, [caslAction, ...rest2]);
130
+ };
131
+ }
132
+ ability.can = decorateCan(ability.can);
133
+ return ability;
134
+ },
135
+ ...rest
136
+ };
137
+ };
138
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
139
+ __proto__: null,
140
+ caslAbilityBuilder
141
+ }, Symbol.toStringTag, { value: "Module" }));
142
+ const createEngineState = () => {
143
+ const hooks2 = createEngineHooks();
144
+ return { hooks: hooks2 };
145
+ };
146
+ const newEngine = (params) => {
147
+ const { providers, abilityBuilderFactory = caslAbilityBuilder } = params;
148
+ const state = createEngineState();
149
+ const runValidationHook = async (hook, context) => state.hooks[hook].call(context);
150
+ const evaluate = async (params2) => {
151
+ const { options, register } = params2;
152
+ const preFormatValidation = await runValidationHook(
153
+ "before-format::validate.permission",
154
+ createBeforeEvaluateContext(params2.permission)
155
+ );
156
+ if (preFormatValidation === false) {
157
+ return;
158
+ }
159
+ const permission = await state.hooks["format.permission"].call(
160
+ params2.permission
161
+ );
162
+ const afterFormatValidation = await runValidationHook(
163
+ "after-format::validate.permission",
164
+ createValidateContext(permission)
165
+ );
166
+ if (afterFormatValidation === false) {
167
+ return;
168
+ }
169
+ await state.hooks["before-evaluate.permission"].call(createBeforeEvaluateContext(permission));
170
+ const {
171
+ action: actionName,
172
+ subject,
173
+ properties,
174
+ conditions = [],
175
+ actionParameters = {}
176
+ } = permission;
177
+ let action = actionName;
178
+ if (actionParameters && Object.keys(actionParameters).length > 0) {
179
+ action = `${actionName}?${qs.stringify(actionParameters)}`;
180
+ }
181
+ if (conditions.length === 0) {
182
+ return register({ action, subject, properties });
183
+ }
184
+ const resolveConditions = _.map(providers.condition.get);
185
+ const removeInvalidConditions = _.filter(
186
+ (condition) => _.isFunction(condition.handler)
187
+ );
188
+ const evaluateConditions = (conditions2) => {
189
+ return Promise.all(
190
+ conditions2.map(async (condition) => ({
191
+ condition,
192
+ result: await condition.handler(
193
+ _.merge(options, { permission: _.cloneDeep(permission) })
194
+ )
195
+ }))
196
+ );
197
+ };
198
+ const removeInvalidResults = _.filter(
199
+ ({ result }) => _.isBoolean(result) || _.isObject(result)
200
+ );
201
+ const evaluatedConditions = await Promise.resolve(conditions).then(resolveConditions).then(removeInvalidConditions).then(evaluateConditions).then(removeInvalidResults);
202
+ const resultPropEq = _.propEq("result");
203
+ const pickResults = _.map(_.prop("result"));
204
+ if (evaluatedConditions.every(resultPropEq(false))) {
205
+ return;
206
+ }
207
+ if (_.isEmpty(evaluatedConditions) || evaluatedConditions.some(resultPropEq(true))) {
208
+ return register({ action, subject, properties });
209
+ }
210
+ const results = pickResults(evaluatedConditions).filter(_.isObject);
211
+ if (_.isEmpty(results)) {
212
+ return register({ action, subject, properties });
213
+ }
214
+ return register({
215
+ action,
216
+ subject,
217
+ properties,
218
+ condition: { $and: [{ $or: results }] }
219
+ });
220
+ };
221
+ return {
222
+ get hooks() {
223
+ return state.hooks;
224
+ },
225
+ /**
226
+ * Create a register function that wraps a `can` function
227
+ * used to register a permission in the ability builder
228
+ */
229
+ createRegisterFunction(can, options) {
230
+ return async (permission) => {
231
+ const hookContext = createWillRegisterContext({ options, permission });
232
+ await state.hooks["before-register.permission"].call(hookContext);
233
+ return can(permission);
234
+ };
235
+ },
236
+ /**
237
+ * Register a new handler for a given hook
238
+ */
239
+ on(hook, handler) {
240
+ const validHooks = Object.keys(state.hooks);
241
+ const isValidHook = validHooks.includes(hook);
242
+ if (!isValidHook) {
243
+ throw new Error(
244
+ `Invalid hook supplied when trying to register an handler to the permission engine. Got "${hook}" but expected one of ${validHooks.join(
245
+ ", "
246
+ )}`
247
+ );
248
+ }
249
+ state.hooks[hook].register(handler);
250
+ return this;
251
+ },
252
+ /**
253
+ * Generate an ability based on the instance's
254
+ * ability builder and the given permissions
255
+ */
256
+ async generateAbility(permissions, options = {}) {
257
+ const { can, build } = abilityBuilderFactory();
258
+ for (const permission of permissions) {
259
+ const register = this.createRegisterFunction(can, options);
260
+ await evaluate({ permission, options, register });
261
+ }
262
+ return build();
263
+ }
264
+ };
265
+ };
266
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
267
+ __proto__: null,
268
+ abilities: index$1,
269
+ new: newEngine
270
+ }, Symbol.toStringTag, { value: "Module" }));
271
+ export {
272
+ index$2 as domain,
273
+ index as engine
274
+ };
275
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/domain/permission/index.ts","../src/engine/hooks.ts","../src/engine/abilities/casl-ability.ts","../src/engine/index.ts"],"sourcesContent":["import _ from 'lodash/fp';\n\nconst PERMISSION_FIELDS = ['action', 'subject', 'properties', 'conditions'] as const;\n\nconst sanitizePermissionFields = _.pick(PERMISSION_FIELDS);\n\nexport interface Permission {\n action: string;\n actionParameters?: Record<string, unknown>;\n subject?: string | object | null;\n properties?: object;\n conditions?: string[];\n}\n\n/**\n * Creates a permission with default values for optional properties\n */\nconst getDefaultPermission = (): Pick<Permission, 'conditions' | 'properties' | 'subject'> => ({\n conditions: [],\n properties: {},\n subject: null,\n});\n\n/**\n * Create a new permission based on given attributes\n *\n * @param {object} attributes\n */\nconst create = _.pipe(_.pick(PERMISSION_FIELDS), _.merge(getDefaultPermission()));\n\n/**\n * Add a condition to a permission\n */\nconst addCondition = _.curry((condition: string, permission: Permission): Permission => {\n const { conditions } = permission;\n\n const newConditions = Array.isArray(conditions)\n ? _.uniq(conditions.concat(condition))\n : [condition];\n\n return _.set('conditions', newConditions, permission);\n});\n\n/**\n * Gets a property or a part of a property from a permission.\n */\nconst getProperty = _.curry(\n <T extends keyof Permission['properties']>(\n property: T,\n permission: Permission\n ): Permission['properties'][T] => _.get(`properties.${property}`, permission)\n);\n\nexport { create, sanitizePermissionFields, addCondition, getProperty };\n","import { cloneDeep, has, isArray } from 'lodash/fp';\nimport { hooks } from '@strapi/utils';\n\nimport * as domain from '../domain';\nimport type { Permission } from '../domain/permission';\nimport type { PermissionRule } from './abilities';\n\nexport interface PermissionEngineHooks {\n 'before-format::validate.permission': ReturnType<typeof hooks.createAsyncBailHook>;\n 'format.permission': ReturnType<typeof hooks.createAsyncSeriesWaterfallHook>;\n 'after-format::validate.permission': ReturnType<typeof hooks.createAsyncBailHook>;\n 'before-evaluate.permission': ReturnType<typeof hooks.createAsyncSeriesHook>;\n 'before-register.permission': ReturnType<typeof hooks.createAsyncSeriesHook>;\n}\n\nexport type HookName = keyof PermissionEngineHooks;\n\n/**\n * Create a hook map used by the permission Engine\n */\nconst createEngineHooks = (): PermissionEngineHooks => ({\n 'before-format::validate.permission': hooks.createAsyncBailHook(),\n 'format.permission': hooks.createAsyncSeriesWaterfallHook(),\n 'after-format::validate.permission': hooks.createAsyncBailHook(),\n 'before-evaluate.permission': hooks.createAsyncSeriesHook(),\n 'before-register.permission': hooks.createAsyncSeriesHook(),\n});\n\n/**\n * Create a context from a domain {@link Permission} used by the validate hooks\n */\nconst createValidateContext = (permission: Permission) => ({\n get permission(): Readonly<Permission> {\n return cloneDeep(permission);\n },\n});\n\n/**\n * Create a context from a domain {@link Permission} used by the before valuate hook\n */\nconst createBeforeEvaluateContext = (permission: Permission) => ({\n get permission(): Readonly<Permission> {\n return cloneDeep(permission);\n },\n\n addCondition(condition: string) {\n Object.assign(permission, domain.permission.addCondition(condition, permission));\n\n return this;\n },\n});\n\ninterface WillRegisterContextParams {\n permission: PermissionRule;\n options: Record<string, unknown>;\n}\n\n/**\n * Create a context from a casl Permission & some options\n * @param caslPermission\n */\nconst createWillRegisterContext = ({ permission, options }: WillRegisterContextParams) => ({\n ...options,\n\n get permission() {\n return cloneDeep(permission);\n },\n\n condition: {\n and(rawConditionObject: unknown) {\n if (!permission.condition) {\n permission.condition = { $and: [] };\n }\n\n if (isArray(permission.condition.$and)) {\n permission.condition.$and.push(rawConditionObject);\n }\n\n return this;\n },\n\n or(rawConditionObject: unknown) {\n if (!permission.condition) {\n permission.condition = { $and: [] };\n }\n\n if (isArray(permission.condition.$and)) {\n const orClause = permission.condition.$and.find(has('$or'));\n\n if (orClause) {\n orClause.$or.push(rawConditionObject);\n } else {\n permission.condition.$and.push({ $or: [rawConditionObject] });\n }\n }\n\n return this;\n },\n },\n});\n\nexport {\n createEngineHooks,\n createValidateContext,\n createBeforeEvaluateContext,\n createWillRegisterContext,\n};\n","import * as sift from 'sift';\nimport qs from 'qs';\nimport { AbilityBuilder, Ability, Subject } from '@casl/ability';\nimport { pick, isNil, isObject } from 'lodash/fp';\n\nexport interface ParametrizedAction {\n name: string;\n params: Record<string, unknown>;\n}\n\nexport interface PermissionRule {\n action: string | ParametrizedAction;\n subject?: Subject | null;\n properties?: {\n fields?: string[];\n };\n condition?: Record<string, unknown>;\n}\n\nexport interface CustomAbilityBuilder {\n can(permission: PermissionRule): ReturnType<AbilityBuilder<Ability>['can']>;\n buildParametrizedAction: (parametrizedAction: ParametrizedAction) => string;\n build(): Ability;\n}\n\nconst allowedOperations = [\n '$or',\n '$and',\n '$eq',\n '$ne',\n '$in',\n '$nin',\n '$lt',\n '$lte',\n '$gt',\n '$gte',\n '$exists',\n '$elemMatch',\n] as const;\n\nconst operations = pick(allowedOperations, sift);\n\nconst conditionsMatcher = (conditions: unknown) => {\n return sift.createQueryTester(conditions, { operations });\n};\n\nconst buildParametrizedAction = ({ name, params }: ParametrizedAction) => {\n return `${name}?${qs.stringify(params)}`;\n};\n\n/**\n * Casl Ability Builder.\n */\nexport const caslAbilityBuilder = (): CustomAbilityBuilder => {\n const { can, build, ...rest } = new AbilityBuilder(Ability);\n\n return {\n can(permission: PermissionRule) {\n const { action, subject, properties = {}, condition } = permission;\n const { fields } = properties;\n\n const caslAction = typeof action === 'string' ? action : buildParametrizedAction(action);\n\n return can(\n caslAction,\n isNil(subject) ? 'all' : subject,\n fields,\n isObject(condition) ? condition : undefined\n );\n },\n\n buildParametrizedAction({ name, params }: ParametrizedAction) {\n return `${name}?${qs.stringify(params)}`;\n },\n\n build() {\n const ability = build({ conditionsMatcher });\n\n function decorateCan(originalCan: Ability['can']) {\n return function (...args: Parameters<Ability['can']>) {\n const [action, ...rest] = args;\n const caslAction = typeof action === 'string' ? action : buildParametrizedAction(action);\n\n // Call the original `can` method\n return originalCan.apply(ability, [caslAction, ...rest]);\n };\n }\n\n ability.can = decorateCan(ability.can);\n return ability;\n },\n\n ...rest,\n };\n};\n","import _ from 'lodash/fp';\nimport qs from 'qs';\nimport { Ability } from '@casl/ability';\nimport { providerFactory } from '@strapi/utils';\n\nimport {\n createEngineHooks,\n createWillRegisterContext,\n createBeforeEvaluateContext,\n createValidateContext,\n} from './hooks';\nimport type { PermissionEngineHooks, HookName } from './hooks';\n\nimport * as abilities from './abilities';\nimport { Permission } from '../domain/permission';\n\nexport { abilities };\n\ntype Provider = Omit<ReturnType<typeof providerFactory>, 'register'> & {\n register(...args: unknown[]): Promise<Provider> | Provider;\n};\n\ntype ActionProvider = Provider;\ntype ConditionProvider = Provider;\n\nexport interface Engine {\n hooks: PermissionEngineHooks;\n on(hook: HookName, handler: (...args: any[]) => any): Engine;\n generateAbility(permissions: Permission[], options?: object): Promise<Ability>;\n createRegisterFunction(\n can: (permission: abilities.PermissionRule) => unknown,\n options: Record<string, unknown>\n ): (permission: abilities.PermissionRule) => Promise<unknown>;\n}\n\nexport interface EngineParams {\n providers: { action: ActionProvider; condition: ConditionProvider };\n abilityBuilderFactory?(): abilities.CustomAbilityBuilder;\n}\n\ninterface EvaluateParams {\n options: Record<string, unknown>;\n register: (permission: abilities.PermissionRule) => Promise<unknown>;\n permission: Permission;\n}\n\ninterface Condition {\n name: string;\n handler(...params: unknown[]): boolean | object;\n}\n\n/**\n * Create a default state object for the engine\n */\nconst createEngineState = () => {\n const hooks = createEngineHooks();\n\n return { hooks };\n};\n\nconst newEngine = (params: EngineParams): Engine => {\n const { providers, abilityBuilderFactory = abilities.caslAbilityBuilder } = params;\n\n const state = createEngineState();\n\n const runValidationHook = async (hook: HookName, context: unknown) =>\n state.hooks[hook].call(context);\n\n /**\n * Evaluate a permission using local and registered behaviors (using hooks).\n * Validate, format (add condition, etc...), evaluate (evaluate conditions) and register a permission\n */\n const evaluate = async (params: EvaluateParams) => {\n const { options, register } = params;\n\n const preFormatValidation = await runValidationHook(\n 'before-format::validate.permission',\n createBeforeEvaluateContext(params.permission)\n );\n\n if (preFormatValidation === false) {\n return;\n }\n\n const permission = (await state.hooks['format.permission'].call(\n params.permission\n )) as Permission;\n\n const afterFormatValidation = await runValidationHook(\n 'after-format::validate.permission',\n createValidateContext(permission)\n );\n\n if (afterFormatValidation === false) {\n return;\n }\n\n await state.hooks['before-evaluate.permission'].call(createBeforeEvaluateContext(permission));\n\n const {\n action: actionName,\n subject,\n properties,\n conditions = [],\n actionParameters = {},\n } = permission;\n\n let action = actionName;\n\n if (actionParameters && Object.keys(actionParameters).length > 0) {\n action = `${actionName}?${qs.stringify(actionParameters)}`;\n }\n\n if (conditions.length === 0) {\n return register({ action, subject, properties });\n }\n\n const resolveConditions = _.map(providers.condition.get);\n\n const removeInvalidConditions = _.filter((condition: Condition) =>\n _.isFunction(condition.handler)\n );\n\n const evaluateConditions = (conditions: Condition[]) => {\n return Promise.all(\n conditions.map(async (condition) => ({\n condition,\n result: await condition.handler(\n _.merge(options, { permission: _.cloneDeep(permission) })\n ),\n }))\n );\n };\n\n const removeInvalidResults = _.filter(\n ({ result }) => _.isBoolean(result) || _.isObject(result)\n );\n\n const evaluatedConditions = await Promise.resolve(conditions)\n .then(resolveConditions)\n .then(removeInvalidConditions)\n .then(evaluateConditions)\n .then(removeInvalidResults);\n\n const resultPropEq = _.propEq('result');\n const pickResults = _.map(_.prop('result'));\n\n if (evaluatedConditions.every(resultPropEq(false))) {\n return;\n }\n\n if (_.isEmpty(evaluatedConditions) || evaluatedConditions.some(resultPropEq(true))) {\n return register({ action, subject, properties });\n }\n\n const results = pickResults(evaluatedConditions).filter(_.isObject);\n\n if (_.isEmpty(results)) {\n return register({ action, subject, properties });\n }\n\n return register({\n action,\n subject,\n properties,\n condition: { $and: [{ $or: results }] },\n });\n };\n\n return {\n get hooks() {\n return state.hooks;\n },\n\n /**\n * Create a register function that wraps a `can` function\n * used to register a permission in the ability builder\n */\n createRegisterFunction(can, options: Record<string, unknown>) {\n return async (permission: abilities.PermissionRule) => {\n const hookContext = createWillRegisterContext({ options, permission });\n\n await state.hooks['before-register.permission'].call(hookContext);\n\n return can(permission);\n };\n },\n\n /**\n * Register a new handler for a given hook\n */\n on(hook, handler) {\n const validHooks = Object.keys(state.hooks);\n const isValidHook = validHooks.includes(hook);\n\n if (!isValidHook) {\n throw new Error(\n `Invalid hook supplied when trying to register an handler to the permission engine. Got \"${hook}\" but expected one of ${validHooks.join(\n ', '\n )}`\n );\n }\n\n state.hooks[hook].register(handler);\n\n return this;\n },\n\n /**\n * Generate an ability based on the instance's\n * ability builder and the given permissions\n */\n async generateAbility(permissions, options: Record<string, unknown> = {}) {\n const { can, build } = abilityBuilderFactory();\n\n for (const permission of permissions) {\n const register = this.createRegisterFunction(can, options);\n\n await evaluate({ permission, options, register });\n }\n\n return build();\n },\n };\n};\n\nexport { newEngine as new };\n"],"names":["domain.permission.addCondition","rest","hooks","abilities.caslAbilityBuilder","params","conditions"],"mappings":";;;;;AAEA,MAAM,oBAAoB,CAAC,UAAU,WAAW,cAAc,YAAY;AAE1E,MAAM,2BAA2B,EAAE,KAAK,iBAAiB;AAazD,MAAM,uBAAuB,OAAkE;AAAA,EAC7F,YAAY,CAAC;AAAA,EACb,YAAY,CAAC;AAAA,EACb,SAAS;AACX;AAOA,MAAM,SAAS,EAAE,KAAK,EAAE,KAAK,iBAAiB,GAAG,EAAE,MAAM,qBAAqB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AAY,SAAS,SAAU,CAAA;AAAA,MAClD;AAEA,aAAO,MAAM;AAAA,IACf;AAAA,EAAA;AAEJ;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/permissions",
3
- "version": "4.15.0-alpha.0",
3
+ "version": "4.15.0",
4
4
  "description": "Strapi's permission layer.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,35 +19,38 @@
19
19
  "url": "https://strapi.io"
20
20
  }
21
21
  ],
22
+ "main": "./dist/index.js",
23
+ "module": "./dist/index.mjs",
24
+ "source": "./src/index.ts",
25
+ "types": "./dist/index.d.ts",
22
26
  "files": [
23
27
  "./dist"
24
28
  ],
25
- "main": "./dist/index.js",
26
- "types": "./dist/index.d.ts",
27
29
  "scripts": {
28
- "build": "run -T tsc",
29
- "build:ts": "run build",
30
- "watch": "run -T tsc -w --preserveWatchOutput",
30
+ "build": "pack-up build",
31
31
  "clean": "run -T rimraf ./dist",
32
+ "lint": "run -T eslint .",
32
33
  "prepublishOnly": "yarn clean && yarn build",
34
+ "test:ts": "run -T tsc --noEmit",
33
35
  "test:unit": "run -T jest",
34
36
  "test:unit:watch": "run -T jest --watch",
35
- "lint": "run -T eslint ."
37
+ "watch": "pack-up watch"
36
38
  },
37
39
  "dependencies": {
38
40
  "@casl/ability": "6.5.0",
39
- "@strapi/utils": "4.15.0-alpha.0",
41
+ "@strapi/utils": "4.15.0",
40
42
  "lodash": "4.17.21",
41
43
  "qs": "6.11.1",
42
44
  "sift": "16.0.1"
43
45
  },
44
46
  "devDependencies": {
45
- "eslint-config-custom": "4.15.0-alpha.0",
46
- "tsconfig": "4.15.0-alpha.0"
47
+ "@strapi/pack-up": "4.15.0",
48
+ "eslint-config-custom": "4.15.0",
49
+ "tsconfig": "4.15.0"
47
50
  },
48
51
  "engines": {
49
- "node": ">=16.0.0 <=20.x.x",
52
+ "node": ">=18.0.0 <=20.x.x",
50
53
  "npm": ">=6.0.0"
51
54
  },
52
- "gitHead": "682a070df9ef90f2aa6966666488e066d61831e2"
55
+ "gitHead": "6e44e1e68db5153e485e61bdc03f42efb0311406"
53
56
  }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.permission = void 0;
27
- const permission = __importStar(require("./permission"));
28
- exports.permission = permission;
29
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAElC,gCAAU"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getProperty = exports.addCondition = exports.sanitizePermissionFields = exports.create = void 0;
7
- const fp_1 = __importDefault(require("lodash/fp"));
8
- const PERMISSION_FIELDS = ['action', 'subject', 'properties', 'conditions'];
9
- const sanitizePermissionFields = fp_1.default.pick(PERMISSION_FIELDS);
10
- exports.sanitizePermissionFields = sanitizePermissionFields;
11
- /**
12
- * Creates a permission with default values for optional properties
13
- */
14
- const getDefaultPermission = () => ({
15
- conditions: [],
16
- properties: {},
17
- subject: null,
18
- });
19
- /**
20
- * Create a new permission based on given attributes
21
- *
22
- * @param {object} attributes
23
- */
24
- const create = fp_1.default.pipe(fp_1.default.pick(PERMISSION_FIELDS), fp_1.default.merge(getDefaultPermission()));
25
- exports.create = create;
26
- /**
27
- * Add a condition to a permission
28
- */
29
- const addCondition = fp_1.default.curry((condition, permission) => {
30
- const { conditions } = permission;
31
- const newConditions = Array.isArray(conditions)
32
- ? fp_1.default.uniq(conditions.concat(condition))
33
- : [condition];
34
- return fp_1.default.set('conditions', newConditions, permission);
35
- });
36
- exports.addCondition = addCondition;
37
- /**
38
- * Gets a property or a part of a property from a permission.
39
- */
40
- const getProperty = fp_1.default.curry((property, permission) => fp_1.default.get(`properties.${property}`, permission));
41
- exports.getProperty = getProperty;
42
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/permission/index.ts"],"names":[],"mappings":";;;;;;AAAA,mDAA0B;AAE1B,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AAErF,MAAM,wBAAwB,GAAG,YAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAiD1C,4DAAwB;AAvCzC;;GAEG;AACH,MAAM,oBAAoB,GAAG,GAA8D,EAAE,CAAC,CAAC;IAC7F,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,IAAI;CACd,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,GAAG,YAAC,CAAC,IAAI,CAAC,YAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,YAAC,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;AAyBzE,wBAAM;AAvBf;;GAEG;AACH,MAAM,YAAY,GAAG,YAAC,CAAC,KAAK,CAAC,CAAC,SAAiB,EAAE,UAAsB,EAAc,EAAE;IACrF,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC;IAElC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAC7C,CAAC,CAAC,YAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEhB,OAAO,YAAC,CAAC,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC;AAYwC,oCAAY;AAVvD;;GAEG;AACH,MAAM,WAAW,GAAG,YAAC,CAAC,KAAK,CACzB,CACE,QAAW,EACX,UAAsB,EACO,EAAE,CAAC,YAAC,CAAC,GAAG,CAAC,cAAc,QAAQ,EAAE,EAAE,UAAU,CAAC,CAC9E,CAAC;AAEuD,kCAAW"}
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.caslAbilityBuilder = void 0;
30
- const sift = __importStar(require("sift"));
31
- const qs_1 = __importDefault(require("qs"));
32
- const ability_1 = require("@casl/ability");
33
- const fp_1 = require("lodash/fp");
34
- const allowedOperations = [
35
- '$or',
36
- '$and',
37
- '$eq',
38
- '$ne',
39
- '$in',
40
- '$nin',
41
- '$lt',
42
- '$lte',
43
- '$gt',
44
- '$gte',
45
- '$exists',
46
- '$elemMatch',
47
- ];
48
- const operations = (0, fp_1.pick)(allowedOperations, sift);
49
- const conditionsMatcher = (conditions) => {
50
- return sift.createQueryTester(conditions, { operations });
51
- };
52
- const buildParametrizedAction = ({ name, params }) => {
53
- return `${name}?${qs_1.default.stringify(params)}`;
54
- };
55
- /**
56
- * Casl Ability Builder.
57
- */
58
- const caslAbilityBuilder = () => {
59
- const { can, build, ...rest } = new ability_1.AbilityBuilder(ability_1.Ability);
60
- return {
61
- can(permission) {
62
- const { action, subject, properties = {}, condition } = permission;
63
- const { fields } = properties;
64
- const caslAction = typeof action === 'string' ? action : buildParametrizedAction(action);
65
- return can(caslAction, (0, fp_1.isNil)(subject) ? 'all' : subject, fields, (0, fp_1.isObject)(condition) ? condition : undefined);
66
- },
67
- buildParametrizedAction({ name, params }) {
68
- return `${name}?${qs_1.default.stringify(params)}`;
69
- },
70
- build() {
71
- const ability = build({ conditionsMatcher });
72
- function decorateCan(originalCan) {
73
- return function (...args) {
74
- const [action, ...rest] = args;
75
- const caslAction = typeof action === 'string' ? action : buildParametrizedAction(action);
76
- // Call the original `can` method
77
- return originalCan.apply(ability, [caslAction, ...rest]);
78
- };
79
- }
80
- ability.can = decorateCan(ability.can);
81
- return ability;
82
- },
83
- ...rest,
84
- };
85
- };
86
- exports.caslAbilityBuilder = caslAbilityBuilder;
87
- //# sourceMappingURL=casl-ability.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"casl-ability.js","sourceRoot":"","sources":["../../../src/engine/abilities/casl-ability.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,4CAAoB;AACpB,2CAAiE;AACjE,kCAAkD;AAsBlD,MAAM,iBAAiB,GAAG;IACxB,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,SAAS;IACT,YAAY;CACJ,CAAC;AAEX,MAAM,UAAU,GAAG,IAAA,SAAI,EAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAEjD,MAAM,iBAAiB,GAAG,CAAC,UAAmB,EAAE,EAAE;IAChD,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAsB,EAAE,EAAE;IACvE,OAAO,GAAG,IAAI,IAAI,YAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;AAC3C,CAAC,CAAC;AAEF;;GAEG;AACI,MAAM,kBAAkB,GAAG,GAAyB,EAAE;IAC3D,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,wBAAc,CAAC,iBAAO,CAAC,CAAC;IAE5D,OAAO;QACL,GAAG,CAAC,UAA0B;YAC5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;YACnE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;YAE9B,MAAM,U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, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./casl-ability"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}