tetrons 2.3.1 → 2.3.21

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.
Files changed (83) hide show
  1. package/dist/components/components/tetrons/EditorContent.tsx +282 -0
  2. package/dist/components/components/tetrons/ResizableImageComponent.tsx +77 -0
  3. package/dist/components/components/tetrons/ResizableVideoComponent.tsx +56 -0
  4. package/dist/index.d.mts +5 -1
  5. package/dist/index.d.ts +12 -7
  6. package/dist/index.js +17254 -21
  7. package/dist/index.mjs +54 -11
  8. package/dist/tetrons-UCHWNATC.css +372 -0
  9. package/package.json +3 -3
  10. package/dist/app/api/export/route.d.ts +0 -1
  11. package/dist/app/api/export/route.js +0 -4
  12. package/dist/app/api/register/route.d.ts +0 -7
  13. package/dist/app/api/register/route.js +0 -32
  14. package/dist/app/api/save/route.d.ts +0 -6
  15. package/dist/app/api/save/route.js +0 -15
  16. package/dist/app/api/validate/route.d.ts +0 -10
  17. package/dist/app/api/validate/route.js +0 -58
  18. package/dist/app/layout.d.ts +0 -6
  19. package/dist/app/layout.jsx +0 -30
  20. package/dist/app/page.d.ts +0 -2
  21. package/dist/app/page.jsx +0 -51
  22. package/dist/components/UI/Button.jsx +0 -1
  23. package/dist/components/UI/Dropdown.jsx +0 -1
  24. package/dist/components/tetrons/EditorContent.d.ts +0 -6
  25. package/dist/components/tetrons/EditorContent.jsx +0 -209
  26. package/dist/components/tetrons/ResizableImage.d.ts +0 -1
  27. package/dist/components/tetrons/ResizableImage.js +0 -40
  28. package/dist/components/tetrons/ResizableImageComponent.d.ts +0 -11
  29. package/dist/components/tetrons/ResizableImageComponent.jsx +0 -37
  30. package/dist/components/tetrons/ResizableVideo.d.ts +0 -12
  31. package/dist/components/tetrons/ResizableVideo.js +0 -61
  32. package/dist/components/tetrons/ResizableVideoComponent.d.ts +0 -4
  33. package/dist/components/tetrons/ResizableVideoComponent.jsx +0 -32
  34. package/dist/components/tetrons/helpers.d.ts +0 -0
  35. package/dist/components/tetrons/helpers.js +0 -1
  36. package/dist/components/tetrons/toolbar/ActionGroup.d.ts +0 -7
  37. package/dist/components/tetrons/toolbar/ActionGroup.jsx +0 -167
  38. package/dist/components/tetrons/toolbar/ClipboardGroup.d.ts +0 -5
  39. package/dist/components/tetrons/toolbar/ClipboardGroup.jsx +0 -36
  40. package/dist/components/tetrons/toolbar/FileGroup.d.ts +0 -7
  41. package/dist/components/tetrons/toolbar/FileGroup.jsx +0 -40
  42. package/dist/components/tetrons/toolbar/FontStyleGroup.d.ts +0 -7
  43. package/dist/components/tetrons/toolbar/FontStyleGroup.jsx +0 -104
  44. package/dist/components/tetrons/toolbar/InsertGroup.d.ts +0 -5
  45. package/dist/components/tetrons/toolbar/InsertGroup.jsx +0 -163
  46. package/dist/components/tetrons/toolbar/ListAlignGroup.d.ts +0 -5
  47. package/dist/components/tetrons/toolbar/ListAlignGroup.jsx +0 -16
  48. package/dist/components/tetrons/toolbar/MiscGroup.d.ts +0 -7
  49. package/dist/components/tetrons/toolbar/MiscGroup.jsx +0 -31
  50. package/dist/components/tetrons/toolbar/TableContextMenu.d.ts +0 -7
  51. package/dist/components/tetrons/toolbar/TableContextMenu.jsx +0 -52
  52. package/dist/components/tetrons/toolbar/TetronsToolbar.d.ts +0 -6
  53. package/dist/components/tetrons/toolbar/TetronsToolbar.jsx +0 -46
  54. package/dist/components/tetrons/toolbar/ToolbarButton.d.ts +0 -12
  55. package/dist/components/tetrons/toolbar/ToolbarButton.jsx +0 -8
  56. package/dist/components/tetrons/toolbar/extensions/Comment.d.ts +0 -17
  57. package/dist/components/tetrons/toolbar/extensions/Comment.js +0 -45
  58. package/dist/components/tetrons/toolbar/extensions/Embed.d.ts +0 -2
  59. package/dist/components/tetrons/toolbar/extensions/Embed.js +0 -90
  60. package/dist/components/tetrons/toolbar/extensions/FontFamily.d.ts +0 -9
  61. package/dist/components/tetrons/toolbar/extensions/FontFamily.js +0 -28
  62. package/dist/components/tetrons/toolbar/extensions/FontSize.d.ts +0 -9
  63. package/dist/components/tetrons/toolbar/extensions/FontSize.js +0 -28
  64. package/dist/components/tetrons/toolbar/extensions/ResizableTable.d.ts +0 -1
  65. package/dist/components/tetrons/toolbar/extensions/ResizableTable.js +0 -11
  66. package/dist/components/tetrons/toolbar/marks/Subscript.d.ts +0 -2
  67. package/dist/components/tetrons/toolbar/marks/Subscript.js +0 -35
  68. package/dist/components/tetrons/toolbar/marks/Superscript.d.ts +0 -2
  69. package/dist/components/tetrons/toolbar/marks/Superscript.js +0 -35
  70. package/dist/lib/db.d.ts +0 -1
  71. package/dist/lib/db.js +0 -15
  72. package/dist/lib/export.d.ts +0 -0
  73. package/dist/lib/export.js +0 -1
  74. package/dist/lib/tiptap-extensions.d.ts +0 -0
  75. package/dist/lib/tiptap-extensions.js +0 -1
  76. package/dist/models/ApiKey.d.ts +0 -2
  77. package/dist/models/ApiKey.js +0 -14
  78. package/dist/utils/apiKeyUtils.d.ts +0 -11
  79. package/dist/utils/apiKeyUtils.js +0 -33
  80. package/dist/utils/loadEmojiPicker.d.ts +0 -1
  81. package/dist/utils/loadEmojiPicker.js +0 -12
  82. /package/dist/components/{UI/Button.d.ts → components/UI/Button.tsx} +0 -0
  83. /package/dist/components/{UI/Dropdown.d.ts → components/UI/Dropdown.tsx} +0 -0
@@ -1,52 +0,0 @@
1
- "use client";
2
- import React, { useEffect, useState } from "react";
3
- export default function TableContextMenu({ editor }) {
4
- const [menuPosition, setMenuPosition] = useState(null);
5
- useEffect(() => {
6
- const handleContextMenu = (event) => {
7
- const target = event.target;
8
- if (target.closest("td") || target.closest("th")) {
9
- event.preventDefault();
10
- setMenuPosition({ x: event.pageX, y: event.pageY });
11
- }
12
- else {
13
- setMenuPosition(null);
14
- }
15
- };
16
- const handleClick = () => setMenuPosition(null);
17
- document.addEventListener("contextmenu", handleContextMenu);
18
- document.addEventListener("click", handleClick);
19
- return () => {
20
- document.removeEventListener("contextmenu", handleContextMenu);
21
- document.removeEventListener("click", handleClick);
22
- };
23
- }, []);
24
- const insertRowAbove = () => editor.chain().focus().addRowBefore().run();
25
- const insertRowBelow = () => editor.chain().focus().addRowAfter().run();
26
- const insertColLeft = () => editor.chain().focus().addColumnBefore().run();
27
- const insertColRight = () => editor.chain().focus().addColumnAfter().run();
28
- const deleteRow = () => editor.chain().focus().deleteRow().run();
29
- const deleteCol = () => editor.chain().focus().deleteColumn().run();
30
- if (!menuPosition)
31
- return null;
32
- return (<ul className="absolute bg-white shadow border rounded text-sm z-50" style={{ top: menuPosition.y, left: menuPosition.x }}>
33
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertRowAbove}>
34
- Insert Row Above
35
- </li>
36
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertRowBelow}>
37
- Insert Row Below
38
- </li>
39
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertColLeft}>
40
- Insert Column Left
41
- </li>
42
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertColRight}>
43
- Insert Column Right
44
- </li>
45
- <li className="px-3 py-1 hover:bg-red-100 cursor-pointer" onClick={deleteRow}>
46
- Delete Row
47
- </li>
48
- <li className="px-3 py-1 hover:bg-red-100 cursor-pointer" onClick={deleteCol}>
49
- Delete Column
50
- </li>
51
- </ul>);
52
- }
@@ -1,6 +0,0 @@
1
- import React from "react";
2
- import type { Editor } from "@tiptap/react";
3
- export default function TetronsToolbar({ editor, version, }: {
4
- editor: Editor;
5
- version: "free" | "pro" | "premium" | "platinum";
6
- }): React.JSX.Element;
@@ -1,46 +0,0 @@
1
- "use client";
2
- import React, { useEffect, useState } from "react";
3
- import ActionGroup from "./ActionGroup";
4
- import ClipboardGroup from "./ClipboardGroup";
5
- import FontStyleGroup from "./FontStyleGroup";
6
- import InsertGroup from "./InsertGroup";
7
- import ListAlignGroup from "./ListAlignGroup";
8
- import MiscGroup from "./MiscGroup";
9
- import FileGroup from "./FileGroup";
10
- export default function TetronsToolbar({ editor, version, }) {
11
- const [autoSave, setAutoSave] = useState(false);
12
- useEffect(() => {
13
- if (!editor)
14
- return;
15
- const handleUpdate = () => {
16
- if (!autoSave)
17
- return;
18
- const content = editor.getJSON();
19
- fetch("/api/save", {
20
- method: "POST",
21
- headers: { "Content-Type": "application/json" },
22
- body: JSON.stringify(content),
23
- }).catch((err) => console.error("Auto-save failed:", err));
24
- };
25
- editor.on("update", handleUpdate);
26
- return () => {
27
- editor.off("update", handleUpdate);
28
- };
29
- }, [autoSave, editor]);
30
- return (<div className="tetrons-toolbar">
31
- {version !== "free" && (<div className="group">
32
- <input type="checkbox" id="autoSave" checked={autoSave} onChange={(e) => setAutoSave(e.target.checked)}/>
33
- <label htmlFor="autoSave">Auto Save</label>
34
- </div>)}
35
-
36
- {["pro", "premium", "platinum"].includes(version) && (<FileGroup editor={editor}/>)}
37
- <ClipboardGroup editor={editor}/>
38
- <FontStyleGroup editor={editor}/>
39
- <ListAlignGroup editor={editor}/>
40
- {["premium", "platinum"].includes(version) && (<>
41
- <InsertGroup editor={editor}/>
42
- <ActionGroup editor={editor}/>
43
- </>)}
44
- {version === "platinum" && <MiscGroup editor={editor}/>}
45
- </div>);
46
- }
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import type { IconType } from "react-icons";
3
- export type ToolbarButtonProps = {
4
- icon: IconType;
5
- onClick: () => void;
6
- disabled?: boolean;
7
- title?: string;
8
- label?: string;
9
- isActive?: boolean;
10
- };
11
- declare const ToolbarButton: React.ForwardRefExoticComponent<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
12
- export default ToolbarButton;
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- const ToolbarButton = React.forwardRef(({ icon: Icon, onClick, disabled = false, title, label, isActive = false }, ref) => {
3
- return (<button type="button" ref={ref} onClick={onClick} disabled={disabled} title={title !== null && title !== void 0 ? title : label} aria-label={title !== null && title !== void 0 ? title : label} className={`toolbar-button ${isActive ? "active" : ""}`}>
4
- <Icon size={20}/>
5
- </button>);
6
- });
7
- ToolbarButton.displayName = "ToolbarButton";
8
- export default ToolbarButton;
@@ -1,17 +0,0 @@
1
- import { Mark } from "@tiptap/core";
2
- export interface CommentOptions {
3
- HTMLAttributes: {
4
- class?: string;
5
- style?: string;
6
- [key: string]: unknown;
7
- };
8
- }
9
- declare module "@tiptap/core" {
10
- interface Commands<ReturnType> {
11
- comment: {
12
- setComment: (comment: string) => ReturnType;
13
- unsetComment: () => ReturnType;
14
- };
15
- }
16
- }
17
- export declare const Comment: Mark<CommentOptions, any>;
@@ -1,45 +0,0 @@
1
- import { Mark, mergeAttributes } from "@tiptap/core";
2
- export const Comment = Mark.create({
3
- name: "comment",
4
- addOptions() {
5
- return {
6
- HTMLAttributes: {},
7
- };
8
- },
9
- addAttributes() {
10
- return {
11
- comment: {
12
- default: "",
13
- },
14
- };
15
- },
16
- parseHTML() {
17
- return [
18
- {
19
- tag: "span[data-comment]",
20
- },
21
- ];
22
- },
23
- renderHTML({ HTMLAttributes }) {
24
- return [
25
- "span",
26
- mergeAttributes(HTMLAttributes, {
27
- "data-comment": HTMLAttributes.comment,
28
- class: "comment-highlight",
29
- title: HTMLAttributes.comment,
30
- style: "background-color: rgba(255, 230, 0, 0.3);",
31
- }),
32
- 0,
33
- ];
34
- },
35
- addCommands() {
36
- return {
37
- setComment: (comment) => ({ commands }) => {
38
- return commands.setMark(this.name, { comment });
39
- },
40
- unsetComment: () => ({ commands }) => {
41
- return commands.unsetMark(this.name);
42
- },
43
- };
44
- },
45
- });
@@ -1,2 +0,0 @@
1
- import { Node } from "@tiptap/core";
2
- export declare const Embed: Node<any, any>;
@@ -1,90 +0,0 @@
1
- import { Node, mergeAttributes } from "@tiptap/core";
2
- export const Embed = Node.create({
3
- name: "embed",
4
- group: "block",
5
- atom: true,
6
- addAttributes() {
7
- return {
8
- src: { default: null },
9
- width: { default: 560 },
10
- height: { default: 315 },
11
- };
12
- },
13
- parseHTML() {
14
- return [{ tag: "iframe[src]" }];
15
- },
16
- renderHTML({ HTMLAttributes }) {
17
- return ["iframe", mergeAttributes(HTMLAttributes)];
18
- },
19
- addCommands() {
20
- return {
21
- setEmbed: ((attributes) => {
22
- return ({ chain }) => {
23
- return chain()
24
- .insertContent({
25
- type: this.name,
26
- attrs: attributes,
27
- })
28
- .run();
29
- };
30
- }).bind(this),
31
- };
32
- },
33
- addNodeView() {
34
- return ({ node, getPos, editor }) => {
35
- const container = document.createElement('div');
36
- container.style.position = 'relative';
37
- container.style.display = 'inline-block';
38
- container.style.width = node.attrs.width + 'px';
39
- container.style.height = node.attrs.height + 'px';
40
- const iframe = document.createElement('iframe');
41
- iframe.setAttribute('src', node.attrs.src);
42
- iframe.setAttribute('frameborder', '0');
43
- iframe.setAttribute('allowfullscreen', 'true');
44
- iframe.style.width = '100%';
45
- iframe.style.height = '100%';
46
- container.appendChild(iframe);
47
- const handle = document.createElement('div');
48
- handle.style.position = 'absolute';
49
- handle.style.width = '16px';
50
- handle.style.height = '16px';
51
- handle.style.right = '0';
52
- handle.style.bottom = '0';
53
- handle.style.cursor = 'se-resize';
54
- handle.style.background = 'rgba(0,0,0,0.5)';
55
- handle.style.borderRadius = '2px';
56
- container.appendChild(handle);
57
- let startX, startY, startWidth, startHeight;
58
- const onMouseDown = (event) => {
59
- event.preventDefault();
60
- startX = event.clientX;
61
- startY = event.clientY;
62
- startWidth = container.offsetWidth;
63
- startHeight = container.offsetHeight;
64
- window.addEventListener('mousemove', onMouseMove);
65
- window.addEventListener('mouseup', onMouseUp);
66
- };
67
- const onMouseMove = (event) => {
68
- const newWidth = Math.max(100, startWidth + (event.clientX - startX));
69
- const newHeight = Math.max(100, startHeight + (event.clientY - startY));
70
- container.style.width = newWidth + 'px';
71
- container.style.height = newHeight + 'px';
72
- };
73
- const onMouseUp = () => {
74
- window.removeEventListener("mousemove", onMouseMove);
75
- window.removeEventListener("mouseup", onMouseUp);
76
- editor.commands.command(({ tr }) => {
77
- tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, node.attrs), { width: container.offsetWidth, height: container.offsetHeight }));
78
- return true;
79
- });
80
- };
81
- handle.addEventListener('mousedown', onMouseDown);
82
- return {
83
- dom: container,
84
- destroy() {
85
- handle.removeEventListener('mousedown', onMouseDown);
86
- }
87
- };
88
- };
89
- },
90
- });
@@ -1,9 +0,0 @@
1
- import { Mark } from '@tiptap/core';
2
- declare module '@tiptap/core' {
3
- interface Commands<ReturnType> {
4
- fontFamily: {
5
- setFontFamily: (font: string) => ReturnType;
6
- };
7
- }
8
- }
9
- export declare const FontFamily: Mark<any, any>;
@@ -1,28 +0,0 @@
1
- import { Mark, mergeAttributes } from '@tiptap/core';
2
- export const FontFamily = Mark.create({
3
- name: 'fontFamily',
4
- addAttributes() {
5
- return {
6
- font: {
7
- default: null,
8
- parseHTML: element => element.style.fontFamily.replace(/['"]/g, ''),
9
- renderHTML: attributes => {
10
- if (!attributes.font)
11
- return {};
12
- return { style: `font-family: ${attributes.font}` };
13
- },
14
- },
15
- };
16
- },
17
- parseHTML() {
18
- return [{ style: 'font-family' }];
19
- },
20
- renderHTML({ HTMLAttributes }) {
21
- return ['span', mergeAttributes(HTMLAttributes), 0];
22
- },
23
- addCommands() {
24
- return {
25
- setFontFamily: font => ({ commands }) => commands.setMark(this.name, { font }),
26
- };
27
- },
28
- });
@@ -1,9 +0,0 @@
1
- import { Mark } from "@tiptap/core";
2
- declare module "@tiptap/core" {
3
- interface Commands<ReturnType> {
4
- fontSize: {
5
- setFontSize: (size: string) => ReturnType;
6
- };
7
- }
8
- }
9
- export declare const FontSize: Mark<any, any>;
@@ -1,28 +0,0 @@
1
- import { Mark, mergeAttributes } from "@tiptap/core";
2
- export const FontSize = Mark.create({
3
- name: "fontSize",
4
- addAttributes() {
5
- return {
6
- size: {
7
- default: null,
8
- parseHTML: (element) => element.style.fontSize,
9
- renderHTML: (attributes) => {
10
- if (!attributes.size)
11
- return {};
12
- return { style: `font-size: ${attributes.size}` };
13
- },
14
- },
15
- };
16
- },
17
- parseHTML() {
18
- return [{ style: "font-size" }];
19
- },
20
- renderHTML({ HTMLAttributes }) {
21
- return ["span", mergeAttributes(HTMLAttributes), 0];
22
- },
23
- addCommands() {
24
- return {
25
- setFontSize: (size) => ({ commands }) => commands.setMark(this.name, { size }),
26
- };
27
- },
28
- });
@@ -1 +0,0 @@
1
- export declare const ResizableTable: import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any>;
@@ -1,11 +0,0 @@
1
- import { Table } from "@tiptap/extension-table";
2
- import { columnResizing, tableEditing } from "prosemirror-tables";
3
- export const ResizableTable = Table.extend({
4
- addOptions() {
5
- var _a;
6
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { resizable: true });
7
- },
8
- addProseMirrorPlugins() {
9
- return [columnResizing({ handleWidth: 5 }), tableEditing()];
10
- },
11
- });
@@ -1,2 +0,0 @@
1
- import { Mark } from "@tiptap/core";
2
- export declare const Subscript: Mark<any, any>;
@@ -1,35 +0,0 @@
1
- import { Mark, markInputRule, markPasteRule } from "@tiptap/core";
2
- export const Subscript = Mark.create({
3
- name: "subscript",
4
- excludes: "superscript",
5
- parseHTML() {
6
- return [{ tag: "sub" }, { style: "vertical-align: sub" }];
7
- },
8
- renderHTML() {
9
- return ["sub", 0];
10
- },
11
- addCommands() {
12
- return {
13
- toggleSubscript: () => ({ chain }) => chain()
14
- .unsetMark("superscript")
15
- .toggleMark(this.name)
16
- .run(),
17
- };
18
- },
19
- addInputRules() {
20
- return [
21
- markInputRule({
22
- find: /~([^~]+)~/,
23
- type: this.type,
24
- }),
25
- ];
26
- },
27
- addPasteRules() {
28
- return [
29
- markPasteRule({
30
- find: /~([^~]+)~/g,
31
- type: this.type,
32
- }),
33
- ];
34
- },
35
- });
@@ -1,2 +0,0 @@
1
- import { Mark } from "@tiptap/core";
2
- export declare const Superscript: Mark<any, any>;
@@ -1,35 +0,0 @@
1
- import { Mark, markInputRule, markPasteRule } from "@tiptap/core";
2
- export const Superscript = Mark.create({
3
- name: "superscript",
4
- excludes: "subscript",
5
- parseHTML() {
6
- return [{ tag: "sup" }, { style: "vertical-align: super" }];
7
- },
8
- renderHTML() {
9
- return ["sup", 0];
10
- },
11
- addCommands() {
12
- return {
13
- toggleSuperscript: () => ({ chain }) => chain()
14
- .unsetMark("subscript")
15
- .toggleMark(this.name)
16
- .run(),
17
- };
18
- },
19
- addInputRules() {
20
- return [
21
- markInputRule({
22
- find: /\^([^^]+)\^/,
23
- type: this.type,
24
- }),
25
- ];
26
- },
27
- addPasteRules() {
28
- return [
29
- markPasteRule({
30
- find: /\^([^^]+)\^/g,
31
- type: this.type,
32
- }),
33
- ];
34
- },
35
- });
package/dist/lib/db.d.ts DELETED
@@ -1 +0,0 @@
1
- export function connectDB(): Promise<void>;
package/dist/lib/db.js DELETED
@@ -1,15 +0,0 @@
1
- import mongoose from "mongoose";
2
- const MONGO_URL = process.env.MONGO_URL;
3
- export const connectDB = async () => {
4
- if (mongoose.connection.readyState >= 1) {
5
- return;
6
- }
7
- try {
8
- await mongoose.connect(MONGO_URL);
9
- console.log("Connected to MongoDB 👍");
10
- }
11
- catch (error) {
12
- console.error("MongoDB connection failed ❌", error);
13
- process.exit(1);
14
- }
15
- };
File without changes
@@ -1 +0,0 @@
1
- "use strict";
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,2 +0,0 @@
1
- import mongoose from "mongoose";
2
- export declare const ApiKey: mongoose.Model<any, {}, {}, {}, any, any>;
@@ -1,14 +0,0 @@
1
- import mongoose from "mongoose";
2
- const ApiKeySchema = new mongoose.Schema({
3
- email: { type: String, required: true },
4
- organization: { type: String, required: true },
5
- version: {
6
- type: String,
7
- enum: ["free", "pro", "premium", "platinum"],
8
- required: true,
9
- },
10
- apiKey: { type: String, required: true, unique: true },
11
- createdAt: { type: Date, default: Date.now },
12
- expiresAt: { type: Date },
13
- });
14
- export const ApiKey = mongoose.models.ApiKey || mongoose.model("ApiKey", ApiKeySchema);
@@ -1,11 +0,0 @@
1
- export declare function getFreeApiKey(): string;
2
- declare const VERSION_PREFIXES: {
3
- readonly pro: "PRO";
4
- readonly premium: "PREMIUM";
5
- readonly platinum: "PLATINUM";
6
- };
7
- export type VersionType = keyof typeof VERSION_PREFIXES;
8
- export declare function generateUserApiKey(email: string, organization: string, version: VersionType): string;
9
- export declare function generateApiKey(length?: number): string;
10
- export declare function generateVersionedKey(prefix?: string): string;
11
- export {};
@@ -1,33 +0,0 @@
1
- import crypto from "crypto";
2
- const FREE_API_KEY = process.env.TETRONS_FREE_KEY || "TETRONS_FREE_KEY";
3
- const SECRET_KEY = process.env.API_KEY_SECRET || "default-secret-key";
4
- export function getFreeApiKey() {
5
- return FREE_API_KEY;
6
- }
7
- const VERSION_PREFIXES = {
8
- pro: "PRO",
9
- premium: "PREMIUM",
10
- platinum: "PLATINUM",
11
- };
12
- export function generateUserApiKey(email, organization, version) {
13
- const input = `${email.trim().toLowerCase()}:${organization
14
- .trim()
15
- .toLowerCase()}`;
16
- const hash = crypto
17
- .createHmac("sha256", SECRET_KEY)
18
- .update(input)
19
- .digest("hex")
20
- .toUpperCase();
21
- const prefix = VERSION_PREFIXES[version];
22
- return `${prefix}${hash.slice(0, 48 - prefix.length)}`;
23
- }
24
- export function generateApiKey(length = 48) {
25
- return crypto
26
- .randomBytes(length / 2)
27
- .toString("hex")
28
- .toUpperCase();
29
- }
30
- export function generateVersionedKey(prefix = "") {
31
- const key = generateApiKey(48 - prefix.length);
32
- return `${prefix}${key}`;
33
- }
@@ -1 +0,0 @@
1
- export declare const loadEmojiPicker: () => void;
@@ -1,12 +0,0 @@
1
- export const loadEmojiPicker = () => {
2
- if (typeof window === "undefined")
3
- return;
4
- if (!window.EmojiButton && !document.getElementById("emoji-picker-script")) {
5
- const script = document.createElement("script");
6
- script.id = "emoji-picker-script";
7
- script.src =
8
- "https://cdn.jsdelivr.net/npm/@joeattardi/emoji-button@latest/dist/index.min.js";
9
- script.async = true;
10
- document.body.appendChild(script);
11
- }
12
- };