@kanonak-protocol/sdk 4.12.0 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/CredentialBackend.d.ts +15 -6
- package/dist/auth/CredentialHelperBackend.d.ts +4 -4
- package/dist/auth/DeviceCertificateStore.d.ts +52 -0
- package/dist/auth/EncryptedFileBackend.d.ts +11 -7
- package/dist/auth/KeychainBackend.d.ts +10 -6
- package/dist/auth/SecretServiceBackend.d.ts +8 -6
- package/dist/auth/WinCredBackend.d.ts +13 -9
- package/dist/auth/index.d.ts +3 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/chunk-2HNPPYSK.js +1 -0
- package/dist/chunk-6U26UASC.js +1 -0
- package/dist/chunk-7BHDZHJY.js +1 -0
- package/dist/{chunk-V72IVYR4.js → chunk-H37TY5AQ.js} +4 -4
- package/dist/{chunk-VWS25JH4.js → chunk-HQQ4OAZ2.js} +1 -1
- package/dist/chunk-MRNELSJF.js +63 -0
- package/dist/{chunk-RGOBWOBB.js → chunk-OR3F4WIF.js} +1 -1
- package/dist/chunk-QDSN5VM3.js +2 -0
- package/dist/chunk-R73T4RUO.js +1 -0
- package/dist/{chunk-CR55WXIN.js → chunk-VDVJJ62W.js} +1 -1
- package/dist/chunk-WGKIRLMA.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +26 -26
- package/dist/kanonaks/DefinedKanonak.d.ts +12 -0
- package/dist/parsing/KanonakObjectParser.d.ts +14 -1
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/resolution/ResourceResolver.d.ts +0 -4
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/ValidationCache.d.ts +34 -76
- package/dist/validation/documentModel.d.ts +47 -1
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/ClassDefinitionRule.d.ts +21 -6
- package/dist/validation/rules/repository/ClassHierarchyCycleRule.d.ts +9 -4
- package/dist/validation/rules/repository/EmbeddedKanonakTypeRule.d.ts +29 -90
- package/dist/validation/rules/repository/ObjectPropertyValueValidationRule.d.ts +20 -6
- package/dist/validation/rules/repository/PropertyDomainRule.d.ts +21 -17
- package/dist/validation/rules/repository/PropertyHierarchyCycleRule.d.ts +8 -4
- package/dist/validation/rules/repository/PropertyKindRangeConsistencyRule.d.ts +29 -0
- package/dist/validation/rules/repository/PropertyRangeReferenceRule.d.ts +14 -7
- package/dist/validation/rules/repository/PropertyRangeRequiredRule.d.ts +13 -2
- package/dist/validation/rules/repository/SubClassOfReferenceRule.d.ts +16 -13
- package/dist/validation/rules/repository/SubPropertyOfReferenceRule.d.ts +12 -5
- package/dist/validation/rules/repository/UnresolvedReferenceRule.d.ts +16 -4
- package/dist/validation/rules/repository/hierarchyCycle.d.ts +25 -0
- package/dist/validation/rules/repository/index.d.ts +1 -4
- package/package.json +2 -2
- package/dist/chunk-4UT2CLAT.js +0 -1
- package/dist/chunk-7HRKWTBB.js +0 -1
- package/dist/chunk-7TKJHKC2.js +0 -1
- package/dist/chunk-BKVPSPG4.js +0 -1
- package/dist/chunk-IEOSSSB5.js +0 -1
- package/dist/chunk-SHDHMKMJ.js +0 -1
- package/dist/chunk-U7LVFPEO.js +0 -2
- package/dist/chunk-UBBZWWRB.js +0 -86
- package/dist/validation/rules/repository/DefinitionPropertyReferenceRule.d.ts +0 -13
- package/dist/validation/rules/repository/ObjectPropertyImportRule.d.ts +0 -9
- package/dist/validation/rules/repository/PropertyValueTypeRule.d.ts +0 -11
- package/dist/validation/rules/repository/XsdImportRule.d.ts +0 -11
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pluggable
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Pluggable secure-storage backend: JSON values of type `T` keyed by a
|
|
3
|
+
* normalized host, in a platform-specific secure store (OS keychain, encrypted
|
|
4
|
+
* file, enterprise vault). The same backend implementations serve different
|
|
5
|
+
* record types under different namespaces — OAuth credentials
|
|
6
|
+
* ({@link StoredCredential}) and device enrollments — so the storage mechanism
|
|
7
|
+
* is written once and reused.
|
|
5
8
|
*/
|
|
6
|
-
export interface
|
|
7
|
-
get(publisher: string): Promise<
|
|
8
|
-
store(publisher: string,
|
|
9
|
+
export interface SecretBackend<T> {
|
|
10
|
+
get(publisher: string): Promise<T | null>;
|
|
11
|
+
store(publisher: string, value: T): Promise<void>;
|
|
9
12
|
remove(publisher: string): Promise<void>;
|
|
10
13
|
list(): Promise<string[]>;
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* The OAuth credential storage backend — a {@link SecretBackend} whose records
|
|
17
|
+
* are {@link StoredCredential}. Kept as a named alias so existing consumers and
|
|
18
|
+
* the `CredentialStore` are unchanged.
|
|
19
|
+
*/
|
|
20
|
+
export type CredentialBackend = SecretBackend<StoredCredential>;
|
|
12
21
|
/**
|
|
13
22
|
* OAuth credential stored per publisher host.
|
|
14
23
|
* Matches the OAuthCredentialStore types from @kanonak-protocol/types.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SecretBackend, StoredCredential } from './CredentialBackend.js';
|
|
2
2
|
/**
|
|
3
3
|
* External credential helper backend.
|
|
4
4
|
* Delegates to an enterprise-configured binary using a stdin/stdout JSON protocol.
|
|
@@ -6,11 +6,11 @@ import type { CredentialBackend, StoredCredential } from './CredentialBackend.js
|
|
|
6
6
|
* Configure in ~/.kanonak/config.json:
|
|
7
7
|
* { "credentialHelper": "/usr/local/bin/kanonak-credential-vault" }
|
|
8
8
|
*/
|
|
9
|
-
export declare class CredentialHelperBackend implements
|
|
9
|
+
export declare class CredentialHelperBackend<T = StoredCredential> implements SecretBackend<T> {
|
|
10
10
|
private readonly helperPath;
|
|
11
11
|
constructor(helperPath: string);
|
|
12
|
-
get(publisher: string): Promise<
|
|
13
|
-
store(publisher: string,
|
|
12
|
+
get(publisher: string): Promise<T | null>;
|
|
13
|
+
store(publisher: string, value: T): Promise<void>;
|
|
14
14
|
remove(publisher: string): Promise<void>;
|
|
15
15
|
list(): Promise<string[]>;
|
|
16
16
|
private runHelper;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SecretBackend } from './CredentialBackend.js';
|
|
2
|
+
import { normalizeHost } from './CredentialBackend.js';
|
|
3
|
+
/**
|
|
4
|
+
* A device certificate enrollment, persisted per registry host (issue #67).
|
|
5
|
+
*
|
|
6
|
+
* The record holds the device-held key material, the CA-signed certificate, and
|
|
7
|
+
* the consent context. In v1 the key is a software key (its private JWK lives in
|
|
8
|
+
* `keyMaterial`); a future hardware {@link KeyProvider} stores an opaque handle
|
|
9
|
+
* here instead, so the secure store never holds an exportable key. Either way the
|
|
10
|
+
* record is opaque JSON to the storage backend.
|
|
11
|
+
*/
|
|
12
|
+
export interface DeviceEnrollmentRecord {
|
|
13
|
+
/** Software provider: the private key JWK. Hardware provider: an opaque key handle. */
|
|
14
|
+
keyMaterial: Record<string, unknown>;
|
|
15
|
+
/** RFC 7638 JWK SHA-256 thumbprint of the device public key — the consent-bound identity. */
|
|
16
|
+
thumbprint: string;
|
|
17
|
+
/** The CA-signed leaf certificate (PEM). */
|
|
18
|
+
certificatePem: string;
|
|
19
|
+
/** The issuing chain (PEM, possibly empty). */
|
|
20
|
+
chainPem: string;
|
|
21
|
+
/** ISO timestamp the certificate was issued/installed. */
|
|
22
|
+
issuedAt: string;
|
|
23
|
+
/** ISO timestamp the certificate expires, or null if unknown. */
|
|
24
|
+
expiresAt: string | null;
|
|
25
|
+
/** The scopes consented at enrollment. */
|
|
26
|
+
scopes: string[];
|
|
27
|
+
/** A human-facing device label shown on the consent screen. */
|
|
28
|
+
deviceName?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Persists {@link DeviceEnrollmentRecord}s in the same platform-secure stores as
|
|
32
|
+
* OAuth credentials, but under a separate `kanonak-device` namespace so the two
|
|
33
|
+
* never collide (separate Keychain service / Credential Manager target prefix /
|
|
34
|
+
* Secret Service attribute / encrypted file). Mirrors {@link CredentialStore}'s
|
|
35
|
+
* backend selection; the external credential-helper backend is intentionally not
|
|
36
|
+
* used for device certs in v1 (device enrollment is a first-party flow).
|
|
37
|
+
*
|
|
38
|
+
* This is a Node-only module (it reaches OS keystores) and is deliberately not
|
|
39
|
+
* exported from the SDK browser entry.
|
|
40
|
+
*/
|
|
41
|
+
export declare class DeviceCertificateStore {
|
|
42
|
+
private backend;
|
|
43
|
+
private backendReady;
|
|
44
|
+
getBackend(): Promise<SecretBackend<DeviceEnrollmentRecord>>;
|
|
45
|
+
get(host: string): Promise<DeviceEnrollmentRecord | null>;
|
|
46
|
+
store(host: string, record: DeviceEnrollmentRecord): Promise<void>;
|
|
47
|
+
remove(host: string): Promise<void>;
|
|
48
|
+
list(): Promise<string[]>;
|
|
49
|
+
private resolveBackend;
|
|
50
|
+
}
|
|
51
|
+
/** Re-exported for callers that namespace device records themselves. */
|
|
52
|
+
export { normalizeHost };
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SecretBackend, StoredCredential } from './CredentialBackend.js';
|
|
2
2
|
/**
|
|
3
|
-
* Encrypted file
|
|
3
|
+
* Encrypted file secret backend.
|
|
4
4
|
* Fallback for headless Linux, containers, and CI environments
|
|
5
|
-
* where no OS keyring is available.
|
|
5
|
+
* where no OS keyring is available. The secrets file is namespaced (OAuth
|
|
6
|
+
* credentials in `credentials.enc`, device enrollments in `device-credentials.enc`)
|
|
7
|
+
* so the two stores never collide; both are sealed with the same per-user key.
|
|
6
8
|
*
|
|
7
9
|
* - Key: ~/.config/kanonak/keyring.key (random 32 bytes, mode 0600)
|
|
8
|
-
* - Secrets:
|
|
10
|
+
* - Secrets: a per-namespace AES-256-GCM encrypted JSON file
|
|
9
11
|
*/
|
|
10
|
-
export declare class EncryptedFileBackend implements
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
export declare class EncryptedFileBackend<T = StoredCredential> implements SecretBackend<T> {
|
|
13
|
+
private readonly secretsFile;
|
|
14
|
+
constructor(secretsFile?: string);
|
|
15
|
+
get(publisher: string): Promise<T | null>;
|
|
16
|
+
store(publisher: string, value: T): Promise<void>;
|
|
13
17
|
remove(publisher: string): Promise<void>;
|
|
14
18
|
list(): Promise<string[]>;
|
|
15
19
|
private loadStore;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SecretBackend, StoredCredential } from './CredentialBackend.js';
|
|
2
2
|
/**
|
|
3
|
-
* macOS Keychain
|
|
4
|
-
* Stores
|
|
3
|
+
* macOS Keychain secret backend.
|
|
4
|
+
* Stores records via the `security` CLI tool (no native modules). The Keychain
|
|
5
|
+
* `service` namespaces the store, so OAuth credentials (`kanonak`) and device
|
|
6
|
+
* enrollments (`kanonak-device`) live side by side without colliding.
|
|
5
7
|
*/
|
|
6
|
-
export declare class KeychainBackend implements
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
export declare class KeychainBackend<T = StoredCredential> implements SecretBackend<T> {
|
|
9
|
+
private readonly service;
|
|
10
|
+
constructor(service?: string);
|
|
11
|
+
get(publisher: string): Promise<T | null>;
|
|
12
|
+
store(publisher: string, value: T): Promise<void>;
|
|
9
13
|
remove(publisher: string): Promise<void>;
|
|
10
14
|
list(): Promise<string[]>;
|
|
11
15
|
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SecretBackend, StoredCredential } from './CredentialBackend.js';
|
|
2
2
|
/**
|
|
3
3
|
* Linux Secret Service backend (GNOME Keyring / KDE Wallet).
|
|
4
4
|
* Uses the `secret-tool` CLI from libsecret-tools.
|
|
5
5
|
*
|
|
6
|
-
* Each
|
|
7
|
-
* service = "kanonak"
|
|
6
|
+
* Each record is stored with attributes:
|
|
7
|
+
* service = the namespace ("kanonak" for OAuth, "kanonak-device" for device certs)
|
|
8
8
|
* publisher = normalized publisher host
|
|
9
9
|
*
|
|
10
10
|
* All interactions use execFile (no shell) to prevent command injection.
|
|
11
11
|
* The store() method uses spawn with stdin piping since secret-tool
|
|
12
12
|
* reads the secret value from stdin.
|
|
13
13
|
*/
|
|
14
|
-
export declare class SecretServiceBackend implements
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export declare class SecretServiceBackend<T = StoredCredential> implements SecretBackend<T> {
|
|
15
|
+
private readonly service;
|
|
16
|
+
constructor(service?: string);
|
|
17
|
+
get(publisher: string): Promise<T | null>;
|
|
18
|
+
store(publisher: string, value: T): Promise<void>;
|
|
17
19
|
remove(publisher: string): Promise<void>;
|
|
18
20
|
list(): Promise<string[]>;
|
|
19
21
|
}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SecretBackend, StoredCredential } from './CredentialBackend.js';
|
|
2
2
|
/**
|
|
3
3
|
* Windows Credential Manager backend.
|
|
4
4
|
* Uses PowerShell P/Invoke to Advapi32.dll for CredRead/CredWrite/CredDelete.
|
|
5
5
|
* cmdkey cannot read passwords back, so P/Invoke is required.
|
|
6
6
|
*
|
|
7
|
-
* Each
|
|
8
|
-
* target = "
|
|
9
|
-
* credential blob = JSON-serialized
|
|
7
|
+
* Each record is stored as a generic credential with:
|
|
8
|
+
* target = "{prefix}{normalized_publisher}"
|
|
9
|
+
* credential blob = JSON-serialized record (UTF-16)
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* The `target` prefix namespaces the store, so OAuth credentials (`kanonak:`)
|
|
12
|
+
* and device enrollments (`kanonak-device:`) do not collide. Data is passed to
|
|
13
|
+
* PowerShell via stdin to prevent injection attacks; no user-supplied values
|
|
14
|
+
* are interpolated into PowerShell code.
|
|
13
15
|
*/
|
|
14
|
-
export declare class WinCredBackend implements
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
export declare class WinCredBackend<T = StoredCredential> implements SecretBackend<T> {
|
|
17
|
+
private readonly targetPrefix;
|
|
18
|
+
constructor(targetPrefix?: string);
|
|
19
|
+
get(publisher: string): Promise<T | null>;
|
|
20
|
+
store(publisher: string, value: T): Promise<void>;
|
|
17
21
|
remove(publisher: string): Promise<void>;
|
|
18
22
|
list(): Promise<string[]>;
|
|
19
23
|
}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export type { CredentialBackend, StoredCredential, DPoPKeyPair } from './CredentialBackend.js';
|
|
1
|
+
export type { SecretBackend, CredentialBackend, StoredCredential, DPoPKeyPair } from './CredentialBackend.js';
|
|
2
2
|
export { isExpired, hasValidToken, normalizeHost } from './CredentialBackend.js';
|
|
3
3
|
export { CredentialStore } from './CredentialStore.js';
|
|
4
|
+
export { DeviceCertificateStore } from './DeviceCertificateStore.js';
|
|
5
|
+
export type { DeviceEnrollmentRecord } from './DeviceCertificateStore.js';
|
|
4
6
|
export type { AuthenticatedFetchFn } from './AuthenticatedFetch.js';
|
|
5
7
|
export { createAuthenticatedFetch } from './AuthenticatedFetch.js';
|
|
6
8
|
export { generateDPoPKeyPair, createDPoPProof, serverSupportsDPoP } from './DPoP.js';
|
package/dist/browser.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { KanonakParser, KanonakObjectParser, PropertyMetadata, KanonakDocumentPo
|
|
|
12
12
|
export type { IKanonakObjectParser, SourcePosition, ImportPackageEntry, ParsedDocumentWithPositions, } from './parsing/index.js';
|
|
13
13
|
export { GraphBuilder, NodeType, EdgeType } from './graph/index.js';
|
|
14
14
|
export type { GraphNode, GraphEdge, GraphData } from './graph/index.js';
|
|
15
|
-
export { OntologyValidationResult, OntologyValidationError, ValidationSeverity, ValidationContext, KanonakObjectValidator, NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule, EmbeddedKanonakTypeRule, ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, UnresolvedPredicateRule,
|
|
15
|
+
export { OntologyValidationResult, OntologyValidationError, ValidationSeverity, ValidationContext, KanonakObjectValidator, NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule, EmbeddedKanonakTypeRule, ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, UnresolvedPredicateRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyKindRangeConsistencyRule, ClassDefinitionRule, MarkdownLinkRule } from './validation/index.js';
|
|
16
16
|
export type { IKanonakObjectValidator, IDocumentValidationRule, IRepositoryValidationRule } from './validation/index.js';
|
|
17
17
|
export { Kanonak, DefinedKanonak, SubjectKanonak, EmbeddedKanonak, ReferenceKanonak } from './kanonaks/index.js';
|
|
18
18
|
export type { IStatement } from './statements/index.js';
|
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as we,b as ke,c as he,d as E,e as _,f as d,g as
|
|
2
|
-
Credential storage requires IndexedDB support in your browser.`))})}async function
|
|
1
|
+
import{a as we,b as ke,c as he,d as E,e as _,f as d,g as Ze}from"./chunk-QDSN5VM3.js";import{a as Ye}from"./chunk-HQQ4OAZ2.js";import"./chunk-QHABFCRC.js";import{a as F,b as W,c as G,d as w,f as Q,g as X,h as Y}from"./chunk-JYBKSBB5.js";import{a as q}from"./chunk-4NO7MHS7.js";import{a as Ke,b as be,c as xe}from"./chunk-OR3F4WIF.js";import{a as Se,b as De}from"./chunk-PEUTCG3B.js";import"./chunk-PEJALHXK.js";import"./chunk-SC5M74NM.js";import{A as Qe,J as Xe,a as Re,b as Be,c as Ce,d as Ee,f as _e,g as ve,h as Ae,i as je,k as Te,l as Ie,m as Oe,n as Ue,o as Ve,p as $e,q as Me,r as Ne,s as ze,t as Je,u as He,v as qe,w as Le,x as Fe,y as We,z as Ge}from"./chunk-MRNELSJF.js";import{a as te,c as ye,l as me}from"./chunk-R73T4RUO.js";import{a as L}from"./chunk-NJ3AZYQD.js";import{a as Pe}from"./chunk-2HNPPYSK.js";import"./chunk-6U26UASC.js";import{a as ge,b as fe}from"./chunk-WGKIRLMA.js";import{a as Z,b as ee,c as re,d as oe,e as se,f as ie,g as ae,h as ce,i as le,j as ue,k as de,l as pe}from"./chunk-7BHDZHJY.js";import{a as ne}from"./chunk-FUUTGGJS.js";import{c as U,d as V,e as $,f as M,g as N,h as z,i as J,j as H}from"./chunk-2ACBWC7K.js";var v="kanonak-credentials",u="credentials",er=1,f=class{async get(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readonly"),i=s.objectStore(u).get(e);i.onsuccess=()=>o(i.result??null),i.onerror=()=>a(new Error(`IndexedDB read failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async store(r,e){let t=d(r),o=await h();return new Promise((a,s)=>{let l=o.transaction(u,"readwrite"),c=l.objectStore(u).put(e,t);c.onsuccess=()=>a(),c.onerror=()=>s(new Error(`IndexedDB write failed for '${t}': ${c.error?.message}`)),l.oncomplete=()=>o.close()})}async remove(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readwrite"),i=s.objectStore(u).delete(e);i.onsuccess=()=>o(),i.onerror=()=>a(new Error(`IndexedDB delete failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async list(){let r=await h();return new Promise((e,t)=>{let o=r.transaction(u,"readonly"),s=o.objectStore(u).getAllKeys();s.onsuccess=()=>e(s.result??[]),s.onerror=()=>t(new Error(`IndexedDB list failed: ${s.error?.message}`)),o.oncomplete=()=>r.close()})}};function h(){return new Promise((n,r)=>{let e=indexedDB.open(v,er);e.onupgradeneeded=()=>{let t=e.result;t.objectStoreNames.contains(u)||t.createObjectStore(u)},e.onsuccess=()=>n(e.result),e.onerror=()=>r(new Error(`Failed to open IndexedDB '${v}': ${e.error?.message}
|
|
2
|
+
Credential storage requires IndexedDB support in your browser.`))})}async function j(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey);return{signingKey:n.privateKey,publicKeyJwk:r}}async function K(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey),e=await crypto.subtle.exportKey("jwk",n.privateKey);return{keys:{signingKey:n.privateKey,publicKeyJwk:r},dpopKeyPair:{publicKey:r,privateKey:e}}}async function b(n){return{signingKey:await crypto.subtle.importKey("jwk",n.privateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),publicKeyJwk:n.publicKey}}async function x(n,r,e,t,o){let a={alg:"ES256",typ:"dpop+jwt",jwk:{kty:n.publicKeyJwk.kty,crv:n.publicKeyJwk.crv,x:n.publicKeyJwk.x,y:n.publicKeyJwk.y}},s={jti:crypto.randomUUID(),htm:r.toUpperCase(),htu:e,iat:Math.floor(Date.now()/1e3)};return t&&(s.ath=await tr(t)),o&&(s.nonce=o),await rr(a,s,n.signingKey)}function S(n){return!n||n.length===0?!1:n.some(r=>r.toUpperCase()==="ES256")}async function rr(n,r,e){let t=A(JSON.stringify(n)),o=A(JSON.stringify(r)),a=new TextEncoder().encode(`${t}.${o}`),s=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,a),l=B(s);return`${t}.${o}.${l}`}async function tr(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return B(e)}function A(n){let r=new TextEncoder().encode(n);return B(r.buffer)}function B(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var nr=300*1e3,D=class{credentialBackend;callbackUrl;constructor(r){this.credentialBackend=new f,this.callbackUrl=r??`${window.location.origin}/browser/callback.html`}async authorize(r){let e=d(r),t=await this.discover(e);if(!t)return{success:!1,error:`No OAuth discovery endpoint found for '${e}'.`};if(!t.authorizationEndpoint||!t.tokenEndpoint)return{success:!1,error:`OAuth metadata incomplete for '${e}'.`};let o=S(t.dpopSigningAlgValuesSupported),a=null,s=null;if(o){let g=await K();a=g.keys,s=g.dpopKeyPair}let l=await this.credentialBackend.get(e),i=l?.clientId??null,c=l?.clientSecret??null;if(!i&&t.registrationEndpoint){let g=await this.registerClient(t.registrationEndpoint);if(!g)return{success:!1,error:`Dynamic client registration failed for '${e}'.`};i=g.clientId,c=g.clientSecret??null}if(!i)return{success:!1,error:`No OAuth client credentials for '${e}'.`};let m=or(),p=await sr(m),R=ir(),I=ar(t.authorizationEndpoint,i,this.callbackUrl,R,p),y=await this.openAuthPopup(I,R);if(!y)return{success:!1,error:"Authorization timed out or was cancelled."};if(y.error)return{success:!1,error:`Authorization failed: ${y.error}`};if(!y.code)return{success:!1,error:"No authorization code received."};if(y.state!==R)return{success:!1,error:"State mismatch \u2014 possible CSRF attack."};let P=await this.exchangeCode(t.tokenEndpoint,i,c,y.code,this.callbackUrl,m,a);if(!P)return{success:!1,error:"Token exchange failed."};let O={clientId:i,clientSecret:c,accessToken:P.accessToken??null,refreshToken:P.refreshToken??null,expiresAt:P.expiresIn?new Date(Date.now()+P.expiresIn*1e3).toISOString():null,tokenEndpoint:t.tokenEndpoint,dpopKeyPair:s};return await this.credentialBackend.store(e,O),{success:!0,host:e}}async getCredentialWithKeys(r){let e=await this.credentialBackend.get(r);if(!e)return null;let t=null;return e.dpopKeyPair&&(t=await b(e.dpopKeyPair)),{credential:e,dpopKeys:t}}async logout(r){let e=d(r);return await this.credentialBackend.remove(e),{success:!0,host:e}}async listAuthenticated(){return this.credentialBackend.list()}async discover(r){for(let e of[`https://${r}/.well-known/oauth-authorization-server`,`https://${r}/.well-known/openid-configuration`])try{let t=await w(e);if(!t.ok)continue;let o=await t.json();return{issuer:k(o.issuer),authorizationEndpoint:k(o.authorization_endpoint),tokenEndpoint:k(o.token_endpoint),registrationEndpoint:k(o.registration_endpoint),revocationEndpoint:k(o.revocation_endpoint),dpopSigningAlgValuesSupported:T(o.dpop_signing_alg_values_supported),codeChallengeMethodsSupported:T(o.code_challenge_methods_supported)}}catch{continue}return null}async registerClient(r){try{let e=await w(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"Kanonak Browser",redirect_uris:[this.callbackUrl],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"})});if(!e.ok)return null;let t=await e.json(),o=t.client_id;return o?{clientId:o,clientSecret:t.client_secret}:null}catch{return null}}openAuthPopup(r,e){return new Promise(t=>{let o=window.open(r,"kanonak-auth","width=500,height=700,menubar=no,toolbar=no,location=yes,status=no");if(!o){t(null);return}let a=setTimeout(()=>{i(),t(null)},nr),s=c=>{c.origin===window.location.origin&&(!c.data||c.data.type!=="kanonak-auth-callback"||(i(),t({code:c.data.code??void 0,state:c.data.state??void 0,error:c.data.error??void 0})))},l=setInterval(()=>{o.closed&&(i(),t(null))},500),i=()=>{clearTimeout(a),clearInterval(l),window.removeEventListener("message",s);try{o.close()}catch{}};window.addEventListener("message",s)})}async exchangeCode(r,e,t,o,a,s,l){let i=new URLSearchParams({grant_type:"authorization_code",client_id:e,code:o,redirect_uri:a,code_verifier:s});t&&i.set("client_secret",t);let c={"Content-Type":"application/x-www-form-urlencoded"};l&&(c.DPoP=await x(l,"POST",r));try{let m=await w(r,{method:"POST",headers:c,body:i.toString()});if(!m.ok)return null;let p=await m.json();return{accessToken:p.access_token,refreshToken:p.refresh_token,expiresIn:typeof p.expires_in=="number"?p.expires_in:void 0}}catch{return null}}};function or(){let n=new Uint8Array(32);return crypto.getRandomValues(n),C(n.buffer)}async function sr(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return C(e)}function ir(){let n=new Uint8Array(16);return crypto.getRandomValues(n),C(n.buffer)}function ar(n,r,e,t,o){let a=new URLSearchParams({client_id:r,response_type:"code",redirect_uri:e,state:t,code_challenge:o,code_challenge_method:"S256"});return`${n}?${a}`}function C(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function k(n){return typeof n=="string"?n:null}function T(n){return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}export{He as AmbiguousReferenceRule,le as BooleanStatement,f as BrowserCredentialBackend,D as BrowserOAuthFlow,Ge as ClassDefinitionRule,Ue as ClassHierarchyCycleRule,ee as DefinedKanonak,ke as EdgeType,te as EmbeddedKanonak,Te as EmbeddedKanonakTypeRule,de as EmbeddedStatement,he as GraphBuilder,Y as HttpKanonakDocumentRepository,Ie as ImportExistenceRule,q as InMemoryKanonakDocumentRepository,F as KANONAK_USER_AGENT,Z as Kanonak,be as KanonakDocumentPositions,me as KanonakObjectParser,Xe as KanonakObjectValidator,L as KanonakParser,ne as KanonakUri,Se as KanonakUriBuilder,pe as ListStatement,Qe as MarkdownLinkRule,ye as MarkdownStatement,ze as NamespaceImportCycleRule,_e as NamespacePrefixRule,we as NodeType,ce as NumberStatement,Le as ObjectPropertyValueValidationRule,Ce as OntologyValidationError,Re as OntologyValidationResult,Fe as PropertyDomainRule,Ve as PropertyHierarchyCycleRule,We as PropertyKindRangeConsistencyRule,Ke as PropertyMetadata,qe as PropertyRangeReferenceRule,$e as PropertyRangeRequiredRule,Ae as PropertyTypeSpecificityRule,Q as PublisherConfigResolver,X as PublisherIndex,oe as ReferenceKanonak,ue as ReferenceStatement,ve as ResourceNamingRule,ge as ResourceResolver,Pe as ResourceTypeClassifier,ie as ScalarStatement,se as Statement,ae as StringStatement,Me as SubClassOfReferenceRule,Ne as SubPropertyOfReferenceRule,re as SubjectKanonak,je as SubjectKanonakTypeRequiredRule,fe as TypeResolver,Je as UnresolvedPredicateRule,Oe as UnresolvedReferenceRule,Ee as ValidationContext,Be as ValidationSeverity,S as browserServerSupportsDPoP,Ze as buildOntologyModel,U as compareVersions,x as createBrowserDPoPProof,M as createVersion,Ye as findDerivation,De as findInstancesByType,$ as formatVersion,K as generateBrowserDPoPKeyPair,j as generateBrowserDPoPKeys,G as getKanonakUserAgent,_ as hasValidToken,b as importDPoPKeys,z as isCompatibleVersion,E as isExpired,J as isMajorCompatible,w as kanonakFetch,d as normalizeHost,N as parseVersionString,xe as parseWithPositions,H as pickHighestDocument,W as setKanonakUserAgent,V as versionsEqual};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as d}from"./chunk-WGKIRLMA.js";import{c as U,d as S,m as u,r as _,v as m,w as g,y as j}from"./chunk-7BHDZHJY.js";import{a as b}from"./chunk-FUUTGGJS.js";var $=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function i(r){let n=r;if(n.entity&&typeof n.entity=="object"){let e=n.entity.type;if(typeof e=="string"){let a={publisher:"",package_:"",name:e.includes(".")?e.substring(e.lastIndexOf(".")+1):e};return d(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}if(n.statement&&Array.isArray(n.statement)){for(let e of n.statement)if(e.predicate?.subject?.name==="type"&&e.object?.subject){let t=e.object.subject,a={publisher:t.publisher??"",package_:t.package_??"",name:t.name};return d(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}return null}function c(r,n){return $.has(`${r}/${n}`)}var y=class r{static getTypeUri(n){return i(n)}static isCoreOntologyType(n){return c(n.publisher,n.package_)}static isClassType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Class":!1}static isDatatypeType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Datatype":!1}static isDatatypePropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="DatatypeProperty":!1}static isObjectPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="ObjectProperty":!1}static isAnnotationPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="AnnotationProperty":!1}static isGenericPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Property":!1}static isAnyPropertyType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"}static isSchemaDefinitionType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Class"||e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"||e.name==="Datatype"}static isInstanceOfKnownClass(n,e){if(r.isSchemaDefinitionType(n))return!1;let t=i(n);return t?e.has(t.name):!1}};function P(r){if(!r||r.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let n=r.trim(),e=n.split("/");if(e.length===1){let t=e[0];if(!t)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(t.includes("@"))throw new Error(`Invalid Kanonak address: "${r}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:t}}if(e.length===2){let[t,a]=e;if(!t||!a)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:t,package_:a};let s=a.substring(0,o),p=a.substring(o+1);if(!s||!p)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let f=A(p);return{kind:"package",publisher:t,package_:s,version:f}}return{kind:"resource",uri:b.parse(n)}}function G(r){switch(r.kind){case"publisher":return r.publisher;case"package":return r.version?`${r.publisher}/${r.package_}@${r.version.major}.${r.version.minor}.${r.version.patch}`:`${r.publisher}/${r.package_}`;case"resource":return r.uri.toString()}}function A(r){let n=r.split(".").map(Number);return w(n[0]||0,n[1]||0,n[2]||0)}function w(r,n,e){return{major:r,minor:n,patch:e,toString:()=>`${r}.${n}.${e}`,equals:t=>!t||typeof t!="object"?!1:t.major===r&&t.minor===n&&t.patch===e,getHashCode:()=>r<<20|n<<10|e,compareTo:t=>r!==t.major?r-t.major:n!==t.minor?n-t.minor:e-t.patch}}var k="kanonak.org",l="core-rdf",T={publisher:k,package_:l,name:"domain"},C={publisher:k,package_:l,name:"range"},R={publisher:k,package_:l,name:"subClassOf"},v={publisher:k,package_:l,name:"type"},x={publisher:k,package_:l,name:"label"},D={publisher:k,package_:l,name:"comment"},O=new b(k,l,"Resource"),I=r=>r;function V(r){try{let n=P(`${r.namespace}/${r.name}`);return n.kind==="resource"?n.uri:void 0}catch{return}}function h(r,n){let e=g(r,n);if(e)return[e];let t=[];for(let a of j(r,n))a instanceof S&&t.push(a.subject);return t}function N(r,n){let e=[],t=new Set,a=[new b(n.publisher,n.package_,n.name)];for(;a.length>0;){let o=a.shift(),s=u(o);if(t.has(s))continue;t.add(s),e.push(o);let p=_(r,o);p&&a.push(...h(p,R))}return e}function B(r,n){let e=new Set([u(O)]);for(let t of N(r,n))e.add(u(t));return e}function F(r,n){let e=B(r,n),t=[],a=new Set;for(let o of r){if(!(o instanceof U))continue;let s=I(o);if(!y.isAnyPropertyType(s))continue;let p=h(o,T);if(!p.some(E=>e.has(u(E))))continue;let f=V(o);if(!f)continue;let K=u(f);a.has(K)||(a.add(K),t.push({uri:f,label:m(o,x),comment:m(o,D),kind:y.isObjectPropertyType(s)?"object":y.isDatatypePropertyType(s)?"datatype":"other",range:g(o,C),domains:p}))}return t}function Z(r,n,e){let t=F(r,n).find(a=>u(a.uri)===u(e));return t?{ok:!0,descriptor:t}:{ok:!1,message:`Property ${e.publisher}/${e.package_}/${e.name} is not in scope for ${n.publisher}/${n.package_}/${n.name}.`}}function ee(r){return h(r,v)}export{y as a,P as b,G as c,V as d,N as e,F as f,Z as g,ee as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as y}from"./chunk-FUUTGGJS.js";import{c as x,g as j}from"./chunk-2ACBWC7K.js";var c=class{};var m=class extends c{statement=[];unresolvedPredicates=[];sourceDoc=""};var f=class extends m{namespace;name;icon};var i=class e extends c{subject;static parse(t){let n=new e;return n.subject=y.parse(t),n}};var o=class{predicate;object};var s=class extends o{carrier;lexical};var k=class e extends s{static parse(t,n){let r=new e;return r.predicate=i.parse(t),r.object=n,r}};var b=class e extends s{static parse(t,n){let r=new e;return r.predicate=i.parse(t),r.object=n,r}};var l=class extends s{};var u=class e extends o{static parse(t,n){let r=new e;return r.predicate=i.parse(t),r.object=i.parse(n),r}};var g=class extends o{};var K=class extends o{};function se(e){return`${e.publisher}/${e.package_}/${e.name}`}function U(e,t){return e.publisher===t.publisher&&e.package_===t.package_&&e.name===t.name}function ce(e){let t=e.version;return t&&typeof t.major=="number"?`https://${e.publisher}/${e.package_}/${t.major}.${t.minor}.${t.patch}/${e.name}`:`https://${e.publisher}/${e.package_}/${e.name}`}function h(e,t){if(!(e instanceof m))return!1;for(let n of e.statement)if(n.predicate?.subject?.name==="type"&&n instanceof u){let a=n.object;if(U(a.subject,t))return!0}return!1}function me(e,t){let n=[];for(let r of e)r instanceof f&&h(r,t)&&n.push(r);return n}function fe(e,t){let n=t.version,r=n&&typeof n.major=="number"?`${t.publisher}/${t.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let a of e){if(!(a instanceof f)||a.name!==t.name)continue;let p=a.namespace||"";if(r!==void 0){if(p===r)return a}else if(p.startsWith(`${t.publisher}/${t.package_}@`))return a}}function pe(e,t){let n=[];for(let r of e){if(!(r instanceof f)||r.name!==t.name)continue;(r.namespace||"").startsWith(`${t.publisher}/${t.package_}@`)&&n.push(r)}return n.sort((r,a)=>{let p=j((r.namespace||"").split("@")[1]??""),S=j((a.namespace||"").split("@")[1]??"");return p?S?x(S,p):-1:S?1:0}),n}function d(e,t){for(let n of e.statement){let r=n.predicate;if(r?.subject&&U(r.subject,t))return n}}function ue(e,t){return d(e,t)!==void 0}function $(e,t){let n=d(e,t);if(n&&(n instanceof k||n instanceof b||n instanceof l))return n.object}function de(e,t){let n=$(e,t);return typeof n=="string"?n:void 0}function ke(e,t){let n=d(e,t);if(n instanceof u)return n.object.subject}function be(e,t){let n=d(e,t);if(n instanceof g)return n.object}function le(e,t){let n=d(e,t);return n instanceof K?n.object??[]:[]}export{c as a,m as b,f as c,i as d,o as e,s as f,k as g,b as h,l as i,u as j,g as k,K as l,se as m,U as n,ce as o,h as p,me as q,fe as r,pe as s,ue as t,$ as u,de as v,ke as w,be as x,le as y};
|