24fire-api 1.0.7 → 2.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/LICENSE +201 -201
- package/README.md +167 -65
- package/package.json +33 -24
- package/src/index.d.ts +135 -0
- package/src/index.js +290 -105
package/LICENSE
CHANGED
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -3,115 +3,217 @@
|
|
|
3
3
|
|
|
4
4
|
# 24fire-api
|
|
5
5
|
|
|
6
|
+
Ein einfacher Node.js-Wrapper für die **24fire REST-API v2**.
|
|
7
|
+
Verwalte deinen Account, KVM-Server, Domains und Webspaces direkt aus deinem Code.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## Features
|
|
8
10
|
|
|
11
|
+
- 🔗 Kommunikation über SSL (`https://manage.24fire.de/api`)
|
|
12
|
+
- 📦 **Keine Abhängigkeiten** nutzt das eingebaute `fetch` von Node.js
|
|
13
|
+
- 🧩 Intuitive, verschachtelte Bedienung (`fire.kvm(id).backup.list()`)
|
|
14
|
+
- 🟦 Mitgelieferte TypeScript-Typen
|
|
15
|
+
- ⚡ Schnell & leichtgewichtig
|
|
9
16
|
|
|
10
|
-
|
|
17
|
+
> **Hinweis:** Dies ist Version **2.0**. Die API-Struktur hat sich gegenüber v1 komplett geändert
|
|
18
|
+
> (neue Base-URL, neuer Auth-Header, `internal_id` pro Dienst). Siehe [Migration von v1](#migration-von-v1).
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
- 🏃 Schnelle interaktion
|
|
14
|
-
- ➡️ Direkte Anfragen ohne Middelware
|
|
15
|
-
- ℹ️ Einfache Bedienung
|
|
20
|
+
## Voraussetzungen
|
|
16
21
|
|
|
22
|
+
- Node.js **18 oder neuer** (wegen des globalen `fetch`)
|
|
17
23
|
|
|
18
|
-
##
|
|
24
|
+
## Installation
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
```bash
|
|
27
|
+
npm install 24fire-api
|
|
28
|
+
```
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
## API-Key erstellen
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
## Empfehlenswert
|
|
32
|
+
1. Logge dich im [24fire Control Panel](https://manage.24fire.de) ein.
|
|
33
|
+
2. Gehe zu **Einstellungen → API-Keys** und klicke auf „API-Key erstellen“.
|
|
34
|
+
3. Speichere den Key sicher ab – er wird nur **einmal** angezeigt.
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
- [24fire](https://24fire.de/)
|
|
31
|
-
- [Discord](https://discord.gg/24fire)
|
|
36
|
+
## Schnellstart
|
|
32
37
|
|
|
38
|
+
```javascript
|
|
39
|
+
const FireAPI = require('24fire-api');
|
|
40
|
+
// oder: import FireAPI from '24fire-api';
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
const fire = new FireAPI('DEIN_API_KEY');
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
// Account-Infos abrufen
|
|
45
|
+
const account = await fire.account.info();
|
|
46
|
+
console.log(account.data);
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
// Alle Dienste anzeigen (hier findest du die internal_id jedes Dienstes)
|
|
49
|
+
const services = await fire.account.services();
|
|
50
|
+
console.log(services.data);
|
|
51
|
+
|
|
52
|
+
// Einen Server starten
|
|
53
|
+
await fire.kvm('INTERNAL_ID').start();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Jede Methode gibt die API-Antwort im Format `{ status, message, data }` zurück.
|
|
57
|
+
Bei Fehlern wird ein `FireAPIError` geworfen (siehe [Fehlerbehandlung](#fehlerbehandlung)).
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Account
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
await fire.account.info(); // Account-Informationen (Name, E-Mail, Guthaben …)
|
|
65
|
+
await fire.account.services(); // Übersicht aller aktiven Dienste (mit internal_id)
|
|
66
|
+
await fire.account.donations(); // Daten zur Spendenseite
|
|
67
|
+
await fire.account.affiliate(); // Daten zum Affiliate-System
|
|
40
68
|
```
|
|
41
69
|
|
|
70
|
+
## KVM-Server
|
|
42
71
|
|
|
43
|
-
|
|
72
|
+
Zuerst einen Server über seine `internal_id` auswählen:
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
#### 2. Öffne das Menu durch den Buttn mit den drei Strichen
|
|
49
|
-

|
|
50
|
-
#### 3. Klicke auf "API-Key anzeigen"
|
|
51
|
-

|
|
52
|
-
#### 4. Nun sollte dieses Modal erscheinen, hier kannst du den API-Key kopieren
|
|
53
|
-
## Wie verwende ich fireapi-24fire?
|
|
74
|
+
```javascript
|
|
75
|
+
const vm = fire.kvm('INTERNAL_ID');
|
|
76
|
+
```
|
|
54
77
|
|
|
78
|
+
### Allgemein
|
|
55
79
|
|
|
56
|
-
|
|
80
|
+
```javascript
|
|
81
|
+
await vm.config(); // Konfiguration (Hardware, IPs, OS …)
|
|
82
|
+
await vm.status(); // Status & Auslastung (running / stopped / …)
|
|
83
|
+
|
|
84
|
+
await vm.power('start'); // Power-Aktion: 'start' | 'stop' | 'restart'
|
|
85
|
+
await vm.start(); // Kurzform für power('start')
|
|
86
|
+
await vm.stop(); // Kurzform für power('stop')
|
|
87
|
+
await vm.restart(); // Kurzform für power('restart')
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Backups
|
|
57
91
|
|
|
58
92
|
```javascript
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
93
|
+
await vm.backup.list(); // Alle Backups auflisten
|
|
94
|
+
await vm.backup.create('Notiz'); // Backup erstellen (24fire+), Notiz optional, max. 24 Zeichen
|
|
95
|
+
await vm.backup.createStatus('BACKUP_ID'); // Status der Erstellung abfragen
|
|
96
|
+
await vm.backup.restore('BACKUP_ID'); // Backup wiederherstellen (24fire+)
|
|
97
|
+
await vm.backup.restoreStatus('BACKUP_ID'); // Status der Wiederherstellung abfragen
|
|
98
|
+
await vm.backup.delete('BACKUP_ID'); // Backup löschen
|
|
62
99
|
```
|
|
63
100
|
|
|
101
|
+
### Traffic
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
await vm.traffic.current(); // Aktueller Traffic-Verbrauch des Monats
|
|
105
|
+
await vm.traffic.log(); // Traffic-Log (Messung alle 10 Minuten)
|
|
106
|
+
|
|
107
|
+
// Traffic-Diagramm generieren (24fire+)
|
|
108
|
+
await vm.traffic.chart({
|
|
109
|
+
type: 'both', // Eingehend / Ausgehend / Beides
|
|
110
|
+
summary: 'DAILY', // DAILY | HOURLY | NONE
|
|
111
|
+
output: 'apexcharts', // chartjs | apexcharts | base64
|
|
112
|
+
datapoints: 30,
|
|
113
|
+
size: '900x300',
|
|
114
|
+
});
|
|
115
|
+
```
|
|
64
116
|
|
|
117
|
+
### Monitoring
|
|
65
118
|
|
|
66
|
-
|
|
119
|
+
```javascript
|
|
120
|
+
await vm.monitoring.timings(); // Messungen abrufen
|
|
121
|
+
await vm.monitoring.incidences(); // Ausfälle abrufen
|
|
122
|
+
```
|
|
67
123
|
|
|
68
|
-
|
|
124
|
+
### DDoS (24fire+)
|
|
69
125
|
|
|
70
126
|
```javascript
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
127
|
+
await vm.ddos.get(); // Aktuelle DDoS-Einstellungen abrufen
|
|
128
|
+
await vm.ddos.change({
|
|
129
|
+
layer4: 'permanent',
|
|
130
|
+
layer7: 'on',
|
|
131
|
+
ip_address: '88.151.194.253', // optional; ohne Angabe gilt es für alle IPv4 der VM
|
|
132
|
+
});
|
|
76
133
|
```
|
|
77
134
|
|
|
78
|
-
|
|
135
|
+
## Domains
|
|
79
136
|
|
|
80
137
|
```javascript
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
138
|
+
const domain = fire.domain('INTERNAL_ID');
|
|
139
|
+
|
|
140
|
+
await domain.info(); // Domain-Informationen
|
|
141
|
+
await domain.dns.list(); // Alle DNS-Einträge
|
|
142
|
+
|
|
143
|
+
// DNS-Eintrag hinzufügen (24fire+)
|
|
144
|
+
await domain.dns.add({ type: 'A', name: '*', data: '1.2.3.4' });
|
|
145
|
+
|
|
146
|
+
// DNS-Eintrag bearbeiten (24fire+)
|
|
147
|
+
await domain.dns.edit({ record_id: 'RECORD_ID', data: '5.6.7.8' });
|
|
148
|
+
|
|
149
|
+
// DNS-Eintrag entfernen
|
|
150
|
+
await domain.dns.remove('RECORD_ID');
|
|
86
151
|
```
|
|
87
152
|
|
|
88
|
-
|
|
153
|
+
## Webspace
|
|
89
154
|
|
|
90
155
|
```javascript
|
|
91
|
-
|
|
92
|
-
console.log('Antwort: ', data);
|
|
93
|
-
}).catch(error => {
|
|
94
|
-
console.error('Fehler: ', error);
|
|
95
|
-
});
|
|
156
|
+
await fire.webspace('INTERNAL_ID').info(); // Webspace-Daten abrufen
|
|
96
157
|
```
|
|
97
158
|
|
|
98
|
-
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Fehlerbehandlung
|
|
162
|
+
|
|
163
|
+
Schlägt eine Anfrage fehl (HTTP-Fehler oder `status: "error"`), wird ein `FireAPIError` geworfen:
|
|
99
164
|
|
|
100
165
|
```javascript
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
166
|
+
const { FireAPIError } = require('24fire-api');
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
await fire.kvm('INTERNAL_ID').start();
|
|
170
|
+
} catch (err) {
|
|
171
|
+
if (err instanceof FireAPIError) {
|
|
172
|
+
console.error('API-Fehler:', err.message);
|
|
173
|
+
console.error('HTTP-Status:', err.status);
|
|
174
|
+
console.error('Antwort:', err.response);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
106
177
|
```
|
|
107
178
|
|
|
179
|
+
## Migration von v1
|
|
180
|
+
|
|
181
|
+
| | v1 (alt) | v2 (neu) |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| Base-URL | `https://api.24fire.de` | `https://manage.24fire.de/api` |
|
|
184
|
+
| Auth-Header | `X-FIRE-APIKEY` | `X-Fire-Apikey` |
|
|
185
|
+
| Server-Auswahl | global über den Key | pro Dienst über die `internal_id` |
|
|
186
|
+
| Abhängigkeiten | `axios` | keine (eingebautes `fetch`) |
|
|
108
187
|
|
|
109
|
-
|
|
188
|
+
**Beispiel:**
|
|
110
189
|
|
|
111
190
|
```javascript
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
191
|
+
// v1
|
|
192
|
+
myFireApi.vm().getVMstatus();
|
|
193
|
+
myFireApi.vm().startVM();
|
|
194
|
+
myFireApi.backup().listBackups();
|
|
195
|
+
|
|
196
|
+
// v2
|
|
197
|
+
fire.kvm('INTERNAL_ID').status();
|
|
198
|
+
fire.kvm('INTERNAL_ID').start();
|
|
199
|
+
fire.kvm('INTERNAL_ID').backup.list();
|
|
117
200
|
```
|
|
201
|
+
|
|
202
|
+
> Manche Endpunkte (z. B. DNS-Verwaltung, Backups erstellen/wiederherstellen, DDoS, Traffic-Chart)
|
|
203
|
+
> erfordern ein aktives **24fire+** Abonnement.
|
|
204
|
+
|
|
205
|
+
## Author & Credits
|
|
206
|
+
|
|
207
|
+
- Florian Linde <florian.linde@flostechnikwelt.de> (FlosTechnikwelt)
|
|
208
|
+
|
|
209
|
+
## Empfehlenswert
|
|
210
|
+
|
|
211
|
+
- [Offizielle API-Dokumentation (v2)](https://apidocs.24fire.de/v2)
|
|
212
|
+
- [24fire](https://24fire.de/)
|
|
213
|
+
- [Discord](https://discord.gg/24fire)
|
|
214
|
+
|
|
215
|
+
## Feedback
|
|
216
|
+
|
|
217
|
+
Wenn du Feedback hast, wende dich an mich unter support@flostechnikwelt.de
|
|
218
|
+
|
|
219
|
+
|
package/package.json
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "24fire-api",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "24fire-api",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Einfacher, abhängigkeitsfreier Node.js-Wrapper für die 24fire REST-API v2",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src/index.js",
|
|
9
|
+
"src/index.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/FlosTechnikwelt/24fire-api.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/FlosTechnikwelt/24fire-api.git",
|
|
19
|
+
"keywords": [
|
|
20
|
+
"24fire",
|
|
21
|
+
"24fireAPI",
|
|
22
|
+
"fireapi",
|
|
23
|
+
"api",
|
|
24
|
+
"v2",
|
|
25
|
+
"Hosting",
|
|
26
|
+
"kvm",
|
|
27
|
+
"wrapper",
|
|
28
|
+
"flostechnikwelt"
|
|
29
|
+
],
|
|
30
|
+
"author": "Florian Linde <florian.linde@flostechnikwelt.de>",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"dependencies": {}
|
|
33
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//███████╗██╗██████╗ ███████╗ █████╗ ██████╗ ██╗
|
|
2
|
+
//██╔════╝██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██║
|
|
3
|
+
//█████╗ ██║██████╔╝█████╗ ███████║██████╔╝██║
|
|
4
|
+
//██╔══╝ ██║██╔══██╗██╔══╝ ██╔══██║██╔═══╝ ██║
|
|
5
|
+
//██║ ██║██║ ██║███████╗██║ ██║██║ ██║
|
|
6
|
+
//╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
|
|
7
|
+
// TypeScript-Definitionen für 24fire-api v2
|
|
8
|
+
// Doku: https://apidocs.24fire.de/v2
|
|
9
|
+
// Made by FlosTechnikwelt <florian.linde@flostechnikwelt.de>
|
|
10
|
+
// https://apidocs.24fire.de/v2
|
|
11
|
+
|
|
12
|
+
/** Standard-Antwortformat der 24fire REST-API */
|
|
13
|
+
export interface FireResponse<T = unknown> {
|
|
14
|
+
status: 'success' | 'error';
|
|
15
|
+
message: string;
|
|
16
|
+
data: T;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Fehler, der bei einer fehlgeschlagenen Anfrage geworfen wird */
|
|
20
|
+
export class FireAPIError extends Error {
|
|
21
|
+
name: 'FireAPIError';
|
|
22
|
+
/** HTTP-Statuscode */
|
|
23
|
+
status?: number;
|
|
24
|
+
/** Rohe API-Antwort */
|
|
25
|
+
response?: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FireAPIOptions {
|
|
29
|
+
/** Abweichende Base-URL (Standard: https://manage.24fire.de/api) */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Power-Aktionen für einen KVM-Server */
|
|
34
|
+
export type PowerMode = 'start' | 'stop' | 'restart' | (string & {});
|
|
35
|
+
|
|
36
|
+
export interface DnsRecordInput {
|
|
37
|
+
type: string;
|
|
38
|
+
name: string;
|
|
39
|
+
data: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface DnsEditInput {
|
|
43
|
+
record_id: string;
|
|
44
|
+
type?: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
data?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface TrafficChartOptions {
|
|
50
|
+
type?: string;
|
|
51
|
+
summary?: string;
|
|
52
|
+
output?: string;
|
|
53
|
+
dataset_in_label?: string;
|
|
54
|
+
dataset_out_label?: string;
|
|
55
|
+
dataset_in_color?: string;
|
|
56
|
+
dataset_out_color?: string;
|
|
57
|
+
axes_y_label?: string;
|
|
58
|
+
datapoints?: number;
|
|
59
|
+
size?: string;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface DdosChangeOptions {
|
|
64
|
+
layer4?: string;
|
|
65
|
+
layer7?: string;
|
|
66
|
+
ip_address?: string;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface KVM {
|
|
71
|
+
config(): Promise<FireResponse>;
|
|
72
|
+
status(): Promise<FireResponse>;
|
|
73
|
+
power(mode: PowerMode): Promise<FireResponse>;
|
|
74
|
+
start(): Promise<FireResponse>;
|
|
75
|
+
stop(): Promise<FireResponse>;
|
|
76
|
+
restart(): Promise<FireResponse>;
|
|
77
|
+
backup: {
|
|
78
|
+
list(): Promise<FireResponse>;
|
|
79
|
+
create(description?: string): Promise<FireResponse>;
|
|
80
|
+
createStatus(backupId: string): Promise<FireResponse>;
|
|
81
|
+
restore(backupId: string): Promise<FireResponse>;
|
|
82
|
+
restoreStatus(backupId: string): Promise<FireResponse>;
|
|
83
|
+
delete(backupId: string): Promise<FireResponse>;
|
|
84
|
+
};
|
|
85
|
+
traffic: {
|
|
86
|
+
current(): Promise<FireResponse>;
|
|
87
|
+
log(): Promise<FireResponse>;
|
|
88
|
+
chart(opts?: TrafficChartOptions): Promise<FireResponse>;
|
|
89
|
+
};
|
|
90
|
+
monitoring: {
|
|
91
|
+
timings(): Promise<FireResponse>;
|
|
92
|
+
incidences(): Promise<FireResponse>;
|
|
93
|
+
};
|
|
94
|
+
ddos: {
|
|
95
|
+
get(): Promise<FireResponse>;
|
|
96
|
+
change(opts?: DdosChangeOptions): Promise<FireResponse>;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface Domain {
|
|
101
|
+
info(): Promise<FireResponse>;
|
|
102
|
+
dns: {
|
|
103
|
+
list(): Promise<FireResponse>;
|
|
104
|
+
add(record: DnsRecordInput): Promise<FireResponse>;
|
|
105
|
+
edit(record: DnsEditInput): Promise<FireResponse>;
|
|
106
|
+
remove(recordId: string): Promise<FireResponse>;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface Webspace {
|
|
111
|
+
info(): Promise<FireResponse>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default class FireAPI {
|
|
115
|
+
constructor(apiKey: string, options?: FireAPIOptions);
|
|
116
|
+
|
|
117
|
+
apiKey: string;
|
|
118
|
+
baseUrl: string;
|
|
119
|
+
|
|
120
|
+
account: {
|
|
121
|
+
info(): Promise<FireResponse>;
|
|
122
|
+
services(): Promise<FireResponse>;
|
|
123
|
+
donations(): Promise<FireResponse>;
|
|
124
|
+
affiliate(): Promise<FireResponse>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** Low-Level-Anfrage gegen die API. */
|
|
128
|
+
request(method: string, path: string, body?: Record<string, unknown>): Promise<FireResponse>;
|
|
129
|
+
|
|
130
|
+
kvm(internalId: string | number): KVM;
|
|
131
|
+
domain(internalId: string | number): Domain;
|
|
132
|
+
webspace(internalId: string | number): Webspace;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { FireAPI };
|
package/src/index.js
CHANGED
|
@@ -1,105 +1,290 @@
|
|
|
1
|
-
//███████╗██╗██████╗ ███████╗ █████╗ ██████╗ ██╗
|
|
2
|
-
//██╔════╝██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██║
|
|
3
|
-
//█████╗ ██║██████╔╝█████╗ ███████║██████╔╝██║
|
|
4
|
-
//██╔══╝ ██║██╔══██╗██╔══╝ ██╔══██║██╔═══╝ ██║
|
|
5
|
-
//██║ ██║██║ ██║███████╗██║ ██║██║ ██║
|
|
6
|
-
//╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//Made by
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
1
|
+
//███████╗██╗██████╗ ███████╗ █████╗ ██████╗ ██╗
|
|
2
|
+
//██╔════╝██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██║
|
|
3
|
+
//█████╗ ██║██████╔╝█████╗ ███████║██████╔╝██║
|
|
4
|
+
//██╔══╝ ██║██╔══██╗██╔══╝ ██╔══██║██╔═══╝ ██║
|
|
5
|
+
//██║ ██║██║ ██║███████╗██║ ██║██║ ██║
|
|
6
|
+
//╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
|
|
7
|
+
// 24fire REST-API v2 für Node.js
|
|
8
|
+
// Doku: https://apidocs.24fire.de/v2
|
|
9
|
+
// Made by FlosTechnikwelt <florian.linde@flostechnikwelt.de>
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const BASE_URL = 'https://manage.24fire.de/api';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Fehler der bei einer fehlgeschlagenen API-Anfrage geworfen wird
|
|
17
|
+
* Enthält die HTTP-Statuscode und die rohe API-Antwort
|
|
18
|
+
*/
|
|
19
|
+
class FireAPIError extends Error {
|
|
20
|
+
constructor(message, { status, response } = {}) {
|
|
21
|
+
super(`[24fire] ${message}`);
|
|
22
|
+
this.name = 'FireAPIError';
|
|
23
|
+
this.status = status;
|
|
24
|
+
this.response = response;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Entfernt undefined/null-Werte aus einem Objekt, damit optionale
|
|
30
|
+
* Parameter einfach weggelassen werden können
|
|
31
|
+
*/
|
|
32
|
+
function clean(obj) {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [key, value] of Object.entries(obj || {})) {
|
|
35
|
+
if (value !== undefined && value !== null) out[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Ein Client wird einmalig mit dem API-Key erstellt:
|
|
42
|
+
*
|
|
43
|
+
* const FireAPI = require('24fire-api');
|
|
44
|
+
* const fire = new FireAPI('DEIN_API_KEY');
|
|
45
|
+
*/
|
|
46
|
+
class FireAPI {
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} apiKey
|
|
49
|
+
* @param {object} [options]
|
|
50
|
+
* @param {string} [options.baseUrl] Abweichende Base-URL (Standard: https://manage.24fire.de/api)
|
|
51
|
+
*/
|
|
52
|
+
constructor(apiKey, options = {}) {
|
|
53
|
+
if (!apiKey || typeof apiKey !== 'string') {
|
|
54
|
+
throw new FireAPIError('Es wurde kein gültiger API-Key übergeben');
|
|
55
|
+
}
|
|
56
|
+
if (typeof fetch !== 'function') {
|
|
57
|
+
throw new FireAPIError('Globales fetch nicht verfügbar – bitte Node.js 18 oder neuer verwenden');
|
|
58
|
+
}
|
|
59
|
+
this.apiKey = apiKey;
|
|
60
|
+
this.baseUrl = (options.baseUrl || BASE_URL).replace(/\/$/, '');
|
|
61
|
+
|
|
62
|
+
// Account-Endpunkte
|
|
63
|
+
this.account = {
|
|
64
|
+
/** Account-Informationen */
|
|
65
|
+
info: () => this.request('GET', '/account'),
|
|
66
|
+
/** Übersicht aller aktiven Dienste */
|
|
67
|
+
services: () => this.request('GET', '/account/services'),
|
|
68
|
+
/** Daten zur Spendenseite */
|
|
69
|
+
donations: () => this.request('GET', '/account/donations'),
|
|
70
|
+
/** Daten zum Affiliate-System */
|
|
71
|
+
affiliate: () => this.request('GET', '/account/affiliate'),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Interne Methode für alle HTTP-Anfragen.
|
|
77
|
+
* @param {string} method GET | POST | PUT | DELETE
|
|
78
|
+
* @param {string} path Pfad ab der Base-URL, z.B. "/account"
|
|
79
|
+
* @param {object} [body] Body-Parameter (werden als x-www-form-urlencoded gesendet)
|
|
80
|
+
* @returns {Promise<object>} geparste JSON-Antwort der API
|
|
81
|
+
*/
|
|
82
|
+
async request(method, path, body) {
|
|
83
|
+
const headers = { 'X-Fire-Apikey': this.apiKey };
|
|
84
|
+
const options = { method, headers };
|
|
85
|
+
|
|
86
|
+
const data = clean(body);
|
|
87
|
+
if (Object.keys(data).length > 0) {
|
|
88
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
89
|
+
options.body = new URLSearchParams(data).toString();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let res;
|
|
93
|
+
try {
|
|
94
|
+
res = await fetch(this.baseUrl + path, options);
|
|
95
|
+
} catch (err) {
|
|
96
|
+
throw new FireAPIError(`Netzwerkfehler: ${err.message}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const text = await res.text();
|
|
100
|
+
let json;
|
|
101
|
+
try {
|
|
102
|
+
json = text ? JSON.parse(text) : null;
|
|
103
|
+
} catch {
|
|
104
|
+
json = text;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!res.ok || (json && json.status === 'error')) {
|
|
108
|
+
const message = (json && json.message) || res.statusText || 'Unbekannter Fehler';
|
|
109
|
+
throw new FireAPIError(message, { status: res.status, response: json });
|
|
110
|
+
}
|
|
111
|
+
return json;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Liefert einen Client für einen bestimmten KVM-Server
|
|
116
|
+
* @param {string|number} internalId internal_id des Servers (siehe account.services())
|
|
117
|
+
*/
|
|
118
|
+
kvm(internalId) {
|
|
119
|
+
return new KVM(this, internalId);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Liefert einen Client für eine bestimmte Domain
|
|
124
|
+
* @param {string|number} internalId internal_id der Domain (siehe account.services())
|
|
125
|
+
*/
|
|
126
|
+
domain(internalId) {
|
|
127
|
+
return new Domain(this, internalId);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Liefert einen Client für einen bestimmten Webspace
|
|
132
|
+
* @param {string|number} internalId internal_id des Webspace (siehe account.services())
|
|
133
|
+
*/
|
|
134
|
+
webspace(internalId) {
|
|
135
|
+
return new Webspace(this, internalId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Alle Endpunkte eines einzelnen KVM-Servers */
|
|
140
|
+
class KVM {
|
|
141
|
+
constructor(client, internalId) {
|
|
142
|
+
if (!internalId && internalId !== 0) {
|
|
143
|
+
throw new FireAPIError('kvm() benötigt eine internal_id');
|
|
144
|
+
}
|
|
145
|
+
this._client = client;
|
|
146
|
+
this._base = `/kvm/${encodeURIComponent(internalId)}`;
|
|
147
|
+
|
|
148
|
+
this.backup = {
|
|
149
|
+
/** Alle Backups auflisten */
|
|
150
|
+
list: () => this._req('GET', '/backup/list'),
|
|
151
|
+
/** Neues Backup erstellen (24fire+). @param {string} [description] max. 24 Zeichen */
|
|
152
|
+
create: (description) => this._req('POST', '/backup/create', { description }),
|
|
153
|
+
/** Status der Backup-Erstellung abfragen */
|
|
154
|
+
createStatus: (backupId) => this._req('POST', '/backup/create/status', { backup_id: backupId }),
|
|
155
|
+
/** Backup wiederherstellen (24fire+) */
|
|
156
|
+
restore: (backupId) => this._req('POST', '/backup/restore', { backup_id: backupId }),
|
|
157
|
+
/** Status der Wiederherstellung abfragen */
|
|
158
|
+
restoreStatus: (backupId) => this._req('POST', '/backup/restore/status', { backup_id: backupId }),
|
|
159
|
+
/** Backup löschen */
|
|
160
|
+
delete: (backupId) => this._req('DELETE', '/backup/delete', { backup_id: backupId }),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
this.traffic = {
|
|
164
|
+
/** Aktueller Traffic-Verbrauch des Monats */
|
|
165
|
+
current: () => this._req('GET', '/traffic/current'),
|
|
166
|
+
/** Traffic-Log (Messung alle 10 Minuten) */
|
|
167
|
+
log: () => this._req('GET', '/traffic/log'),
|
|
168
|
+
/**
|
|
169
|
+
* Traffic-Diagramm generieren (24fire+)
|
|
170
|
+
* @param {object} opts z.B. { type, summary, output, datapoints, size, ... }
|
|
171
|
+
*/
|
|
172
|
+
chart: (opts = {}) => this._req('POST', '/traffic/chart', opts),
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
this.monitoring = {
|
|
176
|
+
/** Monitoring-Messungen (Timings) abrufen */
|
|
177
|
+
timings: () => this._req('GET', '/monitoring/timings'),
|
|
178
|
+
/** Ausfälle / Incidences abrufen */
|
|
179
|
+
incidences: () => this._req('GET', '/monitoring/incidences'),
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
this.ddos = {
|
|
183
|
+
/** Aktuelle DDoS-Einstellungen abrufen */
|
|
184
|
+
get: () => this._req('GET', '/ddos'),
|
|
185
|
+
/**
|
|
186
|
+
* DDoS-Einstellungen ändern (24fire+)
|
|
187
|
+
* @param {object} opts { layer4, layer7, ip_address? }
|
|
188
|
+
*/
|
|
189
|
+
change: (opts = {}) => this._req('POST', '/ddos/change', opts),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
_req(method, path, body) {
|
|
194
|
+
return this._client.request(method, this._base + path, body);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Server-Konfiguration abrufen */
|
|
198
|
+
config() {
|
|
199
|
+
return this._req('GET', '/config');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Aktuellen Status und Auslastung abrufen */
|
|
203
|
+
status() {
|
|
204
|
+
return this._req('GET', '/status');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Server starten / stoppen / neu starten.
|
|
209
|
+
* @param {string} mode z.B. "start", "stop", "restart"
|
|
210
|
+
*/
|
|
211
|
+
power(mode) {
|
|
212
|
+
return this._req('POST', '/power', { mode });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Kurzform für power('start') */
|
|
216
|
+
start() {
|
|
217
|
+
return this.power('start');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Kurzform für power('stop') */
|
|
221
|
+
stop() {
|
|
222
|
+
return this.power('stop');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Kurzform für power('restart') */
|
|
226
|
+
restart() {
|
|
227
|
+
return this.power('restart');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Alle Endpunkte einer einzelnen Domain */
|
|
232
|
+
class Domain {
|
|
233
|
+
constructor(client, internalId) {
|
|
234
|
+
if (!internalId && internalId !== 0) {
|
|
235
|
+
throw new FireAPIError('domain() benötigt eine internal_id');
|
|
236
|
+
}
|
|
237
|
+
this._client = client;
|
|
238
|
+
this._base = `/domain/${encodeURIComponent(internalId)}`;
|
|
239
|
+
|
|
240
|
+
this.dns = {
|
|
241
|
+
/** Alle DNS-Einträge auflisten */
|
|
242
|
+
list: () => this._req('GET', '/dns'),
|
|
243
|
+
/**
|
|
244
|
+
* DNS-Eintrag hinzufügen (24fire+)
|
|
245
|
+
* @param {object} record { type, name, data }
|
|
246
|
+
*/
|
|
247
|
+
add: (record = {}) => this._req('PUT', '/dns/add', record),
|
|
248
|
+
/**
|
|
249
|
+
* DNS-Eintrag bearbeiten (24fire+)
|
|
250
|
+
* @param {object} record { record_id, type?, name?, data? }
|
|
251
|
+
*/
|
|
252
|
+
edit: (record = {}) => this._req('POST', '/dns/edit', record),
|
|
253
|
+
/**
|
|
254
|
+
* DNS-Eintrag entfernen
|
|
255
|
+
* @param {string} recordId ID des Eintrags (siehe dns.list())
|
|
256
|
+
*/
|
|
257
|
+
remove: (recordId) => this._req('DELETE', '/dns/remove', { record_id: recordId }),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
_req(method, path, body) {
|
|
262
|
+
return this._client.request(method, this._base + path, body);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** Domain-Informationen abrufen */
|
|
266
|
+
info() {
|
|
267
|
+
return this._req('GET', '');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Endpunkte eines einzelnen Webspace */
|
|
272
|
+
class Webspace {
|
|
273
|
+
constructor(client, internalId) {
|
|
274
|
+
if (!internalId && internalId !== 0) {
|
|
275
|
+
throw new FireAPIError('webspace() benötigt eine internal_id');
|
|
276
|
+
}
|
|
277
|
+
this._client = client;
|
|
278
|
+
this._base = `/webspace/${encodeURIComponent(internalId)}`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Webspace-Daten abrufen */
|
|
282
|
+
info() {
|
|
283
|
+
return this._client.request('GET', this._base);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
module.exports = FireAPI;
|
|
288
|
+
module.exports.FireAPI = FireAPI;
|
|
289
|
+
module.exports.FireAPIError = FireAPIError;
|
|
290
|
+
module.exports.default = FireAPI;
|