@metalabel/dfos-protocol 0.7.1 → 0.8.1
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 +8 -21
- package/dist/chain/index.d.ts +54 -148
- package/dist/chain/index.js +15 -8
- package/dist/{chunk-QKHP7UVL.js → chunk-LQ56P4SU.js} +137 -110
- package/dist/chunk-MEV6QVLC.js +402 -0
- package/dist/credentials/index.d.ts +133 -117
- package/dist/credentials/index.js +17 -21
- package/dist/index.d.ts +3 -2
- package/dist/index.js +30 -28
- package/dist/schemas-BEl38wrI.d.ts +148 -0
- package/examples/beacon.json +5 -5
- package/examples/content-delegated.json +3 -3
- package/examples/credential-read.json +4 -5
- package/examples/credential-write.json +5 -6
- package/package.json +2 -2
- package/dist/chunk-CZSEEZLL.js +0 -258
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { V as VerifiedIdentity } from '../schemas-BEl38wrI.js';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type
|
|
4
|
+
/** Single attenuation entry — resource + action pair */
|
|
5
|
+
declare const Attenuation: z.ZodObject<{
|
|
6
|
+
resource: z.ZodString;
|
|
7
|
+
action: z.ZodString;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
type Attenuation = z.infer<typeof Attenuation>;
|
|
10
|
+
/** DFOS credential payload — UCAN-style authorization token */
|
|
11
|
+
declare const DFOSCredentialPayload: z.ZodObject<{
|
|
12
|
+
version: z.ZodLiteral<1>;
|
|
13
|
+
type: z.ZodLiteral<"DFOSCredential">;
|
|
14
|
+
/** Issuer DID */
|
|
15
|
+
iss: z.ZodString;
|
|
16
|
+
/** Audience DID or "*" for public credentials */
|
|
17
|
+
aud: z.ZodString;
|
|
18
|
+
/** Attenuations — resource + action pairs */
|
|
19
|
+
att: z.ZodArray<z.ZodObject<{
|
|
20
|
+
resource: z.ZodString;
|
|
21
|
+
action: z.ZodString;
|
|
22
|
+
}, z.core.$strict>>;
|
|
23
|
+
/** Parent credential JWS tokens (for delegation chains) */
|
|
24
|
+
prf: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
25
|
+
/** Expiration — unix seconds */
|
|
26
|
+
exp: z.ZodNumber;
|
|
27
|
+
/** Issued at — unix seconds */
|
|
28
|
+
iat: z.ZodNumber;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
type DFOSCredentialPayload = z.infer<typeof DFOSCredentialPayload>;
|
|
13
31
|
/** Claims for a DID-signed auth token (relay AuthN) */
|
|
14
32
|
declare const AuthTokenClaims: z.ZodObject<{
|
|
15
33
|
/** Issuer — the DID proving identity */
|
|
@@ -24,61 +42,6 @@ declare const AuthTokenClaims: z.ZodObject<{
|
|
|
24
42
|
iat: z.ZodNumber;
|
|
25
43
|
}, z.core.$strict>;
|
|
26
44
|
type AuthTokenClaims = z.infer<typeof AuthTokenClaims>;
|
|
27
|
-
/** Credential subject for content write authorization */
|
|
28
|
-
declare const ContentWriteSubject: z.ZodObject<{
|
|
29
|
-
/** Optional content chain narrowing — if absent, grants broad write access */
|
|
30
|
-
contentId: z.ZodOptional<z.ZodString>;
|
|
31
|
-
}, z.core.$strict>;
|
|
32
|
-
type ContentWriteSubject = z.infer<typeof ContentWriteSubject>;
|
|
33
|
-
/** Credential subject for content read authorization */
|
|
34
|
-
declare const ContentReadSubject: z.ZodObject<{
|
|
35
|
-
/** Optional content chain narrowing — if absent, grants broad read access */
|
|
36
|
-
contentId: z.ZodOptional<z.ZodString>;
|
|
37
|
-
}, z.core.$strict>;
|
|
38
|
-
type ContentReadSubject = z.infer<typeof ContentReadSubject>;
|
|
39
|
-
/** The `vc` claim in a VC-JWT payload */
|
|
40
|
-
declare const VCClaim: z.ZodObject<{
|
|
41
|
-
'@context': z.ZodTuple<[z.ZodLiteral<"https://www.w3.org/ns/credentials/v2">], null>;
|
|
42
|
-
type: z.ZodPipe<z.ZodTuple<[z.ZodLiteral<"VerifiableCredential">, z.ZodEnum<{
|
|
43
|
-
DFOSContentWrite: "DFOSContentWrite";
|
|
44
|
-
DFOSContentRead: "DFOSContentRead";
|
|
45
|
-
}>], null>, z.ZodTransform<[string, "DFOSContentWrite" | "DFOSContentRead"], ["VerifiableCredential", "DFOSContentWrite" | "DFOSContentRead"]>>;
|
|
46
|
-
credentialSubject: z.ZodUnion<readonly [z.ZodObject<{
|
|
47
|
-
/** Optional content chain narrowing — if absent, grants broad write access */
|
|
48
|
-
contentId: z.ZodOptional<z.ZodString>;
|
|
49
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
-
/** Optional content chain narrowing — if absent, grants broad read access */
|
|
51
|
-
contentId: z.ZodOptional<z.ZodString>;
|
|
52
|
-
}, z.core.$strict>]>;
|
|
53
|
-
}, z.core.$strict>;
|
|
54
|
-
type VCClaim = z.infer<typeof VCClaim>;
|
|
55
|
-
/** Full VC-JWT payload claims */
|
|
56
|
-
declare const CredentialClaims: z.ZodObject<{
|
|
57
|
-
/** Issuer — the DID granting the credential */
|
|
58
|
-
iss: z.ZodString;
|
|
59
|
-
/** Subject — the DID receiving the credential */
|
|
60
|
-
sub: z.ZodString;
|
|
61
|
-
/** Expiration — unix seconds */
|
|
62
|
-
exp: z.ZodNumber;
|
|
63
|
-
/** Issued at — unix seconds */
|
|
64
|
-
iat: z.ZodNumber;
|
|
65
|
-
/** Verifiable credential claim */
|
|
66
|
-
vc: z.ZodObject<{
|
|
67
|
-
'@context': z.ZodTuple<[z.ZodLiteral<"https://www.w3.org/ns/credentials/v2">], null>;
|
|
68
|
-
type: z.ZodPipe<z.ZodTuple<[z.ZodLiteral<"VerifiableCredential">, z.ZodEnum<{
|
|
69
|
-
DFOSContentWrite: "DFOSContentWrite";
|
|
70
|
-
DFOSContentRead: "DFOSContentRead";
|
|
71
|
-
}>], null>, z.ZodTransform<[string, "DFOSContentWrite" | "DFOSContentRead"], ["VerifiableCredential", "DFOSContentWrite" | "DFOSContentRead"]>>;
|
|
72
|
-
credentialSubject: z.ZodUnion<readonly [z.ZodObject<{
|
|
73
|
-
/** Optional content chain narrowing — if absent, grants broad write access */
|
|
74
|
-
contentId: z.ZodOptional<z.ZodString>;
|
|
75
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
76
|
-
/** Optional content chain narrowing — if absent, grants broad read access */
|
|
77
|
-
contentId: z.ZodOptional<z.ZodString>;
|
|
78
|
-
}, z.core.$strict>]>;
|
|
79
|
-
}, z.core.$strict>;
|
|
80
|
-
}, z.core.$strict>;
|
|
81
|
-
type CredentialClaims = z.infer<typeof CredentialClaims>;
|
|
82
45
|
|
|
83
46
|
interface AuthTokenCreateOptions {
|
|
84
47
|
/** The DID proving identity */
|
|
@@ -128,79 +91,132 @@ declare class AuthTokenVerificationError extends Error {
|
|
|
128
91
|
constructor(message: string);
|
|
129
92
|
}
|
|
130
93
|
|
|
131
|
-
interface
|
|
132
|
-
/**
|
|
94
|
+
interface VerifiedDFOSCredential {
|
|
95
|
+
/** Issuer DID */
|
|
133
96
|
iss: string;
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
/**
|
|
97
|
+
/** Audience DID or "*" for public */
|
|
98
|
+
aud: string;
|
|
99
|
+
/** Attenuations — resource + action pairs */
|
|
100
|
+
att: Attenuation[];
|
|
101
|
+
/** Parent credential JWS tokens */
|
|
102
|
+
prf: string[];
|
|
103
|
+
/** Expiry (unix seconds) */
|
|
137
104
|
exp: number;
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
/** Issued-at override — unix seconds (defaults to Date.now()) */
|
|
145
|
-
iat?: number;
|
|
146
|
-
/** Signer function */
|
|
147
|
-
sign: (message: Uint8Array) => Promise<Uint8Array>;
|
|
105
|
+
/** Issued at (unix seconds) */
|
|
106
|
+
iat: number;
|
|
107
|
+
/** CID of the credential payload (for revocation references) */
|
|
108
|
+
credentialCID: string;
|
|
109
|
+
/** kid from the JWS header */
|
|
110
|
+
signerKeyId: string;
|
|
148
111
|
}
|
|
149
|
-
interface
|
|
150
|
-
/** The
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
|
|
156
|
-
/** Expected credential type (optional — if provided, type must match) */
|
|
157
|
-
expectedType?: DFOSCredentialType;
|
|
158
|
-
/** Current time in seconds (defaults to Date.now() / 1000) */
|
|
159
|
-
currentTime?: number;
|
|
112
|
+
interface VerifiedDelegationChain {
|
|
113
|
+
/** The leaf credential */
|
|
114
|
+
credential: VerifiedDFOSCredential;
|
|
115
|
+
/** All credentials in the chain, from leaf to root */
|
|
116
|
+
chain: VerifiedDFOSCredential[];
|
|
117
|
+
/** The root DID that ultimately authorized the chain */
|
|
118
|
+
rootDID: string;
|
|
160
119
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Create a signed DFOS credential
|
|
122
|
+
*
|
|
123
|
+
* The credential is a JWS with `typ: "did:dfos:credential"` and a CID in the
|
|
124
|
+
* protected header for revocation addressability.
|
|
125
|
+
*/
|
|
126
|
+
declare const createDFOSCredential: (options: {
|
|
127
|
+
issuerDID: string;
|
|
128
|
+
/** Audience DID, or "*" for public credentials */
|
|
129
|
+
audienceDID: string;
|
|
130
|
+
att: Attenuation[];
|
|
131
|
+
/** Parent credential JWS tokens (for delegation chains) */
|
|
132
|
+
prf?: string[];
|
|
133
|
+
/** Expiry — unix seconds */
|
|
167
134
|
exp: number;
|
|
168
|
-
/**
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
}
|
|
135
|
+
/** Signer function */
|
|
136
|
+
signer: (message: Uint8Array) => Promise<Uint8Array>;
|
|
137
|
+
/** Key ID (without DID prefix — just the key_xxx part) */
|
|
138
|
+
keyId: string;
|
|
139
|
+
/** Issued-at override — unix seconds (defaults to Date.now()) */
|
|
140
|
+
iat?: number;
|
|
141
|
+
}) => Promise<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Verify a DFOS credential — signature, schema, expiry, CID integrity
|
|
144
|
+
*
|
|
145
|
+
* Does NOT verify the delegation chain. Use `verifyDelegationChain` for full
|
|
146
|
+
* chain verification including attenuation enforcement.
|
|
147
|
+
*/
|
|
148
|
+
declare const verifyDFOSCredential: (jwsToken: string, options: {
|
|
149
|
+
resolveIdentity: (did: string) => Promise<VerifiedIdentity | undefined>;
|
|
150
|
+
/** Current time in seconds (defaults to Date.now() / 1000) */
|
|
151
|
+
now?: number;
|
|
152
|
+
}) => Promise<VerifiedDFOSCredential>;
|
|
153
|
+
/**
|
|
154
|
+
* Verify a full delegation chain — walk `prf`, confirm monotonic attenuation,
|
|
155
|
+
* verify each credential's signature, and confirm the chain roots at `rootDID`.
|
|
156
|
+
*
|
|
157
|
+
* The chain is walked from the leaf credential upward through each parent in
|
|
158
|
+
* `prf`. At each hop: the child's `iss` must match a parent's `aud` (or the
|
|
159
|
+
* parent's `aud` must be `"*"`), the child's `att` must be attenuated from the
|
|
160
|
+
* parent's `att`, and the child's `exp` must not exceed the parent's `exp`.
|
|
161
|
+
*
|
|
162
|
+
* The chain terminates when a credential has `prf: []` (root credential). The
|
|
163
|
+
* root credential's `iss` must equal `rootDID`.
|
|
164
|
+
*/
|
|
165
|
+
declare const verifyDelegationChain: (credential: VerifiedDFOSCredential, options: {
|
|
166
|
+
resolveIdentity: (did: string) => Promise<VerifiedIdentity | undefined>;
|
|
167
|
+
/** The expected root authority DID (e.g., content chain creator) */
|
|
168
|
+
rootDID: string;
|
|
169
|
+
/** Current time in seconds (defaults to Date.now() / 1000) */
|
|
170
|
+
now?: number;
|
|
171
|
+
/** Check if a credential has been revoked (checked at every level of the chain) */
|
|
172
|
+
isRevoked?: (issuerDID: string, credentialCID: string) => Promise<boolean>;
|
|
173
|
+
}) => Promise<VerifiedDelegationChain>;
|
|
175
174
|
/**
|
|
176
|
-
*
|
|
175
|
+
* Check if `childAtt` is a valid attenuation of `parentAtt`
|
|
176
|
+
*
|
|
177
|
+
* Every entry in `childAtt` must be covered by at least one entry in
|
|
178
|
+
* `parentAtt`. Coverage rules:
|
|
177
179
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
+
* - `chain:X` covered by `chain:X` (exact match)
|
|
181
|
+
* - `chain:X` covered by `chain:*` (narrowing from wildcard — valid)
|
|
182
|
+
* - `chain:X` covered by `manifest:M` (narrowing from manifest — valid structurally)
|
|
183
|
+
* - `manifest:M` covered by `chain:*` (narrowing from wildcard — valid)
|
|
184
|
+
* - `manifest:M` covered by `manifest:M` (exact match)
|
|
185
|
+
* - `manifest:M` NOT covered by `chain:X` (widening — invalid)
|
|
186
|
+
* - `chain:*` covered by `chain:*` (exact match)
|
|
187
|
+
* - `chain:*` NOT covered by `chain:X` or `manifest:M` (widening — invalid)
|
|
188
|
+
* - Actions: child action set must be a subset of parent action set
|
|
180
189
|
*/
|
|
181
|
-
declare const
|
|
190
|
+
declare const isAttenuated: (parentAtt: Attenuation[], childAtt: Attenuation[]) => boolean;
|
|
182
191
|
/**
|
|
183
|
-
*
|
|
192
|
+
* Check if an `att` array covers a requested resource
|
|
193
|
+
*
|
|
194
|
+
* Used at the relay to determine if a credential authorizes access to a
|
|
195
|
+
* specific content chain.
|
|
184
196
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
197
|
+
* For `manifest:` resources, requires a `manifestLookup` callback to resolve
|
|
198
|
+
* which contentIds the manifest indexes. Without the callback, `manifest:`
|
|
199
|
+
* resources can only match exact `manifest:` requests, not `chain:` requests.
|
|
187
200
|
*/
|
|
188
|
-
declare const
|
|
201
|
+
declare const matchesResource: (att: Attenuation[], resource: string, action: string, options?: {
|
|
202
|
+
manifestLookup?: (manifestContentId: string) => Promise<string[]>;
|
|
203
|
+
}) => Promise<boolean>;
|
|
189
204
|
/**
|
|
190
|
-
* Decode a
|
|
205
|
+
* Decode a DFOS credential JWS without verifying the signature
|
|
191
206
|
*
|
|
192
|
-
* Returns null if the token is malformed or
|
|
207
|
+
* Returns null if the token is malformed or payload is invalid.
|
|
193
208
|
*/
|
|
194
|
-
declare const
|
|
209
|
+
declare const decodeDFOSCredentialUnsafe: (jwsToken: string) => {
|
|
195
210
|
header: {
|
|
196
211
|
alg: string;
|
|
197
212
|
typ: string;
|
|
198
213
|
kid: string;
|
|
214
|
+
cid: string;
|
|
199
215
|
};
|
|
200
|
-
|
|
216
|
+
payload: DFOSCredentialPayload;
|
|
201
217
|
} | null;
|
|
202
218
|
declare class CredentialVerificationError extends Error {
|
|
203
219
|
constructor(message: string);
|
|
204
220
|
}
|
|
205
221
|
|
|
206
|
-
export { AuthTokenClaims, type AuthTokenCreateOptions, AuthTokenVerificationError, type AuthTokenVerifyOptions,
|
|
222
|
+
export { Attenuation, AuthTokenClaims, type AuthTokenCreateOptions, AuthTokenVerificationError, type AuthTokenVerifyOptions, CredentialVerificationError, DFOSCredentialPayload, type VerifiedAuthToken, type VerifiedDFOSCredential, type VerifiedDelegationChain, createAuthToken, createDFOSCredential, decodeDFOSCredentialUnsafe, isAttenuated, matchesResource, verifyAuthToken, verifyDFOSCredential, verifyDelegationChain };
|
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Attenuation,
|
|
2
3
|
AuthTokenClaims,
|
|
3
4
|
AuthTokenVerificationError,
|
|
4
|
-
ContentReadSubject,
|
|
5
|
-
ContentWriteSubject,
|
|
6
|
-
CredentialClaims,
|
|
7
5
|
CredentialVerificationError,
|
|
8
|
-
|
|
9
|
-
VCClaim,
|
|
10
|
-
VC_TYPE_CONTENT_READ,
|
|
11
|
-
VC_TYPE_CONTENT_WRITE,
|
|
6
|
+
DFOSCredentialPayload,
|
|
12
7
|
createAuthToken,
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
createDFOSCredential,
|
|
9
|
+
decodeDFOSCredentialUnsafe,
|
|
10
|
+
isAttenuated,
|
|
11
|
+
matchesResource,
|
|
15
12
|
verifyAuthToken,
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
verifyDFOSCredential,
|
|
14
|
+
verifyDelegationChain
|
|
15
|
+
} from "../chunk-MEV6QVLC.js";
|
|
18
16
|
import "../chunk-ZXXP5W5N.js";
|
|
19
17
|
export {
|
|
18
|
+
Attenuation,
|
|
20
19
|
AuthTokenClaims,
|
|
21
20
|
AuthTokenVerificationError,
|
|
22
|
-
ContentReadSubject,
|
|
23
|
-
ContentWriteSubject,
|
|
24
|
-
CredentialClaims,
|
|
25
21
|
CredentialVerificationError,
|
|
26
|
-
|
|
27
|
-
VCClaim,
|
|
28
|
-
VC_TYPE_CONTENT_READ,
|
|
29
|
-
VC_TYPE_CONTENT_WRITE,
|
|
22
|
+
DFOSCredentialPayload,
|
|
30
23
|
createAuthToken,
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
createDFOSCredential,
|
|
25
|
+
decodeDFOSCredentialUnsafe,
|
|
26
|
+
isAttenuated,
|
|
27
|
+
matchesResource,
|
|
33
28
|
verifyAuthToken,
|
|
34
|
-
|
|
29
|
+
verifyDFOSCredential,
|
|
30
|
+
verifyDelegationChain
|
|
35
31
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { JwsHeader, JwsVerificationError, JwtClaims, JwtCreateOptions, JwtHeader, JwtVerificationError, JwtVerifyOptions, PrefixedID, base64urlDecode, base64urlEncode, createJws, createJwt, createNewEd25519Keypair, dagCborCanonicalEncode, decodeJwsUnsafe, decodeJwtUnsafe, generateId, generateIdNoPrefix, importEd25519Keypair, isCanonicallyEqual, isValidEd25519Signature, isValidId, normalizedId, parseDagCborCID, signPayloadEd25519, verifyJws, verifyJwt } from './crypto/index.js';
|
|
2
|
-
export {
|
|
2
|
+
export { A as ArtifactPayload, B as BeaconPayload, C as ContentOperation, a as CountersignPayload, I as IdentityOperation, M as MAX_ARTIFACT_PAYLOAD_SIZE, b as MultikeyPublicKey, R as RevocationPayload, S as Signer, V as VerifiedIdentity } from './schemas-BEl38wrI.js';
|
|
3
|
+
export { ED25519_PRIV_MULTICODEC, ED25519_PUB_MULTICODEC, VerifiedArtifact, VerifiedBeacon, VerifiedContentChain, VerifiedCountersignature, VerifiedRevocation, decodeMultikey, deriveChainIdentifier, deriveContentId, encodeEd25519Multikey, signArtifact, signBeacon, signContentOperation, signCountersignature, signIdentityOperation, signRevocation, verifyArtifact, verifyBeacon, verifyContentChain, verifyContentExtensionFromTrustedState, verifyCountersignature, verifyIdentityChain, verifyIdentityExtensionFromTrustedState, verifyRevocation } from './chain/index.js';
|
|
3
4
|
export { MerkleProof, buildMerkleTree, generateMerkleProof, hashLeaf, hexToBytes, verifyMerkleProof } from './merkle/index.js';
|
|
4
|
-
export { AuthTokenClaims, AuthTokenCreateOptions, AuthTokenVerificationError, AuthTokenVerifyOptions,
|
|
5
|
+
export { Attenuation, AuthTokenClaims, AuthTokenCreateOptions, AuthTokenVerificationError, AuthTokenVerifyOptions, CredentialVerificationError, DFOSCredentialPayload, VerifiedAuthToken, VerifiedDFOSCredential, VerifiedDelegationChain, createAuthToken, createDFOSCredential, decodeDFOSCredentialUnsafe, isAttenuated, matchesResource, verifyAuthToken, verifyDFOSCredential, verifyDelegationChain } from './credentials/index.js';
|
|
5
6
|
import 'multiformats';
|
|
6
7
|
import 'multiformats/cid';
|
|
7
8
|
import 'zod';
|
package/dist/index.js
CHANGED
|
@@ -3,29 +3,28 @@ import {
|
|
|
3
3
|
BeaconPayload,
|
|
4
4
|
ContentOperation,
|
|
5
5
|
CountersignPayload,
|
|
6
|
-
ED25519_PRIV_MULTICODEC,
|
|
7
|
-
ED25519_PUB_MULTICODEC,
|
|
8
6
|
IdentityOperation,
|
|
9
7
|
MAX_ARTIFACT_PAYLOAD_SIZE,
|
|
10
8
|
MultikeyPublicKey,
|
|
9
|
+
RevocationPayload,
|
|
11
10
|
VerifiedIdentity,
|
|
12
|
-
decodeMultikey,
|
|
13
11
|
deriveChainIdentifier,
|
|
14
12
|
deriveContentId,
|
|
15
|
-
encodeEd25519Multikey,
|
|
16
13
|
signArtifact,
|
|
17
14
|
signBeacon,
|
|
18
15
|
signContentOperation,
|
|
19
16
|
signCountersignature,
|
|
20
17
|
signIdentityOperation,
|
|
18
|
+
signRevocation,
|
|
21
19
|
verifyArtifact,
|
|
22
20
|
verifyBeacon,
|
|
23
21
|
verifyContentChain,
|
|
24
22
|
verifyContentExtensionFromTrustedState,
|
|
25
23
|
verifyCountersignature,
|
|
26
24
|
verifyIdentityChain,
|
|
27
|
-
verifyIdentityExtensionFromTrustedState
|
|
28
|
-
|
|
25
|
+
verifyIdentityExtensionFromTrustedState,
|
|
26
|
+
verifyRevocation
|
|
27
|
+
} from "./chunk-LQ56P4SU.js";
|
|
29
28
|
import {
|
|
30
29
|
buildMerkleTree,
|
|
31
30
|
generateMerkleProof,
|
|
@@ -34,22 +33,24 @@ import {
|
|
|
34
33
|
verifyMerkleProof
|
|
35
34
|
} from "./chunk-E5CFQG2B.js";
|
|
36
35
|
import {
|
|
36
|
+
Attenuation,
|
|
37
37
|
AuthTokenClaims,
|
|
38
38
|
AuthTokenVerificationError,
|
|
39
|
-
ContentReadSubject,
|
|
40
|
-
ContentWriteSubject,
|
|
41
|
-
CredentialClaims,
|
|
42
39
|
CredentialVerificationError,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
VC_TYPE_CONTENT_WRITE,
|
|
40
|
+
DFOSCredentialPayload,
|
|
41
|
+
ED25519_PRIV_MULTICODEC,
|
|
42
|
+
ED25519_PUB_MULTICODEC,
|
|
47
43
|
createAuthToken,
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
createDFOSCredential,
|
|
45
|
+
decodeDFOSCredentialUnsafe,
|
|
46
|
+
decodeMultikey,
|
|
47
|
+
encodeEd25519Multikey,
|
|
48
|
+
isAttenuated,
|
|
49
|
+
matchesResource,
|
|
50
50
|
verifyAuthToken,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
verifyDFOSCredential,
|
|
52
|
+
verifyDelegationChain
|
|
53
|
+
} from "./chunk-MEV6QVLC.js";
|
|
53
54
|
import {
|
|
54
55
|
JwsVerificationError,
|
|
55
56
|
JwtVerificationError,
|
|
@@ -75,16 +76,14 @@ import {
|
|
|
75
76
|
} from "./chunk-ZXXP5W5N.js";
|
|
76
77
|
export {
|
|
77
78
|
ArtifactPayload,
|
|
79
|
+
Attenuation,
|
|
78
80
|
AuthTokenClaims,
|
|
79
81
|
AuthTokenVerificationError,
|
|
80
82
|
BeaconPayload,
|
|
81
83
|
ContentOperation,
|
|
82
|
-
ContentReadSubject,
|
|
83
|
-
ContentWriteSubject,
|
|
84
84
|
CountersignPayload,
|
|
85
|
-
CredentialClaims,
|
|
86
85
|
CredentialVerificationError,
|
|
87
|
-
|
|
86
|
+
DFOSCredentialPayload,
|
|
88
87
|
ED25519_PRIV_MULTICODEC,
|
|
89
88
|
ED25519_PUB_MULTICODEC,
|
|
90
89
|
IdentityOperation,
|
|
@@ -92,20 +91,18 @@ export {
|
|
|
92
91
|
JwtVerificationError,
|
|
93
92
|
MAX_ARTIFACT_PAYLOAD_SIZE,
|
|
94
93
|
MultikeyPublicKey,
|
|
95
|
-
|
|
96
|
-
VC_TYPE_CONTENT_READ,
|
|
97
|
-
VC_TYPE_CONTENT_WRITE,
|
|
94
|
+
RevocationPayload,
|
|
98
95
|
VerifiedIdentity,
|
|
99
96
|
base64urlDecode,
|
|
100
97
|
base64urlEncode,
|
|
101
98
|
buildMerkleTree,
|
|
102
99
|
createAuthToken,
|
|
103
|
-
|
|
100
|
+
createDFOSCredential,
|
|
104
101
|
createJws,
|
|
105
102
|
createJwt,
|
|
106
103
|
createNewEd25519Keypair,
|
|
107
104
|
dagCborCanonicalEncode,
|
|
108
|
-
|
|
105
|
+
decodeDFOSCredentialUnsafe,
|
|
109
106
|
decodeJwsUnsafe,
|
|
110
107
|
decodeJwtUnsafe,
|
|
111
108
|
decodeMultikey,
|
|
@@ -118,9 +115,11 @@ export {
|
|
|
118
115
|
hashLeaf,
|
|
119
116
|
hexToBytes,
|
|
120
117
|
importEd25519Keypair,
|
|
118
|
+
isAttenuated,
|
|
121
119
|
isCanonicallyEqual,
|
|
122
120
|
isValidEd25519Signature,
|
|
123
121
|
isValidId,
|
|
122
|
+
matchesResource,
|
|
124
123
|
normalizedId,
|
|
125
124
|
parseDagCborCID,
|
|
126
125
|
signArtifact,
|
|
@@ -129,16 +128,19 @@ export {
|
|
|
129
128
|
signCountersignature,
|
|
130
129
|
signIdentityOperation,
|
|
131
130
|
signPayloadEd25519,
|
|
131
|
+
signRevocation,
|
|
132
132
|
verifyArtifact,
|
|
133
133
|
verifyAuthToken,
|
|
134
134
|
verifyBeacon,
|
|
135
135
|
verifyContentChain,
|
|
136
136
|
verifyContentExtensionFromTrustedState,
|
|
137
137
|
verifyCountersignature,
|
|
138
|
-
|
|
138
|
+
verifyDFOSCredential,
|
|
139
|
+
verifyDelegationChain,
|
|
139
140
|
verifyIdentityChain,
|
|
140
141
|
verifyIdentityExtensionFromTrustedState,
|
|
141
142
|
verifyJws,
|
|
142
143
|
verifyJwt,
|
|
143
|
-
verifyMerkleProof
|
|
144
|
+
verifyMerkleProof,
|
|
145
|
+
verifyRevocation
|
|
144
146
|
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Function that signs a byte array and returns a signature */
|
|
4
|
+
type Signer = (message: Uint8Array) => Promise<Uint8Array>;
|
|
5
|
+
declare const MultikeyPublicKey: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
type: z.ZodLiteral<"Multikey">;
|
|
8
|
+
publicKeyMultibase: z.ZodString;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
type MultikeyPublicKey = z.infer<typeof MultikeyPublicKey>;
|
|
11
|
+
declare const IdentityOperation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
|
+
version: z.ZodLiteral<1>;
|
|
13
|
+
type: z.ZodLiteral<"create">;
|
|
14
|
+
authKeys: z.ZodArray<z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
type: z.ZodLiteral<"Multikey">;
|
|
17
|
+
publicKeyMultibase: z.ZodString;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
assertKeys: z.ZodArray<z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
type: z.ZodLiteral<"Multikey">;
|
|
22
|
+
publicKeyMultibase: z.ZodString;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
controllerKeys: z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
type: z.ZodLiteral<"Multikey">;
|
|
27
|
+
publicKeyMultibase: z.ZodString;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
createdAt: z.ZodISODateTime;
|
|
30
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
+
version: z.ZodLiteral<1>;
|
|
32
|
+
type: z.ZodLiteral<"update">;
|
|
33
|
+
previousOperationCID: z.ZodString;
|
|
34
|
+
authKeys: z.ZodArray<z.ZodObject<{
|
|
35
|
+
id: z.ZodString;
|
|
36
|
+
type: z.ZodLiteral<"Multikey">;
|
|
37
|
+
publicKeyMultibase: z.ZodString;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
assertKeys: z.ZodArray<z.ZodObject<{
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
type: z.ZodLiteral<"Multikey">;
|
|
42
|
+
publicKeyMultibase: z.ZodString;
|
|
43
|
+
}, z.core.$strict>>;
|
|
44
|
+
controllerKeys: z.ZodArray<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
type: z.ZodLiteral<"Multikey">;
|
|
47
|
+
publicKeyMultibase: z.ZodString;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
createdAt: z.ZodISODateTime;
|
|
50
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
51
|
+
version: z.ZodLiteral<1>;
|
|
52
|
+
type: z.ZodLiteral<"delete">;
|
|
53
|
+
previousOperationCID: z.ZodString;
|
|
54
|
+
createdAt: z.ZodISODateTime;
|
|
55
|
+
}, z.core.$strict>], "type">;
|
|
56
|
+
type IdentityOperation = z.infer<typeof IdentityOperation>;
|
|
57
|
+
declare const VerifiedIdentity: z.ZodObject<{
|
|
58
|
+
did: z.ZodString;
|
|
59
|
+
isDeleted: z.ZodBoolean;
|
|
60
|
+
authKeys: z.ZodArray<z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
type: z.ZodLiteral<"Multikey">;
|
|
63
|
+
publicKeyMultibase: z.ZodString;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
assertKeys: z.ZodArray<z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
type: z.ZodLiteral<"Multikey">;
|
|
68
|
+
publicKeyMultibase: z.ZodString;
|
|
69
|
+
}, z.core.$strict>>;
|
|
70
|
+
controllerKeys: z.ZodArray<z.ZodObject<{
|
|
71
|
+
id: z.ZodString;
|
|
72
|
+
type: z.ZodLiteral<"Multikey">;
|
|
73
|
+
publicKeyMultibase: z.ZodString;
|
|
74
|
+
}, z.core.$strict>>;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
type VerifiedIdentity = z.infer<typeof VerifiedIdentity>;
|
|
77
|
+
declare const ContentOperation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
78
|
+
version: z.ZodLiteral<1>;
|
|
79
|
+
type: z.ZodLiteral<"create">;
|
|
80
|
+
did: z.ZodString;
|
|
81
|
+
documentCID: z.ZodString;
|
|
82
|
+
baseDocumentCID: z.ZodNullable<z.ZodString>;
|
|
83
|
+
createdAt: z.ZodISODateTime;
|
|
84
|
+
note: z.ZodNullable<z.ZodString>;
|
|
85
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
86
|
+
version: z.ZodLiteral<1>;
|
|
87
|
+
type: z.ZodLiteral<"update">;
|
|
88
|
+
did: z.ZodString;
|
|
89
|
+
previousOperationCID: z.ZodString;
|
|
90
|
+
documentCID: z.ZodNullable<z.ZodString>;
|
|
91
|
+
baseDocumentCID: z.ZodNullable<z.ZodString>;
|
|
92
|
+
createdAt: z.ZodISODateTime;
|
|
93
|
+
note: z.ZodNullable<z.ZodString>;
|
|
94
|
+
/** DFOS credential authorizing this operation when signer is not the chain creator */
|
|
95
|
+
authorization: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
97
|
+
version: z.ZodLiteral<1>;
|
|
98
|
+
type: z.ZodLiteral<"delete">;
|
|
99
|
+
did: z.ZodString;
|
|
100
|
+
previousOperationCID: z.ZodString;
|
|
101
|
+
createdAt: z.ZodISODateTime;
|
|
102
|
+
note: z.ZodNullable<z.ZodString>;
|
|
103
|
+
/** DFOS credential authorizing this operation when signer is not the chain creator */
|
|
104
|
+
authorization: z.ZodOptional<z.ZodString>;
|
|
105
|
+
}, z.core.$strict>], "type">;
|
|
106
|
+
type ContentOperation = z.infer<typeof ContentOperation>;
|
|
107
|
+
/** Beacon: floating signed manifest pointer announcement */
|
|
108
|
+
declare const BeaconPayload: z.ZodObject<{
|
|
109
|
+
version: z.ZodLiteral<1>;
|
|
110
|
+
type: z.ZodLiteral<"beacon">;
|
|
111
|
+
did: z.ZodString;
|
|
112
|
+
manifestContentId: z.ZodString;
|
|
113
|
+
createdAt: z.ZodISODateTime;
|
|
114
|
+
}, z.core.$strict>;
|
|
115
|
+
type BeaconPayload = z.infer<typeof BeaconPayload>;
|
|
116
|
+
/** Max CBOR-encoded payload size for artifacts (bytes) — protocol constant */
|
|
117
|
+
declare const MAX_ARTIFACT_PAYLOAD_SIZE = 16384;
|
|
118
|
+
/** Artifact: standalone signed inline document, immutable, CID-addressable */
|
|
119
|
+
declare const ArtifactPayload: z.ZodObject<{
|
|
120
|
+
version: z.ZodLiteral<1>;
|
|
121
|
+
type: z.ZodLiteral<"artifact">;
|
|
122
|
+
did: z.ZodString;
|
|
123
|
+
content: z.ZodObject<{
|
|
124
|
+
$schema: z.ZodString;
|
|
125
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
126
|
+
createdAt: z.ZodISODateTime;
|
|
127
|
+
}, z.core.$strict>;
|
|
128
|
+
type ArtifactPayload = z.infer<typeof ArtifactPayload>;
|
|
129
|
+
/** Countersign: standalone witness attestation referencing a target operation by CID */
|
|
130
|
+
declare const CountersignPayload: z.ZodObject<{
|
|
131
|
+
version: z.ZodLiteral<1>;
|
|
132
|
+
type: z.ZodLiteral<"countersign">;
|
|
133
|
+
did: z.ZodString;
|
|
134
|
+
targetCID: z.ZodString;
|
|
135
|
+
createdAt: z.ZodISODateTime;
|
|
136
|
+
}, z.core.$strict>;
|
|
137
|
+
type CountersignPayload = z.infer<typeof CountersignPayload>;
|
|
138
|
+
/** Revocation: signed credential revocation artifact, gossiped like beacons */
|
|
139
|
+
declare const RevocationPayload: z.ZodObject<{
|
|
140
|
+
version: z.ZodLiteral<1>;
|
|
141
|
+
type: z.ZodLiteral<"revocation">;
|
|
142
|
+
did: z.ZodString;
|
|
143
|
+
credentialCID: z.ZodString;
|
|
144
|
+
createdAt: z.ZodISODateTime;
|
|
145
|
+
}, z.core.$strict>;
|
|
146
|
+
type RevocationPayload = z.infer<typeof RevocationPayload>;
|
|
147
|
+
|
|
148
|
+
export { ArtifactPayload as A, BeaconPayload as B, ContentOperation as C, IdentityOperation as I, MAX_ARTIFACT_PAYLOAD_SIZE as M, RevocationPayload as R, type Signer as S, VerifiedIdentity as V, CountersignPayload as a, MultikeyPublicKey as b };
|