public static function parse()

in Server/php/app_token.php [81:114]


    public static function parse($token): self
    {
        if ($token === null) {
            throw new ValueError('empty appToken');
        }

        if (!substr($token, 0, strlen(self::VERSION_0)) == self::VERSION_0) {
            throw new ValueError('unsupported version');
        }

        $token_buf = fopen("php://memory", 'r+');

        assert($token_buf);

        fwrite($token_buf, decompress(base64_decode(substr($token, strlen(self::VERSION_0)))));
        rewind($token_buf);

        $signature_length = unpack('N', fread($token_buf, 4))[1];
        $signature = fread($token_buf, $signature_length);

        $app_id_length = unpack('N', fread($token_buf, 4))[1];
        $app_id = fread($token_buf, $app_id_length);

        $issue_timestamp = unpack('N', fread($token_buf, 4))[1];
        $salt = unpack('N', fread($token_buf, 4))[1];
        $timestamp = unpack('N', fread($token_buf,4))[1];

        $service = Service::unpack($token_buf);
        $options = AppTokenOptions::unpack($token_buf);

        fclose($token_buf);

        return new self($app_id, null, $timestamp, $issue_timestamp, $salt, $service, $options, $signature);
    }