mezon-sdk 2.7.1 → 2.7.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/dist/api.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ /** A user's session used to authenticate messages. */
2
+ export interface ApiSession {
3
+ created?: boolean;
4
+ refresh_token?: string;
5
+ token?: string;
6
+ }
7
+ /** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
8
+ export interface ApiAuthenticateLogoutRequest {
9
+ refresh_token?: string;
10
+ token?: string;
11
+ }
12
+ /** Authenticate against the server with a refresh token. */
13
+ export interface ApiAuthenticateRefreshRequest {
14
+ refresh_token?: string;
15
+ }
16
+ /** Authenticate against the server with a device ID. */
17
+ export interface ApiAuthenticateRequest {
18
+ account?: ApiAccountApp;
19
+ }
20
+ /** Send a app token to the server. Used with authenticate/link/unlink. */
21
+ export interface ApiAccountApp {
22
+ appid?: string;
23
+ appname?: string;
24
+ token?: string;
25
+ vars?: Record<string, string>;
26
+ }
27
+ /** The request to update the status of a message. */
28
+ export interface ApiUpdateMessageRequest {
29
+ consume_time?: string;
30
+ id?: string;
31
+ read_time?: string;
32
+ }
33
+ export declare class MezonApi {
34
+ readonly apiKey: string;
35
+ readonly basePath: string;
36
+ readonly timeoutMs: number;
37
+ constructor(apiKey: string, basePath: string, timeoutMs: number);
38
+ /** A healthcheck which load balancers can use to check the service. */
39
+ mezonHealthcheck(bearerToken: string, options?: any): Promise<any>;
40
+ /** A readycheck which load balancers can use to check the service. */
41
+ mezonReadycheck(bearerToken: string, options?: any): Promise<any>;
42
+ /** Authenticate a app with a token against the server. */
43
+ mezonAuthenticate(basicAuthUsername: string, basicAuthPassword: string, body: ApiAuthenticateRequest, options?: any): Promise<ApiSession>;
44
+ /** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
45
+ mezonAuthenticateLogout(bearerToken: string, body: ApiAuthenticateLogoutRequest, options?: any): Promise<any>;
46
+ /** Refresh a user's session using a refresh token retrieved from a previous authentication request. */
47
+ mezonAuthenticateRefresh(basicAuthUsername: string, basicAuthPassword: string, body: ApiAuthenticateRefreshRequest, options?: any): Promise<ApiSession>;
48
+ /** Deletes a message for an identity. */
49
+ mezonDeleteMessage(bearerToken: string, id: string, options?: any): Promise<any>;
50
+ /** Updates a message for an identity. */
51
+ mezonUpdateMessage(bearerToken: string, id: string, body: ApiUpdateMessageRequest, options?: any): Promise<any>;
52
+ buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>): string;
53
+ }
package/dist/client.d.ts CHANGED
@@ -1,74 +1,60 @@
1
- /**
2
- * Copyright 2020 The Nakama 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
- import { ApiEvent } from "./api.gen";
17
- import { Session } from "./session";
18
- /** A client for Satori server. */
19
- export declare class Client {
20
- readonly apiKey: string;
21
- readonly host: string;
22
- readonly port: string;
23
- readonly useSSL: boolean;
24
- readonly timeout: number;
25
- readonly autoRefreshSession: boolean;
26
- /** The expired timespan used to check session lifetime. */
27
- expiredTimespanMs: number;
28
- /** The low level API client for Nakama server. */
29
- private readonly apiClient;
30
- constructor(apiKey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number, autoRefreshSession?: boolean);
31
- /** Authenticate a user with an ID against the server. */
32
- authenticate(id: string, customProperties?: Record<string, string>, defaultProperties?: Record<string, string>): Promise<Session>;
33
- /** Refresh a user's session using a refresh token retrieved from a previous authentication request. */
34
- sessionRefresh(session: Session): Promise<Session>;
35
- /** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
36
- logout(session: Session): Promise<boolean>;
37
- /** Publish an event for this session. */
38
- event(session: Session, event: ApiEvent): Promise<boolean>;
39
- /** Publish multiple events for this session */
40
- events(session: Session, events: Array<ApiEvent>): Promise<boolean>;
41
- /** Get or list all available experiments for this identity. */
42
- getExperiments(session: Session, names?: Array<string>): Promise<import("./api.gen").ApiExperimentList>;
43
- /** Get a single flag for this identity. Throws an error when the flag does not exist. */
44
- getFlag(session: Session, name: string): Promise<never>;
45
- /** Get a single flag for this identity. */
46
- getFlagWithFallback(session: Session, name: string, fallbackValue?: string): Promise<{
47
- name: string;
48
- value: string | undefined;
49
- }>;
50
- /** Get a single flag with its configured default value. Throws an error when the flag does not exist. */
51
- getFlagDefault(name: string): Promise<never>;
52
- /** Get a single flag with its configured default value. */
53
- getFlagDefaultWithFallback(name: string, fallbackValue?: string): Promise<{
54
- name: string;
55
- value: string | undefined;
56
- }>;
57
- /** List all available flags for this identity. */
58
- getFlags(session: Session, names?: Array<string>): Promise<import("./api.gen").ApiFlagList>;
59
- /** List all available default flags. */
60
- getFlagsDefault(names?: Array<string>): Promise<import("./api.gen").ApiFlagList>;
61
- /** Enrich/replace the current session with new identifier. */
62
- identify(session: Session, id: string, defaultProperties?: Record<string, string>, customProperties?: Record<string, string>): Promise<Session>;
63
- /** List available live events. */
64
- getLiveEvents(session: Session, names?: Array<string>): Promise<import("./api.gen").ApiLiveEventList>;
65
- /** List properties associated with this identity. */
66
- listProperties(session: Session): Promise<import("./api.gen").ApiProperties>;
67
- /** Update identity properties. */
68
- updateProperties(session: Session, defaultProperties?: Record<string, string>, customProperties?: Record<string, string>, recompute?: boolean): Promise<boolean>;
69
- /** Delete the caller's identity and associated data. */
70
- deleteIdentity(session: Session): Promise<boolean>;
71
- getMessageList(session: Session): Promise<boolean>;
72
- deleteMessage(session: Session, id: string): Promise<boolean>;
73
- updateMessage(session: Session, id: string, consume_time?: string, read_time?: string): Promise<boolean>;
74
- }
1
+ /**
2
+ * Copyright 2020 The Nakama 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
+ import { Session } from "./session";
17
+ import { ApiMessageReaction, ChannelCreatedEvent, ChannelDeletedEvent, ChannelMessage, ChannelUpdatedEvent, Socket, UserChannelAddedEvent, UserChannelRemovedEvent, UserClanRemovedEvent, VoiceJoinedEvent } from "./socket";
18
+ import { WebSocketAdapter } from "./web_socket_adapter";
19
+ /** A client for Mezon server. */
20
+ export declare class Client {
21
+ readonly apiKey: string;
22
+ readonly host: string;
23
+ readonly port: string;
24
+ readonly useSSL: boolean;
25
+ readonly timeout: number;
26
+ readonly autoRefreshSession: boolean;
27
+ /** The expired timespan used to check session lifetime. */
28
+ expiredTimespanMs: number;
29
+ /** The low level API client for Nakama server. */
30
+ private readonly apiClient;
31
+ constructor(apiKey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number, autoRefreshSession?: boolean);
32
+ /** Authenticate a user with an ID against the server. */
33
+ authenticate(): Promise<string | undefined>;
34
+ /** Refresh a user's session using a refresh token retrieved from a previous authentication request. */
35
+ sessionRefresh(session: Session): Promise<Session>;
36
+ /** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
37
+ logout(session: Session): Promise<boolean>;
38
+ deleteMessage(session: Session, id: string): Promise<boolean>;
39
+ updateMessage(session: Session, id: string, consume_time?: string, read_time?: string): Promise<boolean>;
40
+ /** A socket created with the client's configuration. */
41
+ createSocket(useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter, sendTimeoutMs?: number): Socket;
42
+ onerror(evt: Event): void;
43
+ onmessagereaction(messagereaction: ApiMessageReaction): void;
44
+ onchannelmessage(channelMessage: ChannelMessage): void;
45
+ ondisconnect(e: Event): void;
46
+ onuserchanneladded(user: UserChannelAddedEvent): void;
47
+ onuserchannelremoved(user: UserChannelRemovedEvent): void;
48
+ onuserclanremoved(user: UserClanRemovedEvent): void;
49
+ onchannelcreated(channelCreated: ChannelCreatedEvent): void;
50
+ onchanneldeleted(channelDeleted: ChannelDeletedEvent): void;
51
+ onchannelupdated(channelUpdated: ChannelUpdatedEvent): void;
52
+ onheartbeattimeout(): void;
53
+ /** Receive clan evnet. */
54
+ onMessage: (channelMessage: ChannelMessage) => void;
55
+ onClanMemberUpdate: (member_id: Array<string>, leave: boolean) => void;
56
+ onMessageDelete: (channelMessage: ChannelMessage) => void;
57
+ onMessageReactionAdd: (messageReactionEvent: ApiMessageReaction) => void;
58
+ onVoiceStateUpdate: (voiceState: VoiceJoinedEvent) => void;
59
+ onMessageReactionRemove: (messageReactionEvent: ApiMessageReaction) => void;
60
+ }
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- /**
2
- * Copyright 2020 The Nakama 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
- import "whatwg-fetch";
17
- export * from "./client";
18
- export * from "./session";
1
+ /**
2
+ * Copyright 2020 The Nakama 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
+ import "whatwg-fetch";
17
+ export * from "./client";
18
+ export * from "./session";