mezon-js 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright 2022 The Mezon Authors
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
+ /** A session authenticated for a user with Mezon server. */
17
+ export interface ISession {
18
+ /** Claims */
19
+ /** The authorization token used to construct this session. */
20
+ token: string;
21
+ /** If the user account for this session was just created. */
22
+ created: boolean;
23
+ /** The UNIX timestamp when this session was created. */
24
+ readonly created_at: number;
25
+ /** The UNIX timestamp when this session will expire. */
26
+ expires_at?: number;
27
+ /** The UNIX timestamp when the refresh token will expire. */
28
+ refresh_expires_at?: number;
29
+ /** Refresh token that can be used for session token renewal. */
30
+ refresh_token: string;
31
+ /** The username of the user who owns this session. */
32
+ username?: string;
33
+ /** The ID of the user who owns this session. */
34
+ user_id?: string;
35
+ /** Any custom properties associated with this session. */
36
+ vars?: object;
37
+ /** Validate token */
38
+ /** If the session has expired. */
39
+ isexpired(currenttime: number): boolean;
40
+ /** If the refresh token has expired. */
41
+ isrefreshexpired(currenttime: number): boolean;
42
+ }
43
+ export declare class Session implements ISession {
44
+ readonly created: boolean;
45
+ token: string;
46
+ readonly created_at: number;
47
+ expires_at?: number;
48
+ refresh_expires_at?: number;
49
+ refresh_token: string;
50
+ username?: string;
51
+ user_id?: string;
52
+ vars?: object;
53
+ constructor(token: string, refresh_token: string, created: boolean);
54
+ isexpired(currenttime: number): boolean;
55
+ isrefreshexpired(currenttime: number): boolean;
56
+ update(token: string, refreshToken: string): void;
57
+ static restore(token: string, refreshToken: string): Session;
58
+ }