Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@janeirodigital/interop-authorization-agent

Package Overview
Dependencies
Maintainers
5
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@janeirodigital/interop-authorization-agent

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

  • 1.0.0-rc.24
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

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.

NLnet foundation logo

NGI Zero Entrust Logo

FAQs

Package last updated on 18 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc