feat: support forgejo

This commit is contained in:
Yarmo Mackenbach 2023-09-23 09:45:15 +02:00
parent 264645b381
commit ea8eb234ad
No known key found for this signature in database
GPG key ID: 3C57D093219103A3
2 changed files with 11 additions and 2 deletions

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as E from '../enums.js' import * as E from '../enums.js'
import { fetcher } from '../index.js'
import { ServiceProvider } from '../serviceProvider.js' import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/ export const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
@ -63,6 +64,14 @@ export function processURI (uri) {
}) })
} }
export const functions = {
validate: async (/** @type {ServiceProvider} */ claimData, proofData, opts) => {
const url = `https://${new URL(claimData.proof.request.uri).hostname}/api/forgejo/v1/version`
const forgejoData = await fetcher.http.fn({ url, format: E.ProofFormat.JSON }, opts)
return forgejoData && 'version' in forgejoData
}
}
export const tests = [ export const tests = [
{ {
uri: 'https://domain.org/alice/forgejo_proof', uri: 'https://domain.org/alice/forgejo_proof',

View file

@ -25,7 +25,7 @@ import * as lichess from './lichess.js'
import * as hackernews from './hackernews.js' import * as hackernews from './hackernews.js'
import * as lobsters from './lobsters.js' import * as lobsters from './lobsters.js'
import * as forem from './forem.js' import * as forem from './forem.js'
// import * as forgejo from './forgejo.js' import * as forgejo from './forgejo.js'
import * as gitea from './gitea.js' import * as gitea from './gitea.js'
import * as gitlab from './gitlab.js' import * as gitlab from './gitlab.js'
import * as github from './github.js' import * as github from './github.js'
@ -49,7 +49,7 @@ const _data = {
hackernews, hackernews,
lobsters, lobsters,
forem, forem,
// forgejo, forgejo,
gitea, gitea,
gitlab, gitlab,
github, github,