How to use the @tanker/client-browser.Tanker.statuses function in @tanker/client-browser

To help you get started, we’ve selected a few @tanker/client-browser 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 TankerHQ / sdk-js / packages / filekit / src / FileKit.js View on Github external
async startDisposableSession(privateIdentity: { identity: string }) {
    const { identity } = privateIdentity;
    const status = await this.tanker.start(identity);

    switch (status) {
      case Tanker.statuses.IDENTITY_REGISTRATION_NEEDED: {
        const genVerificationKey = await this.tanker.generateVerificationKey();
        await this.tanker.registerIdentity({ verificationKey: genVerificationKey });
        return;
      }
      case Tanker.statuses.IDENTITY_VERIFICATION_NEEDED: {
        throw new errors.InvalidArgument('This identity has already been used, create a new one.');
      }
      // When hitting back or forward on the browser you can start a disposable
      // session with the same identity twice because the browser is caching
      // the xhr request to fake-auth (or another identity server)
      case Tanker.statuses.READY: {
        return;
      }
      default:
        throw new errors.InternalError(`Assertion error: unexpected status ${status}`);
    }
  }
github TankerHQ / quickstart-examples / client / web / notepad / src / Session.js View on Github external
import EventEmitter from 'events';
import { Tanker, toBase64, fromBase64 } from '@tanker/client-browser';
import ServerApi from './ServerApi';

const { READY, IDENTITY_REGISTRATION_NEEDED, IDENTITY_VERIFICATION_NEEDED } = Tanker.statuses;

const STATUSES = [
  'initializing',
  'closed',
  'open',
  'claim',
  'register',
  'verify',
];

export default class Session extends EventEmitter {
  constructor() {
    super();

    this.resourceId = null;
    this._user = null;