@secrecy/lib 1.63.0 → 1.64.1-feat-share-up-to.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.
@@ -305,10 +305,10 @@ export class SecrecyCloudClient {
305
305
  const users = folder.parent?.users?.filter(([u]) => u.id !== this.#client.app.userId) ??
306
306
  [];
307
307
  if (users.length > 0) {
308
- await this.shareNode(users.map(([user, rights]) => ({
308
+ await this.shareNode(users.map(([user, permissions]) => ({
309
309
  userId: user.id,
310
- rights,
311
310
  nodeId: folder.id,
311
+ permissions,
312
312
  })));
313
313
  }
314
314
  return folder;
@@ -359,17 +359,17 @@ export class SecrecyCloudClient {
359
359
  : 'userIds' in input
360
360
  ? 'nodeIds' in input
361
361
  ? input.userIds.flatMap((userId) => input.nodeIds.map((nodeId) => ({
362
- rights: input.rights,
362
+ permissions: input.permissions,
363
363
  userId,
364
364
  nodeId,
365
365
  })))
366
366
  : input.userIds.map((userId) => ({
367
- rights: input.rights,
367
+ permissions: input.permissions,
368
368
  userId,
369
369
  nodeId: input.nodeId,
370
370
  }))
371
371
  : input.nodeIds.map((nodeId) => ({
372
- rights: input.rights,
372
+ permissions: input.permissions,
373
373
  nodeId,
374
374
  userId: input.userId,
375
375
  }));
@@ -380,26 +380,29 @@ export class SecrecyCloudClient {
380
380
  .map((node) => {
381
381
  const share = shares.find((share) => share.nodeId === node.nodeId && share.userId === userId);
382
382
  if (!share) {
383
- throw new Error('Unable to retrieve rights!');
383
+ throw new Error('Unable to retrieve permissions!');
384
384
  }
385
385
  return {
386
386
  nodeId: node.nodeId,
387
387
  userId: userId,
388
- rights: share.rights,
388
+ permissions: share.permissions,
389
389
  };
390
390
  }),
391
391
  ]));
392
- const withKeys = Object.fromEntries(Object.entries(infos).map('rights' in input
392
+ const withKeys = Object.fromEntries(Object.entries(infos).map('permissions' in input
393
393
  ? ([userId, nodes]) => [
394
394
  userId,
395
- { userId, nodes, rights: input.rights },
395
+ { userId, nodes, permissions: input.permissions },
396
396
  ]
397
397
  : ([userId, nodes]) => {
398
398
  const share = shares.find((share) => share.userId === userId && share.nodeId === nodes[0].id);
399
399
  if (!share) {
400
- throw new Error('Unable to retrieve rights!');
400
+ throw new Error('Unable to retrieve permissions!');
401
401
  }
402
- return [userId, { userId, nodes, rights: share.rights }];
402
+ return [
403
+ userId,
404
+ { userId, nodes, permissions: share.permissions },
405
+ ];
403
406
  }));
404
407
  const finishInput = [];
405
408
  for (const [userId, nodes] of Object.entries(withKeys)) {
@@ -407,7 +410,7 @@ export class SecrecyCloudClient {
407
410
  userId,
408
411
  nodes: nodes.nodes.map((node) => ({
409
412
  id: node.id,
410
- rights: nodes.rights,
413
+ permissions: nodes.permissions,
411
414
  nameKey: node.nameKey,
412
415
  data: node.data.map((d) => ({
413
416
  id: d.id,
@@ -422,7 +425,7 @@ export class SecrecyCloudClient {
422
425
  nodes: [
423
426
  {
424
427
  id: node.nodeId,
425
- rights: node.rights,
428
+ permissions: node.permissions,
426
429
  data: [],
427
430
  },
428
431
  ],
@@ -650,13 +653,14 @@ export class SecrecyCloudClient {
650
653
  });
651
654
  const node = await apiNodeToExternalNodeFull(saveInCloud, this.#keys);
652
655
  const me = node.parent?.users.find(([u]) => u.id === this.#client.app.userId);
653
- if (me !== undefined && ['admin', 'write'].includes(me[1])) {
656
+ // TODO: ??
657
+ if (me !== undefined && ['delete', 'write'].includes(me[1].rights)) {
654
658
  const others = node.parent?.users.filter(([u]) => u.id !== this.#client.app.userId) ??
655
659
  [];
656
660
  if (others.length > 0) {
657
- await this.shareNode(others.map(([user, rights]) => ({
661
+ await this.shareNode(others.map(([user, permissions]) => ({
658
662
  userId: user.id,
659
- rights,
663
+ permissions,
660
664
  nodeId: node.id,
661
665
  })));
662
666
  }
@@ -11,7 +11,7 @@ async function apiNodeToInternal(apiNode, keyPair) {
11
11
  name: apiNode.name,
12
12
  isFavorite: apiNode.isFavorite,
13
13
  breadcrumb: 'breadcrumb' in apiNode ? apiNode.breadcrumb : [],
14
- createdBy: apiNode.createdBy,
14
+ owner: apiNode.owner,
15
15
  sizes: 'sizes' in apiNode
16
16
  ? apiNode.sizes
17
17
  : {
@@ -67,8 +67,8 @@ function internalNodeToNode(internal) {
67
67
  })),
68
68
  access: {
69
69
  isRoot: internal.access.isRoot,
70
- rights: internal.access.rights,
71
70
  sharedByPubKey: internal.access.sharedByPubKey,
71
+ permissions: internal.access.permissions,
72
72
  },
73
73
  };
74
74
  return node;
@@ -24,7 +24,7 @@ export declare class BaseClient {
24
24
  static getUser(userId: string, opts?: CreateTrpcClientOptions): Promise<PublicUser>;
25
25
  getUser(userId: string): Promise<PublicUser>;
26
26
  searchUsers(search: string): Promise<PublicUser[]>;
27
- updateProfile(data: RouterInputs['user']['updateProfile']): Promise<Omit<SelfUser, 'account'>>;
27
+ updateProfile(data: RouterInputs['user']['updateProfile']): Promise<RouterOutputs['user']['updateProfile']>;
28
28
  static isCryptoTransactionDone({ idOrHash, network, opts, }: {
29
29
  idOrHash: string;
30
30
  network?: InfuraNetwork;
@@ -132,9 +132,21 @@ export declare class SecrecyCloudClient {
132
132
  }[];
133
133
  invalidRightsAccesses: {
134
134
  userId: string;
135
- current: "admin" | "write" | "read";
135
+ current: {
136
+ rights: "delete" | "write" | "read";
137
+ addAccess: "delete" | "write" | "read" | null;
138
+ sharingAddAccess: "delete" | "write" | "read" | null;
139
+ delAccess: "delete" | "write" | "read" | null;
140
+ sharingDelAccess: "delete" | "write" | "read" | null;
141
+ };
136
142
  nodeId: string;
137
- expect: "admin" | "write" | "read";
143
+ expect: {
144
+ rights: "delete" | "write" | "read";
145
+ addAccess: "delete" | "write" | "read" | null;
146
+ sharingAddAccess: "delete" | "write" | "read" | null;
147
+ delAccess: "delete" | "write" | "read" | null;
148
+ sharingDelAccess: "delete" | "write" | "read" | null;
149
+ };
138
150
  }[];
139
151
  };
140
152
  isMatching: false;
@@ -1,8 +1,9 @@
1
1
  import { type RouterOutputs } from '../../client.js';
2
2
  import type { DataMetadata, InternalData, PublicUser } from './index.js';
3
- export type Rights = ApiNode['users'][number][1];
3
+ export type NodeRights = ApiNode['users'][number][1];
4
+ export type Permissions = Pick<ApiNode['access']['permissions'], 'rights'> & Partial<Omit<ApiNode['access']['permissions'], 'rights'>>;
4
5
  export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T & {
5
- rights: Rights;
6
+ permissions: Permissions;
6
7
  isRoot: boolean;
7
8
  sharedByPubKey: string;
8
9
  };
@@ -31,9 +32,9 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
31
32
  sizes: NodeSize;
32
33
  name: string;
33
34
  breadcrumb: T[];
34
- createdBy: PublicUser;
35
+ owner: PublicUser;
35
36
  access: NodeAccess<U>;
36
- users: Array<[PublicUser, Rights]>;
37
+ users: Array<[PublicUser, NodeRights]>;
37
38
  currentDataId: string | null;
38
39
  parentId: string | null;
39
40
  }
@@ -82,9 +83,9 @@ export type ShareNodeDetails = {
82
83
  }[];
83
84
  invalidRightsAccesses: {
84
85
  userId: string;
85
- current: Rights;
86
+ current: NodeRights;
86
87
  nodeId: string;
87
- expect: Rights;
88
+ expect: NodeRights;
88
89
  }[];
89
90
  };
90
91
  export {};