forked from Mirrors/doipjs
chore: release 1.0.1
This commit is contained in:
parent
d8529a7f92
commit
549a86c121
9 changed files with 157 additions and 15 deletions
|
@ -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).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.0.1] - 2023-09-18
|
||||
### Fixed
|
||||
- Ignore OpenPGP users without userId
|
||||
- OpenCollective GraphQL queries
|
||||
- Improve ActivityPub post proofs support
|
||||
|
||||
## [1.0.0] - 2023-07-13
|
||||
### Changed
|
||||
|
|
152
dist/doip.core.js
vendored
152
dist/doip.core.js
vendored
|
@ -1,4 +1,4 @@
|
|||
var doip = (function (exports, fetcher, openpgp$1) {
|
||||
var doip = (function (exports, openpgp$1, fetcher) {
|
||||
'use strict';
|
||||
|
||||
function _interopNamespaceDefault(e) {
|
||||
|
@ -4660,12 +4660,148 @@ var doip = (function (exports, fetcher, openpgp$1) {
|
|||
}
|
||||
|
||||
const functions = {
|
||||
postprocess: (claimData, proofData) => {
|
||||
claimData.profile.display = `@${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}`;
|
||||
postprocess: async (/** @type {ServiceProvider} */ claimData, proofData, opts) => {
|
||||
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 }
|
||||
}
|
||||
};
|
||||
|
||||
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 = [
|
||||
{
|
||||
uri: 'https://domain.org',
|
||||
|
@ -5143,7 +5279,7 @@ var doip = (function (exports, fetcher, openpgp$1) {
|
|||
accessRestriction: ProofAccessRestriction.NOCORS,
|
||||
data: {
|
||||
url: 'https://api.opencollective.com/graphql/v2',
|
||||
query: `{ "query": "query { collective(slug: \\"${match[1]}\\") { longDescription } }" }`
|
||||
query: `{ "query": "query { account(slug: \\"${match[1]}\\") { longDescription } }" }`
|
||||
}
|
||||
},
|
||||
response: {
|
||||
|
@ -5153,7 +5289,7 @@ var doip = (function (exports, fetcher, openpgp$1) {
|
|||
format: ClaimFormat.URI,
|
||||
encoding: EntityEncodingFormat.PLAIN,
|
||||
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];
|
||||
if (def.functions?.postprocess) {
|
||||
try {
|
||||
({ claimData, proofData } = def.functions.postprocess(claimData, proofData));
|
||||
({ claimData, proofData } = await def.functions.postprocess(claimData, proofData, opts$1));
|
||||
} catch (_) {}
|
||||
}
|
||||
} else {
|
||||
|
@ -8180,6 +8316,8 @@ var doip = (function (exports, fetcher, openpgp$1) {
|
|||
const personas = [];
|
||||
|
||||
users.forEach((user, i) => {
|
||||
if (!user.userID) return
|
||||
|
||||
const pe = new Persona(user.userID.name, []);
|
||||
pe.setIdentifier(user.userID.userID);
|
||||
pe.setDescription(user.userID.comment);
|
||||
|
@ -9565,4 +9703,4 @@ var doip = (function (exports, fetcher, openpgp$1) {
|
|||
|
||||
return exports;
|
||||
|
||||
})({}, doipFetchers, openpgp);
|
||||
})({}, openpgp, doipFetchers);
|
||||
|
|
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
2
dist/doip.fetchers.js
vendored
2
dist/doip.fetchers.js
vendored
|
@ -2728,7 +2728,7 @@ var doipFetchers = (function (exports) {
|
|||
* doip.js library version
|
||||
* @constant {string}
|
||||
*/
|
||||
const version = '0.20.0';
|
||||
const version = '1.0.1';
|
||||
|
||||
/*
|
||||
Copyright 2022 Yarmo Mackenbach
|
||||
|
|
2
dist/doip.fetchers.min.js
vendored
2
dist/doip.fetchers.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/doip.fetchers.minimal.js
vendored
2
dist/doip.fetchers.minimal.js
vendored
|
@ -2698,7 +2698,7 @@ var doipFetchers = (function (exports) {
|
|||
* doip.js library version
|
||||
* @constant {string}
|
||||
*/
|
||||
const version = '0.20.0';
|
||||
const version = '1.0.1';
|
||||
|
||||
/*
|
||||
Copyright 2022 Yarmo Mackenbach
|
||||
|
|
2
dist/doip.fetchers.minimal.min.js
vendored
2
dist/doip.fetchers.minimal.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "doipjs",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Decentralized Online Identity Proofs library in Node.js",
|
||||
"type": "module",
|
||||
"main": "./src/index.js",
|
||||
|
|
|
@ -22,4 +22,4 @@ limitations under the License.
|
|||
* doip.js library version
|
||||
* @constant {string}
|
||||
*/
|
||||
export const version = '1.0.0'
|
||||
export const version = '1.0.1'
|
||||
|
|
Loading…
Reference in a new issue