@nmshd/transport 7.0.0-alpha.3 → 7.0.0-alpha.5

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 (81) hide show
  1. package/dist/buildInformation.js +5 -5
  2. package/dist/core/TransportIds.d.ts +1 -1
  3. package/dist/core/TransportIds.d.ts.map +1 -1
  4. package/dist/core/TransportIds.js +6 -6
  5. package/dist/core/TransportIds.js.map +1 -1
  6. package/dist/core/backbone/BackboneIds.d.ts +1 -1
  7. package/dist/core/backbone/BackboneIds.d.ts.map +1 -1
  8. package/dist/core/backbone/BackboneIds.js +7 -7
  9. package/dist/core/backbone/BackboneIds.js.map +1 -1
  10. package/dist/core/backbone/RESTClient.d.ts.map +1 -1
  11. package/dist/core/backbone/RESTClient.js +2 -2
  12. package/dist/core/backbone/RESTClient.js.map +1 -1
  13. package/dist/core/index.d.ts +0 -2
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js +0 -2
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/core/types/PasswordProtection.d.ts +1 -1
  18. package/dist/core/types/PasswordProtection.d.ts.map +1 -1
  19. package/dist/core/types/PasswordProtection.js +2 -2
  20. package/dist/core/types/PasswordProtection.js.map +1 -1
  21. package/dist/core/types/index.d.ts +0 -1
  22. package/dist/core/types/index.d.ts.map +1 -1
  23. package/dist/core/types/index.js +0 -1
  24. package/dist/core/types/index.js.map +1 -1
  25. package/dist/modules/files/FileController.d.ts +1 -2
  26. package/dist/modules/files/FileController.d.ts.map +1 -1
  27. package/dist/modules/files/FileController.js +1 -2
  28. package/dist/modules/files/FileController.js.map +1 -1
  29. package/dist/modules/files/local/File.d.ts +1 -2
  30. package/dist/modules/files/local/File.d.ts.map +1 -1
  31. package/dist/modules/files/local/File.js +1 -2
  32. package/dist/modules/files/local/File.js.map +1 -1
  33. package/dist/modules/index.d.ts +0 -1
  34. package/dist/modules/index.d.ts.map +1 -1
  35. package/dist/modules/index.js +0 -1
  36. package/dist/modules/index.js.map +1 -1
  37. package/dist/modules/messages/MessageController.d.ts.map +1 -1
  38. package/dist/modules/messages/MessageController.js.map +1 -1
  39. package/dist/modules/messages/transmission/MessageContentWrapper.d.ts +1 -2
  40. package/dist/modules/messages/transmission/MessageContentWrapper.d.ts.map +1 -1
  41. package/dist/modules/messages/transmission/MessageContentWrapper.js +1 -2
  42. package/dist/modules/messages/transmission/MessageContentWrapper.js.map +1 -1
  43. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.d.ts +1 -1
  44. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.d.ts.map +1 -1
  45. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js +2 -1
  46. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js.map +1 -1
  47. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.d.ts +1 -2
  48. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.d.ts.map +1 -1
  49. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.js +1 -2
  50. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.js.map +1 -1
  51. package/dist/modules/tokens/transmission/TokenReference.d.ts +1 -1
  52. package/dist/modules/tokens/transmission/TokenReference.d.ts.map +1 -1
  53. package/dist/modules/tokens/transmission/TokenReference.js +2 -1
  54. package/dist/modules/tokens/transmission/TokenReference.js.map +1 -1
  55. package/dist/util/PasswordGenerator.js +10 -10
  56. package/dist/util/PasswordGenerator.js.map +1 -1
  57. package/dist/util/index.d.ts +0 -1
  58. package/dist/util/index.d.ts.map +1 -1
  59. package/dist/util/index.js +0 -1
  60. package/dist/util/index.js.map +1 -1
  61. package/package.json +5 -5
  62. package/dist/core/CoreIdHelper.d.ts +0 -12
  63. package/dist/core/CoreIdHelper.d.ts.map +0 -1
  64. package/dist/core/CoreIdHelper.js +0 -34
  65. package/dist/core/CoreIdHelper.js.map +0 -1
  66. package/dist/core/Reference.d.ts +0 -25
  67. package/dist/core/Reference.d.ts.map +0 -1
  68. package/dist/core/Reference.js +0 -101
  69. package/dist/core/Reference.js.map +0 -1
  70. package/dist/core/types/SharedPasswordProtection.d.ts +0 -14
  71. package/dist/core/types/SharedPasswordProtection.d.ts.map +0 -1
  72. package/dist/core/types/SharedPasswordProtection.js +0 -51
  73. package/dist/core/types/SharedPasswordProtection.js.map +0 -1
  74. package/dist/modules/files/transmission/FileReference.d.ts +0 -8
  75. package/dist/modules/files/transmission/FileReference.d.ts.map +0 -1
  76. package/dist/modules/files/transmission/FileReference.js +0 -25
  77. package/dist/modules/files/transmission/FileReference.js.map +0 -1
  78. package/dist/util/Random.d.ts +0 -51
  79. package/dist/util/Random.d.ts.map +0 -1
  80. package/dist/util/Random.js +0 -128
  81. package/dist/util/Random.js.map +0 -1
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SharedPasswordProtection = void 0;
13
- const ts_serval_1 = require("@js-soft/ts-serval");
14
- const crypto_1 = require("@nmshd/crypto");
15
- const TransportCoreErrors_1 = require("../TransportCoreErrors");
16
- class SharedPasswordProtection extends ts_serval_1.Serializable {
17
- static from(value) {
18
- return this.fromAny(value);
19
- }
20
- static fromTruncated(value) {
21
- if (value === undefined || value === "")
22
- return undefined;
23
- const splittedPasswordParts = value.split("&");
24
- if (splittedPasswordParts.length !== 2) {
25
- throw TransportCoreErrors_1.TransportCoreErrors.general.invalidTruncatedReference("The password part of a TruncatedReference must consist of exactly 2 components.");
26
- }
27
- const passwordType = splittedPasswordParts[0];
28
- try {
29
- const salt = crypto_1.CoreBuffer.fromBase64(splittedPasswordParts[1]);
30
- return SharedPasswordProtection.from({ passwordType, salt });
31
- }
32
- catch (_) {
33
- throw TransportCoreErrors_1.TransportCoreErrors.general.invalidTruncatedReference("The salt needs to be a Base64 value.");
34
- }
35
- }
36
- truncate() {
37
- return `${this.passwordType}&${this.salt.toBase64()}`;
38
- }
39
- }
40
- exports.SharedPasswordProtection = SharedPasswordProtection;
41
- __decorate([
42
- (0, ts_serval_1.validate)({ regExp: /^(pw|pin(4|5|6|7|8|9|10|11|12|13|14|15|16))$/ }),
43
- (0, ts_serval_1.serialize)(),
44
- __metadata("design:type", String)
45
- ], SharedPasswordProtection.prototype, "passwordType", void 0);
46
- __decorate([
47
- (0, ts_serval_1.validate)({ customValidator: (v) => (v.buffer.byteLength === 16 ? undefined : "must be 16 bytes long") }),
48
- (0, ts_serval_1.serialize)(),
49
- __metadata("design:type", crypto_1.CoreBuffer)
50
- ], SharedPasswordProtection.prototype, "salt", void 0);
51
- //# sourceMappingURL=SharedPasswordProtection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SharedPasswordProtection.js","sourceRoot":"","sources":["../../../src/core/types/SharedPasswordProtection.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAsF;AACtF,0CAAwD;AACxD,gEAA6D;AAO7D,MAAa,wBAAyB,SAAQ,wBAAY;IAS/C,MAAM,CAAC,IAAI,CAAC,KAAgC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,KAAc;QACtC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,SAAS,CAAC;QAE1D,MAAM,qBAAqB,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,yCAAmB,CAAC,OAAO,CAAC,yBAAyB,CAAC,iFAAiF,CAAC,CAAC;QACnJ,CAAC;QAED,MAAM,YAAY,GAAG,qBAAqB,CAAC,CAAC,CAA0B,CAAC;QACvE,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,mBAAU,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,OAAO,wBAAwB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,yCAAmB,CAAC,OAAO,CAAC,yBAAyB,CAAC,sCAAsC,CAAC,CAAC;QACxG,CAAC;IACL,CAAC;IAEM,QAAQ;QACX,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC1D,CAAC;CACJ;AAjCD,4DAiCC;AA9BU;IAFN,IAAA,oBAAQ,EAAC,EAAE,MAAM,EAAE,8CAA8C,EAAE,CAAC;IACpE,IAAA,qBAAS,GAAE;;8DAC+B;AAIpC;IAFN,IAAA,oBAAQ,EAAC,EAAE,eAAe,EAAE,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,EAAE,CAAC;IACrH,IAAA,qBAAS,GAAE;8BACC,mBAAU;sDAAC"}
@@ -1,8 +0,0 @@
1
- import { IReference, Reference } from "../../../core";
2
- export interface IFileReference extends IReference {
3
- }
4
- export declare class FileReference extends Reference implements IFileReference {
5
- protected static preFrom(value: any): any;
6
- static from(value: IFileReference | string): FileReference;
7
- }
8
- //# sourceMappingURL=FileReference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileReference.d.ts","sourceRoot":"","sources":["../../../../src/modules/files/transmission/FileReference.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEnE,MAAM,WAAW,cAAe,SAAQ,UAAU;CAAG;AAErD,qBACa,aAAc,SAAQ,SAAU,YAAW,cAAc;qBACxC,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG;WAM3B,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,aAAa;CAG7E"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.FileReference = void 0;
10
- const ts_serval_1 = require("@js-soft/ts-serval");
11
- const core_1 = require("../../../core");
12
- let FileReference = class FileReference extends core_1.Reference {
13
- static preFrom(value) {
14
- super.validateId(value, core_1.BackboneIds.file);
15
- return value;
16
- }
17
- static from(value) {
18
- return super.from(value);
19
- }
20
- };
21
- exports.FileReference = FileReference;
22
- exports.FileReference = FileReference = __decorate([
23
- (0, ts_serval_1.type)("FileReference")
24
- ], FileReference);
25
- //# sourceMappingURL=FileReference.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileReference.js","sourceRoot":"","sources":["../../../../src/modules/files/transmission/FileReference.ts"],"names":[],"mappings":";;;;;;;;;AAAA,kDAA0C;AAC1C,wCAAmE;AAK5D,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,gBAAS;IAC9B,MAAM,CAAU,OAAO,CAAC,KAAU;QACxC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,kBAAW,CAAC,IAAI,CAAC,CAAC;QAE1C,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,MAAM,CAAU,IAAI,CAAC,KAA8B;QACtD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAA;AAVY,sCAAa;wBAAb,aAAa;IADzB,IAAA,gBAAI,EAAC,eAAe,CAAC;GACT,aAAa,CAUzB"}
@@ -1,51 +0,0 @@
1
- import { ICoreBuffer } from "@nmshd/crypto";
2
- export declare enum RandomCharacterRange {
3
- Digit = "0123456789",
4
- DigitEase = "123456789",
5
- Hex = "0123456789ABCDEF",
6
- LowerCase = "abcdefghijklmnopqrstuvwxyz",
7
- LowerCaseEase = "abcdefghijkmnpqrstuvwxyz",
8
- UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
9
- UpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ",
10
- Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
11
- Alphanumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
12
- AlphanumericEase = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789",
13
- AlphanumericUpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789",
14
- GermanUmlaut = "\u00C4\u00D6\u00DC\u00E4\u00F6\u00FC",
15
- SpecialCharacters = "!?-_.:,;#+"
16
- }
17
- export interface RandomCharacterBucket {
18
- minLength: number;
19
- maxLength: number;
20
- allowedChars: string | string[];
21
- }
22
- export interface IRandom {
23
- }
24
- export interface IRandomStatic {
25
- new (): IRandom;
26
- bytes(length: number): Promise<ICoreBuffer>;
27
- int(length: number): Promise<number>;
28
- array(length: number): Promise<any>;
29
- uuid(): Promise<string>;
30
- scramble(input: string): Promise<string>;
31
- intBetween(min: number, max: number): Promise<number>;
32
- intRandomLength(minLength: number, maxLength: number): Promise<number>;
33
- scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
34
- stringWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
35
- string(length: number, allowedChars?: string | string[]): Promise<string>;
36
- stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise<string>;
37
- }
38
- export declare class Random implements IRandom {
39
- static bytes(length: number): Promise<ICoreBuffer>;
40
- static int(length: number): Promise<number>;
41
- static array(length: number): Promise<any>;
42
- static uuid(): string;
43
- static scramble(input: string): Promise<string>;
44
- static intBetween(min: number, max: number): Promise<number>;
45
- static intRandomLength(minLength: number, maxLength: number): Promise<number>;
46
- static scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
47
- static stringWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
48
- static string(length: number, allowedChars?: string | string[]): Promise<string>;
49
- static stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise<string>;
50
- }
51
- //# sourceMappingURL=Random.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Random.d.ts","sourceRoot":"","sources":["../../src/util/Random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAC;AAG1D,oBAAY,oBAAoB;IAC5B,KAAK,eAAe;IACpB,SAAS,cAAc;IACvB,GAAG,qBAAqB;IACxB,SAAS,+BAA+B;IACxC,aAAa,6BAA6B;IAC1C,SAAS,+BAA+B;IACxC,aAAa,6BAA6B;IAC1C,QAAQ,yDAAyD;IACjE,YAAY,mEAAmE;IAE/E,gBAAgB,8DAA8D;IAC9E,yBAAyB,uCAAuC;IAChE,YAAY,yCAAW;IACvB,iBAAiB,eAAe;CACnC;AAED,MAAM,WAAW,q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E,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;WAG3C,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAMpC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;WAIzC,IAAI,IAAI,MAAM;WAIR,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAYxC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WA0BrD,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAOtE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;WAKtE,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;WAQpE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,GAAE,MAAM,GAAG,MAAM,EAAsC,GAAG,OAAO,CAAC,MAAM,CAAC;WAyB5G,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAYlI"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Random = exports.RandomCharacterRange = void 0;
4
- const crypto_1 = require("@nmshd/crypto");
5
- const uuid_1 = require("uuid");
6
- var RandomCharacterRange;
7
- (function (RandomCharacterRange) {
8
- RandomCharacterRange["Digit"] = "0123456789";
9
- RandomCharacterRange["DigitEase"] = "123456789";
10
- RandomCharacterRange["Hex"] = "0123456789ABCDEF";
11
- RandomCharacterRange["LowerCase"] = "abcdefghijklmnopqrstuvwxyz";
12
- RandomCharacterRange["LowerCaseEase"] = "abcdefghijkmnpqrstuvwxyz";
13
- RandomCharacterRange["UpperCase"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
14
- RandomCharacterRange["UpperCaseEase"] = "ABCDEFGHJKLMNPQRSTUVWXYZ";
15
- RandomCharacterRange["Alphabet"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
16
- RandomCharacterRange["Alphanumeric"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
17
- // Without I, l, O, o, 0
18
- RandomCharacterRange["AlphanumericEase"] = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789";
19
- RandomCharacterRange["AlphanumericUpperCaseEase"] = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789";
20
- RandomCharacterRange["GermanUmlaut"] = "\u00C4\u00D6\u00DC\u00E4\u00F6\u00FC";
21
- RandomCharacterRange["SpecialCharacters"] = "!?-_.:,;#+";
22
- })(RandomCharacterRange || (exports.RandomCharacterRange = RandomCharacterRange = {}));
23
- class Random {
24
- static async bytes(length) {
25
- return await crypto_1.CryptoRandom.bytes(length);
26
- }
27
- static async int(length) {
28
- if (length > 21 || length <= 0) {
29
- throw new Error("Length must be between 1 and 21.");
30
- }
31
- return parseInt(await this.string(length, RandomCharacterRange.Digit));
32
- }
33
- static async array(length) {
34
- return (await crypto_1.CryptoRandom.bytes(length)).toArray();
35
- }
36
- static uuid() {
37
- return (0, uuid_1.v4)();
38
- }
39
- static async scramble(input) {
40
- const out = [];
41
- const inar = input.split("");
42
- const length = input.length;
43
- for (let i = 0; i < length - 1; i++) {
44
- const charAt = await Random.intBetween(0, length - 1 - i);
45
- out.push(inar.splice(charAt, 1)[0]);
46
- }
47
- out.push(inar[0]);
48
- return out.join("");
49
- }
50
- static async intBetween(min, max) {
51
- if (max <= min) {
52
- throw new Error("Max must be larger than min.");
53
- }
54
- const diff = max - min + 1;
55
- const bitLength = Math.abs(Math.ceil(Math.log2(diff)));
56
- if (bitLength > 32) {
57
- throw new Error("The range between the numbers is too big, 32 bit is the maximum -> 4294967296");
58
- }
59
- const byteLength = Math.ceil(bitLength / 8);
60
- const bitMask = Math.pow(2, bitLength) - 1;
61
- const randomArray = await this.bytes(byteLength);
62
- let value = 0;
63
- let p = (byteLength - 1) * 8;
64
- for (let i = 0; i < byteLength; i++) {
65
- value += randomArray.buffer[i] * Math.pow(2, p);
66
- p -= 8;
67
- }
68
- value = value & bitMask;
69
- if (value >= diff) {
70
- return await this.intBetween(min, max);
71
- }
72
- return min + value;
73
- }
74
- static async intRandomLength(minLength, maxLength) {
75
- if (maxLength > 21) {
76
- throw new Error("Max must be below 22.");
77
- }
78
- return parseInt(await this.stringRandomLength(minLength, maxLength, RandomCharacterRange.Digit));
79
- }
80
- static async scrambleWithBuckets(buckets) {
81
- const str = await this.stringWithBuckets(buckets);
82
- return await this.scramble(str);
83
- }
84
- static async stringWithBuckets(buckets) {
85
- const str = [];
86
- for (const bucket of buckets) {
87
- str.push(await this.stringRandomLength(bucket.minLength, bucket.maxLength, bucket.allowedChars));
88
- }
89
- return str.join("");
90
- }
91
- static async string(length, allowedChars = RandomCharacterRange.Alphanumeric) {
92
- if (length <= 0)
93
- return "";
94
- if (allowedChars.length > 256) {
95
- throw new Error("Input exceeds maximum length of 256.");
96
- }
97
- const ar = [];
98
- const inputLength = allowedChars.length;
99
- const random = await this.array(length + 10);
100
- const max = 255 - (255 % inputLength);
101
- for (let i = 0; i < length; i++) {
102
- const nmb = random[i];
103
- if (nmb > max) {
104
- // Reject random value to remove bias if we are at the
105
- // upper (and incomplete end) of possible random values
106
- continue;
107
- }
108
- ar.push(allowedChars[nmb % inputLength]);
109
- }
110
- let retStr = ar.join("");
111
- if (retStr.length < length) {
112
- retStr += await this.string(length - retStr.length, allowedChars);
113
- }
114
- return retStr;
115
- }
116
- static async stringRandomLength(minLength, maxLength, allowedChars) {
117
- if (minLength > maxLength) {
118
- throw new Error("maxLength must be larger than minLength.");
119
- }
120
- if (minLength < 0) {
121
- throw new Error("minlength must not be less than zero.");
122
- }
123
- const length = maxLength > minLength ? await this.intBetween(minLength, maxLength) : maxLength;
124
- return await this.string(length, allowedChars);
125
- }
126
- }
127
- exports.Random = Random;
128
- //# sourceMappingURL=Random.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Random.js","sourceRoot":"","sources":["../../src/util/Random.ts"],"names":[],"mappings":";;;AAAA,0CAA0D;AAC1D,+BAAoC;AAEpC,IAAY,oBAeX;AAfD,WAAY,oBAAoB;IAC5B,4CAAoB,CAAA;IACpB,+CAAuB,CAAA;IACvB,gDAAwB,CAAA;IACxB,gEAAwC,CAAA;IACxC,kEAA0C,CAAA;IAC1C,gEAAwC,CAAA;IACxC,kEAA0C,CAAA;IAC1C,yFAAiE,CAAA;IACjE,uGAA+E,CAAA;IAC/E,wBAAwB;IACxB,sGAA8E,CAAA;IAC9E,wFAAgE,CAAA;IAChE,6EAAuB,CAAA;IACvB,wDAAgC,CAAA;AACpC,CAAC,EAfW,oBAAoB,oCAApB,oBAAoB,QAe/B;AAyBD,MAAa,MAAM;IACR,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAc;QACpC,OAAO,MAAM,qBAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAc;QAClC,IAAI,MAAM,GAAG,EAAE,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAc;QACpC,OAAO,CAAC,MAAM,qBAAY,CAAC,KAAK,CAAC,MAAM,CAA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