dreams-web-sdk
v1.6.0
Published
## Dependencies
Downloads
17
Readme
Dreams Web SDK
Dependencies
To install dependencies run
yarn install
We use lefthook. Refer to their github page for installation instructions.
Testing
yarn test
We use jest for testing.
Building
To build distros run
yarn run build
New distros are going to be created in the dist
folder.
For more info about building packages refer to rollup webpage.
Usage
<div id="dreams-web-sdk-container"></div>
<script src="path/to/dreams/sdk/js/file">
var callbacks = {
onIdTokenDidExpire: async () => {
const resp = await fetch("/token-expired-endpoint");
const data = await resp.json();
return data.token;
},
onAccountProvisionRequested: async () => {
await fetch("/provision-account-endpoint")
},
onExitRequested: () => {
window.location.href = "http://example.com/some/path"
},
onTransferConsentRequested: (event) => promise.resolve({consentId: event.message.consentId, requestId: event.message.requestId, consentRef: 'foo'}),
onAccountRequested: (event) => promise.resolve({requestId: event.message.requestId})
}
var sdk = new DreamsWebSDK("https://dreams.api.endpoint");
// Optional param to redirect user inside dreams app
var location = "marketplace";
// Optional param to set the theme (light/dark)
var theme = "light";
sdk.setup(callbacks);
sdk.start(user_jwk_token_value, "en", location, theme);
</script>
Manually sending a message
<div id="dreams-web-sdk-container"></div>
<script src="path/to/dreams/sdk/js/file">
var callbacks = {}
var sdk = new DreamsWebSDK("https://dreams.api.endpoint");
var messageHandler = sdk.setup(callbacks);
sdk.start(user_jwk_token_value, "en");
const new_token = await fetch("/token-endpoint");
messageHandler.postUpdateToken('request-id-string', new_token)
</script>
message types
currently we can:
postUpdateToken
a response toonIdTokenDidExpire
messagepostAccountProvisionInitiated
a response toonAccountProvisionRequested
messagepostInvestmentAccountProvisionInitiated
a response toonInvestmentAccountProvisionRequested
messagenavigateTo
that has no corresponding dreams side message
see the docs about their usage.
Contributing
Commit naming
We use commitlint to make sure commit messages adhere to certain rules. These are:
Semantic release takes care of automatically bumping release versions provided that we name commits correctly. Here you can find what constitutes a patch/feature/breaking release.
Manual release process
It's possible to manually release a new version locally. Prerequisites:
- Obtain npm token used for releasing. It needs to be put in .npmrc file
In order to leverage semantic-release modify release.config.js
file as follows:
- change the
branches
setting to allow current branch (or'*'
) if different than main - set
ci
tofalse
to allow running it locally - remove
@semantic-release/github
and@semantic-release/git
plugins
Then the process can be started with yarn semantic-release
.
Besides publishing the package it will generate the changelog that should be committed.