@asgardeo/javascript 0.15.0 → 0.16.1
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/HttpClient.d.ts +64 -0
- package/dist/cjs/index.js +100 -0
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +4 -4
- package/dist/models/config.d.ts +15 -1
- package/dist/models/http.d.ts +45 -0
- package/dist/models/v2/embedded-flow-v2.d.ts +7 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -112,3 +112,5 @@ export { default as transformBrandingPreferenceToTheme } from './utils/transform
|
|
|
112
112
|
export { default as logger, createLogger, createComponentLogger, createPackageLogger, createPackageComponentLogger, LogLevel, configure as configureLogger, debug, info, warn, error, } from './utils/logger';
|
|
113
113
|
export type { LoggerConfig } from './utils/logger';
|
|
114
114
|
export { default as StorageManager } from './StorageManager';
|
|
115
|
+
export { HttpClient } from './HttpClient';
|
|
116
|
+
export { HttpError, HttpRequestConfig, HttpResponse } from './models/http';
|
package/dist/index.js
CHANGED
|
@@ -3397,6 +3397,7 @@ var EmbeddedFlowComponentType2 = /* @__PURE__ */ ((EmbeddedFlowComponentType3) =
|
|
|
3397
3397
|
EmbeddedFlowComponentType3["Action"] = "ACTION";
|
|
3398
3398
|
EmbeddedFlowComponentType3["Block"] = "BLOCK";
|
|
3399
3399
|
EmbeddedFlowComponentType3["Consent"] = "CONSENT";
|
|
3400
|
+
EmbeddedFlowComponentType3["CopyableText"] = "COPYABLE_TEXT";
|
|
3400
3401
|
EmbeddedFlowComponentType3["Divider"] = "DIVIDER";
|
|
3401
3402
|
EmbeddedFlowComponentType3["EmailInput"] = "EMAIL_INPUT";
|
|
3402
3403
|
EmbeddedFlowComponentType3["Icon"] = "ICON";
|
|
@@ -5286,6 +5287,103 @@ var transformBrandingPreferenceToTheme = (brandingPreference, forceTheme) => {
|
|
|
5286
5287
|
return createTheme_default(transformedConfig, activeThemeKey === "DARK");
|
|
5287
5288
|
};
|
|
5288
5289
|
var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTheme;
|
|
5290
|
+
|
|
5291
|
+
// src/HttpClient.ts
|
|
5292
|
+
var _HttpClient = class _HttpClient {
|
|
5293
|
+
constructor(isHandlerEnabled = true, attachToken = () => Promise.resolve()) {
|
|
5294
|
+
this.isHandlerEnabled = isHandlerEnabled;
|
|
5295
|
+
this.attachToken = attachToken;
|
|
5296
|
+
// eslint-disable-next-line class-methods-use-this
|
|
5297
|
+
__publicField(this, "requestStartCallback", () => null);
|
|
5298
|
+
// eslint-disable-next-line class-methods-use-this
|
|
5299
|
+
__publicField(this, "requestSuccessCallback", () => null);
|
|
5300
|
+
// eslint-disable-next-line class-methods-use-this
|
|
5301
|
+
__publicField(this, "requestErrorCallback", () => null);
|
|
5302
|
+
// eslint-disable-next-line class-methods-use-this
|
|
5303
|
+
__publicField(this, "requestFinishCallback", () => null);
|
|
5304
|
+
}
|
|
5305
|
+
/**
|
|
5306
|
+
* Public HTTP request entry point. Applies pre/post processing around `transport()`.
|
|
5307
|
+
*/
|
|
5308
|
+
async request(config) {
|
|
5309
|
+
const processedConfig = await this.requestHandler(config);
|
|
5310
|
+
try {
|
|
5311
|
+
const response = await this.transport(processedConfig);
|
|
5312
|
+
return this.successHandler(response);
|
|
5313
|
+
} catch (error2) {
|
|
5314
|
+
this.errorHandler(error2);
|
|
5315
|
+
throw error2;
|
|
5316
|
+
}
|
|
5317
|
+
}
|
|
5318
|
+
enableHandler() {
|
|
5319
|
+
this.isHandlerEnabled = true;
|
|
5320
|
+
}
|
|
5321
|
+
disableHandler() {
|
|
5322
|
+
this.isHandlerEnabled = false;
|
|
5323
|
+
}
|
|
5324
|
+
disableHandlerWithTimeout(timeout = _HttpClient.DEFAULT_HANDLER_DISABLE_TIMEOUT) {
|
|
5325
|
+
this.isHandlerEnabled = false;
|
|
5326
|
+
setTimeout(() => {
|
|
5327
|
+
this.isHandlerEnabled = true;
|
|
5328
|
+
}, timeout);
|
|
5329
|
+
}
|
|
5330
|
+
setHttpRequestStartCallback(cb) {
|
|
5331
|
+
this.requestStartCallback = cb;
|
|
5332
|
+
}
|
|
5333
|
+
setHttpRequestSuccessCallback(cb) {
|
|
5334
|
+
this.requestSuccessCallback = cb;
|
|
5335
|
+
}
|
|
5336
|
+
setHttpRequestErrorCallback(cb) {
|
|
5337
|
+
this.requestErrorCallback = cb;
|
|
5338
|
+
}
|
|
5339
|
+
setHttpRequestFinishCallback(cb) {
|
|
5340
|
+
this.requestFinishCallback = cb;
|
|
5341
|
+
}
|
|
5342
|
+
// eslint-disable-next-line class-methods-use-this
|
|
5343
|
+
all(values) {
|
|
5344
|
+
return Promise.all(values);
|
|
5345
|
+
}
|
|
5346
|
+
// eslint-disable-next-line class-methods-use-this
|
|
5347
|
+
spread(callback) {
|
|
5348
|
+
return (array) => callback(...array);
|
|
5349
|
+
}
|
|
5350
|
+
async requestHandler(config) {
|
|
5351
|
+
await this.attachToken(config);
|
|
5352
|
+
if (config.shouldEncodeToFormData && config.data) {
|
|
5353
|
+
const formData = new FormData();
|
|
5354
|
+
Object.keys(config.data).forEach((key) => formData.append(key, config.data[key]));
|
|
5355
|
+
config.data = formData;
|
|
5356
|
+
}
|
|
5357
|
+
config.startTimeInMs = Date.now();
|
|
5358
|
+
if (this.isHandlerEnabled && typeof this.requestStartCallback === "function") {
|
|
5359
|
+
this.requestStartCallback(config);
|
|
5360
|
+
}
|
|
5361
|
+
return config;
|
|
5362
|
+
}
|
|
5363
|
+
successHandler(response) {
|
|
5364
|
+
if (this.isHandlerEnabled) {
|
|
5365
|
+
if (typeof this.requestSuccessCallback === "function") {
|
|
5366
|
+
this.requestSuccessCallback(response);
|
|
5367
|
+
}
|
|
5368
|
+
if (typeof this.requestFinishCallback === "function") {
|
|
5369
|
+
this.requestFinishCallback();
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
return response;
|
|
5373
|
+
}
|
|
5374
|
+
errorHandler(error2) {
|
|
5375
|
+
if (this.isHandlerEnabled) {
|
|
5376
|
+
if (typeof this.requestErrorCallback === "function") {
|
|
5377
|
+
this.requestErrorCallback(error2);
|
|
5378
|
+
}
|
|
5379
|
+
if (typeof this.requestFinishCallback === "function") {
|
|
5380
|
+
this.requestFinishCallback();
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
}
|
|
5384
|
+
};
|
|
5385
|
+
__publicField(_HttpClient, "DEFAULT_HANDLER_DISABLE_TIMEOUT", 1e3);
|
|
5386
|
+
var HttpClient = _HttpClient;
|
|
5289
5387
|
export {
|
|
5290
5388
|
AgentConfig,
|
|
5291
5389
|
ApplicationNativeAuthenticationConstants_default as ApplicationNativeAuthenticationConstants,
|
|
@@ -5318,6 +5416,7 @@ export {
|
|
|
5318
5416
|
FieldType,
|
|
5319
5417
|
FlowMetaType,
|
|
5320
5418
|
FlowMode,
|
|
5419
|
+
HttpClient,
|
|
5321
5420
|
IsomorphicCrypto,
|
|
5322
5421
|
OIDCRequestConstants_default as OIDCRequestConstants,
|
|
5323
5422
|
Platform,
|