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 c271fbc
Show file tree
Hide file tree
Showing 3 changed files with 18 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
20 changes: 15 additions & 5 deletions src/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,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 +882,8 @@ export class Identity extends EventEmitter {
maxAge,
locale,
oneStepLogin,
prompt
prompt,
frontendVersion
});

if (preferPopup) {
Expand Down Expand Up @@ -952,6 +954,7 @@ export class Identity extends EventEmitter {
locale = '',
oneStepLogin = false,
prompt = 'select_account',
frontendVersion,
}) {
if (typeof arguments[0] !== 'object') {
// backward compatibility
Expand All @@ -972,7 +975,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 +987,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 c271fbc

Please sign in to comment.