@authcore/fastify 0.5.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Ouatedem
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,25 @@
1
+ import type { FastifyRequest, FastifyReply } from 'fastify';
2
+ import type { AuthCore } from '@authcore/core';
3
+ import type { PublicUser } from '@authcore/core';
4
+ import '@fastify/cookie';
5
+ declare module 'fastify' {
6
+ interface FastifyRequest {
7
+ user?: PublicUser;
8
+ }
9
+ }
10
+ /**
11
+ * Extract a Bearer token from the Authorization header or a cookie.
12
+ */
13
+ export declare function extractToken(request: FastifyRequest, cookieName: string): string | null;
14
+ /**
15
+ * Create a preHandler hook that requires authentication.
16
+ * Attaches `request.user` if the token is valid.
17
+ * Returns 401 if no token is provided or the token is invalid.
18
+ */
19
+ export declare function createAuthRequired(auth: AuthCore, cookieName?: string): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
20
+ /**
21
+ * Create a preHandler hook that optionally attaches `request.user`
22
+ * if a valid token is present, but does NOT reject unauthenticated requests.
23
+ */
24
+ export declare function createAuthOptional(auth: AuthCore, cookieName?: string): (request: FastifyRequest) => Promise<void>;
25
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,iBAAiB,CAAA;AAExB,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,cAAc;QACtB,IAAI,CAAC,EAAE,UAAU,CAAA;KAClB;CACF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQvF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,SAAmB,IAE5E,SAAS,cAAc,EACvB,OAAO,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAejB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,SAAmB,IAE5E,SAAS,cAAc,KACtB,OAAO,CAAC,IAAI,CAAC,CAUjB"}
package/dist/hooks.js ADDED
@@ -0,0 +1,46 @@
1
+ import '@fastify/cookie';
2
+ /**
3
+ * Extract a Bearer token from the Authorization header or a cookie.
4
+ */
5
+ export function extractToken(request, cookieName) {
6
+ const authHeader = request.headers['authorization'];
7
+ if (authHeader?.startsWith('Bearer ')) {
8
+ return authHeader.slice(7);
9
+ }
10
+ const cookieToken = request.cookies[cookieName];
11
+ return cookieToken ?? null;
12
+ }
13
+ /**
14
+ * Create a preHandler hook that requires authentication.
15
+ * Attaches `request.user` if the token is valid.
16
+ * Returns 401 if no token is provided or the token is invalid.
17
+ */
18
+ export function createAuthRequired(auth, cookieName = 'authcore_token') {
19
+ return async function authRequired(request, reply) {
20
+ const token = extractToken(request, cookieName);
21
+ if (!token) {
22
+ return reply.code(401).send({ error: 'Authentication required' });
23
+ }
24
+ const user = await auth.verifyToken(token);
25
+ if (!user) {
26
+ return reply.code(401).send({ error: 'Invalid or expired token' });
27
+ }
28
+ request.user = user;
29
+ };
30
+ }
31
+ /**
32
+ * Create a preHandler hook that optionally attaches `request.user`
33
+ * if a valid token is present, but does NOT reject unauthenticated requests.
34
+ */
35
+ export function createAuthOptional(auth, cookieName = 'authcore_token') {
36
+ return async function authOptional(request) {
37
+ const token = extractToken(request, cookieName);
38
+ if (token) {
39
+ const user = await auth.verifyToken(token);
40
+ if (user) {
41
+ request.user = user;
42
+ }
43
+ }
44
+ };
45
+ }
46
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,iBAAiB,CAAA;AAQxB;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,OAAuB,EAAE,UAAkB;IACtE,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACnD,IAAI,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC/C,OAAO,WAAW,IAAI,IAAI,CAAA;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAc,EAAE,UAAU,GAAG,gBAAgB;IAC9E,OAAO,KAAK,UAAU,YAAY,CAChC,OAAuB,EACvB,KAAmB;QAEnB,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAE/C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC,CAAA;QACnE,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAE1C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC,CAAA;QACpE,CAAC;QAED,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;IACrB,CAAC,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAc,EAAE,UAAU,GAAG,gBAAgB;IAC9E,OAAO,KAAK,UAAU,YAAY,CAChC,OAAuB;QAEvB,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAE/C,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;YAC1C,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;YACrB,CAAC;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { AuthCoreConfig } from '@authcore/core';
2
+ import type { FastifyPluginAsync, preHandlerHookHandler } from 'fastify';
3
+ import type { PluginConfig } from './plugin.js';
4
+ export type { PluginConfig };
5
+ /**
6
+ * The Fastify AuthCore instance — wraps the core auth logic with Fastify-specific
7
+ * plugin registration and preHandler hooks.
8
+ */
9
+ export interface FastifyAuth {
10
+ /**
11
+ * Returns a Fastify plugin that registers all auth routes.
12
+ * Register with: `app.register(auth.plugin(), { prefix: '/auth' })`
13
+ */
14
+ plugin(config?: PluginConfig): FastifyPluginAsync;
15
+ /**
16
+ * Returns a preHandler hook that validates the JWT (or cookie) and
17
+ * attaches `request.user`. Returns 401 on failure.
18
+ *
19
+ * Use to protect routes:
20
+ * `app.get('/dashboard', { preHandler: [auth.authRequired()] }, handler)`
21
+ */
22
+ authRequired(): preHandlerHookHandler;
23
+ /**
24
+ * Returns a preHandler hook that optionally attaches `request.user` if
25
+ * a valid token is present, but does NOT reject unauthenticated requests.
26
+ */
27
+ authOptional(): preHandlerHookHandler;
28
+ }
29
+ /**
30
+ * Create a Fastify-specific AuthCore instance.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import Fastify from 'fastify'
35
+ * import cookie from '@fastify/cookie'
36
+ * import { createAuth } from '@authcore/fastify'
37
+ * import { prismaAdapter } from '@authcore/prisma-adapter'
38
+ *
39
+ * const app = Fastify()
40
+ * await app.register(cookie)
41
+ *
42
+ * const auth = createAuth({
43
+ * db: prismaAdapter(prisma),
44
+ * session: { strategy: 'jwt', secret: process.env.AUTH_SECRET! },
45
+ * })
46
+ *
47
+ * await app.register(auth.plugin(), { prefix: '/auth' })
48
+ *
49
+ * app.get('/dashboard', {
50
+ * preHandler: [auth.authRequired()]
51
+ * }, async (request) => {
52
+ * return { user: request.user }
53
+ * })
54
+ * ```
55
+ */
56
+ export declare function createAuth(config: AuthCoreConfig): FastifyAuth;
57
+ export type { AuthCoreConfig, PublicUser, DatabaseAdapter, EmailAdapter } from '@authcore/core';
58
+ export { AuthError } from '@authcore/core';
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG/C,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,kBAAkB,CAAA;IAEjD;;;;;;OAMG;IACH,YAAY,IAAI,qBAAqB,CAAA;IAErC;;;OAGG;IACH,YAAY,IAAI,qBAAqB,CAAA;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,CAgB9D;AAGD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import { createAuth as createCoreAuth } from '@authcore/core';
2
+ import { createAuthPlugin } from './plugin.js';
3
+ import { createAuthRequired, createAuthOptional } from './hooks.js';
4
+ /**
5
+ * Create a Fastify-specific AuthCore instance.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import Fastify from 'fastify'
10
+ * import cookie from '@fastify/cookie'
11
+ * import { createAuth } from '@authcore/fastify'
12
+ * import { prismaAdapter } from '@authcore/prisma-adapter'
13
+ *
14
+ * const app = Fastify()
15
+ * await app.register(cookie)
16
+ *
17
+ * const auth = createAuth({
18
+ * db: prismaAdapter(prisma),
19
+ * session: { strategy: 'jwt', secret: process.env.AUTH_SECRET! },
20
+ * })
21
+ *
22
+ * await app.register(auth.plugin(), { prefix: '/auth' })
23
+ *
24
+ * app.get('/dashboard', {
25
+ * preHandler: [auth.authRequired()]
26
+ * }, async (request) => {
27
+ * return { user: request.user }
28
+ * })
29
+ * ```
30
+ */
31
+ export function createAuth(config) {
32
+ const core = createCoreAuth(config);
33
+ return {
34
+ plugin(pluginConfig) {
35
+ return createAuthPlugin(core, pluginConfig);
36
+ },
37
+ authRequired() {
38
+ return createAuthRequired(core);
39
+ },
40
+ authOptional() {
41
+ return createAuthOptional(core);
42
+ },
43
+ };
44
+ }
45
+ export { AuthError } from '@authcore/core';
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AA+BnE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,UAAU,CAAC,MAAsB;IAC/C,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IAEnC,OAAO;QACL,MAAM,CAAC,YAA2B;YAChC,OAAO,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;QAC7C,CAAC;QAED,YAAY;YACV,OAAO,kBAAkB,CAAC,IAAI,CAA0B,CAAA;QAC1D,CAAC;QAED,YAAY;YACV,OAAO,kBAAkB,CAAC,IAAI,CAA0B,CAAA;QAC1D,CAAC;KACF,CAAA;AACH,CAAC;AAID,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,25 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { AuthCore } from '@authcore/core';
3
+ import '@fastify/cookie';
4
+ export interface PluginConfig {
5
+ /** Base URL used to build links in emails (e.g. 'https://myapp.com') */
6
+ baseUrl?: string;
7
+ routes?: {
8
+ register?: string;
9
+ login?: string;
10
+ logout?: string;
11
+ me?: string;
12
+ verifyEmail?: string;
13
+ forgotPassword?: string;
14
+ resetPassword?: string;
15
+ };
16
+ /** Cookie name for monorepo/cookie mode (default: 'authcore_token') */
17
+ cookieName?: string;
18
+ /** If true, set an httpOnly cookie on login/register instead of returning token in body */
19
+ useCookies?: boolean;
20
+ }
21
+ /**
22
+ * Create a Fastify plugin that registers all auth routes.
23
+ */
24
+ export declare function createAuthPlugin(auth: AuthCore, config?: PluginConfig): (fastify: FastifyInstance) => Promise<void>;
25
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,SAAS,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,iBAAiB,CAAA;AAGxB,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,CAAA;IACD,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2FAA2F;IAC3F,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAUD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAE,YAAiB,IAoBvC,SAAS,eAAe,mBAwE1D"}
package/dist/plugin.js ADDED
@@ -0,0 +1,99 @@
1
+ import { AuthError } from '@authcore/core';
2
+ import '@fastify/cookie';
3
+ import { createAuthRequired } from './hooks.js';
4
+ function handleError(reply, err) {
5
+ if (err instanceof AuthError) {
6
+ return reply.code(err.statusCode).send({ error: err.message, code: err.code });
7
+ }
8
+ console.error('[AuthCore]', err);
9
+ return reply.code(500).send({ error: 'Internal server error' });
10
+ }
11
+ /**
12
+ * Create a Fastify plugin that registers all auth routes.
13
+ */
14
+ export function createAuthPlugin(auth, config = {}) {
15
+ const { cookieName = 'authcore_token', useCookies = false, routes: routePaths = {}, } = config;
16
+ const paths = {
17
+ register: routePaths.register ?? '/register',
18
+ login: routePaths.login ?? '/login',
19
+ logout: routePaths.logout ?? '/logout',
20
+ me: routePaths.me ?? '/me',
21
+ verifyEmail: routePaths.verifyEmail ?? '/verify-email',
22
+ forgotPassword: routePaths.forgotPassword ?? '/forgot-password',
23
+ resetPassword: routePaths.resetPassword ?? '/reset-password',
24
+ };
25
+ const isProduction = process.env['NODE_ENV'] === 'production';
26
+ const authRequired = createAuthRequired(auth, cookieName);
27
+ return async function authPlugin(fastify) {
28
+ // POST /register
29
+ fastify.post(paths.register, async (request, reply) => {
30
+ try {
31
+ const { user, token } = await auth.register(request.body);
32
+ if (useCookies) {
33
+ void reply.setCookie(cookieName, token, { httpOnly: true, sameSite: 'lax', secure: isProduction, path: '/' });
34
+ return reply.code(201).send({ user });
35
+ }
36
+ return reply.code(201).send({ user, token });
37
+ }
38
+ catch (err) {
39
+ return handleError(reply, err);
40
+ }
41
+ });
42
+ // POST /login
43
+ fastify.post(paths.login, async (request, reply) => {
44
+ try {
45
+ const { user, token } = await auth.login(request.body);
46
+ if (useCookies) {
47
+ void reply.setCookie(cookieName, token, { httpOnly: true, sameSite: 'lax', secure: isProduction, path: '/' });
48
+ return reply.send({ user });
49
+ }
50
+ return reply.send({ user, token });
51
+ }
52
+ catch (err) {
53
+ return handleError(reply, err);
54
+ }
55
+ });
56
+ // POST /logout
57
+ fastify.post(paths.logout, async (_request, reply) => {
58
+ if (useCookies) {
59
+ void reply.clearCookie(cookieName, { path: '/' });
60
+ }
61
+ return reply.send({ message: 'Logged out successfully' });
62
+ });
63
+ // GET /me — protected
64
+ fastify.get(paths.me, { preHandler: [authRequired] }, async (request, reply) => {
65
+ return reply.send(request.user);
66
+ });
67
+ // POST /verify-email
68
+ fastify.post(paths.verifyEmail, async (request, reply) => {
69
+ try {
70
+ await auth.verifyEmail(request.body);
71
+ return reply.send({ message: 'Email verified successfully' });
72
+ }
73
+ catch (err) {
74
+ return handleError(reply, err);
75
+ }
76
+ });
77
+ // POST /forgot-password — always 200
78
+ fastify.post(paths.forgotPassword, async (request, reply) => {
79
+ try {
80
+ await auth.forgotPassword(request.body);
81
+ }
82
+ catch {
83
+ // Intentionally swallow — no email enumeration
84
+ }
85
+ return reply.send({ message: 'If that email exists, a reset link has been sent.' });
86
+ });
87
+ // POST /reset-password
88
+ fastify.post(paths.resetPassword, async (request, reply) => {
89
+ try {
90
+ await auth.resetPassword(request.body);
91
+ return reply.send({ message: 'Password updated successfully' });
92
+ }
93
+ catch (err) {
94
+ return handleError(reply, err);
95
+ }
96
+ });
97
+ };
98
+ }
99
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,iBAAiB,CAAA;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAoB/C,SAAS,WAAW,CAAC,KAAmB,EAAE,GAAY;IACpD,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IAChF,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,CA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O,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,mDAAmD,EAAE,CAAC,CAAA;QACrF,CAAC,CAAC,CAAA;QAEF,uBAAuB;QACvB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;YACzD,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBACtC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAAA;YACjE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YAChC,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@authcore/fastify",
3
+ "version": "0.5.0",
4
+ "description": "Fastify adapter for AuthCore",
5
+ "author": "David Ouatedem",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/david-ouatedem/auth-core",
9
+ "directory": "packages/fastify"
10
+ },
11
+ "keywords": [
12
+ "auth",
13
+ "authcore",
14
+ "fastify",
15
+ "plugin"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": "./dist/index.js",
26
+ "types": "./dist/index.d.ts"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "@fastify/cookie": "^11.0.0",
31
+ "fastify": "^5.0.0",
32
+ "@authcore/core": "0.5.0"
33
+ },
34
+ "devDependencies": {
35
+ "@prisma/client": "^5.22.0",
36
+ "@types/node": "^20.0.0",
37
+ "dotenv": "^16.4.0",
38
+ "prisma": "^5.22.0",
39
+ "typescript": "^5.4.0",
40
+ "vitest": "^1.6.0",
41
+ "@authcore/prisma-adapter": "0.5.0"
42
+ },
43
+ "files": [
44
+ "dist"
45
+ ],
46
+ "license": "MIT",
47
+ "scripts": {
48
+ "build": "tsc",
49
+ "dev": "tsc --watch",
50
+ "test": "vitest run",
51
+ "test:watch": "vitest"
52
+ }
53
+ }