How to use the @firebase/util.isValidFormat function in @firebase/util

To help you get started, we’ve selected a few @firebase/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / firebase-js-sdk / packages / database / src / core / PersistentConnection.ts View on Github external
tryAuth() {
    if (this.connected_ && this.authToken_) {
      const token = this.authToken_;
      const authMethod = isValidFormat(token) ? 'auth' : 'gauth';
      const requestData: { [k: string]: any } = { cred: token };
      if (this.authOverride_ === null) {
        requestData['noauth'] = true;
      } else if (typeof this.authOverride_ === 'object') {
        requestData['authvar'] = this.authOverride_;
      }
      this.sendRequest(authMethod, requestData, (res: { [k: string]: any }) => {
        const status: string = res[/*status*/ 's'];
        const data: string = res[/*data*/ 'd'] || 'error';

        if (this.authToken_ === token) {
          if (status === 'ok') {
            this.invalidAuthTokenCount_ = 0;
          } else {
            // Triggers reconnect and force refresh for auth token
            this.onAuthRevoked_(status, data);
github firebase / firebase-js-sdk / packages / database / src / core / PersistentConnection.ts View on Github external
tryAuth() {
    if (this.connected_ && this.authToken_) {
      const token = this.authToken_;
      const authMethod = isValidFormat(token) ? 'auth' : 'gauth';
      const requestData: { [k: string]: unknown } = { cred: token };
      if (this.authOverride_ === null) {
        requestData['noauth'] = true;
      } else if (typeof this.authOverride_ === 'object') {
        requestData['authvar'] = this.authOverride_;
      }
      this.sendRequest(
        authMethod,
        requestData,
        (res: { [k: string]: unknown }) => {
          const status = res[/*status*/ 's'] as string;
          const data = (res[/*data*/ 'd'] as string) || 'error';

          if (this.authToken_ === token) {
            if (status === 'ok') {
              this.invalidAuthTokenCount_ = 0;