Comparing version
# bitski | ||
## 3.6.0 | ||
### Minor Changes | ||
- [#386](https://github.com/BitskiCo/bitski-js/pull/386) [`2c34004`](https://github.com/BitskiCo/bitski-js/commit/2c34004f3521aed613400c0446922f6d1b8fc2ed) Thanks [@chronicIntrovert](https://github.com/chronicIntrovert)! - Add login prompt as request option for sign in | ||
## 3.5.0 | ||
@@ -4,0 +10,0 @@ |
@@ -177,2 +177,5 @@ import { AuthorizationNotifier, AuthorizationRequest, AuthorizationServiceConfiguration, BaseTokenRequestHandler, FetchRequestor, GRANT_TYPE_AUTHORIZATION_CODE, GRANT_TYPE_REFRESH_TOKEN, RedirectRequestHandler, TokenRequest, } from '@openid/appauth'; | ||
} | ||
if (opts.prompt) { | ||
request.extras = Object.assign(Object.assign({}, request.extras), { prompt: opts.prompt }); | ||
} | ||
return request; | ||
@@ -179,0 +182,0 @@ } |
@@ -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.5.0" }, options.additionalHeaders), prependMiddleware: undefined, signerMethod: 'iframe' })); | ||
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.6.0" }, options.additionalHeaders), prependMiddleware: undefined, signerMethod: 'iframe' })); | ||
} | ||
@@ -142,0 +142,0 @@ onSignOut() { |
@@ -207,2 +207,3 @@ import { processCallback } from './-private/utils/callback'; | ||
export const LOGIN_HINT_SIGNUP = 'signup'; | ||
export const LOGIN_PROMPT = 'login'; | ||
function networkFromName(networkName) { | ||
@@ -209,0 +210,0 @@ switch (networkName) { |
@@ -11,2 +11,3 @@ import { type AuthorizationError, AuthorizationNotifier, AuthorizationRequest, type AuthorizationRequestHandler, type AuthorizationResponse, AuthorizationServiceConfiguration, TokenRequest, type TokenRequestHandler, type TokenResponse } from '@openid/appauth'; | ||
login_hint?: string; | ||
prompt?: string; | ||
} | ||
@@ -13,0 +14,0 @@ export declare const LOGIN_HINT_SIGNUP = "signup"; |
@@ -180,2 +180,5 @@ "use strict"; | ||
} | ||
if (opts.prompt) { | ||
request.extras = Object.assign(Object.assign({}, request.extras), { prompt: opts.prompt }); | ||
} | ||
return request; | ||
@@ -182,0 +185,0 @@ } |
@@ -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.5.0" }, options.additionalHeaders), prependMiddleware: undefined, signerMethod: 'iframe' })); | ||
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.6.0" }, options.additionalHeaders), prependMiddleware: undefined, signerMethod: 'iframe' })); | ||
} | ||
@@ -148,0 +148,0 @@ onSignOut() { |
@@ -123,1 +123,2 @@ import { BitskiProviderShim } from './provider-shim'; | ||
export declare const LOGIN_HINT_SIGNUP = "signup"; | ||
export declare const LOGIN_PROMPT = "login"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LOGIN_HINT_SIGNUP = exports.Bitski = exports.OAuthSignInMethod = exports.AuthenticationStatus = exports.Mumbai = exports.Polygon = exports.Goerli = exports.Mainnet = exports.BinanceSmartChainTestnet = exports.BinanceSmartChain = void 0; | ||
exports.LOGIN_PROMPT = exports.LOGIN_HINT_SIGNUP = exports.Bitski = exports.OAuthSignInMethod = exports.AuthenticationStatus = exports.Mumbai = exports.Polygon = exports.Goerli = exports.Mainnet = exports.BinanceSmartChainTestnet = exports.BinanceSmartChain = void 0; | ||
const callback_1 = require("./-private/utils/callback"); | ||
@@ -218,2 +218,3 @@ const load_1 = require("./load"); | ||
exports.LOGIN_HINT_SIGNUP = 'signup'; | ||
exports.LOGIN_PROMPT = 'login'; | ||
function networkFromName(networkName) { | ||
@@ -220,0 +221,0 @@ switch (networkName) { |
@@ -12,3 +12,3 @@ { | ||
}, | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"scripts": { | ||
@@ -15,0 +15,0 @@ "lint": "eslint . --cache", |
@@ -189,2 +189,12 @@ ## Bitski JS SDK | ||
### Customizing the login prompt | ||
If you want to select the WaaS account on login, you can additionally pass the `prompt` parameter to the `signIn` method. | ||
```ts | ||
import { LOGIN_HINT_SIGNUP, LOGIN_PROMPT } from 'bitski'; | ||
bitski.signIn({ login_hint: LOGIN_HINT_SIGNUP, prompt: LOGIN_PROMPT }); | ||
``` | ||
_Note: In order for the popup window to properly open in most browsers, this needs to be triggered with a click action, otherwise it could be blocked. For your convenience, we've included a standard login button that handles that for you._ | ||
@@ -251,3 +261,3 @@ | ||
- authMethod: The sign in method to use. `POPUP` or `REDIRECT`. Default is `POPUP`. | ||
- signInOptions: The options to pass during the sign in request (currently, only login_hint is supported. See above.) | ||
- signInOptions: The options to pass during the sign in request (login_hint and prompt are supported. See above.) | ||
@@ -254,0 +264,0 @@ Note that the `callback` will be called for either successful or failed login attempts. To handle the case where the user cancels part way through, set the `onCancel` handler. |
@@ -37,2 +37,3 @@ import { | ||
login_hint?: string; | ||
prompt?: string; | ||
} | ||
@@ -247,2 +248,6 @@ | ||
if (opts.prompt) { | ||
request.extras = { ...request.extras, prompt: opts.prompt }; | ||
} | ||
return request; | ||
@@ -249,0 +254,0 @@ } |
@@ -21,3 +21,3 @@ import { SignInOptions, USER_CANCELLED_MESSAGE } from '../auth/oauth-manager'; | ||
authMethod?: OAuthSignInMethod; | ||
// Additional sign in options (login_hint) to call sign in with. | ||
// Additional sign in options (login_hint, prompt) to call sign in with. | ||
signInOptions?: SignInOptions; | ||
@@ -24,0 +24,0 @@ // Existing HTML element to embed the Bitski connect button in. |
@@ -282,2 +282,3 @@ import { processCallback } from './-private/utils/callback'; | ||
export const LOGIN_HINT_SIGNUP = 'signup'; | ||
export const LOGIN_PROMPT = 'login'; | ||
@@ -284,0 +285,0 @@ function networkFromName(networkName: string): Network { |
@@ -169,3 +169,3 @@ import { User } from '../src/-private/auth/user'; | ||
spy.mockResolvedValue(dummyUser); | ||
const opts = { login_hint: 'foo' }; | ||
const opts = { login_hint: 'foo', prompt: 'login' }; | ||
return bitski.signIn(opts).then((user) => { | ||
@@ -199,3 +199,3 @@ expect(spy).toHaveBeenCalledWith(OAuthSignInMethod.Popup, opts); | ||
spy.mockResolvedValue(dummyUser); | ||
const opts = { login_hint: 'foo' }; | ||
const opts = { login_hint: 'foo', prompt: 'login' }; | ||
bitski.signInRedirect(opts); | ||
@@ -202,0 +202,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { LOGIN_HINT_SIGNUP } from '../src/index'; | ||
import { LOGIN_HINT_SIGNUP, LOGIN_PROMPT } from '../src/index'; | ||
import { NoHashQueryStringUtils } from '../src/-private/utils/no-hash-query-string-utils'; | ||
@@ -87,3 +87,3 @@ import { MockOAuthManager } from './util/mock-oauth-manager'; | ||
test('signInPopup passes options to authorization request', () => { | ||
expect.assertions(2); | ||
expect.assertions(3); | ||
const manager = createInstance(); | ||
@@ -97,14 +97,16 @@ jest.spyOn(window, 'open').mockImplementation(() => { | ||
}); | ||
manager.signInPopup({ login_hint: LOGIN_HINT_SIGNUP }); | ||
manager.signInPopup({ login_hint: LOGIN_HINT_SIGNUP, prompt: LOGIN_PROMPT }); | ||
expect(manager.currentAuthRequest).toBeDefined(); | ||
expect(manager.currentAuthRequest?.extras?.login_hint).toBe(LOGIN_HINT_SIGNUP); | ||
expect(manager.currentAuthRequest?.extras?.prompt).toBe(LOGIN_PROMPT); | ||
}); | ||
test('signInRedirect passes options to authorization request', () => { | ||
expect.assertions(2); | ||
expect.assertions(3); | ||
const manager = createInstance(); | ||
window.location.assign = jest.fn(); | ||
manager.signInRedirect({ login_hint: LOGIN_HINT_SIGNUP }); | ||
manager.signInPopup({ login_hint: LOGIN_HINT_SIGNUP, prompt: LOGIN_PROMPT }); | ||
expect(manager.currentAuthRequest).toBeDefined(); | ||
expect(manager.currentAuthRequest?.extras?.login_hint).toBe(LOGIN_HINT_SIGNUP); | ||
expect(manager.currentAuthRequest?.extras?.prompt).toBe(LOGIN_PROMPT); | ||
}); | ||
@@ -111,0 +113,0 @@ |
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
1071920
0.15%21436
0.09%553
1.84%