@c1m-public/platform-auth 0.11.0 → 0.12.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/README.md +1 -1
- package/dist/access/index.d.ts +1 -1
- package/dist/access/index.js +4 -4
- package/dist/access/next.d.ts +2 -2
- package/dist/access/next.js +4 -4
- package/dist/access/react.d.ts +4 -4
- package/dist/access/react.js +1 -1
- package/dist/{index-HL6QFIZy.d.ts → index-D-cH_sfe.d.ts} +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ The resolved snapshot from `GET /api/v1/platform/access`.
|
|
|
110
110
|
| `PLATFORM_PERMISSIONS`, `LEADBROKER_PERMISSIONS`, `WORKSPACE_PERMISSIONS`, `WORKSPACE_ROLES` + key types | Generated from the backend catalog — see the drift guard below. |
|
|
111
111
|
| `parseAccessSnapshot`, `emptySnapshot`, `AccessSnapshot`, `AccessEntry` | Validate and shape the snapshot. |
|
|
112
112
|
| `hasPermission`, `hasAnyPermission`, `hasAllPermissions`, `hasWorkspacePermission`, `isPlatformOwner`, `appScopes`, `permissionsFor` | Scope-aware predicates. |
|
|
113
|
-
| `managedDashes`, `dashRole` | The dashes a subject runs, from the mirrored `dash.owner` / `dash.admin` bundle grants (`snapshot.dash_roles`). Admission only — gate an action with `hasPermission(snapshot, "dash.publish", {
|
|
113
|
+
| `managedDashes`, `dashRole` | The dashes a subject runs, from the mirrored `dash.owner` / `dash.admin` bundle grants (`snapshot.dash_roles`). Admission only — gate an action with `hasPermission(snapshot, "dash.publish", { dashId })`. Platform managers are not listed; admit them on `platform.tenants.manage`. |
|
|
114
114
|
| `fetchAccessSnapshot` | Framework-neutral fetch. Pass `request` and it forwards client identity for you. |
|
|
115
115
|
| `AccessSnapshotError`, `isAccessSnapshotError` | `unauthenticated` / `forbidden` / `unavailable` / `invalid_snapshot`. |
|
|
116
116
|
|
package/dist/access/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as AccessEntry, b as AccessErrorCode, c as AccessScopeType, A as AccessSnapshot, d as AccessSnapshotError, D as DASH_PERMISSIONS, e as DASH_ROLES, f as DEFAULT_ACCESS_ENDPOINT_PATH, g as DashPermissionKey, h as DashRole, F as FetchAccessSnapshotOptions, L as LEADBROKER_PERMISSIONS, i as LeadBrokerPermissionKey, j as PIPELINE_STAGES, k as PLATFORM_PERMISSIONS, P as PermissionCheckOptions, l as PermissionKey, m as PipelineStage, n as PlatformPermissionKey, W as WORKSPACE_PERMISSIONS, o as WORKSPACE_ROLES, p as WorkspacePermissionKey, q as WorkspaceRole, r as appScopes, s as dashRole, t as emptySnapshot, u as entryCoversApp, v as fetchAccessSnapshot, w as hasAllPermissions, x as hasAnyPermission, y as hasPermission, z as hasWorkspacePermission, B as isAccessSnapshotError, C as isPipelineStage, E as isPlatformOwner, G as managedDashes, H as parseAccessSnapshot, I as permissionsFor } from '../index-
|
|
1
|
+
export { a as AccessEntry, b as AccessErrorCode, c as AccessScopeType, A as AccessSnapshot, d as AccessSnapshotError, D as DASH_PERMISSIONS, e as DASH_ROLES, f as DEFAULT_ACCESS_ENDPOINT_PATH, g as DashPermissionKey, h as DashRole, F as FetchAccessSnapshotOptions, L as LEADBROKER_PERMISSIONS, i as LeadBrokerPermissionKey, j as PIPELINE_STAGES, k as PLATFORM_PERMISSIONS, P as PermissionCheckOptions, l as PermissionKey, m as PipelineStage, n as PlatformPermissionKey, W as WORKSPACE_PERMISSIONS, o as WORKSPACE_ROLES, p as WorkspacePermissionKey, q as WorkspaceRole, r as appScopes, s as dashRole, t as emptySnapshot, u as entryCoversApp, v as fetchAccessSnapshot, w as hasAllPermissions, x as hasAnyPermission, y as hasPermission, z as hasWorkspacePermission, B as isAccessSnapshotError, C as isPipelineStage, E as isPlatformOwner, G as managedDashes, H as parseAccessSnapshot, I as permissionsFor } from '../index-D-cH_sfe.js';
|
package/dist/access/index.js
CHANGED
|
@@ -111,7 +111,7 @@ function isAccessSnapshotError(error, code) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// src/access/snapshot.ts
|
|
114
|
-
var SCOPE_TYPES = /* @__PURE__ */ new Set(["platform", "
|
|
114
|
+
var SCOPE_TYPES = /* @__PURE__ */ new Set(["platform", "dash_id", "workspace"]);
|
|
115
115
|
function emptySnapshot(subjectId = "") {
|
|
116
116
|
return {
|
|
117
117
|
subject_id: subjectId,
|
|
@@ -144,7 +144,7 @@ function parseAccessSnapshot(input) {
|
|
|
144
144
|
if (!isRecord(raw)) fail(`permissions[${i}]`, "is not an object");
|
|
145
145
|
const { key, scope_type, scope_id } = raw;
|
|
146
146
|
if (typeof key !== "string" || key === "") fail(`permissions[${i}].key`, "must be a non-empty string");
|
|
147
|
-
if (typeof scope_type !== "string" || !SCOPE_TYPES.has(scope_type)) fail(`permissions[${i}].scope_type`, "must be platform|
|
|
147
|
+
if (typeof scope_type !== "string" || !SCOPE_TYPES.has(scope_type)) fail(`permissions[${i}].scope_type`, "must be platform|dash_id|workspace");
|
|
148
148
|
if (scope_id !== void 0 && scope_id !== null && typeof scope_id !== "string") fail(`permissions[${i}].scope_id`, "must be a string");
|
|
149
149
|
return { key, scope_type, scope_id: typeof scope_id === "string" ? scope_id : "" };
|
|
150
150
|
});
|
|
@@ -190,7 +190,7 @@ function entryCoversApp(entry, dashId) {
|
|
|
190
190
|
switch (entry.scope_type) {
|
|
191
191
|
case "platform":
|
|
192
192
|
return true;
|
|
193
|
-
case "
|
|
193
|
+
case "dash_id":
|
|
194
194
|
if (dashId === void 0) return true;
|
|
195
195
|
return entry.scope_id === "*" || entry.scope_id.toLowerCase() === dashId.toLowerCase();
|
|
196
196
|
default:
|
|
@@ -229,7 +229,7 @@ function appScopes(snapshot, key) {
|
|
|
229
229
|
for (const entry of snapshot.permissions) {
|
|
230
230
|
if (entry.key !== key) continue;
|
|
231
231
|
if (entry.scope_type === "platform") return { all: true, apps: [] };
|
|
232
|
-
if (entry.scope_type === "
|
|
232
|
+
if (entry.scope_type === "dash_id") {
|
|
233
233
|
if (entry.scope_id === "*") return { all: true, apps: [] };
|
|
234
234
|
apps.add(entry.scope_id.toLowerCase());
|
|
235
235
|
}
|
package/dist/access/next.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AccessSnapshot, P as PermissionCheckOptions, R as Resolvable } from '../index-
|
|
2
|
-
export { a as AccessEntry, b as AccessErrorCode, c as AccessScopeType, d as AccessSnapshotError, D as DASH_PERMISSIONS, e as DASH_ROLES, f as DEFAULT_ACCESS_ENDPOINT_PATH, g as DashPermissionKey, h as DashRole, F as FetchAccessSnapshotOptions, L as LEADBROKER_PERMISSIONS, i as LeadBrokerPermissionKey, j as PIPELINE_STAGES, k as PLATFORM_PERMISSIONS, l as PermissionKey, m as PipelineStage, n as PlatformPermissionKey, W as WORKSPACE_PERMISSIONS, o as WORKSPACE_ROLES, p as WorkspacePermissionKey, q as WorkspaceRole, r as appScopes, s as dashRole, t as emptySnapshot, u as entryCoversApp, v as fetchAccessSnapshot, w as hasAllPermissions, x as hasAnyPermission, y as hasPermission, z as hasWorkspacePermission, B as isAccessSnapshotError, C as isPipelineStage, E as isPlatformOwner, G as managedDashes, H as parseAccessSnapshot, I as permissionsFor } from '../index-
|
|
1
|
+
import { A as AccessSnapshot, P as PermissionCheckOptions, R as Resolvable } from '../index-D-cH_sfe.js';
|
|
2
|
+
export { a as AccessEntry, b as AccessErrorCode, c as AccessScopeType, d as AccessSnapshotError, D as DASH_PERMISSIONS, e as DASH_ROLES, f as DEFAULT_ACCESS_ENDPOINT_PATH, g as DashPermissionKey, h as DashRole, F as FetchAccessSnapshotOptions, L as LEADBROKER_PERMISSIONS, i as LeadBrokerPermissionKey, j as PIPELINE_STAGES, k as PLATFORM_PERMISSIONS, l as PermissionKey, m as PipelineStage, n as PlatformPermissionKey, W as WORKSPACE_PERMISSIONS, o as WORKSPACE_ROLES, p as WorkspacePermissionKey, q as WorkspaceRole, r as appScopes, s as dashRole, t as emptySnapshot, u as entryCoversApp, v as fetchAccessSnapshot, w as hasAllPermissions, x as hasAnyPermission, y as hasPermission, z as hasWorkspacePermission, B as isAccessSnapshotError, C as isPipelineStage, E as isPlatformOwner, G as managedDashes, H as parseAccessSnapshot, I as permissionsFor } from '../index-D-cH_sfe.js';
|
|
3
3
|
|
|
4
4
|
/** Default cache tag for one subject's snapshot: `access:<subjectId>`. */
|
|
5
5
|
declare function accessCacheTag(subjectId: string): string;
|
package/dist/access/next.js
CHANGED
|
@@ -93,7 +93,7 @@ function forwardedRequestHeaders2(request, init) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// src/access/snapshot.ts
|
|
96
|
-
var SCOPE_TYPES = /* @__PURE__ */ new Set(["platform", "
|
|
96
|
+
var SCOPE_TYPES = /* @__PURE__ */ new Set(["platform", "dash_id", "workspace"]);
|
|
97
97
|
function emptySnapshot(subjectId = "") {
|
|
98
98
|
return {
|
|
99
99
|
subject_id: subjectId,
|
|
@@ -126,7 +126,7 @@ function parseAccessSnapshot(input) {
|
|
|
126
126
|
if (!isRecord(raw)) fail(`permissions[${i}]`, "is not an object");
|
|
127
127
|
const { key, scope_type, scope_id } = raw;
|
|
128
128
|
if (typeof key !== "string" || key === "") fail(`permissions[${i}].key`, "must be a non-empty string");
|
|
129
|
-
if (typeof scope_type !== "string" || !SCOPE_TYPES.has(scope_type)) fail(`permissions[${i}].scope_type`, "must be platform|
|
|
129
|
+
if (typeof scope_type !== "string" || !SCOPE_TYPES.has(scope_type)) fail(`permissions[${i}].scope_type`, "must be platform|dash_id|workspace");
|
|
130
130
|
if (scope_id !== void 0 && scope_id !== null && typeof scope_id !== "string") fail(`permissions[${i}].scope_id`, "must be a string");
|
|
131
131
|
return { key, scope_type, scope_id: typeof scope_id === "string" ? scope_id : "" };
|
|
132
132
|
});
|
|
@@ -201,7 +201,7 @@ function entryCoversApp(entry, dashId) {
|
|
|
201
201
|
switch (entry.scope_type) {
|
|
202
202
|
case "platform":
|
|
203
203
|
return true;
|
|
204
|
-
case "
|
|
204
|
+
case "dash_id":
|
|
205
205
|
if (dashId === void 0) return true;
|
|
206
206
|
return entry.scope_id === "*" || entry.scope_id.toLowerCase() === dashId.toLowerCase();
|
|
207
207
|
default:
|
|
@@ -240,7 +240,7 @@ function appScopes(snapshot, key) {
|
|
|
240
240
|
for (const entry of snapshot.permissions) {
|
|
241
241
|
if (entry.key !== key) continue;
|
|
242
242
|
if (entry.scope_type === "platform") return { all: true, apps: [] };
|
|
243
|
-
if (entry.scope_type === "
|
|
243
|
+
if (entry.scope_type === "dash_id") {
|
|
244
244
|
if (entry.scope_id === "*") return { all: true, apps: [] };
|
|
245
245
|
apps.add(entry.scope_id.toLowerCase());
|
|
246
246
|
}
|
package/dist/access/react.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/** Scope a permission entry applies to. Mirrors c1m-server authz.Scope*. */
|
|
5
|
-
type AccessScopeType = "platform" | "
|
|
5
|
+
type AccessScopeType = "platform" | "dash_id" | "workspace";
|
|
6
6
|
interface AccessEntry {
|
|
7
7
|
/** Permission key, e.g. "platform.users.manage_access". */
|
|
8
8
|
key: string;
|
|
9
9
|
scope_type: AccessScopeType;
|
|
10
|
-
/** "" for platform scope;
|
|
10
|
+
/** "" for platform scope; dash id or "*" for dash scope; workspace id for workspace scope. */
|
|
11
11
|
scope_id: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -25,7 +25,7 @@ interface AccessSnapshot {
|
|
|
25
25
|
platform_role: string;
|
|
26
26
|
permissions: AccessEntry[];
|
|
27
27
|
/**
|
|
28
|
-
* Dash bundle (`dash.owner` / `dash.admin`) per
|
|
28
|
+
* Dash bundle (`dash.owner` / `dash.admin`) per dash id, mirrored from
|
|
29
29
|
* the subject's dash membership. This is the admission list for the dash
|
|
30
30
|
* area: the dashes this subject runs. What they may *do* on one is a normal
|
|
31
31
|
* `hasPermission(snapshot, key, { dashId })` check — platform managers hold
|
|
@@ -41,7 +41,7 @@ interface AccessSnapshot {
|
|
|
41
41
|
interface PermissionCheckOptions {
|
|
42
42
|
/**
|
|
43
43
|
* Dash slug the check is about. Omit for "anywhere": platform
|
|
44
|
-
* entries and any
|
|
44
|
+
* entries and any dash-scoped entry satisfy the check.
|
|
45
45
|
*/
|
|
46
46
|
dashId?: string;
|
|
47
47
|
}
|
package/dist/access/react.js
CHANGED
|
@@ -8,7 +8,7 @@ function entryCoversApp(entry, dashId) {
|
|
|
8
8
|
switch (entry.scope_type) {
|
|
9
9
|
case "platform":
|
|
10
10
|
return true;
|
|
11
|
-
case "
|
|
11
|
+
case "dash_id":
|
|
12
12
|
if (dashId === void 0) return true;
|
|
13
13
|
return entry.scope_id === "*" || entry.scope_id.toLowerCase() === dashId.toLowerCase();
|
|
14
14
|
default:
|
|
@@ -39,12 +39,12 @@ declare class AccessSnapshotError extends Error {
|
|
|
39
39
|
declare function isAccessSnapshotError(error: unknown, code?: AccessErrorCode): error is AccessSnapshotError;
|
|
40
40
|
|
|
41
41
|
/** Scope a permission entry applies to. Mirrors c1m-server authz.Scope*. */
|
|
42
|
-
type AccessScopeType = "platform" | "
|
|
42
|
+
type AccessScopeType = "platform" | "dash_id" | "workspace";
|
|
43
43
|
interface AccessEntry {
|
|
44
44
|
/** Permission key, e.g. "platform.users.manage_access". */
|
|
45
45
|
key: string;
|
|
46
46
|
scope_type: AccessScopeType;
|
|
47
|
-
/** "" for platform scope;
|
|
47
|
+
/** "" for platform scope; dash id or "*" for dash scope; workspace id for workspace scope. */
|
|
48
48
|
scope_id: string;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
@@ -62,7 +62,7 @@ interface AccessSnapshot {
|
|
|
62
62
|
platform_role: string;
|
|
63
63
|
permissions: AccessEntry[];
|
|
64
64
|
/**
|
|
65
|
-
* Dash bundle (`dash.owner` / `dash.admin`) per
|
|
65
|
+
* Dash bundle (`dash.owner` / `dash.admin`) per dash id, mirrored from
|
|
66
66
|
* the subject's dash membership. This is the admission list for the dash
|
|
67
67
|
* area: the dashes this subject runs. What they may *do* on one is a normal
|
|
68
68
|
* `hasPermission(snapshot, key, { dashId })` check — platform managers hold
|
|
@@ -81,13 +81,13 @@ declare function parseAccessSnapshot(input: unknown): AccessSnapshot;
|
|
|
81
81
|
interface PermissionCheckOptions {
|
|
82
82
|
/**
|
|
83
83
|
* Dash slug the check is about. Omit for "anywhere": platform
|
|
84
|
-
* entries and any
|
|
84
|
+
* entries and any dash-scoped entry satisfy the check.
|
|
85
85
|
*/
|
|
86
86
|
dashId?: string;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Mirrors c1m-server authz.entryCoversApp: platform scope covers every app;
|
|
90
|
-
*
|
|
90
|
+
* Dash scope covers "*" or a case-insensitive dash-id match; workspace-scoped
|
|
91
91
|
* entries never satisfy an app-level check.
|
|
92
92
|
*/
|
|
93
93
|
declare function entryCoversApp(entry: AccessEntry, dashId: string | undefined): boolean;
|
|
@@ -98,7 +98,7 @@ declare function hasAllPermissions(snapshot: AccessSnapshot, keys: readonly stri
|
|
|
98
98
|
/**
|
|
99
99
|
* Workspace-staff check. Platform owners always pass (they own every
|
|
100
100
|
* workspace); otherwise the workspace's effective permission list decides.
|
|
101
|
-
* Platform/
|
|
101
|
+
* Platform/dash entries never confer workspace-staff permissions.
|
|
102
102
|
*/
|
|
103
103
|
declare function hasWorkspacePermission(snapshot: AccessSnapshot, workspaceId: string, key: string): boolean;
|
|
104
104
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/platform-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Session and authorization helpers for C1M platform surfaces. The root is runtime-neutral (Web Request/Response): token/session reads, the first-party handoff (PKCE target + source), proxy session gate and coalesced refresh; ./next adds the server-only guard; ./access carries the resolved access snapshot, typed permission keys, predicates, a Next loader and React bindings",
|