@degenerate/generic 0.1.2 → 0.1.4
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/_settings/authorization-settings.d.ts +17 -0
- package/dist/_settings/authorization-settings.d.ts.map +1 -0
- package/dist/_settings/authorization-settings.js +20 -0
- package/dist/_settings/cryptography-settings.d.ts +15 -3
- package/dist/_settings/cryptography-settings.d.ts.map +1 -1
- package/dist/_settings/cryptography-settings.js +16 -2
- package/dist/application/database/firestore/generics/get-items-from-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-items-from-database.js +0 -3
- package/dist/authorization/index.d.ts +24 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +61 -0
- package/dist/authorization/jwt/keys/create-public-key-pem.d.ts +9 -0
- package/dist/authorization/jwt/keys/create-public-key-pem.d.ts.map +1 -0
- package/dist/authorization/jwt/keys/create-public-key-pem.js +25 -0
- package/dist/authorization/jwt/keys/create-secret-key-pem.d.ts +9 -0
- package/dist/authorization/jwt/keys/create-secret-key-pem.d.ts.map +1 -0
- package/dist/authorization/jwt/keys/create-secret-key-pem.js +24 -0
- package/dist/authorization/jwt/sign/create-authorization-issuer.d.ts +10 -0
- package/dist/authorization/jwt/sign/create-authorization-issuer.d.ts.map +1 -0
- package/dist/authorization/jwt/sign/create-authorization-issuer.js +26 -0
- package/dist/authorization/jwt/sign/create-authorization-subject.d.ts +12 -0
- package/dist/authorization/jwt/sign/create-authorization-subject.d.ts.map +1 -0
- package/dist/authorization/jwt/sign/create-authorization-subject.js +19 -0
- package/dist/authorization/jwt/sign/create-jwt-options.d.ts +17 -0
- package/dist/authorization/jwt/sign/create-jwt-options.d.ts.map +1 -0
- package/dist/authorization/jwt/sign/create-jwt-options.js +43 -0
- package/dist/authorization/jwt/sign/create-jwt-signed-token.d.ts +13 -0
- package/dist/authorization/jwt/sign/create-jwt-signed-token.d.ts.map +1 -0
- package/dist/authorization/jwt/sign/create-jwt-signed-token.js +22 -0
- package/dist/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts +10 -0
- package/dist/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts.map +1 -0
- package/dist/authorization/jwt/transform/transform-token-payload-to-safe-payload.js +31 -0
- package/dist/authorization/jwt/verify/get-decoded-jwt-header.d.ts +10 -0
- package/dist/authorization/jwt/verify/get-decoded-jwt-header.d.ts.map +1 -0
- package/dist/authorization/jwt/verify/get-decoded-jwt-header.js +20 -0
- package/dist/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts +9 -0
- package/dist/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts.map +1 -0
- package/dist/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.js +17 -0
- package/dist/authorization/jwt/verify/verify-jwt-signed-token.d.ts +12 -0
- package/dist/authorization/jwt/verify/verify-jwt-signed-token.d.ts.map +1 -0
- package/dist/authorization/jwt/verify/verify-jwt-signed-token.js +34 -0
- package/dist/authorization/safe/authorization/authorized-authorities.d.ts +39 -0
- package/dist/authorization/safe/authorization/authorized-authorities.d.ts.map +1 -0
- package/dist/authorization/safe/authorization/authorized-authorities.js +56 -0
- package/dist/authorization/safe/request/decode-bearer-token.d.ts +11 -0
- package/dist/authorization/safe/request/decode-bearer-token.d.ts.map +1 -0
- package/dist/authorization/safe/request/decode-bearer-token.js +31 -0
- package/dist/authorization/safe/request/decode-safe-request.d.ts +11 -0
- package/dist/authorization/safe/request/decode-safe-request.d.ts.map +1 -0
- package/dist/authorization/safe/request/decode-safe-request.js +30 -0
- package/dist/authorization/safe/request/determine-issuer-from-request.d.ts +10 -0
- package/dist/authorization/safe/request/determine-issuer-from-request.d.ts.map +1 -0
- package/dist/authorization/safe/request/determine-issuer-from-request.js +29 -0
- package/dist/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts +12 -0
- package/dist/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts.map +1 -0
- package/dist/authorization/safe/request/issuer/determine-issuer-from-bearer-token.js +30 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts +10 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-audience.js +24 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts +8 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.js +23 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts +9 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.js +24 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts +10 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issuer.js +25 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts +8 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.js +23 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts +10 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-subject.js +22 -0
- package/dist/authorization/safe/validation/jwt/verify-token-header.d.ts +9 -0
- package/dist/authorization/safe/validation/jwt/verify-token-header.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/verify-token-header.js +25 -0
- package/dist/authorization/safe/validation/jwt/verify-token-payload.d.ts +11 -0
- package/dist/authorization/safe/validation/jwt/verify-token-payload.d.ts.map +1 -0
- package/dist/authorization/safe/validation/jwt/verify-token-payload.js +30 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +1 -0
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +1 -1
- package/dist/crypto/private-public-keys/generation/create-256-private-key-from-mnemonic.d.ts +1 -1
- package/dist/crypto/private-public-keys/generation/create-256-private-key-from-mnemonic.js +1 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +1 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +1 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +3 -2
- package/dist/crypto/private-public-keys/generation/create-random-512-key-pair.d.ts +9 -0
- package/dist/crypto/private-public-keys/generation/create-random-512-key-pair.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/generation/create-random-512-key-pair.js +46 -0
- package/dist/errors/authorization/authorization-errors.d.ts +106 -0
- package/dist/errors/authorization/authorization-errors.d.ts.map +1 -0
- package/dist/errors/authorization/authorization-errors.js +160 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/safe/safe-rules-errors.d.ts +72 -0
- package/dist/errors/safe/safe-rules-errors.d.ts.map +1 -1
- package/dist/errors/safe/safe-rules-errors.js +113 -1
- package/dist/helpers/crypto/cryptography-helpers.d.ts +37 -0
- package/dist/helpers/crypto/cryptography-helpers.d.ts.map +1 -0
- package/dist/helpers/crypto/cryptography-helpers.js +65 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/object-validation-helpers.d.ts +8 -1
- package/dist/helpers/object-validation-helpers.d.ts.map +1 -1
- package/dist/helpers/object-validation-helpers.js +22 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/models/authorization/authorization-models.d.ts +81 -0
- package/dist/models/authorization/authorization-models.d.ts.map +1 -0
- package/dist/models/authorization/authorization-models.js +33 -0
- package/dist/models/crypto/crypto-models.d.ts +5 -0
- package/dist/models/crypto/crypto-models.d.ts.map +1 -0
- package/dist/models/crypto/crypto-models.js +3 -0
- package/dist/models/index.d.ts +5 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +5 -0
- package/dist/models/rules/share-rule-models.d.ts +42 -19
- package/dist/models/rules/share-rule-models.d.ts.map +1 -1
- package/dist/models/rules/share-rule-models.js +9 -8
- package/dist/models/safe/safe-transactions.d.ts +81 -0
- package/dist/models/safe/safe-transactions.d.ts.map +1 -0
- package/dist/models/safe/safe-transactions.js +26 -0
- package/dist/models/share-data/share-data.d.ts +1 -0
- package/dist/models/share-data/share-data.d.ts.map +1 -1
- package/dist/models/share-data/share-data.js +1 -0
- package/package.json +4 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SafeRuleEvaluationSpecialConditionPatternError = exports.SafeRuleEvaluationConditionValueError = exports.SafeRuleEvaluationConditionDataValueError = void 0;
|
|
3
|
+
exports.SafeRulePropertyValueWrongType = exports.SafeRuleHasMissingProperty = exports.SafeRuleHasMismatchingProperties = exports.SafeRuleNotObjectError = exports.SafeRuleConditionTypeNotValidError = exports.SafeRuleConditionValueWrongType = exports.SafeRuleConditionPropertyMissingError = exports.SafeRuleConditionQualifierError = exports.SafeRuleConditionHasMismatchingProperties = exports.SafeRuleConditionNotObjectError = exports.SafeRuleConditionNotTypeOfError = exports.SafeRuleRuleSetNoRuleGroupsError = exports.SafeRuleEvaluationSpecialConditionPatternError = exports.SafeRuleEvaluationConditionValueError = exports.SafeRuleEvaluationConditionDataValueError = void 0;
|
|
4
4
|
const base_error_1 = require("../base-error");
|
|
5
5
|
/**
|
|
6
6
|
* This error is thrown when a evaluation condition data value is not valid
|
|
@@ -38,3 +38,115 @@ class SafeRuleEvaluationSpecialConditionPatternError extends base_error_1.BaseEr
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.SafeRuleEvaluationSpecialConditionPatternError = SafeRuleEvaluationSpecialConditionPatternError;
|
|
41
|
+
/**
|
|
42
|
+
* This error is thrown when a rule set has no rule groups
|
|
43
|
+
*/
|
|
44
|
+
class SafeRuleRuleSetNoRuleGroupsError extends base_error_1.BaseError {
|
|
45
|
+
/**
|
|
46
|
+
* This error is thrown when a rule set has no rule groups
|
|
47
|
+
*/
|
|
48
|
+
constructor(name, description) {
|
|
49
|
+
super(`Share Rule set ${name} with description ${description} has no rule groups`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.SafeRuleRuleSetNoRuleGroupsError = SafeRuleRuleSetNoRuleGroupsError;
|
|
53
|
+
//#region Condition Validation Errors
|
|
54
|
+
class SafeRuleConditionNotTypeOfError extends base_error_1.BaseError {
|
|
55
|
+
constructor(conditionType, expectedType) {
|
|
56
|
+
super(`Share Rule condition type ${conditionType} is not of type ${expectedType}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.SafeRuleConditionNotTypeOfError = SafeRuleConditionNotTypeOfError;
|
|
60
|
+
/**
|
|
61
|
+
* This error is thrown when a rule condition is not an object
|
|
62
|
+
*/
|
|
63
|
+
class SafeRuleConditionNotObjectError extends base_error_1.BaseError {
|
|
64
|
+
constructor(incomingObject) {
|
|
65
|
+
super(`Share Rule condition object ${incomingObject} is not an object`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.SafeRuleConditionNotObjectError = SafeRuleConditionNotObjectError;
|
|
69
|
+
/**
|
|
70
|
+
* This error is thrown when a rule condition is missing or has an extra property
|
|
71
|
+
*/
|
|
72
|
+
class SafeRuleConditionHasMismatchingProperties extends base_error_1.BaseError {
|
|
73
|
+
constructor(incomingObject, expectedPropertyCount, actualPropertyCount) {
|
|
74
|
+
super(`Share Rule condition object ${incomingObject} has mismatching properties, expected ${expectedPropertyCount} but got ${actualPropertyCount}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.SafeRuleConditionHasMismatchingProperties = SafeRuleConditionHasMismatchingProperties;
|
|
78
|
+
/**
|
|
79
|
+
* This error is thrown when the safe condition qualifier is not valid
|
|
80
|
+
*/
|
|
81
|
+
class SafeRuleConditionQualifierError extends base_error_1.BaseError {
|
|
82
|
+
constructor(conditionQualifier) {
|
|
83
|
+
super(`Share Rule condition qualifier ${conditionQualifier} is not valid`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.SafeRuleConditionQualifierError = SafeRuleConditionQualifierError;
|
|
87
|
+
/**
|
|
88
|
+
* This error is thrown when a rule condition property is missing
|
|
89
|
+
*/
|
|
90
|
+
class SafeRuleConditionPropertyMissingError extends base_error_1.BaseError {
|
|
91
|
+
constructor(missingProperty) {
|
|
92
|
+
super(`Share Rule condition property ${missingProperty} is missing`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.SafeRuleConditionPropertyMissingError = SafeRuleConditionPropertyMissingError;
|
|
96
|
+
/**
|
|
97
|
+
* This error is thrown when a rule condition value is not valid
|
|
98
|
+
*/
|
|
99
|
+
class SafeRuleConditionValueWrongType extends base_error_1.BaseError {
|
|
100
|
+
constructor(conditionValue, expectedType) {
|
|
101
|
+
super(`Share Rule condition value ${conditionValue} is not of type ${expectedType}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.SafeRuleConditionValueWrongType = SafeRuleConditionValueWrongType;
|
|
105
|
+
/**
|
|
106
|
+
* This error is thrown when a rule condition type is not valid
|
|
107
|
+
*/
|
|
108
|
+
class SafeRuleConditionTypeNotValidError extends base_error_1.BaseError {
|
|
109
|
+
constructor(conditionType) {
|
|
110
|
+
super(`Share Rule condition type ${conditionType} is not valid`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.SafeRuleConditionTypeNotValidError = SafeRuleConditionTypeNotValidError;
|
|
114
|
+
//#endregion Condition Validation Errors
|
|
115
|
+
//#region Rule Validation Errors
|
|
116
|
+
/**
|
|
117
|
+
* This error is thrown when a safe rule is not an object
|
|
118
|
+
*/
|
|
119
|
+
class SafeRuleNotObjectError extends base_error_1.BaseError {
|
|
120
|
+
constructor(incomingObject) {
|
|
121
|
+
super(`Share Rule object ${incomingObject} is not an object`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.SafeRuleNotObjectError = SafeRuleNotObjectError;
|
|
125
|
+
/**
|
|
126
|
+
* This error is thrown when a safe rule is missing or has an extra property
|
|
127
|
+
*/
|
|
128
|
+
class SafeRuleHasMismatchingProperties extends base_error_1.BaseError {
|
|
129
|
+
constructor(incomingObject, expectedPropertyCount, actualPropertyCount) {
|
|
130
|
+
super(`Share Rule object ${incomingObject} has mismatching properties, expected ${expectedPropertyCount} but got ${actualPropertyCount}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.SafeRuleHasMismatchingProperties = SafeRuleHasMismatchingProperties;
|
|
134
|
+
/**
|
|
135
|
+
* This error is thrown when a safe rule is missing property
|
|
136
|
+
*/
|
|
137
|
+
class SafeRuleHasMissingProperty extends base_error_1.BaseError {
|
|
138
|
+
constructor(incomingObject, expectedProperty) {
|
|
139
|
+
super(`Share Rule object ${incomingObject} is missing property ${expectedProperty}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.SafeRuleHasMissingProperty = SafeRuleHasMissingProperty;
|
|
143
|
+
/**
|
|
144
|
+
* This error is thrown when a safe rule property is not valid
|
|
145
|
+
*/
|
|
146
|
+
class SafeRulePropertyValueWrongType extends base_error_1.BaseError {
|
|
147
|
+
constructor(propertyName, propertyValue, expectedType) {
|
|
148
|
+
super(`Share Rule property ${propertyName} with value ${propertyValue} is not of type ${expectedType}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.SafeRulePropertyValueWrongType = SafeRulePropertyValueWrongType;
|
|
152
|
+
//#endregion Rule Validation Errors
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* this function converts a hex string to a base64 string.
|
|
3
|
+
*
|
|
4
|
+
* @param hex the hex string to convert to base64
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const hexToBase64: (hexString: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* this function converts a base64 string to a hex string.
|
|
10
|
+
*
|
|
11
|
+
* @param base64 the base64 string to convert to hex
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
declare const base64ToHex: (base64String: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* this function converts a base64 string to a PEM string for a public key.
|
|
17
|
+
*
|
|
18
|
+
* @param base64 the base64 string to convert to PEM format.
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
declare const base64ToPublicPEM: (base64: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* this function converts a base64 string to a PEM string for an elliptical curve private key.
|
|
24
|
+
*
|
|
25
|
+
* @param base64 the base64 string to convert to PEM format.
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
declare const base64ToPrivateECPEM: (base64: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* this function converts a base64 string to a PEM string for a private key.
|
|
31
|
+
*
|
|
32
|
+
* @param base64 the base64 string to convert to PEM format.
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
declare const base64ToPrivatePEM: (base64: string) => string;
|
|
36
|
+
export { base64ToHex, base64ToPublicPEM, base64ToPrivateECPEM, base64ToPrivatePEM, hexToBase64, };
|
|
37
|
+
//# sourceMappingURL=cryptography-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptography-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/crypto/cryptography-helpers.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,QAAA,MAAM,WAAW,cAAe,MAAM,KAAG,MAExC,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,WAAW,iBAAkB,MAAM,KAAG,MAE3C,CAAC;AAIF;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,WAAY,MAAM,KAAG,MAK3C,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,oBAAoB,WAAY,MAAM,KAAG,MAK9C,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,WAAY,MAAM,KAAG,MAK5C,CAAC;AAIF,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,GACd,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file contains the helper functions for cryptography in the application.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.hexToBase64 = exports.base64ToPrivatePEM = exports.base64ToPrivateECPEM = exports.base64ToPublicPEM = exports.base64ToHex = void 0;
|
|
5
|
+
//#region hex to base 64 functions
|
|
6
|
+
/**
|
|
7
|
+
* this function converts a hex string to a base64 string.
|
|
8
|
+
*
|
|
9
|
+
* @param hex the hex string to convert to base64
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const hexToBase64 = (hexString) => {
|
|
13
|
+
return Buffer.from(hexString, 'hex').toString('base64');
|
|
14
|
+
};
|
|
15
|
+
exports.hexToBase64 = hexToBase64;
|
|
16
|
+
/**
|
|
17
|
+
* this function converts a base64 string to a hex string.
|
|
18
|
+
*
|
|
19
|
+
* @param base64 the base64 string to convert to hex
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
const base64ToHex = (base64String) => {
|
|
23
|
+
return Buffer.from(base64String, 'base64').toString('hex');
|
|
24
|
+
};
|
|
25
|
+
exports.base64ToHex = base64ToHex;
|
|
26
|
+
//#region base 64 to PEM functions
|
|
27
|
+
/**
|
|
28
|
+
* this function converts a base64 string to a PEM string for a public key.
|
|
29
|
+
*
|
|
30
|
+
* @param base64 the base64 string to convert to PEM format.
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
const base64ToPublicPEM = (base64) => {
|
|
34
|
+
// split the base64 into 64 character chunks
|
|
35
|
+
const regex = /.{64}/g;
|
|
36
|
+
const formattedBase64 = base64.replace(regex, '$&\n');
|
|
37
|
+
return `-----BEGIN PUBLIC KEY-----\n${formattedBase64}\n-----END PUBLIC KEY-----`;
|
|
38
|
+
};
|
|
39
|
+
exports.base64ToPublicPEM = base64ToPublicPEM;
|
|
40
|
+
/**
|
|
41
|
+
* this function converts a base64 string to a PEM string for an elliptical curve private key.
|
|
42
|
+
*
|
|
43
|
+
* @param base64 the base64 string to convert to PEM format.
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
const base64ToPrivateECPEM = (base64) => {
|
|
47
|
+
// split the base64 into 64 character chunks
|
|
48
|
+
const regex = /.{64}/g;
|
|
49
|
+
const formattedBase64 = base64.replace(regex, '$&\n');
|
|
50
|
+
return `-----BEGIN EC PRIVATE KEY-----\n${formattedBase64}\n-----END EC PRIVATE KEY-----`;
|
|
51
|
+
};
|
|
52
|
+
exports.base64ToPrivateECPEM = base64ToPrivateECPEM;
|
|
53
|
+
/**
|
|
54
|
+
* this function converts a base64 string to a PEM string for a private key.
|
|
55
|
+
*
|
|
56
|
+
* @param base64 the base64 string to convert to PEM format.
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
const base64ToPrivatePEM = (base64) => {
|
|
60
|
+
// split the base64 into 64 character chunks
|
|
61
|
+
const regex = /.{64}/g;
|
|
62
|
+
const formattedBase64 = base64.replace(regex, '$&\n');
|
|
63
|
+
return `-----BEGIN PRIVATE KEY-----\n${formattedBase64}\n-----END PRIVATE KEY-----`;
|
|
64
|
+
};
|
|
65
|
+
exports.base64ToPrivatePEM = base64ToPrivatePEM;
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './request/params-object-helpers';
|
|
|
5
5
|
export * from './request/query-object-helpers';
|
|
6
6
|
export * from './request/request-object-helpers';
|
|
7
7
|
export * from './array/array-helpers';
|
|
8
|
+
export * from './crypto/cryptography-helpers';
|
|
8
9
|
export * from './data/data-helpers';
|
|
9
10
|
export * from './file/file-helpers';
|
|
10
11
|
export * from './lodash/lodash-helpers';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAM5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AAKjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAM5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AAKjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./request/request-object-helpers"), exports);
|
|
|
26
26
|
//#endregion request exports
|
|
27
27
|
// additional
|
|
28
28
|
__exportStar(require("./array/array-helpers"), exports);
|
|
29
|
+
__exportStar(require("./crypto/cryptography-helpers"), exports);
|
|
29
30
|
__exportStar(require("./data/data-helpers"), exports);
|
|
30
31
|
__exportStar(require("./file/file-helpers"), exports);
|
|
31
32
|
__exportStar(require("./lodash/lodash-helpers"), exports);
|
|
@@ -47,6 +47,13 @@ declare const validateNumber: (incomingObject: unknown, min?: number, max?: numb
|
|
|
47
47
|
* @returns whether the shape is valid.
|
|
48
48
|
*/
|
|
49
49
|
declare const validateString: (incomingObject: unknown, hasNoSpaces?: boolean, undefinedValid?: boolean, emptyStringValid?: boolean) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* This validates that an incoming object is a valid hex string without spaces.
|
|
52
|
+
*
|
|
53
|
+
* @param incomingObject the object to validate
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
declare const validateStringHex: (incomingObject: unknown) => boolean;
|
|
50
57
|
/**
|
|
51
58
|
* This validates that an incoming object is a valid URL.
|
|
52
59
|
*
|
|
@@ -55,5 +62,5 @@ declare const validateString: (incomingObject: unknown, hasNoSpaces?: boolean, u
|
|
|
55
62
|
* @returns wether it is a valid URL or not
|
|
56
63
|
*/
|
|
57
64
|
declare const validateUrl: (incomingUrl: unknown, undefinedValid?: boolean) => boolean;
|
|
58
|
-
export { validateArray, validateBoolean, validateDate, validateNumber, validateString, validateUrl, };
|
|
65
|
+
export { validateArray, validateBoolean, validateDate, validateNumber, validateString, validateStringHex, validateUrl, };
|
|
59
66
|
//# sourceMappingURL=object-validation-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-validation-helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/object-validation-helpers.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,QAAA,MAAM,aAAa,mBAAoB,OAAO,0CAAqC,MAAM,KAAG,OAc3F,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,eAAe,mBAAoB,OAAO,+BAA2B,OAS1E,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,YAAY,mBAAoB,OAAO,8FACP,OAoCrC,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,cAAc,mBAAoB,OAAO,QAAQ,MAAM,QAAQ,MAAM,KAAG,OAU7E,CAAC;AAEF;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,mBAAoB,OAAO,kFAA0E,OAiCxH,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,gBAAiB,OAAO,+BAA2B,OAqBnE,CAAC;AA+CF,OAAO,EACH,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,WAAW,GACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"object-validation-helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/object-validation-helpers.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,QAAA,MAAM,aAAa,mBAAoB,OAAO,0CAAqC,MAAM,KAAG,OAc3F,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,eAAe,mBAAoB,OAAO,+BAA2B,OAS1E,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,YAAY,mBAAoB,OAAO,8FACP,OAoCrC,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,cAAc,mBAAoB,OAAO,QAAQ,MAAM,QAAQ,MAAM,KAAG,OAU7E,CAAC;AAEF;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,mBAAoB,OAAO,kFAA0E,OAiCxH,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,mBAAoB,OAAO,KAAG,OAepD,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,gBAAiB,OAAO,+BAA2B,OAqBnE,CAAC;AA+CF,OAAO,EACH,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,WAAW,GACd,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file contains the validation functions for objects.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.validateUrl = exports.validateString = exports.validateNumber = exports.validateDate = exports.validateBoolean = exports.validateArray = void 0;
|
|
4
|
+
exports.validateUrl = exports.validateStringHex = exports.validateString = exports.validateNumber = exports.validateDate = exports.validateBoolean = exports.validateArray = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* Checks that an object is an array and that it has the minimum number of items.
|
|
7
7
|
*
|
|
@@ -159,6 +159,27 @@ const validateString = (incomingObject, hasNoSpaces = false, undefinedValid = fa
|
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
161
|
exports.validateString = validateString;
|
|
162
|
+
/**
|
|
163
|
+
* This validates that an incoming object is a valid hex string without spaces.
|
|
164
|
+
*
|
|
165
|
+
* @param incomingObject the object to validate
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
168
|
+
const validateStringHex = (incomingObject) => {
|
|
169
|
+
// make sure its a string
|
|
170
|
+
const isStringWithoutSpaces = validateString(incomingObject, true, false, false);
|
|
171
|
+
// make sure its a valid hex string
|
|
172
|
+
if (!isStringWithoutSpaces) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
// check that it is a hex string
|
|
176
|
+
const hexStringRegexp = /^[0-9a-fA-F]+$/;
|
|
177
|
+
if (!hexStringRegexp.test(incomingObject)) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
};
|
|
182
|
+
exports.validateStringHex = validateStringHex;
|
|
162
183
|
/**
|
|
163
184
|
* This validates that an incoming object is a valid URL.
|
|
164
185
|
*
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAM9C,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
//#region settings
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -14,8 +15,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
16
|
};
|
|
16
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./_settings/application-settings"), exports);
|
|
17
19
|
__exportStar(require("./_settings/cryptography-settings"), exports);
|
|
20
|
+
__exportStar(require("./_settings/database-settings"), exports);
|
|
21
|
+
//#endregion settings
|
|
18
22
|
// import * as crypto from './crypto'; this would become crypto.calculateHash ...
|
|
23
|
+
// export * from './application';
|
|
19
24
|
__exportStar(require("./crypto"), exports);
|
|
20
25
|
__exportStar(require("./errors"), exports);
|
|
21
26
|
__exportStar(require("./helpers"), exports);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the authorities that can be validated with incoming requests.
|
|
3
|
+
* it is AuthorityName Declaration-with ending of the original hex version of the publickey, publickey for the authority
|
|
4
|
+
*/
|
|
5
|
+
export type IJWTAuthority = Map<IAuthorizationIssuer, string>;
|
|
6
|
+
/**
|
|
7
|
+
* This contains the types of validation that can be done on the authority.
|
|
8
|
+
*/
|
|
9
|
+
export declare enum AuthorityValidationType {
|
|
10
|
+
JWT = "jwt"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* This is the payload for the jwt.
|
|
14
|
+
*/
|
|
15
|
+
export interface IAuthorizationPayload {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This is the header for the jwt.
|
|
20
|
+
*/
|
|
21
|
+
export interface IAuthorizationHeader {
|
|
22
|
+
alg: string;
|
|
23
|
+
typ: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* This is the audience that the jwt is intended for.
|
|
27
|
+
*/
|
|
28
|
+
export declare enum AuthorizationAudience {
|
|
29
|
+
AUTHORITIES = "authorities",// the authorities in the SAFE Ecosystem
|
|
30
|
+
SHAREDATA = "sharedata",// the Share Data in the SAFE Ecosystem
|
|
31
|
+
FUNCTIONS = "functions",// the functions in the SAFE Ecosystem
|
|
32
|
+
RULES = "rules",// the rules in the SAFE Ecosystem
|
|
33
|
+
EVENTS = "events",// the events in the SAFE Ecosystem
|
|
34
|
+
ENDPOINTS = "endpoints"
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* This contains the start of the subject for the authorization subject
|
|
38
|
+
*/
|
|
39
|
+
export declare enum AuthorizationSubjectStart {
|
|
40
|
+
USER = "user",
|
|
41
|
+
SAFE_NETWORK = "safe-network"
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* This type represents the formatted authorization subject.
|
|
45
|
+
*/
|
|
46
|
+
export type IAuthorizationSubject = `${AuthorizationSubjectStart}:${string}`;
|
|
47
|
+
/**
|
|
48
|
+
* This is the issuer of the token.
|
|
49
|
+
*/
|
|
50
|
+
export type IAuthorizationIssuer = `${string}-${string}`;
|
|
51
|
+
/**
|
|
52
|
+
* Any custom network claims that are added to the token.
|
|
53
|
+
*/
|
|
54
|
+
export interface ICustomClaims {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* This interface represents the valid safe token payload (after deconstructing the jwt token).
|
|
59
|
+
*/
|
|
60
|
+
export interface IValidSafeTokenPayload {
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
aud: AuthorizationAudience;
|
|
63
|
+
exp: number;
|
|
64
|
+
iat: number;
|
|
65
|
+
nbf: number;
|
|
66
|
+
sub: IAuthorizationSubject;
|
|
67
|
+
iss: IAuthorizationIssuer;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* This is the decoded jwt token.
|
|
71
|
+
*/
|
|
72
|
+
export interface IDecodedJwtToken {
|
|
73
|
+
customClaims?: ICustomClaims;
|
|
74
|
+
aud: AuthorizationAudience;
|
|
75
|
+
exp: number;
|
|
76
|
+
iat: number;
|
|
77
|
+
nbf: number;
|
|
78
|
+
sub: IAuthorizationSubject;
|
|
79
|
+
iss: IAuthorizationIssuer;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=authorization-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-models.d.ts","sourceRoot":"","sources":["../../../src/models/authorization/authorization-models.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;AAG9D;;GAEG;AACH,oBAAY,uBAAuB;IAC/B,GAAG,QAAQ;CACd;AAOD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,qBAAqB;IAC7B,WAAW,gBAAgB,CAAE,wCAAwC;IACrE,SAAS,cAAc,CAAE,uCAAuC;IAChE,SAAS,cAAc,CAAE,sCAAsC;IAC/D,KAAK,UAAU,CAAE,kCAAkC;IACnD,MAAM,WAAW,CAAE,mCAAmC;IACtD,SAAS,cAAc;CAC1B;AAED;;GAEG;AACH,oBAAY,yBAAyB;IACjC,IAAI,SAAS;IACb,YAAY,iBAAiB;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,GAAG,yBAAyB,IAAI,MAAM,EAAE,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAIzD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,GAAG,EAAE,qBAAqB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,qBAAqB,CAAC;IAC3B,GAAG,EAAE,oBAAoB,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,GAAG,EAAE,qBAAqB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,qBAAqB,CAAC;IAC3B,GAAG,EAAE,oBAAoB,CAAC;CAC7B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file contains the models for the authorization.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthorizationSubjectStart = exports.AuthorizationAudience = exports.AuthorityValidationType = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* This contains the types of validation that can be done on the authority.
|
|
7
|
+
*/
|
|
8
|
+
var AuthorityValidationType;
|
|
9
|
+
(function (AuthorityValidationType) {
|
|
10
|
+
AuthorityValidationType["JWT"] = "jwt";
|
|
11
|
+
})(AuthorityValidationType || (exports.AuthorityValidationType = AuthorityValidationType = {}));
|
|
12
|
+
/**
|
|
13
|
+
* This is the audience that the jwt is intended for.
|
|
14
|
+
*/
|
|
15
|
+
var AuthorizationAudience;
|
|
16
|
+
(function (AuthorizationAudience) {
|
|
17
|
+
AuthorizationAudience["AUTHORITIES"] = "authorities";
|
|
18
|
+
AuthorizationAudience["SHAREDATA"] = "sharedata";
|
|
19
|
+
AuthorizationAudience["FUNCTIONS"] = "functions";
|
|
20
|
+
AuthorizationAudience["RULES"] = "rules";
|
|
21
|
+
AuthorizationAudience["EVENTS"] = "events";
|
|
22
|
+
AuthorizationAudience["ENDPOINTS"] = "endpoints";
|
|
23
|
+
})(AuthorizationAudience || (exports.AuthorizationAudience = AuthorizationAudience = {}));
|
|
24
|
+
/**
|
|
25
|
+
* This contains the start of the subject for the authorization subject
|
|
26
|
+
*/
|
|
27
|
+
var AuthorizationSubjectStart;
|
|
28
|
+
(function (AuthorizationSubjectStart) {
|
|
29
|
+
AuthorizationSubjectStart["USER"] = "user";
|
|
30
|
+
AuthorizationSubjectStart["SAFE_NETWORK"] = "safe-network";
|
|
31
|
+
})(AuthorizationSubjectStart || (exports.AuthorizationSubjectStart = AuthorizationSubjectStart = {}));
|
|
32
|
+
//#region jwt header models
|
|
33
|
+
//#endregion jwt models
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto-models.d.ts","sourceRoot":"","sources":["../../../src/models/crypto/crypto-models.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,wBAAwB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACxB"}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
export * from './application/audit-log/application-audit-log-models';
|
|
2
|
+
export * from './application/database/firestore-models';
|
|
3
|
+
export * from './authorization/authorization-models';
|
|
4
|
+
export * from './crypto/crypto-models';
|
|
1
5
|
export * from './data/data-models';
|
|
2
6
|
export * from './dynamic-execution/dynamic-execution-models';
|
|
3
7
|
export * from './events/share-event-models';
|
|
4
8
|
export * from './functions/share-data-function-models';
|
|
5
9
|
export * from './generic/request-response-models';
|
|
6
10
|
export * from './rules/share-rule-models';
|
|
11
|
+
export * from './safe/safe-transactions';
|
|
7
12
|
export * from './share-data/share-data';
|
|
8
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
package/dist/models/index.js
CHANGED
|
@@ -15,10 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./application/audit-log/application-audit-log-models"), exports);
|
|
19
|
+
__exportStar(require("./application/database/firestore-models"), exports);
|
|
20
|
+
__exportStar(require("./authorization/authorization-models"), exports);
|
|
21
|
+
__exportStar(require("./crypto/crypto-models"), exports);
|
|
18
22
|
__exportStar(require("./data/data-models"), exports);
|
|
19
23
|
__exportStar(require("./dynamic-execution/dynamic-execution-models"), exports);
|
|
20
24
|
__exportStar(require("./events/share-event-models"), exports);
|
|
21
25
|
__exportStar(require("./functions/share-data-function-models"), exports);
|
|
22
26
|
__exportStar(require("./generic/request-response-models"), exports);
|
|
23
27
|
__exportStar(require("./rules/share-rule-models"), exports);
|
|
28
|
+
__exportStar(require("./safe/safe-transactions"), exports);
|
|
24
29
|
__exportStar(require("./share-data/share-data"), exports);
|
|
@@ -31,12 +31,12 @@ export interface IRuleEvaluationResults {
|
|
|
31
31
|
/**
|
|
32
32
|
* This contains the interface for the rule set in the share data object
|
|
33
33
|
*/
|
|
34
|
-
export interface
|
|
34
|
+
export interface IShareRuleSet {
|
|
35
|
+
description?: string;
|
|
35
36
|
id: string;
|
|
36
|
-
version: number;
|
|
37
37
|
name: string;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
ruleGroups: IShareRuleGroup[];
|
|
39
|
+
version: number;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* This contains the logical operators for combining rules.
|
|
@@ -50,9 +50,9 @@ export declare enum LogicalOperator {
|
|
|
50
50
|
*
|
|
51
51
|
* A rule group can contain individual rules or nested rule groups.
|
|
52
52
|
*/
|
|
53
|
-
export interface
|
|
53
|
+
export interface IShareRuleGroup {
|
|
54
54
|
operator: LogicalOperator;
|
|
55
|
-
rules: (IShareRuleApplied |
|
|
55
|
+
rules: (IShareRuleApplied | IShareRuleGroup)[];
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* This contains the interface for a share rule in the share data object
|
|
@@ -71,7 +71,7 @@ export interface IShareRuleApplied extends IShareRule {
|
|
|
71
71
|
/**
|
|
72
72
|
* This contains the different types of conditions that can be evaluated.
|
|
73
73
|
*/
|
|
74
|
-
export type ConditionType = ConditionTypeSingle | ConditionTypeRange | ConditionTypeStartsEndsWith | ConditionTypeBoolean |
|
|
74
|
+
export type ConditionType = ConditionTypeSingle | ConditionTypeRange | ConditionTypeStartsEndsWith | ConditionTypeBoolean | ConditionTypeSpecial;
|
|
75
75
|
/**
|
|
76
76
|
* This contains the choices for the type of qualifier.
|
|
77
77
|
*/
|
|
@@ -87,7 +87,8 @@ export declare enum ConditionTypeSingle {
|
|
|
87
87
|
EQUAL = "equal",// the value is equal to the condition value
|
|
88
88
|
CONTAINS = "contains",// the value contains the condition value
|
|
89
89
|
NULL = "null",// the value is null
|
|
90
|
-
EMPTY = "empty"
|
|
90
|
+
EMPTY = "empty",// the value is empty
|
|
91
|
+
SHARE_RULE = "share-rule"
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
93
94
|
* This contains the choices for the range conditions.
|
|
@@ -118,16 +119,10 @@ export declare enum ConditionTypeBoolean {
|
|
|
118
119
|
export declare enum ConditionTypeSpecial {
|
|
119
120
|
PATTERN = "pattern"
|
|
120
121
|
}
|
|
121
|
-
/**
|
|
122
|
-
* This contains the choices for the combined rule conditions that are a type of object
|
|
123
|
-
*/
|
|
124
|
-
export declare enum ConditionTypeCombinedRules {
|
|
125
|
-
OBJECT = "object"
|
|
126
|
-
}
|
|
127
122
|
/**
|
|
128
123
|
* This is the interface for the conditional information in the checks.
|
|
129
124
|
*/
|
|
130
|
-
export type ICondition = IConditionTypeOf | IConditionEquality | IConditionRange | IConditionContains | IConditionStartsEndsWith | IConditionNull | IConditionBoolean | IConditionEmpty |
|
|
125
|
+
export type ICondition = IConditionTypeOf | IConditionEquality | IConditionRange | IConditionContains | IConditionStartsEndsWith | IConditionNull | IConditionBoolean | IConditionEmpty | IConditionShareRule | IConditionSpecial;
|
|
131
126
|
/**
|
|
132
127
|
* This is the interface for the base condition.
|
|
133
128
|
*/
|
|
@@ -271,10 +266,38 @@ export interface IConditionSpecial extends IConditionBase {
|
|
|
271
266
|
conditionValue: string;
|
|
272
267
|
}
|
|
273
268
|
/**
|
|
274
|
-
* This is the interface for the
|
|
269
|
+
* This is the interface for the share rule condition.
|
|
270
|
+
*
|
|
271
|
+
|
|
272
|
+
const nestedShareRule: IShareRule = {
|
|
273
|
+
ruleId: 'nestedRule',
|
|
274
|
+
currentDataConditions: [
|
|
275
|
+
{
|
|
276
|
+
targettedProperty: 'nestedProperty',
|
|
277
|
+
conditionType: 'equal',
|
|
278
|
+
conditionValue: 'expectedValue',
|
|
279
|
+
conditionTypeQualifier: ConditionTypeQualifier.IS,
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
proposedDataConditions: [
|
|
283
|
+
{
|
|
284
|
+
targettedProperty: 'nestedProperty',
|
|
285
|
+
conditionType: 'equal',
|
|
286
|
+
conditionValue: 'newValue',
|
|
287
|
+
conditionTypeQualifier: ConditionTypeQualifier.IS,
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const conditionWithShareRule: IConditionShareRule = {
|
|
293
|
+
conditionType: ConditionTypeSingle.SHARE_RULE,
|
|
294
|
+
conditionTypeQualifier: ConditionTypeQualifier.IS,
|
|
295
|
+
targettedProperty: 'parentProperty',
|
|
296
|
+
rule: nestedShareRule,
|
|
297
|
+
};
|
|
275
298
|
*/
|
|
276
|
-
export interface
|
|
277
|
-
conditionType:
|
|
278
|
-
conditionValue:
|
|
299
|
+
export interface IConditionShareRule extends IConditionBase {
|
|
300
|
+
conditionType: ConditionTypeSingle.SHARE_RULE;
|
|
301
|
+
conditionValue: IShareRule;
|
|
279
302
|
}
|
|
280
303
|
//# sourceMappingURL=share-rule-models.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-rule-models.d.ts","sourceRoot":"","sources":["../../../src/models/rules/share-rule-models.ts"],"names":[],"mappings":"AACA;;GAEG;AAIH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,UAAU,EAAE,CAAC;IACtC,cAAc,EAAE,OAAO,CAAC;IACxB,wBAAwB,EAAE,UAAU,EAAE,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB,EAAE,yBAAyB,EAAE,CAAC;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,2BAA2B,EAAE,CAAC;IAC5C,eAAe,EAAE,OAAO,CAAC;CAC5B;AAMD;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"share-rule-models.d.ts","sourceRoot":"","sources":["../../../src/models/rules/share-rule-models.ts"],"names":[],"mappings":"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"}
|