@fedify/vocab-tools 2.4.0-dev.1995 → 2.4.0-dev.2027
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/deno.json +1 -1
- package/dist/mod.cjs +34 -5
- package/dist/mod.js +34 -5
- package/package.json +1 -1
- package/src/__snapshots__/class.test.ts.deno.snap +1763 -550
- package/src/__snapshots__/class.test.ts.node.snap +1763 -550
- package/src/__snapshots__/class.test.ts.snap +1763 -550
- package/src/class.ts +6 -0
- package/src/codec.ts +14 -2
- package/src/constructor.ts +7 -0
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -8,7 +8,7 @@ let yaml = require("yaml");
|
|
|
8
8
|
let es_toolkit = require("es-toolkit");
|
|
9
9
|
//#region deno.json
|
|
10
10
|
var name = "@fedify/vocab-tools";
|
|
11
|
-
var version = "2.4.0-dev.
|
|
11
|
+
var version = "2.4.0-dev.2027+fcf88bfc";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/type.ts
|
|
14
14
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -785,6 +785,10 @@ async function* generateEncoder(typeUri, types) {
|
|
|
785
785
|
...options,
|
|
786
786
|
contextLoader: options.contextLoader ?? getDocumentLoader(),
|
|
787
787
|
};
|
|
788
|
+
// Joins the enclosing frame's signed-value scope, or starts one when this
|
|
789
|
+
// frame is the outermost. Only the owning frame puts retained signed
|
|
790
|
+
// child documents back in place of their placeholders.
|
|
791
|
+
const signedValues = enterSignedValueScope(options);
|
|
788
792
|
`;
|
|
789
793
|
if (isCompactableType(typeUri, types)) {
|
|
790
794
|
yield `
|
|
@@ -815,9 +819,13 @@ async function* generateEncoder(typeUri, types) {
|
|
|
815
819
|
for (const v of this.${await getFieldName(property.uri)}) {
|
|
816
820
|
const item = (
|
|
817
821
|
`;
|
|
818
|
-
if (!areAllScalarTypes(property.range, types))
|
|
822
|
+
if (!areAllScalarTypes(property.range, types)) {
|
|
823
|
+
yield "retainedSignedValueRef(v, signedValues.scope) ?? (";
|
|
824
|
+
yield "v instanceof URL ? formatIri(v) : ";
|
|
825
|
+
}
|
|
819
826
|
const encoders = getEncoders(property.range, types, "v", "options", true);
|
|
820
827
|
for (const code of encoders) yield code;
|
|
828
|
+
if (!areAllScalarTypes(property.range, types)) yield ")";
|
|
821
829
|
yield `
|
|
822
830
|
);
|
|
823
831
|
compactItems.push(item);
|
|
@@ -848,7 +856,9 @@ async function* generateEncoder(typeUri, types) {
|
|
|
848
856
|
${type.typeless ? "" : `result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};`}
|
|
849
857
|
if (this.id != null) result["id"] = formatIri(this.id);
|
|
850
858
|
result["@context"] = ${JSON.stringify(type.defaultContext)};
|
|
851
|
-
return
|
|
859
|
+
return signedValues.owner
|
|
860
|
+
? resolveSignedValues(result, signedValues.scope)
|
|
861
|
+
: result;
|
|
852
862
|
}
|
|
853
863
|
`;
|
|
854
864
|
}
|
|
@@ -874,8 +884,12 @@ async function* generateEncoder(typeUri, types) {
|
|
|
874
884
|
for (const v of this.${await getFieldName(property.uri)}) {
|
|
875
885
|
let element = (
|
|
876
886
|
`;
|
|
877
|
-
if (!areAllScalarTypes(property.range, types))
|
|
887
|
+
if (!areAllScalarTypes(property.range, types)) {
|
|
888
|
+
yield "retainedSignedValueRef(v, signedValues.scope) ?? (";
|
|
889
|
+
yield "v instanceof URL ? { \"@id\": formatIri(v) } : ";
|
|
890
|
+
}
|
|
878
891
|
for (const code of getEncoders(property.range, types, "v", "options")) yield code;
|
|
892
|
+
if (!areAllScalarTypes(property.range, types)) yield ")";
|
|
879
893
|
yield `
|
|
880
894
|
);
|
|
881
895
|
if (Array.isArray(element)) {
|
|
@@ -962,7 +976,9 @@ async function* generateEncoder(typeUri, types) {
|
|
|
962
976
|
}
|
|
963
977
|
yield `
|
|
964
978
|
}
|
|
965
|
-
return
|
|
979
|
+
return signedValues.owner
|
|
980
|
+
? resolveSignedValues(compacted, signedValues.scope)
|
|
981
|
+
: compacted;
|
|
966
982
|
}
|
|
967
983
|
|
|
968
984
|
protected ${emitOverride$1(typeUri, types)} isCompactable(): boolean {
|
|
@@ -1372,6 +1388,13 @@ async function* generateCloner(typeUri, types) {
|
|
|
1372
1388
|
yield `
|
|
1373
1389
|
/**
|
|
1374
1390
|
* Clones this instance, optionally updating it with the given values.
|
|
1391
|
+
*
|
|
1392
|
+
* A clone never inherits a signed JSON-LD representation retained by
|
|
1393
|
+
* \`signObject()\`: the clone may differ from the document that the proof
|
|
1394
|
+
* covers, so embedding the original secured JSON in a parent document
|
|
1395
|
+
* would be wrong. Sign the clone again if it has to be embedded as a
|
|
1396
|
+
* secured child.
|
|
1397
|
+
*
|
|
1375
1398
|
* @param values The values to update the clone with.
|
|
1376
1399
|
* @param options The options to use for cloning.
|
|
1377
1400
|
* @returns The cloned instance.
|
|
@@ -2013,6 +2036,11 @@ const INTERNAL_RUNTIME_IMPORTS = [
|
|
|
2013
2036
|
"isTrustedIriOrigin",
|
|
2014
2037
|
"normalizeJsonLdIris"
|
|
2015
2038
|
].join(",\n ");
|
|
2039
|
+
const SIGNED_REPRESENTATION_IMPORTS = [
|
|
2040
|
+
"enterSignedValueScope",
|
|
2041
|
+
"resolveSignedValues",
|
|
2042
|
+
"retainedSignedValueRef"
|
|
2043
|
+
].join(",\n ");
|
|
2016
2044
|
const RUNTIME_IMPORTS = [
|
|
2017
2045
|
"canParseDecimal",
|
|
2018
2046
|
"decodeMultibase",
|
|
@@ -2208,6 +2236,7 @@ async function* generateClasses(types) {
|
|
|
2208
2236
|
from "@opentelemetry/api";\n`;
|
|
2209
2237
|
yield `import {\n ${RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime";\n`;
|
|
2210
2238
|
yield `import {\n ${INTERNAL_RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime/internal/jsonld-cache";\n`;
|
|
2239
|
+
yield `import {\n ${SIGNED_REPRESENTATION_IMPORTS}\n} from "@fedify/vocab-runtime/internal/signed-representation";\n`;
|
|
2211
2240
|
yield `import {
|
|
2212
2241
|
isTemporalDuration,
|
|
2213
2242
|
isTemporalInstant,
|
package/dist/mod.js
CHANGED
|
@@ -7,7 +7,7 @@ import { parse } from "yaml";
|
|
|
7
7
|
import { pascalCase } from "es-toolkit";
|
|
8
8
|
//#region deno.json
|
|
9
9
|
var name = "@fedify/vocab-tools";
|
|
10
|
-
var version = "2.4.0-dev.
|
|
10
|
+
var version = "2.4.0-dev.2027+fcf88bfc";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/type.ts
|
|
13
13
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -784,6 +784,10 @@ async function* generateEncoder(typeUri, types) {
|
|
|
784
784
|
...options,
|
|
785
785
|
contextLoader: options.contextLoader ?? getDocumentLoader(),
|
|
786
786
|
};
|
|
787
|
+
// Joins the enclosing frame's signed-value scope, or starts one when this
|
|
788
|
+
// frame is the outermost. Only the owning frame puts retained signed
|
|
789
|
+
// child documents back in place of their placeholders.
|
|
790
|
+
const signedValues = enterSignedValueScope(options);
|
|
787
791
|
`;
|
|
788
792
|
if (isCompactableType(typeUri, types)) {
|
|
789
793
|
yield `
|
|
@@ -814,9 +818,13 @@ async function* generateEncoder(typeUri, types) {
|
|
|
814
818
|
for (const v of this.${await getFieldName(property.uri)}) {
|
|
815
819
|
const item = (
|
|
816
820
|
`;
|
|
817
|
-
if (!areAllScalarTypes(property.range, types))
|
|
821
|
+
if (!areAllScalarTypes(property.range, types)) {
|
|
822
|
+
yield "retainedSignedValueRef(v, signedValues.scope) ?? (";
|
|
823
|
+
yield "v instanceof URL ? formatIri(v) : ";
|
|
824
|
+
}
|
|
818
825
|
const encoders = getEncoders(property.range, types, "v", "options", true);
|
|
819
826
|
for (const code of encoders) yield code;
|
|
827
|
+
if (!areAllScalarTypes(property.range, types)) yield ")";
|
|
820
828
|
yield `
|
|
821
829
|
);
|
|
822
830
|
compactItems.push(item);
|
|
@@ -847,7 +855,9 @@ async function* generateEncoder(typeUri, types) {
|
|
|
847
855
|
${type.typeless ? "" : `result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};`}
|
|
848
856
|
if (this.id != null) result["id"] = formatIri(this.id);
|
|
849
857
|
result["@context"] = ${JSON.stringify(type.defaultContext)};
|
|
850
|
-
return
|
|
858
|
+
return signedValues.owner
|
|
859
|
+
? resolveSignedValues(result, signedValues.scope)
|
|
860
|
+
: result;
|
|
851
861
|
}
|
|
852
862
|
`;
|
|
853
863
|
}
|
|
@@ -873,8 +883,12 @@ async function* generateEncoder(typeUri, types) {
|
|
|
873
883
|
for (const v of this.${await getFieldName(property.uri)}) {
|
|
874
884
|
let element = (
|
|
875
885
|
`;
|
|
876
|
-
if (!areAllScalarTypes(property.range, types))
|
|
886
|
+
if (!areAllScalarTypes(property.range, types)) {
|
|
887
|
+
yield "retainedSignedValueRef(v, signedValues.scope) ?? (";
|
|
888
|
+
yield "v instanceof URL ? { \"@id\": formatIri(v) } : ";
|
|
889
|
+
}
|
|
877
890
|
for (const code of getEncoders(property.range, types, "v", "options")) yield code;
|
|
891
|
+
if (!areAllScalarTypes(property.range, types)) yield ")";
|
|
878
892
|
yield `
|
|
879
893
|
);
|
|
880
894
|
if (Array.isArray(element)) {
|
|
@@ -961,7 +975,9 @@ async function* generateEncoder(typeUri, types) {
|
|
|
961
975
|
}
|
|
962
976
|
yield `
|
|
963
977
|
}
|
|
964
|
-
return
|
|
978
|
+
return signedValues.owner
|
|
979
|
+
? resolveSignedValues(compacted, signedValues.scope)
|
|
980
|
+
: compacted;
|
|
965
981
|
}
|
|
966
982
|
|
|
967
983
|
protected ${emitOverride$1(typeUri, types)} isCompactable(): boolean {
|
|
@@ -1371,6 +1387,13 @@ async function* generateCloner(typeUri, types) {
|
|
|
1371
1387
|
yield `
|
|
1372
1388
|
/**
|
|
1373
1389
|
* Clones this instance, optionally updating it with the given values.
|
|
1390
|
+
*
|
|
1391
|
+
* A clone never inherits a signed JSON-LD representation retained by
|
|
1392
|
+
* \`signObject()\`: the clone may differ from the document that the proof
|
|
1393
|
+
* covers, so embedding the original secured JSON in a parent document
|
|
1394
|
+
* would be wrong. Sign the clone again if it has to be embedded as a
|
|
1395
|
+
* secured child.
|
|
1396
|
+
*
|
|
1374
1397
|
* @param values The values to update the clone with.
|
|
1375
1398
|
* @param options The options to use for cloning.
|
|
1376
1399
|
* @returns The cloned instance.
|
|
@@ -2012,6 +2035,11 @@ const INTERNAL_RUNTIME_IMPORTS = [
|
|
|
2012
2035
|
"isTrustedIriOrigin",
|
|
2013
2036
|
"normalizeJsonLdIris"
|
|
2014
2037
|
].join(",\n ");
|
|
2038
|
+
const SIGNED_REPRESENTATION_IMPORTS = [
|
|
2039
|
+
"enterSignedValueScope",
|
|
2040
|
+
"resolveSignedValues",
|
|
2041
|
+
"retainedSignedValueRef"
|
|
2042
|
+
].join(",\n ");
|
|
2015
2043
|
const RUNTIME_IMPORTS = [
|
|
2016
2044
|
"canParseDecimal",
|
|
2017
2045
|
"decodeMultibase",
|
|
@@ -2207,6 +2235,7 @@ async function* generateClasses(types) {
|
|
|
2207
2235
|
from "@opentelemetry/api";\n`;
|
|
2208
2236
|
yield `import {\n ${RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime";\n`;
|
|
2209
2237
|
yield `import {\n ${INTERNAL_RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime/internal/jsonld-cache";\n`;
|
|
2238
|
+
yield `import {\n ${SIGNED_REPRESENTATION_IMPORTS}\n} from "@fedify/vocab-runtime/internal/signed-representation";\n`;
|
|
2210
2239
|
yield `import {
|
|
2211
2240
|
isTemporalDuration,
|
|
2212
2241
|
isTemporalInstant,
|