Skip to content

Commit

Permalink
feat: add support for frontend v2
Browse files Browse the repository at this point in the history
ref: UUI-1468
  • Loading branch information
hunger-programmer committed Jul 3, 2024
1 parent 2e9b133 commit c82d06c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@schibsted/account-sdk-browser",
"version": "5.0.1",
"version": "5.0.2",
"description": "Schibsted account SDK for browsers",
"main": "index.js",
"type": "module",
Expand Down
21 changes: 16 additions & 5 deletions src/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ export class Identity extends EventEmitter {
* @param {string} [options.locale]
* @param {boolean} [options.oneStepLogin=false]
* @param {string} [options.prompt=select_account]
* @param {string} [options.frontendVersion]
* @return {Window|null} - Reference to popup window if created (or `null` otherwise)
*/
login({
Expand All @@ -866,7 +867,8 @@ export class Identity extends EventEmitter {
maxAge = '',
locale = '',
oneStepLogin = false,
prompt = 'select_account'
prompt = 'select_account',
frontendVersion
}) {
this._closePopup();
this.sessionStorageCache.delete(HAS_SESSION_CACHE_KEY);
Expand All @@ -881,7 +883,8 @@ export class Identity extends EventEmitter {
maxAge,
locale,
oneStepLogin,
prompt
prompt,
frontendVersion
});

if (preferPopup) {
Expand Down Expand Up @@ -952,6 +955,7 @@ export class Identity extends EventEmitter {
locale = '',
oneStepLogin = false,
prompt = 'select_account',
frontendVersion,
}) {
if (typeof arguments[0] !== 'object') {
// backward compatibility
Expand All @@ -972,7 +976,7 @@ export class Identity extends EventEmitter {
assert(isNonEmptyString(state),
`the state parameter should be a non empty string but it is ${state}`);

return this._oauthService.makeUrl('oauth/authorize', {
const queryParams = {
response_type: 'code',
redirect_uri: redirectUri,
scope,
Expand All @@ -984,8 +988,15 @@ export class Identity extends EventEmitter {
max_age: maxAge,
locale,
one_step_login: oneStepLogin || '',
prompt: acrValues ? '' : prompt
});
prompt: acrValues ? '' : prompt,
}

if(frontendVersion){
assert(isStrIn(frontendVersion, ['v2']), 'the frontendVersion parameter must be a valid version');
queryParams.frontendVersion = frontendVersion
}

return this._oauthService.makeUrl('oauth/authorize', queryParams);
}

/**
Expand Down

0 comments on commit c82d06c

Please sign in to comment.