@aneuhold/core-ts-db-lib 1.0.1 → 1.0.2
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/README.md +2 -0
- package/lib/documents/common/ApiKey.d.ts +22 -0
- package/lib/documents/common/ApiKey.d.ts.map +1 -0
- package/lib/documents/common/ApiKey.js +29 -0
- package/lib/documents/common/User.d.ts +1 -0
- package/lib/documents/common/User.d.ts.map +1 -1
- package/lib/documents/common/User.js +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ObjectId } from 'bson';
|
|
2
|
+
import BaseDocument from '../BaseDocument';
|
|
3
|
+
/**
|
|
4
|
+
* A document containing an API key for a particular user. This is stored
|
|
5
|
+
* separately from the {@link User} document to enhance security a bit.
|
|
6
|
+
*/
|
|
7
|
+
export default class ApiKey implements BaseDocument {
|
|
8
|
+
_id: ObjectId;
|
|
9
|
+
/**
|
|
10
|
+
* The API key for the user.
|
|
11
|
+
*/
|
|
12
|
+
key: `${string}-${string}-${string}-${string}-${string}`;
|
|
13
|
+
/**
|
|
14
|
+
* The user ID that this key is for. This field is indexed in the database.
|
|
15
|
+
*/
|
|
16
|
+
userId: ObjectId;
|
|
17
|
+
/**
|
|
18
|
+
* Constructs a new {@link ApiKey} for the provided user.
|
|
19
|
+
*/
|
|
20
|
+
constructor(userId: ObjectId);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ApiKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiKey.d.ts","sourceRoot":"","sources":["../../../src/documents/common/ApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,YAAW,YAAY;IACjD,GAAG,WAAkB;IAErB;;OAEG;IACH,GAAG,sDAAuB;IAE1B;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;gBACS,MAAM,EAAE,QAAQ;CAG7B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
const bson_1 = require("bson");
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
/**
|
|
9
|
+
* A document containing an API key for a particular user. This is stored
|
|
10
|
+
* separately from the {@link User} document to enhance security a bit.
|
|
11
|
+
*/
|
|
12
|
+
class ApiKey {
|
|
13
|
+
_id = new bson_1.ObjectId();
|
|
14
|
+
/**
|
|
15
|
+
* The API key for the user.
|
|
16
|
+
*/
|
|
17
|
+
key = crypto_1.default.randomUUID();
|
|
18
|
+
/**
|
|
19
|
+
* The user ID that this key is for. This field is indexed in the database.
|
|
20
|
+
*/
|
|
21
|
+
userId;
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new {@link ApiKey} for the provided user.
|
|
24
|
+
*/
|
|
25
|
+
constructor(userId) {
|
|
26
|
+
this.userId = userId;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = ApiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../src/documents/common/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,YAAY;IAC/C,GAAG,WAAkB;IAErB,QAAQ,EAAE,MAAM,CAAC;IAEjB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAM;IAEP;;OAEG;gBACS,QAAQ,EAAE,MAAM;CAG7B"}
|
|
1
|
+
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../src/documents/common/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,YAAY;IAC/C,GAAG,WAAkB;IAErB,QAAQ,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAM;IAEP;;OAEG;gBACS,QAAQ,EAAE,MAAM;CAG7B"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAGxB,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.User = void 0;
|
|
6
|
+
exports.ApiKey = exports.User = void 0;
|
|
7
|
+
const ApiKey_1 = __importDefault(require("./documents/common/ApiKey"));
|
|
8
|
+
exports.ApiKey = ApiKey_1.default;
|
|
7
9
|
const User_1 = __importDefault(require("./documents/common/User"));
|
|
8
10
|
exports.User = User_1.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aneuhold/core-ts-db-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A core database library used for personal projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"link:local": "cd lib && yarn link",
|
|
29
29
|
"unlink:local": "cd lib && yarn unlink",
|
|
30
30
|
"upgrade:all": "yarn upgrade --latest",
|
|
31
|
+
"upgrade:core": "yarn upgrade --latest @aneuhold",
|
|
31
32
|
"test": "jest"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|