Skip to content

Commit

Permalink
Add response_hint to login URL and type ui_options as string or array…
Browse files Browse the repository at this point in the history
  • Loading branch information
Akurganow authored and kirill-konshin committed May 27, 2020
1 parent 5659f76 commit 30d7582
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
20 changes: 20 additions & 0 deletions sdk/src/platform/Platform-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,26 @@ describe('RingCentral.platform.Platform', () => {
usePKCE: true,
}),
).to.throw('PKCE only works with Authrization Code Flow');

expect(
platform.loginUrl({
implicit: false,
uiOptions: ['foo', 'bar'],
responseHint: ['baz', 'quux'],
}),
).to.equal(
'http://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Ffoo&client_id=whatever&state=&brand_id=&display=&prompt=&ui_options=foo&ui_options=bar&ui_locales=&localeId=&response_hint=baz&response_hint=quux',
);

expect(
platform.loginUrl({
implicit: false,
uiOptions: 'foo',
responseHint: 'bar',
}),
).to.equal(
'http://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Ffoo&client_id=whatever&state=&brand_id=&display=&prompt=&ui_options=foo&ui_locales=&localeId=&response_hint=bar',
);
}),
);
});
Expand Down
10 changes: 8 additions & 2 deletions sdk/src/platform/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default class Platform extends EventEmitter {
uiLocales,
localeId,
usePKCE,
responseHint,
}: LoginUrlOptions = {}) {
let query: AuthorizationQuery = {
response_type: implicit ? 'token' : 'code',
Expand All @@ -186,6 +187,9 @@ export default class Platform extends EventEmitter {
ui_locales: uiLocales,
localeId,
};
if (responseHint) {
query.response_hint = responseHint;
}
if (usePKCE && implicit) {
throw new Error('PKCE only works with Authrization Code Flow');
}
Expand Down Expand Up @@ -646,10 +650,11 @@ export interface LoginUrlOptions {
display?: LoginUrlDisplay | string;
prompt?: LoginUrlPrompt | string;
implicit?: boolean;
uiOptions?: string;
uiOptions?: string | string[];
uiLocales?: string;
localeId?: string;
usePKCE?: boolean;
responseHint?: string | string[];
}

export enum LoginUrlPrompt {
Expand Down Expand Up @@ -682,13 +687,14 @@ export interface LoginWindowOptions {

export interface AuthorizationQuery {
response_type: 'token' | 'code';
response_hint?: string | string[];
redirect_uri: string;
client_id: string;
state?: string;
brand_id?: string;
display?: LoginUrlDisplay | string;
prompt?: LoginUrlPrompt | string;
ui_options?: string;
ui_options?: string | string[];
ui_locales?: string;
localeId?: string;
code_challenge?: string;
Expand Down

0 comments on commit 30d7582

Please sign in to comment.