@c1m-public/platform-auth 0.14.0 → 0.14.1
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/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-DExfJ-AE.js';
|
package/dist/access/index.js
CHANGED
|
@@ -109,7 +109,9 @@ var AccessSnapshotError = class extends Error {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
function isAccessSnapshotError(error, code) {
|
|
112
|
-
|
|
112
|
+
if (typeof error !== "object" || error === null) return false;
|
|
113
|
+
const candidate = error;
|
|
114
|
+
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
115
|
}
|
|
114
116
|
|
|
115
117
|
// src/access/snapshot.ts
|
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-DExfJ-AE.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-DExfJ-AE.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
|
@@ -61,7 +61,9 @@ var AccessSnapshotError = class extends Error {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
function isAccessSnapshotError(error, code) {
|
|
64
|
-
|
|
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
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.14.1",
|
|
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",
|