@secrecy/lib 1.62.1-feat-orgs.1 → 1.62.1-feat-next15.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.
@@ -1,4 +1,3 @@
1
- import axios from 'axios';
2
1
  import ky from 'ky';
3
2
  import { nodesCache, dataCache, dataContentCache, nodesEncryptionCache, } from '../cache.js';
4
3
  import { secretStreamKeygen } from '../crypto/data.js';
@@ -185,7 +184,7 @@ export class SecrecyCloudClient {
185
184
  const progressParts = {};
186
185
  const onProgress = (part, progressEvent) => {
187
186
  progressParts[part] = progressEvent;
188
- const current = Object.values(progressParts).reduce((prv, cur) => prv + cur.loaded, 0);
187
+ const current = Object.values(progressParts).reduce((prv, cur) => prv + cur.transferredBytes, 0);
189
188
  void uploadProgress?.({
190
189
  percent: current / encryptedData.byteLength,
191
190
  total: encryptedData.byteLength,
@@ -202,11 +201,12 @@ export class SecrecyCloudClient {
202
201
  formData.append(key, value);
203
202
  }
204
203
  formData.append('file', new Blob([chunk.data], { type: filetype?.mime }), `${uploadData.id}-${chunk.order}`);
205
- await axios.post(part.url, formData, {
204
+ await ky.post(part.url, {
205
+ signal,
206
+ body: formData,
206
207
  onUploadProgress: (progressEvent) => {
207
208
  onProgress(part.order, progressEvent);
208
209
  },
209
- signal,
210
210
  });
211
211
  return uploadDataPartEnd(chunk.md5, chunk.order);
212
212
  };
@@ -1,4 +1,4 @@
1
- import { httpBatchLink, loggerLink, createTRPCProxyClient, TRPCClientError, } from '@trpc/client';
1
+ import { httpBatchLink, loggerLink, createTRPCClient as innerCreateTRPCClient, TRPCClientError, } from '@trpc/client';
2
2
  import superjson from 'superjson';
3
3
  import { SECRECY_LIB_VERSION } from './versioning.js';
4
4
  export function isTRPCClientError(cause) {
@@ -9,8 +9,7 @@ superjson.registerCustom({
9
9
  serialize: (v) => [...v],
10
10
  deserialize: (v) => Buffer.from(v),
11
11
  }, 'buffer');
12
- export const createTRPCClient = (opts) => createTRPCProxyClient({
13
- transformer: superjson,
12
+ export const createTRPCClient = (opts) => innerCreateTRPCClient({
14
13
  links: [
15
14
  loggerLink({
16
15
  enabled: (op) => {
@@ -24,6 +23,7 @@ export const createTRPCClient = (opts) => createTRPCProxyClient({
24
23
  },
25
24
  }),
26
25
  httpBatchLink({
26
+ transformer: superjson,
27
27
  url: opts.apiUrl
28
28
  ? `${opts.apiUrl}/trpc`
29
29
  : 'https://api.secrecy.tech/trpc',
@@ -4,9 +4,9 @@ export declare const dataCache: Map<string, InternalData>;
4
4
  export declare const nodesCache: Map<string, InternalNode | InternalNodeFull>;
5
5
  export declare const nodesEncryptionCache: Map<string, InternalMinimalNodeForEncryption>;
6
6
  export declare const usersCache: Map<string, {
7
- id: string;
8
- lastname: string;
9
7
  firstname: string;
8
+ lastname: string;
9
+ id: string;
10
10
  avatar: string | null;
11
11
  isSearchable: boolean;
12
12
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { ProgressCallback, SecrecyClient } from '../index.js';
2
2
  import type { DataMetadata, DataStorageType, KeyPair, LocalData, Node, NodeFull, NodeType } from './types/index.js';
3
3
  import { type RouterInputs, type ApiClient, type RouterOutputs } from '../client.js';
4
- import { type DownloadProgress } from '../types.js';
4
+ import { type Progress } from '../types.js';
5
5
  import { FileTypeResult } from 'file-type';
6
6
  export declare class SecrecyCloudClient {
7
7
  #private;
@@ -63,13 +63,13 @@ export declare class SecrecyCloudClient {
63
63
  }): Promise<NodeFull>;
64
64
  dataContent({ dataId, onDownloadProgress, progressDecrypt, signal, }: {
65
65
  dataId: string;
66
- onDownloadProgress?: (progress: DownloadProgress) => void;
66
+ onDownloadProgress?: (progress: Progress) => void;
67
67
  progressDecrypt?: ProgressCallback;
68
68
  signal?: AbortSignal;
69
69
  }): Promise<LocalData>;
70
70
  dataContents({ dataIds, onDownloadProgress, progressDecrypt, signal, }: {
71
71
  dataIds: string[];
72
- onDownloadProgress?: (progress: DownloadProgress) => void;
72
+ onDownloadProgress?: (progress: Progress) => void;
73
73
  progressDecrypt?: ProgressCallback;
74
74
  signal?: AbortSignal;
75
75
  }): Promise<LocalData[]>;
@@ -104,22 +104,23 @@ export declare class SecrecyCloudClient {
104
104
  toType: "s3" | "cold" | "lite";
105
105
  }>;
106
106
  getPublicDataLink(input: RouterInputs['cloud']['dataLink']): Promise<{
107
- name: string;
108
107
  id: string;
108
+ name: string;
109
109
  dataId: string;
110
- expireAt: Date | null;
111
110
  slug: string;
111
+ expireAt: Date | null;
112
112
  }>;
113
113
  getPublicDataLinks(input: RouterInputs['cloud']['dataLinks']): Promise<{
114
- name: string;
115
114
  id: string;
115
+ name: string;
116
116
  dataId: string;
117
- expireAt: Date | null;
118
117
  slug: string;
118
+ expireAt: Date | null;
119
119
  }[]>;
120
120
  checkAccesses(input: RouterInputs['cloud']['checkAccesses']): Promise<{
121
121
  isMatching: true;
122
122
  } | {
123
+ isMatching: false;
123
124
  details: {
124
125
  missingNodeAccesses: {
125
126
  userId: string;
@@ -132,33 +133,32 @@ export declare class SecrecyCloudClient {
132
133
  }[];
133
134
  invalidRightsAccesses: {
134
135
  userId: string;
135
- current: "admin" | "write" | "read";
136
136
  nodeId: string;
137
+ current: "admin" | "write" | "read";
137
138
  expect: "admin" | "write" | "read";
138
139
  }[];
139
140
  };
140
- isMatching: false;
141
141
  }>;
142
142
  createPublicDataLink(input: RouterInputs['cloud']['createDataLink']): Promise<{
143
- name: string;
144
143
  id: string;
144
+ name: string;
145
145
  dataId: string;
146
- expireAt: Date | null;
147
146
  slug: string;
147
+ expireAt: Date | null;
148
148
  }>;
149
149
  updatePublicDataLink(input: RouterInputs['cloud']['updateDataLink']): Promise<{
150
- name: string;
151
150
  id: string;
151
+ name: string;
152
152
  dataId: string;
153
- expireAt: Date | null;
154
153
  slug: string;
154
+ expireAt: Date | null;
155
155
  }>;
156
156
  deletePublicDataLink(input: RouterInputs['cloud']['deleteDataLink']): Promise<{
157
- name: string;
158
157
  id: string;
158
+ name: string;
159
159
  dataId: string;
160
- expireAt: Date | null;
161
160
  slug: string;
161
+ expireAt: Date | null;
162
162
  }>;
163
163
  private _handleDataContent;
164
164
  }
@@ -1,5 +1,5 @@
1
1
  import { BaseClient, type SecrecyUrls } from '../base-client.js';
2
- import type { Progress } from '../crypto/data.js';
2
+ import type { SecretStreamProgress } from '../crypto/data.js';
3
3
  import { SecrecyCloudClient } from './SecrecyCloudClient.js';
4
4
  import { SecrecyMailClient } from './SecrecyMailClient.js';
5
5
  import { SecrecyAppClient } from './SecrecyAppClient.js';
@@ -11,7 +11,7 @@ import { type KeyPair } from './types/index.js';
11
11
  import { SecrecyUserClient } from './SecrecyUserClient.js';
12
12
  import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
13
13
  export type NewMail = Pick<RouterInputs['mail']['createDraft'], 'body' | 'subject' | 'senderFiles' | 'recipients' | 'replyToId'>;
14
- export type ProgressCallback = (progress: Progress) => Promise<void>;
14
+ export type ProgressCallback = (progress: SecretStreamProgress) => Promise<void>;
15
15
  export interface SecrecyClientOptions {
16
16
  uaSession: string;
17
17
  uaKeys: KeyPair;
@@ -29,18 +29,18 @@ export declare const secrecyUserApp: z.ZodReadonly<z.ZodObject<{
29
29
  jwt: z.ZodString;
30
30
  uaSession: z.ZodString;
31
31
  }, "strict", z.ZodTypeAny, {
32
+ jwt: string;
32
33
  keys: {
33
34
  publicKey: string;
34
35
  privateKey: string;
35
36
  };
36
- jwt: string;
37
37
  uaSession: string;
38
38
  }, {
39
+ jwt: string;
39
40
  keys: {
40
41
  publicKey: string;
41
42
  privateKey: string;
42
43
  };
43
- jwt: string;
44
44
  uaSession: string;
45
45
  }>>;
46
46
  export type SecrecyUserApp = z.infer<typeof secrecyUserApp>;