@only-chat/in-memory-user-store 0.2.0-beta.10

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 ADDED
@@ -0,0 +1,2 @@
1
+ # only-chat
2
+ This is an in-memory user store implementation for only-chat.
@@ -0,0 +1,6 @@
1
+ import type { AuthenticationInfo, UserStore } from '@only-chat/types/userStore.js';
2
+ export interface StoreAuthenticationInfo extends AuthenticationInfo {
3
+ name: string;
4
+ password: string;
5
+ }
6
+ export declare function initialize(): Promise<UserStore>;
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ let users = new Map();
2
+ export async function initialize() {
3
+ users.clear();
4
+ return {
5
+ async authenticate(info) {
6
+ if (info.name) {
7
+ const name = info.name.trim().toLowerCase();
8
+ let password = users.get(name);
9
+ if (password) {
10
+ if (password !== info.password) {
11
+ return;
12
+ }
13
+ }
14
+ else {
15
+ users.set(name, info.password);
16
+ }
17
+ return name;
18
+ }
19
+ }
20
+ };
21
+ }
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,UAAU;IAC5B,KAAK,CAAC,KAAK,EAAE,CAAC;IAEd,OAAO;QACH,KAAK,CAAC,YAAY,CAAC,IAA6B;YAC5C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACZ,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;gBAE5C,IAAI,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAE/B,IAAI,QAAQ,EAAE,CAAC;oBACX,IAAI,QAAQ,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAC7B,OAAO;oBACX,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACJ,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACnC,CAAC;gBAED,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@only-chat/in-memory-user-store",
3
+ "version": "0.2.0-beta.10",
4
+ "description": "In memory users storage for only-chat",
5
+ "homepage": "https://github.com/only-chat/node-backend/packages/user-stores/memory",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/only-chat/node-backend.git",
12
+ "directory": "packages/user-stores/memory"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "test": "jest"
17
+ },
18
+ "author": "only-chat",
19
+ "license": "MIT",
20
+ "devDependencies": {
21
+ "@jest/globals": "^29.7.0",
22
+ "@only-chat/types": "0.2.0-beta.10",
23
+ "@types/jest": "^29.5.12",
24
+ "jest": "^29.7.0",
25
+ "jest-ts-webcompat-resolver": "^1.0.0",
26
+ "ts-jest": "^29.1.4",
27
+ "ts-node": "^10.9.2",
28
+ "typescript": "^5.4.5"
29
+ },
30
+ "files": [
31
+ "dist/"
32
+ ],
33
+ "keywords": [
34
+ "memory",
35
+ "only-chat",
36
+ "store",
37
+ "user"
38
+ ]
39
+ }