@keystonejs/access-control
Advanced tools
Comparing version 7.0.0 to 7.0.1
# @keystonejs/access-control | ||
## 7.0.1 | ||
### Patch Changes | ||
- [`04bf1e4bb`](https://github.com/keystonejs/keystone-5/commit/04bf1e4bb0223f4e2e06664bbc9e95c51118eb84) [#2](https://github.com/keystonejs/keystone-5/pull/2) Thanks [@bladey](https://github.com/bladey)! - Updated repository URL in package.json. | ||
* [`15b1132d2`](https://github.com/keystonejs/keystone-5/commit/15b1132d20d13f79bbf1707e1897b31da887c2b7) Thanks [@timleslie](https://github.com/timleslie)! - Updated types to be parameterised by imperative argument type. | ||
* Updated dependencies [[`04bf1e4bb`](https://github.com/keystonejs/keystone-5/commit/04bf1e4bb0223f4e2e06664bbc9e95c51118eb84)]: | ||
- @keystonejs/utils@6.0.2 | ||
## 7.0.0 | ||
@@ -7,3 +18,3 @@ | ||
- [`28a61dc67`](https://github.com/keystonejs/keystone/commit/28a61dc67b990ebd16bfc4e1c0a1e9ffb0e54d81) [#4801](https://github.com/keystonejs/keystone/pull/4801) Thanks [@timleslie](https://github.com/timleslie)! - Converted the `@keystonejs/access-control` package to TypeScript. | ||
- [`28a61dc67`](https://github.com/keystonejs/keystone-5/commit/28a61dc67b990ebd16bfc4e1c0a1e9ffb0e54d81) [#4801](https://github.com/keystonejs/keystone-5/pull/4801) Thanks [@timleslie](https://github.com/timleslie)! - Converted the `@keystonejs/access-control` package to TypeScript. | ||
@@ -14,15 +25,15 @@ ## 6.3.2 | ||
- [`619ef5051`](https://github.com/keystonejs/keystone/commit/619ef50512c09d7cf988dc3c877eed868eba68a6) [#4730](https://github.com/keystonejs/keystone/pull/4730) Thanks [@timleslie](https://github.com/timleslie)! - Refactored access parsing to separate parsing from validation. | ||
- [`619ef5051`](https://github.com/keystonejs/keystone-5/commit/619ef50512c09d7cf988dc3c877eed868eba68a6) [#4730](https://github.com/keystonejs/keystone-5/pull/4730) Thanks [@timleslie](https://github.com/timleslie)! - Refactored access parsing to separate parsing from validation. | ||
* [`86b597d41`](https://github.com/keystonejs/keystone/commit/86b597d410c907ed54a4948da438de48e313302f) [#4724](https://github.com/keystonejs/keystone/pull/4724) Thanks [@timleslie](https://github.com/timleslie)! - Rearranged code to have an explicit exports group. | ||
* [`86b597d41`](https://github.com/keystonejs/keystone-5/commit/86b597d410c907ed54a4948da438de48e313302f) [#4724](https://github.com/keystonejs/keystone-5/pull/4724) Thanks [@timleslie](https://github.com/timleslie)! - Rearranged code to have an explicit exports group. | ||
- [`c1257ca83`](https://github.com/keystonejs/keystone/commit/c1257ca834ccf5a0407debe6e7d27b45ed32a26a) [#4727](https://github.com/keystonejs/keystone/pull/4727) Thanks [@timleslie](https://github.com/timleslie)! - Refactored out `parseAccess` and added `checkSchemaNames`. | ||
- [`c1257ca83`](https://github.com/keystonejs/keystone-5/commit/c1257ca834ccf5a0407debe6e7d27b45ed32a26a) [#4727](https://github.com/keystonejs/keystone-5/pull/4727) Thanks [@timleslie](https://github.com/timleslie)! - Refactored out `parseAccess` and added `checkSchemaNames`. | ||
* [`5e22cc765`](https://github.com/keystonejs/keystone/commit/5e22cc765a8f18c467457fd2ba738cd90273c8c5) [#4725](https://github.com/keystonejs/keystone/pull/4725) Thanks [@timleslie](https://github.com/timleslie)! - Refactored calls to `validateGranularConfigTypes` to be more explicit. | ||
* [`5e22cc765`](https://github.com/keystonejs/keystone-5/commit/5e22cc765a8f18c467457fd2ba738cd90273c8c5) [#4725](https://github.com/keystonejs/keystone-5/pull/4725) Thanks [@timleslie](https://github.com/timleslie)! - Refactored calls to `validateGranularConfigTypes` to be more explicit. | ||
- [`b9ec7fff9`](https://github.com/keystonejs/keystone/commit/b9ec7fff9d96ac56e2836543d698cf0b62b5dc8f) [#4723](https://github.com/keystonejs/keystone/pull/4723) Thanks [@timleslie](https://github.com/timleslie)! - Replaced usage of `getType()` with `typeof`. | ||
- [`b9ec7fff9`](https://github.com/keystonejs/keystone-5/commit/b9ec7fff9d96ac56e2836543d698cf0b62b5dc8f) [#4723](https://github.com/keystonejs/keystone-5/pull/4723) Thanks [@timleslie](https://github.com/timleslie)! - Replaced usage of `getType()` with `typeof`. | ||
* [`5ad7c12e8`](https://github.com/keystonejs/keystone/commit/5ad7c12e86573e73e85368076bdc1296f3f69db3) [#4726](https://github.com/keystonejs/keystone/pull/4726) Thanks [@timleslie](https://github.com/timleslie)! - Refactored `parseAccess` and inlined the code from `validateGranularConfigTypes` and `parseAccessCore`. | ||
* [`5ad7c12e8`](https://github.com/keystonejs/keystone-5/commit/5ad7c12e86573e73e85368076bdc1296f3f69db3) [#4726](https://github.com/keystonejs/keystone-5/pull/4726) Thanks [@timleslie](https://github.com/timleslie)! - Refactored `parseAccess` and inlined the code from `validateGranularConfigTypes` and `parseAccessCore`. | ||
* Updated dependencies [[`94c8d349d`](https://github.com/keystonejs/keystone/commit/94c8d349d3795cd9abec407f78752417623ee56f)]: | ||
* Updated dependencies [[`94c8d349d`](https://github.com/keystonejs/keystone-5/commit/94c8d349d3795cd9abec407f78752417623ee56f)]: | ||
- @keystonejs/utils@6.0.1 | ||
@@ -34,3 +45,3 @@ | ||
- Updated dependencies [[`b76241695`](https://github.com/keystonejs/keystone/commit/b7624169554b01dba2185ef43856a223d32f12be)]: | ||
- Updated dependencies [[`b76241695`](https://github.com/keystonejs/keystone-5/commit/b7624169554b01dba2185ef43856a223d32f12be)]: | ||
- @keystonejs/utils@6.0.0 | ||
@@ -42,3 +53,3 @@ | ||
- [`5a3849806`](https://github.com/keystonejs/keystone/commit/5a3849806d00e62b722461d02f6e4639bc45c1eb) [#3262](https://github.com/keystonejs/keystone/pull/3262) Thanks [@MadeByMike](https://github.com/MadeByMike)! - Added a new private internal schema that will allow a better method of bypassing access control on the `executeGraphQL` function. | ||
- [`5a3849806`](https://github.com/keystonejs/keystone-5/commit/5a3849806d00e62b722461d02f6e4639bc45c1eb) [#3262](https://github.com/keystonejs/keystone-5/pull/3262) Thanks [@MadeByMike](https://github.com/MadeByMike)! - Added a new private internal schema that will allow a better method of bypassing access control on the `executeGraphQL` function. | ||
@@ -53,3 +64,3 @@ The schema name `internal` is now a reserved name and if you have a schema with this name you will need to change it with this update. | ||
- [`dec3d336a`](https://github.com/keystonejs/keystone/commit/dec3d336adbe8156722fbe65f315a57b2f5c08e7) [#3153](https://github.com/keystonejs/keystone/pull/3153) Thanks [@timleslie](https://github.com/timleslie)! - Made `context` available to user designed access control functions. | ||
- [`dec3d336a`](https://github.com/keystonejs/keystone-5/commit/dec3d336adbe8156722fbe65f315a57b2f5c08e7) [#3153](https://github.com/keystonejs/keystone-5/pull/3153) Thanks [@timleslie](https://github.com/timleslie)! - Made `context` available to user designed access control functions. | ||
@@ -60,3 +71,3 @@ ## 6.1.0 | ||
- [`463f55233`](https://github.com/keystonejs/keystone/commit/463f552335013d5ba9ebf2e8f7a9ebf8e2b0e0db) [#3095](https://github.com/keystonejs/keystone/pull/3095) Thanks [@timleslie](https://github.com/timleslie)! - Added `{ item, args, context, info, gqlName }` to the arguments available in access control functions for custom queries/mutations. | ||
- [`463f55233`](https://github.com/keystonejs/keystone-5/commit/463f552335013d5ba9ebf2e8f7a9ebf8e2b0e0db) [#3095](https://github.com/keystonejs/keystone-5/pull/3095) Thanks [@timleslie](https://github.com/timleslie)! - Added `{ item, args, context, info, gqlName }` to the arguments available in access control functions for custom queries/mutations. | ||
@@ -67,3 +78,3 @@ ## 6.0.0 | ||
- [`839666e25`](https://github.com/keystonejs/keystone/commit/839666e25d8bffefd034e6344e11d72dd43b925b) [#2872](https://github.com/keystonejs/keystone/pull/2872) Thanks [@wcalebgray](https://github.com/wcalebgray)! - Added async capability for all Access Control resolvers. This changes the below methods to async functions, returning Promises: | ||
- [`839666e25`](https://github.com/keystonejs/keystone-5/commit/839666e25d8bffefd034e6344e11d72dd43b925b) [#2872](https://github.com/keystonejs/keystone-5/pull/2872) Thanks [@wcalebgray](https://github.com/wcalebgray)! - Added async capability for all Access Control resolvers. This changes the below methods to async functions, returning Promises: | ||
@@ -102,9 +113,9 @@ ``` | ||
- [`42497b8e`](https://github.com/keystonejs/keystone/commit/42497b8ebbaeaf0f4d7881dbb76c6abafde4cace) [#2456](https://github.com/keystonejs/keystone/pull/2456) Thanks [@timleslie](https://github.com/timleslie)! - Added `validateAuthAccessControl` as a special case for validating access control on authentication queries and mutations. | ||
- [`42497b8e`](https://github.com/keystonejs/keystone-5/commit/42497b8ebbaeaf0f4d7881dbb76c6abafde4cace) [#2456](https://github.com/keystonejs/keystone-5/pull/2456) Thanks [@timleslie](https://github.com/timleslie)! - Added `validateAuthAccessControl` as a special case for validating access control on authentication queries and mutations. | ||
### Patch Changes | ||
- [`5ba330b8`](https://github.com/keystonejs/keystone/commit/5ba330b8b2609ea0033a636daf9a215a5a192c20) [#2487](https://github.com/keystonejs/keystone/pull/2487) Thanks [@Noviny](https://github.com/Noviny)! - Small changes to package.json (mostly adding a repository field) | ||
- [`5ba330b8`](https://github.com/keystonejs/keystone-5/commit/5ba330b8b2609ea0033a636daf9a215a5a192c20) [#2487](https://github.com/keystonejs/keystone-5/pull/2487) Thanks [@Noviny](https://github.com/Noviny)! - Small changes to package.json (mostly adding a repository field) | ||
- Updated dependencies [[`5ba330b8`](https://github.com/keystonejs/keystone/commit/5ba330b8b2609ea0033a636daf9a215a5a192c20)]: | ||
- Updated dependencies [[`5ba330b8`](https://github.com/keystonejs/keystone-5/commit/5ba330b8b2609ea0033a636daf9a215a5a192c20)]: | ||
- @keystonejs/utils@5.2.2 | ||
@@ -116,7 +127,7 @@ | ||
- [`517b23e4`](https://github.com/keystonejs/keystone/commit/517b23e4b17414ed1807e8d7af1e67377ba3b7bf) [#2391](https://github.com/keystonejs/keystone/pull/2391) Thanks [@timleslie](https://github.com/timleslie)! - Removed support for Node 8.x, as it is [no longer in maintenance mode](https://nodejs.org/en/about/releases/). | ||
- [`517b23e4`](https://github.com/keystonejs/keystone-5/commit/517b23e4b17414ed1807e8d7af1e67377ba3b7bf) [#2391](https://github.com/keystonejs/keystone-5/pull/2391) Thanks [@timleslie](https://github.com/timleslie)! - Removed support for Node 8.x, as it is [no longer in maintenance mode](https://nodejs.org/en/about/releases/). | ||
### Patch Changes | ||
- Updated dependencies [[`517b23e4`](https://github.com/keystonejs/keystone/commit/517b23e4b17414ed1807e8d7af1e67377ba3b7bf)]: | ||
- Updated dependencies [[`517b23e4`](https://github.com/keystonejs/keystone-5/commit/517b23e4b17414ed1807e8d7af1e67377ba3b7bf)]: | ||
- @keystonejs/utils@5.2.0 | ||
@@ -128,3 +139,3 @@ | ||
- [`7b4ed362`](https://github.com/keystonejs/keystone/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310) [#1821](https://github.com/keystonejs/keystone/pull/1821) Thanks [@jesstelford](https://github.com/jesstelford)! - Release @keystonejs/\* packages (つ^ ◡ ^)つ | ||
- [`7b4ed362`](https://github.com/keystonejs/keystone-5/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310) [#1821](https://github.com/keystonejs/keystone-5/pull/1821) Thanks [@jesstelford](https://github.com/jesstelford)! - Release @keystonejs/\* packages (つ^ ◡ ^)つ | ||
@@ -137,3 +148,3 @@ - This is the first release of `@keystonejs/*` packages (previously `@keystone-alpha/*`). | ||
- Updated dependencies [[`7b4ed362`](https://github.com/keystonejs/keystone/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310)]: | ||
- Updated dependencies [[`7b4ed362`](https://github.com/keystonejs/keystone-5/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310)]: | ||
- @keystonejs/utils@5.0.0 | ||
@@ -147,3 +158,3 @@ | ||
- [1405eb07](https://github.com/keystonejs/keystone/commit/1405eb07): Add `listKey`, `fieldKey` (fields only), `operation`, `gqlName`, `itemId` and `itemIds` as arguments to imperative access control functions. | ||
- [1405eb07](https://github.com/keystonejs/keystone-5/commit/1405eb07): Add `listKey`, `fieldKey` (fields only), `operation`, `gqlName`, `itemId` and `itemIds` as arguments to imperative access control functions. | ||
@@ -154,3 +165,3 @@ ## 3.0.0 | ||
- [9ade2b2d](https://github.com/keystonejs/keystone/commit/9ade2b2d): Add support for `access: { auth: ... }` which controls whether authentication queries and mutations are accessible on a List | ||
- [9ade2b2d](https://github.com/keystonejs/keystone-5/commit/9ade2b2d): Add support for `access: { auth: ... }` which controls whether authentication queries and mutations are accessible on a List | ||
@@ -161,8 +172,8 @@ If you have a `List` which is being used as the target of an Authentication Strategy, you should set `access: { auth: true }` on that list. | ||
- [b61289b4](https://github.com/keystonejs/keystone/commit/b61289b4): Add `parseCustomAccess()` for parsing the access control directives on custom types/queries/mutations. | ||
- [0bba9f07](https://github.com/keystonejs/keystone/commit/0bba9f07): Add `validateCustomAccessControl()` for use by custom queries/mutations access control checking. | ||
- [b61289b4](https://github.com/keystonejs/keystone-5/commit/b61289b4): Add `parseCustomAccess()` for parsing the access control directives on custom types/queries/mutations. | ||
- [0bba9f07](https://github.com/keystonejs/keystone-5/commit/0bba9f07): Add `validateCustomAccessControl()` for use by custom queries/mutations access control checking. | ||
### Patch Changes | ||
- [9ece715c](https://github.com/keystonejs/keystone/commit/9ece715c): Refactor access-control internals to better support future changes | ||
- [9ece715c](https://github.com/keystonejs/keystone-5/commit/9ece715c): Refactor access-control internals to better support future changes | ||
@@ -173,3 +184,3 @@ ## 2.0.0 | ||
- [bc0b9813](https://github.com/keystonejs/keystone/commit/bc0b9813): `parseListAccess` and `parseFieldAccess` now take `schemaNames` as an argument, and return a nested access object, with the `schemaNames` as keys. | ||
- [bc0b9813](https://github.com/keystonejs/keystone-5/commit/bc0b9813): `parseListAccess` and `parseFieldAccess` now take `schemaNames` as an argument, and return a nested access object, with the `schemaNames` as keys. | ||
@@ -211,3 +222,3 @@ For example, | ||
- [e5d4ee76](https://github.com/keystonejs/keystone/commit/e5d4ee76): Expose 'originalInput' to access control functions for lists & fields | ||
- [e5d4ee76](https://github.com/keystonejs/keystone-5/commit/e5d4ee76): Expose 'originalInput' to access control functions for lists & fields | ||
@@ -218,3 +229,3 @@ ## 1.0.5 | ||
- [19fe6c1b](https://github.com/keystonejs/keystone/commit/19fe6c1b): | ||
- [19fe6c1b](https://github.com/keystonejs/keystone-5/commit/19fe6c1b): | ||
@@ -225,3 +236,3 @@ Move frontmatter in docs into comments | ||
- Updated dependencies [b7a2ea9c](https://github.com/keystonejs/keystone/commit/b7a2ea9c): | ||
- Updated dependencies [b7a2ea9c](https://github.com/keystonejs/keystone-5/commit/b7a2ea9c): | ||
- @keystone-alpha/utils@3.0.0 | ||
@@ -231,3 +242,3 @@ | ||
- [patch][10d96db2](https://github.com/keystonejs/keystone/commit/10d96db2): | ||
- [patch][10d96db2](https://github.com/keystonejs/keystone-5/commit/10d96db2): | ||
@@ -238,3 +249,3 @@ - Restructure internal code | ||
- Updated dependencies [98c02a46](https://github.com/keystonejs/keystone/commit/98c02a46): | ||
- Updated dependencies [98c02a46](https://github.com/keystonejs/keystone-5/commit/98c02a46): | ||
- @keystone-alpha/utils@2.0.0 | ||
@@ -244,7 +255,7 @@ | ||
- [patch][1f0bc236](https://github.com/keystonejs/keystone/commit/1f0bc236): | ||
- [patch][1f0bc236](https://github.com/keystonejs/keystone-5/commit/1f0bc236): | ||
- Update the package.json author field to "The Keystone Development Team" | ||
- [patch][9534f98f](https://github.com/keystonejs/keystone/commit/9534f98f): | ||
- [patch][9534f98f](https://github.com/keystonejs/keystone-5/commit/9534f98f): | ||
@@ -251,0 +262,0 @@ - Add README.md to package |
@@ -7,3 +7,3 @@ declare type Static = boolean; | ||
declare type ListAccessArgs = { | ||
operation: keyof ListAccess; | ||
operation: keyof ListAccess<ListAccessArgs>; | ||
listKey: string; | ||
@@ -18,3 +18,3 @@ authentication: any; | ||
declare type FieldAccessArgs = { | ||
operation: keyof FieldAccess; | ||
operation: keyof FieldAccess<FieldAccessArgs>; | ||
listKey: string; | ||
@@ -31,3 +31,3 @@ fieldKey: string; | ||
declare type AuthAccessArgs = { | ||
operation: keyof AuthAccess; | ||
operation: keyof AuthAccess<AuthAccessArgs>; | ||
listKey: string; | ||
@@ -46,54 +46,54 @@ authentication: any; | ||
}; | ||
declare type ListAccess = { | ||
create: Static | Declarative | Imperative<ListAccessArgs>; | ||
read: Static | Declarative | Imperative<ListAccessArgs>; | ||
update: Static | Declarative | Imperative<ListAccessArgs>; | ||
delete: Static | Declarative | Imperative<ListAccessArgs>; | ||
declare type ListAccess<Args> = { | ||
create: Static | Declarative | Imperative<Args>; | ||
read: Static | Declarative | Imperative<Args>; | ||
update: Static | Declarative | Imperative<Args>; | ||
delete: Static | Declarative | Imperative<Args>; | ||
}; | ||
declare type AuthAccess = { | ||
auth: Static | Declarative | Imperative<AuthAccessArgs>; | ||
declare type AuthAccess<Args> = { | ||
auth: Static | Declarative | Imperative<Args>; | ||
}; | ||
declare type FieldAccess = { | ||
create: Static | FieldImperative<FieldAccessArgs>; | ||
read: Static | FieldImperative<FieldAccessArgs>; | ||
update: Static | FieldImperative<FieldAccessArgs>; | ||
declare type FieldAccess<Args> = { | ||
create: Static | FieldImperative<Args>; | ||
read: Static | FieldImperative<Args>; | ||
update: Static | FieldImperative<Args>; | ||
}; | ||
declare type CustomAccess = Static | Declarative | Imperative<CustomAccessArgs>; | ||
export declare function parseCustomAccess<SN extends string>({ defaultAccess, access, schemaNames, }: { | ||
defaultAccess: CustomAccess; | ||
access?: Partial<Record<SN, CustomAccess>> | CustomAccess; | ||
declare type CustomAccess<Args> = Static | Declarative | Imperative<Args>; | ||
export declare function parseCustomAccess<SN extends string, Args>({ defaultAccess, access, schemaNames, }: { | ||
defaultAccess: CustomAccess<Args>; | ||
access?: Partial<Record<SN, CustomAccess<Args>>> | CustomAccess<Args>; | ||
schemaNames: SN[]; | ||
}): Record<SN, CustomAccess> & { | ||
}): Record<SN, CustomAccess<Args>> & { | ||
internal: true; | ||
}; | ||
declare type ListAuthAccess = ListAccess & AuthAccess; | ||
export declare function parseListAccess<SN extends string>({ listKey, defaultAccess, access, schemaNames, }: { | ||
declare type ListAuthAccess<Args> = ListAccess<Args> & AuthAccess<Args>; | ||
export declare function parseListAccess<SN extends string, Args>({ listKey, defaultAccess, access, schemaNames, }: { | ||
listKey: string; | ||
defaultAccess: ListAccess['read']; | ||
access?: Partial<Record<SN, Partial<ListAuthAccess> | ListAccess['read']>> | Partial<ListAuthAccess> | ListAccess['read']; | ||
defaultAccess: ListAccess<Args>['read']; | ||
access?: Partial<Record<SN, Partial<ListAuthAccess<Args>> | ListAccess<Args>['read']>> | Partial<ListAuthAccess<Args>> | ListAccess<Args>['read']; | ||
schemaNames: SN[]; | ||
}): Record<SN, ListAuthAccess> & { | ||
internal: Record<"update" | "create" | "delete" | "read" | "auth", true>; | ||
}): Record<SN, ListAuthAccess<Args>> & { | ||
internal: Record<"create" | "read" | "update" | "delete" | "auth", true>; | ||
}; | ||
export declare function parseFieldAccess<SN extends string>({ listKey, fieldKey, defaultAccess, access, schemaNames, }: { | ||
export declare function parseFieldAccess<SN extends string, Args>({ listKey, fieldKey, defaultAccess, access, schemaNames, }: { | ||
listKey: string; | ||
fieldKey: string; | ||
defaultAccess: FieldAccess['read']; | ||
access?: Partial<Record<SN, Partial<FieldAccess> | FieldAccess['read']>> | Partial<FieldAccess> | FieldAccess['read']; | ||
defaultAccess: FieldAccess<Args>['read']; | ||
access?: Partial<Record<SN, Partial<FieldAccess<Args>> | FieldAccess<Args>['read']>> | Partial<FieldAccess<Args>> | FieldAccess<Args>['read']; | ||
schemaNames: SN[]; | ||
}): Record<SN, FieldAccess> & { | ||
internal: Record<"update" | "create" | "read", true>; | ||
}): Record<SN, FieldAccess<Args>> & { | ||
internal: Record<"create" | "read" | "update", true>; | ||
}; | ||
export declare function validateCustomAccessControl({ item, args, context, info, access, authentication, gqlName, }: { | ||
access: CustomAccess; | ||
access: CustomAccess<CustomAccessArgs>; | ||
} & CustomAccessArgs): Promise<boolean | Record<string, any>>; | ||
export declare function validateListAccessControl({ access, listKey, operation, authentication, originalInput, gqlName, itemId, itemIds, context, }: { | ||
access: ListAccess; | ||
access: ListAccess<ListAccessArgs>; | ||
} & ListAccessArgs): Promise<boolean | Record<string, any>>; | ||
export declare function validateFieldAccessControl({ access, listKey, fieldKey, originalInput, existingItem, operation, authentication, gqlName, itemId, itemIds, context, }: { | ||
access: FieldAccess; | ||
access: FieldAccess<FieldAccessArgs>; | ||
} & FieldAccessArgs): Promise<boolean>; | ||
export declare function validateAuthAccessControl({ access, listKey, authentication, gqlName, context, }: { | ||
access: AuthAccess; | ||
access: AuthAccess<AuthAccessArgs>; | ||
} & Omit<AuthAccessArgs, 'operation'>): Promise<boolean | Record<string, any>>; | ||
export {}; |
{ | ||
"name": "@keystonejs/access-control", | ||
"description": "KeystoneJS Access Control parsing and validating utilities.", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"author": "The KeystoneJS Development Team", | ||
@@ -13,5 +13,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@keystonejs/utils": "^6.0.1" | ||
"@keystonejs/utils": "^6.0.2" | ||
}, | ||
"repository": "https://github.com/keystonejs/keystone/tree/master/packages/access-control" | ||
"repository": "https://github.com/keystonejs/keystone-5/tree/master/packages/access-control" | ||
} |
@@ -12,3 +12,3 @@ import { pick, defaultObj, intersection } from '@keystonejs/utils'; | ||
type ListAccessArgs = { | ||
operation: keyof ListAccess; | ||
operation: keyof ListAccess<ListAccessArgs>; | ||
listKey: string; | ||
@@ -23,3 +23,3 @@ authentication: any; | ||
type FieldAccessArgs = { | ||
operation: keyof FieldAccess; | ||
operation: keyof FieldAccess<FieldAccessArgs>; | ||
listKey: string; | ||
@@ -36,3 +36,3 @@ fieldKey: string; | ||
type AuthAccessArgs = { | ||
operation: keyof AuthAccess; | ||
operation: keyof AuthAccess<AuthAccessArgs>; | ||
listKey: string; | ||
@@ -52,20 +52,19 @@ authentication: any; | ||
type ListAccess = { | ||
create: Static | Declarative | Imperative<ListAccessArgs>; | ||
read: Static | Declarative | Imperative<ListAccessArgs>; | ||
update: Static | Declarative | Imperative<ListAccessArgs>; | ||
delete: Static | Declarative | Imperative<ListAccessArgs>; | ||
type ListAccess<Args> = { | ||
create: Static | Declarative | Imperative<Args>; | ||
read: Static | Declarative | Imperative<Args>; | ||
update: Static | Declarative | Imperative<Args>; | ||
delete: Static | Declarative | Imperative<Args>; | ||
}; | ||
type AuthAccess = { | ||
auth: Static | Declarative | Imperative<AuthAccessArgs>; | ||
type AuthAccess<Args> = { | ||
auth: Static | Declarative | Imperative<Args>; | ||
}; | ||
type FieldAccess = { | ||
create: Static | FieldImperative<FieldAccessArgs>; | ||
read: Static | FieldImperative<FieldAccessArgs>; | ||
update: Static | FieldImperative<FieldAccessArgs>; | ||
type FieldAccess<Args> = { | ||
create: Static | FieldImperative<Args>; | ||
read: Static | FieldImperative<Args>; | ||
update: Static | FieldImperative<Args>; | ||
}; | ||
// Note: Declarative here (custom) is really just Record<string,any> and is returned to the user | ||
// to do whatever they want with... | ||
type CustomAccess = Static | Declarative | Imperative<CustomAccessArgs>; | ||
type CustomAccess<Args> = Static | Declarative | Imperative<Args>; | ||
@@ -109,3 +108,3 @@ const checkSchemaNames = ({ | ||
export function parseCustomAccess<SN extends string>({ | ||
export function parseCustomAccess<SN extends string, Args>({ | ||
defaultAccess, | ||
@@ -115,4 +114,4 @@ access = defaultAccess, | ||
}: { | ||
defaultAccess: CustomAccess; | ||
access?: Partial<Record<SN, CustomAccess>> | CustomAccess; | ||
defaultAccess: CustomAccess<Args>; | ||
access?: Partial<Record<SN, CustomAccess<Args>>> | CustomAccess<Args>; | ||
schemaNames: SN[]; | ||
@@ -124,3 +123,3 @@ }) { | ||
type GG = CustomAccess; | ||
type GG = CustomAccess<Args>; | ||
const fullAccess = keyedBySchemaName | ||
@@ -143,4 +142,4 @@ ? { ...defaultObj(schemaNames, defaultAccess), ...(access as Partial<Record<SN, GG>>) } // Access keyed by schemaName | ||
type ListAuthAccess = ListAccess & AuthAccess; | ||
export function parseListAccess<SN extends string>({ | ||
type ListAuthAccess<Args> = ListAccess<Args> & AuthAccess<Args>; | ||
export function parseListAccess<SN extends string, Args>({ | ||
listKey, | ||
@@ -152,14 +151,20 @@ defaultAccess, | ||
listKey: string; | ||
defaultAccess: ListAccess['read']; | ||
defaultAccess: ListAccess<Args>['read']; | ||
access?: | ||
| Partial<Record<SN, Partial<ListAuthAccess> | ListAccess['read']>> | ||
| Partial<ListAuthAccess> | ||
| ListAccess['read']; | ||
| Partial<Record<SN, Partial<ListAuthAccess<Args>> | ListAccess<Args>['read']>> | ||
| Partial<ListAuthAccess<Args>> | ||
| ListAccess<Args>['read']; | ||
schemaNames: SN[]; | ||
}) { | ||
const accessTypes = ['create', 'read', 'update', 'delete', 'auth'] as (keyof ListAuthAccess)[]; | ||
const accessTypes = [ | ||
'create', | ||
'read', | ||
'update', | ||
'delete', | ||
'auth', | ||
] as (keyof ListAuthAccess<Args>)[]; | ||
const keyedBySchemaName = checkSchemaNames({ schemaNames, accessTypes, access }); | ||
type GG = Partial<ListAuthAccess> | ListAccess['read']; | ||
type GG = Partial<ListAuthAccess<Args>> | ListAccess<Args>['read']; | ||
const fullAccess = keyedBySchemaName | ||
@@ -171,5 +176,5 @@ ? { ...defaultObj(schemaNames, defaultAccess), ...(access as Partial<Record<SN, GG>>) } // Access keyed by schemaName | ||
if (typeof access === 'boolean' || typeof access === 'function') { | ||
return defaultObj(accessTypes, access) as ListAccess['read']; | ||
return defaultObj(accessTypes, access) as ListAccess<Args>['read']; | ||
} else if (typeof access === 'object') { | ||
const _access = access as Partial<ListAuthAccess>; | ||
const _access = access as Partial<ListAuthAccess<Args>>; | ||
if (Object.keys(pick(_access, accessTypes)).length === 0) { | ||
@@ -195,3 +200,3 @@ // An object was supplied, but it has the wrong keys (it's probably a | ||
(acc, schemaName) => ({ ...acc, [schemaName]: parseAndValidate(fullAccess[schemaName]) }), | ||
{} as Record<SN, ListAuthAccess> | ||
{} as Record<SN, ListAuthAccess<Args>> | ||
), | ||
@@ -224,3 +229,3 @@ internal: defaultObj(accessTypes, true as const), | ||
export function parseFieldAccess<SN extends string>({ | ||
export function parseFieldAccess<SN extends string, Args>({ | ||
listKey, | ||
@@ -234,14 +239,14 @@ fieldKey, | ||
fieldKey: string; | ||
defaultAccess: FieldAccess['read']; | ||
defaultAccess: FieldAccess<Args>['read']; | ||
access?: | ||
| Partial<Record<SN, Partial<FieldAccess> | FieldAccess['read']>> | ||
| Partial<FieldAccess> | ||
| FieldAccess['read']; | ||
| Partial<Record<SN, Partial<FieldAccess<Args>> | FieldAccess<Args>['read']>> | ||
| Partial<FieldAccess<Args>> | ||
| FieldAccess<Args>['read']; | ||
schemaNames: SN[]; | ||
}) { | ||
const accessTypes = ['create', 'read', 'update'] as (keyof FieldAccess)[]; | ||
const accessTypes = ['create', 'read', 'update'] as (keyof FieldAccess<Args>)[]; | ||
const keyedBySchemaName = checkSchemaNames({ schemaNames, accessTypes, access }); | ||
type GG = Partial<FieldAccess> | FieldAccess['read']; | ||
type GG = Partial<FieldAccess<Args>> | FieldAccess<Args>['read']; | ||
const fullAccess = keyedBySchemaName | ||
@@ -255,3 +260,3 @@ ? { ...defaultObj(schemaNames, defaultAccess), ...(access as Partial<Record<SN, GG>>) } // Access keyed by schemaName | ||
} else if (typeof access === 'object') { | ||
const _access = access as Partial<FieldAccess>; | ||
const _access = access as Partial<FieldAccess<Args>>; | ||
if (Object.keys(pick(_access, accessTypes)).length === 0) { | ||
@@ -277,3 +282,3 @@ // An object was supplied, but it has the wrong keys (it's probably a | ||
(acc, schemaName) => ({ ...acc, [schemaName]: parseAndValidate(fullAccess[schemaName]) }), | ||
{} as Record<SN, FieldAccess> | ||
{} as Record<SN, FieldAccess<Args>> | ||
), | ||
@@ -308,3 +313,3 @@ internal: defaultObj(accessTypes, true as const), | ||
gqlName, | ||
}: { access: CustomAccess } & CustomAccessArgs) { | ||
}: { access: CustomAccess<CustomAccessArgs> } & CustomAccessArgs) { | ||
// Either a boolean or an object describing a where clause | ||
@@ -343,3 +348,3 @@ let result: Static | Declarative = false; | ||
context, | ||
}: { access: ListAccess } & ListAccessArgs) { | ||
}: { access: ListAccess<ListAccessArgs> } & ListAccessArgs) { | ||
// Either a boolean or an object describing a where clause | ||
@@ -391,3 +396,3 @@ let result: Static | Declarative = false; | ||
context, | ||
}: { access: FieldAccess } & FieldAccessArgs) { | ||
}: { access: FieldAccess<FieldAccessArgs> } & FieldAccessArgs) { | ||
let result: boolean = false; | ||
@@ -427,3 +432,3 @@ const acc = access[operation]; | ||
context, | ||
}: { access: AuthAccess } & Omit<AuthAccessArgs, 'operation'>) { | ||
}: { access: AuthAccess<AuthAccessArgs> } & Omit<AuthAccessArgs, 'operation'>) { | ||
const operation = 'auth'; | ||
@@ -430,0 +435,0 @@ // Either a boolean or an object describing a where clause |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
86336
2015
Updated@keystonejs/utils@^6.0.2