dreams-web-sdk v1.7.0
Dreams Web SDK
Dependencies
To install dependencies run
yarn installWe use lefthook. Refer to their github page for installation instructions.
Testing
yarn testWe use jest for testing.
Building
To build distros run
yarn run buildNew 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:
postUpdateTokena response toonIdTokenDidExpiremessagepostAccountProvisionInitiateda response toonAccountProvisionRequestedmessagepostInvestmentAccountProvisionInitiateda response toonInvestmentAccountProvisionRequestedmessagenavigateTothat 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
branchessetting to allow current branch (or'*') if different than main - set
citofalseto allow running it locally - remove
@semantic-release/githuband@semantic-release/gitplugins
Then the process can be started with yarn semantic-release.
Besides publishing the package it will generate the changelog that should be committed.
License
1 year ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago