@asgardeo/javascript 0.1.20 → 0.1.21
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 +1 -1
- package/dist/api/v2/executeEmbeddedSignInFlowV2.d.ts +20 -0
- package/dist/cjs/index.js +132 -0
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +4 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +4 -4
- package/dist/models/client.d.ts +19 -0
- package/dist/models/config.d.ts +7 -0
- package/dist/models/embedded-flow.d.ts +1 -0
- package/dist/models/platforms.d.ts +2 -0
- package/dist/models/v2/embedded-signin-flow-v2.d.ts +78 -0
- package/dist/utils/arrayBufferToBase64url.d.ts +48 -0
- package/dist/utils/base64urlToArrayBuffer.d.ts +55 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export { default as getOrganization, OrganizationDetails, GetOrganizationConfig
|
|
|
31
31
|
export { default as updateOrganization, createPatchOperations, UpdateOrganizationConfig } from './api/updateOrganization';
|
|
32
32
|
export { default as updateMeProfile, UpdateMeProfileConfig } from './api/updateMeProfile';
|
|
33
33
|
export { default as getBrandingPreference, GetBrandingPreferenceConfig } from './api/getBrandingPreference';
|
|
34
|
+
export { default as executeEmbeddedSignInFlowV2 } from './api/v2/executeEmbeddedSignInFlowV2';
|
|
34
35
|
export { default as ApplicationNativeAuthenticationConstants } from './constants/ApplicationNativeAuthenticationConstants';
|
|
35
36
|
export { default as TokenConstants } from './constants/TokenConstants';
|
|
36
37
|
export { default as OIDCRequestConstants } from './constants/OIDCRequestConstants';
|
|
@@ -42,6 +43,7 @@ export { AsgardeoAuthException } from './errors/exception';
|
|
|
42
43
|
export { AllOrganizationsApiResponse } from './models/organization';
|
|
43
44
|
export { Platform } from './models/platforms';
|
|
44
45
|
export { EmbeddedSignInFlowInitiateResponse, EmbeddedSignInFlowStatus, EmbeddedSignInFlowType, EmbeddedSignInFlowStepType, EmbeddedSignInFlowAuthenticator, EmbeddedSignInFlowLink, EmbeddedSignInFlowHandleRequestPayload, EmbeddedSignInFlowHandleResponse, EmbeddedSignInFlowAuthenticatorParamType, EmbeddedSignInFlowAuthenticatorPromptType, EmbeddedSignInFlowAuthenticatorKnownIdPType, } from './models/embedded-signin-flow';
|
|
46
|
+
export { EmbeddedSignInFlowResponseV2, EmbeddedSignInFlowStatusV2, EmbeddedSignInFlowTypeV2, EmbeddedSignInFlowInitiateRequestV2, EmbeddedSignInFlowRequestV2, } from './models/v2/embedded-signin-flow-v2';
|
|
45
47
|
export { EmbeddedFlowType, EmbeddedFlowStatus, EmbeddedFlowExecuteResponse, EmbeddedFlowResponseType, EmbeddedSignUpFlowData, EmbeddedFlowComponent, EmbeddedFlowComponentType, EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteRequestConfig, } from './models/embedded-flow';
|
|
46
48
|
export { FlowMode } from './models/flow';
|
|
47
49
|
export { AsgardeoClient } from './models/client';
|
|
@@ -62,6 +64,8 @@ export { FieldType } from './models/field';
|
|
|
62
64
|
export { default as AsgardeoJavaScriptClient } from './AsgardeoJavaScriptClient';
|
|
63
65
|
export { default as createTheme, DEFAULT_THEME } from './theme/createTheme';
|
|
64
66
|
export { ThemeColors, ThemeConfig, Theme, ThemeMode, ThemeDetection } from './theme/types';
|
|
67
|
+
export { default as arrayBufferToBase64url } from './utils/arrayBufferToBase64url';
|
|
68
|
+
export { default as base64urlToArrayBuffer } from './utils/base64urlToArrayBuffer';
|
|
65
69
|
export { default as bem } from './utils/bem';
|
|
66
70
|
export { default as formatDate } from './utils/formatDate';
|
|
67
71
|
export { default as processUsername } from './utils/processUsername';
|
package/dist/index.js
CHANGED
|
@@ -2010,6 +2010,7 @@ var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
|
|
|
2010
2010
|
|
|
2011
2011
|
// src/models/embedded-flow.ts
|
|
2012
2012
|
var EmbeddedFlowType = /* @__PURE__ */ ((EmbeddedFlowType2) => {
|
|
2013
|
+
EmbeddedFlowType2["Authentication"] = "AUTHENTICATION";
|
|
2013
2014
|
EmbeddedFlowType2["Registration"] = "REGISTRATION";
|
|
2014
2015
|
return EmbeddedFlowType2;
|
|
2015
2016
|
})(EmbeddedFlowType || {});
|
|
@@ -2779,6 +2780,102 @@ var getBrandingPreference = async ({
|
|
|
2779
2780
|
};
|
|
2780
2781
|
var getBrandingPreference_default = getBrandingPreference;
|
|
2781
2782
|
|
|
2783
|
+
// src/models/v2/embedded-signin-flow-v2.ts
|
|
2784
|
+
var EmbeddedSignInFlowStatusV2 = /* @__PURE__ */ ((EmbeddedSignInFlowStatusV22) => {
|
|
2785
|
+
EmbeddedSignInFlowStatusV22["Complete"] = "COMPLETE";
|
|
2786
|
+
EmbeddedSignInFlowStatusV22["Incomplete"] = "INCOMPLETE";
|
|
2787
|
+
EmbeddedSignInFlowStatusV22["Error"] = "ERROR";
|
|
2788
|
+
return EmbeddedSignInFlowStatusV22;
|
|
2789
|
+
})(EmbeddedSignInFlowStatusV2 || {});
|
|
2790
|
+
var EmbeddedSignInFlowTypeV2 = /* @__PURE__ */ ((EmbeddedSignInFlowTypeV22) => {
|
|
2791
|
+
EmbeddedSignInFlowTypeV22["Redirection"] = "REDIRECTION";
|
|
2792
|
+
EmbeddedSignInFlowTypeV22["View"] = "VIEW";
|
|
2793
|
+
return EmbeddedSignInFlowTypeV22;
|
|
2794
|
+
})(EmbeddedSignInFlowTypeV2 || {});
|
|
2795
|
+
|
|
2796
|
+
// src/api/v2/executeEmbeddedSignInFlowV2.ts
|
|
2797
|
+
var executeEmbeddedSignInFlowV2 = async ({
|
|
2798
|
+
url,
|
|
2799
|
+
baseUrl,
|
|
2800
|
+
payload,
|
|
2801
|
+
sessionDataKey,
|
|
2802
|
+
...requestConfig
|
|
2803
|
+
}) => {
|
|
2804
|
+
if (!payload) {
|
|
2805
|
+
throw new AsgardeoAPIError(
|
|
2806
|
+
"Authorization payload is required",
|
|
2807
|
+
"executeEmbeddedSignInFlow-ValidationError-002",
|
|
2808
|
+
"javascript",
|
|
2809
|
+
400,
|
|
2810
|
+
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
2811
|
+
);
|
|
2812
|
+
}
|
|
2813
|
+
let endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
2814
|
+
const response = await fetch(endpoint, {
|
|
2815
|
+
...requestConfig,
|
|
2816
|
+
method: requestConfig.method || "POST",
|
|
2817
|
+
headers: {
|
|
2818
|
+
"Content-Type": "application/json",
|
|
2819
|
+
Accept: "application/json",
|
|
2820
|
+
...requestConfig.headers
|
|
2821
|
+
},
|
|
2822
|
+
body: JSON.stringify(payload)
|
|
2823
|
+
});
|
|
2824
|
+
if (!response.ok) {
|
|
2825
|
+
const errorText = await response.text();
|
|
2826
|
+
throw new AsgardeoAPIError(
|
|
2827
|
+
`Authorization request failed: ${errorText}`,
|
|
2828
|
+
"executeEmbeddedSignInFlow-ResponseError-001",
|
|
2829
|
+
"javascript",
|
|
2830
|
+
response.status,
|
|
2831
|
+
response.statusText
|
|
2832
|
+
);
|
|
2833
|
+
}
|
|
2834
|
+
const flowResponse = await response.json();
|
|
2835
|
+
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && sessionDataKey) {
|
|
2836
|
+
try {
|
|
2837
|
+
const oauth2Response = await fetch(`${baseUrl}/oauth2/authorize`, {
|
|
2838
|
+
method: "POST",
|
|
2839
|
+
headers: {
|
|
2840
|
+
"Content-Type": "application/json",
|
|
2841
|
+
Accept: "application/json",
|
|
2842
|
+
...requestConfig.headers
|
|
2843
|
+
},
|
|
2844
|
+
body: JSON.stringify({
|
|
2845
|
+
assertion: flowResponse.assertion,
|
|
2846
|
+
sessionDataKey
|
|
2847
|
+
}),
|
|
2848
|
+
credentials: "include"
|
|
2849
|
+
});
|
|
2850
|
+
if (!oauth2Response.ok) {
|
|
2851
|
+
const oauth2ErrorText = await oauth2Response.text();
|
|
2852
|
+
throw new AsgardeoAPIError(
|
|
2853
|
+
`OAuth2 authorization failed: ${oauth2ErrorText}`,
|
|
2854
|
+
"executeEmbeddedSignInFlow-OAuth2Error-002",
|
|
2855
|
+
"javascript",
|
|
2856
|
+
oauth2Response.status,
|
|
2857
|
+
oauth2Response.statusText
|
|
2858
|
+
);
|
|
2859
|
+
}
|
|
2860
|
+
const oauth2Result = await oauth2Response.json();
|
|
2861
|
+
return {
|
|
2862
|
+
flowStatus: flowResponse.flowStatus,
|
|
2863
|
+
redirectUrl: oauth2Result.redirect_uri
|
|
2864
|
+
};
|
|
2865
|
+
} catch (authError) {
|
|
2866
|
+
throw new AsgardeoAPIError(
|
|
2867
|
+
`OAuth2 authorization failed: ${authError instanceof Error ? authError.message : "Unknown error"}`,
|
|
2868
|
+
"executeEmbeddedSignInFlow-OAuth2Error-001",
|
|
2869
|
+
"javascript",
|
|
2870
|
+
500,
|
|
2871
|
+
"Failed to complete OAuth2 authorization after successful embedded sign-in flow."
|
|
2872
|
+
);
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
return flowResponse;
|
|
2876
|
+
};
|
|
2877
|
+
var executeEmbeddedSignInFlowV2_default = executeEmbeddedSignInFlowV2;
|
|
2878
|
+
|
|
2782
2879
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
2783
2880
|
var ApplicationNativeAuthenticationConstants = {
|
|
2784
2881
|
SupportedAuthenticators: {
|
|
@@ -2813,6 +2910,7 @@ var VendorConstants_default = VendorConstants;
|
|
|
2813
2910
|
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
2814
2911
|
Platform2["Asgardeo"] = "ASGARDEO";
|
|
2815
2912
|
Platform2["IdentityServer"] = "IDENTITY_SERVER";
|
|
2913
|
+
Platform2["AsgardeoV2"] = "AsgardeoV2";
|
|
2816
2914
|
Platform2["Unknown"] = "UNKNOWN";
|
|
2817
2915
|
return Platform2;
|
|
2818
2916
|
})(Platform || {});
|
|
@@ -3467,6 +3565,30 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3467
3565
|
var DEFAULT_THEME = "light";
|
|
3468
3566
|
var createTheme_default = createTheme;
|
|
3469
3567
|
|
|
3568
|
+
// src/utils/arrayBufferToBase64url.ts
|
|
3569
|
+
var arrayBufferToBase64url = (buffer) => {
|
|
3570
|
+
const bytes = new Uint8Array(buffer);
|
|
3571
|
+
let binary = "";
|
|
3572
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
3573
|
+
binary += String.fromCharCode(bytes[i]);
|
|
3574
|
+
}
|
|
3575
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
3576
|
+
};
|
|
3577
|
+
var arrayBufferToBase64url_default = arrayBufferToBase64url;
|
|
3578
|
+
|
|
3579
|
+
// src/utils/base64urlToArrayBuffer.ts
|
|
3580
|
+
var base64urlToArrayBuffer = (base64url) => {
|
|
3581
|
+
const padding = "=".repeat((4 - base64url.length % 4) % 4);
|
|
3582
|
+
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/") + padding;
|
|
3583
|
+
const binaryString = atob(base64);
|
|
3584
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
3585
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
3586
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
3587
|
+
}
|
|
3588
|
+
return bytes.buffer;
|
|
3589
|
+
};
|
|
3590
|
+
var base64urlToArrayBuffer_default = base64urlToArrayBuffer;
|
|
3591
|
+
|
|
3470
3592
|
// src/utils/bem.ts
|
|
3471
3593
|
var bem = (baseClass, element, modifier) => {
|
|
3472
3594
|
let className = baseClass;
|
|
@@ -4314,8 +4436,10 @@ export {
|
|
|
4314
4436
|
EmbeddedSignInFlowAuthenticatorParamType,
|
|
4315
4437
|
EmbeddedSignInFlowAuthenticatorPromptType,
|
|
4316
4438
|
EmbeddedSignInFlowStatus,
|
|
4439
|
+
EmbeddedSignInFlowStatusV2,
|
|
4317
4440
|
EmbeddedSignInFlowStepType,
|
|
4318
4441
|
EmbeddedSignInFlowType,
|
|
4442
|
+
EmbeddedSignInFlowTypeV2,
|
|
4319
4443
|
FieldType,
|
|
4320
4444
|
FlowMode,
|
|
4321
4445
|
IsomorphicCrypto,
|
|
@@ -4325,6 +4449,8 @@ export {
|
|
|
4325
4449
|
TokenConstants_default as TokenConstants,
|
|
4326
4450
|
VendorConstants_default as VendorConstants,
|
|
4327
4451
|
WellKnownSchemaIds,
|
|
4452
|
+
arrayBufferToBase64url_default as arrayBufferToBase64url,
|
|
4453
|
+
base64urlToArrayBuffer_default as base64urlToArrayBuffer,
|
|
4328
4454
|
bem_default as bem,
|
|
4329
4455
|
configure as configureLogger,
|
|
4330
4456
|
createComponentLogger,
|
|
@@ -4339,6 +4465,7 @@ export {
|
|
|
4339
4465
|
deriveOrganizationHandleFromBaseUrl_default as deriveOrganizationHandleFromBaseUrl,
|
|
4340
4466
|
error,
|
|
4341
4467
|
executeEmbeddedSignInFlow_default as executeEmbeddedSignInFlow,
|
|
4468
|
+
executeEmbeddedSignInFlowV2_default as executeEmbeddedSignInFlowV2,
|
|
4342
4469
|
executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow,
|
|
4343
4470
|
extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
|
|
4344
4471
|
extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
|