tinacms-authjs 13.0.1 → 14.0.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/dist/index.js CHANGED
@@ -1,46 +1,17 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
1
  // src/index.ts
30
- var index_exports = {};
31
- __export(index_exports, {
32
- AuthJsBackendAuthProvider: () => AuthJsBackendAuthProvider,
33
- TinaAuthJSOptions: () => TinaAuthJSOptions,
34
- TinaCredentialsProvider: () => TinaCredentialsProvider
35
- });
36
- module.exports = __toCommonJS(index_exports);
37
- var import_next_auth = __toESM(require("next-auth"));
38
- var import_credentials = __toESM(require("next-auth/providers/credentials"));
39
- var import_next = require("next-auth/next");
2
+ import NextAuth from "next-auth";
3
+ import CredentialsProvider from "next-auth/providers/credentials";
4
+ import { getServerSession } from "next-auth/next";
40
5
 
41
6
  // src/tinacms.ts
42
- var import_react = require("next-auth/react");
43
- var import_tinacms = require("tinacms");
7
+ import {
8
+ getCsrfToken,
9
+ getSession,
10
+ signIn,
11
+ signOut,
12
+ SessionProvider
13
+ } from "next-auth/react";
14
+ import { AbstractAuthProvider } from "tinacms";
44
15
  var TINA_CREDENTIALS_PROVIDER_NAME = "TinaCredentials";
45
16
 
46
17
  // src/index.ts
@@ -101,7 +72,7 @@ var TinaCredentialsProvider = ({
101
72
  databaseClient,
102
73
  name = TINA_CREDENTIALS_PROVIDER_NAME
103
74
  }) => {
104
- const p = (0, import_credentials.default)({
75
+ const p = CredentialsProvider({
105
76
  credentials: {
106
77
  username: { label: "Username", type: "text" },
107
78
  password: { label: "Password", type: "password" }
@@ -127,7 +98,7 @@ var AuthJsBackendAuthProvider = ({
127
98
  }
128
99
  },
129
100
  isAuthorized: async (req, res) => {
130
- const session = await (0, import_next.getServerSession)(req, res, authOptions);
101
+ const session = await getServerSession(req, res, authOptions);
131
102
  if (!req.session) {
132
103
  Object.defineProperty(req, "session", {
133
104
  value: session,
@@ -160,16 +131,15 @@ var AuthJsBackendAuthProvider = ({
160
131
  );
161
132
  const authSubRoutes = url.pathname?.replace(`${opts.basePath}auth/`, "")?.split("/");
162
133
  req.query.nextauth = authSubRoutes;
163
- await (0, import_next_auth.default)(authOptions)(req, res);
134
+ await NextAuth(authOptions)(req, res);
164
135
  }
165
136
  }
166
137
  }
167
138
  };
168
139
  return authProvider;
169
140
  };
170
- // Annotate the CommonJS export names for ESM import in node:
171
- 0 && (module.exports = {
141
+ export {
172
142
  AuthJsBackendAuthProvider,
173
143
  TinaAuthJSOptions,
174
144
  TinaCredentialsProvider
175
- });
145
+ };