@cedarjs/router 8.0.0-canary.3565 → 8.0.0-canary.3568

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.
@@ -2,8 +2,6 @@ import React from 'react';
2
2
  interface AuthenticatedRouteProps {
3
3
  children: React.ReactNode;
4
4
  roles?: string | string[];
5
- userRoles?: string | string[];
6
- orgRoles?: string | string[];
7
5
  orgPermission?: string;
8
6
  unauthenticated: string;
9
7
  unauthorized?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticatedRoute.d.ts","sourceRoot":"","sources":["../src/AuthenticatedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAQxD,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACnD;AAgFD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAkJhE,CAAA"}
1
+ {"version":3,"file":"AuthenticatedRoute.d.ts","sourceRoot":"","sources":["../src/AuthenticatedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAQxD,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACnD;AA6ED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAwIhE,CAAA"}
@@ -6,7 +6,6 @@ import { paramsForRoute, pathParamsText } from "./util.js";
6
6
  const REPLACE = { replace: true };
7
7
  const useNoOrg = () => null;
8
8
  const MountedOrgContext = createContext(void 0);
9
- const toList = (roles) => Array.isArray(roles) ? roles : [roles];
10
9
  function currentPathParams(routerState, pathname) {
11
10
  const route = Object.values(routerState.routes.pathRouteMap).find(
12
11
  (candidate) => candidate.name === routerState.activeRouteName
@@ -46,8 +45,6 @@ const AuthenticatedRoute = ({
46
45
  unauthenticated,
47
46
  unauthorized,
48
47
  roles,
49
- userRoles,
50
- orgRoles,
51
48
  orgPermission,
52
49
  whileLoadingAuth,
53
50
  children
@@ -64,12 +61,11 @@ const AuthenticatedRoute = ({
64
61
  const { tenancy } = routerState;
65
62
  const useOrg = tenancy?.useOrg ?? useNoOrg;
66
63
  const org = useOrg(routerState.useAuth, pathParams);
67
- const needsOrg = orgRoles !== void 0 || orgPermission !== void 0;
64
+ const needsOrg = orgPermission !== void 0;
68
65
  if (needsOrg && !org) {
69
- const prop = orgRoles !== void 0 ? "orgRoles" : "orgPermission";
70
66
  if (!tenancy) {
71
67
  throw new Error(
72
- `A PrivateSet with \`${prop}\` needs \`tenancy\` on the Router to find the organization with. Please pass \`tenancy\` from \`@cedarjs/tenancy/web\`: <Router useAuth={useAuth} tenancy={tenancy}>`
68
+ "A PrivateSet with `orgPermission` needs `tenancy` on the Router to find the organization with. Please pass `tenancy` from `@cedarjs/tenancy/web`: <Router useAuth={useAuth} tenancy={tenancy}>"
73
69
  );
74
70
  }
75
71
  if (authLoading) {
@@ -77,15 +73,15 @@ const AuthenticatedRoute = ({
77
73
  }
78
74
  if (pathParams["orgSlug"] === void 0) {
79
75
  throw new Error(
80
- `A PrivateSet with \`${prop}\` needs an organization to check it in, and the route has no \`orgSlug\` param. Please only use \`${prop}\` on routes with \`{orgSlug}\` in their path, or pass \`createTenancy\` a \`useOrg\` that finds the organization another way`
76
+ "A PrivateSet with `orgPermission` needs an organization to check it in, and the route has no `orgSlug` param. Please only use `orgPermission` on routes with `{orgSlug}` in their path, or pass `createTenancy` a `useOrg` that finds the organization another way"
81
77
  );
82
78
  }
83
79
  throw new Error(
84
- `A PrivateSet with \`${prop}\` got no organization from the Router's \`tenancy\` for this route, so there is nothing to check it in`
80
+ "A PrivateSet with `orgPermission` got no organization from the Router's `tenancy` for this route, so there is nothing to check it in"
85
81
  );
86
82
  }
87
- const hasRequiredUserRoles = (!roles || hasRole(roles)) && (!userRoles || hasRole(userRoles));
88
- if (isAuthenticated && hasRequiredUserRoles) {
83
+ const hasRequiredRoles = !roles || hasRole(roles);
84
+ if (isAuthenticated && hasRequiredRoles) {
89
85
  if (!tenancy || !org) {
90
86
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
91
87
  }
@@ -96,7 +92,7 @@ const AuthenticatedRoute = ({
96
92
  }
97
93
  return /* @__PURE__ */ React.createElement(React.Fragment, null, tenancy.notAMember ?? null);
98
94
  }
99
- const hasRequiredOrgAccess = (orgRoles === void 0 || toList(orgRoles).includes(membership.role)) && (orgPermission === void 0 || (membership.permissions?.includes(orgPermission) ?? false));
95
+ const hasRequiredOrgAccess = orgPermission === void 0 || (membership.permissions?.includes(orgPermission) ?? false);
100
96
  if (hasRequiredOrgAccess) {
101
97
  if (mountedOrgId === membership.organizationId) {
102
98
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
package/dist/Set.d.ts CHANGED
@@ -26,50 +26,33 @@ export interface WrapperProps {
26
26
  */
27
27
  export type WrapperType = ComponentType<WrapperProps>;
28
28
  /**
29
- * The role props. An app with tenancy (see `AuthTenancy`) has `userRoles` and
30
- * `orgRoles` instead of `roles`: there, every role check says which kind it
31
- * is. It also has `orgPermission`.
29
+ * `orgPermission`, only in an app with tenancy (see `AuthTenancy`)
32
30
  */
33
- type SetRoles = AuthTenancy extends {
31
+ type SetOrgPermission = AuthTenancy extends {
34
32
  enabled: true;
35
33
  } ? {
36
34
  /**
37
- * Route is permitted when authenticated and user has any of the
38
- * provided roles such as "admin" or ["admin", "editor"], in
39
- * `currentUser.roles`, as opposed to a role in the organization they're
40
- * in (see `orgRoles`). With `orgRoles` as well, they need both.
41
- */
42
- userRoles?: string | string[];
43
- /**
44
- * Route is permitted when authenticated and user has any of the
45
- * provided roles such as "owner" or ["owner", "admin"] in the current
46
- * organization. With `userRoles` as well, they need both.
35
+ * Route is permitted when authenticated and the user's membership in
36
+ * the current organization has this permission (see
37
+ * `createPermissions` in `@cedarjs/tenancy`). With `roles` as well,
38
+ * they need both.
47
39
  *
48
40
  * The organization is the one the Router's `tenancy` finds for the
49
41
  * route, by default the one with the route's `orgSlug` param:
50
42
  *
51
43
  * <Router useAuth={useAuth} tenancy={tenancy}>
52
44
  *
53
- * A `PrivateSet` with `orgRoles` throws without `tenancy` on the
45
+ * A `PrivateSet` with `orgPermission` throws without `tenancy` on the
54
46
  * router, or on a route that isn't in an organization.
55
47
  */
56
- orgRoles?: string | string[];
57
- /**
58
- * Route is permitted when authenticated and the user's membership in
59
- * the current organization has this permission (see
60
- * `createPermissions` in `@cedarjs/tenancy`). The organization is found
61
- * like for `orgRoles`, which it can be combined with: they need both.
62
- */
63
48
  orgPermission?: PermissionName;
64
- } : {
49
+ } : Record<never, never>;
50
+ interface SetProps extends SetOrgPermission {
65
51
  /**
66
- * Route is permitted when authenticated and user has any of the
67
- * provided roles such as "admin" or ["admin", "editor"], in
68
- * `currentUser.roles`
52
+ * Route is permitted when authenticated and user has any of the provided
53
+ * roles such as "admin" or ["admin", "editor"], in `currentUser.roles`
69
54
  */
70
55
  roles?: string | string[];
71
- };
72
- interface SetProps extends SetRoles {
73
56
  /**
74
57
  * Components to wrap all routes in this set with, like layouts. The first
75
58
  * one in an array is the outermost one.
package/dist/Set.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Set.d.ts","sourceRoot":"","sources":["../src/Set.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACnE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;IAC/D,iBAAiB,EAAE,QAAQ;CAC5B,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,YAAY,CAAC,CAAA;AAErD;;;;GAIG;AACH,KAAK,QAAQ,GAAG,WAAW,SAAS;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjD;IACE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC7B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC5B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,cAAc,CAAA;CAC/B,GACD;IACE;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1B,CAAA;AAEL,UAAU,QAAS,SAAQ,QAAQ;IACjC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,WAAW,EAAE,CAAA;IAC3C;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qCAAqC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAA;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AAA;AAED,oDAAoD;AACpD,wBAAgB,OAAO,CAAC,KAAK,EAAE,eAAe,qBAI7C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,qBAIhD;AAED,eAAO,MAAM,SAAS,GAAI,MAAM,SAAS,KAAG,IAAI,IAAI,YAAY,CAAC,QAAQ,CAOxE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,MAAM,SAAS,KACd,IAAI,IAAI,YAAY,CAAC,eAAe,CAEtC,CAAA;AAGD,eAAO,MAAM,aAAa,GACxB,MAAM,SAAS,KACd,IAAI,IAAI,YAAY,CAAC,eAAe,CAEtC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,WAAW,EAAE,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,SAAS,aAKpB"}
@@ -16,8 +16,6 @@ interface SetRenderProps {
16
16
  unauthenticated?: string;
17
17
  unauthorized?: string;
18
18
  roles?: string | string[];
19
- userRoles?: string | string[];
20
- orgRoles?: string | string[];
21
19
  orgPermission?: string;
22
20
  whileLoadingAuth?: () => ReactElement | null;
23
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"analyzeRoutes.d.ts","sourceRoot":"","sources":["../src/analyzeRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAQzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,WAAW,CAAA;AAElB,KAAK,gBAAgB,GAAG,MAAM,YAAY,GAAG,IAAI,CAAA;AAIjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,CACb,IAAI,CAAC,EAAE,MAAM,CAAC,MA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EAAE,gBAAgB,CAAA;IACnC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,UAAU,oBAAoB;IAC5B,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAC3C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,EACnB,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,oBAAoB;;;;;;EAqK1D"}
@@ -25,12 +25,6 @@ function pickSetRenderProps(props) {
25
25
  if (props.roles !== void 0) {
26
26
  picked.roles = props.roles;
27
27
  }
28
- if (props.userRoles !== void 0) {
29
- picked.userRoles = props.userRoles;
30
- }
31
- if (props.orgRoles !== void 0) {
32
- picked.orgRoles = props.orgRoles;
33
- }
34
28
  if (props.orgPermission !== void 0) {
35
29
  picked.orgPermission = props.orgPermission;
36
30
  }
@@ -13,7 +13,7 @@ export type UseAuth = () => AuthContextInterface<unknown, unknown, unknown, unkn
13
13
  export interface RouterMembership {
14
14
  /** Identifies the organization, so one provider stays mounted across it */
15
15
  organizationId: string;
16
- /** The user's role in the organization, for `<PrivateSet orgRoles>` */
16
+ /** The user's role in the organization, passed on to the `OrgProvider` */
17
17
  role: string;
18
18
  /** What the membership may do, for `<PrivateSet orgPermission>` */
19
19
  permissions?: readonly string[] | undefined;
@@ -35,10 +35,10 @@ export interface RouterOrg {
35
35
  *
36
36
  * One of the app's own can answer in three ways:
37
37
  * - an organization, with the user's membership in it or `null` for none.
38
- * A set with `orgRoles` or `orgPermission` denies a user with no
38
+ * A set with `orgPermission` denies a user with no
39
39
  * membership, and the router renders the tenancy's `notAMember`.
40
- * - `null`, for no organization: a set with `orgRoles` or `orgPermission`
41
- * then throws the router's own error.
40
+ * - `null`, for no organization: a set with `orgPermission` then
41
+ * throws the router's own error.
42
42
  * - throw an error of its own, such as for an organization that's been
43
43
  * suspended. It reaches the app's error boundary like any error thrown
44
44
  * while rendering.
@@ -55,7 +55,7 @@ export interface OrgProviderProps {
55
55
  * How the router handles organizations. `createTenancy` from
56
56
  * `@cedarjs/tenancy/web` makes one. The router renders its `OrgProvider`
57
57
  * around the layouts and page of a `PrivateSet` whose route is in an
58
- * organization, and checks `orgRoles` and `orgPermission` against the
58
+ * organization, and checks `orgPermission` against the
59
59
  * membership its `useOrg` finds.
60
60
  */
61
61
  export interface Tenancy {
@@ -1 +1 @@
1
- {"version":3,"file":"router-context.d.ts","sourceRoot":"","sources":["../src/router-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;IACxD,iBAAiB,EAAE,QAAQ;CAC5B,CAAA;AAGD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,MAAM,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAC9C,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,CACR,CAAA;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,cAAc,EAAE,MAAM,CAAA;IACtB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAA;IACnC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAA;CACzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,M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AM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,uDAAuD;IACvD,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAA;IAClD,mFAAmF;IACnF,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CAC5C;AAID,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CACtD,WAAW,EACX,SAAS,CACV;IACC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAwBtE,CAAA;AAED,eAAO,MAAM,cAAc,mBAU1B,CAAA"}
package/dist/router.d.ts CHANGED
@@ -7,14 +7,14 @@ import type { RouterContextProviderProps, Tenancy } from './router-context.js';
7
7
  import type { TrailingSlashesTypes } from './util.js';
8
8
  /**
9
9
  * `tenancy`, only in an app with tenancy (see `AuthTenancy`), where sets have
10
- * `orgRoles` and `orgPermission`
10
+ * `orgPermission`
11
11
  */
12
12
  type RouterTenancy = AuthTenancy extends {
13
13
  enabled: true;
14
14
  } ? {
15
15
  /**
16
16
  * How the router handles organizations: finding the one of the current
17
- * route, checking `orgRoles` and `orgPermission` in it, and providing
17
+ * route, checking `orgPermission` in it, and providing
18
18
  * it to the layouts and page of a `PrivateSet`. Pass the `tenancy` from
19
19
  * `createTenancy` in `@cedarjs/tenancy/web`:
20
20
  *
package/dist/router.js CHANGED
@@ -163,8 +163,6 @@ const WrappedPage = memo(({ sets, children }) => {
163
163
  unauthenticated,
164
164
  unauthorized: set.props.unauthorized,
165
165
  roles: set.props.roles,
166
- userRoles: set.props.userRoles,
167
- orgRoles: set.props.orgRoles,
168
166
  orgPermission: set.props.orgPermission,
169
167
  whileLoadingAuth: set.props.whileLoadingAuth
170
168
  },
@@ -34,9 +34,6 @@ const LocationAwareRouter = ({
34
34
  }
35
35
  const requestedRoute = pathRouteMap[activeRoutePath];
36
36
  for (const set of requestedRoute.sets) {
37
- if (set.props.orgRoles !== void 0) {
38
- throw new Error("`orgRoles` is not supported with RSC yet");
39
- }
40
37
  if (set.props.orgPermission !== void 0) {
41
38
  throw new Error("`orgPermission` is not supported with RSC yet");
42
39
  }
@@ -104,18 +104,13 @@ function hasRole(requiredRoles) {
104
104
  const AuthenticatedRoute = ({
105
105
  children,
106
106
  roles,
107
- userRoles,
108
- orgRoles,
109
107
  orgPermission
110
108
  }) => {
111
109
  const { isAuthenticated } = getAuthState();
112
- if (orgRoles !== void 0) {
113
- throw new Error("`orgRoles` is not supported with RSC yet");
114
- }
115
110
  if (orgPermission !== void 0) {
116
111
  throw new Error("`orgPermission` is not supported with RSC yet");
117
112
  }
118
- const isAuthorized = isAuthenticated && (!roles || hasRole(roles)) && (!userRoles || hasRole(userRoles));
113
+ const isAuthorized = isAuthenticated && (!roles || hasRole(roles));
119
114
  if (isAuthorized) {
120
115
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
121
116
  }
@@ -142,8 +137,6 @@ const WrappedPage = ({ routeLoaderElement, sets }) => {
142
137
  {
143
138
  unauthenticated,
144
139
  roles: set.props.roles,
145
- userRoles: set.props.userRoles,
146
- orgRoles: set.props.orgRoles,
147
140
  orgPermission: set.props.orgPermission,
148
141
  whileLoadingAuth: set.props.whileLoadingAuth
149
142
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/router",
3
- "version": "8.0.0-canary.3565",
3
+ "version": "8.0.0-canary.3568",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -52,15 +52,15 @@
52
52
  "test:watch": "vitest watch"
53
53
  },
54
54
  "dependencies": {
55
- "@cedarjs/project-config": "8.0.0-canary.3565",
56
- "@cedarjs/server-store": "8.0.0-canary.3565",
55
+ "@cedarjs/project-config": "8.0.0-canary.3568",
56
+ "@cedarjs/server-store": "8.0.0-canary.3568",
57
57
  "react-server-dom-webpack": "19.3.1",
58
58
  "ts-toolbelt": "9.6.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@arethetypeswrong/cli": "0.18.5",
62
- "@cedarjs/auth": "8.0.0-canary.3565",
63
- "@cedarjs/framework-tools": "8.0.0-canary.3565",
62
+ "@cedarjs/auth": "8.0.0-canary.3568",
63
+ "@cedarjs/framework-tools": "8.0.0-canary.3568",
64
64
  "@testing-library/jest-dom": "6.9.1",
65
65
  "@types/react": "^19.2.0",
66
66
  "@types/react-dom": "^19.2.0",
@@ -74,7 +74,7 @@
74
74
  "vitest": "4.1.12"
75
75
  },
76
76
  "peerDependencies": {
77
- "@cedarjs/auth": "8.0.0-canary.3565",
77
+ "@cedarjs/auth": "8.0.0-canary.3568",
78
78
  "react": "19.3.1",
79
79
  "react-dom": "19.3.1"
80
80
  },