@asgardeo/javascript 0.1.23 → 0.2.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/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 +3 -1
- package/dist/index.js +99 -0
- package/dist/index.js.map +4 -4
- package/dist/models/config.d.ts +5 -0
- package/dist/models/embedded-flow.d.ts +96 -0
- package/dist/models/v2/embedded-signup-flow-v2.d.ts +226 -0
- package/dist/theme/types.d.ts +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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 { EmbeddedFlowExecuteRequestConfigV2, EmbeddedSignUpFlowResponseV2 } from '../../models/v2/embedded-signup-flow-v2';
|
|
19
|
+
declare const executeEmbeddedSignUpFlowV2: ({ url, baseUrl, payload, sessionDataKey, ...requestConfig }: EmbeddedFlowExecuteRequestConfigV2) => Promise<EmbeddedSignUpFlowResponseV2>;
|
|
20
|
+
export default executeEmbeddedSignUpFlowV2;
|
package/dist/cjs/index.js
CHANGED
|
@@ -41,6 +41,8 @@ __export(index_exports, {
|
|
|
41
41
|
EmbeddedSignInFlowStepType: () => EmbeddedSignInFlowStepType,
|
|
42
42
|
EmbeddedSignInFlowType: () => EmbeddedSignInFlowType,
|
|
43
43
|
EmbeddedSignInFlowTypeV2: () => EmbeddedSignInFlowTypeV2,
|
|
44
|
+
EmbeddedSignUpFlowStatusV2: () => EmbeddedSignUpFlowStatusV2,
|
|
45
|
+
EmbeddedSignUpFlowTypeV2: () => EmbeddedSignUpFlowTypeV2,
|
|
44
46
|
FieldType: () => FieldType,
|
|
45
47
|
FlowMode: () => FlowMode,
|
|
46
48
|
IsomorphicCrypto: () => IsomorphicCrypto,
|
|
@@ -68,6 +70,7 @@ __export(index_exports, {
|
|
|
68
70
|
executeEmbeddedSignInFlow: () => executeEmbeddedSignInFlow_default,
|
|
69
71
|
executeEmbeddedSignInFlowV2: () => executeEmbeddedSignInFlowV2_default,
|
|
70
72
|
executeEmbeddedSignUpFlow: () => executeEmbeddedSignUpFlow_default,
|
|
73
|
+
executeEmbeddedSignUpFlowV2: () => executeEmbeddedSignUpFlowV2_default,
|
|
71
74
|
extractPkceStorageKeyFromState: () => extractPkceStorageKeyFromState_default,
|
|
72
75
|
extractUserClaimsFromIdToken: () => extractUserClaimsFromIdToken_default,
|
|
73
76
|
flattenUserSchema: () => flattenUserSchema_default,
|
|
@@ -3063,6 +3066,102 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
3063
3066
|
};
|
|
3064
3067
|
var executeEmbeddedSignInFlowV2_default = executeEmbeddedSignInFlowV2;
|
|
3065
3068
|
|
|
3069
|
+
// src/models/v2/embedded-signup-flow-v2.ts
|
|
3070
|
+
var EmbeddedSignUpFlowStatusV2 = /* @__PURE__ */ ((EmbeddedSignUpFlowStatusV22) => {
|
|
3071
|
+
EmbeddedSignUpFlowStatusV22["Complete"] = "COMPLETE";
|
|
3072
|
+
EmbeddedSignUpFlowStatusV22["Incomplete"] = "INCOMPLETE";
|
|
3073
|
+
EmbeddedSignUpFlowStatusV22["Error"] = "ERROR";
|
|
3074
|
+
return EmbeddedSignUpFlowStatusV22;
|
|
3075
|
+
})(EmbeddedSignUpFlowStatusV2 || {});
|
|
3076
|
+
var EmbeddedSignUpFlowTypeV2 = /* @__PURE__ */ ((EmbeddedSignUpFlowTypeV22) => {
|
|
3077
|
+
EmbeddedSignUpFlowTypeV22["Redirection"] = "REDIRECTION";
|
|
3078
|
+
EmbeddedSignUpFlowTypeV22["View"] = "VIEW";
|
|
3079
|
+
return EmbeddedSignUpFlowTypeV22;
|
|
3080
|
+
})(EmbeddedSignUpFlowTypeV2 || {});
|
|
3081
|
+
|
|
3082
|
+
// src/api/v2/executeEmbeddedSignUpFlowV2.ts
|
|
3083
|
+
var executeEmbeddedSignUpFlowV2 = async ({
|
|
3084
|
+
url,
|
|
3085
|
+
baseUrl,
|
|
3086
|
+
payload,
|
|
3087
|
+
sessionDataKey,
|
|
3088
|
+
...requestConfig
|
|
3089
|
+
}) => {
|
|
3090
|
+
if (!payload) {
|
|
3091
|
+
throw new AsgardeoAPIError(
|
|
3092
|
+
"Registration payload is required",
|
|
3093
|
+
"executeEmbeddedSignUpFlow-ValidationError-002",
|
|
3094
|
+
"javascript",
|
|
3095
|
+
400,
|
|
3096
|
+
"If a registration payload is not provided, the request cannot be constructed correctly."
|
|
3097
|
+
);
|
|
3098
|
+
}
|
|
3099
|
+
let endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3100
|
+
const response = await fetch(endpoint, {
|
|
3101
|
+
...requestConfig,
|
|
3102
|
+
method: requestConfig.method || "POST",
|
|
3103
|
+
headers: {
|
|
3104
|
+
"Content-Type": "application/json",
|
|
3105
|
+
Accept: "application/json",
|
|
3106
|
+
...requestConfig.headers
|
|
3107
|
+
},
|
|
3108
|
+
body: JSON.stringify(payload)
|
|
3109
|
+
});
|
|
3110
|
+
if (!response.ok) {
|
|
3111
|
+
const errorText = await response.text();
|
|
3112
|
+
throw new AsgardeoAPIError(
|
|
3113
|
+
`Registration request failed: ${errorText}`,
|
|
3114
|
+
"executeEmbeddedSignUpFlow-ResponseError-001",
|
|
3115
|
+
"javascript",
|
|
3116
|
+
response.status,
|
|
3117
|
+
response.statusText
|
|
3118
|
+
);
|
|
3119
|
+
}
|
|
3120
|
+
const flowResponse = await response.json();
|
|
3121
|
+
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && sessionDataKey) {
|
|
3122
|
+
try {
|
|
3123
|
+
const oauth2Response = await fetch(`${baseUrl}/oauth2/authorize`, {
|
|
3124
|
+
method: "POST",
|
|
3125
|
+
headers: {
|
|
3126
|
+
"Content-Type": "application/json",
|
|
3127
|
+
Accept: "application/json",
|
|
3128
|
+
...requestConfig.headers
|
|
3129
|
+
},
|
|
3130
|
+
body: JSON.stringify({
|
|
3131
|
+
assertion: flowResponse.assertion,
|
|
3132
|
+
sessionDataKey
|
|
3133
|
+
}),
|
|
3134
|
+
credentials: "include"
|
|
3135
|
+
});
|
|
3136
|
+
if (!oauth2Response.ok) {
|
|
3137
|
+
const oauth2ErrorText = await oauth2Response.text();
|
|
3138
|
+
throw new AsgardeoAPIError(
|
|
3139
|
+
`OAuth2 authorization failed: ${oauth2ErrorText}`,
|
|
3140
|
+
"executeEmbeddedSignUpFlow-OAuth2Error-002",
|
|
3141
|
+
"javascript",
|
|
3142
|
+
oauth2Response.status,
|
|
3143
|
+
oauth2Response.statusText
|
|
3144
|
+
);
|
|
3145
|
+
}
|
|
3146
|
+
const oauth2Result = await oauth2Response.json();
|
|
3147
|
+
return {
|
|
3148
|
+
flowStatus: flowResponse.flowStatus,
|
|
3149
|
+
redirectUrl: oauth2Result.redirect_uri
|
|
3150
|
+
};
|
|
3151
|
+
} catch (authError) {
|
|
3152
|
+
throw new AsgardeoAPIError(
|
|
3153
|
+
`OAuth2 authorization failed: ${authError instanceof Error ? authError.message : "Unknown error"}`,
|
|
3154
|
+
"executeEmbeddedSignUpFlow-OAuth2Error-001",
|
|
3155
|
+
"javascript",
|
|
3156
|
+
500,
|
|
3157
|
+
"Failed to complete OAuth2 authorization after successful embedded sign-up flow."
|
|
3158
|
+
);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
return flowResponse;
|
|
3162
|
+
};
|
|
3163
|
+
var executeEmbeddedSignUpFlowV2_default = executeEmbeddedSignUpFlowV2;
|
|
3164
|
+
|
|
3066
3165
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
3067
3166
|
var ApplicationNativeAuthenticationConstants = {
|
|
3068
3167
|
SupportedAuthenticators: {
|
|
@@ -4634,6 +4733,8 @@ var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTh
|
|
|
4634
4733
|
EmbeddedSignInFlowStepType,
|
|
4635
4734
|
EmbeddedSignInFlowType,
|
|
4636
4735
|
EmbeddedSignInFlowTypeV2,
|
|
4736
|
+
EmbeddedSignUpFlowStatusV2,
|
|
4737
|
+
EmbeddedSignUpFlowTypeV2,
|
|
4637
4738
|
FieldType,
|
|
4638
4739
|
FlowMode,
|
|
4639
4740
|
IsomorphicCrypto,
|
|
@@ -4661,6 +4762,7 @@ var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTh
|
|
|
4661
4762
|
executeEmbeddedSignInFlow,
|
|
4662
4763
|
executeEmbeddedSignInFlowV2,
|
|
4663
4764
|
executeEmbeddedSignUpFlow,
|
|
4765
|
+
executeEmbeddedSignUpFlowV2,
|
|
4664
4766
|
extractPkceStorageKeyFromState,
|
|
4665
4767
|
extractUserClaimsFromIdToken,
|
|
4666
4768
|
flattenUserSchema,
|