@insforge/sdk 1.1.4 → 1.1.5
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/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -216,6 +216,24 @@ declare class Auth {
|
|
|
216
216
|
} | null;
|
|
217
217
|
error: InsForgeError | null;
|
|
218
218
|
}>;
|
|
219
|
+
/**
|
|
220
|
+
* Sign in with an ID token from a native SDK (Google One Tap, etc.)
|
|
221
|
+
* Use this for native mobile apps or Google One Tap on web.
|
|
222
|
+
*
|
|
223
|
+
* @param credentials.provider - The identity provider (currently only 'google' is supported)
|
|
224
|
+
* @param credentials.token - The ID token from the native SDK
|
|
225
|
+
*/
|
|
226
|
+
signInWithIdToken(credentials: {
|
|
227
|
+
provider: 'google';
|
|
228
|
+
token: string;
|
|
229
|
+
}): Promise<{
|
|
230
|
+
data: {
|
|
231
|
+
accessToken: string;
|
|
232
|
+
refreshToken?: string;
|
|
233
|
+
user: UserSchema;
|
|
234
|
+
} | null;
|
|
235
|
+
error: InsForgeError | null;
|
|
236
|
+
}>;
|
|
219
237
|
/**
|
|
220
238
|
* Get current session, automatically waits for pending OAuth callback
|
|
221
239
|
* @deprecated Use `getCurrentUser` instead
|
package/dist/index.d.ts
CHANGED
|
@@ -216,6 +216,24 @@ declare class Auth {
|
|
|
216
216
|
} | null;
|
|
217
217
|
error: InsForgeError | null;
|
|
218
218
|
}>;
|
|
219
|
+
/**
|
|
220
|
+
* Sign in with an ID token from a native SDK (Google One Tap, etc.)
|
|
221
|
+
* Use this for native mobile apps or Google One Tap on web.
|
|
222
|
+
*
|
|
223
|
+
* @param credentials.provider - The identity provider (currently only 'google' is supported)
|
|
224
|
+
* @param credentials.token - The ID token from the native SDK
|
|
225
|
+
*/
|
|
226
|
+
signInWithIdToken(credentials: {
|
|
227
|
+
provider: 'google';
|
|
228
|
+
token: string;
|
|
229
|
+
}): Promise<{
|
|
230
|
+
data: {
|
|
231
|
+
accessToken: string;
|
|
232
|
+
refreshToken?: string;
|
|
233
|
+
user: UserSchema;
|
|
234
|
+
} | null;
|
|
235
|
+
error: InsForgeError | null;
|
|
236
|
+
}>;
|
|
219
237
|
/**
|
|
220
238
|
* Get current session, automatically waits for pending OAuth callback
|
|
221
239
|
* @deprecated Use `getCurrentUser` instead
|
package/dist/index.js
CHANGED
|
@@ -610,6 +610,30 @@ var Auth = class {
|
|
|
610
610
|
return wrapError(error, "An unexpected error occurred during OAuth code exchange");
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* Sign in with an ID token from a native SDK (Google One Tap, etc.)
|
|
615
|
+
* Use this for native mobile apps or Google One Tap on web.
|
|
616
|
+
*
|
|
617
|
+
* @param credentials.provider - The identity provider (currently only 'google' is supported)
|
|
618
|
+
* @param credentials.token - The ID token from the native SDK
|
|
619
|
+
*/
|
|
620
|
+
async signInWithIdToken(credentials) {
|
|
621
|
+
try {
|
|
622
|
+
const { provider, token } = credentials;
|
|
623
|
+
const response = await this.http.post("/api/auth/id-token?client_type=mobile", { provider, token }, { credentials: "include" });
|
|
624
|
+
this.saveSessionFromResponse(response);
|
|
625
|
+
return {
|
|
626
|
+
data: {
|
|
627
|
+
accessToken: response.accessToken,
|
|
628
|
+
refreshToken: response.refreshToken,
|
|
629
|
+
user: response.user
|
|
630
|
+
},
|
|
631
|
+
error: null
|
|
632
|
+
};
|
|
633
|
+
} catch (error) {
|
|
634
|
+
return wrapError(error, "An unexpected error occurred during ID token sign in");
|
|
635
|
+
}
|
|
636
|
+
}
|
|
613
637
|
// ============================================================================
|
|
614
638
|
// Session Management
|
|
615
639
|
// ============================================================================
|
|
@@ -681,19 +705,6 @@ var Auth = class {
|
|
|
681
705
|
const session = this.tokenManager.getSession();
|
|
682
706
|
if (session) {
|
|
683
707
|
this.http.setAuthToken(session.accessToken);
|
|
684
|
-
if (!session.user || Object.keys(session.user).length === 0) {
|
|
685
|
-
try {
|
|
686
|
-
const authResponse = await this.http.get(
|
|
687
|
-
"/api/auth/sessions/current",
|
|
688
|
-
{ credentials: "include" }
|
|
689
|
-
);
|
|
690
|
-
if (authResponse.user) {
|
|
691
|
-
session.user = authResponse.user;
|
|
692
|
-
this.tokenManager.setUser(authResponse.user);
|
|
693
|
-
}
|
|
694
|
-
} catch {
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
708
|
return { data: { user: session.user }, error: null };
|
|
698
709
|
}
|
|
699
710
|
if (typeof window !== "undefined") {
|