oiu-core 0.1.4 → 0.1.6
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/README.md +4 -0
- package/dist/auth/AuthorizationProvider.d.ts +4 -4
- package/dist/auth/AuthorizationProvider.d.ts.map +1 -1
- package/dist/auth/utils.d.ts +1 -1
- package/dist/auth/utils.d.ts.map +1 -1
- package/dist/{index-YSAkS2Gn.js → index-DBhagcq9.js} +1 -1
- package/dist/{main-DDVh2kVN.js → main-FBHPIaGD.js} +18 -1
- package/dist/main.js +1 -1
- package/dist/utils/promise.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { MongoAbility } from '@casl/ability';
|
|
3
3
|
import { Identity, Permission } from './_type';
|
|
4
|
-
export type PermissionFn = (identity?:
|
|
4
|
+
export type PermissionFn<TIdentity extends Identity> = (identity?: TIdentity) => {
|
|
5
5
|
allowed: Permission[];
|
|
6
6
|
denied: Permission[];
|
|
7
7
|
};
|
|
8
|
-
export type AuthorizationProviderProps = PropsWithChildren<{
|
|
8
|
+
export type AuthorizationProviderProps<TIdentity extends Identity> = PropsWithChildren<{
|
|
9
9
|
/** Optional CSS class name to apply to the Wait component wrapper */
|
|
10
10
|
className?: string;
|
|
11
11
|
/** Get permission for the current identity */
|
|
12
|
-
getPermissionFor: PermissionFn
|
|
12
|
+
getPermissionFor: PermissionFn<TIdentity>;
|
|
13
13
|
/** Default ability to be use */
|
|
14
14
|
defaultAbility?: MongoAbility;
|
|
15
15
|
}>;
|
|
@@ -18,5 +18,5 @@ export type AuthorizationProviderProps = PropsWithChildren<{
|
|
|
18
18
|
* @param param0
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
export declare function AuthorizationProvider({ className, children, getPermissionFor, defaultAbility }: AuthorizationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function AuthorizationProvider<TIdentity extends Identity>({ className, children, getPermissionFor, defaultAbility }: AuthorizationProviderProps<TIdentity>): import("react/jsx-runtime").JSX.Element;
|
|
22
22
|
//# sourceMappingURL=AuthorizationProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationProvider.d.ts","sourceRoot":"","sources":["../../lib/auth/AuthorizationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AAGxE,OAAO,EAAsC,YAAY,EAAE,MAAM,eAAe,CAAC;AAKjF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAa/C,MAAM,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"AuthorizationProvider.d.ts","sourceRoot":"","sources":["../../lib/auth/AuthorizationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AAGxE,OAAO,EAAsC,YAAY,EAAE,MAAM,eAAe,CAAC;AAKjF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAa/C,MAAM,MAAM,YAAY,CAAC,SAAS,SAAS,QAAQ,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,KAAK;IAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC;AACjI,MAAM,MAAM,0BAA0B,CAAC,SAAS,SAAS,QAAQ,IAAI,iBAAiB,CAAC;IACnF,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,gCAAgC;IAChC,cAAc,CAAC,EAAE,YAAY,CAAC;CACjC,CAAC,CAAC;AACH;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,QAAQ,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,0BAA0B,CAAC,SAAS,CAAC,2CA0CjK"}
|
package/dist/auth/utils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function useAuthentication(): IAuthService;
|
|
|
9
9
|
* Retrieve the current identity in the system
|
|
10
10
|
* @returns {Identity | undefined} The current identity
|
|
11
11
|
*/
|
|
12
|
-
export declare function useIdentity():
|
|
12
|
+
export declare function useIdentity<TIdentity extends Identity = Identity>(): TIdentity | undefined;
|
|
13
13
|
/** Function to check if the user has the permission */
|
|
14
14
|
export type AllowedFn = (permission: Permission) => boolean;
|
|
15
15
|
/**
|
package/dist/auth/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/auth/utils.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAM3F,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM7D;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAKhD;AACD;;;GAGG;AACH,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/auth/utils.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAM3F,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM7D;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAKhD;AACD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ,KAAK,SAAS,GAAG,SAAS,CAE1F;AAED,uDAAuD;AACvD,MAAM,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC;AAC5D;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAc5B,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAGvD;AAQD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC;IACzC,gCAAgC;IAChC,UAAU,EAAE,UAAU,CAAC;CAC1B,CAAC,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,OAAO,iEAAmC,YAAY,6CAQjE,CAAC"}
|
|
@@ -19318,7 +19318,7 @@ function UR({ className: e, children: t, getPermissionFor: r, defaultAbility: n
|
|
|
19318
19318
|
var zv = /* @__PURE__ */ ((e) => (e[e.Always = 1] = "Always", e[e.Never = 2] = "Never", e[e.RedirectIfFails = 3] = "RedirectIfFails", e))(zv || {});
|
|
19319
19319
|
const WR = () => import(
|
|
19320
19320
|
/* @vite-ignore */
|
|
19321
|
-
"./index-
|
|
19321
|
+
"./index-DBhagcq9.js"
|
|
19322
19322
|
);
|
|
19323
19323
|
async function GR(e, t, r) {
|
|
19324
19324
|
return (await WR()).default(e, t, r);
|
|
@@ -19340,6 +19340,23 @@ const FN = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
19340
19340
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
19341
19341
|
var qv = /* @__PURE__ */ ((e) => (e[e.Info = 1] = "Info", e[e.Error = 2] = "Error", e[e.Warning = 3] = "Warning", e[e.Success = 4] = "Success", e))(qv || {});
|
|
19342
19342
|
Promise.delay = (e) => new Promise((t) => setTimeout(t, e));
|
|
19343
|
+
Promise.waitUntil = (e, t) => {
|
|
19344
|
+
const r = t?.timeoutMs ?? 1e4, n = t?.intervalMs ?? 25, o = t?.timeoutMessage ?? "Timed out waiting for condition";
|
|
19345
|
+
return new Promise((i, s) => {
|
|
19346
|
+
const a = Date.now(), c = () => {
|
|
19347
|
+
if (e()) {
|
|
19348
|
+
i();
|
|
19349
|
+
return;
|
|
19350
|
+
}
|
|
19351
|
+
if (Date.now() - a >= r) {
|
|
19352
|
+
s(new Error(o));
|
|
19353
|
+
return;
|
|
19354
|
+
}
|
|
19355
|
+
setTimeout(c, n);
|
|
19356
|
+
};
|
|
19357
|
+
c();
|
|
19358
|
+
});
|
|
19359
|
+
};
|
|
19343
19360
|
var Oa, Np;
|
|
19344
19361
|
function Zn() {
|
|
19345
19362
|
return Np || (Np = 1, Oa = TypeError), Oa;
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../lib/utils/promise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../lib/utils/promise.ts"],"names":[],"mappings":"AAqCA,eAAe,OAAO,CAAC"}
|