@c1m-public/platform-auth 0.7.0 → 0.8.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/dist/access/index.d.ts +1 -1
- package/dist/access/index.js +2 -2
- package/dist/access/next.d.ts +1 -1
- package/dist/access/next.js +3 -3
- package/dist/{chunk-RR5DP3QT.js → chunk-OPF4UZLE.js} +1 -1
- package/dist/{chunk-RVKIDFXM.js → chunk-P4LKOHR4.js} +4 -1
- package/dist/{chunk-SMBKTB5V.js → chunk-QV7HSZLE.js} +6 -3
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -2
- package/dist/internal-D6RafCm2.d.ts +6 -0
- package/dist/next.d.ts +6 -3
- package/dist/next.js +5 -4
- package/package.json +1 -1
- package/dist/internal-rnEuAE21.d.ts +0 -4
package/dist/access/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Resolvable } from '../internal-
|
|
1
|
+
import { R as Resolvable } from '../internal-D6RafCm2.js';
|
|
2
2
|
|
|
3
3
|
/** Platform-operator permission keys. */
|
|
4
4
|
declare const PLATFORM_PERMISSIONS: readonly ["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.channels.manage", "platform.channels.view", "platform.config.manage", "platform.docs.manage", "platform.docs.view", "platform.observability.manage", "platform.observability.view", "platform.offboarding.view", "platform.ops.manage", "platform.support.impersonate", "platform.support.sessions", "platform.tenants.archive", "platform.tenants.manage", "platform.tenants.restore", "platform.users.deactivate", "platform.users.delete", "platform.users.invite", "platform.users.manage_access", "platform.users.reactivate", "platform.users.view"];
|
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-OPF4UZLE.js';
|
|
2
|
+
import '../chunk-P4LKOHR4.js';
|
package/dist/access/next.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Resolvable } from '../internal-
|
|
1
|
+
import { R as Resolvable } from '../internal-D6RafCm2.js';
|
|
2
2
|
import { AccessSnapshot, PermissionCheckOptions } from './index.js';
|
|
3
3
|
export { AccessEntry, AccessErrorCode, AccessScopeType, AccessSnapshotError, DASH_PERMISSIONS, DASH_ROLES, DEFAULT_ACCESS_ENDPOINT_PATH, DashPermissionKey, DashRole, FetchAccessSnapshotOptions, LEADBROKER_PERMISSIONS, LeadBrokerPermissionKey, PLATFORM_PERMISSIONS, PermissionKey, PlatformPermissionKey, WORKSPACE_PERMISSIONS, WORKSPACE_ROLES, WorkspacePermissionKey, WorkspaceRole, appScopes, dashRole, emptySnapshot, entryCoversApp, fetchAccessSnapshot, hasAllPermissions, hasAnyPermission, hasPermission, hasWorkspacePermission, isAccessSnapshotError, isPlatformOwner, managedDashes, parseAccessSnapshot, permissionsFor } from './index.js';
|
|
4
4
|
|
package/dist/access/next.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-OPF4UZLE.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-OPF4UZLE.js';
|
|
4
|
+
import { resolveValue } from '../chunk-P4LKOHR4.js';
|
|
5
5
|
import 'server-only';
|
|
6
6
|
import { cache } from 'react';
|
|
7
7
|
import { forbidden, unauthorized } from 'next/navigation';
|
|
@@ -25,6 +25,9 @@ function forwardedRequestHeaders(request, init) {
|
|
|
25
25
|
function resolveValue(value) {
|
|
26
26
|
return typeof value === "function" ? value() : value;
|
|
27
27
|
}
|
|
28
|
+
async function resolveAsync(value) {
|
|
29
|
+
return typeof value === "function" ? await value() : value;
|
|
30
|
+
}
|
|
28
31
|
var DEFAULT_FETCH_TIMEOUT_MS = 1e4;
|
|
29
32
|
async function timedFetch(url, options = {}) {
|
|
30
33
|
const doFetch = options.fetch ?? options.fetchImpl ?? fetch;
|
|
@@ -41,4 +44,4 @@ async function timedFetch(url, options = {}) {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
export { DEFAULT_FETCH_TIMEOUT_MS, applyForwardedClientHeaders, forwardedRequestHeaders, resolveValue, timedFetch };
|
|
47
|
+
export { DEFAULT_FETCH_TIMEOUT_MS, applyForwardedClientHeaders, forwardedRequestHeaders, resolveAsync, resolveValue, timedFetch };
|
|
@@ -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 } from './chunk-
|
|
2
|
+
import { DEFAULT_FETCH_TIMEOUT_MS, forwardedRequestHeaders, timedFetch, resolveValue, resolveAsync } from './chunk-P4LKOHR4.js';
|
|
3
3
|
|
|
4
4
|
// src/return-path.ts
|
|
5
5
|
function safeInternalPath(raw) {
|
|
@@ -315,10 +315,13 @@ function createSessionRefresher(config) {
|
|
|
315
315
|
const inflight = /* @__PURE__ */ new Map();
|
|
316
316
|
async function perform(refreshToken) {
|
|
317
317
|
try {
|
|
318
|
-
const
|
|
318
|
+
const headers = new Headers(await resolveAsync(config.headers));
|
|
319
|
+
headers.set("Content-Type", "application/json");
|
|
320
|
+
headers.set("X-Client-Type", config.clientType);
|
|
321
|
+
const response = await timedFetch(`${await resolveAsync(config.apiUrl)}${config.refreshPath}`, {
|
|
319
322
|
init: {
|
|
320
323
|
method: "POST",
|
|
321
|
-
headers
|
|
324
|
+
headers,
|
|
322
325
|
body: JSON.stringify({ refresh_token: refreshToken })
|
|
323
326
|
},
|
|
324
327
|
timeoutMs,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { applyForwardedClientHeaders, forwardedRequestHeaders } from '@c1m-public/transport';
|
|
2
|
-
import { R as Resolvable } from './internal-
|
|
2
|
+
import { R as Resolvable, A as AsyncResolvable } from './internal-D6RafCm2.js';
|
|
3
3
|
|
|
4
4
|
interface SessionUser {
|
|
5
5
|
id: string;
|
|
@@ -174,8 +174,12 @@ interface RefreshedSession {
|
|
|
174
174
|
refreshToken?: string;
|
|
175
175
|
}
|
|
176
176
|
interface SessionRefresherConfig {
|
|
177
|
-
|
|
177
|
+
/** Backend origin, no /api/v1. May resolve asynchronously (a tenant-scoped origin). */
|
|
178
|
+
apiUrl: AsyncResolvable<string>;
|
|
179
|
+
/** e.g. /api/v1/platform/auth/refresh; empty when `apiUrl` already resolves to the full URL. */
|
|
178
180
|
refreshPath: string;
|
|
181
|
+
/** Extra request headers, e.g. a service credential and its tenant selector. */
|
|
182
|
+
headers?: AsyncResolvable<HeadersInit | undefined>;
|
|
179
183
|
clientType: string;
|
|
180
184
|
audience: string;
|
|
181
185
|
singleflightTtlMs?: number;
|
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-QV7HSZLE.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-P4LKOHR4.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A value that may be fixed or resolved per call (env read at request time). */
|
|
2
|
+
type Resolvable<T = string> = T | (() => T);
|
|
3
|
+
/** A value, a sync resolver, or an async resolver. */
|
|
4
|
+
type AsyncResolvable<T> = T | (() => T | Promise<T>);
|
|
5
|
+
|
|
6
|
+
export type { AsyncResolvable as A, Resolvable as R };
|
package/dist/next.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SessionData, CookieOptions } from './index.js';
|
|
2
2
|
export { AUTH_ERROR_MESSAGES, AuthResponse, DeviceIdentity, DeviceIdentityConfig, DeviceIdentityStore, HANDOFF_ERROR_FALLBACK, HANDOFF_ERROR_MESSAGES, HandoffSource, HandoffSourceConfig, HandoffSourceTarget, HandoffTarget, HandoffTargetConfig, RefreshedSession, SSO_ERROR_MESSAGES, SessionGateDecision, SessionGateInput, SessionRefresher, SessionRefresherConfig, SessionUser, TokenPayload, authErrorMessage, brokerPaths, createDeviceIdentity, createHandoffSource, createHandoffTarget, createSessionRefresher, decodeBase64Url, decodeDefaultSession, decodeTokenPayload, deleteCookie, evaluateSessionGate, handoffErrorMessage, hasSessionShape, hasTokenAudience, isAuthErrorCode, isHandoffErrorCode, isTokenExpired, isTokenExpiringSoon, parseAuthResponse, readCookie, safeInternalPath, serializeCookie, setCookie, sourceStartPath, tokenMaxAgeSeconds } from './index.js';
|
|
3
3
|
export { applyForwardedClientHeaders, forwardedRequestHeaders } from '@c1m-public/transport';
|
|
4
|
-
import { R as Resolvable } from './internal-
|
|
4
|
+
import { R as Resolvable, A as AsyncResolvable } from './internal-D6RafCm2.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The error vocabulary every first-party platform surface uses at its edge.
|
|
@@ -92,9 +92,12 @@ interface SessionCookieNames {
|
|
|
92
92
|
rememberMe: string;
|
|
93
93
|
}
|
|
94
94
|
interface SessionStoreRefreshConfig {
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
/** Backend origin, or a function resolving it per call (a tenant-scoped origin). */
|
|
96
|
+
apiUrl: AsyncResolvable<string>;
|
|
97
|
+
/** e.g. `/api/v1/platform/auth/refresh`; empty when `apiUrl` resolves to the full URL. */
|
|
97
98
|
refreshPath: string;
|
|
99
|
+
/** Extra headers on the refresh call, e.g. a service credential and its tenant selector. */
|
|
100
|
+
headers?: AsyncResolvable<HeadersInit | undefined>;
|
|
98
101
|
clientType: string;
|
|
99
102
|
timeoutMs?: number;
|
|
100
103
|
fetch?: typeof fetch;
|
package/dist/next.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-QV7HSZLE.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-QV7HSZLE.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-P4LKOHR4.js';
|
|
6
|
+
export { applyForwardedClientHeaders, forwardedRequestHeaders } from './chunk-P4LKOHR4.js';
|
|
7
7
|
import 'server-only';
|
|
8
8
|
import { headers, cookies } from 'next/headers';
|
|
9
9
|
|
|
@@ -170,6 +170,7 @@ function createSessionStore(config) {
|
|
|
170
170
|
const refresher = config.refresh ? createSessionRefresher({
|
|
171
171
|
apiUrl: config.refresh.apiUrl,
|
|
172
172
|
refreshPath: config.refresh.refreshPath,
|
|
173
|
+
headers: config.refresh.headers,
|
|
173
174
|
clientType: config.refresh.clientType,
|
|
174
175
|
audience: config.audience,
|
|
175
176
|
timeoutMs: config.refresh.timeoutMs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/platform-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|