@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This contains the settings for the authorization functions.
|
|
3
|
+
*/
|
|
4
|
+
export declare const AuthorizationSettings: {
|
|
5
|
+
JWT: {
|
|
6
|
+
Algorithm: string;
|
|
7
|
+
ExpiresInDefault: string;
|
|
8
|
+
NotBeforeDefault: number;
|
|
9
|
+
EncodingDefault: string;
|
|
10
|
+
MutatePayload: boolean;
|
|
11
|
+
NoTimestamp: boolean;
|
|
12
|
+
AllowInsecureKeySizes: boolean;
|
|
13
|
+
AllowInvalidAsymmetricKeyTypes: boolean;
|
|
14
|
+
HeaderType: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=authorization-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/authorization-settings.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;CAYjC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file contains the settings needed for authorization in the application.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthorizationSettings = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* This contains the settings for the authorization functions.
|
|
7
|
+
*/
|
|
8
|
+
exports.AuthorizationSettings = {
|
|
9
|
+
JWT: {
|
|
10
|
+
Algorithm: 'ES512', // ECDSA using P-521 curve and SHA-512 hash algorithm
|
|
11
|
+
ExpiresInDefault: '1h', // the expiration time of the jwt token
|
|
12
|
+
NotBeforeDefault: 0, // the not before time of the jwt token
|
|
13
|
+
EncodingDefault: 'utf8', // the encoding to use when converting the payload to a string
|
|
14
|
+
MutatePayload: true, // If true, the payload object will be mutated with the standard claims (iat, exp, etc.). Default is false.
|
|
15
|
+
NoTimestamp: false, // If true, the iat (issued at) claim will not be included in the token.
|
|
16
|
+
AllowInsecureKeySizes: false, // If true, allows the use of insecure key sizes.
|
|
17
|
+
AllowInvalidAsymmetricKeyTypes: false, // If true, allows the use of invalid asymmetric key types
|
|
18
|
+
HeaderType: 'JWT', // the type of the token in the header
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -6,22 +6,34 @@ import * as crypto from 'crypto';
|
|
|
6
6
|
* This contains the settings for the cryptography. settings
|
|
7
7
|
*/
|
|
8
8
|
export declare const CryptoSettings: {
|
|
9
|
-
TextEncoding: crypto.Encoding;
|
|
10
9
|
Hash: {
|
|
11
10
|
Algorithm: string;
|
|
11
|
+
Algorithm512: string;
|
|
12
12
|
Digest: crypto.BinaryToTextEncoding;
|
|
13
13
|
};
|
|
14
|
+
Format: {
|
|
15
|
+
hex: string;
|
|
16
|
+
base64: string;
|
|
17
|
+
};
|
|
18
|
+
TextEncoding: crypto.Encoding;
|
|
14
19
|
};
|
|
20
|
+
export declare const base64Encoding: BufferEncoding;
|
|
21
|
+
export declare const hexEncoding: BufferEncoding;
|
|
22
|
+
export declare const sec1KeyExportType = "sec1";
|
|
23
|
+
export declare const spkiKeyExportType = "spki";
|
|
24
|
+
export declare const keyExportFormatDer = "der";
|
|
15
25
|
/**
|
|
16
26
|
* This contains the values for the elliptical curvers for encryption
|
|
17
27
|
*/
|
|
18
28
|
export declare enum EllipticalCurvesEncryption {
|
|
19
|
-
Curve25519 = "curve25519"
|
|
29
|
+
Curve25519 = "curve25519",
|
|
30
|
+
P521 = "p521"
|
|
20
31
|
}
|
|
21
32
|
/**
|
|
22
33
|
* This contains the values for the elliptical curvers for signing
|
|
23
34
|
*/
|
|
24
35
|
export declare enum EllipticalCurvesSigning {
|
|
25
|
-
Curve25519 = "ed25519"
|
|
36
|
+
Curve25519 = "ed25519",
|
|
37
|
+
P521 = "p521"
|
|
26
38
|
}
|
|
27
39
|
//# sourceMappingURL=cryptography-settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cryptography-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/cryptography-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"cryptography-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/cryptography-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;gBAIF,MAAM,CAAC,oBAAoB;;;;;;kBAMxB,MAAM,CAAC,QAAQ;CAC1C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAe,cAAc,CAAC;AACzD,eAAO,MAAM,WAAW,EAAY,cAAc,CAAC;AAGnD,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;GAEG;AACH,oBAAY,0BAA0B;IAClC,UAAU,eAAe;IACzB,IAAI,SAAS;CAChB;AAED;;GAEG;AACH,oBAAY,uBAAuB;IAC/B,UAAU,YAAY;IACtB,IAAI,SAAS;CAChB"}
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EllipticalCurvesSigning = exports.EllipticalCurvesEncryption = exports.CryptoSettings = void 0;
|
|
3
|
+
exports.EllipticalCurvesSigning = exports.EllipticalCurvesEncryption = exports.keyExportFormatDer = exports.spkiKeyExportType = exports.sec1KeyExportType = exports.hexEncoding = exports.base64Encoding = exports.CryptoSettings = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* This contains the settings for the cryptography. settings
|
|
6
6
|
*/
|
|
7
7
|
exports.CryptoSettings = {
|
|
8
|
-
TextEncoding: 'utf8', // "utf8" | "ascii" | "latin1"
|
|
9
8
|
Hash: {
|
|
10
9
|
Algorithm: 'sha256',
|
|
10
|
+
Algorithm512: 'sha512',
|
|
11
11
|
Digest: 'hex', // "hex" | "base64" | "base64url" | "binary"
|
|
12
12
|
},
|
|
13
|
+
Format: {
|
|
14
|
+
hex: 'hex',
|
|
15
|
+
base64: 'base64',
|
|
16
|
+
},
|
|
17
|
+
TextEncoding: 'utf8', // "utf8" | "ascii" | "latin1"
|
|
13
18
|
};
|
|
19
|
+
// export the types fo buffer encodings
|
|
20
|
+
exports.base64Encoding = 'base64';
|
|
21
|
+
exports.hexEncoding = 'hex';
|
|
22
|
+
// export the keyformats
|
|
23
|
+
exports.sec1KeyExportType = 'sec1';
|
|
24
|
+
exports.spkiKeyExportType = 'spki';
|
|
25
|
+
exports.keyExportFormatDer = 'der';
|
|
14
26
|
/**
|
|
15
27
|
* This contains the values for the elliptical curvers for encryption
|
|
16
28
|
*/
|
|
17
29
|
var EllipticalCurvesEncryption;
|
|
18
30
|
(function (EllipticalCurvesEncryption) {
|
|
19
31
|
EllipticalCurvesEncryption["Curve25519"] = "curve25519";
|
|
32
|
+
EllipticalCurvesEncryption["P521"] = "p521";
|
|
20
33
|
})(EllipticalCurvesEncryption || (exports.EllipticalCurvesEncryption = EllipticalCurvesEncryption = {}));
|
|
21
34
|
/**
|
|
22
35
|
* This contains the values for the elliptical curvers for signing
|
|
@@ -24,4 +37,5 @@ var EllipticalCurvesEncryption;
|
|
|
24
37
|
var EllipticalCurvesSigning;
|
|
25
38
|
(function (EllipticalCurvesSigning) {
|
|
26
39
|
EllipticalCurvesSigning["Curve25519"] = "ed25519";
|
|
40
|
+
EllipticalCurvesSigning["P521"] = "p521";
|
|
27
41
|
})(EllipticalCurvesSigning || (exports.EllipticalCurvesSigning = EllipticalCurvesSigning = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-items-from-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-items-from-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAKnG;;;;;;;;GAQG;AACH,QAAA,MAAM,oBAAoB,GAAU,CAAC,UACzB,MAAM,kBACE,uBAAuB,4BACd,uBAAuB,KACjD,OAAO,CAAC,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"get-items-from-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-items-from-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAKnG;;;;;;;;GAQG;AACH,QAAA,MAAM,oBAAoB,GAAU,CAAC,UACzB,MAAM,kBACE,uBAAuB,4BACd,uBAAuB,KACjD,OAAO,CAAC,CAAC,EAAE,CAuCb,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -46,7 +46,6 @@ const getItemsFromDatabase = async (userId, getInformation, applicationAuditLogT
|
|
|
46
46
|
const itemsToReturn = await db.runTransaction(async (t) => {
|
|
47
47
|
const databaseItems = [];
|
|
48
48
|
const itemQuery = getInformation.itemColRef;
|
|
49
|
-
console.log('itemQuery', itemQuery);
|
|
50
49
|
// add in the query fields if they are set.
|
|
51
50
|
for (const queryField of getInformation.queryFields) {
|
|
52
51
|
itemQuery.where(queryField.fieldPath, queryField.opStr, queryField.value);
|
|
@@ -62,9 +61,7 @@ const getItemsFromDatabase = async (userId, getInformation, applicationAuditLogT
|
|
|
62
61
|
}
|
|
63
62
|
// set the limit and query the database.
|
|
64
63
|
itemQuery.limit(maxResults);
|
|
65
|
-
console.log('itemQueryAfter', itemQuery.limit);
|
|
66
64
|
const itemSnapshot = await t.get(itemQuery);
|
|
67
|
-
console.log('itemSnapshot', itemSnapshot);
|
|
68
65
|
// get the items from the database.
|
|
69
66
|
for (const docSnap of itemSnapshot.docs) {
|
|
70
67
|
const item = docSnap.data();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './jwt/keys/create-secret-key-pem';
|
|
2
|
+
export * from './jwt/keys/create-public-key-pem';
|
|
3
|
+
export * from './jwt/sign/create-authorization-issuer';
|
|
4
|
+
export * from './jwt/sign/create-authorization-subject';
|
|
5
|
+
export * from './jwt/sign/create-jwt-options';
|
|
6
|
+
export * from './jwt/sign/create-jwt-signed-token';
|
|
7
|
+
export * from './jwt/transform/transform-token-payload-to-safe-payload';
|
|
8
|
+
export * from './jwt/verify/get-decoded-jwt-header';
|
|
9
|
+
export * from './jwt/verify/get-decoded-jwt-signed-token-payload';
|
|
10
|
+
export * from './jwt/verify/verify-jwt-signed-token';
|
|
11
|
+
export * from './safe/authorization/authorized-authorities';
|
|
12
|
+
export * from './safe/request/decode-bearer-token';
|
|
13
|
+
export * from './safe/request/decode-safe-request';
|
|
14
|
+
export * from './safe/request/determine-issuer-from-request';
|
|
15
|
+
export * from './safe/request/issuer/determine-issuer-from-bearer-token';
|
|
16
|
+
export * from './safe/validation/jwt/payload/verify-authorization-audience';
|
|
17
|
+
export * from './safe/validation/jwt/payload/verify-authorization-expiration-time';
|
|
18
|
+
export * from './safe/validation/jwt/payload/verify-authorization-issued-at-time';
|
|
19
|
+
export * from './safe/validation/jwt/payload/verify-authorization-issuer';
|
|
20
|
+
export * from './safe/validation/jwt/payload/verify-authorization-not-before-time';
|
|
21
|
+
export * from './safe/validation/jwt/payload/verify-authorization-subject';
|
|
22
|
+
export * from './safe/validation/jwt/verify-token-header';
|
|
23
|
+
export * from './safe/validation/jwt/verify-token-payload';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AACA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AAIjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AAInD,cAAc,yDAAyD,CAAC;AAIxE,cAAc,qCAAqC,CAAC;AACpD,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AAMrD,cAAc,6CAA6C,CAAC;AAI5D,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAG7D,cAAc,0DAA0D,CAAC;AAWzE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,oEAAoE,CAAC;AACnF,cAAc,mEAAmE,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,oEAAoE,CAAC;AACnF,cAAc,4DAA4D,CAAC;AAI3E,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
//#region JWT Key functions
|
|
18
|
+
__exportStar(require("./jwt/keys/create-secret-key-pem"), exports);
|
|
19
|
+
__exportStar(require("./jwt/keys/create-public-key-pem"), exports);
|
|
20
|
+
//#endregion JWT Key functions
|
|
21
|
+
//#region JWT sign
|
|
22
|
+
__exportStar(require("./jwt/sign/create-authorization-issuer"), exports);
|
|
23
|
+
__exportStar(require("./jwt/sign/create-authorization-subject"), exports);
|
|
24
|
+
__exportStar(require("./jwt/sign/create-jwt-options"), exports);
|
|
25
|
+
__exportStar(require("./jwt/sign/create-jwt-signed-token"), exports);
|
|
26
|
+
//#endregion JWT sign
|
|
27
|
+
//#region JWT Transform
|
|
28
|
+
__exportStar(require("./jwt/transform/transform-token-payload-to-safe-payload"), exports);
|
|
29
|
+
//#endregion JWT Transform
|
|
30
|
+
//#region JWT verify
|
|
31
|
+
__exportStar(require("./jwt/verify/get-decoded-jwt-header"), exports);
|
|
32
|
+
__exportStar(require("./jwt/verify/get-decoded-jwt-signed-token-payload"), exports);
|
|
33
|
+
__exportStar(require("./jwt/verify/verify-jwt-signed-token"), exports);
|
|
34
|
+
//#endregion JWT verify
|
|
35
|
+
//#region Safe
|
|
36
|
+
//#region Authorization
|
|
37
|
+
__exportStar(require("./safe/authorization/authorized-authorities"), exports);
|
|
38
|
+
//#endregion Authorization
|
|
39
|
+
//#region Request
|
|
40
|
+
__exportStar(require("./safe/request/decode-bearer-token"), exports);
|
|
41
|
+
__exportStar(require("./safe/request/decode-safe-request"), exports);
|
|
42
|
+
__exportStar(require("./safe/request/determine-issuer-from-request"), exports);
|
|
43
|
+
//#region Issuer
|
|
44
|
+
__exportStar(require("./safe/request/issuer/determine-issuer-from-bearer-token"), exports);
|
|
45
|
+
//#endregion Issuer
|
|
46
|
+
//#endregion Request
|
|
47
|
+
//#region Validation
|
|
48
|
+
//#region JWT
|
|
49
|
+
//#region JWT Payload
|
|
50
|
+
__exportStar(require("./safe/validation/jwt/payload/verify-authorization-audience"), exports);
|
|
51
|
+
__exportStar(require("./safe/validation/jwt/payload/verify-authorization-expiration-time"), exports);
|
|
52
|
+
__exportStar(require("./safe/validation/jwt/payload/verify-authorization-issued-at-time"), exports);
|
|
53
|
+
__exportStar(require("./safe/validation/jwt/payload/verify-authorization-issuer"), exports);
|
|
54
|
+
__exportStar(require("./safe/validation/jwt/payload/verify-authorization-not-before-time"), exports);
|
|
55
|
+
__exportStar(require("./safe/validation/jwt/payload/verify-authorization-subject"), exports);
|
|
56
|
+
//#endregion JWT Payload
|
|
57
|
+
__exportStar(require("./safe/validation/jwt/verify-token-header"), exports);
|
|
58
|
+
__exportStar(require("./safe/validation/jwt/verify-token-payload"), exports);
|
|
59
|
+
//#endregion JWT
|
|
60
|
+
//#endregion Validation
|
|
61
|
+
//#endregion Safe
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This takes a public key in hex or Base64 format and creates a PEM key from it.
|
|
3
|
+
*
|
|
4
|
+
* @param publicKey the public key to create the PEM key from.
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const createPublicKeyPem: (publicKey: string) => string;
|
|
8
|
+
export { createPublicKeyPem };
|
|
9
|
+
//# sourceMappingURL=create-public-key-pem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-public-key-pem.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/keys/create-public-key-pem.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,cAAe,MAAM,KAAG,MAW/C,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPublicKeyPem = void 0;
|
|
4
|
+
const cryptography_helpers_1 = require("../../../helpers/crypto/cryptography-helpers");
|
|
5
|
+
const object_validation_helpers_1 = require("../../../helpers/object-validation-helpers");
|
|
6
|
+
/**
|
|
7
|
+
* This takes a public key in hex or Base64 format and creates a PEM key from it.
|
|
8
|
+
*
|
|
9
|
+
* @param publicKey the public key to create the PEM key from.
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const createPublicKeyPem = (publicKey) => {
|
|
13
|
+
let jwtKey; // the key to return
|
|
14
|
+
const isValidHexString = (0, object_validation_helpers_1.validateStringHex)(publicKey);
|
|
15
|
+
if (isValidHexString) { // check if this is a hex encoded secret key.
|
|
16
|
+
const derKey = (0, cryptography_helpers_1.hexToBase64)(publicKey); // convert the hex to base 64
|
|
17
|
+
jwtKey = (0, cryptography_helpers_1.base64ToPublicPEM)(derKey);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// add in the
|
|
21
|
+
jwtKey = (0, cryptography_helpers_1.base64ToPublicPEM)(publicKey);
|
|
22
|
+
}
|
|
23
|
+
return jwtKey;
|
|
24
|
+
};
|
|
25
|
+
exports.createPublicKeyPem = createPublicKeyPem;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This takes a secret key in hex or Base64 format and creates a PEM key from it.
|
|
3
|
+
*
|
|
4
|
+
* @param secretKey the secret key to create the PEM key from.
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const createSecretKeyPem: (secretKey: string) => string;
|
|
8
|
+
export { createSecretKeyPem };
|
|
9
|
+
//# sourceMappingURL=create-secret-key-pem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-secret-key-pem.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/keys/create-secret-key-pem.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,cAAe,MAAM,KAAG,MAU/C,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSecretKeyPem = void 0;
|
|
4
|
+
const cryptography_helpers_1 = require("../../../helpers/crypto/cryptography-helpers");
|
|
5
|
+
const object_validation_helpers_1 = require("../../../helpers/object-validation-helpers");
|
|
6
|
+
/**
|
|
7
|
+
* This takes a secret key in hex or Base64 format and creates a PEM key from it.
|
|
8
|
+
*
|
|
9
|
+
* @param secretKey the secret key to create the PEM key from.
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const createSecretKeyPem = (secretKey) => {
|
|
13
|
+
let jwtKey;
|
|
14
|
+
if ((0, object_validation_helpers_1.validateStringHex)(secretKey)) { // check if this is a hex encoded secret key.
|
|
15
|
+
const derKey = (0, cryptography_helpers_1.hexToBase64)(secretKey); // convert the hex to base 64
|
|
16
|
+
jwtKey = (0, cryptography_helpers_1.base64ToPrivateECPEM)(derKey);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// add in the
|
|
20
|
+
jwtKey = (0, cryptography_helpers_1.base64ToPrivateECPEM)(secretKey);
|
|
21
|
+
}
|
|
22
|
+
return jwtKey;
|
|
23
|
+
};
|
|
24
|
+
exports.createSecretKeyPem = createSecretKeyPem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAuthorizationIssuer } from '../../../models/authorization/authorization-models';
|
|
2
|
+
/**
|
|
3
|
+
* This function creates an authorization issuer.
|
|
4
|
+
* @param issuerName the name of the issuer (this should be letters and numbers only)
|
|
5
|
+
* @param publicKey the public key of the issuer (this should be a hex string)
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const createAuthorizationIssuer: (issuerName: string, publicKey: string) => IAuthorizationIssuer;
|
|
9
|
+
export { createAuthorizationIssuer };
|
|
10
|
+
//# sourceMappingURL=create-authorization-issuer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-authorization-issuer.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/sign/create-authorization-issuer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAE1F;;;;;GAKG;AACH,QAAA,MAAM,yBAAyB,eAAgB,MAAM,aAAa,MAAM,KAAG,oBAe1E,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthorizationIssuer = void 0;
|
|
4
|
+
const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
|
|
5
|
+
const object_validation_helpers_1 = require("../../../helpers/object-validation-helpers");
|
|
6
|
+
/**
|
|
7
|
+
* This function creates an authorization issuer.
|
|
8
|
+
* @param issuerName the name of the issuer (this should be letters and numbers only)
|
|
9
|
+
* @param publicKey the public key of the issuer (this should be a hex string)
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const createAuthorizationIssuer = (issuerName, publicKey) => {
|
|
13
|
+
// make sure the incoming public key is a hex format
|
|
14
|
+
const publicKeyIsHex = (0, object_validation_helpers_1.validateStringHex)(publicKey);
|
|
15
|
+
if (!publicKeyIsHex) { // if the public key is not a valid hex string
|
|
16
|
+
throw new authorization_errors_1.SafeAuthorizationIssuerPublicKeyNotValidError(issuerName, publicKey);
|
|
17
|
+
}
|
|
18
|
+
if (publicKey.length < 8) { // if the public key is less than 8 characters
|
|
19
|
+
throw new authorization_errors_1.SafeAuthorizationIssuerPublicKeyNotValidError(issuerName, publicKey);
|
|
20
|
+
}
|
|
21
|
+
// get the last 8 characters of the public key
|
|
22
|
+
const publicKeyParse = publicKey.slice(-8);
|
|
23
|
+
const authorizationIssuer = `${issuerName}-${publicKeyParse}`;
|
|
24
|
+
return authorizationIssuer;
|
|
25
|
+
};
|
|
26
|
+
exports.createAuthorizationIssuer = createAuthorizationIssuer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuthorizationSubjectStart, IAuthorizationSubject } from '../../../models/authorization/authorization-models';
|
|
2
|
+
/**
|
|
3
|
+
* This creates an authorization subject.
|
|
4
|
+
*
|
|
5
|
+
* @param subjectType the type of the subject
|
|
6
|
+
* @param subjectId the id of the subject (userid, safenetworkid etc.)
|
|
7
|
+
*
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const createAuthorizationSubject: (subjectType: AuthorizationSubjectStart, subjectId: string) => IAuthorizationSubject;
|
|
11
|
+
export { createAuthorizationSubject };
|
|
12
|
+
//# sourceMappingURL=create-authorization-subject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-authorization-subject.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/sign/create-authorization-subject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAEtH;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,gBACf,yBAAyB,aAC3B,MAAM,KAClB,qBAKF,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthorizationSubject = void 0;
|
|
4
|
+
const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
|
|
5
|
+
/**
|
|
6
|
+
* This creates an authorization subject.
|
|
7
|
+
*
|
|
8
|
+
* @param subjectType the type of the subject
|
|
9
|
+
* @param subjectId the id of the subject (userid, safenetworkid etc.)
|
|
10
|
+
*
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
const createAuthorizationSubject = (subjectType, subjectId) => {
|
|
14
|
+
if (!subjectId) {
|
|
15
|
+
throw new authorization_errors_1.SafeAuthorizationSubjectNotValidError(subjectType, subjectId);
|
|
16
|
+
}
|
|
17
|
+
return `${subjectType}:${subjectId}`;
|
|
18
|
+
};
|
|
19
|
+
exports.createAuthorizationSubject = createAuthorizationSubject;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import jwt from 'jsonwebtoken';
|
|
2
|
+
import { AuthorizationAudience, IAuthorizationSubject } from '../../../models/authorization/authorization-models';
|
|
3
|
+
/**
|
|
4
|
+
* This function creates the options for the jwt token issuance
|
|
5
|
+
*
|
|
6
|
+
* @param subject the subject of the token
|
|
7
|
+
* @param audience the audience of the token (default is sharedata)
|
|
8
|
+
* @param algorithm the algorithm to use (default is ES512)
|
|
9
|
+
* @param expiresIn the expiration time of the token (default is 1 hour)
|
|
10
|
+
* @param notBefore the not before time of the token (default is 0)
|
|
11
|
+
* @param keyid A unique identifier for the key used to sign the token. This can be used to prevent replay attacks. (optional)
|
|
12
|
+
* @param header An object containing additional header properties to include in the token. (optional)
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
declare const createJwtOptions: (subject: IAuthorizationSubject, audience?: AuthorizationAudience | AuthorizationAudience[], algorithm?: jwt.Algorithm, expiresIn?: string | number, notBefore?: string | number, keyid?: string, header?: jwt.JwtHeader) => jwt.SignOptions;
|
|
16
|
+
export { createJwtOptions };
|
|
17
|
+
//# sourceMappingURL=create-jwt-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-jwt-options.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/sign/create-jwt-options.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAGlH;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,gBAAgB,YACT,qBAAqB,aACpB,qBAAqB,GAAG,qBAAqB,EAAE,cAC9C,GAAG,CAAC,SAAS,cACb,MAAM,GAAG,MAAM,cACf,MAAM,GAAG,MAAM,UAClB,MAAM,WACL,GAAG,CAAC,SAAS,KACvB,GAAG,CAAC,WAkBN,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createJwtOptions = void 0;
|
|
4
|
+
const authorization_models_1 = require("../../../models/authorization/authorization-models");
|
|
5
|
+
const authorization_settings_1 = require("../../../_settings/authorization-settings");
|
|
6
|
+
/**
|
|
7
|
+
* This function creates the options for the jwt token issuance
|
|
8
|
+
*
|
|
9
|
+
* @param subject the subject of the token
|
|
10
|
+
* @param audience the audience of the token (default is sharedata)
|
|
11
|
+
* @param algorithm the algorithm to use (default is ES512)
|
|
12
|
+
* @param expiresIn the expiration time of the token (default is 1 hour)
|
|
13
|
+
* @param notBefore the not before time of the token (default is 0)
|
|
14
|
+
* @param keyid A unique identifier for the key used to sign the token. This can be used to prevent replay attacks. (optional)
|
|
15
|
+
* @param header An object containing additional header properties to include in the token. (optional)
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
const createJwtOptions = (subject, // the subject of the token
|
|
19
|
+
audience = authorization_models_1.AuthorizationAudience.SHAREDATA, // audience
|
|
20
|
+
algorithm = authorization_settings_1.AuthorizationSettings.JWT.Algorithm, // ECDSA using P-521 curve and SHA-512 hash algorithm
|
|
21
|
+
expiresIn = authorization_settings_1.AuthorizationSettings.JWT.ExpiresInDefault, // Default expiration time
|
|
22
|
+
notBefore = authorization_settings_1.AuthorizationSettings.JWT.NotBeforeDefault, // Default not before time
|
|
23
|
+
keyid, // A unique identifier for the key used to sign the token. This can be used to prevent replay attacks.
|
|
24
|
+
header) => {
|
|
25
|
+
const jwtOptions = {
|
|
26
|
+
subject,
|
|
27
|
+
audience,
|
|
28
|
+
algorithm,
|
|
29
|
+
expiresIn,
|
|
30
|
+
notBefore,
|
|
31
|
+
mutatePayload: authorization_settings_1.AuthorizationSettings.JWT.MutatePayload, // If true, the payload object will be mutated with the standard claims (iat, exp, etc.). Default is false.
|
|
32
|
+
noTimestamp: authorization_settings_1.AuthorizationSettings.JWT.NoTimestamp, // If true, the iat (issued at) claim will not be included in the token.
|
|
33
|
+
encoding: authorization_settings_1.AuthorizationSettings.JWT.EncodingDefault, // The encoding to use when converting the payload to a string.
|
|
34
|
+
allowInsecureKeySizes: authorization_settings_1.AuthorizationSettings.JWT.AllowInsecureKeySizes, // If true, allows the use of insecure key sizes.
|
|
35
|
+
allowInvalidAsymmetricKeyTypes: authorization_settings_1.AuthorizationSettings.JWT.AllowInvalidAsymmetricKeyTypes, // If true, allows the use of invalid asymmetric key types.
|
|
36
|
+
};
|
|
37
|
+
if (keyid)
|
|
38
|
+
jwtOptions.keyid = keyid;
|
|
39
|
+
if (header)
|
|
40
|
+
jwtOptions.header = header;
|
|
41
|
+
return jwtOptions;
|
|
42
|
+
};
|
|
43
|
+
exports.createJwtOptions = createJwtOptions;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IAuthorizationPayload } from '../../../models/authorization/authorization-models';
|
|
2
|
+
import jwt from 'jsonwebtoken';
|
|
3
|
+
/**
|
|
4
|
+
* This creates a signed JWT token with the given payload and secret key.
|
|
5
|
+
*
|
|
6
|
+
* @param payload the payload to sign
|
|
7
|
+
* @param secretKey the secret key to sign the token with
|
|
8
|
+
* @param options the options for the signed jwt token
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
declare const createJWTSignedToken: (payload: IAuthorizationPayload, secretKey: string, options: jwt.SignOptions) => string;
|
|
12
|
+
export { createJWTSignedToken };
|
|
13
|
+
//# sourceMappingURL=create-jwt-signed-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-jwt-signed-token.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/sign/create-jwt-signed-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,GAAG,MAAM,cAAc,CAAC;AAG/B;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,YACb,qBAAqB,aACnB,MAAM,WACR,GAAG,CAAC,WAAW,KACzB,MAIF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createJWTSignedToken = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const create_secret_key_pem_1 = require("../keys/create-secret-key-pem");
|
|
9
|
+
/**
|
|
10
|
+
* This creates a signed JWT token with the given payload and secret key.
|
|
11
|
+
*
|
|
12
|
+
* @param payload the payload to sign
|
|
13
|
+
* @param secretKey the secret key to sign the token with
|
|
14
|
+
* @param options the options for the signed jwt token
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
const createJWTSignedToken = (payload, secretKey, options) => {
|
|
18
|
+
const jwtKey = (0, create_secret_key_pem_1.createSecretKeyPem)(secretKey);
|
|
19
|
+
const jwtToken = jsonwebtoken_1.default.sign(payload, jwtKey, options);
|
|
20
|
+
return jwtToken;
|
|
21
|
+
};
|
|
22
|
+
exports.createJWTSignedToken = createJWTSignedToken;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDecodedJwtToken, IValidSafeTokenPayload } from '../../../models/authorization/authorization-models';
|
|
2
|
+
/**
|
|
3
|
+
* This function transforms the token payload to a safe payload with custom claims (if any).
|
|
4
|
+
*
|
|
5
|
+
* @param payload the payload to transform
|
|
6
|
+
* @returns the safe payload
|
|
7
|
+
*/
|
|
8
|
+
declare const transformTokenPayloadToSafePayload: (payload: IValidSafeTokenPayload) => IDecodedJwtToken;
|
|
9
|
+
export { transformTokenPayloadToSafePayload };
|
|
10
|
+
//# sourceMappingURL=transform-token-payload-to-safe-payload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-token-payload-to-safe-payload.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/transform/transform-token-payload-to-safe-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AAE9G;;;;;GAKG;AACH,QAAA,MAAM,kCAAkC,YAAa,sBAAsB,KAAG,gBAuB7E,CAAC;AAEF,OAAO,EAAE,kCAAkC,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformTokenPayloadToSafePayload = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This function transforms the token payload to a safe payload with custom claims (if any).
|
|
6
|
+
*
|
|
7
|
+
* @param payload the payload to transform
|
|
8
|
+
* @returns the safe payload
|
|
9
|
+
*/
|
|
10
|
+
const transformTokenPayloadToSafePayload = (payload) => {
|
|
11
|
+
// get any other properties from the payload other than the default ones
|
|
12
|
+
const otherProperties = Object.keys(payload).reduce((acc, key) => {
|
|
13
|
+
if (!['iat', 'nbf', 'exp', 'sub', 'aud', 'iss'].includes(key)) {
|
|
14
|
+
acc[key] = payload[key];
|
|
15
|
+
}
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
const safePayload = {
|
|
19
|
+
iat: payload.iat,
|
|
20
|
+
nbf: payload.nbf,
|
|
21
|
+
exp: payload.exp,
|
|
22
|
+
sub: payload.sub,
|
|
23
|
+
aud: payload.aud,
|
|
24
|
+
iss: payload.iss,
|
|
25
|
+
};
|
|
26
|
+
if (Object.keys(otherProperties).length > 0) {
|
|
27
|
+
safePayload.customClaims = otherProperties;
|
|
28
|
+
}
|
|
29
|
+
return safePayload;
|
|
30
|
+
};
|
|
31
|
+
exports.transformTokenPayloadToSafePayload = transformTokenPayloadToSafePayload;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAuthorizationHeader } from '../../../models/authorization/authorization-models';
|
|
2
|
+
/**
|
|
3
|
+
* This function gets the decoded jwt header from the token.
|
|
4
|
+
*
|
|
5
|
+
* @param token the token to get the header from.
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const getDecodedJwtHeader: (token: string) => IAuthorizationHeader;
|
|
9
|
+
export { getDecodedJwtHeader };
|
|
10
|
+
//# sourceMappingURL=get-decoded-jwt-header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-decoded-jwt-header.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/verify/get-decoded-jwt-header.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAE1F;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,UAAW,MAAM,KAAG,oBAU5C,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDecodedJwtHeader = void 0;
|
|
4
|
+
const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
|
|
5
|
+
/**
|
|
6
|
+
* This function gets the decoded jwt header from the token.
|
|
7
|
+
*
|
|
8
|
+
* @param token the token to get the header from.
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const getDecodedJwtHeader = (token) => {
|
|
12
|
+
// break the token apart
|
|
13
|
+
const jwtTokenParts = token.split('.');
|
|
14
|
+
if (jwtTokenParts.length !== 3) {
|
|
15
|
+
throw new authorization_errors_1.SafeAuthorizationTokenNotBase64Error();
|
|
16
|
+
}
|
|
17
|
+
const header = JSON.parse(Buffer.from(jwtTokenParts[0], 'base64').toString('utf-8'));
|
|
18
|
+
return header;
|
|
19
|
+
};
|
|
20
|
+
exports.getDecodedJwtHeader = getDecodedJwtHeader;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JwtPayload } from 'jsonwebtoken';
|
|
2
|
+
/**
|
|
3
|
+
* This function gets the decoded payload from a signed JWT token.
|
|
4
|
+
*
|
|
5
|
+
* @param token the token to get the payload from
|
|
6
|
+
*/
|
|
7
|
+
declare const getDecodedJwtSignedTokenPayload: (token: string) => JwtPayload | null | string;
|
|
8
|
+
export { getDecodedJwtSignedTokenPayload };
|
|
9
|
+
//# sourceMappingURL=get-decoded-jwt-signed-token-payload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-decoded-jwt-signed-token-payload.d.ts","sourceRoot":"","sources":["../../../../src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,QAAA,MAAM,+BAA+B,UAAW,MAAM,KAAG,UAAU,GAAG,IAAI,GAAG,MAG5E,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
|