0.9.4
Single sign on and authentication without third parties or remote servers.
Generates an authentication request and redirects the user to the Blockstack browser to approve the sign in request.
Please note that this requires that the web browser properly handles the
blockstack:
URL protocol handler.
Most applications should use this
method for sign in unless they require more fine grained control over how the
authentication request is generated. If your app falls into this category,
use generateAndStoreAppKey
, makeAuthRequest
,
and redirectToSignInWithAuthRequest
to build your own sign in process.
(String
= `${window.location.origin}/`
)
The location to which the identity provider will redirect the user after
the user approves sign in.
(String
= `${window.location.origin}/manifest.json`
)
Location of the manifest file.
(Array
= DEFAULT_SCOPE
)
Defaults to requesting write access to
this app's data store.
An array of strings indicating which permissions this app is requesting.
void
:
Check if there is a authentication request that hasn't been handled.
Boolean
:
true
if there is a pending sign in, otherwise
false
Try to process any pending sign in request by returning a Promise
that resolves
to the user data object if the sign in succeeds.
(String
= 'https://core.blockstack.org/v1/names/'
)
the endpoint against which to verify public
keys match claimed username
Promise
:
that resolves to the user data object if successful and rejects
if handling the sign in request fails or there was no pending sign in request.
Retrieves the user data object. The user's profile is stored in the key profile
.
Object
:
User data object.
Check if a user is currently signed in.
Boolean
:
true
if the user is signed in,
false
if not.
Sign the user out and redirect to given location.
(String
= '/'
)
Location to redirect user to after sign out.
void
:
Generates an authentication request that can be sent to the Blockstack browser for the user to approve sign in.
(String
= generateAndStoreAppKey()
)
hex encoded app private key
(String
= `${window.location.origin}/`
)
location to redirect user to after sign in approval
(String
= `${window.location.origin}/manifest.json`
)
location of this app's manifest file
(String
= window.location.origin
)
the origin of this app
(Number
= nextHour().getTime()
)
the time at which this request is no longer valid
String
:
the authentication request
Redirects the user to the Blockstack browser to approve the sign in request given.
The user is redirected to the blockstackIDHost
if the blockstack:
protocol handler is not detected. Please note that the protocol handler detection
does not work on all browsers.
(String
= DEFAULT_BLOCKSTACK_HOST
)
the URL to redirect the user to if the blockstack
protocol handler is not detected
void
:
Retrieve the authentication token from the URL query
String
:
the authentication token if it exists otherwise
null
Identity you own and control.
Extracts a profile from an encoded token and optionally verifies it,
if publicKeyOrAddress
is provided.
(String)
the token to be extracted
(String
= null
)
the public key or address of the
keypair that is thought to have signed the token
Object
:
the profile extracted from the encoded token
publicKeyOrAddress
Wraps a token for a profile token file
(String)
the token to be wrapped
Object
:
including
token
and
decodedToken
Signs a profile token
(Object)
the JSON of the profile to be signed
(String)
the signing private key
(Object
= null
)
the entity that the information is about
(Object
= null
)
the entity that is issuing the token
(String
= 'ES256K'
)
the signing algorithm to use
(Date
= new Date()
)
the time of issuance of the token
(Date
= nextYear()
)
the time of expiration of the token
Object
:
the signed profile token
Verifies a profile token
(String)
the token to be verified
(String)
the public key or address of the
keypair that is thought to have signed the token
Object
:
the verified, decoded profile token
Store your app's data without servers in storage your user controls.
Retrieves the specified file from the app's data store.
(String)
the path to the file to read
Promise
:
that resolves to the raw data in the file
or rejects with an error
Stores the data provided in the app's data store to to the file specified.
(String)
the path to store the data in
Promise
:
that resolves if the operation succeed and rejects
if it failed