CloudFlare Worker for Dashy Backup and Restore

February 27, 2024 ยท View on GitHub

This is the code for the backup / restore server used by Dashy. For more info, see Dashy Cloud Sync Docs.

All data needs to be encrypted before being sent to the backend. In Dashy, this is done in CloudBackup.js, using crypto.js's AES method, using the users chosen password as the key.

Getting Started

  1. Install Wrangler CLI Tool: npm i -g @cloudflare/wrangler
  2. Log into Cloudflare account: wrangler login
  3. Create a new project: wrangler generate my-project
  4. Install dependencies: cd my-project && npm i
  5. Populate wrangler.toml
  • Add your account_id (found on the right sidebar of the Workers or Overview Dashboard)
  • Add your zone_id (found in the Overview tab of your desired domain on Cloudflare)
  • Add your route, which should be a domain or host, supporting a wildcard
  1. Populate index.js with your code to handle requests
  2. To start the development server, run wrangler dev
  3. Finally, when you're ready to publish it, run wrangler publish

Endpoints

  • GET - Get config for a given user
    • backupId - The ID of the desired encrypted object
    • subHash - The latter half of the password hash, to verify ownership
  • POST - Save a new config object, and returns backupId
    • userData - The encrypted, compressed and stringified user config
    • subHash - The latter half of the password hash, to verify ownership
  • PUT - Update an existing config object
    • backupId - The ID of the object to update
    • subHash - Part of the hash, to verify ownership of said object
    • userData - The new data to store
  • DELETE - Delete a specified config object
    • backupId - The ID of the object to be deleted
    • subHash - Part of the password hash, to verify ownership of the object

For more details on using these endpoints, see the API Docs or import the Postman collection.