@atproto/pds 0.4.218 → 0.4.219

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atproto/pds
2
2
 
3
+ ## 0.4.219
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4816](https://github.com/bluesky-social/atproto/pull/4816) [`61e75af`](https://github.com/bluesky-social/atproto/commit/61e75af39e63217d915850b2f8ac8db5f92eed0b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use request logger instead of global one when performing service proxying
8
+
9
+ - Updated dependencies [[`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676), [`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676), [`b3ce11a`](https://github.com/bluesky-social/atproto/commit/b3ce11ae2e965f239db6aec6054f069d557f4d55), [`0cfb16b`](https://github.com/bluesky-social/atproto/commit/0cfb16b2bfead81284317f2f893838384070d219), [`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676), [`b3ce11a`](https://github.com/bluesky-social/atproto/commit/b3ce11ae2e965f239db6aec6054f069d557f4d55), [`55d06de`](https://github.com/bluesky-social/atproto/commit/55d06de80a1506908a04ed5c0834986cb5783797), [`952354c`](https://github.com/bluesky-social/atproto/commit/952354c1dd458251f8b643d02f4b227d40c5df17), [`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676)]:
10
+ - @atproto/syntax@0.5.4
11
+ - @atproto/oauth-provider@0.16.0
12
+ - @atproto/lex-json@0.0.16
13
+ - @atproto/lex@0.0.25
14
+ - @atproto/xrpc-server@0.10.20
15
+ - @atproto/lex-cbor@0.0.16
16
+
3
17
  ## 0.4.218
4
18
 
5
19
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"config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B,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA"}
@@ -238,18 +238,22 @@ const envToCfg = (env) => {
238
238
  colors: {
239
239
  light: env.lightColor,
240
240
  dark: env.darkColor,
241
+ contrastSaturation: env.contrastSaturation,
241
242
  primary: env.primaryColor,
242
243
  primaryContrast: env.primaryColorContrast,
243
244
  primaryHue: env.primaryColorHue,
244
245
  error: env.errorColor,
245
246
  errorContrast: env.errorColorContrast,
246
247
  errorHue: env.errorColorHue,
247
- success: env.successColor,
248
- successContrast: env.successColorContrast,
249
- successHue: env.successColorHue,
250
248
  warning: env.warningColor,
251
249
  warningContrast: env.warningColorContrast,
252
250
  warningHue: env.warningColorHue,
251
+ info: env.infoColor,
252
+ infoContrast: env.infoColorContrast,
253
+ infoHue: env.infoColorHue,
254
+ success: env.successColor,
255
+ successContrast: env.successColorContrast,
256
+ successHue: env.successColorHue,
253
257
  },
254
258
  links: [
255
259
  {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,0DAA4B;AAC5B,4CAAmD;AAEnD,4CAAgD;AAGhD,iCAAiC;AACjC,gEAAgE;AAEzD,MAAM,QAAQ,GAAG,CAAC,GAAsB,EAAgB,EAAE;IAC/D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,IAAI,CAAA;IAC7B,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,WAAW,CAAA;IAC5C,MAAM,SAAS,GACb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B,aAAa,EAAE,gBAAgB;QAC/B,KAAK,EAAE,QAAQ;QACf,UAAU,EAAE,aAAa;QACzB,QAAQ,EAAE,WAAW;QACrB,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;KAChB,CAAA;AACH,CAAC,CAAA;AAtVY,QAAA,QAAQ,YAsVpB","sourcesContent":["import assert from 'node:assert'\nimport path from 'node:path'\nimport { DAY, HOUR, SECOND } from '@atproto/common'\nimport { BrandingInput, HcaptchaConfig } from '@atproto/oauth-provider'\nimport { ensureValidDid } from '@atproto/syntax'\nimport { ServerEnvironment } from './env'\n\n// off-config but still from env:\n// logging: LOG_LEVEL, LOG_SYSTEMS, LOG_ENABLED, LOG_DESTINATION\n\nexport const envToCfg = (env: ServerEnvironment): ServerConfig => {\n const port = env.port ?? 2583\n const hostname = env.hostname ?? 'localhost'\n const publicUrl =\n hostname === 'localhost'\n ? `http://localhost:${port}`\n : `https://${hostname}`\n const did = env.serviceDid ?? `did:web:${hostname}`\n const serviceCfg: ServerConfig['service'] = {\n port,\n hostname,\n publicUrl,\n did,\n version: env.version, // default?\n privacyPolicyUrl: env.privacyPolicyUrl,\n termsOfServiceUrl: env.termsOfServiceUrl,\n contactEmailAddress: env.contactEmailAddress,\n acceptingImports: env.acceptingImports ?? true,\n maxImportSize: env.maxImportSize,\n blobUploadLimit: env.blobUploadLimit ?? 5 * 1024 * 1024, // 5mb\n devMode: env.devMode ?? false,\n }\n\n const dbLoc = (name: string) => {\n return env.dataDirectory ? path.join(env.dataDirectory, name) : name\n }\n\n const disableWalAutoCheckpoint = env.disableWalAutoCheckpoint ?? false\n\n const dbCfg: ServerConfig['db'] = {\n accountDbLoc: env.accountDbLocation ?? dbLoc('account.sqlite'),\n sequencerDbLoc: env.sequencerDbLocation ?? dbLoc('sequencer.sqlite'),\n didCacheDbLoc: env.didCacheDbLocation ?? dbLoc('did_cache.sqlite'),\n disableWalAutoCheckpoint,\n }\n\n const actorStoreCfg: ServerConfig['actorStore'] = {\n directory: env.actorStoreDirectory ?? dbLoc('actors'),\n cacheSize: env.actorStoreCacheSize ?? 100,\n disableWalAutoCheckpoint,\n }\n\n let blobstoreCfg: ServerConfig['blobstore']\n if (env.blobstoreS3Bucket && env.blobstoreDiskLocation) {\n throw new Error('Cannot set both S3 and disk blobstore env vars')\n }\n if (env.blobstoreS3Bucket) {\n blobstoreCfg = {\n provider: 's3',\n bucket: env.blobstoreS3Bucket,\n uploadTimeoutMs: env.blobstoreS3UploadTimeoutMs || 20000,\n region: env.blobstoreS3Region,\n endpoint: env.blobstoreS3Endpoint,\n forcePathStyle: env.blobstoreS3ForcePathStyle,\n }\n if (env.blobstoreS3AccessKeyId || env.blobstoreS3SecretAccessKey) {\n if (!env.blobstoreS3AccessKeyId || !env.blobstoreS3SecretAccessKey) {\n throw new Error(\n 'Must specify both S3 access key id and secret access key blobstore env vars',\n )\n }\n blobstoreCfg.credentials = {\n accessKeyId: env.blobstoreS3AccessKeyId,\n secretAccessKey: env.blobstoreS3SecretAccessKey,\n }\n }\n } else if (env.blobstoreDiskLocation) {\n blobstoreCfg = {\n provider: 'disk',\n location: env.blobstoreDiskLocation,\n tempLocation: env.blobstoreDiskTmpLocation,\n }\n } else {\n throw new Error('Must configure either S3 or disk blobstore')\n }\n\n let serviceHandleDomains: string[]\n if (env.serviceHandleDomains && env.serviceHandleDomains.length > 0) {\n serviceHandleDomains = env.serviceHandleDomains\n } else {\n if (hostname === 'localhost') {\n serviceHandleDomains = ['.test']\n } else {\n serviceHandleDomains = [`.${hostname}`]\n }\n }\n const invalidDomain = serviceHandleDomains.find(\n (domain) => domain.length < 1 || !domain.startsWith('.'),\n )\n if (invalidDomain) {\n throw new Error(`Invalid handle domain: ${invalidDomain}`)\n }\n\n const identityCfg: ServerConfig['identity'] = {\n plcUrl: env.didPlcUrl ?? 'https://plc.directory',\n cacheMaxTTL: env.didCacheMaxTTL ?? DAY,\n cacheStaleTTL: env.didCacheStaleTTL ?? HOUR,\n resolverTimeout: env.resolverTimeout ?? 3 * SECOND,\n recoveryDidKey: env.recoveryDidKey ?? null,\n serviceHandleDomains,\n handleBackupNameservers: env.handleBackupNameservers,\n enableDidDocWithSession: !!env.enableDidDocWithSession,\n }\n\n let entrywayCfg: ServerConfig['entryway'] = null\n if (env.entrywayUrl) {\n assert(\n env.entrywayJwtVerifyKeyK256PublicKeyHex &&\n env.entrywayPlcRotationKey &&\n env.entrywayDid,\n 'if entryway url is configured, must include all required entryway configuration',\n )\n entrywayCfg = {\n url: env.entrywayUrl,\n did: env.entrywayDid,\n jwtPublicKeyHex: env.entrywayJwtVerifyKeyK256PublicKeyHex,\n plcRotationKey: env.entrywayPlcRotationKey,\n }\n }\n\n // default to being required if left undefined\n const invitesCfg: ServerConfig['invites'] =\n env.inviteRequired === false\n ? {\n required: false,\n }\n : {\n required: true,\n interval: env.inviteInterval ?? null,\n epoch: env.inviteEpoch ?? 0,\n }\n\n let emailCfg: ServerConfig['email']\n if (!env.emailFromAddress && !env.emailSmtpUrl) {\n emailCfg = null\n } else {\n if (!env.emailFromAddress || !env.emailSmtpUrl) {\n throw new Error(\n 'Partial email config, must set both emailFromAddress and emailSmtpUrl',\n )\n }\n emailCfg = {\n smtpUrl: env.emailSmtpUrl,\n fromAddress: env.emailFromAddress,\n }\n }\n\n let moderationEmailCfg: ServerConfig['moderationEmail']\n if (!env.moderationEmailAddress && !env.moderationEmailSmtpUrl) {\n moderationEmailCfg = null\n } else {\n if (!env.moderationEmailAddress || !env.moderationEmailSmtpUrl) {\n throw new Error(\n 'Partial moderation email config, must set both emailFromAddress and emailSmtpUrl',\n )\n }\n moderationEmailCfg = {\n smtpUrl: env.moderationEmailSmtpUrl,\n fromAddress: env.moderationEmailAddress,\n }\n }\n\n const subscriptionCfg: ServerConfig['subscription'] = {\n maxBuffer: env.maxSubscriptionBuffer ?? 500,\n repoBackfillLimitMs: env.repoBackfillLimitMs ?? DAY,\n }\n\n let bskyAppViewCfg: ServerConfig['bskyAppView'] = null\n if (env.bskyAppViewUrl) {\n assert(\n env.bskyAppViewDid,\n 'if bsky appview service url is configured, must configure its did as well.',\n )\n bskyAppViewCfg = {\n url: env.bskyAppViewUrl,\n did: env.bskyAppViewDid,\n cdnUrlPattern: env.bskyAppViewCdnUrlPattern,\n }\n }\n\n let modServiceCfg: ServerConfig['modService'] = null\n if (env.modServiceUrl) {\n assert(\n env.modServiceDid,\n 'if mod service url is configured, must configure its did as well.',\n )\n modServiceCfg = {\n url: env.modServiceUrl,\n did: env.modServiceDid,\n }\n }\n\n let reportServiceCfg: ServerConfig['reportService'] = null\n if (env.reportServiceUrl) {\n assert(\n env.reportServiceDid,\n 'if report service url is configured, must configure its did as well.',\n )\n reportServiceCfg = {\n url: env.reportServiceUrl,\n did: env.reportServiceDid,\n }\n }\n\n // if there's a mod service, default report service into it\n if (modServiceCfg && !reportServiceCfg) {\n reportServiceCfg = modServiceCfg\n }\n\n const redisCfg: ServerConfig['redis'] = env.redisScratchAddress\n ? {\n address: env.redisScratchAddress,\n password: env.redisScratchPassword,\n }\n : null\n\n const rateLimitsCfg: ServerConfig['rateLimits'] = env.rateLimitsEnabled\n ? {\n enabled: true,\n bypassKey: env.rateLimitBypassKey,\n bypassIps: env.rateLimitBypassIps?.map((ipOrCidr) =>\n ipOrCidr.split('/')[0]?.trim(),\n ),\n }\n : { enabled: false }\n\n const crawlersCfg: ServerConfig['crawlers'] = env.crawlers ?? []\n\n const fetchCfg: ServerConfig['fetch'] = {\n disableSsrfProtection: env.disableSsrfProtection ?? env.devMode ?? false,\n maxResponseSize: env.fetchMaxResponseSize ?? 512 * 1024, // 512kb\n }\n\n const proxyCfg: ServerConfig['proxy'] = {\n disableSsrfProtection: env.disableSsrfProtection ?? env.devMode ?? false,\n allowHTTP2: env.proxyAllowHTTP2 ?? false,\n headersTimeout: env.proxyHeadersTimeout ?? 10e3,\n bodyTimeout: env.proxyBodyTimeout ?? 30e3,\n maxResponseSize: env.proxyMaxResponseSize ?? 10 * 1024 * 1024, // 10mb\n maxRetries:\n env.proxyMaxRetries != null && env.proxyMaxRetries > 0\n ? env.proxyMaxRetries\n : 0,\n preferCompressed: env.proxyPreferCompressed ?? false,\n }\n\n const oauthCfg: ServerConfig['oauth'] = entrywayCfg\n ? {\n issuer: entrywayCfg.url,\n provider: undefined,\n }\n : {\n issuer: serviceCfg.publicUrl,\n provider: {\n hcaptcha:\n env.hcaptchaSiteKey &&\n env.hcaptchaSecretKey &&\n env.hcaptchaTokenSalt\n ? {\n siteKey: env.hcaptchaSiteKey,\n secretKey: env.hcaptchaSecretKey,\n tokenSalt: env.hcaptchaTokenSalt,\n }\n : undefined,\n branding: {\n name: env.serviceName ?? `${hostname} PDS`,\n logo: env.logoUrl,\n colors: {\n light: env.lightColor,\n dark: env.darkColor,\n primary: env.primaryColor,\n primaryContrast: env.primaryColorContrast,\n primaryHue: env.primaryColorHue,\n error: env.errorColor,\n errorContrast: env.errorColorContrast,\n errorHue: env.errorColorHue,\n success: env.successColor,\n successContrast: env.successColorContrast,\n successHue: env.successColorHue,\n warning: env.warningColor,\n warningContrast: env.warningColorContrast,\n warningHue: env.warningColorHue,\n },\n links: [\n {\n title: { en: 'Home', fr: 'Accueil' },\n href: env.homeUrl,\n rel: 'canonical' as const, // Prevents login page from being indexed\n },\n {\n title: { en: 'Terms of Service' },\n href: env.termsOfServiceUrl,\n rel: 'terms-of-service' as const,\n },\n {\n title: { en: 'Privacy Policy' },\n href: env.privacyPolicyUrl,\n rel: 'privacy-policy' as const,\n },\n {\n title: { en: 'Support' },\n href: env.supportUrl,\n rel: 'help' as const,\n },\n ].filter(\n <T extends { href?: string }>(f: T): f is T & { href: string } =>\n f.href != null && f.href !== '',\n ),\n },\n trustedClients: env.trustedOAuthClients,\n },\n }\n\n const lexiconCfg: LexiconResolverConfig = {}\n\n if (env.lexiconDidAuthority != null) {\n ensureValidDid(env.lexiconDidAuthority)\n lexiconCfg.didAuthority = env.lexiconDidAuthority\n }\n\n return {\n service: serviceCfg,\n db: dbCfg,\n actorStore: actorStoreCfg,\n blobstore: blobstoreCfg,\n identity: identityCfg,\n entryway: entrywayCfg,\n invites: invitesCfg,\n email: emailCfg,\n moderationEmail: moderationEmailCfg,\n subscription: subscriptionCfg,\n bskyAppView: bskyAppViewCfg,\n modService: modServiceCfg,\n reportService: reportServiceCfg,\n redis: redisCfg,\n rateLimits: rateLimitsCfg,\n crawlers: crawlersCfg,\n fetch: fetchCfg,\n lexicon: lexiconCfg,\n proxy: proxyCfg,\n oauth: oauthCfg,\n }\n}\n\nexport type ServerConfig = {\n service: ServiceConfig\n db: DatabaseConfig\n actorStore: ActorStoreConfig\n blobstore: S3BlobstoreConfig | DiskBlobstoreConfig\n identity: IdentityConfig\n entryway: EntrywayConfig | null\n invites: InvitesConfig\n email: EmailConfig | null\n moderationEmail: EmailConfig | null\n subscription: SubscriptionConfig\n bskyAppView: BksyAppViewConfig | null\n modService: ModServiceConfig | null\n reportService: ReportServiceConfig | null\n redis: RedisScratchConfig | null\n rateLimits: RateLimitsConfig\n crawlers: string[]\n fetch: FetchConfig\n proxy: ProxyConfig\n oauth: OAuthConfig\n lexicon: LexiconResolverConfig\n}\n\nexport type ServiceConfig = {\n port: number\n hostname: string\n publicUrl: string\n did: string\n version?: string\n privacyPolicyUrl?: string\n termsOfServiceUrl?: string\n acceptingImports: boolean\n maxImportSize?: number\n blobUploadLimit: number\n contactEmailAddress?: string\n devMode: boolean\n}\n\nexport type DatabaseConfig = {\n accountDbLoc: string\n sequencerDbLoc: string\n didCacheDbLoc: string\n disableWalAutoCheckpoint: boolean\n}\n\nexport type ActorStoreConfig = {\n directory: string\n cacheSize: number\n disableWalAutoCheckpoint: boolean\n}\n\nexport type S3BlobstoreConfig = {\n provider: 's3'\n bucket: string\n region?: string\n endpoint?: string\n forcePathStyle?: boolean\n uploadTimeoutMs?: number\n credentials?: {\n accessKeyId: string\n secretAccessKey: string\n }\n}\n\nexport type DiskBlobstoreConfig = {\n provider: 'disk'\n location: string\n tempLocation?: string\n}\n\nexport type IdentityConfig = {\n plcUrl: string\n resolverTimeout: number\n cacheStaleTTL: number\n cacheMaxTTL: number\n recoveryDidKey: string | null\n serviceHandleDomains: string[]\n handleBackupNameservers?: string[]\n enableDidDocWithSession: boolean\n}\n\nexport type EntrywayConfig = {\n url: string\n did: string\n jwtPublicKeyHex: string\n plcRotationKey: string\n}\n\nexport type FetchConfig = {\n disableSsrfProtection: boolean\n maxResponseSize: number\n}\n\nexport type ProxyConfig = {\n disableSsrfProtection: boolean\n allowHTTP2: boolean\n headersTimeout: number\n bodyTimeout: number\n maxResponseSize: number\n maxRetries: number\n\n /**\n * When proxying requests that might get intercepted (for read-after-write) we\n * negotiate the encoding based on the client's preferences. We will however\n * use or own weights in order to be able to better control if the PDS will\n * need to perform content decoding. This settings allows to prefer compressed\n * content over uncompressed one.\n */\n preferCompressed: boolean\n}\n\nexport type OAuthConfig = {\n issuer: string\n provider?: {\n hcaptcha?: HcaptchaConfig\n branding: BrandingInput\n trustedClients?: string[]\n }\n}\n\nexport type LexiconResolverConfig = {\n didAuthority?: `did:${string}:${string}`\n}\n\nexport type InvitesConfig =\n | {\n required: true\n interval: number | null\n epoch: number\n }\n | {\n required: false\n }\n\nexport type EmailConfig = {\n smtpUrl: string\n fromAddress: string\n}\n\nexport type SubscriptionConfig = {\n maxBuffer: number\n repoBackfillLimitMs: number\n}\n\nexport type RedisScratchConfig = {\n address: string\n password?: string\n}\n\nexport type RateLimitsConfig =\n | {\n enabled: true\n bypassKey?: string\n bypassIps?: string[]\n }\n | { enabled: false }\n\nexport type BksyAppViewConfig = {\n url: string\n did: string\n cdnUrlPattern?: string\n}\n\nexport type ModServiceConfig = {\n url: string\n did: string\n}\n\nexport type ReportServiceConfig = {\n url: string\n did: string\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,0DAA4B;AAC5B,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EAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;QACvC,UAAU,CAAC,YAAY,GAAG,GAAG,CAAC,mBAAmB,CAAA;IACnD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,UAAU;QACnB,EAAE,EAAE,KAAK;QACT,UAAU,EAAE,aAAa;QACzB,SAAS,EAAE,YAAY;QACvB,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,QAAQ;QACf,eAAe,EAAE,kBAAkB;QACnC,YAAY,EAAE,eAAe;QAC7B,WAAW,EAAE,cAAc;QAC3B,UAAU,EAAE,aAAa;QACzB,aAAa,EAAE,gBAAgB;QAC/B,KAAK,EAAE,QAAQ;QACf,UAAU,EAAE,aAAa;QACzB,QAAQ,EAAE,WAAW;QACrB,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;KAChB,CAAA;AACH,CAAC,CAAA;AAhWY,QAAA,QAAQ,YAgWpB","sourcesContent":["import assert from 'node:assert'\nimport path from 'node:path'\nimport { DAY, HOUR, SECOND } from '@atproto/common'\nimport { BrandingInput, HcaptchaConfig } from '@atproto/oauth-provider'\nimport { ensureValidDid } from '@atproto/syntax'\nimport { ServerEnvironment } from './env'\n\n// off-config but still from env:\n// logging: LOG_LEVEL, LOG_SYSTEMS, LOG_ENABLED, LOG_DESTINATION\n\nexport const envToCfg = (env: ServerEnvironment): ServerConfig => {\n const port = env.port ?? 2583\n const hostname = env.hostname ?? 'localhost'\n const publicUrl =\n hostname === 'localhost'\n ? `http://localhost:${port}`\n : `https://${hostname}`\n const did = env.serviceDid ?? `did:web:${hostname}`\n const serviceCfg: ServerConfig['service'] = {\n port,\n hostname,\n publicUrl,\n did,\n version: env.version, // default?\n privacyPolicyUrl: env.privacyPolicyUrl,\n termsOfServiceUrl: env.termsOfServiceUrl,\n contactEmailAddress: env.contactEmailAddress,\n acceptingImports: env.acceptingImports ?? true,\n maxImportSize: env.maxImportSize,\n blobUploadLimit: env.blobUploadLimit ?? 5 * 1024 * 1024, // 5mb\n devMode: env.devMode ?? false,\n }\n\n const dbLoc = (name: string) => {\n return env.dataDirectory ? path.join(env.dataDirectory, name) : name\n }\n\n const disableWalAutoCheckpoint = env.disableWalAutoCheckpoint ?? false\n\n const dbCfg: ServerConfig['db'] = {\n accountDbLoc: env.accountDbLocation ?? dbLoc('account.sqlite'),\n sequencerDbLoc: env.sequencerDbLocation ?? dbLoc('sequencer.sqlite'),\n didCacheDbLoc: env.didCacheDbLocation ?? dbLoc('did_cache.sqlite'),\n disableWalAutoCheckpoint,\n }\n\n const actorStoreCfg: ServerConfig['actorStore'] = {\n directory: env.actorStoreDirectory ?? dbLoc('actors'),\n cacheSize: env.actorStoreCacheSize ?? 100,\n disableWalAutoCheckpoint,\n }\n\n let blobstoreCfg: ServerConfig['blobstore']\n if (env.blobstoreS3Bucket && env.blobstoreDiskLocation) {\n throw new Error('Cannot set both S3 and disk blobstore env vars')\n }\n if (env.blobstoreS3Bucket) {\n blobstoreCfg = {\n provider: 's3',\n bucket: env.blobstoreS3Bucket,\n uploadTimeoutMs: env.blobstoreS3UploadTimeoutMs || 20000,\n region: env.blobstoreS3Region,\n endpoint: env.blobstoreS3Endpoint,\n forcePathStyle: env.blobstoreS3ForcePathStyle,\n }\n if (env.blobstoreS3AccessKeyId || env.blobstoreS3SecretAccessKey) {\n if (!env.blobstoreS3AccessKeyId || !env.blobstoreS3SecretAccessKey) {\n throw new Error(\n 'Must specify both S3 access key id and secret access key blobstore env vars',\n )\n }\n blobstoreCfg.credentials = {\n accessKeyId: env.blobstoreS3AccessKeyId,\n secretAccessKey: env.blobstoreS3SecretAccessKey,\n }\n }\n } else if (env.blobstoreDiskLocation) {\n blobstoreCfg = {\n provider: 'disk',\n location: env.blobstoreDiskLocation,\n tempLocation: env.blobstoreDiskTmpLocation,\n }\n } else {\n throw new Error('Must configure either S3 or disk blobstore')\n }\n\n let serviceHandleDomains: string[]\n if (env.serviceHandleDomains && env.serviceHandleDomains.length > 0) {\n serviceHandleDomains = env.serviceHandleDomains\n } else {\n if (hostname === 'localhost') {\n serviceHandleDomains = ['.test']\n } else {\n serviceHandleDomains = [`.${hostname}`]\n }\n }\n const invalidDomain = serviceHandleDomains.find(\n (domain) => domain.length < 1 || !domain.startsWith('.'),\n )\n if (invalidDomain) {\n throw new Error(`Invalid handle domain: ${invalidDomain}`)\n }\n\n const identityCfg: ServerConfig['identity'] = {\n plcUrl: env.didPlcUrl ?? 'https://plc.directory',\n cacheMaxTTL: env.didCacheMaxTTL ?? DAY,\n cacheStaleTTL: env.didCacheStaleTTL ?? HOUR,\n resolverTimeout: env.resolverTimeout ?? 3 * SECOND,\n recoveryDidKey: env.recoveryDidKey ?? null,\n serviceHandleDomains,\n handleBackupNameservers: env.handleBackupNameservers,\n enableDidDocWithSession: !!env.enableDidDocWithSession,\n }\n\n let entrywayCfg: ServerConfig['entryway'] = null\n if (env.entrywayUrl) {\n assert(\n env.entrywayJwtVerifyKeyK256PublicKeyHex &&\n env.entrywayPlcRotationKey &&\n env.entrywayDid,\n 'if entryway url is configured, must include all required entryway configuration',\n )\n entrywayCfg = {\n url: env.entrywayUrl,\n did: env.entrywayDid,\n jwtPublicKeyHex: env.entrywayJwtVerifyKeyK256PublicKeyHex,\n plcRotationKey: env.entrywayPlcRotationKey,\n }\n }\n\n // default to being required if left undefined\n const invitesCfg: ServerConfig['invites'] =\n env.inviteRequired === false\n ? {\n required: false,\n }\n : {\n required: true,\n interval: env.inviteInterval ?? null,\n epoch: env.inviteEpoch ?? 0,\n }\n\n let emailCfg: ServerConfig['email']\n if (!env.emailFromAddress && !env.emailSmtpUrl) {\n emailCfg = null\n } else {\n if (!env.emailFromAddress || !env.emailSmtpUrl) {\n throw new Error(\n 'Partial email config, must set both emailFromAddress and emailSmtpUrl',\n )\n }\n emailCfg = {\n smtpUrl: env.emailSmtpUrl,\n fromAddress: env.emailFromAddress,\n }\n }\n\n let moderationEmailCfg: ServerConfig['moderationEmail']\n if (!env.moderationEmailAddress && !env.moderationEmailSmtpUrl) {\n moderationEmailCfg = null\n } else {\n if (!env.moderationEmailAddress || !env.moderationEmailSmtpUrl) {\n throw new Error(\n 'Partial moderation email config, must set both emailFromAddress and emailSmtpUrl',\n )\n }\n moderationEmailCfg = {\n smtpUrl: env.moderationEmailSmtpUrl,\n fromAddress: env.moderationEmailAddress,\n }\n }\n\n const subscriptionCfg: ServerConfig['subscription'] = {\n maxBuffer: env.maxSubscriptionBuffer ?? 500,\n repoBackfillLimitMs: env.repoBackfillLimitMs ?? DAY,\n }\n\n let bskyAppViewCfg: ServerConfig['bskyAppView'] = null\n if (env.bskyAppViewUrl) {\n assert(\n env.bskyAppViewDid,\n 'if bsky appview service url is configured, must configure its did as well.',\n )\n bskyAppViewCfg = {\n url: env.bskyAppViewUrl,\n did: env.bskyAppViewDid,\n cdnUrlPattern: env.bskyAppViewCdnUrlPattern,\n }\n }\n\n let modServiceCfg: ServerConfig['modService'] = null\n if (env.modServiceUrl) {\n assert(\n env.modServiceDid,\n 'if mod service url is configured, must configure its did as well.',\n )\n modServiceCfg = {\n url: env.modServiceUrl,\n did: env.modServiceDid,\n }\n }\n\n let reportServiceCfg: ServerConfig['reportService'] = null\n if (env.reportServiceUrl) {\n assert(\n env.reportServiceDid,\n 'if report service url is configured, must configure its did as well.',\n )\n reportServiceCfg = {\n url: env.reportServiceUrl,\n did: env.reportServiceDid,\n }\n }\n\n // if there's a mod service, default report service into it\n if (modServiceCfg && !reportServiceCfg) {\n reportServiceCfg = modServiceCfg\n }\n\n const redisCfg: ServerConfig['redis'] = env.redisScratchAddress\n ? {\n address: env.redisScratchAddress,\n password: env.redisScratchPassword,\n }\n : null\n\n const rateLimitsCfg: ServerConfig['rateLimits'] = env.rateLimitsEnabled\n ? {\n enabled: true,\n bypassKey: env.rateLimitBypassKey,\n bypassIps: env.rateLimitBypassIps?.map((ipOrCidr) =>\n ipOrCidr.split('/')[0]?.trim(),\n ),\n }\n : { enabled: false }\n\n const crawlersCfg: ServerConfig['crawlers'] = env.crawlers ?? []\n\n const fetchCfg: ServerConfig['fetch'] = {\n disableSsrfProtection: env.disableSsrfProtection ?? env.devMode ?? false,\n maxResponseSize: env.fetchMaxResponseSize ?? 512 * 1024, // 512kb\n }\n\n const proxyCfg: ServerConfig['proxy'] = {\n disableSsrfProtection: env.disableSsrfProtection ?? env.devMode ?? false,\n allowHTTP2: env.proxyAllowHTTP2 ?? false,\n headersTimeout: env.proxyHeadersTimeout ?? 10e3,\n bodyTimeout: env.proxyBodyTimeout ?? 30e3,\n maxResponseSize: env.proxyMaxResponseSize ?? 10 * 1024 * 1024, // 10mb\n maxRetries:\n env.proxyMaxRetries != null && env.proxyMaxRetries > 0\n ? env.proxyMaxRetries\n : 0,\n preferCompressed: env.proxyPreferCompressed ?? false,\n }\n\n const oauthCfg: ServerConfig['oauth'] = entrywayCfg\n ? {\n issuer: entrywayCfg.url,\n provider: undefined,\n }\n : {\n issuer: serviceCfg.publicUrl,\n provider: {\n hcaptcha:\n env.hcaptchaSiteKey &&\n env.hcaptchaSecretKey &&\n env.hcaptchaTokenSalt\n ? {\n siteKey: env.hcaptchaSiteKey,\n secretKey: env.hcaptchaSecretKey,\n tokenSalt: env.hcaptchaTokenSalt,\n }\n : undefined,\n branding: {\n name: env.serviceName ?? `${hostname} PDS`,\n logo: env.logoUrl,\n colors: {\n light: env.lightColor,\n dark: env.darkColor,\n\n contrastSaturation: env.contrastSaturation,\n\n primary: env.primaryColor,\n primaryContrast: env.primaryColorContrast,\n primaryHue: env.primaryColorHue,\n\n error: env.errorColor,\n errorContrast: env.errorColorContrast,\n errorHue: env.errorColorHue,\n\n warning: env.warningColor,\n warningContrast: env.warningColorContrast,\n warningHue: env.warningColorHue,\n\n info: env.infoColor,\n infoContrast: env.infoColorContrast,\n infoHue: env.infoColorHue,\n\n success: env.successColor,\n successContrast: env.successColorContrast,\n successHue: env.successColorHue,\n },\n links: [\n {\n title: { en: 'Home', fr: 'Accueil' },\n href: env.homeUrl,\n rel: 'canonical' as const, // Prevents login page from being indexed\n },\n {\n title: { en: 'Terms of Service' },\n href: env.termsOfServiceUrl,\n rel: 'terms-of-service' as const,\n },\n {\n title: { en: 'Privacy Policy' },\n href: env.privacyPolicyUrl,\n rel: 'privacy-policy' as const,\n },\n {\n title: { en: 'Support' },\n href: env.supportUrl,\n rel: 'help' as const,\n },\n ].filter(\n <T extends { href?: string }>(f: T): f is T & { href: string } =>\n f.href != null && f.href !== '',\n ),\n },\n trustedClients: env.trustedOAuthClients,\n },\n }\n\n const lexiconCfg: LexiconResolverConfig = {}\n\n if (env.lexiconDidAuthority != null) {\n ensureValidDid(env.lexiconDidAuthority)\n lexiconCfg.didAuthority = env.lexiconDidAuthority\n }\n\n return {\n service: serviceCfg,\n db: dbCfg,\n actorStore: actorStoreCfg,\n blobstore: blobstoreCfg,\n identity: identityCfg,\n entryway: entrywayCfg,\n invites: invitesCfg,\n email: emailCfg,\n moderationEmail: moderationEmailCfg,\n subscription: subscriptionCfg,\n bskyAppView: bskyAppViewCfg,\n modService: modServiceCfg,\n reportService: reportServiceCfg,\n redis: redisCfg,\n rateLimits: rateLimitsCfg,\n crawlers: crawlersCfg,\n fetch: fetchCfg,\n lexicon: lexiconCfg,\n proxy: proxyCfg,\n oauth: oauthCfg,\n }\n}\n\nexport type ServerConfig = {\n service: ServiceConfig\n db: DatabaseConfig\n actorStore: ActorStoreConfig\n blobstore: S3BlobstoreConfig | DiskBlobstoreConfig\n identity: IdentityConfig\n entryway: EntrywayConfig | null\n invites: InvitesConfig\n email: EmailConfig | null\n moderationEmail: EmailConfig | null\n subscription: SubscriptionConfig\n bskyAppView: BksyAppViewConfig | null\n modService: ModServiceConfig | null\n reportService: ReportServiceConfig | null\n redis: RedisScratchConfig | null\n rateLimits: RateLimitsConfig\n crawlers: string[]\n fetch: FetchConfig\n proxy: ProxyConfig\n oauth: OAuthConfig\n lexicon: LexiconResolverConfig\n}\n\nexport type ServiceConfig = {\n port: number\n hostname: string\n publicUrl: string\n did: string\n version?: string\n privacyPolicyUrl?: string\n termsOfServiceUrl?: string\n acceptingImports: boolean\n maxImportSize?: number\n blobUploadLimit: number\n contactEmailAddress?: string\n devMode: boolean\n}\n\nexport type DatabaseConfig = {\n accountDbLoc: string\n sequencerDbLoc: string\n didCacheDbLoc: string\n disableWalAutoCheckpoint: boolean\n}\n\nexport type ActorStoreConfig = {\n directory: string\n cacheSize: number\n disableWalAutoCheckpoint: boolean\n}\n\nexport type S3BlobstoreConfig = {\n provider: 's3'\n bucket: string\n region?: string\n endpoint?: string\n forcePathStyle?: boolean\n uploadTimeoutMs?: number\n credentials?: {\n accessKeyId: string\n secretAccessKey: string\n }\n}\n\nexport type DiskBlobstoreConfig = {\n provider: 'disk'\n location: string\n tempLocation?: string\n}\n\nexport type IdentityConfig = {\n plcUrl: string\n resolverTimeout: number\n cacheStaleTTL: number\n cacheMaxTTL: number\n recoveryDidKey: string | null\n serviceHandleDomains: string[]\n handleBackupNameservers?: string[]\n enableDidDocWithSession: boolean\n}\n\nexport type EntrywayConfig = {\n url: string\n did: string\n jwtPublicKeyHex: string\n plcRotationKey: string\n}\n\nexport type FetchConfig = {\n disableSsrfProtection: boolean\n maxResponseSize: number\n}\n\nexport type ProxyConfig = {\n disableSsrfProtection: boolean\n allowHTTP2: boolean\n headersTimeout: number\n bodyTimeout: number\n maxResponseSize: number\n maxRetries: number\n\n /**\n * When proxying requests that might get intercepted (for read-after-write) we\n * negotiate the encoding based on the client's preferences. We will however\n * use or own weights in order to be able to better control if the PDS will\n * need to perform content decoding. This settings allows to prefer compressed\n * content over uncompressed one.\n */\n preferCompressed: boolean\n}\n\nexport type OAuthConfig = {\n issuer: string\n provider?: {\n hcaptcha?: HcaptchaConfig\n branding: BrandingInput\n trustedClients?: string[]\n }\n}\n\nexport type LexiconResolverConfig = {\n didAuthority?: `did:${string}:${string}`\n}\n\nexport type InvitesConfig =\n | {\n required: true\n interval: number | null\n epoch: number\n }\n | {\n required: false\n }\n\nexport type EmailConfig = {\n smtpUrl: string\n fromAddress: string\n}\n\nexport type SubscriptionConfig = {\n maxBuffer: number\n repoBackfillLimitMs: number\n}\n\nexport type RedisScratchConfig = {\n address: string\n password?: string\n}\n\nexport type RateLimitsConfig =\n | {\n enabled: true\n bypassKey?: string\n bypassIps?: string[]\n }\n | { enabled: false }\n\nexport type BksyAppViewConfig = {\n url: string\n did: string\n cdnUrlPattern?: string\n}\n\nexport type ModServiceConfig = {\n url: string\n did: string\n}\n\nexport type ReportServiceConfig = {\n url: string\n did: string\n}\n"]}
@@ -20,6 +20,7 @@ export declare function readEnv(): {
20
20
  trustedOAuthClients: string[];
21
21
  lightColor: string | undefined;
22
22
  darkColor: string | undefined;
23
+ contrastSaturation: number | undefined;
23
24
  primaryColor: string | undefined;
24
25
  primaryColorContrast: string | undefined;
25
26
  primaryColorHue: number | undefined;
@@ -29,6 +30,9 @@ export declare function readEnv(): {
29
30
  warningColor: string | undefined;
30
31
  warningColorContrast: string | undefined;
31
32
  warningColorHue: number | undefined;
33
+ infoColor: string | undefined;
34
+ infoColorContrast: string | undefined;
35
+ infoColorHue: number | undefined;
32
36
  successColor: string | undefined;
33
37
  successColorContrast: string | undefined;
34
38
  successColorHue: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2JtB;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+JtB;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAA"}
@@ -29,6 +29,7 @@ function readEnv() {
29
29
  // branding
30
30
  lightColor: (0, common_1.envStr)('PDS_LIGHT_COLOR'),
31
31
  darkColor: (0, common_1.envStr)('PDS_DARK_COLOR'),
32
+ contrastSaturation: (0, common_1.envInt)('PDS_CONTRAST_SATURATION'),
32
33
  primaryColor: (0, common_1.envStr)('PDS_PRIMARY_COLOR'),
33
34
  primaryColorContrast: (0, common_1.envStr)('PDS_PRIMARY_COLOR_CONTRAST'),
34
35
  primaryColorHue: (0, common_1.envInt)('PDS_PRIMARY_COLOR_HUE'),
@@ -38,6 +39,9 @@ function readEnv() {
38
39
  warningColor: (0, common_1.envStr)('PDS_WARNING_COLOR'),
39
40
  warningColorContrast: (0, common_1.envStr)('PDS_WARNING_COLOR_CONTRAST'),
40
41
  warningColorHue: (0, common_1.envInt)('PDS_WARNING_COLOR_HUE'),
42
+ infoColor: (0, common_1.envStr)('PDS_INFO_COLOR'),
43
+ infoColorContrast: (0, common_1.envStr)('PDS_INFO_COLOR_CONTRAST'),
44
+ infoColorHue: (0, common_1.envInt)('PDS_INFO_COLOR_HUE'),
41
45
  successColor: (0, common_1.envStr)('PDS_SUCCESS_COLOR'),
42
46
  successColorContrast: (0, common_1.envStr)('PDS_SUCCESS_COLOR_CONTRAST'),
43
47
  successColorHue: (0, common_1.envInt)('PDS_SUCCESS_COLOR_HUE'),
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":";;AAEA,0BA2JC;AA7JD,4CAAkE;AAElE,SAAgB,OAAO;IACrB,OAAO;QACL,UAAU;QACV,IAAI,EAAE,IAAA,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EAAE,IAAA,gBAAO,EAAC,6BAA6B,CAAC;QAE7D,QAAQ;QACR,oBAAoB,EAAE,IAAA,eAAM,EAAC,6BAA6B,CAAC;QAE3D,QAAQ;QACR,eAAe,EAAE,IAAA,gBAAO,EAAC,uBAAuB,CAAC;QACjD,mBAAmB,EAAE,IAAA,eAAM,EAAC,2BAA2B,CAAC;QACxD,gBAAgB,EAAE,IAAA,eAAM,EAAC,wBAAwB,CAAC;QAClD,oBAAoB,EAAE,IAAA,eAAM,EAAC,6BAA6B,CAAC;QAC3D,eAAe,EAAE,IAAA,eAAM,EAAC,uBAAuB,CAAC;QAChD,qBAAqB,EAAE,IAAA,gBAAO,EAAC,6BAA6B,CAAC;QAE7D,qBAAqB;QACrB,mBAAmB,EAAE,IAAA,eAAM,EAAC,2BAA2B,CAAC;KACzD,CAAA;AACH,CAAC","sourcesContent":["import { envBool, envInt, envList, envStr } from '@atproto/common'\n\nexport function readEnv() {\n return {\n // service\n port: envInt('PDS_PORT'),\n hostname: envStr('PDS_HOSTNAME'),\n serviceDid: envStr('PDS_SERVICE_DID'),\n serviceName: envStr('PDS_SERVICE_NAME'),\n version: envStr('PDS_VERSION'),\n homeUrl: envStr('PDS_HOME_URL'),\n logoUrl: envStr('PDS_LOGO_URL'),\n privacyPolicyUrl: envStr('PDS_PRIVACY_POLICY_URL'),\n supportUrl: envStr('PDS_SUPPORT_URL'),\n termsOfServiceUrl: envStr('PDS_TERMS_OF_SERVICE_URL'),\n contactEmailAddress: envStr('PDS_CONTACT_EMAIL_ADDRESS'),\n acceptingImports: envBool('PDS_ACCEPTING_REPO_IMPORTS'),\n maxImportSize: envInt('PDS_MAX_REPO_IMPORT_SIZE'),\n blobUploadLimit: envInt('PDS_BLOB_UPLOAD_LIMIT'),\n devMode: envBool('PDS_DEV_MODE'),\n\n // hCaptcha\n hcaptchaSiteKey: envStr('PDS_HCAPTCHA_SITE_KEY'),\n hcaptchaSecretKey: envStr('PDS_HCAPTCHA_SECRET_KEY'),\n hcaptchaTokenSalt: envStr('PDS_HCAPTCHA_TOKEN_SALT'),\n\n // OAuth\n trustedOAuthClients: envList('PDS_OAUTH_TRUSTED_CLIENTS'),\n\n // branding\n lightColor: envStr('PDS_LIGHT_COLOR'),\n darkColor: envStr('PDS_DARK_COLOR'),\n primaryColor: envStr('PDS_PRIMARY_COLOR'),\n primaryColorContrast: envStr('PDS_PRIMARY_COLOR_CONTRAST'),\n primaryColorHue: envInt('PDS_PRIMARY_COLOR_HUE'),\n errorColor: envStr('PDS_ERROR_COLOR'),\n errorColorContrast: envStr('PDS_ERROR_COLOR_CONTRAST'),\n errorColorHue: envInt('PDS_ERROR_COLOR_HUE'),\n warningColor: envStr('PDS_WARNING_COLOR'),\n warningColorContrast: envStr('PDS_WARNING_COLOR_CONTRAST'),\n warningColorHue: envInt('PDS_WARNING_COLOR_HUE'),\n successColor: envStr('PDS_SUCCESS_COLOR'),\n successColorContrast: envStr('PDS_SUCCESS_COLOR_CONTRAST'),\n successColorHue: envInt('PDS_SUCCESS_COLOR_HUE'),\n\n // database\n dataDirectory: envStr('PDS_DATA_DIRECTORY'),\n disableWalAutoCheckpoint: envBool('PDS_SQLITE_DISABLE_WAL_AUTO_CHECKPOINT'),\n accountDbLocation: envStr('PDS_ACCOUNT_DB_LOCATION'),\n sequencerDbLocation: envStr('PDS_SEQUENCER_DB_LOCATION'),\n didCacheDbLocation: envStr('PDS_DID_CACHE_DB_LOCATION'),\n\n // actor store\n actorStoreDirectory: envStr('PDS_ACTOR_STORE_DIRECTORY'),\n actorStoreCacheSize: envInt('PDS_ACTOR_STORE_CACHE_SIZE'),\n\n // blobstore: one required\n // s3\n blobstoreS3Bucket: envStr('PDS_BLOBSTORE_S3_BUCKET'),\n blobstoreS3Region: envStr('PDS_BLOBSTORE_S3_REGION'),\n blobstoreS3Endpoint: envStr('PDS_BLOBSTORE_S3_ENDPOINT'),\n blobstoreS3ForcePathStyle: envBool('PDS_BLOBSTORE_S3_FORCE_PATH_STYLE'),\n blobstoreS3AccessKeyId: envStr('PDS_BLOBSTORE_S3_ACCESS_KEY_ID'),\n blobstoreS3SecretAccessKey: envStr('PDS_BLOBSTORE_S3_SECRET_ACCESS_KEY'),\n blobstoreS3UploadTimeoutMs: envInt('PDS_BLOBSTORE_S3_UPLOAD_TIMEOUT_MS'),\n // disk\n blobstoreDiskLocation: envStr('PDS_BLOBSTORE_DISK_LOCATION'),\n blobstoreDiskTmpLocation: envStr('PDS_BLOBSTORE_DISK_TMP_LOCATION'),\n\n // identity\n didPlcUrl: envStr('PDS_DID_PLC_URL'),\n didCacheStaleTTL: envInt('PDS_DID_CACHE_STALE_TTL'),\n didCacheMaxTTL: envInt('PDS_DID_CACHE_MAX_TTL'),\n resolverTimeout: envInt('PDS_ID_RESOLVER_TIMEOUT'),\n recoveryDidKey: envStr('PDS_RECOVERY_DID_KEY'),\n serviceHandleDomains: envList('PDS_SERVICE_HANDLE_DOMAINS'), // public hostname by default\n handleBackupNameservers: envList('PDS_HANDLE_BACKUP_NAMESERVERS'),\n enableDidDocWithSession: envBool('PDS_ENABLE_DID_DOC_WITH_SESSION'),\n\n // entryway\n entrywayUrl: envStr('PDS_ENTRYWAY_URL'),\n entrywayDid: envStr('PDS_ENTRYWAY_DID'),\n entrywayJwtVerifyKeyK256PublicKeyHex: envStr(\n 'PDS_ENTRYWAY_JWT_VERIFY_KEY_K256_PUBLIC_KEY_HEX',\n ),\n entrywayPlcRotationKey: envStr('PDS_ENTRYWAY_PLC_ROTATION_KEY'),\n\n // invites\n inviteRequired: envBool('PDS_INVITE_REQUIRED'),\n inviteInterval: envInt('PDS_INVITE_INTERVAL'),\n inviteEpoch: envInt('PDS_INVITE_EPOCH'),\n\n // email\n emailSmtpUrl: envStr('PDS_EMAIL_SMTP_URL'),\n emailFromAddress: envStr('PDS_EMAIL_FROM_ADDRESS'),\n moderationEmailSmtpUrl: envStr('PDS_MODERATION_EMAIL_SMTP_URL'),\n moderationEmailAddress: envStr('PDS_MODERATION_EMAIL_ADDRESS'),\n\n // subscription\n maxSubscriptionBuffer: envInt('PDS_MAX_SUBSCRIPTION_BUFFER'),\n repoBackfillLimitMs: envInt('PDS_REPO_BACKFILL_LIMIT_MS'),\n\n // appview\n bskyAppViewUrl: envStr('PDS_BSKY_APP_VIEW_URL'),\n bskyAppViewDid: envStr('PDS_BSKY_APP_VIEW_DID'),\n bskyAppViewCdnUrlPattern: envStr('PDS_BSKY_APP_VIEW_CDN_URL_PATTERN'),\n\n // mod service\n modServiceUrl: envStr('PDS_MOD_SERVICE_URL'),\n modServiceDid: envStr('PDS_MOD_SERVICE_DID'),\n\n // report service\n reportServiceUrl: envStr('PDS_REPORT_SERVICE_URL'),\n reportServiceDid: envStr('PDS_REPORT_SERVICE_DID'),\n\n // rate limits\n rateLimitsEnabled: envBool('PDS_RATE_LIMITS_ENABLED'),\n rateLimitBypassKey: envStr('PDS_RATE_LIMIT_BYPASS_KEY'),\n rateLimitBypassIps: envList('PDS_RATE_LIMIT_BYPASS_IPS'),\n\n // redis\n redisScratchAddress: envStr('PDS_REDIS_SCRATCH_ADDRESS'),\n redisScratchPassword: envStr('PDS_REDIS_SCRATCH_PASSWORD'),\n\n // crawlers\n crawlers: envList('PDS_CRAWLERS'),\n\n // secrets\n dpopSecret: envStr('PDS_DPOP_SECRET'),\n jwtSecret: envStr('PDS_JWT_SECRET'),\n adminPassword: envStr('PDS_ADMIN_PASSWORD'),\n entrywayAdminToken: envStr('PDS_ENTRYWAY_ADMIN_TOKEN'),\n\n // kms\n plcRotationKeyKmsKeyId: envStr('PDS_PLC_ROTATION_KEY_KMS_KEY_ID'),\n // memory\n plcRotationKeyK256PrivateKeyHex: envStr(\n 'PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX',\n ),\n\n // user provided url http requests\n disableSsrfProtection: envBool('PDS_DISABLE_SSRF_PROTECTION'),\n\n // fetch\n fetchMaxResponseSize: envInt('PDS_FETCH_MAX_RESPONSE_SIZE'),\n\n // proxy\n proxyAllowHTTP2: envBool('PDS_PROXY_ALLOW_HTTP2'),\n proxyHeadersTimeout: envInt('PDS_PROXY_HEADERS_TIMEOUT'),\n proxyBodyTimeout: envInt('PDS_PROXY_BODY_TIMEOUT'),\n proxyMaxResponseSize: envInt('PDS_PROXY_MAX_RESPONSE_SIZE'),\n proxyMaxRetries: envInt('PDS_PROXY_MAX_RETRIES'),\n proxyPreferCompressed: envBool('PDS_PROXY_PREFER_COMPRESSED'),\n\n // lexicon resolution\n lexiconDidAuthority: envStr('PDS_LEXICON_AUTHORITY_DID'),\n }\n}\n\nexport type ServerEnvironment = Partial<ReturnType<typeof readEnv>>\n"]}
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":";;AAEA,0BA+JC;AAjKD,4CAAkE;AAElE,SAAgB,OAAO;IACrB,OAAO;QACL,UAAU;QACV,IAAI,EAAE,IAAA,eAAM,EAAC,UAAU,CAAC;QACxB,QAAQ,EAAE,IAAA,eAAM,EAAC,cAAc,CAAC;QAChC,UAAU,EAAE,IAAA,eAAM,EAAC,iBAAiB,CAAC;QACrC,WAAW,EAAE,IAAA,eAAM,EAAC,kBAAkB,CAAC;QACvC,OAAO,EAAE,IAAA,eAAM,EAAC,aAAa,CAAC;QAC9B,OAAO,EAAE,IAAA,eAAM,EAAC,cAAc,CAAC;QAC/B,OAAO,EAAE,IAAA,eAAM,EAAC,cAAc,CAAC;QAC/B,gBAAgB,EAAE,IAAA,eAAM,EAAC,wBAAwB,CAAC;QAClD,UAAU,EAAE,IAAA,eAAM,EAAC,iBAAiB,CAAC;QACrC,iBAAiB,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC;QACrD,mBAAmB,EAAE,IAAA,eAAM,EAAC,2BAA2B,CAAC;QACxD,gBAAgB,EAAE,IAAA,gBAAO,EAAC,4BAA4B,CAAC;QACvD,aAAa,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC;QACjD,eAAe,EAAE,IAAA,eAAM,EAAC,uBAAuB,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AAA,eAAM,EAAC,2BAA2B,CAAC;KACzD,CAAA;AACH,CAAC","sourcesContent":["import { envBool, envInt, envList, envStr } from '@atproto/common'\n\nexport function readEnv() {\n return {\n // service\n port: envInt('PDS_PORT'),\n hostname: envStr('PDS_HOSTNAME'),\n serviceDid: envStr('PDS_SERVICE_DID'),\n serviceName: envStr('PDS_SERVICE_NAME'),\n version: envStr('PDS_VERSION'),\n homeUrl: envStr('PDS_HOME_URL'),\n logoUrl: envStr('PDS_LOGO_URL'),\n privacyPolicyUrl: envStr('PDS_PRIVACY_POLICY_URL'),\n supportUrl: envStr('PDS_SUPPORT_URL'),\n termsOfServiceUrl: envStr('PDS_TERMS_OF_SERVICE_URL'),\n contactEmailAddress: envStr('PDS_CONTACT_EMAIL_ADDRESS'),\n acceptingImports: envBool('PDS_ACCEPTING_REPO_IMPORTS'),\n maxImportSize: envInt('PDS_MAX_REPO_IMPORT_SIZE'),\n blobUploadLimit: envInt('PDS_BLOB_UPLOAD_LIMIT'),\n devMode: envBool('PDS_DEV_MODE'),\n\n // hCaptcha\n hcaptchaSiteKey: envStr('PDS_HCAPTCHA_SITE_KEY'),\n hcaptchaSecretKey: envStr('PDS_HCAPTCHA_SECRET_KEY'),\n hcaptchaTokenSalt: envStr('PDS_HCAPTCHA_TOKEN_SALT'),\n\n // OAuth\n trustedOAuthClients: envList('PDS_OAUTH_TRUSTED_CLIENTS'),\n\n // branding\n lightColor: envStr('PDS_LIGHT_COLOR'),\n darkColor: envStr('PDS_DARK_COLOR'),\n contrastSaturation: envInt('PDS_CONTRAST_SATURATION'),\n primaryColor: envStr('PDS_PRIMARY_COLOR'),\n primaryColorContrast: envStr('PDS_PRIMARY_COLOR_CONTRAST'),\n primaryColorHue: envInt('PDS_PRIMARY_COLOR_HUE'),\n errorColor: envStr('PDS_ERROR_COLOR'),\n errorColorContrast: envStr('PDS_ERROR_COLOR_CONTRAST'),\n errorColorHue: envInt('PDS_ERROR_COLOR_HUE'),\n warningColor: envStr('PDS_WARNING_COLOR'),\n warningColorContrast: envStr('PDS_WARNING_COLOR_CONTRAST'),\n warningColorHue: envInt('PDS_WARNING_COLOR_HUE'),\n infoColor: envStr('PDS_INFO_COLOR'),\n infoColorContrast: envStr('PDS_INFO_COLOR_CONTRAST'),\n infoColorHue: envInt('PDS_INFO_COLOR_HUE'),\n successColor: envStr('PDS_SUCCESS_COLOR'),\n successColorContrast: envStr('PDS_SUCCESS_COLOR_CONTRAST'),\n successColorHue: envInt('PDS_SUCCESS_COLOR_HUE'),\n\n // database\n dataDirectory: envStr('PDS_DATA_DIRECTORY'),\n disableWalAutoCheckpoint: envBool('PDS_SQLITE_DISABLE_WAL_AUTO_CHECKPOINT'),\n accountDbLocation: envStr('PDS_ACCOUNT_DB_LOCATION'),\n sequencerDbLocation: envStr('PDS_SEQUENCER_DB_LOCATION'),\n didCacheDbLocation: envStr('PDS_DID_CACHE_DB_LOCATION'),\n\n // actor store\n actorStoreDirectory: envStr('PDS_ACTOR_STORE_DIRECTORY'),\n actorStoreCacheSize: envInt('PDS_ACTOR_STORE_CACHE_SIZE'),\n\n // blobstore: one required\n // s3\n blobstoreS3Bucket: envStr('PDS_BLOBSTORE_S3_BUCKET'),\n blobstoreS3Region: envStr('PDS_BLOBSTORE_S3_REGION'),\n blobstoreS3Endpoint: envStr('PDS_BLOBSTORE_S3_ENDPOINT'),\n blobstoreS3ForcePathStyle: envBool('PDS_BLOBSTORE_S3_FORCE_PATH_STYLE'),\n blobstoreS3AccessKeyId: envStr('PDS_BLOBSTORE_S3_ACCESS_KEY_ID'),\n blobstoreS3SecretAccessKey: envStr('PDS_BLOBSTORE_S3_SECRET_ACCESS_KEY'),\n blobstoreS3UploadTimeoutMs: envInt('PDS_BLOBSTORE_S3_UPLOAD_TIMEOUT_MS'),\n // disk\n blobstoreDiskLocation: envStr('PDS_BLOBSTORE_DISK_LOCATION'),\n blobstoreDiskTmpLocation: envStr('PDS_BLOBSTORE_DISK_TMP_LOCATION'),\n\n // identity\n didPlcUrl: envStr('PDS_DID_PLC_URL'),\n didCacheStaleTTL: envInt('PDS_DID_CACHE_STALE_TTL'),\n didCacheMaxTTL: envInt('PDS_DID_CACHE_MAX_TTL'),\n resolverTimeout: envInt('PDS_ID_RESOLVER_TIMEOUT'),\n recoveryDidKey: envStr('PDS_RECOVERY_DID_KEY'),\n serviceHandleDomains: envList('PDS_SERVICE_HANDLE_DOMAINS'), // public hostname by default\n handleBackupNameservers: envList('PDS_HANDLE_BACKUP_NAMESERVERS'),\n enableDidDocWithSession: envBool('PDS_ENABLE_DID_DOC_WITH_SESSION'),\n\n // entryway\n entrywayUrl: envStr('PDS_ENTRYWAY_URL'),\n entrywayDid: envStr('PDS_ENTRYWAY_DID'),\n entrywayJwtVerifyKeyK256PublicKeyHex: envStr(\n 'PDS_ENTRYWAY_JWT_VERIFY_KEY_K256_PUBLIC_KEY_HEX',\n ),\n entrywayPlcRotationKey: envStr('PDS_ENTRYWAY_PLC_ROTATION_KEY'),\n\n // invites\n inviteRequired: envBool('PDS_INVITE_REQUIRED'),\n inviteInterval: envInt('PDS_INVITE_INTERVAL'),\n inviteEpoch: envInt('PDS_INVITE_EPOCH'),\n\n // email\n emailSmtpUrl: envStr('PDS_EMAIL_SMTP_URL'),\n emailFromAddress: envStr('PDS_EMAIL_FROM_ADDRESS'),\n moderationEmailSmtpUrl: envStr('PDS_MODERATION_EMAIL_SMTP_URL'),\n moderationEmailAddress: envStr('PDS_MODERATION_EMAIL_ADDRESS'),\n\n // subscription\n maxSubscriptionBuffer: envInt('PDS_MAX_SUBSCRIPTION_BUFFER'),\n repoBackfillLimitMs: envInt('PDS_REPO_BACKFILL_LIMIT_MS'),\n\n // appview\n bskyAppViewUrl: envStr('PDS_BSKY_APP_VIEW_URL'),\n bskyAppViewDid: envStr('PDS_BSKY_APP_VIEW_DID'),\n bskyAppViewCdnUrlPattern: envStr('PDS_BSKY_APP_VIEW_CDN_URL_PATTERN'),\n\n // mod service\n modServiceUrl: envStr('PDS_MOD_SERVICE_URL'),\n modServiceDid: envStr('PDS_MOD_SERVICE_DID'),\n\n // report service\n reportServiceUrl: envStr('PDS_REPORT_SERVICE_URL'),\n reportServiceDid: envStr('PDS_REPORT_SERVICE_DID'),\n\n // rate limits\n rateLimitsEnabled: envBool('PDS_RATE_LIMITS_ENABLED'),\n rateLimitBypassKey: envStr('PDS_RATE_LIMIT_BYPASS_KEY'),\n rateLimitBypassIps: envList('PDS_RATE_LIMIT_BYPASS_IPS'),\n\n // redis\n redisScratchAddress: envStr('PDS_REDIS_SCRATCH_ADDRESS'),\n redisScratchPassword: envStr('PDS_REDIS_SCRATCH_PASSWORD'),\n\n // crawlers\n crawlers: envList('PDS_CRAWLERS'),\n\n // secrets\n dpopSecret: envStr('PDS_DPOP_SECRET'),\n jwtSecret: envStr('PDS_JWT_SECRET'),\n adminPassword: envStr('PDS_ADMIN_PASSWORD'),\n entrywayAdminToken: envStr('PDS_ENTRYWAY_ADMIN_TOKEN'),\n\n // kms\n plcRotationKeyKmsKeyId: envStr('PDS_PLC_ROTATION_KEY_KMS_KEY_ID'),\n // memory\n plcRotationKeyK256PrivateKeyHex: envStr(\n 'PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX',\n ),\n\n // user provided url http requests\n disableSsrfProtection: envBool('PDS_DISABLE_SSRF_PROTECTION'),\n\n // fetch\n fetchMaxResponseSize: envInt('PDS_FETCH_MAX_RESPONSE_SIZE'),\n\n // proxy\n proxyAllowHTTP2: envBool('PDS_PROXY_ALLOW_HTTP2'),\n proxyHeadersTimeout: envInt('PDS_PROXY_HEADERS_TIMEOUT'),\n proxyBodyTimeout: envInt('PDS_PROXY_BODY_TIMEOUT'),\n proxyMaxResponseSize: envInt('PDS_PROXY_MAX_RESPONSE_SIZE'),\n proxyMaxRetries: envInt('PDS_PROXY_MAX_RETRIES'),\n proxyPreferCompressed: envBool('PDS_PROXY_PREFER_COMPRESSED'),\n\n // lexicon resolution\n lexiconDidAuthority: envStr('PDS_LEXICON_AUTHORITY_DID'),\n }\n}\n\nexport type ServerEnvironment = Partial<ReturnType<typeof readEnv>>\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pipethrough.d.ts","sourceRoot":"","sources":["../src/pipethrough.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAkB,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAe,QAAQ,EAAY,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AASjC,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,wBAAwB,EAIxB,SAAS,IAAI,eAAe,EAG7B,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAItC,eAAO,MAAM,YAAY,GAAI,KAAK,UAAU,KAAG,eAmF9C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,OAAO,EACZ,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CACR,wBAAwB,GAAG;IACzB,MAAM,EAAE,QAAQ,CAAA;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,CACF,CAsDA;AAKD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,MAAM,GACV,MAAM,CAUR;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAA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I,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpC;IAED,IAAI,KAAK,uBAER;CACF"}
@@ -60,7 +60,7 @@ const proxyHandler = (ctx) => {
60
60
  body,
61
61
  headers,
62
62
  };
63
- await pipethroughStream(ctx, dispatchOptions, (upstream) => {
63
+ await pipethroughStream(ctx, req, dispatchOptions, (upstream) => {
64
64
  res.status(upstream.statusCode);
65
65
  for (const [name, val] of responseHeaders(upstream.headers)) {
66
66
  res.setHeader(name, val);
@@ -113,7 +113,7 @@ async function pipethrough(ctx, req, options) {
113
113
  // while processing read-after-write operations.
114
114
  highWaterMark: 2 * 65536, // twice the default (64KiB)
115
115
  };
116
- const { headers, body } = await pipethroughRequest(ctx, dispatchOptions);
116
+ const { headers, body } = await pipethroughRequest(ctx, req, dispatchOptions);
117
117
  return {
118
118
  encoding: safeString(headers['content-type']) ?? 'application/json',
119
119
  headers: Object.fromEntries(responseHeaders(headers)),
@@ -185,7 +185,7 @@ exports.parseProxyHeader = parseProxyHeader;
185
185
  * more efficient than "pipethroughRequest" when a writable stream to pipe the
186
186
  * upstream response to is available.
187
187
  */
188
- async function pipethroughStream(ctx, dispatchOptions, successStreamFactory) {
188
+ async function pipethroughStream(ctx, req, dispatchOptions, successStreamFactory) {
189
189
  return new Promise((resolve, reject) => {
190
190
  void ctx.proxyAgent
191
191
  .stream(dispatchOptions, (upstream) => {
@@ -213,7 +213,7 @@ async function pipethroughStream(ctx, dispatchOptions, successStreamFactory) {
213
213
  // or writable stream errors. In the latter case, the promise will already
214
214
  // be resolved, and reject()ing it there after will have no effect. Those
215
215
  // error would still be logged by the successStreamFactory() function.
216
- .catch(handleUpstreamRequestError)
216
+ .catch(handleUpstreamRequestError.bind(req))
217
217
  .catch(reject);
218
218
  });
219
219
  }
@@ -221,12 +221,12 @@ async function pipethroughStream(ctx, dispatchOptions, successStreamFactory) {
221
221
  * Utility function that wraps the undici request() function and handles request
222
222
  * and response errors by wrapping them in XRPCError instances.
223
223
  */
224
- async function pipethroughRequest(ctx, dispatchOptions) {
224
+ async function pipethroughRequest(ctx, req, dispatchOptions) {
225
225
  // HandlerPipeThroughStream requires a readable stream to be returned, so we
226
226
  // use the (less efficient) request() function instead.
227
227
  const upstream = await ctx.proxyAgent
228
228
  .request(dispatchOptions)
229
- .catch(handleUpstreamRequestError);
229
+ .catch(handleUpstreamRequestError.bind(req));
230
230
  if (upstream.statusCode >= 400) {
231
231
  const parsed = await tryParsingError(upstream.headers, upstream.body);
232
232
  throw new PipethroughUpstreamError(upstream, parsed, {
@@ -236,11 +236,15 @@ async function pipethroughRequest(ctx, dispatchOptions) {
236
236
  return upstream;
237
237
  }
238
238
  function handleUpstreamRequestError(err, message = 'Upstream service unreachable') {
239
- logger_1.httpLogger.error({ err }, message);
239
+ const logger = isPinoHttpRequest(this) ? this.log : logger_1.httpLogger;
240
+ logger.error({ err }, message);
240
241
  throw new xrpc_server_1.XRPCError(xrpc_server_1.ResponseType.UpstreamFailure, message, undefined, {
241
242
  cause: err,
242
243
  });
243
244
  }
245
+ function isPinoHttpRequest(req) {
246
+ return typeof req.log?.error === 'function';
247
+ }
244
248
  // Request parsing/forwarding
245
249
  // -------------------
246
250
  function isJsonContentType(contentType) {
@@ -1 +1 @@
1
- {"version":3,"file":"pipethrough.js","sourceRoot":"","sources":["../src/pipethrough.ts"],"names":[],"mappings":";;;AAqIA,kCAgEC;AAKD,wCAcC;AAED,wCAcC;AA6ID,8CAGC;AAkED,kDAWC;AA8DD,oCAEC;AApgBD,6CAA6D;AAG7D,4CAKwB;AAExB,sDAU6B;AAC7B,yDAAsE;AACtE,6CAAiD;AAEjD,kDAAsD;AACtD,qCAAqC;AAE9B,MAAM,YAAY,GAAG,CAAC,GAAe,EAAmB,EAAE;IAC/D,MAAM,WAAW,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAqB;QACrE,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CA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C,CAAA;QACH;YACE,OAAO;gBACL,SAAS,EAAE,cAAc;gBACzB,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW;aACjC,CAAA;IACL,CAAC;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,GAAY,EAAsB,EAAE;IACtD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AAClD,CAAC,CAAA;AAED,SAAS,gBAAgB,CAAuB,GAAY;IAC1D,mBAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,oCAAoC,CAAC,CAAA;AAChE,CAAC;AAED,MAAa,wBAAyB,SAAQ,uBAAe;IAC3D,YACW,QAGR,EACD,OAA6C,EAC7C,OAAsB;QAEtB,MAAM,MAAM,GACV,QAAQ,CAAC,UAAU,KAAK,GAAG;YACzB,CAAC,CAAC,0BAAY,CAAC,eAAe;YAC9B,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAA;QAEzB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAZtD;;;;mBAAS,QAAQ;WAGhB;IAUH,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAA;IAC9C,CAAC;CACF;AAxBD,4DAwBC","sourcesContent":["import { IncomingHttpHeaders, ServerResponse } from 'node:http'\nimport { PassThrough, Readable, finished } from 'node:stream'\nimport { Request } from 'express'\nimport { Dispatcher } from 'undici'\nimport {\n decodeStream,\n getServiceEndpoint,\n omit,\n streamToNodeBuffer,\n} from '@atproto/common'\nimport { RpcPermissionMatch } from '@atproto/oauth-scopes'\nimport {\n CatchallHandler,\n HandlerPipeThroughBuffer,\n HandlerPipeThroughStream,\n InternalServerError,\n InvalidRequestError,\n ResponseType,\n XRPCError as XRPCServerError,\n excludeErrorResult,\n parseReqNsid,\n} from '@atproto/xrpc-server'\nimport { buildProxiedContentEncoding } from '@atproto-labs/xrpc-utils'\nimport { isAccessPrivileged } from './auth-scope'\nimport { AppContext } from './context'\nimport { chat, com, tools } from './lexicons/index.js'\nimport { httpLogger } from './logger'\n\nexport const proxyHandler = (ctx: AppContext): CatchallHandler => {\n const performAuth = ctx.authVerifier.authorization<RpcPermissionMatch>({\n authorize: (permissions, { params }) => permissions.assertRpc(params),\n })\n\n return async (req, res, next) => {\n // /!\\ Hot path\n try {\n if (\n req.method !== 'GET' &&\n req.method !== 'HEAD' &&\n req.method !== 'POST'\n ) {\n throw new XRPCServerError(\n ResponseType.InvalidRequest,\n 'XRPC requests only supports GET and POST',\n )\n }\n\n const body = req.method === 'POST' ? req : undefined\n if (body != null && !body.readable) {\n // Body was already consumed by a previous middleware\n throw new InternalServerError('Request body is not readable')\n }\n\n const lxm = parseReqNsid(req)\n if (PROTECTED_METHODS.has(lxm)) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const authResult = await performAuth({ req, res, params: { lxm, aud } })\n\n const { credentials } = excludeErrorResult(authResult)\n\n if (\n credentials.type === 'access' &&\n !isAccessPrivileged(credentials.scope) &&\n PRIVILEGED_METHODS.has(lxm)\n ) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const headers: IncomingHttpHeaders = {\n 'accept-encoding': req.headers['accept-encoding'] || 'identity',\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n 'content-type': body && req.headers['content-type'],\n 'content-encoding': body && req.headers['content-encoding'],\n 'content-length': body && req.headers['content-length'],\n\n authorization: `Bearer ${await ctx.serviceAuthJwt(credentials.did, aud, lxm)}`,\n }\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n body,\n headers,\n }\n\n await pipethroughStream(ctx, dispatchOptions, (upstream) => {\n res.status(upstream.statusCode)\n\n for (const [name, val] of responseHeaders(upstream.headers)) {\n res.setHeader(name, val)\n }\n\n // Note that we should not need to manually handle errors here (e.g. by\n // destroying the response), as the http server will handle them for us.\n res.on('error', logResponseError)\n\n // Tell undici to write the upstream response directly to the response\n return res\n })\n } catch (err) {\n next(err)\n }\n }\n}\n\nexport type PipethroughOptions = {\n /**\n * Specify the issuer (requester) for service auth. If not provided, no\n * authorization headers will be added to the request.\n */\n iss?: string\n\n /**\n * Override the audience for service auth. If not provided, the audience will\n * be determined based on the proxy service.\n */\n aud?: string\n\n /**\n * Override the lexicon method for service auth. If not provided, the lexicon\n * method will be determined based on the request path.\n */\n lxm?: string\n}\n\nexport async function pipethrough(\n ctx: AppContext,\n req: Request,\n options?: PipethroughOptions,\n): Promise<\n HandlerPipeThroughStream & {\n stream: Readable\n headers: Record<string, string>\n encoding: string\n }\n> {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n // pipethrough() is used from within xrpcServer handlers, which means that\n // the request body either has been parsed or is a readable stream that has\n // been piped for decoding & size limiting. Because of this, forwarding the\n // request body requires re-encoding it. Since we currently do not use\n // pipethrough() with procedures, proxying of request body is not\n // implemented.\n throw new InternalServerError(\n `Proxying of ${req.method} requests is not supported`,\n )\n }\n\n const lxm = parseReqNsid(req)\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n headers: {\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n // Because we sometimes need to interpret the response (e.g. during\n // read-after-write, through asPipeThroughBuffer()), we need to ask the\n // upstream server for an encoding that both the requester and the PDS can\n // understand. Since we might have to do the decoding ourselves, we will\n // use our own preferences (and weight) to negotiate the encoding.\n 'accept-encoding': buildProxiedContentEncoding(\n req.headers['accept-encoding'],\n ctx.cfg.proxy.preferCompressed,\n ),\n\n authorization: options?.iss\n ? `Bearer ${await ctx.serviceAuthJwt(options.iss, options.aud ?? aud, options.lxm ?? lxm)}`\n : undefined,\n },\n\n // Use a high water mark to buffer more data while performing async\n // operations before this stream is consumed. This is especially useful\n // while processing read-after-write operations.\n highWaterMark: 2 * 65536, // twice the default (64KiB)\n }\n\n const { headers, body } = await pipethroughRequest(ctx, dispatchOptions)\n\n return {\n encoding: safeString(headers['content-type']) ?? 'application/json',\n headers: Object.fromEntries(responseHeaders(headers)),\n stream: body,\n }\n}\n\n// Request setup/formatting\n// -------------------\n\nexport function computeProxyTo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): string {\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return proxyToHeader\n\n const service = defaultService(ctx, lxm)\n if (service.serviceInfo) {\n return `${service.serviceInfo.did}#${service.serviceId}`\n }\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport async function parseProxyInfo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): Promise<{ url: string; did: string }> {\n // /!\\ Hot path\n\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return parseProxyHeader(ctx, proxyToHeader)\n\n const { serviceInfo } = defaultService(ctx, lxm)\n if (serviceInfo) return serviceInfo\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport const parseProxyHeader = async (\n // Using subset of AppContext for testing purposes\n ctx: Pick<AppContext, 'cfg' | 'idResolver'>,\n proxyTo: string,\n): Promise<{ did: string; url: string }> => {\n // /!\\ Hot path\n\n const hashIndex = proxyTo.indexOf('#')\n\n if (hashIndex === 0) {\n throw new InvalidRequestError('no did specified in proxy header')\n }\n\n if (hashIndex === -1 || hashIndex === proxyTo.length - 1) {\n throw new InvalidRequestError('no service id specified in proxy header')\n }\n\n // More than one hash\n if (proxyTo.indexOf('#', hashIndex + 1) !== -1) {\n throw new InvalidRequestError('invalid proxy header format')\n }\n\n // Basic validation\n if (proxyTo.includes(' ')) {\n throw new InvalidRequestError('proxy header cannot contain spaces')\n }\n\n const did = proxyTo.slice(0, hashIndex)\n\n // Special case a configured appview, while still proxying correctly any other appview\n if (\n ctx.cfg.bskyAppView &&\n proxyTo === `${ctx.cfg.bskyAppView.did}#bsky_appview`\n ) {\n return { did, url: ctx.cfg.bskyAppView.url }\n }\n\n const didDoc = await ctx.idResolver.did.resolve(did)\n if (!didDoc) {\n throw new InvalidRequestError('could not resolve proxy did')\n }\n\n const serviceId = proxyTo.slice(hashIndex)\n const url = getServiceEndpoint(didDoc, { id: serviceId })\n if (!url) {\n throw new InvalidRequestError('could not resolve proxy did service url')\n }\n\n return { did, url }\n}\n\n/**\n * Utility function that wraps the undici stream() function and handles request\n * and response errors by wrapping them in XRPCError instances. This function is\n * more efficient than \"pipethroughRequest\" when a writable stream to pipe the\n * upstream response to is available.\n */\nasync function pipethroughStream(\n ctx: AppContext,\n dispatchOptions: Dispatcher.RequestOptions,\n successStreamFactory: Dispatcher.StreamFactory,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n void ctx.proxyAgent\n .stream(dispatchOptions, (upstream) => {\n if (upstream.statusCode >= 400) {\n const passThrough = new PassThrough()\n\n void tryParsingError(upstream.headers, passThrough).then((parsed) => {\n const xrpcError = new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n\n reject(xrpcError)\n }, reject)\n\n return passThrough\n }\n\n const writable = successStreamFactory(upstream)\n\n // As soon as the control was passed to the writable stream (i.e. by\n // returning the writable hereafter), pipethroughStream() is considered\n // to have succeeded. Any error occurring while writing upstream data to\n // the writable stream should be handled through the stream's error\n // state (i.e. successStreamFactory() must ensure that error events on\n // the returned writable will be handled).\n resolve()\n\n return writable\n })\n // The following catch block will be triggered with either network errors\n // or writable stream errors. In the latter case, the promise will already\n // be resolved, and reject()ing it there after will have no effect. Those\n // error would still be logged by the successStreamFactory() function.\n .catch(handleUpstreamRequestError)\n .catch(reject)\n })\n}\n\n/**\n * Utility function that wraps the undici request() function and handles request\n * and response errors by wrapping them in XRPCError instances.\n */\nasync function pipethroughRequest(\n ctx: AppContext,\n dispatchOptions: Dispatcher.RequestOptions,\n) {\n // HandlerPipeThroughStream requires a readable stream to be returned, so we\n // use the (less efficient) request() function instead.\n\n const upstream = await ctx.proxyAgent\n .request(dispatchOptions)\n .catch(handleUpstreamRequestError)\n\n if (upstream.statusCode >= 400) {\n const parsed = await tryParsingError(upstream.headers, upstream.body)\n\n throw new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n }\n\n return upstream\n}\n\nfunction handleUpstreamRequestError(\n err: unknown,\n message = 'Upstream service unreachable',\n): never {\n httpLogger.error({ err }, message)\n throw new XRPCServerError(ResponseType.UpstreamFailure, message, undefined, {\n cause: err,\n })\n}\n\n// Request parsing/forwarding\n// -------------------\n\nexport function isJsonContentType(contentType?: string): boolean | undefined {\n if (!contentType) return undefined\n return /application\\/(?:\\w+\\+)?json/i.test(contentType)\n}\n\nasync function tryParsingError(\n headers: IncomingHttpHeaders,\n readable: Readable,\n): Promise<{ error?: string; message?: string }> {\n if (isJsonContentType(headers['content-type']) === false) {\n // We don't known how to parse non JSON content types so we can discard the\n // whole response.\n\n // Since we don't care about the response, we would normally just destroy\n // the stream. However, if the underlying HTTP connection is an HTTP/1.1\n // connection, this also destroys the underlying (keep-alive) TCP socket. In\n // order to avoid destroying the TCP socket, while avoiding the cost of\n // consuming too much IO, we give it a chance to finish first.\n\n // @NOTE we need to listen (and ignore) \"error\" events, otherwise the\n // process could crash (since we drain the stream asynchronously here). This\n // is performed through the \"finished\" call below.\n\n const to = setTimeout(() => {\n readable.destroy()\n }, 100)\n finished(readable, (_err) => {\n clearTimeout(to)\n })\n readable.resume()\n\n return {}\n }\n\n try {\n const buffer = await bufferUpstreamResponse(\n readable,\n headers['content-encoding'],\n )\n\n const errInfo: unknown = JSON.parse(buffer.toString('utf8'))\n return {\n error: safeString(errInfo?.['error']),\n message: safeString(errInfo?.['message']),\n }\n } catch (err) {\n // Failed to read, decode, buffer or parse. No big deal.\n return {}\n }\n}\n\nasync function bufferUpstreamResponse(\n readable: Readable,\n contentEncoding?: string | string[],\n): Promise<Buffer> {\n try {\n return await streamToNodeBuffer(decodeStream(readable, contentEncoding))\n } catch (err) {\n if (!readable.destroyed) readable.destroy()\n\n throw new XRPCServerError(\n ResponseType.UpstreamFailure,\n err instanceof TypeError ? err.message : 'unable to decode request body',\n undefined,\n { cause: err },\n )\n }\n}\n\nexport async function asPipeThroughBuffer(\n input: HandlerPipeThroughStream,\n): Promise<HandlerPipeThroughBuffer> {\n return {\n buffer: await bufferUpstreamResponse(\n input.stream,\n input.headers?.['content-encoding'],\n ),\n headers: omit(input.headers, ['content-encoding', 'content-length']),\n encoding: input.encoding,\n }\n}\n\n// Response parsing/forwarding\n// -------------------\n\nconst RES_HEADERS_TO_FORWARD = [\n 'atproto-repo-rev',\n 'atproto-content-labelers',\n 'retry-after',\n]\n\nfunction* responseHeaders(\n headers: IncomingHttpHeaders,\n includeContentHeaders = true,\n): Generator<[string, string]> {\n if (includeContentHeaders) {\n const length = headers['content-length']\n if (length) yield ['content-length', length]\n\n const encoding = headers['content-encoding']\n if (encoding) yield ['content-encoding', encoding]\n\n const type = headers['content-type']\n if (type) yield ['content-type', type]\n\n const language = headers['content-language']\n if (language) yield ['content-language', language]\n }\n\n for (let i = 0; i < RES_HEADERS_TO_FORWARD.length; i++) {\n const name = RES_HEADERS_TO_FORWARD[i]\n const val = headers[name]\n\n if (val != null) {\n const value: string = Array.isArray(val) ? val.join(',') : val\n yield [name, value]\n }\n }\n}\n\n// Utils\n// -------------------\n\n/**\n * Performs lexicon method matching on a set of methods,\n * taking into account that they are treated case-insensitively.\n */\nexport class LxmSet {\n private inner: Set<string>\n private original: Iterable<string>\n constructor(items: Iterable<string>) {\n this.inner = new Set(Array.from(items, normalizeLxm))\n this.original = items\n }\n has(lxm: string) {\n return this.inner.has(normalizeLxm(lxm))\n }\n *[Symbol.iterator](): Iterator<string> {\n yield* this.original\n }\n}\n\nexport function normalizeLxm(lxm: string) {\n return lxm.toLowerCase()\n}\n\nexport const CHAT_BSKY_METHODS = new LxmSet([\n chat.bsky.actor.deleteAccount.$lxm,\n chat.bsky.actor.exportAccountData.$lxm,\n chat.bsky.convo.deleteMessageForSelf.$lxm,\n chat.bsky.convo.getConvo.$lxm,\n chat.bsky.convo.getConvoForMembers.$lxm,\n chat.bsky.convo.getLog.$lxm,\n chat.bsky.convo.getMessages.$lxm,\n chat.bsky.convo.leaveConvo.$lxm,\n chat.bsky.convo.listConvos.$lxm,\n chat.bsky.convo.muteConvo.$lxm,\n chat.bsky.convo.sendMessage.$lxm,\n chat.bsky.convo.sendMessageBatch.$lxm,\n chat.bsky.convo.unmuteConvo.$lxm,\n chat.bsky.convo.updateRead.$lxm,\n])\n\nexport const PRIVILEGED_METHODS = new LxmSet([\n ...CHAT_BSKY_METHODS,\n com.atproto.server.createAccount.$lxm,\n])\n\n// These endpoints are related to account management and must be used directly,\n// not proxied or service-authed. Service auth may be utilized between PDS and\n// entryway for these methods.\nexport const PROTECTED_METHODS = new LxmSet([\n com.atproto.admin.sendEmail.$lxm,\n com.atproto.identity.requestPlcOperationSignature.$lxm,\n com.atproto.identity.signPlcOperation.$lxm,\n com.atproto.identity.updateHandle.$lxm,\n com.atproto.server.activateAccount.$lxm,\n com.atproto.server.confirmEmail.$lxm,\n com.atproto.server.createAppPassword.$lxm,\n com.atproto.server.deactivateAccount.$lxm,\n com.atproto.server.getAccountInviteCodes.$lxm,\n com.atproto.server.getSession.$lxm,\n com.atproto.server.listAppPasswords.$lxm,\n com.atproto.server.requestAccountDelete.$lxm,\n com.atproto.server.requestEmailConfirmation.$lxm,\n com.atproto.server.requestEmailUpdate.$lxm,\n com.atproto.server.revokeAppPassword.$lxm,\n com.atproto.server.updateEmail.$lxm,\n])\n\nconst defaultService = (\n ctx: AppContext,\n nsid: string,\n): {\n serviceId: string\n serviceInfo: { url: string; did: string } | null\n} => {\n switch (nsid) {\n case tools.ozone.communication.createTemplate.$lxm:\n case tools.ozone.communication.deleteTemplate.$lxm:\n case tools.ozone.communication.listTemplates.$lxm:\n case tools.ozone.communication.updateTemplate.$lxm:\n case tools.ozone.moderation.cancelScheduledActions.$lxm:\n case tools.ozone.moderation.emitEvent.$lxm:\n case tools.ozone.moderation.getAccountTimeline.$lxm:\n case tools.ozone.moderation.getEvent.$lxm:\n case tools.ozone.moderation.getRecord.$lxm:\n case tools.ozone.moderation.getRepo.$lxm:\n case tools.ozone.moderation.listScheduledActions.$lxm:\n case tools.ozone.moderation.queryEvents.$lxm:\n case tools.ozone.moderation.queryStatuses.$lxm:\n case tools.ozone.moderation.scheduleAction.$lxm:\n case tools.ozone.moderation.searchRepos.$lxm:\n case tools.ozone.safelink.addRule.$lxm:\n case tools.ozone.safelink.queryEvents.$lxm:\n case tools.ozone.safelink.queryRules.$lxm:\n case tools.ozone.safelink.removeRule.$lxm:\n case tools.ozone.safelink.updateRule.$lxm:\n case tools.ozone.team.addMember.$lxm:\n case tools.ozone.team.deleteMember.$lxm:\n case tools.ozone.team.listMembers.$lxm:\n case tools.ozone.team.updateMember.$lxm:\n case tools.ozone.verification.grantVerifications.$lxm:\n case tools.ozone.verification.listVerifications.$lxm:\n case tools.ozone.verification.revokeVerifications.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.modService,\n }\n case com.atproto.moderation.createReport.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.reportService,\n }\n default:\n return {\n serviceId: 'bsky_appview',\n serviceInfo: ctx.cfg.bskyAppView,\n }\n }\n}\n\nconst safeString = (str: unknown): string | undefined => {\n return typeof str === 'string' ? str : undefined\n}\n\nfunction logResponseError(this: ServerResponse, err: unknown): void {\n httpLogger.warn({ err }, 'error forwarding upstream response')\n}\n\nexport class PipethroughUpstreamError extends XRPCServerError {\n constructor(\n readonly upstream: {\n statusCode: number\n headers: IncomingHttpHeaders\n },\n payload: { message?: string; error?: string },\n options?: ErrorOptions,\n ) {\n const status =\n upstream.statusCode === 500\n ? ResponseType.UpstreamFailure\n : upstream.statusCode\n\n super(status, payload.message, payload.error, options)\n }\n\n get headers(): Record<string, string> {\n return Object.fromEntries(responseHeaders(this.upstream.headers, false))\n }\n\n get error() {\n return this.customErrorName ?? this.typeName\n }\n}\n"]}
1
+ {"version":3,"file":"pipethrough.js","sourceRoot":"","sources":["../src/pipethrough.ts"],"names":[],"mappings":";;;AAqIA,kCAgEC;AAKD,wCAcC;AAED,wCAcC;AAuJD,8CAGC;AAkED,kDAWC;AA8DD,oCAEC;AA9gBD,6CAA6D;AAG7D,4CAKwB;AAExB,sDAU6B;AAC7B,yDAAsE;AACtE,6CAAiD;AAEjD,kDAAsD;AACtD,qCAAqC;AAE9B,MAAM,YAAY,GAAG,CAAC,GAAe,EAAmB,EAAE;IAC/D,MAAM,WAAW,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAqB;QACrE,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC;KACtE,CAAC,CAAA;IAEF,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC9B,eAAe;QACf,IAAI,CAAC;YACH,IACE,GAAG,CAAC,MAAM,KAAK,KAAK;gBACpB,GAAG,CAAC,MAAM,KAAK,MAAM;gBACrB,GAAG,CAAC,MAAM,KAAK,MAAM,EACrB,CAAC;gBACD,MAAM,IAAI,uBAAe,CACvB,0BAAY,CAAC,cAAc,EAC3B,0CAA0C,CAC3C,CAAA;YACH,CAAC;YAED,MAAM,IAAI,GAAG,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gBACL,SAAS,EAAE,cAAc;gBACzB,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW;aACjC,CAAA;IACL,CAAC;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,GAAY,EAAsB,EAAE;IACtD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AAClD,CAAC,CAAA;AAED,SAAS,gBAAgB,CAAuB,GAAY;IAC1D,mBAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,oCAAoC,CAAC,CAAA;AAChE,CAAC;AAED,MAAa,wBAAyB,SAAQ,uBAAe;IAC3D,YACW,QAGR,EACD,OAA6C,EAC7C,OAAsB;QAEtB,MAAM,MAAM,GACV,QAAQ,CAAC,UAAU,KAAK,GAAG;YACzB,CAAC,CAAC,0BAAY,CAAC,eAAe;YAC9B,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAA;QAEzB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAZtD;;;;mBAAS,QAAQ;WAGhB;IAUH,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAA;IAC9C,CAAC;CACF;AAxBD,4DAwBC","sourcesContent":["import { IncomingHttpHeaders, ServerResponse } from 'node:http'\nimport { PassThrough, Readable, finished } from 'node:stream'\nimport { Request } from 'express'\nimport { Dispatcher } from 'undici'\nimport {\n decodeStream,\n getServiceEndpoint,\n omit,\n streamToNodeBuffer,\n} from '@atproto/common'\nimport { RpcPermissionMatch } from '@atproto/oauth-scopes'\nimport {\n CatchallHandler,\n HandlerPipeThroughBuffer,\n HandlerPipeThroughStream,\n InternalServerError,\n InvalidRequestError,\n ResponseType,\n XRPCError as XRPCServerError,\n excludeErrorResult,\n parseReqNsid,\n} from '@atproto/xrpc-server'\nimport { buildProxiedContentEncoding } from '@atproto-labs/xrpc-utils'\nimport { isAccessPrivileged } from './auth-scope'\nimport { AppContext } from './context'\nimport { chat, com, tools } from './lexicons/index.js'\nimport { httpLogger } from './logger'\n\nexport const proxyHandler = (ctx: AppContext): CatchallHandler => {\n const performAuth = ctx.authVerifier.authorization<RpcPermissionMatch>({\n authorize: (permissions, { params }) => permissions.assertRpc(params),\n })\n\n return async (req, res, next) => {\n // /!\\ Hot path\n try {\n if (\n req.method !== 'GET' &&\n req.method !== 'HEAD' &&\n req.method !== 'POST'\n ) {\n throw new XRPCServerError(\n ResponseType.InvalidRequest,\n 'XRPC requests only supports GET and POST',\n )\n }\n\n const body = req.method === 'POST' ? req : undefined\n if (body != null && !body.readable) {\n // Body was already consumed by a previous middleware\n throw new InternalServerError('Request body is not readable')\n }\n\n const lxm = parseReqNsid(req)\n if (PROTECTED_METHODS.has(lxm)) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const authResult = await performAuth({ req, res, params: { lxm, aud } })\n\n const { credentials } = excludeErrorResult(authResult)\n\n if (\n credentials.type === 'access' &&\n !isAccessPrivileged(credentials.scope) &&\n PRIVILEGED_METHODS.has(lxm)\n ) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const headers: IncomingHttpHeaders = {\n 'accept-encoding': req.headers['accept-encoding'] || 'identity',\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n 'content-type': body && req.headers['content-type'],\n 'content-encoding': body && req.headers['content-encoding'],\n 'content-length': body && req.headers['content-length'],\n\n authorization: `Bearer ${await ctx.serviceAuthJwt(credentials.did, aud, lxm)}`,\n }\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n body,\n headers,\n }\n\n await pipethroughStream(ctx, req, dispatchOptions, (upstream) => {\n res.status(upstream.statusCode)\n\n for (const [name, val] of responseHeaders(upstream.headers)) {\n res.setHeader(name, val)\n }\n\n // Note that we should not need to manually handle errors here (e.g. by\n // destroying the response), as the http server will handle them for us.\n res.on('error', logResponseError)\n\n // Tell undici to write the upstream response directly to the response\n return res\n })\n } catch (err) {\n next(err)\n }\n }\n}\n\nexport type PipethroughOptions = {\n /**\n * Specify the issuer (requester) for service auth. If not provided, no\n * authorization headers will be added to the request.\n */\n iss?: string\n\n /**\n * Override the audience for service auth. If not provided, the audience will\n * be determined based on the proxy service.\n */\n aud?: string\n\n /**\n * Override the lexicon method for service auth. If not provided, the lexicon\n * method will be determined based on the request path.\n */\n lxm?: string\n}\n\nexport async function pipethrough(\n ctx: AppContext,\n req: Request,\n options?: PipethroughOptions,\n): Promise<\n HandlerPipeThroughStream & {\n stream: Readable\n headers: Record<string, string>\n encoding: string\n }\n> {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n // pipethrough() is used from within xrpcServer handlers, which means that\n // the request body either has been parsed or is a readable stream that has\n // been piped for decoding & size limiting. Because of this, forwarding the\n // request body requires re-encoding it. Since we currently do not use\n // pipethrough() with procedures, proxying of request body is not\n // implemented.\n throw new InternalServerError(\n `Proxying of ${req.method} requests is not supported`,\n )\n }\n\n const lxm = parseReqNsid(req)\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n headers: {\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n // Because we sometimes need to interpret the response (e.g. during\n // read-after-write, through asPipeThroughBuffer()), we need to ask the\n // upstream server for an encoding that both the requester and the PDS can\n // understand. Since we might have to do the decoding ourselves, we will\n // use our own preferences (and weight) to negotiate the encoding.\n 'accept-encoding': buildProxiedContentEncoding(\n req.headers['accept-encoding'],\n ctx.cfg.proxy.preferCompressed,\n ),\n\n authorization: options?.iss\n ? `Bearer ${await ctx.serviceAuthJwt(options.iss, options.aud ?? aud, options.lxm ?? lxm)}`\n : undefined,\n },\n\n // Use a high water mark to buffer more data while performing async\n // operations before this stream is consumed. This is especially useful\n // while processing read-after-write operations.\n highWaterMark: 2 * 65536, // twice the default (64KiB)\n }\n\n const { headers, body } = await pipethroughRequest(ctx, req, dispatchOptions)\n\n return {\n encoding: safeString(headers['content-type']) ?? 'application/json',\n headers: Object.fromEntries(responseHeaders(headers)),\n stream: body,\n }\n}\n\n// Request setup/formatting\n// -------------------\n\nexport function computeProxyTo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): string {\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return proxyToHeader\n\n const service = defaultService(ctx, lxm)\n if (service.serviceInfo) {\n return `${service.serviceInfo.did}#${service.serviceId}`\n }\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport async function parseProxyInfo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): Promise<{ url: string; did: string }> {\n // /!\\ Hot path\n\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return parseProxyHeader(ctx, proxyToHeader)\n\n const { serviceInfo } = defaultService(ctx, lxm)\n if (serviceInfo) return serviceInfo\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport const parseProxyHeader = async (\n // Using subset of AppContext for testing purposes\n ctx: Pick<AppContext, 'cfg' | 'idResolver'>,\n proxyTo: string,\n): Promise<{ did: string; url: string }> => {\n // /!\\ Hot path\n\n const hashIndex = proxyTo.indexOf('#')\n\n if (hashIndex === 0) {\n throw new InvalidRequestError('no did specified in proxy header')\n }\n\n if (hashIndex === -1 || hashIndex === proxyTo.length - 1) {\n throw new InvalidRequestError('no service id specified in proxy header')\n }\n\n // More than one hash\n if (proxyTo.indexOf('#', hashIndex + 1) !== -1) {\n throw new InvalidRequestError('invalid proxy header format')\n }\n\n // Basic validation\n if (proxyTo.includes(' ')) {\n throw new InvalidRequestError('proxy header cannot contain spaces')\n }\n\n const did = proxyTo.slice(0, hashIndex)\n\n // Special case a configured appview, while still proxying correctly any other appview\n if (\n ctx.cfg.bskyAppView &&\n proxyTo === `${ctx.cfg.bskyAppView.did}#bsky_appview`\n ) {\n return { did, url: ctx.cfg.bskyAppView.url }\n }\n\n const didDoc = await ctx.idResolver.did.resolve(did)\n if (!didDoc) {\n throw new InvalidRequestError('could not resolve proxy did')\n }\n\n const serviceId = proxyTo.slice(hashIndex)\n const url = getServiceEndpoint(didDoc, { id: serviceId })\n if (!url) {\n throw new InvalidRequestError('could not resolve proxy did service url')\n }\n\n return { did, url }\n}\n\n/**\n * Utility function that wraps the undici stream() function and handles request\n * and response errors by wrapping them in XRPCError instances. This function is\n * more efficient than \"pipethroughRequest\" when a writable stream to pipe the\n * upstream response to is available.\n */\nasync function pipethroughStream(\n ctx: AppContext,\n req: Request,\n dispatchOptions: Dispatcher.RequestOptions,\n successStreamFactory: Dispatcher.StreamFactory,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n void ctx.proxyAgent\n .stream(dispatchOptions, (upstream) => {\n if (upstream.statusCode >= 400) {\n const passThrough = new PassThrough()\n\n void tryParsingError(upstream.headers, passThrough).then((parsed) => {\n const xrpcError = new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n\n reject(xrpcError)\n }, reject)\n\n return passThrough\n }\n\n const writable = successStreamFactory(upstream)\n\n // As soon as the control was passed to the writable stream (i.e. by\n // returning the writable hereafter), pipethroughStream() is considered\n // to have succeeded. Any error occurring while writing upstream data to\n // the writable stream should be handled through the stream's error\n // state (i.e. successStreamFactory() must ensure that error events on\n // the returned writable will be handled).\n resolve()\n\n return writable\n })\n // The following catch block will be triggered with either network errors\n // or writable stream errors. In the latter case, the promise will already\n // be resolved, and reject()ing it there after will have no effect. Those\n // error would still be logged by the successStreamFactory() function.\n .catch(handleUpstreamRequestError.bind(req))\n .catch(reject)\n })\n}\n\n/**\n * Utility function that wraps the undici request() function and handles request\n * and response errors by wrapping them in XRPCError instances.\n */\nasync function pipethroughRequest(\n ctx: AppContext,\n req: Request,\n dispatchOptions: Dispatcher.RequestOptions,\n) {\n // HandlerPipeThroughStream requires a readable stream to be returned, so we\n // use the (less efficient) request() function instead.\n\n const upstream = await ctx.proxyAgent\n .request(dispatchOptions)\n .catch(handleUpstreamRequestError.bind(req))\n\n if (upstream.statusCode >= 400) {\n const parsed = await tryParsingError(upstream.headers, upstream.body)\n\n throw new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n }\n\n return upstream\n}\n\nfunction handleUpstreamRequestError(\n this: Request,\n err: unknown,\n message = 'Upstream service unreachable',\n): never {\n const logger = isPinoHttpRequest(this) ? this.log : httpLogger\n logger.error({ err }, message)\n throw new XRPCServerError(ResponseType.UpstreamFailure, message, undefined, {\n cause: err,\n })\n}\n\nfunction isPinoHttpRequest(req: Request): req is Request & {\n log: { error: (obj: unknown, msg: string) => void }\n} {\n return typeof (req as { log?: any }).log?.error === 'function'\n}\n\n// Request parsing/forwarding\n// -------------------\n\nexport function isJsonContentType(contentType?: string): boolean | undefined {\n if (!contentType) return undefined\n return /application\\/(?:\\w+\\+)?json/i.test(contentType)\n}\n\nasync function tryParsingError(\n headers: IncomingHttpHeaders,\n readable: Readable,\n): Promise<{ error?: string; message?: string }> {\n if (isJsonContentType(headers['content-type']) === false) {\n // We don't known how to parse non JSON content types so we can discard the\n // whole response.\n\n // Since we don't care about the response, we would normally just destroy\n // the stream. However, if the underlying HTTP connection is an HTTP/1.1\n // connection, this also destroys the underlying (keep-alive) TCP socket. In\n // order to avoid destroying the TCP socket, while avoiding the cost of\n // consuming too much IO, we give it a chance to finish first.\n\n // @NOTE we need to listen (and ignore) \"error\" events, otherwise the\n // process could crash (since we drain the stream asynchronously here). This\n // is performed through the \"finished\" call below.\n\n const to = setTimeout(() => {\n readable.destroy()\n }, 100)\n finished(readable, (_err) => {\n clearTimeout(to)\n })\n readable.resume()\n\n return {}\n }\n\n try {\n const buffer = await bufferUpstreamResponse(\n readable,\n headers['content-encoding'],\n )\n\n const errInfo: unknown = JSON.parse(buffer.toString('utf8'))\n return {\n error: safeString(errInfo?.['error']),\n message: safeString(errInfo?.['message']),\n }\n } catch (err) {\n // Failed to read, decode, buffer or parse. No big deal.\n return {}\n }\n}\n\nasync function bufferUpstreamResponse(\n readable: Readable,\n contentEncoding?: string | string[],\n): Promise<Buffer> {\n try {\n return await streamToNodeBuffer(decodeStream(readable, contentEncoding))\n } catch (err) {\n if (!readable.destroyed) readable.destroy()\n\n throw new XRPCServerError(\n ResponseType.UpstreamFailure,\n err instanceof TypeError ? err.message : 'unable to decode request body',\n undefined,\n { cause: err },\n )\n }\n}\n\nexport async function asPipeThroughBuffer(\n input: HandlerPipeThroughStream,\n): Promise<HandlerPipeThroughBuffer> {\n return {\n buffer: await bufferUpstreamResponse(\n input.stream,\n input.headers?.['content-encoding'],\n ),\n headers: omit(input.headers, ['content-encoding', 'content-length']),\n encoding: input.encoding,\n }\n}\n\n// Response parsing/forwarding\n// -------------------\n\nconst RES_HEADERS_TO_FORWARD = [\n 'atproto-repo-rev',\n 'atproto-content-labelers',\n 'retry-after',\n]\n\nfunction* responseHeaders(\n headers: IncomingHttpHeaders,\n includeContentHeaders = true,\n): Generator<[string, string]> {\n if (includeContentHeaders) {\n const length = headers['content-length']\n if (length) yield ['content-length', length]\n\n const encoding = headers['content-encoding']\n if (encoding) yield ['content-encoding', encoding]\n\n const type = headers['content-type']\n if (type) yield ['content-type', type]\n\n const language = headers['content-language']\n if (language) yield ['content-language', language]\n }\n\n for (let i = 0; i < RES_HEADERS_TO_FORWARD.length; i++) {\n const name = RES_HEADERS_TO_FORWARD[i]\n const val = headers[name]\n\n if (val != null) {\n const value: string = Array.isArray(val) ? val.join(',') : val\n yield [name, value]\n }\n }\n}\n\n// Utils\n// -------------------\n\n/**\n * Performs lexicon method matching on a set of methods,\n * taking into account that they are treated case-insensitively.\n */\nexport class LxmSet {\n private inner: Set<string>\n private original: Iterable<string>\n constructor(items: Iterable<string>) {\n this.inner = new Set(Array.from(items, normalizeLxm))\n this.original = items\n }\n has(lxm: string) {\n return this.inner.has(normalizeLxm(lxm))\n }\n *[Symbol.iterator](): Iterator<string> {\n yield* this.original\n }\n}\n\nexport function normalizeLxm(lxm: string) {\n return lxm.toLowerCase()\n}\n\nexport const CHAT_BSKY_METHODS = new LxmSet([\n chat.bsky.actor.deleteAccount.$lxm,\n chat.bsky.actor.exportAccountData.$lxm,\n chat.bsky.convo.deleteMessageForSelf.$lxm,\n chat.bsky.convo.getConvo.$lxm,\n chat.bsky.convo.getConvoForMembers.$lxm,\n chat.bsky.convo.getLog.$lxm,\n chat.bsky.convo.getMessages.$lxm,\n chat.bsky.convo.leaveConvo.$lxm,\n chat.bsky.convo.listConvos.$lxm,\n chat.bsky.convo.muteConvo.$lxm,\n chat.bsky.convo.sendMessage.$lxm,\n chat.bsky.convo.sendMessageBatch.$lxm,\n chat.bsky.convo.unmuteConvo.$lxm,\n chat.bsky.convo.updateRead.$lxm,\n])\n\nexport const PRIVILEGED_METHODS = new LxmSet([\n ...CHAT_BSKY_METHODS,\n com.atproto.server.createAccount.$lxm,\n])\n\n// These endpoints are related to account management and must be used directly,\n// not proxied or service-authed. Service auth may be utilized between PDS and\n// entryway for these methods.\nexport const PROTECTED_METHODS = new LxmSet([\n com.atproto.admin.sendEmail.$lxm,\n com.atproto.identity.requestPlcOperationSignature.$lxm,\n com.atproto.identity.signPlcOperation.$lxm,\n com.atproto.identity.updateHandle.$lxm,\n com.atproto.server.activateAccount.$lxm,\n com.atproto.server.confirmEmail.$lxm,\n com.atproto.server.createAppPassword.$lxm,\n com.atproto.server.deactivateAccount.$lxm,\n com.atproto.server.getAccountInviteCodes.$lxm,\n com.atproto.server.getSession.$lxm,\n com.atproto.server.listAppPasswords.$lxm,\n com.atproto.server.requestAccountDelete.$lxm,\n com.atproto.server.requestEmailConfirmation.$lxm,\n com.atproto.server.requestEmailUpdate.$lxm,\n com.atproto.server.revokeAppPassword.$lxm,\n com.atproto.server.updateEmail.$lxm,\n])\n\nconst defaultService = (\n ctx: AppContext,\n nsid: string,\n): {\n serviceId: string\n serviceInfo: { url: string; did: string } | null\n} => {\n switch (nsid) {\n case tools.ozone.communication.createTemplate.$lxm:\n case tools.ozone.communication.deleteTemplate.$lxm:\n case tools.ozone.communication.listTemplates.$lxm:\n case tools.ozone.communication.updateTemplate.$lxm:\n case tools.ozone.moderation.cancelScheduledActions.$lxm:\n case tools.ozone.moderation.emitEvent.$lxm:\n case tools.ozone.moderation.getAccountTimeline.$lxm:\n case tools.ozone.moderation.getEvent.$lxm:\n case tools.ozone.moderation.getRecord.$lxm:\n case tools.ozone.moderation.getRepo.$lxm:\n case tools.ozone.moderation.listScheduledActions.$lxm:\n case tools.ozone.moderation.queryEvents.$lxm:\n case tools.ozone.moderation.queryStatuses.$lxm:\n case tools.ozone.moderation.scheduleAction.$lxm:\n case tools.ozone.moderation.searchRepos.$lxm:\n case tools.ozone.safelink.addRule.$lxm:\n case tools.ozone.safelink.queryEvents.$lxm:\n case tools.ozone.safelink.queryRules.$lxm:\n case tools.ozone.safelink.removeRule.$lxm:\n case tools.ozone.safelink.updateRule.$lxm:\n case tools.ozone.team.addMember.$lxm:\n case tools.ozone.team.deleteMember.$lxm:\n case tools.ozone.team.listMembers.$lxm:\n case tools.ozone.team.updateMember.$lxm:\n case tools.ozone.verification.grantVerifications.$lxm:\n case tools.ozone.verification.listVerifications.$lxm:\n case tools.ozone.verification.revokeVerifications.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.modService,\n }\n case com.atproto.moderation.createReport.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.reportService,\n }\n default:\n return {\n serviceId: 'bsky_appview',\n serviceInfo: ctx.cfg.bskyAppView,\n }\n }\n}\n\nconst safeString = (str: unknown): string | undefined => {\n return typeof str === 'string' ? str : undefined\n}\n\nfunction logResponseError(this: ServerResponse, err: unknown): void {\n httpLogger.warn({ err }, 'error forwarding upstream response')\n}\n\nexport class PipethroughUpstreamError extends XRPCServerError {\n constructor(\n readonly upstream: {\n statusCode: number\n headers: IncomingHttpHeaders\n },\n payload: { message?: string; error?: string },\n options?: ErrorOptions,\n ) {\n const status =\n upstream.statusCode === 500\n ? ResponseType.UpstreamFailure\n : upstream.statusCode\n\n super(status, payload.message, payload.error, options)\n }\n\n get headers(): Record<string, string> {\n return Object.fromEntries(responseHeaders(this.upstream.headers, false))\n }\n\n get error() {\n return this.customErrorName ?? this.typeName\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/pds",
3
- "version": "0.4.218",
3
+ "version": "0.4.219",
4
4
  "license": "MIT",
5
5
  "description": "Reference implementation of atproto Personal Data Server (PDS)",
6
6
  "keywords": [
@@ -52,17 +52,17 @@
52
52
  "@atproto/aws": "^0.2.32",
53
53
  "@atproto/common": "^0.5.16",
54
54
  "@atproto/crypto": "^0.4.5",
55
- "@atproto/lex": "^0.0.24",
55
+ "@atproto/identity": "^0.4.12",
56
+ "@atproto/lex": "^0.0.25",
56
57
  "@atproto/lex-cbor": "^0.0.16",
57
58
  "@atproto/lex-data": "^0.0.15",
58
- "@atproto/identity": "^0.4.12",
59
- "@atproto/oauth-provider": "^0.15.16",
59
+ "@atproto/lex-json": "^0.0.16",
60
+ "@atproto/oauth-provider": "^0.16.0",
60
61
  "@atproto/oauth-scopes": "^0.3.2",
61
62
  "@atproto/repo": "^0.9.1",
62
- "@atproto/lex-json": "^0.0.15",
63
- "@atproto/syntax": "^0.5.3",
63
+ "@atproto/syntax": "^0.5.4",
64
64
  "@atproto/xrpc": "^0.7.7",
65
- "@atproto/xrpc-server": "^0.10.19"
65
+ "@atproto/xrpc-server": "^0.10.20"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@atproto/pds-entryway": "npm:@atproto/pds@0.3.0-entryway.3",
@@ -80,10 +80,10 @@
80
80
  "ts-node": "^10.8.2",
81
81
  "typescript": "^5.6.3",
82
82
  "ws": "^8.12.0",
83
- "@atproto/api": "^0.19.7",
84
- "@atproto/lex-document": "^0.0.19",
85
- "@atproto/oauth-client-browser-example": "^0.0.10",
86
- "@atproto/bsky": "^0.0.225"
83
+ "@atproto/api": "^0.19.8",
84
+ "@atproto/bsky": "^0.0.226",
85
+ "@atproto/lex-document": "^0.0.20",
86
+ "@atproto/oauth-client-browser-example": "^0.0.10"
87
87
  },
88
88
  "scripts": {
89
89
  "codegen": "lex build --override --indexFile --lexicons ../../lexicons",
@@ -278,18 +278,28 @@ export const envToCfg = (env: ServerEnvironment): ServerConfig => {
278
278
  colors: {
279
279
  light: env.lightColor,
280
280
  dark: env.darkColor,
281
+
282
+ contrastSaturation: env.contrastSaturation,
283
+
281
284
  primary: env.primaryColor,
282
285
  primaryContrast: env.primaryColorContrast,
283
286
  primaryHue: env.primaryColorHue,
287
+
284
288
  error: env.errorColor,
285
289
  errorContrast: env.errorColorContrast,
286
290
  errorHue: env.errorColorHue,
287
- success: env.successColor,
288
- successContrast: env.successColorContrast,
289
- successHue: env.successColorHue,
291
+
290
292
  warning: env.warningColor,
291
293
  warningContrast: env.warningColorContrast,
292
294
  warningHue: env.warningColorHue,
295
+
296
+ info: env.infoColor,
297
+ infoContrast: env.infoColorContrast,
298
+ infoHue: env.infoColorHue,
299
+
300
+ success: env.successColor,
301
+ successContrast: env.successColorContrast,
302
+ successHue: env.successColorHue,
293
303
  },
294
304
  links: [
295
305
  {
package/src/config/env.ts CHANGED
@@ -30,6 +30,7 @@ export function readEnv() {
30
30
  // branding
31
31
  lightColor: envStr('PDS_LIGHT_COLOR'),
32
32
  darkColor: envStr('PDS_DARK_COLOR'),
33
+ contrastSaturation: envInt('PDS_CONTRAST_SATURATION'),
33
34
  primaryColor: envStr('PDS_PRIMARY_COLOR'),
34
35
  primaryColorContrast: envStr('PDS_PRIMARY_COLOR_CONTRAST'),
35
36
  primaryColorHue: envInt('PDS_PRIMARY_COLOR_HUE'),
@@ -39,6 +40,9 @@ export function readEnv() {
39
40
  warningColor: envStr('PDS_WARNING_COLOR'),
40
41
  warningColorContrast: envStr('PDS_WARNING_COLOR_CONTRAST'),
41
42
  warningColorHue: envInt('PDS_WARNING_COLOR_HUE'),
43
+ infoColor: envStr('PDS_INFO_COLOR'),
44
+ infoColorContrast: envStr('PDS_INFO_COLOR_CONTRAST'),
45
+ infoColorHue: envInt('PDS_INFO_COLOR_HUE'),
42
46
  successColor: envStr('PDS_SUCCESS_COLOR'),
43
47
  successColorContrast: envStr('PDS_SUCCESS_COLOR_CONTRAST'),
44
48
  successColorHue: envInt('PDS_SUCCESS_COLOR_HUE'),
@@ -91,7 +91,7 @@ export const proxyHandler = (ctx: AppContext): CatchallHandler => {
91
91
  headers,
92
92
  }
93
93
 
94
- await pipethroughStream(ctx, dispatchOptions, (upstream) => {
94
+ await pipethroughStream(ctx, req, dispatchOptions, (upstream) => {
95
95
  res.status(upstream.statusCode)
96
96
 
97
97
  for (const [name, val] of responseHeaders(upstream.headers)) {
@@ -188,7 +188,7 @@ export async function pipethrough(
188
188
  highWaterMark: 2 * 65536, // twice the default (64KiB)
189
189
  }
190
190
 
191
- const { headers, body } = await pipethroughRequest(ctx, dispatchOptions)
191
+ const { headers, body } = await pipethroughRequest(ctx, req, dispatchOptions)
192
192
 
193
193
  return {
194
194
  encoding: safeString(headers['content-type']) ?? 'application/json',
@@ -291,6 +291,7 @@ export const parseProxyHeader = async (
291
291
  */
292
292
  async function pipethroughStream(
293
293
  ctx: AppContext,
294
+ req: Request,
294
295
  dispatchOptions: Dispatcher.RequestOptions,
295
296
  successStreamFactory: Dispatcher.StreamFactory,
296
297
  ): Promise<void> {
@@ -327,7 +328,7 @@ async function pipethroughStream(
327
328
  // or writable stream errors. In the latter case, the promise will already
328
329
  // be resolved, and reject()ing it there after will have no effect. Those
329
330
  // error would still be logged by the successStreamFactory() function.
330
- .catch(handleUpstreamRequestError)
331
+ .catch(handleUpstreamRequestError.bind(req))
331
332
  .catch(reject)
332
333
  })
333
334
  }
@@ -338,6 +339,7 @@ async function pipethroughStream(
338
339
  */
339
340
  async function pipethroughRequest(
340
341
  ctx: AppContext,
342
+ req: Request,
341
343
  dispatchOptions: Dispatcher.RequestOptions,
342
344
  ) {
343
345
  // HandlerPipeThroughStream requires a readable stream to be returned, so we
@@ -345,7 +347,7 @@ async function pipethroughRequest(
345
347
 
346
348
  const upstream = await ctx.proxyAgent
347
349
  .request(dispatchOptions)
348
- .catch(handleUpstreamRequestError)
350
+ .catch(handleUpstreamRequestError.bind(req))
349
351
 
350
352
  if (upstream.statusCode >= 400) {
351
353
  const parsed = await tryParsingError(upstream.headers, upstream.body)
@@ -359,15 +361,23 @@ async function pipethroughRequest(
359
361
  }
360
362
 
361
363
  function handleUpstreamRequestError(
364
+ this: Request,
362
365
  err: unknown,
363
366
  message = 'Upstream service unreachable',
364
367
  ): never {
365
- httpLogger.error({ err }, message)
368
+ const logger = isPinoHttpRequest(this) ? this.log : httpLogger
369
+ logger.error({ err }, message)
366
370
  throw new XRPCServerError(ResponseType.UpstreamFailure, message, undefined, {
367
371
  cause: err,
368
372
  })
369
373
  }
370
374
 
375
+ function isPinoHttpRequest(req: Request): req is Request & {
376
+ log: { error: (obj: unknown, msg: string) => void }
377
+ } {
378
+ return typeof (req as { log?: any }).log?.error === 'function'
379
+ }
380
+
371
381
  // Request parsing/forwarding
372
382
  // -------------------
373
383
 
@@ -0,0 +1,23 @@
1
+ import { IncomingMessage, ServerResponse } from 'node:http'
2
+ import files from '@atproto/oauth-client-browser-example' with { type: 'json' }
3
+
4
+ export function oauthClientAssetsMiddleware(
5
+ req: IncomingMessage,
6
+ res: ServerResponse,
7
+ next?: (err?: unknown) => void,
8
+ ): void {
9
+ const path = req.url?.split('?')[0].slice(1) || 'index.html'
10
+ const file = Object.hasOwn(files, path) ? files[path] : null
11
+
12
+ if (file) {
13
+ res
14
+ .writeHead(200, 'OK', { 'content-type': file.mime })
15
+ .end(Buffer.from(file.data, 'base64'))
16
+ } else if (next) {
17
+ next()
18
+ } else {
19
+ res
20
+ .writeHead(404, 'Not Found', { 'content-type': 'text/plain' })
21
+ .end('Page not found')
22
+ }
23
+ }
@@ -1,27 +1,71 @@
1
1
  import assert from 'node:assert'
2
- import { type Browser, type Page } from 'puppeteer'
2
+ import { type Browser, Handler, type Page, Target, TargetType } from 'puppeteer'
3
3
 
4
4
  export class PageHelper implements AsyncDisposable {
5
5
  constructor(protected readonly page: Page) {}
6
6
 
7
- async goto(url: string) {
8
- await this.page.goto(url)
7
+ async goto(url: string | URL) {
8
+ await this.page.goto(url.toString())
9
+ }
10
+
11
+ isClosed() {
12
+ return this.page.isClosed()
13
+ }
14
+
15
+ async title() {
16
+ await this.waitForNetworkIdle()
17
+ return this.page.title()
9
18
  }
10
19
 
11
20
  async waitForNetworkIdle() {
12
21
  await this.page.waitForNetworkIdle()
13
22
  }
14
23
 
15
- async navigationAction(run: () => Promise<unknown>): Promise<void> {
16
- const promise = this.page.waitForNavigation()
24
+ async waitForPopup(run: () => Promise<unknown>): Promise<PageHelper> {
25
+ const browser = this.page.browser()
26
+ const popupPromise = new Promise<Page | null>((resolve, reject) => {
27
+ const cleanup = () => {
28
+ clearTimeout(timeout)
29
+ browser.off('targetcreated', targetcreated)
30
+ }
31
+
32
+ const timeout = setTimeout(() => {
33
+ cleanup()
34
+ reject(new Error('Timeout waiting for popup'))
35
+ }, 5_000)
36
+
37
+ const targetcreated: Handler<Target> = async (target) => {
38
+ switch (target.type()) {
39
+ case TargetType.BACKGROUND_PAGE:
40
+ case TargetType.PAGE: {
41
+ cleanup()
42
+ resolve(target.page())
43
+ }
44
+ }
45
+ }
46
+
47
+ browser.once('targetcreated', targetcreated)
48
+ })
49
+
50
+ await run()
51
+ const popup = await popupPromise
52
+ assert(popup, 'Popup page not found')
53
+
54
+ return new PageHelper(popup)
55
+ }
56
+
57
+ async navigationAction(run: () => unknown | Promise<unknown>): Promise<void> {
58
+ const promise = this.page.waitForNavigation({ timeout: 10_000 })
17
59
  await run()
18
60
  await promise
19
- await this.waitForNetworkIdle()
20
61
  }
21
62
 
22
- async checkTitle(expected: string) {
23
- await this.waitForNetworkIdle()
24
- await expect(this.page.title()).resolves.toBe(expected)
63
+ async navigationClick(text: string, tag = 'button') {
64
+ return this.navigationAction(() => this.clickOnText(text, tag))
65
+ }
66
+
67
+ async assertTitle(expected: string) {
68
+ await expect(this.title()).resolves.toBe(expected)
25
69
  }
26
70
 
27
71
  async clickOn(selector: string) {
@@ -30,8 +74,12 @@ export class PageHelper implements AsyncDisposable {
30
74
  return elementHandle
31
75
  }
32
76
 
33
- async clickOnButton(text: string) {
34
- return this.clickOn(`button::-p-text(${JSON.stringify(text)})`)
77
+ async clickOnText(text: string, tag = 'button') {
78
+ return this.clickOn(`${tag}::-p-text(${JSON.stringify(text)})`)
79
+ }
80
+
81
+ async clickOnAriaLabel(label: string, tag = 'button') {
82
+ return this.clickOn(`${tag}[aria-label=${JSON.stringify(label)}]`)
35
83
  }
36
84
 
37
85
  async typeIn(selector: string, text: string) {
@@ -46,16 +94,22 @@ export class PageHelper implements AsyncDisposable {
46
94
  }
47
95
 
48
96
  async ensureTextVisibility(text: string, tag = 'p') {
49
- await this.page.waitForSelector(`${tag}::-p-text(${JSON.stringify(text)})`)
97
+ await this.page.waitForSelector(
98
+ `${tag}::-p-text(${JSON.stringify(text)})`,
99
+ {
100
+ visible: true,
101
+ timeout: 5_000,
102
+ },
103
+ )
50
104
  }
51
105
 
52
106
  protected async getVisibleElement(selector: string) {
53
- const elementHandle = await this.page.waitForSelector(selector)
54
-
55
- expect(elementHandle).not.toBeNull()
56
- assert(elementHandle)
107
+ const elementHandle = await this.page.waitForSelector(selector, {
108
+ visible: true,
109
+ timeout: 5_000,
110
+ })
57
111
 
58
- await expect(elementHandle.isVisible()).resolves.toBe(true)
112
+ assert(elementHandle, `Element not found: ${selector}`)
59
113
 
60
114
  return elementHandle
61
115
  }
@@ -1,14 +1,9 @@
1
1
  import { once } from 'node:events'
2
- import {
3
- IncomingMessage,
4
- Server,
5
- ServerResponse,
6
- createServer,
7
- } from 'node:http'
2
+ import { Server, createServer } from 'node:http'
8
3
  import { AddressInfo } from 'node:net'
9
4
  import { type Browser, launch } from 'puppeteer'
10
5
  import { TestNetworkNoAppView } from '@atproto/dev-env'
11
- import files from '@atproto/oauth-client-browser-example' with { type: 'json' }
6
+ import { oauthClientAssetsMiddleware } from './_oauth_client_assets_middleware.js'
12
7
  import { PageHelper } from './_puppeteer.js'
13
8
 
14
9
  describe('oauth', () => {
@@ -44,7 +39,7 @@ describe('oauth', () => {
44
39
  password: 'alice-pass',
45
40
  })
46
41
 
47
- server = createServer(clientHandler)
42
+ server = createServer(oauthClientAssetsMiddleware)
48
43
  server.listen(0)
49
44
  await once(server, 'listening')
50
45
 
@@ -67,26 +62,24 @@ describe('oauth', () => {
67
62
 
68
63
  // This uses prompt=create under the hood:
69
64
  it('Allows to sign-up through OAuth', async () => {
70
- const page = await PageHelper.from(browser, { languages })
65
+ await using page = await PageHelper.from(browser, { languages })
71
66
 
72
67
  await page.goto(appUrl)
73
68
 
74
- await page.checkTitle('OAuth Client Example')
69
+ await page.assertTitle('OAuth Client Example')
75
70
 
76
- await page.navigationAction(async () => {
77
- await page.clickOnButton(`Sign up with ${new URL(network.pds.url).host}`)
78
- })
71
+ await page.navigationClick(`Sign up with ${new URL(network.pds.url).host}`)
79
72
 
80
- await page.checkTitle('Créer un compte')
73
+ await page.assertTitle("S'inscrire")
81
74
 
82
75
  await page.typeInInput('handle', 'bob')
83
76
 
84
- await page.clickOnButton('Suivant')
77
+ await page.clickOnText('Suivant')
85
78
 
86
79
  await page.typeInInput('email', 'bob@test.com')
87
80
  await page.typeInInput('password', 'bob-pass')
88
81
 
89
- await page.clickOnButton("S'inscrire")
82
+ await page.clickOnText("S'inscrire")
90
83
 
91
84
  await page.ensureTextVisibility(
92
85
  `L'application demande un contrôle total sur votre identité, ce qui signifie qu'elle pourrait casser de façon permanente, ou même usurper, votre compte. N'authorisez l'accès qu'aux applications auxquelles vous faites vraiment confiance.`,
@@ -96,54 +89,38 @@ describe('oauth', () => {
96
89
  // the client to resolve the account's did
97
90
  await network.processAll()
98
91
 
99
- await page.navigationAction(async () => {
100
- await page.clickOnButton("Authoriser l'accès")
101
- })
92
+ await page.navigationClick('Autoriser')
102
93
 
103
- await page.checkTitle('OAuth Client Example')
94
+ await page.assertTitle('OAuth Client Example')
104
95
 
105
96
  await page.ensureTextVisibility('Token info', 'h2')
106
97
 
107
- await page.clickOn('button[aria-label="User menu"]')
98
+ await page.clickOnAriaLabel('User menu')
108
99
 
109
- await page.clickOnButton('Sign out')
100
+ await page.clickOnText('Sign out')
110
101
 
111
102
  await page.waitForNetworkIdle()
112
-
113
- // TODO: Find out why we can't use "using" here
114
- await page[Symbol.asyncDispose]()
115
103
  })
116
104
 
117
- it('Allows login or signup through OAuth via a choice', async () => {
118
- const page = await PageHelper.from(browser, { languages })
105
+ it('Allows canceling the OAuth flow', async () => {
106
+ await using page = await PageHelper.from(browser, { languages })
119
107
 
120
108
  await page.goto(appUrl)
121
109
 
122
- await page.checkTitle('OAuth Client Example')
123
-
124
- await page.navigationAction(async () => {
125
- await page.clickOnButton(`Login with ${new URL(network.pds.url).host}`)
126
- })
110
+ await page.assertTitle('OAuth Client Example')
127
111
 
128
- await page.checkTitle('Authentification')
112
+ await page.navigationClick(`Login with ${new URL(network.pds.url).host}`)
129
113
 
130
- await page.ensureTextVisibility('Annuler', 'button')
131
- await page.ensureTextVisibility('Se connecter', 'button')
132
- await page.ensureTextVisibility('Créer un nouveau compte', 'button')
114
+ await page.assertTitle("S'identifier")
133
115
 
134
116
  // Cancel the OAuth flow:
135
- await page.navigationAction(async () => {
136
- await page.clickOnButton('Annuler')
137
- })
117
+ await page.navigationClick('Annuler')
138
118
 
139
- await page.checkTitle('OAuth Client Example')
119
+ await page.assertTitle('OAuth Client Example')
140
120
 
141
121
  await page.ensureTextVisibility('Login with the Atmosphere', 'h2')
142
122
 
143
123
  await page.waitForNetworkIdle()
144
-
145
- // TODO: Find out why we can't use "using" here
146
- await page[Symbol.asyncDispose]()
147
124
  })
148
125
 
149
126
  it('allows resetting the password', async () => {
@@ -153,31 +130,29 @@ describe('oauth', () => {
153
130
  // noop
154
131
  })
155
132
 
156
- const page = await PageHelper.from(browser, { languages })
133
+ await using page = await PageHelper.from(browser, { languages })
157
134
 
158
135
  await page.goto(appUrl)
159
136
 
160
- await page.checkTitle('OAuth Client Example')
137
+ await page.assertTitle('OAuth Client Example')
161
138
 
162
- await page.navigationAction(async () => {
163
- const input = await page.typeIn('input[name="identifier"]', 'alice.test')
139
+ const input = await page.typeInInput('identifier', 'alice.test')
164
140
 
165
- await input.press('Enter')
166
- })
141
+ await page.navigationAction(async () => input.press('Enter'))
167
142
 
168
- await page.checkTitle('Connexion')
143
+ await page.assertTitle('Connexion')
169
144
 
170
- await page.clickOnButton('Oublié ?')
145
+ await page.clickOnText('Oublié ?')
171
146
 
172
- await page.checkTitle('Mot de passe oublié')
147
+ await page.assertTitle('Mot de passe oublié')
173
148
 
174
149
  await page.typeInInput('email', 'alice@test.com')
175
150
 
176
151
  expect(sendTemplateMock).toHaveBeenCalledTimes(0)
177
152
 
178
- await page.clickOnButton('Suivant')
153
+ await page.clickOnText('Suivant')
179
154
 
180
- await page.checkTitle('Réinitialiser le mot de passe')
155
+ await page.assertTitle('Réinitialiser le mot de passe')
181
156
 
182
157
  expect(sendTemplateMock).toHaveBeenCalledTimes(1)
183
158
 
@@ -191,34 +166,29 @@ describe('oauth', () => {
191
166
 
192
167
  await page.typeInInput('password', 'alice-new-pass')
193
168
 
194
- await page.clickOnButton('Suivant')
169
+ await page.clickOnText('Suivant')
195
170
 
196
- await page.checkTitle('Mot de passe mis à jour')
171
+ await page.assertTitle('Mot de passe mis à jour')
197
172
 
198
173
  await page.ensureTextVisibility('Mot de passe mis à jour !', 'h2')
199
174
 
200
- // TODO: Find out why we can't use "using" here
201
- await page[Symbol.asyncDispose]()
202
-
203
175
  sendTemplateMock.mockRestore()
204
176
  })
205
177
 
206
178
  it('Allows to sign-in through OAuth', async () => {
207
- const page = await PageHelper.from(browser, { languages })
179
+ await using page = await PageHelper.from(browser, { languages })
208
180
 
209
181
  await page.goto(appUrl)
210
182
 
211
- await page.checkTitle('OAuth Client Example')
183
+ await page.assertTitle('OAuth Client Example')
212
184
 
213
- await page.navigationAction(async () => {
214
- const input = await page.typeIn('input[name="identifier"]', 'alice.test')
185
+ const input = await page.typeInInput('identifier', 'alice.test')
215
186
 
216
- await input.press('Enter')
217
- })
187
+ await page.navigationAction(async () => input.press('Enter'))
218
188
 
219
- await page.checkTitle('Connexion')
189
+ await page.assertTitle('Connexion')
220
190
 
221
- await page.typeIn('input[type="password"]', 'alice-new-pass')
191
+ await page.typeInInput('password', 'alice-new-pass')
222
192
 
223
193
  // Make sure the warning is visible
224
194
  await page.ensureTextVisibility('Avertissement', 'h3')
@@ -227,79 +197,46 @@ describe('oauth', () => {
227
197
  'label::-p-text(Se souvenir de ce compte sur cet appareil)',
228
198
  )
229
199
 
230
- await page.clickOnButton('Se connecter')
200
+ await page.clickOnText('Se connecter')
231
201
 
232
- await page.checkTitle("Authoriser l'accès")
202
+ await page.assertTitle('Autoriser')
233
203
 
234
- await page.navigationAction(async () => {
235
- await page.clickOnButton("Authoriser l'accès")
236
- })
204
+ await page.navigationClick('Autoriser')
237
205
 
238
- await page.checkTitle('OAuth Client Example')
206
+ await page.assertTitle('OAuth Client Example')
239
207
 
240
208
  await page.ensureTextVisibility('Token info', 'h2')
241
209
 
242
- await page.clickOn('button[aria-label="User menu"]')
210
+ await page.clickOnAriaLabel('User menu')
243
211
 
244
- await page.clickOnButton('Sign out')
212
+ await page.clickOnText('Sign out')
245
213
 
246
214
  await page.waitForNetworkIdle()
247
-
248
- // TODO: Find out why we can't use "using" here
249
- await page[Symbol.asyncDispose]()
250
215
  })
251
216
 
252
217
  it('remembers the session', async () => {
253
- const page = await PageHelper.from(browser, { languages })
218
+ await using page = await PageHelper.from(browser, { languages })
254
219
 
255
220
  await page.goto(appUrl)
256
221
 
257
- await page.checkTitle('OAuth Client Example')
222
+ await page.assertTitle('OAuth Client Example')
258
223
 
259
- await page.navigationAction(async () => {
260
- const input = await page.typeIn('input[name="identifier"]', 'alice.test')
224
+ const input = await page.typeInInput('identifier', 'alice.test')
261
225
 
262
- await input.press('Enter')
263
- })
226
+ await page.navigationAction(async () => input.press('Enter'))
264
227
 
265
- await page.checkTitle("Authoriser l'accès")
228
+ await page.assertTitle('Autoriser')
266
229
 
267
- await page.navigationAction(async () => {
268
- await page.clickOnButton("Authoriser l'accès")
269
- })
230
+ await page.navigationClick('Autoriser')
270
231
 
271
- await page.checkTitle('OAuth Client Example')
232
+ await page.assertTitle('OAuth Client Example')
272
233
 
273
234
  await page.ensureTextVisibility('Token info', 'h2')
274
235
 
275
- await page.clickOn('button[aria-label="User menu"]')
236
+ await page.clickOnAriaLabel('User menu')
276
237
 
277
- await page.clickOnButton('Sign out')
238
+ await page.clickOnText('Sign out')
278
239
 
279
240
  await page.waitForNetworkIdle()
280
-
281
- // TODO: Find out why we can't use "using" here
282
- await page[Symbol.asyncDispose]()
283
241
  })
284
242
  })
285
-
286
- function clientHandler(
287
- req: IncomingMessage,
288
- res: ServerResponse,
289
- next?: (err?: unknown) => void,
290
- ): void {
291
- const path = req.url?.split('?')[0].slice(1) || 'index.html'
292
- const file = Object.hasOwn(files, path) ? files[path] : null
293
-
294
- if (file) {
295
- res
296
- .writeHead(200, 'OK', { 'content-type': file.mime })
297
- .end(Buffer.from(file.data, 'base64'))
298
- } else if (next) {
299
- next()
300
- } else {
301
- res
302
- .writeHead(404, 'Not Found', { 'content-type': 'text/plain' })
303
- .end('Page not found')
304
- }
305
- }