@oauth42/next 0.5.0 → 0.5.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.
@@ -1,8 +1,8 @@
1
+ import { a as OAuth42ClientAssertion, O as OAuth42DPoP, S as SessionStoreMode } from './index-BuZTiUds.mjs';
1
2
  import { OAuthUserConfig, OAuthConfig } from 'next-auth/providers/oauth';
2
3
  import * as next_auth from 'next-auth';
3
4
  import { NextAuthOptions } from 'next-auth';
4
5
  import { GetServerSidePropsContext, NextApiRequest, NextApiResponse } from 'next';
5
- import { S as SessionStoreMode } from './index-Cfqxl9r2.mjs';
6
6
 
7
7
  interface OAuth42Profile {
8
8
  sub: string;
@@ -18,15 +18,17 @@ interface OAuth42Profile {
18
18
  }
19
19
  interface OAuth42ProviderOptions {
20
20
  clientId: string;
21
- clientSecret: string;
21
+ clientSecret?: string;
22
+ clientAssertionKey?: OAuth42ClientAssertion;
22
23
  issuer?: string;
23
24
  authorizationUrl?: string;
24
25
  tokenUrl?: string;
25
26
  userinfoUrl?: string;
26
27
  scopes?: string[];
27
28
  pkceEnabled?: boolean;
29
+ dpop?: OAuth42DPoP;
28
30
  }
29
- declare function OAuth42Provider<P extends OAuth42Profile>(options: OAuthUserConfig<P> & Partial<OAuth42ProviderOptions>): OAuthConfig<P>;
31
+ declare function OAuth42Provider<P extends OAuth42Profile>(options: Omit<OAuthUserConfig<P>, 'clientSecret'> & Partial<OAuth42ProviderOptions>): OAuthConfig<P>;
30
32
 
31
33
  /**
32
34
  * Get the OAuth42 session server-side
@@ -44,10 +46,8 @@ declare function OAuth42Provider<P extends OAuth42Profile>(options: OAuthUserCon
44
46
  * const session = await getOAuth42Session(req, res, authOptions);
45
47
  * ```
46
48
  *
47
- * **Token Refresh Support:**
48
- * When middleware refreshes an expired token, it passes the new token via
49
- * the `x-oauth42-refreshed-token` header. This function automatically detects
50
- * and uses that refreshed token, ensuring API routes always have a valid token.
49
+ * Middleware forwards refreshed encrypted session cookies to the current request.
50
+ * Caller-supplied access-token headers are never an authentication source.
51
51
  */
52
52
  declare function getOAuth42Session(...args: [GetServerSidePropsContext['req'], GetServerSidePropsContext['res'], NextAuthOptions] | [NextApiRequest, NextApiResponse, NextAuthOptions] | [NextAuthOptions]): Promise<next_auth.Session | null>;
53
53
  /**
@@ -65,6 +65,10 @@ interface CreateAuthOptions {
65
65
  issuer?: string;
66
66
  scopes?: string[];
67
67
  pkceEnabled?: boolean;
68
+ /** Require PAR through the returned App Router handlers; never falls back. */
69
+ pushedAuthorization?: boolean;
70
+ dpop?: OAuth42DPoP;
71
+ clientAssertionKey?: OAuth42ClientAssertion;
68
72
  debug?: boolean;
69
73
  callbacks?: NextAuthOptions['callbacks'];
70
74
  events?: NextAuthOptions['events'];
@@ -115,10 +119,21 @@ declare const getServerSession: typeof getOAuth42Session;
115
119
  * Token refresh helper with simple per-process locking
116
120
  *
117
121
  * The lock prevents multiple concurrent refresh calls from the same process,
118
- * reducing unnecessary token churn. The backend also has a 10-second grace
119
- * period for blacklisted tokens, so concurrent requests across processes
120
- * will still succeed.
122
+ * reducing unnecessary token churn. Coordinate refresh across backend instances;
123
+ * the server rejects reuse of an already rotated refresh token.
121
124
  */
122
- declare function refreshAccessToken(token: any, clientId: string, clientSecret: string, issuer?: string): Promise<any>;
125
+ declare function refreshAccessToken(token: any, clientId: string, clientSecret: string, issuer?: string, dpop?: OAuth42DPoP, clientAssertionKey?: OAuth42ClientAssertion): Promise<any>;
126
+
127
+ interface PARConfig {
128
+ issuer: string;
129
+ clientId: string;
130
+ clientSecret?: string;
131
+ dpop?: OAuth42DPoP;
132
+ clientAssertionKey?: OAuth42ClientAssertion;
133
+ }
134
+ /** Transform only the authorization redirect produced by NextAuth after its
135
+ * state/nonce/PKCE cookies are set. All pushed parameters stay server-side. */
136
+ declare function pushAuthorizationURL(value: string, config: PARConfig): Promise<string>;
137
+ declare function withPushedAuthorization(handler: (...args: any[]) => any, config: PARConfig): (request: Request, context: unknown) => Promise<Response>;
123
138
 
124
- export { type CreateAuthOptions as C, type OAuth42Profile as O, OAuth42Provider as a, type OAuth42ProviderOptions as b, createAuth as c, getServerSession as d, withOAuth42Session as e, createHandlers as f, getOAuth42Session as g, refreshAccessToken as r, withOAuth42ServerSideProps as w };
139
+ export { type CreateAuthOptions as C, OAuth42Provider as O, type PARConfig as P, createHandlers as a, getServerSession as b, createAuth as c, withOAuth42Session as d, withPushedAuthorization as e, type OAuth42Profile as f, getOAuth42Session as g, type OAuth42ProviderOptions as h, pushAuthorizationURL as p, refreshAccessToken as r, withOAuth42ServerSideProps as w };
@@ -1,8 +1,8 @@
1
+ import { a as OAuth42ClientAssertion, O as OAuth42DPoP, S as SessionStoreMode } from './index-BuZTiUds.js';
1
2
  import { OAuthUserConfig, OAuthConfig } from 'next-auth/providers/oauth';
2
3
  import * as next_auth from 'next-auth';
3
4
  import { NextAuthOptions } from 'next-auth';
4
5
  import { GetServerSidePropsContext, NextApiRequest, NextApiResponse } from 'next';
5
- import { S as SessionStoreMode } from './index-Cfqxl9r2.js';
6
6
 
7
7
  interface OAuth42Profile {
8
8
  sub: string;
@@ -18,15 +18,17 @@ interface OAuth42Profile {
18
18
  }
19
19
  interface OAuth42ProviderOptions {
20
20
  clientId: string;
21
- clientSecret: string;
21
+ clientSecret?: string;
22
+ clientAssertionKey?: OAuth42ClientAssertion;
22
23
  issuer?: string;
23
24
  authorizationUrl?: string;
24
25
  tokenUrl?: string;
25
26
  userinfoUrl?: string;
26
27
  scopes?: string[];
27
28
  pkceEnabled?: boolean;
29
+ dpop?: OAuth42DPoP;
28
30
  }
29
- declare function OAuth42Provider<P extends OAuth42Profile>(options: OAuthUserConfig<P> & Partial<OAuth42ProviderOptions>): OAuthConfig<P>;
31
+ declare function OAuth42Provider<P extends OAuth42Profile>(options: Omit<OAuthUserConfig<P>, 'clientSecret'> & Partial<OAuth42ProviderOptions>): OAuthConfig<P>;
30
32
 
31
33
  /**
32
34
  * Get the OAuth42 session server-side
@@ -44,10 +46,8 @@ declare function OAuth42Provider<P extends OAuth42Profile>(options: OAuthUserCon
44
46
  * const session = await getOAuth42Session(req, res, authOptions);
45
47
  * ```
46
48
  *
47
- * **Token Refresh Support:**
48
- * When middleware refreshes an expired token, it passes the new token via
49
- * the `x-oauth42-refreshed-token` header. This function automatically detects
50
- * and uses that refreshed token, ensuring API routes always have a valid token.
49
+ * Middleware forwards refreshed encrypted session cookies to the current request.
50
+ * Caller-supplied access-token headers are never an authentication source.
51
51
  */
52
52
  declare function getOAuth42Session(...args: [GetServerSidePropsContext['req'], GetServerSidePropsContext['res'], NextAuthOptions] | [NextApiRequest, NextApiResponse, NextAuthOptions] | [NextAuthOptions]): Promise<next_auth.Session | null>;
53
53
  /**
@@ -65,6 +65,10 @@ interface CreateAuthOptions {
65
65
  issuer?: string;
66
66
  scopes?: string[];
67
67
  pkceEnabled?: boolean;
68
+ /** Require PAR through the returned App Router handlers; never falls back. */
69
+ pushedAuthorization?: boolean;
70
+ dpop?: OAuth42DPoP;
71
+ clientAssertionKey?: OAuth42ClientAssertion;
68
72
  debug?: boolean;
69
73
  callbacks?: NextAuthOptions['callbacks'];
70
74
  events?: NextAuthOptions['events'];
@@ -115,10 +119,21 @@ declare const getServerSession: typeof getOAuth42Session;
115
119
  * Token refresh helper with simple per-process locking
116
120
  *
117
121
  * The lock prevents multiple concurrent refresh calls from the same process,
118
- * reducing unnecessary token churn. The backend also has a 10-second grace
119
- * period for blacklisted tokens, so concurrent requests across processes
120
- * will still succeed.
122
+ * reducing unnecessary token churn. Coordinate refresh across backend instances;
123
+ * the server rejects reuse of an already rotated refresh token.
121
124
  */
122
- declare function refreshAccessToken(token: any, clientId: string, clientSecret: string, issuer?: string): Promise<any>;
125
+ declare function refreshAccessToken(token: any, clientId: string, clientSecret: string, issuer?: string, dpop?: OAuth42DPoP, clientAssertionKey?: OAuth42ClientAssertion): Promise<any>;
126
+
127
+ interface PARConfig {
128
+ issuer: string;
129
+ clientId: string;
130
+ clientSecret?: string;
131
+ dpop?: OAuth42DPoP;
132
+ clientAssertionKey?: OAuth42ClientAssertion;
133
+ }
134
+ /** Transform only the authorization redirect produced by NextAuth after its
135
+ * state/nonce/PKCE cookies are set. All pushed parameters stay server-side. */
136
+ declare function pushAuthorizationURL(value: string, config: PARConfig): Promise<string>;
137
+ declare function withPushedAuthorization(handler: (...args: any[]) => any, config: PARConfig): (request: Request, context: unknown) => Promise<Response>;
123
138
 
124
- export { type CreateAuthOptions as C, type OAuth42Profile as O, OAuth42Provider as a, type OAuth42ProviderOptions as b, createAuth as c, getServerSession as d, withOAuth42Session as e, createHandlers as f, getOAuth42Session as g, refreshAccessToken as r, withOAuth42ServerSideProps as w };
139
+ export { type CreateAuthOptions as C, OAuth42Provider as O, type PARConfig as P, createHandlers as a, getServerSession as b, createAuth as c, withOAuth42Session as d, withPushedAuthorization as e, type OAuth42Profile as f, getOAuth42Session as g, type OAuth42ProviderOptions as h, pushAuthorizationURL as p, refreshAccessToken as r, withOAuth42ServerSideProps as w };
@@ -1,15 +1,19 @@
1
- export { C as CreateAuthOptions, a as OAuth42Provider, c as createAuth, f as createHandlers, g as getOAuth42Session, d as getServerSession, r as refreshAccessToken, w as withOAuth42ServerSideProps, e as withOAuth42Session } from '../auth-D3tAruwx.mjs';
1
+ export { C as CreateAuthOptions, O as OAuth42Provider, P as PARConfig, c as createAuth, a as createHandlers, g as getOAuth42Session, b as getServerSession, p as pushAuthorizationURL, r as refreshAccessToken, w as withOAuth42ServerSideProps, d as withOAuth42Session, e as withPushedAuthorization } from '../par-Cyu6M1e6.mjs';
2
2
  export { default as NextAuth, NextAuthOptions } from 'next-auth';
3
- export { B as BackendSessionConfig, a as BackendSessionResponse, b as BackendSessionUser, O as OAuth42AuthOptions, S as SessionStoreMode, d as createBackendSession, c as createMiddlewareConfig, r as resolveBackendSession, e as revokeBackendSession, w as withOAuth42Auth } from '../index-Cfqxl9r2.mjs';
3
+ import { O as OAuth42DPoP, a as OAuth42ClientAssertion } from '../index-BuZTiUds.mjs';
4
+ export { B as BackendSessionConfig, b as BackendSessionResponse, c as BackendSessionUser, d as OAuth42AuthOptions, S as SessionStoreMode, e as createBackendSession, f as createMiddlewareConfig, r as resolveBackendSession, g as revokeBackendSession, w as withOAuth42Auth } from '../index-BuZTiUds.mjs';
4
5
  import { NextRequest, NextResponse } from 'next/server';
5
6
  import 'next-auth/providers/oauth';
6
7
  import 'next';
8
+ import 'node:crypto';
7
9
 
8
10
  interface HostedAuthCallbackOptions {
9
11
  /**
10
12
  * OAuth42 issuer URL (e.g., 'https://api.oauth42.com' or 'https://localhost:8443')
11
13
  */
12
14
  issuer?: string;
15
+ dpop?: OAuth42DPoP;
16
+ clientAssertionKey?: OAuth42ClientAssertion;
13
17
  /**
14
18
  * OAuth2 client ID
15
19
  */
@@ -55,4 +59,4 @@ interface HostedAuthCallbackOptions {
55
59
  */
56
60
  declare function createHostedAuthCallback(options?: HostedAuthCallbackOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
57
61
 
58
- export { type HostedAuthCallbackOptions, createHostedAuthCallback };
62
+ export { type HostedAuthCallbackOptions, OAuth42ClientAssertion, OAuth42DPoP, createHostedAuthCallback };
@@ -1,15 +1,19 @@
1
- export { C as CreateAuthOptions, a as OAuth42Provider, c as createAuth, f as createHandlers, g as getOAuth42Session, d as getServerSession, r as refreshAccessToken, w as withOAuth42ServerSideProps, e as withOAuth42Session } from '../auth-CYMPe3k0.js';
1
+ export { C as CreateAuthOptions, O as OAuth42Provider, P as PARConfig, c as createAuth, a as createHandlers, g as getOAuth42Session, b as getServerSession, p as pushAuthorizationURL, r as refreshAccessToken, w as withOAuth42ServerSideProps, d as withOAuth42Session, e as withPushedAuthorization } from '../par-DQNt8j-s.js';
2
2
  export { default as NextAuth, NextAuthOptions } from 'next-auth';
3
- export { B as BackendSessionConfig, a as BackendSessionResponse, b as BackendSessionUser, O as OAuth42AuthOptions, S as SessionStoreMode, d as createBackendSession, c as createMiddlewareConfig, r as resolveBackendSession, e as revokeBackendSession, w as withOAuth42Auth } from '../index-Cfqxl9r2.js';
3
+ import { O as OAuth42DPoP, a as OAuth42ClientAssertion } from '../index-BuZTiUds.js';
4
+ export { B as BackendSessionConfig, b as BackendSessionResponse, c as BackendSessionUser, d as OAuth42AuthOptions, S as SessionStoreMode, e as createBackendSession, f as createMiddlewareConfig, r as resolveBackendSession, g as revokeBackendSession, w as withOAuth42Auth } from '../index-BuZTiUds.js';
4
5
  import { NextRequest, NextResponse } from 'next/server';
5
6
  import 'next-auth/providers/oauth';
6
7
  import 'next';
8
+ import 'node:crypto';
7
9
 
8
10
  interface HostedAuthCallbackOptions {
9
11
  /**
10
12
  * OAuth42 issuer URL (e.g., 'https://api.oauth42.com' or 'https://localhost:8443')
11
13
  */
12
14
  issuer?: string;
15
+ dpop?: OAuth42DPoP;
16
+ clientAssertionKey?: OAuth42ClientAssertion;
13
17
  /**
14
18
  * OAuth2 client ID
15
19
  */
@@ -55,4 +59,4 @@ interface HostedAuthCallbackOptions {
55
59
  */
56
60
  declare function createHostedAuthCallback(options?: HostedAuthCallbackOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
57
61
 
58
- export { type HostedAuthCallbackOptions, createHostedAuthCallback };
62
+ export { type HostedAuthCallbackOptions, OAuth42ClientAssertion, OAuth42DPoP, createHostedAuthCallback };