@skroz/profile-api 1.0.28 → 1.0.29
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/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/utils/encryptor.d.ts +3 -0
- package/dist/utils/encryptor.js +29 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/utils/encryptor.ts +27 -0
package/dist/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export * from './resolvers/ProfileResolver';
|
|
|
10
10
|
export * from './resolvers/createOauthResolver';
|
|
11
11
|
export * from './oauth';
|
|
12
12
|
export { default as createEntityDataLoader } from './utils/createEntityDataLoader';
|
|
13
|
+
export { getEncryptor, getGlobalId } from './utils/encryptor';
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.createEntityDataLoader = void 0;
|
|
20
|
+
exports.getGlobalId = exports.getEncryptor = exports.createEntityDataLoader = void 0;
|
|
21
21
|
__exportStar(require("./types"), exports);
|
|
22
22
|
__exportStar(require("./adapters/TypeOrmProfileAdapter"), exports);
|
|
23
23
|
__exportStar(require("./entities/TypeOrmBaseEntity"), exports);
|
|
@@ -31,3 +31,6 @@ __exportStar(require("./resolvers/createOauthResolver"), exports);
|
|
|
31
31
|
__exportStar(require("./oauth"), exports);
|
|
32
32
|
var createEntityDataLoader_1 = require("./utils/createEntityDataLoader");
|
|
33
33
|
Object.defineProperty(exports, "createEntityDataLoader", { enumerable: true, get: function () { return __importDefault(createEntityDataLoader_1).default; } });
|
|
34
|
+
var encryptor_1 = require("./utils/encryptor");
|
|
35
|
+
Object.defineProperty(exports, "getEncryptor", { enumerable: true, get: function () { return encryptor_1.getEncryptor; } });
|
|
36
|
+
Object.defineProperty(exports, "getGlobalId", { enumerable: true, get: function () { return encryptor_1.getGlobalId; } });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobalId = exports.getEncryptor = void 0;
|
|
4
|
+
const graphql_utils_1 = require("@os-team/graphql-utils");
|
|
5
|
+
let encryptor;
|
|
6
|
+
let globalId;
|
|
7
|
+
const getEncryptor = () => {
|
|
8
|
+
if (!encryptor) {
|
|
9
|
+
if (!process.env.ENCRYPTION_KEY) {
|
|
10
|
+
throw new Error('ENCRYPTION_KEY is not found');
|
|
11
|
+
}
|
|
12
|
+
if (!process.env.ENCRYPTION_IV) {
|
|
13
|
+
throw new Error('ENCRYPTION_IV is not found');
|
|
14
|
+
}
|
|
15
|
+
encryptor = new graphql_utils_1.Encryptor({
|
|
16
|
+
key: process.env.ENCRYPTION_KEY,
|
|
17
|
+
iv: process.env.ENCRYPTION_IV,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return encryptor;
|
|
21
|
+
};
|
|
22
|
+
exports.getEncryptor = getEncryptor;
|
|
23
|
+
const getGlobalId = () => {
|
|
24
|
+
if (!globalId) {
|
|
25
|
+
globalId = new graphql_utils_1.GlobalId((0, exports.getEncryptor)());
|
|
26
|
+
}
|
|
27
|
+
return globalId;
|
|
28
|
+
};
|
|
29
|
+
exports.getGlobalId = getGlobalId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skroz/profile-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "git@gitlab.com:skroz/libs/utils.git",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"type-graphql": "^1.1.1",
|
|
46
46
|
"typeorm": "^0.2.45"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c30923fe4d0d3ababb7a5056067f29a05d8f071a"
|
|
49
49
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,3 +10,4 @@ export * from './resolvers/ProfileResolver';
|
|
|
10
10
|
export * from './resolvers/createOauthResolver';
|
|
11
11
|
export * from './oauth';
|
|
12
12
|
export { default as createEntityDataLoader } from './utils/createEntityDataLoader';
|
|
13
|
+
export { getEncryptor, getGlobalId } from './utils/encryptor';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Encryptor, GlobalId } from '@os-team/graphql-utils';
|
|
2
|
+
|
|
3
|
+
let encryptor: Encryptor;
|
|
4
|
+
let globalId: GlobalId;
|
|
5
|
+
|
|
6
|
+
export const getEncryptor = () => {
|
|
7
|
+
if (!encryptor) {
|
|
8
|
+
if (!process.env.ENCRYPTION_KEY) {
|
|
9
|
+
throw new Error('ENCRYPTION_KEY is not found');
|
|
10
|
+
}
|
|
11
|
+
if (!process.env.ENCRYPTION_IV) {
|
|
12
|
+
throw new Error('ENCRYPTION_IV is not found');
|
|
13
|
+
}
|
|
14
|
+
encryptor = new Encryptor({
|
|
15
|
+
key: process.env.ENCRYPTION_KEY,
|
|
16
|
+
iv: process.env.ENCRYPTION_IV,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return encryptor;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const getGlobalId = () => {
|
|
23
|
+
if (!globalId) {
|
|
24
|
+
globalId = new GlobalId(getEncryptor());
|
|
25
|
+
}
|
|
26
|
+
return globalId;
|
|
27
|
+
};
|