@oauth42/next 0.4.8 → 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,3 +1,4 @@
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';
@@ -17,15 +18,17 @@ interface OAuth42Profile {
17
18
  }
18
19
  interface OAuth42ProviderOptions {
19
20
  clientId: string;
20
- clientSecret: string;
21
+ clientSecret?: string;
22
+ clientAssertionKey?: OAuth42ClientAssertion;
21
23
  issuer?: string;
22
24
  authorizationUrl?: string;
23
25
  tokenUrl?: string;
24
26
  userinfoUrl?: string;
25
27
  scopes?: string[];
26
28
  pkceEnabled?: boolean;
29
+ dpop?: OAuth42DPoP;
27
30
  }
28
- 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>;
29
32
 
30
33
  /**
31
34
  * Get the OAuth42 session server-side
@@ -43,10 +46,8 @@ declare function OAuth42Provider<P extends OAuth42Profile>(options: OAuthUserCon
43
46
  * const session = await getOAuth42Session(req, res, authOptions);
44
47
  * ```
45
48
  *
46
- * **Token Refresh Support:**
47
- * When middleware refreshes an expired token, it passes the new token via
48
- * the `x-oauth42-refreshed-token` header. This function automatically detects
49
- * 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.
50
51
  */
51
52
  declare function getOAuth42Session(...args: [GetServerSidePropsContext['req'], GetServerSidePropsContext['res'], NextAuthOptions] | [NextApiRequest, NextApiResponse, NextAuthOptions] | [NextAuthOptions]): Promise<next_auth.Session | null>;
52
53
  /**
@@ -64,10 +65,23 @@ interface CreateAuthOptions {
64
65
  issuer?: string;
65
66
  scopes?: string[];
66
67
  pkceEnabled?: boolean;
68
+ /** Require PAR through the returned App Router handlers; never falls back. */
69
+ pushedAuthorization?: boolean;
70
+ dpop?: OAuth42DPoP;
71
+ clientAssertionKey?: OAuth42ClientAssertion;
67
72
  debug?: boolean;
68
73
  callbacks?: NextAuthOptions['callbacks'];
74
+ events?: NextAuthOptions['events'];
69
75
  pages?: NextAuthOptions['pages'];
70
76
  session?: NextAuthOptions['session'];
77
+ /**
78
+ * Session storage mode.
79
+ *
80
+ * - "jwt" keeps OAuth token material in the encrypted NextAuth JWT cookie.
81
+ * - "backend" stores token material behind a Rust-backend-owned opaque
82
+ * session id. Next.js never talks to Redis directly.
83
+ */
84
+ sessionStore?: SessionStoreMode;
71
85
  /**
72
86
  * Unique prefix for cookie names to allow multiple apps on the same domain.
73
87
  * Each app should use a different prefix (e.g., 'portal', 'admin', 'bond').
@@ -105,10 +119,21 @@ declare const getServerSession: typeof getOAuth42Session;
105
119
  * Token refresh helper with simple per-process locking
106
120
  *
107
121
  * The lock prevents multiple concurrent refresh calls from the same process,
108
- * reducing unnecessary token churn. The backend also has a 10-second grace
109
- * period for blacklisted tokens, so concurrent requests across processes
110
- * will still succeed.
122
+ * reducing unnecessary token churn. Coordinate refresh across backend instances;
123
+ * the server rejects reuse of an already rotated refresh token.
111
124
  */
112
- 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>;
113
138
 
114
- 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,3 +1,4 @@
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';
@@ -17,15 +18,17 @@ interface OAuth42Profile {
17
18
  }
18
19
  interface OAuth42ProviderOptions {
19
20
  clientId: string;
20
- clientSecret: string;
21
+ clientSecret?: string;
22
+ clientAssertionKey?: OAuth42ClientAssertion;
21
23
  issuer?: string;
22
24
  authorizationUrl?: string;
23
25
  tokenUrl?: string;
24
26
  userinfoUrl?: string;
25
27
  scopes?: string[];
26
28
  pkceEnabled?: boolean;
29
+ dpop?: OAuth42DPoP;
27
30
  }
28
- 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>;
29
32
 
30
33
  /**
31
34
  * Get the OAuth42 session server-side
@@ -43,10 +46,8 @@ declare function OAuth42Provider<P extends OAuth42Profile>(options: OAuthUserCon
43
46
  * const session = await getOAuth42Session(req, res, authOptions);
44
47
  * ```
45
48
  *
46
- * **Token Refresh Support:**
47
- * When middleware refreshes an expired token, it passes the new token via
48
- * the `x-oauth42-refreshed-token` header. This function automatically detects
49
- * 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.
50
51
  */
51
52
  declare function getOAuth42Session(...args: [GetServerSidePropsContext['req'], GetServerSidePropsContext['res'], NextAuthOptions] | [NextApiRequest, NextApiResponse, NextAuthOptions] | [NextAuthOptions]): Promise<next_auth.Session | null>;
52
53
  /**
@@ -64,10 +65,23 @@ interface CreateAuthOptions {
64
65
  issuer?: string;
65
66
  scopes?: string[];
66
67
  pkceEnabled?: boolean;
68
+ /** Require PAR through the returned App Router handlers; never falls back. */
69
+ pushedAuthorization?: boolean;
70
+ dpop?: OAuth42DPoP;
71
+ clientAssertionKey?: OAuth42ClientAssertion;
67
72
  debug?: boolean;
68
73
  callbacks?: NextAuthOptions['callbacks'];
74
+ events?: NextAuthOptions['events'];
69
75
  pages?: NextAuthOptions['pages'];
70
76
  session?: NextAuthOptions['session'];
77
+ /**
78
+ * Session storage mode.
79
+ *
80
+ * - "jwt" keeps OAuth token material in the encrypted NextAuth JWT cookie.
81
+ * - "backend" stores token material behind a Rust-backend-owned opaque
82
+ * session id. Next.js never talks to Redis directly.
83
+ */
84
+ sessionStore?: SessionStoreMode;
71
85
  /**
72
86
  * Unique prefix for cookie names to allow multiple apps on the same domain.
73
87
  * Each app should use a different prefix (e.g., 'portal', 'admin', 'bond').
@@ -105,10 +119,21 @@ declare const getServerSession: typeof getOAuth42Session;
105
119
  * Token refresh helper with simple per-process locking
106
120
  *
107
121
  * The lock prevents multiple concurrent refresh calls from the same process,
108
- * reducing unnecessary token churn. The backend also has a 10-second grace
109
- * period for blacklisted tokens, so concurrent requests across processes
110
- * will still succeed.
122
+ * reducing unnecessary token churn. Coordinate refresh across backend instances;
123
+ * the server rejects reuse of an already rotated refresh token.
111
124
  */
112
- 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>;
113
138
 
114
- 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-BThRQMzh.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 { OAuth42AuthOptions, createMiddlewareConfig, withOAuth42Auth } from '../middleware/index.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-BThRQMzh.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 { OAuth42AuthOptions, createMiddlewareConfig, withOAuth42Auth } from '../middleware/index.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 };