@webiny/app-security 6.0.0-alpha.0 → 6.0.0-alpha.2

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.
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import type React from "react";
2
2
  interface SecureRouteProps {
3
3
  children: React.ReactNode;
4
4
  permission?: string;
@@ -1 +1 @@
1
- {"version":3,"names":["useSecurity","plugins","children","permission","security","identity","getPermission","hasPermission","Boolean","plugin","byName","render"],"sources":["SecureRoute.tsx"],"sourcesContent":["import React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport { SecureRouteErrorPlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface SecureRouteProps {\n children: React.ReactNode;\n permission?: string;\n}\nexport default ({ children, permission }: SecureRouteProps): React.ReactElement | null => {\n const security = useSecurity();\n\n if (!security) {\n return null;\n }\n\n const { identity, getPermission } = security;\n\n if (!identity) {\n return null;\n }\n\n let hasPermission = false;\n if (identity) {\n hasPermission = permission ? Boolean(getPermission(permission)) : true;\n }\n\n if (hasPermission) {\n return children as unknown as React.ReactElement;\n }\n\n const plugin = plugins.byName<SecureRouteErrorPlugin>(\"secure-route-error\");\n if (!plugin) {\n return null;\n }\n\n return plugin.render();\n};\n"],"mappings":"AACA,SAASA,WAAW;AAEpB,SAASC,OAAO,QAAQ,iBAAiB;AAMzC,eAAe,CAAC;EAAEC,QAAQ;EAAEC;AAA6B,CAAC,KAAgC;EACtF,MAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAE9B,IAAI,CAACI,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,MAAM;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAGF,QAAQ;EAE5C,IAAI,CAACC,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,IAAIE,aAAa,GAAG,KAAK;EACzB,IAAIF,QAAQ,EAAE;IACVE,aAAa,GAAGJ,UAAU,GAAGK,OAAO,CAACF,aAAa,CAACH,UAAU,CAAC,CAAC,GAAG,IAAI;EAC1E;EAEA,IAAII,aAAa,EAAE;IACf,OAAOL,QAAQ;EACnB;EAEA,MAAMO,MAAM,GAAGR,OAAO,CAACS,MAAM,CAAyB,oBAAoB,CAAC;EAC3E,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,OAAOA,MAAM,CAACE,MAAM,CAAC,CAAC;AAC1B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useSecurity","plugins","children","permission","security","identity","getPermission","hasPermission","Boolean","plugin","byName","render"],"sources":["SecureRoute.tsx"],"sourcesContent":["import type React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport type { SecureRouteErrorPlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface SecureRouteProps {\n children: React.ReactNode;\n permission?: string;\n}\nexport default ({ children, permission }: SecureRouteProps): React.ReactElement | null => {\n const security = useSecurity();\n\n if (!security) {\n return null;\n }\n\n const { identity, getPermission } = security;\n\n if (!identity) {\n return null;\n }\n\n let hasPermission = false;\n if (identity) {\n hasPermission = permission ? Boolean(getPermission(permission)) : true;\n }\n\n if (hasPermission) {\n return children as unknown as React.ReactElement;\n }\n\n const plugin = plugins.byName<SecureRouteErrorPlugin>(\"secure-route-error\");\n if (!plugin) {\n return null;\n }\n\n return plugin.render();\n};\n"],"mappings":"AACA,SAASA,WAAW;AAEpB,SAASC,OAAO,QAAQ,iBAAiB;AAMzC,eAAe,CAAC;EAAEC,QAAQ;EAAEC;AAA6B,CAAC,KAAgC;EACtF,MAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAE9B,IAAI,CAACI,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,MAAM;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAGF,QAAQ;EAE5C,IAAI,CAACC,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,IAAIE,aAAa,GAAG,KAAK;EACzB,IAAIF,QAAQ,EAAE;IACVE,aAAa,GAAGJ,UAAU,GAAGK,OAAO,CAACF,aAAa,CAACH,UAAU,CAAC,CAAC,GAAG,IAAI;EAC1E;EAEA,IAAII,aAAa,EAAE;IACf,OAAOL,QAAQ;EACnB;EAEA,MAAMO,MAAM,GAAGR,OAAO,CAACS,MAAM,CAAyB,oBAAoB,CAAC;EAC3E,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,OAAOA,MAAM,CAACE,MAAM,CAAC,CAAC;AAC1B,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as React from "react";
2
- import { SecurityPermission } from "../types";
1
+ import type * as React from "react";
2
+ import type { SecurityPermission } from "../types";
3
3
  interface ChildrenRenderFunctionArgs<T extends SecurityPermission> {
4
4
  hasPermission: boolean;
5
5
  permission: T | null;
@@ -1 +1 @@
1
- {"version":3,"names":["useSecurity","SecureView","children","permission","getPermission","hasPermission","matchedPermission","Boolean"],"sources":["SecureView.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport { SecurityPermission } from \"~/types\";\n\ninterface ChildrenRenderFunctionArgs<T extends SecurityPermission> {\n hasPermission: boolean;\n permission: T | null;\n}\n\ninterface Props<T extends SecurityPermission> {\n children: ((args: ChildrenRenderFunctionArgs<T>) => React.ReactElement) | React.ReactElement;\n permission?: string;\n}\n\nfunction SecureView<T extends SecurityPermission>({\n children,\n permission\n}: Props<T>): React.ReactElement | null {\n const { getPermission } = useSecurity();\n\n let hasPermission = false;\n let matchedPermission: T | null = null;\n if (permission) {\n matchedPermission = getPermission<T>(permission);\n hasPermission = Boolean(matchedPermission);\n }\n\n if (typeof children === \"function\") {\n return children({\n hasPermission,\n permission: matchedPermission\n });\n }\n\n return hasPermission ? children : null;\n}\n\nexport default SecureView;\n"],"mappings":"AACA,SAASA,WAAW;AAapB,SAASC,UAAUA,CAA+B;EAC9CC,QAAQ;EACRC;AACM,CAAC,EAA6B;EACpC,MAAM;IAAEC;EAAc,CAAC,GAAGJ,WAAW,CAAC,CAAC;EAEvC,IAAIK,aAAa,GAAG,KAAK;EACzB,IAAIC,iBAA2B,GAAG,IAAI;EACtC,IAAIH,UAAU,EAAE;IACZG,iBAAiB,GAAGF,aAAa,CAAID,UAAU,CAAC;IAChDE,aAAa,GAAGE,OAAO,CAACD,iBAAiB,CAAC;EAC9C;EAEA,IAAI,OAAOJ,QAAQ,KAAK,UAAU,EAAE;IAChC,OAAOA,QAAQ,CAAC;MACZG,aAAa;MACbF,UAAU,EAAEG;IAChB,CAAC,CAAC;EACN;EAEA,OAAOD,aAAa,GAAGH,QAAQ,GAAG,IAAI;AAC1C;AAEA,eAAeD,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["useSecurity","SecureView","children","permission","getPermission","hasPermission","matchedPermission","Boolean"],"sources":["SecureView.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport type { SecurityPermission } from \"~/types\";\n\ninterface ChildrenRenderFunctionArgs<T extends SecurityPermission> {\n hasPermission: boolean;\n permission: T | null;\n}\n\ninterface Props<T extends SecurityPermission> {\n children: ((args: ChildrenRenderFunctionArgs<T>) => React.ReactElement) | React.ReactElement;\n permission?: string;\n}\n\nfunction SecureView<T extends SecurityPermission>({\n children,\n permission\n}: Props<T>): React.ReactElement | null {\n const { getPermission } = useSecurity();\n\n let hasPermission = false;\n let matchedPermission: T | null = null;\n if (permission) {\n matchedPermission = getPermission<T>(permission);\n hasPermission = Boolean(matchedPermission);\n }\n\n if (typeof children === \"function\") {\n return children({\n hasPermission,\n permission: matchedPermission\n });\n }\n\n return hasPermission ? children : null;\n}\n\nexport default SecureView;\n"],"mappings":"AACA,SAASA,WAAW;AAapB,SAASC,UAAUA,CAA+B;EAC9CC,QAAQ;EACRC;AACM,CAAC,EAA6B;EACpC,MAAM;IAAEC;EAAc,CAAC,GAAGJ,WAAW,CAAC,CAAC;EAEvC,IAAIK,aAAa,GAAG,KAAK;EACzB,IAAIC,iBAA2B,GAAG,IAAI;EACtC,IAAIH,UAAU,EAAE;IACZG,iBAAiB,GAAGF,aAAa,CAAID,UAAU,CAAC;IAChDE,aAAa,GAAGE,OAAO,CAACD,iBAAiB,CAAC;EAC9C;EAEA,IAAI,OAAOJ,QAAQ,KAAK,UAAU,EAAE;IAChC,OAAOA,QAAQ,CAAC;MACZG,aAAa;MACbF,UAAU,EAAEG;IAChB,CAAC,CAAC;EACN;EAEA,OAAOD,aAAa,GAAGH,QAAQ,GAAG,IAAI;AAC1C;AAEA,eAAeD,UAAU","ignoreList":[]}
@@ -1,5 +1,6 @@
1
- import React, { Dispatch, SetStateAction } from "react";
2
- import { IdTokenProvider, SecurityIdentity, SecurityPermission } from "../types";
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ import React from "react";
3
+ import type { IdTokenProvider, SecurityIdentity, SecurityPermission } from "../types";
3
4
  export interface SecurityContext {
4
5
  identity: SecurityIdentity | null;
5
6
  getIdentityId: () => string | null;
@@ -1 +1 @@
1
- {"version":3,"names":["minimatch","React","useCallback","useMemo","useState","defaultIdTokenProvider","undefined","SecurityContext","createContext","SecurityProvider","props","identity","setIdentity","idTokenProvider","setIdTokenProvider","getPermission","name","exact","perms","permissions","exactMatch","find","p","getPermissions","filter","current","getIdentityId","id","login","value","getIdToken","provider","createElement","Provider","children"],"sources":["Security.tsx"],"sourcesContent":["import minimatch from \"minimatch\";\nimport React, { Dispatch, SetStateAction, useCallback, useMemo, useState } from \"react\";\nimport { IdTokenProvider, SecurityIdentity, SecurityPermission } from \"~/types\";\n\nexport interface SecurityContext {\n identity: SecurityIdentity | null;\n getIdentityId: () => string | null;\n setIdentity: Dispatch<SetStateAction<SecurityIdentity | null>>;\n getPermission<T extends SecurityPermission = SecurityPermission>(\n name: string,\n exact?: boolean\n ): T | null;\n getPermissions<T extends SecurityPermission = SecurityPermission>(name: string): T[];\n setIdTokenProvider: (provider: IdTokenProvider) => void;\n getIdToken: IdTokenProvider;\n}\n\ninterface SecurityProviderProps {\n children: React.ReactNode;\n}\n\nconst defaultIdTokenProvider: IdTokenProvider = () => undefined;\n\nexport const SecurityContext = React.createContext<SecurityContext | undefined>(undefined);\n\nexport const SecurityProvider = (props: SecurityProviderProps) => {\n const [identity, setIdentity] = useState<SecurityIdentity | null>(null);\n const [idTokenProvider, setIdTokenProvider] = useState<IdTokenProvider>(\n () => defaultIdTokenProvider\n );\n\n const getPermission = useCallback(\n <T extends SecurityPermission = SecurityPermission>(\n name: string,\n exact?: boolean\n ): T | null => {\n if (!identity) {\n return null;\n }\n\n const perms = (identity.permissions || []) as T[];\n const exactMatch = perms.find(p => p.name === name);\n if (exactMatch) {\n return exactMatch as T;\n } else if (exact) {\n return null;\n }\n\n // Try matching using patterns\n return perms.find(p => minimatch(name, p.name)) || null;\n },\n [identity]\n );\n\n const getPermissions = useCallback(\n <T extends SecurityPermission = SecurityPermission>(name: string): Array<T> => {\n if (!identity) {\n return [];\n }\n\n const permissions = identity.permissions || [];\n\n return permissions.filter(current => {\n const exactMatch = current.name === name;\n if (exactMatch) {\n return true;\n }\n\n // Try matching using patterns.\n return minimatch(name, current.name);\n }) as T[];\n },\n [identity]\n );\n\n const getIdentityId = useCallback(() => {\n if (!identity) {\n return null;\n }\n return identity.id || identity.login || null;\n }, [identity]);\n\n const value: SecurityContext = useMemo(() => {\n return {\n identity: identity\n ? {\n ...identity,\n // For backwards compatibility, expose the `getPermission` method on the `identity` object.\n getPermission\n }\n : null,\n getIdentityId,\n setIdentity,\n getPermission,\n getPermissions,\n getIdToken: idTokenProvider,\n setIdTokenProvider: provider => {\n setIdTokenProvider(() => provider);\n }\n };\n }, [idTokenProvider, identity]);\n\n return <SecurityContext.Provider value={value}>{props.children}</SecurityContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AACjC,OAAOC,KAAK,IAA8BC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAoBvF,MAAMC,sBAAuC,GAAGA,CAAA,KAAMC,SAAS;AAE/D,OAAO,MAAMC,eAAe,gBAAGN,KAAK,CAACO,aAAa,CAA8BF,SAAS,CAAC;AAE1F,OAAO,MAAMG,gBAAgB,GAAIC,KAA4B,IAAK;EAC9D,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGR,QAAQ,CAA0B,IAAI,CAAC;EACvE,MAAM,CAACS,eAAe,EAAEC,kBAAkB,CAAC,GAAGV,QAAQ,CAClD,MAAMC,sBACV,CAAC;EAED,MAAMU,aAAa,GAAGb,WAAW,CAC7B,CACIc,IAAY,EACZC,KAAe,KACJ;IACX,IAAI,CAACN,QAAQ,EAAE;MACX,OAAO,IAAI;IACf;IAEA,MAAMO,KAAK,GAAIP,QAAQ,CAACQ,WAAW,IAAI,EAAU;IACjD,MAAMC,UAAU,GAAGF,KAAK,CAACG,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACN,IAAI,KAAKA,IAAI,CAAC;IACnD,IAAII,UAAU,EAAE;MACZ,OAAOA,UAAU;IACrB,CAAC,MAAM,IAAIH,KAAK,EAAE;MACd,OAAO,IAAI;IACf;;IAEA;IACA,OAAOC,KAAK,CAACG,IAAI,CAACC,CAAC,IAAItB,SAAS,CAACgB,IAAI,EAAEM,CAAC,CAACN,IAAI,CAAC,CAAC,IAAI,IAAI;EAC3D,CAAC,EACD,CAACL,QAAQ,CACb,CAAC;EAED,MAAMY,cAAc,GAAGrB,WAAW,CACsBc,IAAY,IAAe;IAC3E,IAAI,CAACL,QAAQ,EAAE;MACX,OAAO,EAAE;IACb;IAEA,MAAMQ,WAAW,GAAGR,QAAQ,CAACQ,WAAW,IAAI,EAAE;IAE9C,OAAOA,WAAW,CAACK,MAAM,CAACC,OAAO,IAAI;MACjC,MAAML,UAAU,GAAGK,OAAO,CAACT,IAAI,KAAKA,IAAI;MACxC,IAAII,UAAU,EAAE;QACZ,OAAO,IAAI;MACf;;MAEA;MACA,OAAOpB,SAAS,CAACgB,IAAI,EAAES,OAAO,CAACT,IAAI,CAAC;IACxC,CAAC,CAAC;EACN,CAAC,EACD,CAACL,QAAQ,CACb,CAAC;EAED,MAAMe,aAAa,GAAGxB,WAAW,CAAC,MAAM;IACpC,IAAI,CAACS,QAAQ,EAAE;MACX,OAAO,IAAI;IACf;IACA,OAAOA,QAAQ,CAACgB,EAAE,IAAIhB,QAAQ,CAACiB,KAAK,IAAI,IAAI;EAChD,CAAC,EAAE,CAACjB,QAAQ,CAAC,CAAC;EAEd,MAAMkB,KAAsB,GAAG1B,OAAO,CAAC,MAAM;IACzC,OAAO;MACHQ,QAAQ,EAAEA,QAAQ,GACZ;QACI,GAAGA,QAAQ;QACX;QACAI;MACJ,CAAC,GACD,IAAI;MACVW,aAAa;MACbd,WAAW;MACXG,aAAa;MACbQ,cAAc;MACdO,UAAU,EAAEjB,eAAe;MAC3BC,kBAAkB,EAAEiB,QAAQ,IAAI;QAC5BjB,kBAAkB,CAAC,MAAMiB,QAAQ,CAAC;MACtC;IACJ,CAAC;EACL,CAAC,EAAE,CAAClB,eAAe,EAAEF,QAAQ,CAAC,CAAC;EAE/B,oBAAOV,KAAA,CAAA+B,aAAA,CAACzB,eAAe,CAAC0B,QAAQ;IAACJ,KAAK,EAAEA;EAAM,GAAEnB,KAAK,CAACwB,QAAmC,CAAC;AAC9F,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["minimatch","React","useCallback","useMemo","useState","defaultIdTokenProvider","undefined","SecurityContext","createContext","SecurityProvider","props","identity","setIdentity","idTokenProvider","setIdTokenProvider","getPermission","name","exact","perms","permissions","exactMatch","find","p","getPermissions","filter","current","getIdentityId","id","login","value","getIdToken","provider","createElement","Provider","children"],"sources":["Security.tsx"],"sourcesContent":["import minimatch from \"minimatch\";\nimport type { Dispatch, SetStateAction } from \"react\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport type { IdTokenProvider, SecurityIdentity, SecurityPermission } from \"~/types\";\n\nexport interface SecurityContext {\n identity: SecurityIdentity | null;\n getIdentityId: () => string | null;\n setIdentity: Dispatch<SetStateAction<SecurityIdentity | null>>;\n getPermission<T extends SecurityPermission = SecurityPermission>(\n name: string,\n exact?: boolean\n ): T | null;\n getPermissions<T extends SecurityPermission = SecurityPermission>(name: string): T[];\n setIdTokenProvider: (provider: IdTokenProvider) => void;\n getIdToken: IdTokenProvider;\n}\n\ninterface SecurityProviderProps {\n children: React.ReactNode;\n}\n\nconst defaultIdTokenProvider: IdTokenProvider = () => undefined;\n\nexport const SecurityContext = React.createContext<SecurityContext | undefined>(undefined);\n\nexport const SecurityProvider = (props: SecurityProviderProps) => {\n const [identity, setIdentity] = useState<SecurityIdentity | null>(null);\n const [idTokenProvider, setIdTokenProvider] = useState<IdTokenProvider>(\n () => defaultIdTokenProvider\n );\n\n const getPermission = useCallback(\n <T extends SecurityPermission = SecurityPermission>(\n name: string,\n exact?: boolean\n ): T | null => {\n if (!identity) {\n return null;\n }\n\n const perms = (identity.permissions || []) as T[];\n const exactMatch = perms.find(p => p.name === name);\n if (exactMatch) {\n return exactMatch as T;\n } else if (exact) {\n return null;\n }\n\n // Try matching using patterns\n return perms.find(p => minimatch(name, p.name)) || null;\n },\n [identity]\n );\n\n const getPermissions = useCallback(\n <T extends SecurityPermission = SecurityPermission>(name: string): Array<T> => {\n if (!identity) {\n return [];\n }\n\n const permissions = identity.permissions || [];\n\n return permissions.filter(current => {\n const exactMatch = current.name === name;\n if (exactMatch) {\n return true;\n }\n\n // Try matching using patterns.\n return minimatch(name, current.name);\n }) as T[];\n },\n [identity]\n );\n\n const getIdentityId = useCallback(() => {\n if (!identity) {\n return null;\n }\n return identity.id || identity.login || null;\n }, [identity]);\n\n const value: SecurityContext = useMemo(() => {\n return {\n identity: identity\n ? {\n ...identity,\n // For backwards compatibility, expose the `getPermission` method on the `identity` object.\n getPermission\n }\n : null,\n getIdentityId,\n setIdentity,\n getPermission,\n getPermissions,\n getIdToken: idTokenProvider,\n setIdTokenProvider: provider => {\n setIdTokenProvider(() => provider);\n }\n };\n }, [idTokenProvider, identity]);\n\n return <SecurityContext.Provider value={value}>{props.children}</SecurityContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AAEjC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAoB7D,MAAMC,sBAAuC,GAAGA,CAAA,KAAMC,SAAS;AAE/D,OAAO,MAAMC,eAAe,gBAAGN,KAAK,CAACO,aAAa,CAA8BF,SAAS,CAAC;AAE1F,OAAO,MAAMG,gBAAgB,GAAIC,KAA4B,IAAK;EAC9D,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGR,QAAQ,CAA0B,IAAI,CAAC;EACvE,MAAM,CAACS,eAAe,EAAEC,kBAAkB,CAAC,GAAGV,QAAQ,CAClD,MAAMC,sBACV,CAAC;EAED,MAAMU,aAAa,GAAGb,WAAW,CAC7B,CACIc,IAAY,EACZC,KAAe,KACJ;IACX,IAAI,CAACN,QAAQ,EAAE;MACX,OAAO,IAAI;IACf;IAEA,MAAMO,KAAK,GAAIP,QAAQ,CAACQ,WAAW,IAAI,EAAU;IACjD,MAAMC,UAAU,GAAGF,KAAK,CAACG,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACN,IAAI,KAAKA,IAAI,CAAC;IACnD,IAAII,UAAU,EAAE;MACZ,OAAOA,UAAU;IACrB,CAAC,MAAM,IAAIH,KAAK,EAAE;MACd,OAAO,IAAI;IACf;;IAEA;IACA,OAAOC,KAAK,CAACG,IAAI,CAACC,CAAC,IAAItB,SAAS,CAACgB,IAAI,EAAEM,CAAC,CAACN,IAAI,CAAC,CAAC,IAAI,IAAI;EAC3D,CAAC,EACD,CAACL,QAAQ,CACb,CAAC;EAED,MAAMY,cAAc,GAAGrB,WAAW,CACsBc,IAAY,IAAe;IAC3E,IAAI,CAACL,QAAQ,EAAE;MACX,OAAO,EAAE;IACb;IAEA,MAAMQ,WAAW,GAAGR,QAAQ,CAACQ,WAAW,IAAI,EAAE;IAE9C,OAAOA,WAAW,CAACK,MAAM,CAACC,OAAO,IAAI;MACjC,MAAML,UAAU,GAAGK,OAAO,CAACT,IAAI,KAAKA,IAAI;MACxC,IAAII,UAAU,EAAE;QACZ,OAAO,IAAI;MACf;;MAEA;MACA,OAAOpB,SAAS,CAACgB,IAAI,EAAES,OAAO,CAACT,IAAI,CAAC;IACxC,CAAC,CAAC;EACN,CAAC,EACD,CAACL,QAAQ,CACb,CAAC;EAED,MAAMe,aAAa,GAAGxB,WAAW,CAAC,MAAM;IACpC,IAAI,CAACS,QAAQ,EAAE;MACX,OAAO,IAAI;IACf;IACA,OAAOA,QAAQ,CAACgB,EAAE,IAAIhB,QAAQ,CAACiB,KAAK,IAAI,IAAI;EAChD,CAAC,EAAE,CAACjB,QAAQ,CAAC,CAAC;EAEd,MAAMkB,KAAsB,GAAG1B,OAAO,CAAC,MAAM;IACzC,OAAO;MACHQ,QAAQ,EAAEA,QAAQ,GACZ;QACI,GAAGA,QAAQ;QACX;QACAI;MACJ,CAAC,GACD,IAAI;MACVW,aAAa;MACbd,WAAW;MACXG,aAAa;MACbQ,cAAc;MACdO,UAAU,EAAEjB,eAAe;MAC3BC,kBAAkB,EAAEiB,QAAQ,IAAI;QAC5BjB,kBAAkB,CAAC,MAAMiB,QAAQ,CAAC;MACtC;IACJ,CAAC;EACL,CAAC,EAAE,CAAClB,eAAe,EAAEF,QAAQ,CAAC,CAAC;EAE/B,oBAAOV,KAAA,CAAA+B,aAAA,CAACzB,eAAe,CAAC0B,QAAQ;IAACJ,KAAK,EAAEA;EAAM,GAAEnB,KAAK,CAACwB,QAAmC,CAAC;AAC9F,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { SecurityPermission } from "../types";
1
+ import type { SecurityPermission } from "../types";
2
2
  export declare function usePermission<T extends SecurityPermission = SecurityPermission>(name: string): T | null;
@@ -1 +1 @@
1
- {"version":3,"names":["useSecurity","usePermission","name","getPermission"],"sources":["usePermission.ts"],"sourcesContent":["import { useSecurity } from \"~/hooks/useSecurity\";\nimport { SecurityPermission } from \"~/types\";\n\nexport function usePermission<T extends SecurityPermission = SecurityPermission>(name: string) {\n const { getPermission } = useSecurity();\n return getPermission<T>(name);\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAGpB,OAAO,SAASC,aAAaA,CAAoDC,IAAY,EAAE;EAC3F,MAAM;IAAEC;EAAc,CAAC,GAAGH,WAAW,CAAC,CAAC;EACvC,OAAOG,aAAa,CAAID,IAAI,CAAC;AACjC","ignoreList":[]}
1
+ {"version":3,"names":["useSecurity","usePermission","name","getPermission"],"sources":["usePermission.ts"],"sourcesContent":["import { useSecurity } from \"~/hooks/useSecurity\";\nimport type { SecurityPermission } from \"~/types\";\n\nexport function usePermission<T extends SecurityPermission = SecurityPermission>(name: string) {\n const { getPermission } = useSecurity();\n return getPermission<T>(name);\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAGpB,OAAO,SAASC,aAAaA,CAAoDC,IAAY,EAAE;EAC3F,MAAM;IAAEC;EAAc,CAAC,GAAGH,WAAW,CAAC,CAAC;EACvC,OAAOG,aAAa,CAAID,IAAI,CAAC;AACjC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-security",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-alpha.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,15 +13,15 @@
13
13
  ],
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@webiny/app": "6.0.0-alpha.0",
17
- "@webiny/plugins": "6.0.0-alpha.0",
16
+ "@webiny/app": "6.0.0-alpha.2",
17
+ "@webiny/plugins": "6.0.0-alpha.2",
18
18
  "minimatch": "5.1.6",
19
19
  "react": "18.2.0",
20
20
  "react-dom": "18.2.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@emotion/babel-plugin": "11.11.0",
24
- "@webiny/project-utils": "6.0.0-alpha.0",
24
+ "@webiny/project-utils": "6.0.0-alpha.2",
25
25
  "rimraf": "6.0.1",
26
26
  "typescript": "5.3.3"
27
27
  },
@@ -40,5 +40,5 @@
40
40
  ]
41
41
  }
42
42
  },
43
- "gitHead": "a5b28fed7a242d8f56712197a8ea83aa6d2ed101"
43
+ "gitHead": "7c9e8fbfd62a57ece5f880dbad6c864636b0355e"
44
44
  }
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Plugin } from "@webiny/app/types";
2
+ import type { Plugin } from "@webiny/app/types";
3
3
  export type SecureRouteErrorPlugin = Plugin & {
4
4
  render(): React.ReactElement;
5
5
  };
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/app/types\";\n\nexport type SecureRouteErrorPlugin = Plugin & {\n render(): React.ReactElement;\n};\n\nexport interface FullAccessPermission {\n name: \"*\";\n}\n\nexport interface SecurityPermission {\n name: string;\n [key: string]: any;\n}\n\nexport interface SecurityIdentity {\n id: string;\n type: string;\n displayName: string;\n permissions?: SecurityPermission[];\n /**\n * TODO @ts-refactor @pavel\n * Verify that login can be present in here.\n */\n login?: string;\n /**\n * TODO @ts-refactor @pavel\n * Verify that profile can be present in here.\n */\n profile?: {\n email?: string;\n firstName?: string;\n lastName?: string;\n avatar?: {\n src?: string;\n };\n gravatar?: string;\n };\n logout(): void;\n // For backwards compatibility, expose the `getPermission` method on the `identity` object.\n getPermission?<T extends SecurityPermission = SecurityPermission>(name: string): T | null;\n [key: string]: any;\n}\n\nexport type IdToken = string;\n\nexport type IdTokenProvider = () => Promise<IdToken | undefined> | IdToken | undefined;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/app/types\";\n\nexport type SecureRouteErrorPlugin = Plugin & {\n render(): React.ReactElement;\n};\n\nexport interface FullAccessPermission {\n name: \"*\";\n}\n\nexport interface SecurityPermission {\n name: string;\n [key: string]: any;\n}\n\nexport interface SecurityIdentity {\n id: string;\n type: string;\n displayName: string;\n permissions?: SecurityPermission[];\n /**\n * TODO @ts-refactor @pavel\n * Verify that login can be present in here.\n */\n login?: string;\n /**\n * TODO @ts-refactor @pavel\n * Verify that profile can be present in here.\n */\n profile?: {\n email?: string;\n firstName?: string;\n lastName?: string;\n avatar?: {\n src?: string;\n };\n gravatar?: string;\n };\n logout(): void;\n // For backwards compatibility, expose the `getPermission` method on the `identity` object.\n getPermission?<T extends SecurityPermission = SecurityPermission>(name: string): T | null;\n [key: string]: any;\n}\n\nexport type IdToken = string;\n\nexport type IdTokenProvider = () => Promise<IdToken | undefined> | IdToken | undefined;\n"],"mappings":"","ignoreList":[]}