Skip to content

Commit

Permalink
add alternate appview did
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Jan 25, 2024
1 parent 885551e commit 517e2bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/pds/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export const envToCfg = (env: ServerEnvironment): ServerConfig => {
alternate: env.bskyAppviewAlternateUrl
? {
url: env.bskyAppviewAlternateUrl,
did: env.bskyAppviewAlternateDid ?? env.bskyAppViewDid,
users: env.bskyAppviewAlternateUsers ?? [],
}
: undefined,
Expand Down Expand Up @@ -344,6 +345,7 @@ export type BksyAppViewConfig = {
cdnUrlPattern?: string
alternate?: {
url: string
did: string
users: string[]
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/pds/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const readEnv = (): ServerEnvironment => {
bskyAppViewDid: envStr('PDS_BSKY_APP_VIEW_DID'),
bskyAppViewCdnUrlPattern: envStr('PDS_BSKY_APP_VIEW_CDN_URL_PATTERN'),
bskyAppviewAlternateUrl: envStr('PDS_BSKY_APP_VIEW_ALTERNATE_URL'),
bskyAppviewAlternateDid: envStr('PDS_BSKY_APP_VIEW_ALTERNATE_DID'),
bskyAppviewAlternateUsers: envList('PDS_BSKY_APP_VIEW_ALTERNATE_USERS'),

// mod service
Expand Down Expand Up @@ -172,6 +173,7 @@ export type ServerEnvironment = {
bskyAppViewDid?: string
bskyAppViewCdnUrlPattern?: string
bskyAppviewAlternateUrl?: string
bskyAppviewAlternateDid?: string
bskyAppviewAlternateUsers?: string[]

// mod service
Expand Down
6 changes: 5 additions & 1 deletion packages/pds/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ export class AppContext {
}

async appviewAuthHeaders(did: string) {
return this.serviceAuthHeaders(did, this.cfg.bskyAppView.did)
const appviewDid =
this.cfg.bskyAppView.alternate && this.alternateAppviewUsers.has(did)
? this.cfg.bskyAppView.alternate.did
: this.cfg.bskyAppView.did
return this.serviceAuthHeaders(did, appviewDid)
}

async moderationAuthHeaders(did: string) {
Expand Down

0 comments on commit 517e2bc

Please sign in to comment.