actor-gate 0.2.1 → 0.2.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/package.json +51 -8
- package/src/config/index.js +5 -5
- package/src/config/nextjs-public-config.js +2 -2
- package/src/core/index.js +7 -7
- package/src/core/services/access-token-service.js +6 -6
- package/src/core/services/direct-auth-service.js +3 -3
- package/src/core/services/index.js +5 -5
- package/src/core/services/mcp-auth-service.js +3 -3
- package/src/core/services/oauth-service.js +3 -3
- package/src/core/tokens/access-claims.js +1 -1
- package/src/express/index.js +2 -2
- package/src/express/protected-route.js +4 -4
- package/src/index.js +8 -8
- package/src/mcp/index.js +1 -1
- package/src/next/app/catch-all.js +1 -1
- package/src/next/app/cookies.js +1 -1
- package/src/next/app/direct-auth-handlers.js +6 -6
- package/src/next/app/index.js +8 -8
- package/src/next/app/mcp-oauth-handlers.js +5 -5
- package/src/next/app/protected-route.js +3 -3
- package/src/next/app/request.js +1 -1
- package/src/next/app/response.js +1 -1
- package/src/next/app/wrapper.js +3 -3
- package/src/next/index.js +5 -5
- package/src/next/pages/catch-all.js +1 -1
- package/src/next/pages/direct-auth-handlers.js +6 -6
- package/src/next/pages/index.js +8 -8
- package/src/next/pages/mcp-oauth-handlers.js +5 -5
- package/src/next/pages/protected-route.js +3 -3
- package/src/next/pages/response.js +1 -1
- package/src/next/pages/wrapper.js +3 -3
- package/src/next/rewrites.js +1 -1
- package/src/next/shared/auth-http.js +2 -2
- package/src/next/shared/direct-auth-utils.js +2 -2
- package/src/next/shared/oauth-utils.js +1 -1
- package/src/shared/protected-route-session.js +1 -1
- package/src/testing/in-memory/index.js +7 -7
- package/src/testing/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,20 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "actor-gate",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Schema-agnostic Next.js auth library for direct and MCP authentication flows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"./
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"default": "./src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./core": {
|
|
13
|
+
"types": "./src/core/index.d.ts",
|
|
14
|
+
"default": "./src/core/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./config": {
|
|
17
|
+
"types": "./src/config/index.d.ts",
|
|
18
|
+
"default": "./src/config/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./express": {
|
|
21
|
+
"types": "./src/express/index.d.ts",
|
|
22
|
+
"default": "./src/express/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./next": {
|
|
25
|
+
"types": "./src/next/index.d.ts",
|
|
26
|
+
"default": "./src/next/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./mcp": {
|
|
29
|
+
"types": "./src/mcp/index.d.ts",
|
|
30
|
+
"default": "./src/mcp/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./testing": {
|
|
33
|
+
"types": "./src/testing/index.d.ts",
|
|
34
|
+
"default": "./src/testing/index.js"
|
|
35
|
+
}
|
|
15
36
|
},
|
|
16
37
|
"main": "./src/index.js",
|
|
17
38
|
"types": "./src/index.d.ts",
|
|
39
|
+
"typesVersions": {
|
|
40
|
+
"*": {
|
|
41
|
+
"core": [
|
|
42
|
+
"./src/core/index.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"config": [
|
|
45
|
+
"./src/config/index.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"express": [
|
|
48
|
+
"./src/express/index.d.ts"
|
|
49
|
+
],
|
|
50
|
+
"next": [
|
|
51
|
+
"./src/next/index.d.ts"
|
|
52
|
+
],
|
|
53
|
+
"mcp": [
|
|
54
|
+
"./src/mcp/index.d.ts"
|
|
55
|
+
],
|
|
56
|
+
"testing": [
|
|
57
|
+
"./src/testing/index.d.ts"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
18
61
|
"files": [
|
|
19
62
|
"src/**/*.js",
|
|
20
63
|
"src/**/*.d.ts"
|
package/src/config/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defineBaseAuthConfig, } from './base-config';
|
|
2
|
-
export { defineNextJsPublicAuthConfig, toSerializableNextJsPublicAuthConfig, } from './nextjs-public-config';
|
|
3
|
-
export { defineNextJsServerAuthConfig, } from './nextjs-server-config';
|
|
4
|
-
export { defineReactAuthConfig, } from './react-config';
|
|
5
|
-
export { ReactAuthClient, createReactAuthClient, } from './react-client';
|
|
1
|
+
export { defineBaseAuthConfig, } from './base-config.js';
|
|
2
|
+
export { defineNextJsPublicAuthConfig, toSerializableNextJsPublicAuthConfig, } from './nextjs-public-config.js';
|
|
3
|
+
export { defineNextJsServerAuthConfig, } from './nextjs-server-config.js';
|
|
4
|
+
export { defineReactAuthConfig, } from './react-config.js';
|
|
5
|
+
export { ReactAuthClient, createReactAuthClient, } from './react-client.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildAuthRoutePath, } from '../next/shared/auth-routes';
|
|
2
|
-
import { buildAuthRewrites, } from '../next/rewrites';
|
|
1
|
+
import { buildAuthRoutePath, } from '../next/shared/auth-routes.js';
|
|
2
|
+
import { buildAuthRewrites, } from '../next/rewrites.js';
|
|
3
3
|
function normalizePath(path) {
|
|
4
4
|
const trimmed = path.trim();
|
|
5
5
|
if (trimmed.length === 0) {
|
package/src/core/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { buildBearerChallengeHeader, } from './http/bearer-challenge';
|
|
2
|
-
export { base64UrlEncode, createS256CodeChallenge, verifyPkce, } from './oauth/pkce';
|
|
3
|
-
export { numberIdCodec, stringIdCodec } from './ids/id-codec';
|
|
4
|
-
export { decodeSubjectClaims, encodeSubjectClaims, } from './tokens/id-claims';
|
|
5
|
-
export * from './services/index';
|
|
6
|
-
export { DEFAULT_TOKEN_CLAIMS_VERSION, buildAccessClaims, parseAccessClaims, } from './tokens/access-claims';
|
|
7
|
-
export { buildClientSession } from './sessions/client-session';
|
|
1
|
+
export { buildBearerChallengeHeader, } from './http/bearer-challenge.js';
|
|
2
|
+
export { base64UrlEncode, createS256CodeChallenge, verifyPkce, } from './oauth/pkce.js';
|
|
3
|
+
export { numberIdCodec, stringIdCodec } from './ids/id-codec.js';
|
|
4
|
+
export { decodeSubjectClaims, encodeSubjectClaims, } from './tokens/id-claims.js';
|
|
5
|
+
export * from './services/index.js';
|
|
6
|
+
export { DEFAULT_TOKEN_CLAIMS_VERSION, buildAccessClaims, parseAccessClaims, } from './tokens/access-claims.js';
|
|
7
|
+
export { buildClientSession } from './sessions/client-session.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { buildClientSession } from '../sessions/client-session';
|
|
2
|
-
import { decodeSubjectClaims } from '../tokens/id-claims';
|
|
3
|
-
import { buildAccessClaims, parseAccessClaims } from '../tokens/access-claims';
|
|
4
|
-
import { AuthServiceError, isAuthServiceError } from './auth-error';
|
|
5
|
-
import { createRevocationDecisionEngine, shouldValidateSession, } from './revocation-policy';
|
|
6
|
-
import { emitAuditEvent, emitMetric, reportServiceError, } from './observability';
|
|
1
|
+
import { buildClientSession } from '../sessions/client-session.js';
|
|
2
|
+
import { decodeSubjectClaims } from '../tokens/id-claims.js';
|
|
3
|
+
import { buildAccessClaims, parseAccessClaims } from '../tokens/access-claims.js';
|
|
4
|
+
import { AuthServiceError, isAuthServiceError } from './auth-error.js';
|
|
5
|
+
import { createRevocationDecisionEngine, shouldValidateSession, } from './revocation-policy.js';
|
|
6
|
+
import { emitAuditEvent, emitMetric, reportServiceError, } from './observability.js';
|
|
7
7
|
function assertPositiveSafeInteger(value, fieldName) {
|
|
8
8
|
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
9
9
|
throw new AuthServiceError({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { buildClientSession } from '../sessions/client-session';
|
|
2
|
-
import { AuthServiceError, isAuthServiceError } from './auth-error';
|
|
3
|
-
import { emitAuditEvent, emitMetric, reportServiceError, } from './observability';
|
|
1
|
+
import { buildClientSession } from '../sessions/client-session.js';
|
|
2
|
+
import { AuthServiceError, isAuthServiceError } from './auth-error.js';
|
|
3
|
+
import { emitAuditEvent, emitMetric, reportServiceError, } from './observability.js';
|
|
4
4
|
function assertPositiveSafeInteger(value, fieldName) {
|
|
5
5
|
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
6
6
|
throw new AuthServiceError({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AuthServiceError, authErrorToHttpStatus, isAuthServiceError, } from './auth-error';
|
|
2
|
-
export { createAccessTokenService, } from './access-token-service';
|
|
3
|
-
export { createDirectAuthService, } from './direct-auth-service';
|
|
4
|
-
export { createOAuthService, } from './oauth-service';
|
|
5
|
-
export { createMcpAuthService, } from './mcp-auth-service';
|
|
1
|
+
export { AuthServiceError, authErrorToHttpStatus, isAuthServiceError, } from './auth-error.js';
|
|
2
|
+
export { createAccessTokenService, } from './access-token-service.js';
|
|
3
|
+
export { createDirectAuthService, } from './direct-auth-service.js';
|
|
4
|
+
export { createOAuthService, } from './oauth-service.js';
|
|
5
|
+
export { createMcpAuthService, } from './mcp-auth-service.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DEFAULT_UNAUTHENTICATED_RPC_METHODS, getRpcMethodsFromBody, requiresAuth, } from '../../mcp/json-rpc-auth';
|
|
2
|
-
import { AuthServiceError, isAuthServiceError } from './auth-error';
|
|
3
|
-
import { emitAuditEvent, reportServiceError } from './observability';
|
|
1
|
+
import { DEFAULT_UNAUTHENTICATED_RPC_METHODS, getRpcMethodsFromBody, requiresAuth, } from '../../mcp/json-rpc-auth.js';
|
|
2
|
+
import { AuthServiceError, isAuthServiceError } from './auth-error.js';
|
|
3
|
+
import { emitAuditEvent, reportServiceError } from './observability.js';
|
|
4
4
|
function extractToolNameFromPayload(payload) {
|
|
5
5
|
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
6
6
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { verifyPkce } from '../oauth/pkce';
|
|
2
|
-
import { AuthServiceError, isAuthServiceError } from './auth-error';
|
|
3
|
-
import { emitAuditEvent, reportServiceError } from './observability';
|
|
1
|
+
import { verifyPkce } from '../oauth/pkce.js';
|
|
2
|
+
import { AuthServiceError, isAuthServiceError } from './auth-error.js';
|
|
3
|
+
import { emitAuditEvent, reportServiceError } from './observability.js';
|
|
4
4
|
function assertPositiveSafeInteger(value, fieldName) {
|
|
5
5
|
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
6
6
|
throw new AuthServiceError({
|
package/src/express/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { withExpressProtectedRoute, } from './protected-route';
|
|
2
|
-
export { buildProtectedRouteSession, buildProtectedRouteSessionWithMeta, } from '../shared/protected-route-session';
|
|
1
|
+
export { withExpressProtectedRoute, } from './protected-route.js';
|
|
2
|
+
export { buildProtectedRouteSession, buildProtectedRouteSessionWithMeta, } from '../shared/protected-route-session.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AuthServiceError, isAuthServiceError, } from '../core/services/auth-error';
|
|
2
|
-
import { parseCookieHeader } from '../next/pages/request';
|
|
3
|
-
import { buildAuthErrorHttpResponse, buildSystemErrorHttpResponse, } from '../next/shared/auth-http';
|
|
4
|
-
import { assertBearerOnlyActorPolicy, getHeaderValue, resolveAccessTokenTransportAdapter, } from '../next/shared/direct-auth-utils';
|
|
1
|
+
import { AuthServiceError, isAuthServiceError, } from '../core/services/auth-error.js';
|
|
2
|
+
import { parseCookieHeader } from '../next/pages/request.js';
|
|
3
|
+
import { buildAuthErrorHttpResponse, buildSystemErrorHttpResponse, } from '../next/shared/auth-http.js';
|
|
4
|
+
import { assertBearerOnlyActorPolicy, getHeaderValue, resolveAccessTokenTransportAdapter, } from '../next/shared/direct-auth-utils.js';
|
|
5
5
|
function normalizeRequestId(value) {
|
|
6
6
|
return value;
|
|
7
7
|
}
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './core/index';
|
|
2
|
-
export * from './config/index';
|
|
3
|
-
export * from './express/index';
|
|
4
|
-
export * as config from './config/index';
|
|
5
|
-
export * as express from './express/index';
|
|
6
|
-
export * as mcp from './mcp/index';
|
|
7
|
-
export * as next from './next/index';
|
|
8
|
-
export * as testing from './testing/index';
|
|
1
|
+
export * from './core/index.js';
|
|
2
|
+
export * from './config/index.js';
|
|
3
|
+
export * from './express/index.js';
|
|
4
|
+
export * as config from './config/index.js';
|
|
5
|
+
export * as express from './express/index.js';
|
|
6
|
+
export * as mcp from './mcp/index.js';
|
|
7
|
+
export * as next from './next/index.js';
|
|
8
|
+
export * as testing from './testing/index.js';
|
package/src/mcp/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DEFAULT_UNAUTHENTICATED_RPC_METHODS, getRpcMethodFromBody, getRpcMethodsFromBody, requiresAuth, requiresAuthForBody, } from './json-rpc-auth';
|
|
1
|
+
export { DEFAULT_UNAUTHENTICATED_RPC_METHODS, getRpcMethodFromBody, getRpcMethodsFromBody, requiresAuth, requiresAuthForBody, } from './json-rpc-auth.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTH_ROUTE_HTTP_METHODS, isAuthRouteMethodAllowed, normalizeAuthRouteSegments, resolveAuthRoute, } from '../shared/auth-routes';
|
|
1
|
+
import { AUTH_ROUTE_HTTP_METHODS, isAuthRouteMethodAllowed, normalizeAuthRouteSegments, resolveAuthRoute, } from '../shared/auth-routes.js';
|
|
2
2
|
function jsonResponse(statusCode, body, headers) {
|
|
3
3
|
const responseHeaders = new Headers(headers);
|
|
4
4
|
responseHeaders.set('Content-Type', 'application/json');
|
package/src/next/app/cookies.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AuthServiceError } from '../../core/services/auth-error';
|
|
2
|
-
import { clearAppAuthCookie, setAppAuthCookie, } from './cookies';
|
|
3
|
-
import { sendAppRedirect } from './response';
|
|
4
|
-
import { withAppAuthRoute } from './wrapper';
|
|
5
|
-
import { assertBearerOnlyActorPolicy, assertCsrfForCookieMutation, DEFAULT_ACCESS_TOKEN_COOKIE_NAME, DEFAULT_REFRESH_TOKEN_COOKIE_NAME, extractRefreshToken, parseNonNegativeSafeInteger, resolveAccessTokenTransportAdapter, resolveCookieSecureFlag, resolveLoginMethod, resolvePathnameFromUrl, } from '../shared/direct-auth-utils';
|
|
6
|
-
import { parseBodyToRecord, toSingleString } from '../shared/oauth-utils';
|
|
1
|
+
import { AuthServiceError } from '../../core/services/auth-error.js';
|
|
2
|
+
import { clearAppAuthCookie, setAppAuthCookie, } from './cookies.js';
|
|
3
|
+
import { sendAppRedirect } from './response.js';
|
|
4
|
+
import { withAppAuthRoute } from './wrapper.js';
|
|
5
|
+
import { assertBearerOnlyActorPolicy, assertCsrfForCookieMutation, DEFAULT_ACCESS_TOKEN_COOKIE_NAME, DEFAULT_REFRESH_TOKEN_COOKIE_NAME, extractRefreshToken, parseNonNegativeSafeInteger, resolveAccessTokenTransportAdapter, resolveCookieSecureFlag, resolveLoginMethod, resolvePathnameFromUrl, } from '../shared/direct-auth-utils.js';
|
|
6
|
+
import { parseBodyToRecord, toSingleString } from '../shared/oauth-utils.js';
|
|
7
7
|
function jsonResponse(statusCode, body, headers) {
|
|
8
8
|
const responseHeaders = new Headers(headers);
|
|
9
9
|
responseHeaders.set('Content-Type', 'application/json');
|
package/src/next/app/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { buildAppAccessTokenTransportInput, getAppAuthorizationHeader, getAppCookies, getAppRequestId, } from './request';
|
|
2
|
-
export { appendAppSetCookieHeader, clearAppAuthCookie, setAppAuthCookie, setAppCookie, } from './cookies';
|
|
3
|
-
export { sendAppAuthError, sendAppRedirect, sendAppSystemError, } from './response';
|
|
4
|
-
export { withAppAuthRoute, } from './wrapper';
|
|
5
|
-
export { withAppProtectedRoute, } from './protected-route';
|
|
6
|
-
export { APP_AUTH_CATCH_ALL_METHODS, createAppAuthCatchAllHandlers, } from './catch-all';
|
|
7
|
-
export { createAppMcpHandler, createAppOAuthHandlers, createAppWellKnownHandlers, } from './mcp-oauth-handlers';
|
|
8
|
-
export { createAppDirectAuthHandlers, } from './direct-auth-handlers';
|
|
1
|
+
export { buildAppAccessTokenTransportInput, getAppAuthorizationHeader, getAppCookies, getAppRequestId, } from './request.js';
|
|
2
|
+
export { appendAppSetCookieHeader, clearAppAuthCookie, setAppAuthCookie, setAppCookie, } from './cookies.js';
|
|
3
|
+
export { sendAppAuthError, sendAppRedirect, sendAppSystemError, } from './response.js';
|
|
4
|
+
export { withAppAuthRoute, } from './wrapper.js';
|
|
5
|
+
export { withAppProtectedRoute, } from './protected-route.js';
|
|
6
|
+
export { APP_AUTH_CATCH_ALL_METHODS, createAppAuthCatchAllHandlers, } from './catch-all.js';
|
|
7
|
+
export { createAppMcpHandler, createAppOAuthHandlers, createAppWellKnownHandlers, } from './mcp-oauth-handlers.js';
|
|
8
|
+
export { createAppDirectAuthHandlers, } from './direct-auth-handlers.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from 'crypto';
|
|
2
|
-
import { AuthServiceError } from '../../core/services/auth-error';
|
|
3
|
-
import { sendAppRedirect } from './response';
|
|
4
|
-
import { withAppAuthRoute } from './wrapper';
|
|
5
|
-
import { appendUrlParams, parseAuthorizeRequest, parseBodyToRecord, parseBoolean, parseOAuthTokenRequest, parsePositiveSafeInteger, } from '../shared/oauth-utils';
|
|
6
|
-
import { buildWellKnownMetadata, resolveRequestOrigin, } from '../shared/well-known-utils';
|
|
2
|
+
import { AuthServiceError } from '../../core/services/auth-error.js';
|
|
3
|
+
import { sendAppRedirect } from './response.js';
|
|
4
|
+
import { withAppAuthRoute } from './wrapper.js';
|
|
5
|
+
import { appendUrlParams, parseAuthorizeRequest, parseBodyToRecord, parseBoolean, parseOAuthTokenRequest, parsePositiveSafeInteger, } from '../shared/oauth-utils.js';
|
|
6
|
+
import { buildWellKnownMetadata, resolveRequestOrigin, } from '../shared/well-known-utils.js';
|
|
7
7
|
function jsonResponse(statusCode, body, headers) {
|
|
8
8
|
const responseHeaders = new Headers(headers);
|
|
9
9
|
responseHeaders.set('Content-Type', 'application/json');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AuthServiceError } from '../../core/services/auth-error';
|
|
2
|
-
import { assertBearerOnlyActorPolicy, resolveAccessTokenTransportAdapter, } from '../shared/direct-auth-utils';
|
|
3
|
-
import { withAppAuthRoute } from './wrapper';
|
|
1
|
+
import { AuthServiceError } from '../../core/services/auth-error.js';
|
|
2
|
+
import { assertBearerOnlyActorPolicy, resolveAccessTokenTransportAdapter, } from '../shared/direct-auth-utils.js';
|
|
3
|
+
import { withAppAuthRoute } from './wrapper.js';
|
|
4
4
|
/**
|
|
5
5
|
* Wraps a Next.js App Router handler with access-token authentication and
|
|
6
6
|
* standardized auth/system error handling.
|
package/src/next/app/request.js
CHANGED
package/src/next/app/response.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildAuthErrorHttpResponse, buildSystemErrorHttpResponse, } from '../shared/auth-http';
|
|
1
|
+
import { buildAuthErrorHttpResponse, buildSystemErrorHttpResponse, } from '../shared/auth-http.js';
|
|
2
2
|
function createJsonResponse(input) {
|
|
3
3
|
const headers = new Headers(input.headers);
|
|
4
4
|
headers.set('Content-Type', 'application/json');
|
package/src/next/app/wrapper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isAuthServiceError } from '../../core/services/auth-error';
|
|
2
|
-
import { buildAppAccessTokenTransportInput, getAppCookies, getAppRequestId, } from './request';
|
|
3
|
-
import { sendAppAuthError, sendAppSystemError } from './response';
|
|
1
|
+
import { isAuthServiceError } from '../../core/services/auth-error.js';
|
|
2
|
+
import { buildAppAccessTokenTransportInput, getAppCookies, getAppRequestId, } from './request.js';
|
|
3
|
+
import { sendAppAuthError, sendAppSystemError } from './response.js';
|
|
4
4
|
export function withAppAuthRoute(options) {
|
|
5
5
|
return async function appAuthRoute(req) {
|
|
6
6
|
const requestId = getAppRequestId(req, options.requestIdHeaderName);
|
package/src/next/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const SUPPORTED_NEXT_ROUTERS = ['pages', 'app'];
|
|
2
|
-
export { buildProtectedRouteSession, buildProtectedRouteSessionWithMeta, } from '../shared/protected-route-session';
|
|
3
|
-
export * from './pages/index';
|
|
4
|
-
export * from './app/index';
|
|
5
|
-
export * from './shared/auth-routes';
|
|
6
|
-
export * from './rewrites';
|
|
2
|
+
export { buildProtectedRouteSession, buildProtectedRouteSessionWithMeta, } from '../shared/protected-route-session.js';
|
|
3
|
+
export * from './pages/index.js';
|
|
4
|
+
export * from './app/index.js';
|
|
5
|
+
export * from './shared/auth-routes.js';
|
|
6
|
+
export * from './rewrites.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAuthRouteMethodAllowed, normalizeAuthRouteSegments, resolveAuthRoute, } from '../shared/auth-routes';
|
|
1
|
+
import { isAuthRouteMethodAllowed, normalizeAuthRouteSegments, resolveAuthRoute, } from '../shared/auth-routes.js';
|
|
2
2
|
function sendUnsupportedRoute(res) {
|
|
3
3
|
res.status(404).json({
|
|
4
4
|
error: 'not_found',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AuthServiceError } from '../../core/services/auth-error';
|
|
2
|
-
import { clearPagesAuthCookie, setPagesAuthCookie, } from './cookies';
|
|
3
|
-
import { sendPagesRedirect } from './response';
|
|
4
|
-
import { withPagesAuthRoute } from './wrapper';
|
|
5
|
-
import { assertBearerOnlyActorPolicy, assertCsrfForCookieMutation, DEFAULT_ACCESS_TOKEN_COOKIE_NAME, DEFAULT_REFRESH_TOKEN_COOKIE_NAME, extractRefreshToken, parseNonNegativeSafeInteger, resolveAccessTokenTransportAdapter, resolveCookieSecureFlag, resolveLoginMethod, resolvePathnameFromUrl, } from '../shared/direct-auth-utils';
|
|
6
|
-
import { parseBodyToRecord, toSingleString } from '../shared/oauth-utils';
|
|
1
|
+
import { AuthServiceError } from '../../core/services/auth-error.js';
|
|
2
|
+
import { clearPagesAuthCookie, setPagesAuthCookie, } from './cookies.js';
|
|
3
|
+
import { sendPagesRedirect } from './response.js';
|
|
4
|
+
import { withPagesAuthRoute } from './wrapper.js';
|
|
5
|
+
import { assertBearerOnlyActorPolicy, assertCsrfForCookieMutation, DEFAULT_ACCESS_TOKEN_COOKIE_NAME, DEFAULT_REFRESH_TOKEN_COOKIE_NAME, extractRefreshToken, parseNonNegativeSafeInteger, resolveAccessTokenTransportAdapter, resolveCookieSecureFlag, resolveLoginMethod, resolvePathnameFromUrl, } from '../shared/direct-auth-utils.js';
|
|
6
|
+
import { parseBodyToRecord, toSingleString } from '../shared/oauth-utils.js';
|
|
7
7
|
function sendMethodNotAllowed(res, allowedMethods) {
|
|
8
8
|
res.setHeader('Allow', allowedMethods.join(', '));
|
|
9
9
|
res.status(405).json({
|
package/src/next/pages/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { buildPagesAccessTokenTransportInput, getPagesAuthorizationHeader, getPagesCookies, getPagesRequestId, parseCookieHeader, } from './request';
|
|
2
|
-
export { appendSetCookieHeader, clearPagesAuthCookie, serializeSetCookie, setPagesAuthCookie, setPagesCookie, } from './cookies';
|
|
3
|
-
export { sendPagesAuthError, sendPagesRedirect, sendPagesSystemError, } from './response';
|
|
4
|
-
export { withPagesAuthRoute, } from './wrapper';
|
|
5
|
-
export { withPagesProtectedRoute, } from './protected-route';
|
|
6
|
-
export { createPagesAuthCatchAllHandler, } from './catch-all';
|
|
7
|
-
export { createPagesMcpHandler, createPagesOAuthHandlers, createPagesWellKnownHandlers, } from './mcp-oauth-handlers';
|
|
8
|
-
export { createPagesDirectAuthHandlers, } from './direct-auth-handlers';
|
|
1
|
+
export { buildPagesAccessTokenTransportInput, getPagesAuthorizationHeader, getPagesCookies, getPagesRequestId, parseCookieHeader, } from './request.js';
|
|
2
|
+
export { appendSetCookieHeader, clearPagesAuthCookie, serializeSetCookie, setPagesAuthCookie, setPagesCookie, } from './cookies.js';
|
|
3
|
+
export { sendPagesAuthError, sendPagesRedirect, sendPagesSystemError, } from './response.js';
|
|
4
|
+
export { withPagesAuthRoute, } from './wrapper.js';
|
|
5
|
+
export { withPagesProtectedRoute, } from './protected-route.js';
|
|
6
|
+
export { createPagesAuthCatchAllHandler, } from './catch-all.js';
|
|
7
|
+
export { createPagesMcpHandler, createPagesOAuthHandlers, createPagesWellKnownHandlers, } from './mcp-oauth-handlers.js';
|
|
8
|
+
export { createPagesDirectAuthHandlers, } from './direct-auth-handlers.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from 'crypto';
|
|
2
|
-
import { AuthServiceError } from '../../core/services/auth-error';
|
|
3
|
-
import { sendPagesRedirect } from './response';
|
|
4
|
-
import { withPagesAuthRoute } from './wrapper';
|
|
5
|
-
import { appendUrlParams, parseAuthorizeRequest, parseBodyToRecord, parseBoolean, parseOAuthTokenRequest, parsePositiveSafeInteger, toSingleString, } from '../shared/oauth-utils';
|
|
6
|
-
import { buildWellKnownMetadata, resolveRequestOrigin, } from '../shared/well-known-utils';
|
|
2
|
+
import { AuthServiceError } from '../../core/services/auth-error.js';
|
|
3
|
+
import { sendPagesRedirect } from './response.js';
|
|
4
|
+
import { withPagesAuthRoute } from './wrapper.js';
|
|
5
|
+
import { appendUrlParams, parseAuthorizeRequest, parseBodyToRecord, parseBoolean, parseOAuthTokenRequest, parsePositiveSafeInteger, toSingleString, } from '../shared/oauth-utils.js';
|
|
6
|
+
import { buildWellKnownMetadata, resolveRequestOrigin, } from '../shared/well-known-utils.js';
|
|
7
7
|
function sendMethodNotAllowed(res, allowedMethods) {
|
|
8
8
|
res.setHeader('Allow', allowedMethods.join(', '));
|
|
9
9
|
res.status(405).json({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AuthServiceError } from '../../core/services/auth-error';
|
|
2
|
-
import { assertBearerOnlyActorPolicy, resolveAccessTokenTransportAdapter, } from '../shared/direct-auth-utils';
|
|
3
|
-
import { withPagesAuthRoute } from './wrapper';
|
|
1
|
+
import { AuthServiceError } from '../../core/services/auth-error.js';
|
|
2
|
+
import { assertBearerOnlyActorPolicy, resolveAccessTokenTransportAdapter, } from '../shared/direct-auth-utils.js';
|
|
3
|
+
import { withPagesAuthRoute } from './wrapper.js';
|
|
4
4
|
/**
|
|
5
5
|
* Wraps a Next.js Pages API route with access-token authentication and
|
|
6
6
|
* standardized auth/system error handling.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildAuthErrorHttpResponse, buildSystemErrorHttpResponse, } from '../shared/auth-http';
|
|
1
|
+
import { buildAuthErrorHttpResponse, buildSystemErrorHttpResponse, } from '../shared/auth-http.js';
|
|
2
2
|
export function sendPagesAuthError(res, error, options) {
|
|
3
3
|
const mapped = buildAuthErrorHttpResponse({
|
|
4
4
|
error,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isAuthServiceError } from '../../core/services/auth-error';
|
|
2
|
-
import { buildPagesAccessTokenTransportInput, getPagesRequestId, } from './request';
|
|
3
|
-
import { sendPagesAuthError, sendPagesSystemError } from './response';
|
|
1
|
+
import { isAuthServiceError } from '../../core/services/auth-error.js';
|
|
2
|
+
import { buildPagesAccessTokenTransportInput, getPagesRequestId, } from './request.js';
|
|
3
|
+
import { sendPagesAuthError, sendPagesSystemError } from './response.js';
|
|
4
4
|
export function withPagesAuthRoute(options) {
|
|
5
5
|
return async function pagesAuthRoute(req, res) {
|
|
6
6
|
const requestId = getPagesRequestId(req, options.requestIdHeaderName);
|
package/src/next/rewrites.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildBearerChallengeHeader } from '../../core/http/bearer-challenge';
|
|
2
|
-
import { authErrorToHttpStatus, } from '../../core/services/auth-error';
|
|
1
|
+
import { buildBearerChallengeHeader } from '../../core/http/bearer-challenge.js';
|
|
2
|
+
import { authErrorToHttpStatus, } from '../../core/services/auth-error.js';
|
|
3
3
|
function toBearerChallengeError(code) {
|
|
4
4
|
return code === 'invalid_client' ? 'invalid_client' : 'invalid_token';
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthServiceError } from '../../core/services/auth-error';
|
|
2
|
-
import { toSingleString } from './oauth-utils';
|
|
1
|
+
import { AuthServiceError } from '../../core/services/auth-error.js';
|
|
2
|
+
import { toSingleString } from './oauth-utils.js';
|
|
3
3
|
export const DEFAULT_ACCESS_TOKEN_COOKIE_NAME = 'access_token';
|
|
4
4
|
export const DEFAULT_REFRESH_TOKEN_COOKIE_NAME = 'refresh_token';
|
|
5
5
|
export const DEFAULT_CSRF_COOKIE_NAME = 'csrf_token';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createInMemoryAccessTokenRevocationAdapter } from './in-memory-access-token-revocation-adapter';
|
|
2
|
-
export { createInMemoryAuthorizationCodeAdapter } from './in-memory-authorization-code-adapter';
|
|
3
|
-
export { createInMemoryOAuthClientAdapter, } from './in-memory-oauth-client-adapter';
|
|
4
|
-
export { createInMemoryPendingAuthRequestAdapter } from './in-memory-pending-auth-request-adapter';
|
|
5
|
-
export { createInMemoryRefreshTokenAdapter } from './in-memory-refresh-token-adapter';
|
|
6
|
-
export { createInMemorySessionAdapter } from './in-memory-session-adapter';
|
|
7
|
-
export { createIncrementingIdFactory, createStepClock } from './test-fixtures';
|
|
1
|
+
export { createInMemoryAccessTokenRevocationAdapter } from './in-memory-access-token-revocation-adapter.js';
|
|
2
|
+
export { createInMemoryAuthorizationCodeAdapter } from './in-memory-authorization-code-adapter.js';
|
|
3
|
+
export { createInMemoryOAuthClientAdapter, } from './in-memory-oauth-client-adapter.js';
|
|
4
|
+
export { createInMemoryPendingAuthRequestAdapter } from './in-memory-pending-auth-request-adapter.js';
|
|
5
|
+
export { createInMemoryRefreshTokenAdapter } from './in-memory-refresh-token-adapter.js';
|
|
6
|
+
export { createInMemorySessionAdapter } from './in-memory-session-adapter.js';
|
|
7
|
+
export { createIncrementingIdFactory, createStepClock } from './test-fixtures.js';
|
package/src/testing/index.js
CHANGED