@lumjs/encode 2.4.1 → 2.6.0
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/CHANGELOG.md +16 -1
- package/jsdoc.js +6 -0
- package/lib/base64.js +30 -17
- package/lib/hash.js +1 -1
- package/lib/hotp.js +3 -0
- package/lib/index.js +16 -0
- package/lib/polyfill.js +135 -0
- package/lib/sets/_inc.js +18 -0
- package/lib/sets/all.js +14 -0
- package/lib/sets/base.js +20 -0
- package/lib/sets/digest.js +16 -0
- package/lib/sets/otp.js +18 -0
- package/lib/sets/sign.js +20 -0
- package/lib/totp.js +3 -0
- package/lib/util.js +103 -84
- package/lum.build.js +24 -0
- package/package.json +73 -24
- package/tsconfig.json +12 -0
- package/types/auto/base32.d.ts +72 -0
- package/types/auto/base32.d.ts.map +1 -0
- package/types/auto/base64.d.ts +258 -0
- package/types/auto/base64.d.ts.map +1 -0
- package/types/auto/base91.d.ts +3 -0
- package/types/auto/base91.d.ts.map +1 -0
- package/types/auto/hash.d.ts +216 -0
- package/types/auto/hash.d.ts.map +1 -0
- package/types/auto/hmac.d.ts +35 -0
- package/types/auto/hmac.d.ts.map +1 -0
- package/types/auto/hotp.d.ts +42 -0
- package/types/auto/hotp.d.ts.map +1 -0
- package/types/auto/index.d.ts +2 -0
- package/types/auto/index.d.ts.map +1 -0
- package/types/auto/pem.d.ts +62 -0
- package/types/auto/pem.d.ts.map +1 -0
- package/types/auto/polyfill.d.ts +72 -0
- package/types/auto/polyfill.d.ts.map +1 -0
- package/types/auto/signature.d.ts +25 -0
- package/types/auto/signature.d.ts.map +1 -0
- package/types/auto/totp.d.ts +22 -0
- package/types/auto/totp.d.ts.map +1 -0
- package/types/auto/util.d.ts +26 -0
- package/types/auto/util.d.ts.map +1 -0
- package/types/sets/_inc.d.ts +6 -0
- package/types/sets/all.d.ts +2 -0
- package/types/sets/base.d.ts +6 -0
- package/types/sets/digest.d.ts +4 -0
- package/types/sets/otp.d.ts +5 -0
- package/types/sets/sign.d.ts +6 -0
- package/jsdoc.json +0 -33
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polyfill Ruleset
|
|
3
|
+
*/
|
|
4
|
+
export type PolyfillRuleset = {
|
|
5
|
+
/**
|
|
6
|
+
* - The target to polyfill.
|
|
7
|
+
*
|
|
8
|
+
* Class constructors are functions, class prototypes are objects.
|
|
9
|
+
* Each Ruleset may only have one target, so if you need to polyfill
|
|
10
|
+
* both static and instance methods you'll need to use an array with
|
|
11
|
+
* a Ruleset for the constructor, and a Ruleset for the prototype.
|
|
12
|
+
*/
|
|
13
|
+
into: (object | Function);
|
|
14
|
+
/**
|
|
15
|
+
* - An object containing the polyfill methods.
|
|
16
|
+
*
|
|
17
|
+
* Any method in this object that doesn't exist in the `for` target,
|
|
18
|
+
* will be added to it. As these are expected to be methods respecting
|
|
19
|
+
* the `this` context variable they should NOT be arrow (`=>`) closures.
|
|
20
|
+
*/
|
|
21
|
+
fill: object;
|
|
22
|
+
};
|
|
23
|
+
export namespace NON {
|
|
24
|
+
let native: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Polyfills for Uint8Array.
|
|
28
|
+
*
|
|
29
|
+
* This is an array of two ruleset objects:
|
|
30
|
+
*
|
|
31
|
+
* - Uint8Array
|
|
32
|
+
* - fromBase64()
|
|
33
|
+
* - fromHex()
|
|
34
|
+
* - Uint8Array.prototype
|
|
35
|
+
* - toBase64()
|
|
36
|
+
* - toHex()
|
|
37
|
+
*
|
|
38
|
+
* @alias module:@lumjs/encode/polyfill.UI8
|
|
39
|
+
* @type {PolyfillRuleset[]}
|
|
40
|
+
*/
|
|
41
|
+
export const UI8: PolyfillRuleset[];
|
|
42
|
+
export function isPolyfill(v: any): any;
|
|
43
|
+
/**
|
|
44
|
+
* Process one or more polyfill definitions.
|
|
45
|
+
* @param {(PolyfillRuleset|PolyfillRuleset[])} rules - Rulesets to apply.
|
|
46
|
+
*
|
|
47
|
+
* You can pass a single Ruleset object, or an array of associated Rulesets.
|
|
48
|
+
*
|
|
49
|
+
* @returns {Map}
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
*
|
|
53
|
+
* For these examples I'll be applying the `UI8` polyfills.
|
|
54
|
+
*
|
|
55
|
+
* **Usage if using *ESModules***:
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* import { polyfill, UI8 } from '@lumjs/encode/polyfill';
|
|
59
|
+
* polyfill(UI8);
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* **OR if using *CommonJS***:
|
|
63
|
+
*
|
|
64
|
+
* ```js
|
|
65
|
+
* const { polyfill, UI8 } = require('@lumjs/encode/polyfill');
|
|
66
|
+
* polyfill(UI8);
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @alias module:@lumjs/encode/polyfill.polyfill
|
|
70
|
+
*/
|
|
71
|
+
export function polyfill(rules: (PolyfillRuleset | PolyfillRuleset[])): Map;
|
|
72
|
+
//# sourceMappingURL=polyfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../../lib/polyfill.js"],"names":[],"mappings":";;;;;;;;;;;;UAyHU,CAAC,MAAM,WAAS,CAAC;;;;;;;;UAOjB,MAAM;;;;;AAnHhB;;;;;;;;;;;;;;GAcG;AACH,kBAFU,eAAe,EAAE,CAyBzB;AAEF,wCAGC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,gCA1BW,CAAC,eAAe,GAAC,eAAe,EAAE,CAAC,GAIjC,GAAG,CAiDf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small wrapepr class representing a crypto signature.
|
|
3
|
+
* @alias module:@lumjs/encode/signature
|
|
4
|
+
*/
|
|
5
|
+
declare class Signature {
|
|
6
|
+
/**
|
|
7
|
+
* Build a Signature instance.
|
|
8
|
+
* @param {ArrayBuffer} buffer - The signature data.
|
|
9
|
+
*/
|
|
10
|
+
constructor(buffer: ArrayBuffer);
|
|
11
|
+
buffer: ArrayBuffer;
|
|
12
|
+
/**
|
|
13
|
+
* Get the signature as a Uint8Array.
|
|
14
|
+
*/
|
|
15
|
+
get uint8Array(): Uint8Array<ArrayBuffer>;
|
|
16
|
+
/**
|
|
17
|
+
* Get the signature as an array of bytes.
|
|
18
|
+
*/
|
|
19
|
+
get byteArray(): any;
|
|
20
|
+
/**
|
|
21
|
+
* Get the signature as a Hex string.
|
|
22
|
+
*/
|
|
23
|
+
get hex(): any;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../lib/signature.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IACE;;;OAGG;IACH,oBAFW,WAAW,EAIrB;IADC,oBAAoB;IAGtB;;OAEG;IACH,0CAEC;IAED;;OAEG;IACH,qBAEC;IAED;;OAEG;IACH,eAEC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export = TOTP;
|
|
2
|
+
/**
|
|
3
|
+
* Time-based One-Time-Passwords.
|
|
4
|
+
*
|
|
5
|
+
* TODO: this needs documentation!
|
|
6
|
+
*
|
|
7
|
+
* @exports module:@lumjs/encode/totp
|
|
8
|
+
*/
|
|
9
|
+
declare class TOTP extends HOTP {
|
|
10
|
+
get defaultOptions(): ({
|
|
11
|
+
algorithm: string;
|
|
12
|
+
checkSize: number;
|
|
13
|
+
counter: number;
|
|
14
|
+
debug: number;
|
|
15
|
+
window: number;
|
|
16
|
+
} | {
|
|
17
|
+
step: number;
|
|
18
|
+
})[];
|
|
19
|
+
getExpiry(opts: any): any;
|
|
20
|
+
}
|
|
21
|
+
import HOTP = require("./hotp");
|
|
22
|
+
//# sourceMappingURL=totp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../lib/totp.js"],"names":[],"mappings":";AAKA;;;;;;GAMG;AACH;IACE;;;;;;;;SAEC;IAED,0BAEC;CAUF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function ord(string: string): number;
|
|
2
|
+
export function numByteArray(numStr: string, options?: (object | number), ...args: any[]): any[];
|
|
3
|
+
export function wordArrayToUint8Array(wordArray: WordArray): Uint8Array;
|
|
4
|
+
export function intToBytes(num: Integer): any[];
|
|
5
|
+
export function hexToBytes(hex: string, uint8?: boolean, native?: boolean): (number[] | Uint8Array);
|
|
6
|
+
export function bytesToHex(bytes: (Uint8Array | number[]), native?: boolean): string;
|
|
7
|
+
/**
|
|
8
|
+
* Convert a binary string into a TypedArray.
|
|
9
|
+
*
|
|
10
|
+
* Inspired by the str2ab() example from:
|
|
11
|
+
* https://developer.chrome.com/blog/how-to-convert-arraybuffer-to-and-from-string
|
|
12
|
+
*
|
|
13
|
+
* The biggest difference being this version supports specifying the specific
|
|
14
|
+
* TypedArray class you want to use, and it returns the TypedArray by default
|
|
15
|
+
* rather than the ArrayBuffer.
|
|
16
|
+
*
|
|
17
|
+
* To get the ArrayBuffer just use: `str2ta(string).buffer;`
|
|
18
|
+
*
|
|
19
|
+
* @param {string} str - Binary string to convert.
|
|
20
|
+
* @param {function} [typeClass=Uint8Array] TypedArray class to use;
|
|
21
|
+
* MUST be a TypedArray class constructor. Default is `Uint8Array`.
|
|
22
|
+
* @returns {TypedArray} Will be an instance of `typeClass`.
|
|
23
|
+
* @throws {TypeError} If invalid arguments were passed.
|
|
24
|
+
*/
|
|
25
|
+
export function str2ta(str: string, typeClass?: Function): TypedArray;
|
|
26
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../lib/util.js"],"names":[],"mappings":"AAsBc,4BAHH,MAAM,GACJ,MAAM,CAiClB;AAyCsB,qCApCZ,MAAM,YACN,CAAC,MAAM,GAAC,MAAM,CAAC,yBAyFzB;AAQ+B,iDAHrB,SAAS,GACP,UAAU,CAwBtB;AAWoB,gCAHV,OAAO,SAYjB;AAkBoB,gCAVV,MAAM,UACN,OAAO,WACP,OAAO,GAML,CAAC,MAAM,EAAE,GAAC,UAAU,CAAC,CAcjC;AAcoB,kCATV,CAAC,UAAU,GAAC,MAAM,EAAE,CAAC,WACrB,OAAO,GAML,MAAM,CAWlB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,4BANW,MAAM,yBAGJ,UAAU,CAoBtB"}
|
package/jsdoc.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tags":
|
|
3
|
-
{
|
|
4
|
-
"allowUnknownTags": true
|
|
5
|
-
},
|
|
6
|
-
"source":
|
|
7
|
-
{
|
|
8
|
-
"include": ["./lib"]
|
|
9
|
-
},
|
|
10
|
-
"opts":
|
|
11
|
-
{
|
|
12
|
-
"destination": "./docs/api",
|
|
13
|
-
"recurse": true
|
|
14
|
-
},
|
|
15
|
-
"plugins":
|
|
16
|
-
[
|
|
17
|
-
"plugins/markdown"
|
|
18
|
-
],
|
|
19
|
-
"templates":
|
|
20
|
-
{
|
|
21
|
-
"cleverLinks": false,
|
|
22
|
-
"monospaceLinks": false,
|
|
23
|
-
"default":
|
|
24
|
-
{
|
|
25
|
-
"outputSourceFiles": true
|
|
26
|
-
},
|
|
27
|
-
"path": "ink-docstrap",
|
|
28
|
-
"theme": "cerulean",
|
|
29
|
-
"navType": "vertical",
|
|
30
|
-
"linenums": true,
|
|
31
|
-
"dateFormat": "YYYY-MM-DD, hh:mm:ss"
|
|
32
|
-
}
|
|
33
|
-
}
|