forked from Mirrors/doipjs
Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
0f43a7b9e3 | |||
2153185729 | |||
a523ec4191 | |||
|
fa57e7b538 | ||
|
758255f652 | ||
|
fff5ce4aca | ||
06ea6732de | |||
|
041e22c52d | ||
|
6d464176df | ||
|
9b1a5d4d26 | ||
|
689117ac98 |
17 changed files with 8016 additions and 4921 deletions
BIN
.yarn/install-state.gz
Normal file
BIN
.yarn/install-state.gz
Normal file
Binary file not shown.
6
.yarnrc.yml
Normal file
6
.yarnrc.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
nodeLinker: node-modules
|
||||||
|
npmScopes:
|
||||||
|
myriation:
|
||||||
|
npmPublishRegistry: https://git.myriation.xyz/api/packages/myriation/npm/
|
||||||
|
npmAlwaysAuth: true
|
||||||
|
npmAuthToken: REPLACE-ME
|
643
dist/doip.core.js
vendored
643
dist/doip.core.js
vendored
File diff suppressed because it is too large
Load diff
4
dist/doip.core.min.js
vendored
4
dist/doip.core.min.js
vendored
File diff suppressed because one or more lines are too long
660
dist/doip.fetchers.js
vendored
660
dist/doip.fetchers.js
vendored
File diff suppressed because it is too large
Load diff
6
dist/doip.fetchers.min.js
vendored
6
dist/doip.fetchers.min.js
vendored
File diff suppressed because one or more lines are too long
660
dist/doip.fetchers.minimal.js
vendored
660
dist/doip.fetchers.minimal.js
vendored
File diff suppressed because it is too large
Load diff
6
dist/doip.fetchers.minimal.min.js
vendored
6
dist/doip.fetchers.minimal.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "doipjs",
|
"name": "@myriation/doipjs",
|
||||||
"version": "1.2.9",
|
"version": "1.2.9+myriaiton.1",
|
||||||
"description": "Decentralized Online Identity Proofs library in Node.js",
|
"description": "Decentralized Online Identity Proofs library in Node.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.js",
|
"main": "./src/index.js",
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
"default": "./src/fetcher/index.minimal.js"
|
"default": "./src/fetcher/index.minimal.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@1.22.19",
|
"packageManager": "yarn@4.3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@openpgp/hkp-client": "^0.0.3",
|
"@openpgp/hkp-client": "^0.0.3",
|
||||||
"@openpgp/wkd-client": "^0.0.4",
|
"@openpgp/wkd-client": "^0.0.4",
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://codeberg.org/keyoxide/doipjs"
|
"url": "https://git.myriation.org/myriation/doipjs"
|
||||||
},
|
},
|
||||||
"homepage": "https://js.doip.rocks",
|
"homepage": "https://js.doip.rocks",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
@ -22,4 +22,4 @@ limitations under the License.
|
||||||
* doip.js library version
|
* doip.js library version
|
||||||
* @constant {string}
|
* @constant {string}
|
||||||
*/
|
*/
|
||||||
export const version = '1.2.9'
|
export const version = '1.2.9+myriaiton.1'
|
||||||
|
|
|
@ -35,7 +35,8 @@ export const opts = {
|
||||||
privateKey: null
|
privateKey: null
|
||||||
},
|
},
|
||||||
irc: {
|
irc: {
|
||||||
nick: null
|
nick: null,
|
||||||
|
sasl: []
|
||||||
},
|
},
|
||||||
matrix: {
|
matrix: {
|
||||||
instance: null,
|
instance: null,
|
||||||
|
|
|
@ -59,12 +59,25 @@ export async function fn (data, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Add sasl-related config if the server matches
|
||||||
|
const matchedSaslConfig = opts.claims.irc.sasl.find(saslConfig => data.domain.match(new RegExp(saslConfig.domainRegex)) !== null)
|
||||||
|
const saslOptions = matchedSaslConfig
|
||||||
|
? {
|
||||||
|
sasl: true,
|
||||||
|
userName: matchedSaslConfig.username,
|
||||||
|
password: matchedSaslConfig.password
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
sasl: false
|
||||||
|
}
|
||||||
|
|
||||||
const client = new irc.Client(data.domain, opts.claims.irc.nick, {
|
const client = new irc.Client(data.domain, opts.claims.irc.nick, {
|
||||||
port: 6697,
|
port: 6697,
|
||||||
secure: true,
|
secure: true,
|
||||||
channels: [],
|
channels: [],
|
||||||
showErrors: false,
|
showErrors: false,
|
||||||
debug: false
|
debug: false,
|
||||||
|
...saslOptions
|
||||||
})
|
})
|
||||||
const reKey = /[a-zA-Z0-9\-_]+\s+:\s((?:openpgp4fpr|aspe):.*)/
|
const reKey = /[a-zA-Z0-9\-_]+\s+:\s((?:openpgp4fpr|aspe):.*)/
|
||||||
const reEnd = /End\sof\s.*\staxonomy./
|
const reEnd = /End\sof\s.*\staxonomy./
|
||||||
|
|
127
src/serviceProviders/discord.js
Normal file
127
src/serviceProviders/discord.js
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
Copyright 2024 Bram Hagens
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Discord service provider
|
||||||
|
* @module serviceProviders/discord
|
||||||
|
* @example
|
||||||
|
* import { ServiceProviderDefinitions } from 'doipjs';
|
||||||
|
* const sp = ServiceProviderDefinitions.data.discord.processURI('https://discord.com/invite/AbCdEf');
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as E from '../enums.js'
|
||||||
|
import { ServiceProvider } from '../serviceProvider.js'
|
||||||
|
|
||||||
|
export const reURI = /^https:\/\/(?:discord\.gg|discord\.com\/invite)\/(.+)/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {string} uri - Claim URI to process
|
||||||
|
* @returns {ServiceProvider} The service provider information based on the claim URI
|
||||||
|
*/
|
||||||
|
export function processURI (uri) {
|
||||||
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
|
return new ServiceProvider({
|
||||||
|
about: {
|
||||||
|
id: 'discord',
|
||||||
|
name: 'Discord',
|
||||||
|
homepage: 'https://discord.com'
|
||||||
|
},
|
||||||
|
profile: {
|
||||||
|
display: null,
|
||||||
|
uri: null,
|
||||||
|
qr: null
|
||||||
|
},
|
||||||
|
claim: {
|
||||||
|
uriRegularExpression: reURI.toString(),
|
||||||
|
uriIsAmbiguous: false
|
||||||
|
},
|
||||||
|
// Get proof from invites (https://discord.com/developers/docs/resources/invite#get-invite)
|
||||||
|
// See https://discord.com/developers/docs/reference#api-versioning for Discord's API versioning
|
||||||
|
proof: {
|
||||||
|
request: {
|
||||||
|
uri: `https://discord.com/api/v10/invites/${match[1]}`,
|
||||||
|
fetcher: E.Fetcher.HTTP,
|
||||||
|
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||||
|
data: {
|
||||||
|
url: `https://discord.com/api/v10/invites/${match[1]}`,
|
||||||
|
format: E.ProofFormat.JSON
|
||||||
|
}
|
||||||
|
},
|
||||||
|
response: {
|
||||||
|
format: E.ProofFormat.JSON
|
||||||
|
},
|
||||||
|
target: [
|
||||||
|
{
|
||||||
|
format: E.ClaimFormat.URI,
|
||||||
|
encoding: E.EntityEncodingFormat.PLAIN,
|
||||||
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
|
path: ['guild', 'description']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
format: E.ClaimFormat.URI,
|
||||||
|
encoding: E.EntityEncodingFormat.PLAIN,
|
||||||
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
|
path: ['guild', 'name']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const functions = {
|
||||||
|
postprocess: async (claimData, proofData, opts) => {
|
||||||
|
// Extract inviter's username from https://discord.com/developers/docs/resources/invite#invite-object
|
||||||
|
claimData.profile.display = proofData.result.inviter.username
|
||||||
|
|
||||||
|
return { claimData, proofData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const tests = [
|
||||||
|
{
|
||||||
|
uri: 'https://discord.com/invite/AbCdEf',
|
||||||
|
shouldMatch: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://discord.com/invite/AbCdEfGh',
|
||||||
|
shouldMatch: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://discord.gg/AbCdEf',
|
||||||
|
shouldMatch: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://discord.gg/AbCdEfGh',
|
||||||
|
shouldMatch: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://domain.com/invite/AbCdEf',
|
||||||
|
shouldMatch: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://domain.gg/AbCdEf',
|
||||||
|
shouldMatch: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://discord.com/invite/',
|
||||||
|
shouldMatch: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://discord.gg/',
|
||||||
|
shouldMatch: false
|
||||||
|
}
|
||||||
|
]
|
|
@ -38,6 +38,8 @@ import * as stackexchange from './stackexchange.js'
|
||||||
import * as keybase from './keybase.js'
|
import * as keybase from './keybase.js'
|
||||||
import * as opencollective from './opencollective.js'
|
import * as opencollective from './opencollective.js'
|
||||||
import * as orcid from './orcid.js'
|
import * as orcid from './orcid.js'
|
||||||
|
import * as pronounscc from './pronounscc.js'
|
||||||
|
import * as discord from './discord.js'
|
||||||
|
|
||||||
const _data = {
|
const _data = {
|
||||||
aspe,
|
aspe,
|
||||||
|
@ -64,7 +66,9 @@ const _data = {
|
||||||
stackexchange,
|
stackexchange,
|
||||||
keybase,
|
keybase,
|
||||||
opencollective,
|
opencollective,
|
||||||
orcid
|
orcid,
|
||||||
|
pronounscc,
|
||||||
|
discord
|
||||||
}
|
}
|
||||||
|
|
||||||
export const list = Object.keys(_data)
|
export const list = Object.keys(_data)
|
||||||
|
|
100
src/serviceProviders/pronounscc.js
Normal file
100
src/serviceProviders/pronounscc.js
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
Copyright 2024 Tyler Beckman
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* pronouns.cc service provider
|
||||||
|
* @module serviceProviders/pronounscc
|
||||||
|
* @example
|
||||||
|
* import { ServiceProviderDefinitions } from 'doipjs';
|
||||||
|
* const sp = ServiceProviderDefinitions.data.pronounscc.processURI('https://pronouns.cc/@Alice');
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as E from '../enums.js'
|
||||||
|
import { ServiceProvider } from '../serviceProvider.js'
|
||||||
|
|
||||||
|
export const reURI = /^https:\/\/pronouns\.cc\/@(.*)\/?/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {string} uri - Claim URI to process
|
||||||
|
* @returns {ServiceProvider} The service provider information based on the claim URI
|
||||||
|
*/
|
||||||
|
export function processURI (uri) {
|
||||||
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
|
return new ServiceProvider({
|
||||||
|
about: {
|
||||||
|
id: 'pronounscc',
|
||||||
|
name: 'pronouns.cc',
|
||||||
|
homepage: 'https://pronouns.cc'
|
||||||
|
},
|
||||||
|
profile: {
|
||||||
|
display: `@${match[1]}`,
|
||||||
|
uri: `https://pronouns.cc/@${match[1]}`,
|
||||||
|
qr: null
|
||||||
|
},
|
||||||
|
claim: {
|
||||||
|
uriRegularExpression: reURI.toString(),
|
||||||
|
uriIsAmbiguous: false
|
||||||
|
},
|
||||||
|
proof: {
|
||||||
|
request: {
|
||||||
|
uri,
|
||||||
|
fetcher: E.Fetcher.HTTP,
|
||||||
|
accessRestriction: E.ProofAccessRestriction.NOCORS,
|
||||||
|
data: {
|
||||||
|
url: `https://pronouns.cc/api/v1/users/${match[1]}`,
|
||||||
|
format: E.ProofFormat.JSON
|
||||||
|
}
|
||||||
|
},
|
||||||
|
response: {
|
||||||
|
format: E.ProofFormat.JSON
|
||||||
|
},
|
||||||
|
target: [
|
||||||
|
{
|
||||||
|
format: E.ClaimFormat.URI,
|
||||||
|
encoding: E.EntityEncodingFormat.PLAIN,
|
||||||
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
|
path: ['links']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
format: E.ClaimFormat.URI,
|
||||||
|
encoding: E.EntityEncodingFormat.PLAIN,
|
||||||
|
relation: E.ClaimRelation.CONTAINS,
|
||||||
|
path: ['bio']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const tests = [
|
||||||
|
{
|
||||||
|
uri: 'https://pronouns.cc/@Alice',
|
||||||
|
shouldMatch: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://pronouns.cc/@Alice/',
|
||||||
|
shouldMatch: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://pronouns.cc/Alice',
|
||||||
|
shouldMatch: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uri: 'https://pronouns.cc/Alice/',
|
||||||
|
shouldMatch: false
|
||||||
|
}
|
||||||
|
]
|
|
@ -130,6 +130,7 @@ import { PublicKeyType, PublicKeyEncoding, PublicKeyFetchMethod, ProxyPolicy, Cl
|
||||||
* Config related to the verification of IRC claims
|
* Config related to the verification of IRC claims
|
||||||
* @typedef {object} IrcClaimVerificationConfig
|
* @typedef {object} IrcClaimVerificationConfig
|
||||||
* @property {string} nick - The nick that the library uses to connect to the IRC server
|
* @property {string} nick - The nick that the library uses to connect to the IRC server
|
||||||
|
* @property {{ domainRegex: string; username: string; password: string; }[]} sasl - An array of possible SASL logins
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue