@asgardeo/javascript 0.1.23 → 0.2.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.
- package/dist/api/v2/executeEmbeddedSignUpFlowV2.d.ts +20 -0
- package/dist/cjs/index.js +102 -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 +5 -0
- package/dist/models/v2/embedded-signup-flow-v2.d.ts +89 -0
- package/dist/theme/types.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { default as updateOrganization, createPatchOperations, UpdateOrganizatio
|
|
|
32
32
|
export { default as updateMeProfile, UpdateMeProfileConfig } from './api/updateMeProfile';
|
|
33
33
|
export { default as getBrandingPreference, GetBrandingPreferenceConfig } from './api/getBrandingPreference';
|
|
34
34
|
export { default as executeEmbeddedSignInFlowV2 } from './api/v2/executeEmbeddedSignInFlowV2';
|
|
35
|
+
export { default as executeEmbeddedSignUpFlowV2 } from './api/v2/executeEmbeddedSignUpFlowV2';
|
|
35
36
|
export { default as ApplicationNativeAuthenticationConstants } from './constants/ApplicationNativeAuthenticationConstants';
|
|
36
37
|
export { default as TokenConstants } from './constants/TokenConstants';
|
|
37
38
|
export { default as OIDCRequestConstants } from './constants/OIDCRequestConstants';
|
|
@@ -45,6 +46,7 @@ export { Platform } from './models/platforms';
|
|
|
45
46
|
export { EmbeddedSignInFlowInitiateResponse, EmbeddedSignInFlowStatus, EmbeddedSignInFlowType, EmbeddedSignInFlowStepType, EmbeddedSignInFlowAuthenticator, EmbeddedSignInFlowLink, EmbeddedSignInFlowHandleRequestPayload, EmbeddedSignInFlowHandleResponse, EmbeddedSignInFlowAuthenticatorParamType, EmbeddedSignInFlowAuthenticatorPromptType, EmbeddedSignInFlowAuthenticatorKnownIdPType, } from './models/embedded-signin-flow';
|
|
46
47
|
export { EmbeddedSignInFlowResponseV2, EmbeddedSignInFlowStatusV2, EmbeddedSignInFlowTypeV2, EmbeddedSignInFlowInitiateRequestV2, EmbeddedSignInFlowRequestV2, } from './models/v2/embedded-signin-flow-v2';
|
|
47
48
|
export { EmbeddedFlowType, EmbeddedFlowStatus, EmbeddedFlowExecuteResponse, EmbeddedFlowResponseType, EmbeddedSignUpFlowData, EmbeddedFlowComponent, EmbeddedFlowComponentType, EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteRequestConfig, } from './models/embedded-flow';
|
|
49
|
+
export { EmbeddedSignUpFlowStatusV2, EmbeddedSignUpFlowInitiateRequestV2, EmbeddedSignUpFlowRequestV2, EmbeddedSignUpFlowCompleteResponse, EmbeddedSignUpFlowResponseV2, ExtendedEmbeddedSignUpFlowResponseV2, EmbeddedSignUpFlowTypeV2, EmbeddedFlowExecuteRequestConfigV2, } from './models/v2/embedded-signup-flow-v2';
|
|
48
50
|
export { FlowMode } from './models/flow';
|
|
49
51
|
export { AsgardeoClient } from './models/client';
|
|
50
52
|
export { BaseConfig, Config, Preferences, ThemePreferences, I18nPreferences, WithPreferences, SignInOptions, SignOutOptions, SignUpOptions, } from './models/config';
|
package/dist/index.js
CHANGED
|
@@ -2961,6 +2961,102 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
2961
2961
|
};
|
|
2962
2962
|
var executeEmbeddedSignInFlowV2_default = executeEmbeddedSignInFlowV2;
|
|
2963
2963
|
|
|
2964
|
+
// src/models/v2/embedded-signup-flow-v2.ts
|
|
2965
|
+
var EmbeddedSignUpFlowStatusV2 = /* @__PURE__ */ ((EmbeddedSignUpFlowStatusV22) => {
|
|
2966
|
+
EmbeddedSignUpFlowStatusV22["Complete"] = "COMPLETE";
|
|
2967
|
+
EmbeddedSignUpFlowStatusV22["Incomplete"] = "INCOMPLETE";
|
|
2968
|
+
EmbeddedSignUpFlowStatusV22["Error"] = "ERROR";
|
|
2969
|
+
return EmbeddedSignUpFlowStatusV22;
|
|
2970
|
+
})(EmbeddedSignUpFlowStatusV2 || {});
|
|
2971
|
+
var EmbeddedSignUpFlowTypeV2 = /* @__PURE__ */ ((EmbeddedSignUpFlowTypeV22) => {
|
|
2972
|
+
EmbeddedSignUpFlowTypeV22["Redirection"] = "REDIRECTION";
|
|
2973
|
+
EmbeddedSignUpFlowTypeV22["View"] = "VIEW";
|
|
2974
|
+
return EmbeddedSignUpFlowTypeV22;
|
|
2975
|
+
})(EmbeddedSignUpFlowTypeV2 || {});
|
|
2976
|
+
|
|
2977
|
+
// src/api/v2/executeEmbeddedSignUpFlowV2.ts
|
|
2978
|
+
var executeEmbeddedSignUpFlowV2 = async ({
|
|
2979
|
+
url,
|
|
2980
|
+
baseUrl,
|
|
2981
|
+
payload,
|
|
2982
|
+
sessionDataKey,
|
|
2983
|
+
...requestConfig
|
|
2984
|
+
}) => {
|
|
2985
|
+
if (!payload) {
|
|
2986
|
+
throw new AsgardeoAPIError(
|
|
2987
|
+
"Registration payload is required",
|
|
2988
|
+
"executeEmbeddedSignUpFlow-ValidationError-002",
|
|
2989
|
+
"javascript",
|
|
2990
|
+
400,
|
|
2991
|
+
"If a registration payload is not provided, the request cannot be constructed correctly."
|
|
2992
|
+
);
|
|
2993
|
+
}
|
|
2994
|
+
let endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
2995
|
+
const response = await fetch(endpoint, {
|
|
2996
|
+
...requestConfig,
|
|
2997
|
+
method: requestConfig.method || "POST",
|
|
2998
|
+
headers: {
|
|
2999
|
+
"Content-Type": "application/json",
|
|
3000
|
+
Accept: "application/json",
|
|
3001
|
+
...requestConfig.headers
|
|
3002
|
+
},
|
|
3003
|
+
body: JSON.stringify(payload)
|
|
3004
|
+
});
|
|
3005
|
+
if (!response.ok) {
|
|
3006
|
+
const errorText = await response.text();
|
|
3007
|
+
throw new AsgardeoAPIError(
|
|
3008
|
+
`Registration request failed: ${errorText}`,
|
|
3009
|
+
"executeEmbeddedSignUpFlow-ResponseError-001",
|
|
3010
|
+
"javascript",
|
|
3011
|
+
response.status,
|
|
3012
|
+
response.statusText
|
|
3013
|
+
);
|
|
3014
|
+
}
|
|
3015
|
+
const flowResponse = await response.json();
|
|
3016
|
+
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && sessionDataKey) {
|
|
3017
|
+
try {
|
|
3018
|
+
const oauth2Response = await fetch(`${baseUrl}/oauth2/authorize`, {
|
|
3019
|
+
method: "POST",
|
|
3020
|
+
headers: {
|
|
3021
|
+
"Content-Type": "application/json",
|
|
3022
|
+
Accept: "application/json",
|
|
3023
|
+
...requestConfig.headers
|
|
3024
|
+
},
|
|
3025
|
+
body: JSON.stringify({
|
|
3026
|
+
assertion: flowResponse.assertion,
|
|
3027
|
+
sessionDataKey
|
|
3028
|
+
}),
|
|
3029
|
+
credentials: "include"
|
|
3030
|
+
});
|
|
3031
|
+
if (!oauth2Response.ok) {
|
|
3032
|
+
const oauth2ErrorText = await oauth2Response.text();
|
|
3033
|
+
throw new AsgardeoAPIError(
|
|
3034
|
+
`OAuth2 authorization failed: ${oauth2ErrorText}`,
|
|
3035
|
+
"executeEmbeddedSignUpFlow-OAuth2Error-002",
|
|
3036
|
+
"javascript",
|
|
3037
|
+
oauth2Response.status,
|
|
3038
|
+
oauth2Response.statusText
|
|
3039
|
+
);
|
|
3040
|
+
}
|
|
3041
|
+
const oauth2Result = await oauth2Response.json();
|
|
3042
|
+
return {
|
|
3043
|
+
flowStatus: flowResponse.flowStatus,
|
|
3044
|
+
redirectUrl: oauth2Result.redirect_uri
|
|
3045
|
+
};
|
|
3046
|
+
} catch (authError) {
|
|
3047
|
+
throw new AsgardeoAPIError(
|
|
3048
|
+
`OAuth2 authorization failed: ${authError instanceof Error ? authError.message : "Unknown error"}`,
|
|
3049
|
+
"executeEmbeddedSignUpFlow-OAuth2Error-001",
|
|
3050
|
+
"javascript",
|
|
3051
|
+
500,
|
|
3052
|
+
"Failed to complete OAuth2 authorization after successful embedded sign-up flow."
|
|
3053
|
+
);
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
return flowResponse;
|
|
3057
|
+
};
|
|
3058
|
+
var executeEmbeddedSignUpFlowV2_default = executeEmbeddedSignUpFlowV2;
|
|
3059
|
+
|
|
2964
3060
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
2965
3061
|
var ApplicationNativeAuthenticationConstants = {
|
|
2966
3062
|
SupportedAuthenticators: {
|
|
@@ -4531,6 +4627,8 @@ export {
|
|
|
4531
4627
|
EmbeddedSignInFlowStepType,
|
|
4532
4628
|
EmbeddedSignInFlowType,
|
|
4533
4629
|
EmbeddedSignInFlowTypeV2,
|
|
4630
|
+
EmbeddedSignUpFlowStatusV2,
|
|
4631
|
+
EmbeddedSignUpFlowTypeV2,
|
|
4534
4632
|
FieldType,
|
|
4535
4633
|
FlowMode,
|
|
4536
4634
|
IsomorphicCrypto,
|
|
@@ -4558,6 +4656,7 @@ export {
|
|
|
4558
4656
|
executeEmbeddedSignInFlow_default as executeEmbeddedSignInFlow,
|
|
4559
4657
|
executeEmbeddedSignInFlowV2_default as executeEmbeddedSignInFlowV2,
|
|
4560
4658
|
executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow,
|
|
4659
|
+
executeEmbeddedSignUpFlowV2_default as executeEmbeddedSignUpFlowV2,
|
|
4561
4660
|
extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
|
|
4562
4661
|
extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
|
|
4563
4662
|
flattenUserSchema_default as flattenUserSchema,
|