@c1m-public/platform-auth 0.9.1 → 0.9.3
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 +1 -0
- package/dist/access/next.d.ts +2 -2
- package/dist/access/next.js +3 -2
- package/dist/{index-CbsCWtku.d.ts → index-BcDlVbUd.d.ts} +1 -1
- package/dist/index.js +28 -10
- package/dist/next.js +39 -17
- package/package.json +1 -1
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-BcDlVbUd.js';
|
package/dist/access/index.js
CHANGED
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-BcDlVbUd.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-BcDlVbUd.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
2
|
import { cache } from 'react';
|
|
3
|
-
import { forbidden, unauthorized } from 'next/navigation
|
|
4
|
-
import { updateTag } from 'next/cache
|
|
3
|
+
import { forbidden, unauthorized } from 'next/navigation';
|
|
4
|
+
import { updateTag } from 'next/cache';
|
|
5
5
|
|
|
6
6
|
// src/access/next.ts
|
|
7
7
|
|
|
@@ -251,6 +251,7 @@ function permissionsFor(snapshot, opts = {}) {
|
|
|
251
251
|
|
|
252
252
|
// src/access/generated/keys.ts
|
|
253
253
|
var PLATFORM_PERMISSIONS = [
|
|
254
|
+
"affiliates.enrollments.manage",
|
|
254
255
|
"affiliates.finance.manage",
|
|
255
256
|
"affiliates.partners.manage",
|
|
256
257
|
"affiliates.programmes.manage",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Platform-operator permission keys. */
|
|
2
|
-
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"];
|
|
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.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"];
|
|
3
3
|
type PlatformPermissionKey = (typeof PLATFORM_PERMISSIONS)[number];
|
|
4
4
|
/** Dash-owner permission keys (granted at dash scope, mirrored from the membership role). */
|
|
5
5
|
declare const DASH_PERMISSIONS: readonly ["dash.apps.manage", "dash.billing.manage", "dash.channels.manage", "dash.customers.manage", "dash.domains.manage", "dash.members.manage", "dash.ownership.transfer", "dash.plans.manage", "dash.publish", "dash.settings.manage", "dash.workspaces.admin", "dash.workspaces.manage"];
|
package/dist/index.js
CHANGED
|
@@ -151,12 +151,27 @@ function serializeCookie(name, value, options = {}) {
|
|
|
151
151
|
return parts.join("; ");
|
|
152
152
|
}
|
|
153
153
|
function setCookie(response, name, value, options) {
|
|
154
|
-
response
|
|
155
|
-
return response;
|
|
154
|
+
return appendSetCookie(response, serializeCookie(name, value, options));
|
|
156
155
|
}
|
|
157
156
|
function deleteCookie(response, name, options) {
|
|
158
|
-
response
|
|
159
|
-
|
|
157
|
+
return appendSetCookie(response, serializeCookie(name, "", { ...options, maxAge: 0 }));
|
|
158
|
+
}
|
|
159
|
+
function appendSetCookie(response, cookie) {
|
|
160
|
+
try {
|
|
161
|
+
response.headers.append("Set-Cookie", cookie);
|
|
162
|
+
return response;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (!(error instanceof TypeError) || !/immutable/i.test(error.message)) {
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
const mutable = new Response(response.body, {
|
|
168
|
+
status: response.status,
|
|
169
|
+
statusText: response.statusText,
|
|
170
|
+
headers: response.headers
|
|
171
|
+
});
|
|
172
|
+
mutable.headers.append("Set-Cookie", cookie);
|
|
173
|
+
return mutable;
|
|
174
|
+
}
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
// src/device-cookie.ts
|
|
@@ -316,8 +331,11 @@ function createHandoffTarget(config) {
|
|
|
316
331
|
const cookieOptions = { httpOnly: true, secure, sameSite: "lax", path: "/", maxAge: HANDOFF_COOKIE_TTL_SECONDS };
|
|
317
332
|
const timeout = config.timeoutMs ?? config.fetchTimeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS;
|
|
318
333
|
const clearHandoffCookies = (response) => {
|
|
319
|
-
|
|
320
|
-
|
|
334
|
+
let result = response;
|
|
335
|
+
for (const name of Object.values(cookies)) {
|
|
336
|
+
result = deleteCookie(result, name, { path: "/", secure });
|
|
337
|
+
}
|
|
338
|
+
return result;
|
|
321
339
|
};
|
|
322
340
|
const fail = (origin, code) => clearHandoffCookies(loginErrorRedirect(origin, config.loginPath, code));
|
|
323
341
|
return {
|
|
@@ -335,11 +353,11 @@ function createHandoffTarget(config) {
|
|
|
335
353
|
const start = new URL(sourceStartPath(config.app), sourceOrigin);
|
|
336
354
|
start.searchParams.set("code_challenge", await s256(verifier));
|
|
337
355
|
start.searchParams.set("state", state);
|
|
338
|
-
|
|
339
|
-
setCookie(response, cookies.verifier, verifier, cookieOptions);
|
|
340
|
-
setCookie(response, cookies.state, state, cookieOptions);
|
|
356
|
+
let response = redirect(start);
|
|
357
|
+
response = setCookie(response, cookies.verifier, verifier, cookieOptions);
|
|
358
|
+
response = setCookie(response, cookies.state, state, cookieOptions);
|
|
341
359
|
const from = safeInternalPath(url.searchParams.get("from"));
|
|
342
|
-
if (from) setCookie(response, cookies.from, from, cookieOptions);
|
|
360
|
+
if (from) response = setCookie(response, cookies.from, from, cookieOptions);
|
|
343
361
|
return response;
|
|
344
362
|
},
|
|
345
363
|
/** GET `?code=&state=` */
|
package/dist/next.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
|
-
import { headers, cookies } from 'next/headers
|
|
2
|
+
import { headers, cookies } from 'next/headers';
|
|
3
3
|
|
|
4
4
|
// src/next.ts
|
|
5
5
|
|
|
@@ -156,12 +156,27 @@ function serializeCookie(name, value, options = {}) {
|
|
|
156
156
|
return parts.join("; ");
|
|
157
157
|
}
|
|
158
158
|
function setCookie(response, name, value, options) {
|
|
159
|
-
response
|
|
160
|
-
return response;
|
|
159
|
+
return appendSetCookie(response, serializeCookie(name, value, options));
|
|
161
160
|
}
|
|
162
161
|
function deleteCookie(response, name, options) {
|
|
163
|
-
response
|
|
164
|
-
|
|
162
|
+
return appendSetCookie(response, serializeCookie(name, "", { ...options, maxAge: 0 }));
|
|
163
|
+
}
|
|
164
|
+
function appendSetCookie(response, cookie) {
|
|
165
|
+
try {
|
|
166
|
+
response.headers.append("Set-Cookie", cookie);
|
|
167
|
+
return response;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (!(error instanceof TypeError) || !/immutable/i.test(error.message)) {
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
const mutable = new Response(response.body, {
|
|
173
|
+
status: response.status,
|
|
174
|
+
statusText: response.statusText,
|
|
175
|
+
headers: response.headers
|
|
176
|
+
});
|
|
177
|
+
mutable.headers.append("Set-Cookie", cookie);
|
|
178
|
+
return mutable;
|
|
179
|
+
}
|
|
165
180
|
}
|
|
166
181
|
|
|
167
182
|
// src/device-cookie.ts
|
|
@@ -321,8 +336,11 @@ function createHandoffTarget(config) {
|
|
|
321
336
|
const cookieOptions = { httpOnly: true, secure, sameSite: "lax", path: "/", maxAge: HANDOFF_COOKIE_TTL_SECONDS };
|
|
322
337
|
const timeout = config.timeoutMs ?? config.fetchTimeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS;
|
|
323
338
|
const clearHandoffCookies = (response) => {
|
|
324
|
-
|
|
325
|
-
|
|
339
|
+
let result = response;
|
|
340
|
+
for (const name of Object.values(cookies)) {
|
|
341
|
+
result = deleteCookie(result, name, { path: "/", secure });
|
|
342
|
+
}
|
|
343
|
+
return result;
|
|
326
344
|
};
|
|
327
345
|
const fail = (origin, code) => clearHandoffCookies(loginErrorRedirect(origin, config.loginPath, code));
|
|
328
346
|
return {
|
|
@@ -340,11 +358,11 @@ function createHandoffTarget(config) {
|
|
|
340
358
|
const start = new URL(sourceStartPath(config.app), sourceOrigin);
|
|
341
359
|
start.searchParams.set("code_challenge", await s256(verifier));
|
|
342
360
|
start.searchParams.set("state", state);
|
|
343
|
-
|
|
344
|
-
setCookie(response, cookies.verifier, verifier, cookieOptions);
|
|
345
|
-
setCookie(response, cookies.state, state, cookieOptions);
|
|
361
|
+
let response = redirect(start);
|
|
362
|
+
response = setCookie(response, cookies.verifier, verifier, cookieOptions);
|
|
363
|
+
response = setCookie(response, cookies.state, state, cookieOptions);
|
|
346
364
|
const from = safeInternalPath(url.searchParams.get("from"));
|
|
347
|
-
if (from) setCookie(response, cookies.from, from, cookieOptions);
|
|
365
|
+
if (from) response = setCookie(response, cookies.from, from, cookieOptions);
|
|
348
366
|
return response;
|
|
349
367
|
},
|
|
350
368
|
/** GET `?code=&state=` */
|
|
@@ -747,10 +765,11 @@ function createSessionStore(config) {
|
|
|
747
765
|
}
|
|
748
766
|
function writeSessionCookies(response, accessToken, refreshToken, rememberMe = config.defaultRememberMe ?? true) {
|
|
749
767
|
assertAudience(accessToken);
|
|
750
|
-
setCookie(response, names.session, accessToken, cookieOptions(rememberMe, accessToken));
|
|
751
|
-
if (refreshToken)
|
|
752
|
-
|
|
753
|
-
|
|
768
|
+
let result = setCookie(response, names.session, accessToken, cookieOptions(rememberMe, accessToken));
|
|
769
|
+
if (refreshToken) {
|
|
770
|
+
result = setCookie(result, names.refreshToken, refreshToken, cookieOptions(rememberMe, refreshToken));
|
|
771
|
+
}
|
|
772
|
+
return setCookie(result, names.rememberMe, rememberMe ? "true" : "false", cookieOptions(rememberMe));
|
|
754
773
|
}
|
|
755
774
|
async function getAccessToken() {
|
|
756
775
|
const store = await jar("getAccessToken");
|
|
@@ -805,8 +824,11 @@ function createSessionStore(config) {
|
|
|
805
824
|
}
|
|
806
825
|
}
|
|
807
826
|
function clearSessionCookies(response) {
|
|
808
|
-
|
|
809
|
-
|
|
827
|
+
let result = response;
|
|
828
|
+
for (const name of [names.session, names.refreshToken, names.rememberMe]) {
|
|
829
|
+
result = deleteCookie(result, name, clearOptions());
|
|
830
|
+
}
|
|
831
|
+
return result;
|
|
810
832
|
}
|
|
811
833
|
async function requireSession() {
|
|
812
834
|
const session = await getSession();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/platform-auth",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
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",
|