@kya-brasil/core 0.7.0 → 0.7.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/dist/icp-brasil.js +9 -0
- package/package.json +1 -1
package/dist/icp-brasil.js
CHANGED
|
@@ -87,6 +87,15 @@ export async function verifyIcpSignature(p) {
|
|
|
87
87
|
throw new KyaError("CERTIFICATE_INVALID", "CMS carries no signer certificate");
|
|
88
88
|
const trusted = p.anchors.map((a) => pkijs.Certificate.fromBER(unb64(a.replace(/-----[^-]+-----/g, ""))));
|
|
89
89
|
const data = new TextEncoder().encode(p.challenge);
|
|
90
|
+
// An attached CMS (the .p7s carries the signed text) is verified over its own content by pkijs, whatever
|
|
91
|
+
// `data` says: it MUST carry exactly the challenge, or any document the company ever signed would pass.
|
|
92
|
+
const embedded = signed.encapContentInfo.eContent;
|
|
93
|
+
if (embedded) {
|
|
94
|
+
const content = new Uint8Array(embedded.getValue());
|
|
95
|
+
if (content.length !== data.length || !content.every((b, i) => b === data[i])) {
|
|
96
|
+
throw new KyaError("CHALLENGE_FAILED", "the signed content is not the challenge text (sign exactly the challenge, without extra line breaks)");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
90
99
|
let ok = false;
|
|
91
100
|
try {
|
|
92
101
|
ok = await signed.verify({ signer: 0, data: data.buffer, trustedCerts: trusted, checkChain: false, checkDate: now });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-brasil/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "KYA Brasil as a library: verify and issue know-your-agent credentials for Brazilian companies without any hosted service. e-CNPJ (ICP-Brasil) CMS signature and chain validation, CRL revocation, CNPJ, agent key challenges (EVM, Ed25519 / Web Bot Auth, ERC-8004), mandate schema and evaluation (including payment instruments for card networks and acquirers), credential build, Ed25519 signing and verification. Pure functions: storage and network are yours.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|