Skip to content

Commit 3c0406c

Browse files
authored
Merge pull request #100 from brionmario/next-fixes
chore: expose a `http` module from `useAuthentication` instead of `fetch`
2 parents a3fa4e1 + 399a2e1 commit 3c0406c

File tree

21 files changed

+1560
-80
lines changed

21 files changed

+1560
-80
lines changed

.changeset/warm-dots-obey.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@asgardeo/javascript': patch
3+
'@asgardeo/browser': patch
4+
'@asgardeo/nextjs': patch
5+
'@asgardeo/react': patch
6+
---
7+
8+
Expose `http` module instead of `fetch`

packages/browser/src/__legacy__/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ export class AsgardeoSPAClient {
813813
*
814814
* @preserve
815815
*/
816-
public async getAccessToken(): Promise<string> {
816+
public async getAccessToken(sessionId?: string): Promise<string> {
817817
await this._validateMethod();
818818

819819
if (this._storage && [(BrowserStorage.WebWorker, BrowserStorage.BrowserMemory)].includes(this._storage)) {
@@ -827,7 +827,7 @@ export class AsgardeoSPAClient {
827827
}
828828
const mainThreadClient = this._client as MainThreadClientInterface;
829829

830-
return mainThreadClient.getAccessToken();
830+
return mainThreadClient.getAccessToken(sessionId);
831831
}
832832

833833
/**

packages/browser/src/__legacy__/clients/main-thread-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export const MainThreadClient = async (
380380
const getOpenIDProviderEndpoints = async (): Promise<OIDCEndpoints> =>
381381
_authenticationHelper.getOpenIDProviderEndpoints();
382382

383-
const getAccessToken = async (): Promise<string> => _authenticationHelper.getAccessToken();
383+
const getAccessToken = async (sessionId?: string): Promise<string> => _authenticationHelper.getAccessToken(sessionId);
384384

385385
const getStorageManager = async (): Promise<StorageManager<MainThreadClientConfig>> =>
386386
_authenticationHelper.getStorageManager();

packages/browser/src/__legacy__/helpers/authentication-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
679679
return this._authenticationClient.getOpenIDProviderEndpoints() as any;
680680
}
681681

682-
public async getAccessToken(): Promise<string> {
683-
return this._authenticationClient.getAccessToken();
682+
public async getAccessToken(sessionId?: string): Promise<string> {
683+
return this._authenticationClient.getAccessToken(sessionId);
684684
}
685685

686686
public async getIDPAccessToken(): Promise<string> {

packages/browser/src/__legacy__/models/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface MainThreadClientInterface {
6464
getConfigData(): Promise<AuthClientConfig<MainThreadClientConfig>>;
6565
getIdToken(): Promise<string>;
6666
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
67-
getAccessToken(): Promise<string>;
67+
getAccessToken(sessionId?: string): Promise<string>;
6868
getStorageManager(): Promise<StorageManager<MainThreadClientConfig>>;
6969
isSignedIn(): Promise<boolean>;
7070
reInitialize(config: Partial<AuthClientConfig<MainThreadClientConfig>>): Promise<void>;

packages/javascript/src/AsgardeoJavaScriptClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T>
7878
abstract signUp(options?: SignUpOptions): Promise<void>;
7979
abstract signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
8080
abstract signUp(payload?: unknown): Promise<void> | Promise<EmbeddedFlowExecuteResponse>;
81+
82+
abstract getAccessToken(sessionId?: string): Promise<string>;
8183
}
8284

8385
export default AsgardeoJavaScriptClient;

packages/javascript/src/models/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,11 @@ export interface AsgardeoClient<T> {
187187
* @returns A promise that resolves to an EmbeddedFlowExecuteResponse containing the flow execution details.
188188
*/
189189
signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
190+
191+
/**
192+
* Retrieves the access token for the current session.
193+
* @param sessionId - Optional session ID to retrieve the access token for a specific session.
194+
* @returns A promise that resolves to the access token string.
195+
*/
196+
getAccessToken(sessionId?: string): Promise<string>;
190197
}

packages/nextjs/QUICKSTART.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Create a `.env` file in your project root and add the following environment vari
7272
**.env**
7373

7474
```bash
75-
NEXT_PUBLIC_ASGARDEO_BASE_URL="https://api.asgardeo.io/t/<your-org-name>"
75+
NEXT_PUBLIC_ASGARDEO_BASE_URL="https://api.asgardeo.io/t/<your-organization-name>"
7676
NEXT_PUBLIC_ASGARDEO_CLIENT_ID="<your-app-client-id>"
7777
ASGARDEO_CLIENT_SECRET="<your-app-client-secret>"
7878
```

packages/nextjs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ yarn add @asgardeo/nextjs
2828
1. Create a `.env.local` file with your Asgardeo configuration:
2929

3030
```bash
31-
NEXT_PUBLIC_ASGARDEO_BASE_URL=https://api.asgardeo.io/t/<your-org-name>
31+
NEXT_PUBLIC_ASGARDEO_BASE_URL=https://api.asgardeo.io/t/<your-organization-name>
3232
NEXT_PUBLIC_ASGARDEO_CLIENT_ID=<your-client-id>
3333
NEXT_PUBLIC_ASGARDEO_CLIENT_SECRET=<your-client-secret>
3434
```

packages/react/docs/OVERVIEW.md

Whitespace-only changes.

0 commit comments

Comments
 (0)