chore: release 1.0.1

This commit is contained in:
Yarmo Mackenbach 2023-09-18 17:46:54 +02:00
parent d8529a7f92
commit 549a86c121
No known key found for this signature in database
GPG key ID: 3C57D093219103A3
9 changed files with 157 additions and 15 deletions

View file

@ -5,8 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
## [1.0.1] - 2023-09-18
### Fixed ### Fixed
- Ignore OpenPGP users without userId - Ignore OpenPGP users without userId
- OpenCollective GraphQL queries
- Improve ActivityPub post proofs support
## [1.0.0] - 2023-07-13 ## [1.0.0] - 2023-07-13
### Changed ### Changed

152
dist/doip.core.js vendored
View file

@ -1,4 +1,4 @@
var doip = (function (exports, fetcher, openpgp$1) { var doip = (function (exports, openpgp$1, fetcher) {
'use strict'; 'use strict';
function _interopNamespaceDefault(e) { function _interopNamespaceDefault(e) {
@ -4660,12 +4660,148 @@ var doip = (function (exports, fetcher, openpgp$1) {
} }
const functions = { const functions = {
postprocess: (claimData, proofData) => { postprocess: async (/** @type {ServiceProvider} */ claimData, proofData, opts) => {
claimData.profile.display = `@${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}`; switch (proofData.result.type) {
case 'Note': {
claimData.profile.uri = proofData.result.attributedTo;
const personData = await fetcher__namespace.activitypub.fn({ url: proofData.result.attributedTo }, opts);
claimData.profile.display = `@${personData.preferredUsername}@${new URL(proofData.result.url).hostname}`;
break
}
case 'Person':
claimData.profile.display = `@${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}`;
break
}
// Attempt to fetch and process the instance's NodeInfo data
const nodeinfo = await _processNodeinfo(new URL(proofData.result.url).hostname);
if (nodeinfo) {
claimData.about.name = nodeinfo.software.name;
claimData.about.id = nodeinfo.software.name;
claimData.about.homepage = nodeinfo.software.homepage;
}
return { claimData, proofData } return { claimData, proofData }
} }
}; };
const _processNodeinfo = async (/** @type {string} */ domain) => {
const nodeinfoRef = await fetch(`http://${domain}/.well-known/nodeinfo`)
.then(res => {
if (res.status !== 200) {
throw new Error('HTTP Status was not 200')
}
return res.json()
})
.catch(_ => {
return null
});
if (!nodeinfoRef) return null
// NodeInfo version 2.1
{
const nodeinfo = nodeinfoRef.links.find(x => { return x.rel === 'http://nodeinfo.diaspora.software/ns/schema/2.1' });
if (nodeinfo) {
return await fetch(nodeinfo.href)
.then(res => {
if (res.status !== 200) {
throw new Error('HTTP Status was not 200')
}
return res.json()
})
.then(res => {
return {
software: {
name: res.software.name,
version: res.software.version,
homepage: res.software.homepage || 'https://activitypub.rocks'
}
}
})
.catch(_ => {
return null
})
}
}
// NodeInfo version 2.0
{
const nodeinfo = nodeinfoRef.links.find(x => { return x.rel === 'http://nodeinfo.diaspora.software/ns/schema/2.0' });
if (nodeinfo) {
return await fetch(nodeinfo.href)
.then(res => {
if (res.status !== 200) {
throw new Error('HTTP Status was not 200')
}
return res.json()
})
.then(res => {
return {
software: {
name: res.software.name,
version: res.software.version,
homepage: 'https://activitypub.rocks'
}
}
})
.catch(_ => {
return null
})
}
}
// NodeInfo version 1.1
{
const nodeinfo = nodeinfoRef.links.find(x => { return x.rel === 'http://nodeinfo.diaspora.software/ns/schema/1.1' });
if (nodeinfo) {
return await fetch(nodeinfo.href)
.then(res => {
if (res.status !== 200) {
throw new Error('HTTP Status was not 200')
}
return res.json()
})
.then(res => {
return {
software: {
name: res.software.name,
version: res.software.version,
homepage: 'https://activitypub.rocks'
}
}
})
.catch(_ => {
return null
})
}
}
// NodeInfo version 1.0
{
const nodeinfo = nodeinfoRef.links.find(x => { return x.rel === 'http://nodeinfo.diaspora.software/ns/schema/1.0' });
if (nodeinfo) {
return await fetch(nodeinfo.href)
.then(res => {
if (res.status !== 200) {
throw new Error('HTTP Status was not 200')
}
return res.json()
})
.then(res => {
return {
software: {
name: res.software.name,
version: res.software.version,
homepage: 'https://activitypub.rocks'
}
}
})
.catch(_ => {
return null
})
}
}
};
const tests$5 = [ const tests$5 = [
{ {
uri: 'https://domain.org', uri: 'https://domain.org',
@ -5143,7 +5279,7 @@ var doip = (function (exports, fetcher, openpgp$1) {
accessRestriction: ProofAccessRestriction.NOCORS, accessRestriction: ProofAccessRestriction.NOCORS,
data: { data: {
url: 'https://api.opencollective.com/graphql/v2', url: 'https://api.opencollective.com/graphql/v2',
query: `{ "query": "query { collective(slug: \\"${match[1]}\\") { longDescription } }" }` query: `{ "query": "query { account(slug: \\"${match[1]}\\") { longDescription } }" }`
} }
}, },
response: { response: {
@ -5153,7 +5289,7 @@ var doip = (function (exports, fetcher, openpgp$1) {
format: ClaimFormat.URI, format: ClaimFormat.URI,
encoding: EntityEncodingFormat.PLAIN, encoding: EntityEncodingFormat.PLAIN,
relation: ClaimRelation.CONTAINS, relation: ClaimRelation.CONTAINS,
path: ['data', 'collective', 'longDescription'] path: ['data', 'account', 'longDescription']
}] }]
} }
}) })
@ -5569,7 +5705,7 @@ var doip = (function (exports, fetcher, openpgp$1) {
const def = _data[claimData.about.id]; const def = _data[claimData.about.id];
if (def.functions?.postprocess) { if (def.functions?.postprocess) {
try { try {
({ claimData, proofData } = def.functions.postprocess(claimData, proofData)); ({ claimData, proofData } = await def.functions.postprocess(claimData, proofData, opts$1));
} catch (_) {} } catch (_) {}
} }
} else { } else {
@ -8180,6 +8316,8 @@ var doip = (function (exports, fetcher, openpgp$1) {
const personas = []; const personas = [];
users.forEach((user, i) => { users.forEach((user, i) => {
if (!user.userID) return
const pe = new Persona(user.userID.name, []); const pe = new Persona(user.userID.name, []);
pe.setIdentifier(user.userID.userID); pe.setIdentifier(user.userID.userID);
pe.setDescription(user.userID.comment); pe.setDescription(user.userID.comment);
@ -9565,4 +9703,4 @@ var doip = (function (exports, fetcher, openpgp$1) {
return exports; return exports;
})({}, doipFetchers, openpgp); })({}, openpgp, doipFetchers);

File diff suppressed because one or more lines are too long

View file

@ -2728,7 +2728,7 @@ var doipFetchers = (function (exports) {
* doip.js library version * doip.js library version
* @constant {string} * @constant {string}
*/ */
const version = '0.20.0'; const version = '1.0.1';
/* /*
Copyright 2022 Yarmo Mackenbach Copyright 2022 Yarmo Mackenbach

File diff suppressed because one or more lines are too long

View file

@ -2698,7 +2698,7 @@ var doipFetchers = (function (exports) {
* doip.js library version * doip.js library version
* @constant {string} * @constant {string}
*/ */
const version = '0.20.0'; const version = '1.0.1';
/* /*
Copyright 2022 Yarmo Mackenbach Copyright 2022 Yarmo Mackenbach

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "doipjs", "name": "doipjs",
"version": "1.0.0", "version": "1.0.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",

View file

@ -22,4 +22,4 @@ limitations under the License.
* doip.js library version * doip.js library version
* @constant {string} * @constant {string}
*/ */
export const version = '1.0.0' export const version = '1.0.1'