@c1m-public/platform-auth 0.14.0 → 0.15.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.
@@ -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-C-wuZVM9.js';
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-D7Y5nD3s.js';
@@ -41,20 +41,33 @@ var PLATFORM_PERMISSIONS = [
41
41
  "platform.users.view"
42
42
  ];
43
43
  var DASH_PERMISSIONS = [
44
+ "dash.activity.view",
44
45
  "dash.apps.manage",
46
+ "dash.apps.view",
45
47
  "dash.billing.manage",
46
48
  "dash.billing.view",
47
49
  "dash.channels.manage",
48
50
  "dash.customers.manage",
51
+ "dash.customers.view",
49
52
  "dash.domains.manage",
50
53
  "dash.domains.view",
54
+ "dash.leads.export",
55
+ "dash.leads.view",
56
+ "dash.learning.records.view",
57
+ "dash.learning.view",
58
+ "dash.marketing.view",
51
59
  "dash.mcp.access",
52
60
  "dash.members.manage",
61
+ "dash.members.view",
62
+ "dash.ops_library.view",
63
+ "dash.overview.view",
53
64
  "dash.ownership.transfer",
54
65
  "dash.plans.manage",
55
66
  "dash.plans.view",
56
67
  "dash.publish",
57
68
  "dash.settings.manage",
69
+ "dash.settings.view",
70
+ "dash.shop.view",
58
71
  "dash.workspaces.admin",
59
72
  "dash.workspaces.manage",
60
73
  "dash.workspaces.view"
@@ -109,7 +122,9 @@ var AccessSnapshotError = class extends Error {
109
122
  }
110
123
  };
111
124
  function isAccessSnapshotError(error, code) {
112
- return error instanceof AccessSnapshotError && (code === void 0 || error.code === code);
125
+ if (typeof error !== "object" || error === null) return false;
126
+ const candidate = error;
127
+ return candidate.name === "AccessSnapshotError" && typeof candidate.message === "string" && (candidate.code === "unauthenticated" || candidate.code === "forbidden" || candidate.code === "unavailable" || candidate.code === "invalid_snapshot") && (candidate.status === void 0 || Number.isInteger(candidate.status) && candidate.status >= 100 && candidate.status <= 599) && (code === void 0 || candidate.code === code);
113
128
  }
114
129
 
115
130
  // src/access/snapshot.ts
@@ -1,5 +1,5 @@
1
- import { A as AccessSnapshot, P as PermissionCheckOptions, R as Resolvable } from '../index-C-wuZVM9.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-C-wuZVM9.js';
1
+ import { A as AccessSnapshot, P as PermissionCheckOptions, R as Resolvable } from '../index-D7Y5nD3s.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-D7Y5nD3s.js';
3
3
 
4
4
  /** Default cache tag for one subject's snapshot: `access:<subjectId>`. */
5
5
  declare function accessCacheTag(subjectId: string): string;
@@ -61,7 +61,9 @@ var AccessSnapshotError = class extends Error {
61
61
  }
62
62
  };
63
63
  function isAccessSnapshotError(error, code) {
64
- return error instanceof AccessSnapshotError && (code === void 0 || error.code === code);
64
+ if (typeof error !== "object" || error === null) return false;
65
+ const candidate = error;
66
+ return candidate.name === "AccessSnapshotError" && typeof candidate.message === "string" && (candidate.code === "unauthenticated" || candidate.code === "forbidden" || candidate.code === "unavailable" || candidate.code === "invalid_snapshot") && (candidate.status === void 0 || Number.isInteger(candidate.status) && candidate.status >= 100 && candidate.status <= 599) && (code === void 0 || candidate.code === code);
65
67
  }
66
68
 
67
69
  // ../transport/src/forwarding.ts
@@ -297,20 +299,33 @@ var PLATFORM_PERMISSIONS = [
297
299
  "platform.users.view"
298
300
  ];
299
301
  var DASH_PERMISSIONS = [
302
+ "dash.activity.view",
300
303
  "dash.apps.manage",
304
+ "dash.apps.view",
301
305
  "dash.billing.manage",
302
306
  "dash.billing.view",
303
307
  "dash.channels.manage",
304
308
  "dash.customers.manage",
309
+ "dash.customers.view",
305
310
  "dash.domains.manage",
306
311
  "dash.domains.view",
312
+ "dash.leads.export",
313
+ "dash.leads.view",
314
+ "dash.learning.records.view",
315
+ "dash.learning.view",
316
+ "dash.marketing.view",
307
317
  "dash.mcp.access",
308
318
  "dash.members.manage",
319
+ "dash.members.view",
320
+ "dash.ops_library.view",
321
+ "dash.overview.view",
309
322
  "dash.ownership.transfer",
310
323
  "dash.plans.manage",
311
324
  "dash.plans.view",
312
325
  "dash.publish",
313
326
  "dash.settings.manage",
327
+ "dash.settings.view",
328
+ "dash.shop.view",
314
329
  "dash.workspaces.admin",
315
330
  "dash.workspaces.manage",
316
331
  "dash.workspaces.view"
@@ -2,7 +2,7 @@
2
2
  declare const PLATFORM_PERMISSIONS: readonly ["affiliates.enrollments.manage", "affiliates.finance.manage", "affiliates.partners.manage", "affiliates.programmes.manage", "affiliates.view", "linkservice.domains.manage", "linkservice.links.manage", "linkservice.qr.manage", "linkservice.view", "platform.admin.view", "platform.audit.view", "platform.auth.manage", "platform.billing.manage", "platform.billing.view", "platform.channels.manage", "platform.channels.view", "platform.config.manage", "platform.docs.manage", "platform.docs.view", "platform.mcp.access", "platform.observability.manage", "platform.observability.view", "platform.offboarding.view", "platform.ops.manage", "platform.ops.view", "platform.service_accounts.manage", "platform.service_accounts.view", "platform.support.impersonate", "platform.support.sessions", "platform.tenants.archive", "platform.tenants.manage", "platform.tenants.restore", "platform.tenants.view", "platform.users.deactivate", "platform.users.delete", "platform.users.invite", "platform.users.manage_access", "platform.users.reactivate", "platform.users.view"];
3
3
  type PlatformPermissionKey = (typeof PLATFORM_PERMISSIONS)[number];
4
4
  /** Dash-owner permission keys (granted at dash scope, mirrored from the membership role). */
5
- declare const DASH_PERMISSIONS: readonly ["dash.apps.manage", "dash.billing.manage", "dash.billing.view", "dash.channels.manage", "dash.customers.manage", "dash.domains.manage", "dash.domains.view", "dash.mcp.access", "dash.members.manage", "dash.ownership.transfer", "dash.plans.manage", "dash.plans.view", "dash.publish", "dash.settings.manage", "dash.workspaces.admin", "dash.workspaces.manage", "dash.workspaces.view"];
5
+ declare const DASH_PERMISSIONS: readonly ["dash.activity.view", "dash.apps.manage", "dash.apps.view", "dash.billing.manage", "dash.billing.view", "dash.channels.manage", "dash.customers.manage", "dash.customers.view", "dash.domains.manage", "dash.domains.view", "dash.leads.export", "dash.leads.view", "dash.learning.records.view", "dash.learning.view", "dash.marketing.view", "dash.mcp.access", "dash.members.manage", "dash.members.view", "dash.ops_library.view", "dash.overview.view", "dash.ownership.transfer", "dash.plans.manage", "dash.plans.view", "dash.publish", "dash.settings.manage", "dash.settings.view", "dash.shop.view", "dash.workspaces.admin", "dash.workspaces.manage", "dash.workspaces.view"];
6
6
  type DashPermissionKey = (typeof DASH_PERMISSIONS)[number];
7
7
  /** Membership-mirrored dash role bundles (grant keys at dash scope). */
8
8
  declare const DASH_ROLES: readonly ["dash.admin", "dash.owner"];
@@ -36,6 +36,7 @@ declare class AccessSnapshotError extends Error {
36
36
  readonly status: number | undefined;
37
37
  constructor(code: AccessErrorCode, message: string, status?: number);
38
38
  }
39
+ /** Class identity is not shared by /access and /access/next (or duplicate installs). */
39
40
  declare function isAccessSnapshotError(error: unknown, code?: AccessErrorCode): error is AccessSnapshotError;
40
41
 
41
42
  /** Scope a permission entry applies to. Mirrors c1m-server authz.Scope*. */
package/dist/next.d.ts CHANGED
@@ -30,7 +30,7 @@ declare class PlatformServerFetchError extends Error {
30
30
  declare const isSessionExpiredError: (error: unknown) => error is SessionExpiredError;
31
31
  declare const isRecentAuthenticationRequiredError: (error: unknown) => error is RecentAuthenticationRequiredError;
32
32
  declare const isSSOReauthenticationRequiredError: (error: unknown) => error is SSOReauthenticationRequiredError;
33
- declare const isPlatformServerFetchError: (error: unknown) => error is PlatformServerFetchError;
33
+ declare function isPlatformServerFetchError(error: unknown): error is PlatformServerFetchError;
34
34
  /** Map a 401 body's `code` onto the session error it means. */
35
35
  declare function authenticationErrorFor(code: unknown): SessionExpiredError | RecentAuthenticationRequiredError | SSOReauthenticationRequiredError;
36
36
  /**
package/dist/next.js CHANGED
@@ -595,23 +595,28 @@ var PlatformServerFetchError = class extends Error {
595
595
  code;
596
596
  requestId;
597
597
  };
598
- var named = (error, name) => typeof error === "object" && error !== null && error.name === name;
598
+ var named = (error, name) => typeof error === "object" && error !== null && error.name === name && typeof error.message === "string";
599
599
  var isSessionExpiredError = (error) => named(error, "SessionExpiredError");
600
600
  var isRecentAuthenticationRequiredError = (error) => named(error, "RecentAuthenticationRequiredError");
601
601
  var isSSOReauthenticationRequiredError = (error) => named(error, "SSOReauthenticationRequiredError");
602
- var isPlatformServerFetchError = (error) => named(error, "PlatformServerFetchError");
602
+ function isPlatformServerFetchError(error) {
603
+ if (!named(error, "PlatformServerFetchError")) return false;
604
+ const candidate = error;
605
+ return typeof candidate.path === "string" && (candidate.status === void 0 || Number.isInteger(candidate.status) && candidate.status >= 100 && candidate.status <= 599) && (candidate.code === void 0 || typeof candidate.code === "string") && (candidate.requestId === void 0 || typeof candidate.requestId === "string");
606
+ }
603
607
  function authenticationErrorFor(code) {
604
608
  if (code === "sso_reauthentication_required") return new SSOReauthenticationRequiredError();
605
609
  if (code === "recent_authentication_required") return new RecentAuthenticationRequiredError();
606
610
  return new SessionExpiredError();
607
611
  }
608
612
  function isControlAPIErrorLike(error) {
609
- return typeof error === "object" && error !== null && error.name === "ControlAPIError" && typeof error.status === "number" && typeof error.code === "string" && typeof error.requestId === "string";
613
+ return typeof error === "object" && error !== null && error.name === "ControlAPIError" && typeof error.message === "string" && typeof error.status === "number" && typeof error.code === "string" && typeof error.requestId === "string";
610
614
  }
611
615
  function mapControlError(error) {
612
616
  if (!isControlAPIErrorLike(error)) return error;
613
617
  if (error.status === 401) return authenticationErrorFor(error.code);
614
- return new PlatformServerFetchError(error.message, "control API", error.status, error.code, error.requestId);
618
+ const status = Number.isInteger(error.status) && error.status >= 400 && error.status <= 599 ? error.status : error.code === "control_request_timeout" ? 504 : 502;
619
+ return new PlatformServerFetchError(error.message, "control API", status, error.code, error.requestId);
615
620
  }
616
621
  async function controlRequest(run) {
617
622
  try {
@@ -652,7 +657,7 @@ function createPlatformFetch(config) {
652
657
  signal: init?.signal ? AbortSignal.any([init.signal, deadline]) : deadline
653
658
  });
654
659
  } catch (error) {
655
- if (error instanceof PlatformServerFetchError) throw error;
660
+ if (isPlatformServerFetchError(error)) throw error;
656
661
  if (isTimeout(error)) throw new PlatformServerFetchError("Platform service timed out", path, 504, "upstream_timeout");
657
662
  throw new PlatformServerFetchError("Platform service is unavailable", path);
658
663
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/platform-auth",
3
- "version": "0.14.0",
3
+ "version": "0.15.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",