@nmshd/core-types 7.0.0-alpha.14 → 7.0.0-alpha.16
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/dist/PasswordLocationIndicator.d.ts +14 -0
- package/dist/PasswordLocationIndicator.d.ts.map +1 -0
- package/dist/PasswordLocationIndicator.js +14 -0
- package/dist/PasswordLocationIndicator.js.map +1 -0
- package/dist/SharedPasswordProtection.d.ts +2 -0
- package/dist/SharedPasswordProtection.d.ts.map +1 -1
- package/dist/SharedPasswordProtection.js +11 -4
- package/dist/SharedPasswordProtection.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type Enumerate<N extends number, Acc extends number[] = []> = Acc["length"] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc["length"]]>;
|
|
2
|
+
type IntRange<From extends number, To extends number> = Exclude<Enumerate<To>, Enumerate<From>>;
|
|
3
|
+
export declare enum PasswordLocationIndicatorOptions {
|
|
4
|
+
RecoveryKit = 0,
|
|
5
|
+
Self = 1,
|
|
6
|
+
Letter = 2,
|
|
7
|
+
RegistrationLetter = 3,
|
|
8
|
+
Email = 4,
|
|
9
|
+
SMS = 5,
|
|
10
|
+
Website = 6
|
|
11
|
+
}
|
|
12
|
+
export type PasswordLocationIndicator = keyof typeof PasswordLocationIndicatorOptions | IntRange<50, 100>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=PasswordLocationIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordLocationIndicator.d.ts","sourceRoot":"","sources":["../src/PasswordLocationIndicator.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC5I,KAAK,QAAQ,CAAC,IAAI,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAEhG,oBAAY,gCAAgC;IACxC,WAAW,IAAI;IACf,IAAI,IAAI;IACR,MAAM,IAAI;IACV,kBAAkB,IAAI;IACtB,KAAK,IAAI;IACT,GAAG,IAAI;IACP,OAAO,IAAI;CACd;AAED,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,gCAAgC,GAAG,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PasswordLocationIndicatorOptions = void 0;
|
|
4
|
+
var PasswordLocationIndicatorOptions;
|
|
5
|
+
(function (PasswordLocationIndicatorOptions) {
|
|
6
|
+
PasswordLocationIndicatorOptions[PasswordLocationIndicatorOptions["RecoveryKit"] = 0] = "RecoveryKit";
|
|
7
|
+
PasswordLocationIndicatorOptions[PasswordLocationIndicatorOptions["Self"] = 1] = "Self";
|
|
8
|
+
PasswordLocationIndicatorOptions[PasswordLocationIndicatorOptions["Letter"] = 2] = "Letter";
|
|
9
|
+
PasswordLocationIndicatorOptions[PasswordLocationIndicatorOptions["RegistrationLetter"] = 3] = "RegistrationLetter";
|
|
10
|
+
PasswordLocationIndicatorOptions[PasswordLocationIndicatorOptions["Email"] = 4] = "Email";
|
|
11
|
+
PasswordLocationIndicatorOptions[PasswordLocationIndicatorOptions["SMS"] = 5] = "SMS";
|
|
12
|
+
PasswordLocationIndicatorOptions[PasswordLocationIndicatorOptions["Website"] = 6] = "Website";
|
|
13
|
+
})(PasswordLocationIndicatorOptions || (exports.PasswordLocationIndicatorOptions = PasswordLocationIndicatorOptions = {}));
|
|
14
|
+
//# sourceMappingURL=PasswordLocationIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordLocationIndicator.js","sourceRoot":"","sources":["../src/PasswordLocationIndicator.ts"],"names":[],"mappings":";;;AAGA,IAAY,gCAQX;AARD,WAAY,gCAAgC;IACxC,qGAAe,CAAA;IACf,uFAAQ,CAAA;IACR,2FAAU,CAAA;IACV,mHAAsB,CAAA;IACtB,yFAAS,CAAA;IACT,qFAAO,CAAA;IACP,6FAAW,CAAA;AACf,CAAC,EARW,gCAAgC,gDAAhC,gCAAgC,QAQ3C"}
|
|
@@ -3,10 +3,12 @@ import { CoreBuffer, ICoreBuffer } from "@nmshd/crypto";
|
|
|
3
3
|
export interface ISharedPasswordProtection extends ISerializable {
|
|
4
4
|
passwordType: "pw" | `pin${number}`;
|
|
5
5
|
salt: ICoreBuffer;
|
|
6
|
+
passwordLocationIndicator?: number;
|
|
6
7
|
}
|
|
7
8
|
export declare class SharedPasswordProtection extends Serializable implements ISharedPasswordProtection {
|
|
8
9
|
passwordType: "pw" | `pin${number}`;
|
|
9
10
|
salt: CoreBuffer;
|
|
11
|
+
passwordLocationIndicator?: number;
|
|
10
12
|
static from(value: ISharedPasswordProtection): SharedPasswordProtection;
|
|
11
13
|
static fromTruncated(value?: string): SharedPasswordProtection | undefined;
|
|
12
14
|
truncate(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedPasswordProtection.d.ts","sourceRoot":"","sources":["../src/SharedPasswordProtection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC5D,YAAY,EAAE,IAAI,GAAG,MAAM,MAAM,EAAE,CAAC;IACpC,IAAI,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"SharedPasswordProtection.d.ts","sourceRoot":"","sources":["../src/SharedPasswordProtection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC5D,YAAY,EAAE,IAAI,GAAG,MAAM,MAAM,EAAE,CAAC;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,qBAAa,wBAAyB,SAAQ,YAAa,YAAW,yBAAyB;IAGpF,YAAY,EAAE,IAAI,GAAG,MAAM,MAAM,EAAE,CAAC;IAIpC,IAAI,EAAE,UAAU,CAAC;IAIjB,yBAAyB,CAAC,EAAE,MAAM,CAAC;WAE5B,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,wBAAwB;WAIhE,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAmB1E,QAAQ,IAAI,MAAM;CAI5B"}
|
|
@@ -21,20 +21,22 @@ class SharedPasswordProtection extends ts_serval_1.Serializable {
|
|
|
21
21
|
if (value === undefined || value === "")
|
|
22
22
|
return undefined;
|
|
23
23
|
const splittedPasswordParts = value.split("&");
|
|
24
|
-
if (splittedPasswordParts.length !== 2) {
|
|
25
|
-
throw new CoreError_1.CoreError("error.core-types.invalidTruncatedReference", "The password part of a TruncatedReference must consist of exactly 2 components.");
|
|
24
|
+
if (splittedPasswordParts.length !== 2 && splittedPasswordParts.length !== 3) {
|
|
25
|
+
throw new CoreError_1.CoreError("error.core-types.invalidTruncatedReference", "The password part of a TruncatedReference must consist of exactly 2 or 3 components.");
|
|
26
26
|
}
|
|
27
27
|
const passwordType = splittedPasswordParts[0];
|
|
28
|
+
const passwordLocationIndicator = splittedPasswordParts.length === 3 ? parseInt(splittedPasswordParts[2]) : undefined;
|
|
28
29
|
try {
|
|
29
30
|
const salt = crypto_1.CoreBuffer.fromBase64(splittedPasswordParts[1]);
|
|
30
|
-
return SharedPasswordProtection.from({ passwordType, salt });
|
|
31
|
+
return SharedPasswordProtection.from({ passwordType, salt, passwordLocationIndicator });
|
|
31
32
|
}
|
|
32
33
|
catch (_) {
|
|
33
34
|
throw new CoreError_1.CoreError("error.core-types.invalidTruncatedReference", "The salt needs to be a Base64 value.");
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
truncate() {
|
|
37
|
-
|
|
38
|
+
const passwordLocationIndicatorPart = this.passwordLocationIndicator !== undefined ? `&${this.passwordLocationIndicator}` : "";
|
|
39
|
+
return `${this.passwordType}&${this.salt.toBase64()}${passwordLocationIndicatorPart}`;
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
exports.SharedPasswordProtection = SharedPasswordProtection;
|
|
@@ -48,4 +50,9 @@ __decorate([
|
|
|
48
50
|
(0, ts_serval_1.serialize)(),
|
|
49
51
|
__metadata("design:type", crypto_1.CoreBuffer)
|
|
50
52
|
], SharedPasswordProtection.prototype, "salt", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, ts_serval_1.validate)({ nullable: true, min: 0, max: 99, customValidator: (v) => (!Number.isInteger(v) ? "This value must be an integer." : undefined) }),
|
|
55
|
+
(0, ts_serval_1.serialize)({ any: true }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], SharedPasswordProtection.prototype, "passwordLocationIndicator", void 0);
|
|
51
58
|
//# sourceMappingURL=SharedPasswordProtection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedPasswordProtection.js","sourceRoot":"","sources":["../src/SharedPasswordProtection.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA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C;IAEM,QAAQ;QACX,MAAM,6BAA6B,GAAG,IAAI,CAAC,yBAAyB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/H,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,6BAA6B,EAAE,CAAC;IAC1F,CAAC;CACJ;AAxCD,4DAwCC;AArCU;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;AAIjB;IAFN,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;IAC5I,IAAA,qBAAS,EAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;;2EACiB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./CoreDate";
|
|
|
3
3
|
export * from "./CoreError";
|
|
4
4
|
export * from "./CoreId";
|
|
5
5
|
export * from "./CoreIdHelper";
|
|
6
|
+
export * from "./PasswordLocationIndicator";
|
|
6
7
|
export * from "./Random";
|
|
7
8
|
export * from "./references";
|
|
8
9
|
export * from "./SharedPasswordProtection";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./CoreDate"), exports);
|
|
|
19
19
|
__exportStar(require("./CoreError"), exports);
|
|
20
20
|
__exportStar(require("./CoreId"), exports);
|
|
21
21
|
__exportStar(require("./CoreIdHelper"), exports);
|
|
22
|
+
__exportStar(require("./PasswordLocationIndicator"), exports);
|
|
22
23
|
__exportStar(require("./Random"), exports);
|
|
23
24
|
__exportStar(require("./references"), exports);
|
|
24
25
|
__exportStar(require("./SharedPasswordProtection"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,6CAA2B;AAC3B,8CAA4B;AAC5B,2CAAyB;AACzB,iDAA+B;AAC/B,2CAAyB;AACzB,+CAA6B;AAC7B,6DAA2C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,6CAA2B;AAC3B,8CAA4B;AAC5B,2CAAyB;AACzB,iDAA+B;AAC/B,8DAA4C;AAC5C,2CAAyB;AACzB,+CAA6B;AAC7B,6DAA2C"}
|
package/package.json
CHANGED