tinacms-clerk 13.0.0 → 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,34 +1,11 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
1
  // src/index.ts
20
- var index_exports = {};
21
- __export(index_exports, {
22
- ClerkBackendAuthentication: () => ClerkBackendAuthentication
23
- });
24
- module.exports = __toCommonJS(index_exports);
25
- var import_backend = require("@clerk/backend");
2
+ import { Clerk } from "@clerk/backend";
26
3
  var ClerkBackendAuthentication = ({
27
4
  secretKey,
28
5
  allowList,
29
6
  orgId
30
7
  }) => {
31
- const clerk = (0, import_backend.Clerk)({
8
+ const clerk = Clerk({
32
9
  secretKey
33
10
  });
34
11
  return {
@@ -72,7 +49,6 @@ var ClerkBackendAuthentication = ({
72
49
  }
73
50
  };
74
51
  };
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
52
+ export {
77
53
  ClerkBackendAuthentication
78
- });
54
+ };
package/dist/tinacms.js CHANGED
@@ -1,73 +1,70 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("tinacms")) : typeof define === "function" && define.amd ? define(["exports", "tinacms"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["tinacms-clerk"] = {}, global.NOOP));
3
- })(this, function(exports2, tinacms) {
4
- "use strict";
5
- class ClerkAuthProvider extends tinacms.AbstractAuthProvider {
6
- constructor({
7
- orgId,
8
- clerk,
9
- allowedList
10
- }) {
11
- super();
12
- this.clerk = clerk;
13
- this.allowedList = allowedList;
14
- this.orgId = orgId;
15
- }
16
- /**
17
- * Generates a short-lived token when Tina makes a request
18
- */
19
- async getToken() {
20
- await this.clerk.load();
21
- if (this.clerk.session) {
22
- return { id_token: await this.clerk.session.getToken() };
23
- }
24
- }
25
- async logout() {
26
- var _a, _b, _c;
27
- await ((_a = this.clerk) == null ? void 0 : _a.load());
28
- await ((_c = (_b = this.clerk) == null ? void 0 : _b.session) == null ? void 0 : _c.remove());
29
- }
30
- async authenticate() {
31
- this.clerk.openSignIn({
32
- redirectUrl: "/admin/index.html",
33
- // This should be the Tina admin path
34
- appearance: {
35
- elements: {
36
- // Tina's sign in modal is in the way without this
37
- modalBackdrop: { zIndex: 2e4 },
38
- // Some styles clash with Tina's styling
39
- socialButtonsBlockButton: "px-4 py-2 border border-gray-100",
40
- formFieldInput: `px-4 py-2`,
41
- formButtonPrimary: "bg-blue-600 text-white p-4",
42
- formFieldInputShowPasswordButton: "m-2",
43
- dividerText: "px-2"
44
- }
45
- }
46
- });
1
+ import { AbstractAuthProvider } from "tinacms";
2
+ class ClerkAuthProvider extends AbstractAuthProvider {
3
+ constructor({
4
+ orgId,
5
+ clerk,
6
+ allowedList
7
+ }) {
8
+ super();
9
+ this.clerk = clerk;
10
+ this.allowedList = allowedList;
11
+ this.orgId = orgId;
12
+ }
13
+ /**
14
+ * Generates a short-lived token when Tina makes a request
15
+ */
16
+ async getToken() {
17
+ await this.clerk.load();
18
+ if (this.clerk.session) {
19
+ return { id_token: await this.clerk.session.getToken() };
47
20
  }
48
- async authorize(context) {
49
- await this.clerk.load();
50
- if (this.clerk.user) {
51
- if (this.allowedList && !this.allowedList.includes(
52
- this.clerk.user.primaryEmailAddress.emailAddress
53
- )) {
54
- return false;
55
- }
56
- if (this.orgId && !this.clerk.user.organizationMemberships.find(
57
- (x) => x.id === this.orgId
58
- )) {
59
- return false;
21
+ }
22
+ async logout() {
23
+ var _a, _b, _c;
24
+ await ((_a = this.clerk) == null ? void 0 : _a.load());
25
+ await ((_c = (_b = this.clerk) == null ? void 0 : _b.session) == null ? void 0 : _c.remove());
26
+ }
27
+ async authenticate() {
28
+ this.clerk.openSignIn({
29
+ redirectUrl: "/admin/index.html",
30
+ // This should be the Tina admin path
31
+ appearance: {
32
+ elements: {
33
+ // Tina's sign in modal is in the way without this
34
+ modalBackdrop: { zIndex: 2e4 },
35
+ // Some styles clash with Tina's styling
36
+ socialButtonsBlockButton: "px-4 py-2 border border-gray-100",
37
+ formFieldInput: `px-4 py-2`,
38
+ formButtonPrimary: "bg-blue-600 text-white p-4",
39
+ formFieldInputShowPasswordButton: "m-2",
40
+ dividerText: "px-2"
60
41
  }
61
- return true;
62
42
  }
63
- await this.clerk.session.end();
64
- return false;
65
- }
66
- async getUser() {
67
- await this.clerk.load();
68
- return this.clerk.user;
43
+ });
44
+ }
45
+ async authorize(context) {
46
+ await this.clerk.load();
47
+ if (this.clerk.user) {
48
+ if (this.allowedList && !this.allowedList.includes(
49
+ this.clerk.user.primaryEmailAddress.emailAddress
50
+ )) {
51
+ return false;
52
+ }
53
+ if (this.orgId && !this.clerk.user.organizationMemberships.find(
54
+ (x) => x.id === this.orgId
55
+ )) {
56
+ return false;
57
+ }
58
+ return true;
69
59
  }
60
+ await this.clerk.session.end();
61
+ return false;
62
+ }
63
+ async getUser() {
64
+ await this.clerk.load();
65
+ return this.clerk.user;
70
66
  }
71
- exports2.ClerkAuthProvider = ClerkAuthProvider;
72
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
73
- });
67
+ }
68
+ export {
69
+ ClerkAuthProvider
70
+ };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "tinacms-clerk",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "main": "dist/index.js",
5
- "module": "dist/index.mjs",
5
+ "module": "./dist/index.js",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
@@ -23,12 +23,12 @@
23
23
  "@types/node": "^22.13.1",
24
24
  "typescript": "^5.7.3",
25
25
  "@tinacms/scripts": "1.4.1",
26
- "tinacms": "2.10.0"
26
+ "tinacms": "3.0.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@clerk/backend": "0.x",
30
30
  "@clerk/clerk-js": "4.x",
31
- "tinacms": "2.10.0"
31
+ "tinacms": "3.0.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "registry": "https://registry.npmjs.org"
package/dist/tinacms.mjs DELETED
@@ -1,70 +0,0 @@
1
- import { AbstractAuthProvider } from "tinacms";
2
- class ClerkAuthProvider extends AbstractAuthProvider {
3
- constructor({
4
- orgId,
5
- clerk,
6
- allowedList
7
- }) {
8
- super();
9
- this.clerk = clerk;
10
- this.allowedList = allowedList;
11
- this.orgId = orgId;
12
- }
13
- /**
14
- * Generates a short-lived token when Tina makes a request
15
- */
16
- async getToken() {
17
- await this.clerk.load();
18
- if (this.clerk.session) {
19
- return { id_token: await this.clerk.session.getToken() };
20
- }
21
- }
22
- async logout() {
23
- var _a, _b, _c;
24
- await ((_a = this.clerk) == null ? void 0 : _a.load());
25
- await ((_c = (_b = this.clerk) == null ? void 0 : _b.session) == null ? void 0 : _c.remove());
26
- }
27
- async authenticate() {
28
- this.clerk.openSignIn({
29
- redirectUrl: "/admin/index.html",
30
- // This should be the Tina admin path
31
- appearance: {
32
- elements: {
33
- // Tina's sign in modal is in the way without this
34
- modalBackdrop: { zIndex: 2e4 },
35
- // Some styles clash with Tina's styling
36
- socialButtonsBlockButton: "px-4 py-2 border border-gray-100",
37
- formFieldInput: `px-4 py-2`,
38
- formButtonPrimary: "bg-blue-600 text-white p-4",
39
- formFieldInputShowPasswordButton: "m-2",
40
- dividerText: "px-2"
41
- }
42
- }
43
- });
44
- }
45
- async authorize(context) {
46
- await this.clerk.load();
47
- if (this.clerk.user) {
48
- if (this.allowedList && !this.allowedList.includes(
49
- this.clerk.user.primaryEmailAddress.emailAddress
50
- )) {
51
- return false;
52
- }
53
- if (this.orgId && !this.clerk.user.organizationMemberships.find(
54
- (x) => x.id === this.orgId
55
- )) {
56
- return false;
57
- }
58
- return true;
59
- }
60
- await this.clerk.session.end();
61
- return false;
62
- }
63
- async getUser() {
64
- await this.clerk.load();
65
- return this.clerk.user;
66
- }
67
- }
68
- export {
69
- ClerkAuthProvider
70
- };