Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "solid-logic",
"version": "6.0.0-1",
"version": "6.0.0-2",
"description": "Core business logic of SolidOS",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.esm.js",
"require": "./dist/index.cjs.js",
"types": "./dist/index.d.ts"
"require": "./dist/index.cjs.js"
}
},
"sideEffects": false,
Expand All @@ -20,7 +20,8 @@
],
"scripts": {
"clean": "rm -rf dist src/versionInfo.ts",
"build": "npm run clean && npm run typecheck && vite build",
"build": "npm run clean && npm run typecheck && vite build && npm run build-types",
"build-types": "tsc --emitDeclarationOnly",
"watch": "vite build --watch",
"postbuild": "npm run postbuild-js",
"postbuild-js": "rm -f dist/versionInfo.d.ts dist/versionInfo.d.ts.map dist/index.js dist/index.js.map",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { getSuggestedIssuers } from './issuer/issuerLogic'
export { createTypeIndexLogic } from './typeIndex/typeIndexLogic'
export { createDirectoryLogic, DEFAULT_DIRECTORY_CATALOG_URL, DEFAULT_DIRECTORY_SOURCES } from './directory/directoryLogic'
export type { AccessControlSubjectKind, AccessControlSubject } from './acl/accessControlSubjects'
export type { ACLContext, AccessMode, AccessSubject, Authorization, PatchPlan } from './types'
export type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic, ChatLogic, DirectoryLogic, DirectoryEntry, DirectorySearchOptions, DirectoryRelationshipLabel, DirectorySource } from './types'
export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'

Expand Down
32 changes: 32 additions & 0 deletions test/publicAclApi.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, expectTypeOf, it } from 'vitest'
import {
ACCESS_ROLES,
solidLogicSingleton,
type ACLContext,
type AccessControlSubjectKind,
type AccessMode,
type AccessRole,
type AccessSubject,
type Authorization,
type PatchPlan
} from '../src'

describe('public ACL API', () => {
it('exports the role list and exposes mapping through the singleton', () => {
expect(ACCESS_ROLES).toEqual(['Owner', 'Editor', 'No Access', 'Viewer', 'Poster', 'Submitter'])
for (const role of ACCESS_ROLES) {
expect(solidLogicSingleton.acl.roleFromModes(solidLogicSingleton.acl.modesFromRole(role))).toBe(role)
}
})

it('exports the types used by access-control consumers', () => {
expectTypeOf(solidLogicSingleton.acl.modesFromRole).toEqualTypeOf<(role: AccessRole) => AccessMode[]>()
expectTypeOf(solidLogicSingleton.acl.roleFromModes).toEqualTypeOf<(modes: Iterable<AccessMode>) => AccessRole>()
expectTypeOf(solidLogicSingleton.acl.findEffectiveAcl).returns.toEqualTypeOf<Promise<ACLContext>>()
expectTypeOf(solidLogicSingleton.acl.findAccessGrants).returns.toEqualTypeOf<Promise<Authorization[]>>()
expectTypeOf(solidLogicSingleton.acl.planGrant).toEqualTypeOf<
(resource: string | import('rdflib').NamedNode, subject: AccessSubject, modes: AccessMode[]) => Promise<PatchPlan>
>()
expectTypeOf<AccessControlSubjectKind>().toEqualTypeOf<'agent' | 'agentGroup' | 'agentClass' | 'origin'>()
})
})
Loading