@asgardeo/javascript 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsgardeoJavaScriptClient.d.ts +1 -0
- package/dist/__legacy__/models/client-config.d.ts +19 -6
- package/dist/cjs/index.js +28 -27
- package/dist/cjs/index.js.map +2 -2
- package/dist/index.js +28 -27
- package/dist/index.js.map +2 -2
- package/dist/models/client.d.ts +6 -0
- package/dist/models/config.d.ts +26 -0
- package/package.json +1 -1
|
@@ -49,5 +49,6 @@ declare abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoC
|
|
|
49
49
|
abstract signUp(options?: SignUpOptions): Promise<void>;
|
|
50
50
|
abstract signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
|
|
51
51
|
abstract signUp(payload?: unknown): Promise<void> | Promise<EmbeddedFlowExecuteResponse>;
|
|
52
|
+
abstract getAccessToken(sessionId?: string): Promise<string>;
|
|
52
53
|
}
|
|
53
54
|
export default AsgardeoJavaScriptClient;
|
|
@@ -27,12 +27,25 @@ export interface DefaultAuthClientConfig {
|
|
|
27
27
|
prompt?: string;
|
|
28
28
|
responseMode?: OAuthResponseMode;
|
|
29
29
|
scopes?: string | string[] | undefined;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
tokenValidation?: {
|
|
31
|
+
/**
|
|
32
|
+
* ID token validation config.
|
|
33
|
+
*/
|
|
34
|
+
idToken?: {
|
|
35
|
+
/**
|
|
36
|
+
* Whether to validate ID tokens.
|
|
37
|
+
*/
|
|
38
|
+
validate?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to validate the issuer of ID tokens.
|
|
41
|
+
*/
|
|
42
|
+
validateIssuer?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Allowed leeway for ID tokens (in seconds).
|
|
45
|
+
*/
|
|
46
|
+
clockTolerance?: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
36
49
|
/**
|
|
37
50
|
* Specifies if cookies should be sent with access-token requests, refresh-token requests,
|
|
38
51
|
* custom-grant requests, etc.
|
package/dist/cjs/index.js
CHANGED
|
@@ -900,8 +900,8 @@ var AuthenticationHelper = class {
|
|
|
900
900
|
(await this._config()).clientId,
|
|
901
901
|
issuer ?? "",
|
|
902
902
|
this._cryptoHelper.decodeIdToken(idToken).sub,
|
|
903
|
-
(await this._config()).clockTolerance,
|
|
904
|
-
(await this._config()).
|
|
903
|
+
(await this._config()).tokenValidation?.idToken?.clockTolerance,
|
|
904
|
+
(await this._config()).tokenValidation?.idToken?.validateIssuer ?? true
|
|
905
905
|
);
|
|
906
906
|
}
|
|
907
907
|
getAuthenticatedUserInfo(idToken) {
|
|
@@ -943,7 +943,7 @@ var AuthenticationHelper = class {
|
|
|
943
943
|
}
|
|
944
944
|
const parsedResponse = await response.json();
|
|
945
945
|
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
946
|
-
const shouldValidateIdToken = (await this._config()).
|
|
946
|
+
const shouldValidateIdToken = (await this._config()).tokenValidation?.idToken?.validate;
|
|
947
947
|
if (shouldValidateIdToken) {
|
|
948
948
|
return this.validateIdToken(parsedResponse.id_token).then(async () => {
|
|
949
949
|
await this._storageManager.setSessionData(parsedResponse, userId);
|
|
@@ -1042,12 +1042,16 @@ var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
|
|
|
1042
1042
|
|
|
1043
1043
|
// src/__legacy__/client.ts
|
|
1044
1044
|
var DefaultConfig = {
|
|
1045
|
-
|
|
1045
|
+
tokenValidation: {
|
|
1046
|
+
idToken: {
|
|
1047
|
+
validate: true,
|
|
1048
|
+
validateIssuer: true,
|
|
1049
|
+
clockTolerance: 300
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1046
1052
|
enablePKCE: true,
|
|
1047
1053
|
responseMode: "query",
|
|
1048
|
-
sendCookiesInRequests: true
|
|
1049
|
-
validateIDToken: true,
|
|
1050
|
-
validateIDTokenIssuer: true
|
|
1054
|
+
sendCookiesInRequests: true
|
|
1051
1055
|
};
|
|
1052
1056
|
var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
1053
1057
|
/**
|
|
@@ -3528,32 +3532,29 @@ var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
|
3528
3532
|
"The provided base URL does not conform to valid URL syntax."
|
|
3529
3533
|
);
|
|
3530
3534
|
}
|
|
3531
|
-
const
|
|
3532
|
-
if (!hostname.endsWith(".asgardeo.io")) {
|
|
3533
|
-
throw new AsgardeoRuntimeError(
|
|
3534
|
-
"Organization handle is required since a custom domain is configured.",
|
|
3535
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-001",
|
|
3536
|
-
"javascript",
|
|
3537
|
-
"The provided base URL uses a custom domain. Please provide the organizationHandle explicitly in the configuration."
|
|
3538
|
-
);
|
|
3539
|
-
}
|
|
3540
|
-
const pathSegments = parsedUrl.pathname.split("/").filter((segment) => segment.length > 0);
|
|
3535
|
+
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
3541
3536
|
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3537
|
+
console.warn(
|
|
3538
|
+
new AsgardeoRuntimeError(
|
|
3539
|
+
"Organization handle is required since a custom domain is configured.",
|
|
3540
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
|
|
3541
|
+
"javascript",
|
|
3542
|
+
"The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
|
|
3543
|
+
).toString()
|
|
3547
3544
|
);
|
|
3545
|
+
return "";
|
|
3548
3546
|
}
|
|
3549
3547
|
const organizationHandle = pathSegments[1];
|
|
3550
3548
|
if (!organizationHandle || organizationHandle.trim().length === 0) {
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3549
|
+
console.warn(
|
|
3550
|
+
new AsgardeoRuntimeError(
|
|
3551
|
+
"Organization handle is required since a custom domain is configured.",
|
|
3552
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
|
|
3553
|
+
"javascript",
|
|
3554
|
+
"The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
|
|
3555
|
+
).toString()
|
|
3556
3556
|
);
|
|
3557
|
+
return "";
|
|
3557
3558
|
}
|
|
3558
3559
|
return organizationHandle;
|
|
3559
3560
|
};
|