Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

add nanoid

Marc Seitza0f6b419260a
diff --git a/lib/utils.ts b/lib/utils.ts
index 880ab589..25f6293e 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -3,6 +3,7 @@ import { twMerge } from "tailwind-merge";
import ms from "ms"
import bcrypt from "bcryptjs";
import { toast } from "sonner";
+import { customAlphabet } from "nanoid";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
@@ -38,7 +39,7 @@ export async function fetcher<JSON = any>(
return res.json();
}
-export const log = async (message: string) => {
+export const log = async (message: string, mention?: boolean) => {
/* Log a message to the console */
try {
return await fetch(`${process.env.PPMK_SLACK_WEBHOOK_URL}`, {
@@ -52,7 +53,7 @@ export const log = async (message: string) => {
type: "section",
text: {
type: "mrkdwn",
- text: `${message}`,
+ text: `${mention ? "<@U05BTDUKPLZ> " : ""}${message}`,
},
},
],
@@ -223,4 +224,9 @@ export const formattedDate = (date: Date) => {
day: "2-digit",
year: "numeric",
});
-}
\ No newline at end of file
+}
+
+export const nanoid = customAlphabet(
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
+ 7,
+); // 7-character random string
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 93d3bed9..35d42281 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -47,6 +47,7 @@
"js-cookie": "^3.0.5",
"lucide-react": "^0.279.0",
"ms": "^2.1.3",
+ "nanoid": "^5.0.1",
"next": "^13.5.3",
"next-auth": "^4.23.1",
"next-plausible": "^3.11.1",
@@ -7500,9 +7501,9 @@
"optional": true
},
"node_modules/nanoid": {
- "version": "3.3.6",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
- "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.1.tgz",
+ "integrity": "sha512-vWeVtV5Cw68aML/QaZvqN/3QQXc6fBfIieAlu05m7FZW2Dgb+3f0xc0TTxuJW+7u30t7iSDTV/j3kVI0oJqIfQ==",
"funding": [
{
"type": "github",
@@ -7510,10 +7511,10 @@
}
],
"bin": {
- "nanoid": "bin/nanoid.cjs"
+ "nanoid": "bin/nanoid.js"
},
"engines": {
- "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ "node": "^18 || >=20"
}
},
"node_modules/natural-compare": {
@@ -7617,6 +7618,23 @@
"react-dom": "*"
}
},
+ "node_modules/next/node_modules/nanoid": {
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
"node_modules/next/node_modules/postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@@ -8329,6 +8347,23 @@
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
},
+ "node_modules/postcss/node_modules/nanoid": {
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
"node_modules/preact": {
"version": "10.15.1",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.15.1.tgz",
@@ -10099,6 +10134,23 @@
"node": ">=16.0.0"
}
},
+ "node_modules/tw-to-css/node_modules/nanoid": {
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
"node_modules/tw-to-css/node_modules/object-hash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz",
@@ -13435,6 +13487,11 @@
"which": "^2.0.1"
}
},
+ "crypto-js": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
+ "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
+ },
"css-unit-converter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/css-unit-converter/-/css-unit-converter-1.1.2.tgz",
@@ -15917,9 +15974,9 @@
"optional": true
},
"nanoid": {
- "version": "3.3.6",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
- "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA=="
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.1.tgz",
+ "integrity": "sha512-vWeVtV5Cw68aML/QaZvqN/3QQXc6fBfIieAlu05m7FZW2Dgb+3f0xc0TTxuJW+7u30t7iSDTV/j3kVI0oJqIfQ=="
},
"natural-compare": {
"version": "1.4.0",
@@ -15950,6 +16007,11 @@
"zod": "3.21.4"
},
"dependencies": {
+ "nanoid": {
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA=="
+ },
"postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@@ -16373,6 +16435,13 @@
"nanoid": "^3.3.6",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.2"
+ },
+ "dependencies": {
+ "nanoid": {
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA=="
+ }
}
},
"postcss-css-variables": {
@@ -17702,6 +17771,11 @@
"tailwindcss": "3.2.7"
},
"dependencies": {
+ "nanoid": {
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA=="
+ },
"object-hash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz",
diff --git a/package.json b/package.json
index 0211cdca..c6f47174 100644
--- a/package.json
+++ b/package.json
@@ -53,6 +53,7 @@
"js-cookie": "^3.0.5",
"lucide-react": "^0.279.0",
"ms": "^2.1.3",
+ "nanoid": "^5.0.1",
"next": "^13.5.3",
"next-auth": "^4.23.1",
"next-plausible": "^3.11.1",