@noartem/xews 1.0.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/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ EWS_EMAIL=
2
+ EWS_PASSWORD=
3
+ EWS_URL=https://email.metib.ru/EWS/Exchange.asmx
package/LICENSE ADDED
@@ -0,0 +1,618 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the GNU
18
+ General Public License for most of our software; it applies also to any
19
+ other work released this way by its authors. You can apply it to your
20
+ programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the terms
212
+ of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the machine-readable
249
+ Corresponding Source under the terms of this License, in one of these
250
+ ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium customarily
255
+ used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a written
259
+ offer, valid for at least three years and valid for as long as you
260
+ offer spare parts or customer support for that product model, to give
261
+ anyone who possesses the object code either (1) a copy of the
262
+ Corresponding Source for all the software in the product that is
263
+ covered by this License, on a durable physical medium customarily used
264
+ for software interchange, for a price no more than your reasonable cost
265
+ of physically performing this conveying of source, or (2) access to
266
+ copy the Corresponding Source from a network server at no charge.
267
+
268
+ c) Convey individual copies of the object code with a copy of the
269
+ written offer to provide the Corresponding Source. This alternative is
270
+ allowed only occasionally and noncommercially, and only if you received
271
+ the object code with such an offer, in accord with subsection 6b.
272
+
273
+ d) Convey the object code by offering access from a designated place
274
+ (gratis or for a charge), and offer equivalent access to the
275
+ Corresponding Source in the same way through the same place at no
276
+ further charge. You need not require recipients to copy the
277
+ Corresponding Source along with the object code. If the place to copy
278
+ the object code is a network server, the Corresponding Source may be on
279
+ a different server (operated by you or a third party) that supports
280
+ equivalent copying facilities, provided you maintain clear directions
281
+ next to the object code saying where to find the Corresponding Source.
282
+ Regardless of what server hosts the Corresponding Source, you remain
283
+ obligated to ensure that it is available for as long as needed to
284
+ satisfy these requirements.
285
+
286
+ e) Convey the object code using peer-to-peer transmission, provided
287
+ you inform other peers where the object code and Corresponding Source
288
+ of the work are being offered to the general public at no charge under
289
+ subsection 6d.
290
+
291
+ A separable portion of the object code, whose source code is excluded
292
+ from the Corresponding Source as a System Library, need not be included
293
+ in conveying the object code work.
294
+
295
+ A "User Product" is either (1) a "consumer product", which means any
296
+ tangible personal property which is normally used for personal, family,
297
+ or household purposes, or (2) anything designed or sold for incorporation
298
+ into a dwelling. In determining whether a product is a consumer product,
299
+ doubtful cases shall be resolved in favor of coverage. For a particular
300
+ product received by a particular user, "normally used" refers to a
301
+ typical or common use of that class of product, regardless of the status
302
+ of the particular user or of the way in which the particular user
303
+ actually uses, or expects or is expected to use, the product. A product
304
+ is a consumer product regardless of whether the product has substantial
305
+ commercial, industrial or non-consumer uses, unless such uses represent
306
+ the only significant mode of use of the product.
307
+
308
+ "Installation Information" for a User Product means any methods,
309
+ procedures, authorization keys, or other information required to install
310
+ and execute modified versions of a covered work in that User Product from
311
+ a modified version of its Corresponding Source. The information must
312
+ suffice to ensure that the continued functioning of the modified object
313
+ code is in no case prevented or interfered with solely because
314
+ modification has been made.
315
+
316
+ If you convey an object code work under this section in, or with, or
317
+ specifically for use in, a User Product, and the conveying occurs as
318
+ part of a transaction in which the right of possession and use of the
319
+ User Product is transferred to the recipient in perpetuity or for a
320
+ fixed term (regardless of how the transaction is characterized), the
321
+ Corresponding Source conveyed under this section must be accompanied by
322
+ the Installation Information. But this requirement does not apply if
323
+ neither you nor any third party retains the ability to install modified
324
+ object code on the User Product (for example, the work has been
325
+ installed in ROM).
326
+
327
+ The requirement to provide Installation Information does not include a
328
+ requirement to continue to provide support service, warranty, or updates
329
+ for a work that has been modified or installed by the recipient, or for
330
+ the User Product in which it has been modified or installed. Access to a
331
+ network may be denied when the modification itself materially and
332
+ adversely affects the operation of the network or violates the rules and
333
+ protocols for communication across the network.
334
+
335
+ Corresponding Source conveyed, and Installation Information provided,
336
+ in accord with this section must be in a format that is publicly
337
+ documented (and with an implementation available to the public in source
338
+ code form), and must require no special password or key for unpacking,
339
+ reading or copying.
340
+
341
+ 7. Additional Terms.
342
+
343
+ "Additional permissions" are terms that supplement the terms of this
344
+ License by making exceptions from one or more of its conditions.
345
+ Additional permissions that are applicable to the entire Program shall
346
+ be treated as though they were included in this License, to the extent
347
+ that they are valid under applicable law. If additional permissions
348
+ apply only to part of the Program, that part may be used separately
349
+ under those permissions, but the entire Program remains governed by this
350
+ License without regard to the additional permissions.
351
+
352
+ When you convey a copy of a covered work, you may at your option
353
+ remove any additional permissions from that copy, or from any part of
354
+ it. (Additional permissions may be written to require their own removal
355
+ in certain cases when you modify the work.) You may place additional
356
+ permissions on material, added by you to a covered work, for which you
357
+ have or can give appropriate copyright permission.
358
+
359
+ Notwithstanding any other provision of this License, for material you
360
+ add to a covered work, you may (if authorized by the copyright holders of
361
+ that material) supplement the terms of this License with terms:
362
+
363
+ a) Disclaiming warranty or limiting liability differently from the
364
+ terms of sections 15 and 16 of this License; or
365
+
366
+ b) Requiring preservation of specified reasonable legal notices or
367
+ author attributions in that material or in the Appropriate Legal Notices
368
+ displayed by works containing it; or
369
+
370
+ c) Prohibiting misrepresentation of the origin of that material, or
371
+ requiring that modified versions of such material be marked in
372
+ reasonable ways as different from the original version; or
373
+
374
+ d) Limiting the use for publicity purposes of names of licensors or
375
+ authors of the material; or
376
+
377
+ e) Declining to grant rights under trademark law for use of some trade
378
+ names, trademarks, or service marks; or
379
+
380
+ f) Requiring indemnification of licensors and authors of that material
381
+ by anyone who conveys the material (or modified versions of it) with
382
+ contractual assumptions of liability to the recipient, for any liability
383
+ that these contractual assumptions directly impose on those licensors and
384
+ authors.
385
+
386
+ All other non-permissive additional terms are considered "further
387
+ restrictions" within the meaning of section 10. If the Program as you
388
+ received it, or any part of it, contains a notice stating that it is
389
+ governed by this License along with a term that is a further restriction,
390
+ you may remove that term. If a license document contains a further
391
+ restriction but permits relicensing or conveying under this License, you
392
+ may add to a covered work material governed by the terms of that license
393
+ document, provided that the further restriction does not survive such
394
+ relicensing or conveying.
395
+
396
+ If you add terms to a covered work in accord with this section, you
397
+ must place, in the relevant source files, a statement of the additional
398
+ terms that apply to those files, or a notice indicating where to find
399
+ the applicable terms.
400
+
401
+ Additional terms, permissive or non-permissive, may be stated in the
402
+ form of a separately written license, or stated as exceptions; the above
403
+ requirements apply either way.
404
+
405
+ 8. Termination.
406
+
407
+ You may not propagate or modify a covered work except as expressly
408
+ provided under this License. Any attempt otherwise to propagate or
409
+ modify it is void, and will automatically terminate your rights under
410
+ this License (including any patent licenses granted under the third
411
+ paragraph of section 11).
412
+
413
+ However, if you cease all violation of this License, then your license
414
+ from a particular copyright holder is reinstated (a) provisionally,
415
+ unless and until the copyright holder explicitly and finally terminates
416
+ your license, and (b) permanently, if the copyright holder fails to
417
+ notify you of the violation by some reasonable means prior to 60 days
418
+ after the cessation.
419
+
420
+ Moreover, your license from a particular copyright holder is reinstated
421
+ permanently if the copyright holder notifies you of the violation by some
422
+ reasonable means, this is the first time you have received notice of
423
+ violation of this License (for any work) from that copyright holder, and
424
+ you cure the violation prior to 30 days after your receipt of the notice.
425
+
426
+ Termination of your rights under this section does not terminate the
427
+ licenses of parties who have received copies or rights from you under
428
+ this License. If your rights have been terminated and not permanently
429
+ reinstated, you do not qualify to receive new licenses for the same
430
+ material under section 10.
431
+
432
+ 9. Acceptance Not Required for Having Copies.
433
+
434
+ You are not required to accept this License in order to receive or run
435
+ a copy of the Program. Ancillary propagation of a covered work occurring
436
+ solely as a consequence of using peer-to-peer transmission to receive a
437
+ copy likewise does not require acceptance. However, nothing other than
438
+ this License grants you permission to propagate or modify any covered
439
+ work. These actions infringe copyright if you do not accept this
440
+ License. Therefore, by modifying or propagating a covered work, you
441
+ indicate your acceptance of this License to do so.
442
+
443
+ 10. Automatic Licensing of Downstream Recipients.
444
+
445
+ Each time you convey a covered work, the recipient automatically
446
+ receives a license from the original licensors, to run, modify and
447
+ propagate that work, subject to this License. You are not responsible
448
+ for enforcing compliance by third parties with this License.
449
+
450
+ An "entity transaction" is a transaction transferring control of an
451
+ organization, or substantially all assets of one, or subdividing an
452
+ organization, or merging organizations. If propagation of a covered work
453
+ results from an entity transaction, each party to that transaction who
454
+ receives a copy of the work also receives whatever licenses to the work
455
+ the party's predecessor in interest had or could give under the previous
456
+ paragraph, plus a right to possession of the Corresponding Source of the
457
+ work from the predecessor in interest, if the predecessor has it or can
458
+ get it with reasonable efforts.
459
+
460
+ You may not impose any further restrictions on the exercise of the
461
+ rights granted or affirmed under this License. For example, you may not
462
+ impose a license fee, royalty, or other charge for exercise of rights
463
+ granted under this License, and you may not initiate litigation
464
+ (including a cross-claim or counterclaim in a lawsuit) alleging that any
465
+ patent claim is infringed by making, using, selling, offering for sale,
466
+ or importing the Program or any portion of it.
467
+
468
+ 11. Patents.
469
+
470
+ A "contributor" is a copyright holder who authorizes use under this
471
+ License of the Program or a work on which the Program is based. The work
472
+ thus licensed is called the contributor's "contributor version".
473
+
474
+ A contributor's "essential patent claims" are all patent claims owned
475
+ or controlled by the contributor, whether already acquired or hereafter
476
+ acquired, that would be infringed by some manner, permitted by this
477
+ License, of making, using, or selling its contributor version, but do
478
+ not include claims that would be infringed only as a consequence of
479
+ further modification of the contributor version. For purposes of this
480
+ definition, "control" includes the right to grant patent sublicenses in
481
+ a manner consistent with the requirements of this License.
482
+
483
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
484
+ patent license under the contributor's essential patent claims, to make,
485
+ use, sell, offer for sale, import and otherwise run, modify and
486
+ propagate the contents of its contributor version.
487
+
488
+ In the following three paragraphs, a "patent license" is any express
489
+ agreement or commitment, however denominated, not to enforce a patent
490
+ (such as an express permission to practice a patent or covenant not to
491
+ sue for patent infringement). To "grant" such a patent license to a
492
+ party means to make such an agreement or commitment not to enforce a
493
+ patent against the party.
494
+
495
+ If you convey a covered work, knowingly relying on a patent license,
496
+ and the Corresponding Source of the work is not available for anyone to
497
+ copy, free of charge and under the terms of this License, through a
498
+ publicly available network server or other readily accessible means,
499
+ then you must either (1) cause the Corresponding Source to be so
500
+ available, or (2) arrange to deprive yourself of the benefit of the
501
+ patent license for this particular work, or (3) arrange, in a manner
502
+ consistent with the requirements of this License, to extend the patent
503
+ license to downstream recipients. "Knowingly relying" means you have
504
+ actual knowledge that, but for the patent license, your conveying the
505
+ covered work in a country, or your recipient's use of the covered work
506
+ in a country, would infringe one or more identifiable patents in that
507
+ country that you have reason to believe are valid.
508
+
509
+ If, pursuant to or in connection with a single transaction or
510
+ arrangement, you convey, or propagate by procuring conveyance of, a
511
+ covered work, and grant a patent license to some of the parties
512
+ receiving the covered work authorizing them to use, propagate, modify
513
+ or convey a specific copy of the covered work, then the patent license
514
+ you grant is automatically extended to all recipients of the covered
515
+ work and works based on it.
516
+
517
+ A patent license is "discriminatory" if it does not include within the
518
+ scope of its coverage, prohibits the exercise of, or is conditioned on
519
+ the non-exercise of one or more of the rights that are specifically
520
+ granted under this License. You may not convey a covered work if you are
521
+ a party to an arrangement with a third party that is in the business of
522
+ distributing software, under which you make payment to the third party
523
+ based on the extent of your activity of conveying the work, and under
524
+ which the third party grants, to any of the parties who would receive
525
+ the covered work from you, a discriminatory patent license (a) in
526
+ connection with copies of the covered work conveyed by you (or copies
527
+ made from those copies), or (b) primarily for and in connection with
528
+ specific products or compilations that contain the covered work, unless
529
+ you entered into that arrangement, or that patent license was granted,
530
+ prior to 28 March 2007.
531
+
532
+ Nothing in this License shall be construed as excluding or limiting
533
+ any implied license or other defenses to infringement that may otherwise
534
+ be available to you under applicable patent law.
535
+
536
+ 12. No Surrender of Others' Freedom.
537
+
538
+ If conditions are imposed on you (whether by court order, agreement or
539
+ otherwise) that contradict the conditions of this License, they do not
540
+ excuse you from the conditions of this License. If you cannot convey a
541
+ covered work so as to satisfy simultaneously your obligations under this
542
+ License and any other pertinent obligations, then as a consequence you
543
+ may not convey it at all. For example, if you agree to terms that
544
+ obligate you to collect a royalty for further conveying from those to
545
+ whom you convey the Program, the only way you could satisfy both those
546
+ terms and this License would be to refrain entirely from conveying the
547
+ Program.
548
+
549
+ 13. Use with the GNU Affero General Public License.
550
+
551
+ Notwithstanding any other provision of this License, you have
552
+ permission to link or combine any covered work with a work licensed
553
+ under version 3 of the GNU Affero General Public License into a single
554
+ combined work, and to convey the resulting work. The terms of this
555
+ License will continue to apply to the part which is the covered work,
556
+ but the special requirements of the GNU Affero General Public License,
557
+ section 13, concerning interaction through a network will apply to the
558
+ combination as such.
559
+
560
+ 14. Revised Versions of this License.
561
+
562
+ The Free Software Foundation may publish revised and/or new versions of
563
+ the GNU General Public License from time to time. Such new versions will
564
+ be similar in spirit to the present version, but may differ in detail to
565
+ address new problems or concerns.
566
+
567
+ Each version is given a distinguishing version number. If the Program
568
+ specifies that a certain numbered version of the GNU General Public
569
+ License "or any later version" applies to it, you have the option of
570
+ following the terms and conditions either of that numbered version or of
571
+ any later version published by the Free Software Foundation. If the
572
+ Program does not specify a version number of the GNU General Public
573
+ License, you may choose any version ever published by the Free Software
574
+ Foundation.
575
+
576
+ If the Program specifies that a proxy can decide which future versions
577
+ of the GNU General Public License can be used, that proxy's public
578
+ statement of acceptance of a version permanently authorizes you to
579
+ choose that version for the Program.
580
+
581
+ Later license versions may give you additional or different
582
+ permissions. However, no additional obligations are imposed on any
583
+ author or copyright holder as a result of your choosing to follow a
584
+ later version.
585
+
586
+ 15. Disclaimer of Warranty.
587
+
588
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
589
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
590
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
591
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
592
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
593
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
594
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
595
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
596
+
597
+ 16. Limitation of Liability.
598
+
599
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
600
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
601
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
602
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
603
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
604
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
605
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
606
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
607
+ SUCH DAMAGES.
608
+
609
+ 17. Interpretation of Sections 15 and 16.
610
+
611
+ If the disclaimer of warranty and limitation of liability provided
612
+ above cannot be given local legal effect according to their terms,
613
+ reviewing courts shall apply local law that most closely approximates
614
+ an absolute waiver of all civil liability in connection with the
615
+ Program, unless a warranty or assumption of liability accompanies a
616
+ copy of the Program in return for a fee.
617
+
618
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # @noartem/xews
2
+
3
+ `xews` is a small CLI for transferring files through Exchange Web Services by using attachments on the first draft message.
4
+
5
+ It is useful when you already have EWS access and want a simple way to upload, list, download, and clear files through Exchange without opening a mail client.
6
+
7
+ ## Install
8
+
9
+ Install from a local checkout:
10
+
11
+ ```bash
12
+ npm link
13
+ ```
14
+
15
+ After that, the CLI is available globally as:
16
+
17
+ ```bash
18
+ xews
19
+ ```
20
+
21
+ Install from npm after publishing:
22
+
23
+ ```bash
24
+ npm install -g xews
25
+ ```
26
+
27
+ ## Configuration
28
+
29
+ You can let `xews` create and open the config for you:
30
+
31
+ ```bash
32
+ xews init
33
+ ```
34
+
35
+ Or create `~/.config/xews/auth.json` manually:
36
+
37
+ ```json
38
+ {
39
+ "email": "user@example.com",
40
+ "password": "your-password",
41
+ "url": "https://exchange.example.com/EWS/Exchange.asmx"
42
+ }
43
+ ```
44
+
45
+ Required fields:
46
+
47
+ - `email`
48
+ - `password`
49
+ - `url`
50
+
51
+ `xews init` opens the file in your default terminal editor. It first checks `VISUAL`, then `EDITOR`, and falls back to `vi`.
52
+
53
+ ## Usage
54
+
55
+ Typical file transfer flow:
56
+
57
+ ```bash
58
+ xews upload --file ./archive.zip
59
+ xews ls
60
+ xews download
61
+ ```
62
+
63
+ Show help:
64
+
65
+ ```bash
66
+ xews --help
67
+ ```
68
+
69
+ Upload one or more files to the first draft:
70
+
71
+ ```bash
72
+ xews upload --file ./file1.txt --file ./file2.pdf
73
+ ```
74
+
75
+ Download all attachments from the first draft into the current directory:
76
+
77
+ ```bash
78
+ xews download
79
+ ```
80
+
81
+ Download attachments and delete the draft after download:
82
+
83
+ ```bash
84
+ xews download --delete
85
+ ```
86
+
87
+ List attachments from the first draft:
88
+
89
+ ```bash
90
+ xews list
91
+ xews ls
92
+ ```
93
+
94
+ Clear all attachments from the first draft:
95
+
96
+ ```bash
97
+ xews clear
98
+ ```
99
+
100
+ ## Commands
101
+
102
+ - `init`: create `~/.config/xews/auth.json` if needed and open it in your default editor
103
+ - `upload`: attach one or more files to the first draft
104
+ - `download`: download all file attachments from the first draft into the current directory
105
+ - `list` / `ls`: show attachment names and sizes from the first draft
106
+ - `clear`: remove all attachments from the first draft
107
+
108
+ ## Publish
109
+
110
+ Preview the package contents:
111
+
112
+ ```bash
113
+ npm pack --dry-run
114
+ ```
115
+
116
+ Publish to npm:
117
+
118
+ ```bash
119
+ npm publish
120
+ ```
121
+
122
+ For a scoped public package:
123
+
124
+ ```bash
125
+ npm publish --access public
126
+ ```
package/index.js ADDED
@@ -0,0 +1,277 @@
1
+ #!/usr/bin/env node
2
+
3
+ import * as os from "os";
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
+ import { spawnSync } from "child_process";
7
+
8
+ import {
9
+ ExchangeService,
10
+ ExchangeVersion,
11
+ WebCredentials,
12
+ Uri,
13
+ WellKnownFolderName,
14
+ ItemView,
15
+ EmailMessage,
16
+ PropertySet,
17
+ BasePropertySet,
18
+ FileAttachment,
19
+ DeleteMode,
20
+ MessageBody,
21
+ } from "ews-javascript-api";
22
+
23
+ import { Cli, z } from "incur";
24
+
25
+ const CLI_VERSION = "1.0.0";
26
+ const CONFIG_PATH = path.join(os.homedir(), ".config", "xews", "auth.json");
27
+ const DEFAULT_CONFIG = `${JSON.stringify(
28
+ {
29
+ email: "user@example.com",
30
+ password: "your-password",
31
+ url: "https://exchange.example.com/EWS/Exchange.asmx",
32
+ },
33
+ null,
34
+ 2,
35
+ )}\n`;
36
+
37
+ function getEditor() {
38
+ return (
39
+ process.env.VISUAL || process.env.EDITOR || process.env.GIT_EDITOR || "vi"
40
+ );
41
+ }
42
+
43
+ function ensureConfigFile() {
44
+ fs.mkdirSync(path.dirname(CONFIG_PATH), { recursive: true });
45
+
46
+ if (!fs.existsSync(CONFIG_PATH)) {
47
+ fs.writeFileSync(CONFIG_PATH, DEFAULT_CONFIG);
48
+ }
49
+
50
+ return CONFIG_PATH;
51
+ }
52
+
53
+ function openInEditor(filePath) {
54
+ const editor = getEditor();
55
+
56
+ const result = spawnSync(`${editor} ${JSON.stringify(filePath)}`, {
57
+ shell: true,
58
+ stdio: "inherit",
59
+ });
60
+
61
+ if (result.error) {
62
+ throw result.error;
63
+ }
64
+
65
+ if (result.status !== 0) {
66
+ throw new Error(`Editor exited with code ${result.status}`);
67
+ }
68
+ }
69
+
70
+ function loadConfig() {
71
+ const configPath = CONFIG_PATH;
72
+
73
+ if (!fs.existsSync(configPath)) {
74
+ throw new Error(`Config not found: ${configPath}`);
75
+ }
76
+
77
+ const raw = fs.readFileSync(configPath, "utf-8");
78
+ const cfg = JSON.parse(raw);
79
+
80
+ if (!cfg.email || !cfg.password || !cfg.url) {
81
+ throw new Error("Invalid config: email/password/url required");
82
+ }
83
+
84
+ return cfg;
85
+ }
86
+
87
+ function createService() {
88
+ const cfg = loadConfig();
89
+
90
+ const service = new ExchangeService(ExchangeVersion.Exchange2016);
91
+
92
+ service.Credentials = new WebCredentials(cfg.email, cfg.password);
93
+
94
+ service.Url = new Uri(cfg.url);
95
+
96
+ return service;
97
+ }
98
+
99
+ async function getOrCreateDraft(service) {
100
+ const res = await service.FindItems(
101
+ WellKnownFolderName.Drafts,
102
+ new ItemView(1),
103
+ );
104
+
105
+ if (res.Items.length === 0) {
106
+ const draft = new EmailMessage(service);
107
+ draft.Subject = "Auto draft";
108
+ draft.Body = new MessageBody("Generated");
109
+
110
+ await draft.Save(WellKnownFolderName.Drafts);
111
+ return draft;
112
+ }
113
+
114
+ const draft = res.Items[0];
115
+ await draft.Load(new PropertySet(BasePropertySet.FirstClassProperties));
116
+ return draft;
117
+ }
118
+
119
+ async function getFirstDraft(service) {
120
+ const res = await service.FindItems(
121
+ WellKnownFolderName.Drafts,
122
+ new ItemView(1),
123
+ );
124
+
125
+ if (res.Items.length === 0) return null;
126
+
127
+ const draft = res.Items[0];
128
+ await draft.Load(new PropertySet(BasePropertySet.FirstClassProperties));
129
+ return draft;
130
+ }
131
+
132
+ /* ================= ENTRY ================= */
133
+
134
+ const cli = Cli.create("xews", {
135
+ description:
136
+ "Upload and download draft attachments via Exchange Web Services",
137
+ version: CLI_VERSION,
138
+ });
139
+
140
+ cli.command("init", {
141
+ description: "Create auth config if needed and open it in editor",
142
+ async run() {
143
+ const configPath = ensureConfigFile();
144
+ openInEditor(configPath);
145
+ },
146
+ });
147
+
148
+ cli.command("upload", {
149
+ description: "Attach one or more files to a draft",
150
+ options: z.object({
151
+ file: z
152
+ .array(z.string())
153
+ .default([])
154
+ .describe("File path to attach. Repeat --file for multiple files."),
155
+ }),
156
+ alias: { file: "f" },
157
+ async run(c) {
158
+ if (c.options.file.length === 0) {
159
+ return c.error({
160
+ code: "USAGE",
161
+ message: "Provide at least one file with --file <path>",
162
+ });
163
+ }
164
+
165
+ const service = createService();
166
+ const draft = await getOrCreateDraft(service);
167
+
168
+ for (const file of c.options.file) {
169
+ if (!fs.existsSync(file)) {
170
+ console.warn("Skip missing:", file);
171
+ continue;
172
+ }
173
+
174
+ const content = fs.readFileSync(file);
175
+ const name = path.basename(file);
176
+
177
+ draft.Attachments.AddFileAttachment(name, content.toString("base64"));
178
+
179
+ console.log("Attached:", name);
180
+ }
181
+
182
+ await draft.Update(null);
183
+ console.log("Done");
184
+ },
185
+ });
186
+
187
+ cli.command("download", {
188
+ description: "Download attachments from the first draft",
189
+ options: z.object({
190
+ delete: z
191
+ .boolean()
192
+ .default(false)
193
+ .describe("Delete the draft after download"),
194
+ }),
195
+ async run(c) {
196
+ const service = createService();
197
+ const draft = await getFirstDraft(service);
198
+
199
+ if (!draft) {
200
+ console.log("No drafts found");
201
+ return;
202
+ }
203
+
204
+ if (!draft.HasAttachments) {
205
+ console.log("No attachments");
206
+ return;
207
+ }
208
+
209
+ for (const att of draft.Attachments.Items) {
210
+ if (!(att instanceof FileAttachment)) continue;
211
+
212
+ await att.Load();
213
+
214
+ if (!att.Base64Content) {
215
+ console.warn("Empty:", att.Name);
216
+ continue;
217
+ }
218
+
219
+ fs.writeFileSync(att.Name, Buffer.from(att.Base64Content, "base64"));
220
+ console.log("Downloaded:", att.Name);
221
+ }
222
+
223
+ if (c.options.delete) {
224
+ await draft.Delete(DeleteMode.MoveToDeletedItems);
225
+ console.log("Draft deleted");
226
+ }
227
+ },
228
+ });
229
+
230
+ cli.command("list", {
231
+ description: "List attachments from the first draft",
232
+ aliases: ["ls"],
233
+ async run() {
234
+ const service = createService();
235
+ const draft = await getFirstDraft(service);
236
+
237
+ if (!draft) {
238
+ console.log("No drafts found");
239
+ return;
240
+ }
241
+
242
+ if (!draft.HasAttachments) {
243
+ console.log("No attachments");
244
+ return;
245
+ }
246
+
247
+ for (const att of draft.Attachments.Items) {
248
+ const size = typeof att.Size === "number" ? att.Size : "-";
249
+ console.log(`${size}\t${att.Name}`);
250
+ }
251
+ },
252
+ });
253
+
254
+ cli.command("clear", {
255
+ description: "Delete all attachments from the first draft",
256
+ async run() {
257
+ const service = createService();
258
+ const draft = await getFirstDraft(service);
259
+
260
+ if (!draft) {
261
+ console.log("No drafts found");
262
+ return;
263
+ }
264
+
265
+ if (!draft.HasAttachments) {
266
+ console.log("No attachments");
267
+ return;
268
+ }
269
+
270
+ draft.Attachments.Clear();
271
+ await draft.Update(null);
272
+
273
+ console.log("Attachments cleared");
274
+ },
275
+ });
276
+
277
+ await cli.serve();
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@noartem/xews",
3
+ "version": "1.0.0",
4
+ "description": "CLI for transferring files through Exchange drafts over EWS",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "check": "prettier -c .",
8
+ "fix": "prettier -w ."
9
+ },
10
+ "bin": {
11
+ "xews": "./index.js"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "LICENSE",
16
+ "README.md",
17
+ ".env.example"
18
+ ],
19
+ "keywords": [
20
+ "ews",
21
+ "exchange",
22
+ "cli",
23
+ "attachments",
24
+ "drafts"
25
+ ],
26
+ "author": "Artem Noskov <artem@noartem.ru>",
27
+ "license": "GPL-3.0-or-later",
28
+ "type": "module",
29
+ "dependencies": {
30
+ "ews-javascript-api": "^0.15.3",
31
+ "incur": "^0.3.25"
32
+ },
33
+ "devDependencies": {
34
+ "prettier": "^3.8.1"
35
+ }
36
+ }