aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api/crypto.classes.ts
blob: 471e87702c4c020a6ccaabd5366be2b2cb0f70ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { define } from "../scripts/class-definitions";

const names = ["SHA1", "MD5", "MD4", "SHA224", "SHA512", "SHA384", "SHA256", "SHA512_256"];
const named = names.map(name => {
  return define({
    name: name,
    construct: true,
    finalize: true,
    configurable: false,
    klass: {
      hash: {
        fn: "hash",
        length: 2,
      },
      byteLength: {
        getter: "getByteLengthStatic",
      },
    },
    JSType: "0b11101110",
    proto: {
      digest: {
        fn: "digest",
        length: 0,
      },
      update: {
        fn: "update",
        length: 1,
      },
      byteLength: {
        getter: "getByteLength",
      },
    },
  });
});

export default [
  define({
    name: "Crypto",
    construct: true,
    finalize: false,

    proto: {
      getRandomValues: {
        fn: "getRandomValues",
        DOMJIT: {
          returns: "JSValue",
          "pure": false,
          args: ["JSUint8Array"],
        },
      },
      randomUUID: {
        fn: "randomUUID",
        length: 1,
        DOMJIT: {
          returns: "JSString",
          "pure": false,
          args: [],
        },
      },
      timingSafeEqual: {
        fn: "timingSafeEqual",
        DOMJIT: {
          returns: "JSValue",
          "pure": false,
          args: ["JSUint8Array", "JSUint8Array"],
        },
        length: 2,
      },
      randomInt: {
        fn: "randomInt",
        length: 2,
      },
      scryptSync: {
        fn: "doScryptSync",
        length: 2,
      },
    },
    klass: {},
  }),
  ...named,
  define({
    name: "CryptoHasher",
    construct: true,
    finalize: true,
    klass: {
      hash: {
        fn: "hash",
        length: 2,
      },
      algorithms: {
        getter: "getAlgorithms",
        cache: true,
      },
    },
    JSType: "0b11101110",
    proto: {
      digest: {
        fn: "digest",
        length: 0,
      },
      algorithm: {
        getter: "getAlgorithm",
        cache: true,
      },
      update: {
        fn: "update",
        length: 2,
      },
      copy: {
        fn: "copy",
        length: 0,
      },
      byteLength: {
        getter: "getByteLength",
      },
    },
  }),
];