Skip to content

Commit 0ddf320

Browse files
committed
fix type errors
Signed-off-by: Brian DeHamer <[email protected]>
1 parent 6c1ebed commit 0ddf320

File tree

20 files changed

+60
-48
lines changed

20 files changed

+60
-48
lines changed

packages/bundle/src/__tests__/__snapshots__/build.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`toDSSEBundle when the certificateChain option is true when a certificate chain provided returns a valid DSSE bundle 1`] = `
44
{

packages/bundle/src/__tests__/__snapshots__/serialized.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`bundleToJSON SerializedDSSEBundle (v0.3) matches the snapshot 1`] = `
44
{

packages/core/src/asn1/obj.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ import { ASN1Tag } from './tag';
2828
export class ASN1Obj {
2929
readonly tag: ASN1Tag;
3030
readonly subs: ASN1Obj[];
31-
readonly value: Buffer;
31+
readonly value: Buffer<ArrayBufferLike>;
3232

33-
constructor(tag: ASN1Tag, value: Buffer, subs: ASN1Obj[]) {
33+
constructor(tag: ASN1Tag, value: Buffer<ArrayBufferLike>, subs: ASN1Obj[]) {
3434
this.tag = tag;
3535
this.value = value;
3636
this.subs = subs;
3737
}
3838

3939
// Constructs an ASN.1 object from a Buffer of DER-encoded bytes.
40-
public static parseBuffer(buf: Buffer): ASN1Obj {
40+
public static parseBuffer(buf: Buffer<ArrayBuffer>): ASN1Obj {
4141
return parseStream(new ByteStream(buf));
4242
}
4343

packages/core/src/pem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616
const PEM_HEADER = /-----BEGIN (.*)-----/;
1717
const PEM_FOOTER = /-----END (.*)-----/;
1818

19-
export function toDER(certificate: string): Buffer {
19+
export function toDER(certificate: string): Buffer<ArrayBuffer> {
2020
let der = '';
2121

2222
certificate.split('\n').forEach((line) => {

packages/core/src/rfc3161/timestamp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class RFC3161Timestamp {
3030
this.root = asn1;
3131
}
3232

33-
public static parse(der: Buffer): RFC3161Timestamp {
33+
public static parse(der: Buffer<ArrayBuffer>): RFC3161Timestamp {
3434
const asn1 = ASN1Obj.parseBuffer(der);
3535
return new RFC3161Timestamp(asn1);
3636
}

packages/core/src/stream.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ class StreamError extends Error {}
1818
export class ByteStream {
1919
private static BLOCK_SIZE = 1024;
2020

21-
private buf: ArrayBuffer;
21+
private buf: Buffer<ArrayBufferLike>;
2222
private view: Buffer;
2323
private start = 0;
2424

25-
constructor(buffer?: ArrayBuffer) {
25+
constructor(buffer?: Buffer<ArrayBufferLike>) {
2626
if (buffer) {
2727
this.buf = buffer;
2828
this.view = Buffer.from(buffer);
2929
} else {
30-
this.buf = new ArrayBuffer(0);
30+
this.buf = Buffer.alloc(0);
3131
this.view = Buffer.from(this.buf);
3232
}
3333
}
@@ -129,7 +129,7 @@ export class ByteStream {
129129
}
130130

131131
private realloc(size: number) {
132-
const newArray = new ArrayBuffer(size);
132+
const newArray = Buffer.alloc(size);
133133
const newView = Buffer.from(newArray);
134134

135135
// Copy the old buffer into the new one

packages/core/src/x509/cert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class X509Certificate {
4141
this.root = asn1;
4242
}
4343

44-
public static parse(cert: Buffer | string): X509Certificate {
44+
public static parse(cert: Buffer<ArrayBuffer> | string): X509Certificate {
4545
const der = typeof cert === 'string' ? pem.toDER(cert) : cert;
4646
const asn1 = ASN1Obj.parseBuffer(der);
4747
return new X509Certificate(asn1);

packages/core/src/x509/ext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class X509Extension {
3535
return this.root.subs.length === 3 ? this.root.subs[1].toBoolean() : false;
3636
}
3737

38-
get value(): Buffer {
38+
get value(): Buffer<ArrayBufferLike> {
3939
return this.extnValueObj.value;
4040
}
4141

packages/mock-server/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export default class Server extends Command {
104104
tufEndpoints.forEach(({ path, fn }) => {
105105
app.get(
106106
path,
107-
adapt(() => Promise.resolve(fn()))
107+
// TODO: fix types in tuf-mock
108+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
109+
adapt(() => Promise.resolve((fn as any)()))
108110
);
109111
});
110112

@@ -143,7 +145,7 @@ function assembleTrustedRoot({
143145
}
144146

145147
function certificateAuthority(
146-
certificates: Buffer[],
148+
certificates: ArrayBufferView<ArrayBuffer>[],
147149
url: string
148150
): CertificateAuthority {
149151
return {
@@ -154,7 +156,7 @@ function certificateAuthority(
154156
uri: url,
155157
certChain: {
156158
certificates: certificates.map((certificate) => ({
157-
rawBytes: certificate,
159+
rawBytes: Buffer.from(certificate.buffer),
158160
})),
159161
},
160162
validFor: { start: new Date() },

packages/mock/src/fulcio/__snapshots__/handler.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`fulcioHandler #fn when invoked w/ a CSR returns a certificate chain 1`] = `
44
Extensions [

0 commit comments

Comments
 (0)