Update serviceProviders with enums

This commit is contained in:
Yarmo Mackenbach 2021-04-12 14:31:34 +02:00
parent 8dc0372ea7
commit 10a32f98a5
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1
17 changed files with 101 additions and 72 deletions

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/dev\.to\/(.*)\/(.*)\/?/ const reURI = /^https:\/\/dev\.to\/(.*)\/(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: `https://dev.to/api/articles/${match[1]}/${match[2]}`, fetch: `https://dev.to/api/articles/${match[1]}/${match[2]}`,
useProxy: true, access: proofAccess.NOCORS,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: ['body_markdown'], path: ['body_markdown'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/(.*)\/u\/(.*)\/?/ const reURI = /^https:\/\/(.*)\/u\/(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: `https://${match[1]}/u/${match[2]}.json`, fetch: `https://${match[1]}/u/${match[2]}.json`,
useProxy: true, access: proofAccess.NOCORS,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: ['user', 'bio_raw'], path: ['user', 'bio_raw'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,10 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const dns = require('dns') const dns = require('dns')
const bent = require('bent') const bent = require('bent')
const req = bent('GET') const req = bent('GET')
const utils = require('../utils')
const reURI = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/ const reURI = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
const customRequestHandler = async (spData, opts) => { const customRequestHandler = async (spData, opts) => {
@ -61,16 +62,16 @@ const processURI = (uri, opts) => {
qr: null, qr: null,
}, },
proof: { proof: {
uri: utils.generateProxyURL('dns', match[1], opts), uri: null,
fetch: null, fetch: null,
useProxy: false, access: proofAccess.SERVER,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'uri', format: claimFormat.URI,
relation: claimRelation.CONTAINS,
path: ['records', 'txt'], path: ['records', 'txt'],
relation: 'contains',
}, },
customRequestHandler: customRequestHandler, customRequestHandler: customRequestHandler,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/(.*)\/users\/(.*)\/?/ const reURI = /^https:\/\/(.*)\/users\/(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: null, fetch: null,
useProxy: false, access: proofAccess.GENERIC,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'fingerprint', format: claimFormat.FINGERPRINT,
relation: claimRelation.CONTAINS,
path: ['summary'], path: ['summary'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/(.*)\/(.*)\/gitea_proof\/?/ const reURI = /^https:\/\/(.*)\/(.*)\/gitea_proof\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: `https://${match[1]}/api/v1/repos/${match[2]}/gitea_proof`, fetch: `https://${match[1]}/api/v1/repos/${match[2]}/gitea_proof`,
useProxy: true, access: proofAccess.NOCORS,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.EQUALS,
path: ['description'], path: ['description'],
relation: 'equals',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/ const reURI = /^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: `https://api.github.com/gists/${match[2]}`, fetch: `https://api.github.com/gists/${match[2]}`,
useProxy: false, access: proofAccess.GENERIC,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: ['files', 'openpgp.md', 'content'], path: ['files', 'openpgp.md', 'content'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const bent = require('bent') const bent = require('bent')
const req = bent('GET') const req = bent('GET')
@ -77,14 +78,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: null, fetch: null,
useProxy: false, access: proofAccess.GENERIC,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.EQUALS,
path: ['description'], path: ['description'],
relation: 'equals',
}, },
customRequestHandler: customRequestHandler, customRequestHandler: customRequestHandler,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/ const reURI = /^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`, uri: `https://hacker-news.firebaseio.com/v0/user/${match[1]}.json`,
fetch: null, fetch: null,
useProxy: true, access: proofAccess.NOCORS,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'uri', format: claimFormat.URI,
relation: claimRelation.CONTAINS,
path: ['about'], path: ['about'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const utils = require('../utils') const utils = require('../utils')
const reURI = /^irc\:\/\/(.*)\/([a-zA-Z0-9]*)/ const reURI = /^irc\:\/\/(.*)\/([a-zA-Z0-9]*)/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -35,14 +37,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: utils.generateProxyURL('irc', [match[1], match[2]], opts), uri: utils.generateProxyURL('irc', [match[1], match[2]], opts),
fetch: null, fetch: null,
useProxy: false, access: proofAccess.SERVER,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'uri', format: claimFormat.URI,
relation: claimRelation.CONTAINS,
path: [], path: [],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/ const reURI = /^https:\/\/liberapay\.com\/(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: `https://liberapay.com/${match[1]}/public.json`, fetch: `https://liberapay.com/${match[1]}/public.json`,
useProxy: false, access: proofAccess.GENERIC,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: ['statements', 'content'], path: ['statements', 'content'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/ const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: `https://lobste.rs/u/${match[1]}.json`, uri: `https://lobste.rs/u/${match[1]}.json`,
fetch: null, fetch: null,
useProxy: true, access: proofAccess.NOCORS,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: ['about'], path: ['about'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/(.*)\/@(.*)\/?/ const reURI = /^https:\/\/(.*)\/@(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: null, fetch: null,
useProxy: false, access: proofAccess.GENERIC,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'fingerprint', format: claimFormat.FINGERPRINT,
relation: claimRelation.CONTAINS,
path: ['attachment', 'value'], path: ['attachment', 'value'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,10 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const bent = require('bent') const bent = require('bent')
const req = bent('GET') const req = bent('GET')
const queryString = require('query-string') const queryString = require('query-string')
const utils = require('../utils') const utils = require('../utils')
const reURI = /^matrix\:u\/(?:\@)?([^@:]*\:[^?]*)(\?.*)?/ const reURI = /^matrix\:u\/(?:\@)?([^@:]*\:[^?]*)(\?.*)?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -55,14 +57,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: eventUrl, uri: eventUrl,
fetch: proofUrl, fetch: proofUrl,
useProxy: false, access: proofAccess.GRANTED,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: ['data', 'content', 'body'], path: ['data', 'content', 'body'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const bent = require('bent') const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const req = bent('GET')
const reURI = /^https:\/\/(.*)/ const reURI = /^https:\/\/(.*)/
@ -37,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: `${uri}/api/config`, uri: `${uri}/api/config`,
fetch: null, fetch: null,
useProxy: false, access: proofAccess.GENERIC,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'fingerprint', format: claimFormat.FINGERPRINT,
relation: claimRelation.CONTAINS,
path: ['socialHandles', 'url'], path: ['socialHandles', 'url'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const reURI = /^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.*)\/(.*)\/?/ const reURI = /^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.*)\/(.*)\/?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -34,14 +36,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`, fetch: `https://www.reddit.com/user/${match[1]}/comments/${match[2]}.json`,
useProxy: true, access: proofAccess.NOCORS,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: ['data', 'children', 'data', 'selftext'], path: ['data', 'children', 'data', 'selftext'],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }

View file

@ -13,10 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const bent = require('bent') const bent = require('bent')
const req = bent('GET') const req = bent('GET')
const serviceproviders = require('../serviceproviders') const serviceproviders = require('../serviceproviders')
const utils = require('../utils') const utils = require('../utils')
const reURI = /^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/ const reURI = /^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/
const customRequestHandler = async (spData, opts) => { const customRequestHandler = async (spData, opts) => {
@ -81,14 +83,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: uri, uri: uri,
fetch: utils.generateProxyURL('twitter', match[2], opts), fetch: utils.generateProxyURL('twitter', match[2], opts),
useProxy: false, access: proofAccess.GRANTED,
format: 'text', format: proofFormat.TEXT,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: [], path: [],
relation: 'contains',
}, },
customRequestHandler: customRequestHandler, customRequestHandler: customRequestHandler,
} }

View file

@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const { proofAccess, proofFormat, claimFormat, claimRelation } = require('../enums')
const utils = require('../utils') const utils = require('../utils')
const reURI = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/ const reURI = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
const processURI = (uri, opts) => { const processURI = (uri, opts) => {
@ -35,14 +37,14 @@ const processURI = (uri, opts) => {
proof: { proof: {
uri: utils.generateProxyURL('xmpp', `${match[1]}@${match[2]}`, opts), uri: utils.generateProxyURL('xmpp', `${match[1]}@${match[2]}`, opts),
fetch: null, fetch: null,
useProxy: false, access: proofAccess.SERVER,
format: 'json', format: proofFormat.JSON,
}, },
claim: { claim: {
fingerprint: null, fingerprint: null,
format: 'message', format: claimFormat.MESSAGE,
relation: claimRelation.CONTAINS,
path: [], path: [],
relation: 'contains',
}, },
customRequestHandler: null, customRequestHandler: null,
} }