@asgardeo/javascript 0.1.21 → 0.1.23
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/cjs/index.js +161 -70
- package/dist/cjs/index.js.map +3 -3
- package/dist/index.js +161 -70
- package/dist/index.js.map +3 -3
- package/dist/models/config.d.ts +1 -1
- package/dist/models/embedded-flow.d.ts +2 -2
- package/dist/models/v2/embedded-signin-flow-v2.d.ts +12 -1
- package/dist/theme/createTheme.d.ts +1 -17
- package/dist/utils/deriveOrganizationHandleFromBaseUrl.d.ts +3 -3
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2031,6 +2031,17 @@ var initializeEmbeddedSignInFlow = async ({
|
|
|
2031
2031
|
payload,
|
|
2032
2032
|
...requestConfig
|
|
2033
2033
|
}) => {
|
|
2034
|
+
try {
|
|
2035
|
+
new URL(url ?? baseUrl);
|
|
2036
|
+
} catch (error2) {
|
|
2037
|
+
throw new AsgardeoAPIError(
|
|
2038
|
+
`Invalid URL provided. ${error2?.toString()}`,
|
|
2039
|
+
"getSchemas-ValidationError-001",
|
|
2040
|
+
"javascript",
|
|
2041
|
+
400,
|
|
2042
|
+
"The provided `url` or `baseUrl` path does not adhere to the URL schema."
|
|
2043
|
+
);
|
|
2044
|
+
}
|
|
2034
2045
|
if (!payload) {
|
|
2035
2046
|
throw new AsgardeoAPIError(
|
|
2036
2047
|
"Authorization payload is required",
|
|
@@ -2046,27 +2057,40 @@ var initializeEmbeddedSignInFlow = async ({
|
|
|
2046
2057
|
searchParams.append(key, String(value));
|
|
2047
2058
|
}
|
|
2048
2059
|
});
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2060
|
+
try {
|
|
2061
|
+
const response = await fetch(url ?? `${baseUrl}/oauth2/authorize`, {
|
|
2062
|
+
...requestConfig,
|
|
2063
|
+
method: requestConfig.method || "POST",
|
|
2064
|
+
headers: {
|
|
2065
|
+
...requestConfig.headers,
|
|
2066
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
2067
|
+
Accept: "application/json"
|
|
2068
|
+
},
|
|
2069
|
+
body: searchParams.toString()
|
|
2070
|
+
});
|
|
2071
|
+
if (!response.ok) {
|
|
2072
|
+
const errorText = await response.text();
|
|
2073
|
+
throw new AsgardeoAPIError(
|
|
2074
|
+
`Authorization request failed: ${errorText}`,
|
|
2075
|
+
"initializeEmbeddedSignInFlow-ResponseError-001",
|
|
2076
|
+
"javascript",
|
|
2077
|
+
response.status,
|
|
2078
|
+
response.statusText
|
|
2079
|
+
);
|
|
2080
|
+
}
|
|
2081
|
+
return await response.json();
|
|
2082
|
+
} catch (error2) {
|
|
2083
|
+
if (error2 instanceof AsgardeoAPIError) {
|
|
2084
|
+
throw error2;
|
|
2085
|
+
}
|
|
2061
2086
|
throw new AsgardeoAPIError(
|
|
2062
|
-
`
|
|
2063
|
-
"initializeEmbeddedSignInFlow-
|
|
2087
|
+
`Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
2088
|
+
"initializeEmbeddedSignInFlow-NetworkError-001",
|
|
2064
2089
|
"javascript",
|
|
2065
|
-
|
|
2066
|
-
|
|
2090
|
+
0,
|
|
2091
|
+
"Network Error"
|
|
2067
2092
|
);
|
|
2068
2093
|
}
|
|
2069
|
-
return await response.json();
|
|
2070
2094
|
};
|
|
2071
2095
|
var initializeEmbeddedSignInFlow_default = initializeEmbeddedSignInFlow;
|
|
2072
2096
|
|
|
@@ -2077,6 +2101,17 @@ var executeEmbeddedSignInFlow = async ({
|
|
|
2077
2101
|
payload,
|
|
2078
2102
|
...requestConfig
|
|
2079
2103
|
}) => {
|
|
2104
|
+
try {
|
|
2105
|
+
new URL(url ?? baseUrl);
|
|
2106
|
+
} catch (error2) {
|
|
2107
|
+
throw new AsgardeoAPIError(
|
|
2108
|
+
`Invalid URL provided. ${error2?.toString()}`,
|
|
2109
|
+
"executeEmbeddedSignInFlow-ValidationError-001",
|
|
2110
|
+
"javascript",
|
|
2111
|
+
400,
|
|
2112
|
+
"The provided `url` or `baseUrl` path does not adhere to the URL schema."
|
|
2113
|
+
);
|
|
2114
|
+
}
|
|
2080
2115
|
if (!payload) {
|
|
2081
2116
|
throw new AsgardeoAPIError(
|
|
2082
2117
|
"Authorization payload is required",
|
|
@@ -2086,27 +2121,40 @@ var executeEmbeddedSignInFlow = async ({
|
|
|
2086
2121
|
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
2087
2122
|
);
|
|
2088
2123
|
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2124
|
+
try {
|
|
2125
|
+
const response = await fetch(url ?? `${baseUrl}/oauth2/authn`, {
|
|
2126
|
+
...requestConfig,
|
|
2127
|
+
method: requestConfig.method || "POST",
|
|
2128
|
+
headers: {
|
|
2129
|
+
"Content-Type": "application/json",
|
|
2130
|
+
Accept: "application/json",
|
|
2131
|
+
...requestConfig.headers
|
|
2132
|
+
},
|
|
2133
|
+
body: JSON.stringify(payload)
|
|
2134
|
+
});
|
|
2135
|
+
if (!response.ok) {
|
|
2136
|
+
const errorText = await response.text();
|
|
2137
|
+
throw new AsgardeoAPIError(
|
|
2138
|
+
`Authorization request failed: ${errorText}`,
|
|
2139
|
+
"initializeEmbeddedSignInFlow-ResponseError-001",
|
|
2140
|
+
"javascript",
|
|
2141
|
+
response.status,
|
|
2142
|
+
response.statusText
|
|
2143
|
+
);
|
|
2144
|
+
}
|
|
2145
|
+
return await response.json();
|
|
2146
|
+
} catch (error2) {
|
|
2147
|
+
if (error2 instanceof AsgardeoAPIError) {
|
|
2148
|
+
throw error2;
|
|
2149
|
+
}
|
|
2101
2150
|
throw new AsgardeoAPIError(
|
|
2102
|
-
`
|
|
2103
|
-
"
|
|
2151
|
+
`Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
2152
|
+
"executeEmbeddedSignInFlow-NetworkError-001",
|
|
2104
2153
|
"javascript",
|
|
2105
|
-
|
|
2106
|
-
|
|
2154
|
+
0,
|
|
2155
|
+
"Network Error"
|
|
2107
2156
|
);
|
|
2108
2157
|
}
|
|
2109
|
-
return await response.json();
|
|
2110
2158
|
};
|
|
2111
2159
|
var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
|
|
2112
2160
|
|
|
@@ -2155,30 +2203,54 @@ var executeEmbeddedSignUpFlow = async ({
|
|
|
2155
2203
|
"At least one of the baseUrl or url must be provided to execute the embedded sign up flow."
|
|
2156
2204
|
);
|
|
2157
2205
|
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
headers: {
|
|
2162
|
-
"Content-Type": "application/json",
|
|
2163
|
-
Accept: "application/json",
|
|
2164
|
-
...requestConfig.headers
|
|
2165
|
-
},
|
|
2166
|
-
body: JSON.stringify({
|
|
2167
|
-
...payload ?? {},
|
|
2168
|
-
flowType: "REGISTRATION" /* Registration */
|
|
2169
|
-
})
|
|
2170
|
-
});
|
|
2171
|
-
if (!response.ok) {
|
|
2172
|
-
const errorText = await response.text();
|
|
2206
|
+
try {
|
|
2207
|
+
new URL(url ?? baseUrl);
|
|
2208
|
+
} catch (error2) {
|
|
2173
2209
|
throw new AsgardeoAPIError(
|
|
2174
|
-
`
|
|
2175
|
-
"
|
|
2210
|
+
`Invalid URL provided. ${error2?.toString()}`,
|
|
2211
|
+
"executeEmbeddedSignUpFlow-ValidationError-001",
|
|
2176
2212
|
"javascript",
|
|
2177
|
-
|
|
2178
|
-
|
|
2213
|
+
400,
|
|
2214
|
+
"The provided `url` or `baseUrl` path does not adhere to the URL schema."
|
|
2215
|
+
);
|
|
2216
|
+
}
|
|
2217
|
+
try {
|
|
2218
|
+
const response = await fetch(url ?? `${baseUrl}/api/server/v1/flow/execute`, {
|
|
2219
|
+
...requestConfig,
|
|
2220
|
+
method: requestConfig.method || "POST",
|
|
2221
|
+
headers: {
|
|
2222
|
+
"Content-Type": "application/json",
|
|
2223
|
+
Accept: "application/json",
|
|
2224
|
+
...requestConfig.headers
|
|
2225
|
+
},
|
|
2226
|
+
body: JSON.stringify({
|
|
2227
|
+
...payload ?? {},
|
|
2228
|
+
flowType: "REGISTRATION" /* Registration */
|
|
2229
|
+
})
|
|
2230
|
+
});
|
|
2231
|
+
if (!response.ok) {
|
|
2232
|
+
const errorText = await response.text();
|
|
2233
|
+
throw new AsgardeoAPIError(
|
|
2234
|
+
`Embedded SignUp flow execution failed: ${errorText}`,
|
|
2235
|
+
"javascript-executeEmbeddedSignUpFlow-ResponseError-100",
|
|
2236
|
+
"javascript",
|
|
2237
|
+
response.status,
|
|
2238
|
+
response.statusText
|
|
2239
|
+
);
|
|
2240
|
+
}
|
|
2241
|
+
return await response.json();
|
|
2242
|
+
} catch (error2) {
|
|
2243
|
+
if (error2 instanceof AsgardeoAPIError) {
|
|
2244
|
+
throw error2;
|
|
2245
|
+
}
|
|
2246
|
+
throw new AsgardeoAPIError(
|
|
2247
|
+
`Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
2248
|
+
"executeEmbeddedSignUpFlow-NetworkError-001",
|
|
2249
|
+
"javascript",
|
|
2250
|
+
0,
|
|
2251
|
+
"Network Error"
|
|
2179
2252
|
);
|
|
2180
2253
|
}
|
|
2181
|
-
return await response.json();
|
|
2182
2254
|
};
|
|
2183
2255
|
var executeEmbeddedSignUpFlow_default = executeEmbeddedSignUpFlow;
|
|
2184
2256
|
|
|
@@ -2195,26 +2267,39 @@ var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
|
2195
2267
|
"Invalid Request"
|
|
2196
2268
|
);
|
|
2197
2269
|
}
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2270
|
+
try {
|
|
2271
|
+
const response = await fetch(url, {
|
|
2272
|
+
...requestConfig,
|
|
2273
|
+
method: "GET",
|
|
2274
|
+
headers: {
|
|
2275
|
+
"Content-Type": "application/json",
|
|
2276
|
+
Accept: "application/json",
|
|
2277
|
+
...requestConfig.headers
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
if (!response.ok) {
|
|
2281
|
+
const errorText = await response.text();
|
|
2282
|
+
throw new AsgardeoAPIError(
|
|
2283
|
+
`Failed to fetch user info: ${errorText}`,
|
|
2284
|
+
"getUserInfo-ResponseError-001",
|
|
2285
|
+
"javascript",
|
|
2286
|
+
response.status,
|
|
2287
|
+
response.statusText
|
|
2288
|
+
);
|
|
2289
|
+
}
|
|
2290
|
+
return await response.json();
|
|
2291
|
+
} catch (error2) {
|
|
2292
|
+
if (error2 instanceof AsgardeoAPIError) {
|
|
2293
|
+
throw error2;
|
|
2205
2294
|
}
|
|
2206
|
-
});
|
|
2207
|
-
if (!response.ok) {
|
|
2208
|
-
const errorText = await response.text();
|
|
2209
2295
|
throw new AsgardeoAPIError(
|
|
2210
|
-
`
|
|
2211
|
-
"getUserInfo-
|
|
2296
|
+
`Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
2297
|
+
"getUserInfo-NetworkError-001",
|
|
2212
2298
|
"javascript",
|
|
2213
|
-
|
|
2214
|
-
|
|
2299
|
+
0,
|
|
2300
|
+
"Network Error"
|
|
2215
2301
|
);
|
|
2216
2302
|
}
|
|
2217
|
-
return await response.json();
|
|
2218
2303
|
};
|
|
2219
2304
|
var getUserInfo_default = getUserInfo;
|
|
2220
2305
|
|
|
@@ -3830,6 +3915,12 @@ var BROWSER_STYLES = {
|
|
|
3830
3915
|
prefix: "color: #7c3aed; font-weight: bold;",
|
|
3831
3916
|
timestamp: "color: #6b7280; font-size: 0.9em;"
|
|
3832
3917
|
};
|
|
3918
|
+
var LOG_LEVEL_ORDER = {
|
|
3919
|
+
debug: 0,
|
|
3920
|
+
info: 1,
|
|
3921
|
+
warn: 2,
|
|
3922
|
+
error: 3
|
|
3923
|
+
};
|
|
3833
3924
|
var Logger = class _Logger {
|
|
3834
3925
|
constructor(config = {}) {
|
|
3835
3926
|
__publicField(this, "config");
|
|
@@ -3851,7 +3942,7 @@ var Logger = class _Logger {
|
|
|
3851
3942
|
* Check if a log level should be output
|
|
3852
3943
|
*/
|
|
3853
3944
|
shouldLog(level) {
|
|
3854
|
-
return level >= this.config.level;
|
|
3945
|
+
return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.config.level];
|
|
3855
3946
|
}
|
|
3856
3947
|
/**
|
|
3857
3948
|
* Get timestamp string
|