@motebit/verify 0.5.3 → 0.6.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 +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.js +1419 -713
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Verify any Motebit artifact — identity files, execution receipts, verifiable credentials, and verifiable presentations.
|
|
4
4
|
|
|
5
|
-
One function. Any artifact. Zero
|
|
5
|
+
One function. Any artifact. Zero runtime dependencies. MIT licensed.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* // With expected type (fail-fast on misclassification)
|
|
22
22
|
* const result = await verify(artifact, { expectedType: "receipt" });
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
interface MotebitIdentityFile {
|
|
25
25
|
spec: string;
|
|
26
26
|
motebit_id: string;
|
|
27
27
|
created_at: string;
|
|
@@ -61,7 +61,7 @@ export interface MotebitIdentityFile {
|
|
|
61
61
|
}>;
|
|
62
62
|
succession?: Array<SuccessionRecord>;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
interface SuccessionRecord {
|
|
65
65
|
old_public_key: string;
|
|
66
66
|
new_public_key: string;
|
|
67
67
|
timestamp: number;
|
|
@@ -69,7 +69,7 @@ export interface SuccessionRecord {
|
|
|
69
69
|
old_key_signature: string;
|
|
70
70
|
new_key_signature: string;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
interface ExecutionReceipt {
|
|
73
73
|
task_id: string;
|
|
74
74
|
motebit_id: string;
|
|
75
75
|
/** Signer's Ed25519 public key (hex). Enables verification without relay lookup. */
|
|
@@ -87,7 +87,7 @@ export interface ExecutionReceipt {
|
|
|
87
87
|
delegated_scope?: string;
|
|
88
88
|
signature: string;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
interface DataIntegrityProof {
|
|
91
91
|
type: "DataIntegrityProof";
|
|
92
92
|
cryptosuite: "eddsa-jcs-2022";
|
|
93
93
|
created: string;
|
|
@@ -95,7 +95,7 @@ export interface DataIntegrityProof {
|
|
|
95
95
|
proofPurpose: "assertionMethod" | "authentication";
|
|
96
96
|
proofValue: string;
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
interface VerifiableCredential {
|
|
99
99
|
"@context": string[];
|
|
100
100
|
type: string[];
|
|
101
101
|
issuer: string;
|
|
@@ -110,14 +110,14 @@ export interface VerifiableCredential {
|
|
|
110
110
|
};
|
|
111
111
|
proof: DataIntegrityProof;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
interface VerifiablePresentation {
|
|
114
114
|
"@context": string[];
|
|
115
115
|
type: string[];
|
|
116
116
|
holder: string;
|
|
117
117
|
verifiableCredential: VerifiableCredential[];
|
|
118
118
|
proof: DataIntegrityProof;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
interface VerificationError {
|
|
121
121
|
message: string;
|
|
122
122
|
path?: string;
|
|
123
123
|
}
|
|
@@ -125,7 +125,7 @@ interface BaseResult {
|
|
|
125
125
|
valid: boolean;
|
|
126
126
|
errors?: VerificationError[];
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
interface IdentityVerifyResult extends BaseResult {
|
|
129
129
|
type: "identity";
|
|
130
130
|
identity: MotebitIdentityFile | null;
|
|
131
131
|
did?: string;
|
|
@@ -138,34 +138,34 @@ export interface IdentityVerifyResult extends BaseResult {
|
|
|
138
138
|
error?: string;
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
interface ReceiptVerifyResult extends BaseResult {
|
|
142
142
|
type: "receipt";
|
|
143
143
|
receipt: ExecutionReceipt | null;
|
|
144
144
|
signer?: string;
|
|
145
145
|
delegations?: ReceiptVerifyResult[];
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
interface CredentialVerifyResult extends BaseResult {
|
|
148
148
|
type: "credential";
|
|
149
149
|
credential: VerifiableCredential | null;
|
|
150
150
|
issuer?: string;
|
|
151
151
|
subject?: string;
|
|
152
152
|
expired?: boolean;
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
interface PresentationVerifyResult extends BaseResult {
|
|
155
155
|
type: "presentation";
|
|
156
156
|
presentation: VerifiablePresentation | null;
|
|
157
157
|
holder?: string;
|
|
158
158
|
credentials?: CredentialVerifyResult[];
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
type VerifyResult = IdentityVerifyResult | ReceiptVerifyResult | CredentialVerifyResult | PresentationVerifyResult;
|
|
161
|
+
type ArtifactType = VerifyResult["type"];
|
|
162
|
+
interface VerifyOptions {
|
|
163
163
|
expectedType?: ArtifactType;
|
|
164
164
|
/** Clock skew tolerance in seconds for credential expiry checks. Default: 60. */
|
|
165
165
|
clockSkewSeconds?: number;
|
|
166
166
|
}
|
|
167
167
|
/** @deprecated Use VerifyResult instead. Kept for backward compatibility. */
|
|
168
|
-
|
|
168
|
+
interface LegacyVerifyResult {
|
|
169
169
|
valid: boolean;
|
|
170
170
|
identity: MotebitIdentityFile | null;
|
|
171
171
|
did?: string;
|
|
@@ -181,7 +181,7 @@ export interface LegacyVerifyResult {
|
|
|
181
181
|
* Parse a motebit.md file into its components.
|
|
182
182
|
* Does not verify the signature — use `verify()` for that.
|
|
183
183
|
*/
|
|
184
|
-
|
|
184
|
+
declare function parse(content: string): {
|
|
185
185
|
frontmatter: MotebitIdentityFile;
|
|
186
186
|
signature: string;
|
|
187
187
|
rawFrontmatter: string;
|
|
@@ -213,12 +213,12 @@ export declare function parse(content: string): {
|
|
|
213
213
|
* if (r3.type === "credential" && r3.valid) console.log(r3.issuer);
|
|
214
214
|
* ```
|
|
215
215
|
*/
|
|
216
|
-
|
|
216
|
+
declare function verify(artifact: unknown, options?: VerifyOptions): Promise<VerifyResult>;
|
|
217
217
|
/**
|
|
218
218
|
* Verify a motebit.md identity file. Backward-compatible with pre-0.4.0.
|
|
219
219
|
*
|
|
220
220
|
* @deprecated Use `verify(content)` instead — it handles all artifact types.
|
|
221
221
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
declare function verifyIdentityFile(content: string): Promise<LegacyVerifyResult>;
|
|
223
|
+
|
|
224
|
+
export { type ArtifactType, type CredentialVerifyResult, type DataIntegrityProof, type ExecutionReceipt, type IdentityVerifyResult, type LegacyVerifyResult, type MotebitIdentityFile, type PresentationVerifyResult, type ReceiptVerifyResult, type SuccessionRecord, type VerifiableCredential, type VerifiablePresentation, type VerificationError, type VerifyOptions, type VerifyResult, parse, verify, verifyIdentityFile };
|