@soid/core
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@soid/core

Give your Solid service a Solid-OIDC-compatible identity.

Overview

This library:

  • tells you which endpoints your service has to serve: getEndpoints(webId: string, issuer?: string)
  • provides authenticated fetch that your service can use to access protected resources: await getAuthenticatedFetch(webId: string, issuer?: string)

Please consider using higher-level libraries like @soid/koa.

Usage

Installation

npm install --save @soid/core
# or
yarn add @soid/core

Identity for service's own webId

By default, your service can serve its own webId.

import { getEndpoints, getAuthenticatedFetch } from '@soid/core'

// The webId's origin has to match the service's origin
const webId = 'https://service.example/profile/card#bot'

// Get authenticated fetch to make requests with this identity
const authenticatedFetch = await getAuthenticatedFetch(webId)

// Get array of configuration for endpoints that your service needs to serve
const endpoints = getEndpoints(webId)
// [{
//   method: 'get',
//   path: '/path/to/endpoint',
//   body: {
//     'text/turtle': '<a> <b> <c>.',
//     'application/json': { a: 'b' },
//   },
//   defaultContentType: 'text/turtle',
// }]

Identity for custom webId

You can also authenticate your service with custom webId, such as your personal webId.

You MUST add triple <webId> solid:oidcIssuer <issuer>. to your webId, where issuer MUST match the origin of the service. (no trailing slashes!)

import { getEndpoints, getAuthenticatedFetch } from '@soid/core'

const webId = 'https://custom.webid/profile/card#me' // you'll have to serve this somewhere, and add the required triple
const issuer = 'https://service.example' // this has to match your service's origin

// Get authenticated fetch to make requests with this identity
const authenticatedFetch = await getAuthenticatedFetch(webId, issuer)

// Get configuration of endpoints that your service MUST serve
const endpoints = getEndpoints(webId, issuer)

Package Sidebar

Install

npm i @soid/core

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

24.3 kB

Total Files

25

Last publish

Collaborators

  • mrkvon