@dorvyn/server 0.0.0-stage → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Dorvyn SDK
2
+ Copyright (c) 2026 Dorvyn Pvt Ltd. All rights reserved.
3
+
4
+ This package is part of the Dorvyn SDK. The SDK is licensed, not sold. You may use it only under
5
+ Dorvyn's Terms of Service at https://dorvyn.dev/terms, which include your license to the SDK
6
+ (section 5), the rules for license keys (section 6) and what you may not do with it (section 7),
7
+ or under a written agreement you have with Dorvyn Pvt Ltd.
8
+
9
+ Downloading or installing this package does not by itself grant any license. Test keys are for
10
+ development and testing only; using the SDK in production needs a live key from a paid plan.
11
+ Everything not expressly licensed stays with Dorvyn Pvt Ltd.
12
+
13
+ The SDK includes open-source components. They are listed, with their licenses, in
14
+ THIRD_PARTY_NOTICES.md in this package, and those licenses apply to those components.
15
+
16
+ THE SDK IS PROVIDED AS DESCRIBED IN THE TERMS. EXCEPT AS THE TERMS OR YOUR WRITTEN AGREEMENT
17
+ EXPRESSLY STATE, IT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
18
+
19
+ Questions: support@dorvyn.dev
package/README.md CHANGED
@@ -1,3 +1,19 @@
1
- # Temporary Holding Version
1
+ # @dorvyn/server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Dorvyn on your server: grants and exports for your signed-in users, with your secret key from the environment.
4
+
5
+ Dorvyn for your server is part of the Dorvyn SDK: a Word-compatible document editor for your web application, with saving as .docx.
6
+
7
+ ```sh
8
+ npm install @dorvyn/server
9
+ ```
10
+
11
+ **Documentation:** https://docs.dorvyn.dev/server-reference/
12
+
13
+ You need a Dorvyn key to use it: test keys work on localhost for building and trying everything; live keys come with a plan. Get yours at https://app.dorvyn.dev.
14
+
15
+ ## License
16
+
17
+ Proprietary: see [LICENSE](./LICENSE) and Dorvyn's terms at https://dorvyn.dev/terms. Open-source components in the SDK are listed in [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).
18
+
19
+ Support: support@dorvyn.dev
@@ -0,0 +1,592 @@
1
+ # Third-party notices
2
+
3
+ The Dorvyn SDK's engine includes the open-source components below. Each is used under the license shown;
4
+ those licenses apply to those components only. The rest of the SDK is Dorvyn's (see LICENSE).
5
+
6
+ ### adler2 2.0.1
7
+
8
+ License: 0BSD OR MIT OR Apache-2.0
9
+ Source: https://github.com/oyvindln/adler2
10
+ Used under Apache-2.0 (text below).
11
+
12
+ ### base16ct 1.0.0
13
+
14
+ License: Apache-2.0 OR MIT
15
+ Source: https://github.com/RustCrypto/formats
16
+ Used under Apache-2.0 (text below).
17
+
18
+ ### base64 0.23.1
19
+
20
+ License: MIT OR Apache-2.0
21
+ Source: https://github.com/marshallpierce/rust-base64
22
+ Used under Apache-2.0 (text below).
23
+
24
+ ### block-buffer 0.12.1
25
+
26
+ License: MIT OR Apache-2.0
27
+ Source: https://github.com/RustCrypto/utils
28
+ Used under Apache-2.0 (text below).
29
+
30
+ ### cfg-if 1.0.5
31
+
32
+ License: MIT OR Apache-2.0
33
+ Source: https://github.com/rust-lang/cfg-if
34
+ Used under Apache-2.0 (text below).
35
+
36
+ ### cmov 0.5.4
37
+
38
+ License: Apache-2.0 OR MIT
39
+ Source: https://github.com/RustCrypto/utils
40
+ Used under Apache-2.0 (text below).
41
+
42
+ ### const-oid 0.10.3
43
+
44
+ License: Apache-2.0 OR MIT
45
+ Source: https://github.com/RustCrypto/formats
46
+ Used under Apache-2.0 (text below).
47
+
48
+ ### cpubits 0.1.1
49
+
50
+ License: MIT OR Apache-2.0
51
+ Source: https://github.com/RustCrypto/utils
52
+ Used under Apache-2.0 (text below).
53
+
54
+ ### crypto-bigint 0.7.11
55
+
56
+ License: Apache-2.0 OR MIT
57
+ Source: https://github.com/RustCrypto/crypto-bigint
58
+ Used under Apache-2.0 (text below).
59
+
60
+ ### crypto-common 0.2.2
61
+
62
+ License: MIT OR Apache-2.0
63
+ Source: https://github.com/RustCrypto/traits
64
+ Used under Apache-2.0 (text below).
65
+
66
+ ### ctutils 0.4.8
67
+
68
+ License: Apache-2.0 OR MIT
69
+ Source: https://github.com/RustCrypto/utils
70
+ Used under Apache-2.0 (text below).
71
+
72
+ ### der 0.8.3
73
+
74
+ License: Apache-2.0 OR MIT
75
+ Source: https://github.com/RustCrypto/formats
76
+ Used under Apache-2.0 (text below).
77
+
78
+ ### digest 0.11.3
79
+
80
+ License: MIT OR Apache-2.0
81
+ Source: https://github.com/RustCrypto/traits
82
+ Used under Apache-2.0 (text below).
83
+
84
+ ### ecdsa 0.17.0
85
+
86
+ License: Apache-2.0 OR MIT
87
+ Source: https://github.com/RustCrypto/signatures
88
+ Used under Apache-2.0 (text below).
89
+
90
+ ### elliptic-curve 0.14.3
91
+
92
+ License: Apache-2.0 OR MIT
93
+ Source: https://github.com/RustCrypto/traits
94
+ Used under Apache-2.0 (text below).
95
+
96
+ ### ff 0.14.0
97
+
98
+ License: MIT/Apache-2.0
99
+ Source: https://github.com/zkcrypto/ff
100
+ Used under Apache-2.0 (text below).
101
+
102
+ ### group 0.14.0
103
+
104
+ License: MIT/Apache-2.0
105
+ Source: https://github.com/zkcrypto/group
106
+ Used under Apache-2.0 (text below).
107
+
108
+ ### hmac 0.13.0
109
+
110
+ License: MIT OR Apache-2.0
111
+ Source: https://github.com/RustCrypto/MACs
112
+ Used under Apache-2.0 (text below).
113
+
114
+ ### hybrid-array 0.4.15
115
+
116
+ License: MIT OR Apache-2.0
117
+ Source: https://github.com/RustCrypto/hybrid-array
118
+ Used under Apache-2.0 (text below).
119
+
120
+ ### itoa 1.0.19
121
+
122
+ License: MIT OR Apache-2.0
123
+ Source: https://github.com/dtolnay/itoa
124
+ Used under Apache-2.0 (text below).
125
+
126
+ ### memchr 2.8.3
127
+
128
+ License: Unlicense OR MIT
129
+ Source: https://github.com/BurntSushi/memchr
130
+ Used under MIT.
131
+
132
+ ```
133
+ The MIT License (MIT)
134
+
135
+ Copyright (c) 2015 Andrew Gallant
136
+
137
+ Permission is hereby granted, free of charge, to any person obtaining a copy
138
+ of this software and associated documentation files (the "Software"), to deal
139
+ in the Software without restriction, including without limitation the rights
140
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
141
+ copies of the Software, and to permit persons to whom the Software is
142
+ furnished to do so, subject to the following conditions:
143
+
144
+ The above copyright notice and this permission notice shall be included in
145
+ all copies or substantial portions of the Software.
146
+
147
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
148
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
149
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
150
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
151
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
152
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
153
+ THE SOFTWARE.
154
+ ```
155
+
156
+ ### miniz_oxide 0.9.1
157
+
158
+ License: MIT OR Zlib OR Apache-2.0
159
+ Source: https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide
160
+ Used under Apache-2.0 (text below).
161
+
162
+ ### num-traits 0.2.19
163
+
164
+ License: MIT OR Apache-2.0
165
+ Source: https://github.com/rust-num/num-traits
166
+ Used under Apache-2.0 (text below).
167
+
168
+ ### p256 0.14.0
169
+
170
+ License: Apache-2.0 OR MIT
171
+ Source: https://github.com/RustCrypto/elliptic-curves
172
+ Used under Apache-2.0 (text below).
173
+
174
+ ### primefield 0.14.0
175
+
176
+ License: Apache-2.0 OR MIT
177
+ Source: https://github.com/RustCrypto/elliptic-curves
178
+ Used under Apache-2.0 (text below).
179
+
180
+ ### primeorder 0.14.0
181
+
182
+ License: Apache-2.0 OR MIT
183
+ Source: https://github.com/RustCrypto/elliptic-curves
184
+ Used under Apache-2.0 (text below).
185
+
186
+ ### rand_core 0.10.1
187
+
188
+ License: MIT OR Apache-2.0
189
+ Source: https://github.com/rust-random/rand_core
190
+ Used under Apache-2.0 (text below).
191
+
192
+ ### rfc6979 0.6.0
193
+
194
+ License: Apache-2.0 OR MIT
195
+ Source: https://github.com/RustCrypto/signatures
196
+ Used under Apache-2.0 (text below).
197
+
198
+ ### roxmltree 0.21.2
199
+
200
+ License: MIT OR Apache-2.0
201
+ Source: https://github.com/RazrFalcon/roxmltree
202
+ Used under Apache-2.0 (text below).
203
+
204
+ ### sec1 0.8.1
205
+
206
+ License: Apache-2.0 OR MIT
207
+ Source: https://github.com/RustCrypto/formats
208
+ Used under Apache-2.0 (text below).
209
+
210
+ ### serde 1.0.229
211
+
212
+ License: MIT OR Apache-2.0
213
+ Source: https://github.com/serde-rs/serde
214
+ Used under Apache-2.0 (text below).
215
+
216
+ ### serde_core 1.0.229
217
+
218
+ License: MIT OR Apache-2.0
219
+ Source: https://github.com/serde-rs/serde
220
+ Used under Apache-2.0 (text below).
221
+
222
+ ### serde_json 1.0.154
223
+
224
+ License: MIT OR Apache-2.0
225
+ Source: https://github.com/serde-rs/json
226
+ Used under Apache-2.0 (text below).
227
+
228
+ ### sha2 0.11.1
229
+
230
+ License: MIT OR Apache-2.0
231
+ Source: https://github.com/RustCrypto/hashes
232
+ Used under Apache-2.0 (text below).
233
+
234
+ ### signature 3.0.0
235
+
236
+ License: Apache-2.0 OR MIT
237
+ Source: https://github.com/RustCrypto/traits
238
+ Used under Apache-2.0 (text below).
239
+
240
+ ### subtle 2.6.1
241
+
242
+ License: BSD-3-Clause
243
+ Source: https://github.com/dalek-cryptography/subtle
244
+
245
+ ```
246
+ Copyright (c) 2016-2017 Isis Agora Lovecruft, Henry de Valence. All rights reserved.
247
+ Copyright (c) 2016-2024 Isis Agora Lovecruft. All rights reserved.
248
+
249
+ Redistribution and use in source and binary forms, with or without
250
+ modification, are permitted provided that the following conditions are
251
+ met:
252
+
253
+ 1. Redistributions of source code must retain the above copyright
254
+ notice, this list of conditions and the following disclaimer.
255
+
256
+ 2. Redistributions in binary form must reproduce the above copyright
257
+ notice, this list of conditions and the following disclaimer in the
258
+ documentation and/or other materials provided with the distribution.
259
+
260
+ 3. Neither the name of the copyright holder nor the names of its
261
+ contributors may be used to endorse or promote products derived from
262
+ this software without specific prior written permission.
263
+
264
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
265
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
266
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
267
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
268
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
269
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
270
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
271
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
272
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
273
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
274
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275
+ ```
276
+
277
+ ### typenum 1.20.1
278
+
279
+ License: MIT OR Apache-2.0
280
+ Source: https://github.com/paholg/typenum
281
+ Used under Apache-2.0 (text below).
282
+
283
+ ### unicode-ident 1.0.27
284
+
285
+ License: (MIT OR Apache-2.0) AND Unicode-3.0
286
+ Source: https://github.com/dtolnay/unicode-ident
287
+ Used under Apache-2.0 (text below).
288
+
289
+ And under the Unicode License:
290
+
291
+ ```
292
+ UNICODE LICENSE V3
293
+
294
+ COPYRIGHT AND PERMISSION NOTICE
295
+
296
+ Copyright © 1991-2023 Unicode, Inc.
297
+
298
+ NOTICE TO USER: Carefully read the following legal agreement. BY
299
+ DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
300
+ SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
301
+ TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
302
+ DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
303
+
304
+ Permission is hereby granted, free of charge, to any person obtaining a
305
+ copy of data files and any associated documentation (the "Data Files") or
306
+ software and any associated documentation (the "Software") to deal in the
307
+ Data Files or Software without restriction, including without limitation
308
+ the rights to use, copy, modify, merge, publish, distribute, and/or sell
309
+ copies of the Data Files or Software, and to permit persons to whom the
310
+ Data Files or Software are furnished to do so, provided that either (a)
311
+ this copyright and permission notice appear with all copies of the Data
312
+ Files or Software, or (b) this copyright and permission notice appear in
313
+ associated Documentation.
314
+
315
+ THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
316
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
317
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
318
+ THIRD PARTY RIGHTS.
319
+
320
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
321
+ BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
322
+ OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
323
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
324
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
325
+ FILES OR SOFTWARE.
326
+
327
+ Except as contained in this notice, the name of a copyright holder shall
328
+ not be used in advertising or otherwise to promote the sale, use or other
329
+ dealings in these Data Files or Software without prior written
330
+ authorization of the copyright holder.
331
+ ```
332
+
333
+ ### wasm-bindgen 0.2.130
334
+
335
+ License: MIT OR Apache-2.0
336
+ Source: https://github.com/wasm-bindgen/wasm-bindgen
337
+ Used under Apache-2.0 (text below).
338
+
339
+ ### wasm-bindgen-shared 0.2.130
340
+
341
+ License: MIT OR Apache-2.0
342
+ Source: https://github.com/wasm-bindgen/wasm-bindgen/tree/master/crates/shared
343
+ Used under Apache-2.0 (text below).
344
+
345
+ ### wnaf 0.14.1
346
+
347
+ License: Apache-2.0 OR MIT
348
+ Source: https://github.com/RustCrypto/elliptic-curves
349
+ Used under Apache-2.0 (text below).
350
+
351
+ ### zeroize 1.9.2
352
+
353
+ License: Apache-2.0 OR MIT
354
+ Source: https://github.com/RustCrypto/utils
355
+ Used under Apache-2.0 (text below).
356
+
357
+ ### zmij 1.0.23
358
+
359
+ License: MIT
360
+ Source: https://github.com/dtolnay/zmij
361
+
362
+ ```
363
+ Permission is hereby granted, free of charge, to any
364
+ person obtaining a copy of this software and associated
365
+ documentation files (the "Software"), to deal in the
366
+ Software without restriction, including without
367
+ limitation the rights to use, copy, modify, merge,
368
+ publish, distribute, sublicense, and/or sell copies of
369
+ the Software, and to permit persons to whom the Software
370
+ is furnished to do so, subject to the following
371
+ conditions:
372
+
373
+ The above copyright notice and this permission notice
374
+ shall be included in all copies or substantial portions
375
+ of the Software.
376
+
377
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
378
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
379
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
380
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
381
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
382
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
383
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
384
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
385
+ DEALINGS IN THE SOFTWARE.
386
+ ```
387
+
388
+ ## Apache License 2.0
389
+
390
+ ```
391
+ Apache License
392
+ Version 2.0, January 2004
393
+ https://www.apache.org/licenses/LICENSE-2.0
394
+
395
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
396
+
397
+ 1. Definitions.
398
+
399
+ "License" shall mean the terms and conditions for use, reproduction,
400
+ and distribution as defined by Sections 1 through 9 of this document.
401
+
402
+ "Licensor" shall mean the copyright owner or entity authorized by
403
+ the copyright owner that is granting the License.
404
+
405
+ "Legal Entity" shall mean the union of the acting entity and all
406
+ other entities that control, are controlled by, or are under common
407
+ control with that entity. For the purposes of this definition,
408
+ "control" means (i) the power, direct or indirect, to cause the
409
+ direction or management of such entity, whether by contract or
410
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
411
+ outstanding shares, or (iii) beneficial ownership of such entity.
412
+
413
+ "You" (or "Your") shall mean an individual or Legal Entity
414
+ exercising permissions granted by this License.
415
+
416
+ "Source" form shall mean the preferred form for making modifications,
417
+ including but not limited to software source code, documentation
418
+ source, and configuration files.
419
+
420
+ "Object" form shall mean any form resulting from mechanical
421
+ transformation or translation of a Source form, including but
422
+ not limited to compiled object code, generated documentation,
423
+ and conversions to other media types.
424
+
425
+ "Work" shall mean the work of authorship, whether in Source or
426
+ Object form, made available under the License, as indicated by a
427
+ copyright notice that is included in or attached to the work
428
+ (an example is provided in the Appendix below).
429
+
430
+ "Derivative Works" shall mean any work, whether in Source or Object
431
+ form, that is based on (or derived from) the Work and for which the
432
+ editorial revisions, annotations, elaborations, or other modifications
433
+ represent, as a whole, an original work of authorship. For the purposes
434
+ of this License, Derivative Works shall not include works that remain
435
+ separable from, or merely link (or bind by name) to the interfaces of,
436
+ the Work and Derivative Works thereof.
437
+
438
+ "Contribution" shall mean any work of authorship, including
439
+ the original version of the Work and any modifications or additions
440
+ to that Work or Derivative Works thereof, that is intentionally
441
+ submitted to Licensor for inclusion in the Work by the copyright owner
442
+ or by an individual or Legal Entity authorized to submit on behalf of
443
+ the copyright owner. For the purposes of this definition, "submitted"
444
+ means any form of electronic, verbal, or written communication sent
445
+ to the Licensor or its representatives, including but not limited to
446
+ communication on electronic mailing lists, source code control systems,
447
+ and issue tracking systems that are managed by, or on behalf of, the
448
+ Licensor for the purpose of discussing and improving the Work, but
449
+ excluding communication that is conspicuously marked or otherwise
450
+ designated in writing by the copyright owner as "Not a Contribution."
451
+
452
+ "Contributor" shall mean Licensor and any individual or Legal Entity
453
+ on behalf of whom a Contribution has been received by Licensor and
454
+ subsequently incorporated within the Work.
455
+
456
+ 2. Grant of Copyright License. Subject to the terms and conditions of
457
+ this License, each Contributor hereby grants to You a perpetual,
458
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
459
+ copyright license to reproduce, prepare Derivative Works of,
460
+ publicly display, publicly perform, sublicense, and distribute the
461
+ Work and such Derivative Works in Source or Object form.
462
+
463
+ 3. Grant of Patent License. Subject to the terms and conditions of
464
+ this License, each Contributor hereby grants to You a perpetual,
465
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
466
+ (except as stated in this section) patent license to make, have made,
467
+ use, offer to sell, sell, import, and otherwise transfer the Work,
468
+ where such license applies only to those patent claims licensable
469
+ by such Contributor that are necessarily infringed by their
470
+ Contribution(s) alone or by combination of their Contribution(s)
471
+ with the Work to which such Contribution(s) was submitted. If You
472
+ institute patent litigation against any entity (including a
473
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
474
+ or a Contribution incorporated within the Work constitutes direct
475
+ or contributory patent infringement, then any patent licenses
476
+ granted to You under this License for that Work shall terminate
477
+ as of the date such litigation is filed.
478
+
479
+ 4. Redistribution. You may reproduce and distribute copies of the
480
+ Work or Derivative Works thereof in any medium, with or without
481
+ modifications, and in Source or Object form, provided that You
482
+ meet the following conditions:
483
+
484
+ (a) You must give any other recipients of the Work or
485
+ Derivative Works a copy of this License; and
486
+
487
+ (b) You must cause any modified files to carry prominent notices
488
+ stating that You changed the files; and
489
+
490
+ (c) You must retain, in the Source form of any Derivative Works
491
+ that You distribute, all copyright, patent, trademark, and
492
+ attribution notices from the Source form of the Work,
493
+ excluding those notices that do not pertain to any part of
494
+ the Derivative Works; and
495
+
496
+ (d) If the Work includes a "NOTICE" text file as part of its
497
+ distribution, then any Derivative Works that You distribute must
498
+ include a readable copy of the attribution notices contained
499
+ within such NOTICE file, excluding those notices that do not
500
+ pertain to any part of the Derivative Works, in at least one
501
+ of the following places: within a NOTICE text file distributed
502
+ as part of the Derivative Works; within the Source form or
503
+ documentation, if provided along with the Derivative Works; or,
504
+ within a display generated by the Derivative Works, if and
505
+ wherever such third-party notices normally appear. The contents
506
+ of the NOTICE file are for informational purposes only and
507
+ do not modify the License. You may add Your own attribution
508
+ notices within Derivative Works that You distribute, alongside
509
+ or as an addendum to the NOTICE text from the Work, provided
510
+ that such additional attribution notices cannot be construed
511
+ as modifying the License.
512
+
513
+ You may add Your own copyright statement to Your modifications and
514
+ may provide additional or different license terms and conditions
515
+ for use, reproduction, or distribution of Your modifications, or
516
+ for any such Derivative Works as a whole, provided Your use,
517
+ reproduction, and distribution of the Work otherwise complies with
518
+ the conditions stated in this License.
519
+
520
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
521
+ any Contribution intentionally submitted for inclusion in the Work
522
+ by You to the Licensor shall be under the terms and conditions of
523
+ this License, without any additional terms or conditions.
524
+ Notwithstanding the above, nothing herein shall supersede or modify
525
+ the terms of any separate license agreement you may have executed
526
+ with Licensor regarding such Contributions.
527
+
528
+ 6. Trademarks. This License does not grant permission to use the trade
529
+ names, trademarks, service marks, or product names of the Licensor,
530
+ except as required for reasonable and customary use in describing the
531
+ origin of the Work and reproducing the content of the NOTICE file.
532
+
533
+ 7. Disclaimer of Warranty. Unless required by applicable law or
534
+ agreed to in writing, Licensor provides the Work (and each
535
+ Contributor provides its Contributions) on an "AS IS" BASIS,
536
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
537
+ implied, including, without limitation, any warranties or conditions
538
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
539
+ PARTICULAR PURPOSE. You are solely responsible for determining the
540
+ appropriateness of using or redistributing the Work and assume any
541
+ risks associated with Your exercise of permissions under this License.
542
+
543
+ 8. Limitation of Liability. In no event and under no legal theory,
544
+ whether in tort (including negligence), contract, or otherwise,
545
+ unless required by applicable law (such as deliberate and grossly
546
+ negligent acts) or agreed to in writing, shall any Contributor be
547
+ liable to You for damages, including any direct, indirect, special,
548
+ incidental, or consequential damages of any character arising as a
549
+ result of this License or out of the use or inability to use the
550
+ Work (including but not limited to damages for loss of goodwill,
551
+ work stoppage, computer failure or malfunction, or any and all
552
+ other commercial damages or losses), even if such Contributor
553
+ has been advised of the possibility of such damages.
554
+
555
+ 9. Accepting Warranty or Additional Liability. While redistributing
556
+ the Work or Derivative Works thereof, You may choose to offer,
557
+ and charge a fee for, acceptance of support, warranty, indemnity,
558
+ or other liability obligations and/or rights consistent with this
559
+ License. However, in accepting such obligations, You may act only
560
+ on Your own behalf and on Your sole responsibility, not on behalf
561
+ of any other Contributor, and only if You agree to indemnify,
562
+ defend, and hold each Contributor harmless for any liability
563
+ incurred by, or claims asserted against, such Contributor by reason
564
+ of your accepting any such warranty or additional liability.
565
+
566
+ END OF TERMS AND CONDITIONS
567
+
568
+ APPENDIX: How to apply the Apache License to your work.
569
+
570
+ To apply the Apache License to your work, attach the following
571
+ boilerplate notice, with the fields enclosed by brackets "[]"
572
+ replaced with your own identifying information. (Don't include
573
+ the brackets!) The text should be enclosed in the appropriate
574
+ comment syntax for the file format. We also recommend that a
575
+ file or class name and description of purpose be included on the
576
+ same "printed page" as the copyright notice for easier
577
+ identification within third-party archives.
578
+
579
+ Copyright [yyyy] [name of copyright owner]
580
+
581
+ Licensed under the Apache License, Version 2.0 (the "License");
582
+ you may not use this file except in compliance with the License.
583
+ You may obtain a copy of the License at
584
+
585
+ https://www.apache.org/licenses/LICENSE-2.0
586
+
587
+ Unless required by applicable law or agreed to in writing, software
588
+ distributed under the License is distributed on an "AS IS" BASIS,
589
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
590
+ See the License for the specific language governing permissions and
591
+ limitations under the License.
592
+ ```
@@ -0,0 +1,79 @@
1
+ export interface DorvynServerOptions {
2
+ /** Your secret key (default: the DORVYN_SECRET_KEY environment variable). */
3
+ secretKey?: string;
4
+ /** Dorvyn's API (default: DORVYN_API, or https://api.dorvyn.dev). */
5
+ api?: string;
6
+ /** Dorvyn's export service (default: DORVYN_EXPORT_URL, or your organization's region's). */
7
+ exportUrl?: string;
8
+ fetch?: typeof fetch;
9
+ }
10
+ export interface EngineSettings {
11
+ url?: string;
12
+ integrity?: string;
13
+ }
14
+ export interface DorvynRoutesOptions extends DorvynServerOptions {
15
+ /**
16
+ * Who is asking: your signed-in user's id, from your own session (an opaque id, not an email: 1–128 of
17
+ * A–Z a–z 0–9 . _ : @ | -). Nothing (null, undefined, ""): no grant and no export, the route answers 401.
18
+ * Grants and exports are counted per user, and each names the user it was for.
19
+ */
20
+ user: (request: Request) => string | null | undefined | Promise<string | null | undefined>;
21
+ /** The page addresses that may ask (default: any your application allows; Dorvyn checks the origin either way). */
22
+ origins?: string[];
23
+ /** The engine's address and hash for the page (default: DORVYN_ENGINE_URL, DORVYN_ENGINE_INTEGRITY, or neither). */
24
+ engine?: EngineSettings;
25
+ }
26
+ /** What the editor sends for a grant (no key): its version, build and random session ids. */
27
+ export interface GrantRequest {
28
+ sdk: string;
29
+ build?: string;
30
+ session: string;
31
+ device?: string;
32
+ }
33
+ export interface IssuedGrant {
34
+ grant: string;
35
+ exp: number;
36
+ /** The engine's settings for the page, when your server has any (dorvynRoutes adds them). */
37
+ engine?: EngineSettings;
38
+ }
39
+ export declare class DorvynServerError extends Error {
40
+ readonly status: number;
41
+ constructor(message: string, status: number);
42
+ }
43
+ /**
44
+ * A grant from Dorvyn for one page origin and user, with your secret key. `request`: what the editor sent
45
+ * (its SDK version, build and session; anything else is dropped).
46
+ */
47
+ export declare function requestGrant(options: DorvynServerOptions & {
48
+ origin: string;
49
+ subject?: string;
50
+ request?: Partial<GrantRequest>;
51
+ }): Promise<IssuedGrant>;
52
+ /**
53
+ * Saves a document as .docx under the editor's grant: a ticket for this one export from the API (your
54
+ * secret key; counted against the grant's user), then the export service. Returns the file's bytes.
55
+ */
56
+ export declare function requestExport(options: DorvynServerOptions & {
57
+ grant: string;
58
+ input: unknown;
59
+ }): Promise<Uint8Array>;
60
+ /**
61
+ * The routes for `server-url`: POST …/grant and POST …/export (the last part of the path picks), for the
62
+ * signed-in user only, and only for the page that asked.
63
+ */
64
+ export declare function dorvynRoutes(options: DorvynRoutesOptions): (request: Request) => Promise<Response>;
65
+ /** Node's http and Express (req, res): the same routes. Express's parsed JSON body is used if it ran first. */
66
+ export declare function nodeHandler(handler: (request: Request) => Promise<Response>): (req: NodeRequest, res: NodeResponse) => Promise<void>;
67
+ /** The parts of Node's IncomingMessage (and Express's Request) used here. */
68
+ export interface NodeRequest extends AsyncIterable<Uint8Array | string> {
69
+ method?: string;
70
+ url?: string;
71
+ originalUrl?: string;
72
+ headers: Record<string, string | string[] | undefined>;
73
+ body?: unknown;
74
+ }
75
+ /** The parts of Node's ServerResponse used here. */
76
+ export interface NodeResponse {
77
+ writeHead(status: number, headers: Record<string, string>): unknown;
78
+ end(body: Uint8Array): unknown;
79
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ class d extends Error{status;constructor(e,r){super(e),this.name="DorvynServerError",this.status=r}}const b=/^dvn_sk_(live|test)_[0-9A-HJKMNP-TV-Z]{59}$/,m=/^sha384-[A-Za-z0-9+/]{64}$/,T=/^[A-Za-z0-9._-]{1,64}$/,g={us:"https://export.dorvyn.dev",eu:"https://eu.export.dorvyn.dev"},k="application/vnd.openxmlformats-officedocument.wordprocessingml.document",u=t=>globalThis.process?.env?.[t];function p(t){const e=t.secretKey??u("DORVYN_SECRET_KEY");if(!e||!b.test(e))throw new d("Set DORVYN_SECRET_KEY on the server to your secret key (dvn_sk_…).",500);return{secretKey:e,api:t.api??u("DORVYN_API")??"https://api.dorvyn.dev",exportUrl:t.exportUrl??u("DORVYN_EXPORT_URL"),fetch:t.fetch??fetch}}async function l(t,e,r,a=!0){let o;try{o=await t.fetch(e,{method:"POST",headers:{"content-type":"application/json",...a&&{authorization:`Bearer ${t.secretKey}`}},body:JSON.stringify(r)})}catch{throw new d("Dorvyn couldn't be reached.",502)}if(!o.ok){const s=await o.text().catch(()=>"");let n=s;try{n=JSON.parse(s).message??s}catch{}throw new d(n||`Dorvyn refused (${o.status}).`,o.status)}return o}function y(t){if(typeof t!="string"||t.length>8192)return null;try{return JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}async function x(t){const e=p(t),r=t.request??{},a=n=>typeof n=="string"&&T.test(n)?n:void 0,s=await(await l(e,`${e.api}/v1/grants/server`,{sdk:typeof r.sdk=="string"&&/^\d{1,4}\.\d{1,4}\.\d{1,4}$/.test(r.sdk)?r.sdk:"0.2.0",build:a(r.build),session:a(r.session),device:a(r.device),nonce:O(),origin:t.origin,subject:t.subject})).json().catch(()=>null);if(typeof s?.grant!="string"||typeof s.exp!="number")throw new d("Dorvyn sent an answer this package doesn't understand.",502);return{grant:s.grant,exp:s.exp}}async function E(t){const e=p(t),r=await(await l(e,`${e.api}/v1/exports/ticket`,{grant:t.grant})).json();if(typeof r?.ticket!="string")throw new d("Dorvyn sent an answer this package doesn't understand.",502);const a=y(t.grant)?.region,o=e.exportUrl??(a==="eu"?g.eu:g.us),s=new TextEncoder().encode(JSON.stringify(t.input));let n;if(s.length+t.grant.length+r.ticket.length+96<=R)n=await l(e,`${o}/v1/export`,{grant:t.grant,ticket:r.ticket,input:t.input},!1);else{const c=await(await l(e,`${o}/v1/export/upload`,{grant:t.grant,ticket:r.ticket,size:s.length},!1)).json();if(typeof c?.key!="string"||typeof c.url!="string")throw new d("Dorvyn sent an answer this package doesn't understand.",502);let i;try{i=await e.fetch(c.url,{method:"PUT",headers:{"content-type":"application/json"},body:s})}catch{throw new d("The document couldn't be uploaded to Dorvyn.",502)}if(!i.ok)throw new d("The document couldn't be uploaded to Dorvyn.",502);n=await l(e,`${o}/v1/export`,{grant:t.grant,ticket:r.ticket,upload:c.key},!1)}return new Uint8Array(await n.arrayBuffer())}const R=5*1024*1024;function _(t){const e=t.engine?.url??u("DORVYN_ENGINE_URL"),r=t.engine?.integrity??u("DORVYN_ENGINE_INTEGRITY");if(r&&!m.test(r))throw new d("The engine's integrity must be sha384-… (64 base64 characters).",500);const a=e||r?{...e&&{url:e},...r&&{integrity:r}}:void 0,o=(s,n)=>Response.json({message:n},{status:s,headers:{"cache-control":"no-store"}});return async s=>{try{const n=new URL(s.url).pathname.replace(/\/+$/,"").split("/").pop();if(s.method!=="POST")return o(405,"Method not allowed.");if(n!=="grant"&&n!=="export")return o(404,"Not found.");const c=s.headers.get("origin");if(!c)return o(400,"No Origin header.");if(t.origins&&!t.origins.includes(c))return o(403,"Not from an allowed page.");const i=await t.user(s);if(!i)return o(401,"Sign in to edit.");const f=await s.json().catch(()=>({}));if(n==="grant"){const v=await x({...t,origin:c,subject:i,request:f});return Response.json({...v,...a&&{engine:a}},{headers:{"cache-control":"no-store"}})}const h=y(f.grant);if(!h||h.sub!==i||h.origin!==c)return o(403,"That license is for another user or page.");const w=await E({...t,grant:f.grant,input:f.input});return new Response(w,{headers:{"content-type":k,"cache-control":"no-store"}})}catch(n){const c=n instanceof d?n.status:500;return c>=500&&console.error("Dorvyn route:",n instanceof Error?n.name:typeof n,n instanceof d?n.status:""),o(c,c>=500?"The editor's license isn't available right now.":String(n.message))}}}function D(t){return async(e,r)=>{let a;if(e.body!==void 0&&typeof e.body=="object"&&!(e.body instanceof Uint8Array))a=JSON.stringify(e.body);else{const c=[];for await(const i of e)c.push(typeof i=="string"?new TextEncoder().encode(i):i);a=new TextDecoder().decode(N(c))}const o=new Headers;for(const[c,i]of Object.entries(e.headers))typeof i=="string"&&o.set(c,i);const s=new URL(e.originalUrl??e.url??"/",`http://${e.headers.host??"localhost"}`),n=await t(new Request(s,{method:e.method??"POST",headers:o,body:e.method==="GET"?void 0:a}));r.writeHead(n.status,Object.fromEntries(n.headers)),r.end(new Uint8Array(await n.arrayBuffer()))}}function N(t){const e=new Uint8Array(t.reduce((a,o)=>a+o.length,0));let r=0;for(const a of t)e.set(a,r),r+=a.length;return e}function O(){const t=new Uint8Array(16);return globalThis.crypto.getRandomValues(t),[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}export{d as DorvynServerError,_ as dorvynRoutes,D as nodeHandler,E as requestExport,x as requestGrant};
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@dorvyn/server",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Dorvyn on your server: grants and exports for your signed-in users, with your secret key from the environment.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "author": "Dorvyn Pvt Ltd <support@dorvyn.dev>",
7
+ "homepage": "https://docs.dorvyn.dev/server-reference/",
8
+ "bugs": {
9
+ "email": "support@dorvyn.dev"
10
+ },
11
+ "keywords": [
12
+ "docx",
13
+ "word",
14
+ "document-editor",
15
+ "editor",
16
+ "dorvyn"
17
+ ],
18
+ "type": "module",
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "LICENSE",
29
+ "THIRD_PARTY_NOTICES.md",
30
+ "README.md"
31
+ ],
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "scripts": {
36
+ "build": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json && node ../core/scripts/minify-dist.mjs dist",
37
+ "typecheck": "tsc -p tsconfig.json --noEmit",
38
+ "test": "node --test src/*.test.ts"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ }
43
+ }