Decodes a single JWT segment.
350072
def _decode_jwt_segment(encoded_section):
    """"""
    section_bytes = _helpers.padded_urlsafe_b64decode(encoded_section)
    try:
        return json.loads(section_bytes.decode('utf-8'))
    except ValueError as caught_exc:
        new_exc = ValueError('Can\'t parse segment: {0}'.format(section_bytes))
        six.raise_from(new_exc, caught_exc)
738367
function decode(events) {
  let indexList = [];
  let eventsByte = parseInt(events, 16);

  if(eventsByte & APPEARANCE_MASK) {
    indexList.push(APPEARANCE);
  }
  if(eventsByte & DISPLACEMENT_MASK) {
    indexList.push(DISPLACEMENT);
  }
  if(eventsByte & PACKETS_MASK) {
    indexList.push(PACKETS);
  }
  if(eventsByte & KEEPALIVE_MASK) {
    indexList.push(KEEPALIVE);
  }
  if(eventsByte & DISAPPEARANCE_MASK) {
    indexList.push(DISAPPEARANCE);
  }

  return indexList;
}
221132
def decode_header(cls, stream):
        
        read = stream.read
        data = read(2)
        if len(data) != 2:
            raise WebSocketError("Unexpected EOF while decoding header")
        first_byte, second_byte = struct.unpack('!BB', data)
        header = cls(
            fin=first_byte & cls.FIN_MASK == cls.FIN_MASK,
            opcode=first_byte & cls.OPCODE_MASK,
            flags=first_byte & cls.HEADER_FLAG_MASK,
            length=second_byte & cls.LENGTH_MASK)
        has_mask = second_byte & cls.MASK_MASK == cls.MASK_MASK
        if header.opcode > 0x07:
            if not header.fin:
                raise WebSocketError('Received fragmented control frame: {0!r}'.format(data))
            # Control frames MUST have a payload length of 125 bytes or less
            if header.length > 125:
                raise FrameTooLargeException('Control frame cannot be larger than 125 bytes: {0!r}'.format(data))
        if header.length == 126:
            # 16 bit length
            data = read(2)
            if len(data) != 2:
                raise WebSocketError('Unexpected EOF while decoding header')
            header.length = struct.unpack('!H', data)[0]
        elif header.length == 127:
            # 64 bit length
            data = read(8)
            if len(data) != 8:
                raise WebSocketError('Unexpected EOF while decoding header')
            header.length = struct.unpack('!Q', data)[0]
        if has_mask:
            mask = read(4)
            if len(mask) != 4:
                raise WebSocketError('Unexpected EOF while decoding header')
            header.mask = mask
        return header
1203038
def validate_and_decode(jwt_bu64, cert_obj):
    
    public_key = cert_obj.public_key()
    message = '.'.join(d1_common.cert.jwt.get_bu64_tup(jwt_bu64)[:2])
    signature = d1_common.cert.jwt.get_jwt_tup(jwt_bu64)[2]
    try:
        public_key.verify(
            signature,
            message,
            cryptography.hazmat.primitives.asymmetric.padding.PKCS1v15(),
            cryptography.hazmat.primitives.hashes.SHA256(),
        )
    except cryptography.exceptions.InvalidSignature as e:
        raise Exception('Signature is invalid. error="{}"'.format(str(e)))
    return d1_common.cert.jwt.get_jwt_dict(jwt_bu64)
946357
def _unpack_token_compact(token):
    
    if isinstance(token, (str, unicode)):
        token = token.encode('utf-8')

    try:
        signing_input, crypto_segment = token.rsplit(b'.', 1)
        header_segment, payload_segment = signing_input.split(b'.', 1)
    except ValueError:
        raise DecodeError('Not enough segments')

    try:
        header_data = base64url_decode(header_segment)
    except (TypeError, binascii.Error):
        raise DecodeError('Invalid header padding')

    try:
        header = json.loads(header_data.decode('utf-8'))
    except ValueError as e:
        raise DecodeError('Invalid header string: %s' % e)

    if not isinstance(header, Mapping):
        raise DecodeError('Invalid header string: must be a json object')

    try:
        payload_data = base64url_decode(payload_segment)
    except (TypeError, binascii.Error):
        raise DecodeError('Invalid payload padding')

    try:
        payload = json.loads(payload_data.decode('utf-8'))
    except ValueError as e:
        raise DecodeError('Invalid payload string: %s' % e)

    try:
        signature = base64url_decode(crypto_segment)
    except (TypeError, binascii.Error):
        raise DecodeError('Invalid crypto padding')

    return (header, payload, signature, signing_input)
5793
def decodetx(tx_hex, coin_symbol='btc', api_key=None):
    '''
    
    '''

    assert is_valid_coin_symbol(coin_symbol)
    assert api_key, 'api_key required'

    url = make_url(coin_symbol, **dict(txs='decode'))

    params = {'token': api_key}
    data = {
        'tx': tx_hex,
        'token': api_key,
    }

    r = requests.post(url, json=data, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS)
    return get_valid_json(r)
1028023
def decode(self):
        """"""
        return serialization.decode(self.body, self.content_type,
                                    self.content_encoding)
471790
public function getDecodedToken(string $jwt)
    {
        try {
            /** @noinspection PhpUnusedLocalVariableInspection */
            [$headb64, $bodyb64, $cryptob64] = \explode('.', $jwt);
            $decodedToken = \json_decode(JWT::urlsafeB64Decode($bodyb64));

            /** @noinspection NullPointerExceptionInspection */
            JWT::decode($jwt, $this->findTenant($decodedToken->iss)->getSharedSecret(), ['HS256']);

            return $decodedToken;
        } catch (\Throwable $e) {
            throw new AuthenticationException($e->getMessage());
        }
    }
553175
def _from_jwt(cls, headers, payload, key=None):
        
        jwt = Jwt(
            secret_key=key,
            issuer=payload.get('iss', None),
            subject=payload.get('sub', None),
            algorithm=headers.get('alg', None),
            valid_until=payload.get('exp', None),
            nbf=payload.get('nbf', None),
        )
        jwt.__decoded_payload = payload
        jwt.__decoded_headers = headers
        return jwt
1103397
public Object decode(byte[] frame, int offset, int indirect, JMFMessageData msg) throws JMFMessageCorruptionException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "decode", new Object[]{frame, offset, indirect, msg});
    Object result = null;
    if (indirect < 0) {
      indirect = this.indirect;
    }
    if (indirect > 0) {
      result = new JSVaryingListImpl(frame, offset, element, indirect);
    }
    else if (varying) {
      result = new JSVaryingListImpl(frame, offset, element, 0);
    }
    else {
      result = new JSFixedListImpl(frame, offset, element);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "decode",  result);
    return result;
  }
362448
def decode(self):
        """"""
        if _debug: IOChainMixIn._debug("decode")

        # refer to the chained iocb
        iocb = self.ioChain

        # if this has completed successfully, pass it up
        if self.ioState == COMPLETED:
            if _debug: IOChainMixIn._debug("    - completed: %r", self.ioResponse)

            # change the state and transform the content
            iocb.ioState = COMPLETED
            iocb.ioResponse = self.ioResponse

        # if this aborted, pass that up too
        elif self.ioState == ABORTED:
            if _debug: IOChainMixIn._debug("    - aborted: %r", self.ioError)

            # change the state
            iocb.ioState = ABORTED
            iocb.ioError = self.ioError

        else:
            raise RuntimeError("invalid state: %d" % (self.ioState,))
578722
public static final SegmentId decode(final Segment segment) {
        Preconditions.checkNotNull(segment, "segment");
        return createSegmentId(segment.getScope(), segment.getStreamName(), segment.getSegmentId());
    }
1114987
def decode_jwt(encoded_token):
    
    secret = config.decode_key
    algorithm = config.algorithm
    audience = config.audience
    return jwt.decode(encoded_token, secret, algorithms=[algorithm], audience=audience)
830106
function(jwt) {
  try {
    var segments = jwt.split('.');
    this.signature = segments.pop();
    this.signatureBase = segments.join('.');
    this.header = decodeSegment(segments.shift());
    this.payload = decodeSegment(segments.shift());
  } catch (e) {
    throw new Error("Unable to parse JWT");
  }
}
278931
def decode_token(token):
    
    if isinstance(token, (unicode,str)):
        return _decode_token_compact(token)

    else:
        return _decode_token_json(token)
163129
def decode(self, token, verify=True):
        
        try:
            return jwt.decode(token, self.verifying_key, algorithms=[self.algorithm], verify=verify)
        except InvalidTokenError:
            raise TokenBackendError(_('Token is invalid or expired'))
577662
function verifyToken(token) {
    var decodedToken = jwt.decode(token)
    return userdb.users.filter(user => user.name == decodedToken).length > 0;
}