Skip to content

Commit 590e380

Browse files
authored
Merge pull request #98 from brionmario/next-fixes
fix(react): fix `organizationHandle` resolution issues with the on-prem WSO2 Identity Server
2 parents b837bd3 + 5ae3af4 commit 590e380

File tree

14 files changed

+289
-37
lines changed

14 files changed

+289
-37
lines changed

.changeset/slimy-seas-relax.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@asgardeo/javascript': patch
3+
'@asgardeo/react': patch
4+
---
5+
6+
- Fix `organizationHandle` resolution issues with the on-prem WSO2 Identity Server
7+
- Expose `fetch` method in `AsgardeoContext` to allow custom HTTP requests

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: "🐞 Report a Bug"
2+
description: Create an issue if something does not work as expected.
3+
labels: ["Type/Bug"]
4+
body:
5+
- type: textarea
6+
id: background
7+
attributes:
8+
label: Description
9+
description: Please share a clear and concise description of the problem.
10+
placeholder: Description
11+
- type: textarea
12+
id: steps
13+
attributes:
14+
label: Steps to Reproduce
15+
description: List the steps you followed when you encountered the issue.
16+
validations:
17+
required: true
18+
- type: dropdown
19+
id: area
20+
attributes:
21+
label: Please select the package issue is related to
22+
options:
23+
- '@asgardeo/browser'
24+
- '@asgardeo/express'
25+
- '@asgardeo/javascript'
26+
- '@asgardeo/nextjs'
27+
- '@asgardeo/node'
28+
- '@asgardeo/nuxt'
29+
- '@asgardeo/react'
30+
- '@asgardeo/react-router'
31+
- '@asgardeo/vue'
32+
- 'samples'
33+
default: 1
34+
multiple: true
35+
validations:
36+
required: true
37+
- type: input
38+
id: version
39+
attributes:
40+
label: Version
41+
description: Enter package version or commit hash.
42+
validations:
43+
required: true
44+
- type: textarea
45+
id: environment
46+
attributes:
47+
label: Environment Details (with versions)
48+
description: Mention the environment details (OS, Browser, etc..) that the SDK is running on.
49+
validations:
50+
required: false
51+
- type: checkboxes
52+
id: reporter-checklist
53+
attributes:
54+
label: Reporter Checklist
55+
description: Please ensure the following before submitting the issue.
56+
options:
57+
- label: "I have searched the existing issues and this is not a duplicate."
58+
required: true
59+
- label: "I have provided all the necessary information."
60+
required: true
61+
- label: "I have tested the issue on the latest version of the package."
62+
required: true
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "🚀 Improvement Request"
2+
description: Suggest an improvement for the SDKs.
3+
labels: ["Type/Improvement"]
4+
body:
5+
- type: textarea
6+
id: limitation
7+
attributes:
8+
label: Current Limitation
9+
description: Describe the current limitation.
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: suggestion
14+
attributes:
15+
label: Suggested Improvement
16+
description: Describe the improvement you suggest.
17+
validations:
18+
required: true
19+
- type: dropdown
20+
id: area
21+
attributes:
22+
label: Please select the package issue is related to
23+
options:
24+
- '@asgardeo/browser'
25+
- '@asgardeo/express'
26+
- '@asgardeo/javascript'
27+
- '@asgardeo/nextjs'
28+
- '@asgardeo/node'
29+
- '@asgardeo/nuxt'
30+
- '@asgardeo/react'
31+
- '@asgardeo/react-router'
32+
- '@asgardeo/vue'
33+
- 'samples'
34+
default: 1
35+
multiple: true
36+
validations:
37+
required: true
38+
- type: input
39+
id: version
40+
attributes:
41+
label: Version
42+
description: Enter package version or commit hash.
43+
validations:
44+
required: true
45+
- type: checkboxes
46+
id: reporter-checklist
47+
attributes:
48+
label: Reporter Checklist
49+
description: Please review and confirm the following items before opening the improvement request.
50+
options:
51+
- label: "I have searched the existing issues and this is not a duplicate."
52+
required: true
53+
- label: "I have provided all the necessary information."
54+
required: true
55+
- label: "I have verified the improvement is not available in the latest version of the package."
56+
required: true
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "💡 New Feature Request"
2+
description: Suggest new functionality and features for the SDKs.
3+
labels: ["Type/NewFeature"]
4+
body:
5+
- type: textarea
6+
id: problem
7+
attributes:
8+
label: Problem
9+
description: What is the problem this feature will solve?
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: solution
14+
attributes:
15+
label: Proposed Solution
16+
description: Describe the solution you'd like to have.
17+
validations:
18+
required: true
19+
- type: textarea
20+
id: alternatives
21+
attributes:
22+
label: Alternatives
23+
description: Describe any alternatives have you considered
24+
validations:
25+
required: false
26+
- type: dropdown
27+
id: area
28+
attributes:
29+
label: Please select the package issue is related to
30+
options:
31+
- '@asgardeo/browser'
32+
- '@asgardeo/express'
33+
- '@asgardeo/javascript'
34+
- '@asgardeo/nextjs'
35+
- '@asgardeo/node'
36+
- '@asgardeo/nuxt'
37+
- '@asgardeo/react'
38+
- '@asgardeo/react-router'
39+
- '@asgardeo/vue'
40+
- 'samples'
41+
default: 1
42+
multiple: true
43+
validations:
44+
required: true
45+
- type: input
46+
id: version
47+
attributes:
48+
label: Version
49+
description: Enter package version or commit hash.
50+
validations:
51+
required: true
52+
- type: checkboxes
53+
id: reporter-checklist
54+
attributes:
55+
label: Reporter Checklist
56+
description: Please review and confirm the following items before opening the feature request.
57+
options:
58+
- label: "I have searched the existing issues and this is not a duplicate."
59+
required: true
60+
- label: "I have provided all the necessary information."
61+
required: true
62+
- label: "I have verified the feature on the latest version of the package."
63+
required: true

packages/browser/src/__legacy__/http-client/clients/axios-http-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class HttpClient implements HttpClientInterface<HttpRequestConfig, HttpRe
8484
}
8585

8686
// Register request interceptor
87-
this.axiosInstance.interceptors.request.use(async request => await this.clientInstance.requestHandler(request));
87+
this.axiosInstance.interceptors.request.use(async request => await this.clientInstance.requestHandler(request as HttpRequestConfig));
8888

8989
// Register response interceptor
9090
this.axiosInstance.interceptors.response.use(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface HttpRequestInterface {
3636
enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void;
3737
}
3838

39-
export interface HttpRequestConfig extends AxiosRequestConfig {
39+
export interface HttpRequestConfig extends AxiosRequestConfig, Omit<Request, 'headers' | 'method' | 'signal' | 'url'> {
4040
attachToken?: boolean;
4141
shouldEncodeToFormData?: boolean;
4242
shouldAttachIDPAccessToken?: boolean;

packages/javascript/src/__legacy__/client.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ import processOpenIDScopes from '../utils/processOpenIDScopes';
4545
* Default configurations.
4646
*/
4747
const DefaultConfig: Partial<AuthClientConfig<unknown>> = {
48-
clockTolerance: 300,
48+
tokenValidation: {
49+
idToken: {
50+
validate: true,
51+
validateIssuer: true,
52+
clockTolerance: 300,
53+
},
54+
},
4955
enablePKCE: true,
5056
responseMode: 'query',
5157
sendCookiesInRequests: true,
52-
validateIDToken: true,
53-
validateIDTokenIssuer: true,
5458
};
5559

5660
/**

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ export class AuthenticationHelper<T> {
197197
(await this._config()).clientId,
198198
issuer ?? '',
199199
this._cryptoHelper.decodeIdToken(idToken).sub,
200-
(await this._config()).clockTolerance,
201-
(await this._config()).validateIDTokenIssuer ?? true,
200+
(await this._config()).tokenValidation?.idToken?.clockTolerance,
201+
(await this._config()).tokenValidation?.idToken?.validateIssuer ?? true,
202202
);
203203
}
204204

@@ -257,7 +257,7 @@ export class AuthenticationHelper<T> {
257257

258258
parsedResponse.created_at = new Date().getTime();
259259

260-
const shouldValidateIdToken: boolean | undefined = (await this._config()).validateIDToken;
260+
const shouldValidateIdToken: boolean | undefined = (await this._config()).tokenValidation?.idToken?.validate;
261261

262262
if (shouldValidateIdToken) {
263263
return this.validateIdToken(parsedResponse.id_token).then(async () => {

packages/javascript/src/__legacy__/models/client-config.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,25 @@ export interface DefaultAuthClientConfig {
2929
prompt?: string;
3030
responseMode?: OAuthResponseMode;
3131
scopes?: string | string[] | undefined;
32-
validateIDToken?: boolean;
33-
validateIDTokenIssuer?: boolean;
34-
/**
35-
* Allowed leeway for id_tokens (in seconds).
36-
*/
37-
clockTolerance?: number;
32+
tokenValidation?: {
33+
/**
34+
* ID token validation config.
35+
*/
36+
idToken?: {
37+
/**
38+
* Whether to validate ID tokens.
39+
*/
40+
validate?: boolean;
41+
/**
42+
* Whether to validate the issuer of ID tokens.
43+
*/
44+
validateIssuer?: boolean;
45+
/**
46+
* Allowed leeway for ID tokens (in seconds).
47+
*/
48+
clockTolerance?: number;
49+
};
50+
};
3851
/**
3952
* Specifies if cookies should be sent with access-token requests, refresh-token requests,
4053
* custom-grant requests, etc.

packages/javascript/src/models/config.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,33 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
107107
* and use the `SignUp` component to render it.
108108
*/
109109
signUpUrl?: string | undefined;
110+
111+
/**
112+
* Token validation configuration.
113+
* This allows you to configure how the SDK validates tokens received from the authorization server.
114+
* It includes options for ID token validation, such as whether to validate the token,
115+
* whether to validate the issuer, and the allowed clock tolerance for token validation.
116+
* If not provided, the SDK will use default validation settings.
117+
*/
118+
tokenValidation?: {
119+
/**
120+
* ID token validation config.
121+
*/
122+
idToken?: {
123+
/**
124+
* Whether to validate ID tokens.
125+
*/
126+
validate?: boolean;
127+
/**
128+
* Whether to validate the issuer of ID tokens.
129+
*/
130+
validateIssuer?: boolean;
131+
/**
132+
* Allowed leeway for ID tokens (in seconds).
133+
*/
134+
clockTolerance?: number;
135+
};
136+
};
110137
}
111138

112139
export interface WithPreferences {

0 commit comments

Comments
 (0)