@asgardeo/javascript 0.10.2 → 0.12.0

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.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ /**
19
+ * Constants related to OpenID Connect (OIDC) metadata and endpoints.
20
+ * This object contains all the standard OIDC endpoints and storage keys
21
+ * used throughout the application for authentication and authorization.
22
+ *
23
+ * @remarks
24
+ * The constants are organized into two main sections:
25
+ * 1. Endpoints - Contains all OIDC standard endpoint paths
26
+ * 2. Storage - Contains keys used for storing OIDC-related data
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Using an endpoint
31
+ * const wellKnownEndpoint = OIDCDiscoveryConstants.Endpoints.WELL_KNOWN;
32
+ * ```
33
+ */
34
+ declare const OIDCDiscoveryConstants: {
35
+ readonly Endpoints: {
36
+ readonly WELL_KNOWN: string;
37
+ };
38
+ };
39
+ export default OIDCDiscoveryConstants;
package/dist/index.d.ts CHANGED
@@ -61,6 +61,7 @@ export { Crypto, JWKInterface } from './models/crypto';
61
61
  export { OAuthResponseMode } from './models/oauth-response';
62
62
  export { AuthorizeRequestUrlParams, KnownExtendedAuthorizeRequestUrlParams, ExtendedAuthorizeRequestUrlParams, } from './models/oauth-request';
63
63
  export { OIDCEndpoints } from './models/oidc-endpoints';
64
+ export { OIDCDiscoveryApiResponse } from './models/oidc-discovery';
64
65
  export { Storage, TemporaryStore } from './models/store';
65
66
  export { User, UserProfile } from './models/user';
66
67
  export { SessionData } from './models/session';
package/dist/index.js CHANGED
@@ -630,6 +630,23 @@ var PKCEConstants = {
630
630
  };
631
631
  var PKCEConstants_default = PKCEConstants;
632
632
 
633
+ // src/constants/v2/OIDCDiscoveryConstants.ts
634
+ var OIDCDiscoveryConstants2 = {
635
+ /**
636
+ * Collection of standard OIDC endpoint paths used for authentication flows.
637
+ * These endpoints are relative paths that should be appended to the base URL
638
+ * of your identity provider.
639
+ */
640
+ Endpoints: {
641
+ /**
642
+ * OpenID Connect discovery document endpoint.
643
+ * Used to fetch provider metadata from the authorization server.
644
+ */
645
+ WELL_KNOWN: "/.well-known/openid-configuration"
646
+ }
647
+ };
648
+ var OIDCDiscoveryConstants_default2 = OIDCDiscoveryConstants2;
649
+
633
650
  // src/constants/TokenConstants.ts
634
651
  var TokenConstants = {
635
652
  /**
@@ -1111,7 +1128,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
1111
1128
  this.configProvider = async () => this.storageManager.getConfigData();
1112
1129
  this.oidcProviderMetaDataProvider = async () => this.storageManager.loadOpenIDProviderConfiguration();
1113
1130
  _AsgardeoAuthClient.authHelperInstance = this.authHelper;
1114
- let { applicationId } = config;
1131
+ const { applicationId, platform, endpoints } = config;
1132
+ let resolvedApplicationId = applicationId;
1115
1133
  if (applicationId) {
1116
1134
  await this.storageManager.setPersistedData({
1117
1135
  applicationId
@@ -1119,13 +1137,20 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
1119
1137
  } else {
1120
1138
  const persistedData = await this.storageManager.getPersistedData();
1121
1139
  if (persistedData["applicationId"]) {
1122
- applicationId = persistedData["applicationId"];
1140
+ resolvedApplicationId = persistedData["applicationId"];
1141
+ }
1142
+ }
1143
+ const resolvedEndpoints = endpoints || {};
1144
+ if (platform === "AsgardeoV2" /* AsgardeoV2 */) {
1145
+ if (!resolvedEndpoints["wellKnown"]) {
1146
+ resolvedEndpoints["wellKnown"] = OIDCDiscoveryConstants_default2.Endpoints.WELL_KNOWN;
1123
1147
  }
1124
1148
  }
1125
1149
  await this.storageManager.setConfigData({
1126
1150
  ...DefaultConfig,
1127
1151
  ...config,
1128
- applicationId,
1152
+ applicationId: resolvedApplicationId,
1153
+ endpoints: resolvedEndpoints,
1129
1154
  scope: processOpenIDScopes_default(config.scopes)
1130
1155
  });
1131
1156
  }
@@ -1341,11 +1366,12 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
1341
1366
  )) {
1342
1367
  return Promise.resolve();
1343
1368
  }
1344
- const { wellKnownEndpoint } = configData;
1345
- if (wellKnownEndpoint) {
1369
+ const { wellKnownEndpoint, platform, discovery, baseUrl, endpoints } = configData;
1370
+ const resolvedWellKnownEndpoint = wellKnownEndpoint || (platform === "AsgardeoV2" /* AsgardeoV2 */ && discovery?.wellKnown?.enabled ? `${baseUrl}${endpoints?.wellKnown ?? "/.well-known/openid-configuration"}` : void 0);
1371
+ if (resolvedWellKnownEndpoint) {
1346
1372
  let response;
1347
1373
  try {
1348
- response = await fetch(wellKnownEndpoint);
1374
+ response = await fetch(resolvedWellKnownEndpoint);
1349
1375
  if (response.status !== 200 || !response.ok) {
1350
1376
  throw new Error();
1351
1377
  }
@@ -3514,6 +3540,12 @@ var AsgardeoJavaScriptClient = class {
3514
3540
  }
3515
3541
  this.baseURL = config?.baseUrl ?? "";
3516
3542
  }
3543
+ async getDiscoveryResponse() {
3544
+ if (!this.storageManager) {
3545
+ return null;
3546
+ }
3547
+ return this.storageManager.loadOpenIDProviderConfiguration();
3548
+ }
3517
3549
  /* eslint-disable class-methods-use-this, @typescript-eslint/no-unused-vars */
3518
3550
  switchOrganization(_organization, _sessionId) {
3519
3551
  throw new Error("Method not implemented.");