@fedify/fedify 0.10.0-dev.196 → 0.10.0-dev.197
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGES.md +5 -0
- package/esm/testing/fixtures/w3id.org/security/data-integrity/v1 +74 -0
- package/esm/vocab/dataintegrityproof.yaml +56 -0
- package/esm/vocab/vocab.js +376 -0
- package/package.json +1 -1
- package/types/codegen/type.d.ts.map +1 -1
- package/types/vocab/vocab.d.ts +98 -0
- package/types/vocab/vocab.d.ts.map +1 -1
package/CHANGES.md
CHANGED
@@ -70,6 +70,9 @@ To be released.
|
|
70
70
|
- `Service.clone()` method now accepts `assertionMethod` option.
|
71
71
|
- `Service.clone()` method now accepts `assertionMethods` option.
|
72
72
|
|
73
|
+
- Added `DataIntegrityProof` class to Activity Vocabulary API.
|
74
|
+
[[FEP-8b32], [#54]]
|
75
|
+
|
73
76
|
- Deprecated `treatHttps` option in `FederationParameters` interface.
|
74
77
|
Instead, use the [x-forwarded-fetch] library to recognize the
|
75
78
|
`X-Forwarded-Host` and `X-Forwarded-Proto` headers.
|
@@ -81,8 +84,10 @@ To be released.
|
|
81
84
|
`following`, `followers`, `outbox`, `manuallyApprovesFollowers`, and
|
82
85
|
`url`.
|
83
86
|
|
87
|
+
[#54]: https://github.com/dahlia/fedify/issues/54
|
84
88
|
[#55]: https://github.com/dahlia/fedify/issues/55
|
85
89
|
[FEP-521a]: https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md
|
90
|
+
[FEP-8b32]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8b32/fep-8b32.md
|
86
91
|
[x-forwarded-fetch]: https://github.com/dahlia/x-forwarded-fetch
|
87
92
|
|
88
93
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"id": "@id",
|
4
|
+
"type": "@type",
|
5
|
+
"@protected": true,
|
6
|
+
"proof": {
|
7
|
+
"@id": "https://w3id.org/security#proof",
|
8
|
+
"@type": "@id",
|
9
|
+
"@container": "@graph"
|
10
|
+
},
|
11
|
+
"DataIntegrityProof": {
|
12
|
+
"@id": "https://w3id.org/security#DataIntegrityProof",
|
13
|
+
"@context": {
|
14
|
+
"@protected": true,
|
15
|
+
"id": "@id",
|
16
|
+
"type": "@type",
|
17
|
+
"challenge": "https://w3id.org/security#challenge",
|
18
|
+
"created": {
|
19
|
+
"@id": "http://purl.org/dc/terms/created",
|
20
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
21
|
+
},
|
22
|
+
"domain": "https://w3id.org/security#domain",
|
23
|
+
"expires": {
|
24
|
+
"@id": "https://w3id.org/security#expiration",
|
25
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
26
|
+
},
|
27
|
+
"nonce": "https://w3id.org/security#nonce",
|
28
|
+
"proofPurpose": {
|
29
|
+
"@id": "https://w3id.org/security#proofPurpose",
|
30
|
+
"@type": "@vocab",
|
31
|
+
"@context": {
|
32
|
+
"@protected": true,
|
33
|
+
"id": "@id",
|
34
|
+
"type": "@type",
|
35
|
+
"assertionMethod": {
|
36
|
+
"@id": "https://w3id.org/security#assertionMethod",
|
37
|
+
"@type": "@id",
|
38
|
+
"@container": "@set"
|
39
|
+
},
|
40
|
+
"authentication": {
|
41
|
+
"@id": "https://w3id.org/security#authenticationMethod",
|
42
|
+
"@type": "@id",
|
43
|
+
"@container": "@set"
|
44
|
+
},
|
45
|
+
"capabilityInvocation": {
|
46
|
+
"@id": "https://w3id.org/security#capabilityInvocationMethod",
|
47
|
+
"@type": "@id",
|
48
|
+
"@container": "@set"
|
49
|
+
},
|
50
|
+
"capabilityDelegation": {
|
51
|
+
"@id": "https://w3id.org/security#capabilityDelegationMethod",
|
52
|
+
"@type": "@id",
|
53
|
+
"@container": "@set"
|
54
|
+
},
|
55
|
+
"keyAgreement": {
|
56
|
+
"@id": "https://w3id.org/security#keyAgreementMethod",
|
57
|
+
"@type": "@id",
|
58
|
+
"@container": "@set"
|
59
|
+
}
|
60
|
+
}
|
61
|
+
},
|
62
|
+
"cryptosuite": "https://w3id.org/security#cryptosuite",
|
63
|
+
"proofValue": {
|
64
|
+
"@id": "https://w3id.org/security#proofValue",
|
65
|
+
"@type": "https://w3id.org/security#multibase"
|
66
|
+
},
|
67
|
+
"verificationMethod": {
|
68
|
+
"@id": "https://w3id.org/security#verificationMethod",
|
69
|
+
"@type": "@id"
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
$schema: ../codegen/schema.yaml
|
2
|
+
name: DataIntegrityProof
|
3
|
+
uri: "https://w3id.org/security#DataIntegrityProof"
|
4
|
+
entity: true
|
5
|
+
description: |
|
6
|
+
A proof that can be added to any activity or object, allowing recipients to
|
7
|
+
verify the identity of the actor and the integrity of the data.
|
8
|
+
defaultContext: "https://w3id.org/security/data-integrity/v1"
|
9
|
+
|
10
|
+
properties:
|
11
|
+
- singularName: cryptosuite
|
12
|
+
functional: true
|
13
|
+
uri: "https://w3id.org/security#cryptosuite"
|
14
|
+
description: |
|
15
|
+
The cryptographic suite used to create the proof.
|
16
|
+
range:
|
17
|
+
- "https://w3id.org/security#cryptosuiteString"
|
18
|
+
|
19
|
+
- singularName: verificationMethod
|
20
|
+
functional: true
|
21
|
+
uri: "https://w3id.org/security#verificationMethod"
|
22
|
+
description: |
|
23
|
+
A key owned by an actor according to [FEP-521a: Representing actor's public
|
24
|
+
keys][1].
|
25
|
+
|
26
|
+
[1]: https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md
|
27
|
+
range:
|
28
|
+
- "https://w3id.org/security#Multikey"
|
29
|
+
|
30
|
+
- singularName: proofPurpose
|
31
|
+
functional: true
|
32
|
+
uri: "https://w3id.org/security#proofPurpose"
|
33
|
+
description: |
|
34
|
+
The reason the proof was created.
|
35
|
+
|
36
|
+
- `"assertionMethod"`
|
37
|
+
- `"authentication"`
|
38
|
+
- `"capabilityInvocation"`
|
39
|
+
- `"capabilityDelegation"`
|
40
|
+
- `"keyAgreement"`
|
41
|
+
range:
|
42
|
+
- fedify:proofPurpose
|
43
|
+
|
44
|
+
- singularName: proofValue
|
45
|
+
functional: true
|
46
|
+
uri: "https://w3id.org/security#proofValue"
|
47
|
+
description: The proof value.
|
48
|
+
range:
|
49
|
+
- "https://w3id.org/security#multibase"
|
50
|
+
|
51
|
+
- singularName: created
|
52
|
+
functional: true
|
53
|
+
uri: "https://www.w3.org/ns/activitystreams#published"
|
54
|
+
description: The date and time the proof was created.
|
55
|
+
range:
|
56
|
+
- "http://www.w3.org/2001/XMLSchema#dateTime"
|
package/esm/vocab/vocab.js
CHANGED
@@ -4,6 +4,7 @@ import * as dntShim from "../_dnt.shims.js";
|
|
4
4
|
// @ts-ignore TS7016
|
5
5
|
import jsonld from "jsonld";
|
6
6
|
import { parseLanguageTag } from "@phensley/language-tag";
|
7
|
+
import { decode as decodeMultibase, encode as encodeMultibase, } from "multibase";
|
7
8
|
import { fetchDocumentLoader, } from "../runtime/docloader.js";
|
8
9
|
import { exportMultibaseKey, exportSpki, importMultibaseKey, importSpki, } from "../runtime/key.js";
|
9
10
|
import { LanguageString } from "../runtime/langstr.js";
|
@@ -3631,6 +3632,381 @@ export class PropertyValue {
|
|
3631
3632
|
return "PropertyValue " + inspect(proxy, options);
|
3632
3633
|
}
|
3633
3634
|
}
|
3635
|
+
/** A proof that can be added to any activity or object, allowing recipients to
|
3636
|
+
* verify the identity of the actor and the integrity of the data.
|
3637
|
+
*/
|
3638
|
+
export class DataIntegrityProof {
|
3639
|
+
#documentLoader;
|
3640
|
+
#contextLoader;
|
3641
|
+
id;
|
3642
|
+
get _documentLoader() {
|
3643
|
+
return this.#documentLoader;
|
3644
|
+
}
|
3645
|
+
get _contextLoader() {
|
3646
|
+
return this.#contextLoader;
|
3647
|
+
}
|
3648
|
+
/**
|
3649
|
+
* The type URI of {@link DataIntegrityProof}: `https://w3id.org/security#DataIntegrityProof`.
|
3650
|
+
*/
|
3651
|
+
static get typeId() {
|
3652
|
+
return new URL("https://w3id.org/security#DataIntegrityProof");
|
3653
|
+
}
|
3654
|
+
#_3RurJsa7tnptyqMFR5hDGcP9pMs5 = [];
|
3655
|
+
#_2mHVKxqA7zncjveJrDEo3pWpMZqg = [];
|
3656
|
+
#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb = [];
|
3657
|
+
#_3CjFK5vfKpX4HQuNh2b18TykoVLq = [];
|
3658
|
+
#_5e258TDXtuhaFRPZiGoDfEpjdMr = [];
|
3659
|
+
/**
|
3660
|
+
* Constructs a new instance of DataIntegrityProof with the given values.
|
3661
|
+
* @param values The values to initialize the instance with.
|
3662
|
+
* @param options The options to use for initialization.
|
3663
|
+
*/
|
3664
|
+
constructor(values, { documentLoader, contextLoader, } = {}) {
|
3665
|
+
this.#documentLoader = documentLoader;
|
3666
|
+
this.#contextLoader = contextLoader;
|
3667
|
+
this.id = values.id ?? null;
|
3668
|
+
if ("cryptosuite" in values && values.cryptosuite != null) {
|
3669
|
+
this.#_3RurJsa7tnptyqMFR5hDGcP9pMs5 = [values.cryptosuite];
|
3670
|
+
}
|
3671
|
+
if ("verificationMethod" in values && values.verificationMethod != null) {
|
3672
|
+
this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg = [values.verificationMethod];
|
3673
|
+
}
|
3674
|
+
if ("proofPurpose" in values && values.proofPurpose != null) {
|
3675
|
+
this.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb = [values.proofPurpose];
|
3676
|
+
}
|
3677
|
+
if ("proofValue" in values && values.proofValue != null) {
|
3678
|
+
this.#_3CjFK5vfKpX4HQuNh2b18TykoVLq = [values.proofValue];
|
3679
|
+
}
|
3680
|
+
if ("created" in values && values.created != null) {
|
3681
|
+
this.#_5e258TDXtuhaFRPZiGoDfEpjdMr = [values.created];
|
3682
|
+
}
|
3683
|
+
}
|
3684
|
+
/**
|
3685
|
+
* Clones this instance, optionally updating it with the given values.
|
3686
|
+
* @param values The values to update the clone with.
|
3687
|
+
* @options The options to use for cloning.
|
3688
|
+
* @returns The cloned instance.
|
3689
|
+
*/
|
3690
|
+
clone(values = {}, options = {}) {
|
3691
|
+
// @ts-ignore: this.constructor is not recognized as a constructor, but it is.
|
3692
|
+
const clone = new this.constructor({ id: values.id }, options);
|
3693
|
+
clone.#_3RurJsa7tnptyqMFR5hDGcP9pMs5 = this.#_3RurJsa7tnptyqMFR5hDGcP9pMs5;
|
3694
|
+
if ("cryptosuite" in values && values.cryptosuite != null) {
|
3695
|
+
clone.#_3RurJsa7tnptyqMFR5hDGcP9pMs5 = [values.cryptosuite];
|
3696
|
+
}
|
3697
|
+
clone.#_2mHVKxqA7zncjveJrDEo3pWpMZqg = this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg;
|
3698
|
+
if ("verificationMethod" in values && values.verificationMethod != null) {
|
3699
|
+
clone.#_2mHVKxqA7zncjveJrDEo3pWpMZqg = [values.verificationMethod];
|
3700
|
+
}
|
3701
|
+
clone.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb = this.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb;
|
3702
|
+
if ("proofPurpose" in values && values.proofPurpose != null) {
|
3703
|
+
clone.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb = [values.proofPurpose];
|
3704
|
+
}
|
3705
|
+
clone.#_3CjFK5vfKpX4HQuNh2b18TykoVLq = this.#_3CjFK5vfKpX4HQuNh2b18TykoVLq;
|
3706
|
+
if ("proofValue" in values && values.proofValue != null) {
|
3707
|
+
clone.#_3CjFK5vfKpX4HQuNh2b18TykoVLq = [values.proofValue];
|
3708
|
+
}
|
3709
|
+
clone.#_5e258TDXtuhaFRPZiGoDfEpjdMr = this.#_5e258TDXtuhaFRPZiGoDfEpjdMr;
|
3710
|
+
if ("created" in values && values.created != null) {
|
3711
|
+
clone.#_5e258TDXtuhaFRPZiGoDfEpjdMr = [values.created];
|
3712
|
+
}
|
3713
|
+
return clone;
|
3714
|
+
}
|
3715
|
+
/** The cryptographic suite used to create the proof.
|
3716
|
+
*/
|
3717
|
+
get cryptosuite() {
|
3718
|
+
if (this.#_3RurJsa7tnptyqMFR5hDGcP9pMs5.length < 1)
|
3719
|
+
return null;
|
3720
|
+
return this.#_3RurJsa7tnptyqMFR5hDGcP9pMs5[0];
|
3721
|
+
}
|
3722
|
+
async #fetchVerificationMethod(url, options = {}) {
|
3723
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
3724
|
+
fetchDocumentLoader;
|
3725
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
3726
|
+
fetchDocumentLoader;
|
3727
|
+
const { document } = await documentLoader(url.href);
|
3728
|
+
try {
|
3729
|
+
return await Multikey.fromJsonLd(document, { documentLoader, contextLoader });
|
3730
|
+
}
|
3731
|
+
catch (e) {
|
3732
|
+
if (!(e instanceof TypeError))
|
3733
|
+
throw e;
|
3734
|
+
}
|
3735
|
+
throw new TypeError("Expected an object of any type of: " +
|
3736
|
+
["https://w3id.org/security#Multikey"].join(", "));
|
3737
|
+
}
|
3738
|
+
/**
|
3739
|
+
* Similar to
|
3740
|
+
* {@link DataIntegrityProof.getVerificationMethod},
|
3741
|
+
* but returns its `@id` URL instead of the object itself.
|
3742
|
+
*/
|
3743
|
+
get verificationMethodId() {
|
3744
|
+
if (this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg.length < 1)
|
3745
|
+
return null;
|
3746
|
+
const v = this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg[0];
|
3747
|
+
if (v instanceof URL)
|
3748
|
+
return v;
|
3749
|
+
return v.id;
|
3750
|
+
}
|
3751
|
+
/** A key owned by an actor according to [FEP-521a: Representing actor's public
|
3752
|
+
* keys][1].
|
3753
|
+
*
|
3754
|
+
* [1]: https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md
|
3755
|
+
*/
|
3756
|
+
async getVerificationMethod(options = {}) {
|
3757
|
+
if (this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg.length < 1)
|
3758
|
+
return null;
|
3759
|
+
const v = this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg[0];
|
3760
|
+
if (v instanceof URL) {
|
3761
|
+
const fetched = await this.#fetchVerificationMethod(v, options);
|
3762
|
+
this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg[0] = fetched;
|
3763
|
+
return fetched;
|
3764
|
+
}
|
3765
|
+
return v;
|
3766
|
+
}
|
3767
|
+
/** The reason the proof was created.
|
3768
|
+
*
|
3769
|
+
* - `"assertionMethod"`
|
3770
|
+
* - `"authentication"`
|
3771
|
+
* - `"capabilityInvocation"`
|
3772
|
+
* - `"capabilityDelegation"`
|
3773
|
+
* - `"keyAgreement"`
|
3774
|
+
*/
|
3775
|
+
get proofPurpose() {
|
3776
|
+
if (this.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb.length < 1)
|
3777
|
+
return null;
|
3778
|
+
return this.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb[0];
|
3779
|
+
}
|
3780
|
+
/** The proof value.
|
3781
|
+
*/
|
3782
|
+
get proofValue() {
|
3783
|
+
if (this.#_3CjFK5vfKpX4HQuNh2b18TykoVLq.length < 1)
|
3784
|
+
return null;
|
3785
|
+
return this.#_3CjFK5vfKpX4HQuNh2b18TykoVLq[0];
|
3786
|
+
}
|
3787
|
+
/** The date and time the proof was created.
|
3788
|
+
*/
|
3789
|
+
get created() {
|
3790
|
+
if (this.#_5e258TDXtuhaFRPZiGoDfEpjdMr.length < 1)
|
3791
|
+
return null;
|
3792
|
+
return this.#_5e258TDXtuhaFRPZiGoDfEpjdMr[0];
|
3793
|
+
}
|
3794
|
+
/**
|
3795
|
+
* Converts this object to a JSON-LD structure.
|
3796
|
+
* @returns The JSON-LD representation of this object.
|
3797
|
+
*/
|
3798
|
+
async toJsonLd(options = {}) {
|
3799
|
+
options = {
|
3800
|
+
...options,
|
3801
|
+
contextLoader: options.contextLoader ?? fetchDocumentLoader,
|
3802
|
+
};
|
3803
|
+
// deno-lint-ignore no-unused-vars prefer-const
|
3804
|
+
let array;
|
3805
|
+
const values = {};
|
3806
|
+
array = [];
|
3807
|
+
for (const v of this.#_3RurJsa7tnptyqMFR5hDGcP9pMs5) {
|
3808
|
+
array.push({ "@value": v });
|
3809
|
+
}
|
3810
|
+
if (array.length > 0) {
|
3811
|
+
values["https://w3id.org/security#cryptosuite"] = array;
|
3812
|
+
}
|
3813
|
+
array = [];
|
3814
|
+
for (const v of this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg) {
|
3815
|
+
array.push(v instanceof URL ? { "@id": v.href } : await v.toJsonLd(options));
|
3816
|
+
}
|
3817
|
+
if (array.length > 0) {
|
3818
|
+
values["https://w3id.org/security#verificationMethod"] = array;
|
3819
|
+
}
|
3820
|
+
array = [];
|
3821
|
+
for (const v of this.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb) {
|
3822
|
+
array.push({
|
3823
|
+
"@id": "https://w3id.org/security#" + v,
|
3824
|
+
});
|
3825
|
+
}
|
3826
|
+
if (array.length > 0) {
|
3827
|
+
values["https://w3id.org/security#proofPurpose"] = array;
|
3828
|
+
}
|
3829
|
+
array = [];
|
3830
|
+
for (const v of this.#_3CjFK5vfKpX4HQuNh2b18TykoVLq) {
|
3831
|
+
array.push({
|
3832
|
+
"@type": "https://w3id.org/security#multibase",
|
3833
|
+
"@value": new TextDecoder().decode(encodeMultibase("base58btc", v)),
|
3834
|
+
});
|
3835
|
+
}
|
3836
|
+
if (array.length > 0) {
|
3837
|
+
values["https://w3id.org/security#proofValue"] = array;
|
3838
|
+
}
|
3839
|
+
array = [];
|
3840
|
+
for (const v of this.#_5e258TDXtuhaFRPZiGoDfEpjdMr) {
|
3841
|
+
array.push({
|
3842
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
|
3843
|
+
"@value": v.toString(),
|
3844
|
+
});
|
3845
|
+
}
|
3846
|
+
if (array.length > 0) {
|
3847
|
+
values["https://www.w3.org/ns/activitystreams#published"] = array;
|
3848
|
+
}
|
3849
|
+
values["@type"] = ["https://w3id.org/security#DataIntegrityProof"];
|
3850
|
+
if (this.id)
|
3851
|
+
values["@id"] = this.id.href;
|
3852
|
+
if (options.expand) {
|
3853
|
+
return await jsonld.expand(values, { documentLoader: options.contextLoader });
|
3854
|
+
}
|
3855
|
+
return await jsonld.compact(values, "https://w3id.org/security/data-integrity/v1", { documentLoader: options.contextLoader });
|
3856
|
+
}
|
3857
|
+
/**
|
3858
|
+
* Converts a JSON-LD structure to an object of this type.
|
3859
|
+
* @param json The JSON-LD structure to convert.
|
3860
|
+
* @returns The object of this type.
|
3861
|
+
* @throws {TypeError} If the given `json` is invalid.
|
3862
|
+
*/
|
3863
|
+
static async fromJsonLd(json, options = {}) {
|
3864
|
+
if (typeof json === "undefined") {
|
3865
|
+
throw new TypeError("Invalid JSON-LD: undefined.");
|
3866
|
+
}
|
3867
|
+
else if (json === null)
|
3868
|
+
throw new TypeError("Invalid JSON-LD: null.");
|
3869
|
+
options = {
|
3870
|
+
...options,
|
3871
|
+
documentLoader: options.documentLoader ?? fetchDocumentLoader,
|
3872
|
+
contextLoader: options.contextLoader ?? fetchDocumentLoader,
|
3873
|
+
};
|
3874
|
+
// deno-lint-ignore no-explicit-any
|
3875
|
+
let values;
|
3876
|
+
if (globalThis.Object.keys(json).length == 0) {
|
3877
|
+
values = {};
|
3878
|
+
}
|
3879
|
+
else {
|
3880
|
+
const expanded = await jsonld.expand(json, {
|
3881
|
+
documentLoader: options.contextLoader,
|
3882
|
+
keepFreeFloatingNodes: true,
|
3883
|
+
});
|
3884
|
+
values =
|
3885
|
+
// deno-lint-ignore no-explicit-any
|
3886
|
+
(expanded[0] ?? {});
|
3887
|
+
}
|
3888
|
+
if ("@type" in values) {
|
3889
|
+
if (!values["@type"].includes("https://w3id.org/security#DataIntegrityProof")) {
|
3890
|
+
throw new TypeError("Invalid type: " + values["@type"]);
|
3891
|
+
}
|
3892
|
+
}
|
3893
|
+
const instance = new this({ id: "@id" in values ? new URL(values["@id"]) : undefined }, options);
|
3894
|
+
const _3RurJsa7tnptyqMFR5hDGcP9pMs5 = [];
|
3895
|
+
for (const v of values["https://w3id.org/security#cryptosuite"] ?? []) {
|
3896
|
+
if (v == null)
|
3897
|
+
continue;
|
3898
|
+
_3RurJsa7tnptyqMFR5hDGcP9pMs5.push(v["@value"]);
|
3899
|
+
}
|
3900
|
+
instance.#_3RurJsa7tnptyqMFR5hDGcP9pMs5 = _3RurJsa7tnptyqMFR5hDGcP9pMs5;
|
3901
|
+
const _2mHVKxqA7zncjveJrDEo3pWpMZqg = [];
|
3902
|
+
for (const v of values["https://w3id.org/security#verificationMethod"] ?? []) {
|
3903
|
+
if (v == null)
|
3904
|
+
continue;
|
3905
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
3906
|
+
globalThis.Object.keys(v).length === 1) {
|
3907
|
+
_2mHVKxqA7zncjveJrDEo3pWpMZqg.push(new URL(v["@id"]));
|
3908
|
+
continue;
|
3909
|
+
}
|
3910
|
+
_2mHVKxqA7zncjveJrDEo3pWpMZqg.push(await Multikey.fromJsonLd(v, options));
|
3911
|
+
}
|
3912
|
+
instance.#_2mHVKxqA7zncjveJrDEo3pWpMZqg = _2mHVKxqA7zncjveJrDEo3pWpMZqg;
|
3913
|
+
const _2AeEnPcAvVrPEuKbpmn9ZKNmWHKb = [];
|
3914
|
+
for (const v of values["https://w3id.org/security#proofPurpose"] ?? []) {
|
3915
|
+
if (v == null)
|
3916
|
+
continue;
|
3917
|
+
_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb.push(v["@id"].substring(26));
|
3918
|
+
}
|
3919
|
+
instance.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb = _2AeEnPcAvVrPEuKbpmn9ZKNmWHKb;
|
3920
|
+
const _3CjFK5vfKpX4HQuNh2b18TykoVLq = [];
|
3921
|
+
for (const v of values["https://w3id.org/security#proofValue"] ?? []) {
|
3922
|
+
if (v == null)
|
3923
|
+
continue;
|
3924
|
+
_3CjFK5vfKpX4HQuNh2b18TykoVLq.push(decodeMultibase(v["@value"]));
|
3925
|
+
}
|
3926
|
+
instance.#_3CjFK5vfKpX4HQuNh2b18TykoVLq = _3CjFK5vfKpX4HQuNh2b18TykoVLq;
|
3927
|
+
const _5e258TDXtuhaFRPZiGoDfEpjdMr = [];
|
3928
|
+
for (const v of values["https://www.w3.org/ns/activitystreams#published"] ?? []) {
|
3929
|
+
if (v == null)
|
3930
|
+
continue;
|
3931
|
+
_5e258TDXtuhaFRPZiGoDfEpjdMr.push(dntShim.Temporal.Instant.from(v["@value"]));
|
3932
|
+
}
|
3933
|
+
instance.#_5e258TDXtuhaFRPZiGoDfEpjdMr = _5e258TDXtuhaFRPZiGoDfEpjdMr;
|
3934
|
+
return instance;
|
3935
|
+
}
|
3936
|
+
_getCustomInspectProxy() {
|
3937
|
+
const proxy = {};
|
3938
|
+
if (this.id != null) {
|
3939
|
+
proxy.id = {
|
3940
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(this.id.href, options),
|
3941
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(this.id.href, options),
|
3942
|
+
};
|
3943
|
+
}
|
3944
|
+
const _3RurJsa7tnptyqMFR5hDGcP9pMs5 = this.#_3RurJsa7tnptyqMFR5hDGcP9pMs5
|
3945
|
+
// deno-lint-ignore no-explicit-any
|
3946
|
+
.map((v) => v instanceof URL
|
3947
|
+
? {
|
3948
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
3949
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
3950
|
+
}
|
3951
|
+
: v);
|
3952
|
+
if (_3RurJsa7tnptyqMFR5hDGcP9pMs5.length == 1) {
|
3953
|
+
proxy.cryptosuite = _3RurJsa7tnptyqMFR5hDGcP9pMs5[0];
|
3954
|
+
}
|
3955
|
+
const _2mHVKxqA7zncjveJrDEo3pWpMZqg = this.#_2mHVKxqA7zncjveJrDEo3pWpMZqg
|
3956
|
+
// deno-lint-ignore no-explicit-any
|
3957
|
+
.map((v) => v instanceof URL
|
3958
|
+
? {
|
3959
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
3960
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
3961
|
+
}
|
3962
|
+
: v);
|
3963
|
+
if (_2mHVKxqA7zncjveJrDEo3pWpMZqg.length == 1) {
|
3964
|
+
proxy.verificationMethod = _2mHVKxqA7zncjveJrDEo3pWpMZqg[0];
|
3965
|
+
}
|
3966
|
+
const _2AeEnPcAvVrPEuKbpmn9ZKNmWHKb = this.#_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb
|
3967
|
+
// deno-lint-ignore no-explicit-any
|
3968
|
+
.map((v) => v instanceof URL
|
3969
|
+
? {
|
3970
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
3971
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
3972
|
+
}
|
3973
|
+
: v);
|
3974
|
+
if (_2AeEnPcAvVrPEuKbpmn9ZKNmWHKb.length == 1) {
|
3975
|
+
proxy.proofPurpose = _2AeEnPcAvVrPEuKbpmn9ZKNmWHKb[0];
|
3976
|
+
}
|
3977
|
+
const _3CjFK5vfKpX4HQuNh2b18TykoVLq = this.#_3CjFK5vfKpX4HQuNh2b18TykoVLq
|
3978
|
+
// deno-lint-ignore no-explicit-any
|
3979
|
+
.map((v) => v instanceof URL
|
3980
|
+
? {
|
3981
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
3982
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
3983
|
+
}
|
3984
|
+
: v);
|
3985
|
+
if (_3CjFK5vfKpX4HQuNh2b18TykoVLq.length == 1) {
|
3986
|
+
proxy.proofValue = _3CjFK5vfKpX4HQuNh2b18TykoVLq[0];
|
3987
|
+
}
|
3988
|
+
const _5e258TDXtuhaFRPZiGoDfEpjdMr = this.#_5e258TDXtuhaFRPZiGoDfEpjdMr
|
3989
|
+
// deno-lint-ignore no-explicit-any
|
3990
|
+
.map((v) => v instanceof URL
|
3991
|
+
? {
|
3992
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
3993
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
3994
|
+
}
|
3995
|
+
: v);
|
3996
|
+
if (_5e258TDXtuhaFRPZiGoDfEpjdMr.length == 1) {
|
3997
|
+
proxy.created = _5e258TDXtuhaFRPZiGoDfEpjdMr[0];
|
3998
|
+
}
|
3999
|
+
return proxy;
|
4000
|
+
}
|
4001
|
+
[Symbol.for("Deno.customInspect")](inspect, options) {
|
4002
|
+
const proxy = this._getCustomInspectProxy();
|
4003
|
+
return "DataIntegrityProof " + inspect(proxy, options);
|
4004
|
+
}
|
4005
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
|
4006
|
+
const proxy = this._getCustomInspectProxy();
|
4007
|
+
return "DataIntegrityProof " + inspect(proxy, options);
|
4008
|
+
}
|
4009
|
+
}
|
3634
4010
|
/** A key owned by an actor.
|
3635
4011
|
*/
|
3636
4012
|
export class CryptographicKey {
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/codegen/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/codegen/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwT9C,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAChC,MAAM,CAIR;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,WAAW,UAAQ,GAClB,MAAM,CAOR;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAChC,OAAO,CAIT;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAChC,OAAO,CAET;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,WAAW,UAAQ,GAClB,MAAM,EAAE,CAOV;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,MAAM,CAIR;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,QAAQ,EAAE,MAAM,GACf,MAAM,CAIR;AAED,wBAAiB,WAAW,CAC1B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,QAAQ,CAAC,MAAM,CAAC,CAUlB;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,MAAM,CAOR;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,QAAQ,EAAE,MAAM,GACf,MAAM,CAYR;AAED,wBAAiB,WAAW,CAC1B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,QAAQ,CAAC,MAAM,CAAC,CAQlB"}
|
package/types/vocab/vocab.d.ts
CHANGED
@@ -776,6 +776,104 @@ export declare class PropertyValue {
|
|
776
776
|
}): Promise<PropertyValue>;
|
777
777
|
protected _getCustomInspectProxy(): Record<string, unknown>;
|
778
778
|
}
|
779
|
+
/** A proof that can be added to any activity or object, allowing recipients to
|
780
|
+
* verify the identity of the actor and the integrity of the data.
|
781
|
+
*/
|
782
|
+
export declare class DataIntegrityProof {
|
783
|
+
#private;
|
784
|
+
readonly id: URL | null;
|
785
|
+
protected get _documentLoader(): DocumentLoader | undefined;
|
786
|
+
protected get _contextLoader(): DocumentLoader | undefined;
|
787
|
+
/**
|
788
|
+
* The type URI of {@link DataIntegrityProof}: `https://w3id.org/security#DataIntegrityProof`.
|
789
|
+
*/
|
790
|
+
static get typeId(): URL;
|
791
|
+
/**
|
792
|
+
* Constructs a new instance of DataIntegrityProof with the given values.
|
793
|
+
* @param values The values to initialize the instance with.
|
794
|
+
* @param options The options to use for initialization.
|
795
|
+
*/
|
796
|
+
constructor(values: {
|
797
|
+
id?: URL | null;
|
798
|
+
cryptosuite?: "eddsa-jcs-2022" | null;
|
799
|
+
verificationMethod?: Multikey | URL | null;
|
800
|
+
proofPurpose?: ("assertionMethod" | "authentication" | "capabilityInvocation" | "capabilityDelegation" | "keyAgreement") | null;
|
801
|
+
proofValue?: Uint8Array | null;
|
802
|
+
created?: dntShim.Temporal.Instant | null;
|
803
|
+
}, { documentLoader, contextLoader, }?: {
|
804
|
+
documentLoader?: DocumentLoader;
|
805
|
+
contextLoader?: DocumentLoader;
|
806
|
+
});
|
807
|
+
/**
|
808
|
+
* Clones this instance, optionally updating it with the given values.
|
809
|
+
* @param values The values to update the clone with.
|
810
|
+
* @options The options to use for cloning.
|
811
|
+
* @returns The cloned instance.
|
812
|
+
*/
|
813
|
+
clone(values?: {
|
814
|
+
id?: URL | null;
|
815
|
+
cryptosuite?: "eddsa-jcs-2022" | null;
|
816
|
+
verificationMethod?: Multikey | URL | null;
|
817
|
+
proofPurpose?: ("assertionMethod" | "authentication" | "capabilityInvocation" | "capabilityDelegation" | "keyAgreement") | null;
|
818
|
+
proofValue?: Uint8Array | null;
|
819
|
+
created?: dntShim.Temporal.Instant | null;
|
820
|
+
}, options?: {
|
821
|
+
documentLoader?: DocumentLoader;
|
822
|
+
contextLoader?: DocumentLoader;
|
823
|
+
}): DataIntegrityProof;
|
824
|
+
/** The cryptographic suite used to create the proof.
|
825
|
+
*/
|
826
|
+
get cryptosuite(): "eddsa-jcs-2022" | null;
|
827
|
+
/**
|
828
|
+
* Similar to
|
829
|
+
* {@link DataIntegrityProof.getVerificationMethod},
|
830
|
+
* but returns its `@id` URL instead of the object itself.
|
831
|
+
*/
|
832
|
+
get verificationMethodId(): URL | null;
|
833
|
+
/** A key owned by an actor according to [FEP-521a: Representing actor's public
|
834
|
+
* keys][1].
|
835
|
+
*
|
836
|
+
* [1]: https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md
|
837
|
+
*/
|
838
|
+
getVerificationMethod(options?: {
|
839
|
+
documentLoader?: DocumentLoader;
|
840
|
+
contextLoader?: DocumentLoader;
|
841
|
+
}): Promise<Multikey | null>;
|
842
|
+
/** The reason the proof was created.
|
843
|
+
*
|
844
|
+
* - `"assertionMethod"`
|
845
|
+
* - `"authentication"`
|
846
|
+
* - `"capabilityInvocation"`
|
847
|
+
* - `"capabilityDelegation"`
|
848
|
+
* - `"keyAgreement"`
|
849
|
+
*/
|
850
|
+
get proofPurpose(): ("assertionMethod" | "authentication" | "capabilityInvocation" | "capabilityDelegation" | "keyAgreement") | null;
|
851
|
+
/** The proof value.
|
852
|
+
*/
|
853
|
+
get proofValue(): Uint8Array | null;
|
854
|
+
/** The date and time the proof was created.
|
855
|
+
*/
|
856
|
+
get created(): dntShim.Temporal.Instant | null;
|
857
|
+
/**
|
858
|
+
* Converts this object to a JSON-LD structure.
|
859
|
+
* @returns The JSON-LD representation of this object.
|
860
|
+
*/
|
861
|
+
toJsonLd(options?: {
|
862
|
+
expand?: boolean;
|
863
|
+
contextLoader?: DocumentLoader;
|
864
|
+
}): Promise<unknown>;
|
865
|
+
/**
|
866
|
+
* Converts a JSON-LD structure to an object of this type.
|
867
|
+
* @param json The JSON-LD structure to convert.
|
868
|
+
* @returns The object of this type.
|
869
|
+
* @throws {TypeError} If the given `json` is invalid.
|
870
|
+
*/
|
871
|
+
static fromJsonLd(json: unknown, options?: {
|
872
|
+
documentLoader?: DocumentLoader;
|
873
|
+
contextLoader?: DocumentLoader;
|
874
|
+
}): Promise<DataIntegrityProof>;
|
875
|
+
protected _getCustomInspectProxy(): Record<string, unknown>;
|
876
|
+
}
|
779
877
|
/** A key owned by an actor.
|
780
878
|
*/
|
781
879
|
export declare class CryptographicKey {
|