Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth.ts demo #981

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions chrome/browser/resources/record_replay/auth.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,46 @@
// external (c++-side) interface
declare function getEnv(key: string): string | null;
declare function getBuildId(): string;
declare function getReplayUserToken(): string | null;
declare function setReplayUserToken(token: string | null): void;
declare function getReplayRefreshToken(): string | null;
declare function setReplayRefreshToken(token: string | null): void;
declare function showAuthenticationError(message: string): void;
declare function openExternalBrowser(url: string): Promise<void>;
declare function onSignInButtonClicked(callback: () => void): void;
// declare function getEnv(key: string): string | null;
// declare function getBuildId(): string;
// declare function getReplayUserToken(): string | null;
// declare function setReplayUserToken(token: string | null): void;
// declare function getReplayRefreshToken(): string | null;
// declare function setReplayRefreshToken(token: string | null): void;
// declare function showAuthenticationError(message: string): void;
// declare function openExternalBrowser(url: string): Promise<void>;
// declare function onSignInButtonClicked(callback: () => void): void;
function getEnv(key: string): string | null {
console.log(`getEnv: ${key}`);
return null;
}
function getBuildId(): string {
return "";
}
let _userToken: string | null = null;
function getReplayUserToken(): string | null {
return _userToken;
}
function setReplayUserToken(token: string | null): void {
console.error(`setReplayUserToken: ${token}`);
_userToken = token;
}
let _refreshToken: string | null = null;
function getReplayRefreshToken(): string | null {
return _refreshToken;
}
function setReplayRefreshToken(token: string | null): void {
console.error(`setReplayRefreshToken: ${token}`);
_refreshToken = token;
}
function showAuthenticationError(message: string): void {
console.error(`Authentication error: ${message}`);
}
function openExternalBrowser(url: string): Promise<void> {
console.error(`openExternalBrowser: ${url}`);
return Promise.resolve();
}
function onSignInButtonClicked(callback: () => void): void {
callback();
}

function getAuthHost() {
return getEnv("RECORD_REPLAY_AUTH_HOST") || "webreplay.us.auth0.com";
Expand All @@ -28,7 +61,7 @@ function getTelemetryUrl() {
return "https://telemetry.replay.io";
}
function isTelemetryEnabled() {
return true;
return false;
}

// https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
Expand Down