UNPKG

blockstack

Version:

The Blockstack Javascript library for authentication, identity, and storage.

40 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const service_1 = require("./service"); class Twitter extends service_1.Service { getBaseUrls() { const baseUrls = [ 'https://twitter.com/', 'http://twitter.com/', 'twitter.com/' ]; return baseUrls; } normalizeUrl(_proof) { return ''; } getProofStatement(searchText, cheerio) { const $ = cheerio.load(searchText); const statement = $('meta[property="og:description"]').attr('content'); if (statement !== undefined) { return statement.trim().replace('“', '').replace('”', ''); } else { return ''; } } getProofUrl(proof) { const baseUrls = this.getBaseUrls(); let proofUrl = proof.proof_url.toLowerCase(); proofUrl = this.prefixScheme(proofUrl); for (let i = 0; i < baseUrls.length; i++) { const requiredPrefix = `${baseUrls[i]}${proof.identifier}`.toLowerCase(); if (proofUrl.startsWith(requiredPrefix)) { return proofUrl; } } throw new Error(`Proof url ${proof.proof_url} is not valid for service ${proof.service}`); } } exports.Twitter = Twitter; //# sourceMappingURL=twitter.js.map