How to use the taskcluster-client-web.fromNow function in taskcluster-client-web

To help you get started, we’ve selected a few taskcluster-client-web 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 taskcluster / taskcluster-tools / src / auth / auth0.js View on Github external
export function userSessionFromAuthResult(authResult) {
  return UserSession.fromOIDC({
    oidcProvider: process.env.OIDC_PROVIDER,
    accessToken: authResult.accessToken,
    fullName: authResult.idTokenPayload.nickname,
    picture: authResult.idTokenPayload.picture,
    oidcSubject: authResult.idTokenPayload.sub,
    // per https://wiki.mozilla.org/Security/Guidelines/OpenID_connect#Session_handling
    renewAfter: fromNow('15 minutes')
  });
}
github taskcluster / taskcluster-tools / src / views / SecretsManager / SecretEditor.jsx View on Github external
async loadSecret(props) {
    // If there is a secretId, we load it. Otherwise we create a new secret
    if (!props.secretId) {
      const defaultSecret = { foo: 'bar' };

      return this.setState({
        secret: defaultSecret,
        secretValue: safeDump(defaultSecret, safeDumpOpts),
        expires: fromNow('1000 years'),
        editing: true,
        loading: false,
        error: null
      });
    }

    // indicate loading while the async secret fetch occurs
    this.setState({
      loading: true,
      error: null
    });

    try {
      const { secret, expires } = await props.secrets.get(props.secretId);

      this.setState({
github mozilla / treeherder / ui / helpers / auth.js View on Github external
//
  // For more details, see:
  // https://auth0.com/docs/libraries/auth0js/v9#extract-the-authresult-and-get-user-info
  //
  const userSession = {
    idToken: authResult.idToken,
    accessToken: authResult.accessToken,
    fullName: authResult.idTokenPayload.nickname,
    picture: authResult.idTokenPayload.picture,
    oidcSubject: authResult.idTokenPayload.sub,
    url: authResult.url,
    // `accessTokenexpiresAt` is the unix timestamp (in seconds) at which the access token expires.
    // It is used by the Django backend along with idToken's `exp` to determine session expiry.
    accessTokenExpiresAt: authResult.expiresIn + Math.floor(Date.now() / 1000),
    // per https://wiki.mozilla.org/Security/Guidelines/OpenID_connect#Session_handling
    renewAfter: fromNow('15 minutes'),
  };

  return userSession;
};
github taskcluster / taskcluster-tools / src / views / ClientCreator / ClientCreator.jsx View on Github external
this.setState({ loading: true }, async () => {
      try {
        const description =
          this.state.query.description ||
          `Client created ${new Date()} for ${this.state.query.callback_url}`;
        const requestedScopes = toArray(this.state.query.scope);
        const currentScopes = (await this.props.auth.currentScopes()).scopes;

        await this.props.auth.updateClient(this.state.client.clientId, {
          description,
          expires: fromNow(this.state.query.expires || '3 days'),
          scopes: scopeIntersection(currentScopes, requestedScopes),
          deleteOnExpiration: true
        });

        const client = await this.props.auth.resetAccessToken(
          this.state.client.clientId
        );

        this.triggerCallback(client.clientId, client.accessToken);
      } catch (error) {
        this.setState({ error, loading: false });
      }
    });
  };

taskcluster-client-web

[![Download](https://img.shields.io/badge/yarn-taskcluster--client--web-brightgreen)](https://yarnpkg.com/en/package/taskcluster-client-web) [![License](https://img.shields.io/badge/license-MPL%202.0-orange.svg)](http://mozilla.org/MPL/2.0)

MPL-2.0
Latest version published 10 days ago

Package Health Score

66 / 100
Full package analysis

Similar packages