@peers-app/peers-ui 0.20.0 → 0.20.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.
@@ -161,16 +161,8 @@ function CreateGroupModal({ colorMode, userContext, onClose, onGroupCreated, })
161
161
  const groupKeys = (0, peers_sdk_1.newKeys)();
162
162
  // Create group data context
163
163
  const groupDataContext = userContext.getDataContext(groupId);
164
- // Store groupKeys.secretKey securely for this group
165
- const persistentVarsTable = userContext.userDataContext.tableContainer.getTableByName("PersistentVars");
166
- const groupSecretKeyVarName = `groupSecretKey_${groupDataContext.dataContextId}`;
167
- await persistentVarsTable.save({
168
- persistentVarId: (0, peers_sdk_1.newid)(),
169
- name: groupSecretKeyVarName,
170
- scope: "groupUser",
171
- isSecret: true,
172
- value: { value: groupKeys.secretKey },
173
- });
164
+ // Store the validated secret under its deterministic persistent-variable ID.
165
+ await (0, peers_sdk_1.saveGroupSecretKey)(userContext.userDataContext, groupId, groupKeys.secretKey, groupKeys);
174
166
  // Add current user to the group's users table
175
167
  await (0, peers_sdk_1.Users)(groupDataContext).save(me);
176
168
  // Set trust level for current user in the group context
@@ -82,16 +82,8 @@ function GroupList() {
82
82
  // NOTE: this is relying on the userContext to be able to create a group context for a group that doesn't yet exist
83
83
  // at time of writing, this is supported but is probably unintuitive behavior so we need to watch for this changing in the future
84
84
  const groupDataContext = userContext.getDataContext(groupId);
85
- // Store groupKeys.secretKey securely for this group
86
- const persistentVarsTable = userContext.userDataContext.tableContainer.getTableByName("PersistentVars");
87
- const groupSecretKeyVarName = `groupSecretKey_${groupDataContext.dataContextId}`;
88
- await persistentVarsTable.save({
89
- persistentVarId: (0, peers_sdk_1.newid)(),
90
- name: groupSecretKeyVarName,
91
- scope: "groupUser",
92
- isSecret: true,
93
- value: { value: groupKeys.secretKey },
94
- });
85
+ // Store the validated secret under its deterministic persistent-variable ID.
86
+ await (0, peers_sdk_1.saveGroupSecretKey)(userContext.userDataContext, groupId, groupKeys.secretKey, groupKeys);
95
87
  // add me to the group's users table
96
88
  const me = await (0, peers_sdk_1.getMe)();
97
89
  await (0, peers_sdk_1.Users)(groupDataContext).save(me);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-ui",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-ui.git"
@@ -28,7 +28,7 @@
28
28
  "lint:fix": "biome check --write ."
29
29
  },
30
30
  "peerDependencies": {
31
- "@peers-app/peers-sdk": "^0.20.0",
31
+ "@peers-app/peers-sdk": "^0.20.1",
32
32
  "bootstrap": "^5.3.3",
33
33
  "react": "^18.0.0",
34
34
  "react-dom": "^18.0.0"
@@ -39,7 +39,7 @@
39
39
  "@babel/preset-env": "^7.24.5",
40
40
  "@babel/preset-react": "^7.24.1",
41
41
  "@babel/preset-typescript": "^7.27.1",
42
- "@peers-app/peers-sdk": "0.20.0",
42
+ "@peers-app/peers-sdk": "0.20.1",
43
43
  "@testing-library/dom": "^10.4.0",
44
44
  "@testing-library/jest-dom": "^6.6.3",
45
45
  "@testing-library/react": "^16.3.0",
@@ -6,6 +6,7 @@ import {
6
6
  newid,
7
7
  newKeys,
8
8
  rpcServerCalls,
9
+ saveGroupSecretKey,
9
10
  setUserTrustLevel,
10
11
  TrustLevel,
11
12
  type UserContext,
@@ -258,17 +259,13 @@ function CreateGroupModal({
258
259
  // Create group data context
259
260
  const groupDataContext = userContext.getDataContext(groupId);
260
261
 
261
- // Store groupKeys.secretKey securely for this group
262
- const persistentVarsTable =
263
- userContext.userDataContext.tableContainer.getTableByName("PersistentVars");
264
- const groupSecretKeyVarName = `groupSecretKey_${groupDataContext.dataContextId}`;
265
- await persistentVarsTable.save({
266
- persistentVarId: newid(),
267
- name: groupSecretKeyVarName,
268
- scope: "groupUser",
269
- isSecret: true,
270
- value: { value: groupKeys.secretKey },
271
- });
262
+ // Store the validated secret under its deterministic persistent-variable ID.
263
+ await saveGroupSecretKey(
264
+ userContext.userDataContext,
265
+ groupId,
266
+ groupKeys.secretKey,
267
+ groupKeys,
268
+ );
272
269
 
273
270
  // Add current user to the group's users table
274
271
  await Users(groupDataContext).save(me);
@@ -8,6 +8,7 @@ import {
8
8
  newKeys,
9
9
  observable,
10
10
  rpcServerCalls,
11
+ saveGroupSecretKey,
11
12
  setUserTrustLevel,
12
13
  TrustLevel,
13
14
  Users,
@@ -97,17 +98,8 @@ export function GroupList() {
97
98
  // at time of writing, this is supported but is probably unintuitive behavior so we need to watch for this changing in the future
98
99
  const groupDataContext = userContext.getDataContext(groupId);
99
100
 
100
- // Store groupKeys.secretKey securely for this group
101
- const persistentVarsTable =
102
- userContext.userDataContext.tableContainer.getTableByName("PersistentVars");
103
- const groupSecretKeyVarName = `groupSecretKey_${groupDataContext.dataContextId}`;
104
- await persistentVarsTable.save({
105
- persistentVarId: newid(),
106
- name: groupSecretKeyVarName,
107
- scope: "groupUser",
108
- isSecret: true,
109
- value: { value: groupKeys.secretKey },
110
- });
101
+ // Store the validated secret under its deterministic persistent-variable ID.
102
+ await saveGroupSecretKey(userContext.userDataContext, groupId, groupKeys.secretKey, groupKeys);
111
103
 
112
104
  // add me to the group's users table
113
105
  const me = await getMe();