Comparing version 3.3.0-beta.0 to 3.3.0-beta.1
# bitski | ||
## 3.3.0-beta.1 | ||
### Patch Changes | ||
- [#305](https://github.com/BitskiCo/bitski-js/pull/305) [`eb505af`](https://github.com/BitskiCo/bitski-js/commit/eb505aff9cf0a3e338aec278be131df1b17fb66b) Thanks [@pzuraq](https://github.com/pzuraq)! - - Add destructor for store | ||
- Also thread `Extra` type through provider and add `requestWithExtra` so | ||
requests can be made with additional context. Also add a few missing eth | ||
methods. | ||
- Make stores able to return MaybePromise so they can be more efficient | ||
- Updated dependencies [[`eb505af`](https://github.com/BitskiCo/bitski-js/commit/eb505aff9cf0a3e338aec278be131df1b17fb66b)]: | ||
- bitski-provider@2.0.0-beta.2 | ||
- eth-provider-types@0.1.0-beta.1 | ||
## 3.3.0-beta.0 | ||
@@ -4,0 +17,0 @@ |
@@ -38,3 +38,3 @@ import { ACCESS_TOKEN_KEY, ID_TOKEN_KEY, REFRESH_TOKEN_KEY } from '../constants'; | ||
loadTokensFromCache() { | ||
this.accessToken = this.store.getItem(this.accessTokenKey).then((accessTokenString) => { | ||
this.accessToken = Promise.resolve(this.store.getItem(this.accessTokenKey)).then((accessTokenString) => { | ||
const accessTokenResult = string.decode(accessTokenString); | ||
@@ -45,6 +45,4 @@ if (accessTokenResult.value) { | ||
}); | ||
this.idToken = this.store.getItem(this.idTokenKey).then((token) => string.decode(token).value); | ||
this.refreshToken = this.store | ||
.getItem(this.refreshTokenKey) | ||
.then((token) => string.decode(token).value); | ||
this.idToken = Promise.resolve(this.store.getItem(this.idTokenKey)).then((token) => string.decode(token).value); | ||
this.refreshToken = Promise.resolve(this.store.getItem(this.refreshTokenKey)).then((token) => string.decode(token).value); | ||
} | ||
@@ -51,0 +49,0 @@ persistTokenResponse(response) { |
@@ -139,3 +139,3 @@ import { createBitskiProvider, LocalStorageStore, } from 'bitski-provider'; | ||
createProvider(options = {}) { | ||
return createBitskiProvider(Object.assign(Object.assign({ clientId: this.clientId, getAccessToken: this.getCurrentAccessToken.bind(this), clearAccessToken: this.signOut.bind(this), getUser: async () => this.authProvider.getUserFromCache(), signerBaseUrl: options.webBaseUrl, transactionCallbackUrl: options.callbackURL }, options), { additionalHeaders: Object.assign({ 'X-CLIENT-VERSION': "bitski-sdk-v3.3.0-beta.0" }, options.additionalHeaders), prependMiddleware: undefined })); | ||
return createBitskiProvider(Object.assign(Object.assign({ clientId: this.clientId, getAccessToken: this.getCurrentAccessToken.bind(this), clearAccessToken: this.signOut.bind(this), getUser: async () => this.authProvider.getUserFromCache(), signerBaseUrl: options.webBaseUrl, transactionCallbackUrl: options.callbackURL }, options), { additionalHeaders: Object.assign({ 'X-CLIENT-VERSION': "bitski-sdk-v3.3.0-beta.1" }, options.additionalHeaders), prependMiddleware: undefined })); | ||
} | ||
@@ -142,0 +142,0 @@ onSignOut() { |
@@ -63,4 +63,4 @@ import { processCallback } from './-private/utils/callback'; | ||
async initialize() { | ||
var _a, _b; | ||
const localStorageKeys = ((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.store) === null || _b === void 0 ? void 0 : _b.keys()) || Object.keys(localStorage); | ||
var _a, _b, _c; | ||
const localStorageKeys = (await ((_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.store) === null || _b === void 0 ? void 0 : _b.keys) === null || _c === void 0 ? void 0 : _c.call(_b))) || Object.keys(localStorage); | ||
if (!localStorageKeys.find((key) => key.startsWith('bitski'))) { | ||
@@ -67,0 +67,0 @@ return; |
@@ -41,3 +41,3 @@ "use strict"; | ||
loadTokensFromCache() { | ||
this.accessToken = this.store.getItem(this.accessTokenKey).then((accessTokenString) => { | ||
this.accessToken = Promise.resolve(this.store.getItem(this.accessTokenKey)).then((accessTokenString) => { | ||
const accessTokenResult = decoders_1.string.decode(accessTokenString); | ||
@@ -48,6 +48,4 @@ if (accessTokenResult.value) { | ||
}); | ||
this.idToken = this.store.getItem(this.idTokenKey).then((token) => decoders_1.string.decode(token).value); | ||
this.refreshToken = this.store | ||
.getItem(this.refreshTokenKey) | ||
.then((token) => decoders_1.string.decode(token).value); | ||
this.idToken = Promise.resolve(this.store.getItem(this.idTokenKey)).then((token) => decoders_1.string.decode(token).value); | ||
this.refreshToken = Promise.resolve(this.store.getItem(this.refreshTokenKey)).then((token) => decoders_1.string.decode(token).value); | ||
} | ||
@@ -54,0 +52,0 @@ persistTokenResponse(response) { |
@@ -145,3 +145,3 @@ "use strict"; | ||
createProvider(options = {}) { | ||
return (0, bitski_provider_1.createBitskiProvider)(Object.assign(Object.assign({ clientId: this.clientId, getAccessToken: this.getCurrentAccessToken.bind(this), clearAccessToken: this.signOut.bind(this), getUser: async () => this.authProvider.getUserFromCache(), signerBaseUrl: options.webBaseUrl, transactionCallbackUrl: options.callbackURL }, options), { additionalHeaders: Object.assign({ 'X-CLIENT-VERSION': "bitski-sdk-v3.3.0-beta.0" }, options.additionalHeaders), prependMiddleware: undefined })); | ||
return (0, bitski_provider_1.createBitskiProvider)(Object.assign(Object.assign({ clientId: this.clientId, getAccessToken: this.getCurrentAccessToken.bind(this), clearAccessToken: this.signOut.bind(this), getUser: async () => this.authProvider.getUserFromCache(), signerBaseUrl: options.webBaseUrl, transactionCallbackUrl: options.callbackURL }, options), { additionalHeaders: Object.assign({ 'X-CLIENT-VERSION': "bitski-sdk-v3.3.0-beta.1" }, options.additionalHeaders), prependMiddleware: undefined })); | ||
} | ||
@@ -148,0 +148,0 @@ onSignOut() { |
@@ -73,4 +73,4 @@ "use strict"; | ||
async initialize() { | ||
var _a, _b; | ||
const localStorageKeys = ((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.store) === null || _b === void 0 ? void 0 : _b.keys()) || Object.keys(localStorage); | ||
var _a, _b, _c; | ||
const localStorageKeys = (await ((_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.store) === null || _b === void 0 ? void 0 : _b.keys) === null || _c === void 0 ? void 0 : _c.call(_b))) || Object.keys(localStorage); | ||
if (!localStorageKeys.find((key) => key.startsWith('bitski'))) { | ||
@@ -77,0 +77,0 @@ return; |
@@ -12,3 +12,3 @@ { | ||
}, | ||
"version": "3.3.0-beta.0", | ||
"version": "3.3.0-beta.1", | ||
"scripts": { | ||
@@ -26,4 +26,4 @@ "lint": "eslint . --cache", | ||
"@openid/appauth": "^1.2.6", | ||
"bitski-provider": "^2.0.0-beta.0", | ||
"eth-provider-types": "^0.1.0-beta.0", | ||
"bitski-provider": "^2.0.0-beta.2", | ||
"eth-provider-types": "^0.1.0-beta.1", | ||
"decoders": "^2.0.1" | ||
@@ -30,0 +30,0 @@ }, |
@@ -53,13 +53,17 @@ import { TokenResponse } from '@openid/appauth'; | ||
public loadTokensFromCache(): void { | ||
this.accessToken = this.store.getItem(this.accessTokenKey).then((accessTokenString) => { | ||
const accessTokenResult = string.decode(accessTokenString); | ||
if (accessTokenResult.value) { | ||
return AccessToken.fromString(accessTokenResult.value); | ||
} | ||
}); | ||
this.accessToken = Promise.resolve(this.store.getItem(this.accessTokenKey)).then( | ||
(accessTokenString) => { | ||
const accessTokenResult = string.decode(accessTokenString); | ||
if (accessTokenResult.value) { | ||
return AccessToken.fromString(accessTokenResult.value); | ||
} | ||
}, | ||
); | ||
this.idToken = this.store.getItem(this.idTokenKey).then((token) => string.decode(token).value); | ||
this.refreshToken = this.store | ||
.getItem(this.refreshTokenKey) | ||
.then((token) => string.decode(token).value); | ||
this.idToken = Promise.resolve(this.store.getItem(this.idTokenKey)).then( | ||
(token) => string.decode(token).value, | ||
); | ||
this.refreshToken = Promise.resolve(this.store.getItem(this.refreshTokenKey)).then( | ||
(token) => string.decode(token).value, | ||
); | ||
} | ||
@@ -66,0 +70,0 @@ |
@@ -115,3 +115,3 @@ import { processCallback } from './-private/utils/callback'; | ||
async initialize(): Promise<void> { | ||
const localStorageKeys = this.options?.store?.keys() || Object.keys(localStorage); | ||
const localStorageKeys = (await this.options?.store?.keys?.()) || Object.keys(localStorage); | ||
@@ -118,0 +118,0 @@ if (!localStorageKeys.find((key) => key.startsWith('bitski'))) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1036479
21040