ranuts 0.1.0-alpha.11 → 0.1.0-alpha.13

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.
Files changed (103) hide show
  1. package/dist/index.d.ts +5 -3
  2. package/dist/index.js +25 -16
  3. package/dist/{mimeType-Clvz2Teb.js → mimeType-eRf1TlBb.js} +4 -9
  4. package/dist/{reactify-C4cesbXi.js → reactify-Z-V9Vblb.js} +3 -8
  5. package/dist/{ml.js → src/ml/index.js} +19 -24
  6. package/dist/src/node/body.d.ts +0 -1
  7. package/dist/src/node/command.d.ts +0 -1
  8. package/dist/src/node/ctx2req.d.ts +0 -1
  9. package/dist/src/node/fs.d.ts +0 -2
  10. package/dist/src/node/index.d.ts +3 -2
  11. package/dist/src/node/index.js +54 -0
  12. package/dist/src/node/paresUrl.d.ts +0 -1
  13. package/dist/src/node/readFile.d.ts +0 -1
  14. package/dist/src/node/server.d.ts +0 -1
  15. package/dist/src/node/stream.d.ts +0 -1
  16. package/dist/src/node/traverse.d.ts +0 -1
  17. package/dist/src/node/watchFile.d.ts +1 -1
  18. package/dist/src/node/websocket.d.ts +2 -6
  19. package/dist/src/node/ws.d.ts +0 -1
  20. package/dist/src/optimize/index.d.ts +3 -3
  21. package/dist/src/react/index.js +4 -0
  22. package/dist/src/utils/behavior.d.ts +1 -1
  23. package/dist/src/utils/bom.d.ts +7 -7
  24. package/dist/src/utils/device.d.ts +9 -3
  25. package/dist/src/utils/dom.d.ts +87 -2
  26. package/dist/src/utils/img.d.ts +1 -1
  27. package/dist/src/utils/index.d.ts +8 -4
  28. package/dist/src/utils/index.js +4021 -0
  29. package/dist/src/utils/number.d.ts +1 -1
  30. package/dist/src/utils/obj.d.ts +10 -3
  31. package/dist/src/utils/storage.d.ts +2 -0
  32. package/dist/src/utils/subscribe.d.ts +34 -4
  33. package/dist/src/utils/totp/sha/common.d.ts +151 -0
  34. package/dist/src/utils/totp/sha/converters.d.ts +88 -0
  35. package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
  36. package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
  37. package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
  38. package/dist/src/utils/totp/sha/sha.d.ts +103 -0
  39. package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
  40. package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
  41. package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
  42. package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
  43. package/dist/src/utils/totp/totp.d.ts +23 -0
  44. package/dist/src/utils/visual/application.d.ts +10 -0
  45. package/dist/src/utils/visual/demo/index.d.ts +1 -0
  46. package/dist/src/utils/visual/demo/sankey.d.ts +2 -0
  47. package/dist/src/utils/visual/enums.d.ts +21 -0
  48. package/dist/src/utils/visual/event/boundary.d.ts +22 -0
  49. package/dist/src/utils/visual/event/event.d.ts +14 -0
  50. package/dist/src/utils/visual/event/index.d.ts +3 -0
  51. package/dist/src/utils/visual/event/types.d.ts +32 -0
  52. package/dist/src/utils/visual/graphics/graphics.d.ts +19 -0
  53. package/dist/src/utils/visual/graphics/graphicsData.d.ts +10 -0
  54. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +10 -0
  55. package/dist/src/utils/visual/graphics/index.d.ts +3 -0
  56. package/dist/src/utils/visual/index.d.ts +4 -0
  57. package/dist/src/utils/visual/math/bezier.d.ts +2 -0
  58. package/dist/src/utils/visual/math/enums.d.ts +2 -0
  59. package/dist/src/utils/visual/math/index.d.ts +4 -0
  60. package/dist/src/utils/visual/math/matrix.d.ts +32 -0
  61. package/dist/src/utils/visual/math/transform.d.ts +27 -0
  62. package/dist/src/utils/visual/render/canvasRenderer.d.ts +9 -0
  63. package/dist/src/utils/visual/render/index.d.ts +3 -0
  64. package/dist/src/utils/visual/render/render.d.ts +10 -0
  65. package/dist/src/utils/visual/render/webGlRenderer.d.ts +7 -0
  66. package/dist/src/utils/visual/shape/circle.d.ts +11 -0
  67. package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
  68. package/dist/src/utils/visual/shape/index.d.ts +5 -0
  69. package/dist/src/utils/visual/shape/polygon.d.ts +10 -0
  70. package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
  71. package/dist/src/utils/visual/shape/shape.d.ts +7 -0
  72. package/dist/src/utils/visual/style/fill.d.ts +8 -0
  73. package/dist/src/utils/visual/style/index.d.ts +2 -0
  74. package/dist/src/utils/visual/style/line.d.ts +9 -0
  75. package/dist/src/utils/visual/types.d.ts +6 -0
  76. package/dist/src/utils/visual/vertex/application.d.ts +13 -0
  77. package/dist/src/utils/visual/vertex/container.d.ts +38 -0
  78. package/dist/src/utils/visual/vertex/index.d.ts +4 -0
  79. package/dist/src/utils/visual/vertex/point.d.ts +18 -0
  80. package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
  81. package/dist/src/vnode/chainDom.d.ts +47 -0
  82. package/dist/{wasm.js → src/wasm/index.js} +4 -8
  83. package/dist/test/writeFile.test.d.ts +1 -0
  84. package/dist/tsconfig.json +1 -0
  85. package/dist/umd/index.umd.cjs +1 -1
  86. package/dist/umd/ml/ml.umd.cjs +1 -1
  87. package/dist/umd/node/node.umd.cjs +1 -1
  88. package/dist/umd/react/react.umd.cjs +1 -1
  89. package/dist/umd/utils/utils.umd.cjs +1 -1
  90. package/dist/{ws-DoSbcWWZ.js → ws-CQA-0Bzm.js} +31 -53
  91. package/package.json +18 -16
  92. package/readme.md +6 -2
  93. package/typings.d.ts +4 -10
  94. package/dist/node.js +0 -27
  95. package/dist/react.js +0 -4
  96. package/dist/utils.js +0 -2092
  97. /package/dist/test/{server/encodeUrl.test.d.ts → encodeUrl.test.d.ts} +0 -0
  98. /package/dist/test/{server/escapeHtml.test.d.ts → escapeHtml.test.d.ts} +0 -0
  99. /package/dist/test/{server/mimeType.test.d.ts → mimeType.test.d.ts} +0 -0
  100. /package/dist/test/{server/server.test.d.ts → server.test.d.ts} +0 -0
  101. /package/dist/test/{server/status.test.d.ts → status.test.d.ts} +0 -0
  102. /package/dist/test/{file/writeFile.test.d.ts → totp.test.d.ts} +0 -0
  103. /package/dist/test/{server/websocket.test.d.ts → websocket.test.d.ts} +0 -0
@@ -33,7 +33,7 @@ export declare class Mathjs {
33
33
  getDecimalLength: (n: number) => number;
34
34
  amend: (n: number, precision?: number) => number;
35
35
  power: (a: number, b: number) => number;
36
- static handleMethod: (l: number, r: number) => (type: string) => number | undefined;
36
+ static handleMethod: (l: number, r: number) => ((type: string) => number | undefined);
37
37
  static add: (a: number, b: number) => number | undefined;
38
38
  static divide: (a: number, b: number) => number | undefined;
39
39
  static multiply: (a: number, b: number) => number | undefined;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @description: 对象转url字符串
2
+ * @description: 对象转 url 字符串
3
3
  * @param {*} data
4
4
  * @return {*}
5
5
  */
@@ -25,16 +25,23 @@ export declare const merge: (a: Obj, b?: Obj) => Obj;
25
25
  *
26
26
  * @export
27
27
  * @param {IAnyObject} source 需要被重写的对象
28
- * @param {string} name 需要被重写对象的key
28
+ * @param {string} name 需要被重写对象的 key
29
29
  * @param {(...args: any[]) => any} replacement 以原有的函数作为参数,执行并重写原有函数
30
30
  * @param {boolean} isForced 是否强制重写(可能原先没有该属性)
31
31
  */
32
32
  export declare function replaceOld(source: any, name: string, replacement: (...args: unknown[]) => unknown, isForced?: boolean): void;
33
33
  /**
34
- * @description: 将exports对象拼接到obj上,并冻结obj
34
+ * @description: 将 exports 对象拼接到 obj 上,并冻结 obj
35
35
  * @param {Object} obj
36
36
  * @param {Object} exports
37
37
  * @return {Object}
38
38
  */
39
39
  export declare const mergeExports: (obj: Object, exports: Object) => Object;
40
+ /**
41
+ * @description: 给全局对象上增加属性
42
+ * @param {string} name
43
+ * @param {string} value
44
+ * @return {*}
45
+ */
46
+ export declare const setAttributeByGlobal: (name: string, value: unknown) => void;
40
47
  export {};
@@ -0,0 +1,2 @@
1
+ export declare const localStorageSetItem: (name: string, value: string) => void;
2
+ export declare const localStorageGetItem: (name: string) => string;
@@ -1,4 +1,4 @@
1
- type Callback = (...args: unknown[]) => unknown;
1
+ type Callback = Function;
2
2
  type EventName = string | symbol;
3
3
  type EventItem = {
4
4
  name?: string | symbol;
@@ -8,10 +8,40 @@ type EventItem = {
8
8
  export declare class SyncHook {
9
9
  private _events;
10
10
  constructor();
11
- tap: (eventName: EventName, eventItem: EventItem | Callback) => void;
11
+ /**
12
+ * @description: 订阅事件
13
+ * @param {EventName} eventName
14
+ * @param {EventItem} eventItem
15
+ * @return {void}
16
+ */
17
+ tap: (eventName: EventName, eventItem: EventItem | Callback) => SyncHook;
18
+ /**
19
+ * @description: 触发事件
20
+ * @param {EventName} eventName
21
+ * @param {array} args
22
+ * @return {void}
23
+ */
12
24
  call: (eventName: EventName, ...args: Array<unknown>) => void;
25
+ /**
26
+ * @description: 同步触发事件
27
+ * @param {EventName} eventName
28
+ * @param {array} args
29
+ * @return {Promise<void>}
30
+ */
13
31
  callSync: (eventName: EventName, ...args: Array<unknown>) => Promise<void>;
14
- once: (eventName: EventName, eventItem: EventItem | Callback) => void;
15
- off: (eventName: EventName, eventItem: EventItem | Callback) => void;
32
+ /**
33
+ * @description: 只订阅一次事件,触发后就移除事件
34
+ * @param {EventName} eventName
35
+ * @param {EventItem} eventItem
36
+ * @return {void}
37
+ */
38
+ once: (eventName: EventName, eventItem: EventItem | Callback) => SyncHook;
39
+ /**
40
+ * @description: 移除订阅的事件
41
+ * @param {EventName} eventName
42
+ * @param {EventItem} eventItem
43
+ * @return {void}
44
+ */
45
+ off: (eventName: EventName, eventItem: EventItem | Callback) => SyncHook;
16
46
  }
17
47
  export {};
@@ -0,0 +1,151 @@
1
+ import type { EncodingType, FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, FormatType, GenericInputType, packedValue } from './custom_types';
2
+ export declare const TWO_PWR_32 = 4294967296;
3
+ export declare const K_sha2: number[];
4
+ export declare const H_trunc: number[];
5
+ export declare const H_full: number[];
6
+ export declare const sha_variant_error = "Chosen SHA variant is not supported";
7
+ export declare const mac_rounds_error = "Cannot set numRounds with MAC";
8
+ /**
9
+ * Concatenates 2 packed arrays. Clobbers array `a`.
10
+ *
11
+ * @param a First array to concatenate.
12
+ * @param b Second array to concatenate.
13
+ * @returns The concatentation of `a` + `b`.
14
+ */
15
+ export declare function packedLEConcat(a: packedValue, b: packedValue): packedValue;
16
+ /**
17
+ * Validate hash list containing output formatting options, ensuring presence of every option or adding the default
18
+ * value.
19
+ *
20
+ * @param options Hashmap of output formatting options from user.
21
+ * @returns Validated hashmap containing output formatting options.
22
+ */
23
+ export declare function getOutputOpts(options?: {
24
+ outputUpper?: boolean;
25
+ b64Pad?: string;
26
+ shakeLen?: number;
27
+ outputLen?: number;
28
+ }): {
29
+ outputUpper: boolean;
30
+ b64Pad: string;
31
+ outputLen: number;
32
+ };
33
+ /**
34
+ * Parses an external constructor object and returns a packed number, if possible.
35
+ *
36
+ * @param key The human-friendly key name to prefix any errors with
37
+ * @param value The input value object to parse
38
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
39
+ * @param fallback Fallback value if `value` is undefined. If not present and `value` is undefined, an Error is thrown
40
+ */
41
+ export declare function parseInputOption(key: string, value: GenericInputType | undefined, bigEndianMod: -1 | 1, fallback?: packedValue): packedValue;
42
+ export declare abstract class jsSHABase<StateT, VariantT> {
43
+ /**
44
+ * @param variant The desired SHA variant.
45
+ * @param inputFormat The input format to be used in future `update` calls.
46
+ * @param options Hashmap of extra input options.
47
+ */
48
+ protected readonly shaVariant: VariantT;
49
+ protected readonly inputFormat: FormatType;
50
+ protected readonly utfType: EncodingType;
51
+ protected readonly numRounds: number;
52
+ protected abstract intermediateState: StateT;
53
+ protected keyWithIPad: number[];
54
+ protected keyWithOPad: number[];
55
+ protected remainder: number[];
56
+ protected remainderLen: number;
57
+ protected updateCalled: boolean;
58
+ protected processedLen: number;
59
+ protected macKeySet: boolean;
60
+ protected abstract readonly variantBlockSize: number;
61
+ protected abstract readonly bigEndianMod: -1 | 1;
62
+ protected abstract readonly outputBinLen: number;
63
+ protected abstract readonly isVariableLen: boolean;
64
+ protected abstract readonly HMACSupported: boolean;
65
+ protected abstract readonly converterFunc: (input: any, existingBin: number[], existingBinLen: number) => packedValue;
66
+ protected abstract readonly roundFunc: (block: number[], H: StateT) => StateT;
67
+ protected abstract readonly finalizeFunc: (remainder: number[], remainderBinLen: number, processedBinLen: number, H: StateT, outputLen: number) => number[];
68
+ protected abstract readonly stateCloneFunc: (state: StateT) => StateT;
69
+ protected abstract readonly newStateFunc: (variant: VariantT) => StateT;
70
+ protected abstract readonly getMAC: ((options: {
71
+ outputLen: number;
72
+ }) => number[]) | null;
73
+ protected constructor(variant: VariantT, inputFormat: 'TEXT', options?: FixedLengthOptionsEncodingType);
74
+ protected constructor(variant: VariantT, inputFormat: FormatNoTextType, options?: FixedLengthOptionsNoEncodingType);
75
+ /**
76
+ * Hashes as many blocks as possible. Stores the rest for either a future update or getHash call.
77
+ *
78
+ * @param srcString The input to be hashed.
79
+ * @returns A reference to the object.
80
+ */
81
+ update(srcString: string | ArrayBuffer | Uint8Array): this;
82
+ /**
83
+ * Returns the desired SHA hash of the input fed in via `update` calls.
84
+ *
85
+ * @param format The desired output formatting
86
+ * @param options Hashmap of output formatting options. `outputLen` must be specified for variable length hashes.
87
+ * `outputLen` replaces the now deprecated `shakeLen` key.
88
+ * @returns The hash in the format specified.
89
+ */
90
+ getHash(format: 'HEX', options?: {
91
+ outputUpper?: boolean;
92
+ outputLen?: number;
93
+ shakeLen?: number;
94
+ }): string;
95
+ getHash(format: 'B64', options?: {
96
+ b64Pad?: string;
97
+ outputLen?: number;
98
+ shakeLen?: number;
99
+ }): string;
100
+ getHash(format: 'BYTES', options?: {
101
+ outputLen?: number;
102
+ shakeLen?: number;
103
+ }): string;
104
+ getHash(format: 'UINT8ARRAY', options?: {
105
+ outputLen?: number;
106
+ shakeLen?: number;
107
+ }): Uint8Array;
108
+ getHash(format: 'ARRAYBUFFER', options?: {
109
+ outputLen?: number;
110
+ shakeLen?: number;
111
+ }): ArrayBuffer;
112
+ /**
113
+ * Sets the HMAC key for an eventual `getHMAC` call. Must be called immediately after jsSHA object instantiation.
114
+ *
115
+ * @param key The key used to calculate the HMAC
116
+ * @param inputFormat The format of key.
117
+ * @param options Hashmap of extra input options.
118
+ */
119
+ setHMACKey(key: string, inputFormat: 'TEXT', options?: {
120
+ encoding?: EncodingType;
121
+ }): void;
122
+ setHMACKey(key: string, inputFormat: 'B64' | 'HEX' | 'BYTES'): void;
123
+ setHMACKey(key: ArrayBuffer, inputFormat: 'ARRAYBUFFER'): void;
124
+ setHMACKey(key: Uint8Array, inputFormat: 'UINT8ARRAY'): void;
125
+ /**
126
+ * Internal function that sets the MAC key.
127
+ *
128
+ * @param key The packed MAC key to use
129
+ */
130
+ protected _setHMACKey(key: packedValue): void;
131
+ /**
132
+ * Returns the the HMAC in the specified format using the key given by a previous `setHMACKey` call.
133
+ *
134
+ * @param format The desired output formatting.
135
+ * @param options Hashmap of extra outputs options.
136
+ * @returns The HMAC in the format specified.
137
+ */
138
+ getHMAC(format: 'HEX', options?: {
139
+ outputUpper?: boolean;
140
+ }): string;
141
+ getHMAC(format: 'B64', options?: {
142
+ b64Pad?: string;
143
+ }): string;
144
+ getHMAC(format: 'BYTES'): string;
145
+ getHMAC(format: 'UINT8ARRAY'): Uint8Array;
146
+ getHMAC(format: 'ARRAYBUFFER'): ArrayBuffer;
147
+ /**
148
+ * Internal function that returns the "raw" HMAC
149
+ */
150
+ protected _getHMAC(): number[];
151
+ }
@@ -0,0 +1,88 @@
1
+ import type { EncodingType, FormatType, packedValue } from './custom_types';
2
+ /**
3
+ * Function that takes an input format and UTF encoding and returns the appropriate function used to convert the input.
4
+ *
5
+ * @param format The format of the input to be converted
6
+ * @param utfType The string encoding to use for TEXT inputs.
7
+ * @param bigEndianMod Modifier for whether hash function is big or small endian
8
+ * @returns Function that will convert an input to a packed int array.
9
+ */
10
+ export declare function getStrConverter(format: FormatType, utfType: EncodingType, bigEndianMod: -1 | 1): (input: any, existingBin?: number[], existingBinLen?: number) => packedValue;
11
+ /**
12
+ * Convert an array of words to a hexadecimal string.
13
+ *
14
+ * toString() won't work here because it removes preceding zeros (e.g. 0x00000001.toString === "1" rather than
15
+ * "00000001" and 0.toString(16) === "0" rather than "00").
16
+ *
17
+ * @param packed Array of integers to be converted.
18
+ * @param outputLength Length of output in bits.
19
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
20
+ * @param formatOpts Hashmap containing validated output formatting options.
21
+ * @returns Hexadecimal representation of `packed`.
22
+ */
23
+ export declare function packed2hex(packed: number[], outputLength: number, bigEndianMod: -1 | 1, formatOpts: {
24
+ outputUpper: boolean;
25
+ b64Pad: string;
26
+ }): string;
27
+ /**
28
+ * Convert an array of words to a base-64 string.
29
+ *
30
+ * @param packed Array of integers to be converted.
31
+ * @param outputLength Length of output in bits.
32
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
33
+ * @param formatOpts Hashmap containing validated output formatting options.
34
+ * @returns Base64-encoded representation of `packed`.
35
+ */
36
+ export declare function packed2b64(packed: number[], outputLength: number, bigEndianMod: -1 | 1, formatOpts: {
37
+ outputUpper: boolean;
38
+ b64Pad: string;
39
+ }): string;
40
+ /**
41
+ * Convert an array of words to raw bytes string.
42
+ *
43
+ * @param packed Array of integers to be converted.
44
+ * @param outputLength Length of output in bits.
45
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
46
+ * @returns Raw bytes representation of `packed`.
47
+ */
48
+ export declare function packed2bytes(packed: number[], outputLength: number, bigEndianMod: -1 | 1): string;
49
+ /**
50
+ * Convert an array of words to an ArrayBuffer.
51
+ *
52
+ * @param packed Array of integers to be converted.
53
+ * @param outputLength Length of output in bits.
54
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
55
+ * @returns An ArrayBuffer containing bytes from `packed.
56
+ */
57
+ export declare function packed2arraybuffer(packed: number[], outputLength: number, bigEndianMod: -1 | 1): ArrayBuffer;
58
+ /**
59
+ * Convert an array of words to an Uint8Array.
60
+ *
61
+ * @param packed Array of integers to be converted.
62
+ * @param outputLength Length of output in bits.
63
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
64
+ * @returns An Uint8Array containing bytes from `packed.
65
+ */
66
+ export declare function packed2uint8array(packed: number[], outputLength: number, bigEndianMod: -1 | 1): Uint8Array;
67
+ /**
68
+ * Function that takes an output format and associated parameters and returns a function that converts packed integers
69
+ * to that format.
70
+ *
71
+ * @param format The desired output formatting.
72
+ * @param outputBinLen Output length in bits.
73
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
74
+ * @param outputOptions Hashmap of output formatting options
75
+ * @returns Function that will convert a packed integer array to desired format.
76
+ */
77
+ export declare function getOutputConverter(format: 'HEX' | 'B64' | 'BYTES', outputBinLen: number, bigEndianMod: -1 | 1, outputOptions: {
78
+ outputUpper: boolean;
79
+ b64Pad: string;
80
+ }): (binarray: number[]) => string;
81
+ export declare function getOutputConverter(format: 'ARRAYBUFFER', outputBinLen: number, bigEndianMod: -1 | 1, outputOptions: {
82
+ outputUpper: boolean;
83
+ b64Pad: string;
84
+ }): (binarray: number[]) => ArrayBuffer;
85
+ export declare function getOutputConverter(format: 'UINT8ARRAY', outputBinLen: number, bigEndianMod: -1 | 1, outputOptions: {
86
+ outputUpper: boolean;
87
+ b64Pad: string;
88
+ }): (binarray: number[]) => Uint8Array;
@@ -0,0 +1,60 @@
1
+ export type EncodingType = 'UTF8' | 'UTF16BE' | 'UTF16LE';
2
+ export type FormatNoTextType = 'HEX' | 'B64' | 'BYTES' | 'ARRAYBUFFER' | 'UINT8ARRAY';
3
+ export type FormatType = 'TEXT' | FormatNoTextType;
4
+ export type GenericInputType = {
5
+ value: string;
6
+ format: 'TEXT';
7
+ encoding?: EncodingType;
8
+ } | {
9
+ value: string;
10
+ format: 'B64' | 'HEX' | 'BYTES';
11
+ } | {
12
+ value: ArrayBuffer;
13
+ format: 'ARRAYBUFFER';
14
+ } | {
15
+ value: Uint8Array;
16
+ format: 'UINT8ARRAY';
17
+ };
18
+ export type FixedLengthOptionsNoEncodingType = {
19
+ hmacKey?: GenericInputType;
20
+ } | {
21
+ numRounds?: number;
22
+ };
23
+ export type FixedLengthOptionsEncodingType = {
24
+ hmacKey?: GenericInputType;
25
+ encoding?: EncodingType;
26
+ } | {
27
+ numRounds?: number;
28
+ encoding?: EncodingType;
29
+ };
30
+ export interface packedValue {
31
+ value: number[];
32
+ binLen: number;
33
+ }
34
+ export interface SHAKEOptionsNoEncodingType {
35
+ numRounds?: number;
36
+ }
37
+ export interface SHAKEOptionsEncodingType extends SHAKEOptionsNoEncodingType {
38
+ encoding?: EncodingType;
39
+ }
40
+ export interface CSHAKEOptionsNoEncodingType {
41
+ customization?: GenericInputType;
42
+ funcName?: GenericInputType;
43
+ }
44
+ export interface CSHAKEOptionsEncodingType extends CSHAKEOptionsNoEncodingType {
45
+ encoding?: EncodingType;
46
+ }
47
+ export interface KMACOptionsNoEncodingType {
48
+ kmacKey: GenericInputType;
49
+ customization?: GenericInputType;
50
+ }
51
+ export interface KMACOptionsEncodingType extends KMACOptionsNoEncodingType {
52
+ encoding?: EncodingType;
53
+ }
54
+ export interface ResolvedCSHAKEOptionsNoEncodingType {
55
+ funcName: packedValue;
56
+ customization: packedValue;
57
+ }
58
+ export interface ResolvedKMACOptionsNoEncodingType extends ResolvedCSHAKEOptionsNoEncodingType {
59
+ kmacKey: packedValue;
60
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The 32-bit implementation of circular rotate left.
3
+ *
4
+ * @param x The 32-bit integer argument.
5
+ * @param n The number of bits to shift.
6
+ * @returns `x` shifted left circularly by `n` bits
7
+ */
8
+ export declare function rotl_32(x: number, n: number): number;
9
+ /**
10
+ * The 32-bit implementation of the NIST specified Parity function.
11
+ *
12
+ * @param x The first 32-bit integer argument.
13
+ * @param y The second 32-bit integer argument.
14
+ * @param z The third 32-bit integer argument.
15
+ * @returns The NIST specified output of the function.
16
+ */
17
+ export declare function parity_32(x: number, y: number, z: number): number;
18
+ /**
19
+ * The 32-bit implementation of the NIST specified Ch function.
20
+ *
21
+ * @param x The first 32-bit integer argument.
22
+ * @param y The second 32-bit integer argument.
23
+ * @param z The third 32-bit integer argument.
24
+ * @returns The NIST specified output of the function.
25
+ */
26
+ export declare function ch_32(x: number, y: number, z: number): number;
27
+ /**
28
+ * The 32-bit implementation of the NIST specified Maj function.
29
+ *
30
+ * @param x The first 32-bit integer argument.
31
+ * @param y The second 32-bit integer argument.
32
+ * @param z The third 32-bit integer argument.
33
+ * @returns The NIST specified output of the function.
34
+ */
35
+ export declare function maj_32(x: number, y: number, z: number): number;
36
+ /**
37
+ * The 32-bit implementation of the NIST specified Sigma0 function.
38
+ *
39
+ * @param x The 32-bit integer argument.
40
+ * @returns The NIST specified output of the function.
41
+ */
42
+ export declare function sigma0_32(x: number): number;
43
+ /**
44
+ * Add two 32-bit integers.
45
+ *
46
+ * This uses 16-bit operations internally to work around sign problems due to JavaScript's lack of uint32 support.
47
+ *
48
+ * @param a The first 32-bit integer argument to be added.
49
+ * @param b The second 32-bit integer argument to be added.
50
+ * @returns The sum of `a` + `b`.
51
+ */
52
+ export declare function safeAdd_32_2(a: number, b: number): number;
53
+ /**
54
+ * Add four 32-bit integers.
55
+ *
56
+ * This uses 16-bit operations internally to work around sign problems due to JavaScript's lack of uint32 support.
57
+ *
58
+ * @param a The first 32-bit integer argument to be added.
59
+ * @param b The second 32-bit integer argument to be added.
60
+ * @param c The third 32-bit integer argument to be added.
61
+ * @param d The fourth 32-bit integer argument to be added.
62
+ * @returns The sum of `a` + `b` + `c` + `d`.
63
+ */
64
+ export declare function safeAdd_32_4(a: number, b: number, c: number, d: number): number;
65
+ /**
66
+ * Add five 32-bit integers.
67
+ *
68
+ * This uses 16-bit operations internally to work around sign problems due to JavaScript's lack of uint32 support.
69
+ *
70
+ * @param a The first 32-bit integer argument to be added.
71
+ * @param b The second 32-bit integer argument to be added.
72
+ * @param c The third 32-bit integer argument to be added.
73
+ * @param d The fourth 32-bit integer argument to be added.
74
+ * @param e The fifth 32-bit integer argument to be added.
75
+ * @returns The sum of `a` + `b` + `c` + `d` + `e`.
76
+ */
77
+ export declare function safeAdd_32_5(a: number, b: number, c: number, d: number, e: number): number;
78
+ /**
79
+ * The 32-bit implementation of the NIST specified Gamma1 function.
80
+ *
81
+ * @param x The 32-bit integer argument.
82
+ * @returns The NIST specified output of the function.
83
+ */
84
+ export declare function gamma1_32(x: number): number;
85
+ /**
86
+ * The 32-bit implementation of the NIST specified Gamma0 function.
87
+ *
88
+ * @param x The 32-bit integer argument.
89
+ * @returns The NIST specified output of the function.
90
+ */
91
+ export declare function gamma0_32(x: number): number;
92
+ /**
93
+ * The 32-bit implementation of the NIST specified Sigma1 function.
94
+ *
95
+ * @param x The 32-bit integer argument.
96
+ * @returns The NIST specified output of the function.
97
+ */
98
+ export declare function sigma1_32(x: number): number;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Int_64 is a object for 2 32-bit numbers emulating a 64-bit number.
3
+ */
4
+ export declare class Int_64 {
5
+ /**
6
+ * @param msint_32 The most significant 32-bits of a 64-bit number.
7
+ * @param lsint_32 The least significant 32-bits of a 64-bit number.
8
+ */
9
+ readonly highOrder: number;
10
+ readonly lowOrder: number;
11
+ constructor(msint_32: number, lsint_32: number);
12
+ }
13
+ /**
14
+ * The 64-bit implementation of circular rotate left.
15
+ *
16
+ * This does not work for n >= 64 or n == 32 but those are never done.
17
+ *
18
+ * @param x The 64-bit integer argument.
19
+ * @param n The number of bits to shift.
20
+ * @returns `x` shifted left circularly by `n` bits.
21
+ */
22
+ export declare function rotl_64(x: Int_64, n: number): Int_64;
23
+ /**
24
+ * The 64-bit implementation of the NIST specified Ch function.
25
+ *
26
+ * @param x The first 64-bit integer argument.
27
+ * @param y The second 64-bit integer argument.
28
+ * @param z The third 64-bit integer argument.
29
+ * @returns The NIST specified output of the function.
30
+ */
31
+ export declare function ch_64(x: Int_64, y: Int_64, z: Int_64): Int_64;
32
+ /**
33
+ * The 64-bit implementation of the NIST specified Maj function.
34
+ *
35
+ * @param x The first 64-bit integer argument.
36
+ * @param y The second 64-bit integer argument.
37
+ * @param z The third 64-bit integer argument.
38
+ * @returns The NIST specified output of the function.
39
+ */
40
+ export declare function maj_64(x: Int_64, y: Int_64, z: Int_64): Int_64;
41
+ /**
42
+ * The 64-bit implementation of the NIST specified Sigma0 function.
43
+ *
44
+ * @param x The 64-bit integer argument.
45
+ * @returns The NIST specified output of the function.
46
+ */
47
+ export declare function sigma0_64(x: Int_64): Int_64;
48
+ /**
49
+ * Add two 64-bit integers.
50
+ *
51
+ * @param x The first 64-bit integer argument to be added.
52
+ * @param y The second 64-bit integer argument to be added.
53
+ * @returns The sum of `x` + `y`.
54
+ */
55
+ export declare function safeAdd_64_2(x: Int_64, y: Int_64): Int_64;
56
+ /**
57
+ * Add four 64-bit integers.
58
+ *
59
+ * @param a The first 64-bit integer argument to be added.
60
+ * @param b The second 64-bit integer argument to be added.
61
+ * @param c The third 64-bit integer argument to be added.
62
+ * @param d The fouth 64-bit integer argument to be added.
63
+ * @returns The sum of `a` + `b` + `c` + `d`.
64
+ */
65
+ export declare function safeAdd_64_4(a: Int_64, b: Int_64, c: Int_64, d: Int_64): Int_64;
66
+ /**
67
+ * Add five 64-bit integers.
68
+ *
69
+ * @param a The first 64-bit integer argument to be added.
70
+ * @param b The second 64-bit integer argument to be added.
71
+ * @param c The third 64-bit integer argument to be added.
72
+ * @param d The fouth 64-bit integer argument to be added.
73
+ * @param e The fifth 64-bit integer argument to be added.
74
+ * @returns The sum of `a` + `b` + `c` + `d` + `e`.
75
+ */
76
+ export declare function safeAdd_64_5(a: Int_64, b: Int_64, c: Int_64, d: Int_64, e: Int_64): Int_64;
77
+ /**
78
+ * XORs two given arguments.
79
+ *
80
+ * @param a The first argument to be XORed.
81
+ * @param b The second argument to be XORed.
82
+ * @returns The The XOR `a` and `b`
83
+ */
84
+ export declare function xor_64_2(a: Int_64, b: Int_64): Int_64;
85
+ /**
86
+ * XORs five given arguments.
87
+ *
88
+ * @param a The first argument to be XORed.
89
+ * @param b The second argument to be XORed.
90
+ * @param c The third argument to be XORed.
91
+ * @param d The fourth argument to be XORed.
92
+ * @param e The fifth argument to be XORed.
93
+ * @returns The XOR of `a`, `b`, `c`, `d`, and `e`.
94
+ */
95
+ export declare function xor_64_5(a: Int_64, b: Int_64, c: Int_64, d: Int_64, e: Int_64): Int_64;
96
+ /**
97
+ * The 64-bit implementation of the NIST specified Gamma1 function.
98
+ *
99
+ * @param x The 64-bit integer argument.
100
+ * @returns The NIST specified output of the function.
101
+ */
102
+ export declare function gamma1_64(x: Int_64): Int_64;
103
+ /**
104
+ * The 64-bit implementation of the NIST specified Gamma0 function.
105
+ *
106
+ * @param x The 64-bit integer argument.
107
+ * @returns The NIST specified output of the function.
108
+ */
109
+ export declare function gamma0_64(x: Int_64): Int_64;
110
+ /**
111
+ * The 64-bit implementation of the NIST specified Sigma1 function.
112
+ *
113
+ * @param x The 64-bit integer argument.
114
+ * @returns The NIST specified output of the function.
115
+ */
116
+ export declare function sigma1_64(x: Int_64): Int_64;