Skip to content

misobarisic/SafeLink

Repository files navigation

Welcome to SafeLink 👋

License: MIT

SafeLink is an open-source link "shortener"

What makes SafeLink stand out is its lack of a database. It is 100% frontend (client side).

Advantages:

  • Your links cannot be deleted
  • The server hosting SafeLink (including any fork using the same encode process) have no access to your data
  • Your link will be accessible forever
  • Links are decoded on your device
  • AES256 + Base64 encoding

How it works

When you click on "Generate URL", SafeLink generates a link based on your input: link.misobarisic.com/<your data>

When you open a link, SafeLink reads and decodes whatever comes after the first / upon which you are redirected to their respective destination.

HTTP REST

SafeLink links can be easily created or read with a HTTP GET request:

Make sure to use x-www-form-urlencoded to pass data.

The accept header should include application/json or */*.

data refers to the original (redirect) URL, whereas link refers to the part of the URL after link.misobarisic.com/

Encode

GET /api/encode
Body should contain: data

Example response:
{
  "data": "https://github.com",
  "link":"dGhpcyBpcyBhbiBleGFtcGxl"
} 

Encode with password

GET /api/encode
Body should contain: data, pass

// Password is not sent back in the response
Example response:
{
  "data": "https://github.com",
  "link": "dGhpcyBpcyBhbiBleGFtcGxl"
} 

Decode

GET /api/decode
Body should contain: link

Example response:
{
  "data": "https://github.com",
  "link": "YW5vdGhlciBleGFtcGxl"
}

Decode with password

GET /api/decode
Body should contain: link, pass

// Password is not sent back in the response
Example response:
{
  "data": "https://github.com",
  "link": "YW5vdGhlciBleGFtcGxl"
}

Forks

If you wish for all SafePaste links to be accessible on your fork of this project make sure not to edit these fields

config.js

module.exports.base = {
    key: "safepaste"
}

utils/urlUtils.js

module.exports.generateURL = input => {
  if (input) {
    if (input.startsWith("https://") || input.startsWith("http://")) {
      return base64.encode(aes256.encrypt(key, input))
    } else if (input.startsWith("http://") || !input.startsWith("https://")) {
      return base64.encode(aes256.encrypt(key, `https://${input}`))
    }
  } else {
    return ""
  }
}
module.exports.decodeURL = input => {
  return input ? aes256.decrypt(key, base64.decode(input)) : "";
}

Deploy your own

Deploy with Vercel

Author

👤 Mišo Barišić

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 misobarisic.
This project is MIT licensed.

About

Permanent link sharing service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published