@factoidal/core 0.19.0 → 0.21.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/bin/pack-host.mjs CHANGED
@@ -363,6 +363,11 @@ export async function denoReexec (options) {
363
363
  return null
364
364
  }
365
365
  if (granted.indexOf('run') < 0 || granted.indexOf('read') < 0) return null
366
+ // A `deno compile` executable is not the deno command: given `run ...` it
367
+ // reads `run` as a factoidal command (found 2026-10-28, building the
368
+ // single-file executables of docs/designissues/2026-10-28-single-file-app.md).
369
+ // It packs in process instead.
370
+ if (!/^deno(\.exe)?$/i.test(Deno.execPath().split(/[\\/]/).pop())) return null
366
371
  const main = Deno.mainModule.startsWith('file://')
367
372
  ? fileUrlToPath(Deno.mainModule)
368
373
  : Deno.mainModule
package/bin/serve.mjs CHANGED
@@ -147,6 +147,8 @@ export async function openServedStore (root, options = {}) {
147
147
  const config = {}
148
148
  if (typeof options.queryPath === 'string') config.queryPath = options.queryPath
149
149
  if (typeof options.gspPath === 'string') config.gspPath = options.gspPath
150
+ // The Host and Origin guard (issue 1124): passed unread; the engine decides.
151
+ if (options.localGuard !== undefined && options.localGuard !== null) config.localGuard = options.localGuard
150
152
  const info = engine.callBlobIO('storeServeOpen',
151
153
  [manifestHex, JSON.stringify(artifacts), JSON.stringify(state), JSON.stringify(config)],
152
154
  concatenate(chunks)).envelope
@@ -233,6 +235,8 @@ export async function openServedTdb2 (root, options = {}) {
233
235
  const config = {}
234
236
  if (typeof options.queryPath === 'string') config.queryPath = options.queryPath
235
237
  if (typeof options.gspPath === 'string') config.gspPath = options.gspPath
238
+ // The Host and Origin guard (issue 1124): passed unread; the engine decides.
239
+ if (options.localGuard !== undefined && options.localGuard !== null) config.localGuard = options.localGuard
236
240
  const info = engine.callBlobIO('tdb2ServeOpen',
237
241
  [JSON.stringify(files), JSON.stringify(config)], concatenate(chunks)).envelope
238
242
  const handle = info.handle
@@ -343,9 +347,22 @@ function serveConnection (served, socket, onError) {
343
347
  */
344
348
  export async function listen (root, options = {}) {
345
349
  const net = await import('node:net')
350
+ const host = typeof options.host === 'string' ? options.host : '127.0.0.1'
351
+ // `factoidal serve` has no authentication: the engine answers only the
352
+ // listener's own names and refuses writes from another origin
353
+ // (https://github.com/danbri/factoidal/issues/1124). Data for its check.
354
+ const os = await import('node:os')
355
+ let addresses = []
356
+ try { addresses = Object.values(os.networkInterfaces()).flat().filter(Boolean).map((i) => i.address) } catch (_error) { addresses = [] }
357
+ const localGuard = {
358
+ host,
359
+ addresses,
360
+ ...(Array.isArray(options.allowHosts) ? { allowHosts: options.allowHosts } : {}),
361
+ ...(Array.isArray(options.allowOrigins) ? { allowOrigins: options.allowOrigins } : {})
362
+ }
346
363
  const served = options.tdb2 === true
347
- ? await openServedTdb2(root, options)
348
- : await openServedStore(root, options)
364
+ ? await openServedTdb2(root, { ...options, localGuard })
365
+ : await openServedStore(root, { ...options, localGuard })
349
366
  const onError = typeof options.onError === 'function'
350
367
  ? options.onError
351
368
  : (error) => { console.error(`factoidal serve: ${error && error.message ? error.message : error}`) }
@@ -356,7 +373,6 @@ export async function listen (root, options = {}) {
356
373
  serveConnection(served, socket, onError)
357
374
  })
358
375
  const port = typeof options.port === 'number' ? options.port : 0
359
- const host = typeof options.host === 'string' ? options.host : '127.0.0.1'
360
376
  await new Promise((resolve, reject) => {
361
377
  server.once('error', reject)
362
378
  server.listen(port, host, resolve)
package/browser.d.ts CHANGED
@@ -12,7 +12,9 @@ export type {
12
12
  QueryOptions, SerializeOptions, StoreReader, OpenStoreOptions,
13
13
  DeltaLogHandle, DeltaLogInspection,
14
14
  Sbm11Reader, Sbm11Answer, Sbm11Store, Sbm11ReadEvidence, Sbm11Transport,
15
+ LiteralValueData, LiteralValueResult,
15
16
  ExplainResult, StageInfo, EvidenceRecord, Wire, FactoidalNode, Pipeline, RunResult, RunOptions,
17
+ NodePort, GraphSource, GraphSpec, GraphIssue, GraphCheck, FactoidalGraph, GraphRunResult,
16
18
  } from './index';
17
19
 
18
20
  export {
@@ -23,12 +25,26 @@ export {
23
25
  canonicalize,
24
26
  graphs,
25
27
  canonicalHash,
28
+ asDefaultGraph,
26
29
  isomorphic,
30
+ datasetMerge,
27
31
  fromQuads,
32
+ literalValue,
33
+ isValidLiteral,
34
+ canonicalLiteral,
35
+ literalFromValue,
28
36
  ready,
29
37
  engineTables,
38
+ sameValue,
39
+ syntaxFor,
40
+ splitIri,
41
+ isNCName,
42
+ vocabularies,
43
+ memberIri,
44
+ memberOrdinal,
30
45
  openDataset,
31
46
  closure,
47
+ sparqlRlInfer,
32
48
  formats,
33
49
  queryRaw,
34
50
  queryHdt,
@@ -61,6 +77,7 @@ export {
61
77
  stages,
62
78
  node,
63
79
  pipe,
80
+ graph,
64
81
  run,
65
82
  rdfsPlusClosure,
66
83
  rhoDfClosure,
@@ -94,12 +111,18 @@ export {
94
111
  vcEd25519SecretToPublic,
95
112
  vcEd25519Sign,
96
113
  vcEd25519Verify,
114
+ xmlDecrypt,
115
+ xmlEncrypt,
116
+ jweDecrypt,
117
+ jweEncrypt,
97
118
  vcEddsaCreateFromCanonical,
98
119
  vcEddsaVerifyFromCanonical,
99
120
  vcCheckCredential,
100
121
  vcCheckCredentialSubject,
101
122
  vcCheckNoDataLoss,
102
123
  vcCheckRelatedResourceDigests,
124
+ cidValidate,
125
+ cidRetrieveVerificationMethod,
103
126
  didKeyResolve,
104
127
  capabilities,
105
128
  Dataset,
package/browser.js CHANGED
@@ -83,12 +83,28 @@ export const serialize = api.serialize;
83
83
  export const canonicalize = api.canonicalize;
84
84
  export const graphs = api.graphs;
85
85
  export const canonicalHash = api.canonicalHash;
86
+ export const asDefaultGraph = api.asDefaultGraph;
86
87
  export const isomorphic = api.isomorphic;
88
+ export const datasetMerge = api.datasetMerge;
87
89
  export const fromQuads = api.fromQuads;
90
+ // Literal values (https://github.com/danbri/factoidal/issues/1051): synchronous
91
+ // after the engine is loaded.
92
+ export const literalValue = api.literalValue;
93
+ export const isValidLiteral = api.isValidLiteral;
94
+ export const canonicalLiteral = api.canonicalLiteral;
95
+ export const literalFromValue = api.literalFromValue;
88
96
  export const ready = api.ready;
89
97
  export const engineTables = api.engineTables;
98
+ export const sameValue = api.sameValue;
99
+ export const syntaxFor = api.syntaxFor;
100
+ export const splitIri = api.splitIri;
101
+ export const isNCName = api.isNCName;
102
+ export const vocabularies = api.vocabularies;
103
+ export const memberIri = api.memberIri;
104
+ export const memberOrdinal = api.memberOrdinal;
90
105
  export const openDataset = api.openDataset;
91
106
  export const closure = api.closure;
107
+ export const sparqlRlInfer = api.sparqlRlInfer;
92
108
  export const formats = api.formats;
93
109
  export const queryRaw = api.queryRaw;
94
110
  export const queryHdt = api.queryHdt;
@@ -122,6 +138,7 @@ export const explain = api.explain;
122
138
  export const stages = api.stages;
123
139
  export const node = api.node;
124
140
  export const pipe = api.pipe;
141
+ export const graph = api.graph;
125
142
  export const run = api.run;
126
143
  export const rdfsPlusClosure = api.rdfsPlusClosure;
127
144
  export const rhoDfClosure = api.rhoDfClosure;
@@ -163,12 +180,21 @@ export const vcSha256Hex = api.vcSha256Hex;
163
180
  export const vcEd25519SecretToPublic = api.vcEd25519SecretToPublic;
164
181
  export const vcEd25519Sign = api.vcEd25519Sign;
165
182
  export const vcEd25519Verify = api.vcEd25519Verify;
183
+
184
+ // XML Encryption 1.1 and JWE; AES through WebCrypto (lib/cipher-host.mjs)
185
+ export const xmlDecrypt = api.xmlDecrypt;
186
+ export const xmlEncrypt = api.xmlEncrypt;
187
+ export const jweDecrypt = api.jweDecrypt;
188
+ export const jweEncrypt = api.jweEncrypt;
166
189
  export const vcEddsaCreateFromCanonical = api.vcEddsaCreateFromCanonical;
167
190
  export const vcEddsaVerifyFromCanonical = api.vcEddsaVerifyFromCanonical;
168
191
  export const vcCheckCredential = api.vcCheckCredential;
169
192
  export const vcCheckCredentialSubject = api.vcCheckCredentialSubject;
170
193
  export const vcCheckNoDataLoss = api.vcCheckNoDataLoss;
171
194
  export const vcCheckRelatedResourceDigests = api.vcCheckRelatedResourceDigests;
195
+ // Controlled Identifiers v1.0 (https://github.com/danbri/factoidal/issues/1100).
196
+ export const cidValidate = api.cidValidate;
197
+ export const cidRetrieveVerificationMethod = api.cidRetrieveVerificationMethod;
172
198
  export const didKeyResolve = api.didKeyResolve;
173
199
 
174
200
  // Types, probes and metadata