@insforge/sdk 1.3.0-ssr.3 → 1.3.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/CONTRIBUTING.md +27 -0
- package/README.md +5 -2
- package/SDK-REFERENCE.md +842 -0
- package/dist/{client-CQfw9UsO.d.mts → client-DTNmGqHB.d.mts} +20 -5
- package/dist/{client-CQfw9UsO.d.ts → client-DTNmGqHB.d.ts} +20 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +36 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -13
- package/dist/index.mjs.map +1 -1
- package/dist/ssr.d.mts +1 -1
- package/dist/ssr.d.ts +1 -1
- package/dist/ssr.js +46 -15
- package/dist/ssr.js.map +1 -1
- package/dist/ssr.mjs +46 -15
- package/dist/ssr.mjs.map +1 -1
- package/package.json +5 -3
package/dist/index.mjs
CHANGED
|
@@ -1009,21 +1009,43 @@ var Auth = class {
|
|
|
1009
1009
|
};
|
|
1010
1010
|
}
|
|
1011
1011
|
}
|
|
1012
|
-
|
|
1013
|
-
// OAuth Authentication
|
|
1014
|
-
// ============================================================================
|
|
1015
|
-
/**
|
|
1016
|
-
* Sign in with OAuth provider using PKCE flow
|
|
1017
|
-
*/
|
|
1018
|
-
async signInWithOAuth(options) {
|
|
1012
|
+
async signInWithOAuth(providerOrOptions, options) {
|
|
1019
1013
|
try {
|
|
1020
|
-
|
|
1014
|
+
let signInOptions;
|
|
1015
|
+
if (typeof providerOrOptions === "object") {
|
|
1016
|
+
signInOptions = providerOrOptions;
|
|
1017
|
+
} else if (options) {
|
|
1018
|
+
signInOptions = { provider: providerOrOptions, ...options };
|
|
1019
|
+
} else {
|
|
1020
|
+
return {
|
|
1021
|
+
data: {},
|
|
1022
|
+
error: new InsForgeError(
|
|
1023
|
+
"OAuth sign-in options are required",
|
|
1024
|
+
400,
|
|
1025
|
+
ERROR_CODES.INVALID_INPUT
|
|
1026
|
+
)
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
if (!signInOptions || !signInOptions.redirectTo) {
|
|
1030
|
+
return {
|
|
1031
|
+
data: {},
|
|
1032
|
+
error: new InsForgeError(
|
|
1033
|
+
"Redirect URI is required",
|
|
1034
|
+
400,
|
|
1035
|
+
ERROR_CODES.INVALID_INPUT
|
|
1036
|
+
)
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
const { provider } = signInOptions;
|
|
1021
1040
|
const providerKey = encodeURIComponent(provider.toLowerCase());
|
|
1022
1041
|
const codeVerifier = generateCodeVerifier();
|
|
1023
1042
|
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
1024
1043
|
storePkceVerifier(codeVerifier);
|
|
1025
|
-
const params = {
|
|
1026
|
-
|
|
1044
|
+
const params = {
|
|
1045
|
+
...signInOptions.additionalParams ?? {},
|
|
1046
|
+
redirect_uri: signInOptions.redirectTo,
|
|
1047
|
+
code_challenge: codeChallenge
|
|
1048
|
+
};
|
|
1027
1049
|
const isBuiltInProvider = oAuthProvidersSchema.options.includes(
|
|
1028
1050
|
providerKey
|
|
1029
1051
|
);
|
|
@@ -1032,7 +1054,7 @@ var Auth = class {
|
|
|
1032
1054
|
params,
|
|
1033
1055
|
skipAuthRefresh: true
|
|
1034
1056
|
});
|
|
1035
|
-
if (!this.isServerMode() && typeof window !== "undefined" && !skipBrowserRedirect) {
|
|
1057
|
+
if (!this.isServerMode() && typeof window !== "undefined" && !signInOptions.skipBrowserRedirect) {
|
|
1036
1058
|
window.location.href = response.authUrl;
|
|
1037
1059
|
return { data: {}, error: null };
|
|
1038
1060
|
}
|
|
@@ -2601,10 +2623,11 @@ function createClient(config = {}) {
|
|
|
2601
2623
|
return new InsForgeClient(config);
|
|
2602
2624
|
}
|
|
2603
2625
|
function createAdminClient(config) {
|
|
2604
|
-
|
|
2626
|
+
const { apiKey: rawApiKey, ...clientConfig } = config ?? {};
|
|
2627
|
+
const apiKey = rawApiKey?.trim();
|
|
2628
|
+
if (!apiKey) {
|
|
2605
2629
|
throw new Error("Missing apiKey. Pass apiKey to createAdminClient().");
|
|
2606
2630
|
}
|
|
2607
|
-
const { apiKey, ...clientConfig } = config;
|
|
2608
2631
|
return new InsForgeClient({
|
|
2609
2632
|
...clientConfig,
|
|
2610
2633
|
edgeFunctionToken: apiKey,
|