authmi 1.0.0 → 1.1.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/README.md +7 -7
- package/dist/chunk-EAK7C6YO.mjs +688 -0
- package/dist/client-DmZsG2xs.d.mts +406 -0
- package/dist/client-DmZsG2xs.d.ts +406 -0
- package/dist/index.d.mts +48 -23
- package/dist/index.d.ts +48 -23
- package/dist/index.js +581 -386
- package/dist/index.mjs +115 -3
- package/dist/next.d.mts +7 -37
- package/dist/next.d.ts +7 -37
- package/dist/next.js +476 -416
- package/dist/next.mjs +5 -24
- package/dist/react.d.mts +29 -30
- package/dist/react.d.ts +29 -30
- package/dist/react.js +549 -444
- package/dist/react.mjs +77 -52
- package/package.json +8 -6
- package/dist/chunk-UNKK6FP4.mjs +0 -609
- package/dist/client-D6JiIhlU.d.mts +0 -332
- package/dist/client-D6JiIhlU.d.ts +0 -332
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ Create `middleware.ts` in your project root:
|
|
|
149
149
|
import { createAuthMiMiddleware } from "authmi/next";
|
|
150
150
|
|
|
151
151
|
export const middleware = createAuthMiMiddleware({
|
|
152
|
-
baseUrl: process.env.
|
|
152
|
+
baseUrl: process.env.AUTHMI_URL!,
|
|
153
153
|
protectedPaths: ["/dashboard", "/profile", "/settings"],
|
|
154
154
|
authPaths: ["/login", "/signup"],
|
|
155
155
|
loginPath: "/login",
|
|
@@ -169,7 +169,7 @@ import { withAuth, withScope } from "authmi/next";
|
|
|
169
169
|
|
|
170
170
|
// Any authenticated user
|
|
171
171
|
export const GET = withAuth(
|
|
172
|
-
{ baseUrl: process.env.
|
|
172
|
+
{ baseUrl: process.env.AUTHMI_URL! },
|
|
173
173
|
async (request, { userId, scope }) => {
|
|
174
174
|
return NextResponse.json({
|
|
175
175
|
message: "Hello user!",
|
|
@@ -180,7 +180,7 @@ export const GET = withAuth(
|
|
|
180
180
|
|
|
181
181
|
// Admin only
|
|
182
182
|
export const POST = withScope(
|
|
183
|
-
{ baseUrl: process.env.
|
|
183
|
+
{ baseUrl: process.env.AUTHMI_URL! },
|
|
184
184
|
["admin"], // Only admins
|
|
185
185
|
async (request, { userId }) => {
|
|
186
186
|
return NextResponse.json({
|
|
@@ -196,8 +196,8 @@ export const POST = withScope(
|
|
|
196
196
|
import { createServerClient } from "authmi/next";
|
|
197
197
|
|
|
198
198
|
const serverClient = createServerClient({
|
|
199
|
-
baseUrl: process.env.
|
|
200
|
-
apiKey: process.env.
|
|
199
|
+
baseUrl: process.env.AUTHMI_URL!,
|
|
200
|
+
apiKey: process.env.AUTHMI_API_KEY!, // Server-only
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
// Create a user
|
|
@@ -366,7 +366,7 @@ Common error codes:
|
|
|
366
366
|
import { createAuthMiMiddleware } from "authmi/next";
|
|
367
367
|
|
|
368
368
|
export const middleware = createAuthMiMiddleware({
|
|
369
|
-
baseUrl: process.env.
|
|
369
|
+
baseUrl: process.env.AUTHMI_URL!,
|
|
370
370
|
protectedPaths: ["/api/protected"],
|
|
371
371
|
});
|
|
372
372
|
|
|
@@ -379,7 +379,7 @@ import { NextResponse } from "next/server";
|
|
|
379
379
|
import { withAuth } from "authmi/next";
|
|
380
380
|
|
|
381
381
|
export const GET = withAuth(
|
|
382
|
-
{ baseUrl: process.env.
|
|
382
|
+
{ baseUrl: process.env.AUTHMI_URL! },
|
|
383
383
|
async (request, { userId, scope }) => {
|
|
384
384
|
// User is authenticated!
|
|
385
385
|
return NextResponse.json({
|