Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/tall-lemons-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@asgardeo/browser': patch
'@asgardeo/javascript': patch
'@asgardeo/nextjs': patch
'@asgardeo/react': patch
'@asgardeo/react-router': patch
'@asgardeo/vue': patch
---

This update addresses issues in the `@asgardeo/react-router` package and exposes the `signInSilently` method from the `@asgardeo/react` package. The changes ensure that the `ProtectedRoute` component works correctly with the new sign-in functionality.
6 changes: 3 additions & 3 deletions packages/browser/src/__legacy__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@ export class AsgardeoSPAClient {
*
* @example
*```
* auth.trySignInSilently()
* auth.signInSilently()
*```
*/
public async trySignInSilently(
public async signInSilently(
additionalParams?: Record<string, string | boolean>,
tokenRequestConfig?: {params: Record<string, unknown>},
): Promise<User | boolean | undefined> {
Expand All @@ -442,7 +442,7 @@ export class AsgardeoSPAClient {
return undefined;
}

return this._client?.trySignInSilently(additionalParams, tokenRequestConfig).then((response: User | boolean) => {
return this._client?.signInSilently(additionalParams, tokenRequestConfig).then((response: User | boolean) => {
if (this._onSignInCallback && response) {
this._onSignInCallback(response as User);
}
Expand Down
9 changes: 5 additions & 4 deletions packages/browser/src/__legacy__/clients/main-thread-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ export const MainThreadClient = async (
* @return {Promise<User|boolean} Returns a Promise that resolves with the User
* if the user is signed in or with `false` if there is no active user session in the server.
*/
const trySignInSilently = async (
const signInSilently = async (
additionalParams?: Record<string, string | boolean>,
tokenRequestConfig?: {params: Record<string, unknown>},
): Promise<User | boolean> =>
_authenticationHelper.trySignInSilently(
_authenticationHelper.signInSilently(
constructSilentSignInUrl,
requestAccessToken,
_sessionManagementHelper,
Expand All @@ -370,7 +370,8 @@ export const MainThreadClient = async (

const getUser = async (): Promise<User> => _authenticationHelper.getUser();

const getDecodedIdToken = async (sessionId?: string): Promise<IdToken> => _authenticationHelper.getDecodedIdToken(sessionId);
const getDecodedIdToken = async (sessionId?: string): Promise<IdToken> =>
_authenticationHelper.getDecodedIdToken(sessionId);

const getCrypto = async (): Promise<IsomorphicCrypto> => _authenticationHelper.getCrypto();

Expand Down Expand Up @@ -437,7 +438,7 @@ export const MainThreadClient = async (
setHttpRequestSuccessCallback,
signIn,
signOut,
trySignInSilently,
signInSilently,
reInitialize,
};
};
6 changes: 3 additions & 3 deletions packages/browser/src/__legacy__/clients/web-worker-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ export const WebWorkerClient = async (
* @return {Promise<User|boolean} Returns a Promise that resolves with the User
* if the user is signed in or with `false` if there is no active user session in the server.
*/
const trySignInSilently = async (
const signInSilently = async (
additionalParams?: Record<string, string | boolean>,
tokenRequestConfig?: {params: Record<string, unknown>},
): Promise<User | boolean> => {
return await _authenticationHelper.trySignInSilently(
return await _authenticationHelper.signInSilently(
constructSilentSignInUrl,
requestAccessToken,
_sessionManagementHelper,
Expand Down Expand Up @@ -859,7 +859,7 @@ export const WebWorkerClient = async (
setHttpRequestSuccessCallback,
signIn,
signOut,
trySignInSilently,
signInSilently,
reInitialize,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
);
}

public async trySignInSilently(
public async signInSilently(
constructSilentSignInUrl: (additionalParams?: Record<string, string | boolean>) => Promise<string>,
requestAccessToken: (
authzCode: string,
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/__legacy__/models/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface MainThreadClientInterface {
getStorageManager(): Promise<StorageManager<MainThreadClientConfig>>;
isSignedIn(): Promise<boolean>;
reInitialize(config: Partial<AuthClientConfig<MainThreadClientConfig>>): Promise<void>;
trySignInSilently(
signInSilently(
additionalParams?: Record<string, string | boolean>,
tokenRequestConfig?: {params: Record<string, unknown>},
): Promise<User | boolean>;
Expand Down Expand Up @@ -107,7 +107,7 @@ export interface WebWorkerClientInterface {
setHttpRequestFinishCallback(callback: () => void): void;
refreshAccessToken(): Promise<User>;
reInitialize(config: Partial<AuthClientConfig<WebWorkerClientConfig>>): Promise<void>;
trySignInSilently(
signInSilently(
additionalParams?: Record<string, string | boolean>,
tokenRequestConfig?: {params: Record<string, unknown>},
): Promise<User | boolean>;
Expand Down
2 changes: 2 additions & 0 deletions packages/javascript/src/AsgardeoJavaScriptClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T>
onSignInSuccess?: (afterSignInUrl: string) => void,
): Promise<User>;

abstract signInSilently(options?: SignInOptions): Promise<User | boolean>;

abstract signOut(options?: SignOutOptions, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
abstract signOut(
options?: SignOutOptions,
Expand Down
13 changes: 12 additions & 1 deletion packages/javascript/src/models/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface AsgardeoClient<T> {
* @param organization - The organization to switch to.
* @returns A promise that resolves when the switch is complete.
*/
switchOrganization(organization: Organization, sessionId?: string): Promise<TokenResponse | Response> ;
switchOrganization(organization: Organization, sessionId?: string): Promise<TokenResponse | Response>;

getConfiguration(): T;

Expand Down Expand Up @@ -137,6 +137,17 @@ export interface AsgardeoClient<T> {
onSignInSuccess?: (afterSignInUrl: string) => void,
): Promise<User>;

/**
* Try signing in silently in the background without any user interactions.
*
* @remarks This approach uses a passive auth request (prompt=none) sent from an iframe which might pose issues in cross-origin scenarios.
* Make sure you are aware of the limitations and browser compatibility issues.
*
* @param options - Optional sign-in options like additional parameters to be sent in the authorize request, etc.
* @returns A promise that resolves to the user if sign-in is successful, or false if not.
*/
signInSilently(options?: SignInOptions): Promise<User | boolean>;

/**
* Signs out the currently signed-in user.
*
Expand Down
9 changes: 9 additions & 0 deletions packages/nextjs/src/AsgardeoNextClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,15 @@ class AsgardeoNextClient<T extends AsgardeoNextConfig = AsgardeoNextConfig> exte
);
}

override signInSilently(options?: SignInOptions): Promise<User | boolean> {
throw new AsgardeoRuntimeError(
'Not implemented',
'AsgardeoNextClient-signInSilently-NotImplementedError-001',
'nextjs',
'The signInSilently method is not implemented in the Next.js client.',
);
}

/**
* Gets the sign-in URL for authentication.
* Ensures the client is initialized before making the call.
Expand Down
Loading
Loading