sigflint 0.0.0 → 1.0.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/types/v4a.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ export declare const asymmetric: {
2
+ algorithm: string;
3
+ scope: (date: any, _region: any, service: any) => string;
4
+ };
5
+ /** The request with the region set added as a signed header; `regionSet` is 'us-east-1,us-west-2' or '*'. */
6
+ export declare const withRegionSet: (request: any) => any;
7
+ export declare const regionSetQuery: (request: any) => string;
8
+ export declare const kdfInput: (accessKeyId: any, counter: any) => string;
9
+ /** The private scalar (HMAC output + 1) when the HMAC output is at most the curve order minus 2, else undefined. */
10
+ export declare function scalarFrom(k: any): Uint8Array<ArrayBuffer> | undefined;
11
+ /** The SigV4a private key: the P-256 scalar derived from the secret key by the counter-mode HMAC construction in the AWS documentation (32 bytes, big-endian). */
12
+ export declare function deriveP256(hmac: any, accessKeyId: any, secretAccessKey: any): Uint8Array<ArrayBuffer>;
13
+ /** A signer from the string to sign to a hex DER ECDSA signature, with a cache of the keys built from credentials. Asking again for the same `ecdsa` returns the same signer. */
14
+ export declare function createAsymmetric(hmac: any, ecdsa: any): any;
15
+ export type AsymmetricPrimitives = {
16
+ /**
17
+ * - SHA-256 as lowercase hex
18
+ */
19
+ hexHash: (data: string | Uint8Array) => string;
20
+ /**
21
+ * - HMAC-SHA-256 as bytes
22
+ */
23
+ hmac: (key: string | Uint8Array, data: string) => Uint8Array;
24
+ /**
25
+ * - the entry's ECDSA P-256 primitive; built here rather than in the entry so a bundle without SigV4a does not carry it
26
+ */
27
+ ecdsa: {
28
+ key: (scalar: Uint8Array) => unknown;
29
+ sign: (key: any, text: string) => string;
30
+ };
31
+ };
32
+ /**
33
+ * @typedef {Object} AsymmetricPrimitives
34
+ * @property {(data: string | Uint8Array) => string} hexHash - SHA-256 as lowercase hex
35
+ * @property {(key: string | Uint8Array, data: string) => Uint8Array} hmac - HMAC-SHA-256 as bytes
36
+ * @property {{ key: (scalar: Uint8Array) => unknown, sign: (key: any, text: string) => string }} ecdsa - the entry's ECDSA P-256 primitive; built here rather than in the entry so a bundle without SigV4a does not carry it
37
+ */
38
+ /**
39
+ * The synchronous entries' SigV4a header signer.
40
+ * @param {AsymmetricPrimitives} primitives
41
+ * @returns {(request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials) => import('./base.js').AuthHeaders}
42
+ */
43
+ export declare function createSignerV4a({ hexHash, hmac, ecdsa }: AsymmetricPrimitives): (request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials) => import('./base.js').AuthHeaders;
44
+ /**
45
+ * @param {AsymmetricPrimitives} primitives
46
+ * @returns {(request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials) => string}
47
+ */
48
+ export declare function createPresignerV4a({ hexHash, hmac, ecdsa }: AsymmetricPrimitives): (request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials) => string;
package/types/web.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Same request and credentials as the other entries; resolves to the headers to send.
3
+ * @param {import('./base.js').SignRequest} request
4
+ * @param {import('./base.js').Credentials} credentials
5
+ * @returns {Promise<import('./base.js').AuthHeaders>}
6
+ */
7
+ export declare function getAuthHeaders(request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials): Promise<import('./base.js').AuthHeaders>;
8
+ /**
9
+ * SigV4a: the same, signed with ECDSA for the regions in `request.regionSet` ('us-east-1,us-west-2' or '*').
10
+ * @param {import('./base.js').SignRequest} request
11
+ * @param {import('./base.js').Credentials} credentials
12
+ * @returns {Promise<import('./base.js').AuthHeaders>}
13
+ */
14
+ export declare function getAuthHeadersV4a(request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials): Promise<import('./base.js').AuthHeaders>;
15
+ /**
16
+ * A presigned URL for the same request and credentials; `request.expires` is the lifetime in seconds (default 3600).
17
+ * @param {import('./base.js').SignRequest} request
18
+ * @param {import('./base.js').Credentials} credentials
19
+ * @returns {Promise<string>}
20
+ */
21
+ export declare function presign(request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials): Promise<string>;
22
+ /**
23
+ * SigV4a presigned URL for the regions in `request.regionSet`.
24
+ * @param {import('./base.js').SignRequest} request
25
+ * @param {import('./base.js').Credentials} credentials
26
+ * @returns {Promise<string>}
27
+ */
28
+ export declare function presignV4a(request: import('./base.js').SignRequest, credentials: import('./base.js').Credentials): Promise<string>;
29
+ /**
30
+ * Signs an aws-chunked upload chunk by chunk; the same shape as the other entries, with promises.
31
+ * @param {import('./base.js').AuthHeaders} authHeaders - the headers getAuthHeaders returned for the request
32
+ * @param {import('./base.js').Credentials} credentials
33
+ * @returns {{ chunk: (data: Uint8Array) => Promise<Uint8Array>, end: (trailers?: Record<string, string>) => Promise<Uint8Array> }}
34
+ */
35
+ export declare function chunkSigner(authHeaders: import('./base.js').AuthHeaders, credentials: import('./base.js').Credentials): {
36
+ chunk: (data: Uint8Array) => Promise<Uint8Array>;
37
+ end: (trailers?: Record<string, string>) => Promise<Uint8Array>;
38
+ };
39
+ /**
40
+ * Signs event-stream messages in order.
41
+ * @param {import('./base.js').AuthHeaders} authHeaders - the headers getAuthHeaders returned for the request
42
+ * @param {import('./base.js').Credentials} credentials
43
+ * @returns {{ sign: (message: Uint8Array, now?: number) => Promise<Uint8Array> }}
44
+ */
45
+ export declare function eventSigner(authHeaders: import('./base.js').AuthHeaders, credentials: import('./base.js').Credentials): {
46
+ sign: (message: Uint8Array, now?: number) => Promise<Uint8Array>;
47
+ };