@rebasepro/client 0.33.1 → 0.34.0

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/auth.d.ts CHANGED
@@ -399,6 +399,11 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
399
399
  accessToken: string;
400
400
  refreshToken: string;
401
401
  }>;
402
+ signInWithPlatformToken: (token: string) => Promise<{
403
+ user: User;
404
+ accessToken: string;
405
+ refreshToken: string;
406
+ }>;
402
407
  sendEmailOtp: (email: string) => Promise<{
403
408
  success: boolean;
404
409
  message: string;
package/dist/index.es.js CHANGED
@@ -1214,6 +1214,28 @@ function createAuth(transport, options) {
1214
1214
  };
1215
1215
  }
1216
1216
  /**
1217
+ * Sign in with a token the platform hosting the backend minted for a
1218
+ * project's owner (`POST /auth/platform-signin`). The admin panel reads it
1219
+ * from its address, where the platform's console put it; see
1220
+ * `@rebasepro/app`'s `platform-signin.ts`.
1221
+ */
1222
+ async function signInWithPlatformToken(token) {
1223
+ const res = await getFetch()(authUrl("/platform-signin"), {
1224
+ method: "POST",
1225
+ headers: { "Content-Type": "application/json" },
1226
+ body: JSON.stringify({ token }),
1227
+ credentials: authFlowMode === "cookie" ? "include" : void 0
1228
+ });
1229
+ const body = await res.json().catch(() => ({}));
1230
+ if (!res.ok) throwApiError(res.status, body, res.statusText);
1231
+ const session = handleAuthResponse(body, "SIGNED_IN");
1232
+ return {
1233
+ user: session.user,
1234
+ accessToken: session.accessToken,
1235
+ refreshToken: session.refreshToken
1236
+ };
1237
+ }
1238
+ /**
1217
1239
  * Ask for a six-digit sign-in code by email.
1218
1240
  *
1219
1241
  * Answers the same thing whether or not the address has an account — do not
@@ -1669,6 +1691,7 @@ function createAuth(transport, options) {
1669
1691
  confirmEmailChange,
1670
1692
  sendMagicLink,
1671
1693
  verifyMagicLink,
1694
+ signInWithPlatformToken,
1672
1695
  sendEmailOtp,
1673
1696
  verifyEmailOtp,
1674
1697
  startDeviceLogin,