@degenerate/generic 0.1.3 → 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/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/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/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
- package/dist/crypto/seal/seal.d.ts +0 -1
- package/dist/crypto/seal/seal.d.ts.map +0 -1
- package/dist/crypto/seal/seal.js +0 -51
|
@@ -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);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AuthorityValidationType, IAuthorizationIssuer } from '../authorization/authorization-models';
|
|
2
|
+
/**
|
|
3
|
+
* This is the type of function that is being targetted in the transaction.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum SAFETransactionActionType {
|
|
6
|
+
ADD = "ADD",
|
|
7
|
+
REMOVE = "REMOVE",
|
|
8
|
+
UPDATE = "UPDATE"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* This is the transaction for sharing data in the SAFE Ecosystem.
|
|
12
|
+
*/
|
|
13
|
+
export declare enum SAFETransactionType {
|
|
14
|
+
AUTHORITY = "AUTHORITY",// the authority in the SAFE Ecosystem
|
|
15
|
+
SHAREDATA = "SHAREDATA",// the Share Data in the SAFE Ecosystem
|
|
16
|
+
FUNCTIONS = "FUNCTIONS",// the functions in the SAFE Ecosystem
|
|
17
|
+
RULES = "RULES",// the rules in the SAFE Ecosystem
|
|
18
|
+
EVENTS = "EVENTS",// the events in the SAFE Ecosystem
|
|
19
|
+
ENDPOINTS = "ENDPOINTS"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* This contains the minimum information required for a SAFE transaction.
|
|
23
|
+
*
|
|
24
|
+
const sampleTransactionBase: ISAFETransactionBase = {
|
|
25
|
+
createdAt: Date.now(),
|
|
26
|
+
authority: '0xAuthorityPublicKey',
|
|
27
|
+
authoritySignature: '0xAuthoritySignature',
|
|
28
|
+
transaction: {
|
|
29
|
+
type: SAFETransactionType.AUTHORITY,
|
|
30
|
+
action: SAFETransactionActionType.CREATE,
|
|
31
|
+
},
|
|
32
|
+
version: 1,
|
|
33
|
+
};
|
|
34
|
+
*/
|
|
35
|
+
export interface ISAFETransactionBase {
|
|
36
|
+
createdAt: number;
|
|
37
|
+
authority: string;
|
|
38
|
+
authoritySignature: string;
|
|
39
|
+
transaction: {
|
|
40
|
+
type: SAFETransactionType;
|
|
41
|
+
action: SAFETransactionActionType;
|
|
42
|
+
};
|
|
43
|
+
version: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* This is the transaction targetting an authority in the SAFE Ecosystem.
|
|
47
|
+
*
|
|
48
|
+
const sampleTransactionAuthority: ISAFETransactionAuthority = {
|
|
49
|
+
createdAt: Date.now(),
|
|
50
|
+
authority: '0xAuthorityPublicKey',
|
|
51
|
+
authoritySignature: '0xAuthoritySignature',
|
|
52
|
+
transaction: {
|
|
53
|
+
type: SAFETransactionType.AUTHORITY,
|
|
54
|
+
action: SAFETransactionActionType.CREATE,
|
|
55
|
+
data: {
|
|
56
|
+
authorizationIssuer: 'exampleIssuer-12345678' as IAuthorizationIssuer,
|
|
57
|
+
authorizationPublicKey: '0xAuthorizationPublicKey',
|
|
58
|
+
authorityValidationType: AuthorityValidationType.JWT,
|
|
59
|
+
authorityOver: [SAFETransactionType.SHAREDATA, SAFETransactionType.FUNCTIONS],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
version: 1,
|
|
63
|
+
};
|
|
64
|
+
*/
|
|
65
|
+
export interface ISAFETransactionAuthority extends ISAFETransactionBase {
|
|
66
|
+
transaction: {
|
|
67
|
+
type: SAFETransactionType.AUTHORITY;
|
|
68
|
+
action: SAFETransactionActionType;
|
|
69
|
+
data: ISAFETransactionAuthorityData;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* This is the data for the authority in the SAFE Ecosystem.
|
|
74
|
+
*/
|
|
75
|
+
export interface ISAFETransactionAuthorityData {
|
|
76
|
+
authorizationIssuer: IAuthorizationIssuer;
|
|
77
|
+
authorizationPublicKey: string;
|
|
78
|
+
authorityValidationType: AuthorityValidationType;
|
|
79
|
+
authorityOver: SAFETransactionType[];
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=safe-transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-transactions.d.ts","sourceRoot":"","sources":["../../../src/models/safe/safe-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAItG;;GAEG;AACH,oBAAY,yBAAyB;IACjC,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,oBAAY,mBAAmB;IAC3B,SAAS,cAAc,CAAE,sCAAsC;IAC/D,SAAS,cAAc,CAAE,uCAAuC;IAChE,SAAS,cAAc,CAAE,sCAAsC;IAC/D,KAAK,UAAU,CAAE,kCAAkC;IACnD,MAAM,WAAW,CAAE,mCAAmC;IACtD,SAAS,cAAc;CAC1B;AAID;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,oBAAoB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE;QACT,IAAI,EAAE,mBAAmB,CAAC;QAC1B,MAAM,EAAE,yBAAyB,CAAC;KACrC,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACnE,WAAW,EAAE;QACT,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC;QACpC,MAAM,EAAE,yBAAyB,CAAC;QAClC,IAAI,EAAE,6BAA6B,CAAC;KACvC,CAAA;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,mBAAmB,EAAE,oBAAoB,CAAC;IAC1C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,aAAa,EAAE,mBAAmB,EAAE,CAAC;CACxC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// This file is used to keep all safe transactions for the SAFE system.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SAFETransactionType = exports.SAFETransactionActionType = void 0;
|
|
5
|
+
//#region Enums
|
|
6
|
+
/**
|
|
7
|
+
* This is the type of function that is being targetted in the transaction.
|
|
8
|
+
*/
|
|
9
|
+
var SAFETransactionActionType;
|
|
10
|
+
(function (SAFETransactionActionType) {
|
|
11
|
+
SAFETransactionActionType["ADD"] = "ADD";
|
|
12
|
+
SAFETransactionActionType["REMOVE"] = "REMOVE";
|
|
13
|
+
SAFETransactionActionType["UPDATE"] = "UPDATE";
|
|
14
|
+
})(SAFETransactionActionType || (exports.SAFETransactionActionType = SAFETransactionActionType = {}));
|
|
15
|
+
/**
|
|
16
|
+
* This is the transaction for sharing data in the SAFE Ecosystem.
|
|
17
|
+
*/
|
|
18
|
+
var SAFETransactionType;
|
|
19
|
+
(function (SAFETransactionType) {
|
|
20
|
+
SAFETransactionType["AUTHORITY"] = "AUTHORITY";
|
|
21
|
+
SAFETransactionType["SHAREDATA"] = "SHAREDATA";
|
|
22
|
+
SAFETransactionType["FUNCTIONS"] = "FUNCTIONS";
|
|
23
|
+
SAFETransactionType["RULES"] = "RULES";
|
|
24
|
+
SAFETransactionType["EVENTS"] = "EVENTS";
|
|
25
|
+
SAFETransactionType["ENDPOINTS"] = "ENDPOINTS";
|
|
26
|
+
})(SAFETransactionType || (exports.SAFETransactionType = SAFETransactionType = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-data.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,oBAAY,cAAc;IACtB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,mBAAmB,wBAAwB;IAC3C,IAAI,SAAS;CAChB;AAGD,MAAM,WAAW,UAAU;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,MAAM,EAAE,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,OAAO;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,mBAAmB,EAAE,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC;CAC1E;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,qBAAqB;IACnE,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;CAClB"}
|
|
1
|
+
{"version":3,"file":"share-data.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,oBAAY,cAAc;IACtB,aAAa,kBAAkB;IAC/B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,mBAAmB,wBAAwB;IAC3C,IAAI,SAAS;CAChB;AAGD,MAAM,WAAW,UAAU;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,MAAM,EAAE,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,OAAO;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,mBAAmB,EAAE,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC;CAC1E;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,qBAAqB;IACnE,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -6,6 +6,7 @@ exports.ShareDataTypes = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
var ShareDataTypes;
|
|
8
8
|
(function (ShareDataTypes) {
|
|
9
|
+
ShareDataTypes["AUTHORIZATION"] = "AUTHORIZATION";
|
|
9
10
|
ShareDataTypes["RULE"] = "RULE";
|
|
10
11
|
ShareDataTypes["FUNCTION"] = "FUNCTION";
|
|
11
12
|
ShareDataTypes["TRANSACTION_HISTORY"] = "TRANSACTION_HISTORY";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@degenerate/generic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "This contains the generic information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"bip39": "^3.1.0",
|
|
51
51
|
"elliptic": "^6.5.7",
|
|
52
52
|
"firebase-admin": "^12.7.0",
|
|
53
|
-
"firebase-functions": "^6.1.0"
|
|
53
|
+
"firebase-functions": "^6.1.0",
|
|
54
|
+
"jsonwebtoken": "^9.0.2"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "914fe4dbb4c4a61963d137a4c583bd9084e2d802"
|
|
56
57
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../../src/crypto/seal/seal.ts"],"names":[],"mappings":""}
|
package/dist/crypto/seal/seal.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
;
|
|
3
|
-
(async () => {
|
|
4
|
-
// ES6 or CommonJS
|
|
5
|
-
// import SEAL from 'node-seal'
|
|
6
|
-
// const SEAL = require('node-seal')
|
|
7
|
-
// Using CommonJS for RunKit
|
|
8
|
-
const SEAL = require('node-seal');
|
|
9
|
-
const seal = await SEAL();
|
|
10
|
-
const schemeType = seal.SchemeType.bfv;
|
|
11
|
-
const securityLevel = seal.SecurityLevel.tc128;
|
|
12
|
-
const polyModulusDegree = 4096;
|
|
13
|
-
const bitSizes = [36, 36, 37];
|
|
14
|
-
const bitSize = 20;
|
|
15
|
-
const parms = seal.EncryptionParameters(schemeType);
|
|
16
|
-
// Set the PolyModulusDegree
|
|
17
|
-
parms.setPolyModulusDegree(polyModulusDegree);
|
|
18
|
-
// Create a suitable set of CoeffModulus primes
|
|
19
|
-
parms.setCoeffModulus(seal.CoeffModulus.Create(polyModulusDegree, Int32Array.from(bitSizes)));
|
|
20
|
-
// Set the PlainModulus to a prime of bitSize 20.
|
|
21
|
-
parms.setPlainModulus(seal.PlainModulus.Batching(polyModulusDegree, bitSize));
|
|
22
|
-
const context = seal.Context(parms, // Encryption Parameters
|
|
23
|
-
true, // ExpandModChain
|
|
24
|
-
securityLevel // Enforce a security level
|
|
25
|
-
);
|
|
26
|
-
if (!context.parametersSet()) {
|
|
27
|
-
throw new Error('Could not set the parameters in the given context. Please try different encryption parameters.');
|
|
28
|
-
}
|
|
29
|
-
const encoder = seal.BatchEncoder(context);
|
|
30
|
-
const keyGenerator = seal.KeyGenerator(context);
|
|
31
|
-
const publicKey = keyGenerator.createPublicKey();
|
|
32
|
-
const secretKey = keyGenerator.secretKey();
|
|
33
|
-
const encryptor = seal.Encryptor(context, publicKey);
|
|
34
|
-
const decryptor = seal.Decryptor(context, secretKey);
|
|
35
|
-
const evaluator = seal.Evaluator(context);
|
|
36
|
-
// Create data to be encrypted
|
|
37
|
-
const array = Int32Array.from([1, 2, 3, 4, 5]);
|
|
38
|
-
// Encode the Array
|
|
39
|
-
const plainText = encoder.encode(array);
|
|
40
|
-
// Encrypt the PlainText
|
|
41
|
-
const cipherText = encryptor.encrypt(plainText);
|
|
42
|
-
// Add the CipherText to itself and store it in the destination parameter (itself)
|
|
43
|
-
evaluator.add(cipherText, cipherText, cipherText); // Op (A), Op (B), Op (Dest)
|
|
44
|
-
// Or create return a new cipher with the result (omitting destination parameter)
|
|
45
|
-
// const cipher2x = evaluator.add(cipherText, cipherText)
|
|
46
|
-
// Decrypt the CipherText
|
|
47
|
-
const decryptedPlainText = decryptor.decrypt(cipherText);
|
|
48
|
-
// Decode the PlainText
|
|
49
|
-
const decodedArray = encoder.decode(decryptedPlainText);
|
|
50
|
-
console.log('decodedArray', decodedArray);
|
|
51
|
-
})();
|