npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@janeirodigital/interop-authorization-agent

v1.0.0-rc.24

Published

Top level module for authorization agents confirming to Solid Application Interoperability specification

Downloads

583

Readme

Authorization Agent

CI codecov Gitter chat npm version MIT license

Early access

Specifications this library implements are still a work in progress. While we track changes to the public API of this library with semver, the underlying data will be slightly changing for the rest of 2021. We are commited to keep this implementation up to date. If you plan to use your application in production please ask the specification editors on the public chatroom about the stability of the data model.

Service

An open-source implementation of a full service using this library is also available: sai-impl-service (under active development)

Creating Authorization Agent instance

Authorization Agent class provides a static build method to create instances. It expects:

  • webId - WebID of the user which this instance will be an authorization agent of.
  • agentId - Unique IRI denoting this instance. The user will add it to their WebID and it will be used as client_id in Solid-OIDC
  • dependencies
import { randomUUID } from 'crypto';
import { getSessionFromStorage, Session } from '@inrupt/solid-client-authn-node';
import { AuthorizationAgent } from '@janeirodigital/interop-authorization-agent';

import { storage } from './oidc-storage';

const webId = 'https://alice.example/#id';
const agentId = 'https://authz.alice.example/';

// we assume that webId was used as sessionId the when session was created
const session = await getSessionFromStorage(webId, storage);

const agent = AuthorizationAgent.build(webId, clientId, {
  fetch: oidcSession.fetch,
  randomUUID
});

Agent Registry

An instance of Authorization Agent provides a useful method for accessing agent registrations

Application Registrations

applicationRegistrations(): AsyncIterable<CRUDApplicationRegistration is an async iterable over all the application registrations

for await (const registration of agent.applicationRegistrations) {
  // do something with the application registration
}

async findApplicationRegistration(iri: string): Promise<CRUDApplicationRegistration | undefined> finds an application registration based on client_id, if one exists

const clientId = 'https://projectron.example/#app';
const registration = await agent.findApplicationRegistration(clientId);

Social Agent Registrations

socialAgentRegistrations(): AsyncIterable<CRUDSocialAgentRegistration> is an async iterable over all the social agent registrations

for await (const registration of agent.socialAgentRegistrations) {
  // do something with the social agent registration
}

findSocialAgentRegistration(iri: string): Promise<CRUDSocialAgentRegistration | undefined> finds a social registration based on webid, if one exists

const webId = 'https://alice.example/#id';
const registration = await agent.findSocialAgentRegistration(webId);

Access Authorization

Creating Access Authorizations is the primary responsibility of an Authorization Agent.

async recordAccessAuthorization(authorization: AccessAuthorizationStructure): Promise<ReadableAccessAuthorization>

Since access authorization is immutable, it is required to create a new one to replace the old one.

type AccessAuthorizationStructure = {
  grantee: string; // webid or clientid
  hasAccessNeedGroup: string; // iri
  dataAuthorizations: DataAuthorizationData[];
};
type DataAuthorizationData = {
  grantee: string; // webid or clientid
  registeredShapeTree: string;
  scopeOfAuthorization: string;
  accessMode: string[];
  dataOwner?: string; // webid
  hasDataRegistration?: string;
  inheritsFromAuthorization?: string;
  creatorAccessMode?: string[];
  hasDataInstance?: string[];
};

Access Grant

Based on existing Access Authorization an Access Grant can be created

async generateAccessGrant(accessAuthorizationIri: string): Promise<void>

This method updates the appropriate agent registration to reference the newly created access grant.

const authorizationData: AccessAuthorizationStructure = {
  /* all the data */
};
const authorization = await agent.recordAccessAuthorization(authorizationData);
await agent.generateAccessGrant(authorization.iri);

Funding

This project is funded through the NGI Zero Entrust Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.