@voyant-travel/apps 0.2.0 → 0.4.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.
Files changed (41) hide show
  1. package/dist/access-boundary.d.ts +29 -0
  2. package/dist/access-boundary.js +33 -0
  3. package/dist/api-runtime.d.ts +15 -0
  4. package/dist/api-runtime.js +15 -1
  5. package/dist/app-api-contracts.d.ts +51 -0
  6. package/dist/app-api-contracts.js +50 -0
  7. package/dist/app-api-routes.d.ts +28 -0
  8. package/dist/app-api-routes.js +141 -0
  9. package/dist/app-api-service.d.ts +1263 -0
  10. package/dist/app-api-service.js +244 -0
  11. package/dist/app-api-service.test.d.ts +1 -0
  12. package/dist/app-api-service.test.js +109 -0
  13. package/dist/consent.d.ts +15 -0
  14. package/dist/consent.js +65 -0
  15. package/dist/consent.test.d.ts +1 -0
  16. package/dist/consent.test.js +104 -0
  17. package/dist/contracts.d.ts +82 -3
  18. package/dist/contracts.js +50 -0
  19. package/dist/index.d.ts +8 -1
  20. package/dist/index.js +8 -1
  21. package/dist/installation-reconciliation.d.ts +1 -1
  22. package/dist/installation-reconciliation.js +5 -1
  23. package/dist/installation-service.d.ts +13 -2
  24. package/dist/installation-service.js +22 -7
  25. package/dist/oauth-crypto.d.ts +8 -0
  26. package/dist/oauth-crypto.js +23 -0
  27. package/dist/oauth-crypto.test.d.ts +1 -0
  28. package/dist/oauth-crypto.test.js +11 -0
  29. package/dist/oauth-service.d.ts +66 -0
  30. package/dist/oauth-service.js +398 -0
  31. package/dist/oauth-service.test.d.ts +1 -0
  32. package/dist/oauth-service.test.js +60 -0
  33. package/dist/routes.d.ts +8 -1
  34. package/dist/routes.js +70 -1
  35. package/dist/schema.d.ts +536 -4
  36. package/dist/schema.js +52 -1
  37. package/dist/service.d.ts +16 -16
  38. package/dist/voyant.js +87 -1
  39. package/migrations/20260717143000_app_oauth_authorization.sql +47 -0
  40. package/migrations/meta/_journal.json +7 -0
  41. package/package.json +40 -4
package/dist/contracts.js CHANGED
@@ -221,3 +221,53 @@ export const appWebhookReplaySchema = z
221
221
  signingSecret: z.string().min(32),
222
222
  })
223
223
  .strict();
224
+ export const appOAuthAuthorizeQuerySchema = z
225
+ .object({
226
+ response_type: z.literal("code"),
227
+ client_id: z.string().trim().min(1),
228
+ release_id: z.string().trim().min(1),
229
+ redirect_uri: z.string().url(),
230
+ state: z.string().trim().min(1),
231
+ code_challenge: z.string().trim().min(1),
232
+ code_challenge_method: z.literal("S256"),
233
+ actor_id: z.string().trim().min(1),
234
+ operator_scopes: z.string().trim().default(""),
235
+ optional_scopes: z.string().trim().default(""),
236
+ })
237
+ .strict();
238
+ export const appOAuthTokenSchema = z
239
+ .discriminatedUnion("grant_type", [
240
+ z.object({
241
+ grant_type: z.literal("authorization_code"),
242
+ code: z.string().trim().min(1),
243
+ redirect_uri: z.string().url(),
244
+ code_verifier: z.string().trim().min(43).max(128),
245
+ client_id: z.string().trim().min(1),
246
+ client_secret: z.string().trim().optional(),
247
+ }),
248
+ z.object({
249
+ grant_type: z.literal("refresh_token"),
250
+ refresh_token: z.string().trim().min(1),
251
+ client_id: z.string().trim().min(1),
252
+ client_secret: z.string().trim().optional(),
253
+ }),
254
+ z.object({
255
+ grant_type: z.literal("urn:voyant:params:oauth:grant-type:actor-token-exchange"),
256
+ installation_id: z.string().trim().min(1),
257
+ viewer_id: z.string().trim().min(1),
258
+ viewer_scopes: z.array(scopeSchema).default([]),
259
+ contextual_scopes: z.array(scopeSchema).optional(),
260
+ client_id: z.string().trim().min(1),
261
+ client_secret: z.string().trim().optional(),
262
+ }),
263
+ ])
264
+ .transform((input) => ({
265
+ ...input,
266
+ client_secret: input.client_secret?.trim() || undefined,
267
+ }));
268
+ export const appCredentialRevocationSchema = z
269
+ .object({
270
+ installationId: z.string().trim().min(1),
271
+ actorId: z.string().trim().min(1),
272
+ })
273
+ .strict();
package/dist/index.d.ts CHANGED
@@ -1,9 +1,16 @@
1
+ export * from "./access-boundary.js";
2
+ export * from "./app-api-contracts.js";
3
+ export * from "./app-api-routes.js";
4
+ export * from "./app-api-service.js";
1
5
  export * from "./compiler.js";
6
+ export * from "./consent.js";
2
7
  export * from "./contracts.js";
3
8
  export * from "./ingestion.js";
4
9
  export * from "./installation-service.js";
10
+ export * from "./oauth-crypto.js";
11
+ export * from "./oauth-service.js";
5
12
  export { createAppsAdminRoutes } from "./routes.js";
6
- export { appAccessCredentialStatusEnum, appAccessCredentials, appAuditEventKindEnum, appAuditEvents, appCredentialKindEnum, appCredentials, appDistributionEnum, appExtensionInstallations, appGrantStatusEnum, appGrants, appInstallationRegistrationStatusEnum, appInstallationSettings, appInstallationStatusEnum, appInstallations, appInstallationUpdatePolicyEnum, appLifecycleStateEnum, appRedirectUris, appReleaseArtifactStateEnum, appReleaseArtifacts, appReleaseLocalizations, appReleaseStateEnum, appReleases, appSecretReferences, apps, appWebhookSubscriptionStatusEnum, appWebhookSubscriptions, } from "./schema.js";
13
+ export { appAccessCredentialStatusEnum, appAccessCredentials, appAccessTokenModeEnum, appAuditEventKindEnum, appAuditEvents, appCredentialKindEnum, appCredentials, appDistributionEnum, appExtensionInstallations, appGrantStatusEnum, appGrants, appInstallationRegistrationStatusEnum, appInstallationSettings, appInstallationStatusEnum, appInstallations, appInstallationUpdatePolicyEnum, appLifecycleStateEnum, appOAuthAuthorizationCodes, appOAuthRefreshTokens, appRedirectUris, appReleaseArtifactStateEnum, appReleaseArtifacts, appReleaseLocalizations, appReleaseStateEnum, appReleases, appSecretReferences, apps, appWebhookSubscriptionStatusEnum, appWebhookSubscriptions, } from "./schema.js";
7
14
  export { createAppsService } from "./service.js";
8
15
  export type { AppWebhookDeliveryOptions } from "./webhook-delivery.js";
9
16
  export { createAppWebhookDeliveryStore, createAppWebhookEventQueue, enqueueAppWebhookEvent, listAppWebhookHealth, replayAppWebhookDelivery, } from "./webhook-delivery.js";
package/dist/index.js CHANGED
@@ -1,8 +1,15 @@
1
+ export * from "./access-boundary.js";
2
+ export * from "./app-api-contracts.js";
3
+ export * from "./app-api-routes.js";
4
+ export * from "./app-api-service.js";
1
5
  export * from "./compiler.js";
6
+ export * from "./consent.js";
2
7
  export * from "./contracts.js";
3
8
  export * from "./ingestion.js";
4
9
  export * from "./installation-service.js";
10
+ export * from "./oauth-crypto.js";
11
+ export * from "./oauth-service.js";
5
12
  export { createAppsAdminRoutes } from "./routes.js";
6
- export { appAccessCredentialStatusEnum, appAccessCredentials, appAuditEventKindEnum, appAuditEvents, appCredentialKindEnum, appCredentials, appDistributionEnum, appExtensionInstallations, appGrantStatusEnum, appGrants, appInstallationRegistrationStatusEnum, appInstallationSettings, appInstallationStatusEnum, appInstallations, appInstallationUpdatePolicyEnum, appLifecycleStateEnum, appRedirectUris, appReleaseArtifactStateEnum, appReleaseArtifacts, appReleaseLocalizations, appReleaseStateEnum, appReleases, appSecretReferences, apps, appWebhookSubscriptionStatusEnum, appWebhookSubscriptions, } from "./schema.js";
13
+ export { appAccessCredentialStatusEnum, appAccessCredentials, appAccessTokenModeEnum, appAuditEventKindEnum, appAuditEvents, appCredentialKindEnum, appCredentials, appDistributionEnum, appExtensionInstallations, appGrantStatusEnum, appGrants, appInstallationRegistrationStatusEnum, appInstallationSettings, appInstallationStatusEnum, appInstallations, appInstallationUpdatePolicyEnum, appLifecycleStateEnum, appOAuthAuthorizationCodes, appOAuthRefreshTokens, appRedirectUris, appReleaseArtifactStateEnum, appReleaseArtifacts, appReleaseLocalizations, appReleaseStateEnum, appReleases, appSecretReferences, apps, appWebhookSubscriptionStatusEnum, appWebhookSubscriptions, } from "./schema.js";
7
14
  export { createAppsService } from "./service.js";
8
15
  export { createAppWebhookDeliveryStore, createAppWebhookEventQueue, enqueueAppWebhookEvent, listAppWebhookHealth, replayAppWebhookDelivery, } from "./webhook-delivery.js";
@@ -14,5 +14,5 @@ export declare function deactivateRuntimeState(db: PostgresJsDatabase, installat
14
14
  export declare function deactivateResolvedRegistrations(db: PostgresJsDatabase, installation: AppInstallation): Promise<void>;
15
15
  export declare function markAppDefinitionsInactive(db: PostgresJsDatabase, installation: AppInstallation, actorId: string): Promise<void>;
16
16
  export declare function countInstallationRows(db: PostgresJsDatabase, table: typeof appGrants | typeof appAccessCredentials | typeof appExtensionInstallations | typeof appWebhookSubscriptions, installationId: string): Promise<number>;
17
- export declare function audit(db: PostgresJsDatabase, installation: AppInstallation, actorId: string, kind: "lifecycle" | "grant" | "credential" | "reconciliation" | "purge", action: string, details: Record<string, unknown>): Promise<void>;
17
+ export declare function audit(db: PostgresJsDatabase, installation: AppInstallation, actorId: string, kind: "lifecycle" | "grant" | "consent" | "credential" | "token" | "reconciliation" | "purge", action: string, details: Record<string, unknown>): Promise<void>;
18
18
  export {};
@@ -1,7 +1,7 @@
1
1
  import { createAppCustomFieldDefinitionOwner, customFieldDefinitions, } from "@voyant-travel/custom-fields";
2
2
  import { ApiHttpError } from "@voyant-travel/hono";
3
3
  import { and, eq, sql } from "drizzle-orm";
4
- import { appAccessCredentials, appAuditEvents, appExtensionInstallations, appGrants, appWebhookSubscriptions, } from "./schema.js";
4
+ import { appAccessCredentials, appAuditEvents, appExtensionInstallations, appGrants, appOAuthRefreshTokens, appWebhookSubscriptions, } from "./schema.js";
5
5
  export async function reconcileRelease(db, installation, release, actorId, action, options) {
6
6
  const normalized = parseNormalizedRelease(release.normalizedRecord);
7
7
  await reconcileCustomFields(db, installation, release, normalized, actorId, options);
@@ -78,6 +78,10 @@ export async function deactivateRuntimeState(db, installation) {
78
78
  .update(appAccessCredentials)
79
79
  .set({ status: "inactive", deactivatedAt: now })
80
80
  .where(eq(appAccessCredentials.installationId, installation.id));
81
+ await db
82
+ .update(appOAuthRefreshTokens)
83
+ .set({ status: "revoked", revokedAt: now })
84
+ .where(eq(appOAuthRefreshTokens.installationId, installation.id));
81
85
  await deactivateResolvedRegistrations(db, installation);
82
86
  }
83
87
  export async function deactivateResolvedRegistrations(db, installation) {
@@ -58,6 +58,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
58
58
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
59
59
  namespace: string;
60
60
  installedBy: string;
61
+ credentialGeneration: number;
61
62
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
62
63
  lastCompatibleReleaseCheckAt: Date | null;
63
64
  pendingReleaseId: string | null;
@@ -76,15 +77,16 @@ export declare function createAppInstallationService(options?: AppInstallationSe
76
77
  outcome: "unchanged";
77
78
  } | {
78
79
  installation: {
79
- status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
80
80
  id: string;
81
81
  createdAt: Date;
82
82
  updatedAt: Date;
83
83
  appId: string;
84
84
  releaseId: string;
85
85
  deploymentId: string;
86
+ status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
86
87
  namespace: string;
87
88
  installedBy: string;
89
+ credentialGeneration: number;
88
90
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
89
91
  lastCompatibleReleaseCheckAt: Date | null;
90
92
  pendingReleaseId: string | null;
@@ -98,7 +100,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
98
100
  uninstalledAt: Date | null;
99
101
  purgedAt: Date | null;
100
102
  };
101
- outcome: "created" | "reinstalled";
103
+ outcome: "reinstalled" | "created";
102
104
  }>;
103
105
  upgrade: (db: PostgresJsDatabase, input: UpgradeAppInput) => Promise<{
104
106
  installation: {
@@ -109,6 +111,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
109
111
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
110
112
  namespace: string;
111
113
  installedBy: string;
114
+ credentialGeneration: number;
112
115
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
113
116
  lastCompatibleReleaseCheckAt: Date | null;
114
117
  pendingReleaseId: string | null;
@@ -135,6 +138,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
135
138
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
136
139
  namespace: string;
137
140
  installedBy: string;
141
+ credentialGeneration: number;
138
142
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
139
143
  lastCompatibleReleaseCheckAt: Date | null;
140
144
  pendingReleaseId: string | null;
@@ -162,6 +166,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
162
166
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
163
167
  namespace: string;
164
168
  installedBy: string;
169
+ credentialGeneration: number;
165
170
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
166
171
  lastCompatibleReleaseCheckAt: Date | null;
167
172
  pendingReleaseId: string | null;
@@ -187,6 +192,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
187
192
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
188
193
  namespace: string;
189
194
  installedBy: string;
195
+ credentialGeneration: number;
190
196
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
191
197
  lastCompatibleReleaseCheckAt: Date | null;
192
198
  pendingReleaseId: string | null;
@@ -213,6 +219,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
213
219
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
214
220
  namespace: string;
215
221
  installedBy: string;
222
+ credentialGeneration: number;
216
223
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
217
224
  lastCompatibleReleaseCheckAt: Date | null;
218
225
  pendingReleaseId: string | null;
@@ -238,6 +245,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
238
245
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
239
246
  namespace: string;
240
247
  installedBy: string;
248
+ credentialGeneration: number;
241
249
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
242
250
  lastCompatibleReleaseCheckAt: Date | null;
243
251
  pendingReleaseId: string | null;
@@ -264,6 +272,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
264
272
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
265
273
  namespace: string;
266
274
  installedBy: string;
275
+ credentialGeneration: number;
267
276
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
268
277
  lastCompatibleReleaseCheckAt: Date | null;
269
278
  pendingReleaseId: string | null;
@@ -289,6 +298,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
289
298
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
290
299
  namespace: string;
291
300
  installedBy: string;
301
+ credentialGeneration: number;
292
302
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
293
303
  lastCompatibleReleaseCheckAt: Date | null;
294
304
  pendingReleaseId: string | null;
@@ -315,6 +325,7 @@ export declare function createAppInstallationService(options?: AppInstallationSe
315
325
  status: "active" | "pending" | "authorizing" | "paused" | "degraded" | "revoked" | "uninstalled";
316
326
  namespace: string;
317
327
  installedBy: string;
328
+ credentialGeneration: number;
318
329
  updatePolicy: "manual" | "compatible" | "patch" | "pinned";
319
330
  lastCompatibleReleaseCheckAt: Date | null;
320
331
  pendingReleaseId: string | null;
@@ -1,5 +1,5 @@
1
1
  import { ApiHttpError } from "@voyant-travel/hono";
2
- import { and, eq } from "drizzle-orm";
2
+ import { and, eq, sql } from "drizzle-orm";
3
3
  import { audit, countInstallationRows, deactivateResolvedRegistrations, deactivateRuntimeState, markAppDefinitionsInactive, newlyRequiredScopes, reconcileGrants, reconcileRelease, rotateCredential, } from "./installation-reconciliation.js";
4
4
  import { canInstallOver, invalidTransition, planLifecycleTransition } from "./installation-state.js";
5
5
  import { appAccessCredentials, appExtensionInstallations, appGrants, appInstallations, appReleases, apps, appWebhookSubscriptions, } from "./schema.js";
@@ -295,14 +295,29 @@ function lifecyclePatch(to, now) {
295
295
  const base = { status: to, updatedAt: now };
296
296
  if (to === "active")
297
297
  return { ...base, activatedAt: now };
298
- if (to === "paused")
299
- return { ...base, pausedAt: now };
298
+ if (to === "paused") {
299
+ return {
300
+ ...base,
301
+ pausedAt: now,
302
+ credentialGeneration: sql `${appInstallations.credentialGeneration} + 1`,
303
+ };
304
+ }
300
305
  if (to === "degraded")
301
306
  return { ...base, degradedAt: now };
302
- if (to === "revoked")
303
- return { ...base, revokedAt: now };
304
- if (to === "uninstalled")
305
- return { ...base, uninstalledAt: now };
307
+ if (to === "revoked") {
308
+ return {
309
+ ...base,
310
+ revokedAt: now,
311
+ credentialGeneration: sql `${appInstallations.credentialGeneration} + 1`,
312
+ };
313
+ }
314
+ if (to === "uninstalled") {
315
+ return {
316
+ ...base,
317
+ uninstalledAt: now,
318
+ credentialGeneration: sql `${appInstallations.credentialGeneration} + 1`,
319
+ };
320
+ }
306
321
  return base;
307
322
  }
308
323
  function writeFailed() {
@@ -0,0 +1,8 @@
1
+ export declare const APP_ACCESS_TOKEN_PREFIX = "vapp_";
2
+ export declare const APP_REFRESH_TOKEN_PREFIX = "vappr_";
3
+ export declare const APP_AUTH_CODE_PREFIX = "vappc_";
4
+ export declare function randomToken(prefix: string, bytes?: number): string;
5
+ export declare function sha256Hex(value: string): string;
6
+ export declare function sha256Base64Url(value: string): string;
7
+ export declare function constantTimeEqual(left: string, right: string): boolean;
8
+ export declare function verifyPkceS256(verifier: string, challenge: string): boolean;
@@ -0,0 +1,23 @@
1
+ import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
2
+ export const APP_ACCESS_TOKEN_PREFIX = "vapp_";
3
+ export const APP_REFRESH_TOKEN_PREFIX = "vappr_";
4
+ export const APP_AUTH_CODE_PREFIX = "vappc_";
5
+ export function randomToken(prefix, bytes = 32) {
6
+ return `${prefix}${randomBytes(bytes).toString("base64url")}`;
7
+ }
8
+ export function sha256Hex(value) {
9
+ return createHash("sha256").update(value).digest("hex");
10
+ }
11
+ export function sha256Base64Url(value) {
12
+ return createHash("sha256").update(value).digest("base64url");
13
+ }
14
+ export function constantTimeEqual(left, right) {
15
+ const leftHash = Buffer.from(sha256Hex(left), "hex");
16
+ const rightHash = Buffer.from(sha256Hex(right), "hex");
17
+ return timingSafeEqual(leftHash, rightHash);
18
+ }
19
+ export function verifyPkceS256(verifier, challenge) {
20
+ if (!/^[A-Za-z0-9._~-]{43,128}$/.test(verifier))
21
+ return false;
22
+ return constantTimeEqual(sha256Base64Url(verifier), challenge);
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { sha256Base64Url, verifyPkceS256 } from "./oauth-crypto.js";
3
+ describe("app OAuth PKCE", () => {
4
+ it("accepts only S256 challenges derived from the verifier", () => {
5
+ const verifier = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ_0123456789-1234567890";
6
+ const challenge = sha256Base64Url(verifier);
7
+ expect(verifyPkceS256(verifier, challenge)).toBe(true);
8
+ expect(verifyPkceS256(`${verifier}x`, challenge)).toBe(false);
9
+ expect(verifyPkceS256("too-short", challenge)).toBe(false);
10
+ });
11
+ });
@@ -0,0 +1,66 @@
1
+ import type { VoyantAuthContext } from "@voyant-travel/core";
2
+ import type { AccessCatalog } from "@voyant-travel/types/api-keys";
3
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
4
+ export interface AppOAuthServiceOptions {
5
+ accessCatalog: AccessCatalog;
6
+ deploymentId: string;
7
+ now?: () => Date;
8
+ }
9
+ export interface AuthorizeAppInput {
10
+ appId: string;
11
+ releaseId: string;
12
+ redirectUri: string;
13
+ state: string;
14
+ codeChallenge: string;
15
+ codeChallengeMethod: "S256";
16
+ actorId: string;
17
+ operatorGrantedScopes: readonly string[];
18
+ grantedOptionalScopes?: readonly string[];
19
+ }
20
+ export interface TokenCodeInput {
21
+ grantType: "authorization_code";
22
+ code: string;
23
+ redirectUri: string;
24
+ codeVerifier: string;
25
+ clientId: string;
26
+ clientSecret?: string;
27
+ }
28
+ export interface RefreshTokenInput {
29
+ grantType: "refresh_token";
30
+ refreshToken: string;
31
+ clientId: string;
32
+ clientSecret?: string;
33
+ }
34
+ export interface TokenExchangeInput {
35
+ grantType: "urn:voyant:params:oauth:grant-type:actor-token-exchange";
36
+ installationId: string;
37
+ viewerId: string;
38
+ viewerScopes: readonly string[];
39
+ contextualScopes?: readonly string[];
40
+ clientId: string;
41
+ clientSecret?: string;
42
+ }
43
+ export type AppTokenInput = TokenCodeInput | RefreshTokenInput | TokenExchangeInput;
44
+ export declare function createAppOAuthService(options: AppOAuthServiceOptions): {
45
+ authorize: (db: PostgresJsDatabase, input: AuthorizeAppInput) => Promise<{
46
+ code: string;
47
+ state: string;
48
+ redirectUri: string;
49
+ expiresAt: Date;
50
+ }>;
51
+ token: (db: PostgresJsDatabase, input: AppTokenInput) => Promise<{
52
+ refreshToken?: string | undefined;
53
+ accessToken: string;
54
+ tokenType: "Bearer";
55
+ expiresIn: number;
56
+ scope: string;
57
+ tokenMode: "offline" | "online";
58
+ }>;
59
+ resolveAccessToken: (db: PostgresJsDatabase, rawToken: string) => Promise<VoyantAuthContext | null>;
60
+ revokeInstallationCredentials: (db: PostgresJsDatabase, installationId: string, actorId: string) => Promise<{
61
+ installationId: string;
62
+ generation: number;
63
+ }>;
64
+ };
65
+ export declare function intersectAppTokenScopes(...sets: readonly (readonly string[])[]): string[];
66
+ export declare function readStoredScopes(metadata: Record<string, unknown>): string[] | null;