@originator-profile/verify 0.6.0-beta.1 → 0.6.0-beta.2
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 +27 -0
- package/dist/index.d.ts +20 -2
- package/dist/index.js +64 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
1
|
# Profile Verify
|
|
2
2
|
|
|
3
3
|
署名を検証するためのパッケージです。
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore-start -->
|
|
6
|
+
<!-- environments-start -->
|
|
7
|
+
|
|
8
|
+
<!-- NOTE: Auto-generated by ../../scripts/update-readme-environments.ts from package.json, .github/workflows/test.yml, Dockerfile, and manifest.json. Edit the source, not this section. -->
|
|
9
|
+
|
|
10
|
+
## Environment
|
|
11
|
+
|
|
12
|
+
### Verified
|
|
13
|
+
|
|
14
|
+
- OS: Ubuntu 24.04
|
|
15
|
+
|
|
16
|
+
### Development
|
|
17
|
+
|
|
18
|
+
- Node.js: `^22.18.0 || ^24.10.0 || ^26.2.0`
|
|
19
|
+
- pnpm: `11.0.9`
|
|
20
|
+
|
|
21
|
+
<!-- environments-stop -->
|
|
22
|
+
<!-- prettier-ignore-end -->
|
|
23
|
+
|
|
24
|
+
### Verified
|
|
25
|
+
|
|
26
|
+
- Browser: Modern browsers with Web Crypto API (bundled in OP Inspector)
|
|
27
|
+
|
|
28
|
+
### Incompatible
|
|
29
|
+
|
|
30
|
+
- Environments without Web Crypto API: Requires Web Crypto API (SubtleCrypto).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentAttestation, Image, Target, ContentAttestationSet, OpVc, Jwk, ArticleCA, Certificate as Certificate$1, CoreProfile, WebMediaProfile, WebsiteProfile, JapaneseExistenceCertificate, ProfileAnnotation, JapaneseExistencePA, ProfileAnnotationIssuerRegistration, OriginatorProfileSet, Jwks, SiteProfile, AllowedOrigin } from '@originator-profile/model';
|
|
1
|
+
import { ContentAttestation, Image, Target, ContentAttestationSet, OpVc, Jwk, ArticleCA, Certificate as Certificate$1, CoreProfile, WebMediaProfile, WebsiteProfile, JapaneseExistenceCertificate, ProfileAnnotation, JapaneseExistencePA, ProfileAnnotationIssuerRegistration, OriginatorProfileSet, ProfileAnnotationPolicy, CertificationSystem, Jwks, SiteProfile, AllowedOrigin } from '@originator-profile/model';
|
|
2
2
|
import { JwtVcDecodingResult, UnverifiedJwtVc, JwtVcVerificationResult, VerifiedJwtVc, VcValidator } from '@originator-profile/securing-mechanism';
|
|
3
3
|
import { Keys } from '@originator-profile/cryptography';
|
|
4
4
|
import { DigestSriResult, ContentFetcher, ElementSelector } from '@originator-profile/sign';
|
|
@@ -394,6 +394,24 @@ type OpsVerificationResult = VerifiedOps | OpsInvalid | OpsVerifyFailed;
|
|
|
394
394
|
*/
|
|
395
395
|
declare function decodeOps(ops: OriginatorProfileSet): OpsDecodingResult;
|
|
396
396
|
|
|
397
|
+
/** 新形式 PA の `credentialSubject.annotation` と旧 Certificate 形式の `credentialSubject.certificationSystem` 存在するほうを返す */
|
|
398
|
+
declare function getAnnotationPolicy(doc: Certificate): ProfileAnnotationPolicy | CertificationSystem;
|
|
399
|
+
/** Profile Annotation Issuer 登録証 PA かどうか */
|
|
400
|
+
declare function isProfileAnnotationIssuerRegistration(doc: Certificate): doc is ProfileAnnotationIssuerRegistration;
|
|
401
|
+
/**
|
|
402
|
+
* Profile Annotation Issuer 登録証 PA に基づく発行者の認可を確認
|
|
403
|
+
*
|
|
404
|
+
* 各 Profile Annotation の発行者が、Core Profile Issuer から発行された登録証 PA によって、その PA が準拠する 認証制度(Profile Annotation Policy)の発行を認可されているかを検証
|
|
405
|
+
*
|
|
406
|
+
* (2027年まで) 後方互換性のため、認可を確認できない場合も検証は失敗させず console.warn に留める。
|
|
407
|
+
*
|
|
408
|
+
* @param verifiedOps 検証済み Originator Profile Set
|
|
409
|
+
* @param cpIssuer 基底となる Core Profile Issuer の OP ID
|
|
410
|
+
*
|
|
411
|
+
* @see https://docs.originator-profile.org/opb/pa-model/profile-annotation-issuer-registration/
|
|
412
|
+
*/
|
|
413
|
+
declare function verifyAnnotationIssuerRegistration(verifiedOps: VerifiedOps, cpIssuer: string | string[]): VerifiedOps;
|
|
414
|
+
|
|
397
415
|
/**
|
|
398
416
|
* Originator Profile Set の検証者の作成
|
|
399
417
|
* @param ops Originator Profile Set
|
|
@@ -468,5 +486,5 @@ declare function SpVerifier(sp: SiteProfile, keys: Keys, issuer: string | string
|
|
|
468
486
|
*/
|
|
469
487
|
declare function verifyAllowedOrigin(origin: URL["origin"], allowedOrigins: AllowedOrigin): boolean;
|
|
470
488
|
|
|
471
|
-
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, getMappedKeys, getTupledKeys, normalizeCasItem, opId, patch, verifyAllowedOrigin, verifyCas, verifyDigestSri, verifyImageDigestSri, verifyIntegrity, wmp, wsp };
|
|
489
|
+
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 };
|
|
472
490
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -998,6 +998,68 @@ function decodeOps(ops) {
|
|
|
998
998
|
return resultOps;
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
+
function getAnnotationPolicy(doc) {
|
|
1002
|
+
return "annotation" in doc.credentialSubject ? doc.credentialSubject.annotation : doc.credentialSubject.certificationSystem;
|
|
1003
|
+
}
|
|
1004
|
+
const isProfileAnnotation = (doc) => doc.type.includes("ProfileAnnotation");
|
|
1005
|
+
function isProfileAnnotationIssuerRegistration(doc) {
|
|
1006
|
+
return doc.credentialSubject.type === "ProfileAnnotationIssuerRegistration";
|
|
1007
|
+
}
|
|
1008
|
+
function buildProfileAnnotationPolicy(verifiedOps, cpIssuers) {
|
|
1009
|
+
const policy = /* @__PURE__ */ new Map();
|
|
1010
|
+
const annotations = verifiedOps.flatMap((op) => op.annotations ?? []);
|
|
1011
|
+
for (const { doc } of annotations) {
|
|
1012
|
+
if (!isProfileAnnotationIssuerRegistration(doc)) continue;
|
|
1013
|
+
if (!cpIssuers.has(doc.issuer)) continue;
|
|
1014
|
+
const { id: registrationIssuer, annotationScheme } = doc.credentialSubject;
|
|
1015
|
+
const allowedPolicy = policy.get(registrationIssuer) ?? /* @__PURE__ */ new Set();
|
|
1016
|
+
for (const scheme of annotationScheme) allowedPolicy.add(scheme);
|
|
1017
|
+
policy.set(registrationIssuer, allowedPolicy);
|
|
1018
|
+
}
|
|
1019
|
+
return policy;
|
|
1020
|
+
}
|
|
1021
|
+
function reportUnauthorizedAnnotation({
|
|
1022
|
+
annotation,
|
|
1023
|
+
opIndex,
|
|
1024
|
+
paIndex,
|
|
1025
|
+
policy,
|
|
1026
|
+
cpIssuers
|
|
1027
|
+
}) {
|
|
1028
|
+
const { doc } = annotation;
|
|
1029
|
+
const { issuer: profileAnnotationIssuer } = doc;
|
|
1030
|
+
const location = `OP[${opIndex}].PA[${paIndex}]`;
|
|
1031
|
+
if (!isProfileAnnotation(doc)) {
|
|
1032
|
+
console.warn(`Certificate is deprecated (${location})`);
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
if (isProfileAnnotationIssuerRegistration(doc) && cpIssuers.has(profileAnnotationIssuer)) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
const policyId = getAnnotationPolicy(doc)?.id;
|
|
1039
|
+
const isAllowed = policyId && policy.get(profileAnnotationIssuer)?.has(policyId);
|
|
1040
|
+
if (!isAllowed) {
|
|
1041
|
+
console.warn(
|
|
1042
|
+
`Profile Annotation Issuer is not registered for this annotation scheme (${location} issuer: ${profileAnnotationIssuer}, scheme: ${policyId ?? "unknown"})`
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
function verifyAnnotationIssuerRegistration(verifiedOps, cpIssuer) {
|
|
1047
|
+
const cpIssuers = new Set([cpIssuer].flat());
|
|
1048
|
+
const policy = buildProfileAnnotationPolicy(verifiedOps, cpIssuers);
|
|
1049
|
+
for (const [opIndex, op] of verifiedOps.entries()) {
|
|
1050
|
+
for (const [paIndex, annotation] of op.annotations?.entries() ?? []) {
|
|
1051
|
+
reportUnauthorizedAnnotation({
|
|
1052
|
+
annotation,
|
|
1053
|
+
opIndex,
|
|
1054
|
+
paIndex,
|
|
1055
|
+
policy,
|
|
1056
|
+
cpIssuers
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
return verifiedOps;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1001
1063
|
function OpVerifier(paOrWmpIssuerKeys, vc, validator) {
|
|
1002
1064
|
const issuer = vc.doc.issuer;
|
|
1003
1065
|
const jwks = paOrWmpIssuerKeys[issuer];
|
|
@@ -1136,7 +1198,7 @@ function OpsVerifier(ops, keys, issuer, validator) {
|
|
|
1136
1198
|
const msg = verifyFailedIndexes.length > 0 ? `Originator Profile Set verify failed (${verifyFailedIndexes.map((i) => `OP[${i}]`).join(", ")})` : "Originator Profile Set verify failed";
|
|
1137
1199
|
return new OpsVerifyFailed(msg, resultOps);
|
|
1138
1200
|
}
|
|
1139
|
-
return resultOps;
|
|
1201
|
+
return verifyAnnotationIssuerRegistration(resultOps, issuer);
|
|
1140
1202
|
}
|
|
1141
1203
|
return verify;
|
|
1142
1204
|
}
|
|
@@ -1263,4 +1325,4 @@ function SpVerifier(sp, keys, issuer, origin, verifyOrigin = true, validator) {
|
|
|
1263
1325
|
return verify;
|
|
1264
1326
|
}
|
|
1265
1327
|
|
|
1266
|
-
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, getMappedKeys, getTupledKeys, normalizeCasItem, opId, patch, verifyAllowedOrigin, verifyCas, verifyDigestSri, verifyImageDigestSri, verifyIntegrity, wmp, wsp };
|
|
1328
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@originator-profile/verify",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.2",
|
|
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/core": "0.6.0-beta.
|
|
31
|
-
"@originator-profile/
|
|
32
|
-
"@originator-profile/
|
|
33
|
-
"@originator-profile/
|
|
34
|
-
"@originator-profile/
|
|
30
|
+
"@originator-profile/core": "0.6.0-beta.2",
|
|
31
|
+
"@originator-profile/cryptography": "0.6.0-beta.2",
|
|
32
|
+
"@originator-profile/model": "0.6.0-beta.2",
|
|
33
|
+
"@originator-profile/sign": "0.6.0-beta.2",
|
|
34
|
+
"@originator-profile/securing-mechanism": "0.6.0-beta.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@playwright/test": "1.59.1",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"vite": "8.0.8",
|
|
48
48
|
"vitest": "4.1.4",
|
|
49
49
|
"websri": "1.0.1",
|
|
50
|
-
"@originator-profile/tsconfig": "0.6.0-beta.
|
|
51
|
-
"eslint-config-originator-profile": "0.6.0-beta.
|
|
50
|
+
"@originator-profile/tsconfig": "0.6.0-beta.2",
|
|
51
|
+
"eslint-config-originator-profile": "0.6.0-beta.2"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "pkgroll --clean-dist",
|