@voyant-travel/hono 0.128.1 → 0.128.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.
package/dist/index.d.ts CHANGED
@@ -20,5 +20,5 @@ export { stampOpenApiRegistryApiId } from "./openapi-ownership.js";
20
20
  export { openApiValidationHook } from "./openapi-validation.js";
21
21
  export type { CreatePublicCapabilityOptions, PublicCapabilityCookieOptions, PublicCapabilityPayload, VerifyPublicCapabilityOptions, } from "./public-capability.js";
22
22
  export { createPublicCapabilityToken, extractPublicCapabilityToken, serializePublicCapabilityCookie, verifyPublicCapabilityToken, } from "./public-capability.js";
23
- export type { DbFactory, DbFactorySelector, DbSource, DbSurfaceSelection, LogEntry, LoggerProvider, VoyantAppConfig, VoyantAuthIntegration, VoyantAuthPermissionArgs, VoyantAuthResolveArgs, VoyantBindings, VoyantDb, VoyantExecutionContext, VoyantQueryRuntime, VoyantRequestAuthContext, VoyantRouteHandler, VoyantVariables, } from "./types.js";
23
+ export type { DbFactory, DbFactorySelector, DbSource, DbSurfaceSelection, LogEntry, LoggerProvider, VoyantAppConfig, VoyantAuthAppTokenResolveArgs, VoyantAuthIntegration, VoyantAuthPermissionArgs, VoyantAuthResolveArgs, VoyantBindings, VoyantDb, VoyantExecutionContext, VoyantQueryRuntime, VoyantRequestAuthContext, VoyantRouteHandler, VoyantVariables, } from "./types.js";
24
24
  export { ApiHttpError, ForbiddenApiError, normalizeValidationError, parseJsonBody, parseOptionalJsonBody, parseQuery, RequestValidationError, UnauthorizedApiError, } from "./validation.js";
@@ -139,6 +139,19 @@ function applyAuthContext(c, auth) {
139
139
  c.set("apiTokenId", auth.apiTokenId);
140
140
  if (auth.apiKeyId)
141
141
  c.set("apiKeyId", auth.apiKeyId);
142
+ if (auth.appId)
143
+ c.set("appId", auth.appId);
144
+ if (auth.appInstallationId)
145
+ c.set("appInstallationId", auth.appInstallationId);
146
+ if (auth.appReleaseId)
147
+ c.set("appReleaseId", auth.appReleaseId);
148
+ if (auth.appCredentialGeneration !== undefined) {
149
+ c.set("appCredentialGeneration", auth.appCredentialGeneration);
150
+ }
151
+ if (auth.appTokenMode)
152
+ c.set("appTokenMode", auth.appTokenMode);
153
+ if (auth.appViewerId)
154
+ c.set("appViewerId", auth.appViewerId);
142
155
  }
143
156
  export function requireAuth(dbSource, opts) {
144
157
  const publicPaths = opts?.publicPaths ?? [];
@@ -270,7 +283,29 @@ export function requireAuth(dbSource, opts) {
270
283
  await lease.release();
271
284
  }
272
285
  }
273
- // Strategy 3: App-provided auth resolution (cookies, provider tokens, etc.)
286
+ // Strategy 3: Remote app access token support
287
+ if (token && opts?.auth?.resolveAppToken) {
288
+ const lease = acquireRequestDb(c, dbFactory);
289
+ try {
290
+ const resolved = await opts.auth.resolveAppToken({
291
+ request: c.req.raw,
292
+ env: c.env,
293
+ db: lease.db,
294
+ // Guarded: Hono throws on `executionCtx` access outside Workers.
295
+ ctx: tryGetExecutionCtx(c),
296
+ token,
297
+ });
298
+ if (resolved?.callerType === "app" && resolved.appInstallationId) {
299
+ applyAuthContext(c, resolved);
300
+ // `await` is load-bearing — see strategy 2.
301
+ return await next();
302
+ }
303
+ }
304
+ finally {
305
+ await lease.release();
306
+ }
307
+ }
308
+ // Strategy 4: App-provided auth resolution (cookies, provider tokens, etc.)
274
309
  if (opts?.auth?.resolve) {
275
310
  const lease = acquireRequestDb(c, dbFactory);
276
311
  try {
@@ -293,7 +328,7 @@ export function requireAuth(dbSource, opts) {
293
328
  await lease.release();
294
329
  }
295
330
  }
296
- // Strategy 4: Generic session-claims bearer token support
331
+ // Strategy 5: Generic session-claims bearer token support
297
332
  const sessionSecret = c.env.SESSION_CLAIMS_SECRET;
298
333
  if (token && sessionSecret && token.includes(".")) {
299
334
  try {
@@ -98,7 +98,9 @@ export function requireActor(...args) {
98
98
  return async (c, next) => {
99
99
  if (c.req.method === "OPTIONS")
100
100
  return next();
101
- if (c.get("callerType") === "api_key" || c.get("callerType") === "internal") {
101
+ if (c.get("callerType") === "api_key" ||
102
+ c.get("callerType") === "app" ||
103
+ c.get("callerType") === "internal") {
102
104
  const pathname = normalizePathname(new URL(c.req.url).pathname, {
103
105
  basePath: options.basePath,
104
106
  });
@@ -116,7 +118,7 @@ export function requireActor(...args) {
116
118
  hasAnyApiKeyPermission(c.get("scopes"), resource, actions, options.accessCatalog)) {
117
119
  return next();
118
120
  }
119
- return c.json({ error: "Forbidden: API key missing required permission" }, 403);
121
+ return c.json({ error: "Forbidden: token missing required permission" }, 403);
120
122
  }
121
123
  const actor = c.get("actor");
122
124
  if (!actor) {
package/dist/types.d.ts CHANGED
@@ -134,6 +134,9 @@ export interface VoyantAuthResolveArgs<TBindings extends VoyantBindings = Voyant
134
134
  db: VoyantDb;
135
135
  ctx?: VoyantExecutionContext;
136
136
  }
137
+ export interface VoyantAuthAppTokenResolveArgs<TBindings extends VoyantBindings = VoyantBindings> extends VoyantAuthResolveArgs<TBindings> {
138
+ token: string;
139
+ }
137
140
  export interface VoyantAuthPermissionArgs<TBindings extends VoyantBindings = VoyantBindings> extends VoyantAuthResolveArgs<TBindings> {
138
141
  permission: VoyantPermission;
139
142
  auth: VoyantRequestAuthContext;
@@ -160,6 +163,7 @@ export interface VoyantAuthIntegration<TBindings extends VoyantBindings = Voyant
160
163
  * so `/v1/public/*` route guards work.
161
164
  */
162
165
  resolve?: (args: VoyantAuthResolveArgs<TBindings>) => Promise<VoyantRequestAuthContext | null> | VoyantRequestAuthContext | null;
166
+ resolveAppToken?: (args: VoyantAuthAppTokenResolveArgs<TBindings>) => Promise<VoyantAuthContext | null> | VoyantAuthContext | null;
163
167
  hasPermission?: (args: VoyantAuthPermissionArgs<TBindings>) => Promise<boolean> | boolean;
164
168
  validateApiKey?: (args: VoyantAuthApiKeyValidationArgs<TBindings>) => Promise<boolean> | boolean;
165
169
  onUnauthorized?: (args: VoyantAuthUnauthorizedArgs<TBindings>) => Promise<Response | null> | Response | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/hono",
3
- "version": "0.128.1",
3
+ "version": "0.128.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -130,17 +130,17 @@
130
130
  "drizzle-orm": "^0.45.2",
131
131
  "hono": "^4.12.27",
132
132
  "zod": "^4.4.3",
133
- "@voyant-travel/core": "^0.125.0",
134
- "@voyant-travel/db": "^0.114.9",
135
- "@voyant-travel/types": "^0.109.2",
133
+ "@voyant-travel/core": "^0.125.1",
134
+ "@voyant-travel/db": "^0.114.10",
135
+ "@voyant-travel/types": "^0.109.3",
136
136
  "@voyant-travel/utils": "^0.107.1",
137
- "@voyant-travel/workflows": "^0.122.2"
137
+ "@voyant-travel/workflows": "^0.122.3"
138
138
  },
139
139
  "devDependencies": {
140
140
  "typescript": "^6.0.3",
141
141
  "vitest": "^4.1.9",
142
142
  "@voyant-travel/voyant-typescript-config": "^0.1.0",
143
- "@voyant-travel/workflows-orchestrator": "^0.122.2"
143
+ "@voyant-travel/workflows-orchestrator": "^0.122.3"
144
144
  },
145
145
  "files": [
146
146
  "dist"