@asgardeo/javascript 0.8.0 → 0.8.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/AsgardeoJavaScriptClient.d.ts +36 -33
- package/dist/DefaultCacheStore.d.ts +30 -0
- package/dist/DefaultCrypto.d.ts +29 -0
- package/dist/IsomorphicCrypto.d.ts +1 -1
- package/dist/cjs/index.js +320 -32
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +6 -0
- package/dist/index.js +307 -32
- package/dist/index.js.map +4 -4
- package/dist/models/agent.d.ts +44 -0
- package/dist/models/auth-code-response.d.ts +34 -0
- package/dist/models/crypto.d.ts +1 -1
- package/dist/models/v2/embedded-flow-v2.d.ts +67 -1
- package/dist/models/v2/flow-meta-v2.d.ts +1 -1
- package/dist/models/v2/translation.d.ts +34 -0
- package/dist/models/v2/vars.d.ts +35 -0
- package/dist/utils/v2/resolveMeta.d.ts +34 -0
- package/dist/utils/v2/resolveVars.d.ts +41 -0
- package/package.json +2 -1
|
@@ -15,45 +15,48 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
import { AuthClientConfig } from './__legacy__/models/client-config';
|
|
19
|
+
import { AgentConfig } from './models/agent';
|
|
20
|
+
import { AuthCodeResponse } from './models/auth-code-response';
|
|
18
21
|
import { AsgardeoClient } from './models/client';
|
|
19
22
|
import { Config, SignInOptions, SignOutOptions, SignUpOptions } from './models/config';
|
|
23
|
+
import { Crypto } from './models/crypto';
|
|
20
24
|
import { EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse } from './models/embedded-flow';
|
|
21
|
-
import { EmbeddedSignInFlowHandleRequestPayload } from './models/embedded-signin-flow';
|
|
22
25
|
import { AllOrganizationsApiResponse, Organization } from './models/organization';
|
|
23
26
|
import { Storage } from './models/store';
|
|
24
27
|
import { TokenExchangeRequestConfig, TokenResponse } from './models/token';
|
|
25
28
|
import { User, UserProfile } from './models/user';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
29
|
+
declare class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T> {
|
|
30
|
+
private cacheStore;
|
|
31
|
+
private cryptoUtils;
|
|
32
|
+
private auth;
|
|
33
|
+
private storageManager;
|
|
34
|
+
private baseURL;
|
|
35
|
+
constructor(config?: AuthClientConfig<T>, cacheStore?: Storage, cryptoUtils?: Crypto);
|
|
36
|
+
switchOrganization(_organization: Organization, _sessionId?: string): Promise<TokenResponse | Response>;
|
|
37
|
+
initialize(_config: T, _storage?: Storage): Promise<boolean>;
|
|
38
|
+
reInitialize(_config: Partial<T>): Promise<boolean>;
|
|
39
|
+
getUser(_options?: any): Promise<User>;
|
|
40
|
+
getAllOrganizations(_options?: any, _sessionId?: string): Promise<AllOrganizationsApiResponse>;
|
|
41
|
+
getMyOrganizations(_options?: any, _sessionId?: string): Promise<Organization[]>;
|
|
42
|
+
getCurrentOrganization(_sessionId?: string): Promise<Organization | null>;
|
|
43
|
+
getUserProfile(_options?: any): Promise<UserProfile>;
|
|
44
|
+
isLoading(): boolean;
|
|
45
|
+
isSignedIn(): Promise<boolean>;
|
|
46
|
+
updateUserProfile(_payload: any, _userId?: string): Promise<User>;
|
|
47
|
+
getConfiguration(): T;
|
|
48
|
+
exchangeToken(_config: TokenExchangeRequestConfig, _sessionId?: string): Promise<TokenResponse | Response>;
|
|
49
|
+
signInSilently(_options?: SignInOptions): Promise<User | boolean>;
|
|
50
|
+
getAccessToken(_sessionId?: string): Promise<string>;
|
|
51
|
+
clearSession(_sessionId?: string): void;
|
|
52
|
+
setSession(_sessionData: Record<string, unknown>, _sessionId?: string): Promise<void>;
|
|
53
|
+
decodeJwtToken<R = Record<string, unknown>>(_token: string): Promise<R>;
|
|
54
|
+
signIn(_options?: SignInOptions): Promise<User>;
|
|
55
|
+
signOut(_options?: SignOutOptions, _sessionIdOrAfterSignOut?: string | ((afterSignOutUrl: string) => void), _afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
|
|
56
|
+
signUp(options?: SignUpOptions): Promise<void>;
|
|
57
|
+
signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
|
|
58
|
+
getAgentToken(agentConfig: AgentConfig): Promise<TokenResponse>;
|
|
59
|
+
getOBOSignInURL(agentConfig: AgentConfig): Promise<string>;
|
|
60
|
+
getOBOToken(agentConfig: AgentConfig, authCodeResponse: AuthCodeResponse): Promise<TokenResponse>;
|
|
58
61
|
}
|
|
59
62
|
export default AsgardeoJavaScriptClient;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
export declare class DefaultCacheStore implements Storage {
|
|
19
|
+
private cache;
|
|
20
|
+
constructor();
|
|
21
|
+
get length(): number;
|
|
22
|
+
getItem(key: string): string | null;
|
|
23
|
+
setItem(key: string, value: string): void;
|
|
24
|
+
removeItem(key: string): void;
|
|
25
|
+
clear(): void;
|
|
26
|
+
key(index: number): string | null;
|
|
27
|
+
setData(key: string, value: string): Promise<void>;
|
|
28
|
+
getData(key: string): Promise<string>;
|
|
29
|
+
removeData(key: string): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import { Crypto, JWKInterface } from './models/crypto';
|
|
19
|
+
/**
|
|
20
|
+
* Default implementation of the Crypto interface using the 'jose' library
|
|
21
|
+
* and the native Web Crypto API.
|
|
22
|
+
*/
|
|
23
|
+
export declare class DefaultCrypto implements Crypto<Uint8Array> {
|
|
24
|
+
base64URLDecode(value: string): string;
|
|
25
|
+
base64URLEncode(value: Uint8Array): string;
|
|
26
|
+
generateRandomBytes(length: number): Uint8Array;
|
|
27
|
+
hashSha256(data: string): Promise<Uint8Array>;
|
|
28
|
+
verifyJwt(idToken: string, jwk: JWKInterface, algorithms: string[], clientId: string, issuer: string, subject: string, clockTolerance?: number, validateJwtIssuer?: boolean): Promise<boolean>;
|
|
29
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
8
|
var __export = (target, all) => {
|
|
@@ -15,12 +17,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
30
|
|
|
21
31
|
// src/index.ts
|
|
22
32
|
var index_exports = {};
|
|
23
33
|
__export(index_exports, {
|
|
34
|
+
AgentConfig: () => AgentConfig,
|
|
24
35
|
ApplicationNativeAuthenticationConstants: () => ApplicationNativeAuthenticationConstants_default,
|
|
25
36
|
AsgardeoAPIError: () => AsgardeoAPIError,
|
|
26
37
|
AsgardeoAuthClient: () => AsgardeoAuthClient,
|
|
@@ -105,6 +116,8 @@ __export(index_exports, {
|
|
|
105
116
|
removeTrailingSlash: () => removeTrailingSlash_default,
|
|
106
117
|
resolveFieldName: () => resolveFieldName_default,
|
|
107
118
|
resolveFieldType: () => resolveFieldType_default,
|
|
119
|
+
resolveMeta: () => resolveMeta,
|
|
120
|
+
resolveVars: () => resolveVars,
|
|
108
121
|
set: () => set_default,
|
|
109
122
|
transformBrandingPreferenceToTheme: () => transformBrandingPreferenceToTheme_default,
|
|
110
123
|
updateMeProfile: () => updateMeProfile_default,
|
|
@@ -785,8 +798,9 @@ var IsomorphicCrypto = class {
|
|
|
785
798
|
*
|
|
786
799
|
* @returns - code challenge.
|
|
787
800
|
*/
|
|
788
|
-
getCodeChallenge(verifier) {
|
|
789
|
-
|
|
801
|
+
async getCodeChallenge(verifier) {
|
|
802
|
+
const hashed = await this.cryptoUtils.hashSha256(verifier);
|
|
803
|
+
return this.cryptoUtils.base64URLEncode(hashed);
|
|
790
804
|
}
|
|
791
805
|
/**
|
|
792
806
|
* Get JWK used for the id_token
|
|
@@ -1006,6 +1020,31 @@ var StorageManager = class _StorageManager {
|
|
|
1006
1020
|
};
|
|
1007
1021
|
var StorageManager_default = StorageManager;
|
|
1008
1022
|
|
|
1023
|
+
// src/utils/deepMerge.ts
|
|
1024
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
1025
|
+
var deepMerge = (target, ...sources) => {
|
|
1026
|
+
if (!target || typeof target !== "object") {
|
|
1027
|
+
throw new Error("Target must be an object");
|
|
1028
|
+
}
|
|
1029
|
+
const result = { ...target };
|
|
1030
|
+
sources.forEach((source) => {
|
|
1031
|
+
if (!source || typeof source !== "object") {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
Object.keys(source).forEach((key) => {
|
|
1035
|
+
const sourceValue = source[key];
|
|
1036
|
+
const targetValue = result[key];
|
|
1037
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
1038
|
+
result[key] = deepMerge(targetValue, sourceValue);
|
|
1039
|
+
} else if (sourceValue !== void 0) {
|
|
1040
|
+
result[key] = sourceValue;
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
return result;
|
|
1045
|
+
};
|
|
1046
|
+
var deepMerge_default = deepMerge;
|
|
1047
|
+
|
|
1009
1048
|
// src/utils/extractPkceStorageKeyFromState.ts
|
|
1010
1049
|
var extractPkceStorageKeyFromState = (state) => {
|
|
1011
1050
|
const index = parseInt(state.split("request_")[1], 10);
|
|
@@ -1246,7 +1285,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1246
1285
|
let codeChallenge;
|
|
1247
1286
|
if (configData.enablePKCE) {
|
|
1248
1287
|
codeVerifier = this.cryptoHelper?.getCodeVerifier();
|
|
1249
|
-
codeChallenge = this.cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
1288
|
+
codeChallenge = await this.cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
1250
1289
|
await this.storageManager.setTemporaryDataParameter(pkceKey, codeVerifier, userId);
|
|
1251
1290
|
}
|
|
1252
1291
|
if (authRequestConfig["client_secret"]) {
|
|
@@ -2013,7 +2052,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
2013
2052
|
* @preserve
|
|
2014
2053
|
*/
|
|
2015
2054
|
async reInitialize(config) {
|
|
2016
|
-
|
|
2055
|
+
const currentConfig = this.storageManager.getConfigData();
|
|
2056
|
+
const newConfig = deepMerge_default(currentConfig, config);
|
|
2057
|
+
await this.storageManager.setConfigData(newConfig);
|
|
2017
2058
|
await this.loadOpenIDProviderConfiguration(true);
|
|
2018
2059
|
}
|
|
2019
2060
|
static async clearSession(userId) {
|
|
@@ -3379,10 +3420,14 @@ var EmbeddedFlowComponentType2 = /* @__PURE__ */ ((EmbeddedFlowComponentType3) =
|
|
|
3379
3420
|
EmbeddedFlowComponentType3["Block"] = "BLOCK";
|
|
3380
3421
|
EmbeddedFlowComponentType3["Divider"] = "DIVIDER";
|
|
3381
3422
|
EmbeddedFlowComponentType3["EmailInput"] = "EMAIL_INPUT";
|
|
3423
|
+
EmbeddedFlowComponentType3["Icon"] = "ICON";
|
|
3424
|
+
EmbeddedFlowComponentType3["Image"] = "IMAGE";
|
|
3382
3425
|
EmbeddedFlowComponentType3["OtpInput"] = "OTP_INPUT";
|
|
3383
3426
|
EmbeddedFlowComponentType3["PasswordInput"] = "PASSWORD_INPUT";
|
|
3384
3427
|
EmbeddedFlowComponentType3["PhoneInput"] = "PHONE_INPUT";
|
|
3428
|
+
EmbeddedFlowComponentType3["RichText"] = "RICH_TEXT";
|
|
3385
3429
|
EmbeddedFlowComponentType3["Select"] = "SELECT";
|
|
3430
|
+
EmbeddedFlowComponentType3["Stack"] = "STACK";
|
|
3386
3431
|
EmbeddedFlowComponentType3["Text"] = "TEXT";
|
|
3387
3432
|
EmbeddedFlowComponentType3["TextInput"] = "TEXT_INPUT";
|
|
3388
3433
|
return EmbeddedFlowComponentType3;
|
|
@@ -3439,6 +3484,12 @@ var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
|
|
|
3439
3484
|
return FlowMode2;
|
|
3440
3485
|
})(FlowMode || {});
|
|
3441
3486
|
|
|
3487
|
+
// src/models/agent.ts
|
|
3488
|
+
var AgentConfig;
|
|
3489
|
+
((AgentConfig2) => {
|
|
3490
|
+
AgentConfig2.DEFAULT_AUTHENTICATOR_NAME = "Username & Password";
|
|
3491
|
+
})(AgentConfig || (AgentConfig = {}));
|
|
3492
|
+
|
|
3442
3493
|
// src/models/scim2-schema.ts
|
|
3443
3494
|
var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
3444
3495
|
WellKnownSchemaIds2["Core"] = "urn:ietf:params:scim:schemas:core:2.0";
|
|
@@ -3465,8 +3516,225 @@ var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
|
3465
3516
|
return FieldType2;
|
|
3466
3517
|
})(FieldType || {});
|
|
3467
3518
|
|
|
3519
|
+
// src/DefaultCacheStore.ts
|
|
3520
|
+
var DefaultCacheStore = class {
|
|
3521
|
+
constructor() {
|
|
3522
|
+
__publicField(this, "cache");
|
|
3523
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
3524
|
+
}
|
|
3525
|
+
get length() {
|
|
3526
|
+
return this.cache.size;
|
|
3527
|
+
}
|
|
3528
|
+
getItem(key) {
|
|
3529
|
+
return this.cache.get(key) ?? null;
|
|
3530
|
+
}
|
|
3531
|
+
setItem(key, value) {
|
|
3532
|
+
this.cache.set(key, value);
|
|
3533
|
+
}
|
|
3534
|
+
removeItem(key) {
|
|
3535
|
+
this.cache.delete(key);
|
|
3536
|
+
}
|
|
3537
|
+
clear() {
|
|
3538
|
+
this.cache.clear();
|
|
3539
|
+
}
|
|
3540
|
+
key(index) {
|
|
3541
|
+
const keys = Array.from(this.cache.keys());
|
|
3542
|
+
return keys[index] ?? null;
|
|
3543
|
+
}
|
|
3544
|
+
async setData(key, value) {
|
|
3545
|
+
this.cache.set(key, value);
|
|
3546
|
+
}
|
|
3547
|
+
async getData(key) {
|
|
3548
|
+
return this.cache.get(key) ?? "{}";
|
|
3549
|
+
}
|
|
3550
|
+
async removeData(key) {
|
|
3551
|
+
this.cache.delete(key);
|
|
3552
|
+
}
|
|
3553
|
+
};
|
|
3554
|
+
|
|
3555
|
+
// src/DefaultCrypto.ts
|
|
3556
|
+
var jose = __toESM(require("jose"), 1);
|
|
3557
|
+
var DefaultCrypto = class {
|
|
3558
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3559
|
+
base64URLDecode(value) {
|
|
3560
|
+
const decodedArray = jose.base64url.decode(value);
|
|
3561
|
+
return new TextDecoder().decode(decodedArray);
|
|
3562
|
+
}
|
|
3563
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3564
|
+
base64URLEncode(value) {
|
|
3565
|
+
return jose.base64url.encode(value);
|
|
3566
|
+
}
|
|
3567
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3568
|
+
generateRandomBytes(length) {
|
|
3569
|
+
return crypto.getRandomValues(new Uint8Array(length));
|
|
3570
|
+
}
|
|
3571
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3572
|
+
async hashSha256(data) {
|
|
3573
|
+
const encoder = new TextEncoder();
|
|
3574
|
+
const dataBuffer = encoder.encode(data);
|
|
3575
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", dataBuffer);
|
|
3576
|
+
return new Uint8Array(hashBuffer);
|
|
3577
|
+
}
|
|
3578
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3579
|
+
async verifyJwt(idToken, jwk, algorithms, clientId, issuer, subject, clockTolerance, validateJwtIssuer = true) {
|
|
3580
|
+
const key = await jose.importJWK(jwk);
|
|
3581
|
+
await jose.jwtVerify(idToken, key, {
|
|
3582
|
+
algorithms,
|
|
3583
|
+
audience: clientId,
|
|
3584
|
+
clockTolerance,
|
|
3585
|
+
issuer: validateJwtIssuer ? issuer : void 0,
|
|
3586
|
+
subject
|
|
3587
|
+
});
|
|
3588
|
+
return true;
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
|
|
3468
3592
|
// src/AsgardeoJavaScriptClient.ts
|
|
3469
3593
|
var AsgardeoJavaScriptClient = class {
|
|
3594
|
+
constructor(config, cacheStore, cryptoUtils) {
|
|
3595
|
+
__publicField(this, "cacheStore");
|
|
3596
|
+
__publicField(this, "cryptoUtils");
|
|
3597
|
+
__publicField(this, "auth");
|
|
3598
|
+
__publicField(this, "storageManager");
|
|
3599
|
+
__publicField(this, "baseURL");
|
|
3600
|
+
this.cacheStore = cacheStore ?? new DefaultCacheStore();
|
|
3601
|
+
this.cryptoUtils = cryptoUtils ?? new DefaultCrypto();
|
|
3602
|
+
this.auth = new AsgardeoAuthClient();
|
|
3603
|
+
if (config) {
|
|
3604
|
+
this.auth.initialize(config, this.cacheStore, this.cryptoUtils);
|
|
3605
|
+
this.storageManager = this.auth.getStorageManager();
|
|
3606
|
+
}
|
|
3607
|
+
this.baseURL = config?.baseUrl ?? "";
|
|
3608
|
+
}
|
|
3609
|
+
/* eslint-disable class-methods-use-this, @typescript-eslint/no-unused-vars */
|
|
3610
|
+
switchOrganization(_organization, _sessionId) {
|
|
3611
|
+
throw new Error("Method not implemented.");
|
|
3612
|
+
}
|
|
3613
|
+
initialize(_config, _storage) {
|
|
3614
|
+
throw new Error("Method not implemented.");
|
|
3615
|
+
}
|
|
3616
|
+
reInitialize(_config) {
|
|
3617
|
+
throw new Error("Method not implemented.");
|
|
3618
|
+
}
|
|
3619
|
+
getUser(_options) {
|
|
3620
|
+
throw new Error("Method not implemented.");
|
|
3621
|
+
}
|
|
3622
|
+
getAllOrganizations(_options, _sessionId) {
|
|
3623
|
+
throw new Error("Method not implemented.");
|
|
3624
|
+
}
|
|
3625
|
+
getMyOrganizations(_options, _sessionId) {
|
|
3626
|
+
throw new Error("Method not implemented.");
|
|
3627
|
+
}
|
|
3628
|
+
getCurrentOrganization(_sessionId) {
|
|
3629
|
+
throw new Error("Method not implemented.");
|
|
3630
|
+
}
|
|
3631
|
+
getUserProfile(_options) {
|
|
3632
|
+
throw new Error("Method not implemented.");
|
|
3633
|
+
}
|
|
3634
|
+
isLoading() {
|
|
3635
|
+
throw new Error("Method not implemented.");
|
|
3636
|
+
}
|
|
3637
|
+
isSignedIn() {
|
|
3638
|
+
throw new Error("Method not implemented.");
|
|
3639
|
+
}
|
|
3640
|
+
updateUserProfile(_payload, _userId) {
|
|
3641
|
+
throw new Error("Method not implemented.");
|
|
3642
|
+
}
|
|
3643
|
+
getConfiguration() {
|
|
3644
|
+
throw new Error("Method not implemented.");
|
|
3645
|
+
}
|
|
3646
|
+
exchangeToken(_config, _sessionId) {
|
|
3647
|
+
throw new Error("Method not implemented.");
|
|
3648
|
+
}
|
|
3649
|
+
signInSilently(_options) {
|
|
3650
|
+
throw new Error("Method not implemented.");
|
|
3651
|
+
}
|
|
3652
|
+
getAccessToken(_sessionId) {
|
|
3653
|
+
throw new Error("Method not implemented.");
|
|
3654
|
+
}
|
|
3655
|
+
clearSession(_sessionId) {
|
|
3656
|
+
throw new Error("Method not implemented.");
|
|
3657
|
+
}
|
|
3658
|
+
setSession(_sessionData, _sessionId) {
|
|
3659
|
+
throw new Error("Method not implemented.");
|
|
3660
|
+
}
|
|
3661
|
+
decodeJwtToken(_token) {
|
|
3662
|
+
throw new Error("Method not implemented.");
|
|
3663
|
+
}
|
|
3664
|
+
signIn(_options) {
|
|
3665
|
+
throw new Error("Method not implemented.");
|
|
3666
|
+
}
|
|
3667
|
+
signOut(_options, _sessionIdOrAfterSignOut, _afterSignOut) {
|
|
3668
|
+
throw new Error("Method not implemented.");
|
|
3669
|
+
}
|
|
3670
|
+
signUp(_optionsOrPayload) {
|
|
3671
|
+
throw new Error("Method not implemented.");
|
|
3672
|
+
}
|
|
3673
|
+
/* eslint-enable class-methods-use-this, @typescript-eslint/no-unused-vars */
|
|
3674
|
+
async getAgentToken(agentConfig) {
|
|
3675
|
+
const customParam = {
|
|
3676
|
+
response_mode: "direct"
|
|
3677
|
+
};
|
|
3678
|
+
const authorizeURL = new URL(await this.auth.getSignInUrl(customParam));
|
|
3679
|
+
const authorizeResponse = await initializeEmbeddedSignInFlow_default({
|
|
3680
|
+
payload: Object.fromEntries(authorizeURL.searchParams.entries()),
|
|
3681
|
+
url: `${authorizeURL.origin}${authorizeURL.pathname}`
|
|
3682
|
+
});
|
|
3683
|
+
const authenticatorName = agentConfig.authenticatorName ?? AgentConfig.DEFAULT_AUTHENTICATOR_NAME;
|
|
3684
|
+
const targetAuthenticator = authorizeResponse.nextStep.authenticators.find(
|
|
3685
|
+
(auth) => auth.authenticator === authenticatorName
|
|
3686
|
+
);
|
|
3687
|
+
if (!targetAuthenticator) {
|
|
3688
|
+
throw new Error(`Authenticator '${authenticatorName}' not found among authentication steps.`);
|
|
3689
|
+
}
|
|
3690
|
+
const authnRequest = {
|
|
3691
|
+
baseUrl: this.baseURL,
|
|
3692
|
+
payload: {
|
|
3693
|
+
flowId: authorizeResponse.flowId,
|
|
3694
|
+
selectedAuthenticator: {
|
|
3695
|
+
authenticatorId: targetAuthenticator.authenticatorId,
|
|
3696
|
+
params: {
|
|
3697
|
+
password: agentConfig.agentSecret,
|
|
3698
|
+
username: agentConfig.agentID
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
};
|
|
3703
|
+
const authnResponse = await executeEmbeddedSignInFlow_default(authnRequest);
|
|
3704
|
+
if (authnResponse.flowStatus !== "SUCCESS_COMPLETED" /* SuccessCompleted */) {
|
|
3705
|
+
throw new Error("Agent authentication failed.");
|
|
3706
|
+
}
|
|
3707
|
+
return this.auth.requestAccessToken(
|
|
3708
|
+
authnResponse.authData["code"],
|
|
3709
|
+
authnResponse.authData["session_state"],
|
|
3710
|
+
authnResponse.authData["state"]
|
|
3711
|
+
);
|
|
3712
|
+
}
|
|
3713
|
+
async getOBOSignInURL(agentConfig) {
|
|
3714
|
+
const customParam = {
|
|
3715
|
+
requested_actor: agentConfig.agentID
|
|
3716
|
+
};
|
|
3717
|
+
const authURL = await this.auth.getSignInUrl(customParam);
|
|
3718
|
+
if (authURL) {
|
|
3719
|
+
return authURL.toString();
|
|
3720
|
+
}
|
|
3721
|
+
throw new Error("Could not build Authorize URL");
|
|
3722
|
+
}
|
|
3723
|
+
async getOBOToken(agentConfig, authCodeResponse) {
|
|
3724
|
+
const agentToken = await this.getAgentToken(agentConfig);
|
|
3725
|
+
const tokenRequestConfig = {
|
|
3726
|
+
params: {
|
|
3727
|
+
actor_token: agentToken.accessToken
|
|
3728
|
+
}
|
|
3729
|
+
};
|
|
3730
|
+
return this.auth.requestAccessToken(
|
|
3731
|
+
authCodeResponse.code,
|
|
3732
|
+
authCodeResponse.session_state,
|
|
3733
|
+
authCodeResponse.state,
|
|
3734
|
+
void 0,
|
|
3735
|
+
tokenRequestConfig
|
|
3736
|
+
);
|
|
3737
|
+
}
|
|
3470
3738
|
};
|
|
3471
3739
|
var AsgardeoJavaScriptClient_default = AsgardeoJavaScriptClient;
|
|
3472
3740
|
|
|
@@ -4060,9 +4328,9 @@ var arrayBufferToBase64url = (buffer) => {
|
|
|
4060
4328
|
var arrayBufferToBase64url_default = arrayBufferToBase64url;
|
|
4061
4329
|
|
|
4062
4330
|
// src/utils/base64urlToArrayBuffer.ts
|
|
4063
|
-
var base64urlToArrayBuffer = (
|
|
4064
|
-
const padding = "=".repeat((4 -
|
|
4065
|
-
const base64 =
|
|
4331
|
+
var base64urlToArrayBuffer = (base64url2) => {
|
|
4332
|
+
const padding = "=".repeat((4 - base64url2.length % 4) % 4);
|
|
4333
|
+
const base64 = base64url2.replace(/-/g, "+").replace(/_/g, "/") + padding;
|
|
4066
4334
|
const binaryString = atob(base64);
|
|
4067
4335
|
const bytes = new Uint8Array(binaryString.length);
|
|
4068
4336
|
for (let i = 0; i < binaryString.length; i += 1) {
|
|
@@ -4100,31 +4368,6 @@ var formatDate = (dateString) => {
|
|
|
4100
4368
|
};
|
|
4101
4369
|
var formatDate_default = formatDate;
|
|
4102
4370
|
|
|
4103
|
-
// src/utils/deepMerge.ts
|
|
4104
|
-
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
4105
|
-
var deepMerge = (target, ...sources) => {
|
|
4106
|
-
if (!target || typeof target !== "object") {
|
|
4107
|
-
throw new Error("Target must be an object");
|
|
4108
|
-
}
|
|
4109
|
-
const result = { ...target };
|
|
4110
|
-
sources.forEach((source) => {
|
|
4111
|
-
if (!source || typeof source !== "object") {
|
|
4112
|
-
return;
|
|
4113
|
-
}
|
|
4114
|
-
Object.keys(source).forEach((key) => {
|
|
4115
|
-
const sourceValue = source[key];
|
|
4116
|
-
const targetValue = result[key];
|
|
4117
|
-
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
4118
|
-
result[key] = deepMerge(targetValue, sourceValue);
|
|
4119
|
-
} else if (sourceValue !== void 0) {
|
|
4120
|
-
result[key] = sourceValue;
|
|
4121
|
-
}
|
|
4122
|
-
});
|
|
4123
|
-
});
|
|
4124
|
-
return result;
|
|
4125
|
-
};
|
|
4126
|
-
var deepMerge_default = deepMerge;
|
|
4127
|
-
|
|
4128
4371
|
// src/utils/logger.ts
|
|
4129
4372
|
var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
|
|
4130
4373
|
var DEFAULT_CONFIG = {
|
|
@@ -4756,6 +4999,48 @@ var resolveFieldName = (field) => {
|
|
|
4756
4999
|
};
|
|
4757
5000
|
var resolveFieldName_default = resolveFieldName;
|
|
4758
5001
|
|
|
5002
|
+
// src/utils/v2/resolveMeta.ts
|
|
5003
|
+
function resolveMeta(path, meta) {
|
|
5004
|
+
const value = path.split(".").reduce((current, part) => {
|
|
5005
|
+
if (current == null || typeof current !== "object") {
|
|
5006
|
+
return void 0;
|
|
5007
|
+
}
|
|
5008
|
+
const obj = current;
|
|
5009
|
+
const snakePart = part.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
5010
|
+
return part in obj ? obj[part] : obj[snakePart];
|
|
5011
|
+
}, meta);
|
|
5012
|
+
return value != null ? String(value) : "";
|
|
5013
|
+
}
|
|
5014
|
+
|
|
5015
|
+
// src/utils/v2/resolveVars.ts
|
|
5016
|
+
function resolveVars(text, { t, meta }) {
|
|
5017
|
+
if (!text) {
|
|
5018
|
+
return "";
|
|
5019
|
+
}
|
|
5020
|
+
return text.replace(/\{\{(.+?)\}\}/g, (match, content) => {
|
|
5021
|
+
const trimmed = content.trim();
|
|
5022
|
+
const tMatch = trimmed.match(/^t\((.+)\)$/);
|
|
5023
|
+
if (tMatch) {
|
|
5024
|
+
let key = tMatch[1].trim();
|
|
5025
|
+
if (key.startsWith('"') && key.endsWith('"') || key.startsWith("'") && key.endsWith("'")) {
|
|
5026
|
+
key = key.slice(1, -1);
|
|
5027
|
+
}
|
|
5028
|
+
return t(key.replace(/:/g, "."));
|
|
5029
|
+
}
|
|
5030
|
+
if (meta) {
|
|
5031
|
+
const metaMatch = trimmed.match(/^meta\((.+)\)$/);
|
|
5032
|
+
if (metaMatch) {
|
|
5033
|
+
let path = metaMatch[1].trim();
|
|
5034
|
+
if (path.startsWith('"') && path.endsWith('"') || path.startsWith("'") && path.endsWith("'")) {
|
|
5035
|
+
path = path.slice(1, -1);
|
|
5036
|
+
}
|
|
5037
|
+
return resolveMeta(path, meta);
|
|
5038
|
+
}
|
|
5039
|
+
}
|
|
5040
|
+
return match;
|
|
5041
|
+
});
|
|
5042
|
+
}
|
|
5043
|
+
|
|
4759
5044
|
// src/utils/withVendorCSSClassPrefix.ts
|
|
4760
5045
|
var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_PREFIX}-${className}`;
|
|
4761
5046
|
var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
|
|
@@ -4899,6 +5184,7 @@ var transformBrandingPreferenceToTheme = (brandingPreference, forceTheme) => {
|
|
|
4899
5184
|
var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTheme;
|
|
4900
5185
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4901
5186
|
0 && (module.exports = {
|
|
5187
|
+
AgentConfig,
|
|
4902
5188
|
ApplicationNativeAuthenticationConstants,
|
|
4903
5189
|
AsgardeoAPIError,
|
|
4904
5190
|
AsgardeoAuthClient,
|
|
@@ -4983,6 +5269,8 @@ var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTh
|
|
|
4983
5269
|
removeTrailingSlash,
|
|
4984
5270
|
resolveFieldName,
|
|
4985
5271
|
resolveFieldType,
|
|
5272
|
+
resolveMeta,
|
|
5273
|
+
resolveVars,
|
|
4986
5274
|
set,
|
|
4987
5275
|
transformBrandingPreferenceToTheme,
|
|
4988
5276
|
updateMeProfile,
|