camstack 1.2.32 → 1.2.34

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/cli.js CHANGED
@@ -38,7 +38,7 @@ async function runServe(args) {
38
38
  ...typeof values.data === "string" ? { data: values.data } : {}
39
39
  };
40
40
  Object.assign(process.env, buildServeEnv(opts));
41
- await import("./launcher-OBXOIIQJ.js");
41
+ await import("./launcher-CSBOA3IK.js");
42
42
  }
43
43
 
44
44
  // src/commands/agent.ts
@@ -83,7 +83,7 @@ async function runAgent(args) {
83
83
  ...typeof values.port === "string" ? { port: values.port } : {}
84
84
  };
85
85
  Object.assign(process.env, buildAgentEnv(opts));
86
- await import("./launcher-OBXOIIQJ.js");
86
+ await import("./launcher-CSBOA3IK.js");
87
87
  }
88
88
 
89
89
  // src/commands/setup.ts
@@ -396909,7 +396909,7 @@ var require_trpc_context = __commonJS({
396909
396909
  }
396910
396910
  return null;
396911
396911
  }
396912
- async function resolveUser(token2, authService, addonRegistry, shareTokens = null) {
396912
+ async function resolveUser(token2, authService, addonRegistry, shareTokens = null, logger = null) {
396913
396913
  if (!token2)
396914
396914
  return null;
396915
396915
  if (token2.startsWith(share_token_service_js_1.SHARE_TOKEN_PREFIX)) {
@@ -396971,6 +396971,13 @@ var require_trpc_context = __commonJS({
396971
396971
  if (typeof payload.isAdmin !== "boolean") {
396972
396972
  return null;
396973
396973
  }
396974
+ const principal = (0, types_1.classifyBearerPrincipal)(payload);
396975
+ if (principal.kind === "not-a-credential") {
396976
+ logger?.warn("trpc: refused a bearer that is not an API credential", {
396977
+ meta: { reason: principal.reason, userId: payload.userId ?? payload.keyId ?? "unknown" }
396978
+ });
396979
+ return null;
396980
+ }
396974
396981
  const credential = (0, trpc_error_principal_js_1.readCredentialIdentity)(payload);
396975
396982
  return {
396976
396983
  id: payload.userId ?? payload.keyId ?? "unknown",
@@ -396992,12 +396999,21 @@ var require_trpc_context = __commonJS({
396992
396999
  // user's scopes expects the change to APPLY, and the live session
396993
397000
  // kept gating on the old set until re-login (2026-08-15: a user
396994
397001
  // granted the whole fleet kept seeing zero cameras). For non-admin
396995
- // JWT principals the store's current scopes win when readable
397002
+ // SESSION principals the store's current scopes win when readable
396996
397003
  // (memoized — see above); the JWT's copy is the fallback when the
396997
397004
  // user-management cap is unreachable, so a store hiccup never
396998
397005
  // locks anybody out mid-request.
397006
+ //
397007
+ // `session` ONLY, and that word is the whole fix. An ACCOUNT-LINK token
397008
+ // is governed by the grant the operator consented to, not by the linking
397009
+ // user's record: it always carries `isAdmin: false` (`oauth-grants.ts`
397010
+ // → `baseClaims`) and its owner is normally an admin, whose record is
397011
+ // deliberately unscoped — so the refresh replaced a six-scope Home
397012
+ // Assistant grant with `[]` and the hub refused the component's first
397013
+ // call with `Have: (none)` (2026-08-19). The user store knows nothing
397014
+ // about a link and must not get a vote on one.
396999
397015
  ...payload.scopes !== void 0 ? { scopes: (0, types_1.normalizeTokenScopes)(payload.scopes) } : {},
397000
- ...!payload.isAdmin ? await (async () => {
397016
+ ...!payload.isAdmin && principal.kind === "session" ? await (async () => {
397001
397017
  const fresh = await refreshScopesFromStore(payload.userId ?? payload.keyId ?? "unknown", addonRegistry);
397002
397018
  return fresh !== null ? { scopes: fresh } : {};
397003
397019
  })() : {},
@@ -397025,19 +397041,19 @@ var require_trpc_context = __commonJS({
397025
397041
  };
397026
397042
  return { user };
397027
397043
  }
397028
- async function createTrpcContext(req, authService, addonRegistry, shareTokens = null) {
397044
+ async function createTrpcContext(req, authService, addonRegistry, shareTokens = null, logger = null) {
397029
397045
  const token2 = extractTokenFromRequest(req);
397030
397046
  return {
397031
- user: await resolveUser(token2, authService, addonRegistry, shareTokens),
397047
+ user: await resolveUser(token2, authService, addonRegistry, shareTokens, logger),
397032
397048
  req,
397033
397049
  deviceScopeLookup: makeDeviceScopeLookup(addonRegistry),
397034
397050
  deviceFleet: () => addonRegistry.getPersistedDeviceList()
397035
397051
  };
397036
397052
  }
397037
- async function createWsTrpcContext(opts, authService, addonRegistry, shareTokens = null) {
397053
+ async function createWsTrpcContext(opts, authService, addonRegistry, shareTokens = null, logger = null) {
397038
397054
  const paramToken = opts.info.connectionParams?.["token"];
397039
397055
  const token2 = (typeof paramToken === "string" ? paramToken : null) ?? extractTokenFromRequest(opts.req);
397040
- const user = await resolveUser(token2, authService, addonRegistry, shareTokens);
397056
+ const user = await resolveUser(token2, authService, addonRegistry, shareTokens, logger);
397041
397057
  return {
397042
397058
  user,
397043
397059
  req: opts.req,
@@ -408907,7 +408923,16 @@ var require_main4 = __commonJS({
408907
408923
  prefix: "/trpc",
408908
408924
  trpcOptions: {
408909
408925
  router: appRouter,
408910
- createContext: ({ req }) => (0, trpc_context_1.createTrpcContext)(req, authService, addonRegistry, shareTokenService),
408926
+ createContext: ({ req }) => (0, trpc_context_1.createTrpcContext)(
408927
+ req,
408928
+ authService,
408929
+ addonRegistry,
408930
+ shareTokenService,
408931
+ // A bearer refused for NOT being an API credential never reaches a
408932
+ // procedure, so `onError` below never sees it — the refusal would
408933
+ // be silent without this. Same reason `gateAddonJwt` logs (D103).
408934
+ app.get(logging_service_1.LoggingService).createLogger("tRPC")
408935
+ ),
408911
408936
  onError: ({ path: trpcPath, error, ctx }) => {
408912
408937
  const trpcLogger = app.get(logging_service_1.LoggingService).createLogger("tRPC");
408913
408938
  trpcLogger.warn("tRPC error", {
@@ -409301,7 +409326,7 @@ var require_main4 = __commonJS({
409301
409326
  (0, ws_1.applyWSSHandler)({
409302
409327
  wss,
409303
409328
  router: appRouter,
409304
- createContext: (opts) => (0, trpc_context_1.createWsTrpcContext)(opts, authService, addonRegistry, shareTokenService),
409329
+ createContext: (opts) => (0, trpc_context_1.createWsTrpcContext)(opts, authService, addonRegistry, shareTokenService, app.get(logging_service_1.LoggingService).createLogger("tRPC:ws")),
409305
409330
  onError: ({ path: trpcPath, error, ctx }) => {
409306
409331
  const trpcLogger = app.get(logging_service_1.LoggingService).createLogger("tRPC:ws");
409307
409332
  trpcLogger.warn("tRPC error", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstack",
3
- "version": "1.2.32",
3
+ "version": "1.2.34",
4
4
  "description": "CLI tool for managing and running CamStack server",
5
5
  "keywords": [
6
6
  "camstack",