@c1m-public/platform-auth 0.8.0 → 0.8.2
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.js +2 -2
- package/dist/access/next.js +5 -5
- package/dist/{chunk-OPF4UZLE.js → chunk-73ZH67GM.js} +1 -1
- package/dist/{chunk-QV7HSZLE.js → chunk-GQ36R3RQ.js} +5 -3
- package/dist/{chunk-P4LKOHR4.js → chunk-ZWSJVE5S.js} +8 -3
- package/dist/index.js +2 -2
- package/dist/next.js +7 -7
- package/package.json +1 -1
package/dist/access/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AccessSnapshotError, DASH_PERMISSIONS, DASH_ROLES, DEFAULT_ACCESS_ENDPOINT_PATH, LEADBROKER_PERMISSIONS, PLATFORM_PERMISSIONS, WORKSPACE_PERMISSIONS, WORKSPACE_ROLES, appScopes, dashRole, emptySnapshot, entryCoversApp, fetchAccessSnapshot, hasAllPermissions, hasAnyPermission, hasPermission, hasWorkspacePermission, isAccessSnapshotError, isPlatformOwner, managedDashes, parseAccessSnapshot, permissionsFor } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { AccessSnapshotError, DASH_PERMISSIONS, DASH_ROLES, DEFAULT_ACCESS_ENDPOINT_PATH, LEADBROKER_PERMISSIONS, PLATFORM_PERMISSIONS, WORKSPACE_PERMISSIONS, WORKSPACE_ROLES, appScopes, dashRole, emptySnapshot, entryCoversApp, fetchAccessSnapshot, hasAllPermissions, hasAnyPermission, hasPermission, hasWorkspacePermission, isAccessSnapshotError, isPlatformOwner, managedDashes, parseAccessSnapshot, permissionsFor } from '../chunk-73ZH67GM.js';
|
|
2
|
+
import '../chunk-ZWSJVE5S.js';
|
package/dist/access/next.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { decodeTokenPayload } from '../chunk-FBC2NUH7.js';
|
|
2
|
-
import { AccessSnapshotError, fetchAccessSnapshot, isAccessSnapshotError, hasAnyPermission, hasAllPermissions, hasWorkspacePermission } from '../chunk-
|
|
3
|
-
export { AccessSnapshotError, DASH_PERMISSIONS, DASH_ROLES, DEFAULT_ACCESS_ENDPOINT_PATH, LEADBROKER_PERMISSIONS, PLATFORM_PERMISSIONS, WORKSPACE_PERMISSIONS, WORKSPACE_ROLES, appScopes, dashRole, emptySnapshot, entryCoversApp, fetchAccessSnapshot, hasAllPermissions, hasAnyPermission, hasPermission, hasWorkspacePermission, isAccessSnapshotError, isPlatformOwner, managedDashes, parseAccessSnapshot, permissionsFor } from '../chunk-
|
|
4
|
-
import { resolveValue } from '../chunk-
|
|
2
|
+
import { AccessSnapshotError, fetchAccessSnapshot, isAccessSnapshotError, hasAnyPermission, hasAllPermissions, hasWorkspacePermission } from '../chunk-73ZH67GM.js';
|
|
3
|
+
export { AccessSnapshotError, DASH_PERMISSIONS, DASH_ROLES, DEFAULT_ACCESS_ENDPOINT_PATH, LEADBROKER_PERMISSIONS, PLATFORM_PERMISSIONS, WORKSPACE_PERMISSIONS, WORKSPACE_ROLES, appScopes, dashRole, emptySnapshot, entryCoversApp, fetchAccessSnapshot, hasAllPermissions, hasAnyPermission, hasPermission, hasWorkspacePermission, isAccessSnapshotError, isPlatformOwner, managedDashes, parseAccessSnapshot, permissionsFor } from '../chunk-73ZH67GM.js';
|
|
4
|
+
import { resolveValue } from '../chunk-ZWSJVE5S.js';
|
|
5
5
|
import 'server-only';
|
|
6
6
|
import { cache } from 'react';
|
|
7
|
-
import { forbidden, unauthorized } from 'next/navigation';
|
|
8
|
-
import { updateTag } from 'next/cache';
|
|
7
|
+
import { forbidden, unauthorized } from 'next/navigation.js';
|
|
8
|
+
import { updateTag } from 'next/cache.js';
|
|
9
9
|
|
|
10
10
|
function accessCacheTag(subjectId) {
|
|
11
11
|
return `access:${subjectId}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseAuthResponse, hasTokenAudience, decodeTokenPayload, isTokenExpired, isTokenExpiringSoon } from './chunk-FBC2NUH7.js';
|
|
2
|
-
import { DEFAULT_FETCH_TIMEOUT_MS, forwardedRequestHeaders, timedFetch, resolveValue,
|
|
2
|
+
import { DEFAULT_FETCH_TIMEOUT_MS, forwardedRequestHeaders, timedFetch, resolveValue, resolveAll } from './chunk-ZWSJVE5S.js';
|
|
3
3
|
|
|
4
4
|
// src/return-path.ts
|
|
5
5
|
function safeInternalPath(raw) {
|
|
@@ -315,10 +315,12 @@ function createSessionRefresher(config) {
|
|
|
315
315
|
const inflight = /* @__PURE__ */ new Map();
|
|
316
316
|
async function perform(refreshToken) {
|
|
317
317
|
try {
|
|
318
|
-
const
|
|
318
|
+
const pending = resolveAll(config.apiUrl, config.headers);
|
|
319
|
+
const [origin, extra] = pending instanceof Promise ? await pending : pending;
|
|
320
|
+
const headers = new Headers(extra);
|
|
319
321
|
headers.set("Content-Type", "application/json");
|
|
320
322
|
headers.set("X-Client-Type", config.clientType);
|
|
321
|
-
const response = await timedFetch(`${
|
|
323
|
+
const response = await timedFetch(`${origin}${config.refreshPath}`, {
|
|
322
324
|
init: {
|
|
323
325
|
method: "POST",
|
|
324
326
|
headers,
|
|
@@ -25,8 +25,13 @@ function forwardedRequestHeaders(request, init) {
|
|
|
25
25
|
function resolveValue(value) {
|
|
26
26
|
return typeof value === "function" ? value() : value;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
return typeof value === "function" ?
|
|
28
|
+
function resolveAsync(value) {
|
|
29
|
+
return typeof value === "function" ? value() : value;
|
|
30
|
+
}
|
|
31
|
+
var isPromise = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
|
|
32
|
+
function resolveAll(...values) {
|
|
33
|
+
const resolved = values.map((value) => resolveAsync(value));
|
|
34
|
+
return resolved.some(isPromise) ? Promise.all(resolved) : resolved;
|
|
30
35
|
}
|
|
31
36
|
var DEFAULT_FETCH_TIMEOUT_MS = 1e4;
|
|
32
37
|
async function timedFetch(url, options = {}) {
|
|
@@ -44,4 +49,4 @@ async function timedFetch(url, options = {}) {
|
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
export { DEFAULT_FETCH_TIMEOUT_MS, applyForwardedClientHeaders, forwardedRequestHeaders,
|
|
52
|
+
export { DEFAULT_FETCH_TIMEOUT_MS, applyForwardedClientHeaders, forwardedRequestHeaders, resolveAll, resolveValue, timedFetch };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AUTH_ERROR_MESSAGES, HANDOFF_ERROR_FALLBACK, HANDOFF_ERROR_MESSAGES, SSO_ERROR_MESSAGES, authErrorMessage, brokerPaths, createDeviceIdentity, createHandoffSource, createHandoffTarget, createSessionRefresher, deleteCookie, evaluateSessionGate, handoffErrorMessage, hasSessionShape, isAuthErrorCode, isHandoffErrorCode, readCookie, safeInternalPath, serializeCookie, setCookie, sourceStartPath } from './chunk-
|
|
1
|
+
export { AUTH_ERROR_MESSAGES, HANDOFF_ERROR_FALLBACK, HANDOFF_ERROR_MESSAGES, SSO_ERROR_MESSAGES, authErrorMessage, brokerPaths, createDeviceIdentity, createHandoffSource, createHandoffTarget, createSessionRefresher, deleteCookie, evaluateSessionGate, handoffErrorMessage, hasSessionShape, isAuthErrorCode, isHandoffErrorCode, readCookie, safeInternalPath, serializeCookie, setCookie, sourceStartPath } from './chunk-GQ36R3RQ.js';
|
|
2
2
|
export { decodeBase64Url, decodeDefaultSession, decodeTokenPayload, hasTokenAudience, isTokenExpired, isTokenExpiringSoon, parseAuthResponse, tokenMaxAgeSeconds } from './chunk-FBC2NUH7.js';
|
|
3
|
-
export { applyForwardedClientHeaders, forwardedRequestHeaders } from './chunk-
|
|
3
|
+
export { applyForwardedClientHeaders, forwardedRequestHeaders } from './chunk-ZWSJVE5S.js';
|
package/dist/next.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createSessionRefresher, setCookie, deleteCookie } from './chunk-
|
|
2
|
-
export { AUTH_ERROR_MESSAGES, HANDOFF_ERROR_FALLBACK, HANDOFF_ERROR_MESSAGES, SSO_ERROR_MESSAGES, authErrorMessage, brokerPaths, createDeviceIdentity, createHandoffSource, createHandoffTarget, createSessionRefresher, deleteCookie, evaluateSessionGate, handoffErrorMessage, hasSessionShape, isAuthErrorCode, isHandoffErrorCode, readCookie, safeInternalPath, serializeCookie, setCookie, sourceStartPath } from './chunk-
|
|
1
|
+
import { createSessionRefresher, setCookie, deleteCookie } from './chunk-GQ36R3RQ.js';
|
|
2
|
+
export { AUTH_ERROR_MESSAGES, HANDOFF_ERROR_FALLBACK, HANDOFF_ERROR_MESSAGES, SSO_ERROR_MESSAGES, authErrorMessage, brokerPaths, createDeviceIdentity, createHandoffSource, createHandoffTarget, createSessionRefresher, deleteCookie, evaluateSessionGate, handoffErrorMessage, hasSessionShape, isAuthErrorCode, isHandoffErrorCode, readCookie, safeInternalPath, serializeCookie, setCookie, sourceStartPath } from './chunk-GQ36R3RQ.js';
|
|
3
3
|
import { decodeDefaultSession, tokenMaxAgeSeconds, hasTokenAudience, isTokenExpiringSoon, isTokenExpired } from './chunk-FBC2NUH7.js';
|
|
4
4
|
export { decodeBase64Url, decodeDefaultSession, decodeTokenPayload, hasTokenAudience, isTokenExpired, isTokenExpiringSoon, parseAuthResponse, tokenMaxAgeSeconds } from './chunk-FBC2NUH7.js';
|
|
5
|
-
import { applyForwardedClientHeaders, resolveValue } from './chunk-
|
|
6
|
-
export { applyForwardedClientHeaders, forwardedRequestHeaders } from './chunk-
|
|
5
|
+
import { applyForwardedClientHeaders, resolveValue } from './chunk-ZWSJVE5S.js';
|
|
6
|
+
export { applyForwardedClientHeaders, forwardedRequestHeaders } from './chunk-ZWSJVE5S.js';
|
|
7
7
|
import 'server-only';
|
|
8
|
-
import { headers, cookies } from 'next/headers';
|
|
8
|
+
import { headers, cookies } from 'next/headers.js';
|
|
9
9
|
|
|
10
10
|
// src/next/errors.ts
|
|
11
11
|
var SessionExpiredError = class extends Error {
|
|
@@ -83,7 +83,7 @@ function isTimeout(error) {
|
|
|
83
83
|
return error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
|
|
84
84
|
}
|
|
85
85
|
function createPlatformFetch(config) {
|
|
86
|
-
const doFetch = config.fetch ?? globalThis.fetch;
|
|
86
|
+
const doFetch = (input, init) => (config.fetch ?? globalThis.fetch)(input, init);
|
|
87
87
|
const forward = config.forwardHeaders ?? buildForwardedRequestHeaders;
|
|
88
88
|
async function fetchWithAccessToken(path, accessToken, init) {
|
|
89
89
|
try {
|
|
@@ -189,7 +189,7 @@ function createSessionStore(config) {
|
|
|
189
189
|
}
|
|
190
190
|
function assertAudience(token) {
|
|
191
191
|
if (!hasTokenAudience(token, config.audience)) {
|
|
192
|
-
throw new Error(`refusing to store a session token
|
|
192
|
+
throw new Error(`refusing to store a session token with the wrong audience (expected ${config.audience})`);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
function acceptable(token) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/platform-auth",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
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",
|