@originator-profile/verify 0.7.0-beta.4 → 0.7.0-beta.5
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/dist/index.d.ts +419 -67
- package/dist/index.js +609 -268
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ContentAttestation, Image, Target, ContentAttestationSet, OpVc,
|
|
2
|
-
import { JwtVcDecodingResult, UnverifiedJwtVc, JwtVcVerificationResult, VerifiedJwtVc, VcValidator } from '@originator-profile/securing-mechanism';
|
|
1
|
+
import { ContentAttestation, Jwk, Image, Target, ContentAttestationSet, OpVc, Certificate as Certificate$1, JapaneseExistenceCertificate, ProfileAnnotation, JapaneseExistencePA, ProfileAnnotationIssuerRegistration, CoreProfile, WebMediaProfile, OriginatorProfileSet, ProfileAnnotationPolicy, CertificationSystem, ArticleCA, WebsiteProfile, Jwks, SiteProfile, AllowedOrigin } from '@originator-profile/model';
|
|
2
|
+
import { JwtVcDecodingResult, UnverifiedJwtVc, JwtVcVerificationResult, VerifiedJwtVc, VcValidator, VcValidatorFactory } from '@originator-profile/securing-mechanism';
|
|
3
3
|
import { Keys } from '@originator-profile/cryptography';
|
|
4
4
|
import { DigestSriResult, ContentFetcher, ElementSelector } from '@originator-profile/sign';
|
|
5
5
|
|
|
@@ -39,14 +39,94 @@ declare class CaVerifyFailed extends Error {
|
|
|
39
39
|
constructor(message: string, result: CaVerificationFailure);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* 検証中に検出された問題
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://www.w3.org/TR/vc-data-model-2.0/#problem-details}
|
|
46
|
+
*/
|
|
47
|
+
type ProblemDetails = {
|
|
48
|
+
/** 問題の種類を識別する URL */
|
|
49
|
+
type: string;
|
|
50
|
+
/** 短い説明 */
|
|
51
|
+
title: string;
|
|
52
|
+
/** この発生に固有の説明 */
|
|
53
|
+
detail?: string;
|
|
54
|
+
/** 問題を検出した位置を指す JSONPath。例: `$.originators[0].annotations[1]` */
|
|
55
|
+
pointer?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* VC ごとの securing mechanism の検証結果
|
|
59
|
+
*
|
|
60
|
+
* 復号したペイロードは {@link VerificationResult.outcome} が階層で保持し、
|
|
61
|
+
* securing mechanism に由来する情報と検証の成否はこちらが持つ。
|
|
62
|
+
* 対応は `pointer` で取る。
|
|
63
|
+
*/
|
|
64
|
+
type SecuringResult = {
|
|
65
|
+
/** 対応する {@link VerificationResult.outcome} 内の位置を指す JSONPath */
|
|
66
|
+
pointer: string;
|
|
67
|
+
/** 検証を通過したか */
|
|
68
|
+
status: boolean;
|
|
69
|
+
/** 保護された表現。JWT VC では JWT 文字列 */
|
|
70
|
+
source?: string;
|
|
71
|
+
/** メディアタイプ */
|
|
72
|
+
mediaType?: string;
|
|
73
|
+
/** 暗号アルゴリズム */
|
|
74
|
+
algorithm?: string;
|
|
75
|
+
/** 発行日時 (ISO 8601) */
|
|
76
|
+
issuedAt?: string;
|
|
77
|
+
/** 有効期限 (ISO 8601) */
|
|
78
|
+
expiredAt?: string;
|
|
79
|
+
/** 検証に用いた鍵 */
|
|
80
|
+
verificationKey?: Jwk;
|
|
81
|
+
/** 検証鍵の保有者 */
|
|
82
|
+
controller?: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* 検証結果
|
|
86
|
+
*
|
|
87
|
+
* 階層を持つのは `outcome` だけで、securing mechanism の情報と検出した問題は
|
|
88
|
+
* いずれも JSONPath で `outcome` 内の位置を指すフラットなリストとして持つ。
|
|
89
|
+
* JSON で表現できる値だけで構成されるため、メッセージ境界や storage を跨いでも
|
|
90
|
+
* 値と判定が変わらない。
|
|
91
|
+
*
|
|
92
|
+
* @see {@link https://www.w3.org/TR/vc-data-model-2.0/#verification}
|
|
93
|
+
*/
|
|
94
|
+
type VerificationResult<T> = {
|
|
95
|
+
/** 検証を通過したか */
|
|
96
|
+
status: true;
|
|
97
|
+
/** 復号したペイロードの階層 */
|
|
98
|
+
outcome: T;
|
|
99
|
+
/** VC ごとの securing mechanism の検証結果 */
|
|
100
|
+
securingResults: SecuringResult[];
|
|
101
|
+
/** 無効性を意味しない通知 */
|
|
102
|
+
warnings: ProblemDetails[];
|
|
103
|
+
/** システムの正常な動作記録 */
|
|
104
|
+
info: ProblemDetails[];
|
|
105
|
+
/** 検証を通過しているため参照しない */
|
|
106
|
+
errors?: never;
|
|
107
|
+
} | {
|
|
108
|
+
status: false;
|
|
109
|
+
outcome?: T;
|
|
110
|
+
securingResults: SecuringResult[];
|
|
111
|
+
warnings: ProblemDetails[];
|
|
112
|
+
info: ProblemDetails[];
|
|
113
|
+
errors: ProblemDetails[];
|
|
114
|
+
};
|
|
115
|
+
|
|
42
116
|
/**
|
|
43
117
|
* 検証中のメッセージを受け取るロガー
|
|
44
118
|
* - `warn`: 警告
|
|
45
119
|
* 主に互換性 (非推奨 Certificate や digestSRI の欠落・不一致など) の通知に使用
|
|
46
120
|
* - `info`: システムの正常な動作記録
|
|
47
121
|
* (Profile Annotation Issuer 登録証 PA 未保有など、無効性を意味しない状態) の通知に使用する。
|
|
122
|
+
*
|
|
123
|
+
* 第 2 引数の `details` には構造化した通知内容を渡す。`console` をはじめ
|
|
124
|
+
* 第 1 引数のみを受け取る実装も、そのまま渡せる。
|
|
48
125
|
*/
|
|
49
|
-
type Logger =
|
|
126
|
+
type Logger = {
|
|
127
|
+
warn(message: string, details?: ProblemDetails): void;
|
|
128
|
+
info(message: string, details?: ProblemDetails): void;
|
|
129
|
+
};
|
|
50
130
|
|
|
51
131
|
/**
|
|
52
132
|
* `digestSRI` の検証
|
|
@@ -71,6 +151,8 @@ declare function verifyImageDigestSri(value: Image | undefined, options?: {
|
|
|
71
151
|
fetcher?: typeof fetch;
|
|
72
152
|
/** ロガー (デフォルト: `console`) */
|
|
73
153
|
logger?: Logger;
|
|
154
|
+
/** 検証対象の位置を指す JSONPath */
|
|
155
|
+
at?: string;
|
|
74
156
|
}): Promise<void>;
|
|
75
157
|
|
|
76
158
|
declare class IntegrityFetchFailed extends Error {
|
|
@@ -140,9 +222,11 @@ type VerifyIntegrity = typeof verifyIntegrity;
|
|
|
140
222
|
* @param url 検証対象のURL
|
|
141
223
|
* @param verifyIntegrity Target Integrity の検証器
|
|
142
224
|
* @param validator バリデーター
|
|
225
|
+
* @param logger ロガー (デフォルト: `console`)
|
|
226
|
+
* @param at 検証対象の位置を指す JSONPath
|
|
143
227
|
* @returns 検証機
|
|
144
228
|
*/
|
|
145
|
-
declare function CaVerifier<T extends ContentAttestation>(ca: string, keys: Keys, issuer: string, url: URL, verifyIntegrity?: VerifyIntegrity, validator?: VcValidator<VerifiedCa<T
|
|
229
|
+
declare function CaVerifier<T extends ContentAttestation>(ca: string, keys: Keys, issuer: string, url: URL, verifyIntegrity?: VerifyIntegrity, validator?: VcValidator<VerifiedCa<T>>, logger?: Logger, at?: string): () => Promise<CaVerificationResult<T>>;
|
|
146
230
|
|
|
147
231
|
/** COntent Attestation Set 要素 */
|
|
148
232
|
type CasItem<Ca> = {
|
|
@@ -187,8 +271,17 @@ declare function normalizeCasItem<Ca>(ca: Ca | CasItem<Ca>): CasItem<Ca>;
|
|
|
187
271
|
* @param url 検証対象のURL
|
|
188
272
|
* @param verifyIntegrity Target Integrity の検証器
|
|
189
273
|
* @param validator バリデーター
|
|
274
|
+
* @param logger ロガー (デフォルト: `console`)
|
|
275
|
+
* @param at 検証対象の文書の位置を指す JSONPath
|
|
190
276
|
* @returns CAS 検証結果
|
|
191
277
|
*
|
|
278
|
+
* @remarks
|
|
279
|
+
* `CasVerifyFailed` を返さず `VerifiedCas` を返す場合、その配列は `cas` と同じ順序・同じ件数になる契約とする。内部では
|
|
280
|
+
* `Promise.all(cas.map(...))` により検証しており、要素のフィルタ・並び替えは
|
|
281
|
+
* 行わない。この契約は呼び出し側(例: inspector の `verifyFramesCas`)が
|
|
282
|
+
* インデックスで入力と結果を対応付ける際の前提になっているため、将来実装を
|
|
283
|
+
* 変更する場合はこの契約を維持するか、呼び出し側にも影響がある点に注意すること。
|
|
284
|
+
*
|
|
192
285
|
* @example
|
|
193
286
|
* ```ts
|
|
194
287
|
* import { verifyIntegirty } from "@originator-profile/verify";
|
|
@@ -204,65 +297,7 @@ declare function normalizeCasItem<Ca>(ca: Ca | CasItem<Ca>): CasItem<Ca>;
|
|
|
204
297
|
* verified; // VerifiedCas
|
|
205
298
|
* ```
|
|
206
299
|
*/
|
|
207
|
-
declare function verifyCas<T extends ContentAttestation = ContentAttestation>(cas: ContentAttestationSet, verifiedOps: VerifiedOps, url: string, verifyIntegrity: VerifyIntegrity, validator?:
|
|
208
|
-
|
|
209
|
-
// Definitions by: Eddie Atkinson <https://github.com/eddie-atkinson>
|
|
210
|
-
|
|
211
|
-
type Operation = "add" | "replace" | "remove" | "move";
|
|
212
|
-
|
|
213
|
-
type DiffOps = Array<{
|
|
214
|
-
op: Operation;
|
|
215
|
-
path: Array<string | number>;
|
|
216
|
-
value?: any;
|
|
217
|
-
}>;
|
|
218
|
-
type PathConverter = (path: string) => string[];
|
|
219
|
-
|
|
220
|
-
declare function diffApply<T extends object>(
|
|
221
|
-
obj: T,
|
|
222
|
-
diff: DiffOps,
|
|
223
|
-
pathConverter?: PathConverter
|
|
224
|
-
): T;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* JSON Patch を適用する関数
|
|
228
|
-
*
|
|
229
|
-
* @link https://jsonpatch.com/
|
|
230
|
-
*/
|
|
231
|
-
declare const patch: <T extends object>(...args: Parameters<typeof diffApply<T>>) => T;
|
|
232
|
-
/**
|
|
233
|
-
* VerifyResult ファクトリー
|
|
234
|
-
*
|
|
235
|
-
* @link https://reference.originator-profile.org/ts/types/_originator-profile_securing-mechanism.UnverifiedJwtVc
|
|
236
|
-
* @link https://reference.originator-profile.org/ts/types/_originator-profile_securing-mechanism.VerifiedJwtVc
|
|
237
|
-
*/
|
|
238
|
-
declare const VerifyResultFactory: (issuedAt: Date, expiredAt: Date) => {
|
|
239
|
-
create: (vc: OpVc, jwt: string, verificationKey?: Jwk, validated?: boolean) => UnverifiedJwtVc<OpVc> | VerifiedJwtVc<OpVc>;
|
|
240
|
-
};
|
|
241
|
-
/** OP ID Constants */
|
|
242
|
-
declare const opId: {
|
|
243
|
-
/** CP 発行者 */
|
|
244
|
-
authority: "dns:cp-issuer.example.org";
|
|
245
|
-
/** PA 発行者 */
|
|
246
|
-
certifier: "dns:pa-issuer.example.org";
|
|
247
|
-
/** CA 発行者 */
|
|
248
|
-
originator: "dns:originator.example.org";
|
|
249
|
-
/** 無効な第三者 */
|
|
250
|
-
invalid: "dns:invalid.example.org";
|
|
251
|
-
};
|
|
252
|
-
/** Core Profile */
|
|
253
|
-
declare const cp: CoreProfile;
|
|
254
|
-
/** Certificate */
|
|
255
|
-
declare const certificate: Certificate$1;
|
|
256
|
-
/** Web Media Profile */
|
|
257
|
-
declare const wmp: WebMediaProfile;
|
|
258
|
-
/** Website Profile */
|
|
259
|
-
declare const wsp: WebsiteProfile;
|
|
260
|
-
/** CA ID */
|
|
261
|
-
declare const caId = "urn:uuid:78550fa7-f846-4e0f-ad5c-8d34461cb95b";
|
|
262
|
-
/** CA URL */
|
|
263
|
-
declare const caUrl: URL;
|
|
264
|
-
/** Article CA */
|
|
265
|
-
declare const article: ArticleCA;
|
|
300
|
+
declare function verifyCas<T extends ContentAttestation = ContentAttestation>(cas: ContentAttestationSet, verifiedOps: VerifiedOps, url: string, verifyIntegrity: VerifyIntegrity, validator?: VcValidatorFactory, logger?: Logger, at?: string): Promise<CasVerificationResult<T>>;
|
|
266
301
|
|
|
267
302
|
/**
|
|
268
303
|
* Originator Profile Set 無効
|
|
@@ -432,14 +467,213 @@ declare function verifyAnnotationIssuerRegistration(verifiedOps: VerifiedOps, pa
|
|
|
432
467
|
* @param issuer Core Profile の発行者
|
|
433
468
|
* @param options バリデーターとロガー
|
|
434
469
|
* @returns 検証者
|
|
470
|
+
*
|
|
471
|
+
* @remarks
|
|
472
|
+
* 生成された検証者(`verify()`)が `VerifiedOps` を返す場合、その配列は `ops` と同じ順序・同じ件数になる契約とする。
|
|
473
|
+
* 内部では `Promise.all(ops.map(...))` により検証しており、要素のフィルタ・
|
|
474
|
+
* 並び替え・重複排除は行わない。この契約は呼び出し側(例: inspector の
|
|
475
|
+
* `verifyOps`)がインデックスで入力と結果を対応付ける際の前提になっているため、
|
|
476
|
+
* 将来実装を変更する場合はこの契約を維持するか、呼び出し側にも影響がある点に
|
|
477
|
+
* 注意すること。
|
|
435
478
|
*/
|
|
436
479
|
declare function OpsVerifier(ops: OriginatorProfileSet, keys: Keys, issuer: string | string[], options?: {
|
|
437
480
|
/** バリデーター */
|
|
438
|
-
validator?:
|
|
481
|
+
validator?: VcValidatorFactory;
|
|
439
482
|
/** ロガー (デフォルト: `console`) */
|
|
440
483
|
logger?: Logger;
|
|
441
484
|
}): () => Promise<OpsVerificationResult>;
|
|
442
485
|
|
|
486
|
+
/** Core Profile 発行者 (レジストリ) の Originator Profile Set と検証鍵 */
|
|
487
|
+
type Registry = {
|
|
488
|
+
/** レジストリの Originator Profile Set */
|
|
489
|
+
ops: OriginatorProfileSet;
|
|
490
|
+
/** Core Profile の検証鍵 */
|
|
491
|
+
keys: Keys;
|
|
492
|
+
/**
|
|
493
|
+
* Core Profile の発行者
|
|
494
|
+
*
|
|
495
|
+
* レジストリが複数の発行者を含む場合は配列になる。
|
|
496
|
+
* @see {@link prepareRegistry}
|
|
497
|
+
*/
|
|
498
|
+
issuer: string | string[];
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* レジストリの Originator Profile Set から検証に用いる形を用意する
|
|
502
|
+
* @param ops レジストリの Originator Profile Set
|
|
503
|
+
* @returns Registry、または復号に失敗した場合は OpsInvalid
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```ts
|
|
507
|
+
* const registry = prepareRegistry(await fetchRegistryOps());
|
|
508
|
+
* if (registry instanceof Error) throw registry;
|
|
509
|
+
* const verified = await verifyWebsite(origin, { siteProfile, registry });
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
declare function prepareRegistry(ops: OriginatorProfileSet): Registry | OpsInvalid;
|
|
513
|
+
|
|
514
|
+
/** 復号した Originator Profile のペイロード */
|
|
515
|
+
type OriginatorPayload = {
|
|
516
|
+
/** 復号できなかった場合は null */
|
|
517
|
+
core: CoreProfile | null;
|
|
518
|
+
annotations?: (Certificate | null)[];
|
|
519
|
+
media?: (WebMediaProfile | null)[];
|
|
520
|
+
};
|
|
521
|
+
/** 復号した Content Attestation Set の要素 */
|
|
522
|
+
type CasPayload = {
|
|
523
|
+
main: boolean;
|
|
524
|
+
/** 復号できなかった場合は null */
|
|
525
|
+
attestation: ContentAttestation | null;
|
|
526
|
+
};
|
|
527
|
+
/** 変換中に集める securing mechanism の検証結果と問題 */
|
|
528
|
+
type Collector = {
|
|
529
|
+
securingResults: SecuringResult[];
|
|
530
|
+
errors: ProblemDetails[];
|
|
531
|
+
};
|
|
532
|
+
/** 収集先を作る */
|
|
533
|
+
declare const createCollector: () => Collector;
|
|
534
|
+
/**
|
|
535
|
+
* VC の検証結果を、復号したペイロードと収集物に分解する
|
|
536
|
+
* @param value 検証済み VC、または検証・復号に失敗したエラー
|
|
537
|
+
* @param at 位置を指す JSONPath
|
|
538
|
+
* @param collect 収集先
|
|
539
|
+
* @returns 復号できたペイロード。復号できなければ null
|
|
540
|
+
*/
|
|
541
|
+
declare function convertVc<T extends OpVc>(value: unknown, at: string, collect: Collector): T | null;
|
|
542
|
+
/**
|
|
543
|
+
* Originator Profile の検証結果を、復号したペイロードと収集物に分解する
|
|
544
|
+
* @param op 検証済み OP、または検証・復号に失敗したエラー
|
|
545
|
+
* @param at 位置を指す JSONPath
|
|
546
|
+
* @param collect 収集先
|
|
547
|
+
*/
|
|
548
|
+
declare function convertOp(op: unknown, at: string, collect: Collector): OriginatorPayload;
|
|
549
|
+
/**
|
|
550
|
+
* Originator Profile Set の検証結果を、復号したペイロードと収集物に分解する
|
|
551
|
+
* @param ops 検証済み OPS、または検証・復号に失敗したエラー
|
|
552
|
+
* @param collect 収集先
|
|
553
|
+
*/
|
|
554
|
+
declare function convertOps(ops: unknown, collect: Collector): OriginatorPayload[];
|
|
555
|
+
/**
|
|
556
|
+
* Content Attestation Set の検証結果を、復号したペイロードと収集物に分解する
|
|
557
|
+
* @param cas 検証済み CAS、または検証に失敗した結果
|
|
558
|
+
* @param at 対象の文書の位置を指す JSONPath
|
|
559
|
+
* @param collect 収集先
|
|
560
|
+
*/
|
|
561
|
+
declare function convertCas(cas: {
|
|
562
|
+
main: boolean;
|
|
563
|
+
attestation: unknown;
|
|
564
|
+
}[], at: string, collect: Collector): CasPayload[];
|
|
565
|
+
|
|
566
|
+
/** 検証対象の文書 */
|
|
567
|
+
type VerificationTarget = {
|
|
568
|
+
/** 文書に設置された Originator Profile Set */
|
|
569
|
+
ops: OriginatorProfileSet;
|
|
570
|
+
/** 文書に設置された Content Attestation Set */
|
|
571
|
+
cas: ContentAttestationSet;
|
|
572
|
+
/** 文書の URL */
|
|
573
|
+
url: string;
|
|
574
|
+
/** 文書内の Target Integrity 検証器 */
|
|
575
|
+
verifyIntegrity: VerifyIntegrity;
|
|
576
|
+
};
|
|
577
|
+
/** 文書ごとの復号ペイロード */
|
|
578
|
+
type DocumentOutcome<Target extends VerificationTarget> = {
|
|
579
|
+
/** 検証対象の文書 */
|
|
580
|
+
target: Target;
|
|
581
|
+
/** Content Attestation の復号ペイロード */
|
|
582
|
+
cas: CasPayload[];
|
|
583
|
+
};
|
|
584
|
+
/** 文書群の検証結果に含まれる復号ペイロード */
|
|
585
|
+
type DocumentsOutcome<Target extends VerificationTarget> = {
|
|
586
|
+
/** 発信者ごとの復号ペイロード */
|
|
587
|
+
originators: OriginatorPayload[];
|
|
588
|
+
/** 文書ごとの復号ペイロード */
|
|
589
|
+
documents: DocumentOutcome<Target>[];
|
|
590
|
+
};
|
|
591
|
+
/**
|
|
592
|
+
* 文書群の検証
|
|
593
|
+
*
|
|
594
|
+
* レジストリ・Web サイト・各文書の Originator Profile Set を結合して検証し、
|
|
595
|
+
* その結果を用いて文書ごとに Content Attestation Set を検証する。
|
|
596
|
+
*
|
|
597
|
+
* @param targets 検証対象の文書
|
|
598
|
+
* @param options レジストリ・Web サイトの発信者・バリデーター・ロガー
|
|
599
|
+
* @returns 検証結果。復号できたペイロードは status によらず outcome に含まれる
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* ```ts
|
|
603
|
+
* const result = await verifyDocuments(targets, { registry });
|
|
604
|
+
* result.outcome?.documents; // 文書ごとの Content Attestation の復号ペイロード
|
|
605
|
+
* if (!result.status) result.errors; // 検証失敗の理由
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
declare function verifyDocuments<Target extends VerificationTarget = VerificationTarget>(targets: Target[], options: {
|
|
609
|
+
/** Core Profile 発行者のレジストリ */
|
|
610
|
+
registry: Registry;
|
|
611
|
+
/** Web サイトが提示する発信者。文書の OPS と併せて検証し、検証鍵に加える */
|
|
612
|
+
websiteOriginators?: OriginatorProfileSet;
|
|
613
|
+
/** バリデーター */
|
|
614
|
+
validator?: VcValidatorFactory;
|
|
615
|
+
/** ロガー (デフォルト: `console`) */
|
|
616
|
+
logger?: Logger;
|
|
617
|
+
}): Promise<VerificationResult<DocumentsOutcome<Target>>>;
|
|
618
|
+
|
|
619
|
+
// Definitions by: Eddie Atkinson <https://github.com/eddie-atkinson>
|
|
620
|
+
|
|
621
|
+
type Operation = "add" | "replace" | "remove" | "move";
|
|
622
|
+
|
|
623
|
+
type DiffOps = Array<{
|
|
624
|
+
op: Operation;
|
|
625
|
+
path: Array<string | number>;
|
|
626
|
+
value?: any;
|
|
627
|
+
}>;
|
|
628
|
+
type PathConverter = (path: string) => string[];
|
|
629
|
+
|
|
630
|
+
declare function diffApply<T extends object>(
|
|
631
|
+
obj: T,
|
|
632
|
+
diff: DiffOps,
|
|
633
|
+
pathConverter?: PathConverter
|
|
634
|
+
): T;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* JSON Patch を適用する関数
|
|
638
|
+
*
|
|
639
|
+
* @link https://jsonpatch.com/
|
|
640
|
+
*/
|
|
641
|
+
declare const patch: <T extends object>(...args: Parameters<typeof diffApply<T>>) => T;
|
|
642
|
+
/**
|
|
643
|
+
* VerifyResult ファクトリー
|
|
644
|
+
*
|
|
645
|
+
* @link UnverifiedJwtVc
|
|
646
|
+
* @link VerifiedJwtVc
|
|
647
|
+
*/
|
|
648
|
+
declare const VerifyResultFactory: (issuedAt: Date, expiredAt: Date) => {
|
|
649
|
+
create: (vc: OpVc, jwt: string, verificationKey?: Jwk, validated?: boolean) => UnverifiedJwtVc<OpVc> | VerifiedJwtVc<OpVc>;
|
|
650
|
+
};
|
|
651
|
+
/** OP ID Constants */
|
|
652
|
+
declare const opId: {
|
|
653
|
+
/** CP 発行者 */
|
|
654
|
+
authority: "dns:cp-issuer.example.org";
|
|
655
|
+
/** PA 発行者 */
|
|
656
|
+
certifier: "dns:pa-issuer.example.org";
|
|
657
|
+
/** CA 発行者 */
|
|
658
|
+
originator: "dns:originator.example.org";
|
|
659
|
+
/** 無効な第三者 */
|
|
660
|
+
invalid: "dns:invalid.example.org";
|
|
661
|
+
};
|
|
662
|
+
/** Core Profile */
|
|
663
|
+
declare const cp: CoreProfile;
|
|
664
|
+
/** Certificate */
|
|
665
|
+
declare const certificate: Certificate$1;
|
|
666
|
+
/** Web Media Profile */
|
|
667
|
+
declare const wmp: WebMediaProfile;
|
|
668
|
+
/** Website Profile */
|
|
669
|
+
declare const wsp: WebsiteProfile;
|
|
670
|
+
/** CA ID */
|
|
671
|
+
declare const caId = "urn:uuid:78550fa7-f846-4e0f-ad5c-8d34461cb95b";
|
|
672
|
+
/** CA URL */
|
|
673
|
+
declare const caUrl: URL;
|
|
674
|
+
/** Article CA */
|
|
675
|
+
declare const article: ArticleCA;
|
|
676
|
+
|
|
443
677
|
type OpId = string;
|
|
444
678
|
/**
|
|
445
679
|
* OPS から鍵を取得する
|
|
@@ -460,6 +694,87 @@ type MappedKeys = ReturnType<typeof getMappedKeys>;
|
|
|
460
694
|
declare function getTupledKeys(ops: DecodedOps): [opId: OpId | OpId[], Keys];
|
|
461
695
|
type TupledKeys = ReturnType<typeof getTupledKeys>;
|
|
462
696
|
|
|
697
|
+
/** 収集先を備えたロガー */
|
|
698
|
+
type ProblemCollector = {
|
|
699
|
+
logger: Logger;
|
|
700
|
+
warnings: ProblemDetails[];
|
|
701
|
+
info: ProblemDetails[];
|
|
702
|
+
};
|
|
703
|
+
/**
|
|
704
|
+
* 検証中の通知を収集するロガーを作成する
|
|
705
|
+
*
|
|
706
|
+
* 構造化された `details` を伴わない通知は、メッセージ文字列のみを持つ
|
|
707
|
+
* {@link ProblemDetails} として収集する。
|
|
708
|
+
*
|
|
709
|
+
* @param delegate 収集と併せて通知を委譲する先 (デフォルト: `console`)
|
|
710
|
+
* @returns 収集先を備えたロガー
|
|
711
|
+
*/
|
|
712
|
+
declare function collectProblems(delegate?: Logger): ProblemCollector;
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* JSONPath を組み立てる
|
|
716
|
+
*
|
|
717
|
+
* 文字列は property、数値は index として連結する。
|
|
718
|
+
* @example
|
|
719
|
+
* ```ts
|
|
720
|
+
* pointer("originators", 0, "annotations", 1); // "$.originators[0].annotations[1]"
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
723
|
+
declare const pointer: (...segments: (string | number)[]) => string;
|
|
724
|
+
/**
|
|
725
|
+
* 既存の JSONPath に続けて組み立てる
|
|
726
|
+
* @example
|
|
727
|
+
* ```ts
|
|
728
|
+
* childPointer("$.documents[0]", "cas", 1); // "$.documents[0].cas[1]"
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
declare const childPointer: (base: string, ...segments: (string | number)[]) => string;
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* 問題の種類を識別する URL を組み立てる
|
|
735
|
+
*
|
|
736
|
+
* VC DM 2.0 は {@link ProblemDetails.type} を URL と規定している。検証パッケージの
|
|
737
|
+
* エラーは `code` (`ERR_*`) を持つため、それをエラーリファレンスの URL に対応させる。
|
|
738
|
+
* @param code エラーコードまたは通知の識別子
|
|
739
|
+
*/
|
|
740
|
+
declare const problemType: (code: string) => string;
|
|
741
|
+
/**
|
|
742
|
+
* 検証中の通知の種類
|
|
743
|
+
*
|
|
744
|
+
* 検証失敗を表す種類には各エラークラスの `code` を用いる。ここで定義するのは、
|
|
745
|
+
* 失敗として扱わない通知の種類。
|
|
746
|
+
*/
|
|
747
|
+
declare const ProblemType: {
|
|
748
|
+
/** 非推奨の Certificate を検出した */
|
|
749
|
+
readonly CertificateDeprecated: string;
|
|
750
|
+
/** Content Attestation の allowedOrigin は非推奨 */
|
|
751
|
+
readonly AllowedOriginDeprecated: string;
|
|
752
|
+
/** Content Attestation の VisibleTextTargetIntegrity は非推奨 */
|
|
753
|
+
readonly VisibleTextTargetIntegrityDeprecated: string;
|
|
754
|
+
/** digestSRI が設定されていない */
|
|
755
|
+
readonly DigestSriMissing: string;
|
|
756
|
+
/** digestSRI の検証に失敗した */
|
|
757
|
+
readonly DigestSriInvalid: string;
|
|
758
|
+
/** Profile Annotation Issuer がその認証制度の発行を認可されていない */
|
|
759
|
+
readonly PaIssuerNotRegistered: string;
|
|
760
|
+
/** 種類が特定されていない通知 */
|
|
761
|
+
readonly Unspecified: string;
|
|
762
|
+
};
|
|
763
|
+
type ProblemType = (typeof ProblemType)[keyof typeof ProblemType];
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* エラーを {@link ProblemDetails} に変換する
|
|
767
|
+
*
|
|
768
|
+
* 検証パッケージのエラークラスは `code` (`ERR_*`) を持つため、それを
|
|
769
|
+
* エラーリファレンスの URL に対応させて `type` とする。内側のエラー
|
|
770
|
+
* (JOSE の失敗理由やスキーマ検証の issue) は `detail` に載せる。
|
|
771
|
+
*
|
|
772
|
+
* @param error 変換対象
|
|
773
|
+
* @param at 問題を検出した位置を指す JSONPath
|
|
774
|
+
* @returns 問題の詳細
|
|
775
|
+
*/
|
|
776
|
+
declare function toProblemDetails(error: unknown, at?: string): ProblemDetails;
|
|
777
|
+
|
|
463
778
|
declare class SiteProfileInvalid extends Error {
|
|
464
779
|
result: SpVerificationFailure;
|
|
465
780
|
static get code(): "ERR_SITE_PROFILE_INVALID";
|
|
@@ -497,7 +812,7 @@ declare function SpVerifier(sp: SiteProfile, keys: Keys, issuer: string | string
|
|
|
497
812
|
/** WSPが提示されたWebサイトのorigin引数との一致性検証の可否 (デフォルト: 有効) */
|
|
498
813
|
verifyOrigin?: boolean;
|
|
499
814
|
/** バリデーター */
|
|
500
|
-
validator?:
|
|
815
|
+
validator?: VcValidatorFactory;
|
|
501
816
|
/** ロガー (デフォルト: `console`) */
|
|
502
817
|
logger?: Logger;
|
|
503
818
|
}): () => Promise<SpVerificationResult>;
|
|
@@ -510,5 +825,42 @@ declare function SpVerifier(sp: SiteProfile, keys: Keys, issuer: string | string
|
|
|
510
825
|
*/
|
|
511
826
|
declare function verifyAllowedOrigin(origin: URL["origin"], allowedOrigins: AllowedOrigin): boolean;
|
|
512
827
|
|
|
513
|
-
|
|
514
|
-
|
|
828
|
+
/** Web サイトの検証結果に含まれる復号ペイロード */
|
|
829
|
+
type WebsiteOutcome = {
|
|
830
|
+
/** 発信者ごとの復号ペイロード */
|
|
831
|
+
originators: OriginatorPayload[];
|
|
832
|
+
/** Website Profile の復号ペイロード。復号できなかった要素は null */
|
|
833
|
+
sites: (WebsiteProfile | null)[];
|
|
834
|
+
};
|
|
835
|
+
/**
|
|
836
|
+
* Web サイトの検証
|
|
837
|
+
*
|
|
838
|
+
* サイトが提示する Site Profile とレジストリを用いて、指定した origin の
|
|
839
|
+
* サイトを誰が運営しているものとして確認できるかを検証する。
|
|
840
|
+
*
|
|
841
|
+
* @param origin 検証対象のサイトを識別する RFC 6454 オリジン
|
|
842
|
+
* @param options Site Profile・レジストリ・オリジン検証の可否・バリデーター・ロガー
|
|
843
|
+
* @returns 検証結果。復号できたペイロードは status によらず outcome に含まれる
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```ts
|
|
847
|
+
* const result = await verifyWebsite(location.origin, { siteProfile, registry });
|
|
848
|
+
* result.outcome?.sites; // Website Profile の復号ペイロード
|
|
849
|
+
* if (!result.status) result.errors; // 検証失敗の理由
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
852
|
+
declare function verifyWebsite(origin: URL["origin"], options: {
|
|
853
|
+
/** サイトが提示する Site Profile */
|
|
854
|
+
siteProfile: SiteProfile;
|
|
855
|
+
/** Core Profile 発行者のレジストリ */
|
|
856
|
+
registry: Registry;
|
|
857
|
+
/** WSP が提示された Web サイトの origin との一致性検証の可否 (デフォルト: 有効) */
|
|
858
|
+
verifyOrigin?: boolean;
|
|
859
|
+
/** バリデーター */
|
|
860
|
+
validator?: VcValidatorFactory;
|
|
861
|
+
/** ロガー (デフォルト: `console`) */
|
|
862
|
+
logger?: Logger;
|
|
863
|
+
}): Promise<VerificationResult<WebsiteOutcome>>;
|
|
864
|
+
|
|
865
|
+
export { CaInvalid, CaVerifier, CaVerifyFailed, CasVerifyFailed, CertificateExpired, CoreProfileNotFound, IntegrityFetchFailed, IntegrityVerificationFailed, OpInvalid, OpVerifyFailed, OpsInvalid, OpsVerifier, OpsVerifyFailed, ProblemType, SiteProfileInvalid, SiteProfileVerifyFailed, SpVerifier, TargetIntegrityAlgorithm, VerifyResultFactory, article, caId, caUrl, certificate, childPointer, collectProblems, convertCas, convertOp, convertOps, convertVc, cp, createCollector, decodeOps, getAnnotationPolicy, getMappedKeys, getTupledKeys, isProfileAnnotationIssuerRegistration, normalizeCasItem, opId, patch, pointer, prepareRegistry, problemType, toProblemDetails, verifyAllowedOrigin, verifyAnnotationIssuerRegistration, verifyCas, verifyDigestSri, verifyDocuments, verifyImageDigestSri, verifyIntegrity, verifyWebsite, wmp, wsp };
|
|
866
|
+
export type { CaDecodingFailure, CaDecodingResult, CaVerificationFailure, CaVerificationResult, CasItem, CasPayload, CasVerificationFailure, CasVerificationResult, Certificate, Collector, DecodedCa, DecodedOp, DecodedOps, DocumentOutcome, DocumentsOutcome, FetchIntegrityResult, IntegrityVerifyResult, Logger, MappedKeys, OpDecodingFailure, OpDecodingResult, OpVerificationFailure, OpVerificationResult, OpsDecodingFailure, OpsDecodingResult, OpsVerificationFailure, OpsVerificationResult, OriginatorPayload, ProblemCollector, ProblemDetails, Registry, SecuringResult, SpVerificationFailure, SpVerificationResult, TupledKeys, VerificationResult, VerificationTarget, VerifiedCa, VerifiedCas, VerifiedOp, VerifiedOps, VerifiedSp, VerifyIntegrity, WebsiteOutcome };
|