Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various crypto function param types are mismatched #16598

Open
Pckool opened this issue Jan 22, 2025 · 0 comments
Open

Various crypto function param types are mismatched #16598

Pckool opened this issue Jan 22, 2025 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@Pckool
Copy link

Pckool commented Jan 22, 2025

What version of Bun is running?

1.1.45+196621f25

What platform is your computer?

on an ubuntu base docker container

What steps can reproduce the bug?

import { timingSafeEqual } from 'crypto';

export function verifyHashWithTimingSafeEqual(hashedToken: string, comparativeToken: string) {
  return timingSafeEqual(Buffer.from(hashedToken, 'hex'), Buffer.from(comparativeToken, 'hex'));
}

What is the expected behavior?

for it to pass

What do you see instead?

../../packages/clients/aws/r2/src/index.ts(140,15): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'BinaryLike'.
  Type 'Buffer' is not assignable to type 'Uint8Array | DataView'.
    Type 'Buffer' is not assignable to type 'Uint8Array'.
      The types returned by 'entries()' are incompatible between these types.
        Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../packages/infrastructure/utils/src/hashes.ts(16,26): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'ArrayBufferView'.
  Type 'Buffer' is not assignable to type 'Uint8Array | DataView'.
    Type 'Buffer' is not assignable to type 'Uint8Array'.
      The types returned by 'entries()' are incompatible between these types.
        Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/core/assets/module/src/logic/utils.ts(18,23): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'string | ArrayBufferView'.
  Type 'Buffer' is not assignable to type 'Uint8Array | DataView'.
    Type 'Buffer' is not assignable to type 'Uint8Array'.
      The types returned by 'entries()' are incompatible between these types.
        Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/pms/pms/module/src/utils/pms-keys-encryption.ts(15,25): error TS[276](https://github.com/wandercom/wander/actions/runs/12901347268/job/35973262194?pr=11648#step:8:277)9: No overload matches this call.
  Overload 1 of 4, '(algorithm: CipherGCMTypes, key: CipherKey, iv: BinaryLike, options?: CipherGCMOptions | undefined): CipherGCM', gave the following error.
    Argument of type '"aes-256-cbc"' is not assignable to parameter of type 'CipherGCMTypes'.
  Overload 2 of 4, '(algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: TransformOptions | undefined): Cipher', gave the following error.
    Argument of type 'Buffer' is not assignable to parameter of type 'CipherKey'.
      Type 'Buffer' is not assignable to type 'Uint8Array | DataView'.
        Type 'Buffer' is not assignable to type 'Uint8Array'.
          The types returned by 'entries()' are incompatible between these types.
            Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/pms/pms/module/src/utils/pms-keys-encryption.ts(16,36): error TS2322: Type 'Buffer' is not assignable to type 'Uint8Array'.
  The types returned by 'entries()' are incompatible between these types.
    Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/pms/pms/module/src/utils/pms-keys-encryption.ts(16,65): error TS2322: Type 'Buffer' is not assignable to type 'Uint8Array'.
  The types returned by 'entries()' are incompatible between these types.
    Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/pms/pms/module/src/utils/pms-keys-encryption.ts(32,27): error TS2769: No overload matches this call.
  Overload 1 of 4, '(algorithm: CipherGCMTypes, key: CipherKey, iv: BinaryLike, options?: CipherGCMOptions | undefined): DecipherGCM', gave the following error.
    Argument of type '"aes-256-cbc"' is not assignable to parameter of type 'CipherGCMTypes'.
  Overload 2 of 4, '(algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: TransformOptions | undefined): Decipher', gave the following error.
    Argument of type 'Buffer' is not assignable to parameter of type 'CipherKey'.
      Type 'Buffer' is not assignable to type 'Uint8Array | DataView'.
        Type 'Buffer' is not assignable to type 'Uint8Array'.
          The types returned by 'entries()' are incompatible between these types.
            Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/pms/pms/module/src/utils/pms-keys-encryption.ts(33,36): error TS2322: Type 'Buffer & string' is not assignable to type 'Uint8Array'.
  The types returned by 'slice(...).entries()' are incompatible between these types.
    Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/pms/pms/module/src/utils/pms-keys-encryption.ts(33,52): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'ArrayBufferView'.
  Type 'Buffer' is not assignable to type 'Uint8Array | DataView'.
    Type 'Buffer' is not assignable to type 'Uint8Array'.
      The types returned by 'entries()' are incompatible between these types.
        Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/pms/pms/module/src/utils/pms-keys-encryption.ts(33,64): error TS2322: Type 'Buffer' is not assignable to type 'Uint8Array'.
  The types returned by 'entries()' are incompatible between these types.
    Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.
../../src/support/chat/chat-attachments/src/actions/get-metadata.ts(16,29): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'string | ArrayBufferView'.
  Type 'Buffer' is not assignable to type 'Uint8Array | DataView'.
    Type 'Buffer' is not assignable to type 'Uint8Array'.
      The types returned by 'entries()' are incompatible between these types.
        Type 'IterableIterator<[number, number]>' is missing the following properties from type 'ArrayIterator<[number, number]>': map, filter, take, drop, and 9 more.

Additional information

this only happens during our typecheck ci job for some reason

@Pckool Pckool added bug Something isn't working needs triage labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant