New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

layer-migrate

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

layer-migrate

A command line tool for exporting your chat data from Layer and importing it to Stream

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
1
Weekly downloads
 
Created
Source

Layer Chat Migration

Layer's API is shutting down October 30th leaving many customers in a difficult position. This guide shows you how to export your data from Layer and safely migrate to Stream.

This is a work in progress. The automatic import functionality on Stream's side is tested by many customers. What's not done yet is the scripts to easily export your data from Layer and the serverless endpoints to sync data via webhooks. This repo will be much easier to use in a couple of days.

TODO

  • CLI: fix paths
  • Layer Client: Better handling of webhook header and the app_uuid query param (Thierry)
  • Serverless, update readme with instructions
  • Serverless: convert message, convert channel

Step 1 - Layer Chat Data Export, Creating an Export

Install the layer-migrate tool

yarn global add layer-migrate

A. You need to generate a key to sign your layer export with:

mkdir keys
openssl genrsa -out keys/layer-export.pem 2048 && openssl rsa -in keys/layer-export.pem -pubout -out keys/layer-export.pub

B. As a second step you'll want to lookup your application ID and the Server API token from your Layer Dashboard.

export LAYER_APP_ID=YOUR_APP_ID_HERE (looks like 1dab157e-4d19-11e6-bb33-493b0000asdfasba)
export LAYER_TOKEN=YOUR_TOKEN_HERE (2vsm4yLCG24Y44IfSK6w8nBIxAgrVcU20zuPJ3fO8eXXv5Ub)

You can find your application ID under the Keys section of your Layer dashboard.

Layer Key

And you can find your Layer token under Server API.

Layer Server API

Note: You must create the server API token. It will not be automatically generated for you.

C. Register your new key

layer-migrate register-key

D. Start an export

layer-migrate export

Step 2 - Downloading a Layer Chat Export

A. Wait for the export to complete

layer-migrate status

Note that Layer will also send you an email when the download completes

B. Download the export

Once the export is completed the json will include a download_url. Go ahead and download it

wget -O download.tar.gz.enc download_url

C. Decrypt the export

https://docs.layer.com/reference/server_api/data.out#decrypting-export-archives

# path to the file you just downloaded
export ENCRYPTED_TARBALL=download.tar.gz.enc
# path for the unencrypted tar
export OUTPUT_TAR=export.tar.gz
# path to the private key
export PRIVATE_KEY_PATH=keys/layer-export-key.pem
# the encrypted_aes_key from the export json
export ENCRYPTED_AES_KEY=V5sWiwjTVEur3/YfHvAsqj2tIBAcw5Q0pVnwQT1A03SwrD5PpQKZv9IlN1wFncVmuk+UWM2ZEJXbDUJRrHZktFvG9TTDL4M39HoFDqQNUD2g6Sof6JMmTAmoohHrVBiKDMxHXftuN+K/xnk0XR6xytPGd44R9NLuOVnOSgYldqQzCGHXIutUSfrbji+SWL3bPOJ72PMWolxoB8kVnFzwaiKn8spMzetw5yOsilwcijQy8PqUsDMz6ExKYvTB7N1tKmUccfSQoLG4jRqTlrgVGWpwp/a/kRDN5gsbGasZqi3zRP0tzcSOpAPH2mjfAc6gbrCLkaWPdtzVw3LWDo6HOQ==
# the aes_iv key from the export json
export AES_IV=dcmxMx47CNS6R5d8VcMISA==

openssl enc -in $ENCRYPTED_TARBALL -out $OUTPUT_TAR -d -aes-256-cbc -K `echo $ENCRYPTED_AES_KEY | base64 --decode | openssl rsautl -decrypt -inkey $PRIVATE_KEY_PATH | hexdump -ve '1/1 "%.2x"'` -iv `echo $AES_IV | base64 --decode | hexdump -ve '1/1 "%.2x"'`

Step 2 - Import to Stream

Simply email support@getstream.io with your data export. It typically takes us 1 business day to import the data. (if it's a small import it will take less time).

Depending on your security preferences you can either send us the decrypted file, or the encrypted version with the key to decode it.

Step 3 - Webhooks (optional)

You can start syncing writes from Stream to Layer via webhooks. This is especially useful if you have mobile clients where you can't immediately remove the Layer client. We're currently working on setting up a serverless example for this.

Step 4 - React/ iOS/ React Native

The stream support team will send you a fully functional react example for testing your imported data. You'll want to review these 4 tutorials to learn more about how Stream works:

React Chat Tutorial React Native Chat Tutorial iOS/Swift Chat Tutorial Chat API Tour

Step 5 - Migrate the UI

Implement the UI that you want for your chat, and flip the switch Customizing Stream's libraries is typically easier than starting from scratch.

Keywords

FAQs

Package last updated on 26 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc