Skip to content

Commit

Permalink
fix: compile break
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 9, 2024
1 parent a7d3e59 commit 83fbdbb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/ui/docs-bundle/src/server/DocsLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class DocsLoader {
return this;
}

private async loadAuth(): Promise<AuthProps | undefined> {
private async loadAuth(): Promise<[AuthProps | undefined, AuthEdgeConfig | undefined]> {
if (!this.auth) {
this.auth = await getAuthEdgeConfig(this.xFernHost);

Expand All @@ -53,9 +53,9 @@ export class DocsLoader {
}
}
if (!this.auth) {
return undefined;
return [undefined, undefined];
}
return withAuthProps(this.auth, this.fernToken);
return [await withAuthProps(this.auth, this.fernToken), this.auth];
}

#loadForDocsUrlResponse: DocsV2Read.LoadDocsForUrlResponse | undefined;
Expand All @@ -72,7 +72,7 @@ export class DocsLoader {

private async loadDocs(): Promise<DocsV2Read.LoadDocsForUrlResponse | undefined> {
if (!this.#loadForDocsUrlResponse) {
const authProps = await this.loadAuth();
const [authProps] = await this.loadAuth();

const response = await loadWithUrl(this.xFernHost, authProps);

Expand Down Expand Up @@ -100,17 +100,20 @@ export class DocsLoader {
}

public async root(): Promise<FernNavigation.RootNode | undefined> {
const { authConfig, user } = await this.loadAuth();
const [auth, authConfig] = await this.loadAuth();
let node = await this.unprunedRoot();

// if the user is not authenticated, and the page requires authentication, prune the navigation tree
// to only show pages that are allowed to be viewed without authentication.
// note: the middleware will not show this page at all if the user is not authenticated.
if (node && authConfig?.type === "basic_token_verification" && !user) {
if (node && authConfig?.type === "basic_token_verification" && !auth) {
try {
// TODO: store this in cache
node = pruneWithBasicTokenPublic(authConfig, node);
} catch (e) {
// TODO: sentry
// eslint-disable-next-line no-console
console.error(e);
return undefined;
}
}
Expand Down

0 comments on commit 83fbdbb

Please sign in to comment.