@shipdit/cli 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +154 -108
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Command, CommanderError } from "commander";
2
+ import { Command, CommanderError, Option } from "commander";
3
3
  import fs from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
@@ -51,7 +51,7 @@ function findProjectRoot(start = process.cwd()) {
51
51
  function loadProjectConfig(projectRoot, configPath) {
52
52
  return readJsonFile(configPath ?? path.join(projectRoot, ".shipd", "config.json")) ?? {};
53
53
  }
54
- function resolveRuntimeConfig(flags) {
54
+ function resolveRuntimeConfig(flags, options) {
55
55
  const cwd = process.cwd();
56
56
  const projectRoot = findProjectRoot(cwd);
57
57
  const projectConfig = loadProjectConfig(projectRoot, flags.config);
@@ -60,7 +60,7 @@ function resolveRuntimeConfig(flags) {
60
60
  const ci = flags.ci === true || flags.yes === true || process.env.CI === "1" || process.env.CI === "true" || process.env.SHIPD_CI === "1";
61
61
  const defaultConfigFile = fs.existsSync(path.join(projectRoot, "shipd.config.ts")) ? path.join(projectRoot, "shipd.config.ts") : path.join(cwd, "shipd.config.ts");
62
62
  return {
63
- apiUrl: flags.apiUrl ?? process.env.SHIPD_API_URL ?? projectConfig.apiUrl ?? globalConfig.apiUrl ?? credentials.apiUrl ?? "http://localhost:8000",
63
+ apiUrl: flags.apiUrl ?? process.env.SHIPD_API_URL ?? projectConfig.apiUrl ?? globalConfig.apiUrl ?? credentials.apiUrl ?? options?.defaultApiUrl ?? "http://localhost:8000",
64
64
  appUrl: process.env.SHIPD_APP_URL ?? projectConfig.appUrl ?? globalConfig.appUrl ?? "http://localhost:5173",
65
65
  apiKey: process.env.SHIPD_API_KEY ?? credentials.apiKey,
66
66
  org: flags.org ?? process.env.SHIPD_ORG ?? projectConfig.org ?? globalConfig.org,
@@ -481,7 +481,7 @@ function x$1(e) {
481
481
  }
482
482
 
483
483
  //#endregion
484
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_92516152aeaed9865e4d3971447ef996/node_modules/@better-auth/core/dist/utils/error-codes.mjs
484
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_1aaca9e036ea8c887647c0ceb365d61f/node_modules/@better-auth/core/dist/utils/error-codes.mjs
485
485
  function defineErrorCodes(codes) {
486
486
  return Object.fromEntries(Object.entries(codes).map(([key, value]) => [key, {
487
487
  code: key,
@@ -491,7 +491,7 @@ function defineErrorCodes(codes) {
491
491
  }
492
492
 
493
493
  //#endregion
494
- //#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.4.3/node_modules/better-call/dist/error.mjs
494
+ //#region ../../node_modules/.pnpm/better-call@1.4.0_zod@4.4.3/node_modules/better-call/dist/error.mjs
495
495
  function isErrorStackTraceLimitWritable() {
496
496
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
497
497
  if (desc === void 0) return Object.isExtensible(Error);
@@ -588,6 +588,10 @@ const statusCodes = {
588
588
  NETWORK_AUTHENTICATION_REQUIRED: 511
589
589
  };
590
590
  var InternalAPIError = class extends Error {
591
+ status;
592
+ body;
593
+ headers;
594
+ statusCode;
591
595
  constructor(status = "INTERNAL_SERVER_ERROR", body = void 0, headers = {}, statusCode = typeof status === "number" ? status : statusCodes[status]) {
592
596
  super(body?.message, body?.cause ? { cause: body.cause } : void 0);
593
597
  this.status = status;
@@ -604,7 +608,7 @@ var InternalAPIError = class extends Error {
604
608
  const APIError = makeErrorForHideStackFrame(InternalAPIError, Error);
605
609
 
606
610
  //#endregion
607
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_92516152aeaed9865e4d3971447ef996/node_modules/@better-auth/core/dist/error/index.mjs
611
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_1aaca9e036ea8c887647c0ceb365d61f/node_modules/@better-auth/core/dist/error/index.mjs
608
612
  var BetterAuthError = class extends Error {
609
613
  constructor(message, options) {
610
614
  super(message, options);
@@ -615,7 +619,7 @@ var BetterAuthError = class extends Error {
615
619
  };
616
620
 
617
621
  //#endregion
618
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/access/access.mjs
622
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/access/access.mjs
619
623
  function unknownResourceResponse(requestedResource) {
620
624
  return {
621
625
  success: false,
@@ -692,11 +696,13 @@ function createAccessControl(s) {
692
696
  }
693
697
 
694
698
  //#endregion
695
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/two-factor/error-code.mjs
699
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/two-factor/error-code.mjs
696
700
  const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
697
701
  OTP_NOT_ENABLED: "OTP not enabled",
702
+ OTP_NOT_CONFIGURED: "OTP is not available",
698
703
  OTP_HAS_EXPIRED: "OTP has expired",
699
704
  TOTP_NOT_ENABLED: "TOTP not enabled",
705
+ TOTP_NOT_CONFIGURED: "TOTP is not available",
700
706
  TWO_FACTOR_NOT_ENABLED: "Two factor isn't enabled",
701
707
  BACKUP_CODES_NOT_ENABLED: "Backup codes aren't enabled",
702
708
  INVALID_BACKUP_CODE: "Invalid backup code",
@@ -707,15 +713,15 @@ const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
707
713
  });
708
714
 
709
715
  //#endregion
710
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/package.mjs
711
- var version = "1.6.26";
716
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/package.mjs
717
+ var version = "1.7.1";
712
718
 
713
719
  //#endregion
714
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/version.mjs
720
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/version.mjs
715
721
  const PACKAGE_VERSION$2 = version;
716
722
 
717
723
  //#endregion
718
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_92516152aeaed9865e4d3971447ef996/node_modules/@better-auth/core/dist/utils/url.mjs
724
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_1aaca9e036ea8c887647c0ceb365d61f/node_modules/@better-auth/core/dist/utils/url.mjs
719
725
  /**
720
726
  * Schemes that execute or embed code when navigated to or accepted as a
721
727
  * redirect target. These are never safe as an OAuth `redirect_uri` or as a
@@ -747,7 +753,7 @@ function isSafeUrlScheme(value) {
747
753
  }
748
754
 
749
755
  //#endregion
750
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/two-factor/client.mjs
756
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/two-factor/client.mjs
751
757
  const twoFactorClient = (options) => {
752
758
  return {
753
759
  id: "two-factor",
@@ -785,7 +791,7 @@ const twoFactorClient = (options) => {
785
791
  };
786
792
 
787
793
  //#endregion
788
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/admin/access/statement.mjs
794
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/admin/access/statement.mjs
789
795
  const defaultStatements$1 = {
790
796
  user: [
791
797
  "create",
@@ -836,7 +842,7 @@ const defaultRoles$1 = {
836
842
  };
837
843
 
838
844
  //#endregion
839
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/admin/error-codes.mjs
845
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/admin/error-codes.mjs
840
846
  const ADMIN_ERROR_CODES = defineErrorCodes({
841
847
  FAILED_TO_CREATE_USER: "Failed to create user",
842
848
  USER_ALREADY_EXISTS: "User already exists.",
@@ -864,7 +870,7 @@ const ADMIN_ERROR_CODES = defineErrorCodes({
864
870
  });
865
871
 
866
872
  //#endregion
867
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_92516152aeaed9865e4d3971447ef996/node_modules/@better-auth/core/dist/env/env-impl.mjs
873
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_1aaca9e036ea8c887647c0ceb365d61f/node_modules/@better-auth/core/dist/env/env-impl.mjs
868
874
  const _envShim = Object.create(null);
869
875
  const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
870
876
  const env = new Proxy(_envShim, {
@@ -928,7 +934,7 @@ const ENV = Object.freeze({
928
934
  });
929
935
 
930
936
  //#endregion
931
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/utils/url.mjs
937
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/utils/url.mjs
932
938
  const SLASH_CHAR_CODE = "/".charCodeAt(0);
933
939
  function trimTrailingSlashes(value) {
934
940
  let end = value.length;
@@ -1007,7 +1013,7 @@ function getOrigin(url) {
1007
1013
  }
1008
1014
 
1009
1015
  //#endregion
1010
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/admin/has-permission.mjs
1016
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/admin/has-permission.mjs
1011
1017
  const hasPermission = (input) => {
1012
1018
  if (input.userId && input.options?.adminUserIds?.includes(input.userId)) return true;
1013
1019
  if (!input.permissions) return false;
@@ -1536,7 +1542,7 @@ var betterFetch = async (url, options) => {
1536
1542
  };
1537
1543
 
1538
1544
  //#endregion
1539
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/parser.mjs
1545
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/parser.mjs
1540
1546
  const PROTO_POLLUTION_PATTERNS = {
1541
1547
  proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
1542
1548
  constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
@@ -1606,7 +1612,7 @@ function parseJSON(value, options = { strict: true }) {
1606
1612
  }
1607
1613
 
1608
1614
  //#endregion
1609
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/organization/access/statement.mjs
1615
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/organization/access/statement.mjs
1610
1616
  const defaultStatements = {
1611
1617
  organization: ["update", "delete"],
1612
1618
  member: [
@@ -1682,7 +1688,7 @@ const defaultRoles = {
1682
1688
  };
1683
1689
 
1684
1690
  //#endregion
1685
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/organization/permission.mjs
1691
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/organization/permission.mjs
1686
1692
  const hasPermissionFn = (input, acRoles) => {
1687
1693
  if (!input.permissions) return false;
1688
1694
  const roles = input.role.split(",");
@@ -1695,7 +1701,7 @@ const hasPermissionFn = (input, acRoles) => {
1695
1701
  };
1696
1702
 
1697
1703
  //#endregion
1698
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/organization/error-codes.mjs
1704
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/organization/error-codes.mjs
1699
1705
  const ORGANIZATION_ERROR_CODES = defineErrorCodes({
1700
1706
  YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION: "You are not allowed to create a new organization",
1701
1707
  YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS: "You have reached the maximum number of organizations",
@@ -1916,7 +1922,7 @@ const n$1 = {
1916
1922
  };
1917
1923
 
1918
1924
  //#endregion
1919
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/broadcast-channel.mjs
1925
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/broadcast-channel.mjs
1920
1926
  const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
1921
1927
  const now$1 = () => Math.floor(Date.now() / 1e3);
1922
1928
  var WindowBroadcastChannel = class {
@@ -1960,23 +1966,30 @@ function getGlobalBroadcastChannel(name = "better-auth.message") {
1960
1966
  }
1961
1967
 
1962
1968
  //#endregion
1963
- //#region ../../node_modules/.pnpm/nanostores@1.4.2/node_modules/nanostores/clean-stores/index.js
1969
+ //#region ../../node_modules/.pnpm/nanostores@1.5.2/node_modules/nanostores/clean-stores/index.js
1964
1970
  const clean = Symbol("clean");
1965
1971
 
1966
1972
  //#endregion
1967
- //#region ../../node_modules/.pnpm/nanostores@1.4.2/node_modules/nanostores/atom/index.js
1973
+ //#region ../../node_modules/.pnpm/nanostores@1.5.2/node_modules/nanostores/atom/index.js
1968
1974
  let listenerQueue = [];
1969
1975
  let lqIndex = 0;
1970
1976
  let batchSeen = null;
1971
1977
  const QUEUE_ITEMS_PER_LISTENER = 4;
1972
1978
  const nanostoresGlobal = globalThis.nanostoresGlobal ||= { epoch: 0 };
1973
1979
  let drainQueue = () => {
1974
- for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) listenerQueue[lqIndex](listenerQueue[lqIndex + 1].value, listenerQueue[lqIndex + 2], listenerQueue[lqIndex + 3]);
1980
+ let thrown;
1981
+ for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) try {
1982
+ listenerQueue[lqIndex](listenerQueue[lqIndex + 1].value, listenerQueue[lqIndex + 2], listenerQueue[lqIndex + 3]);
1983
+ } catch (e) {
1984
+ thrown = e;
1985
+ }
1975
1986
  listenerQueue.length = 0;
1987
+ if (thrown) throw thrown;
1976
1988
  };
1977
1989
  const atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
1978
1990
  let listeners = [];
1979
1991
  let $atom = {
1992
+ eq: Object.is,
1980
1993
  get() {
1981
1994
  if (!$atom.lc) $atom.listen(() => {})();
1982
1995
  return $atom.value;
@@ -2008,7 +2021,7 @@ const atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
2008
2021
  off() {},
2009
2022
  set(newValue) {
2010
2023
  let oldValue = $atom.value;
2011
- if (oldValue !== newValue) {
2024
+ if (!$atom.eq(oldValue, newValue)) {
2012
2025
  $atom.value = newValue;
2013
2026
  $atom.notify(oldValue);
2014
2027
  }
@@ -2029,7 +2042,7 @@ const atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
2029
2042
  };
2030
2043
 
2031
2044
  //#endregion
2032
- //#region ../../node_modules/.pnpm/nanostores@1.4.2/node_modules/nanostores/lifecycle/index.js
2045
+ //#region ../../node_modules/.pnpm/nanostores@1.5.2/node_modules/nanostores/lifecycle/index.js
2033
2046
  const SET = 2;
2034
2047
  const MOUNT = 5;
2035
2048
  const UNMOUNT = 6;
@@ -2133,7 +2146,7 @@ let onMount = ($store, initialize) => {
2133
2146
  };
2134
2147
 
2135
2148
  //#endregion
2136
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/equality.mjs
2149
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/equality.mjs
2137
2150
  function isPlainObject(value) {
2138
2151
  if (typeof value !== "object" || value === null) return false;
2139
2152
  const prototype = Object.getPrototypeOf(value);
@@ -2174,7 +2187,7 @@ function withEquality(store, isEqual) {
2174
2187
  }
2175
2188
 
2176
2189
  //#endregion
2177
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/focus-manager.mjs
2190
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/focus-manager.mjs
2178
2191
  const kFocusManager = Symbol.for("better-auth:focus-manager");
2179
2192
  var WindowFocusManager = class {
2180
2193
  listeners = /* @__PURE__ */ new Set();
@@ -2204,7 +2217,7 @@ function getGlobalFocusManager() {
2204
2217
  }
2205
2218
 
2206
2219
  //#endregion
2207
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/online-manager.mjs
2220
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/online-manager.mjs
2208
2221
  const kOnlineManager = Symbol.for("better-auth:online-manager");
2209
2222
  var WindowOnlineManager = class {
2210
2223
  listeners = /* @__PURE__ */ new Set();
@@ -2237,7 +2250,7 @@ function getGlobalOnlineManager() {
2237
2250
  }
2238
2251
 
2239
2252
  //#endregion
2240
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/query.mjs
2253
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/query.mjs
2241
2254
  const isServer$1 = () => typeof window === "undefined";
2242
2255
  function isAuthQueryStateEqual(a, b) {
2243
2256
  return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
@@ -2250,7 +2263,7 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
2250
2263
  isRefetching: false,
2251
2264
  refetch: (queryParams) => fn(queryParams)
2252
2265
  });
2253
- withEquality(value, isAuthQueryStateEqual);
2266
+ onMount(value, () => withEquality(value, isAuthQueryStateEqual));
2254
2267
  const fn = async (queryParams) => {
2255
2268
  return new Promise((resolve) => {
2256
2269
  const opts = typeof options === "function" ? options({
@@ -2359,7 +2372,7 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
2359
2372
  };
2360
2373
 
2361
2374
  //#endregion
2362
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/session-refresh.mjs
2375
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/session-refresh.mjs
2363
2376
  const now = () => Math.floor(Date.now() / 1e3);
2364
2377
  /**
2365
2378
  * Rate limit: don't refetch on focus if a session request was made within this many seconds
@@ -2487,7 +2500,7 @@ function createSessionRefreshManager(opts) {
2487
2500
  }
2488
2501
 
2489
2502
  //#endregion
2490
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/fetch-plugins.mjs
2503
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/fetch-plugins.mjs
2491
2504
  const redirectPlugin = {
2492
2505
  id: "redirect",
2493
2506
  name: "Redirect",
@@ -2503,8 +2516,20 @@ const redirectPlugin = {
2503
2516
  };
2504
2517
 
2505
2518
  //#endregion
2506
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/session-atom.mjs
2519
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/session-atom.mjs
2507
2520
  const isServer = () => typeof window === "undefined";
2521
+ const SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
2522
+ function hydrateSessionAtom(sessionAtom, session) {
2523
+ if (typeof window === "undefined") return;
2524
+ const currentSession = sessionAtom.get();
2525
+ if (currentSession.data !== null || session === null) return;
2526
+ sessionAtom.set({
2527
+ ...currentSession,
2528
+ data: session,
2529
+ error: null,
2530
+ isPending: false
2531
+ });
2532
+ }
2508
2533
  /**
2509
2534
  * Normalize $fetch response: `throw: true` returns data directly,
2510
2535
  * otherwise `{ data, error }`.
@@ -2526,7 +2551,13 @@ function isSessionAtomEqual(a, b) {
2526
2551
  }
2527
2552
  function getSessionAtom($fetch, options) {
2528
2553
  const $signal = /* @__PURE__ */ atom(false);
2529
- let abortController;
2554
+ let flight;
2555
+ let freshUntil = 0;
2556
+ let sessionRevision = 0;
2557
+ $signal.listen(() => {
2558
+ sessionRevision++;
2559
+ freshUntil = 0;
2560
+ });
2530
2561
  const refetch = (queryParams) => fetchSession(queryParams);
2531
2562
  const session = /* @__PURE__ */ atom({
2532
2563
  data: null,
@@ -2536,23 +2567,8 @@ function getSessionAtom($fetch, options) {
2536
2567
  refetch
2537
2568
  });
2538
2569
  withEquality(session, isSessionAtomEqual);
2539
- const settleAbortedFetch = (controller) => {
2540
- if (abortController !== controller) return;
2541
- const current = session.get();
2542
- abortController = void 0;
2543
- if (!current.isPending && !current.isRefetching) return;
2544
- session.set({
2545
- ...current,
2546
- isPending: false,
2547
- isRefetching: false,
2548
- refetch
2549
- });
2550
- };
2551
- const fetchSession = async (queryParams) => {
2552
- abortController?.abort();
2553
- const controller = new AbortController();
2554
- abortController = controller;
2555
- const current = session.get();
2570
+ const executeSessionFetch = async (signal, queryParams) => {
2571
+ const current = session.value;
2556
2572
  session.set({
2557
2573
  ...current,
2558
2574
  isPending: current.data === null,
@@ -2560,35 +2576,29 @@ function getSessionAtom($fetch, options) {
2560
2576
  error: null,
2561
2577
  refetch
2562
2578
  });
2579
+ if (signal.aborted) return "aborted";
2563
2580
  try {
2564
2581
  const res = await $fetch("/get-session", {
2565
2582
  method: "GET",
2566
2583
  query: queryParams?.query,
2567
- signal: controller.signal
2584
+ signal
2568
2585
  });
2569
- if (controller.signal.aborted) {
2570
- settleAbortedFetch(controller);
2571
- return;
2572
- }
2586
+ if (signal.aborted) return "aborted";
2573
2587
  let { data, error } = normalizeSessionResponse(res);
2588
+ let outcome = "fresh";
2574
2589
  if (data?.needsRefresh) try {
2575
2590
  const refreshRes = await $fetch("/get-session", {
2576
2591
  method: "POST",
2577
- signal: controller.signal
2592
+ signal
2578
2593
  });
2579
- if (controller.signal.aborted) {
2580
- settleAbortedFetch(controller);
2581
- return;
2582
- }
2594
+ if (signal.aborted) return "aborted";
2583
2595
  ({data, error} = normalizeSessionResponse(refreshRes));
2584
2596
  } catch {
2585
- if (controller.signal.aborted) {
2586
- settleAbortedFetch(controller);
2587
- return;
2588
- }
2597
+ if (signal.aborted) return "aborted";
2598
+ outcome = "stale";
2589
2599
  }
2590
2600
  if (error) {
2591
- const latest = session.get();
2601
+ const latest = session.value;
2592
2602
  const isUnauthorized = error?.status === 401;
2593
2603
  session.set({
2594
2604
  data: isUnauthorized ? null : latest.data,
@@ -2597,10 +2607,10 @@ function getSessionAtom($fetch, options) {
2597
2607
  isRefetching: false,
2598
2608
  refetch
2599
2609
  });
2600
- return;
2610
+ return "failed";
2601
2611
  }
2602
2612
  const sessionData = normalizeSessionData(data);
2603
- const current = session.get();
2613
+ const current = session.value;
2604
2614
  const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
2605
2615
  session.set({
2606
2616
  data: stableData,
@@ -2609,12 +2619,10 @@ function getSessionAtom($fetch, options) {
2609
2619
  isRefetching: false,
2610
2620
  refetch
2611
2621
  });
2622
+ return outcome;
2612
2623
  } catch (fetchError) {
2613
- if (controller.signal.aborted) {
2614
- settleAbortedFetch(controller);
2615
- return;
2616
- }
2617
- const latest = session.get();
2624
+ if (signal.aborted) return "aborted";
2625
+ const latest = session.value;
2618
2626
  session.set({
2619
2627
  data: latest.data,
2620
2628
  error: fetchError,
@@ -2622,17 +2630,49 @@ function getSessionAtom($fetch, options) {
2622
2630
  isRefetching: false,
2623
2631
  refetch
2624
2632
  });
2633
+ return "failed";
2625
2634
  }
2626
2635
  };
2636
+ const getFreshUntil = () => {
2637
+ const expiresAt = session.value.data?.session?.expiresAt;
2638
+ const sessionExpiresAt = expiresAt instanceof Date ? expiresAt.getTime() : Number.POSITIVE_INFINITY;
2639
+ return Math.min(Date.now() + SESSION_MOUNT_DEDUPE_INTERVAL, sessionExpiresAt);
2640
+ };
2641
+ const fetchSession = (queryParams) => {
2642
+ freshUntil = 0;
2643
+ flight?.cancel();
2644
+ const controller = new AbortController();
2645
+ const request = {
2646
+ cancel: () => controller.abort(),
2647
+ promise: Promise.resolve().then(() => {
2648
+ if (controller.signal.aborted) return "aborted";
2649
+ return executeSessionFetch(controller.signal, queryParams);
2650
+ }),
2651
+ revision: sessionRevision
2652
+ };
2653
+ flight = request;
2654
+ const settleFlight = (outcome) => {
2655
+ if (flight !== request) return;
2656
+ flight = void 0;
2657
+ if (outcome === "fresh" && request.revision === sessionRevision) freshUntil = getFreshUntil();
2658
+ };
2659
+ request.promise.then(settleFlight, () => settleFlight("failed"));
2660
+ return request.promise.then(() => void 0);
2661
+ };
2662
+ const fetchSessionOnMount = () => {
2663
+ if (flight?.revision === sessionRevision) return flight.promise.then(() => void 0);
2664
+ if (Date.now() < freshUntil) return Promise.resolve();
2665
+ return fetchSession();
2666
+ };
2627
2667
  let broadcastSessionUpdate = () => {};
2628
2668
  onMount(session, () => {
2629
2669
  let timeoutId;
2630
2670
  if (!isServer()) timeoutId = setTimeout(() => {
2631
- fetchSession();
2671
+ fetchSessionOnMount();
2632
2672
  }, 0);
2633
2673
  const refreshManager = createSessionRefreshManager({
2634
2674
  fetchSession,
2635
- shouldPollSession: () => session.get().data != null,
2675
+ shouldPollSession: () => session.value.data != null,
2636
2676
  sessionSignal: $signal,
2637
2677
  options
2638
2678
  });
@@ -2640,9 +2680,6 @@ function getSessionAtom($fetch, options) {
2640
2680
  broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
2641
2681
  return () => {
2642
2682
  if (timeoutId) clearTimeout(timeoutId);
2643
- const controller = abortController;
2644
- controller?.abort();
2645
- if (controller) settleAbortedFetch(controller);
2646
2683
  refreshManager.cleanup();
2647
2684
  };
2648
2685
  });
@@ -2654,7 +2691,7 @@ function getSessionAtom($fetch, options) {
2654
2691
  }
2655
2692
 
2656
2693
  //#endregion
2657
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/config.mjs
2694
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/config.mjs
2658
2695
  const resolvePublicAuthUrl = (basePath) => {
2659
2696
  if (typeof process === "undefined") return void 0;
2660
2697
  const path = basePath ?? "/api/auth";
@@ -2702,6 +2739,12 @@ const getClientConfig = (options, loadEnv) => {
2702
2739
  ]
2703
2740
  });
2704
2741
  const { $sessionSignal, session, broadcastSessionUpdate } = getSessionAtom($fetch, options);
2742
+ let hasHydrated = false;
2743
+ const hydrateSession = (sessionData) => {
2744
+ if (hasHydrated || sessionData === null) return;
2745
+ hasHydrated = true;
2746
+ hydrateSessionAtom(session, sessionData);
2747
+ };
2705
2748
  const plugins = options?.plugins || [];
2706
2749
  let pluginsActions = {};
2707
2750
  const pluginsAtoms = {
@@ -2747,19 +2790,20 @@ const getClientConfig = (options, loadEnv) => {
2747
2790
  pluginsAtoms,
2748
2791
  pluginPathMethods,
2749
2792
  atomListeners,
2793
+ hydrateSession,
2750
2794
  $fetch,
2751
2795
  $store
2752
2796
  };
2753
2797
  };
2754
2798
 
2755
2799
  //#endregion
2756
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/utils/is-atom.mjs
2800
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/utils/is-atom.mjs
2757
2801
  function isAtom(value) {
2758
2802
  return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
2759
2803
  }
2760
2804
 
2761
2805
  //#endregion
2762
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_92516152aeaed9865e4d3971447ef996/node_modules/@better-auth/core/dist/utils/string.mjs
2806
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_1aaca9e036ea8c887647c0ceb365d61f/node_modules/@better-auth/core/dist/utils/string.mjs
2763
2807
  function capitalizeFirstLetter(str) {
2764
2808
  return str.charAt(0).toUpperCase() + str.slice(1);
2765
2809
  }
@@ -2773,7 +2817,7 @@ function toKebabCase(input) {
2773
2817
  }
2774
2818
 
2775
2819
  //#endregion
2776
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/proxy.mjs
2820
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/proxy.mjs
2777
2821
  function getMethod(path, knownPathMethods, args) {
2778
2822
  const method = knownPathMethods[path];
2779
2823
  const { fetchOptions, query: _query, ...body } = args || {};
@@ -2849,21 +2893,22 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
2849
2893
  }
2850
2894
 
2851
2895
  //#endregion
2852
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/client/vanilla.mjs
2896
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/client/vanilla.mjs
2853
2897
  function createAuthClient(options) {
2854
- const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
2898
+ const { pluginPathMethods, pluginsActions, pluginsAtoms, hydrateSession, $fetch, atomListeners, $store } = getClientConfig(options);
2855
2899
  const resolvedHooks = {};
2856
2900
  for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[`use${capitalizeFirstLetter(key)}`] = value;
2857
2901
  return createDynamicPathProxy({
2858
2902
  ...pluginsActions,
2859
2903
  ...resolvedHooks,
2904
+ hydrateSession,
2860
2905
  $fetch,
2861
2906
  $store
2862
2907
  }, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
2863
2908
  }
2864
2909
 
2865
2910
  //#endregion
2866
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/additional-fields/client.mjs
2911
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/additional-fields/client.mjs
2867
2912
  const inferAdditionalFields = (schema) => {
2868
2913
  return {
2869
2914
  id: "additional-fields-client",
@@ -2873,7 +2918,7 @@ const inferAdditionalFields = (schema) => {
2873
2918
  };
2874
2919
 
2875
2920
  //#endregion
2876
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/admin/client.mjs
2921
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/admin/client.mjs
2877
2922
  const adminClient = (options) => {
2878
2923
  const roles = {
2879
2924
  admin: adminAc$1,
@@ -2908,7 +2953,7 @@ const adminClient = (options) => {
2908
2953
  };
2909
2954
 
2910
2955
  //#endregion
2911
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
2956
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
2912
2957
  const deviceAuthorizationClient = () => {
2913
2958
  return {
2914
2959
  id: "device-authorization",
@@ -2925,7 +2970,7 @@ const deviceAuthorizationClient = () => {
2925
2970
  };
2926
2971
 
2927
2972
  //#endregion
2928
- //#region ../../node_modules/.pnpm/better-auth@1.6.26_@opentelemetry+api@1.9.1_drizzle-orm@1.0.0-rc.4_@opentelemetry+api@1_20fb48331ea10f84b14a69b42b690fe2/node_modules/better-auth/dist/plugins/organization/client.mjs
2973
+ //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._31fe88df78ef9a08dd335587a42dd18d/node_modules/better-auth/dist/plugins/organization/client.mjs
2929
2974
  /**
2930
2975
  * Using the same `hasPermissionFn` function, but without the need for a `ctx` parameter or the `organizationId` parameter.
2931
2976
  */
@@ -2968,18 +3013,15 @@ const organizationClient = (options) => {
2968
3013
  }),
2969
3014
  getAtoms: ($fetch) => {
2970
3015
  const listOrganizations = useAuthQuery($listOrg, "/organization/list", $fetch, { method: "GET" });
2971
- const activeOrganization = useAuthQuery([$activeOrgSignal], "/organization/get-full-organization", $fetch, () => ({ method: "GET" }));
2972
- const activeMember = useAuthQuery([$activeOrgSignal, $activeMemberSignal], "/organization/get-active-member", $fetch, { method: "GET" });
2973
- const activeMemberRole = useAuthQuery([$activeOrgSignal, $activeMemberRoleSignal], "/organization/get-active-member-role", $fetch, { method: "GET" });
2974
3016
  return {
2975
3017
  $listOrg,
2976
3018
  $activeOrgSignal,
2977
3019
  $activeMemberSignal,
2978
3020
  $activeMemberRoleSignal,
2979
- activeOrganization,
3021
+ activeOrganization: useAuthQuery([$activeOrgSignal], "/organization/get-full-organization", $fetch, () => ({ method: "GET" })),
2980
3022
  listOrganizations,
2981
- activeMember,
2982
- activeMemberRole
3023
+ activeMember: useAuthQuery([$activeOrgSignal, $activeMemberSignal], "/organization/get-active-member", $fetch, { method: "GET" }),
3024
+ activeMemberRole: useAuthQuery([$activeOrgSignal, $activeMemberRoleSignal], "/organization/get-active-member-role", $fetch, { method: "GET" })
2983
3025
  };
2984
3026
  },
2985
3027
  pathMethods: {
@@ -3023,7 +3065,7 @@ const organizationClient = (options) => {
3023
3065
  };
3024
3066
 
3025
3067
  //#endregion
3026
- //#region ../../node_modules/.pnpm/@better-auth+api-key@1.6.26_@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-f_26c063546df2762d5214ad7424a4d563/node_modules/@better-auth/api-key/dist/version-vgVyvied.mjs
3068
+ //#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fet_730a8e1115b706db03150c1fedf71d83/node_modules/@better-auth/api-key/dist/version-D365O1mH.mjs
3027
3069
  const API_KEY_ERROR_CODES = defineErrorCodes({
3028
3070
  INVALID_METADATA_TYPE: "metadata must be an object or undefined",
3029
3071
  REFILL_AMOUNT_AND_INTERVAL_REQUIRED: "refillAmount is required when refillInterval is provided",
@@ -3057,10 +3099,10 @@ const API_KEY_ERROR_CODES = defineErrorCodes({
3057
3099
  NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: "No default api-key configuration found.",
3058
3100
  ORGANIZATION_PLUGIN_REQUIRED: "Organization plugin is required for organization-owned API keys. Please install and configure the organization plugin."
3059
3101
  });
3060
- const PACKAGE_VERSION$1 = "1.6.26";
3102
+ const PACKAGE_VERSION$1 = "1.7.1";
3061
3103
 
3062
3104
  //#endregion
3063
- //#region ../../node_modules/.pnpm/@better-auth+api-key@1.6.26_@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-f_26c063546df2762d5214ad7424a4d563/node_modules/@better-auth/api-key/dist/client.mjs
3105
+ //#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fet_730a8e1115b706db03150c1fedf71d83/node_modules/@better-auth/api-key/dist/client.mjs
3064
3106
  const apiKeyClient = () => {
3065
3107
  return {
3066
3108
  id: "api-key",
@@ -3076,7 +3118,7 @@ const apiKeyClient = () => {
3076
3118
  };
3077
3119
 
3078
3120
  //#endregion
3079
- //#region ../../node_modules/.pnpm/@better-auth+passkey@1.6.26_@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-f_b9d6999fc8dc623532f797abb6d4608d/node_modules/@better-auth/passkey/dist/version-BE4wdr64.mjs
3121
+ //#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.1_3091161c3af04ded06e8ccc4fdc3184d/node_modules/@better-auth/passkey/dist/version-CNE1I0BY.mjs
3080
3122
  const PASSKEY_ERROR_CODES = defineErrorCodes({
3081
3123
  CHALLENGE_NOT_FOUND: "Challenge not found",
3082
3124
  YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: "You are not allowed to register this passkey",
@@ -3084,6 +3126,7 @@ const PASSKEY_ERROR_CODES = defineErrorCodes({
3084
3126
  PASSKEY_NOT_FOUND: "Passkey not found",
3085
3127
  AUTHENTICATION_FAILED: "Authentication failed",
3086
3128
  UNABLE_TO_CREATE_SESSION: "Unable to create session",
3129
+ USER_NOT_FOUND: "User not found",
3087
3130
  FAILED_TO_UPDATE_PASSKEY: "Failed to update passkey",
3088
3131
  PREVIOUSLY_REGISTERED: "Previously registered",
3089
3132
  REGISTRATION_CANCELLED: "Registration cancelled",
@@ -3093,7 +3136,7 @@ const PASSKEY_ERROR_CODES = defineErrorCodes({
3093
3136
  RESOLVE_USER_REQUIRED: "Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false",
3094
3137
  RESOLVED_USER_INVALID: "Resolved user is invalid"
3095
3138
  });
3096
- const PACKAGE_VERSION = "1.6.26";
3139
+ const PACKAGE_VERSION = "1.7.1";
3097
3140
 
3098
3141
  //#endregion
3099
3142
  //#region ../../node_modules/.pnpm/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js
@@ -3565,7 +3608,7 @@ async function startAuthentication(options) {
3565
3608
  }
3566
3609
 
3567
3610
  //#endregion
3568
- //#region ../../node_modules/.pnpm/@better-auth+passkey@1.6.26_@better-auth+core@1.6.26_@better-auth+utils@0.4.2_@better-f_b9d6999fc8dc623532f797abb6d4608d/node_modules/@better-auth/passkey/dist/client.mjs
3611
+ //#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.1_3091161c3af04ded06e8ccc4fdc3184d/node_modules/@better-auth/passkey/dist/client.mjs
3569
3612
  const getPasskeyActions = ($fetch, { $listPasskeys, $store }) => {
3570
3613
  const signInPasskey = async (opts, options) => {
3571
3614
  const response = await $fetch("/passkey/generate-authenticate-options", {
@@ -3658,13 +3701,15 @@ const getPasskeyActions = ($fetch, { $listPasskeys, $store }) => {
3658
3701
  ...fetchOpts,
3659
3702
  body: {
3660
3703
  response: responseBody,
3661
- name: opts?.name
3704
+ name: opts?.name,
3705
+ ...opts?.createSession && { createSession: true }
3662
3706
  },
3663
3707
  method: "POST",
3664
3708
  throw: false
3665
3709
  });
3666
3710
  if (!verified.data) return verified;
3667
3711
  $listPasskeys.set(Math.random());
3712
+ if (verified.data.session) $store.notify("$sessionSignal");
3668
3713
  if (opts?.returnWebAuthnResponse) return {
3669
3714
  ...verified,
3670
3715
  webauthn: {
@@ -3935,9 +3980,9 @@ async function resolveIds(client, runtime) {
3935
3980
 
3936
3981
  //#endregion
3937
3982
  //#region src/lib/output.ts
3938
- function getRuntime(command) {
3983
+ function getRuntime(command, options) {
3939
3984
  const opts = command.optsWithGlobals();
3940
- return resolveRuntimeConfig(opts);
3985
+ return resolveRuntimeConfig(opts, options);
3941
3986
  }
3942
3987
  function printResult(runtime, data, human) {
3943
3988
  if (runtime.json) {
@@ -3973,9 +4018,10 @@ function e(e) {
3973
4018
  //#region src/commands/auth.ts
3974
4019
  const CLIENT_ID = "shipd-cli";
3975
4020
  const MANAGEMENT_KEY_PREFIX = "shipd_mgmt_";
4021
+ const DEFAULT_API_URL = "https://api.useshipd.com";
3976
4022
  function registerAuthCommands(program) {
3977
- program.command("login").description("Authenticate via browser device authorization").action(async (_opts, command) => {
3978
- const runtime = getRuntime(command);
4023
+ program.command("login").description("Authenticate via browser device authorization").addOption(new Option("--api-url <url>", `API origin (default: ${DEFAULT_API_URL})`).env("SHIPD_API_URL")).action(async (_opts, command) => {
4024
+ const runtime = getRuntime(command, { defaultApiUrl: DEFAULT_API_URL });
3979
4025
  const auth = e(createCliAuthClient(runtime.apiUrl));
3980
4026
  const codeResult = await auth.device.code({ client_id: CLIENT_ID });
3981
4027
  if (codeResult.error) throw new CliError("unauthenticated", codeResult.error.error_description ?? "Failed to start device authorization");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipdit/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "shipd's command-line interface",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "commander": "^14.0.0",
21
21
  "jiti": "^2.5.1",
22
22
  "zod": "^4",
23
- "shipdit": "0.2.0"
23
+ "shipdit": "0.2.2"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^24.13.3",