magicrealmsshared 0.3.7 → 0.3.9
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/communication/ws.d.ts +6 -0
- package/dist/communication/ws.js +2 -1
- package/dist/util/authentication.d.ts +1 -0
- package/dist/util/authentication.js +8 -0
- package/package.json +5 -1
- package/src/communication/ws.ts +23 -1
- package/src/types/types.ts +18 -0
- package/src/util/authentication.ts +6 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Well } from "../types/types";
|
|
2
2
|
export declare const AUTH = "AUTH";
|
|
3
3
|
export declare const AUTH_ACK = "AUTH_ACK";
|
|
4
|
+
export declare const LOGIN_COMMAND = "LOGIN";
|
|
5
|
+
export type LOGIN_DATA = {
|
|
6
|
+
email: string;
|
|
7
|
+
passwordHash: string;
|
|
8
|
+
passwordSalt: string;
|
|
9
|
+
};
|
|
4
10
|
export declare const DATA_UPDATE_COMMAND = "DATA_UPDATE";
|
|
5
11
|
export type DATA_UPDATE<T> = {
|
|
6
12
|
wells: Well<T>[];
|
package/dist/communication/ws.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.POSUPDATE_COMMAND = exports.DATA_UPDATE_COMMAND = exports.AUTH_ACK = exports.AUTH = void 0;
|
|
3
|
+
exports.POSUPDATE_COMMAND = exports.DATA_UPDATE_COMMAND = exports.LOGIN_COMMAND = exports.AUTH_ACK = exports.AUTH = void 0;
|
|
4
4
|
exports.AUTH = "AUTH";
|
|
5
5
|
exports.AUTH_ACK = "AUTH_ACK";
|
|
6
|
+
exports.LOGIN_COMMAND = "LOGIN";
|
|
6
7
|
exports.DATA_UPDATE_COMMAND = "DATA_UPDATE";
|
|
7
8
|
exports.POSUPDATE_COMMAND = "POSUPDATE";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function passwordSalted(username: string, password: string, salt: string, sha256: (input: string) => (Promise<string> | string)): Promise<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.passwordSalted = passwordSalted;
|
|
4
|
+
const salt1 = 'c<MS$gk:^8r[K`;6b!x#a@';
|
|
5
|
+
const salt2 = 'r@k-6>}3mJhgX72Y{,HV!:';
|
|
6
|
+
async function passwordSalted(username, password, salt, sha256) {
|
|
7
|
+
return sha256(salt1 + username + salt + password + salt2);
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magicrealmsshared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"./types": {
|
|
25
25
|
"types": "./dist/types/types.d.ts",
|
|
26
26
|
"default": "./dist/types/types.js"
|
|
27
|
+
},
|
|
28
|
+
"./util/authentication": {
|
|
29
|
+
"types": "./dist/util/authentication.d.ts",
|
|
30
|
+
"default": "./dist/util/authentication.js"
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
}
|
package/src/communication/ws.ts
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
import { Well } from "../types/types";
|
|
1
|
+
import { Auth_Token, Player, Well } from "../types/types";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export const AUTH = "AUTH";
|
|
5
5
|
export const AUTH_ACK = "AUTH_ACK";
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const LOGIN_COMMAND = "LOGIN";
|
|
10
|
+
export type LOGIN_DATA = {
|
|
11
|
+
email: string;
|
|
12
|
+
passwordHash: string;
|
|
13
|
+
passwordSalt: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const LOGIN_RESPONSE_COMMAND = "NIGOL";
|
|
17
|
+
export type LOGIN_RESPONSE_DATA<T> = {
|
|
18
|
+
code: number;
|
|
19
|
+
playerData?: Player<T>;
|
|
20
|
+
authToken?: Auth_Token;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const LOGIN_RESPONSE_CODE_SUCCESS = 0;
|
|
24
|
+
export const LOGIN_RESPONSE_CODE_EMAIL_INVALID = 10;
|
|
25
|
+
export const LOGIN_RESPONSE_CODE_PASSWORD_INVALID = 20;
|
|
26
|
+
export const LOGIN_RESPONSE_CODE_SERVER_ERROR = 1000;
|
|
27
|
+
|
|
28
|
+
|
|
7
29
|
export const DATA_UPDATE_COMMAND = "DATA_UPDATE";
|
|
8
30
|
export type DATA_UPDATE<T> = {
|
|
9
31
|
wells: Well<T>[],
|
package/src/types/types.ts
CHANGED
|
@@ -18,6 +18,24 @@ export type Privileges = {
|
|
|
18
18
|
//TODO: add other privileges as required
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
export type Auth_Token = {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Auth-Token-String
|
|
25
|
+
*
|
|
26
|
+
* @type {string}
|
|
27
|
+
*/
|
|
28
|
+
s: string,
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Expiration
|
|
33
|
+
*
|
|
34
|
+
* @type {Date}
|
|
35
|
+
*/
|
|
36
|
+
e: Date,
|
|
37
|
+
};
|
|
38
|
+
|
|
21
39
|
export type Player<T> = ObjectWithId<T> & {
|
|
22
40
|
email: string,
|
|
23
41
|
password: string,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const salt1 = 'c<MS$gk:^8r[K`;6b!x#a@';
|
|
2
|
+
const salt2 = 'r@k-6>}3mJhgX72Y{,HV!:';
|
|
3
|
+
|
|
4
|
+
export async function passwordSalted(username: string, password: string,salt: string, sha256: (input: string) => (Promise<string>|string)): Promise<string> {
|
|
5
|
+
return sha256(salt1 + username + salt + password + salt2);
|
|
6
|
+
}
|