mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39: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]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
|
- SourceHut identity claims
|
||||||
- Bluesky identity claims
|
- Bluesky identity claims
|
||||||
|
|
||||||
## [2.0.1] - 2024-09-01
|
## [2.0.1] - 2024-09-01
|
||||||
|
|
|
@ -47,7 +47,7 @@ const verifyIdentity = async (url, fp) => {
|
||||||
const claim = new doip.Claim(url, fp)
|
const claim = new doip.Claim(url, fp)
|
||||||
claim.match()
|
claim.match()
|
||||||
await claim.verify()
|
await claim.verify()
|
||||||
console.log(claim.result)
|
console.log(claim.toJSON())
|
||||||
}
|
}
|
||||||
verifyIdentity('dns:doip.rocks', '9f0048ac0b23301e1f77e994909f6bd6f80f485d')
|
verifyIdentity('dns:doip.rocks', '9f0048ac0b23301e1f77e994909f6bd6f80f485d')
|
||||||
```
|
```
|
||||||
|
|
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 main = async () => {
|
||||||
// const sp = doip.ServiceProviderDefinitions.data['activitypub'].processURI('https://fosstodon.org/@yarmo')
|
// 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);
|
console.log(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import * as orcid from './orcid.js'
|
||||||
import * as pronounscc from './pronounscc.js'
|
import * as pronounscc from './pronounscc.js'
|
||||||
import * as discord from './discord.js'
|
import * as discord from './discord.js'
|
||||||
import * as bsky from './bsky.js'
|
import * as bsky from './bsky.js'
|
||||||
|
import * as sourcehut from './sourcehut.js'
|
||||||
|
|
||||||
const _data = {
|
const _data = {
|
||||||
aspe,
|
aspe,
|
||||||
|
@ -70,7 +71,8 @@ const _data = {
|
||||||
orcid,
|
orcid,
|
||||||
pronounscc,
|
pronounscc,
|
||||||
discord,
|
discord,
|
||||||
bsky
|
bsky,
|
||||||
|
sourcehut
|
||||||
}
|
}
|
||||||
|
|
||||||
export const list = Object.keys(_data)
|
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