@secrecy/lib 1.7.0 → 1.8.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 (152) hide show
  1. package/LICENSE +1 -1
  2. package/dist/lib/base-client.js +91 -0
  3. package/dist/lib/cache.js +4 -0
  4. package/dist/lib/client/SecrecryCareClient.js +19 -0
  5. package/dist/lib/client/SecrecyAppClient.js +87 -0
  6. package/dist/lib/client/SecrecyCloudClient.js +475 -0
  7. package/dist/lib/client/SecrecyDbClient.js +10 -0
  8. package/dist/lib/client/SecrecyMailClient.js +283 -0
  9. package/dist/lib/client/SecrecyPayClient.js +34 -0
  10. package/dist/lib/client/SecrecyUserClient.js +27 -0
  11. package/dist/lib/client/SecrecyWalletClient.js +50 -0
  12. package/dist/lib/client/convert/file.js +29 -0
  13. package/dist/lib/client/convert/mail.js +42 -0
  14. package/dist/lib/client/convert/node.js +100 -0
  15. package/dist/lib/client/helpers.js +103 -0
  16. package/dist/lib/client/index.js +49 -0
  17. package/dist/lib/client/storage.js +7 -0
  18. package/dist/lib/client/types/app.js +1 -0
  19. package/dist/lib/client/types/file.js +1 -0
  20. package/dist/lib/client/types/index.js +15 -0
  21. package/dist/lib/client/types/mail.js +1 -0
  22. package/dist/lib/client/types/node.js +1 -0
  23. package/dist/lib/client/types/user.js +1 -0
  24. package/dist/lib/client.js +47 -0
  25. package/dist/lib/crypto/file.js +184 -0
  26. package/dist/lib/crypto/index.js +41 -0
  27. package/dist/lib/error/client.js +10 -0
  28. package/dist/lib/error/index.js +10 -0
  29. package/dist/lib/error/server.js +27 -0
  30. package/dist/lib/index.js +10 -0
  31. package/dist/lib/minify/index.js +23 -0
  32. package/dist/lib/minify/lz4.js +517 -0
  33. package/dist/lib/sodium.js +5 -0
  34. package/dist/lib/types.js +1 -0
  35. package/dist/lib/utils/array.js +25 -0
  36. package/dist/lib/utils/base64.js +2 -0
  37. package/dist/lib/utils/popup-tools.js +180 -0
  38. package/dist/lib/utils/promise.js +20 -0
  39. package/dist/lib/utils/store-buddy.js +60 -0
  40. package/dist/lib/utils/time.js +13 -0
  41. package/dist/lib/worker/md5.js +18 -0
  42. package/dist/lib/worker/sodium.js +95 -0
  43. package/dist/lib/worker/workerCodes.js +254 -0
  44. package/dist/types/base-client.d.ts +28 -0
  45. package/dist/types/cache.d.ts +11 -0
  46. package/dist/types/client/SecrecryCareClient.d.ts +9 -0
  47. package/dist/types/client/SecrecyAppClient.d.ts +20 -0
  48. package/dist/types/client/SecrecyCloudClient.d.ts +88 -0
  49. package/dist/types/client/SecrecyDbClient.d.ts +7 -0
  50. package/dist/types/client/SecrecyMailClient.d.ts +42 -0
  51. package/dist/types/client/SecrecyPayClient.d.ts +27 -0
  52. package/dist/types/client/SecrecyUserClient.d.ts +14 -0
  53. package/dist/{client → types/client}/SecrecyWalletClient.d.ts +9 -12
  54. package/dist/types/client/convert/file.d.ts +4 -0
  55. package/dist/types/client/convert/mail.d.ts +8 -0
  56. package/dist/types/client/convert/node.d.ts +7 -0
  57. package/dist/types/client/helpers.d.ts +26 -0
  58. package/dist/types/client/index.d.ts +29 -0
  59. package/dist/{client → types/client}/storage.d.ts +2 -2
  60. package/dist/types/client/types/app.d.ts +2 -0
  61. package/dist/types/client/types/file.d.ts +6 -0
  62. package/dist/types/client/types/index.d.ts +46 -0
  63. package/dist/types/client/types/mail.d.ts +87 -0
  64. package/dist/{client/types/Node.d.ts → types/client/types/node.d.ts} +20 -25
  65. package/dist/types/client/types/user.d.ts +3 -0
  66. package/dist/types/client.d.ts +12138 -0
  67. package/dist/{crypto → types/crypto}/file.d.ts +4 -4
  68. package/dist/{crypto → types/crypto}/index.d.ts +1 -4
  69. package/dist/types/error/client.d.ts +22 -0
  70. package/dist/types/error/index.d.ts +40 -0
  71. package/dist/types/error/server.d.ts +26 -0
  72. package/dist/types/index.d.ts +13 -0
  73. package/dist/{minify → types/minify}/index.d.ts +1 -1
  74. package/dist/types/minify/lz4.d.ts +35 -0
  75. package/dist/{sodium.d.ts → types/sodium.d.ts} +1 -1
  76. package/dist/types/types.d.ts +10 -0
  77. package/dist/{utils/utils.d.ts → types/utils/array.d.ts} +0 -1
  78. package/dist/types/utils/base64.d.ts +1 -0
  79. package/dist/types/utils/popup-tools.d.ts +52 -0
  80. package/dist/types/utils/promise.d.ts +1 -0
  81. package/dist/types/utils/store-buddy.d.ts +130 -0
  82. package/dist/{worker → types/worker}/sodium.d.ts +1 -1
  83. package/package.json +48 -73
  84. package/dist/BaseClient.d.ts +0 -111
  85. package/dist/BaseClient.js +0 -506
  86. package/dist/PopupTools.d.ts +0 -17
  87. package/dist/PopupTools.js +0 -195
  88. package/dist/ZeusThunder.d.ts +0 -2
  89. package/dist/ZeusThunder.js +0 -65
  90. package/dist/cache.d.ts +0 -6
  91. package/dist/cache.js +0 -4
  92. package/dist/client/SecrecyAppClient.d.ts +0 -17
  93. package/dist/client/SecrecyAppClient.js +0 -226
  94. package/dist/client/SecrecyCloudClient.d.ts +0 -89
  95. package/dist/client/SecrecyCloudClient.js +0 -1405
  96. package/dist/client/SecrecyDbClient.d.ts +0 -48
  97. package/dist/client/SecrecyDbClient.js +0 -419
  98. package/dist/client/SecrecyMailClient.d.ts +0 -42
  99. package/dist/client/SecrecyMailClient.js +0 -1022
  100. package/dist/client/SecrecyPayClient.d.ts +0 -28
  101. package/dist/client/SecrecyPayClient.js +0 -68
  102. package/dist/client/SecrecyWalletClient.js +0 -73
  103. package/dist/client/convert/file.d.ts +0 -5
  104. package/dist/client/convert/file.js +0 -33
  105. package/dist/client/convert/mail.d.ts +0 -3
  106. package/dist/client/convert/mail.js +0 -42
  107. package/dist/client/convert/node.d.ts +0 -9
  108. package/dist/client/convert/node.js +0 -87
  109. package/dist/client/helpers.d.ts +0 -28
  110. package/dist/client/helpers.js +0 -119
  111. package/dist/client/index.d.ts +0 -34
  112. package/dist/client/index.js +0 -46
  113. package/dist/client/storage.js +0 -12
  114. package/dist/client/types/File.d.ts +0 -14
  115. package/dist/client/types/File.js +0 -3
  116. package/dist/client/types/Inputs.d.ts +0 -16
  117. package/dist/client/types/Inputs.js +0 -3
  118. package/dist/client/types/Node.js +0 -3
  119. package/dist/client/types/UserAppNotifications.d.ts +0 -6
  120. package/dist/client/types/UserAppNotifications.js +0 -3
  121. package/dist/client/types/UserAppSettings.d.ts +0 -5
  122. package/dist/client/types/UserAppSettings.js +0 -3
  123. package/dist/client/types/index.d.ts +0 -120
  124. package/dist/client/types/index.js +0 -8
  125. package/dist/client/types/selectors.d.ts +0 -400
  126. package/dist/client/types/selectors.js +0 -135
  127. package/dist/crypto/file.js +0 -195
  128. package/dist/crypto/index.js +0 -45
  129. package/dist/error.d.ts +0 -33
  130. package/dist/error.js +0 -3
  131. package/dist/index.d.ts +0 -14
  132. package/dist/index.js +0 -10
  133. package/dist/minify/index.js +0 -23
  134. package/dist/minify/lz4.d.ts +0 -5
  135. package/dist/minify/lz4.js +0 -539
  136. package/dist/sodium.js +0 -6
  137. package/dist/utils/encoders.d.ts +0 -26
  138. package/dist/utils/encoders.js +0 -18
  139. package/dist/utils/store-buddy.d.ts +0 -14
  140. package/dist/utils/store-buddy.js +0 -58
  141. package/dist/utils/time.js +0 -12
  142. package/dist/utils/utils.js +0 -47
  143. package/dist/worker/md5.js +0 -24
  144. package/dist/worker/sodium.js +0 -118
  145. package/dist/worker/workerCodes.js +0 -255
  146. package/dist/zeus/const.d.ts +0 -7
  147. package/dist/zeus/const.js +0 -1846
  148. package/dist/zeus/index.d.ts +0 -8721
  149. package/dist/zeus/index.js +0 -642
  150. /package/dist/{utils → types/utils}/time.d.ts +0 -0
  151. /package/dist/{worker → types/worker}/md5.d.ts +0 -0
  152. /package/dist/{worker → types/worker}/workerCodes.d.ts +0 -0
@@ -1,14 +1,14 @@
1
- export type EncryptedFile = {
1
+ export interface EncryptedFile {
2
2
  data: Uint8Array;
3
3
  md5: string;
4
4
  md5Encrypted: string;
5
- };
5
+ }
6
6
  export declare function secretstreamKeygen(): Uint8Array;
7
7
  export declare const CHUNK_SIZE = 8192;
8
- export type Progress = {
8
+ export interface Progress {
9
9
  percent: number;
10
10
  total: number;
11
11
  current: number;
12
- };
12
+ }
13
13
  export declare function encryptSecretstream(key: Uint8Array, data: Uint8Array, progress?: (progress: Progress) => Promise<void>, abort?: AbortController): Promise<EncryptedFile>;
14
14
  export declare function decryptSecretstream(key: Uint8Array, data: Uint8Array, progress?: (progress: Progress) => Promise<void>, abort?: AbortController): Promise<Uint8Array>;
@@ -1,7 +1,4 @@
1
- export interface KeyPair {
2
- publicKey: string;
3
- privateKey: string;
4
- }
1
+ import { type KeyPair } from '../client/types/index.js';
5
2
  export declare function encryptCryptoBox(data: Uint8Array, publicKeyBob: string, privateKeyAlice: string): Uint8Array;
6
3
  export declare function generateCryptoBoxKeyPair(): KeyPair;
7
4
  export declare function decryptCryptoBox(data: Uint8Array, publicKeyAlice: string, privateKeyBob: string): Uint8Array;
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ export declare const clientErrorCodeKey: z.ZodEnum<["NOT_FOUND"]>;
3
+ export type CLIENT_ERROR_CODE_KEY = z.infer<typeof clientErrorCodeKey>;
4
+ export declare const clientError: z.ZodObject<{
5
+ name: z.ZodLiteral<"ClientError">;
6
+ code: z.ZodEnum<["NOT_FOUND"]>;
7
+ message: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ name: "ClientError";
10
+ message: string;
11
+ code: "NOT_FOUND";
12
+ }, {
13
+ name: "ClientError";
14
+ message: string;
15
+ code: "NOT_FOUND";
16
+ }>;
17
+ export type ClientError = z.infer<typeof clientError>;
18
+ export declare const isClientError: (input: unknown) => input is {
19
+ name: "ClientError";
20
+ message: string;
21
+ code: "NOT_FOUND";
22
+ };
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ export declare const secrecyError: z.ZodDiscriminatedUnion<"name", [z.ZodObject<{
3
+ name: z.ZodLiteral<"TRPCError">;
4
+ code: z.ZodEnum<["PARSE_ERROR", "BAD_REQUEST", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "UNAUTHORIZED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_SUPPORTED", "TIMEOUT", "CONFLICT", "PRECONDITION_FAILED", "PAYLOAD_TOO_LARGE", "UNPROCESSABLE_CONTENT", "TOO_MANY_REQUESTS", "CLIENT_CLOSED_REQUEST"]>;
5
+ message: z.ZodString;
6
+ data: z.ZodOptional<z.ZodUnknown>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ name: "TRPCError";
9
+ message: string;
10
+ code: "UNAUTHORIZED" | "NOT_FOUND" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "FORBIDDEN" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
11
+ data?: unknown;
12
+ }, {
13
+ name: "TRPCError";
14
+ message: string;
15
+ code: "UNAUTHORIZED" | "NOT_FOUND" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "FORBIDDEN" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
16
+ data?: unknown;
17
+ }>, z.ZodObject<{
18
+ name: z.ZodLiteral<"ClientError">;
19
+ code: z.ZodEnum<["NOT_FOUND"]>;
20
+ message: z.ZodString;
21
+ }, "strip", z.ZodTypeAny, {
22
+ name: "ClientError";
23
+ message: string;
24
+ code: "NOT_FOUND";
25
+ }, {
26
+ name: "ClientError";
27
+ message: string;
28
+ code: "NOT_FOUND";
29
+ }>]>;
30
+ export type SecrecyError = z.infer<typeof secrecyError>;
31
+ export declare const isSecrecyError: (input: unknown) => input is {
32
+ name: "ClientError";
33
+ message: string;
34
+ code: "NOT_FOUND";
35
+ } | {
36
+ name: "TRPCError";
37
+ message: string;
38
+ code: "UNAUTHORIZED" | "NOT_FOUND" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "FORBIDDEN" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
39
+ data?: unknown;
40
+ };
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ export declare const trpcErrorCodeKey: z.ZodEnum<["PARSE_ERROR", "BAD_REQUEST", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "UNAUTHORIZED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_SUPPORTED", "TIMEOUT", "CONFLICT", "PRECONDITION_FAILED", "PAYLOAD_TOO_LARGE", "UNPROCESSABLE_CONTENT", "TOO_MANY_REQUESTS", "CLIENT_CLOSED_REQUEST"]>;
3
+ export type TRPC_ERROR_CODE_KEY = z.infer<typeof trpcErrorCodeKey>;
4
+ export declare const serverError: z.ZodObject<{
5
+ name: z.ZodLiteral<"TRPCError">;
6
+ code: z.ZodEnum<["PARSE_ERROR", "BAD_REQUEST", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "UNAUTHORIZED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_SUPPORTED", "TIMEOUT", "CONFLICT", "PRECONDITION_FAILED", "PAYLOAD_TOO_LARGE", "UNPROCESSABLE_CONTENT", "TOO_MANY_REQUESTS", "CLIENT_CLOSED_REQUEST"]>;
7
+ message: z.ZodString;
8
+ data: z.ZodOptional<z.ZodUnknown>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ name: "TRPCError";
11
+ message: string;
12
+ code: "UNAUTHORIZED" | "NOT_FOUND" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "FORBIDDEN" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
13
+ data?: unknown;
14
+ }, {
15
+ name: "TRPCError";
16
+ message: string;
17
+ code: "UNAUTHORIZED" | "NOT_FOUND" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "FORBIDDEN" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
18
+ data?: unknown;
19
+ }>;
20
+ export type ServerError = z.infer<typeof serverError>;
21
+ export declare const isServerError: (input: unknown) => input is {
22
+ name: "TRPCError";
23
+ message: string;
24
+ code: "UNAUTHORIZED" | "NOT_FOUND" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "FORBIDDEN" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
25
+ data?: unknown;
26
+ };
@@ -0,0 +1,13 @@
1
+ /// <reference lib="dom" />
2
+ /// <reference lib="dom.iterable" />
3
+ export * from './client/index.js';
4
+ export * from './crypto/index.js';
5
+ export type { Progress } from './crypto/file.js';
6
+ export { BaseClient } from './base-client.js';
7
+ export type { Node, NodeFull, FileMetadata, SecrecyUserApp, BaseMail, ReceivedMail, SentMail, PublicUser, SelfUser, NodeSize, MailFile, MailIntegrity, DraftMail, Mail, WaitingReceivedMail, KeyPair, } from './client/types/index.js';
8
+ export * from './client/helpers.js';
9
+ export * from './sodium.js';
10
+ export * from './utils/store-buddy.js';
11
+ export type { UserAppNotifications, UserAppSettings, InfuraNetwork, UserData, DownloadProgress, } from './types.js';
12
+ export * from './error/index.js';
13
+ export type { Rights } from './client/types/node.js';
@@ -1,2 +1,2 @@
1
1
  export declare function compress(data: Uint8Array): Uint8Array;
2
- export declare function uncompress(data: Uint8Array): Uint8Array;
2
+ export declare function decompress(data: Uint8Array): Uint8Array;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) 2015, Pierre Curto
3
+ * Copyright (c) 2016, oov
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * * Redistributions of source code must retain the above copyright notice, this
10
+ * list of conditions and the following disclaimer.
11
+ *
12
+ * * Redistributions in binary form must reproduce the above copyright notice,
13
+ * this list of conditions and the following disclaimer in the documentation
14
+ * and/or other materials provided with the distribution.
15
+ *
16
+ * * Neither the name of xxHash nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+ export declare function calcUncompressedLen(src: Uint8Array): number;
32
+ export declare function uncompressBlock(src: Uint8Array, dest: Uint8Array): number;
33
+ export declare function compressBlockBound(n: number): number;
34
+ export declare function compressBlock(src: Uint8Array, dest: Uint8Array, soffset: number): number;
35
+ export declare function compressBlockHC(src: Uint8Array, dest: Uint8Array, soffset: number): number;
@@ -1,3 +1,3 @@
1
- import sodium from "libsodium-wrappers";
1
+ import sodium from 'libsodium-wrappers-sumo';
2
2
  export declare function setup(): Promise<void>;
3
3
  export { sodium };
@@ -0,0 +1,10 @@
1
+ import type { DownloadProgress as DLProgress } from 'ky';
2
+ import { type RouterOutputs, type RouterInputs } from './client.js';
3
+ export type InfuraNetwork = NonNullable<RouterInputs['crypto']['isTransactionDone']['network']>;
4
+ export type UserAppNotifications = RouterOutputs['application']['notification'];
5
+ export type UserAppSettings = RouterOutputs['application']['settings'];
6
+ export type DownloadProgress = DLProgress;
7
+ export type UserData<T extends Record<string, unknown> = Record<string, unknown>> = {
8
+ isSuperuser: boolean;
9
+ isSearchable: boolean;
10
+ } & T;
@@ -1,4 +1,3 @@
1
1
  export declare function concatenate(...arrays: Uint8Array[]): Uint8Array;
2
2
  export declare function enumerate<T>(iterable: Iterable<T>): IterableIterator<[number, T]>;
3
3
  export declare function chunks(arr: Uint8Array, n: number): Generator<Uint8Array, void, unknown>;
4
- export declare const promiseAllLimit: <T>(n: number, list: (() => Promise<T>)[]) => Promise<T[]>;
@@ -0,0 +1 @@
1
+ export declare const bufferToBase64: (u8: Uint8Array) => string;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * TS Rewrite of https://github.com/enhancv/popup-tools
3
+ */
4
+ type YesNo = 'yes' | 'no';
5
+ interface Options {
6
+ width?: number;
7
+ height?: number;
8
+ menubar: YesNo;
9
+ resizable: YesNo;
10
+ location: YesNo;
11
+ scrollbars: YesNo;
12
+ centered?: boolean;
13
+ left?: number;
14
+ top?: number;
15
+ }
16
+ type Callback = (err?: Error, data?: unknown) => void;
17
+ /**
18
+ * Open a popup using the first argument.
19
+ * Wait for it to close and call the callback.
20
+ * Set the options string using the options object
21
+ * Returns the window object
22
+ *
23
+ * @param {String} url
24
+ * @param {String} name
25
+ * @param {Object} options
26
+ * @param {Function} callback
27
+ * @return {Object}
28
+ */
29
+ export declare function popup(url: string, name: string, options: Partial<Options>, callback: Callback): Window | null;
30
+ /**
31
+ * Open a popup using the first argument.
32
+ * Post the data into the open popup.
33
+ * Wait for it to close and call the callback.
34
+ * Set the options string using the options object
35
+ * Returns the window object
36
+ *
37
+ * @param {String} url
38
+ * @param {Object} postData
39
+ * @param {String} name
40
+ * @param {Object} options
41
+ * @param {Function} callback
42
+ * @return {Object}
43
+ */
44
+ export declare function popupWithPost(url: string, postData: Record<string, string>, name: string, options: Partial<Options>, callback: Callback): Window | null;
45
+ /**
46
+ * Return html that when executed, will trigger the popup to callback with a response
47
+ *
48
+ * @param {Object}
49
+ * @return {String}
50
+ */
51
+ export declare function popupResponse<T>(id: string, data: T): string;
52
+ export {};
@@ -0,0 +1 @@
1
+ export declare const promiseAllLimit: <T>(n: number, list: (() => Promise<T>)[]) => Promise<T[]>;
@@ -0,0 +1,130 @@
1
+ type IsEmptyObject<O> = O extends Record<string, never> ? Record<string, unknown> : O;
2
+ interface StoreBuddyInit<T> {
3
+ /**
4
+ * Initialise the storeBuddy instance with 'default' (first-load) data. This
5
+ * behaves in the same way as the `save` method in the main `StoreBuddy`
6
+ * interface but doesn't save any data if the storage entry already exists
7
+ * (to prevent new data being overwritten by its older, default form).
8
+ * @param data The data to save to localStorage or sessionStorage.
9
+ * @returns The main `StoreBuddy` interface with methods like `load`, etc.
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import storeBuddy from "store-buddy";
14
+ *
15
+ * // The "foo" entry is initialised with the default data "bar"
16
+ * const storage1 = storeBuddy("foo").init("bar");
17
+ *
18
+ * // The "hello" entry is initialised with a default object literal
19
+ * const storage2 = storeBuddy("hello").init({ prop1: "world", prop2: false });
20
+ * ```
21
+ */
22
+ init: (data: IsEmptyObject<T>) => StoreBuddy<T>;
23
+ }
24
+ export interface StoreBuddy<T> {
25
+ /**
26
+ * Retrieve the current data set using this instance.
27
+ * @returns The data from localStorage or sessionStorage, throwing an error
28
+ * if no data is found.
29
+ * @example
30
+ *
31
+ * ```ts
32
+ * import storeBuddy from "store-buddy";
33
+ *
34
+ * const storage1 = storeBuddy("foo").init("bar");
35
+ * storage1.load(); // returns "bar"
36
+ * ```
37
+ */
38
+ load: () => IsEmptyObject<T>;
39
+ /**
40
+ * Set new data or overwrite old data in localStorage or sessionStorage. For
41
+ * TS developers, saving data of a _different_ type to the one specified in
42
+ * the type parameter is prevented.
43
+ * @param data The data to save to localStorage or sessionStorage.
44
+ * @example
45
+ *
46
+ * ```ts
47
+ * import storeBuddy from "store-buddy";
48
+ *
49
+ * // Saves the string "bar" to the localStorage entry with the key "foo"
50
+ * const storage1 = storeBuddy("foo").init("bar");
51
+ *
52
+ * // Overwrites that same string with different data. Note that, without
53
+ * // specifying a specific type when initialising, there is no type safety
54
+ * // provided for TypeScript developers
55
+ * storage1.save("baz");
56
+ * storage1.save(123);
57
+ *
58
+ * // This is type-safe...
59
+ * const storage2 = storeBuddy<number>("foo").init(123);
60
+ *
61
+ * // ...so this works...
62
+ * storage2.save(456);
63
+ *
64
+ * // ...and this does not work :)
65
+ * storage2.save("I am not a number");
66
+ * ```
67
+ */
68
+ save: (data: IsEmptyObject<T>) => void;
69
+ /**
70
+ * Reset the data back to its original value set with the `init` method.
71
+ * @example
72
+ *
73
+ * ```ts
74
+ * import storeBuddy from "store-buddy";
75
+ *
76
+ * const storage = storeBuddy("foo").init("bar");
77
+ * storage.save("hello");
78
+ * storage.reset();
79
+ * storage.load(); // returns "bar"
80
+ * ```
81
+ */
82
+ reset: () => void;
83
+ /**
84
+ * Remove all data set using this instance.
85
+ * @example
86
+ *
87
+ * ```ts
88
+ * import storeBuddy from "store-buddy";
89
+ *
90
+ * const storage = storeBuddy("foo").init("bar");
91
+ * storage.load(); // returns "bar"
92
+ * storage.clear();
93
+ * storage.load(); // throws an error (no data exists)
94
+ * ```
95
+ */
96
+ clear: () => void;
97
+ }
98
+ /**
99
+ * Create persistent or temporary client-side storage with a portable,
100
+ * type-safe wrapper around the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API).
101
+ * @param key The key used to access the stored value.
102
+ * @param [session] Save data in sessionStorage (`true`) or in localStorage
103
+ * (`false`). Default is `false`.
104
+ * @example
105
+ *
106
+ * ```ts
107
+ * import storeBuddy from "store-buddy";
108
+ *
109
+ * // "foo" is the key used to access the stored value, which is created in the
110
+ * // method `init`
111
+ * const storage1 = storeBuddy("foo").init("bar");
112
+ *
113
+ * // Using sessionStorage instead of localStorage is possible by specifying
114
+ * // `true` in the `session` parameter
115
+ * const storage2 = storeBuddy("foo", true).init("bar");
116
+ *
117
+ * // Type safety can be enabled by providing an argument to the type parameter
118
+ * type Data = {
119
+ * hello: string;
120
+ * world: number;
121
+ * }
122
+ *
123
+ * const storage3 = storeBuddy<Data>("foo").init({
124
+ * hello: "foo",
125
+ * world: 123
126
+ * })
127
+ * ```
128
+ */
129
+ export declare function storeBuddy<T>(key: string, session?: boolean): StoreBuddyInit<T>;
130
+ export {};
@@ -1,3 +1,3 @@
1
- import type { EncryptedFile, Progress } from "../crypto/file.js";
1
+ import type { EncryptedFile, Progress } from '../crypto/file.js';
2
2
  export declare function encrypt(key: Uint8Array, dataToEncrypt: Uint8Array, progress?: (progress: Progress) => Promise<void>, signal?: AbortSignal): Promise<EncryptedFile>;
3
3
  export declare function decrypt(key: Uint8Array, dataToDecrypt: Uint8Array, progress?: (progress: Progress) => Promise<void>, signal?: AbortSignal): Promise<Uint8Array>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@secrecy/lib",
3
3
  "author": "Anonymize <anonymize@gmail.com>",
4
4
  "description": "Anonymize Secrecy Library",
5
- "version": "1.7.0",
5
+ "version": "1.8.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"
@@ -22,95 +22,70 @@
22
22
  "type": "module",
23
23
  "exports": {
24
24
  ".": {
25
- "types": "./dist/index.d.ts",
26
- "import": "./dist/index.js",
27
- "require": "./dist/index.cjs"
25
+ "types": "./dist/types/index.d.ts",
26
+ "import": "./dist/lib/index.js"
28
27
  },
29
- "./dist/*": {
30
- "types": "./dist/*.d.ts",
31
- "import": "./dist/*.js",
32
- "require": "./dist/*.cjs"
28
+ "./*": {
29
+ "types": "./dist/types/*.d.ts",
30
+ "import": "./dist/lib/*.js"
33
31
  }
34
32
  },
35
- "main": "./dist/index.cjs",
36
- "module": "./dist/index.js",
37
- "types": "./dist/index.d.ts",
33
+ "module": "./dist/lib/index.js",
34
+ "types": "./dist/types/index.d.ts",
38
35
  "files": [
39
36
  "dist"
40
37
  ],
41
- "engines": {
42
- "node": ">=16.13.0"
43
- },
44
38
  "scripts": {
45
39
  "clean": "rimraf dist",
46
- "test": "cross-env NEXT_PUBLIC_SECRECY_API_URL=http://localhost:4000/graphql NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --forceExit",
47
- "lint": "eslint \"./**/*.{ts,tsx}\"",
48
- "format": "prettier --cache --write \"./**/*.{ts,tsx}\"",
40
+ "lint": "eslint . --cache --cache-location 'node_modules/.cache/.eslintcache'",
41
+ "lint:fix": "eslint . --fix --cache --cache-location 'node_modules/.cache/.eslintcache'",
42
+ "format": "prettier \"**/*.{ts,tsx,md,mdx,json}\" --check --cache --cache-location='node_modules/.cache/.prettiercache'",
43
+ "format:fix": "prettier \"**/*.{ts,tsx,md,mdx,json}\" --check --write --cache --cache-location='node_modules/.cache/.prettiercache'",
49
44
  "doc": "typedoc --out docs src",
50
- "prepublish": "pnpm build",
51
- "type-check": "tsc --noEmit",
52
- "type-check:watch": "pnpm type-check --watch",
53
- "build:types": "tsc --emitDeclarationOnly",
54
- "build": "run-p -l clean build:types babel",
55
- "babel": "babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline",
56
- "watch": "pnpm build --watch",
57
- "zeus": "zeus http://localhost:4000/graphql ./src --ts --es",
45
+ "prepublish": "bun run build",
46
+ "typecheck": "tsc --noEmit",
47
+ "build": "tsc -p tsconfig.build.json",
58
48
  "prepare": "husky install",
59
49
  "semantic-release": "semantic-release"
60
50
  },
61
51
  "devDependencies": {
62
- "@babel/cli": "^7.20.7",
63
- "@babel/core": "^7.20.12",
64
- "@babel/plugin-proposal-class-properties": "^7.18.6",
65
- "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
66
- "@babel/plugin-proposal-private-methods": "^7.18.6",
67
- "@babel/plugin-syntax-import-meta": "^7.10.4",
68
- "@babel/plugin-transform-runtime": "^7.19.1",
69
- "@babel/plugin-transform-typescript": "^7.20.7",
70
- "@babel/preset-env": "^7.20.2",
71
- "@babel/preset-typescript": "^7.18.6",
72
- "@commitlint/cli": "^17.4.0",
73
- "@commitlint/config-conventional": "^17.4.0",
74
- "@types/jest": "^29.2.5",
75
- "@types/jsonwebtoken": "^9.0.0",
76
- "@types/node": "^18.11.18",
77
- "@types/shortid": "^0.0.29",
52
+ "@commitlint/cli": "^18.4.3",
53
+ "@commitlint/config-conventional": "^18.4.3",
54
+ "@prisma/client": "5.7.1",
55
+ "@types/bun": "^1.0.0",
56
+ "@types/jsonwebtoken": "^9.0.2",
78
57
  "@types/spark-md5": "^3.0.2",
79
- "@typescript-eslint/eslint-plugin": "^5.47.1",
80
- "@typescript-eslint/parser": "^5.47.1",
81
- "babel-loader": "^9.1.2",
82
- "babel-plugin-const-enum": "^1.2.0",
83
- "cross-env": "^7.0.3",
84
- "eslint": "^8.31.0",
85
- "eslint-config-prettier": "^8.5.0",
86
- "eslint-plugin-prettier": "^4.2.1",
87
- "graphql-zeus": "^5.2.3",
58
+ "@typescript-eslint/eslint-plugin": "^6.6.0",
59
+ "@typescript-eslint/parser": "^6.6.0",
60
+ "eslint": "^8.56.0",
61
+ "eslint-config-prettier": "^9.1.0",
62
+ "eslint-config-standard-with-typescript": "^43.0.0",
63
+ "eslint-plugin-import": "^2.28.1",
64
+ "eslint-plugin-n": "^16.0.2",
65
+ "eslint-plugin-promise": "^6.1.1",
88
66
  "husky": "^8.0.3",
89
- "jest": "^29.3.1",
90
- "jest-environment-jsdom": "^29.3.1",
91
- "jest-fetch-mock": "^3.0.3",
92
67
  "npm-run-all": "^4.1.5",
93
- "prettier": "^2.8.1",
94
- "rimraf": "^3.0.2",
95
- "semantic-release": "^19.0.5",
96
- "ts-jest": "^29.0.3",
97
- "ts-node": "^10.9.1",
98
- "tsup": "^6.5.0",
99
- "typedoc": "^0.23.23",
100
- "typedoc-plugin-missing-exports": "^1.0.0",
101
- "typescript": "^4.9.4"
68
+ "prettier": "^3.1.1",
69
+ "rimraf": "^5.0.5",
70
+ "semantic-release": "^22.0.12",
71
+ "typedoc": "^0.25.1",
72
+ "typedoc-plugin-missing-exports": "^2.1.0",
73
+ "typescript": "^5.3.3"
102
74
  },
103
75
  "dependencies": {
104
76
  "@secrecy/lib-utils": "^1.0.18",
105
- "@types/libsodium-wrappers": "^0.7.10",
106
- "axios": "^1.2.2",
107
- "bson": "^4.7.0",
108
- "ethers": "^5.7.2",
109
- "jsonwebtoken": "^9.0.0",
110
- "ky": "^0.33.1",
111
- "libsodium-wrappers": "^0.7.10",
112
- "shortid": "^2.2.16",
113
- "spark-md5": "^3.0.2"
114
- },
115
- "packageManager": "pnpm@7.22.0"
77
+ "@secrecy/trpc-api-types": "1.15.0-dev.1",
78
+ "@trpc/client": "10.45.0",
79
+ "@trpc/server": "10.45.0",
80
+ "@types/libsodium-wrappers-sumo": "^0.7.6",
81
+ "axios": "^1.6.2",
82
+ "bson": "^6.2.0",
83
+ "ethers": "^6.9.1",
84
+ "jsonwebtoken": "^9.0.2",
85
+ "ky": "^1.1.3",
86
+ "libsodium-wrappers-sumo": "^0.7.13",
87
+ "spark-md5": "^3.0.2",
88
+ "superjson": "2.2.1",
89
+ "zod": "3.22.4"
90
+ }
116
91
  }