@4players/odin-nodejs 0.10.0 → 0.10.1

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.
@@ -11,8 +11,12 @@
11
11
  Napi::Object OdinClient::Init(Napi::Env env, Napi::Object exports) {
12
12
  // This method is used to hook the accessor and method callbacks
13
13
  Napi::Function func = DefineClass(env, "OdinClient", {
14
- InstanceMethod<&OdinClient::GenerateAccessToken>("generateAccessToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
14
+ InstanceMethod<&OdinClient::GenerateAccessToken>("generateToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
15
15
  InstanceMethod<&OdinClient::CreateRoom>("createRoom", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
16
+ InstanceMethod<&OdinClient::CreateRoomWithAccessToken>("createRoomWithToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
17
+
18
+ // Deprecated functions
19
+ InstanceMethod<&OdinClient::GenerateAccessToken>("generateAccessToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
16
20
  InstanceMethod<&OdinClient::CreateRoomWithAccessToken>("createRoomWithAccessToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable))
17
21
  });
18
22
 
package/odin.client.d.ts CHANGED
@@ -13,13 +13,23 @@ export declare class OdinClient {
13
13
  constructor(sampleRate?: number, channelCount?: number);
14
14
 
15
15
  /**
16
- * Generates an access token for the given access key, room and user ID. This token can be used to join the room.
16
+ * Generates a token for the given access key, room and user ID. This token can be used to join the room.
17
+ * To be more consistent with other SDKs, this method is deprecated. Use generateToken instead.
17
18
  * @param accessKey - The access key to use to generate the token. You can get a free access token in our developer center
18
19
  * @param roomId - The ID of the room to generate the token for.
19
20
  * @param userId - The ID of the user to generate the token for.
21
+ * @deprecated Use generateToken instead
20
22
  */
21
23
  generateAccessToken(accessKey: string, roomId: string, userId: string): string;
22
24
 
25
+ /**
26
+ * Generates a room token for the given access key, room and user ID. This token can be used to join the room.
27
+ * @param accessKey - The access key to use to generate the token. You can get a free access token in our developer center
28
+ * @param roomId - The ID of the room to generate the token for.
29
+ * @param userId - The ID of the user to generate the token for.
30
+ */
31
+ generateToken(accessKey: string, roomId: string, userId: string): string;
32
+
23
33
  /**
24
34
  * Creates a new local room instance with the given ID and user ID. Use join to connect to that room.
25
35
  * @param accessKey - The access key to use to generate the token. You can get a free access token in our developer center
@@ -31,8 +41,18 @@ export declare class OdinClient {
31
41
  /**
32
42
  * Creates a new local room instance with the given access token. Use `join` on the returned OdinRoom instance to
33
43
  * connect to that room. Use this method if you already have an access token, either created elsewhere or by calling
34
- * `generateAccessToken`.
44
+ * `generateToken`.
45
+ * To be more consistent with other SDKs, this method is deprecated. Use createRoomWithToken instead.
35
46
  * @param accessToken - The access token to use to join the room.
47
+ * @deprecated Use createRoomWithToken instead
36
48
  */
37
49
  createRoomWithAccessToken(accessToken: string): OdinRoom;
50
+
51
+ /**
52
+ * Creates a new local room instance with the given room token. Use `join` on the returned OdinRoom instance to
53
+ * connect to that room. Use this method if you already have an access token, either created elsewhere or by calling
54
+ * `generateAccessToken`.
55
+ * @param accessToken - The access token to use to join the room.
56
+ */
57
+ createRoomWithToken(accessToken: string): OdinRoom;
38
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4players/odin-nodejs",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "NodeJS bindings for the ODIN SDK. Use for AI enhanced human interactions, content moderation and audio processing features in a backend.",
5
5
  "main": "index.cjs",
6
6
  "types": "index.d.ts",
Binary file
@@ -18,8 +18,8 @@ const configuration = new Configuration({
18
18
  const openai = new OpenAIApi(configuration);
19
19
 
20
20
  // Create an odin client instance using our access key and create a room
21
- const odinClient = new OdinClient(accessKey);
22
- const room = odinClient.createRoom(roomName, userName);
21
+ const odinClient = new OdinClient();
22
+ const room = odinClient.createRoom(accessKey, roomName, userName);
23
23
 
24
24
  // Listen on PeerJoined messages and print the user data of the joined peer
25
25
  room.addEventListener('PeerJoined', (event) => {
@@ -24,8 +24,8 @@ const data = new TextEncoder().encode(JSON.stringify(userData));
24
24
  const odinClient = new OdinClient(48000, 2);
25
25
 
26
26
  // Create a token then join the room with that token, token may also be created elsewhere
27
- const token = odinClient.generateAccessToken(accessKey, roomName, userName);
28
- const room = odinClient.createRoomWithAccessToken(token);
27
+ const token = odinClient.generateToken(accessKey, roomName, userName);
28
+ const room = odinClient.createRoomWithToken(token);
29
29
 
30
30
  // It's also possible to create a room with an access key, room name and username then token is created internally
31
31
  //const room = odinClient.createRoom(accessKey, roomName, userName);