mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 06:29:28 -07:00
feat: add sourcehut provider
This commit is contained in:
parent
6a5f3a773e
commit
ae3f84d477
11 changed files with 1568 additions and 646 deletions
|
@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- SourceHut identity claims
|
||||
- Bluesky identity claims
|
||||
|
||||
## [2.0.1] - 2024-09-01
|
||||
|
@ -480,4 +481,4 @@ Bump necessary due to tag-related glitch in git forge
|
|||
- Dots in URL regex
|
||||
|
||||
## [0.2.0] - 2020-11-03
|
||||
Initial release
|
||||
Initial release
|
|
@ -47,7 +47,7 @@ const verifyIdentity = async (url, fp) => {
|
|||
const claim = new doip.Claim(url, fp)
|
||||
claim.match()
|
||||
await claim.verify()
|
||||
console.log(claim.result)
|
||||
console.log(claim.toJSON())
|
||||
}
|
||||
verifyIdentity('dns:doip.rocks', '9f0048ac0b23301e1f77e994909f6bd6f80f485d')
|
||||
```
|
||||
|
@ -80,4 +80,4 @@ Please note that this project has a [Code of Conduct](https://codeberg.org/keyox
|
|||
|
||||
The Keyoxide project strives for a healthier internet for all and has made its efforts fully [open source](https://codeberg.org/keyoxide). Our [community](https://docs.keyoxide.org/community/) is open and welcoming, feel free to say hi!
|
||||
|
||||
Funding for the project comes from the [NLnet foundation](https://nlnet.nl/), [NGI0](https://www.ngi.eu/) and the people supporting our [OpenCollective](https://opencollective.com/keyoxide). The project is grateful for all your support.
|
||||
Funding for the project comes from the [NLnet foundation](https://nlnet.nl/), [NGI0](https://www.ngi.eu/) and the people supporting our [OpenCollective](https://opencollective.com/keyoxide). The project is grateful for all your support.
|
698
dist/doip.core.js
vendored
698
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
698
dist/doip.fetchers.js
vendored
698
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
698
dist/doip.fetchers.minimal.js
vendored
698
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
|
@ -2,7 +2,8 @@ import * as doip from '../src/index.js'
|
|||
|
||||
const main = async () => {
|
||||
// const sp = doip.ServiceProviderDefinitions.data['activitypub'].processURI('https://fosstodon.org/@yarmo')
|
||||
const sp = doip.ServiceProviderDefinitions.data['discourse'].processURI('https://domain.org/u/alice')
|
||||
// const sp = doip.ServiceProviderDefinitions.data['discourse'].processURI('https://domain.org/u/alice')
|
||||
const sp = doip.ServiceProviderDefinitions.data['sourcehut'].processURI('https://git.sr.ht/~alice/keyoxide_proof')
|
||||
console.log(sp);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import * as orcid from './orcid.js'
|
|||
import * as pronounscc from './pronounscc.js'
|
||||
import * as discord from './discord.js'
|
||||
import * as bsky from './bsky.js'
|
||||
import * as sourcehut from './sourcehut.js'
|
||||
|
||||
const _data = {
|
||||
aspe,
|
||||
|
@ -70,7 +71,8 @@ const _data = {
|
|||
orcid,
|
||||
pronounscc,
|
||||
discord,
|
||||
bsky
|
||||
bsky,
|
||||
sourcehut
|
||||
}
|
||||
|
||||
export const list = Object.keys(_data)
|
||||
|
|
90
src/serviceProviders/sourcehut.js
Normal file
90
src/serviceProviders/sourcehut.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
Copyright 2024 quaff
|
||||
|
||||
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.
|
||||
*/
|
||||
/**
|
||||
* SourceHut service provider ({@link https://docs.keyoxide.org/service-providers/sourcehut/|Keyoxide docs})
|
||||
* @module serviceProviders/sourcehut
|
||||
* @example
|
||||
* import { ServiceProviderDefinitions } from 'doipjs';
|
||||
* const sp = ServiceProviderDefinitions.data.sourcehut.processURI('https://git.sr.ht/~alice/keyoxide_proof')
|
||||
*/
|
||||
|
||||
import * as E from '../enums.js'
|
||||
import { ServiceProvider } from '../serviceProvider.js'
|
||||
|
||||
export const reURI = /^https:\/\/git\.sr\.ht\/~([^~]*)\/(.*)\/?/
|
||||
|
||||
/**
|
||||
* @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: 'sourcehut',
|
||||
name: 'SourceHut',
|
||||
homepage: 'https://sourcehut.org'
|
||||
},
|
||||
profile: {
|
||||
display: match[1],
|
||||
uri: `https://sr.ht/~${match[1]}`,
|
||||
qr: null
|
||||
},
|
||||
claim: {
|
||||
uriRegularExpression: reURI.toString(),
|
||||
uriIsAmbiguous: false
|
||||
},
|
||||
proof: {
|
||||
request: {
|
||||
uri,
|
||||
fetcher: E.Fetcher.HTTP,
|
||||
accessRestriction: E.ProofAccessRestriction.NONE,
|
||||
data: {
|
||||
url: `https://git.sr.ht/~${match[1]}/${match[2]}/blob/main/proof.md`,
|
||||
format: E.ProofFormat.TEXT
|
||||
}
|
||||
},
|
||||
response: {
|
||||
format: E.ProofFormat.TEXT
|
||||
},
|
||||
target: [
|
||||
{
|
||||
format: E.ClaimFormat.URI,
|
||||
encoding: E.EntityEncodingFormat.PLAIN,
|
||||
relation: E.ClaimRelation.CONTAINS,
|
||||
path: []
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const tests = [
|
||||
{
|
||||
uri: 'https://git.sr.ht/~alice/sourcehut_proof',
|
||||
shouldMatch: true
|
||||
},
|
||||
{
|
||||
uri: 'https://git.sr.ht/~alice/keyoxide_proof/',
|
||||
shouldMatch: true
|
||||
},
|
||||
{
|
||||
uri: 'https://domain.org/alice/keyoxide_proof',
|
||||
shouldMatch: false
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue