@interop/zcap 10.0.2 → 11.0.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/README.md +21 -3
- package/dist/CapabilityDelegation.d.ts +173 -0
- package/dist/CapabilityDelegation.d.ts.map +1 -0
- package/dist/CapabilityDelegation.js +372 -0
- package/dist/CapabilityDelegation.js.map +1 -0
- package/dist/CapabilityInvocation.d.ts +151 -0
- package/dist/CapabilityInvocation.d.ts.map +1 -0
- package/dist/CapabilityInvocation.js +365 -0
- package/dist/CapabilityInvocation.js.map +1 -0
- package/dist/CapabilityProofPurpose.d.ts +203 -0
- package/dist/CapabilityProofPurpose.d.ts.map +1 -0
- package/dist/CapabilityProofPurpose.js +531 -0
- package/dist/CapabilityProofPurpose.js.map +1 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +23 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +224 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +250 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +591 -0
- package/dist/utils.js.map +1 -0
- package/package.json +47 -34
- package/lib/CapabilityDelegation.js +0 -312
- package/lib/CapabilityInvocation.js +0 -343
- package/lib/CapabilityProofPurpose.js +0 -538
- package/lib/constants.js +0 -32
- package/lib/index.js +0 -55
- package/lib/utils.js +0 -672
- package/types/lib/CapabilityDelegation.d.ts +0 -101
- package/types/lib/CapabilityDelegation.d.ts.map +0 -1
- package/types/lib/CapabilityInvocation.d.ts +0 -100
- package/types/lib/CapabilityInvocation.d.ts.map +0 -1
- package/types/lib/CapabilityProofPurpose.d.ts +0 -126
- package/types/lib/CapabilityProofPurpose.d.ts.map +0 -1
- package/types/lib/constants.d.ts +0 -15
- package/types/lib/constants.d.ts.map +0 -1
- package/types/lib/index.d.ts +0 -42
- package/types/lib/index.d.ts.map +0 -1
- package/types/lib/utils.d.ts +0 -304
- package/types/lib/utils.d.ts.map +0 -1
package/types/lib/utils.d.ts
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a root capability from a root controller and a root invocation
|
|
3
|
-
* target.
|
|
4
|
-
*
|
|
5
|
-
* @param {object} options - The options.
|
|
6
|
-
* @param {string|string[]} options.controller - The root controller.
|
|
7
|
-
* @param {string} options.invocationTarget - The root invocation target.
|
|
8
|
-
*
|
|
9
|
-
* @returns {IRootZcap} The root capability.
|
|
10
|
-
*/
|
|
11
|
-
export function createRootCapability({ controller, invocationTarget }: {
|
|
12
|
-
controller: string | string[];
|
|
13
|
-
invocationTarget: string;
|
|
14
|
-
}): IRootZcap;
|
|
15
|
-
/**
|
|
16
|
-
* Retrieves the controller(s) from a capability.
|
|
17
|
-
*
|
|
18
|
-
* @param {object} options - The options.
|
|
19
|
-
* @param {IZcap} options.capability - The authorization capability (zcap).
|
|
20
|
-
*
|
|
21
|
-
* @returns {string[]} The controller(s) for the capability.
|
|
22
|
-
*/
|
|
23
|
-
export function getControllers({ capability }: {
|
|
24
|
-
capability: IZcap;
|
|
25
|
-
}): string[];
|
|
26
|
-
/**
|
|
27
|
-
* Returns true if the given verification method is a controller (or is
|
|
28
|
-
* controlled by a controller) of the given capability.
|
|
29
|
-
*
|
|
30
|
-
* @param {object} options - The options.
|
|
31
|
-
* @param {IZcap} options.capability - The authorization capability (zcap).
|
|
32
|
-
* @param {object} options.verificationMethod - The verification method to
|
|
33
|
-
* check.
|
|
34
|
-
*
|
|
35
|
-
* @returns {boolean} `true` if the controller matches, `false` if not.
|
|
36
|
-
*/
|
|
37
|
-
export function isController({ capability, verificationMethod }: {
|
|
38
|
-
capability: IZcap;
|
|
39
|
-
verificationMethod: object;
|
|
40
|
-
}): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Retrieves the allowed actions from a capability.
|
|
43
|
-
*
|
|
44
|
-
* @param {object} options - The options.
|
|
45
|
-
* @param {IZcap} options.capability - The authorization capability (zcap).
|
|
46
|
-
*
|
|
47
|
-
* @returns {string[]} Allowed actions.
|
|
48
|
-
*/
|
|
49
|
-
export function getAllowedActions({ capability }: {
|
|
50
|
-
capability: IZcap;
|
|
51
|
-
}): string[];
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves the target from a capability.
|
|
54
|
-
*
|
|
55
|
-
* @param {object} options - The options.
|
|
56
|
-
* @param {IZcap} options.capability - The authorization capability (zcap).
|
|
57
|
-
*
|
|
58
|
-
* @returns {string} - Capability target.
|
|
59
|
-
*/
|
|
60
|
-
export function getTarget({ capability }: {
|
|
61
|
-
capability: IZcap;
|
|
62
|
-
}): string;
|
|
63
|
-
/**
|
|
64
|
-
* Retrieves the delegation proof(s) for a capability that is associated with
|
|
65
|
-
* its parent capability. A capability that has no parent or no associated
|
|
66
|
-
* delegation proofs will cause this function to return an empty array.
|
|
67
|
-
*
|
|
68
|
-
* @param {object} options - The options.
|
|
69
|
-
* @param {IZcap} options.capability - The authorization capability.
|
|
70
|
-
*
|
|
71
|
-
* @returns {ICapabilityDelegationProof[]} Any `capabilityDelegation` proof
|
|
72
|
-
* objects attached to the given capability.
|
|
73
|
-
*/
|
|
74
|
-
export function getDelegationProofs({ capability }: {
|
|
75
|
-
capability: IZcap;
|
|
76
|
-
}): ICapabilityDelegationProof[];
|
|
77
|
-
/**
|
|
78
|
-
* Gets the `capabilityChain` associated with the given capability.
|
|
79
|
-
*
|
|
80
|
-
* @param {object} options - The options.
|
|
81
|
-
* @param {IZcap} options.capability - The authorization capability.
|
|
82
|
-
*
|
|
83
|
-
* @returns {Array<string|IDelegatedZcap>} The capability chain entries
|
|
84
|
-
* (root to parent), as stored in the delegation proof.
|
|
85
|
-
*/
|
|
86
|
-
export function getCapabilityChain({ capability }: {
|
|
87
|
-
capability: IZcap;
|
|
88
|
-
}): Array<string | IDelegatedZcap>;
|
|
89
|
-
/**
|
|
90
|
-
* Determines if the given `invocationTarget` is valid given a
|
|
91
|
-
* `baseInvocationTarget`.
|
|
92
|
-
*
|
|
93
|
-
* To check for a proper delegation, `invocationTarget` must be the child
|
|
94
|
-
* capability's `invocationTarget` and `baseInvocationTarget` must be the
|
|
95
|
-
* parent capability's `invocationTarget`.
|
|
96
|
-
*
|
|
97
|
-
* To check for a proper invocation, `invocationTarget` must be the value from
|
|
98
|
-
* the invocation proof and `baseInvocationTarget` must be the invoked
|
|
99
|
-
* capability's `invocationTarget`.
|
|
100
|
-
*
|
|
101
|
-
* @param {object} options - The options.
|
|
102
|
-
* @param {string} options.invocationTarget - The invocation target to check.
|
|
103
|
-
* @param {string} options.baseInvocationTarget - The base invocation target.
|
|
104
|
-
* @param {boolean} options.allowTargetAttenuation - `true` to allow target
|
|
105
|
-
* attenuation.
|
|
106
|
-
*
|
|
107
|
-
* @returns {boolean} `true` if the target is valid, `false` if not.
|
|
108
|
-
*/
|
|
109
|
-
export function isValidTarget({ invocationTarget, baseInvocationTarget, allowTargetAttenuation }: {
|
|
110
|
-
invocationTarget: string;
|
|
111
|
-
baseInvocationTarget: string;
|
|
112
|
-
allowTargetAttenuation: boolean;
|
|
113
|
-
}): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Creates a capability chain for delegating a capability from the
|
|
116
|
-
* given `parentCapability`.
|
|
117
|
-
*
|
|
118
|
-
* @param {object} options - The options.
|
|
119
|
-
* @param {string|IZcap} options.parentCapability - The parent capability from
|
|
120
|
-
* which to compute the capability chain (a root zcap ID string, or a full
|
|
121
|
-
* root or delegated zcap object).
|
|
122
|
-
* @param {boolean} options._skipLocalValidationForTesting - Private.
|
|
123
|
-
*
|
|
124
|
-
* @returns {Array<string|IDelegatedZcap>} The computed capability chain to be
|
|
125
|
-
* included in a capability delegation proof.
|
|
126
|
-
*/
|
|
127
|
-
export function computeCapabilityChain({ parentCapability, _skipLocalValidationForTesting }: {
|
|
128
|
-
parentCapability: string | IZcap;
|
|
129
|
-
_skipLocalValidationForTesting: boolean;
|
|
130
|
-
}): Array<string | IDelegatedZcap>;
|
|
131
|
-
/**
|
|
132
|
-
* Dereferences the capability chain associated with the given capability,
|
|
133
|
-
* ensuring it passes a number of validation checks.
|
|
134
|
-
*
|
|
135
|
-
* A delegated zcap's chain has a reference to a root zcap. A verifier must
|
|
136
|
-
* provide a hook (`getRootCapability`) to dereference this root zcap since
|
|
137
|
-
* the root zcap has no delegation proof and must therefore be trusted by
|
|
138
|
-
* the verifier. If the root zcap can't be dereferenced by the trusted hook,
|
|
139
|
-
* then an authorization error must be thrown by that hook.
|
|
140
|
-
*
|
|
141
|
-
* This function will dereference the root zcap and then dereference all of
|
|
142
|
-
* the embedded delegated zcaps from the chain, combining them into a single
|
|
143
|
-
* array containing full zcaps ordered from root => tail.
|
|
144
|
-
*
|
|
145
|
-
* The dereferenced chain (result of this function) should then compare the
|
|
146
|
-
* root zcap's ID against a list of expected root capabilities, throwing
|
|
147
|
-
* an error if none of them match. Otherwise, the dereferenced chain should
|
|
148
|
-
* then be processed to ensure that all delegation rules have been followed.
|
|
149
|
-
* If checking an invocation, it should also be ensured that a combination of
|
|
150
|
-
* an expected target and a root zcap is permitted (note it is conceivable that
|
|
151
|
-
* a verifier may accept more than one combination, e.g., a target of `x` could
|
|
152
|
-
* work with both root zcap `a` and `b`).
|
|
153
|
-
*
|
|
154
|
-
* @param {object} options - The options.
|
|
155
|
-
* @param {string|IDelegatedZcap} options.capability - The authorization
|
|
156
|
-
* capability to dereference the chain for. Pass a string (the root zcap ID)
|
|
157
|
-
* to dereference a root zcap directly, or a delegated zcap object.
|
|
158
|
-
* @param {Function} options.getRootCapability - A function for dereferencing
|
|
159
|
-
* the root capability (the root zcap must be deref'd in a trusted way by the
|
|
160
|
-
* verifier, it must not be untrusted input).
|
|
161
|
-
* @param {number} [options.maxChainLength=10] - The maximum length of the
|
|
162
|
-
* capability delegation chain (this is inclusive of `capability` itself).
|
|
163
|
-
*
|
|
164
|
-
* @returns {Promise<{dereferencedChain: IZcap[]}>} Resolves to an object
|
|
165
|
-
* containing the full dereferenced chain ordered root to tail.
|
|
166
|
-
*/
|
|
167
|
-
export function dereferenceCapabilityChain({ capability, getRootCapability, maxChainLength }: {
|
|
168
|
-
capability: string | IDelegatedZcap;
|
|
169
|
-
getRootCapability: Function;
|
|
170
|
-
maxChainLength?: number;
|
|
171
|
-
}): Promise<{
|
|
172
|
-
dereferencedChain: IZcap[];
|
|
173
|
-
}>;
|
|
174
|
-
export function checkProofContext({ proof }: {
|
|
175
|
-
proof: any;
|
|
176
|
-
}): void;
|
|
177
|
-
export function hasValidAllowedAction({ allowedAction, parentAllowedAction }: {
|
|
178
|
-
allowedAction: any;
|
|
179
|
-
parentAllowedAction: any;
|
|
180
|
-
}): boolean;
|
|
181
|
-
export function checkCapability({ capability, expectRoot }: {
|
|
182
|
-
capability: any;
|
|
183
|
-
expectRoot: any;
|
|
184
|
-
}): void;
|
|
185
|
-
export function compareTime({ t1, t2, maxClockSkew }: {
|
|
186
|
-
t1: any;
|
|
187
|
-
t2: any;
|
|
188
|
-
maxClockSkew: any;
|
|
189
|
-
}): 0 | 1 | -1;
|
|
190
|
-
/**
|
|
191
|
-
* The zcap object shapes (`IRootZcap`, `IDelegatedZcap`,
|
|
192
|
-
* `ICapabilityDelegationProof`, `IZcap`) live in `@digitalcredentials/ssi/zcap`
|
|
193
|
-
* (the canonical home) and are re-imported here as typedefs for JSDoc use.
|
|
194
|
-
*/
|
|
195
|
-
export type IRootZcap = import("@digitalcredentials/ssi/zcap").IRootZcap;
|
|
196
|
-
/**
|
|
197
|
-
* The zcap object shapes (`IRootZcap`, `IDelegatedZcap`,
|
|
198
|
-
* `ICapabilityDelegationProof`, `IZcap`) live in `@digitalcredentials/ssi/zcap`
|
|
199
|
-
* (the canonical home) and are re-imported here as typedefs for JSDoc use.
|
|
200
|
-
*/
|
|
201
|
-
export type ICapabilityDelegationProof = import("@digitalcredentials/ssi/zcap").ICapabilityDelegationProof;
|
|
202
|
-
/**
|
|
203
|
-
* The zcap object shapes (`IRootZcap`, `IDelegatedZcap`,
|
|
204
|
-
* `ICapabilityDelegationProof`, `IZcap`) live in `@digitalcredentials/ssi/zcap`
|
|
205
|
-
* (the canonical home) and are re-imported here as typedefs for JSDoc use.
|
|
206
|
-
*/
|
|
207
|
-
export type IDelegatedZcap = import("@digitalcredentials/ssi/zcap").IDelegatedZcap;
|
|
208
|
-
/**
|
|
209
|
-
* The zcap object shapes (`IRootZcap`, `IDelegatedZcap`,
|
|
210
|
-
* `ICapabilityDelegationProof`, `IZcap`) live in `@digitalcredentials/ssi/zcap`
|
|
211
|
-
* (the canonical home) and are re-imported here as typedefs for JSDoc use.
|
|
212
|
-
*/
|
|
213
|
-
export type IZcap = import("@digitalcredentials/ssi/zcap").IZcap;
|
|
214
|
-
/**
|
|
215
|
-
* An inspection function result.
|
|
216
|
-
*/
|
|
217
|
-
export type InspectResult = {
|
|
218
|
-
/**
|
|
219
|
-
* - `true` if the chain passed inspection.
|
|
220
|
-
*/
|
|
221
|
-
valid?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* - Set if inspection failed.
|
|
224
|
-
*/
|
|
225
|
-
error?: Error;
|
|
226
|
-
};
|
|
227
|
-
/**
|
|
228
|
-
* A capability chain inspection function.
|
|
229
|
-
*/
|
|
230
|
-
export type InspectCapabilityChain = Function;
|
|
231
|
-
/**
|
|
232
|
-
* A capability. The capability is compacted into the security
|
|
233
|
-
* context. Only the required fields are shown here, a capability will contain
|
|
234
|
-
* additional properties.
|
|
235
|
-
*/
|
|
236
|
-
export type Capability = {
|
|
237
|
-
/**
|
|
238
|
-
* - The ID of the capability.
|
|
239
|
-
*/
|
|
240
|
-
id: string;
|
|
241
|
-
/**
|
|
242
|
-
* - The controller of the capability.
|
|
243
|
-
*/
|
|
244
|
-
controller: string;
|
|
245
|
-
};
|
|
246
|
-
export type CapabilityChainDetails = {
|
|
247
|
-
/**
|
|
248
|
-
* - The capabilities in the chain.
|
|
249
|
-
*/
|
|
250
|
-
capabilityChain: Capability[];
|
|
251
|
-
/**
|
|
252
|
-
* - The results returned
|
|
253
|
-
* from jsonld-signatures verify for each capability in the chain. Each
|
|
254
|
-
* object contains `{verifyResult}` where each `verifyResult` is an
|
|
255
|
-
* `InspectChainResult`.
|
|
256
|
-
*/
|
|
257
|
-
capabilityChainMeta: CapabilityMeta[];
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* The metadata resulting from the verification of a delegated capability.
|
|
261
|
-
*/
|
|
262
|
-
export type CapabilityMeta = {
|
|
263
|
-
/**
|
|
264
|
-
* - The capability verify result, which
|
|
265
|
-
* is `null` for the root capability.
|
|
266
|
-
*/
|
|
267
|
-
verifyResult: VerifyResult;
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* The result of running jsonld-signature's verify method.
|
|
271
|
-
*/
|
|
272
|
-
export type VerifyResult = {
|
|
273
|
-
/**
|
|
274
|
-
* - `true` if all the checked proofs were
|
|
275
|
-
* successfully verified.
|
|
276
|
-
*/
|
|
277
|
-
verified: boolean;
|
|
278
|
-
/**
|
|
279
|
-
* - The verify results for each
|
|
280
|
-
* delegation proof.
|
|
281
|
-
*/
|
|
282
|
-
results: VerifyProofResult[];
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
285
|
-
* The result of verifying a capability delegation proof.
|
|
286
|
-
*/
|
|
287
|
-
export type VerifyProofResult = {
|
|
288
|
-
/**
|
|
289
|
-
* - The result from
|
|
290
|
-
* verifying the capability delegation proof purpose.
|
|
291
|
-
*/
|
|
292
|
-
proofPurposeResult: VerifyProofPurposeResult;
|
|
293
|
-
};
|
|
294
|
-
/**
|
|
295
|
-
* The result of verifying a capability delegation proof purpose.
|
|
296
|
-
*/
|
|
297
|
-
export type VerifyProofPurposeResult = {
|
|
298
|
-
/**
|
|
299
|
-
* - The party that created the capability
|
|
300
|
-
* delegation proof, i.e., the party that delegated the capability.
|
|
301
|
-
*/
|
|
302
|
-
delegator: string;
|
|
303
|
-
};
|
|
304
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/types/lib/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.js"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,uEALG;IAAiC,UAAU,EAAnC,MAAM,GAAC,MAAM,EAAE;IACC,gBAAgB,EAAhC,MAAM;CAEd,GAAU,SAAS,CASrB;AAED;;;;;;;GAOG;AACH,+CAJG;IAAuB,UAAU,EAAzB,KAAK;CAEb,GAAU,MAAM,EAAE,CAQpB;AAED;;;;;;;;;;GAUG;AACH,iEANG;IAAuB,UAAU,EAAzB,KAAK;IACW,kBAAkB,EAAlC,MAAM;CAGd,GAAU,OAAO,CAMnB;AAED;;;;;;;GAOG;AACH,kDAJG;IAAuB,UAAU,EAAzB,KAAK;CAEb,GAAU,MAAM,EAAE,CAWpB;AAED;;;;;;;GAOG;AACH,0CAJG;IAAuB,UAAU,EAAzB,KAAK;CAEb,GAAU,MAAM,CAKlB;AAED;;;;;;;;;;GAUG;AACH,oDALG;IAAuB,UAAU,EAAzB,KAAK;CAEb,GAAU,0BAA0B,EAAE,CAcxC;AAED;;;;;;;;GAQG;AACH,mDALG;IAAuB,UAAU,EAAzB,KAAK;CAEb,GAAU,KAAK,CAAC,MAAM,GAAC,cAAc,CAAC,CAwBxC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,kGAPG;IAAwB,gBAAgB,EAAhC,MAAM;IACU,oBAAoB,EAApC,MAAM;IACW,sBAAsB,EAAvC,OAAO;CAGf,GAAU,OAAO,CAkCnB;AAED;;;;;;;;;;;;GAYG;AACH,6FARG;IAA8B,gBAAgB,EAAtC,MAAM,GAAC,KAAK;IAGK,8BAA8B,EAA/C,OAAO;CAEf,GAAU,KAAK,CAAC,MAAM,GAAC,cAAc,CAAC,CA0ExC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,8FAZG;IAAuC,UAAU,EAAzC,MAAM,GAAC,cAAc;IAGH,iBAAiB;IAGlB,cAAc,GAA/B,MAAM;CAGd,GAAU,OAAO,CAAC;IAAC,iBAAiB,EAAE,KAAK,EAAE,CAAA;CAAC,CAAC,CAkKjD;AAED;;SAQC;AAED;;;YAiBC;AAED;;;SAqEC;AAED;;;;eAOC;;;;;;wBAOY,OAAO,8BAA8B,EAAE,SAAS;;;;;;yCAChD,OAAO,8BAA8B,EAAE,0BAA0B;;;;;;6BACjE,OAAO,8BAA8B,EAAE,cAAc;;;;;;oBACrD,OAAO,8BAA8B,EAAE,KAAK;;;;;;;;YAO3C,OAAO;;;;YACP,KAAK;;;;;;;;;;;;;;;QAiBL,MAAM;;;;gBACN,MAAM;;;;;;qBAKN,UAAU,EAAE;;;;;;;yBACZ,cAAc,EAAE;;;;;;;;;;kBAUhB,YAAY;;;;;;;;;;cAQZ,OAAO;;;;;aAEP,iBAAiB,EAAE;;;;;;;;;;wBAQnB,wBAAwB;;;;;;;;;;eAQxB,MAAM"}
|