@stacksjs/auth 0.74.27 → 0.74.29
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/gate.d.ts +1 -1
- package/dist/page-gate.d.ts +4 -1
- package/dist/page-gate.js +1 -1
- package/package.json +13 -13
package/dist/gate.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ import type { UserModel as OrmUserModel } from '@stacksjs/orm';
|
|
|
27
27
|
*
|
|
28
28
|
* export default defineGates({
|
|
29
29
|
* gates: {
|
|
30
|
-
* 'access-admin': user => user?.email?.endsWith('@stacksjs.
|
|
30
|
+
* 'access-admin': user => user?.email?.endsWith('@stacksjs.com') ?? false,
|
|
31
31
|
* },
|
|
32
32
|
* policies: {
|
|
33
33
|
* Post: 'PostPolicy',
|
package/dist/page-gate.d.ts
CHANGED
|
@@ -31,4 +31,7 @@ export declare interface PageGateOptions {
|
|
|
31
31
|
home?: string
|
|
32
32
|
validate?: (token: string) => Promise<unknown>
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
35
|
+
declare type StxPageMiddleware = ((request: Request, context: StxPageContext) => Promise<Response | null>) & {
|
|
36
|
+
priority: number
|
|
37
|
+
}
|
package/dist/page-gate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Auth}from"./authentication";import{authCookieName}from"./cookie-auth";export function stxPageAuthMiddleware(options={}){const redirectTo=options.redirectTo??"/login",home=options.home??"/",validate=options.validate??((token)=>Auth.getUserFromToken(token));async function signedInUser(ctx){const token=ctx.cookies[authCookieName({name:options.cookieName})];if(!token)return;try{return await validate(token)}catch{return}}
|
|
1
|
+
import{Auth}from"./authentication";import{authCookieName}from"./cookie-auth";export function stxPageAuthMiddleware(options={}){const redirectTo=options.redirectTo??"/login",home=options.home??"/",validate=options.validate??((token)=>Auth.getUserFromToken(token));async function signedInUser(ctx){const token=ctx.cookies[authCookieName({name:options.cookieName})];if(!token)return;try{return await validate(token)}catch{return}}const auth=Object.assign(async(_req,ctx)=>{if(await signedInUser(ctx))return null;return ctx.redirect(redirectTo)},{priority:1}),guest=Object.assign(async(_req,ctx)=>{if(await signedInUser(ctx))return Response.redirect(home,302);return null},{priority:1});return{auth,guest}}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/auth",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.29",
|
|
6
6
|
"description": "A more simplistic way to authenticate.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -58,18 +58,18 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@stacksjs/bun-router": "^0.1.11",
|
|
61
|
-
"@stacksjs/cache": "0.74.
|
|
62
|
-
"@stacksjs/config": "0.74.
|
|
63
|
-
"@stacksjs/database": "0.74.
|
|
64
|
-
"@stacksjs/email": "0.74.
|
|
65
|
-
"@stacksjs/env": "0.74.
|
|
66
|
-
"@stacksjs/error-handling": "0.74.
|
|
67
|
-
"@stacksjs/logging": "0.74.
|
|
68
|
-
"@stacksjs/orm": "0.74.
|
|
69
|
-
"@stacksjs/path": "0.74.
|
|
70
|
-
"@stacksjs/router": "0.74.
|
|
71
|
-
"@stacksjs/security": "0.74.
|
|
72
|
-
"@stacksjs/storage": "0.74.
|
|
61
|
+
"@stacksjs/cache": "0.74.29",
|
|
62
|
+
"@stacksjs/config": "0.74.29",
|
|
63
|
+
"@stacksjs/database": "0.74.29",
|
|
64
|
+
"@stacksjs/email": "0.74.29",
|
|
65
|
+
"@stacksjs/env": "0.74.29",
|
|
66
|
+
"@stacksjs/error-handling": "0.74.29",
|
|
67
|
+
"@stacksjs/logging": "0.74.29",
|
|
68
|
+
"@stacksjs/orm": "0.74.29",
|
|
69
|
+
"@stacksjs/path": "0.74.29",
|
|
70
|
+
"@stacksjs/router": "0.74.29",
|
|
71
|
+
"@stacksjs/security": "0.74.29",
|
|
72
|
+
"@stacksjs/storage": "0.74.29",
|
|
73
73
|
"@stacksjs/ts-auth": "^0.4.4",
|
|
74
74
|
"ts-qr-codes": "^0.1.8"
|
|
75
75
|
},
|