Exemple #1
0
    def wrapInRequest(self, payload, defaults=True):

        # If we haven't authenticated before
        info = None
        if not self.authTicket:
            info = RequestEnvelope_pb2.RequestEnvelope.AuthInfo(
                provider=self.authProvider,
                token=RequestEnvelope_pb2.RequestEnvelope.AuthInfo.JWT(
                    contents=self.accessToken, unknown2=59))

        # Build Envelope
        latitude, longitude, altitude = self.getCoordinates()
        req = RequestEnvelope_pb2.RequestEnvelope(status_code=2,
                                                  request_id=api.getRPCId(),
                                                  longitude=longitude,
                                                  latitude=latitude,
                                                  altitude=altitude,
                                                  auth_ticket=self.authTicket,
                                                  unknown12=989,
                                                  auth_info=info)

        # Add requests
        if defaults:
            payload += self.getDefaults()
        req.requests.extend(payload)

        return req
    def wrapInRequest(self, payload, defaults=True):

        # Grab coords
        latitude, longitude, altitude = self.getCoordinates()

        # Add requests
        if defaults:
            payload += self.getDefaults()

        # If we haven't authenticated before
        info = None
        signature = None
        if self.authTicket is None:
            info = RequestEnvelope.RequestEnvelope.AuthInfo(
                provider=self.authProvider,
                token=RequestEnvelope.RequestEnvelope.AuthInfo.JWT(
                    contents=self.accessToken, unknown2=59))

        # Otherwise build signature
        elif self.encryptLib and not self.location.noop:

            # Generate hashes
            hashA, hashB = hashLocation(self.authTicket, latitude, longitude,
                                        altitude)

            # Build and hash signature
            proto = Signature.Signature(
                location_hash1=hashA,
                location_hash2=hashB,
                session_hash=os.urandom(32),
                timestamp=getMs(),
                timestamp_since_start=getMs() - self._start,
                request_hash=hashRequests(self.authTicket, payload),
                unknown25=-8537042734809897855)

            signature = hashSignature(proto, self.encryptLib)

        # Build Envelope
        req = RequestEnvelope.RequestEnvelope(
            status_code=2,
            request_id=PogoSessionBare.getRPCId(),
            unknown6=Unknown6.Unknown6(request_type=6,
                                       unknown2=Unknown6.Unknown6.Unknown2(
                                           encrypted_signature=signature)),
            longitude=longitude,
            latitude=latitude,
            altitude=altitude,
            auth_ticket=self.authTicket,
            unknown12=741,
            auth_info=info)

        req.requests.extend(payload)

        return req