@kanonak-protocol/sdk 4.16.0 → 4.18.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.
Files changed (2) hide show
  1. package/dist/index.js +28 -26
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import{a as br,b as Pr,c as wr,d as Sr,e as be}from"./chunk-TVSHIXLA.js";import{a as mn,c as we,e as Ue,h as Fe,i as Le,j as fn}from"./chunk-IHB7UVEH.js";import{a as gr,b as kr,c as hr,d as M,e as H,f as c,g as yn}from"./chunk-VZNNI2VR.js";import{a as dn}from"./chunk-EZSHR3CB.js";import"./chunk-QHABFCRC.js";import{a as Ft,b as Lt,c as Mt,d as Ht,e as zt,f as Qt,g as er,h as tr,i as rr}from"./chunk-GMEPM2QQ.js";import{a as Wt,b as Gt,c as Jt,d as R,f as qt,g as Zt,h as Xt}from"./chunk-JYBKSBB5.js";import{a as Ut}from"./chunk-4NO7MHS7.js";import{a as Rr,b as Cr,c as Er,d as xr}from"./chunk-S6VSAKXB.js";import{a as Ir,b as Br}from"./chunk-PEUTCG3B.js";import{a as $r}from"./chunk-PEJALHXK.js";import{a as Yt}from"./chunk-SC5M74NM.js";import{A as ln,B as un,K as pn,a as Vr,b as Or,c as Nr,d as _r,e as Ur,f as Fr,g as Lr,h as Mr,i as Hr,j as zr,k as Wr,l as Gr,m as Jr,n as qr,o as Zr,p as Yr,q as Xr,r as Qr,s as en,t as tn,u as rn,v as nn,w as on,x as an,y as sn,z as cn}from"./chunk-ZO5IUMX6.js";import{a as y,b as le,c as ar,h as L,i as Ne,j as mr,k as fr,l as j}from"./chunk-MX3DEXMV.js";import{a as I}from"./chunk-NJ3AZYQD.js";import{a as yr,b as Pe,c as Kr,d as g,e as jr,f as Dr,g as Ar,h as Tr}from"./chunk-WFQANMBQ.js";import{a as _e}from"./chunk-6U26UASC.js";import{a as sr,b as cr,c as $,d as lr,e as ur,g as pr,k as dr}from"./chunk-GZPLWII7.js";import{a as nr,b as ce,c as f,d as h,e as ir,f as ue,g as pe,h as de,i as me,j as fe,k as ye,l as ge,r as F,w as K,x as ke,y as he}from"./chunk-7BHDZHJY.js";import{a as or}from"./chunk-FUUTGGJS.js";import{a as At,b as se,c as U,d as Tt,e as k,f as Bt,g as Vt,h as Ot,i as Nt,j as _t}from"./chunk-2ACBWC7K.js";import{a as vr}from"./chunk-ODIECDN7.js";import{VersionOperator as Fa}from"@kanonak-protocol/types/document/models/enums";import{existsSync as On,readFileSync as Nn}from"fs";import{homedir as _n}from"os";import{join as Un}from"path";import{execFile as gn}from"child_process";import{promisify as kn}from"util";var z=kn(gn),hn="kanonak",W="/usr/bin/security",b=class{constructor(e=hn){this.service=e}service;async get(e){let t=c(e);try{let{stdout:n}=await z(W,["find-generic-password","-s",this.service,"-a",t,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${t}' is corrupted (not valid JSON).
1
+ import{a as wr,b as Sr,c as Rr,d as Er,e as be}from"./chunk-TVSHIXLA.js";import{a as yn,c as we,e as Fe,h as Ue,i as Le,j as gn}from"./chunk-IHB7UVEH.js";import{a as kr,b as br,c as Pr,d as M,e as H,f as l,g as hn}from"./chunk-VZNNI2VR.js";import{a as fn}from"./chunk-EZSHR3CB.js";import"./chunk-QHABFCRC.js";import{a as Mt,b as Ht,c as zt,d as Wt,e as Gt,f as tr,g as rr,h as nr,i as or}from"./chunk-GMEPM2QQ.js";import{a as Jt,b as qt,c as Xt,d as E,f as Zt,g as Yt,h as er}from"./chunk-JYBKSBB5.js";import{a as Lt}from"./chunk-4NO7MHS7.js";import{a as Cr,b as xr,c as Ir,d as Kr}from"./chunk-S6VSAKXB.js";import{a as $r,b as Br}from"./chunk-PEUTCG3B.js";import{a as Dr}from"./chunk-PEJALHXK.js";import{a as Qt}from"./chunk-SC5M74NM.js";import{A as pn,B as dn,K as mn,a as Or,b as Vr,c as Fr,d as Ur,e as Lr,f as Mr,g as Hr,h as zr,i as Wr,j as Gr,k as Jr,l as qr,m as Xr,n as Zr,o as Yr,p as Qr,q as en,r as tn,s as rn,t as nn,u as on,v as an,w as sn,x as cn,y as ln,z as un}from"./chunk-ZO5IUMX6.js";import{a as y,b as le,c as cr,h as L,i as Oe,j as yr,k as gr,l as A}from"./chunk-MX3DEXMV.js";import{a as I}from"./chunk-NJ3AZYQD.js";import{a as hr,b as Pe,c as Ar,d as g,e as Tr,f as jr,g as _r,h as Nr}from"./chunk-WFQANMBQ.js";import{a as Ve}from"./chunk-6U26UASC.js";import{a as lr,b as ur,c as $,d as pr,e as dr,g as mr,k as fr}from"./chunk-GZPLWII7.js";import{a as ir,b as ce,c as f,d as k,e as sr,f as ue,g as pe,h as de,i as me,j as fe,k as ye,l as ge,r as U,w as K,x as he,y as ke}from"./chunk-7BHDZHJY.js";import{a as ar}from"./chunk-FUUTGGJS.js";import{a as _t,b as se,c as F,d as Nt,e as h,f as Bt,g as Ot,h as Vt,i as Ft,j as Ut}from"./chunk-2ACBWC7K.js";import{a as vr}from"./chunk-ODIECDN7.js";import{VersionOperator as La}from"@kanonak-protocol/types/document/models/enums";import{existsSync as Vn,readFileSync as Fn}from"fs";import{homedir as Un}from"os";import{join as Ln}from"path";import{execFile as kn}from"child_process";import{promisify as bn}from"util";var z=bn(kn),Pn="kanonak",W="/usr/bin/security",b=class{constructor(e=Pn){this.service=e}service;async get(e){let t=l(e);try{let{stdout:n}=await z(W,["find-generic-password","-s",this.service,"-a",t,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${t}' is corrupted (not valid JSON).
2
2
  Run 'kanonak logout ${t}' then 'kanonak login ${t}' to fix.`)}}catch(n){if(Me(n,44))return null;throw new Error(`macOS Keychain read failed for '${t}': ${G(n)}
3
3
  The Keychain may be locked or inaccessible.
4
- Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,t){let n=c(e),o=JSON.stringify(t);try{await z(W,["add-generic-password","-s",this.service,"-a",n,"-U","-w",o],{timeout:1e4})}catch(i){throw new Error(`macOS Keychain write failed for '${n}': ${G(i)}
4
+ Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,t){let n=l(e),o=JSON.stringify(t);try{await z(W,["add-generic-password","-s",this.service,"-a",n,"-U","-w",o],{timeout:1e4})}catch(i){throw new Error(`macOS Keychain write failed for '${n}': ${G(i)}
5
5
  Ensure the Keychain is unlocked and the CLI has write permission.
6
- On managed devices, your IT policy may block credential storage.`)}}async remove(e){let t=c(e);try{await z(W,["delete-generic-password","-s",this.service,"-a",t],{timeout:1e4})}catch(n){if(Me(n,44))return;console.warn(` Warning: macOS Keychain delete failed for '${t}': ${G(n)}
6
+ On managed devices, your IT policy may block credential storage.`)}}async remove(e){let t=l(e);try{await z(W,["delete-generic-password","-s",this.service,"-a",t],{timeout:1e4})}catch(n){if(Me(n,44))return;console.warn(` Warning: macOS Keychain delete failed for '${t}': ${G(n)}
7
7
  The credential may not have been fully removed.`)}}async list(){try{let{stdout:e}=await z(W,["dump-keychain"],{timeout:1e4}),t=[],n=!1;for(let o of e.split(`
8
- `))if(o.includes(`"svce"<blob>="${this.service}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let i=o.match(/"acct"<blob>="([^"]+)"/);i&&t.push(i[1]),n=!1}return t}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${G(e)}`),[]}}};function Me(r,e){return typeof r=="object"&&r!==null&&"code"in r&&r.code===e}function G(r){return r instanceof Error?r.message:String(r)}import{execFile as bn}from"child_process";import{promisify as Pn}from"util";var wn=Pn(bn),Sn="kanonak:",P=class{constructor(e=Sn){this.targetPrefix=e}targetPrefix;async get(e){let t=this.targetPrefix+c(e),n=`
8
+ `))if(o.includes(`"svce"<blob>="${this.service}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let i=o.match(/"acct"<blob>="([^"]+)"/);i&&t.push(i[1]),n=!1}return t}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${G(e)}`),[]}}};function Me(r,e){return typeof r=="object"&&r!==null&&"code"in r&&r.code===e}function G(r){return r instanceof Error?r.message:String(r)}import{execFile as wn}from"child_process";import{promisify as Sn}from"util";var Rn=Sn(wn),En="kanonak:",He=2560,P=class{constructor(e=En){this.targetPrefix=e}targetPrefix;async get(e){let t=this.targetPrefix+l(e),n=`
9
9
  ${q}
10
- $target = [Console]::In.ReadLine()
10
+ $target = $env:KANONAK_CRED_TARGET
11
11
  $ptr = [IntPtr]::Zero
12
12
  $result = [CredMan]::CredRead($target, 1, 0, [ref]$ptr)
13
13
  if (-not $result) { exit 1 }
@@ -18,10 +18,10 @@ try {
18
18
  [System.Text.Encoding]::Unicode.GetString($bytes)
19
19
  } finally {
20
20
  [CredMan]::CredFree($ptr)
21
- }`;try{let{stdout:o}=await J(n,t),i=o.trim();return i?JSON.parse(i):null}catch{return null}}async store(e,t){let n=this.targetPrefix+c(e),o=JSON.stringify(t),i=`
21
+ }`;try{let{stdout:o}=await J(n,{KANONAK_CRED_TARGET:t}),i=o.trim();return i?JSON.parse(i):null}catch{return null}}async store(e,t){let n=this.targetPrefix+l(e),o=JSON.stringify(t),i=Buffer.byteLength(o,"utf16le");if(i>He)throw new Error(`Credential '${n}' is ${i} bytes (UTF-16), over the Windows Credential Manager limit of ${He} (CRED_MAX_CREDENTIAL_BLOB_SIZE). Keep only the secret here and store large/public material (certificates, chains) on disk.`);let a=`
22
22
  ${q}
23
- $target = [Console]::In.ReadLine()
24
- $json = [Console]::In.ReadLine()
23
+ $target = $env:KANONAK_CRED_TARGET
24
+ $json = $env:KANONAK_CRED_JSON
25
25
  $bytes = [System.Text.Encoding]::Unicode.GetBytes($json)
26
26
  $cred = New-Object CredMan+CREDENTIAL
27
27
  $cred.Type = 1
@@ -32,20 +32,22 @@ try {
32
32
  [System.Runtime.InteropServices.Marshal]::Copy($bytes, 0, $cred.CredentialBlob, $bytes.Length)
33
33
  $cred.Persist = 2
34
34
  $result = [CredMan]::CredWrite([ref]$cred, 0)
35
- if (-not $result) { throw "CredWrite failed" }
35
+ if (-not $result) { throw "CredWrite failed (Win32 error $([System.Runtime.InteropServices.Marshal]::GetLastWin32Error()))" }
36
36
  } finally {
37
37
  [System.Runtime.InteropServices.Marshal]::FreeHGlobal($cred.CredentialBlob)
38
- }`;try{await J(i,`${n}
39
- ${o}`)}catch(a){throw new Error(`Windows Credential Manager write failed: ${String(a)}`)}}async remove(e){let t=this.targetPrefix+c(e),n=`
38
+ }`;try{await J(a,{KANONAK_CRED_TARGET:n,KANONAK_CRED_JSON:o})}catch(s){let c=s,u=c.stderr&&c.stderr.trim()||c.message||String(s);throw new Error(`Windows Credential Manager write failed: ${u}`)}}async remove(e){let t=this.targetPrefix+l(e),n=`
40
39
  ${q}
41
- $target = [Console]::In.ReadLine()
42
- [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await J(n,t)}catch{}}async list(){let e=`
40
+ $target = $env:KANONAK_CRED_TARGET
41
+ [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await J(n,{KANONAK_CRED_TARGET:t})}catch{}}async list(){let e=`
43
42
  ${q}
44
43
  ${vn}
45
- $prefix = [Console]::In.ReadLine()
44
+ $prefix = $env:KANONAK_CRED_PREFIX
46
45
  $count = 0
47
46
  $pCreds = [IntPtr]::Zero
48
- if ([CredMan]::CredEnumerate($null, 0, [ref]$count, [ref]$pCreds)) {
47
+ # Filter by the namespace prefix as a wildcard (CredEnumerate flags=0). A $null
48
+ # filter would need CRED_ENUMERATE_ALL_CREDENTIALS, but PowerShell marshals a
49
+ # null string as "" so the API rejects it (ERROR_INVALID_FLAGS, 1004).
50
+ if ([CredMan]::CredEnumerate(($prefix + "*"), 0, [ref]$count, [ref]$pCreds)) {
49
51
  $ptrSize = [System.Runtime.InteropServices.Marshal]::SizeOf([Type][IntPtr])
50
52
  for ($i = 0; $i -lt $count; $i++) {
51
53
  $credPtr = [System.Runtime.InteropServices.Marshal]::ReadIntPtr($pCreds, $i * $ptrSize)
@@ -55,8 +57,8 @@ if ([CredMan]::CredEnumerate($null, 0, [ref]$count, [ref]$pCreds)) {
55
57
  }
56
58
  }
57
59
  [CredMan]::CredFree($pCreds)
58
- }`;try{let{stdout:t}=await J(e,this.targetPrefix);return t.trim().split(`
59
- `).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function J(r,e){for(let t of["pwsh","powershell"])try{return await wn(t,["-NoProfile","-NonInteractive","-Command",r],{timeout:15e3,...e!==void 0&&{input:e}})}catch(n){if(t==="powershell")throw n}throw new Error("Neither pwsh nor powershell found")}var q=`
60
+ }`;try{let{stdout:t}=await J(e,{KANONAK_CRED_PREFIX:this.targetPrefix});return t.trim().split(`
61
+ `).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function J(r,e){let t=Buffer.from(r,"utf16le").toString("base64");for(let n of["pwsh","powershell"])try{return await Rn(n,["-NoProfile","-NonInteractive","-EncodedCommand",t],{timeout:15e3,...e&&{env:{...process.env,...e}}})}catch(o){if(n==="powershell")throw o}throw new Error("Neither pwsh nor powershell found")}var q=`
60
62
  Add-Type -TypeDefinition @"
61
63
  using System;
62
64
  using System.Runtime.InteropServices;
@@ -87,13 +89,13 @@ public class CredMan {
87
89
  [DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
88
90
  public static extern bool CredEnumerate(string filter, int flags, out int count, out IntPtr credentials);
89
91
  }
90
- "@`,vn="";import{execFile as Rn,spawn as Cn}from"child_process";import{promisify as En}from"util";var Z=En(Rn),xn="kanonak",w=class{constructor(e=xn){this.service=e}service;async get(e){let t=c(e);try{let{stdout:n}=await Z("secret-tool",["lookup","service",this.service,"publisher",t],{timeout:1e4}),o=n.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,t){let n=c(e),o=JSON.stringify(t);await new Promise((i,a)=>{let s=Cn("secret-tool",["store","--label",`Kanonak: ${n}`,"service",this.service,"publisher",n],{stdio:["pipe","ignore","ignore"],timeout:1e4});s.stdin.write(o),s.stdin.end(),s.on("close",l=>{l===0?i():a(new Error(`secret-tool store exited with code ${l}`))}),s.on("error",a)})}async remove(e){let t=c(e);try{await Z("secret-tool",["clear","service",this.service,"publisher",t],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await Z("secret-tool",["search","service",this.service],{timeout:1e4}),t=[];for(let n of e.split(`
91
- `)){let o=n.match(/attribute\.publisher\s*=\s*(.+)/);o&&t.push(o[1].trim())}return t}catch{return[]}}};async function D(){try{return await Z("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as He,mkdirSync as ze,readFileSync as We,writeFileSync as Ge}from"fs";import{createCipheriv as In,createDecipheriv as Kn,randomBytes as Je}from"crypto";import{homedir as $n}from"os";import{join as Re,dirname as qe}from"path";var Ye=Re($n(),".config","kanonak"),A=Re(Ye,"keyring.key"),jn=Re(Ye,"credentials.enc"),Ze="aes-256-gcm",Se=32,C=12,ve=16,S=class{constructor(e=jn){this.secretsFile=e}secretsFile;async get(e){let t=this.loadStore(),n=c(e);return t[n]??null}async store(e,t){let n=this.loadStore(),o=c(e);n[o]=t,this.saveStore(n)}async remove(e){let t=this.loadStore(),n=c(e);delete t[n],this.saveStore(t)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!He(this.secretsFile))return{};try{let e=this.getOrCreateKey(),t=We(this.secretsFile);if(t.length<C+ve)return{};let n=t.subarray(0,C),o=t.subarray(C,C+ve),i=t.subarray(C+ve),a=Kn(Ze,e,n);a.setAuthTag(o);let s=Buffer.concat([a.update(i),a.final()]);return JSON.parse(s.toString("utf-8"))}catch{return{}}}saveStore(e){let t=this.getOrCreateKey(),n=Je(C),o=In(Ze,t,n),i=Buffer.from(JSON.stringify(e),"utf-8"),a=Buffer.concat([o.update(i),o.final()]),s=o.getAuthTag(),l=Buffer.concat([n,s,a]);ze(qe(this.secretsFile),{recursive:!0}),Ge(this.secretsFile,l,{mode:384})}getOrCreateKey(){if(He(A)){let t=We(A);if(t.length!==Se)throw new Error(`Credential keyring key is corrupted (expected ${Se} bytes, got ${t.length}). Delete ${A} and re-authenticate.`);return t}let e=Je(Se);return ze(qe(A),{recursive:!0}),Ge(A,e,{mode:384}),e}};import{execFile as Dn}from"child_process";import{promisify as An}from"util";var Tn=An(Dn),Xe=3e4,T=class{constructor(e){this.helperPath=e}helperPath;async get(e){let t=c(e);try{let o=(await this.runHelper("get",{publisher:t})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${t}': ${Y(n)}
92
+ "@`,vn="";import{execFile as Cn,spawn as xn}from"child_process";import{promisify as In}from"util";var X=In(Cn),Kn="kanonak",w=class{constructor(e=Kn){this.service=e}service;async get(e){let t=l(e);try{let{stdout:n}=await X("secret-tool",["lookup","service",this.service,"publisher",t],{timeout:1e4}),o=n.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,t){let n=l(e),o=JSON.stringify(t);await new Promise((i,a)=>{let s=xn("secret-tool",["store","--label",`Kanonak: ${n}`,"service",this.service,"publisher",n],{stdio:["pipe","ignore","ignore"],timeout:1e4});s.stdin.write(o),s.stdin.end(),s.on("close",c=>{c===0?i():a(new Error(`secret-tool store exited with code ${c}`))}),s.on("error",a)})}async remove(e){let t=l(e);try{await X("secret-tool",["clear","service",this.service,"publisher",t],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await X("secret-tool",["search","service",this.service],{timeout:1e4}),t=[];for(let n of e.split(`
93
+ `)){let o=n.match(/attribute\.publisher\s*=\s*(.+)/);o&&t.push(o[1].trim())}return t}catch{return[]}}};async function D(){try{return await X("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as ze,mkdirSync as We,readFileSync as Ge,writeFileSync as Je}from"fs";import{createCipheriv as $n,createDecipheriv as An,randomBytes as qe}from"crypto";import{homedir as Dn}from"os";import{join as Ee,dirname as Xe}from"path";var Ye=Ee(Dn(),".config","kanonak"),T=Ee(Ye,"keyring.key"),Tn=Ee(Ye,"credentials.enc"),Ze="aes-256-gcm",Se=32,v=12,Re=16,S=class{constructor(e=Tn){this.secretsFile=e}secretsFile;async get(e){let t=this.loadStore(),n=l(e);return t[n]??null}async store(e,t){let n=this.loadStore(),o=l(e);n[o]=t,this.saveStore(n)}async remove(e){let t=this.loadStore(),n=l(e);delete t[n],this.saveStore(t)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!ze(this.secretsFile))return{};try{let e=this.getOrCreateKey(),t=Ge(this.secretsFile);if(t.length<v+Re)return{};let n=t.subarray(0,v),o=t.subarray(v,v+Re),i=t.subarray(v+Re),a=An(Ze,e,n);a.setAuthTag(o);let s=Buffer.concat([a.update(i),a.final()]);return JSON.parse(s.toString("utf-8"))}catch{return{}}}saveStore(e){let t=this.getOrCreateKey(),n=qe(v),o=$n(Ze,t,n),i=Buffer.from(JSON.stringify(e),"utf-8"),a=Buffer.concat([o.update(i),o.final()]),s=o.getAuthTag(),c=Buffer.concat([n,s,a]);We(Xe(this.secretsFile),{recursive:!0}),Je(this.secretsFile,c,{mode:384})}getOrCreateKey(){if(ze(T)){let t=Ge(T);if(t.length!==Se)throw new Error(`Credential keyring key is corrupted (expected ${Se} bytes, got ${t.length}). Delete ${T} and re-authenticate.`);return t}let e=qe(Se);return We(Xe(T),{recursive:!0}),Je(T,e,{mode:384}),e}};import{execFile as jn}from"child_process";import{promisify as _n}from"util";var Nn=_n(jn),Qe=3e4,j=class{constructor(e){this.helperPath=e}helperPath;async get(e){let t=l(e);try{let o=(await this.runHelper("get",{publisher:t})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${t}': ${Z(n)}
92
94
  Verify the helper binary exists, is executable, and implements the Kanonak credential helper protocol.
93
- Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,t){let n=c(e);try{await this.runHelper("store",{publisher:n,credential:t})}catch(o){throw new Error(`Credential helper '${this.helperPath}' failed to store credential for '${n}': ${Y(o)}
94
- Verify the helper binary supports the 'store' action.`)}}async remove(e){let t=c(e);try{await this.runHelper("erase",{publisher:t})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${t}': ${Y(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${Y(e)}`),[]}}async runHelper(e,t){try{let{stdout:n}=await Tn(this.helperPath,[e],{...t&&{input:JSON.stringify(t)},timeout:Xe});return n}catch(n){throw Bn(n)?new Error(`Credential helper not found at '${this.helperPath}'.
95
- Check the 'credentialHelper' path in ~/.kanonak/config.json.`):Vn(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${Xe/1e3}s on '${e}'.
96
- The helper may be waiting for authentication to an external vault.`):n}}};function Y(r){return r instanceof Error?r.message:String(r)}function Bn(r){return r instanceof Error&&"code"in r&&r.code==="ENOENT"}function Vn(r){return r instanceof Error&&"killed"in r&&r.killed}var Ce=Un(_n(),".kanonak","config.json"),X=class{backend=null;backendReady=null;async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async getToken(e){let t=Fn(e);if(t)return t;let o=await(await this.getBackend()).get(e);return!o||!H(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,t){return(await this.getBackend()).store(e,t)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=Ln();return e.credentialHelper?new T(e.credentialHelper):process.platform==="darwin"?new b:process.platform==="win32"?new P:await D()?new w:new S}};function Fn(r){let t="KANONAK_TOKEN_"+c(r).replace(/[.\-]/g,"_").toUpperCase();return process.env[t]??null}function Ln(){if(!On(Ce))return{};try{return JSON.parse(Nn(Ce,"utf-8"))}catch(r){let e=r instanceof Error?r.message:String(r);return console.warn(` Warning: Failed to parse ${Ce}: ${e}
97
- Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{homedir as tt}from"os";import{join as v}from"path";import{mkdir as Mn,writeFile as Qe,readFile as et,rm as Hn}from"fs/promises";var Ee="kanonak-device",zn=v(tt(),".config","kanonak","device-credentials.enc"),Wn=v(tt(),".kanonak","devices"),Q=class{constructor(e={}){this.deps=e}deps;backend=null;backendReady=null;certDir(e){let t=c(e).replace(/[^a-zA-Z0-9._-]/g,"_");return v(this.deps.certBaseDir??Wn,t)}async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async get(e){let t=await(await this.getBackend()).get(e);if(!t)return null;if(typeof t.certificatePem=="string"&&typeof t.chainPem=="string")return t;let n=this.certDir(e),o,i;try{o=await et(v(n,"cert.pem"),"utf-8"),i=await et(v(n,"chain.pem"),"utf-8")}catch{return null}return{...t,certificatePem:o,chainPem:i}}async store(e,t){let{certificatePem:n,chainPem:o,...i}=t,a=this.certDir(e);await Mn(a,{recursive:!0}),await Qe(v(a,"cert.pem"),n,"utf-8"),await Qe(v(a,"chain.pem"),o,"utf-8"),await(await this.getBackend()).store(e,i)}async remove(e){await(await this.getBackend()).remove(e),await Hn(this.certDir(e),{recursive:!0,force:!0})}async list(){return(await this.getBackend()).list()}async resolveBackend(){return this.deps.backend?this.deps.backend:process.platform==="darwin"?new b(Ee):process.platform==="win32"?new P(`${Ee}:`):await D()?new w(Ee):new S(zn)}};import{createHash as Gn,createPrivateKey as Jn,generateKeyPairSync as qn,randomUUID as Zn,sign as Yn}from"crypto";function nt(){let{publicKey:r,privateKey:e}=qn("ec",{namedCurve:"P-256"});return{publicKey:r.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function B(r,e,t,n,o,i){let a={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},s={jti:Zn(),htm:t.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(s.ath=Gn("sha256").update(o).digest("base64url")),i&&(s.nonce=i),Xn(a,s,r)}function ot(r){return!r||r.length===0?!1:r.some(e=>e.toUpperCase()==="ES256")}function Xn(r,e,t){let n=rt(JSON.stringify(r)),o=rt(JSON.stringify(e)),i=`${n}.${o}`,a=Jn({key:t,format:"jwk"}),l=Yn("SHA256",Buffer.from(i),{key:a,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${i}.${l}`}function rt(r){return Buffer.from(r,"utf-8").toString("base64url")}function it(r){let e=new Map;return async(t,n,o="GET")=>{if(!r)return R(t,{method:o});let i=await r.getCredential(n);if(!i?.accessToken)return R(t,{method:o});M(i)&&console.warn(` Warning: Access token for '${n}' is expired. Run 'kanonak login ${n}' to re-authenticate.`);let a={};if(i.dpopKeyPair){let l=e.get(n);try{let u=B(i.dpopKeyPair.privateKey,i.dpopKeyPair.publicKey,o,t,i.accessToken,l);a.Authorization=`DPoP ${i.accessToken}`,a.DPoP=u}catch(u){let p=u instanceof Error?u.message:String(u);console.error(` Error: Failed to create DPoP proof for '${n}': ${p}
98
- The stored key pair may be corrupted. Run 'kanonak login ${n}' to re-authenticate.`),a.Authorization=`Bearer ${i.accessToken}`}}else a.Authorization=`Bearer ${i.accessToken}`;let s=await R(t,{method:o,headers:a});if(s.status===401&&i.dpopKeyPair){let l=s.headers.get("DPoP-Nonce");if(l){e.set(n,l);try{let u=B(i.dpopKeyPair.privateKey,i.dpopKeyPair.publicKey,o,t,i.accessToken,l);a.DPoP=u,s=await R(t,{method:o,headers:a})}catch{}}}return s}}import{readFileSync as Qn,writeFileSync as eo,existsSync as to}from"fs";import{createHash as ro}from"crypto";import at from"js-yaml";var st="kanonak.lock",no=`# This file is generated by Kanonak CLI. Do not edit manually.
99
- `;function ct(r=st){if(!to(r))return null;let e=Qn(r,"utf-8"),t=at.load(e);return!t||typeof t!="object"||t.version!=="1"?null:{version:"1",lastUpdated:t.lastUpdated??new Date().toISOString(),packages:t.packages??{}}}function lt(r,e=st){r.lastUpdated=new Date().toISOString();let t={};for(let o of Object.keys(r.packages).sort())t[o]=r.packages[o];r.packages=t;let n=at.dump(r,{lineWidth:-1,sortKeys:!1,quotingType:'"'});eo(e,no+n,"utf-8")}function ut(r){return`sha256:${ro("sha256").update(r).digest("hex")}`}import*as Ke from"js-yaml";import{canonicalForm as oo,canonicalHash as io}from"@kanonak-protocol/canonical";function xe(r){return typeof r=="object"&&r!==null&&Array.isArray(r.subjects)}import{CANONICAL_FORM_VERSION as kt}from"@kanonak-protocol/canonical";function pt(r){return oo(xe(r)?r:dt(r))}function ee(r){return io(xe(r)?r:dt(r))}function dt(r){let e=[];for(let t of r)t instanceof f&&e.push({uri:lo(t),statements:Ie(t.statement)});return{subjects:e}}function Ie(r){let e=[];for(let t of r){let n=co(t);if(!n)continue;let o=ao(t);o&&e.push({predicate:n,value:o})}return e}function ao(r){if(r instanceof ue&&r.carrier)return{lit:r.lexical??String(r.object),datatype:ft(r.carrier)};if(r instanceof pe)return{raw:r.object};if(r instanceof de)return{raw:r.lexical??String(r.object)};if(r instanceof me)return{raw:r.lexical??String(r.object)};if(r instanceof fe)return{ref:yt(r.object)};if(r instanceof ye)return mt(r.object);if(r instanceof ge)return{list:r.object.map(so)}}function mt(r){let e=Ie(r.statement);return r.name&&r.name.length>0?{embed:{name:r.name,statements:e}}:{embed:{statements:e}}}function so(r){if(r instanceof h)return{ref:yt(r)};if(r instanceof y)return mt(r);if(r instanceof le){if(r.carrier)return{lit:r.lexical??String(r.value),datatype:ft(r.carrier)};let e=r.value;if(typeof e=="string")return{raw:e};if(typeof e=="number")return{raw:String(e)};if(typeof e=="boolean")return{raw:String(e)}}if(r instanceof ce)return{embed:{statements:Ie(r.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${r.constructor?.name??typeof r}); add canonicalization support before hashing data that contains it`)}function ft(r){return r===L.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${r}`}function co(r){let e=r.predicate;if(e)return gt(e.subject)}function lo(r){let e=r.namespace??"",t=r.name??"";return`${e}/${t}`}function yt(r){return gt(r.subject)}function gt(r){let e=r.version;return e&&typeof e.major=="number"?`${r.publisher}/${r.package_}@${e.major}.${e.minor}.${e.patch}/${r.name}`:`${r.publisher}/${r.package_}/${r.name}`}import{VersionOperator as ht}from"@kanonak-protocol/types/document/models/enums";var uo="0.0.0",E=class{constructor(e,t=new I,n){this.repository=e;this.parser=t;this.objectParser=n??new j(this.parser)}repository;parser;objectParser;imports(){return new V}serializeValue(e,t){return wt(e,t)}async buildContentAddressed(e){let t=e.book.toImports(),n=await this.hashBody(e.publisher,t,e.body),o=$e(n),i={type:"EphemeralPackage",publisher:e.publisher,imports:t};e.contentHashProperty&&(i[e.contentHashProperty]=n),Object.assign(i,e.header??{}),i.imports=t;let a={[o]:i,...e.body},s=this.dump(a);return{yaml:s,byteCount:Pt(s),contentHash:n,packageName:o,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let t=e.book.toImports(),n={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:t},o;e.contentHashProperty&&(o=await this.hashBody(e.publisher,t,e.body),n[e.contentHashProperty]=o),Object.assign(n,e.header??{}),n.imports=t;let i={[e.name]:n,...e.body},a=this.dump(i),s={yaml:a,byteCount:Pt(a),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return o!==void 0&&(s.contentHash=o),s}dump(e){return Ke.dump(e,{lineWidth:-1})}async hashBody(e,t,n){let o={[bt]:{type:"EphemeralPackage",publisher:e,imports:t},...n},i=this.parser.parse(Ke.dump(o,{lineWidth:-1})),a=i.metadata.namespace_?.toString(),l=(await this.objectParser.parseKanonaks(new _e(i,this.repository))).filter(u=>u instanceof f&&u.namespace===a&&u.name!==bt);for(let u of l)u.namespace="ephemeral";return ee(l)}},bt="__pkgbuilder_probe__";function Pt(r){return new TextEncoder().encode(r).length}function $e(r){let e="sha256:",t=r.startsWith(e)?e.length:0;return`q-${r.slice(t,t+16)}`}var V=class{byKey=new Map;aliases=new Set;ensure(e,t,n,o,i=ht.Major){let a=`${e}/${t}@${n}`,s=this.byKey.get(a);if(s)return s.alias;let l=this.uniqueAlias(o);return this.byKey.set(a,{publisher:e,package_:t,version:n,alias:l,match:i}),l}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,k(e.version),e.package_)}.${e.name}`}refLatest(e,t,n,o){return`${this.ensure(e,t,uo,o??t,ht.Any)}.${n}`}toImports(){let e=new Map;for(let n of this.byKey.values()){let o=e.get(n.publisher)??[];o.push(n),e.set(n.publisher,o)}return[...e.keys()].sort().map(n=>({publisher:n,packages:e.get(n).sort((o,i)=>o.package_<i.package_?-1:1).map(o=>({package:o.package_,match:se(o.match),version:o.version,alias:o.alias}))}))}uniqueAlias(e){let t=O(e)||"pkg",n=t,o=2;for(;this.aliases.has(n);)n=`${t}${o++}`;return this.aliases.add(n),n}};function wt(r,e){if(r!=null){if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(r instanceof h)return e.ref(r.subject);if(Array.isArray(r)){let t=r.map(n=>wt(n,e)).filter(n=>n!==void 0);return t.length>0?t:void 0}if(r instanceof y)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(po(r))throw new Error(`Value produced a bare URI without a version (${r.publisher}/${r.package_}/${r.name}); cannot serialize it as a reference.`)}}function O(r){return r.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function po(r){return typeof r=="object"&&r!==null&&typeof r.publisher=="string"&&typeof r.package_=="string"&&typeof r.name=="string"}var te=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,t){return this.producers.find(n=>n.canProduce(e,t))}async produceCached(e,t,n,o){let i=`${t}/${n}@${k(o)}`,a=this.produced.get(i);if(a)return a;let{document:s}=await e.produce(t,n,o);return this.produced.set(i,s),s}async getHighestCompatibleVersionAsync(e,t){let n=this.producerFor(e,t.packageName);if(!n)return null;let o={operator:t.versionOperator,version:t.version},i=await n.resolveVersion(e,t.packageName,o);return i?this.produceCached(n,e,t.packageName,i):null}async getDocumentAsync(e){let t;try{t=Pe(e)}catch{return null}if(t.kind!=="package"||!t.version)return null;let n=this.producerFor(t.publisher,t.package_);return n?this.produceCached(n,t.publisher,t.package_,t.version):null}async getDocumentsByNamespaceAsync(e,t){return Array.from(this.produced.values()).filter(n=>{let o=n.metadata.namespace_;return o!=null&&o.publisher===e&&o.package_===t})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},De={async record(){}},N=class extends Error{constructor(t,n){let o=`${t.publisher}/${t.package_}${t.version?`@${t.version.major}.${t.version.minor}.${t.version.patch}`:""}`;super(`Not entitled to produce ${o}${n?`: ${n}`:""}`);this.address=t;this.reason=n;this.name="EntitlementDeniedError"}address;reason},re=class{inner;ctx;policy;meter;constructor(e,t,n=je,o=De){this.inner=e,this.ctx=t,this.policy=n,this.meter=o}canProduce(e,t){return this.inner.canProduce(e,t)}async resolveVersion(e,t,n){return await this.assertAllowed({publisher:e,package_:t,version:n.version}),this.inner.resolveVersion(e,t,n)}async produce(e,t,n){let o={publisher:e,package_:t,version:n};await this.assertAllowed(o);let i=await this.inner.produce(e,t,n);return await this.meter.record(this.ctx,o,i),i}async assertAllowed(e){let t=await this.policy.authorize(this.ctx,e);if(!t.allowed)throw new N(e,t.reason)}};var d="kanonak.org",m="view",St="core-kanonak",mo={publisher:d,package_:m,name:"rootView"},fo={publisher:d,package_:m,name:"bind"},yo={publisher:d,package_:m,name:"produces"},go={publisher:d,package_:m,name:"projections"},ko={publisher:d,package_:m,name:"where"},ho={publisher:d,package_:m,name:"value"},bo={publisher:d,package_:m,name:"as"},ne=class{constructor(e,t=new I){this.repository=e;this.parser=t;this.objectParser=new j(this.parser),this.builder=new E(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let n=await this.objectParser.parseKanonaks(this.repository),o=this.resolveView(n,e),i=K(o,fo);if(!i)throw new Error(`View ${o.namespace}/${o.name} declares no view.bind; cannot materialize.`);let a=K(o,yo);if(!a)throw new Error(`View ${o.namespace}/${o.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let s=Po(o),l=vt(n,d,St),u=vt(n,d,m),p=this.builder.imports(),oe=p.ensure(d,St,l,"ck"),Ct=p.ensure(d,m,u,"v"),Et=p.ref(a),xt=new Le(this.repository,this.parser,this.objectParser),Ae=new Ue(xt,n),It=this.readProjections(n,o),Kt=vo(o,ko),$t=this.findInstances(n,i,await this.reason(t)),Te={},jt=new Set;for(let _ of $t){if(!await this.passesWhere(Ae,n,Kt,_))continue;let ae={type:Et};for(let Ve of It){let Dt=await this.evaluateValue(Ae,n,Ve.value,_),Oe=this.builder.serializeValue(Rt(Dt),p);Oe!==void 0&&(ae[p.ref(Ve.as)]=Oe)}let Be=g(_);Be&&(ae[`${Ct}.derivedFrom`]=p.ref(Be)),Te[this.rowName(_,jt)]=ae}let ie={};t.resolvedAt&&(ie[`${oe}.resolvedAt`]=t.resolvedAt),t.invocationId&&(ie[`${oe}.id`]=t.invocationId);let x=await this.builder.buildContentAddressed({publisher:s,book:p,body:Te,contentHashProperty:`${oe}.contentHash`,header:ie});return{yaml:x.yaml,contentHash:x.contentHash,packageName:x.packageName,publisher:x.publisher,rowCount:x.resourceCount}}resolveView(e,t){let n=F(e,t);if(!n)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let o=K(n,mo);if(o){let i=F(e,o);if(!i)throw new Error(`ViewPackage ${t.name} names rootView ${o.name}, which is not in the catalog.`);return i}return n}readProjections(e,t){let n=[];for(let o of he(t,go)){let i=o instanceof y?o:o instanceof h?F(e,o.subject):void 0;if(!i)continue;let a=ke(i,ho),s=K(i,bo);a&&s&&n.push({value:a,as:s})}return n}async reason(e){return new be({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,n){let o=So(e),i=[],a=new Set;for(let s of n.getInstancesOfClass(t)){if(a.has(s))continue;a.add(s);let l=o.get(s);l&&i.push(l)}return i.sort((s,l)=>{let u=$(g(s)),p=$(g(l));return u<p?-1:u>p?1:0}),i}async passesWhere(e,t,n,o){for(let i of n){let a=await this.evaluateValue(e,t,i,o);if(!Ro(a))return!1}return!0}async evaluateValue(e,t,n,o){let i=Fe(n,"view-projection",{catalog:t,depth:0}),a=new Map([["input",o]]);return e.evaluate(i,a)}rowName(e,t){let n=O(e.name)||"row",o=n,i=2;for(;t.has(o);)o=`${n}-${i++}`;return t.add(o),o}};function Rt(r){return we(r)?r.value:Array.isArray(r)?r.map(Rt):r}function Po(r){let e=g(r);if(!e)throw new Error(`Could not derive a publisher from view ${r.namespace}/${r.name}.`);return e.publisher}function vt(r,e,t){let n=wo(r,e,t);if(!n)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return n}function wo(r,e,t){let n;for(let o of r){if(!(o instanceof f))continue;let i=g(o);!i||i.publisher!==e||i.package_!==t||!i.version||(!n||U(i.version,n)>0)&&(n=i.version)}return n?k(n):void 0}function So(r){let e=new Map,t=new Map;for(let n of r){if(!(n instanceof f))continue;let o=g(n);if(!o||!o.version)continue;let i=$(o),a=t.get(i);(!a||U(o.version,a)>0)&&(t.set(i,o.version),e.set(i,n))}return e}function vo(r,e){let t=ke(r,e);return t?[t]:he(r,e).filter(n=>n instanceof y)}function Ro(r){return r===!0?!0:r===!1||r===void 0||r===null?!1:typeof r=="string"?r.length>0:typeof r=="number"?r!==0:we(r)?r.value.length>0:Array.isArray(r)?r.length>0:!!r}export{rn as AmbiguousReferenceRule,me as BooleanStatement,kt as CANONICAL_FORM_VERSION,L as Carrier,ln as ClassDefinitionRule,qr as ClassHierarchyCycleRule,Mt as CompositeKanonakDocumentRepository,X as CredentialStore,ce as DefinedKanonak,Q as DeviceCertificateStore,Lt as DocumentLocation,kr as EdgeType,y as EmbeddedKanonak,Wr as EmbeddedKanonakTypeRule,ye as EmbeddedStatement,N as EntitlementDeniedError,re as EntitlementProducer,Ft as FileSystemKanonakDocumentRepository,vr as GitIgnoreFilter,hr as GraphBuilder,Xt as HttpKanonakDocumentRepository,V as ImportBook,Gr as ImportExistenceRule,Ut as InMemoryKanonakDocumentRepository,Wt as KANONAK_USER_AGENT,nr as Kanonak,Cr as KanonakDocumentPositions,j as KanonakObjectParser,pn as KanonakObjectValidator,I as KanonakParser,or as KanonakUri,Ir as KanonakUriBuilder,$r as KanonakUrlResolver,dr as KanonakVocabulary,ge as ListStatement,le as LiteralKanonak,Qt as LocalFirstRepository,er as LockAwareRepository,fn as LookRenderer,un as MarkdownLinkRule,ar as MarkdownStatement,en as NamespaceImportCycleRule,Fr as NamespacePrefixRule,gr as NodeType,de as NumberStatement,wr as OWL_RL_CLASSIFICATION_RULES,on as ObjectPropertyValueValidationRule,Nr as OntologyValidationError,Vr as OntologyValidationResult,E as PackageBuilder,zr as PackageHeaderRule,te as ProducerRepository,an as PropertyDomainRule,Zr as PropertyHierarchyCycleRule,sn as PropertyKindRangeConsistencyRule,Rr as PropertyMetadata,nn as PropertyRangeReferenceRule,Yr as PropertyRangeRequiredRule,Mr as PropertyTypeSpecificityRule,qt as PublisherConfigResolver,Zt as PublisherIndex,Pr as RDFS_RULES,be as Reasoner,Sr as ReasoningResult,h as ReferenceKanonak,fe as ReferenceStatement,zt as RepositoryFactory,cn as ReservedNameShadowRule,Lr as ResourceNamingRule,sr as ResourceResolver,yr as ResourceTypeClassifier,ue as ScalarStatement,ir as Statement,pe as StringStatement,Xr as SubClassOfReferenceRule,Qr as SubPropertyOfReferenceRule,f as SubjectKanonak,Hr as SubjectKanonakTypeRequiredRule,br as TripleStore,cr as TypeResolver,tn as UnresolvedPredicateRule,Jr as UnresolvedReferenceRule,Ur as ValidationCache,_r as ValidationContext,Or as ValidationSeverity,Fa as VersionOperator,ne as ViewMaterializer,je as allowAllPolicy,Yt as assertPackageIdentity,rr as buildLocalFirstRepository,yn as buildOntologyModel,pt as canonicalForm,ee as canonicalHash,Ne as carrierOf,tr as collectKanonakFiles,U as compareVersions,ut as computeIntegrity,$e as contentAddressedName,Tr as contextTypesOf,it as createAuthenticatedFetch,B as createDPoPProof,Bt as createVersion,fr as extractMarkdownLinks,dn as findDerivation,Br as findInstancesByType,mr as findMalformedReferences,xr as findMarkdownLinkAt,Kr as formatKanonakAddress,k as formatVersion,nt as generateDPoPKeyPair,Ht as getGlobalCachePath,Jt as getKanonakUserAgent,H as hasValidToken,Ot as isCompatibleVersion,M as isExpired,Nt as isMajorCompatible,R as kanonakFetch,ct as loadLockFile,lr as makeUriKey,De as noopMeter,c as normalizeHost,Pe as parseKanonakAddress,Vt as parseVersionString,Er as parseWithPositions,_t as pickHighestDocument,Dr as propertiesInScope,mn as resolveDisplayValue,Ar as resolvePropertyStep,O as sanitizeName,lt as saveLockFile,ot as serverSupportsDPoP,Gt as setKanonakUserAgent,g as subjectUri,jr as superClassChain,ur as tripleKey,$ as uriKey,pr as uriTriple,At as versionOperatorFromChar,se as versionOperatorToChar,Tt as versionsEqual};
95
+ Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,t){let n=l(e);try{await this.runHelper("store",{publisher:n,credential:t})}catch(o){throw new Error(`Credential helper '${this.helperPath}' failed to store credential for '${n}': ${Z(o)}
96
+ Verify the helper binary supports the 'store' action.`)}}async remove(e){let t=l(e);try{await this.runHelper("erase",{publisher:t})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${t}': ${Z(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${Z(e)}`),[]}}async runHelper(e,t){try{let{stdout:n}=await Nn(this.helperPath,[e],{...t&&{input:JSON.stringify(t)},timeout:Qe});return n}catch(n){throw Bn(n)?new Error(`Credential helper not found at '${this.helperPath}'.
97
+ Check the 'credentialHelper' path in ~/.kanonak/config.json.`):On(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${Qe/1e3}s on '${e}'.
98
+ The helper may be waiting for authentication to an external vault.`):n}}};function Z(r){return r instanceof Error?r.message:String(r)}function Bn(r){return r instanceof Error&&"code"in r&&r.code==="ENOENT"}function On(r){return r instanceof Error&&"killed"in r&&r.killed}var ve=Ln(Un(),".kanonak","config.json"),Y=class{backend=null;backendReady=null;async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async getToken(e){let t=Mn(e);if(t)return t;let o=await(await this.getBackend()).get(e);return!o||!H(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,t){return(await this.getBackend()).store(e,t)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=Hn();return e.credentialHelper?new j(e.credentialHelper):process.platform==="darwin"?new b:process.platform==="win32"?new P:await D()?new w:new S}};function Mn(r){let t="KANONAK_TOKEN_"+l(r).replace(/[.\-]/g,"_").toUpperCase();return process.env[t]??null}function Hn(){if(!Vn(ve))return{};try{return JSON.parse(Fn(ve,"utf-8"))}catch(r){let e=r instanceof Error?r.message:String(r);return console.warn(` Warning: Failed to parse ${ve}: ${e}
99
+ Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{homedir as nt}from"os";import{join as R}from"path";import{mkdir as zn,writeFile as et,readFile as tt,rm as rt}from"fs/promises";var Ce="kanonak-device",Wn=R(nt(),".config","kanonak","device-credentials.enc"),Gn=R(nt(),".kanonak","devices"),Q=class{constructor(e={}){this.deps=e}deps;backend=null;backendReady=null;certDir(e){let t=l(e).replace(/[^a-zA-Z0-9._-]/g,"_");return R(this.deps.certBaseDir??Gn,t)}async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async get(e){let t=await(await this.getBackend()).get(e);if(!t)return null;if(typeof t.certificatePem=="string"&&typeof t.chainPem=="string")return t;let n=this.certDir(e),o,i;try{o=await tt(R(n,"cert.pem"),"utf-8"),i=await tt(R(n,"chain.pem"),"utf-8")}catch{return null}return{...t,certificatePem:o,chainPem:i}}async store(e,t){let{certificatePem:n,chainPem:o,...i}=t,a=this.certDir(e);await zn(a,{recursive:!0}),await et(R(a,"cert.pem"),n,"utf-8"),await et(R(a,"chain.pem"),o,"utf-8");try{await(await this.getBackend()).store(e,i)}catch(s){throw await rt(a,{recursive:!0,force:!0}).catch(()=>{}),s}}async remove(e){await(await this.getBackend()).remove(e),await rt(this.certDir(e),{recursive:!0,force:!0})}async list(){return(await this.getBackend()).list()}async resolveBackend(){return this.deps.backend?this.deps.backend:process.platform==="darwin"?new b(Ce):process.platform==="win32"?new P(`${Ce}:`):await D()?new w(Ce):new S(Wn)}};import{createHash as Jn,createPrivateKey as qn,generateKeyPairSync as Xn,randomUUID as Zn,sign as Yn}from"crypto";function it(){let{publicKey:r,privateKey:e}=Xn("ec",{namedCurve:"P-256"});return{publicKey:r.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function _(r,e,t,n,o,i){let a={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},s={jti:Zn(),htm:t.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(s.ath=Jn("sha256").update(o).digest("base64url")),i&&(s.nonce=i),Qn(a,s,r)}function at(r){return!r||r.length===0?!1:r.some(e=>e.toUpperCase()==="ES256")}function Qn(r,e,t){let n=ot(JSON.stringify(r)),o=ot(JSON.stringify(e)),i=`${n}.${o}`,a=qn({key:t,format:"jwk"}),c=Yn("SHA256",Buffer.from(i),{key:a,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${i}.${c}`}function ot(r){return Buffer.from(r,"utf-8").toString("base64url")}function st(r){let e=new Map;return async(t,n,o="GET")=>{if(!r)return E(t,{method:o});let i=await r.getCredential(n);if(!i?.accessToken)return E(t,{method:o});M(i)&&console.warn(` Warning: Access token for '${n}' is expired. Run 'kanonak login ${n}' to re-authenticate.`);let a={};if(i.dpopKeyPair){let c=e.get(n);try{let u=_(i.dpopKeyPair.privateKey,i.dpopKeyPair.publicKey,o,t,i.accessToken,c);a.Authorization=`DPoP ${i.accessToken}`,a.DPoP=u}catch(u){let p=u instanceof Error?u.message:String(u);console.error(` Error: Failed to create DPoP proof for '${n}': ${p}
100
+ The stored key pair may be corrupted. Run 'kanonak login ${n}' to re-authenticate.`),a.Authorization=`Bearer ${i.accessToken}`}}else a.Authorization=`Bearer ${i.accessToken}`;let s=await E(t,{method:o,headers:a});if(s.status===401&&i.dpopKeyPair){let c=s.headers.get("DPoP-Nonce");if(c){e.set(n,c);try{let u=_(i.dpopKeyPair.privateKey,i.dpopKeyPair.publicKey,o,t,i.accessToken,c);a.DPoP=u,s=await E(t,{method:o,headers:a})}catch{}}}return s}}import{readFileSync as eo,writeFileSync as to,existsSync as ro}from"fs";import{createHash as no}from"crypto";import ct from"js-yaml";var lt="kanonak.lock",oo=`# This file is generated by Kanonak CLI. Do not edit manually.
101
+ `;function ut(r=lt){if(!ro(r))return null;let e=eo(r,"utf-8"),t=ct.load(e);return!t||typeof t!="object"||t.version!=="1"?null:{version:"1",lastUpdated:t.lastUpdated??new Date().toISOString(),packages:t.packages??{}}}function pt(r,e=lt){r.lastUpdated=new Date().toISOString();let t={};for(let o of Object.keys(r.packages).sort())t[o]=r.packages[o];r.packages=t;let n=ct.dump(r,{lineWidth:-1,sortKeys:!1,quotingType:'"'});to(e,oo+n,"utf-8")}function dt(r){return`sha256:${no("sha256").update(r).digest("hex")}`}import*as Ke from"js-yaml";import{canonicalForm as io,canonicalHash as ao}from"@kanonak-protocol/canonical";function xe(r){return typeof r=="object"&&r!==null&&Array.isArray(r.subjects)}import{CANONICAL_FORM_VERSION as bt}from"@kanonak-protocol/canonical";function mt(r){return io(xe(r)?r:ft(r))}function ee(r){return ao(xe(r)?r:ft(r))}function ft(r){let e=[];for(let t of r)t instanceof f&&e.push({uri:uo(t),statements:Ie(t.statement)});return{subjects:e}}function Ie(r){let e=[];for(let t of r){let n=lo(t);if(!n)continue;let o=so(t);o&&e.push({predicate:n,value:o})}return e}function so(r){if(r instanceof ue&&r.carrier)return{lit:r.lexical??String(r.object),datatype:gt(r.carrier)};if(r instanceof pe)return{raw:r.object};if(r instanceof de)return{raw:r.lexical??String(r.object)};if(r instanceof me)return{raw:r.lexical??String(r.object)};if(r instanceof fe)return{ref:ht(r.object)};if(r instanceof ye)return yt(r.object);if(r instanceof ge)return{list:r.object.map(co)}}function yt(r){let e=Ie(r.statement);return r.name&&r.name.length>0?{embed:{name:r.name,statements:e}}:{embed:{statements:e}}}function co(r){if(r instanceof k)return{ref:ht(r)};if(r instanceof y)return yt(r);if(r instanceof le){if(r.carrier)return{lit:r.lexical??String(r.value),datatype:gt(r.carrier)};let e=r.value;if(typeof e=="string")return{raw:e};if(typeof e=="number")return{raw:String(e)};if(typeof e=="boolean")return{raw:String(e)}}if(r instanceof ce)return{embed:{statements:Ie(r.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${r.constructor?.name??typeof r}); add canonicalization support before hashing data that contains it`)}function gt(r){return r===L.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${r}`}function lo(r){let e=r.predicate;if(e)return kt(e.subject)}function uo(r){let e=r.namespace??"",t=r.name??"";return`${e}/${t}`}function ht(r){return kt(r.subject)}function kt(r){let e=r.version;return e&&typeof e.major=="number"?`${r.publisher}/${r.package_}@${e.major}.${e.minor}.${e.patch}/${r.name}`:`${r.publisher}/${r.package_}/${r.name}`}import{VersionOperator as Pt}from"@kanonak-protocol/types/document/models/enums";var po="0.0.0",C=class{constructor(e,t=new I,n){this.repository=e;this.parser=t;this.objectParser=n??new A(this.parser)}repository;parser;objectParser;imports(){return new N}serializeValue(e,t){return Rt(e,t)}async buildContentAddressed(e){let t=e.book.toImports(),n=await this.hashBody(e.publisher,t,e.body),o=$e(n),i={type:"EphemeralPackage",publisher:e.publisher,imports:t};e.contentHashProperty&&(i[e.contentHashProperty]=n),Object.assign(i,e.header??{}),i.imports=t;let a={[o]:i,...e.body},s=this.dump(a);return{yaml:s,byteCount:St(s),contentHash:n,packageName:o,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let t=e.book.toImports(),n={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:t},o;e.contentHashProperty&&(o=await this.hashBody(e.publisher,t,e.body),n[e.contentHashProperty]=o),Object.assign(n,e.header??{}),n.imports=t;let i={[e.name]:n,...e.body},a=this.dump(i),s={yaml:a,byteCount:St(a),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return o!==void 0&&(s.contentHash=o),s}dump(e){return Ke.dump(e,{lineWidth:-1})}async hashBody(e,t,n){let o={[wt]:{type:"EphemeralPackage",publisher:e,imports:t},...n},i=this.parser.parse(Ke.dump(o,{lineWidth:-1})),a=i.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Ve(i,this.repository))).filter(u=>u instanceof f&&u.namespace===a&&u.name!==wt);for(let u of c)u.namespace="ephemeral";return ee(c)}},wt="__pkgbuilder_probe__";function St(r){return new TextEncoder().encode(r).length}function $e(r){let e="sha256:",t=r.startsWith(e)?e.length:0;return`q-${r.slice(t,t+16)}`}var N=class{byKey=new Map;aliases=new Set;ensure(e,t,n,o,i=Pt.Major){let a=`${e}/${t}@${n}`,s=this.byKey.get(a);if(s)return s.alias;let c=this.uniqueAlias(o);return this.byKey.set(a,{publisher:e,package_:t,version:n,alias:c,match:i}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,h(e.version),e.package_)}.${e.name}`}refLatest(e,t,n,o){return`${this.ensure(e,t,po,o??t,Pt.Any)}.${n}`}toImports(){let e=new Map;for(let n of this.byKey.values()){let o=e.get(n.publisher)??[];o.push(n),e.set(n.publisher,o)}return[...e.keys()].sort().map(n=>({publisher:n,packages:e.get(n).sort((o,i)=>o.package_<i.package_?-1:1).map(o=>({package:o.package_,match:se(o.match),version:o.version,alias:o.alias}))}))}uniqueAlias(e){let t=B(e)||"pkg",n=t,o=2;for(;this.aliases.has(n);)n=`${t}${o++}`;return this.aliases.add(n),n}};function Rt(r,e){if(r!=null){if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(r instanceof k)return e.ref(r.subject);if(Array.isArray(r)){let t=r.map(n=>Rt(n,e)).filter(n=>n!==void 0);return t.length>0?t:void 0}if(r instanceof y)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(mo(r))throw new Error(`Value produced a bare URI without a version (${r.publisher}/${r.package_}/${r.name}); cannot serialize it as a reference.`)}}function B(r){return r.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function mo(r){return typeof r=="object"&&r!==null&&typeof r.publisher=="string"&&typeof r.package_=="string"&&typeof r.name=="string"}var te=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,t){return this.producers.find(n=>n.canProduce(e,t))}async produceCached(e,t,n,o){let i=`${t}/${n}@${h(o)}`,a=this.produced.get(i);if(a)return a;let{document:s}=await e.produce(t,n,o);return this.produced.set(i,s),s}async getHighestCompatibleVersionAsync(e,t){let n=this.producerFor(e,t.packageName);if(!n)return null;let o={operator:t.versionOperator,version:t.version},i=await n.resolveVersion(e,t.packageName,o);return i?this.produceCached(n,e,t.packageName,i):null}async getDocumentAsync(e){let t;try{t=Pe(e)}catch{return null}if(t.kind!=="package"||!t.version)return null;let n=this.producerFor(t.publisher,t.package_);return n?this.produceCached(n,t.publisher,t.package_,t.version):null}async getDocumentsByNamespaceAsync(e,t){return Array.from(this.produced.values()).filter(n=>{let o=n.metadata.namespace_;return o!=null&&o.publisher===e&&o.package_===t})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var Ae={async authorize(){return{allowed:!0}}},De={async record(){}},O=class extends Error{constructor(t,n){let o=`${t.publisher}/${t.package_}${t.version?`@${t.version.major}.${t.version.minor}.${t.version.patch}`:""}`;super(`Not entitled to produce ${o}${n?`: ${n}`:""}`);this.address=t;this.reason=n;this.name="EntitlementDeniedError"}address;reason},re=class{inner;ctx;policy;meter;constructor(e,t,n=Ae,o=De){this.inner=e,this.ctx=t,this.policy=n,this.meter=o}canProduce(e,t){return this.inner.canProduce(e,t)}async resolveVersion(e,t,n){return await this.assertAllowed({publisher:e,package_:t,version:n.version}),this.inner.resolveVersion(e,t,n)}async produce(e,t,n){let o={publisher:e,package_:t,version:n};await this.assertAllowed(o);let i=await this.inner.produce(e,t,n);return await this.meter.record(this.ctx,o,i),i}async assertAllowed(e){let t=await this.policy.authorize(this.ctx,e);if(!t.allowed)throw new O(e,t.reason)}};var d="kanonak.org",m="view",Et="core-kanonak",fo={publisher:d,package_:m,name:"rootView"},yo={publisher:d,package_:m,name:"bind"},go={publisher:d,package_:m,name:"produces"},ho={publisher:d,package_:m,name:"projections"},ko={publisher:d,package_:m,name:"where"},bo={publisher:d,package_:m,name:"value"},Po={publisher:d,package_:m,name:"as"},ne=class{constructor(e,t=new I){this.repository=e;this.parser=t;this.objectParser=new A(this.parser),this.builder=new C(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let n=await this.objectParser.parseKanonaks(this.repository),o=this.resolveView(n,e),i=K(o,yo);if(!i)throw new Error(`View ${o.namespace}/${o.name} declares no view.bind; cannot materialize.`);let a=K(o,go);if(!a)throw new Error(`View ${o.namespace}/${o.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let s=wo(o),c=vt(n,d,Et),u=vt(n,d,m),p=this.builder.imports(),oe=p.ensure(d,Et,c,"ck"),xt=p.ensure(d,m,u,"v"),It=p.ref(a),Kt=new Le(this.repository,this.parser,this.objectParser),Te=new Fe(Kt,n),$t=this.readProjections(n,o),At=Eo(o,ko),Dt=this.findInstances(n,i,await this.reason(t)),je={},Tt=new Set;for(let V of Dt){if(!await this.passesWhere(Te,n,At,V))continue;let ae={type:It};for(let Ne of $t){let jt=await this.evaluateValue(Te,n,Ne.value,V),Be=this.builder.serializeValue(Ct(jt),p);Be!==void 0&&(ae[p.ref(Ne.as)]=Be)}let _e=g(V);_e&&(ae[`${xt}.derivedFrom`]=p.ref(_e)),je[this.rowName(V,Tt)]=ae}let ie={};t.resolvedAt&&(ie[`${oe}.resolvedAt`]=t.resolvedAt),t.invocationId&&(ie[`${oe}.id`]=t.invocationId);let x=await this.builder.buildContentAddressed({publisher:s,book:p,body:je,contentHashProperty:`${oe}.contentHash`,header:ie});return{yaml:x.yaml,contentHash:x.contentHash,packageName:x.packageName,publisher:x.publisher,rowCount:x.resourceCount}}resolveView(e,t){let n=U(e,t);if(!n)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let o=K(n,fo);if(o){let i=U(e,o);if(!i)throw new Error(`ViewPackage ${t.name} names rootView ${o.name}, which is not in the catalog.`);return i}return n}readProjections(e,t){let n=[];for(let o of ke(t,ho)){let i=o instanceof y?o:o instanceof k?U(e,o.subject):void 0;if(!i)continue;let a=he(i,bo),s=K(i,Po);a&&s&&n.push({value:a,as:s})}return n}async reason(e){return new be({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,n){let o=Ro(e),i=[],a=new Set;for(let s of n.getInstancesOfClass(t)){if(a.has(s))continue;a.add(s);let c=o.get(s);c&&i.push(c)}return i.sort((s,c)=>{let u=$(g(s)),p=$(g(c));return u<p?-1:u>p?1:0}),i}async passesWhere(e,t,n,o){for(let i of n){let a=await this.evaluateValue(e,t,i,o);if(!vo(a))return!1}return!0}async evaluateValue(e,t,n,o){let i=Ue(n,"view-projection",{catalog:t,depth:0}),a=new Map([["input",o]]);return e.evaluate(i,a)}rowName(e,t){let n=B(e.name)||"row",o=n,i=2;for(;t.has(o);)o=`${n}-${i++}`;return t.add(o),o}};function Ct(r){return we(r)?r.value:Array.isArray(r)?r.map(Ct):r}function wo(r){let e=g(r);if(!e)throw new Error(`Could not derive a publisher from view ${r.namespace}/${r.name}.`);return e.publisher}function vt(r,e,t){let n=So(r,e,t);if(!n)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return n}function So(r,e,t){let n;for(let o of r){if(!(o instanceof f))continue;let i=g(o);!i||i.publisher!==e||i.package_!==t||!i.version||(!n||F(i.version,n)>0)&&(n=i.version)}return n?h(n):void 0}function Ro(r){let e=new Map,t=new Map;for(let n of r){if(!(n instanceof f))continue;let o=g(n);if(!o||!o.version)continue;let i=$(o),a=t.get(i);(!a||F(o.version,a)>0)&&(t.set(i,o.version),e.set(i,n))}return e}function Eo(r,e){let t=he(r,e);return t?[t]:ke(r,e).filter(n=>n instanceof y)}function vo(r){return r===!0?!0:r===!1||r===void 0||r===null?!1:typeof r=="string"?r.length>0:typeof r=="number"?r!==0:we(r)?r.value.length>0:Array.isArray(r)?r.length>0:!!r}export{on as AmbiguousReferenceRule,me as BooleanStatement,bt as CANONICAL_FORM_VERSION,L as Carrier,pn as ClassDefinitionRule,Zr as ClassHierarchyCycleRule,zt as CompositeKanonakDocumentRepository,Y as CredentialStore,ce as DefinedKanonak,Q as DeviceCertificateStore,Ht as DocumentLocation,br as EdgeType,y as EmbeddedKanonak,Jr as EmbeddedKanonakTypeRule,ye as EmbeddedStatement,O as EntitlementDeniedError,re as EntitlementProducer,Mt as FileSystemKanonakDocumentRepository,vr as GitIgnoreFilter,Pr as GraphBuilder,er as HttpKanonakDocumentRepository,N as ImportBook,qr as ImportExistenceRule,Lt as InMemoryKanonakDocumentRepository,Jt as KANONAK_USER_AGENT,ir as Kanonak,xr as KanonakDocumentPositions,A as KanonakObjectParser,mn as KanonakObjectValidator,I as KanonakParser,ar as KanonakUri,$r as KanonakUriBuilder,Dr as KanonakUrlResolver,fr as KanonakVocabulary,ge as ListStatement,le as LiteralKanonak,tr as LocalFirstRepository,rr as LockAwareRepository,gn as LookRenderer,dn as MarkdownLinkRule,cr as MarkdownStatement,rn as NamespaceImportCycleRule,Mr as NamespacePrefixRule,kr as NodeType,de as NumberStatement,Rr as OWL_RL_CLASSIFICATION_RULES,sn as ObjectPropertyValueValidationRule,Fr as OntologyValidationError,Or as OntologyValidationResult,C as PackageBuilder,Gr as PackageHeaderRule,te as ProducerRepository,cn as PropertyDomainRule,Yr as PropertyHierarchyCycleRule,ln as PropertyKindRangeConsistencyRule,Cr as PropertyMetadata,an as PropertyRangeReferenceRule,Qr as PropertyRangeRequiredRule,zr as PropertyTypeSpecificityRule,Zt as PublisherConfigResolver,Yt as PublisherIndex,Sr as RDFS_RULES,be as Reasoner,Er as ReasoningResult,k as ReferenceKanonak,fe as ReferenceStatement,Gt as RepositoryFactory,un as ReservedNameShadowRule,Hr as ResourceNamingRule,lr as ResourceResolver,hr as ResourceTypeClassifier,ue as ScalarStatement,sr as Statement,pe as StringStatement,en as SubClassOfReferenceRule,tn as SubPropertyOfReferenceRule,f as SubjectKanonak,Wr as SubjectKanonakTypeRequiredRule,wr as TripleStore,ur as TypeResolver,nn as UnresolvedPredicateRule,Xr as UnresolvedReferenceRule,Lr as ValidationCache,Ur as ValidationContext,Vr as ValidationSeverity,La as VersionOperator,ne as ViewMaterializer,Ae as allowAllPolicy,Qt as assertPackageIdentity,or as buildLocalFirstRepository,hn as buildOntologyModel,mt as canonicalForm,ee as canonicalHash,Oe as carrierOf,nr as collectKanonakFiles,F as compareVersions,dt as computeIntegrity,$e as contentAddressedName,Nr as contextTypesOf,st as createAuthenticatedFetch,_ as createDPoPProof,Bt as createVersion,gr as extractMarkdownLinks,fn as findDerivation,Br as findInstancesByType,yr as findMalformedReferences,Kr as findMarkdownLinkAt,Ar as formatKanonakAddress,h as formatVersion,it as generateDPoPKeyPair,Wt as getGlobalCachePath,Xt as getKanonakUserAgent,H as hasValidToken,Vt as isCompatibleVersion,M as isExpired,Ft as isMajorCompatible,E as kanonakFetch,ut as loadLockFile,pr as makeUriKey,De as noopMeter,l as normalizeHost,Pe as parseKanonakAddress,Ot as parseVersionString,Ir as parseWithPositions,Ut as pickHighestDocument,jr as propertiesInScope,yn as resolveDisplayValue,_r as resolvePropertyStep,B as sanitizeName,pt as saveLockFile,at as serverSupportsDPoP,qt as setKanonakUserAgent,g as subjectUri,Tr as superClassChain,dr as tripleKey,$ as uriKey,mr as uriTriple,_t as versionOperatorFromChar,se as versionOperatorToChar,Nt as versionsEqual};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "4.16.0",
3
+ "version": "4.18.0",
4
4
  "description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -126,7 +126,7 @@
126
126
  ],
127
127
  "dependencies": {
128
128
  "@kanonak-protocol/canonical": "^0.1.1",
129
- "@kanonak-protocol/types": "^4.16.0",
129
+ "@kanonak-protocol/types": "^4.18.0",
130
130
  "ignore": "^7.0.5",
131
131
  "js-yaml": "^4.1.0",
132
132
  "yaml": "^2.7.0"