diff --git a/cli.js b/cli.js
index 1940c09..bf28ab4 100644
--- a/cli.js
+++ b/cli.js
@@ -29,15 +29,15 @@ const cli = meow(
Examples
$ hemmelig "my super secret" --password=1337
- [*] Hemmelig.app URL: https://hemmelig.app/secret/myencryptionkey/thesecretid
+ [*] Hemmelig.app URL: https://hemmelig.app/secret/thesecretid#encryption_key=myencryptionkey
# Pipe data to the hemmelig cli
$ cat mysecret.txt | hemmelig
- [*] Hemmelig.app URL: https://hemmelig.app/secret/myencryptionkey2/thesecretid2
+ [*] Hemmelig.app URL: https://hemmelig.app/secret/thesecretid2#encryption_key=myencryptionkey2
# Different output
$ hemmelig "I am secret" -o=json
- {"encryptionKey":"9LiWq3iMAF0IkQs1tecOxbYKFesEnTN9","secretId":"manageable_CEsgWtxEaNNbwld6PjwyF1bQaiy4jQl9","url":"https://hemmelig.app/secret/9LiWq3iMAF0IkQs1tecOxbYKFesEnTN9/manageable_CEsgWtxEaNNbwld6PjwyF1bQaiy4jQl9"}
+ {"encryptionKey":"9LiWq3iMAF0IkQs1tecOxbYKFesEnTN9","secretId":"manageable_CEsgWtxEaNNbwld6PjwyF1bQaiy4jQl9","url":"https://hemmelig.app/secret/manageable_CEsgWtxEaNNbwld6PjwyF1bQaiy4jQl9#encryption_key=9LiWq3iMAF0IkQs1tecOxbYKFesEnTN9"}
`,
{
importMeta: { url },
@@ -109,7 +109,7 @@ const createSecret = async (data = {}) => {
};
const getSecretURL = (encryptionKey, secretId) =>
- `${cli.flags.url}/secret/${encryptionKey}/${secretId}`;
+ `${cli.flags.url}/secret/${secretId}#encryption_key=${encryptionKey}`;
const createOutput = (encryptionKey, secretId) => {
const url = getSecretURL(encryptionKey, secretId);
diff --git a/hemmelig.ts b/hemmelig.ts
index e0e334f..37f2a44 100644
--- a/hemmelig.ts
+++ b/hemmelig.ts
@@ -1,82 +1,90 @@
const completionSpec: Fig.Spec = {
- "name": "hemmelig",
- "description": "Encrypt text",
- "args": [
+ name: 'hemmelig',
+ description: 'Encrypt text',
+ args: [
{
- "name": "text",
- "description": "Text"
- }
+ name: 'text',
+ description: 'Text',
+ },
],
- "options": [
+ options: [
{
- "name": ["-t", "--title"],
- "description": "The secret title",
- "isOptional": true,
- "args": {
- "name": "title",
- "description": "The secret title"
- }
+ name: ['-t', '--title'],
+ description: 'The secret title',
+ isOptional: true,
+ args: {
+ name: 'title',
+ description: 'The secret title',
+ },
},
{
- "name": ["-p", "--password"],
- "description": "The password to protect the secret",
- "isOptional": true,
- "args": {
- "name": "password",
- "description": "The password to protect the secret"
- }
+ name: ['-p', '--password'],
+ description: 'The password to protect the secret',
+ isOptional: true,
+ args: {
+ name: 'password',
+ description: 'The password to protect the secret',
+ },
},
{
- "name": ["-l", "--lifetime"],
- "description": "The lifetime of the secret",
- "isOptional": true,
- "args": {
- "name": "lifetime",
- "description": "The lifetime of the secret"
- }
+ name: ['-l', '--lifetime'],
+ description: 'The lifetime of the secret',
+ isOptional: true,
+ args: {
+ name: 'lifetime',
+ description: 'The lifetime of the secret',
+ },
},
{
- "name": ["-m", "--maxViews"],
- "description": "The max views of the secret",
- "isOptional": true,
- "args": {
- "name": "maxViews",
- "description": "The max views of the secret"
- }
+ name: ['-m', '--maxViews'],
+ description: 'The max views of the secret',
+ isOptional: true,
+ args: {
+ name: 'maxViews',
+ description: 'The max views of the secret',
+ },
},
{
- "name": ["-c", "--cidr"],
- "description": "Provide the IP or CIDR range",
- "isOptional": true,
- "args": {
- "name": "cidr",
- "description": "Provide the IP or CIDR range"
- }
+ name: ['-c', '--cidr'],
+ description: 'Provide the IP or CIDR range',
+ isOptional: true,
+ args: {
+ name: 'cidr',
+ description: 'Provide the IP or CIDR range',
+ },
},
{
- "name": ["-e", "--expire"],
- "description": "Burn the secret only after the expire time",
- "isOptional": true,
- "args": {
- "name": "expire",
- "description": "Burn the secret only after the expire time"
- }
+ name: ['-e', '--expire'],
+ description: 'Burn the secret only after the expire time',
+ isOptional: true,
+ args: {
+ name: 'expire',
+ description: 'Burn the secret only after the expire time',
+ },
},
{
- "name": ["-u", "--url"],
- "description": "If you have your own instance of the Hemmelig.app",
- "isOptional": true,
- "args": {
- "name": "url",
- "description": "If you have your own instance of the Hemmelig.app"
- }
+ name: ['-u', '--url'],
+ description: 'If you have your own instance of the Hemmelig.app',
+ isOptional: true,
+ args: {
+ name: 'url',
+ description: 'If you have your own instance of the Hemmelig.app',
+ },
},
{
- "name": "--help",
- "description": "Prints help information",
- "isOptional": true,
- }
- ]
-
+ name: ['-o', '--output'],
+ description: 'Do you want the output response in yaml or json',
+ isOptional: true,
+ args: {
+ name: 'output',
+ description: 'Do you want the output response in yaml or json',
+ },
+ },
+ {
+ name: '--help',
+ description: 'Prints help information',
+ isOptional: true,
+ },
+ ],
};
export default completionSpec;
diff --git a/package.json b/package.json
index 4226d3a..6b024dd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "hemmelig",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "Paste a password, secret message or private information",
"main": "index.js",
"type": "module",
diff --git a/src/client/app.js b/src/client/app.js
index 7808fdf..d92f72e 100644
--- a/src/client/app.js
+++ b/src/client/app.js
@@ -159,6 +159,9 @@ const App = () => {
+
+
+
diff --git a/src/client/routes/home/index.js b/src/client/routes/home/index.js
index 4305688..1dbaf4f 100644
--- a/src/client/routes/home/index.js
+++ b/src/client/routes/home/index.js
@@ -198,7 +198,8 @@ const Home = () => {
const handleFocus = (event) => event.target.select();
- const getSecretURL = () => `${window.location.origin}/secret/${encryptionKey}/${secretId}`;
+ const getSecretURL = () =>
+ `${window.location.origin}/secret/${secretId}#encryption_key=${encryptionKey}`;
const inputReadOnly = !!secretId;
diff --git a/src/client/routes/secret/index.js b/src/client/routes/secret/index.js
index 9b85cc7..7b0e833 100644
--- a/src/client/routes/secret/index.js
+++ b/src/client/routes/secret/index.js
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
-import { useParams, Link } from 'react-router-dom';
+import { useParams, Link, useLocation } from 'react-router-dom';
import { Button, Group, Container, Textarea, TextInput, Stack, Title, Text } from '@mantine/core';
import {
@@ -19,10 +19,24 @@ import { decrypt } from '../../../shared/helpers/crypto';
import { useTranslation } from 'react-i18next';
+const getEncryptionKeyHash = (hash) => {
+ const id = '#encryption_key=';
+
+ if (!hash || !hash.includes(id)) {
+ return '';
+ }
+
+ const [_, encryptionKey] = hash.split('#encryption_key=');
+
+ return encryptionKey;
+};
+
const Secret = () => {
const { t } = useTranslation();
- const { secretId, encryptionKey = null } = useParams();
+ const { hash = '' } = useLocation();
+
+ const { secretId, encryptionKey = getEncryptionKeyHash(hash) } = useParams();
const [secret, setSecret] = useState(null);
const [title, setTitle] = useState(null);
const [preventBurn, setPreventBurn] = useState(false);