tinacms 1.5.23 → 1.5.25

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,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/plate-headless"), require("@monaco-editor/react"), require("slate-react"), require("@headlessui/react"), require("slate"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("@radix-ui/react-popover"), require("react-color"), require("color-string"), require("react-dropzone"), require("@tinacms/sharedctx"), require("is-hotkey"), require("@floating-ui/dom"), require("moment"), require("date-fns"), require("@react-hook/window-size"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("yup"), require("@graphql-inspector/core"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/plate-headless", "@monaco-editor/react", "slate-react", "@headlessui/react", "slate", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "@radix-ui/react-popover", "react-color", "color-string", "react-dropzone", "@tinacms/sharedctx", "is-hotkey", "@floating-ui/dom", "moment", "date-fns", "@react-hook/window-size", "graphql", "graphql-tag", "@tinacms/schema-tools", "yup", "@graphql-inspector/core", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
- })(this, function(exports2, zod, React, reactDom, plateHeadless, MonacoEditor, slateReact, react, slate, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, Popover$1, pkg$1, pkg, dropzone, sharedctx, isHotkey, dom, moment, dateFns, windowSize, graphql, gql$1, schemaTools, yup, core, reactRouterDom, mdx) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/plate-headless"), require("@monaco-editor/react"), require("slate-react"), require("@headlessui/react"), require("slate"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("@radix-ui/react-popover"), require("react-color"), require("color-string"), require("react-dropzone"), require("@tinacms/sharedctx"), require("lodash.get"), require("moment"), require("date-fns"), require("@react-hook/window-size"), require("is-hotkey"), require("@floating-ui/dom"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("yup"), require("@graphql-inspector/core"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/plate-headless", "@monaco-editor/react", "slate-react", "@headlessui/react", "slate", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "@radix-ui/react-popover", "react-color", "color-string", "react-dropzone", "@tinacms/sharedctx", "lodash.get", "moment", "date-fns", "@react-hook/window-size", "is-hotkey", "@floating-ui/dom", "graphql", "graphql-tag", "@tinacms/schema-tools", "yup", "@graphql-inspector/core", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
+ })(this, function(exports2, zod, React, reactDom, plateHeadless, MonacoEditor, slateReact, react, slate, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, Popover$1, pkg$1, pkg, dropzone, sharedctx, get, moment, dateFns, windowSize, isHotkey, dom, graphql, gql$1, schemaTools, yup, core, reactRouterDom, mdx) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => {
@@ -30,42 +30,6 @@ var __publicField = (obj, key, value) => {
30
30
  const pkg__namespace = /* @__PURE__ */ _interopNamespaceDefault(pkg);
31
31
  const dropzone__namespace = /* @__PURE__ */ _interopNamespaceDefault(dropzone);
32
32
  const yup__namespace = /* @__PURE__ */ _interopNamespaceDefault(yup);
33
- function popupWindow(url, title, window2, w, h) {
34
- const y = window2.top.outerHeight / 2 + window2.top.screenY - h / 2;
35
- const x = window2.top.outerWidth / 2 + window2.top.screenX - w / 2;
36
- return window2.open(
37
- url,
38
- title,
39
- "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", top=" + y + ", left=" + x
40
- );
41
- }
42
- const TINA_LOGIN_EVENT = "tinaCloudLogin";
43
- const AUTH_TOKEN_KEY = "tinacms-auth";
44
- const authenticate = (clientId, frontendUrl) => {
45
- return new Promise((resolve) => {
46
- let authTab;
47
- window.addEventListener("message", function(e) {
48
- if (e.data.source === TINA_LOGIN_EVENT) {
49
- if (authTab) {
50
- authTab.close();
51
- }
52
- resolve({
53
- id_token: e.data.id_token,
54
- access_token: e.data.access_token,
55
- refresh_token: e.data.refresh_token
56
- });
57
- }
58
- });
59
- const origin = `${window.location.protocol}//${window.location.host}`;
60
- authTab = popupWindow(
61
- `${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
62
- "_blank",
63
- window,
64
- 1e3,
65
- 700
66
- );
67
- });
68
- };
69
33
  const ModalProvider = ({ children }) => {
70
34
  const [modalRootContainerRef, setModalRootContainerRef] = React.useState(
71
35
  null
@@ -3086,6 +3050,9 @@ var __publicField = (obj, key, value) => {
3086
3050
  function IoMdRefresh(props) {
3087
3051
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M256 388c-72.597 0-132-59.405-132-132 0-72.601 59.403-132 132-132 36.3 0 69.299 15.4 92.406 39.601L278 234h154V80l-51.698 51.702C348.406 99.798 304.406 80 256 80c-96.797 0-176 79.203-176 176s78.094 176 176 176c81.045 0 148.287-54.134 169.401-128H378.85c-18.745 49.561-67.138 84-122.85 84z" } }] })(props);
3088
3052
  }
3053
+ function MdVpnKey(props) {
3054
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0z" } }, { "tag": "path", "attr": { "d": "M12.65 10A5.99 5.99 0 007 6c-3.31 0-6 2.69-6 6s2.69 6 6 6a5.99 5.99 0 005.65-4H17v4h4v-4h2v-4H12.65zM7 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z" } }] })(props);
3055
+ }
3089
3056
  function MdKeyboardArrowDown(props) {
3090
3057
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" } }, { "tag": "path", "attr": { "d": "M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z" } }] })(props);
3091
3058
  }
@@ -3147,14 +3114,14 @@ var __publicField = (obj, key, value) => {
3147
3114
  return branchData;
3148
3115
  };
3149
3116
  const textFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded-md";
3150
- const disabledClasses = "opacity-50 pointer-events-none cursor-not-allowed";
3117
+ const disabledClasses$1 = "opacity-50 pointer-events-none cursor-not-allowed";
3151
3118
  const BaseTextField = React__namespace.forwardRef(({ className, disabled, ...rest }, ref) => {
3152
3119
  return /* @__PURE__ */ React__namespace.createElement(
3153
3120
  "input",
3154
3121
  {
3155
3122
  ref,
3156
3123
  type: "text",
3157
- className: `${textFieldClasses} ${disabled ? disabledClasses : ""} ${className}`,
3124
+ className: `${textFieldClasses} ${disabled ? disabledClasses$1 : ""} ${className}`,
3158
3125
  ...rest
3159
3126
  }
3160
3127
  );
@@ -3973,6 +3940,20 @@ var __publicField = (obj, key, value) => {
3973
3940
  return option;
3974
3941
  return { value: option, label: option };
3975
3942
  }
3943
+ const passwordFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded-md";
3944
+ const disabledClasses = "opacity-50 pointer-events-none cursor-not-allowed";
3945
+ const errorClasses = "border-red-500 focus:border-red-500 focus:shadow-outline-red";
3946
+ const BasePasswordField = React__namespace.forwardRef(({ className, disabled, error, ...rest }, ref) => {
3947
+ return /* @__PURE__ */ React__namespace.createElement(
3948
+ "input",
3949
+ {
3950
+ ref,
3951
+ type: "password",
3952
+ className: `${passwordFieldClasses} ${disabled ? disabledClasses : ""} ${className} ${error ? errorClasses : ""}`,
3953
+ ...rest
3954
+ }
3955
+ );
3956
+ });
3976
3957
  const Group$1 = wrapFieldWithError(({ tinaForm, field }) => {
3977
3958
  const cms = useCMS$1();
3978
3959
  React__namespace.useState(false);
@@ -5059,9 +5040,19 @@ var __publicField = (obj, key, value) => {
5059
5040
  const TextFieldPlugin = {
5060
5041
  name: "text",
5061
5042
  Component: TextField,
5062
- validate(value, values, meta, field) {
5043
+ validate(value, allValues, meta, field) {
5044
+ var _a;
5063
5045
  if (field.required && !value)
5064
5046
  return "Required";
5047
+ if (field.uid) {
5048
+ const path = field.name.split(".");
5049
+ const fieldName = path[path.length - 1];
5050
+ const parent = path.slice(0, path.length - 2);
5051
+ const items = get(allValues, parent);
5052
+ if (((_a = items == null ? void 0 : items.filter((item) => item[fieldName] === value)) == null ? void 0 : _a.length) > 1) {
5053
+ return `Item with this unique id already exists`;
5054
+ }
5055
+ }
5065
5056
  },
5066
5057
  parse: parse$2
5067
5058
  };
@@ -5724,7 +5715,7 @@ var __publicField = (obj, key, value) => {
5724
5715
  }
5725
5716
  var passive = false;
5726
5717
  var options = Object.defineProperty({}, "passive", {
5727
- get: function get() {
5718
+ get: function get2() {
5728
5719
  passive = true;
5729
5720
  }
5730
5721
  });
@@ -6572,6 +6563,111 @@ var __publicField = (obj, key, value) => {
6572
6563
  Component: HiddenField,
6573
6564
  parse: parse$2
6574
6565
  };
6566
+ const PasswordMask = "********";
6567
+ const PasswordFieldComponent = wrapFieldsWithMeta(({ field, form, meta, input, children }) => {
6568
+ const ref1 = React__namespace.useRef(null);
6569
+ const ref2 = React__namespace.useRef(null);
6570
+ const [error, setError] = React__namespace.useState(false);
6571
+ const [password, setPassword] = React__namespace.useState();
6572
+ const [confirmPassword, setConfirmPassword] = React__namespace.useState();
6573
+ const [passwordChangeRequired, setPasswordChangeRequired] = React__namespace.useState(input.value.passwordChangeRequired);
6574
+ React__namespace.useEffect(() => {
6575
+ if (password) {
6576
+ if (password === confirmPassword) {
6577
+ setError(false);
6578
+ form.change(field.name, { value: password, passwordChangeRequired });
6579
+ } else {
6580
+ setError(true);
6581
+ form.change(field.name, void 0);
6582
+ }
6583
+ } else {
6584
+ setError(false);
6585
+ form.change(field.name, { passwordChangeRequired });
6586
+ }
6587
+ }, [password, confirmPassword, passwordChangeRequired]);
6588
+ return /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-row space-x-4" }, /* @__PURE__ */ React__namespace.createElement(
6589
+ BasePasswordField,
6590
+ {
6591
+ autoComplete: "off",
6592
+ value: password ?? PasswordMask,
6593
+ ref: ref1,
6594
+ disabled: (field == null ? void 0 : field.disabled) ?? false,
6595
+ error,
6596
+ placeholder: field.placeholder || "Password",
6597
+ onKeyDown: (_) => {
6598
+ if (password === void 0) {
6599
+ setPassword("");
6600
+ }
6601
+ if (confirmPassword === void 0) {
6602
+ setConfirmPassword("");
6603
+ }
6604
+ },
6605
+ onChange: (event) => {
6606
+ setPassword(event.target.value);
6607
+ }
6608
+ }
6609
+ ), /* @__PURE__ */ React__namespace.createElement(
6610
+ BasePasswordField,
6611
+ {
6612
+ autoComplete: "off",
6613
+ ref: ref2,
6614
+ value: confirmPassword ?? PasswordMask,
6615
+ disabled: (field == null ? void 0 : field.disabled) ?? false,
6616
+ error,
6617
+ placeholder: field.confirmPlaceholder || "Confirm Password",
6618
+ onKeyDown: (_) => {
6619
+ setPasswordChangeRequired(true);
6620
+ if (password === void 0) {
6621
+ setPassword("");
6622
+ }
6623
+ if (confirmPassword === void 0) {
6624
+ setConfirmPassword("");
6625
+ }
6626
+ },
6627
+ onChange: (event) => {
6628
+ setConfirmPassword(event.target.value);
6629
+ }
6630
+ }
6631
+ ), /* @__PURE__ */ React__namespace.createElement(
6632
+ Button,
6633
+ {
6634
+ variant: "secondary",
6635
+ disabled: password === void 0 && confirmPassword === void 0,
6636
+ onClick: () => {
6637
+ setError(false);
6638
+ setPassword(void 0);
6639
+ setConfirmPassword(void 0);
6640
+ setPasswordChangeRequired(void 0);
6641
+ form.change(field.name, void 0);
6642
+ }
6643
+ },
6644
+ "Reset"
6645
+ )), /* @__PURE__ */ React__namespace.createElement("div", { className: "flex w-full items-center pl-1 pt-3" }, /* @__PURE__ */ React__namespace.createElement(
6646
+ Toggle,
6647
+ {
6648
+ field: { name: "passwordChangeRequired", component: "toggle" },
6649
+ input: {
6650
+ value: passwordChangeRequired ?? true,
6651
+ onChange: () => setPasswordChangeRequired(!passwordChangeRequired)
6652
+ },
6653
+ name: "passwordChangeRequired"
6654
+ }
6655
+ ), /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement("label", { className: "block font-sans text-xs font-semibold text-gray-700 whitespace-normal h-full items-center ml-1" }, "Require Password Change on Next Login"))));
6656
+ });
6657
+ const PasswordFieldPlugin = {
6658
+ name: "password",
6659
+ Component: PasswordFieldComponent,
6660
+ validate(value, values, meta, field) {
6661
+ let password = value;
6662
+ if (Array.isArray(value)) {
6663
+ password = value[0];
6664
+ }
6665
+ if (field.required && (password == null ? void 0 : password.passwordChangeRequired) === void 0) {
6666
+ return "Required";
6667
+ }
6668
+ },
6669
+ parse: parse$2
6670
+ };
6575
6671
  function GrCircleQuestion(props) {
6576
6672
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "stroke": "#000", "strokeWidth": "2", "d": "M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,15 L12,14 C12,13 12,12.5 13,12 C14,11.5 15,11 15,9.5 C15,8.5 14,7 12,7 C10,7 9,8.26413718 9,10 M12,16 L12,18" } }] })(props);
6577
6673
  }
@@ -7526,14 +7622,19 @@ var __publicField = (obj, key, value) => {
7526
7622
  if (!this.api) {
7527
7623
  this.api = (_b = (_a = this.cms) == null ? void 0 : _a.api) == null ? void 0 : _b.tina;
7528
7624
  this.isLocal = !!this.api.isLocalMode;
7529
- const contentApiUrl = new URL(this.api.contentApiUrl);
7530
- this.url = `${contentApiUrl.origin}/media`;
7531
- if (!this.isLocal) {
7532
- if ((_d = (_c = this.api.options) == null ? void 0 : _c.tinaioConfig) == null ? void 0 : _d.assetsApiUrlOverride) {
7533
- const url = new URL(this.api.assetsApiUrl);
7534
- this.url = `${url.origin}/v1/${this.api.clientId}`;
7535
- } else {
7536
- this.url = `${contentApiUrl.origin.replace("content", "assets")}/v1/${this.api.clientId}`;
7625
+ if (!this.isStatic) {
7626
+ const contentApiUrl = new URL(this.api.contentApiUrl);
7627
+ this.url = `${contentApiUrl.origin}/media`;
7628
+ if (!this.isLocal) {
7629
+ if ((_d = (_c = this.api.options) == null ? void 0 : _c.tinaioConfig) == null ? void 0 : _d.assetsApiUrlOverride) {
7630
+ const url = new URL(this.api.assetsApiUrl);
7631
+ this.url = `${url.origin}/v1/${this.api.clientId}`;
7632
+ } else {
7633
+ this.url = `${contentApiUrl.origin.replace(
7634
+ "content",
7635
+ "assets"
7636
+ )}/v1/${this.api.clientId}`;
7637
+ }
7537
7638
  }
7538
7639
  }
7539
7640
  }
@@ -7673,6 +7774,38 @@ var __publicField = (obj, key, value) => {
7673
7774
  }
7674
7775
  async list(options) {
7675
7776
  this.setup();
7777
+ if (this.staticMedia) {
7778
+ const offset = options.offset || 0;
7779
+ const media = this.staticMedia[String(offset)];
7780
+ let hasMore = false;
7781
+ if (this.staticMedia[String(Number(offset) + 20)]) {
7782
+ hasMore = true;
7783
+ }
7784
+ if (options.directory) {
7785
+ let depth = 0;
7786
+ const pathToDirectory = options.directory.split("/");
7787
+ let currentFolder = media;
7788
+ let hasMore2 = false;
7789
+ while (depth < pathToDirectory.length) {
7790
+ const nextFolder = currentFolder.find(
7791
+ (item) => item.type === "dir" && item.filename === pathToDirectory[depth]
7792
+ );
7793
+ if (nextFolder) {
7794
+ const offset2 = options.offset || 0;
7795
+ currentFolder = nextFolder.children[String(offset2)];
7796
+ if (nextFolder.children[String(Number(offset2) + 20)]) {
7797
+ hasMore2 = true;
7798
+ }
7799
+ }
7800
+ depth++;
7801
+ }
7802
+ return {
7803
+ items: currentFolder,
7804
+ nextOffset: hasMore2 ? Number(offset) + 20 : null
7805
+ };
7806
+ }
7807
+ return { items: media, nextOffset: hasMore ? Number(offset) + 20 : null };
7808
+ }
7676
7809
  let res;
7677
7810
  if (!this.isLocal) {
7678
7811
  if (await this.isAuthenticated()) {
@@ -7725,38 +7858,6 @@ var __publicField = (obj, key, value) => {
7725
7858
  filename: dir
7726
7859
  });
7727
7860
  }
7728
- if (this.staticMedia) {
7729
- const offset = options.offset || 0;
7730
- const media = this.staticMedia[String(offset)];
7731
- let hasMore = false;
7732
- if (this.staticMedia[String(Number(offset) + 20)]) {
7733
- hasMore = true;
7734
- }
7735
- if (options.directory) {
7736
- let depth = 0;
7737
- const pathToDirectory = options.directory.split("/");
7738
- let currentFolder = media;
7739
- let hasMore2 = false;
7740
- while (depth < pathToDirectory.length) {
7741
- const nextFolder = currentFolder.find(
7742
- (item) => item.type === "dir" && item.filename === pathToDirectory[depth]
7743
- );
7744
- if (nextFolder) {
7745
- const offset2 = options.offset || 0;
7746
- currentFolder = nextFolder.children[String(offset2)];
7747
- if (nextFolder.children[String(Number(offset2) + 20)]) {
7748
- hasMore2 = true;
7749
- }
7750
- }
7751
- depth++;
7752
- }
7753
- return {
7754
- items: currentFolder,
7755
- nextOffset: hasMore2 ? Number(offset) + 20 : null
7756
- };
7757
- }
7758
- return { items: media, nextOffset: hasMore ? Number(offset) + 20 : null };
7759
- }
7760
7861
  return {
7761
7862
  items,
7762
7863
  nextOffset: cursor || 0
@@ -8422,6 +8523,9 @@ var __publicField = (obj, key, value) => {
8422
8523
  function ImFilesEmpty(props) {
8423
8524
  return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 16 16" }, "child": [{ "tag": "path", "attr": { "d": "M14.341 5.579c-0.347-0.473-0.831-1.027-1.362-1.558s-1.085-1.015-1.558-1.362c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.689 0.561 1.25 1.25 1.25h9.5c0.689 0 1.25-0.561 1.25-1.25v-7.75c0-0.224-0.068-0.615-0.659-1.421zM12.271 4.729c0.48 0.48 0.856 0.912 1.134 1.271h-2.406v-2.405c0.359 0.278 0.792 0.654 1.271 1.134v0zM14 14.75c0 0.136-0.114 0.25-0.25 0.25h-9.5c-0.136 0-0.25-0.114-0.25-0.25v-11.5c0-0.135 0.114-0.25 0.25-0.25 0 0 5.749-0 5.75 0v3.5c0 0.276 0.224 0.5 0.5 0.5h3.5v7.75z" } }, { "tag": "path", "attr": { "d": "M9.421 0.659c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.604 0.43 1.109 1 1.225v-12.725c0-0.135 0.115-0.25 0.25-0.25h7.607c-0.151-0.124-0.297-0.238-0.437-0.341z" } }] })(props);
8424
8525
  }
8526
+ function ImUsers(props) {
8527
+ return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 18 16" }, "child": [{ "tag": "path", "attr": { "d": "M12 12.041v-0.825c1.102-0.621 2-2.168 2-3.716 0-2.485 0-4.5-3-4.5s-3 2.015-3 4.5c0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h14c0-2.015-2.608-3.682-6-3.959z" } }, { "tag": "path", "attr": { "d": "M5.112 12.427c0.864-0.565 1.939-0.994 3.122-1.256-0.235-0.278-0.449-0.588-0.633-0.922-0.475-0.863-0.726-1.813-0.726-2.748 0-1.344 0-2.614 0.478-3.653 0.464-1.008 1.299-1.633 2.488-1.867-0.264-1.195-0.968-1.98-2.841-1.98-3 0-3 2.015-3 4.5 0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h4.359c0.227-0.202 0.478-0.393 0.753-0.573z" } }] })(props);
8528
+ }
8425
8529
  const LocalWarning = () => {
8426
8530
  return /* @__PURE__ */ React__namespace.createElement(
8427
8531
  "a",
@@ -8509,10 +8613,10 @@ var __publicField = (obj, key, value) => {
8509
8613
  const [error, setError] = React.useState(void 0);
8510
8614
  React__namespace.useEffect(() => {
8511
8615
  const fetchEvents = async () => {
8512
- var _a, _b, _c, _d;
8616
+ var _a, _b, _c, _d, _e;
8513
8617
  let doFetchEvents = false;
8514
8618
  if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi)) {
8515
- doFetchEvents = await ((_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isAuthenticated());
8619
+ doFetchEvents = await ((_e = (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.authProvider) == null ? void 0 : _e.isAuthenticated());
8516
8620
  }
8517
8621
  if (doFetchEvents) {
8518
8622
  try {
@@ -8671,17 +8775,40 @@ var __publicField = (obj, key, value) => {
8671
8775
  RenderNavSite,
8672
8776
  RenderNavCloud,
8673
8777
  RenderNavCollection,
8778
+ AuthRenderNavCollection,
8674
8779
  ...props
8675
8780
  }) => {
8676
8781
  const cms = useCMS$1();
8677
8782
  const { setEdit } = sharedctx.useEditState();
8678
8783
  const [eventsOpen, setEventsOpen] = React__namespace.useState(false);
8784
+ const { contentCollections, authCollection } = collectionsInfo.collections.reduce(
8785
+ (acc, collection) => {
8786
+ if (collection.isAuthCollection) {
8787
+ acc.authCollection = collection;
8788
+ } else {
8789
+ acc.contentCollections.push(collection);
8790
+ }
8791
+ return acc;
8792
+ },
8793
+ {
8794
+ contentCollections: []
8795
+ }
8796
+ );
8679
8797
  function closeEventsModal() {
8680
8798
  setEventsOpen(false);
8681
8799
  }
8682
8800
  const WrappedSyncStatus = React__namespace.forwardRef(
8683
8801
  (props2, ref) => /* @__PURE__ */ React__namespace.createElement(SyncStatus, { ...props2 })
8684
8802
  );
8803
+ const screenCategories = screens.reduce(
8804
+ (acc, screen) => {
8805
+ const category = screen.navCategory || "Site";
8806
+ acc[category] = acc[category] || [];
8807
+ acc[category].push(screen);
8808
+ return acc;
8809
+ },
8810
+ { Site: [] }
8811
+ );
8685
8812
  return /* @__PURE__ */ React__namespace.createElement(
8686
8813
  "div",
8687
8814
  {
@@ -8727,18 +8854,21 @@ var __publicField = (obj, key, value) => {
8727
8854
  {
8728
8855
  className: `text-lg px-4 py-2 first:pt-3 last:pb-3 tracking-wide whitespace-nowrap flex items-center opacity-80 text-gray-600 hover:text-blue-400 hover:bg-gray-50 hover:opacity-100`,
8729
8856
  onClick: async () => {
8730
- var _a, _b, _c, _d, _e, _f;
8857
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8731
8858
  updateBodyDisplacement({
8732
8859
  displayState: "closed",
8733
8860
  sidebarWidth: null,
8734
8861
  resizingSidebar: false
8735
8862
  });
8736
8863
  try {
8737
- if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
8738
- await cms.api.tina.logout();
8739
- if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
8740
- await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
8864
+ if ((_c = (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.authProvider) == null ? void 0 : _c.logout) {
8865
+ await ((_d = cms.api.tina) == null ? void 0 : _d.authProvider.logout());
8866
+ if ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout) {
8867
+ await ((_h = (_g = cms == null ? void 0 : cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.onLogout());
8741
8868
  }
8869
+ window.location.href = new URL(
8870
+ window.location.href
8871
+ ).pathname;
8742
8872
  }
8743
8873
  setEdit(false);
8744
8874
  } catch (e) {
@@ -8771,13 +8901,25 @@ var __publicField = (obj, key, value) => {
8771
8901
  CollectionsList,
8772
8902
  {
8773
8903
  RenderNavCollection,
8774
- ...collectionsInfo
8904
+ collections: contentCollections
8775
8905
  }
8776
- )), (screens.length > 0 || contentCreators.length) > 0 && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Site"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, screens.map((view) => {
8906
+ )), (screenCategories.Site.length > 0 || contentCreators.length) > 0 && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Site"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, screenCategories.Site.map((view) => {
8777
8907
  return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavSite, { view }));
8778
8908
  }), contentCreators.map((plugin, idx) => {
8779
8909
  return /* @__PURE__ */ React__namespace.createElement(CreateContentNavItem, { key: `plugin-${idx}`, plugin });
8780
- }))), !!(cloudConfigs == null ? void 0 : cloudConfigs.length) && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Cloud"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, cloudConfigs.map((config) => {
8910
+ }), authCollection && /* @__PURE__ */ React__namespace.createElement(
8911
+ CollectionsList,
8912
+ {
8913
+ RenderNavCollection: AuthRenderNavCollection,
8914
+ collections: [authCollection]
8915
+ }
8916
+ ))), Object.entries(screenCategories).map(([category, screens2]) => {
8917
+ if (category !== "Site") {
8918
+ return /* @__PURE__ */ React__namespace.createElement("div", { key: category }, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, category), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, screens2.map((view) => {
8919
+ return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavSite, { view }));
8920
+ })));
8921
+ }
8922
+ }), !!(cloudConfigs == null ? void 0 : cloudConfigs.length) && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Cloud"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, cloudConfigs.map((config) => {
8781
8923
  return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${config.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavCloud, { config }));
8782
8924
  }))))
8783
8925
  );
@@ -8934,6 +9076,12 @@ var __publicField = (obj, key, value) => {
8934
9076
  const [activeScreen, setActiveView] = React.useState(null);
8935
9077
  const [sidebarWidth, setSidebarWidth] = React__namespace.useState(defaultWidth);
8936
9078
  const [formIsPristine, setFormIsPristine] = React__namespace.useState(true);
9079
+ const activeScreens = allScreens.filter(
9080
+ (screen) => {
9081
+ var _a2, _b2;
9082
+ return screen.navCategory !== "Account" || ((_b2 = (_a2 = cms.api.tina) == null ? void 0 : _a2.authProvider) == null ? void 0 : _b2.getLoginStrategy()) === "UsernamePassword";
9083
+ }
9084
+ );
8937
9085
  const setDisplayState = (value) => cms.dispatch({ type: "sidebar:set-display-state", value });
8938
9086
  const displayState = cms.state.sidebarDisplayState;
8939
9087
  React__namespace.useEffect(() => {
@@ -9029,7 +9177,7 @@ var __publicField = (obj, key, value) => {
9029
9177
  isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode,
9030
9178
  showCollections: isTinaAdminEnabled,
9031
9179
  collectionsInfo,
9032
- screens: allScreens,
9180
+ screens: activeScreens,
9033
9181
  cloudConfigs: allConfigs,
9034
9182
  contentCreators,
9035
9183
  sidebarWidth,
@@ -9052,6 +9200,16 @@ var __publicField = (obj, key, value) => {
9052
9200
  },
9053
9201
  collection
9054
9202
  }
9203
+ ),
9204
+ AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React__namespace.createElement(
9205
+ SidebarCollectionLink,
9206
+ {
9207
+ onClick: () => {
9208
+ setMenuIsOpen(false);
9209
+ },
9210
+ collection,
9211
+ Icon: ImUsers
9212
+ }
9055
9213
  )
9056
9214
  }
9057
9215
  ), /* @__PURE__ */ React__namespace.createElement(SidebarBody, null, /* @__PURE__ */ React__namespace.createElement(
@@ -9086,7 +9244,7 @@ var __publicField = (obj, key, value) => {
9086
9244
  className: "rounded-r-md",
9087
9245
  showCollections: isTinaAdminEnabled,
9088
9246
  collectionsInfo,
9089
- screens: allScreens,
9247
+ screens: activeScreens,
9090
9248
  cloudConfigs: allConfigs,
9091
9249
  contentCreators,
9092
9250
  sidebarWidth,
@@ -9109,6 +9267,16 @@ var __publicField = (obj, key, value) => {
9109
9267
  },
9110
9268
  collection
9111
9269
  }
9270
+ ),
9271
+ AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React__namespace.createElement(
9272
+ SidebarCollectionLink,
9273
+ {
9274
+ onClick: () => {
9275
+ setMenuIsOpen(false);
9276
+ },
9277
+ collection,
9278
+ Icon: ImUsers
9279
+ }
9112
9280
  )
9113
9281
  },
9114
9282
  /* @__PURE__ */ React__namespace.createElement("div", { className: "absolute top-8 right-0 transform translate-x-full overflow-hidden" }, /* @__PURE__ */ React__namespace.createElement(
@@ -9270,6 +9438,7 @@ var __publicField = (obj, key, value) => {
9270
9438
  return /* @__PURE__ */ React__namespace.createElement("span", { className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100" }, /* @__PURE__ */ React__namespace.createElement(config.Icon, { className: "mr-2 h-6 opacity-80 w-auto" }), /* @__PURE__ */ React__namespace.createElement("a", { target: "_blank", href: config.link.href }, config.link.text));
9271
9439
  };
9272
9440
  const SidebarCollectionLink = ({
9441
+ Icon = ImFilesEmpty,
9273
9442
  collection,
9274
9443
  onClick
9275
9444
  }) => {
@@ -9282,7 +9451,7 @@ var __publicField = (obj, key, value) => {
9282
9451
  href: `${tinaPreview ? `/${tinaPreview}/index.html#` : "/admin#"}/collections/${collection.name}/~`,
9283
9452
  className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100"
9284
9453
  },
9285
- /* @__PURE__ */ React__namespace.createElement(ImFilesEmpty, { className: "mr-2 h-6 opacity-80 w-auto" }),
9454
+ /* @__PURE__ */ React__namespace.createElement(Icon, { className: "mr-2 h-6 opacity-80 w-auto" }),
9286
9455
  " ",
9287
9456
  collection.label ? collection.label : collection.name
9288
9457
  );
@@ -9998,7 +10167,9 @@ var __publicField = (obj, key, value) => {
9998
10167
  setSyncStatus(project.mediaBranch ? "synced" : "needs-sync");
9999
10168
  }
10000
10169
  };
10001
- checkSyncStatus();
10170
+ if (!cms.media.store.isStatic) {
10171
+ checkSyncStatus();
10172
+ }
10002
10173
  }, []);
10003
10174
  return syncStatus == "needs-sync" ? /* @__PURE__ */ React.createElement("div", { className: "h-full flex items-center justify-center p-6 bg-gradient-to-t from-gray-200 to-transparent" }, /* @__PURE__ */ React.createElement("div", { className: "rounded-lg border shadow-sm px-4 lg:px-6 py-3 lg:py-4 bg-gradient-to-r from-yellow-50 to-yellow-100 border-yellow-200 mx-auto mb-12" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-start sm:items-center gap-2" }, /* @__PURE__ */ React.createElement(
10004
10175
  BiError,
@@ -10088,6 +10259,108 @@ var __publicField = (obj, key, value) => {
10088
10259
  allowDelete: true
10089
10260
  }
10090
10261
  });
10262
+ function UpdatePassword(props) {
10263
+ const cms = useCMS$1();
10264
+ const client = cms.api.tina;
10265
+ const [password, setPassword] = React.useState("");
10266
+ const [confirmPassword, setConfirmPassword] = React.useState("");
10267
+ const [dirty, setDirty] = React.useState(false);
10268
+ const [result, setResult] = React.useState(null);
10269
+ const [formState, setFormState] = React.useState("idle");
10270
+ const [passwordChangeRequired, setPasswordChangeRequired] = React.useState(false);
10271
+ React.useEffect(() => {
10272
+ var _a;
10273
+ (_a = client == null ? void 0 : client.authProvider) == null ? void 0 : _a.getUser().then(
10274
+ (user) => setPasswordChangeRequired((user == null ? void 0 : user.passwordChangeRequired) ?? false)
10275
+ );
10276
+ }, []);
10277
+ let err = null;
10278
+ if (dirty && password !== confirmPassword) {
10279
+ err = "Passwords do not match";
10280
+ }
10281
+ if (dirty && !password) {
10282
+ err = "Please enter a password";
10283
+ }
10284
+ const updatePassword = async () => {
10285
+ var _a;
10286
+ setResult(null);
10287
+ setFormState("busy");
10288
+ const res = await cms.api.tina.request(
10289
+ `mutation($password: String!) { updatePassword(password: $password) }`,
10290
+ {
10291
+ variables: {
10292
+ password
10293
+ }
10294
+ }
10295
+ );
10296
+ if (!(res == null ? void 0 : res.updatePassword)) {
10297
+ setResult("Error updating password");
10298
+ } else {
10299
+ setDirty(false);
10300
+ setPassword("");
10301
+ setConfirmPassword("");
10302
+ setResult("Password updated");
10303
+ setPasswordChangeRequired(false);
10304
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
10305
+ (_a = client == null ? void 0 : client.authProvider) == null ? void 0 : _a.logout().then(async () => {
10306
+ if (typeof (client == null ? void 0 : client.onLogout) === "function") {
10307
+ await client.onLogout();
10308
+ }
10309
+ window.location.href = new URL(window.location.href).pathname;
10310
+ }).catch((e) => console.error(e));
10311
+ }
10312
+ setFormState("idle");
10313
+ };
10314
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex justify-center items-center h-full" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-col space-y-8 p-6" }, passwordChangeRequired && /* @__PURE__ */ React.createElement("div", { className: "text-center text-red-500" }, "Your password has expired. Please update your password."), /* @__PURE__ */ React.createElement("label", { className: "block" }, /* @__PURE__ */ React.createElement("span", { className: "text-gray-700" }, "New Password"), /* @__PURE__ */ React.createElement(
10315
+ BaseTextField,
10316
+ {
10317
+ type: "password",
10318
+ name: "password",
10319
+ id: "password",
10320
+ placeholder: "Enter password",
10321
+ className: err ? "border-red-500" : "border-gray-300 focus:ring-indigo-500 focus:border-indigo-500",
10322
+ value: password,
10323
+ onKeyDown: () => {
10324
+ setDirty(true);
10325
+ setResult(null);
10326
+ },
10327
+ onChange: (e) => setPassword(e.target.value),
10328
+ required: true
10329
+ }
10330
+ )), /* @__PURE__ */ React.createElement("label", { className: "block" }, /* @__PURE__ */ React.createElement("span", { className: "text-gray-700" }, "Confirm New Password"), /* @__PURE__ */ React.createElement(
10331
+ BaseTextField,
10332
+ {
10333
+ type: "password",
10334
+ name: "confirmPassword",
10335
+ id: "confirmPassword",
10336
+ placeholder: "Confirm password",
10337
+ className: err ? "border-red-500" : "border-gray-300 focus:ring-indigo-500 focus:border-indigo-500",
10338
+ value: confirmPassword,
10339
+ onKeyDown: () => {
10340
+ setDirty(true);
10341
+ setResult(null);
10342
+ },
10343
+ onChange: (e) => setConfirmPassword(e.target.value),
10344
+ required: true
10345
+ }
10346
+ )), result && /* @__PURE__ */ React.createElement("div", { className: "text-center text-sm text-gray-500" }, result), err && /* @__PURE__ */ React.createElement("div", { className: "text-center text-sm text-red-500" }, err), /* @__PURE__ */ React.createElement(
10347
+ Button,
10348
+ {
10349
+ onClick: updatePassword,
10350
+ disabled: err,
10351
+ variant: "primary",
10352
+ busy: formState === "busy"
10353
+ },
10354
+ "Update"
10355
+ ))));
10356
+ }
10357
+ const PasswordScreenPlugin = createScreen({
10358
+ name: "Change Password",
10359
+ Component: UpdatePassword,
10360
+ Icon: MdVpnKey,
10361
+ layout: "fullscreen",
10362
+ navCategory: "Account"
10363
+ });
10091
10364
  function createCloudConfig({
10092
10365
  ...options
10093
10366
  }) {
@@ -10117,7 +10390,8 @@ var __publicField = (obj, key, value) => {
10117
10390
  CheckboxGroupFieldPlugin,
10118
10391
  ReferenceFieldPlugin,
10119
10392
  ButtonToggleFieldPlugin,
10120
- HiddenFieldPlugin
10393
+ HiddenFieldPlugin,
10394
+ PasswordFieldPlugin
10121
10395
  ];
10122
10396
  class TinaCMS extends CMS {
10123
10397
  constructor({
@@ -10156,6 +10430,7 @@ var __publicField = (obj, key, value) => {
10156
10430
  }
10157
10431
  });
10158
10432
  this.plugins.add(MediaManagerScreenPlugin);
10433
+ this.plugins.add(PasswordScreenPlugin);
10159
10434
  if (isLocalClient !== true) {
10160
10435
  if (clientId) {
10161
10436
  this.plugins.add(
@@ -26385,25 +26660,6 @@ var __publicField = (obj, key, value) => {
26385
26660
  };
26386
26661
  }
26387
26662
  };
26388
- const captureBranchName = /^refs\/heads\/(.*)/;
26389
- const parseRefForBranchName = (ref) => {
26390
- const matches = ref.match(captureBranchName);
26391
- return matches[1];
26392
- };
26393
- const ListBranchResponse = zod.z.object({
26394
- name: zod.z.string(),
26395
- protected: zod.z.boolean().optional().default(false),
26396
- githubPullRequestUrl: zod.z.string().optional()
26397
- }).array().nonempty();
26398
- const IndexStatusResponse = zod.z.object({
26399
- status: zod.z.union([
26400
- zod.z.literal("complete"),
26401
- zod.z.literal("unknown"),
26402
- zod.z.literal("failed"),
26403
- zod.z.literal("inprogress")
26404
- ]).optional(),
26405
- timestamp: zod.z.number().optional()
26406
- });
26407
26663
  function asyncPoll(fn, pollInterval = 5 * 1e3, pollTimeout = 30 * 1e3) {
26408
26664
  const endTime = (/* @__PURE__ */ new Date()).getTime() + pollTimeout;
26409
26665
  let stop = false;
@@ -26428,24 +26684,266 @@ var __publicField = (obj, key, value) => {
26428
26684
  };
26429
26685
  return [new Promise(checkCondition), cancel];
26430
26686
  }
26431
- class Client {
26432
- constructor({ tokenStorage = "MEMORY", ...options }) {
26433
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X;
26434
- this.events = new EventBus();
26435
- this.protectedBranches = [];
26436
- this.usingEditorialWorkflow = false;
26437
- this.addPendingContent = async (props) => {
26438
- const mutation = `#graphql
26439
- mutation addPendingDocumentMutation(
26440
- $relativePath: String!
26441
- $collection: String!
26442
- $template: String
26443
- ) {
26444
- addPendingDocument(
26445
- relativePath: $relativePath
26446
- template: $template
26447
- collection: $collection
26448
- ) {
26687
+ function popupWindow(url, title, window2, w, h) {
26688
+ const y = window2.top.outerHeight / 2 + window2.top.screenY - h / 2;
26689
+ const x = window2.top.outerWidth / 2 + window2.top.screenX - w / 2;
26690
+ return window2.open(
26691
+ url,
26692
+ title,
26693
+ "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", top=" + y + ", left=" + x
26694
+ );
26695
+ }
26696
+ const TINA_LOGIN_EVENT = "tinaCloudLogin";
26697
+ const AUTH_TOKEN_KEY = "tinacms-auth";
26698
+ const authenticate = (clientId, frontendUrl) => {
26699
+ return new Promise((resolve) => {
26700
+ let authTab;
26701
+ window.addEventListener("message", function(e) {
26702
+ if (e.data.source === TINA_LOGIN_EVENT) {
26703
+ if (authTab) {
26704
+ authTab.close();
26705
+ }
26706
+ resolve({
26707
+ id_token: e.data.id_token,
26708
+ access_token: e.data.access_token,
26709
+ refresh_token: e.data.refresh_token
26710
+ });
26711
+ }
26712
+ });
26713
+ const origin = `${window.location.protocol}//${window.location.host}`;
26714
+ authTab = popupWindow(
26715
+ `${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
26716
+ "_blank",
26717
+ window,
26718
+ 1e3,
26719
+ 700
26720
+ );
26721
+ });
26722
+ };
26723
+ const DefaultSessionProvider = ({
26724
+ children
26725
+ }) => /* @__PURE__ */ React.createElement(React.Fragment, null, children);
26726
+ class AbstractAuthProvider {
26727
+ /**
26728
+ * Wraps the normal fetch function with same API but adds the authorization header token.
26729
+ *
26730
+ * @example
26731
+ * const test = await tinaCloudClient.fetchWithToken(`/mycustomAPI/thing/one`) // the token will be passed in the authorization header
26732
+ *
26733
+ * @param input fetch function input
26734
+ * @param init fetch function init
26735
+ */
26736
+ async fetchWithToken(input, init) {
26737
+ const headers2 = (init == null ? void 0 : init.headers) || {};
26738
+ const token = await this.getToken();
26739
+ if (token == null ? void 0 : token.id_token) {
26740
+ headers2["Authorization"] = "Bearer " + (token == null ? void 0 : token.id_token);
26741
+ }
26742
+ return await fetch(input, {
26743
+ ...init || {},
26744
+ headers: new Headers(headers2)
26745
+ });
26746
+ }
26747
+ async authorize(context) {
26748
+ return this.getToken();
26749
+ }
26750
+ async isAuthorized(context) {
26751
+ return !!await this.authorize(context);
26752
+ }
26753
+ async isAuthenticated() {
26754
+ return !!await this.getUser();
26755
+ }
26756
+ getLoginStrategy() {
26757
+ return "Redirect";
26758
+ }
26759
+ getSessionProvider() {
26760
+ return DefaultSessionProvider;
26761
+ }
26762
+ }
26763
+ class TinaCloudAuthProvider extends AbstractAuthProvider {
26764
+ constructor({
26765
+ clientId,
26766
+ identityApiUrl,
26767
+ tokenStorage = "MEMORY",
26768
+ frontendUrl,
26769
+ ...options
26770
+ }) {
26771
+ super();
26772
+ this.frontendUrl = frontendUrl;
26773
+ this.clientId = clientId;
26774
+ this.identityApiUrl = identityApiUrl;
26775
+ switch (tokenStorage) {
26776
+ case "LOCAL_STORAGE":
26777
+ this.getToken = async function() {
26778
+ const tokens = localStorage.getItem(AUTH_TOKEN_KEY) || null;
26779
+ if (tokens) {
26780
+ return await this.getRefreshedToken(tokens);
26781
+ } else {
26782
+ return {
26783
+ access_token: null,
26784
+ id_token: null,
26785
+ refresh_token: null
26786
+ };
26787
+ }
26788
+ };
26789
+ this.setToken = function(token) {
26790
+ localStorage.setItem(AUTH_TOKEN_KEY, JSON.stringify(token, null, 2));
26791
+ };
26792
+ break;
26793
+ case "MEMORY":
26794
+ this.getToken = async () => {
26795
+ if (this.token) {
26796
+ return await this.getRefreshedToken(this.token);
26797
+ } else {
26798
+ return {
26799
+ access_token: null,
26800
+ id_token: null,
26801
+ refresh_token: null
26802
+ };
26803
+ }
26804
+ };
26805
+ this.setToken = (token) => {
26806
+ this.token = JSON.stringify(token, null, 2);
26807
+ };
26808
+ break;
26809
+ case "CUSTOM":
26810
+ if (!options.getTokenFn) {
26811
+ throw new Error(
26812
+ "When CUSTOM token storage is selected, a getTokenFn must be provided"
26813
+ );
26814
+ }
26815
+ this.getToken = options.getTokenFn;
26816
+ break;
26817
+ }
26818
+ }
26819
+ async authenticate() {
26820
+ const token = await authenticate(this.clientId, this.frontendUrl);
26821
+ this.setToken(token);
26822
+ return token;
26823
+ }
26824
+ async getUser() {
26825
+ if (!this.clientId) {
26826
+ return null;
26827
+ }
26828
+ const url = `${this.identityApiUrl}/v2/apps/${this.clientId}/currentUser`;
26829
+ try {
26830
+ const res = await this.fetchWithToken(url, {
26831
+ method: "GET"
26832
+ });
26833
+ const val = await res.json();
26834
+ if (!res.status.toString().startsWith("2")) {
26835
+ console.error(val.error);
26836
+ return null;
26837
+ }
26838
+ return val;
26839
+ } catch (e) {
26840
+ console.error(e);
26841
+ return null;
26842
+ }
26843
+ }
26844
+ async logout() {
26845
+ this.setToken(null);
26846
+ }
26847
+ async getRefreshedToken(tokens) {
26848
+ const { access_token, id_token, refresh_token } = JSON.parse(tokens);
26849
+ const { exp, iss, client_id } = this.parseJwt(access_token);
26850
+ if (Date.now() / 1e3 >= exp - 120) {
26851
+ const refreshResponse = await fetch(iss, {
26852
+ method: "POST",
26853
+ headers: {
26854
+ "Content-Type": "application/x-amz-json-1.1",
26855
+ "x-amz-target": "AWSCognitoIdentityProviderService.InitiateAuth"
26856
+ },
26857
+ body: JSON.stringify({
26858
+ ClientId: client_id,
26859
+ AuthFlow: "REFRESH_TOKEN_AUTH",
26860
+ AuthParameters: {
26861
+ REFRESH_TOKEN: refresh_token,
26862
+ DEVICE_KEY: null
26863
+ }
26864
+ })
26865
+ });
26866
+ if (refreshResponse.status !== 200) {
26867
+ throw new Error("Unable to refresh auth tokens");
26868
+ }
26869
+ const responseJson = await refreshResponse.json();
26870
+ const newToken = {
26871
+ access_token: responseJson.AuthenticationResult.AccessToken,
26872
+ id_token: responseJson.AuthenticationResult.IdToken,
26873
+ refresh_token
26874
+ };
26875
+ this.setToken(newToken);
26876
+ return Promise.resolve(newToken);
26877
+ }
26878
+ return Promise.resolve({ access_token, id_token, refresh_token });
26879
+ }
26880
+ parseJwt(token) {
26881
+ const base64Url = token.split(".")[1];
26882
+ const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
26883
+ const jsonPayload = decodeURIComponent(
26884
+ atob(base64).split("").map(function(c) {
26885
+ return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
26886
+ }).join("")
26887
+ );
26888
+ return JSON.parse(jsonPayload);
26889
+ }
26890
+ }
26891
+ const LOCAL_CLIENT_KEY = "tina.local.isLogedIn";
26892
+ class LocalAuthProvider extends AbstractAuthProvider {
26893
+ constructor() {
26894
+ super();
26895
+ }
26896
+ async authenticate() {
26897
+ localStorage.setItem(LOCAL_CLIENT_KEY, "true");
26898
+ return { access_token: "LOCAL", id_token: "LOCAL", refresh_token: "LOCAL" };
26899
+ }
26900
+ async getUser() {
26901
+ return localStorage.getItem(LOCAL_CLIENT_KEY) === "true";
26902
+ }
26903
+ async getToken() {
26904
+ return Promise.resolve({ id_token: "" });
26905
+ }
26906
+ async logout() {
26907
+ localStorage.removeItem(LOCAL_CLIENT_KEY);
26908
+ }
26909
+ }
26910
+ const captureBranchName = /^refs\/heads\/(.*)/;
26911
+ const parseRefForBranchName = (ref) => {
26912
+ const matches = ref.match(captureBranchName);
26913
+ return matches[1];
26914
+ };
26915
+ const ListBranchResponse = zod.z.object({
26916
+ name: zod.z.string(),
26917
+ protected: zod.z.boolean().optional().default(false),
26918
+ githubPullRequestUrl: zod.z.string().optional()
26919
+ }).array().nonempty();
26920
+ const IndexStatusResponse = zod.z.object({
26921
+ status: zod.z.union([
26922
+ zod.z.literal("complete"),
26923
+ zod.z.literal("unknown"),
26924
+ zod.z.literal("failed"),
26925
+ zod.z.literal("inprogress")
26926
+ ]).optional(),
26927
+ timestamp: zod.z.number().optional()
26928
+ });
26929
+ class Client {
26930
+ constructor({ tokenStorage = "MEMORY", ...options }) {
26931
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
26932
+ this.events = new EventBus();
26933
+ this.protectedBranches = [];
26934
+ this.usingEditorialWorkflow = false;
26935
+ this.addPendingContent = async (props) => {
26936
+ const mutation = `#graphql
26937
+ mutation addPendingDocumentMutation(
26938
+ $relativePath: String!
26939
+ $collection: String!
26940
+ $template: String
26941
+ ) {
26942
+ addPendingDocument(
26943
+ relativePath: $relativePath
26944
+ template: $template
26945
+ collection: $collection
26946
+ ) {
26449
26947
  ... on Document {
26450
26948
  _sys {
26451
26949
  relativePath
@@ -26484,20 +26982,8 @@ mutation addPendingDocumentMutation(
26484
26982
  return graphql.parse(data.getOptimizedQuery);
26485
26983
  };
26486
26984
  this.tinaGraphQLVersion = options.tinaGraphQLVersion;
26487
- this.onLogin = (_d = (_c = (_b = (_a = options.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.auth) == null ? void 0 : _d.onLogin;
26488
- this.onLogout = (_h = (_g = (_f = (_e = options.schema) == null ? void 0 : _e.config) == null ? void 0 : _f.admin) == null ? void 0 : _g.auth) == null ? void 0 : _h.onLogout;
26489
- if ((_l = (_k = (_j = (_i = options.schema) == null ? void 0 : _i.config) == null ? void 0 : _j.admin) == null ? void 0 : _k.auth) == null ? void 0 : _l.logout) {
26490
- this.onLogout = (_p = (_o = (_n = (_m = options.schema) == null ? void 0 : _m.config) == null ? void 0 : _n.admin) == null ? void 0 : _o.auth) == null ? void 0 : _p.logout;
26491
- }
26492
- if ((_t = (_s = (_r = (_q = options.schema) == null ? void 0 : _q.config) == null ? void 0 : _r.admin) == null ? void 0 : _s.auth) == null ? void 0 : _t.getUser) {
26493
- this.getUser = (_x = (_w = (_v = (_u = options.schema) == null ? void 0 : _u.config) == null ? void 0 : _v.admin) == null ? void 0 : _w.auth) == null ? void 0 : _x.getUser;
26494
- }
26495
- if ((_B = (_A = (_z = (_y = options.schema) == null ? void 0 : _y.config) == null ? void 0 : _z.admin) == null ? void 0 : _A.auth) == null ? void 0 : _B.authenticate) {
26496
- this.authenticate = (_F = (_E = (_D = (_C = options.schema) == null ? void 0 : _C.config) == null ? void 0 : _D.admin) == null ? void 0 : _E.auth) == null ? void 0 : _F.authenticate;
26497
- }
26498
- if ((_J = (_I = (_H = (_G = options.schema) == null ? void 0 : _G.config) == null ? void 0 : _H.admin) == null ? void 0 : _I.auth) == null ? void 0 : _J.authorize) {
26499
- this.authorize = (_N = (_M = (_L = (_K = options.schema) == null ? void 0 : _K.config) == null ? void 0 : _L.admin) == null ? void 0 : _M.auth) == null ? void 0 : _N.authorize;
26500
- }
26985
+ this.onLogin = ((_d = (_c = (_b = (_a = options.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.authHooks) == null ? void 0 : _d.onLogin) || ((_h = (_g = (_f = (_e = options.schema) == null ? void 0 : _e.config) == null ? void 0 : _f.admin) == null ? void 0 : _g.auth) == null ? void 0 : _h.onLogin);
26986
+ this.onLogout = ((_l = (_k = (_j = (_i = options.schema) == null ? void 0 : _i.config) == null ? void 0 : _j.admin) == null ? void 0 : _k.authHooks) == null ? void 0 : _l.onLogout) || ((_p = (_o = (_n = (_m = options.schema) == null ? void 0 : _m.config) == null ? void 0 : _n.admin) == null ? void 0 : _o.auth) == null ? void 0 : _p.onLogout);
26501
26987
  if (options.schema) {
26502
26988
  const enrichedSchema = new schemaTools.TinaSchema({
26503
26989
  version: { fullVersion: "", major: "", minor: "", patch: "" },
@@ -26507,7 +26993,7 @@ mutation addPendingDocumentMutation(
26507
26993
  this.schema = enrichedSchema;
26508
26994
  }
26509
26995
  this.options = options;
26510
- if ((_P = (_O = options.schema) == null ? void 0 : _O.config) == null ? void 0 : _P.contentApiUrlOverride) {
26996
+ if ((_r = (_q = options.schema) == null ? void 0 : _q.config) == null ? void 0 : _r.contentApiUrlOverride) {
26511
26997
  this.options.customContentApiUrl = options.schema.config.contentApiUrlOverride;
26512
26998
  }
26513
26999
  this.setBranch(options.branch);
@@ -26518,52 +27004,13 @@ mutation addPendingDocumentMutation(
26518
27004
  }
26519
27005
  );
26520
27006
  this.clientId = options.clientId;
26521
- switch (tokenStorage) {
26522
- case "LOCAL_STORAGE":
26523
- this.getToken = async function() {
26524
- const tokens = localStorage.getItem(AUTH_TOKEN_KEY) || null;
26525
- if (tokens) {
26526
- return await this.getRefreshedToken(tokens);
26527
- } else {
26528
- return {
26529
- access_token: null,
26530
- id_token: null,
26531
- refresh_token: null
26532
- };
26533
- }
26534
- };
26535
- this.setToken = function(token) {
26536
- localStorage.setItem(AUTH_TOKEN_KEY, JSON.stringify(token, null, 2));
26537
- };
26538
- break;
26539
- case "MEMORY":
26540
- this.getToken = async () => {
26541
- if (this.token) {
26542
- return await this.getRefreshedToken(this.token);
26543
- } else {
26544
- return {
26545
- access_token: null,
26546
- id_token: null,
26547
- refresh_token: null
26548
- };
26549
- }
26550
- };
26551
- this.setToken = (token) => {
26552
- this.token = JSON.stringify(token, null, 2);
26553
- };
26554
- break;
26555
- case "CUSTOM":
26556
- if (!options.getTokenFn) {
26557
- throw new Error(
26558
- "When CUSTOM token storage is selected, a getTokenFn must be provided"
26559
- );
26560
- }
26561
- this.getToken = options.getTokenFn;
26562
- break;
26563
- }
26564
- if ((_T = (_S = (_R = (_Q = options.schema) == null ? void 0 : _Q.config) == null ? void 0 : _R.admin) == null ? void 0 : _S.auth) == null ? void 0 : _T.getToken) {
26565
- this.getToken = (_X = (_W = (_V = (_U = options.schema) == null ? void 0 : _U.config) == null ? void 0 : _V.admin) == null ? void 0 : _W.auth) == null ? void 0 : _X.getToken;
26566
- }
27007
+ this.authProvider = ((_u = (_t = (_s = this.schema) == null ? void 0 : _s.config) == null ? void 0 : _t.config) == null ? void 0 : _u.authProvider) || new TinaCloudAuthProvider({
27008
+ clientId: options.clientId,
27009
+ identityApiUrl: this.identityApiUrl,
27010
+ getTokenFn: options.getTokenFn,
27011
+ tokenStorage,
27012
+ frontendUrl: this.frontendUrl
27013
+ });
26567
27014
  }
26568
27015
  get isLocalMode() {
26569
27016
  return false;
@@ -26580,12 +27027,16 @@ mutation addPendingDocumentMutation(
26580
27027
  this.identityApiUrl = ((_c = this.options.tinaioConfig) == null ? void 0 : _c.identityApiUrlOverride) || "https://identity.tinajs.io";
26581
27028
  this.contentApiBase = ((_d = this.options.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://content.tinajs.io`;
26582
27029
  this.contentApiUrl = this.options.customContentApiUrl || `${this.contentApiBase}/${this.tinaGraphQLVersion}/content/${this.options.clientId}/github/${encodedBranch}`;
27030
+ if (this.authProvider instanceof TinaCloudAuthProvider) {
27031
+ this.authProvider.identityApiUrl = this.identityApiUrl;
27032
+ this.authProvider.frontendUrl = this.frontendUrl;
27033
+ }
26583
27034
  }
26584
27035
  getBranch() {
26585
27036
  return this.branch;
26586
27037
  }
26587
27038
  async request(query, { variables }) {
26588
- const token = await this.getToken();
27039
+ const token = await this.authProvider.getToken();
26589
27040
  const headers2 = {
26590
27041
  "Content-Type": "application/json"
26591
27042
  };
@@ -26632,7 +27083,7 @@ mutation addPendingDocumentMutation(
26632
27083
  async checkSyncStatus({
26633
27084
  assetsSyncing
26634
27085
  }) {
26635
- const res = await this.fetchWithToken(
27086
+ const res = await this.authProvider.fetchWithToken(
26636
27087
  `${this.assetsApiUrl}/v1/${this.clientId}/syncStatus`,
26637
27088
  {
26638
27089
  method: "POST",
@@ -26646,7 +27097,7 @@ mutation addPendingDocumentMutation(
26646
27097
  return jsonRes;
26647
27098
  }
26648
27099
  async getProject() {
26649
- const res = await this.fetchWithToken(
27100
+ const res = await this.authProvider.fetchWithToken(
26650
27101
  `${this.identityApiUrl}/v2/apps/${this.clientId}`,
26651
27102
  {
26652
27103
  method: "GET"
@@ -26662,7 +27113,7 @@ mutation addPendingDocumentMutation(
26662
27113
  }) {
26663
27114
  const url = `${this.contentApiBase}/github/${this.clientId}/create_pull_request`;
26664
27115
  try {
26665
- const res = await this.fetchWithToken(url, {
27116
+ const res = await this.authProvider.fetchWithToken(url, {
26666
27117
  method: "POST",
26667
27118
  body: JSON.stringify({
26668
27119
  baseBranch,
@@ -26691,119 +27142,19 @@ mutation addPendingDocumentMutation(
26691
27142
  events: []
26692
27143
  };
26693
27144
  } else {
26694
- return (await this.fetchWithToken(
27145
+ return (await this.authProvider.fetchWithToken(
26695
27146
  `${this.contentApiBase}/events/${this.clientId}/${this.branch}?limit=${limit || 1}${cursor ? `&cursor=${cursor}` : ""}`,
26696
27147
  { method: "GET" }
26697
27148
  )).json();
26698
27149
  }
26699
27150
  }
26700
- parseJwt(token) {
26701
- const base64Url = token.split(".")[1];
26702
- const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
26703
- const jsonPayload = decodeURIComponent(
26704
- atob(base64).split("").map(function(c) {
26705
- return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
26706
- }).join("")
26707
- );
26708
- return JSON.parse(jsonPayload);
26709
- }
26710
- async getRefreshedToken(tokens) {
26711
- const { access_token, id_token, refresh_token } = JSON.parse(tokens);
26712
- const { exp, iss, client_id } = this.parseJwt(access_token);
26713
- if (Date.now() / 1e3 >= exp - 120) {
26714
- const refreshResponse = await fetch(iss, {
26715
- method: "POST",
26716
- headers: {
26717
- "Content-Type": "application/x-amz-json-1.1",
26718
- "x-amz-target": "AWSCognitoIdentityProviderService.InitiateAuth"
26719
- },
26720
- body: JSON.stringify({
26721
- ClientId: client_id,
26722
- AuthFlow: "REFRESH_TOKEN_AUTH",
26723
- AuthParameters: {
26724
- REFRESH_TOKEN: refresh_token,
26725
- DEVICE_KEY: null
26726
- }
26727
- })
26728
- });
26729
- if (refreshResponse.status !== 200) {
26730
- throw new Error("Unable to refresh auth tokens");
26731
- }
26732
- const responseJson = await refreshResponse.json();
26733
- const newToken = {
26734
- access_token: responseJson.AuthenticationResult.AccessToken,
26735
- id_token: responseJson.AuthenticationResult.IdToken,
26736
- refresh_token
26737
- };
26738
- this.setToken(newToken);
26739
- return Promise.resolve(newToken);
26740
- }
26741
- return Promise.resolve({ access_token, id_token, refresh_token });
26742
- }
26743
- async isAuthorized(context) {
26744
- return !!await this.authorize(context);
26745
- }
26746
- async isAuthenticated() {
26747
- return !!await this.getUser();
26748
- }
26749
- async logout() {
26750
- this.setToken(null);
26751
- }
26752
- async authenticate() {
26753
- const token = await authenticate(this.clientId, this.frontendUrl);
26754
- this.setToken(token);
26755
- return token;
26756
- }
26757
- async authorize(context) {
26758
- return this.getToken();
26759
- }
26760
- /**
26761
- * Wraps the normal fetch function with same API but adds the authorization header token.
26762
- *
26763
- * @example
26764
- * const test = await tinaCloudClient.fetchWithToken(`/mycustomAPI/thing/one`) // the token will be passed in the authorization header
26765
- *
26766
- * @param input fetch function input
26767
- * @param init fetch function init
26768
- */
26769
- async fetchWithToken(input, init) {
26770
- const headers2 = (init == null ? void 0 : init.headers) || {};
26771
- const token = await this.getToken();
26772
- if (token == null ? void 0 : token.id_token) {
26773
- headers2["Authorization"] = "Bearer " + (token == null ? void 0 : token.id_token);
26774
- }
26775
- return await fetch(input, {
26776
- ...init,
26777
- headers: new Headers(headers2)
26778
- });
26779
- }
26780
- async getUser() {
26781
- if (!this.clientId) {
26782
- return null;
26783
- }
26784
- const url = `${this.identityApiUrl}/v2/apps/${this.clientId}/currentUser`;
26785
- try {
26786
- const res = await this.fetchWithToken(url, {
26787
- method: "GET"
26788
- });
26789
- const val = await res.json();
26790
- if (!res.status.toString().startsWith("2")) {
26791
- console.error(val.error);
26792
- return null;
26793
- }
26794
- return val;
26795
- } catch (e) {
26796
- console.error(e);
26797
- return null;
26798
- }
26799
- }
26800
27151
  async getBillingState() {
26801
27152
  if (!this.clientId) {
26802
27153
  return null;
26803
27154
  }
26804
27155
  const url = `${this.identityApiUrl}/v2/apps/${this.clientId}/billing/state`;
26805
27156
  try {
26806
- const res = await this.fetchWithToken(url, {
27157
+ const res = await this.authProvider.fetchWithToken(url, {
26807
27158
  method: "GET"
26808
27159
  });
26809
27160
  const val = await res.json();
@@ -26869,7 +27220,7 @@ mutation addPendingDocumentMutation(
26869
27220
  }
26870
27221
  async getIndexStatus({ ref }) {
26871
27222
  const url = `${this.contentApiBase}/db/${this.clientId}/status/${ref}`;
26872
- const res = await this.fetchWithToken(url);
27223
+ const res = await this.authProvider.fetchWithToken(url);
26873
27224
  const result = await res.json();
26874
27225
  const parsedResult = IndexStatusResponse.parse(result);
26875
27226
  return parsedResult;
@@ -26877,7 +27228,7 @@ mutation addPendingDocumentMutation(
26877
27228
  async listBranches(args) {
26878
27229
  try {
26879
27230
  const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
26880
- const res = await this.fetchWithToken(url, {
27231
+ const res = await this.authProvider.fetchWithToken(url, {
26881
27232
  method: "GET"
26882
27233
  });
26883
27234
  const branches = await res.json();
@@ -26907,7 +27258,7 @@ mutation addPendingDocumentMutation(
26907
27258
  async createBranch({ baseBranch, branchName }) {
26908
27259
  const url = `${this.contentApiBase}/github/${this.clientId}/create_branch`;
26909
27260
  try {
26910
- const res = await this.fetchWithToken(url, {
27261
+ const res = await this.authProvider.fetchWithToken(url, {
26911
27262
  method: "POST",
26912
27263
  body: JSON.stringify({
26913
27264
  baseBranch,
@@ -26931,9 +27282,9 @@ mutation addPendingDocumentMutation(
26931
27282
  }
26932
27283
  }
26933
27284
  const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
26934
- const LOCAL_CLIENT_KEY = "tina.local.isLogedIn";
26935
27285
  class LocalClient extends Client {
26936
27286
  constructor(props) {
27287
+ var _a, _b, _c;
26937
27288
  const clientProps = {
26938
27289
  ...props,
26939
27290
  clientId: "",
@@ -26942,21 +27293,11 @@ mutation addPendingDocumentMutation(
26942
27293
  customContentApiUrl: props && props.customContentApiUrl ? props.customContentApiUrl : DEFAULT_LOCAL_TINA_GQL_SERVER_URL
26943
27294
  };
26944
27295
  super(clientProps);
27296
+ this.authProvider = ((_c = (_b = (_a = this.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.authProvider) || new LocalAuthProvider();
26945
27297
  }
26946
27298
  get isLocalMode() {
26947
27299
  return true;
26948
27300
  }
26949
- // These functions allow the local client to have a login state so that we can correctly call the "OnLogin" callback. This is important for things like preview mode
26950
- async logout() {
26951
- localStorage.removeItem(LOCAL_CLIENT_KEY);
26952
- }
26953
- async authenticate() {
26954
- localStorage.setItem(LOCAL_CLIENT_KEY, "true");
26955
- return { access_token: "LOCAL", id_token: "LOCAL", refresh_token: "LOCAL" };
26956
- }
26957
- async getUser() {
26958
- return localStorage.getItem(LOCAL_CLIENT_KEY) === "true";
26959
- }
26960
27301
  }
26961
27302
  class TinaCMSSearchClient {
26962
27303
  constructor(client, tinaSearchConfig) {
@@ -26971,13 +27312,13 @@ mutation addPendingDocumentMutation(
26971
27312
  );
26972
27313
  const opt = optionsToSearchIndexOptions(options);
26973
27314
  const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
26974
- const res = await this.client.fetchWithToken(
27315
+ const res = await this.client.authProvider.fetchWithToken(
26975
27316
  `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?q=${JSON.stringify(q)}${optionsParam}`
26976
27317
  );
26977
27318
  return parseSearchIndexResponse(await res.json(), options);
26978
27319
  }
26979
27320
  async del(ids) {
26980
- const res = await this.client.fetchWithToken(
27321
+ const res = await this.client.authProvider.fetchWithToken(
26981
27322
  `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?ids=${ids.join(",")}`,
26982
27323
  {
26983
27324
  method: "DELETE"
@@ -26988,7 +27329,7 @@ mutation addPendingDocumentMutation(
26988
27329
  }
26989
27330
  }
26990
27331
  async put(docs) {
26991
- const res = await this.client.fetchWithToken(
27332
+ const res = await this.client.authProvider.fetchWithToken(
26992
27333
  `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}`,
26993
27334
  {
26994
27335
  method: "POST",
@@ -27014,7 +27355,7 @@ mutation addPendingDocumentMutation(
27014
27355
  const q = queryToSearchIndexQuery(query);
27015
27356
  const opt = optionsToSearchIndexOptions(options);
27016
27357
  const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
27017
- const res = await this.client.fetchWithToken(
27358
+ const res = await this.client.authProvider.fetchWithToken(
27018
27359
  `http://localhost:4001/searchIndex?q=${JSON.stringify(q)}${optionsParam}`
27019
27360
  );
27020
27361
  return parseSearchIndexResponse(await res.json(), options);
@@ -27030,12 +27371,19 @@ mutation addPendingDocumentMutation(
27030
27371
  }
27031
27372
  }
27032
27373
  function ModalBuilder(modalProps) {
27033
- return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(ModalPopup, null, /* @__PURE__ */ React.createElement(ModalHeader, null, modalProps.title), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, modalProps.message), modalProps.error && /* @__PURE__ */ React.createElement(ErrorLabel, null, modalProps.error)), /* @__PURE__ */ React.createElement(ModalActions, null, modalProps.actions.map((action) => /* @__PURE__ */ React.createElement(AsyncButton, { key: action.name, ...action })))));
27374
+ return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(ModalPopup, null, /* @__PURE__ */ React.createElement(ModalHeader, null, modalProps.title), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, modalProps.message && /* @__PURE__ */ React.createElement("p", null, modalProps.message), modalProps.error && /* @__PURE__ */ React.createElement(ErrorLabel, null, modalProps.error), modalProps.children), /* @__PURE__ */ React.createElement(ModalActions, null, modalProps.actions.map((action) => /* @__PURE__ */ React.createElement(AsyncButton, { key: action.name, ...action })))));
27034
27375
  }
27035
27376
  const ErrorLabel = ({ style = {}, ...props }) => /* @__PURE__ */ React.createElement("p", { style: { ...style, color: "var(--tina-color-error)" }, ...props });
27036
27377
  const AsyncButton = ({ name, primary, action }) => {
27037
27378
  const [submitting, setSubmitting] = React.useState(false);
27379
+ const [mounted, setMounted] = React.useState(false);
27380
+ React.useEffect(() => {
27381
+ setMounted(true);
27382
+ return () => setMounted(false);
27383
+ }, []);
27038
27384
  const onClick = React.useCallback(async () => {
27385
+ if (!mounted)
27386
+ return;
27039
27387
  setSubmitting(true);
27040
27388
  try {
27041
27389
  await action();
@@ -27044,7 +27392,7 @@ mutation addPendingDocumentMutation(
27044
27392
  setSubmitting(false);
27045
27393
  throw e;
27046
27394
  }
27047
- }, [action, setSubmitting]);
27395
+ }, [action, setSubmitting, mounted]);
27048
27396
  return /* @__PURE__ */ React.createElement(
27049
27397
  Button,
27050
27398
  {
@@ -27120,7 +27468,7 @@ mutation addPendingDocumentMutation(
27120
27468
  }
27121
27469
  }
27122
27470
  async isAuthenticated() {
27123
- return await this.api.isAuthenticated();
27471
+ return await this.api.authProvider.isAuthenticated();
27124
27472
  }
27125
27473
  async checkGraphqlSchema({ localSchema }) {
27126
27474
  const schemaFromCloud = await this.api.getSchema();
@@ -27442,17 +27790,29 @@ mutation addPendingDocumentMutation(
27442
27790
  loginScreen,
27443
27791
  getModalActions
27444
27792
  }) => {
27445
- var _a, _b, _c, _d, _e;
27793
+ var _a, _b, _c;
27446
27794
  const client = cms.api.tina;
27447
- const isTinaCloud = !client.isLocalMode && !((_e = (_d = (_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.admin) == null ? void 0 : _d.auth) == null ? void 0 : _e.customAuth);
27795
+ const isTinaCloud = !client.isLocalMode && !((_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.contentApiUrlOverride);
27796
+ const loginStrategy = client.authProvider.getLoginStrategy();
27448
27797
  const [activeModal, setActiveModal] = React.useState(null);
27449
27798
  const [errorMessage, setErrorMessage] = React.useState();
27450
27799
  const [showChildren, setShowChildren] = React.useState(false);
27800
+ const [authProps, setAuthProps] = React.useState({ username: "", password: "" });
27801
+ const [authenticated, setAuthenticated] = React.useState(false);
27451
27802
  React.useEffect(() => {
27452
- client.isAuthenticated().then((isAuthenticated) => {
27803
+ let mounted = true;
27804
+ client.authProvider.isAuthenticated().then((isAuthenticated) => {
27805
+ if (!mounted)
27806
+ return;
27453
27807
  if (isAuthenticated) {
27454
- client.isAuthorized().then((isAuthorized) => {
27808
+ client.authProvider.isAuthorized().then(async (isAuthorized) => {
27809
+ if (!mounted)
27810
+ return;
27455
27811
  if (isAuthorized) {
27812
+ const user = await client.authProvider.getUser();
27813
+ if (user.passwordChangeRequired) {
27814
+ window.location.hash = "#/screens/change_password";
27815
+ }
27456
27816
  setShowChildren(true);
27457
27817
  cms.enable();
27458
27818
  } else {
@@ -27463,6 +27823,8 @@ mutation addPendingDocumentMutation(
27463
27823
  setActiveModal("error");
27464
27824
  }
27465
27825
  }).catch((e) => {
27826
+ if (!mounted)
27827
+ return;
27466
27828
  console.error(e);
27467
27829
  setErrorMessage({ title: "Unexpected Error:", message: `${e}` });
27468
27830
  setActiveModal("error");
@@ -27473,33 +27835,59 @@ mutation addPendingDocumentMutation(
27473
27835
  });
27474
27836
  }
27475
27837
  }).catch((e) => {
27838
+ if (!mounted)
27839
+ return;
27476
27840
  console.error(e);
27477
27841
  setErrorMessage({ title: "Unexpected Error:", message: `${e}` });
27478
27842
  setActiveModal("error");
27479
27843
  });
27480
- }, []);
27844
+ return () => {
27845
+ mounted = false;
27846
+ };
27847
+ }, [authenticated]);
27481
27848
  const onAuthenticated = async () => {
27482
- if (await client.isAuthorized()) {
27483
- setShowChildren(true);
27484
- setActiveModal(null);
27485
- cms.events.dispatch({ type: "cms:login" });
27486
- } else {
27487
- setErrorMessage({
27488
- title: "Access Denied:",
27489
- message: "Not Authorized To Edit"
27490
- });
27491
- setActiveModal("error");
27492
- }
27849
+ setAuthenticated(true);
27850
+ setActiveModal(null);
27851
+ cms.events.dispatch({ type: "cms:login" });
27493
27852
  };
27494
27853
  const otherModalActions = getModalActions ? getModalActions({
27495
27854
  closeModal: () => {
27496
27855
  setActiveModal(null);
27497
27856
  }
27498
27857
  }) : [];
27499
- return /* @__PURE__ */ React.createElement(React.Fragment, null, activeModal === "authenticate" && /* @__PURE__ */ React.createElement(
27858
+ const handleAuthenticate = async () => {
27859
+ try {
27860
+ setAuthenticated(false);
27861
+ const token = await client.authProvider.authenticate(authProps);
27862
+ if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27863
+ await (client == null ? void 0 : client.onLogin({ token }));
27864
+ }
27865
+ return onAuthenticated();
27866
+ } catch (e) {
27867
+ console.error(e);
27868
+ setActiveModal("error");
27869
+ setErrorMessage({
27870
+ title: "Authentication Error",
27871
+ message: `${e}`
27872
+ });
27873
+ }
27874
+ };
27875
+ let modalTitle = "Tina Cloud Authorization";
27876
+ if (activeModal === "authenticate" && loginStrategy === "Redirect" && !isTinaCloud) {
27877
+ modalTitle = "Enter into edit mode";
27878
+ } else if (activeModal === "authenticate" && loginStrategy === "UsernamePassword") {
27879
+ modalTitle = "Sign in to Tina";
27880
+ } else if (activeModal === "error") {
27881
+ if (loginStrategy === "Redirect" && !isTinaCloud) {
27882
+ modalTitle = "Enter into edit mode";
27883
+ } else if (loginStrategy === "UsernamePassword") {
27884
+ modalTitle = "Sign in to Tina";
27885
+ }
27886
+ }
27887
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, activeModal === "authenticate" && loginStrategy === "Redirect" && /* @__PURE__ */ React.createElement(
27500
27888
  ModalBuilder,
27501
27889
  {
27502
- title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
27890
+ title: modalTitle,
27503
27891
  message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get committed using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
27504
27892
  close,
27505
27893
  actions: [
@@ -27514,30 +27902,61 @@ mutation addPendingDocumentMutation(
27514
27902
  },
27515
27903
  {
27516
27904
  name: isTinaCloud ? "Continue to Tina Cloud" : "Enter Edit Mode",
27517
- action: async () => {
27518
- try {
27519
- const token = await client.authenticate();
27520
- if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27521
- await (client == null ? void 0 : client.onLogin({ token }));
27522
- }
27523
- return onAuthenticated();
27524
- } catch (e) {
27525
- console.error(e);
27526
- setActiveModal("error");
27527
- setErrorMessage({
27528
- title: "Unexpected Error:",
27529
- message: `${e}`
27530
- });
27531
- }
27532
- },
27905
+ action: handleAuthenticate,
27533
27906
  primary: true
27534
27907
  }
27535
27908
  ]
27536
27909
  }
27910
+ ), activeModal === "authenticate" && loginStrategy === "UsernamePassword" && /* @__PURE__ */ React.createElement(
27911
+ ModalBuilder,
27912
+ {
27913
+ title: modalTitle,
27914
+ message: "",
27915
+ close,
27916
+ actions: [
27917
+ ...otherModalActions,
27918
+ {
27919
+ name: "Login",
27920
+ action: handleAuthenticate,
27921
+ primary: true
27922
+ }
27923
+ ]
27924
+ },
27925
+ /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-center bg-gray-50 px-4 sm:px-6 lg:px-8" }, /* @__PURE__ */ React.createElement("div", { className: "max-w-md w-full space-y-6" }, /* @__PURE__ */ React.createElement("label", { className: "block" }, /* @__PURE__ */ React.createElement("span", { className: "text-gray-700" }, "Username"), /* @__PURE__ */ React.createElement(
27926
+ BaseTextField,
27927
+ {
27928
+ id: "username",
27929
+ name: "username",
27930
+ type: "text",
27931
+ autoComplete: "username",
27932
+ required: true,
27933
+ placeholder: "Username",
27934
+ value: authProps.username,
27935
+ onChange: (e) => setAuthProps((prevState) => ({
27936
+ ...prevState,
27937
+ username: e.target.value
27938
+ }))
27939
+ }
27940
+ )), /* @__PURE__ */ React.createElement("label", { className: "block" }, /* @__PURE__ */ React.createElement("span", { className: "text-gray-700" }, "Password"), /* @__PURE__ */ React.createElement(
27941
+ BaseTextField,
27942
+ {
27943
+ id: "password",
27944
+ name: "password",
27945
+ type: "password",
27946
+ autoComplete: "current-password",
27947
+ required: true,
27948
+ placeholder: "Password",
27949
+ value: authProps.password,
27950
+ onChange: (e) => setAuthProps((prevState) => ({
27951
+ ...prevState,
27952
+ password: e.target.value
27953
+ }))
27954
+ }
27955
+ ))))
27537
27956
  ), activeModal === "error" && errorMessage && /* @__PURE__ */ React.createElement(
27538
27957
  ModalBuilder,
27539
27958
  {
27540
- title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
27959
+ title: modalTitle,
27541
27960
  message: errorMessage.title,
27542
27961
  error: errorMessage.message,
27543
27962
  close,
@@ -27549,13 +27968,12 @@ mutation addPendingDocumentMutation(
27549
27968
  try {
27550
27969
  setActiveModal(null);
27551
27970
  setErrorMessage(void 0);
27552
- await client.logout();
27553
- await client.onLogout();
27554
- const token = await client.authenticate();
27555
- if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27556
- await (client == null ? void 0 : client.onLogin({ token }));
27971
+ const { authProvider } = client;
27972
+ await authProvider.logout();
27973
+ if (typeof (client == null ? void 0 : client.onLogout) === "function") {
27974
+ await client.onLogout();
27557
27975
  }
27558
- return onAuthenticated();
27976
+ window.location.href = new URL(window.location.href).pathname;
27559
27977
  } catch (e) {
27560
27978
  console.error(e);
27561
27979
  setActiveModal("error");
@@ -27572,7 +27990,7 @@ mutation addPendingDocumentMutation(
27572
27990
  ), showChildren ? children : loginScreen ? loginScreen : null);
27573
27991
  };
27574
27992
  const TinaCloudProvider = (props) => {
27575
- var _a, _b, _c, _d, _e;
27993
+ var _a, _b, _c;
27576
27994
  const baseBranch = props.branch || "main";
27577
27995
  const [currentBranch, setCurrentBranch] = useLocalStorage(
27578
27996
  "tinacms-current-branch",
@@ -27595,7 +28013,7 @@ mutation addPendingDocumentMutation(
27595
28013
  cms.api.tina.setBranch(currentBranch);
27596
28014
  }
27597
28015
  React.useEffect(() => {
27598
- var _a2, _b2, _c2, _d2, _e2, _f;
28016
+ var _a2, _b2, _c2, _d, _e, _f;
27599
28017
  let searchClient;
27600
28018
  if (props.isLocalClient) {
27601
28019
  searchClient = new LocalSearchClient(cms.api.tina);
@@ -27604,10 +28022,10 @@ mutation addPendingDocumentMutation(
27604
28022
  if (hasTinaSearch) {
27605
28023
  searchClient = new TinaCMSSearchClient(
27606
28024
  cms.api.tina,
27607
- (_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d2.tina
28025
+ (_d = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d.tina
27608
28026
  );
27609
28027
  } else {
27610
- searchClient = (_f = (_e2 = props.schema.config) == null ? void 0 : _e2.search) == null ? void 0 : _f.searchClient;
28028
+ searchClient = (_f = (_e = props.schema.config) == null ? void 0 : _e.search) == null ? void 0 : _f.searchClient;
27611
28029
  }
27612
28030
  }
27613
28031
  if (searchClient) {
@@ -27618,7 +28036,7 @@ mutation addPendingDocumentMutation(
27618
28036
  cms.registerApi("admin", new TinaAdminApi(cms));
27619
28037
  }
27620
28038
  const setupMedia = async (staticMedia) => {
27621
- var _a2, _b2, _c2, _d2, _e2, _f, _g;
28039
+ var _a2, _b2, _c2, _d, _e, _f, _g;
27622
28040
  const hasTinaMedia = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.media) == null ? void 0 : _b2.tina);
27623
28041
  if (hasTinaMedia) {
27624
28042
  cms.media.store = new TinaMediaStore(cms, staticMedia);
@@ -27626,9 +28044,9 @@ mutation addPendingDocumentMutation(
27626
28044
  /*
27627
28045
  Has tina custom media (set up in the schema or define schema)
27628
28046
  */
27629
- ((_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d2.loadCustomStore) || props.mediaStore
28047
+ ((_d = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d.loadCustomStore) || props.mediaStore
27630
28048
  ) {
27631
- const mediaStoreFromProps = ((_f = (_e2 = props.schema.config) == null ? void 0 : _e2.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
28049
+ const mediaStoreFromProps = ((_f = (_e = props.schema.config) == null ? void 0 : _e.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
27632
28050
  if ((_g = mediaStoreFromProps.prototype) == null ? void 0 : _g.persist) {
27633
28051
  cms.media.store = new mediaStoreFromProps(cms.api.tina);
27634
28052
  } else {
@@ -27640,7 +28058,8 @@ mutation addPendingDocumentMutation(
27640
28058
  }
27641
28059
  };
27642
28060
  const client = cms.api.tina;
27643
- const isTinaCloud = !client.isLocalMode && !((_e = (_d = (_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.admin) == null ? void 0 : _d.auth) == null ? void 0 : _e.customAuth);
28061
+ const isTinaCloud = !client.isLocalMode && !((_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.contentApiUrlOverride);
28062
+ const SessionProvider = client.authProvider.getSessionProvider();
27644
28063
  const handleListBranches = async () => {
27645
28064
  const branches = await cms.api.tina.listBranches({
27646
28065
  includeIndexStatus: true
@@ -27654,7 +28073,9 @@ mutation addPendingDocumentMutation(
27654
28073
  const newBranch = await cms.api.tina.createBranch(data);
27655
28074
  return newBranch;
27656
28075
  };
27657
- setupMedia(props.staticMedia);
28076
+ setupMedia(props.staticMedia).catch((e) => {
28077
+ console.error(e);
28078
+ });
27658
28079
  const [branchingEnabled, setBranchingEnabled] = React.useState(
27659
28080
  () => cms.flags.get("branch-switcher")
27660
28081
  );
@@ -27707,7 +28128,7 @@ mutation addPendingDocumentMutation(
27707
28128
  });
27708
28129
  return unsubscribe;
27709
28130
  }, [isTinaCloud, cms]);
27710
- return /* @__PURE__ */ React.createElement(
28131
+ return /* @__PURE__ */ React.createElement(SessionProvider, { basePath: "/api/tina/auth" }, /* @__PURE__ */ React.createElement(
27711
28132
  BranchDataProvider,
27712
28133
  {
27713
28134
  currentBranch,
@@ -27716,7 +28137,7 @@ mutation addPendingDocumentMutation(
27716
28137
  }
27717
28138
  },
27718
28139
  /* @__PURE__ */ React.createElement(TinaProvider, { cms }, /* @__PURE__ */ React.createElement(AuthWallInner, { ...props, cms }))
27719
- );
28140
+ ));
27720
28141
  };
27721
28142
  const TinaCloudAuthWall = TinaCloudProvider;
27722
28143
  class ContentCreatorPlugin {
@@ -27995,14 +28416,13 @@ mutation addPendingDocumentMutation(
27995
28416
  schema,
27996
28417
  ...props
27997
28418
  }) => {
27998
- var _a, _b, _c, _d, _e, _f;
28419
+ var _a, _b, _c;
27999
28420
  if (props == null ? void 0 : props.apiURL) {
28000
28421
  console.warn(
28001
28422
  "The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API"
28002
28423
  );
28003
28424
  }
28004
28425
  const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
28005
- const isLocalOverride = (_d = (_c = (_b = schema == null ? void 0 : schema.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.auth) == null ? void 0 : _d.useLocalAuth;
28006
28426
  const { branch, clientId, isLocalClient } = apiURL ? schemaTools.parseURL(apiURL) : {
28007
28427
  branch: props.branch,
28008
28428
  clientId: props.clientId,
@@ -28028,10 +28448,10 @@ mutation addPendingDocumentMutation(
28028
28448
  TinaCloudProvider,
28029
28449
  {
28030
28450
  branch,
28031
- clientId: clientId || ((_e = schema == null ? void 0 : schema.config) == null ? void 0 : _e.clientId),
28451
+ clientId: clientId || ((_b = schema == null ? void 0 : schema.config) == null ? void 0 : _b.clientId),
28032
28452
  tinaioConfig: props.tinaioConfig,
28033
- isLocalClient: isLocalOverride || isLocalClient,
28034
- isSelfHosted: !!((_f = schema == null ? void 0 : schema.config) == null ? void 0 : _f.contentApiUrlOverride),
28453
+ isLocalClient,
28454
+ isSelfHosted: !!((_c = schema == null ? void 0 : schema.config) == null ? void 0 : _c.contentApiUrlOverride),
28035
28455
  cmsCallback: props.cmsCallback,
28036
28456
  mediaStore: props.mediaStore,
28037
28457
  apiUrl: apiURL,
@@ -28235,6 +28655,12 @@ This will work when developing locally but NOT when deployed to production.
28235
28655
  const navBreakpoint2 = 1e3;
28236
28656
  const windowWidth = windowSize.useWindowWidth();
28237
28657
  const renderDesktopNav = windowWidth > navBreakpoint2;
28658
+ const activeScreens = screens.filter(
28659
+ (screen) => {
28660
+ var _a2;
28661
+ return screen.navCategory !== "Account" || ((_a2 = cms.api.tina.authProvider) == null ? void 0 : _a2.getLoginStrategy()) === "UsernamePassword";
28662
+ }
28663
+ );
28238
28664
  return /* @__PURE__ */ React.createElement(React.Fragment, null, renderDesktopNav && /* @__PURE__ */ React.createElement(
28239
28665
  Nav,
28240
28666
  {
@@ -28242,7 +28668,7 @@ This will work when developing locally but NOT when deployed to production.
28242
28668
  sidebarWidth: 360,
28243
28669
  showCollections: true,
28244
28670
  collectionsInfo,
28245
- screens,
28671
+ screens: activeScreens,
28246
28672
  cloudConfigs,
28247
28673
  contentCreators: [],
28248
28674
  RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(
@@ -28261,6 +28687,14 @@ This will work when developing locally but NOT when deployed to production.
28261
28687
  to: `/collections/${collection.name}/~`,
28262
28688
  Icon: ImFilesEmpty
28263
28689
  }
28690
+ ),
28691
+ AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
28692
+ SidebarLink,
28693
+ {
28694
+ label: collection.label ? collection.label : collection.name,
28695
+ to: `/collections/${collection.name}/~`,
28696
+ Icon: ImUsers
28697
+ }
28264
28698
  )
28265
28699
  }
28266
28700
  ), !renderDesktopNav && /* @__PURE__ */ React.createElement(react.Transition, { show: menuIsOpen }, /* @__PURE__ */ React.createElement(
@@ -28282,7 +28716,7 @@ This will work when developing locally but NOT when deployed to production.
28282
28716
  sidebarWidth: 360,
28283
28717
  showCollections: true,
28284
28718
  collectionsInfo,
28285
- screens,
28719
+ screens: activeScreens,
28286
28720
  cloudConfigs,
28287
28721
  contentCreators: [],
28288
28722
  RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(
@@ -28307,6 +28741,17 @@ This will work when developing locally but NOT when deployed to production.
28307
28741
  setMenuIsOpen(false);
28308
28742
  }
28309
28743
  }
28744
+ ),
28745
+ AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
28746
+ SidebarLink,
28747
+ {
28748
+ label: collection.label ? collection.label : collection.name,
28749
+ to: `/collections/${collection.name}/~`,
28750
+ Icon: ImUsers,
28751
+ onClick: () => {
28752
+ setMenuIsOpen(false);
28753
+ }
28754
+ }
28310
28755
  )
28311
28756
  },
28312
28757
  /* @__PURE__ */ React.createElement("div", { className: "absolute top-8 right-0 transform translate-x-full overflow-hidden" }, /* @__PURE__ */ React.createElement(
@@ -28445,11 +28890,11 @@ This will work when developing locally but NOT when deployed to production.
28445
28890
  const [searchParams] = reactRouterDom.useSearchParams();
28446
28891
  const slug = searchParams.get("slug") || "/";
28447
28892
  const logout2 = async () => {
28448
- var _a, _b, _c, _d, _e, _f;
28449
- if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
28450
- await cms.api.tina.logout();
28451
- if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
28452
- await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
28893
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
28894
+ if ((_c = (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.authProvider) == null ? void 0 : _c.logout) {
28895
+ await ((_f = (_e = (_d = cms == null ? void 0 : cms.api) == null ? void 0 : _d.tina) == null ? void 0 : _e.authProvider) == null ? void 0 : _f.logout());
28896
+ if ((_h = (_g = cms == null ? void 0 : cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.onLogout) {
28897
+ await ((_j = (_i = cms == null ? void 0 : cms.api) == null ? void 0 : _i.tina) == null ? void 0 : _j.onLogout());
28453
28898
  }
28454
28899
  }
28455
28900
  setEdit(false);
@@ -30660,6 +31105,7 @@ This will work when developing locally but NOT when deployed to production.
30660
31105
  enumerable: true,
30661
31106
  get: () => schemaTools.resolveField
30662
31107
  });
31108
+ exports2.AbstractAuthProvider = AbstractAuthProvider;
30663
31109
  exports2.ActionButton = ActionButton;
30664
31110
  exports2.AddIcon = AddIcon;
30665
31111
  exports2.AlertIcon = AlertIcon;
@@ -30668,6 +31114,7 @@ This will work when developing locally but NOT when deployed to production.
30668
31114
  exports2.AlignLeft = AlignLeft;
30669
31115
  exports2.AlignRight = AlignRight;
30670
31116
  exports2.AuthWallInner = AuthWallInner;
31117
+ exports2.BasePasswordField = BasePasswordField;
30671
31118
  exports2.BaseTextField = BaseTextField;
30672
31119
  exports2.BillingWarning = BillingWarning;
30673
31120
  exports2.BlocksField = BlocksField;
@@ -30762,6 +31209,7 @@ This will work when developing locally but NOT when deployed to production.
30762
31209
  exports2.ListField = ListField;
30763
31210
  exports2.ListFieldPlugin = ListFieldPlugin;
30764
31211
  exports2.LoadingDots = LoadingDots;
31212
+ exports2.LocalAuthProvider = LocalAuthProvider;
30765
31213
  exports2.LocalClient = LocalClient;
30766
31214
  exports2.LocalSearchClient = LocalSearchClient;
30767
31215
  exports2.LocalWarning = LocalWarning;
@@ -30789,6 +31237,8 @@ This will work when developing locally but NOT when deployed to production.
30789
31237
  exports2.OverflowMenu = OverflowMenu$1;
30790
31238
  exports2.PanelBody = PanelBody;
30791
31239
  exports2.PanelHeader = PanelHeader$1;
31240
+ exports2.PasswordFieldComponent = PasswordFieldComponent;
31241
+ exports2.PasswordFieldPlugin = PasswordFieldPlugin;
30792
31242
  exports2.PopupModal = PopupModal;
30793
31243
  exports2.PrefixedTextField = PrefixedTextField;
30794
31244
  exports2.PullRequestIcon = PullRequestIcon;
@@ -30830,6 +31280,7 @@ This will work when developing locally but NOT when deployed to production.
30830
31280
  exports2.TinaCMSProvider = TinaCMSProvider;
30831
31281
  exports2.TinaCMSProvider2 = TinaCMSProvider2;
30832
31282
  exports2.TinaCMSSearchClient = TinaCMSSearchClient;
31283
+ exports2.TinaCloudAuthProvider = TinaCloudAuthProvider;
30833
31284
  exports2.TinaCloudAuthWall = TinaCloudAuthWall;
30834
31285
  exports2.TinaCloudProvider = TinaCloudProvider;
30835
31286
  exports2.TinaField = TinaField;
@@ -30848,7 +31299,6 @@ This will work when developing locally but NOT when deployed to production.
30848
31299
  exports2.UploadIcon = UploadIcon;
30849
31300
  exports2.WarningIcon = WarningIcon;
30850
31301
  exports2.assertShape = assertShape;
30851
- exports2.asyncPoll = asyncPoll;
30852
31302
  exports2.classNames = classNames;
30853
31303
  exports2.createClient = createClient;
30854
31304
  exports2.default = TinaCMSProvider2;
@@ -30860,6 +31310,7 @@ This will work when developing locally but NOT when deployed to production.
30860
31310
  exports2.getFilteredBranchList = getFilteredBranchList;
30861
31311
  exports2.getStaticPropsForTina = getStaticPropsForTina;
30862
31312
  exports2.gql = gql;
31313
+ exports2.passwordFieldClasses = passwordFieldClasses;
30863
31314
  exports2.safeAssertShape = safeAssertShape;
30864
31315
  exports2.selectFieldClasses = selectFieldClasses;
30865
31316
  exports2.staticRequest = staticRequest;