Skip to content

Commit

Permalink
feat(datadirect-puppeteer): Authenticated.decodedToken()
Browse files Browse the repository at this point in the history
Deprecates `Authenticated.user()` in favor of more transparent and flexible `decodedToken()` method
  • Loading branch information
battis committed Jan 8, 2025
1 parent 167609c commit 261ea36
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Authenticated extends Base {
return await new Authenticated(url, options).ready();
}

private async appLoaded(
protected async appLoaded(
timeout = Authenticated.DefaultTimeout,
authenticated?: MutexInterface.Releaser
) {
Expand Down Expand Up @@ -101,13 +101,18 @@ export class Authenticated extends Base {
return this;
}

public async user(): Promise<string> {
public async decodedToken(): Promise<DecodedToken> {
await this.ready();
return await this.page.evaluate(
async () => (await BBAuthClient.BBAuth.getDecodedToken(null)).email
async () => await BBAuthClient.BBAuth.getDecodedToken(null)
);
}

/** Deprecated: use Authenticated.decodedToken().email */
public async user(): Promise<string> {
return (await this.decodedToken()).email;
}

public async clone() {
await this.ready();
return await new Authenticated(this.page).ready();
Expand Down

0 comments on commit 261ea36

Please sign in to comment.