mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
feat: Add ORCID service provider
This commit is contained in:
parent
626077f880
commit
0dd0d91104
2 changed files with 87 additions and 1 deletions
|
@ -37,6 +37,7 @@ import * as owncast from './owncast.js'
|
||||||
import * as stackexchange from './stackexchange.js'
|
import * as stackexchange from './stackexchange.js'
|
||||||
import * as keybase from './keybase.js'
|
import * as keybase from './keybase.js'
|
||||||
import * as opencollective from './opencollective.js'
|
import * as opencollective from './opencollective.js'
|
||||||
|
import * as orcid from './orcid.js'
|
||||||
|
|
||||||
const _data = {
|
const _data = {
|
||||||
aspe,
|
aspe,
|
||||||
|
@ -62,7 +63,8 @@ const _data = {
|
||||||
owncast,
|
owncast,
|
||||||
stackexchange,
|
stackexchange,
|
||||||
keybase,
|
keybase,
|
||||||
opencollective
|
opencollective,
|
||||||
|
orcid
|
||||||
}
|
}
|
||||||
|
|
||||||
export const list = Object.keys(_data)
|
export const list = Object.keys(_data)
|
||||||
|
|
84
src/serviceProviders/orcid.js
Normal file
84
src/serviceProviders/orcid.js
Normal 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
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in a new issue