@originator-profile/verify 0.7.0-beta.2 → 0.7.0-beta.4
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 +19 -21
- package/dist/index.js +32 -28
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -40,13 +40,13 @@ declare class CaVerifyFailed extends Error {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
43
|
+
* 検証中のメッセージを受け取るロガー
|
|
44
|
+
* - `warn`: 警告
|
|
45
|
+
* 主に互換性 (非推奨 Certificate や digestSRI の欠落・不一致など) の通知に使用
|
|
46
|
+
* - `info`: システムの正常な動作記録
|
|
47
|
+
* (Profile Annotation Issuer 登録証 PA 未保有など、無効性を意味しない状態) の通知に使用する。
|
|
48
48
|
*/
|
|
49
|
-
type
|
|
49
|
+
type Logger = Pick<Console, "warn" | "info">;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* `digestSRI` の検証
|
|
@@ -69,8 +69,8 @@ declare function verifyDigestSri(content: DigestSriResult, fetcher?: typeof fetc
|
|
|
69
69
|
declare function verifyImageDigestSri(value: Image | undefined, options?: {
|
|
70
70
|
/** コンテンツの取得に用いる fetch 実装 */
|
|
71
71
|
fetcher?: typeof fetch;
|
|
72
|
-
/**
|
|
73
|
-
|
|
72
|
+
/** ロガー (デフォルト: `console`) */
|
|
73
|
+
logger?: Logger;
|
|
74
74
|
}): Promise<void>;
|
|
75
75
|
|
|
76
76
|
declare class IntegrityFetchFailed extends Error {
|
|
@@ -415,31 +415,29 @@ declare function isProfileAnnotationIssuerRegistration(doc: Certificate): doc is
|
|
|
415
415
|
/**
|
|
416
416
|
* Profile Annotation Issuer 登録証 PA に基づく発行者の認可を確認
|
|
417
417
|
*
|
|
418
|
-
* 各 Profile Annotation
|
|
419
|
-
*
|
|
420
|
-
* (2027年まで) 後方互換性のため、認可を確認できない場合も検証は失敗させず warn に留める。
|
|
418
|
+
* 各 Profile Annotation の発行者が、基底となる Profile Annotation Issuer 登録証 PA によって、その PA が準拠する 認証制度(Profile Annotation Policy)の発行を認可されているかを検証
|
|
421
419
|
*
|
|
422
420
|
* @param verifiedOps 検証済み Originator Profile Set
|
|
423
|
-
* @param
|
|
424
|
-
* @param
|
|
421
|
+
* @param paIssuerRegistrationIssuer 基底となる Profile Annotation Issuer 登録証 PA Issuer の OP ID
|
|
422
|
+
* @param logger ロガー (デフォルト: `console`)
|
|
425
423
|
*
|
|
426
424
|
* @see https://docs.originator-profile.org/opb/pa-model/profile-annotation-issuer-registration/
|
|
427
425
|
*/
|
|
428
|
-
declare function verifyAnnotationIssuerRegistration(verifiedOps: VerifiedOps,
|
|
426
|
+
declare function verifyAnnotationIssuerRegistration(verifiedOps: VerifiedOps, paIssuerRegistrationIssuer: string | string[], logger?: Logger): VerifiedOps;
|
|
429
427
|
|
|
430
428
|
/**
|
|
431
429
|
* Originator Profile Set の検証者の作成
|
|
432
430
|
* @param ops Originator Profile Set
|
|
433
431
|
* @param keys Core Profile の発行者の検証鍵
|
|
434
432
|
* @param issuer Core Profile の発行者
|
|
435
|
-
* @param options
|
|
433
|
+
* @param options バリデーターとロガー
|
|
436
434
|
* @returns 検証者
|
|
437
435
|
*/
|
|
438
436
|
declare function OpsVerifier(ops: OriginatorProfileSet, keys: Keys, issuer: string | string[], options?: {
|
|
439
437
|
/** バリデーター */
|
|
440
438
|
validator?: typeof VcValidator;
|
|
441
|
-
/**
|
|
442
|
-
|
|
439
|
+
/** ロガー (デフォルト: `console`) */
|
|
440
|
+
logger?: Logger;
|
|
443
441
|
}): () => Promise<OpsVerificationResult>;
|
|
444
442
|
|
|
445
443
|
type OpId = string;
|
|
@@ -492,7 +490,7 @@ type SpVerificationResult = VerifiedSp | SiteProfileInvalid | SiteProfileVerifyF
|
|
|
492
490
|
* @param keys Core Profile の発行者の検証鍵
|
|
493
491
|
* @param issuer Core Profile の発行者
|
|
494
492
|
* @param origin 提示するWebサイトを識別するための RFC 6454 オリジン
|
|
495
|
-
* @param options
|
|
493
|
+
* @param options オリジン検証の可否・バリデーター・ロガー
|
|
496
494
|
* @returns 検証者
|
|
497
495
|
*/
|
|
498
496
|
declare function SpVerifier(sp: SiteProfile, keys: Keys, issuer: string | string[], origin: URL["origin"], options?: {
|
|
@@ -500,8 +498,8 @@ declare function SpVerifier(sp: SiteProfile, keys: Keys, issuer: string | string
|
|
|
500
498
|
verifyOrigin?: boolean;
|
|
501
499
|
/** バリデーター */
|
|
502
500
|
validator?: typeof VcValidator;
|
|
503
|
-
/**
|
|
504
|
-
|
|
501
|
+
/** ロガー (デフォルト: `console`) */
|
|
502
|
+
logger?: Logger;
|
|
505
503
|
}): () => Promise<SpVerificationResult>;
|
|
506
504
|
|
|
507
505
|
/**
|
|
@@ -513,4 +511,4 @@ declare function SpVerifier(sp: SiteProfile, keys: Keys, issuer: string | string
|
|
|
513
511
|
declare function verifyAllowedOrigin(origin: URL["origin"], allowedOrigins: AllowedOrigin): boolean;
|
|
514
512
|
|
|
515
513
|
export { CaInvalid, CaVerifier, CaVerifyFailed, CasVerifyFailed, CertificateExpired, CoreProfileNotFound, IntegrityFetchFailed, IntegrityVerificationFailed, OpInvalid, OpVerifyFailed, OpsInvalid, OpsVerifier, OpsVerifyFailed, SiteProfileInvalid, SiteProfileVerifyFailed, SpVerifier, TargetIntegrityAlgorithm, VerifyResultFactory, article, caId, caUrl, certificate, cp, decodeOps, getAnnotationPolicy, getMappedKeys, getTupledKeys, isProfileAnnotationIssuerRegistration, normalizeCasItem, opId, patch, verifyAllowedOrigin, verifyAnnotationIssuerRegistration, verifyCas, verifyDigestSri, verifyImageDigestSri, verifyIntegrity, wmp, wsp };
|
|
516
|
-
export type { CaDecodingFailure, CaDecodingResult, CaVerificationFailure, CaVerificationResult, CasItem, CasVerificationFailure, CasVerificationResult, Certificate, DecodedCa, DecodedOp, DecodedOps, FetchIntegrityResult, IntegrityVerifyResult, MappedKeys, OpDecodingFailure, OpDecodingResult, OpVerificationFailure, OpVerificationResult, OpsDecodingFailure, OpsDecodingResult, OpsVerificationFailure, OpsVerificationResult, SpVerificationFailure, SpVerificationResult, TupledKeys, VerifiedCa, VerifiedCas, VerifiedOp, VerifiedOps, VerifiedSp, VerifyIntegrity
|
|
514
|
+
export type { CaDecodingFailure, CaDecodingResult, CaVerificationFailure, CaVerificationResult, CasItem, CasVerificationFailure, CasVerificationResult, Certificate, DecodedCa, DecodedOp, DecodedOps, FetchIntegrityResult, IntegrityVerifyResult, Logger, MappedKeys, OpDecodingFailure, OpDecodingResult, OpVerificationFailure, OpVerificationResult, OpsDecodingFailure, OpsDecodingResult, OpsVerificationFailure, OpsVerificationResult, SpVerificationFailure, SpVerificationResult, TupledKeys, VerifiedCa, VerifiedCas, VerifiedOp, VerifiedOps, VerifiedSp, VerifyIntegrity };
|
package/dist/index.js
CHANGED
|
@@ -316,10 +316,10 @@ async function verifyDigestSri(content, fetcher = fetch) {
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
async function verifyImageDigestSri(value, options = {}) {
|
|
319
|
-
const { fetcher = fetch,
|
|
319
|
+
const { fetcher = fetch, logger = console } = options;
|
|
320
320
|
if (!value) return;
|
|
321
321
|
if (!value.digestSRI) {
|
|
322
|
-
warn(`digestSRI is missing. ${WARN_SUFFIX}`);
|
|
322
|
+
logger.warn(`digestSRI is missing. ${WARN_SUFFIX}`);
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
325
|
const valid = await verifyDigestSri(
|
|
@@ -327,7 +327,7 @@ async function verifyImageDigestSri(value, options = {}) {
|
|
|
327
327
|
fetcher
|
|
328
328
|
);
|
|
329
329
|
if (!valid) {
|
|
330
|
-
warn(`digestSRI verification failed. ${WARN_SUFFIX}`);
|
|
330
|
+
logger.warn(`digestSRI verification failed. ${WARN_SUFFIX}`);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
@@ -1006,12 +1006,12 @@ const isProfileAnnotation = (doc) => doc.type.includes("ProfileAnnotation");
|
|
|
1006
1006
|
function isProfileAnnotationIssuerRegistration(doc) {
|
|
1007
1007
|
return doc.credentialSubject.type === "ProfileAnnotationIssuerRegistration";
|
|
1008
1008
|
}
|
|
1009
|
-
function buildProfileAnnotationPolicy(verifiedOps,
|
|
1009
|
+
function buildProfileAnnotationPolicy(verifiedOps, paIssuerRegistrationIssuers) {
|
|
1010
1010
|
const policy = /* @__PURE__ */ new Map();
|
|
1011
1011
|
const annotations = verifiedOps.flatMap((op) => op.annotations ?? []);
|
|
1012
1012
|
for (const { doc } of annotations) {
|
|
1013
1013
|
if (!isProfileAnnotationIssuerRegistration(doc)) continue;
|
|
1014
|
-
if (!
|
|
1014
|
+
if (!paIssuerRegistrationIssuers.has(doc.issuer)) continue;
|
|
1015
1015
|
const { id: registrationIssuer, annotationScheme } = doc.credentialSubject;
|
|
1016
1016
|
const allowedPolicy = policy.get(registrationIssuer) ?? /* @__PURE__ */ new Set();
|
|
1017
1017
|
for (const scheme of annotationScheme) allowedPolicy.add(scheme);
|
|
@@ -1024,30 +1024,31 @@ function reportUnauthorizedAnnotation({
|
|
|
1024
1024
|
opIndex,
|
|
1025
1025
|
paIndex,
|
|
1026
1026
|
policy,
|
|
1027
|
-
|
|
1028
|
-
warn
|
|
1027
|
+
logger
|
|
1029
1028
|
}) {
|
|
1030
1029
|
const { doc } = annotation;
|
|
1031
1030
|
const { issuer: profileAnnotationIssuer } = doc;
|
|
1032
1031
|
const location = `OP[${opIndex}].PA[${paIndex}]`;
|
|
1033
1032
|
if (!isProfileAnnotation(doc)) {
|
|
1034
|
-
warn(`Certificate is deprecated (${location})`);
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
1037
|
-
if (isProfileAnnotationIssuerRegistration(doc) && cpIssuers.has(profileAnnotationIssuer)) {
|
|
1033
|
+
logger.warn(`Certificate is deprecated (${location})`);
|
|
1038
1034
|
return;
|
|
1039
1035
|
}
|
|
1040
1036
|
const policyId = getAnnotationPolicy(doc)?.id;
|
|
1041
1037
|
const isAllowed = policyId && policy.get(profileAnnotationIssuer)?.has(policyId);
|
|
1042
1038
|
if (!isAllowed) {
|
|
1043
|
-
|
|
1039
|
+
logger.info(
|
|
1044
1040
|
`Profile Annotation Issuer is not registered for this annotation scheme (${location} issuer: ${profileAnnotationIssuer}, scheme: ${policyId ?? "unknown"})`
|
|
1045
1041
|
);
|
|
1046
1042
|
}
|
|
1047
1043
|
}
|
|
1048
|
-
function verifyAnnotationIssuerRegistration(verifiedOps,
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1044
|
+
function verifyAnnotationIssuerRegistration(verifiedOps, paIssuerRegistrationIssuer, logger = console) {
|
|
1045
|
+
const paIssuerRegistrationIssuers = new Set(
|
|
1046
|
+
[paIssuerRegistrationIssuer].flat()
|
|
1047
|
+
);
|
|
1048
|
+
const policy = buildProfileAnnotationPolicy(
|
|
1049
|
+
verifiedOps,
|
|
1050
|
+
paIssuerRegistrationIssuers
|
|
1051
|
+
);
|
|
1051
1052
|
for (const [opIndex, op] of verifiedOps.entries()) {
|
|
1052
1053
|
for (const [paIndex, annotation] of op.annotations?.entries() ?? []) {
|
|
1053
1054
|
reportUnauthorizedAnnotation({
|
|
@@ -1055,8 +1056,7 @@ function verifyAnnotationIssuerRegistration(verifiedOps, cpIssuer, warn = consol
|
|
|
1055
1056
|
opIndex,
|
|
1056
1057
|
paIndex,
|
|
1057
1058
|
policy,
|
|
1058
|
-
|
|
1059
|
-
warn
|
|
1059
|
+
logger
|
|
1060
1060
|
});
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
@@ -1086,7 +1086,7 @@ function validateCertificateExpiry(verifiedVc) {
|
|
|
1086
1086
|
return verifiedVc;
|
|
1087
1087
|
}
|
|
1088
1088
|
async function verifyAnnotations(paIssuerKeys, annotations, options = {}) {
|
|
1089
|
-
const { validator,
|
|
1089
|
+
const { validator, logger = console } = options;
|
|
1090
1090
|
if (!annotations) return;
|
|
1091
1091
|
return await Promise.all(
|
|
1092
1092
|
annotations.map(async (annotation) => {
|
|
@@ -1112,14 +1112,16 @@ async function verifyAnnotations(paIssuerKeys, annotations, options = {}) {
|
|
|
1112
1112
|
if (valid instanceof CertificateExpired) {
|
|
1113
1113
|
return valid;
|
|
1114
1114
|
}
|
|
1115
|
-
await verifyImageDigestSri(valid.doc.credentialSubject.image, {
|
|
1115
|
+
await verifyImageDigestSri(valid.doc.credentialSubject.image, {
|
|
1116
|
+
logger
|
|
1117
|
+
});
|
|
1116
1118
|
return valid;
|
|
1117
1119
|
})
|
|
1118
1120
|
);
|
|
1119
1121
|
}
|
|
1120
1122
|
|
|
1121
1123
|
async function verifyMedia(wmpIssuerKeys, media, options = {}) {
|
|
1122
|
-
const { validator,
|
|
1124
|
+
const { validator, logger = console } = options;
|
|
1123
1125
|
if (!media) return;
|
|
1124
1126
|
return await Promise.all(
|
|
1125
1127
|
media.map(async (m) => {
|
|
@@ -1132,7 +1134,9 @@ async function verifyMedia(wmpIssuerKeys, media, options = {}) {
|
|
|
1132
1134
|
if (result instanceof Error) {
|
|
1133
1135
|
return result;
|
|
1134
1136
|
}
|
|
1135
|
-
await verifyImageDigestSri(result.doc.credentialSubject.logo, {
|
|
1137
|
+
await verifyImageDigestSri(result.doc.credentialSubject.logo, {
|
|
1138
|
+
logger
|
|
1139
|
+
});
|
|
1136
1140
|
return result;
|
|
1137
1141
|
})
|
|
1138
1142
|
);
|
|
@@ -1149,7 +1153,7 @@ function generateErrorDetails(items, opIndex, prefix, sources) {
|
|
|
1149
1153
|
}
|
|
1150
1154
|
const isVerifiedOps = (ops) => ops.every((op) => !(op instanceof OpVerifyFailed));
|
|
1151
1155
|
function OpsVerifier(ops, keys, issuer, options = {}) {
|
|
1152
|
-
const { validator,
|
|
1156
|
+
const { validator, logger = console } = options;
|
|
1153
1157
|
const decoded = decodeOps(ops);
|
|
1154
1158
|
const verifyCp = JwtVcVerifier(
|
|
1155
1159
|
keys,
|
|
@@ -1167,11 +1171,11 @@ function OpsVerifier(ops, keys, issuer, options = {}) {
|
|
|
1167
1171
|
const annotations = await verifyAnnotations(
|
|
1168
1172
|
paOrWmpIssuerKeys,
|
|
1169
1173
|
op.annotations,
|
|
1170
|
-
{ validator,
|
|
1174
|
+
{ validator, logger }
|
|
1171
1175
|
);
|
|
1172
1176
|
const media = await verifyMedia(paOrWmpIssuerKeys, op.media, {
|
|
1173
1177
|
validator,
|
|
1174
|
-
|
|
1178
|
+
logger
|
|
1175
1179
|
});
|
|
1176
1180
|
const resultOp = { core, annotations, media };
|
|
1177
1181
|
if (core instanceof Error) {
|
|
@@ -1207,7 +1211,7 @@ function OpsVerifier(ops, keys, issuer, options = {}) {
|
|
|
1207
1211
|
const msg = verifyFailedIndexes.length > 0 ? `Originator Profile Set verify failed (${verifyFailedIndexes.map((i) => `OP[${i}]`).join(", ")})` : "Originator Profile Set verify failed";
|
|
1208
1212
|
return new OpsVerifyFailed(msg, resultOps);
|
|
1209
1213
|
}
|
|
1210
|
-
return verifyAnnotationIssuerRegistration(resultOps, issuer,
|
|
1214
|
+
return verifyAnnotationIssuerRegistration(resultOps, issuer, logger);
|
|
1211
1215
|
}
|
|
1212
1216
|
return verify;
|
|
1213
1217
|
}
|
|
@@ -1256,11 +1260,11 @@ const decodeWebsiteProfiles = (sp, opsVerified) => {
|
|
|
1256
1260
|
};
|
|
1257
1261
|
};
|
|
1258
1262
|
function SpVerifier(sp, keys, issuer, origin, options = {}) {
|
|
1259
|
-
const { verifyOrigin = true, validator,
|
|
1263
|
+
const { verifyOrigin = true, validator, logger = console } = options;
|
|
1260
1264
|
async function verify() {
|
|
1261
1265
|
const verifyOps = OpsVerifier(sp.originators, keys, issuer, {
|
|
1262
1266
|
validator,
|
|
1263
|
-
|
|
1267
|
+
logger
|
|
1264
1268
|
});
|
|
1265
1269
|
const opsVerified = await verifyOps();
|
|
1266
1270
|
if (opsVerified instanceof OpsInvalid) {
|
|
@@ -1311,7 +1315,7 @@ function SpVerifier(sp, keys, issuer, origin, options = {}) {
|
|
|
1311
1315
|
}
|
|
1312
1316
|
}
|
|
1313
1317
|
await verifyImageDigestSri(verified.doc.credentialSubject.image, {
|
|
1314
|
-
|
|
1318
|
+
logger
|
|
1315
1319
|
});
|
|
1316
1320
|
return verified;
|
|
1317
1321
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@originator-profile/verify",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://docs.originator-profile.org",
|
|
6
6
|
"repository": {
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"jose": "^6.2.2",
|
|
28
28
|
"jsonld": "^9.0.0",
|
|
29
29
|
"zod": "^4.3.6",
|
|
30
|
-
"@originator-profile/
|
|
31
|
-
"@originator-profile/securing-mechanism": "0.7.0-beta.
|
|
32
|
-
"@originator-profile/
|
|
33
|
-
"@originator-profile/sign": "0.7.0-beta.
|
|
34
|
-
"@originator-profile/model": "0.7.0-beta.
|
|
30
|
+
"@originator-profile/cryptography": "0.7.0-beta.4",
|
|
31
|
+
"@originator-profile/securing-mechanism": "0.7.0-beta.4",
|
|
32
|
+
"@originator-profile/core": "0.7.0-beta.4",
|
|
33
|
+
"@originator-profile/sign": "0.7.0-beta.4",
|
|
34
|
+
"@originator-profile/model": "0.7.0-beta.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@playwright/test": "1.59.1",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vite": "8.0.16",
|
|
49
49
|
"vitest": "4.1.4",
|
|
50
50
|
"websri": "1.0.1",
|
|
51
|
-
"@originator-profile/tsconfig": "0.7.0-beta.
|
|
51
|
+
"@originator-profile/tsconfig": "0.7.0-beta.4"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "pkgroll --clean-dist",
|