@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
|
@@ -312,6 +312,14 @@ declare class HttpClient {
|
|
|
312
312
|
interface AuthOptions {
|
|
313
313
|
isServerMode?: boolean;
|
|
314
314
|
}
|
|
315
|
+
type OAuthSignInOptions = {
|
|
316
|
+
redirectTo: string;
|
|
317
|
+
additionalParams?: Record<string, string>;
|
|
318
|
+
skipBrowserRedirect?: boolean;
|
|
319
|
+
};
|
|
320
|
+
type OAuthSignInLegacyOptions = OAuthSignInOptions & {
|
|
321
|
+
provider: OAuthProvidersSchema | string;
|
|
322
|
+
};
|
|
315
323
|
declare class Auth {
|
|
316
324
|
private http;
|
|
317
325
|
private tokenManager;
|
|
@@ -343,11 +351,18 @@ declare class Auth {
|
|
|
343
351
|
/**
|
|
344
352
|
* Sign in with OAuth provider using PKCE flow
|
|
345
353
|
*/
|
|
346
|
-
signInWithOAuth(options: {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
354
|
+
signInWithOAuth(provider: OAuthProvidersSchema | string, options: OAuthSignInOptions): Promise<{
|
|
355
|
+
data: {
|
|
356
|
+
url?: string;
|
|
357
|
+
provider?: string;
|
|
358
|
+
codeVerifier?: string;
|
|
359
|
+
};
|
|
360
|
+
error: InsForgeError | null;
|
|
361
|
+
}>;
|
|
362
|
+
/**
|
|
363
|
+
* @deprecated Use signInWithOAuth(provider, { redirectTo, additionalParams, skipBrowserRedirect }).
|
|
364
|
+
*/
|
|
365
|
+
signInWithOAuth(options: OAuthSignInLegacyOptions): Promise<{
|
|
351
366
|
data: {
|
|
352
367
|
url?: string;
|
|
353
368
|
provider?: string;
|
|
@@ -312,6 +312,14 @@ declare class HttpClient {
|
|
|
312
312
|
interface AuthOptions {
|
|
313
313
|
isServerMode?: boolean;
|
|
314
314
|
}
|
|
315
|
+
type OAuthSignInOptions = {
|
|
316
|
+
redirectTo: string;
|
|
317
|
+
additionalParams?: Record<string, string>;
|
|
318
|
+
skipBrowserRedirect?: boolean;
|
|
319
|
+
};
|
|
320
|
+
type OAuthSignInLegacyOptions = OAuthSignInOptions & {
|
|
321
|
+
provider: OAuthProvidersSchema | string;
|
|
322
|
+
};
|
|
315
323
|
declare class Auth {
|
|
316
324
|
private http;
|
|
317
325
|
private tokenManager;
|
|
@@ -343,11 +351,18 @@ declare class Auth {
|
|
|
343
351
|
/**
|
|
344
352
|
* Sign in with OAuth provider using PKCE flow
|
|
345
353
|
*/
|
|
346
|
-
signInWithOAuth(options: {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
354
|
+
signInWithOAuth(provider: OAuthProvidersSchema | string, options: OAuthSignInOptions): Promise<{
|
|
355
|
+
data: {
|
|
356
|
+
url?: string;
|
|
357
|
+
provider?: string;
|
|
358
|
+
codeVerifier?: string;
|
|
359
|
+
};
|
|
360
|
+
error: InsForgeError | null;
|
|
361
|
+
}>;
|
|
362
|
+
/**
|
|
363
|
+
* @deprecated Use signInWithOAuth(provider, { redirectTo, additionalParams, skipBrowserRedirect }).
|
|
364
|
+
*/
|
|
365
|
+
signInWithOAuth(options: OAuthSignInLegacyOptions): Promise<{
|
|
351
366
|
data: {
|
|
352
367
|
url?: string;
|
|
353
368
|
provider?: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-
|
|
2
|
-
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-
|
|
1
|
+
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-DTNmGqHB.mjs';
|
|
2
|
+
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-DTNmGqHB.mjs';
|
|
3
3
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, RealtimeErrorPayload, SendRawEmailRequest as SendEmailOptions, SendEmailResponse, SocketMessage, SubscribeResponse, UserSchema } from '@insforge/shared-schemas';
|
|
4
4
|
import '@supabase/postgrest-js';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-
|
|
2
|
-
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-
|
|
1
|
+
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-DTNmGqHB.js';
|
|
2
|
+
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-DTNmGqHB.js';
|
|
3
3
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, RealtimeErrorPayload, SendRawEmailRequest as SendEmailOptions, SendEmailResponse, SocketMessage, SubscribeResponse, UserSchema } from '@insforge/shared-schemas';
|
|
4
4
|
import '@supabase/postgrest-js';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1061,21 +1061,43 @@ var Auth = class {
|
|
|
1061
1061
|
};
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
|
|
1065
|
-
// OAuth Authentication
|
|
1066
|
-
// ============================================================================
|
|
1067
|
-
/**
|
|
1068
|
-
* Sign in with OAuth provider using PKCE flow
|
|
1069
|
-
*/
|
|
1070
|
-
async signInWithOAuth(options) {
|
|
1064
|
+
async signInWithOAuth(providerOrOptions, options) {
|
|
1071
1065
|
try {
|
|
1072
|
-
|
|
1066
|
+
let signInOptions;
|
|
1067
|
+
if (typeof providerOrOptions === "object") {
|
|
1068
|
+
signInOptions = providerOrOptions;
|
|
1069
|
+
} else if (options) {
|
|
1070
|
+
signInOptions = { provider: providerOrOptions, ...options };
|
|
1071
|
+
} else {
|
|
1072
|
+
return {
|
|
1073
|
+
data: {},
|
|
1074
|
+
error: new InsForgeError(
|
|
1075
|
+
"OAuth sign-in options are required",
|
|
1076
|
+
400,
|
|
1077
|
+
import_shared_schemas.ERROR_CODES.INVALID_INPUT
|
|
1078
|
+
)
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
if (!signInOptions || !signInOptions.redirectTo) {
|
|
1082
|
+
return {
|
|
1083
|
+
data: {},
|
|
1084
|
+
error: new InsForgeError(
|
|
1085
|
+
"Redirect URI is required",
|
|
1086
|
+
400,
|
|
1087
|
+
import_shared_schemas.ERROR_CODES.INVALID_INPUT
|
|
1088
|
+
)
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
const { provider } = signInOptions;
|
|
1073
1092
|
const providerKey = encodeURIComponent(provider.toLowerCase());
|
|
1074
1093
|
const codeVerifier = generateCodeVerifier();
|
|
1075
1094
|
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
1076
1095
|
storePkceVerifier(codeVerifier);
|
|
1077
|
-
const params = {
|
|
1078
|
-
|
|
1096
|
+
const params = {
|
|
1097
|
+
...signInOptions.additionalParams ?? {},
|
|
1098
|
+
redirect_uri: signInOptions.redirectTo,
|
|
1099
|
+
code_challenge: codeChallenge
|
|
1100
|
+
};
|
|
1079
1101
|
const isBuiltInProvider = import_shared_schemas.oAuthProvidersSchema.options.includes(
|
|
1080
1102
|
providerKey
|
|
1081
1103
|
);
|
|
@@ -1084,7 +1106,7 @@ var Auth = class {
|
|
|
1084
1106
|
params,
|
|
1085
1107
|
skipAuthRefresh: true
|
|
1086
1108
|
});
|
|
1087
|
-
if (!this.isServerMode() && typeof window !== "undefined" && !skipBrowserRedirect) {
|
|
1109
|
+
if (!this.isServerMode() && typeof window !== "undefined" && !signInOptions.skipBrowserRedirect) {
|
|
1088
1110
|
window.location.href = response.authUrl;
|
|
1089
1111
|
return { data: {}, error: null };
|
|
1090
1112
|
}
|
|
@@ -2653,10 +2675,11 @@ function createClient(config = {}) {
|
|
|
2653
2675
|
return new InsForgeClient(config);
|
|
2654
2676
|
}
|
|
2655
2677
|
function createAdminClient(config) {
|
|
2656
|
-
|
|
2678
|
+
const { apiKey: rawApiKey, ...clientConfig } = config ?? {};
|
|
2679
|
+
const apiKey = rawApiKey?.trim();
|
|
2680
|
+
if (!apiKey) {
|
|
2657
2681
|
throw new Error("Missing apiKey. Pass apiKey to createAdminClient().");
|
|
2658
2682
|
}
|
|
2659
|
-
const { apiKey, ...clientConfig } = config;
|
|
2660
2683
|
return new InsForgeClient({
|
|
2661
2684
|
...clientConfig,
|
|
2662
2685
|
edgeFunctionToken: apiKey,
|