feat: Add ORCID service provider

This commit is contained in:
Tim Haase 2023-05-23 15:26:05 +02:00 committed by Yarmo Mackenbach
parent 626077f880
commit 0dd0d91104
2 changed files with 87 additions and 1 deletions

View file

@ -37,6 +37,7 @@ import * as owncast from './owncast.js'
import * as stackexchange from './stackexchange.js'
import * as keybase from './keybase.js'
import * as opencollective from './opencollective.js'
import * as orcid from './orcid.js'
const _data = {
aspe,
@ -62,7 +63,8 @@ const _data = {
owncast,
stackexchange,
keybase,
opencollective
opencollective,
orcid
}
export const list = Object.keys(_data)

View file

@ -0,0 +1,84 @@
/*
Copyright 2023 Tim Haase
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.
*/
import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/orcid\.org\/(.*)\/?/
/**
* @function
* @param {string} uri
*/
export function processURI (uri) {
const match = uri.match(reURI)
return new ServiceProvider({
about: {
id: 'orcid',
name: 'ORCiD',
homepage: 'https://orcid.org/'
},
profile: {
display: match[1],
uri,
qr: null
},
claim: {
uriRegularExpression: reURI.toString(),
uriIsAmbiguous: false
},
proof: {
request: {
uri,
fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NONE,
data: {
url: uri,
format: E.ProofFormat.JSON
}
},
response: {
format: E.ProofFormat.JSON
},
target: [{
format: E.ClaimFormat.URI,
encoding: E.EntityEncodingFormat.PLAIN,
relation: E.ClaimRelation.EQUALS,
path: ['person', 'researcher-urls', 'researcher-url', 'url', 'value']
}, {
format: E.ClaimFormat.URI,
encoding: E.EntityEncodingFormat.PLAIN,
relation: E.ClaimRelation.EQUALS,
path: ['person', 'keywords', 'keyword', 'content']
}]
}
})
}
export const tests = [
{
uri: 'https://orcid.org/0000-0000-0000-0000',
shouldMatch: true
},
{
uri: 'https://orcid.org/0000-0000-0000-0000/',
shouldMatch: true
},
{
uri: 'https://domain.org/0000-0000-0000-0000',
shouldMatch: false
}
]