SkyID
Global frontend-only verification system for web3 dapps.
https://sky-id.hns.siasky.net/
SkyID:https://sky-note.hns.siasky.net/
Demo dapp using SkyID login:Read security logs in CHANGELOG.md
Getting started
Install
Initialize
var skyid = 'App name'
Initialize with options and callback (optional)
// detect if app is opened on localhost for developmentif windowlocationhostname == 'idtest.local' || windowlocationhostname == 'localhost' || windowlocationprotocol == 'file:'var devMode = trueelsevar devMode = falsevar opts = 'devMode': devModevar skyid = 'App name' skyidEventCallback opts{}
Available options:
Option | default |
---|---|
devMode | false |
disableLoadingScreen | false |
customSkyidUrl | null |
onUploadProgress | null |
Start session (login)
skyid
Destroy session (logout)
skyid
Display classes
If you wnat, you can use special HTML classes, so you don't need to listen for SkyID callbacks.
-
show-if-logged-in
- Setdisplay
to''
if user logged in -
hide-if-logged-in
- Setdisplay
tononde
if user logged in -
show-if-initialized
- Setdisplay
to''
if SkyID initialized -
hide-if-initialized
- Setdisplay
tononde
if SkyID initialized
Example:
<div class="show-if-logged-in"> You are logged in! </div>
You can also combine these classes:
Loading...Loaded and you are not logged in :(Loaded and you are logged in!
It is important to use style="display:none"
and not a CSS class the display property (bad example class="display-none"
) because SkyID will only reset the display attribute and not the CSS class
Documentation
Save JSON
SkyID uses SkyDB under the hood to save, modify, and fetch files. The only difference is that you don't need to remember for your secret key - SkyID generates deterministic keypairs instead.
let yourObject = key1: 'value1'let jsonData = JSONskyid
You can store any JSON data, for example notes, settings, or a list of your uploaded files.
Get JSON
skyid
Set registry entry
skyid
Get registry entry
skyid
Get registry URL
skydbFile = skyid
Upload directory
let files = documentgetElementById'my_input'filesskyid
Upload encrypted file
let file = documentgetElementById'my_input'files0skyid
derivationPath can be any string. It will be hashed with the user's app-seed, no need to make it long since the app-seed is not public. It is recommended to use unique derivationPath to each file, so users can share decription keys for one file without revealing the other files
You can put a callback function to the onUploadProgress
option both for upload and download.
Download encrypted file
let skylink = 'sia:/...'skyid
RFC: https://forum.sia.tech/t/discussion-about-sky-id/64
Used libraries:
Contributors:
@Delivator
❤ Thank you! ❤
Brainstorm participants & helpers:
Taek, wkibbler, redsolver, Nemo, pjbrone, kreelud, Mortal-Killer, RLZL
Development
Install development dependencies
cd SkyID
npm install
Compiling Javascript
You need to compile your node-js files (from the src
folder) to a web-browser friendly javascript. Type
npx webpack
You'll see 3 new .js file in the dist
folder. If you want to edit javascript, you can make changes inside the src
folder and run npx webpack
again. (Of course you can use npx webpack --watch
so it will watch and compile automatically if you change something.
Open in browser
You can just open the /dist/index.html
in your browser.
If you're using the file://
protocol (or idtest.local
as localhost domain), SkyID will recognise you're in development mode and siasky.net will be used as default Skynet portal.
Chrome won't savecookies with file:// protocol. YOu can use Firefox, use idtest.local as localhost domain, or upload the dist folder to Skynet.
Testing with example dapp
We have a SkyID-example-note-dapp, so you can clone it. Don't forget to change the source of skyid.js
if you want to test with self-hosted SkyID (open image)
To be able to test cross-domain things, you need to setup two local virtual-host domains. If you have Wamp.NET installed (what I really recommend), this will be easy. You just need to create two sites pointing to your local SkyID projects: idtest.local
for SkyID and skynote.local
for the example dapp (open image).