How to use the jsrsasign.jws.JWS function in jsrsasign

To help you get started, we’ve selected a few jsrsasign 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 wazo-platform / wazo-js-sdk / src / domain / Session.js View on Github external
static parse(plain: Response): ?Session {
    const token = plain.data.metadata ? plain.data.metadata.jwt : null;
    let authorizations = [];

    // Add authorizations from JWT
    if (token) {
      const isValid = jws.JWS.verifyJWT(token, swarmKey, { alg: ['RS256'], verifyAt: new Date() });
      if (isValid) {
        const decodedToken = jws.JWS.readSafeJSONString(b64utoutf8(token.split('.')[1]));
        authorizations = decodedToken ? decodedToken.authorizations : [];
      }
    }

    return new Session({
      token: plain.data.token,
      refreshToken: plain.data.refresh_token || null,
      uuid: plain.data.metadata ? plain.data.metadata.uuid : null,
      sessionUuid: plain.data.session_uuid,
      authorizations,
      tenantUuid: plain.data.metadata ? plain.data.metadata.tenant_uuid : undefined,
      expiresAt: new Date(`${plain.data.utc_expires_at}z`),
    });
  }
github ovh / cds / ui / src / app / views / auth / callback / callback.component.ts View on Github external
this.paramsSub = this._route.params.subscribe(params => {
            this.consumerType = params['consumerType'];

            this.code = this._route.snapshot.queryParams.code || this._route.snapshot.queryParams.token;
            this.state = this._route.snapshot.queryParams.state || this._route.snapshot.queryParams.request;

            if (!this.code || !this.state) {
                this.loading = false;
                this.missingParams = true;
                this._cd.markForCheck();
                return;
            }

            // If the origin is cdsctl, show the code and the state for copy
            let payload = jws.JWS.parse(this.state).payloadObj;
            if (payload.data) {
                this.payloadData = JSON.parse(payload.data);
            }
            if (this.payloadData && this.payloadData.origin === 'cdsctl') {
                this.loading = false;
                this.showCTL = true;
                this._cd.markForCheck();
                return;
            }

            // If the first connection flag is set, show init token form
            if (this.payloadData && this.payloadData.is_first_connection) {
                this.loading = false;
                this.showInitTokenForm = true;
                this._cd.markForCheck();
                return;
github RocketChat / Rocket.Chat / packages / rocketchat-videobridge / server / methods / jitsiGenerateToken.js View on Github external
const commonPayload = {
			iss: JITSI_OPTIONS.jitsi_application_id,
			sub: JITSI_OPTIONS.jitsi_domain,
			iat: jws.IntDate.get('now'),
			nbf: jws.IntDate.get('now'),
			exp: jws.IntDate.get(`now + ${ JITSI_OPTIONS.jitsi_lifetime_token }`),
			aud: 'RocketChat',
			room: '*',
			context: '', // first empty
		};

		const header = JSON.stringify(HEADER);
		const payload = JSON.stringify(addUserContextToPayload(commonPayload));

		return jws.JWS.sign(HEADER.alg, header, payload, { rstr: JITSI_OPTIONS.jitsi_application_secret });
	},
});

jsrsasign

opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp and CAdES and JSON Web Signature(JWS)/Token(JWT)/Key(JWK)

MIT
Latest version published 11 months ago

Package Health Score

74 / 100
Full package analysis