@vanaheimr/cose 0.9.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/CHANGELOG.md +81 -0
- package/LICENSE.md +201 -0
- package/NOTICE +31 -0
- package/README.md +537 -0
- package/dist/aes.d.ts +45 -0
- package/dist/aes.d.ts.map +1 -0
- package/dist/algorithm.d.ts +137 -0
- package/dist/algorithm.d.ts.map +1 -0
- package/dist/asn1.d.ts +114 -0
- package/dist/asn1.d.ts.map +1 -0
- package/dist/cbor.d.ts +65 -0
- package/dist/cbor.d.ts.map +1 -0
- package/dist/curve.d.ts +65 -0
- package/dist/curve.d.ts.map +1 -0
- package/dist/ecdsa.d.ts +56 -0
- package/dist/ecdsa.d.ts.map +1 -0
- package/dist/eddsa.d.ts +14 -0
- package/dist/eddsa.d.ts.map +1 -0
- package/dist/encrypt.d.ts +140 -0
- package/dist/encrypt.d.ts.map +1 -0
- package/dist/errors.d.ts +64 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/headers.d.ts +77 -0
- package/dist/headers.d.ts.map +1 -0
- package/dist/hmac.d.ts +32 -0
- package/dist/hmac.d.ts.map +1 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4159 -0
- package/dist/index.js.map +1 -0
- package/dist/key.d.ts +201 -0
- package/dist/key.d.ts.map +1 -0
- package/dist/labels.d.ts +51 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/mac.d.ts +93 -0
- package/dist/mac.d.ts.map +1 -0
- package/dist/mac0.d.ts +132 -0
- package/dist/mac0.d.ts.map +1 -0
- package/dist/mldsa.d.ts +29 -0
- package/dist/mldsa.d.ts.map +1 -0
- package/dist/payload.d.ts +25 -0
- package/dist/payload.d.ts.map +1 -0
- package/dist/recipient.d.ts +65 -0
- package/dist/recipient.d.ts.map +1 -0
- package/dist/resolve.d.ts +29 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/sign.d.ts +82 -0
- package/dist/sign.d.ts.map +1 -0
- package/dist/sign1.d.ts +273 -0
- package/dist/sign1.d.ts.map +1 -0
- package/dist/signature.d.ts +43 -0
- package/dist/signature.d.ts.map +1 -0
- package/dist/x509.d.ts +144 -0
- package/dist/x509.d.ts.map +1 -0
- package/dist/x5chain.d.ts +98 -0
- package/dist/x5chain.d.ts.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { CoseAlgorithm } from './algorithm.ts';
|
|
2
|
+
import type { CborValue } from './cbor.ts';
|
|
3
|
+
import type { Verification } from './errors.ts';
|
|
4
|
+
import type { CoseKey } from './key.ts';
|
|
5
|
+
import { X509Certificate } from './x509.ts';
|
|
6
|
+
/** How a chain is to be validated. */
|
|
7
|
+
export interface ChainValidationOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The instant to check the validity periods at, now by default.
|
|
10
|
+
*
|
|
11
|
+
* Worth passing whenever the answer has to be reproducible — a conformance
|
|
12
|
+
* vector, an archived message, a signature being re-checked years later —
|
|
13
|
+
* because "now" makes the same input give different answers on different
|
|
14
|
+
* days.
|
|
15
|
+
*/
|
|
16
|
+
readonly at?: Date;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A `COSE_X509` [RFC 9360, Section 2] — a chain of X.509 certificates.
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* COSE_X509 = bstr / [ 2*certs: bstr ]
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* A single certificate is a bare byte string; two or more form an array. The
|
|
26
|
+
* order is end-entity first, then whoever signed it, and so on. The trust
|
|
27
|
+
* anchor need not be present — the recipient is expected to have it already,
|
|
28
|
+
* which is what makes it an anchor.
|
|
29
|
+
*
|
|
30
|
+
* A chain proves nothing on its own. It becomes an answer only once
|
|
31
|
+
* {@link validate} has walked it to an anchor the recipient configured, and
|
|
32
|
+
* once the key of its end-entity certificate turns out to be the key that
|
|
33
|
+
* verified the signature — which is
|
|
34
|
+
* {@link CoseSign1.verifyWithCertificateChain}'s half of the job.
|
|
35
|
+
*/
|
|
36
|
+
export declare class CoseCertificateChain {
|
|
37
|
+
/** The certificates, end-entity first. */
|
|
38
|
+
readonly certificates: readonly X509Certificate[];
|
|
39
|
+
constructor(certificates: readonly X509Certificate[]);
|
|
40
|
+
/** The certificate holding the key that is expected to have signed. */
|
|
41
|
+
get endEntity(): X509Certificate;
|
|
42
|
+
/** The public key of the end-entity certificate. */
|
|
43
|
+
publicKey(): CoseKey;
|
|
44
|
+
/** Read a `COSE_X509` from its CBOR form. */
|
|
45
|
+
static fromCbor(value: CborValue): CoseCertificateChain;
|
|
46
|
+
/** The CBOR form: a bare byte string for one certificate, an array for several. */
|
|
47
|
+
toCbor(): CborValue;
|
|
48
|
+
/**
|
|
49
|
+
* Walk this chain to one of the given trust anchors.
|
|
50
|
+
*
|
|
51
|
+
* Every certificate within its validity period, every certificate signed
|
|
52
|
+
* by the next one, every issuing certificate actually allowed to issue,
|
|
53
|
+
* the last one either an anchor or issued by one, and the end-entity
|
|
54
|
+
* certificate allowed to sign.
|
|
55
|
+
*
|
|
56
|
+
* This answers "does this chain lead somewhere I trust". It does *not*
|
|
57
|
+
* answer whether the key of the end-entity certificate is the key that
|
|
58
|
+
* signed the message — without that binding a perfectly valid chain says
|
|
59
|
+
* nothing about the message it travelled with.
|
|
60
|
+
*
|
|
61
|
+
* Not checked, and the same list as Styx so that the two agree about what
|
|
62
|
+
* a pass means: revocation, name constraints, certificate policies, and
|
|
63
|
+
* path length beyond the CA flag.
|
|
64
|
+
*/
|
|
65
|
+
validate(trustAnchors: readonly X509Certificate[], options?: ChainValidationOptions): Verification;
|
|
66
|
+
toString(): string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A `COSE_CertHash` [RFC 9360, Section 2] — the hash of a DER encoded
|
|
70
|
+
* certificate, as `x5t` carries it.
|
|
71
|
+
*
|
|
72
|
+
* ```
|
|
73
|
+
* COSE_CertHash = [ hashAlg: (int / tstr), hashValue: bstr ]
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare class CoseCertificateHash {
|
|
77
|
+
/** The hash algorithm the thumbprint was computed with. */
|
|
78
|
+
readonly algorithm: CoseAlgorithm;
|
|
79
|
+
/** The hash of the certificate's DER encoding. */
|
|
80
|
+
readonly value: Uint8Array;
|
|
81
|
+
constructor(algorithm: CoseAlgorithm, value: Uint8Array);
|
|
82
|
+
/** Compute the thumbprint of a certificate, with SHA-256 unless told otherwise. */
|
|
83
|
+
static from(certificate: X509Certificate, algorithm?: CoseAlgorithm): CoseCertificateHash;
|
|
84
|
+
/** Read a `COSE_CertHash` from its CBOR form. */
|
|
85
|
+
static fromCbor(value: CborValue): CoseCertificateHash;
|
|
86
|
+
/** The CBOR form. */
|
|
87
|
+
toCbor(): CborValue;
|
|
88
|
+
/**
|
|
89
|
+
* Whether this thumbprint names the given certificate.
|
|
90
|
+
*
|
|
91
|
+
* A thumbprint that names a *different* certificate than the one that
|
|
92
|
+
* travelled is not a detail to shrug at: the message states which
|
|
93
|
+
* certificate it means, and the chain offers another. One of the two is
|
|
94
|
+
* wrong and there is no way to tell which.
|
|
95
|
+
*/
|
|
96
|
+
matches(certificate: X509Certificate): Verification;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=x5chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x5chain.d.ts","sourceRoot":"","sources":["../src/x5chain.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAA+B,gBAAgB,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAmC,WAAW,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAgC,aAAa,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAqC,UAAU,CAAC;AACvE,OAAO,EAAY,eAAe,EAAE,MAAwB,WAAW,CAAC;AAGxE,sCAAsC;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Encryption (RFC 9052) in TypeScript, on top of the Metrological CBOR codec — the TypeScript counterpart of Vanaheimr Styx's Illias/COSE.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cose",
|
|
7
|
+
"cbor",
|
|
8
|
+
"rfc9052",
|
|
9
|
+
"rfc9053",
|
|
10
|
+
"cose-sign1",
|
|
11
|
+
"signing",
|
|
12
|
+
"encryption",
|
|
13
|
+
"mac",
|
|
14
|
+
"ecdsa",
|
|
15
|
+
"eddsa",
|
|
16
|
+
"ml-dsa",
|
|
17
|
+
"post-quantum",
|
|
18
|
+
"brainpool",
|
|
19
|
+
"x509",
|
|
20
|
+
"metrology",
|
|
21
|
+
"smart-metering",
|
|
22
|
+
"e-mobility"
|
|
23
|
+
],
|
|
24
|
+
"homepage": "https://github.com/Vanaheimr/COSE.TS#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/Vanaheimr/COSE.TS/issues"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/Vanaheimr/COSE.TS.git"
|
|
31
|
+
},
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"author": "GraphDefined GmbH <achim.friedland@graphdefined.com>",
|
|
34
|
+
"type": "module",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"default": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"main": "./dist/index.js",
|
|
43
|
+
"module": "./dist/index.js",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"files": [
|
|
46
|
+
"dist",
|
|
47
|
+
"README.md",
|
|
48
|
+
"LICENSE.md",
|
|
49
|
+
"NOTICE",
|
|
50
|
+
"CHANGELOG.md"
|
|
51
|
+
],
|
|
52
|
+
"sideEffects": false,
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=20"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "npm run build:js && npm run build:types && npm run build:finish",
|
|
61
|
+
"build:js": "tsup",
|
|
62
|
+
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
63
|
+
"build:finish": "tsx scripts/finish-build.ts",
|
|
64
|
+
"clean": "node -e \"import('node:fs').then(fs => fs.rmSync('dist', { recursive: true, force: true }))\"",
|
|
65
|
+
"docs:api": "typedoc",
|
|
66
|
+
"lint": "eslint .",
|
|
67
|
+
"lint:fix": "eslint . --fix",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test:coverage": "vitest run --coverage",
|
|
70
|
+
"test:fuzz": "vitest run tests/fuzz",
|
|
71
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.browser.json",
|
|
72
|
+
"verify": "npm run typecheck && npm run lint && npm run build && npm run test && npm run docs:api",
|
|
73
|
+
"prepublishOnly": "npm run verify"
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@noble/ciphers": "^2.3.0",
|
|
77
|
+
"@noble/curves": "^2.3.0",
|
|
78
|
+
"@noble/hashes": "^2.3.0",
|
|
79
|
+
"@noble/post-quantum": "^0.7.0",
|
|
80
|
+
"@vanaheimr/metrological-cbor": "^0.10.0"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@eslint/js": "^10.0.1",
|
|
84
|
+
"@types/node": "^26.2.0",
|
|
85
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
86
|
+
"esbuild": "^0.28.2",
|
|
87
|
+
"eslint": "^10.9.0",
|
|
88
|
+
"fast-check": "^4.9.0",
|
|
89
|
+
"globals": "^17.11.0",
|
|
90
|
+
"tsup": "^8.5.1",
|
|
91
|
+
"tsx": "^4.23.12",
|
|
92
|
+
"typedoc": "^0.28.20",
|
|
93
|
+
"typescript": "^6.0.3",
|
|
94
|
+
"typescript-eslint": "^8.67.0",
|
|
95
|
+
"vitest": "^4.1.10"
|
|
96
|
+
}
|
|
97
|
+
}
|