mezon-js 2.13.78 → 2.13.80
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/client.ts +3279 -2482
- package/dist/client.d.ts +163 -349
- package/dist/gateway.api.d.ts +33 -0
- package/dist/index.d.ts +2 -4
- package/dist/{api.gen.d.ts → mezon-js/api.gen.d.ts} +1 -0
- package/dist/mezon-js/client.d.ts +347 -0
- package/dist/mezon-js/gateway.api.d.ts +33 -0
- package/dist/mezon-js/index.d.ts +23 -0
- package/dist/mezon-js/session.d.ts +61 -0
- package/dist/mezon-js/socket.d.ts +1212 -0
- package/dist/mezon-js/types/index.d.ts +2212 -0
- package/dist/mezon-js/utils.d.ts +6 -0
- package/dist/mezon-js/web_socket_adapter.d.ts +83 -0
- package/dist/mezon-js.cjs.js +9038 -21145
- package/dist/mezon-js.esm.mjs +9038 -21145
- package/dist/mezon-js.esm.mjs.map +1 -0
- package/dist/session.d.ts +11 -11
- package/dist/socket.d.ts +385 -386
- package/dist/types/index.d.ts +2212 -0
- package/dist/utils.d.ts +2 -0
- package/dist/webrpc/index.d.ts +3 -0
- package/gateway.api.ts +577 -0
- package/index.ts +2 -5
- package/package.json +3 -2
- package/rollup.config.js +64 -30
- package/session.ts +22 -22
- package/socket.ts +921 -846
- package/types/index.ts +3883 -0
- package/utils.ts +107 -47
- package/api/api.ts +0 -39185
- package/api.gen.ts +0 -11777
- package/google/protobuf/struct.ts +0 -554
- package/google/protobuf/timestamp.ts +0 -223
- package/google/protobuf/wrappers.ts +0 -670
- /package/dist/{api → mezon-js/api}/api.d.ts +0 -0
- /package/dist/{google → mezon-js/google}/protobuf/struct.d.ts +0 -0
- /package/dist/{google → mezon-js/google}/protobuf/timestamp.d.ts +0 -0
- /package/dist/{google → mezon-js/google}/protobuf/wrappers.d.ts +0 -0
package/rollup.config.js
CHANGED
|
@@ -1,44 +1,78 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Heroic Labs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// Rollup is the legacy build system for mezon-js and is only used for cocos2d-x-js support.
|
|
18
|
-
|
|
19
1
|
import typescript from '@rollup/plugin-typescript';
|
|
20
2
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
21
3
|
import commonjs from '@rollup/plugin-commonjs';
|
|
22
4
|
|
|
23
5
|
export default {
|
|
6
|
+
context: 'globalThis',
|
|
24
7
|
input: './index.ts',
|
|
25
|
-
output:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
output: [
|
|
9
|
+
{
|
|
10
|
+
format: 'umd',
|
|
11
|
+
name: 'mezonjs',
|
|
12
|
+
dir: "dist",
|
|
13
|
+
entryFileNames: "mezon-js.umd.js",
|
|
14
|
+
sourcemap: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
format: 'es',
|
|
18
|
+
name: 'mezonjs',
|
|
19
|
+
dir: "dist",
|
|
20
|
+
entryFileNames: "mezon-js.esm.mjs",
|
|
21
|
+
sourcemap: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
format: 'cjs',
|
|
25
|
+
name: 'mezonjs',
|
|
26
|
+
dir: "dist",
|
|
27
|
+
entryFileNames: "mezon-js.cjs.js",
|
|
28
|
+
sourcemap: true,
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
31
|
plugins: [
|
|
32
|
+
// 1. nodeResolve MUST be first to find the files in node_modules and gen folder
|
|
33
|
+
nodeResolve({
|
|
34
|
+
browser: true,
|
|
35
|
+
extensions: ['.ts', '.js']
|
|
36
|
+
}),
|
|
37
|
+
|
|
38
|
+
// 2. Only ONE typescript plugin. Use it to handle everything.
|
|
32
39
|
typescript({
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
// Ensure this covers your source, generated files, and connectrpc
|
|
41
|
+
include: [
|
|
42
|
+
"**/*.ts",
|
|
43
|
+
"../webrpc/frontend/src/gen/**/*.ts",
|
|
44
|
+
"src/gen/**/*.ts",
|
|
45
|
+
"node_modules/@connectrpc/**/*.ts"
|
|
46
|
+
],
|
|
47
|
+
target: "es5",
|
|
48
|
+
module: "esnext",
|
|
49
|
+
tsconfig: "./tsconfig.json",
|
|
50
|
+
rootDir: "../",
|
|
35
51
|
}),
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
|
|
53
|
+
// 3. CommonJS converts the output so UMD works correctly
|
|
54
|
+
commonjs({
|
|
55
|
+
extensions: ['.ts', '.js'],
|
|
56
|
+
// If connectrpc uses commonjs internally, include it here
|
|
57
|
+
include: [/node_modules/]
|
|
38
58
|
}),
|
|
39
|
-
commonjs()
|
|
40
59
|
],
|
|
41
60
|
moduleContext: {
|
|
42
61
|
[require.resolve('whatwg-fetch')]: 'window'
|
|
62
|
+
},
|
|
63
|
+
onwarn(warning, warn) {
|
|
64
|
+
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.ids[0].includes('node_modules')) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (warning.code === 'EVAL' && warning.loc && warning.loc.file.includes('protobufjs')) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (warning.code === 'THIS_IS_UNDEFINED' && warning.loc && warning.loc.file.includes('@connectrpc')) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
warn(warning);
|
|
43
77
|
}
|
|
44
|
-
};
|
|
78
|
+
};
|
package/session.ts
CHANGED
|
@@ -25,17 +25,17 @@ export interface ISession {
|
|
|
25
25
|
/** If the user account for this session was just created. */
|
|
26
26
|
created: boolean
|
|
27
27
|
/** The UNIX timestamp when this session was created. */
|
|
28
|
-
readonly
|
|
28
|
+
readonly createdAt: number;
|
|
29
29
|
/** The UNIX timestamp when this session will expire. */
|
|
30
30
|
expires_at?: number;
|
|
31
31
|
/** The UNIX timestamp when the refresh token will expire. */
|
|
32
32
|
refresh_expires_at?: number;
|
|
33
33
|
/** Refresh token that can be used for session token renewal. */
|
|
34
|
-
|
|
34
|
+
refreshToken: string;
|
|
35
35
|
/** The username of the user who owns this session. */
|
|
36
36
|
username?: string;
|
|
37
37
|
/** The ID of the user who owns this session. */
|
|
38
|
-
|
|
38
|
+
userId?: string;
|
|
39
39
|
/** Any custom properties associated with this session. */
|
|
40
40
|
vars?: object;
|
|
41
41
|
|
|
@@ -49,29 +49,29 @@ export interface ISession {
|
|
|
49
49
|
export class Session implements ISession {
|
|
50
50
|
|
|
51
51
|
token : string;
|
|
52
|
-
readonly
|
|
52
|
+
readonly createdAt: number;
|
|
53
53
|
expires_at?: number;
|
|
54
54
|
refresh_expires_at?: number;
|
|
55
|
-
|
|
55
|
+
refreshToken: string;
|
|
56
56
|
username?: string;
|
|
57
|
-
|
|
57
|
+
userId?: string;
|
|
58
58
|
vars?: object;
|
|
59
|
-
|
|
59
|
+
isRemember?: boolean;
|
|
60
60
|
|
|
61
61
|
constructor(
|
|
62
62
|
token: string,
|
|
63
|
-
|
|
63
|
+
refreshToken: string,
|
|
64
64
|
readonly created: boolean,
|
|
65
|
-
readonly
|
|
66
|
-
readonly
|
|
67
|
-
|
|
65
|
+
readonly apiUrl: string,
|
|
66
|
+
readonly idToken: string,
|
|
67
|
+
isRemember: boolean) {
|
|
68
68
|
this.token = token;
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
this.update(token,
|
|
69
|
+
this.refreshToken = refreshToken;
|
|
70
|
+
this.idToken = idToken;
|
|
71
|
+
this.apiUrl = apiUrl;
|
|
72
|
+
this.createdAt = Math.floor(new Date().getTime() / 1000);
|
|
73
|
+
this.isRemember = isRemember;
|
|
74
|
+
this.update(token, refreshToken, isRemember);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
isexpired(currenttime: number): boolean {
|
|
@@ -105,18 +105,18 @@ export class Session implements ISession {
|
|
|
105
105
|
const refreshTokenDecoded = JSON.parse(base64.atob(refreshTokenParts[1]))
|
|
106
106
|
const refreshTokenExpiresAt = Math.floor(parseInt(refreshTokenDecoded['exp']));
|
|
107
107
|
this.refresh_expires_at = refreshTokenExpiresAt;
|
|
108
|
-
this.
|
|
109
|
-
this.
|
|
108
|
+
this.refreshToken = refreshToken;
|
|
109
|
+
this.isRemember = isRemember;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
this.token = token;
|
|
113
113
|
this.expires_at = tokenExpiresAt;
|
|
114
114
|
this.username = tokenDecoded['usn'];
|
|
115
|
-
this.
|
|
115
|
+
this.userId = tokenDecoded['uid'];
|
|
116
116
|
this.vars = tokenDecoded['vrs'];
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
static restore(token: string, refreshToken: string,
|
|
120
|
-
return new Session(token, refreshToken, false,
|
|
119
|
+
static restore(token: string, refreshToken: string, apiUrl: string, isRemember: boolean): Session {
|
|
120
|
+
return new Session(token, refreshToken, false, apiUrl, "", isRemember);
|
|
121
121
|
}
|
|
122
122
|
}
|