@meistrari/auth-core 1.39.2 → 1.40.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/index.mjs CHANGED
@@ -21,7 +21,7 @@ function isTokenExpired(token, expiresInMs) {
21
21
  return nowInSeconds > expirationTime;
22
22
  }
23
23
 
24
- const version = "1.39.2";
24
+ const version = "1.40.0";
25
25
 
26
26
  function parsedEnumValues(schema) {
27
27
  return Object.fromEntries(
@@ -354,6 +354,62 @@ function applicationsPluginClient() {
354
354
  };
355
355
  }
356
356
 
357
+ function customEndpointsPluginClient() {
358
+ return {
359
+ id: "custom-endpoints",
360
+ getActions: ($fetch) => ({
361
+ customEndpoints: {
362
+ organizations: {
363
+ apiKeys: async () => {
364
+ return await $fetch("/custom-endpoints/organizations/api-keys");
365
+ }
366
+ },
367
+ teams: {
368
+ members: async (teamId) => {
369
+ return await $fetch(`/custom-endpoints/teams/${teamId}/members`);
370
+ }
371
+ }
372
+ }
373
+ })
374
+ };
375
+ }
376
+
377
+ function handshakePluginClient() {
378
+ return {
379
+ id: "handshake",
380
+ getActions: ($fetch) => ({
381
+ handshake: {
382
+ noncePayload: async (nonce) => {
383
+ return await $fetch("/handshake/nonce-payload", {
384
+ query: { nonce }
385
+ });
386
+ }
387
+ }
388
+ })
389
+ };
390
+ }
391
+
392
+ function invitationSignupPluginClient() {
393
+ return {
394
+ id: "invitation-signup",
395
+ getActions: ($fetch) => ({
396
+ invitationSignup: {
397
+ status: async (invitationId) => {
398
+ return await $fetch("/invitation/signup-status", {
399
+ query: { invitationId }
400
+ });
401
+ },
402
+ setupPassword: async (invitationId, password) => {
403
+ return await $fetch("/invitation/setup-password", {
404
+ method: "POST",
405
+ body: { invitationId, password }
406
+ });
407
+ }
408
+ }
409
+ })
410
+ };
411
+ }
412
+
357
413
  function sessionAssurancePluginClient() {
358
414
  return {
359
415
  id: "session-assurance",
@@ -382,18 +438,6 @@ function sessionAssurancePluginClient() {
382
438
  };
383
439
  }
384
440
 
385
- function customEndpointsPluginClient() {
386
- return {
387
- id: "custom-endpoints",
388
- $InferServerPlugin: {}
389
- };
390
- }
391
- function handshakePluginClient() {
392
- return {
393
- id: "handshake",
394
- $InferServerPlugin: {}
395
- };
396
- }
397
441
  function createAPIClient(apiUrl, fetchOptions = {}) {
398
442
  const serviceName = typeof process !== "undefined" ? process.env.SERVICE_NAME : "";
399
443
  const userAgent = `auth-sdk:core:${version}${serviceName ? `@${serviceName}` : ""}`;
@@ -410,6 +454,7 @@ function createAPIClient(apiUrl, fetchOptions = {}) {
410
454
  }),
411
455
  customEndpointsPluginClient(),
412
456
  handshakePluginClient(),
457
+ invitationSignupPluginClient(),
413
458
  ssoClient(),
414
459
  twoFactorClient(),
415
460
  jwtClient(),
@@ -1685,6 +1730,33 @@ class OrganizationService {
1685
1730
  member: response.member
1686
1731
  };
1687
1732
  }
1733
+ /**
1734
+ * Gets the pre-login signup status for an invitation.
1735
+ *
1736
+ * Public endpoint keyed by the invitation id from the emailed invite link.
1737
+ * While the invitation is pending, the result includes the invited email
1738
+ * and whether the invited user still needs to set up their account.
1739
+ *
1740
+ * @param id - The invitation ID from the invite link
1741
+ * @returns The invitation status with account-setup information
1742
+ */
1743
+ async getInvitationSignupStatus(id) {
1744
+ return await this.client.invitationSignup.status(id);
1745
+ }
1746
+ /**
1747
+ * Creates a password for an invited user who has no account yet.
1748
+ *
1749
+ * Only available once per invitation, while the invitation is pending and
1750
+ * the invited user has never signed in. The user is signed in as part of
1751
+ * the call; the session cookie is set on the response.
1752
+ *
1753
+ * @param id - The invitation ID from the invite link
1754
+ * @param password - The password to create (minimum 8 characters)
1755
+ * @returns The session token and signed-in user
1756
+ */
1757
+ async setupInvitationPassword(id, password) {
1758
+ return await this.client.invitationSignup.setupPassword(id, password);
1759
+ }
1688
1760
  /**
1689
1761
  * Removes a user from the active organization.
1690
1762
  *
@@ -1851,6 +1923,7 @@ class SessionService {
1851
1923
  * @param options.provider - The social provider
1852
1924
  * @param options.callbackURL - URL to redirect to after successful authentication
1853
1925
  * @param options.errorCallbackURL - URL to redirect to on error
1926
+ * @param options.loginHint - Email to preselect at the provider
1854
1927
  *
1855
1928
  * @throws {InvalidSocialProvider} When the provider is not 'google' or 'microsoft'
1856
1929
  * @throws {InvalidCallbackURL} When callback URLs are malformed
@@ -1858,7 +1931,8 @@ class SessionService {
1858
1931
  async signInWithSocialProvider({
1859
1932
  provider,
1860
1933
  callbackURL,
1861
- errorCallbackURL
1934
+ errorCallbackURL,
1935
+ loginHint
1862
1936
  }) {
1863
1937
  if (provider !== "google" && provider !== "microsoft") {
1864
1938
  throw new InvalidSocialProvider("Invalid social provider");
@@ -1873,7 +1947,8 @@ class SessionService {
1873
1947
  await this.client.signIn.social({
1874
1948
  provider,
1875
1949
  callbackURL,
1876
- errorCallbackURL: errorCallbackURL ?? `${this.apiUrl}/error?callbackURL=${appUrl}`
1950
+ errorCallbackURL: errorCallbackURL ?? `${this.apiUrl}/error?callbackURL=${appUrl}`,
1951
+ ...loginHint && { loginHint }
1877
1952
  });
1878
1953
  }
1879
1954
  /**
@@ -1971,11 +2046,7 @@ class SessionService {
1971
2046
  * @returns The JWT token for the nonce
1972
2047
  */
1973
2048
  async getNoncePayload(nonce) {
1974
- return await this.client.handshake.noncePayload({
1975
- query: {
1976
- nonce
1977
- }
1978
- });
2049
+ return await this.client.handshake.noncePayload(nonce);
1979
2050
  }
1980
2051
  }
1981
2052
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-core",
3
- "version": "1.39.2",
3
+ "version": "1.40.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -18,9 +18,9 @@
18
18
  "docs": "typedoc"
19
19
  },
20
20
  "dependencies": {
21
- "@better-auth/api-key": "1.5.4",
22
- "@better-auth/sso": "1.5.4",
23
- "better-auth": "1.5.4",
21
+ "@better-auth/api-key": "1.6.26",
22
+ "@better-auth/sso": "1.6.26",
23
+ "better-auth": "1.6.26",
24
24
  "jose": "6.1.3",
25
25
  "zod": "4.3.6"
26
26
  },