@auditauth/next 0.1.7 → 0.1.9
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/request.d.ts +2 -0
- package/dist/request.js +53 -0
- package/dist/sdk.d.ts +8 -5
- package/dist/sdk.js +150 -64
- package/dist/settings.d.ts +3 -30
- package/dist/settings.js +5 -30
- package/dist/types.d.ts +7 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/request.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { cookies } from "next/headers";
|
|
3
|
+
import { SETTINGS } from "./settings";
|
|
4
|
+
const auditauthFetch = async (url, init = {}) => {
|
|
5
|
+
const cookieManager = await cookies();
|
|
6
|
+
const access_token = cookieManager.get(SETTINGS.cookies.access.name);
|
|
7
|
+
const refresh_token = cookieManager.get(SETTINGS.cookies.refresh.name);
|
|
8
|
+
const doFetch = (token) => fetch(url, {
|
|
9
|
+
...init,
|
|
10
|
+
headers: {
|
|
11
|
+
...init.headers,
|
|
12
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
const start = performance.now();
|
|
16
|
+
let response = await doFetch(access_token?.value);
|
|
17
|
+
if (response.status === 401 && refresh_token) {
|
|
18
|
+
const refreshResponse = await fetch(`${SETTINGS.domains.api}/auth/refresh`, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: { 'Content-Type': 'application/json' },
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
refresh_token,
|
|
23
|
+
client_type: 'server',
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
if (!refreshResponse.ok)
|
|
27
|
+
return response;
|
|
28
|
+
const data = await refreshResponse.json();
|
|
29
|
+
if (data?.access_token && data?.refresh_token) {
|
|
30
|
+
response = await doFetch(data.access_token);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
queueMicrotask(() => {
|
|
34
|
+
const payload = {
|
|
35
|
+
event_type: 'request',
|
|
36
|
+
runtime: 'server',
|
|
37
|
+
target: {
|
|
38
|
+
type: 'api',
|
|
39
|
+
method: init.method || 'GET',
|
|
40
|
+
path: url,
|
|
41
|
+
status: response.status,
|
|
42
|
+
duration_ms: Math.round(performance.now() - start),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
fetch(`${SETTINGS.bff.paths.metrics}`, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: { 'Content-Type': 'application/json' },
|
|
48
|
+
body: JSON.stringify({ ...payload }),
|
|
49
|
+
}).catch(() => { });
|
|
50
|
+
});
|
|
51
|
+
return response;
|
|
52
|
+
};
|
|
53
|
+
export { auditauthFetch };
|
package/dist/sdk.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare class AuditAuthNext {
|
|
|
4
4
|
private config;
|
|
5
5
|
private cookies;
|
|
6
6
|
constructor(config: AuditAuthConfig, cookies: CookieAdapter);
|
|
7
|
-
|
|
7
|
+
verifyAccessToken(token: string): Promise<boolean>;
|
|
8
8
|
private getCookieTokens;
|
|
9
9
|
private setCookieTokens;
|
|
10
10
|
getSession(): SessionUser | null;
|
|
@@ -24,10 +24,14 @@ declare class AuditAuthNext {
|
|
|
24
24
|
url: string;
|
|
25
25
|
reason: null;
|
|
26
26
|
}>;
|
|
27
|
-
private
|
|
28
|
-
request(
|
|
27
|
+
private refreshRequest;
|
|
28
|
+
request(url: string, init?: RequestInit): Promise<Response>;
|
|
29
|
+
metrics(payload: Metric): Promise<Response>;
|
|
29
30
|
private pushMetric;
|
|
30
|
-
|
|
31
|
+
refresh(): Promise<{
|
|
32
|
+
ok: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
middleware(request: NextRequest): Promise<NextResponse<unknown>>;
|
|
31
35
|
getHandlers(): {
|
|
32
36
|
GET: (req: NextRequest, ctx: {
|
|
33
37
|
params: Promise<{
|
|
@@ -40,6 +44,5 @@ declare class AuditAuthNext {
|
|
|
40
44
|
}>;
|
|
41
45
|
}) => Promise<Response>;
|
|
42
46
|
};
|
|
43
|
-
metrics(payload: Metric): Promise<Response>;
|
|
44
47
|
}
|
|
45
48
|
export { AuditAuthNext };
|
package/dist/sdk.js
CHANGED
|
@@ -11,14 +11,22 @@ let cachedKey = null;
|
|
|
11
11
|
/* -------------------------------------------------------------------------- */
|
|
12
12
|
class AuditAuthNext {
|
|
13
13
|
constructor(config, cookies) {
|
|
14
|
-
if (!
|
|
15
|
-
throw new Error('Missing
|
|
14
|
+
if (!config.appId)
|
|
15
|
+
throw new Error('Missing appId');
|
|
16
|
+
if (!config.apiKey)
|
|
17
|
+
throw new Error('Missing apiKey');
|
|
18
|
+
if (!config.baseUrl)
|
|
19
|
+
throw new Error('Missing baseUrl');
|
|
20
|
+
if (!config.redirectUrl)
|
|
21
|
+
throw new Error('Missing redirectUrl');
|
|
22
|
+
if (!cookies?.get || !cookies?.set || !cookies?.remove) {
|
|
23
|
+
throw new Error('Invalid cookie adapter');
|
|
16
24
|
}
|
|
17
25
|
this.config = config;
|
|
18
26
|
this.cookies = cookies;
|
|
19
27
|
}
|
|
20
28
|
/* ------------------------------------------------------------------------ */
|
|
21
|
-
/* AUTH PRIMITIVES
|
|
29
|
+
/* AUTH PRIMITIVES */
|
|
22
30
|
/* ------------------------------------------------------------------------ */
|
|
23
31
|
async verifyAccessToken(token) {
|
|
24
32
|
try {
|
|
@@ -41,12 +49,25 @@ class AuditAuthNext {
|
|
|
41
49
|
refresh: this.cookies.get(SETTINGS.cookies.refresh.name),
|
|
42
50
|
};
|
|
43
51
|
}
|
|
44
|
-
setCookieTokens(
|
|
45
|
-
|
|
46
|
-
this.cookies.set(SETTINGS.cookies.
|
|
52
|
+
setCookieTokens(params) {
|
|
53
|
+
const isSecure = this.config.redirectUrl.includes('https');
|
|
54
|
+
this.cookies.set(SETTINGS.cookies.access.name, params.access_token, {
|
|
55
|
+
httpOnly: true,
|
|
56
|
+
sameSite: 'lax',
|
|
57
|
+
secure: isSecure,
|
|
58
|
+
path: '/',
|
|
59
|
+
maxAge: params.access_expires_seconds - 60,
|
|
60
|
+
});
|
|
61
|
+
this.cookies.set(SETTINGS.cookies.refresh.name, params.refresh_token, {
|
|
62
|
+
httpOnly: true,
|
|
63
|
+
sameSite: 'lax',
|
|
64
|
+
secure: isSecure,
|
|
65
|
+
path: '/',
|
|
66
|
+
maxAge: params.refresh_expires_seconds - 60,
|
|
67
|
+
});
|
|
47
68
|
}
|
|
48
69
|
/* ------------------------------------------------------------------------ */
|
|
49
|
-
/* SESSION HELPERS
|
|
70
|
+
/* SESSION HELPERS */
|
|
50
71
|
/* ------------------------------------------------------------------------ */
|
|
51
72
|
getSession() {
|
|
52
73
|
return JSON.parse(this.cookies.get(SETTINGS.cookies.session.name) || '{}')?.user || null;
|
|
@@ -55,7 +76,7 @@ class AuditAuthNext {
|
|
|
55
76
|
return !!this.cookies.get(SETTINGS.cookies.session.name);
|
|
56
77
|
}
|
|
57
78
|
/* ------------------------------------------------------------------------ */
|
|
58
|
-
/* AUTH FLOWS
|
|
79
|
+
/* AUTH FLOWS */
|
|
59
80
|
/* ------------------------------------------------------------------------ */
|
|
60
81
|
async buildAuthUrl() {
|
|
61
82
|
const response = await fetch(`${SETTINGS.domains.api}/apps/login`, {
|
|
@@ -98,10 +119,19 @@ class AuditAuthNext {
|
|
|
98
119
|
name: result.user.name,
|
|
99
120
|
},
|
|
100
121
|
};
|
|
101
|
-
this.
|
|
122
|
+
const isSecure = this.config.redirectUrl.includes('http');
|
|
123
|
+
this.cookies.set(SETTINGS.cookies.session.name, JSON.stringify(session), {
|
|
124
|
+
httpOnly: true,
|
|
125
|
+
sameSite: 'lax',
|
|
126
|
+
secure: isSecure,
|
|
127
|
+
path: '/',
|
|
128
|
+
maxAge: result.refresh_expires_seconds - 60,
|
|
129
|
+
});
|
|
102
130
|
this.setCookieTokens({
|
|
103
|
-
|
|
104
|
-
|
|
131
|
+
access_token: result.access_token,
|
|
132
|
+
access_expires_seconds: result.access_expires_seconds,
|
|
133
|
+
refresh_token: result.refresh_token,
|
|
134
|
+
refresh_expires_seconds: result.refresh_expires_seconds,
|
|
105
135
|
});
|
|
106
136
|
return { ok: true, url: this.config.redirectUrl };
|
|
107
137
|
}
|
|
@@ -109,7 +139,7 @@ class AuditAuthNext {
|
|
|
109
139
|
const { access } = this.getCookieTokens();
|
|
110
140
|
if (access) {
|
|
111
141
|
await fetch(`${SETTINGS.domains.api}/auth/revoke`, {
|
|
112
|
-
method: '
|
|
142
|
+
method: 'PATCH',
|
|
113
143
|
headers: { Authorization: `Bearer ${access}` },
|
|
114
144
|
}).catch(() => { });
|
|
115
145
|
}
|
|
@@ -132,12 +162,16 @@ class AuditAuthNext {
|
|
|
132
162
|
return { ok: false, url: null, reason: 'fail' };
|
|
133
163
|
}
|
|
134
164
|
const body = await res.json();
|
|
135
|
-
return {
|
|
165
|
+
return {
|
|
166
|
+
ok: true,
|
|
167
|
+
url: `${body.redirectUrl}?code=${body.code}&redirectUrl=${this.config.redirectUrl}`,
|
|
168
|
+
reason: null,
|
|
169
|
+
};
|
|
136
170
|
}
|
|
137
171
|
/* ------------------------------------------------------------------------ */
|
|
138
172
|
/* REFRESH FLOW */
|
|
139
173
|
/* ------------------------------------------------------------------------ */
|
|
140
|
-
async
|
|
174
|
+
async refreshRequest(refreshToken) {
|
|
141
175
|
try {
|
|
142
176
|
const response = await fetch(`${SETTINGS.domains.api}/auth/refresh`, {
|
|
143
177
|
method: 'POST',
|
|
@@ -158,9 +192,9 @@ class AuditAuthNext {
|
|
|
158
192
|
/* ------------------------------------------------------------------------ */
|
|
159
193
|
/* REQUEST WITH AUTO-REFRESH */
|
|
160
194
|
/* ------------------------------------------------------------------------ */
|
|
161
|
-
async request(
|
|
195
|
+
async request(url, init = {}) {
|
|
162
196
|
const { access, refresh } = this.getCookieTokens();
|
|
163
|
-
const doFetch = (token) => fetch(
|
|
197
|
+
const doFetch = (token) => fetch(url, {
|
|
164
198
|
...init,
|
|
165
199
|
headers: {
|
|
166
200
|
...init.headers,
|
|
@@ -169,9 +203,8 @@ class AuditAuthNext {
|
|
|
169
203
|
});
|
|
170
204
|
const start = performance.now();
|
|
171
205
|
let res = await doFetch(access);
|
|
172
|
-
// Attempt refresh once on 401
|
|
173
206
|
if (res.status === 401 && refresh) {
|
|
174
|
-
const data = await this.
|
|
207
|
+
const data = await this.refreshRequest(refresh);
|
|
175
208
|
if (data?.access_token && data?.refresh_token) {
|
|
176
209
|
res = await doFetch(data.access_token);
|
|
177
210
|
}
|
|
@@ -182,7 +215,7 @@ class AuditAuthNext {
|
|
|
182
215
|
target: {
|
|
183
216
|
type: 'api',
|
|
184
217
|
method: init.method || 'GET',
|
|
185
|
-
path,
|
|
218
|
+
path: url,
|
|
186
219
|
status: res.status,
|
|
187
220
|
duration_ms: Math.round(performance.now() - start),
|
|
188
221
|
},
|
|
@@ -192,66 +225,131 @@ class AuditAuthNext {
|
|
|
192
225
|
/* ------------------------------------------------------------------------ */
|
|
193
226
|
/* METRICS */
|
|
194
227
|
/* ------------------------------------------------------------------------ */
|
|
228
|
+
async metrics(payload) {
|
|
229
|
+
await fetch(`${SETTINGS.domains.api}/metrics`, {
|
|
230
|
+
method: 'POST',
|
|
231
|
+
headers: {
|
|
232
|
+
'Content-Type': 'application/json',
|
|
233
|
+
'x-auditauth-app': this.config.appId,
|
|
234
|
+
'x-auditauth-key': this.config.apiKey,
|
|
235
|
+
},
|
|
236
|
+
body: JSON.stringify({ ...payload }),
|
|
237
|
+
});
|
|
238
|
+
return new Response(null, { status: 204 });
|
|
239
|
+
}
|
|
195
240
|
pushMetric(payload) {
|
|
196
|
-
|
|
241
|
+
const session_id = this.cookies.get(SETTINGS.cookies.session_id.name);
|
|
197
242
|
queueMicrotask(() => {
|
|
198
243
|
fetch(`${this.config.baseUrl}${SETTINGS.bff.paths.metrics}`, {
|
|
199
244
|
method: 'POST',
|
|
200
245
|
headers: { 'Content-Type': 'application/json' },
|
|
201
|
-
body: JSON.stringify({ ...payload, session_id
|
|
246
|
+
body: JSON.stringify({ ...payload, session_id }),
|
|
202
247
|
}).catch(() => { });
|
|
203
248
|
});
|
|
204
249
|
}
|
|
205
250
|
/* ------------------------------------------------------------------------ */
|
|
251
|
+
/* METRICS */
|
|
252
|
+
/* ------------------------------------------------------------------------ */
|
|
253
|
+
async refresh() {
|
|
254
|
+
const { refresh } = this.getCookieTokens();
|
|
255
|
+
if (!refresh)
|
|
256
|
+
return { ok: false };
|
|
257
|
+
const result = await this.refreshRequest(refresh);
|
|
258
|
+
if (!result)
|
|
259
|
+
return { ok: false };
|
|
260
|
+
this.setCookieTokens(result);
|
|
261
|
+
return { ok: true };
|
|
262
|
+
}
|
|
263
|
+
/* ------------------------------------------------------------------------ */
|
|
206
264
|
/* MIDDLEWARE */
|
|
207
265
|
/* ------------------------------------------------------------------------ */
|
|
208
|
-
async middleware(
|
|
266
|
+
async middleware(request) {
|
|
209
267
|
const { access, refresh } = this.getCookieTokens();
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
268
|
+
const url = request.nextUrl;
|
|
269
|
+
if (access && refresh) {
|
|
270
|
+
const sid = this.cookies.get(SETTINGS.cookies.session_id.name);
|
|
271
|
+
if (!sid) {
|
|
272
|
+
this.cookies.set(SETTINGS.cookies.session_id.name, crypto.randomUUID(), {
|
|
273
|
+
httpOnly: true,
|
|
274
|
+
sameSite: 'lax',
|
|
275
|
+
secure: this.config.baseUrl.startsWith('https'),
|
|
276
|
+
path: '/',
|
|
277
|
+
maxAge: 60 * 30,
|
|
219
278
|
});
|
|
220
279
|
}
|
|
280
|
+
this.pushMetric({
|
|
281
|
+
event_type: 'navigation',
|
|
282
|
+
runtime: 'browser',
|
|
283
|
+
target: {
|
|
284
|
+
type: 'page',
|
|
285
|
+
path: url.pathname,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
return NextResponse.next();
|
|
221
289
|
}
|
|
290
|
+
if (!refresh)
|
|
291
|
+
return NextResponse.redirect(new URL(SETTINGS.bff.paths.login, request.url));
|
|
292
|
+
if (refresh && !access)
|
|
293
|
+
return NextResponse.redirect(new URL(`${SETTINGS.bff.paths.refresh}?redirectUrl=${url}`, request.url));
|
|
222
294
|
return NextResponse.next();
|
|
223
295
|
}
|
|
224
296
|
/* ------------------------------------------------------------------------ */
|
|
225
|
-
/* BFF HANDLERS
|
|
297
|
+
/* BFF HANDLERS */
|
|
226
298
|
/* ------------------------------------------------------------------------ */
|
|
227
299
|
getHandlers() {
|
|
228
300
|
return {
|
|
229
301
|
GET: async (req, ctx) => {
|
|
230
302
|
const action = (await ctx.params).auditauth[0];
|
|
303
|
+
const redirectUrl = req.nextUrl.searchParams.get('redirectUrl');
|
|
231
304
|
switch (action) {
|
|
232
305
|
case 'login':
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
306
|
+
{
|
|
307
|
+
const url = await this.buildAuthUrl();
|
|
308
|
+
return NextResponse.redirect(url);
|
|
309
|
+
}
|
|
310
|
+
;
|
|
311
|
+
case 'refresh':
|
|
312
|
+
{
|
|
313
|
+
const { ok } = await this.refresh();
|
|
314
|
+
if (ok)
|
|
315
|
+
return NextResponse.redirect(redirectUrl || this.config.redirectUrl);
|
|
316
|
+
const url = await this.buildAuthUrl();
|
|
317
|
+
return NextResponse.redirect(url);
|
|
318
|
+
}
|
|
319
|
+
;
|
|
320
|
+
case 'callback':
|
|
321
|
+
{
|
|
322
|
+
const { url } = await this.callback(req);
|
|
323
|
+
return NextResponse.redirect(url);
|
|
324
|
+
}
|
|
325
|
+
;
|
|
238
326
|
case 'logout':
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
327
|
+
{
|
|
328
|
+
await this.logout();
|
|
329
|
+
return NextResponse.redirect(this.config.redirectUrl);
|
|
330
|
+
}
|
|
331
|
+
;
|
|
332
|
+
case 'portal':
|
|
333
|
+
{
|
|
334
|
+
const { ok, url } = await this.getPortalUrl();
|
|
335
|
+
return ok && url
|
|
336
|
+
? NextResponse.redirect(url)
|
|
337
|
+
: NextResponse.redirect(`${SETTINGS.domains.client}/auth/invalid`);
|
|
338
|
+
}
|
|
339
|
+
;
|
|
340
|
+
case 'session':
|
|
341
|
+
{
|
|
342
|
+
const user = this.getSession();
|
|
343
|
+
if (!user)
|
|
344
|
+
return new NextResponse(null, { status: 401 });
|
|
345
|
+
return NextResponse.json({ user });
|
|
346
|
+
}
|
|
347
|
+
;
|
|
253
348
|
default:
|
|
254
|
-
|
|
349
|
+
{
|
|
350
|
+
return new Response('not found', { status: 404 });
|
|
351
|
+
}
|
|
352
|
+
;
|
|
255
353
|
}
|
|
256
354
|
},
|
|
257
355
|
POST: async (req, ctx) => {
|
|
@@ -263,17 +361,5 @@ class AuditAuthNext {
|
|
|
263
361
|
},
|
|
264
362
|
};
|
|
265
363
|
}
|
|
266
|
-
async metrics(payload) {
|
|
267
|
-
await fetch(`${SETTINGS.domains.api}/metrics`, {
|
|
268
|
-
method: 'POST',
|
|
269
|
-
headers: {
|
|
270
|
-
'Content-Type': 'application/json',
|
|
271
|
-
'x-auditauth-app': this.config.appId,
|
|
272
|
-
'x-auditauth-key': this.config.apiKey,
|
|
273
|
-
},
|
|
274
|
-
body: JSON.stringify(payload),
|
|
275
|
-
});
|
|
276
|
-
return new Response(null, { status: 204 });
|
|
277
|
-
}
|
|
278
364
|
}
|
|
279
365
|
export { AuditAuthNext };
|
package/dist/settings.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ declare const SETTINGS: {
|
|
|
2
2
|
readonly jwt_public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs2EYs4Q9OyjNuAEPqb4j\nIzc52JdfVcNvEbG43Xp8B2kI9QxwRyX7rtFSwKowj3W1BlCLaTIMK3TafWOf9QwH\nfemuL9Ni37PFcGptzpyuoCYYA650EuD82PENcO49lsObvty2cuXxQszbPPvAecm4\nJ/XG70td/W1UwbjAJcdmp8ktZGYR0JXM37hYA9Xq/aKwu7d0FTL6WdKTvt3L5VxL\nF6WNyLs65ZSbu+j8UEkwmoJ9h9Y0mLQmFtmkoh/HWOFyFDnBNiJX0vRb++RhJw6w\ncrSbqpbTu7z4vIep5lgSOut39P273SVTQZ3cGQIS+605Ur5wjkkSzzaJV1QLBBR9\nAQIDAQAB\n-----END PUBLIC KEY-----\n";
|
|
3
3
|
readonly jwt_issuer: "https://api.auditauth.com";
|
|
4
4
|
readonly domains: {
|
|
5
|
-
readonly api: "
|
|
6
|
-
readonly client: "
|
|
5
|
+
readonly api: "https://api.auditauth.com/v1";
|
|
6
|
+
readonly client: "https://auditauth.com";
|
|
7
7
|
};
|
|
8
8
|
readonly bff: {
|
|
9
9
|
readonly paths: {
|
|
@@ -13,48 +13,21 @@ declare const SETTINGS: {
|
|
|
13
13
|
readonly logout: "/api/auditauth/logout";
|
|
14
14
|
readonly portal: "/api/auditauth/portal";
|
|
15
15
|
readonly session: "/api/auditauth/session";
|
|
16
|
+
readonly refresh: "/api/auditauth/refresh";
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
readonly cookies: {
|
|
19
20
|
readonly access: {
|
|
20
21
|
readonly name: "auditauth_access";
|
|
21
|
-
readonly config: {
|
|
22
|
-
readonly httpOnly: true;
|
|
23
|
-
readonly sameSite: "lax";
|
|
24
|
-
readonly secure: false;
|
|
25
|
-
readonly path: "/";
|
|
26
|
-
readonly maxAge: number;
|
|
27
|
-
};
|
|
28
22
|
};
|
|
29
23
|
readonly session: {
|
|
30
24
|
readonly name: "auditauth_session";
|
|
31
|
-
readonly config: {
|
|
32
|
-
readonly maxAge: number;
|
|
33
|
-
readonly httpOnly: true;
|
|
34
|
-
readonly secure: false;
|
|
35
|
-
readonly path: "/";
|
|
36
|
-
readonly sameSite: "lax";
|
|
37
|
-
};
|
|
38
25
|
};
|
|
39
26
|
readonly refresh: {
|
|
40
27
|
readonly name: "auditauth_refresh";
|
|
41
|
-
readonly config: {
|
|
42
|
-
readonly httpOnly: true;
|
|
43
|
-
readonly sameSite: "lax";
|
|
44
|
-
readonly secure: false;
|
|
45
|
-
readonly path: "/";
|
|
46
|
-
readonly maxAge: number;
|
|
47
|
-
};
|
|
48
28
|
};
|
|
49
29
|
readonly session_id: {
|
|
50
30
|
readonly name: "auditauth_sid";
|
|
51
|
-
readonly config: {
|
|
52
|
-
readonly httpOnly: false;
|
|
53
|
-
readonly sameSite: "lax";
|
|
54
|
-
readonly secure: false;
|
|
55
|
-
readonly path: "/";
|
|
56
|
-
readonly maxAge: number;
|
|
57
|
-
};
|
|
58
31
|
};
|
|
59
32
|
};
|
|
60
33
|
};
|
package/dist/settings.js
CHANGED
|
@@ -2,8 +2,10 @@ const SETTINGS = {
|
|
|
2
2
|
jwt_public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs2EYs4Q9OyjNuAEPqb4j\nIzc52JdfVcNvEbG43Xp8B2kI9QxwRyX7rtFSwKowj3W1BlCLaTIMK3TafWOf9QwH\nfemuL9Ni37PFcGptzpyuoCYYA650EuD82PENcO49lsObvty2cuXxQszbPPvAecm4\nJ/XG70td/W1UwbjAJcdmp8ktZGYR0JXM37hYA9Xq/aKwu7d0FTL6WdKTvt3L5VxL\nF6WNyLs65ZSbu+j8UEkwmoJ9h9Y0mLQmFtmkoh/HWOFyFDnBNiJX0vRb++RhJw6w\ncrSbqpbTu7z4vIep5lgSOut39P273SVTQZ3cGQIS+605Ur5wjkkSzzaJV1QLBBR9\nAQIDAQAB\n-----END PUBLIC KEY-----\n",
|
|
3
3
|
jwt_issuer: "https://api.auditauth.com",
|
|
4
4
|
domains: {
|
|
5
|
-
api: '
|
|
6
|
-
client: '
|
|
5
|
+
api: 'https://api.auditauth.com/v1',
|
|
6
|
+
client: 'https://auditauth.com',
|
|
7
|
+
// api: 'http://localhost:4000/v1',
|
|
8
|
+
// client: 'http://localhost:3000',
|
|
7
9
|
},
|
|
8
10
|
bff: {
|
|
9
11
|
paths: {
|
|
@@ -13,48 +15,21 @@ const SETTINGS = {
|
|
|
13
15
|
logout: '/api/auditauth/logout',
|
|
14
16
|
portal: '/api/auditauth/portal',
|
|
15
17
|
session: '/api/auditauth/session',
|
|
18
|
+
refresh: '/api/auditauth/refresh',
|
|
16
19
|
}
|
|
17
20
|
},
|
|
18
21
|
cookies: {
|
|
19
22
|
access: {
|
|
20
23
|
name: 'auditauth_access',
|
|
21
|
-
config: {
|
|
22
|
-
httpOnly: true,
|
|
23
|
-
sameSite: 'lax',
|
|
24
|
-
secure: false,
|
|
25
|
-
path: '/',
|
|
26
|
-
maxAge: 60 * 15,
|
|
27
|
-
}
|
|
28
24
|
},
|
|
29
25
|
session: {
|
|
30
26
|
name: 'auditauth_session',
|
|
31
|
-
config: {
|
|
32
|
-
maxAge: 60 * 60 * 24,
|
|
33
|
-
httpOnly: true,
|
|
34
|
-
secure: false,
|
|
35
|
-
path: "/",
|
|
36
|
-
sameSite: "lax",
|
|
37
|
-
},
|
|
38
27
|
},
|
|
39
28
|
refresh: {
|
|
40
29
|
name: 'auditauth_refresh',
|
|
41
|
-
config: {
|
|
42
|
-
httpOnly: true,
|
|
43
|
-
sameSite: 'lax',
|
|
44
|
-
secure: false,
|
|
45
|
-
path: '/',
|
|
46
|
-
maxAge: 60 * 60 * 24,
|
|
47
|
-
}
|
|
48
30
|
},
|
|
49
31
|
session_id: {
|
|
50
32
|
name: 'auditauth_sid',
|
|
51
|
-
config: {
|
|
52
|
-
httpOnly: false,
|
|
53
|
-
sameSite: 'lax',
|
|
54
|
-
secure: false,
|
|
55
|
-
path: '/',
|
|
56
|
-
maxAge: 60 * 60,
|
|
57
|
-
}
|
|
58
33
|
}
|
|
59
34
|
}
|
|
60
35
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
type AuditAuthConfig = {
|
|
2
|
-
requestUrl: string;
|
|
3
2
|
apiKey: string;
|
|
4
3
|
redirectUrl: string;
|
|
5
4
|
baseUrl: string;
|
|
6
5
|
appId: string;
|
|
7
6
|
};
|
|
7
|
+
type CredentialResponse = {
|
|
8
|
+
access_token: string;
|
|
9
|
+
access_expires_seconds: number;
|
|
10
|
+
refresh_token: string;
|
|
11
|
+
refresh_expires_seconds: number;
|
|
12
|
+
};
|
|
8
13
|
type SessionUser = {
|
|
9
14
|
_id: string;
|
|
10
15
|
name: string;
|
|
@@ -47,4 +52,4 @@ type CookieAdapter = {
|
|
|
47
52
|
set: (name: string, value: string, options?: CookieOptions) => void;
|
|
48
53
|
remove: (name: string) => void;
|
|
49
54
|
};
|
|
50
|
-
export type { AuditAuthConfig, SessionUser, Session, RequestMethod, Metric, CookieOptions, CookieAdapter, };
|
|
55
|
+
export type { AuditAuthConfig, CredentialResponse, SessionUser, Session, RequestMethod, Metric, CookieOptions, CookieAdapter, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auditauth/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Official AuditAuth SDK for Next.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nimibyte",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc -p tsconfig.build.json",
|
|
21
|
-
"prepublishOnly": "npm run build"
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"dev": "tsc -p tsconfig.build.json --watch"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
25
|
"next": ">=13",
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
"react-dom": ">=18"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"crypto": "^1.0.1",
|
|
30
30
|
"jose": "^5.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|