@asgardeo/javascript 0.10.0 → 0.10.2

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.
@@ -38,6 +38,8 @@ declare class StorageManager<T> {
38
38
  getConfigData(userId?: string): Promise<AuthClientConfig<T>>;
39
39
  loadOpenIDProviderConfiguration(): Promise<OIDCDiscoveryApiResponse>;
40
40
  getTemporaryData(userId?: string): Promise<TemporaryStore>;
41
+ getPersistedData(userId?: string): Promise<TemporaryStore>;
42
+ setPersistedData(persistedData: Partial<TemporaryStore>, userId?: string): Promise<void>;
41
43
  getSessionData(userId?: string, instanceId?: string): Promise<SessionData>;
42
44
  getCustomData<K>(key: string, userId?: string): Promise<K>;
43
45
  setSessionStatus(status: string): void;
@@ -20,6 +20,10 @@ import { OIDCEndpoints } from '../../models/oidc-endpoints';
20
20
  export interface DefaultAuthClientConfig {
21
21
  afterSignInUrl: string;
22
22
  afterSignOutUrl?: string;
23
+ /**
24
+ * Application UUID for the client.
25
+ */
26
+ applicationId?: string;
23
27
  clientHost?: string;
24
28
  clientId?: string;
25
29
  clientSecret?: string;
@@ -25,12 +25,12 @@ import { FlowMetadataResponse, GetFlowMetaRequestConfig } from '../../models/v2/
25
25
  * - i18n translations filtered by `language` and `namespace`
26
26
  * - Registration flow enablement status
27
27
  *
28
- * @param config - Request configuration including `baseUrl`/`url`, `type`, `id`,
29
- * and optional `language` / `namespace` filters.
28
+ * @param config - Request configuration including `baseUrl`/`url`, and optional
29
+ * `type`, `id`, `language`, and `namespace` filters. When `type`
30
+ * and `id` are omitted the server returns i18n-only metadata.
30
31
  * @returns A promise that resolves to the {@link FlowMetadataResponse}.
31
32
  *
32
- * @throws {AsgardeoAPIError} When required parameters are missing or the server
33
- * returns a non-OK response.
33
+ * @throws {AsgardeoAPIError} When the server returns a non-OK response.
34
34
  *
35
35
  * @example
36
36
  * ```typescript
package/dist/cjs/index.js CHANGED
@@ -978,6 +978,12 @@ var StorageManager = class _StorageManager {
978
978
  async getTemporaryData(userId) {
979
979
  return JSON.parse(await this.store.getData(this.resolveKey("temporary_data" /* TemporaryData */, userId)) ?? null);
980
980
  }
981
+ async getPersistedData(userId) {
982
+ return JSON.parse(await this.store.getData(this.resolveKey("persisted_data" /* PersistedData */, userId)) ?? null);
983
+ }
984
+ async setPersistedData(persistedData, userId) {
985
+ this.setDataInBulk(this.resolveKey("persisted_data" /* PersistedData */, userId), persistedData);
986
+ }
981
987
  async getSessionData(userId, instanceId) {
982
988
  return JSON.parse(await this.store.getData(this.resolveKey("session_data" /* SessionData */, userId, instanceId)) ?? null);
983
989
  }
@@ -1236,9 +1242,21 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
1236
1242
  this.configProvider = async () => this.storageManager.getConfigData();
1237
1243
  this.oidcProviderMetaDataProvider = async () => this.storageManager.loadOpenIDProviderConfiguration();
1238
1244
  _AsgardeoAuthClient.authHelperInstance = this.authHelper;
1245
+ let { applicationId } = config;
1246
+ if (applicationId) {
1247
+ await this.storageManager.setPersistedData({
1248
+ applicationId
1249
+ });
1250
+ } else {
1251
+ const persistedData = await this.storageManager.getPersistedData();
1252
+ if (persistedData["applicationId"]) {
1253
+ applicationId = persistedData["applicationId"];
1254
+ }
1255
+ }
1239
1256
  await this.storageManager.setConfigData({
1240
1257
  ...DefaultConfig,
1241
1258
  ...config,
1259
+ applicationId,
1242
1260
  scope: processOpenIDScopes_default(config.scopes)
1243
1261
  });
1244
1262
  }
@@ -3338,27 +3356,9 @@ var getFlowMetaV2 = async ({
3338
3356
  namespace,
3339
3357
  ...requestConfig
3340
3358
  }) => {
3341
- if (!type) {
3342
- throw new AsgardeoAPIError(
3343
- 'The "type" parameter is required',
3344
- "getFlowMetaV2-ValidationError-001",
3345
- "javascript",
3346
- 400,
3347
- 'The "type" query parameter must be either "APP" or "OU".'
3348
- );
3349
- }
3350
- if (!id) {
3351
- throw new AsgardeoAPIError(
3352
- 'The "id" parameter is required',
3353
- "getFlowMetaV2-ValidationError-002",
3354
- "javascript",
3355
- 400,
3356
- 'The "id" query parameter must be a valid UUID of the target application or organization unit.'
3357
- );
3358
- }
3359
3359
  const queryParams = new URLSearchParams({
3360
- id,
3361
- type,
3360
+ ...id ? { id } : {},
3361
+ ...type ? { type } : {},
3362
3362
  ...language ? { language } : {},
3363
3363
  ...namespace ? { namespace } : {}
3364
3364
  });