sealnet 3.0.0 → 3.1.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.
package/dist/index.d.cts CHANGED
@@ -17,36 +17,99 @@ interface OpenedStream {
17
17
  declare const TTL_OPTIONS: readonly string[];
18
18
  /** A seal's lifetime, one of the contract's `ttl_options`. */
19
19
  type TTL = (typeof TTL_OPTIONS)[number];
20
+ /**
21
+ * A file's bytes: a `File` or `Blob` (in Node, `fs.openAsBlob(path)` reads one from disk as it goes up), an
22
+ * `ArrayBuffer` or a `Uint8Array`.
23
+ */
24
+ type SealSource = File | Blob | ArrayBuffer | Uint8Array;
25
+ /** One file of a seal, as the recipient sees it. */
26
+ interface SealFile {
27
+ readonly file: SealSource;
28
+ /** The name the recipient sees: a `File`'s own when omitted; bytes need one. */
29
+ readonly filename?: string;
30
+ /** The type the recipient sees: a `File`'s own when omitted, else `application/octet-stream`. */
31
+ readonly mimeType?: string;
32
+ /** A secret — a key, a password: the recipient's page shows it hidden, a receiving agent saves it and never prints it. */
33
+ readonly secret?: boolean;
34
+ }
35
+ /** One file of a folder: its path in the folder, `/` between folders, is its name in the seal (`docs/q3/report.pdf`). */
36
+ interface SealFolderFile {
37
+ readonly path: string;
38
+ readonly file: SealSource;
39
+ readonly mimeType?: string;
40
+ }
41
+ /** Where a send stands: the whole seal's `percent` (0–100, never back), and the phase and name of the file moving now. */
42
+ interface SendProgress {
43
+ readonly phase: string;
44
+ readonly percent: number;
45
+ readonly fileIndex: number;
46
+ readonly totalFiles: number;
47
+ readonly fileName: string;
48
+ }
20
49
  interface CreateAnonymousSealOptions {
21
- /** File data (File, ArrayBuffer, Uint8Array, or Blob) */
22
- file: File | ArrayBuffer | Uint8Array | Blob;
23
- /** Original filename */
24
- filename: string;
25
- /** MIME type (optional, defaults to application/octet-stream) */
50
+ /** One file (File, ArrayBuffer, Uint8Array, or Blob); `files`, `folder` and `secret` add to the same seal */
51
+ file?: SealSource;
52
+ /** The name the recipient sees for `file`: a `File`'s own when omitted; bytes need one */
53
+ filename?: string;
54
+ /** MIME type of `file` (optional: a `File`'s own, else application/octet-stream) */
26
55
  mimeType?: string;
27
- /** Time to live: one of the lifetimes seal.net offers */
28
- ttl: TTL;
29
- /** Optional password (OTP) for download protection */
30
- otp?: string;
56
+ /** More files, after `file`, in this order */
57
+ files?: ReadonlyArray<SealFile>;
58
+ /**
59
+ * A folder, file by file under its paths, no ZIP: a `File` of a folder picker (`<input webkitdirectory>`) carries
60
+ * its path, any other file says it (`{ path, file }`).
61
+ */
62
+ folder?: ReadonlyArray<File | SealFolderFile>;
63
+ /**
64
+ * A password, a key or a text, sealed first as `Secret`: the recipient's page shows it hidden. Read it from the
65
+ * environment or a file, never write it into code. An empty one is refused, and so is one given unset
66
+ * (`secret: process.env.KEY` with no `KEY`).
67
+ */
68
+ secret?: string | Uint8Array | undefined;
69
+ /**
70
+ * Time to live: one of the lifetimes seal.net offers. Omitted, as on seal.net: a secret alone in the seal lives an
71
+ * hour, anything else the longest lifetime.
72
+ */
73
+ ttl?: TTL;
74
+ /**
75
+ * Optional password (OTP) for download protection. Read it from the environment, never write it into code; an empty
76
+ * one, or one given unset (`otp: process.env.PASSWORD` with no `PASSWORD`), is refused.
77
+ */
78
+ otp?: string | undefined;
31
79
  /** Require NDA signature before download */
32
80
  nda?: boolean;
33
- /** Owner email (required if nda=true) */
81
+ /** Your email: a letter each time the seal is opened, with when and from which country. Required with `nda`: the signed agreement comes here too. */
34
82
  ownerEmail?: string;
35
- /** Optional message to display to recipient */
83
+ /**
84
+ * The document the recipient signs for (with `nda`, instead of `message`): sent last, marked as the NDA's. The
85
+ * agreement then reads "NDA document attached: <name> (<size>)", as on seal.net.
86
+ */
87
+ ndaFile?: SealFile;
88
+ /**
89
+ * A note to the recipient (up to 5000 characters), encrypted inside the seal. With `nda` it is the agreement's
90
+ * text; an NDA with neither it nor `ndaFile` reads "Confidentiality Agreement".
91
+ */
36
92
  message?: string;
37
- /** Delete after first download */
93
+ /**
94
+ * One open. Omitted, as on seal.net: a secret alone in the seal opens once unless `maxOpens` is given.
95
+ */
38
96
  singleUse?: boolean;
39
- /** Maximum number of downloads allowed */
97
+ /** The most opens, 1 to 10; with `singleUse` the seal opens once and this is not sent */
40
98
  maxOpens?: number;
41
- /** Restrict access to specific countries (ISO codes) */
99
+ /**
100
+ * The countries it opens from, two-letter codes in any case (`UK` is written `GB`): the country of the network the
101
+ * recipient opens it from, which a VPN changes. A code that names no country is refused before anything is sent.
102
+ */
42
103
  geoAllowlist?: string[];
43
104
  /**
44
105
  * The recipient's address (their `keygen().address`): the link opens only
45
106
  * with their seed and also lands in their inbox (`inbox()`). Its key must
46
107
  * be published (`inbox()` or `keygen` of any SEAL client does it), else
47
- * nothing is uploaded and `RESOURCE_NOT_FOUND` is thrown.
108
+ * nothing is uploaded and `RESOURCE_NOT_FOUND` is thrown. An empty one is
109
+ * refused, and so is one given unset (`to: process.env.ADDRESS` with no
110
+ * `ADDRESS`).
48
111
  */
49
- to?: string;
112
+ to?: string | undefined;
50
113
  /**
51
114
  * The address of a person's SEAL inbox (`pair()`): the seal also lands
52
115
  * there, for them to manage and revoke. Best effort: if the inbox has no
@@ -62,8 +125,8 @@ interface CreateAnonymousSealOptions {
62
125
  };
63
126
  /**
64
127
  * Over 1 GB: the tier the person pays for once by card (prices and terms:
65
- * seal.net/pricing). Needs `onPaymentRequired` and a `ttl` the server allows
66
- * a paid seal.
128
+ * seal.net/pricing). Needs `onPaymentRequired`. A lifetime shorter than a
129
+ * day becomes a day, as on seal.net: the seal waits for its payment.
67
130
  */
68
131
  tier?: '5gb' | '50gb' | '500gb';
69
132
  /**
@@ -73,11 +136,8 @@ interface CreateAnonymousSealOptions {
73
136
  * Not paid by then: the seal is revoked and `PAYMENT_REQUIRED` is thrown.
74
137
  */
75
138
  onPaymentRequired?: (checkoutUrl: string) => void | Promise<void>;
76
- /** Progress callback for large files */
77
- onProgress?: (progress: {
78
- phase: string;
79
- percent: number;
80
- }) => void;
139
+ /** Progress of the whole seal, and of the file moving now */
140
+ onProgress?: (progress: SendProgress) => void;
81
141
  /** Abort signal */
82
142
  signal?: AbortSignal;
83
143
  }
@@ -102,10 +162,15 @@ interface CreateAnonymousSealResult {
102
162
  ownerToken: string;
103
163
  /** Expiration datetime (ISO string) */
104
164
  expiresAt: string;
105
- /** Encryption key (base64) - only returned, never stored */
165
+ /** Encryption key of the seal's first file (base64) - only returned, never stored */
106
166
  encryptionKey: string;
107
- /** File ID */
167
+ /** File ID of the seal's first file */
108
168
  fileId: string;
169
+ /** Every file of the seal in the order sent, by the name the recipient sees: a folder's by its path. */
170
+ files: ReadonlyArray<{
171
+ readonly fileId: string;
172
+ readonly name: string;
173
+ }>;
109
174
  /** The link is in the recipient's inbox (`to` was given). */
110
175
  delivered: boolean;
111
176
  /** The seal is in the owner's inbox (`owner` was given and it took it). */
@@ -178,7 +243,7 @@ interface OpenOptions {
178
243
  /** Opens a link addressed to this seed. */
179
244
  readonly keyPair?: Pick<KeyPair, 'secretKey'>;
180
245
  /** The seal's password, when it has one. */
181
- readonly password?: string;
246
+ readonly password?: string | undefined;
182
247
  readonly signal?: AbortSignal;
183
248
  /** Ciphertext bytes received so far, out of the seal's total. */
184
249
  readonly onProgress?: (done: number, total: number) => void;
@@ -315,7 +380,7 @@ interface SealClientOptions {
315
380
  * import { SealClient } from 'sealnet'
316
381
  *
317
382
  * const seal = new SealClient()
318
- * const { shareUrl } = await seal.send({ file, filename: 'dump.sql', ttl: '1d' })
383
+ * const { shareUrl } = await seal.send({ file, filename: 'dump.sql', secret: process.env.DB_PASSWORD, ttl: '1d' })
319
384
  * const opened = await seal.open(shareUrl, { to: './downloads' }) // Node
320
385
  * ```
321
386
  */
@@ -325,8 +390,10 @@ declare class SealClient {
325
390
  private readonly site;
326
391
  constructor(options?: SealClientOptions);
327
392
  /**
328
- * Encrypt a file client-side, upload the ciphertext, and return the
329
- * recipient share link plus the owner management material.
393
+ * Encrypt files client-side — one or several, a folder file by file under
394
+ * its paths, a secret the recipient's page shows hidden — into one seal,
395
+ * upload the ciphertext, and return the recipient share link plus the
396
+ * owner management material. The rules go as seal.net reads and sends them.
330
397
  *
331
398
  * `filename` and `mimeType` are what the RECIPIENT sees — they override
332
399
  * the name and type of a `File` you pass in.
@@ -334,11 +401,12 @@ declare class SealClient {
334
401
  send(options: SendOptions): Promise<SendResult>;
335
402
  /**
336
403
  * Open a link, or an item of your inbox (with `keyPair`). With `to` (Node)
337
- * every file is streamed into that directory — 0600, named only after its
338
- * header matched the one registered at upload and its last segment opened.
339
- * Without it each file is downloaded when you `read()` it, as a stream that
340
- * fails if the file was changed. Either way memory stays one segment
341
- * whatever the size. `keyPair` opens a link addressed to your address.
404
+ * every file is streamed into that directory — a folder's under its path
405
+ * in it — 0600, named only after its header matched the one registered at
406
+ * upload and its last segment opened. Without it each file is downloaded
407
+ * when you `read()` it, as a stream that fails if the file was changed.
408
+ * Either way memory stays one segment whatever the size. `keyPair` opens a
409
+ * link addressed to your address.
342
410
  */
343
411
  open(link: string | InboxItem, options: OpenOptions & {
344
412
  to: string;
@@ -392,4 +460,4 @@ declare class SealClient {
392
460
  }
393
461
  declare const VERSION: string;
394
462
 
395
- export { type Inbox, type InboxItem, type InboxOptions, type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type PairOptions, type PairResult, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SendOptions, type SendResult, type TTL, VERSION };
463
+ export { type Inbox, type InboxItem, type InboxOptions, type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type PairOptions, type PairResult, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SealFile, type SealFolderFile, type SealSource, type SendOptions, type SendProgress, type SendResult, type TTL, VERSION };
package/dist/index.d.ts CHANGED
@@ -17,36 +17,99 @@ interface OpenedStream {
17
17
  declare const TTL_OPTIONS: readonly string[];
18
18
  /** A seal's lifetime, one of the contract's `ttl_options`. */
19
19
  type TTL = (typeof TTL_OPTIONS)[number];
20
+ /**
21
+ * A file's bytes: a `File` or `Blob` (in Node, `fs.openAsBlob(path)` reads one from disk as it goes up), an
22
+ * `ArrayBuffer` or a `Uint8Array`.
23
+ */
24
+ type SealSource = File | Blob | ArrayBuffer | Uint8Array;
25
+ /** One file of a seal, as the recipient sees it. */
26
+ interface SealFile {
27
+ readonly file: SealSource;
28
+ /** The name the recipient sees: a `File`'s own when omitted; bytes need one. */
29
+ readonly filename?: string;
30
+ /** The type the recipient sees: a `File`'s own when omitted, else `application/octet-stream`. */
31
+ readonly mimeType?: string;
32
+ /** A secret — a key, a password: the recipient's page shows it hidden, a receiving agent saves it and never prints it. */
33
+ readonly secret?: boolean;
34
+ }
35
+ /** One file of a folder: its path in the folder, `/` between folders, is its name in the seal (`docs/q3/report.pdf`). */
36
+ interface SealFolderFile {
37
+ readonly path: string;
38
+ readonly file: SealSource;
39
+ readonly mimeType?: string;
40
+ }
41
+ /** Where a send stands: the whole seal's `percent` (0–100, never back), and the phase and name of the file moving now. */
42
+ interface SendProgress {
43
+ readonly phase: string;
44
+ readonly percent: number;
45
+ readonly fileIndex: number;
46
+ readonly totalFiles: number;
47
+ readonly fileName: string;
48
+ }
20
49
  interface CreateAnonymousSealOptions {
21
- /** File data (File, ArrayBuffer, Uint8Array, or Blob) */
22
- file: File | ArrayBuffer | Uint8Array | Blob;
23
- /** Original filename */
24
- filename: string;
25
- /** MIME type (optional, defaults to application/octet-stream) */
50
+ /** One file (File, ArrayBuffer, Uint8Array, or Blob); `files`, `folder` and `secret` add to the same seal */
51
+ file?: SealSource;
52
+ /** The name the recipient sees for `file`: a `File`'s own when omitted; bytes need one */
53
+ filename?: string;
54
+ /** MIME type of `file` (optional: a `File`'s own, else application/octet-stream) */
26
55
  mimeType?: string;
27
- /** Time to live: one of the lifetimes seal.net offers */
28
- ttl: TTL;
29
- /** Optional password (OTP) for download protection */
30
- otp?: string;
56
+ /** More files, after `file`, in this order */
57
+ files?: ReadonlyArray<SealFile>;
58
+ /**
59
+ * A folder, file by file under its paths, no ZIP: a `File` of a folder picker (`<input webkitdirectory>`) carries
60
+ * its path, any other file says it (`{ path, file }`).
61
+ */
62
+ folder?: ReadonlyArray<File | SealFolderFile>;
63
+ /**
64
+ * A password, a key or a text, sealed first as `Secret`: the recipient's page shows it hidden. Read it from the
65
+ * environment or a file, never write it into code. An empty one is refused, and so is one given unset
66
+ * (`secret: process.env.KEY` with no `KEY`).
67
+ */
68
+ secret?: string | Uint8Array | undefined;
69
+ /**
70
+ * Time to live: one of the lifetimes seal.net offers. Omitted, as on seal.net: a secret alone in the seal lives an
71
+ * hour, anything else the longest lifetime.
72
+ */
73
+ ttl?: TTL;
74
+ /**
75
+ * Optional password (OTP) for download protection. Read it from the environment, never write it into code; an empty
76
+ * one, or one given unset (`otp: process.env.PASSWORD` with no `PASSWORD`), is refused.
77
+ */
78
+ otp?: string | undefined;
31
79
  /** Require NDA signature before download */
32
80
  nda?: boolean;
33
- /** Owner email (required if nda=true) */
81
+ /** Your email: a letter each time the seal is opened, with when and from which country. Required with `nda`: the signed agreement comes here too. */
34
82
  ownerEmail?: string;
35
- /** Optional message to display to recipient */
83
+ /**
84
+ * The document the recipient signs for (with `nda`, instead of `message`): sent last, marked as the NDA's. The
85
+ * agreement then reads "NDA document attached: <name> (<size>)", as on seal.net.
86
+ */
87
+ ndaFile?: SealFile;
88
+ /**
89
+ * A note to the recipient (up to 5000 characters), encrypted inside the seal. With `nda` it is the agreement's
90
+ * text; an NDA with neither it nor `ndaFile` reads "Confidentiality Agreement".
91
+ */
36
92
  message?: string;
37
- /** Delete after first download */
93
+ /**
94
+ * One open. Omitted, as on seal.net: a secret alone in the seal opens once unless `maxOpens` is given.
95
+ */
38
96
  singleUse?: boolean;
39
- /** Maximum number of downloads allowed */
97
+ /** The most opens, 1 to 10; with `singleUse` the seal opens once and this is not sent */
40
98
  maxOpens?: number;
41
- /** Restrict access to specific countries (ISO codes) */
99
+ /**
100
+ * The countries it opens from, two-letter codes in any case (`UK` is written `GB`): the country of the network the
101
+ * recipient opens it from, which a VPN changes. A code that names no country is refused before anything is sent.
102
+ */
42
103
  geoAllowlist?: string[];
43
104
  /**
44
105
  * The recipient's address (their `keygen().address`): the link opens only
45
106
  * with their seed and also lands in their inbox (`inbox()`). Its key must
46
107
  * be published (`inbox()` or `keygen` of any SEAL client does it), else
47
- * nothing is uploaded and `RESOURCE_NOT_FOUND` is thrown.
108
+ * nothing is uploaded and `RESOURCE_NOT_FOUND` is thrown. An empty one is
109
+ * refused, and so is one given unset (`to: process.env.ADDRESS` with no
110
+ * `ADDRESS`).
48
111
  */
49
- to?: string;
112
+ to?: string | undefined;
50
113
  /**
51
114
  * The address of a person's SEAL inbox (`pair()`): the seal also lands
52
115
  * there, for them to manage and revoke. Best effort: if the inbox has no
@@ -62,8 +125,8 @@ interface CreateAnonymousSealOptions {
62
125
  };
63
126
  /**
64
127
  * Over 1 GB: the tier the person pays for once by card (prices and terms:
65
- * seal.net/pricing). Needs `onPaymentRequired` and a `ttl` the server allows
66
- * a paid seal.
128
+ * seal.net/pricing). Needs `onPaymentRequired`. A lifetime shorter than a
129
+ * day becomes a day, as on seal.net: the seal waits for its payment.
67
130
  */
68
131
  tier?: '5gb' | '50gb' | '500gb';
69
132
  /**
@@ -73,11 +136,8 @@ interface CreateAnonymousSealOptions {
73
136
  * Not paid by then: the seal is revoked and `PAYMENT_REQUIRED` is thrown.
74
137
  */
75
138
  onPaymentRequired?: (checkoutUrl: string) => void | Promise<void>;
76
- /** Progress callback for large files */
77
- onProgress?: (progress: {
78
- phase: string;
79
- percent: number;
80
- }) => void;
139
+ /** Progress of the whole seal, and of the file moving now */
140
+ onProgress?: (progress: SendProgress) => void;
81
141
  /** Abort signal */
82
142
  signal?: AbortSignal;
83
143
  }
@@ -102,10 +162,15 @@ interface CreateAnonymousSealResult {
102
162
  ownerToken: string;
103
163
  /** Expiration datetime (ISO string) */
104
164
  expiresAt: string;
105
- /** Encryption key (base64) - only returned, never stored */
165
+ /** Encryption key of the seal's first file (base64) - only returned, never stored */
106
166
  encryptionKey: string;
107
- /** File ID */
167
+ /** File ID of the seal's first file */
108
168
  fileId: string;
169
+ /** Every file of the seal in the order sent, by the name the recipient sees: a folder's by its path. */
170
+ files: ReadonlyArray<{
171
+ readonly fileId: string;
172
+ readonly name: string;
173
+ }>;
109
174
  /** The link is in the recipient's inbox (`to` was given). */
110
175
  delivered: boolean;
111
176
  /** The seal is in the owner's inbox (`owner` was given and it took it). */
@@ -178,7 +243,7 @@ interface OpenOptions {
178
243
  /** Opens a link addressed to this seed. */
179
244
  readonly keyPair?: Pick<KeyPair, 'secretKey'>;
180
245
  /** The seal's password, when it has one. */
181
- readonly password?: string;
246
+ readonly password?: string | undefined;
182
247
  readonly signal?: AbortSignal;
183
248
  /** Ciphertext bytes received so far, out of the seal's total. */
184
249
  readonly onProgress?: (done: number, total: number) => void;
@@ -315,7 +380,7 @@ interface SealClientOptions {
315
380
  * import { SealClient } from 'sealnet'
316
381
  *
317
382
  * const seal = new SealClient()
318
- * const { shareUrl } = await seal.send({ file, filename: 'dump.sql', ttl: '1d' })
383
+ * const { shareUrl } = await seal.send({ file, filename: 'dump.sql', secret: process.env.DB_PASSWORD, ttl: '1d' })
319
384
  * const opened = await seal.open(shareUrl, { to: './downloads' }) // Node
320
385
  * ```
321
386
  */
@@ -325,8 +390,10 @@ declare class SealClient {
325
390
  private readonly site;
326
391
  constructor(options?: SealClientOptions);
327
392
  /**
328
- * Encrypt a file client-side, upload the ciphertext, and return the
329
- * recipient share link plus the owner management material.
393
+ * Encrypt files client-side — one or several, a folder file by file under
394
+ * its paths, a secret the recipient's page shows hidden — into one seal,
395
+ * upload the ciphertext, and return the recipient share link plus the
396
+ * owner management material. The rules go as seal.net reads and sends them.
330
397
  *
331
398
  * `filename` and `mimeType` are what the RECIPIENT sees — they override
332
399
  * the name and type of a `File` you pass in.
@@ -334,11 +401,12 @@ declare class SealClient {
334
401
  send(options: SendOptions): Promise<SendResult>;
335
402
  /**
336
403
  * Open a link, or an item of your inbox (with `keyPair`). With `to` (Node)
337
- * every file is streamed into that directory — 0600, named only after its
338
- * header matched the one registered at upload and its last segment opened.
339
- * Without it each file is downloaded when you `read()` it, as a stream that
340
- * fails if the file was changed. Either way memory stays one segment
341
- * whatever the size. `keyPair` opens a link addressed to your address.
404
+ * every file is streamed into that directory — a folder's under its path
405
+ * in it — 0600, named only after its header matched the one registered at
406
+ * upload and its last segment opened. Without it each file is downloaded
407
+ * when you `read()` it, as a stream that fails if the file was changed.
408
+ * Either way memory stays one segment whatever the size. `keyPair` opens a
409
+ * link addressed to your address.
342
410
  */
343
411
  open(link: string | InboxItem, options: OpenOptions & {
344
412
  to: string;
@@ -392,4 +460,4 @@ declare class SealClient {
392
460
  }
393
461
  declare const VERSION: string;
394
462
 
395
- export { type Inbox, type InboxItem, type InboxOptions, type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type PairOptions, type PairResult, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SendOptions, type SendResult, type TTL, VERSION };
463
+ export { type Inbox, type InboxItem, type InboxOptions, type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type PairOptions, type PairResult, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SealFile, type SealFolderFile, type SealSource, type SendOptions, type SendProgress, type SendResult, type TTL, VERSION };