forked from Mirrors/doipjs
Compare commits
14 commits
fix-jsdoc-
...
dev
Author | SHA1 | Date | |
---|---|---|---|
0f43a7b9e3 | |||
2153185729 | |||
a523ec4191 | |||
|
fa57e7b538 | ||
|
758255f652 | ||
|
fff5ce4aca | ||
06ea6732de | |||
|
041e22c52d | ||
|
6d464176df | ||
|
9b1a5d4d26 | ||
|
689117ac98 | ||
|
6d2606c8a9 | ||
|
fecaf7df12 | ||
|
c52632cbb6 |
19 changed files with 9975 additions and 6602 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
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.2.9] - 2024-02-01
|
||||
### Added
|
||||
- ORCiD identity claims
|
||||
### Changed
|
||||
- Improved code documentation
|
||||
- Optimized creation of Regexp instances
|
||||
### Fixed
|
||||
- Bad promise timeout logic
|
||||
- Dependencies cleaned up
|
||||
|
||||
## [1.2.8] - 2024-01-23
|
||||
### Added
|
||||
- OpenPGP and ASP claims
|
||||
|
|
1557
dist/doip.core.js
vendored
1557
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
1774
dist/doip.fetchers.js
vendored
1774
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
1774
dist/doip.fetchers.minimal.js
vendored
1774
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
|
@ -15,21 +15,26 @@
|
|||
}
|
||||
},
|
||||
"opts": {
|
||||
"template": "node_modules/clean-jsdoc-theme",
|
||||
"theme_opts": {
|
||||
"theme": "light",
|
||||
"menu": [
|
||||
{
|
||||
"title": "Source code",
|
||||
"link": "https://codeberg.org/keyoxide/doipjs",
|
||||
"target": "_blank"
|
||||
},
|
||||
{
|
||||
"title": "Keyoxide",
|
||||
"link": "https://keyoxide.org",
|
||||
"target": "_blank"
|
||||
}
|
||||
]
|
||||
"template": "node_modules/docdash",
|
||||
"destination": "docs/"
|
||||
},
|
||||
"docdash": {
|
||||
"collapse": true,
|
||||
"meta": {
|
||||
"title": "doipjs",
|
||||
"description": "Documentation for the doip.js library"
|
||||
},
|
||||
"menu": {
|
||||
"Keyoxide": {
|
||||
"href":"https://keyoxide.org",
|
||||
"target":"_blank",
|
||||
"class":"menu-item"
|
||||
},
|
||||
"Keyoxide docs": {
|
||||
"href":"https://docs.keyoxide.org",
|
||||
"target":"_blank",
|
||||
"class":"menu-item"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
package.json
14
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "doipjs",
|
||||
"version": "1.2.8",
|
||||
"name": "@myriation/doipjs",
|
||||
"version": "1.2.9+myriaiton.1",
|
||||
"description": "Decentralized Online Identity Proofs library in Node.js",
|
||||
"type": "module",
|
||||
"main": "./src/index.js",
|
||||
|
@ -15,7 +15,7 @@
|
|||
"default": "./src/fetcher/index.minimal.js"
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@1.22.19",
|
||||
"packageManager": "yarn@4.3.0",
|
||||
"dependencies": {
|
||||
"@openpgp/hkp-client": "^0.0.3",
|
||||
"@openpgp/wkd-client": "^0.0.4",
|
||||
|
@ -23,10 +23,7 @@
|
|||
"@xmpp/debug": "^0.13.0",
|
||||
"axios": "^1.6.5",
|
||||
"browser-or-node": "^1.3.0",
|
||||
"cors": "^2.8.5",
|
||||
"entities": "^4.4.0",
|
||||
"express": "^4.17.1",
|
||||
"express-validator": "^6.10.0",
|
||||
"hash-wasm": "^4.9.0",
|
||||
"irc-upd": "^0.11.0",
|
||||
"jose": "^4.14.4",
|
||||
|
@ -42,7 +39,7 @@
|
|||
"@rollup/plugin-node-resolve": "^15.1.0",
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"clean-jsdoc-theme": "^4.2.17",
|
||||
"docdash": "^2.0.2",
|
||||
"eslint": "^8.39.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
|
@ -56,7 +53,6 @@
|
|||
"lint-staged": "^11.0.0",
|
||||
"minify": "^9.1",
|
||||
"mocha": "^9.2.0",
|
||||
"nodemon": "^3.0.3",
|
||||
"rollup": "^3.26.2",
|
||||
"rollup-plugin-polyfill-node": "^0.12.0",
|
||||
"rollup-plugin-visualizer": "^5.9.2"
|
||||
|
@ -77,7 +73,7 @@
|
|||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/keyoxide/doipjs"
|
||||
"url": "https://git.myriation.org/myriation/doipjs"
|
||||
},
|
||||
"homepage": "https://js.doip.rocks",
|
||||
"keywords": [
|
||||
|
|
|
@ -22,4 +22,4 @@ limitations under the License.
|
|||
* doip.js library version
|
||||
* @constant {string}
|
||||
*/
|
||||
export const version = '1.2.8'
|
||||
export const version = '1.2.9+myriaiton.1'
|
||||
|
|
|
@ -35,7 +35,8 @@ export const opts = {
|
|||
privateKey: null
|
||||
},
|
||||
irc: {
|
||||
nick: null
|
||||
nick: null,
|
||||
sasl: []
|
||||
},
|
||||
matrix: {
|
||||
instance: null,
|
||||
|
|
|
@ -59,12 +59,25 @@ export async function fn (data, opts) {
|
|||
}
|
||||
|
||||
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, {
|
||||
port: 6697,
|
||||
secure: true,
|
||||
channels: [],
|
||||
showErrors: false,
|
||||
debug: false
|
||||
debug: false,
|
||||
...saslOptions
|
||||
})
|
||||
const reKey = /[a-zA-Z0-9\-_]+\s+:\s((?:openpgp4fpr|aspe):.*)/
|
||||
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 opencollective from './opencollective.js'
|
||||
import * as orcid from './orcid.js'
|
||||
import * as pronounscc from './pronounscc.js'
|
||||
import * as discord from './discord.js'
|
||||
|
||||
const _data = {
|
||||
aspe,
|
||||
|
@ -64,7 +66,9 @@ const _data = {
|
|||
stackexchange,
|
||||
keybase,
|
||||
opencollective,
|
||||
orcid
|
||||
orcid,
|
||||
pronounscc,
|
||||
discord
|
||||
}
|
||||
|
||||
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
|
||||
* @typedef {object} IrcClaimVerificationConfig
|
||||
* @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