@auditauth/next 0.2.0-beta.6 → 0.2.0-beta.8
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/facade/createAuditAuth.d.cts +5 -5
- package/dist/facade/createAuditAuth.d.ts +5 -5
- package/dist/sdk.cjs +3 -3
- package/dist/sdk.d.cts +6 -5
- package/dist/sdk.d.ts +6 -5
- package/dist/sdk.js +3 -3
- package/dist/settings.d.cts +0 -3
- package/dist/settings.d.ts +0 -3
- package/package.json +3 -3
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NextResponse } from 'next/server.js';
|
|
2
2
|
import { SessionUser, AuditAuthConfig } from '@auditauth/core';
|
|
3
3
|
import { AuditAuthTokenPayload } from '@auditauth/node';
|
|
4
4
|
|
|
5
5
|
type AuditAuthNextFacade = {
|
|
6
6
|
handlers: {
|
|
7
|
-
GET: (req:
|
|
7
|
+
GET: (req: Request, ctx: {
|
|
8
8
|
params: Promise<{
|
|
9
9
|
auditauth: string[];
|
|
10
10
|
}>;
|
|
11
11
|
}) => Promise<Response>;
|
|
12
|
-
POST: (req:
|
|
12
|
+
POST: (req: Request, ctx: {
|
|
13
13
|
params: Promise<{
|
|
14
14
|
auditauth: string[];
|
|
15
15
|
}>;
|
|
16
16
|
}) => Promise<Response>;
|
|
17
17
|
};
|
|
18
|
-
middleware: (req:
|
|
18
|
+
middleware: (req: Request) => Promise<NextResponse>;
|
|
19
19
|
getSession: () => Promise<SessionUser | null>;
|
|
20
20
|
hasSession: () => Promise<boolean>;
|
|
21
21
|
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
22
22
|
getLoginUrl: () => URL;
|
|
23
23
|
getLogoutUrl: () => URL;
|
|
24
24
|
getPortalUrl: () => URL;
|
|
25
|
-
withAuthRequest: <C>(handler: (req:
|
|
25
|
+
withAuthRequest: <C, R extends Request = Request>(handler: (req: R, ctx: C, session: AuditAuthTokenPayload) => Promise<Response>) => (req: R, ctx: C) => Promise<Response>;
|
|
26
26
|
};
|
|
27
27
|
declare function createAuditAuthNext(config: AuditAuthConfig): AuditAuthNextFacade;
|
|
28
28
|
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NextResponse } from 'next/server.js';
|
|
2
2
|
import { SessionUser, AuditAuthConfig } from '@auditauth/core';
|
|
3
3
|
import { AuditAuthTokenPayload } from '@auditauth/node';
|
|
4
4
|
|
|
5
5
|
type AuditAuthNextFacade = {
|
|
6
6
|
handlers: {
|
|
7
|
-
GET: (req:
|
|
7
|
+
GET: (req: Request, ctx: {
|
|
8
8
|
params: Promise<{
|
|
9
9
|
auditauth: string[];
|
|
10
10
|
}>;
|
|
11
11
|
}) => Promise<Response>;
|
|
12
|
-
POST: (req:
|
|
12
|
+
POST: (req: Request, ctx: {
|
|
13
13
|
params: Promise<{
|
|
14
14
|
auditauth: string[];
|
|
15
15
|
}>;
|
|
16
16
|
}) => Promise<Response>;
|
|
17
17
|
};
|
|
18
|
-
middleware: (req:
|
|
18
|
+
middleware: (req: Request) => Promise<NextResponse>;
|
|
19
19
|
getSession: () => Promise<SessionUser | null>;
|
|
20
20
|
hasSession: () => Promise<boolean>;
|
|
21
21
|
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
22
22
|
getLoginUrl: () => URL;
|
|
23
23
|
getLogoutUrl: () => URL;
|
|
24
24
|
getPortalUrl: () => URL;
|
|
25
|
-
withAuthRequest: <C>(handler: (req:
|
|
25
|
+
withAuthRequest: <C, R extends Request = Request>(handler: (req: R, ctx: C, session: AuditAuthTokenPayload) => Promise<Response>) => (req: R, ctx: C) => Promise<Response>;
|
|
26
26
|
};
|
|
27
27
|
declare function createAuditAuthNext(config: AuditAuthConfig): AuditAuthNextFacade;
|
|
28
28
|
|
package/dist/sdk.cjs
CHANGED
|
@@ -257,7 +257,7 @@ class AuditAuthNext {
|
|
|
257
257
|
}
|
|
258
258
|
async middleware(request) {
|
|
259
259
|
const { access, refresh } = this.getCookieTokens();
|
|
260
|
-
const url = request.
|
|
260
|
+
const url = new URL(request.url);
|
|
261
261
|
if (access && refresh) {
|
|
262
262
|
const sid = this.cookies.get(import_settings.SETTINGS.storage_keys.session_id);
|
|
263
263
|
if (!sid) {
|
|
@@ -294,7 +294,7 @@ class AuditAuthNext {
|
|
|
294
294
|
return {
|
|
295
295
|
GET: async (req, ctx) => {
|
|
296
296
|
const action = (await ctx.params).auditauth[0];
|
|
297
|
-
const redirectUrl = req.
|
|
297
|
+
const redirectUrl = new URL(req.url).searchParams.get("redirectUrl");
|
|
298
298
|
switch (action) {
|
|
299
299
|
case "login":
|
|
300
300
|
{
|
|
@@ -398,7 +398,7 @@ class AuditAuthNext {
|
|
|
398
398
|
;
|
|
399
399
|
case "refresh":
|
|
400
400
|
{
|
|
401
|
-
const redirectUrl = req.
|
|
401
|
+
const redirectUrl = new URL(req.url).searchParams.get("redirectUrl");
|
|
402
402
|
const { ok } = await this.refresh();
|
|
403
403
|
if (ok) return import_server.NextResponse.redirect(redirectUrl || this.config.redirectUrl);
|
|
404
404
|
return new Response("Session expired", { status: 401 });
|
package/dist/sdk.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NextResponse } from 'next/server.js';
|
|
2
2
|
import { CookieAdapter } from './types.cjs';
|
|
3
3
|
import { AuditAuthConfig, SessionUser } from '@auditauth/core';
|
|
4
4
|
import { AuditAuthTokenPayload } from '@auditauth/node';
|
|
5
5
|
|
|
6
|
+
type RouteRequest = Request;
|
|
6
7
|
declare class AuditAuthNext {
|
|
7
8
|
private config;
|
|
8
9
|
private cookies;
|
|
@@ -22,17 +23,17 @@ declare class AuditAuthNext {
|
|
|
22
23
|
getPortalUrl(): URL;
|
|
23
24
|
private callback;
|
|
24
25
|
private logout;
|
|
25
|
-
withAuthRequest<C>(handler: (req:
|
|
26
|
+
withAuthRequest<C, R extends Request = Request>(handler: (req: R, ctx: C, session: AuditAuthTokenPayload) => Promise<Response>): (req: R, ctx: C) => Promise<Response>;
|
|
26
27
|
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
27
28
|
private refresh;
|
|
28
|
-
middleware(request:
|
|
29
|
+
middleware(request: RouteRequest): Promise<NextResponse<unknown>>;
|
|
29
30
|
getHandlers(): {
|
|
30
|
-
GET: (req:
|
|
31
|
+
GET: (req: RouteRequest, ctx: {
|
|
31
32
|
params: Promise<{
|
|
32
33
|
auditauth: string[];
|
|
33
34
|
}>;
|
|
34
35
|
}) => Promise<Response>;
|
|
35
|
-
POST: (req:
|
|
36
|
+
POST: (req: RouteRequest, ctx: {
|
|
36
37
|
params: Promise<{
|
|
37
38
|
auditauth: string[];
|
|
38
39
|
}>;
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NextResponse } from 'next/server.js';
|
|
2
2
|
import { CookieAdapter } from './types.js';
|
|
3
3
|
import { AuditAuthConfig, SessionUser } from '@auditauth/core';
|
|
4
4
|
import { AuditAuthTokenPayload } from '@auditauth/node';
|
|
5
5
|
|
|
6
|
+
type RouteRequest = Request;
|
|
6
7
|
declare class AuditAuthNext {
|
|
7
8
|
private config;
|
|
8
9
|
private cookies;
|
|
@@ -22,17 +23,17 @@ declare class AuditAuthNext {
|
|
|
22
23
|
getPortalUrl(): URL;
|
|
23
24
|
private callback;
|
|
24
25
|
private logout;
|
|
25
|
-
withAuthRequest<C>(handler: (req:
|
|
26
|
+
withAuthRequest<C, R extends Request = Request>(handler: (req: R, ctx: C, session: AuditAuthTokenPayload) => Promise<Response>): (req: R, ctx: C) => Promise<Response>;
|
|
26
27
|
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
27
28
|
private refresh;
|
|
28
|
-
middleware(request:
|
|
29
|
+
middleware(request: RouteRequest): Promise<NextResponse<unknown>>;
|
|
29
30
|
getHandlers(): {
|
|
30
|
-
GET: (req:
|
|
31
|
+
GET: (req: RouteRequest, ctx: {
|
|
31
32
|
params: Promise<{
|
|
32
33
|
auditauth: string[];
|
|
33
34
|
}>;
|
|
34
35
|
}) => Promise<Response>;
|
|
35
|
-
POST: (req:
|
|
36
|
+
POST: (req: RouteRequest, ctx: {
|
|
36
37
|
params: Promise<{
|
|
37
38
|
auditauth: string[];
|
|
38
39
|
}>;
|
package/dist/sdk.js
CHANGED
|
@@ -242,7 +242,7 @@ class AuditAuthNext {
|
|
|
242
242
|
}
|
|
243
243
|
async middleware(request) {
|
|
244
244
|
const { access, refresh } = this.getCookieTokens();
|
|
245
|
-
const url = request.
|
|
245
|
+
const url = new URL(request.url);
|
|
246
246
|
if (access && refresh) {
|
|
247
247
|
const sid = this.cookies.get(SETTINGS.storage_keys.session_id);
|
|
248
248
|
if (!sid) {
|
|
@@ -279,7 +279,7 @@ class AuditAuthNext {
|
|
|
279
279
|
return {
|
|
280
280
|
GET: async (req, ctx) => {
|
|
281
281
|
const action = (await ctx.params).auditauth[0];
|
|
282
|
-
const redirectUrl = req.
|
|
282
|
+
const redirectUrl = new URL(req.url).searchParams.get("redirectUrl");
|
|
283
283
|
switch (action) {
|
|
284
284
|
case "login":
|
|
285
285
|
{
|
|
@@ -383,7 +383,7 @@ class AuditAuthNext {
|
|
|
383
383
|
;
|
|
384
384
|
case "refresh":
|
|
385
385
|
{
|
|
386
|
-
const redirectUrl = req.
|
|
386
|
+
const redirectUrl = new URL(req.url).searchParams.get("redirectUrl");
|
|
387
387
|
const { ok } = await this.refresh();
|
|
388
388
|
if (ok) return NextResponse.redirect(redirectUrl || this.config.redirectUrl);
|
|
389
389
|
return new Response("Session expired", { status: 401 });
|
package/dist/settings.d.cts
CHANGED
|
@@ -16,9 +16,6 @@ declare const SETTINGS: {
|
|
|
16
16
|
readonly domains: {
|
|
17
17
|
readonly api: "https://api.auditauth.com/v1";
|
|
18
18
|
readonly client: "https://auditauth.com";
|
|
19
|
-
} | {
|
|
20
|
-
readonly api: "http://localhost:4000/v1";
|
|
21
|
-
readonly client: "https://localhost:3000";
|
|
22
19
|
};
|
|
23
20
|
readonly storage_keys: {
|
|
24
21
|
readonly access: "auditauth_access";
|
package/dist/settings.d.ts
CHANGED
|
@@ -16,9 +16,6 @@ declare const SETTINGS: {
|
|
|
16
16
|
readonly domains: {
|
|
17
17
|
readonly api: "https://api.auditauth.com/v1";
|
|
18
18
|
readonly client: "https://auditauth.com";
|
|
19
|
-
} | {
|
|
20
|
-
readonly api: "http://localhost:4000/v1";
|
|
21
|
-
readonly client: "https://localhost:3000";
|
|
22
19
|
};
|
|
23
20
|
readonly storage_keys: {
|
|
24
21
|
readonly access: "auditauth_access";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auditauth/next",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.8",
|
|
4
4
|
"description": "AuditAuth NextJS SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nimibyte",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"react-dom": ">=18"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@auditauth/core": "^0.2.0-beta.
|
|
57
|
-
"@auditauth/node": "^0.2.0-beta.
|
|
56
|
+
"@auditauth/core": "^0.2.0-beta.8",
|
|
57
|
+
"@auditauth/node": "^0.2.0-beta.8"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"typescript": "^5.9.0",
|