From cbfeb2a12f4e2ef33f5529c35e34aaaf7fdf3a6d Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Mon, 16 Dec 2024 11:30:33 -0600 Subject: [PATCH] Add support for custom permissions policy (node) --- sdks/node-sdk/package.json | 2 +- sdks/node-sdk/test/Conversations.test.ts | 37 ++++++++++++++++++++++++ yarn.lock | 10 +++---- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/sdks/node-sdk/package.json b/sdks/node-sdk/package.json index b83400d0f..9c0907d17 100644 --- a/sdks/node-sdk/package.json +++ b/sdks/node-sdk/package.json @@ -51,7 +51,7 @@ "@xmtp/content-type-group-updated": "^2.0.0", "@xmtp/content-type-primitives": "^2.0.0", "@xmtp/content-type-text": "^2.0.0", - "@xmtp/node-bindings": "^0.0.28", + "@xmtp/node-bindings": "^0.0.29", "@xmtp/proto": "^3.72.3" }, "devDependencies": { diff --git a/sdks/node-sdk/test/Conversations.test.ts b/sdks/node-sdk/test/Conversations.test.ts index 9c2e1a0d5..f28ddd7db 100644 --- a/sdks/node-sdk/test/Conversations.test.ts +++ b/sdks/node-sdk/test/Conversations.test.ts @@ -254,6 +254,43 @@ describe("Conversations", () => { expect(groupWithPinnedFrameUrl.pinnedFrameUrl).toBe("https://foo/bar"); }); + it("should create a group with custom permissions", async () => { + const user1 = createUser(); + const user2 = createUser(); + const client1 = await createRegisteredClient(user1); + await createRegisteredClient(user2); + const group = await client1.conversations.newGroup( + [user2.account.address], + { + permissions: GroupPermissionsOptions.CustomPolicy, + customPermissionPolicySet: { + addAdminPolicy: 1, + addMemberPolicy: 0, + removeAdminPolicy: 1, + removeMemberPolicy: 1, + updateGroupNamePolicy: 1, + updateGroupDescriptionPolicy: 1, + updateGroupImageUrlSquarePolicy: 1, + updateGroupPinnedFrameUrlPolicy: 1, + }, + }, + ); + expect(group).toBeDefined(); + expect(group.permissions.policyType).toBe( + GroupPermissionsOptions.CustomPolicy, + ); + expect(group.permissions.policySet).toEqual({ + addAdminPolicy: 1, + addMemberPolicy: 0, + removeAdminPolicy: 1, + removeMemberPolicy: 1, + updateGroupNamePolicy: 1, + updateGroupDescriptionPolicy: 1, + updateGroupImageUrlSquarePolicy: 1, + updateGroupPinnedFrameUrlPolicy: 1, + }); + }); + it("should stream new conversations", async () => { const user1 = createUser(); const user2 = createUser(); diff --git a/yarn.lock b/yarn.lock index 7700db730..a0dbed143 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5107,10 +5107,10 @@ __metadata: languageName: unknown linkType: soft -"@xmtp/node-bindings@npm:^0.0.28": - version: 0.0.28 - resolution: "@xmtp/node-bindings@npm:0.0.28" - checksum: 10/0ceea72582926dcce03c8e3839b7101d7ce4aef56a55b46421c2e46e96f65c90a224b1649ff765c1f3cb1e2e21a730d1891bb369260c94712066b85d358fb6f4 +"@xmtp/node-bindings@npm:^0.0.29": + version: 0.0.29 + resolution: "@xmtp/node-bindings@npm:0.0.29" + checksum: 10/d6abb86a58517bffff07bda59b387318a9d60b2ba0ca13376ef60fe79aa9afefb8e2b07b218064738b07c4e699eac967f8aff64942017f8872f4fe982ac475ae languageName: node linkType: hard @@ -5125,7 +5125,7 @@ __metadata: "@xmtp/content-type-group-updated": "npm:^2.0.0" "@xmtp/content-type-primitives": "npm:^2.0.0" "@xmtp/content-type-text": "npm:^2.0.0" - "@xmtp/node-bindings": "npm:^0.0.28" + "@xmtp/node-bindings": "npm:^0.0.29" "@xmtp/proto": "npm:^3.72.3" "@xmtp/xmtp-js": "workspace:^" fast-glob: "npm:^3.3.2"