Skip to content

Commit 270d8d1

Browse files
committed
feat(javascript): refactor sign-in, sign-out, and sign-up options to improve organization and documentation
1 parent f0b54df commit 270d8d1

File tree

3 files changed

+64
-6
lines changed

3 files changed

+64
-6
lines changed

packages/javascript/src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,18 @@ export {
7575
EmbeddedFlowExecuteRequestConfig,
7676
} from './models/embedded-flow';
7777
export {FlowMode} from './models/flow';
78-
export {AsgardeoClient, SignInOptions, SignOutOptions, SignUpOptions} from './models/client';
79-
export {BaseConfig, Config, Preferences, ThemePreferences, I18nPreferences, WithPreferences} from './models/config';
78+
export {AsgardeoClient} from './models/client';
79+
export {
80+
BaseConfig,
81+
Config,
82+
Preferences,
83+
ThemePreferences,
84+
I18nPreferences,
85+
WithPreferences,
86+
SignInOptions,
87+
SignOutOptions,
88+
SignUpOptions,
89+
} from './models/config';
8090
export {TokenResponse, IdToken, TokenExchangeRequestConfig} from './models/token';
8191
export {Crypto, JWKInterface} from './models/crypto';
8292
export {OAuthResponseMode} from './models/oauth-response';

packages/javascript/src/models/client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ import {Organization} from './organization';
2727
import {User, UserProfile} from './user';
2828
import {TokenResponse} from './token';
2929
import {Storage} from './store';
30-
31-
export type SignInOptions = Record<string, unknown>;
32-
export type SignOutOptions = Record<string, unknown>;
33-
export type SignUpOptions = Record<string, unknown>;
30+
import {SignInOptions, SignOutOptions, SignUpOptions} from './config';
3431

3532
/**
3633
* Interface defining the core functionality for Asgardeo authentication clients.

packages/javascript/src/models/config.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,39 @@ import {I18nBundle} from './i18n';
2020
import {RecursivePartial} from './utility-types';
2121
import {ThemeConfig, ThemeMode} from '../theme/types';
2222

23+
/**
24+
* Interface representing the additional parameters to be sent in the sign-in request.
25+
* This can include custom parameters that your authorization server supports.
26+
* These parameters will be included in the authorization request sent to the server.
27+
* If not provided, no additional parameters will be sent.
28+
*
29+
* @example
30+
* signInOptions: { prompt: "login", fidp: "OrganizationSSO" }
31+
*/
32+
export type SignInOptions = Record<string, any>;
33+
34+
/**
35+
* Interface representing the additional parameters to be sent in the sign-out request.
36+
* This can include custom parameters that your authorization server supports.
37+
* These parameters will be included in the sign-out request sent to the server.
38+
* If not provided, no additional parameters will be sent.
39+
*
40+
* @example
41+
* signOutOptions: { idTokenHint: "your-id-token-hint" }
42+
*/
43+
export type SignOutOptions = Record<string, unknown>;
44+
45+
/**
46+
* Interface representing the additional parameters to be sent in the sign-up request.
47+
* This can include custom parameters that your authorization server supports.
48+
* These parameters will be included in the sign-up request sent to the server.
49+
* If not provided, no additional parameters will be sent.
50+
*
51+
* @example
52+
* signUpOptions: { appId: "your-app-id" }
53+
*/
54+
export type SignUpOptions = Record<string, unknown>;
55+
2356
export interface BaseConfig<T = unknown> extends WithPreferences {
2457
/**
2558
* Optional URL where the authorization server should redirect after authentication.
@@ -134,6 +167,24 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
134167
clockTolerance?: number;
135168
};
136169
};
170+
171+
/**
172+
* Optional additional parameters to be sent in the authorize request.
173+
* @see {@link SignInOptions} for more details.
174+
*/
175+
signInOptions?: SignInOptions;
176+
177+
/**
178+
* Optional additional parameters to be sent in the sign-out request.
179+
* @see {@link SignOutOptions} for more details.
180+
*/
181+
signOutOptions?: SignOutOptions;
182+
183+
/**
184+
* Optional additional parameters to be sent in the sign-up request.
185+
* @see {@link SignUpOptions} for more details.
186+
*/
187+
signUpOptions?: SignUpOptions;
137188
}
138189

139190
export interface WithPreferences {

0 commit comments

Comments
 (0)