@secrecy/lib 1.0.0 → 1.1.0

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.
Files changed (64) hide show
  1. package/LICENSE +1 -1
  2. package/dist/BaseClient.d.ts +29 -177
  3. package/dist/BaseClient.js +114 -732
  4. package/dist/PopupTools.d.ts +4 -4
  5. package/dist/PopupTools.js +24 -41
  6. package/dist/ZeusThunder.js +3 -17
  7. package/dist/cache.js +1 -1
  8. package/dist/client/SecrecyAppClient.d.ts +17 -0
  9. package/dist/client/SecrecyAppClient.js +226 -0
  10. package/dist/client/SecrecyCloudClient.d.ts +89 -0
  11. package/dist/client/SecrecyCloudClient.js +1405 -0
  12. package/dist/client/SecrecyDbClient.d.ts +21 -0
  13. package/dist/client/SecrecyDbClient.js +177 -0
  14. package/dist/client/SecrecyMailClient.d.ts +42 -0
  15. package/dist/client/SecrecyMailClient.js +1022 -0
  16. package/dist/client/SecrecyPayClient.d.ts +28 -0
  17. package/dist/client/SecrecyPayClient.js +68 -0
  18. package/dist/client/SecrecyWalletClient.d.ts +30 -0
  19. package/dist/client/SecrecyWalletClient.js +73 -0
  20. package/dist/client/convert/file.js +2 -3
  21. package/dist/client/convert/mail.d.ts +2 -2
  22. package/dist/client/convert/mail.js +7 -11
  23. package/dist/client/convert/node.js +19 -33
  24. package/dist/client/helpers.d.ts +9 -4
  25. package/dist/client/helpers.js +30 -25
  26. package/dist/client/index.d.ts +15 -145
  27. package/dist/client/index.js +16 -3176
  28. package/dist/client/storage.js +4 -4
  29. package/dist/client/types/File.d.ts +3 -3
  30. package/dist/client/types/Inputs.d.ts +4 -4
  31. package/dist/client/types/Node.d.ts +21 -14
  32. package/dist/client/types/Node.js +1 -1
  33. package/dist/client/types/UserAppNotifications.d.ts +1 -1
  34. package/dist/client/types/UserAppSettings.d.ts +2 -3
  35. package/dist/client/types/UserAppSettings.js +1 -1
  36. package/dist/client/types/index.d.ts +23 -51
  37. package/dist/client/types/index.js +1 -1
  38. package/dist/client/types/selectors.d.ts +51 -127
  39. package/dist/client/types/selectors.js +21 -11
  40. package/dist/crypto/file.d.ts +2 -2
  41. package/dist/crypto/file.js +19 -34
  42. package/dist/crypto/index.js +1 -3
  43. package/dist/error.d.ts +5 -2
  44. package/dist/error.js +1 -1
  45. package/dist/index.d.ts +7 -5
  46. package/dist/index.js +4 -4
  47. package/dist/minify/index.js +2 -7
  48. package/dist/minify/lz4.js +79 -167
  49. package/dist/sodium.js +1 -1
  50. package/dist/utils/store-buddy.d.ts +1 -1
  51. package/dist/utils/store-buddy.js +1 -8
  52. package/dist/utils/time.js +1 -3
  53. package/dist/utils/utils.js +1 -11
  54. package/dist/worker/md5.js +1 -2
  55. package/dist/worker/sodium.js +16 -18
  56. package/dist/worker/workerCodes.js +255 -3
  57. package/dist/zeus/const.js +587 -31
  58. package/dist/zeus/index.d.ts +5014 -631
  59. package/dist/zeus/index.js +213 -255
  60. package/package.json +64 -61
  61. package/dist/client/admin/index.d.ts +0 -11
  62. package/dist/client/admin/index.js +0 -110
  63. package/dist/worker/__mock__/sodium.worker.d.ts +0 -19
  64. package/dist/worker/__mock__/sodium.worker.js +0 -49
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Anonymize
3
+ Copyright (c) 2023 Anonymize
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,106 +1,14 @@
1
1
  import type { DownloadProgress as DLProgress } from "ky";
2
- import type { UserSession } from "./client/types/index.js";
3
2
  import type { SecrecyEnv } from "./client/helpers.js";
4
- import type { Lang, PayInputType, PlanKind, Thunder, UserRole } from "./zeus/index.js";
5
- import type { ErrorAccessDenied, ErrorLimit, ErrorNotFound, ErrorNotExist, ErrorLangNotExist, ErrorBasic } from "./error.js";
6
- export declare type SuccessResponse<T> = {
3
+ import type { GraphQLTypes, Lang, Thunder, UserRole } from "./zeus/index.js";
4
+ import { InfuraNetwork } from "./zeus/index.js";
5
+ import type { ErrorAccessDenied, ErrorLimit, ErrorNotFound, ErrorNotExist } from "./error.js";
6
+ export type SuccessResponse<T> = {
7
7
  __typename: "SuccessResponse";
8
8
  data: T;
9
9
  };
10
- export declare type DownloadProgress = DLProgress;
11
- export declare type PayInput = {
12
- type: PayInputType;
13
- token: string;
14
- firstName: string;
15
- lastName: string;
16
- street: string;
17
- postalCode: string;
18
- city: string;
19
- country: string;
20
- month: string;
21
- year: string;
22
- cvv: string;
23
- number: string;
24
- };
25
- export declare type MailLimits = {
26
- count?: bigint | undefined;
27
- fileCount?: bigint | undefined;
28
- fileSize?: bigint | undefined;
29
- hardCount?: bigint | undefined;
30
- hardFileCount?: bigint | undefined;
31
- hardFileSize?: bigint | undefined;
32
- perFileSize?: bigint | undefined;
33
- };
34
- export declare type Limits = {
35
- downloadBandwidth?: bigint | undefined;
36
- downloadCount?: bigint | undefined;
37
- hardFileCount?: bigint | undefined;
38
- hardFileSize?: bigint | undefined;
39
- perFileSize?: bigint | undefined;
40
- receivedMails: MailLimits;
41
- sentMails: MailLimits;
42
- uploadBandwidth?: bigint | undefined;
43
- uploadCount?: bigint | undefined;
44
- };
45
- export declare type GodUser = {
46
- id: string;
47
- firstname: string;
48
- lastname: string;
49
- email: string;
50
- phone: string;
51
- };
52
- export declare type GodFatherAndChildren = {
53
- godFather: GodUser | null;
54
- godChildren: GodUser[];
55
- };
56
- export declare type Plan = {
57
- codes: string[];
58
- kind: PlanKind;
59
- limits: Limits;
60
- };
61
- export declare type SubscriptionState = "active" | "canceled" | "paused" | "expired" | "future" | "in_trial" | "live" | "past_due";
62
- export declare type SubscriptionCollectionMethod = "automatic" | "manual";
63
- declare type InternalSubscription = {
64
- autorenew: boolean;
65
- activatedAt?: Date | null | undefined;
66
- currentPeriodEndsAt?: Date | null | undefined;
67
- currentPeriodStartedAt?: Date | null | undefined;
68
- canceledAt?: Date | null | undefined;
69
- createdAt?: Date | null | undefined;
70
- expiresAt?: Date | null | undefined;
71
- pausedAt?: Date | null | undefined;
72
- trialEndsAt?: Date | null | undefined;
73
- trialStartedAt?: Date | null | undefined;
74
- updatedAt?: Date | null | undefined;
75
- collectionMethod: string;
76
- state: string;
77
- plan?: string | null | undefined;
78
- planCode?: string | null | undefined;
79
- total?: number | null | undefined;
80
- };
81
- declare type RecurlyInvoiceStatus = "pending" | "paid" | "failed" | "past_due" | "open" | "closed" | "voided" | "processing";
82
- declare type InternalRecurlyInvoices = {
83
- pdf: string;
84
- date: Date;
85
- due: Date;
86
- status: string;
87
- total: number;
88
- name: string;
89
- currency: string;
90
- };
91
- export declare type Subscription = InternalSubscription & {
92
- collectionMethod: SubscriptionCollectionMethod;
93
- state: SubscriptionState;
94
- };
95
- export declare type RecurlyInvoices = InternalRecurlyInvoices & {
96
- status: RecurlyInvoiceStatus;
97
- };
98
- export declare type PaymentInfos = {
99
- hostedUrl: string;
100
- currentSubscription: Subscription;
101
- invoices: RecurlyInvoices[];
102
- };
103
- export declare type SendReport = {
10
+ export type DownloadProgress = DLProgress;
11
+ export type SendReport = {
104
12
  id: string;
105
13
  user: {
106
14
  id: string;
@@ -116,47 +24,11 @@ export declare type SendReport = {
116
24
  };
117
25
  customMessage?: string | undefined;
118
26
  };
119
- declare const plansCodes: readonly ["basic_month", "advanced_month", "pro_month", "basic_year", "advanced_year", "pro_year"];
120
- export declare type SecrecyPlansCodes = typeof plansCodes[number];
121
- export declare function isValidPlan(planCode: string): planCode is SecrecyPlansCodes;
122
- export declare type UserData<T extends Record<string, unknown> = Record<string, unknown>> = {
27
+ export type UserData<T extends Record<string, unknown> = Record<string, unknown>> = {
123
28
  isSuperuser: boolean;
124
29
  isSearchable: boolean;
125
30
  } & T;
126
- export declare type FolderSize = {
127
- size: bigint;
128
- sizeBefore: bigint;
129
- };
130
- export declare type AppDBConfigField = {
131
- name: string;
132
- type: "string" | "number" | "boolean" | "object";
133
- isArray?: boolean | undefined;
134
- isNullable?: boolean | undefined;
135
- isEditable?: boolean | undefined;
136
- isKey?: boolean | undefined;
137
- default?: unknown;
138
- };
139
- export declare type AppDBConfig = {
140
- fields: AppDBConfigField[];
141
- };
142
- export declare type FaqItem = {
143
- order: number;
144
- question: string;
145
- answer: string;
146
- };
147
- export declare type BlogItem = {
148
- id: string;
149
- blogId: string;
150
- order: number;
151
- author: string;
152
- body: string;
153
- date: Date;
154
- image: string;
155
- imageAlt: string;
156
- summary: string;
157
- title: string;
158
- };
159
- export declare type UserBase = {
31
+ export type UserBase = {
160
32
  email: string;
161
33
  phone: string;
162
34
  lastname: string;
@@ -167,28 +39,28 @@ export declare type UserBase = {
167
39
  lastLogin: Date;
168
40
  lang: Lang;
169
41
  };
170
- declare type WithPublicKey = {
42
+ type WithPublicKey = {
171
43
  withPublicKey?: boolean;
172
44
  };
173
- export declare type User<T extends WithPublicKey = WithPublicKey> = T extends {
45
+ export type User<T extends WithPublicKey = WithPublicKey> = T extends {
174
46
  withPublicKey: true;
175
47
  } ? UserBase & {
176
48
  publicKey: string;
177
49
  } : UserBase;
178
- declare type ClassGetUserParams = WithPublicKey & {
50
+ type ClassGetUserParams = WithPublicKey & {
179
51
  userId?: string;
180
52
  userEmail?: string;
181
53
  };
182
- declare type StaticGetUserParams = ClassGetUserParams & {
54
+ type StaticGetUserParams = ClassGetUserParams & {
183
55
  env: SecrecyEnv;
184
56
  };
185
- export declare type CloudLimits = {
57
+ export type CloudLimits = {
186
58
  count: bigint;
187
59
  maxCount?: bigint | undefined;
188
60
  size: bigint;
189
61
  maxSize?: bigint | undefined;
190
62
  };
191
- export declare type MailLimitsValues = {
63
+ export type MailLimitsValues = {
192
64
  count: bigint;
193
65
  maxCount?: bigint | undefined;
194
66
  fileSize: bigint;
@@ -196,7 +68,7 @@ export declare type MailLimitsValues = {
196
68
  fileCount: bigint;
197
69
  maxFileCount?: bigint | undefined;
198
70
  };
199
- export declare type QueryLimits = {
71
+ export type QueryLimits = {
200
72
  cloud: CloudLimits;
201
73
  mail: {
202
74
  sent: MailLimitsValues;
@@ -205,11 +77,10 @@ export declare type QueryLimits = {
205
77
  };
206
78
  export declare class BaseClient {
207
79
  static readonly getBaseUrl: (env?: SecrecyEnv, graphcdn?: boolean) => string;
208
- private static readonly _getBaseClient;
209
- protected client: ReturnType<typeof Thunder>;
80
+ static readonly getBaseClient: (env: SecrecyEnv, session?: string | null | undefined) => ReturnType<typeof Thunder>;
81
+ protected thunder: ReturnType<typeof Thunder>;
210
82
  sessionId: string;
211
83
  constructor(session: string, env: SecrecyEnv);
212
- sessions(): Promise<SuccessResponse<UserSession[]> | ErrorNotFound | null>;
213
84
  logout(sessionId?: string | null | undefined): Promise<void>;
214
85
  me<T extends WithPublicKey = WithPublicKey>(params?: T): Promise<SuccessResponse<User<T>> | ErrorNotFound | null>;
215
86
  static user<T extends StaticGetUserParams>(params: T, sessionId?: string | null | undefined): Promise<SuccessResponse<User<T>> | ErrorNotFound | null>;
@@ -219,41 +90,22 @@ export declare class BaseClient {
219
90
  lastname: string | null;
220
91
  lang: Lang | null;
221
92
  }): Promise<SuccessResponse<User> | ErrorNotFound | ErrorAccessDenied | null>;
222
- static plans(env: SecrecyEnv, sessionId?: string | null | undefined): Promise<SuccessResponse<Plan[]> | null>;
223
- pay(planCode: SecrecyPlansCodes, input: PayInput, autoRenew?: boolean | null | undefined): Promise<SuccessResponse<boolean> | ErrorAccessDenied | null>;
224
- cancelPayment(): Promise<SuccessResponse<boolean> | ErrorAccessDenied | null>;
225
- paymentInfos(): Promise<SuccessResponse<PaymentInfos> | ErrorAccessDenied | null>;
226
- limits(): Promise<SuccessResponse<QueryLimits> | ErrorAccessDenied | ErrorNotExist | ErrorLimit | ErrorNotFound | null>;
227
- godFatherAndChildren(): Promise<SuccessResponse<GodFatherAndChildren> | ErrorNotFound | null>;
228
- static updateAppDBConfig({ appCode, config, env, sessionId }: {
229
- appCode: string;
230
- config: AppDBConfig;
231
- env: SecrecyEnv;
232
- sessionId?: string | null | undefined;
233
- }): Promise<SuccessResponse<AppDBConfig> | ErrorAccessDenied | null>;
234
- static getAppDBConfig(appCode: string, env: SecrecyEnv, sessionId?: string | null | undefined): Promise<SuccessResponse<AppDBConfig> | ErrorAccessDenied | ErrorNotFound | ErrorNotExist | null>;
235
- static getFAQ({ lang, env, sessionId }: {
236
- lang?: Lang;
93
+ static isCryptoTransactionDone({ env, idOrHash, network }: {
237
94
  env: SecrecyEnv;
238
- sessionId?: string | null | undefined;
239
- }): Promise<SuccessResponse<FaqItem[]> | ErrorAccessDenied | null>;
240
- static getBlog({ env, lang, sessionId }: {
241
- env: SecrecyEnv;
242
- lang?: Lang | null | undefined;
243
- sessionId?: string | null | undefined;
244
- }): Promise<SuccessResponse<BlogItem[]> | ErrorLangNotExist | null>;
95
+ idOrHash: string;
96
+ network?: InfuraNetwork;
97
+ }): Promise<boolean>;
98
+ limits(): Promise<SuccessResponse<QueryLimits> | ErrorAccessDenied | ErrorNotExist | ErrorLimit | ErrorNotFound | null>;
245
99
  reportUser(reportedUserId: string, customMessage?: string): Promise<SuccessResponse<SendReport> | ErrorAccessDenied | ErrorNotFound | null>;
246
- static deleteUser({ sessionId, userId, env }: {
247
- sessionId: string;
248
- userId?: string;
249
- env: SecrecyEnv;
250
- }): Promise<SuccessResponse<boolean> | ErrorAccessDenied | null>;
251
100
  getSponsorshipLink({ backUrl }: {
252
101
  backUrl: string;
253
102
  }): Promise<string | null>;
254
- updateAutoDisconnectDelay({ id, delay }: {
255
- id: string;
256
- delay: number | null;
257
- }): Promise<SuccessResponse<boolean> | ErrorNotFound | ErrorAccessDenied | ErrorBasic | null>;
103
+ static getPaymentRequest: ({ env, paymentRequestId, secrecyIdSeller, secrecyId, appCode }: {
104
+ env: SecrecyEnv;
105
+ paymentRequestId: string;
106
+ secrecyIdSeller: string;
107
+ secrecyId?: string | undefined;
108
+ appCode?: string | undefined;
109
+ }) => Promise<SuccessResponse<GraphQLTypes["GetPaymentRequestToPay"]> | ErrorAccessDenied | ErrorNotFound>;
258
110
  }
259
111
  export {};