@heroiclabs/nakama-js
Advanced tools
Comparing version 2.1.3 to 2.1.4
// tslint:disable | ||
/* Code generated by openapi-gen/main.go. DO NOT EDIT. */ | ||
import {encode} from 'js-base64'; | ||
export interface ConfigurationParameters { | ||
@@ -166,5 +168,7 @@ basePath?: string; | ||
export interface ApiChannelMessageList { | ||
// Cacheable cursor to list newer messages. Durable and designed to be stored, unlike next/prev cursors. | ||
cacheable_cursor?: string; | ||
// A list of messages. | ||
messages?: Array<ApiChannelMessage>; | ||
// The cursor to send when retireving the next page, if any. | ||
// The cursor to send when retrieving the next page, if any. | ||
next_cursor?: string; | ||
@@ -313,2 +317,4 @@ // The cursor to send when retrieving the previous page, if any. | ||
authoritative?: boolean; | ||
// | ||
handler_name?: string; | ||
// Match label, if any. | ||
@@ -320,2 +326,4 @@ label?: string; | ||
size?: number; | ||
// | ||
tick_rate?: number; | ||
} | ||
@@ -378,5 +386,14 @@ /** A list of realtime matches. */ | ||
created?: boolean; | ||
// Refresh token that can be used for session token renewal. | ||
refresh_token?: string; | ||
// Authentication credentials. | ||
token?: string; | ||
} | ||
/** Authenticate against the server with a refresh token. */ | ||
export interface ApiSessionRefreshRequest { | ||
// Refresh token. | ||
token?: string; | ||
// Extra information that will be bundled in the session token. | ||
vars?: Map<string, string>; | ||
} | ||
/** An object within the storage engine. */ | ||
@@ -641,3 +658,3 @@ export interface ApiStorageObject { | ||
} else if (this.configuration.username) { | ||
fetchOptions.headers["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); | ||
fetchOptions.headers["Authorization"] = "Basic " + encode(this.configuration.username + ":" + this.configuration.password); | ||
} | ||
@@ -1020,2 +1037,18 @@ if(!Object.keys(fetchOptions.headers).includes("Accept")) { | ||
} | ||
/** Refresh a user's session using a refresh token retrieved from a previous authentication request. */ | ||
sessionRefresh(body: ApiSessionRefreshRequest, options: any = {}): Promise<ApiSession> { | ||
if (body === null || body === undefined) { | ||
throw new Error("'body' is a required parameter but is null or undefined."); | ||
} | ||
const urlPath = "/v2/account/session/refresh"; | ||
const queryParams = { | ||
} as any; | ||
let _body = null; | ||
_body = JSON.stringify(body || {}); | ||
return this.doFetch(urlPath, "POST", queryParams, _body, options) | ||
} | ||
/** Remove the Apple ID from the social profiles on the current user's account. */ | ||
@@ -1022,0 +1055,0 @@ |
@@ -504,3 +504,3 @@ /** | ||
/** Authenticate a user with a device id against the server. */ | ||
authenticateDevice(id : string, vars? : Map<string, string>): Promise<Session> { | ||
authenticateDevice(id : string, create?: boolean, username?: string, vars? : Map<string, string>): Promise<Session> { | ||
const request = { | ||
@@ -511,3 +511,3 @@ "id": id, | ||
return this.apiClient.authenticateDevice(request).then((apiSession : ApiSession) => { | ||
return this.apiClient.authenticateDevice(request, create, username).then((apiSession : ApiSession) => { | ||
return Session.restore(apiSession.token || ""); | ||
@@ -518,3 +518,3 @@ }); | ||
/** Authenticate a user with an email+password against the server. */ | ||
authenticateEmail(email: string, password: string, vars?: Map<string,string>): Promise<Session> { | ||
authenticateEmail(email: string, password: string, create?: boolean, username?: string, vars?: Map<string,string>): Promise<Session> { | ||
const request = { | ||
@@ -526,3 +526,3 @@ "email": email, | ||
return this.apiClient.authenticateEmail(request).then((apiSession : ApiSession) => { | ||
return this.apiClient.authenticateEmail(request, create, username).then((apiSession : ApiSession) => { | ||
return Session.restore(apiSession.token || ""); | ||
@@ -570,3 +570,3 @@ }); | ||
/** Authenticate a user with GameCenter against the server. */ | ||
authenticateGameCenter(token: string, vars?: Map<string, string>): Promise<Session> { | ||
authenticateGameCenter(token: string, create?: boolean, username? :string, vars?: Map<string, string>): Promise<Session> { | ||
const request = { | ||
@@ -577,3 +577,3 @@ "token": token, | ||
return this.apiClient.authenticateGameCenter(request).then((apiSession : ApiSession) => { | ||
return this.apiClient.authenticateGameCenter(request, create, username).then((apiSession : ApiSession) => { | ||
return Session.restore(apiSession.token || ""); | ||
@@ -584,3 +584,3 @@ }); | ||
/** Authenticate a user with Steam against the server. */ | ||
authenticateSteam(token : string, vars? : Map<string, string>) : Promise<Session> { | ||
authenticateSteam(token : string, create?: boolean, username?: string, vars? : Map<string, string>) : Promise<Session> { | ||
const request = { | ||
@@ -591,3 +591,3 @@ "token": token, | ||
return this.apiClient.authenticateSteam(request).then((apiSession : ApiSession) => { | ||
return this.apiClient.authenticateSteam(request, create, username).then((apiSession : ApiSession) => { | ||
return Session.restore(apiSession.token || ""); | ||
@@ -986,2 +986,3 @@ }); | ||
return this.apiClient.listFriends(limit, state, cursor).then((response: ApiFriendList) => { | ||
var result: Friends = { | ||
@@ -1014,3 +1015,4 @@ friends: [], | ||
username: f.user!.username, | ||
metadata: f.user!.metadata ? JSON.parse(f.user!.metadata!) : undefined | ||
metadata: f.user!.metadata ? JSON.parse(f.user!.metadata!) : undefined, | ||
facebook_instant_game_id: f.user!.facebook_instant_game_id! | ||
}, | ||
@@ -1017,0 +1019,0 @@ state: f.state |
@@ -93,2 +93,3 @@ export interface ConfigurationParameters { | ||
export interface ApiChannelMessageList { | ||
cacheable_cursor?: string; | ||
messages?: Array<ApiChannelMessage>; | ||
@@ -173,5 +174,7 @@ next_cursor?: string; | ||
authoritative?: boolean; | ||
handler_name?: string; | ||
label?: string; | ||
match_id?: string; | ||
size?: number; | ||
tick_rate?: number; | ||
} | ||
@@ -209,4 +212,9 @@ export interface ApiMatchList { | ||
created?: boolean; | ||
refresh_token?: string; | ||
token?: string; | ||
} | ||
export interface ApiSessionRefreshRequest { | ||
token?: string; | ||
vars?: Map<string, string>; | ||
} | ||
export interface ApiStorageObject { | ||
@@ -356,2 +364,3 @@ collection?: string; | ||
linkSteam(body: ApiAccountSteam, options?: any): Promise<any>; | ||
sessionRefresh(body: ApiSessionRefreshRequest, options?: any): Promise<ApiSession>; | ||
unlinkApple(body: ApiAccountApple, options?: any): Promise<any>; | ||
@@ -358,0 +367,0 @@ unlinkCustom(body: ApiAccountCustom, options?: any): Promise<any>; |
@@ -205,9 +205,9 @@ import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiCreateGroupRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiMatchList, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiUpdateGroupRequest, ApiAccountApple } from "./api.gen"; | ||
authenticateCustom(id: string, create?: boolean, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>; | ||
authenticateDevice(id: string, vars?: Map<string, string>): Promise<Session>; | ||
authenticateEmail(email: string, password: string, vars?: Map<string, string>): Promise<Session>; | ||
authenticateDevice(id: string, create?: boolean, username?: string, vars?: Map<string, string>): Promise<Session>; | ||
authenticateEmail(email: string, password: string, create?: boolean, username?: string, vars?: Map<string, string>): Promise<Session>; | ||
authenticateFacebookInstantGame(signedPlayerInfo: string, create?: boolean, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>; | ||
authenticateFacebook(token: string, create?: boolean, username?: string, sync?: boolean, vars?: Map<string, string>, options?: any): Promise<Session>; | ||
authenticateGoogle(token: string, create?: boolean, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>; | ||
authenticateGameCenter(token: string, vars?: Map<string, string>): Promise<Session>; | ||
authenticateSteam(token: string, vars?: Map<string, string>): Promise<Session>; | ||
authenticateGameCenter(token: string, create?: boolean, username?: string, vars?: Map<string, string>): Promise<Session>; | ||
authenticateSteam(token: string, create?: boolean, username?: string, vars?: Map<string, string>): Promise<Session>; | ||
banGroupUsers(session: Session, groupId: string, ids?: Array<string>): Promise<boolean>; | ||
@@ -214,0 +214,0 @@ blockFriends(session: Session, ids?: Array<string>, usernames?: Array<string>): Promise<boolean>; |
@@ -1,2 +0,1 @@ | ||
import "Base64"; | ||
import "whatwg-fetch"; | ||
@@ -3,0 +2,0 @@ export * from "./client"; |
@@ -17,3 +17,2 @@ /** | ||
import "Base64"; | ||
import "whatwg-fetch"; | ||
@@ -20,0 +19,0 @@ |
{ | ||
"name": "@heroiclabs/nakama-js", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"scripts": { | ||
@@ -29,8 +29,11 @@ "build": "node build.js" | ||
"dependencies": { | ||
"Base64": "1.0.1", | ||
"js-base64": "^3.6.0", | ||
"whatwg-fetch": "^2.0.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/runtime": "^7.12.5", | ||
"@rollup/plugin-typescript": "^6.1.0", | ||
"rollup": "latest", | ||
"tslib": "^2.0.3" | ||
} | ||
} |
@@ -41,13 +41,2 @@ Nakama JavaScript client | ||
If you are including the optional protocol buffer adapter, pass the adapter to the Client object: | ||
```js | ||
import {Client} from "@heroiclabs/nakama-js"; | ||
import {WebSocketAdapterPb} from "@heroiclabs/nakama-js-protobuf"; | ||
var useSSL = false; // Enable if server is run with an SSL certificate. | ||
var client = new Client("defaultkey", "127.0.0.1", "7350", useSSL, new WebSocketAdapterPb()); | ||
``` | ||
## Usage | ||
@@ -121,2 +110,12 @@ | ||
If you are using the optional protocol buffer adapter, pass the adapter to the Socket object during construction: | ||
```js | ||
import {WebSocketAdapterPb} from "@heroiclabs/nakama-js-protobuf" | ||
const secure = false; // Enable if server is run with an SSL certificate | ||
const trace = false; | ||
const socket = client.createSocket(secure, trace, new WebSocketAdapterPb()); | ||
``` | ||
There's many messages for chat, realtime, status events, notifications, etc. which can be sent or received from the socket. | ||
@@ -123,0 +122,0 @@ |
@@ -0,3 +1,5 @@ | ||
import {encode, decode} from "js-base64" | ||
export function b64EncodeUnicode(str:string) { | ||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, | ||
return encode(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, | ||
function toSolidBytes(_match:string, p1) { | ||
@@ -9,5 +11,5 @@ return String.fromCharCode(Number('0x' + p1)); | ||
export function b64DecodeUnicode(str: string) { | ||
return decodeURIComponent(atob(str).split('').map(function(c) { | ||
return decodeURIComponent(decode(str).split('').map(function(c) { | ||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); | ||
}).join('')); | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
968404
16847
4
195
+ Addedjs-base64@^3.6.0
+ Addedjs-base64@3.7.7(transitive)
- RemovedBase64@1.0.1
- RemovedBase64@1.0.1(transitive)