Compare commits

...

14 commits

Author SHA1 Message Date
Ty
0f43a7b9e3
Update for publishing 2024-06-14 22:50:22 -06:00
Ty
2153185729
Add sasl support 2024-06-14 22:15:42 -06:00
Ty
a523ec4191
Update to yarn modern 2024-06-14 22:15:21 -06:00
André Jaenisch
fa57e7b538 feat: add discord support
bump discord API version to v10

accept discord.gg urls

allow proof in guild name

add comments

Reviewed-on: https://codeberg.org/keyoxide/doipjs/pulls/85
2024-04-08 13:44:44 +00:00
Bram Hagens
758255f652
add comments 2024-04-08 00:22:44 +02:00
Bram Hagens
fff5ce4aca
Merge remote-tracking branch 'upstream/dev' into support-discord 2024-04-08 00:05:52 +02:00
Ty
06ea6732de
Add pronouns.cc verification 2024-03-22 18:44:49 -06:00
Bram Hagens
041e22c52d
allow proof in guild name 2024-02-08 10:36:18 +01:00
Bram Hagens
6d464176df
accept discord.gg urls 2024-02-08 10:36:18 +01:00
Bram Hagens
9b1a5d4d26
bump discord API version to v10 2024-02-08 10:11:52 +01:00
Bram Hagens
689117ac98
feat: add discord support 2024-02-08 01:04:16 +01:00
Yarmo Mackenbach
6d2606c8a9
chore: release 1.2.9 2024-02-01 17:06:40 +01:00
Dario Vladovic
fecaf7df12 feat: remove unused dependencies 2024-01-31 02:47:48 +00:00
Yarmo Mackenbach
c52632cbb6
feat: change jsdoc theme 2024-01-30 01:13:36 +01:00
19 changed files with 9975 additions and 6602 deletions

BIN
.yarn/install-state.gz Normal file

Binary file not shown.

6
.yarnrc.yml Normal file
View file

@ -0,0 +1,6 @@
nodeLinker: node-modules
npmScopes:
myriation:
npmPublishRegistry: https://git.myriation.xyz/api/packages/myriation/npm/
npmAlwaysAuth: true
npmAuthToken: REPLACE-ME

View file

@ -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

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

1774
dist/doip.fetchers.js vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -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"
}
}
}
}

View file

@ -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": [

View file

@ -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'

View file

@ -35,7 +35,8 @@ export const opts = {
privateKey: null
},
irc: {
nick: null
nick: null,
sasl: []
},
matrix: {
instance: null,

View file

@ -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./

View 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
}
]

View file

@ -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)

View 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
}
]

View file

@ -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
*/
/**

11137
yarn.lock

File diff suppressed because it is too large Load diff