@stryke/cookie 0.1.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 -0
- package/README.md +292 -0
- package/dist/index.cjs +49 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +1 -0
- package/dist/parse.cjs +90 -0
- package/dist/parse.d.ts +17 -0
- package/dist/parse.mjs +1 -0
- package/dist/split.cjs +31 -0
- package/dist/split.d.ts +1 -0
- package/dist/split.mjs +1 -0
- package/dist/stringify.cjs +78 -0
- package/dist/stringify.d.ts +10 -0
- package/dist/stringify.mjs +1 -0
- package/dist/types.cjs +1 -0
- package/dist/types.d.ts +184 -0
- package/dist/types.mjs +0 -0
- package/package.json +121 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/README.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
<!-- START header -->
|
|
2
|
+
<!-- prettier-ignore-start -->
|
|
3
|
+
<!-- markdownlint-disable -->
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<div align="center"><img src="https://public.storm-cdn.com/storm-banner.gif" width="100%" alt="Storm Software" /></div>
|
|
7
|
+
<br />
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
<b>
|
|
11
|
+
<a href="https://stormsoftware.com" target="_blank">Website</a> •
|
|
12
|
+
<a href="https://github.com/storm-software/stryke" target="_blank">GitHub</a> •
|
|
13
|
+
<a href="https://discord.gg/MQ6YVzakM5">Discord</a> • <a href="https://stormsoftware.com/projects/stryke/docs" target="_blank">Docs</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> •
|
|
14
|
+
<a href="https://github.com/storm-software/stryke/issues/new?assignees=&labels=bug&template=bug-report.yml&title=Bug Report%3A+">Report a Bug</a>
|
|
15
|
+
</b>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<br />
|
|
19
|
+
This package is part of Storm Software's **🌩️ Stryke** monorepo. Stryke packages TypeScript utility packages with shared functionality common to many Storm Software applications.
|
|
20
|
+
|
|
21
|
+
<br />
|
|
22
|
+
|
|
23
|
+
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
24
|
+
|
|
25
|
+
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
26
|
+
|
|
27
|
+
> [!IMPORTANT] Important
|
|
28
|
+
> This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be available through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.
|
|
29
|
+
|
|
30
|
+
<div align="center">
|
|
31
|
+
<b>Be sure to ⭐ this repository on <a href="https://github.com/storm-software/stryke" target="_blank">GitHub</a> so you can keep up to date on any daily progress!</b>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<br />
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<!-- markdownlint-restore -->
|
|
38
|
+
<!-- prettier-ignore-end -->
|
|
39
|
+
|
|
40
|
+
<!-- END header -->
|
|
41
|
+
|
|
42
|
+
# Stryke - HTTP Cookie Helpers
|
|
43
|
+
|
|
44
|
+
A package that includes utility functions used to help with
|
|
45
|
+
parsing and serializing HTTP cookies.
|
|
46
|
+
|
|
47
|
+
<!-- START doctoc -->
|
|
48
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
49
|
+
|
|
50
|
+
## Table of Contents
|
|
51
|
+
|
|
52
|
+
- [Stryke - HTTP Cookie Helpers](#stryke---http-cookie-helpers)
|
|
53
|
+
- [Table of Contents](#table-of-contents)
|
|
54
|
+
- [Installing](#installing)
|
|
55
|
+
- [Reduced Package Size](#reduced-package-size)
|
|
56
|
+
- [Development](#development)
|
|
57
|
+
- [Building](#building)
|
|
58
|
+
- [Running unit tests](#running-unit-tests)
|
|
59
|
+
- [Linting](#linting)
|
|
60
|
+
- [Storm Workspaces](#storm-workspaces)
|
|
61
|
+
- [Roadmap](#roadmap)
|
|
62
|
+
- [Support](#support)
|
|
63
|
+
- [License](#license)
|
|
64
|
+
- [Changelog](#changelog)
|
|
65
|
+
- [Contributing](#contributing)
|
|
66
|
+
- [Contributors](#contributors)
|
|
67
|
+
|
|
68
|
+
<!-- END doctoc -->
|
|
69
|
+
|
|
70
|
+
<br />
|
|
71
|
+
|
|
72
|
+
## Installing
|
|
73
|
+
|
|
74
|
+
Using [pnpm](http://pnpm.io):
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pnpm add -D @stryke/http
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
<details>
|
|
81
|
+
<summary>Using npm</summary>
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install -D @stryke/http
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
</details>
|
|
88
|
+
|
|
89
|
+
<details>
|
|
90
|
+
<summary>Using yarn</summary>
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
yarn add -D @stryke/http
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
</details>
|
|
97
|
+
|
|
98
|
+
## Reduced Package Size
|
|
99
|
+
|
|
100
|
+
This project uses [tsup](https://tsup.egoist.dev/) to package the source code
|
|
101
|
+
due to its ability to remove unused code and ship smaller javascript files
|
|
102
|
+
thanks to code splitting. This helps to greatly reduce the size of the package
|
|
103
|
+
and to make it easier to use in other projects.
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
This project is built using [Nx](https://nx.dev). As a result, many of the usual
|
|
108
|
+
commands are available to assist in development.
|
|
109
|
+
|
|
110
|
+
### Building
|
|
111
|
+
|
|
112
|
+
Run `nx build http` to build the library.
|
|
113
|
+
|
|
114
|
+
### Running unit tests
|
|
115
|
+
|
|
116
|
+
Run `nx test http` to execute the unit tests via [Jest](https://jestjs.io).
|
|
117
|
+
|
|
118
|
+
### Linting
|
|
119
|
+
|
|
120
|
+
Run `nx lint http` to run [ESLint](https://eslint.org/) on the package.
|
|
121
|
+
|
|
122
|
+
<!-- START footer -->
|
|
123
|
+
<!-- prettier-ignore-start -->
|
|
124
|
+
<!-- markdownlint-disable -->
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
## Storm Workspaces
|
|
128
|
+
|
|
129
|
+
Storm workspaces are built using
|
|
130
|
+
<a href="https://nx.dev/" target="_blank">Nx</a>, a set of extensible dev tools
|
|
131
|
+
for monorepos, which helps you develop like Google, Facebook, and Microsoft.
|
|
132
|
+
Building on top of Nx, the Open System provides a set of tools and patterns that
|
|
133
|
+
help you scale your monorepo to many teams while keeping the codebase
|
|
134
|
+
maintainable.
|
|
135
|
+
|
|
136
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
137
|
+
<br />
|
|
138
|
+
|
|
139
|
+
## Roadmap
|
|
140
|
+
|
|
141
|
+
See the [open issues](https://github.com/storm-software/stryke/issues) for a
|
|
142
|
+
list of proposed features (and known issues).
|
|
143
|
+
|
|
144
|
+
- [Top Feature Requests](https://github.com/storm-software/stryke/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc)
|
|
145
|
+
(Add your votes using the 👍 reaction)
|
|
146
|
+
- [Top Bugs](https://github.com/storm-software/stryke/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc)
|
|
147
|
+
(Add your votes using the 👍 reaction)
|
|
148
|
+
- [Newest Bugs](https://github.com/storm-software/stryke/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
|
|
149
|
+
|
|
150
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
151
|
+
<br />
|
|
152
|
+
|
|
153
|
+
## Support
|
|
154
|
+
|
|
155
|
+
Reach out to the maintainer at one of the following places:
|
|
156
|
+
|
|
157
|
+
- [Contact](https://stormsoftware.com/contact)
|
|
158
|
+
- [GitHub discussions](https://github.com/storm-software/stryke/discussions)
|
|
159
|
+
- <support@stormsoftware.com>
|
|
160
|
+
|
|
161
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
162
|
+
<br />
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
This project is licensed under the **Apache License 2.0**. Feel free to edit and
|
|
167
|
+
distribute this template as you like.
|
|
168
|
+
|
|
169
|
+
See [LICENSE](LICENSE) for more information.
|
|
170
|
+
|
|
171
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
172
|
+
<br />
|
|
173
|
+
|
|
174
|
+
## Changelog
|
|
175
|
+
|
|
176
|
+
This project adheres to
|
|
177
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every release, along
|
|
178
|
+
with the migration instructions, is documented in the [CHANGELOG](CHANGELOG.md)
|
|
179
|
+
file
|
|
180
|
+
|
|
181
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
182
|
+
<br />
|
|
183
|
+
|
|
184
|
+
## Contributing
|
|
185
|
+
|
|
186
|
+
First off, thanks for taking the time to contribute! Contributions are what
|
|
187
|
+
makes the open-source community such an amazing place to learn, inspire, and
|
|
188
|
+
create. Any contributions you make will benefit everybody else and are **greatly
|
|
189
|
+
appreciated**.
|
|
190
|
+
|
|
191
|
+
Please try to create bug reports that are:
|
|
192
|
+
|
|
193
|
+
- _Reproducible._ Include steps to reproduce the problem.
|
|
194
|
+
- _Specific._ Include as much detail as possible: which version, what
|
|
195
|
+
environment, etc.
|
|
196
|
+
- _Unique._ Do not duplicate existing opened issues.
|
|
197
|
+
- _Scoped to a Single Bug._ One bug per report.
|
|
198
|
+
|
|
199
|
+
Please adhere to this project's [code of conduct](.github/CODE_OF_CONDUCT.md).
|
|
200
|
+
|
|
201
|
+
You can use
|
|
202
|
+
[markdownlint-cli](https://github.com/storm-software/stryke/markdownlint-cli) to
|
|
203
|
+
check for common markdown style inconsistency.
|
|
204
|
+
|
|
205
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
206
|
+
<br />
|
|
207
|
+
|
|
208
|
+
## Contributors
|
|
209
|
+
|
|
210
|
+
Thanks goes to these wonderful people
|
|
211
|
+
([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
212
|
+
|
|
213
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
214
|
+
|
|
215
|
+
<table>
|
|
216
|
+
<tbody>
|
|
217
|
+
<tr>
|
|
218
|
+
<td align="center" valign="top" width="14.28%"><a href="http://www.sullypat.com/"><img src="https://avatars.githubusercontent.com/u/99053093?v=4?s=100" width="100px;" alt="Patrick Sullivan"/><br /><sub><b>Patrick Sullivan</b></sub></a><br /><a href="#design-sullivanpj" title="Design">🎨</a> <a href="https://github.com/storm-software/stryke/commits?author=sullivanpj" title="Code">💻</a> <a href="#tool-sullivanpj" title="Tools">🔧</a> <a href="https://github.com/storm-software/stryke/commits?author=sullivanpj" title="Documentation">📖</a> <a href="https://github.com/storm-software/stryke/commits?author=sullivanpj" title="Tests">⚠️</a></td>
|
|
219
|
+
<td align="center" valign="top" width="14.28%"><a href="https://tylerbenning.com/"><img src="https://avatars.githubusercontent.com/u/7265547?v=4?s=100" width="100px;" alt="Tyler Benning"/><br /><sub><b>Tyler Benning</b></sub></a><br /><a href="#design-tbenning" title="Design">🎨</a></td>
|
|
220
|
+
<td align="center" valign="top" width="14.28%"><a href="http://stormsoftware.com"><img src="https://avatars.githubusercontent.com/u/149802440?v=4?s=100" width="100px;" alt="Stormie"/><br /><sub><b>Stormie</b></sub></a><br /><a href="#maintenance-stormie-bot" title="Maintenance">🚧</a></td>
|
|
221
|
+
</tr>
|
|
222
|
+
</tbody>
|
|
223
|
+
<tfoot>
|
|
224
|
+
<tr>
|
|
225
|
+
<td align="center" size="13px" colspan="7">
|
|
226
|
+
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg" alt="All Contributors">
|
|
227
|
+
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
|
|
228
|
+
</img>
|
|
229
|
+
</td>
|
|
230
|
+
</tr>
|
|
231
|
+
</tfoot>
|
|
232
|
+
</table>
|
|
233
|
+
|
|
234
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
235
|
+
|
|
236
|
+
This project follows the
|
|
237
|
+
[all-contributors](https://github.com/all-contributors/all-contributors)
|
|
238
|
+
specification. Contributions of any kind welcome!
|
|
239
|
+
|
|
240
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
241
|
+
<br />
|
|
242
|
+
|
|
243
|
+
<hr />
|
|
244
|
+
<br />
|
|
245
|
+
|
|
246
|
+
<div align="center">
|
|
247
|
+
<img src="https://public.storm-cdn.com/logo-banner.png" width="100%" alt="Storm Software" />
|
|
248
|
+
</div>
|
|
249
|
+
<br />
|
|
250
|
+
|
|
251
|
+
<div align="center">
|
|
252
|
+
<a href="https://stormsoftware.com" target="_blank">Website</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> • <a href="https://linkedin.com/in/patrick-sullivan-865526b0" target="_blank">LinkedIn</a> • <a href="https://medium.com/@pat.joseph.sullivan" target="_blank">Medium</a> • <a href="https://github.com/storm-software" target="_blank">GitHub</a> • <a href="https://keybase.io/sullivanp" target="_blank">OpenPGP Key</a>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
<div align="center">
|
|
256
|
+
<b>Fingerprint:</b> 1BD2 7192 7770 2549 F4C9 F238 E6AD C420 DA5C 4C2D
|
|
257
|
+
</div>
|
|
258
|
+
<br />
|
|
259
|
+
|
|
260
|
+
Storm Software is an open source software development organization and creator
|
|
261
|
+
of Acidic, StormStack and StormCloud.
|
|
262
|
+
|
|
263
|
+
Our mission is to make software development more accessible. Our ideal future is
|
|
264
|
+
one where anyone can create software without years of prior development
|
|
265
|
+
experience serving as a barrier to entry. We hope to achieve this via LLMs,
|
|
266
|
+
Generative AI, and intuitive, high-level data modeling/programming languages.
|
|
267
|
+
|
|
268
|
+
Join us on [Discord](https://discord.gg/MQ6YVzakM5) to chat with the team,
|
|
269
|
+
receive release notifications, ask questions, and get involved.
|
|
270
|
+
|
|
271
|
+
If this sounds interesting, and you would like to help us in creating the next
|
|
272
|
+
generation of development tools, please reach out on our
|
|
273
|
+
[website](https://stormsoftware.com/contact) or join our
|
|
274
|
+
[Slack channel](https://join.slack.com/t/storm-software/shared_invite/zt-2gsmk04hs-i6yhK_r6urq0dkZYAwq2pA)!
|
|
275
|
+
|
|
276
|
+
<br />
|
|
277
|
+
|
|
278
|
+
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/icon-fill.png" alt="Storm Software" width="200px"/></a></div>
|
|
279
|
+
<br />
|
|
280
|
+
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/visit-us-text.svg" alt="Visit us at stormsoftware.com" height="90px"/></a></div>
|
|
281
|
+
|
|
282
|
+
<br />
|
|
283
|
+
|
|
284
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
285
|
+
<br />
|
|
286
|
+
<br />
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
<!-- markdownlint-restore -->
|
|
290
|
+
<!-- prettier-ignore-end -->
|
|
291
|
+
|
|
292
|
+
<!-- END footer -->
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _parse = require("./parse.cjs");
|
|
7
|
+
Object.keys(_parse).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _parse[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _parse[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _split = require("./split.cjs");
|
|
18
|
+
Object.keys(_split).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _split[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _split[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _stringify = require("./stringify.cjs");
|
|
29
|
+
Object.keys(_stringify).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _stringify[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _stringify[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _types = require("./types.cjs");
|
|
40
|
+
Object.keys(_types).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _types[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./parse";export*from"./split";export*from"./stringify";export*from"./types";
|
package/dist/parse.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseCookie = parseCookie;
|
|
7
|
+
exports.parseSetCookie = parseSetCookie;
|
|
8
|
+
var _typeChecks = require("@stryke/type-checks");
|
|
9
|
+
function parseCookie(n, c) {
|
|
10
|
+
if (!(0, _typeChecks.isString)(n)) throw new Error("argument str must be a string");
|
|
11
|
+
const r = {},
|
|
12
|
+
a = c ?? {},
|
|
13
|
+
l = a.decode ?? (s => s.includes("%") ? decodeURIComponent(s) : s);
|
|
14
|
+
let e = 0;
|
|
15
|
+
for (; e < n.length;) {
|
|
16
|
+
const s = n.indexOf("=", e);
|
|
17
|
+
if (s === -1) break;
|
|
18
|
+
let t = n.indexOf(";", e);
|
|
19
|
+
if (t === -1) t = n.length;else if (t < s) {
|
|
20
|
+
e = n.lastIndexOf(";", s - 1) + 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const i = n.slice(e, s).trim();
|
|
24
|
+
if (a?.filter && !a?.filter(i)) {
|
|
25
|
+
e = t + 1;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (r[i] === void 0) {
|
|
29
|
+
let o = n.slice(s + 1, t).trim();
|
|
30
|
+
o.codePointAt(0) === 34 && (o = o.slice(1, -1));
|
|
31
|
+
try {
|
|
32
|
+
r[i] = l(o);
|
|
33
|
+
} catch {
|
|
34
|
+
r[i] = o;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
e = t + 1;
|
|
38
|
+
}
|
|
39
|
+
return r;
|
|
40
|
+
}
|
|
41
|
+
function parseSetCookie(n, c) {
|
|
42
|
+
const r = (n || "").split(";").filter(i => (0, _typeChecks.isString)(i) && !!i.trim()),
|
|
43
|
+
a = r.shift() || "";
|
|
44
|
+
let l = "",
|
|
45
|
+
e = "";
|
|
46
|
+
const s = a.split("=");
|
|
47
|
+
s.length > 1 ? (l = s.shift(), e = s.join("=")) : e = a;
|
|
48
|
+
try {
|
|
49
|
+
e = c?.decode === !1 ? e : (c?.decode ?? decodeURIComponent)(e);
|
|
50
|
+
} catch {}
|
|
51
|
+
const t = {
|
|
52
|
+
name: l,
|
|
53
|
+
value: e
|
|
54
|
+
};
|
|
55
|
+
for (const i of r) {
|
|
56
|
+
const o = i.split("="),
|
|
57
|
+
p = (o.shift() || "").trimStart().toLowerCase(),
|
|
58
|
+
f = o.join("=");
|
|
59
|
+
switch (p) {
|
|
60
|
+
case "expires":
|
|
61
|
+
{
|
|
62
|
+
t.expires = new Date(f);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case "max-age":
|
|
66
|
+
{
|
|
67
|
+
t.maxAge = Number.parseInt(f, 10);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case "secure":
|
|
71
|
+
{
|
|
72
|
+
t.secure = !0;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case "httponly":
|
|
76
|
+
{
|
|
77
|
+
t.httpOnly = !0;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "samesite":
|
|
81
|
+
{
|
|
82
|
+
t.sameSite = f;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
default:
|
|
86
|
+
t[p] = f;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return t;
|
|
90
|
+
}
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CookieParseOptions, SetCookie, SetCookieParseOptions } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.
|
|
4
|
+
*
|
|
5
|
+
* @param cookie - the string representing a `Cookie` header value
|
|
6
|
+
* @param options - object containing parsing options
|
|
7
|
+
* @returns an object with the parsed cookies
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseCookie(cookie: string, options?: CookieParseOptions): Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.
|
|
12
|
+
*
|
|
13
|
+
* @param setCookieValue - the string representing a `Set-Cookie` header value
|
|
14
|
+
* @param options - object containing parsing options
|
|
15
|
+
* @returns an object with the parsed cookie
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseSetCookie(setCookieValue: string, options?: SetCookieParseOptions): SetCookie;
|
package/dist/parse.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isString as d}from"@stryke/type-checks";export function parseCookie(n,c){if(!d(n))throw new Error("argument str must be a string");const r={},a=c??{},l=a.decode??(s=>s.includes("%")?decodeURIComponent(s):s);let e=0;for(;e<n.length;){const s=n.indexOf("=",e);if(s===-1)break;let t=n.indexOf(";",e);if(t===-1)t=n.length;else if(t<s){e=n.lastIndexOf(";",s-1)+1;continue}const i=n.slice(e,s).trim();if(a?.filter&&!a?.filter(i)){e=t+1;continue}if(r[i]===void 0){let o=n.slice(s+1,t).trim();o.codePointAt(0)===34&&(o=o.slice(1,-1));try{r[i]=l(o)}catch{r[i]=o}}e=t+1}return r}export function parseSetCookie(n,c){const r=(n||"").split(";").filter(i=>d(i)&&!!i.trim()),a=r.shift()||"";let l="",e="";const s=a.split("=");s.length>1?(l=s.shift(),e=s.join("=")):e=a;try{e=c?.decode===!1?e:(c?.decode??decodeURIComponent)(e)}catch{}const t={name:l,value:e};for(const i of r){const o=i.split("="),p=(o.shift()||"").trimStart().toLowerCase(),f=o.join("=");switch(p){case"expires":{t.expires=new Date(f);break}case"max-age":{t.maxAge=Number.parseInt(f,10);break}case"secure":{t.secure=!0;break}case"httponly":{t.httpOnly=!0;break}case"samesite":{t.sameSite=f;break}default:t[p]=f}}return t}
|
package/dist/split.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.splitSetCookieString = splitSetCookieString;
|
|
7
|
+
var _isString = require("@stryke/type-checks/is-string");
|
|
8
|
+
function splitSetCookieString(n) {
|
|
9
|
+
if (Array.isArray(n)) return n.flatMap(s => splitSetCookieString(s));
|
|
10
|
+
if (!(0, _isString.isString)(n)) return [];
|
|
11
|
+
const r = [];
|
|
12
|
+
let t = 0,
|
|
13
|
+
l,
|
|
14
|
+
e,
|
|
15
|
+
a,
|
|
16
|
+
i,
|
|
17
|
+
h;
|
|
18
|
+
const c = () => {
|
|
19
|
+
for (; t < n.length && /\s/.test(n.charAt(t));) t += 1;
|
|
20
|
+
return t < n.length;
|
|
21
|
+
},
|
|
22
|
+
g = () => (e = n.charAt(t), e !== "=" && e !== ";" && e !== ",");
|
|
23
|
+
for (; t < n.length;) {
|
|
24
|
+
for (l = t, h = !1; c();) if (e = n.charAt(t), e === ",") {
|
|
25
|
+
for (a = t, t += 1, c(), i = t; t < n.length && g();) t += 1;
|
|
26
|
+
t < n.length && n.charAt(t) === "=" ? (h = !0, t = i, r.push(n.slice(l, a)), l = t) : t = a + 1;
|
|
27
|
+
} else t += 1;
|
|
28
|
+
(!h || t >= n.length) && r.push(n.slice(l));
|
|
29
|
+
}
|
|
30
|
+
return r;
|
|
31
|
+
}
|
package/dist/split.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function splitSetCookieString(strCookie: string | string[]): string[];
|
package/dist/split.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isString as u}from"@stryke/type-checks/is-string";export function splitSetCookieString(n){if(Array.isArray(n))return n.flatMap(s=>splitSetCookieString(s));if(!u(n))return[];const r=[];let t=0,l,e,a,i,h;const c=()=>{for(;t<n.length&&/\s/.test(n.charAt(t));)t+=1;return t<n.length},g=()=>(e=n.charAt(t),e!=="="&&e!==";"&&e!==",");for(;t<n.length;){for(l=t,h=!1;c();)if(e=n.charAt(t),e===","){for(a=t,t+=1,c(),i=t;t<n.length&&g();)t+=1;t<n.length&&n.charAt(t)==="="?(h=!0,t=i,r.push(n.slice(l,a)),l=t):t=a+1}else t+=1;(!h||t>=n.length)&&r.push(n.slice(l))}return r}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stringifyCookie = stringifyCookie;
|
|
7
|
+
var _typeChecks = require("@stryke/type-checks");
|
|
8
|
+
const r = /^[\t\u0020-\u007E\u0080-\u00FF]+$/;
|
|
9
|
+
function stringifyCookie(n, p, m) {
|
|
10
|
+
const i = m ?? {},
|
|
11
|
+
a = i.encode ?? encodeURIComponent;
|
|
12
|
+
if (!(0, _typeChecks.isFunction)(a)) throw new Error("option encode is invalid");
|
|
13
|
+
if (!r.test(n)) throw new Error("argument name is invalid");
|
|
14
|
+
const o = a(p);
|
|
15
|
+
if (o && !r.test(o)) throw new Error("argument val is invalid");
|
|
16
|
+
let e = `${n}=${o}`;
|
|
17
|
+
if (!(0, _typeChecks.isSet)(i.maxAge)) {
|
|
18
|
+
const t = Number(i.maxAge);
|
|
19
|
+
if (Number.isNaN(t) || !Number.isFinite(t)) throw new TypeError("option maxAge is invalid");
|
|
20
|
+
e += `; Max-Age=${Math.floor(t)}`;
|
|
21
|
+
}
|
|
22
|
+
if (i.domain) {
|
|
23
|
+
if (!r.test(i.domain)) throw new Error("option domain is invalid");
|
|
24
|
+
e += `; Domain=${i.domain}`;
|
|
25
|
+
}
|
|
26
|
+
if (i.path) {
|
|
27
|
+
if (!r.test(i.path)) throw new Error("option path is invalid");
|
|
28
|
+
e += `; Path=${i.path}`;
|
|
29
|
+
}
|
|
30
|
+
if (i.expires) {
|
|
31
|
+
if (!(0, _typeChecks.isDate)(i.expires) || Number.isNaN(i.expires.valueOf())) throw new Error("option expires is invalid");
|
|
32
|
+
e += `; Expires=${i.expires.toUTCString()}`;
|
|
33
|
+
}
|
|
34
|
+
if (i.httpOnly && (e += "; HttpOnly"), i.secure && (e += "; Secure"), i.priority) switch ((0, _typeChecks.isString)(i.priority) ? i.priority.toLowerCase() : i.priority) {
|
|
35
|
+
case "low":
|
|
36
|
+
{
|
|
37
|
+
e += "; Priority=Low";
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case "medium":
|
|
41
|
+
{
|
|
42
|
+
e += "; Priority=Medium";
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case "high":
|
|
46
|
+
{
|
|
47
|
+
e += "; Priority=High";
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
default:
|
|
51
|
+
throw new Error("option priority is invalid");
|
|
52
|
+
}
|
|
53
|
+
if (i.sameSite) switch ((0, _typeChecks.isString)(i.sameSite) ? i.sameSite.toLowerCase() : i.sameSite) {
|
|
54
|
+
case !0:
|
|
55
|
+
{
|
|
56
|
+
e += "; SameSite=Strict";
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "lax":
|
|
60
|
+
{
|
|
61
|
+
e += "; SameSite=Lax";
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "strict":
|
|
65
|
+
{
|
|
66
|
+
e += "; SameSite=Strict";
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
case "none":
|
|
70
|
+
{
|
|
71
|
+
e += "; SameSite=None";
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
default:
|
|
75
|
+
throw new Error("option sameSite is invalid");
|
|
76
|
+
}
|
|
77
|
+
return i.partitioned && (e += "; Partitioned"), e;
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CookieSerializeOptions } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Serialize a cookie name-value pair into a `Set-Cookie` header string.
|
|
4
|
+
*
|
|
5
|
+
* @param name - the name for the cookie
|
|
6
|
+
* @param value - value to set the cookie to
|
|
7
|
+
* @param options - object containing serialization options
|
|
8
|
+
* @returns a `Set-Cookie` header string
|
|
9
|
+
*/
|
|
10
|
+
export declare function stringifyCookie(name: string, value: string, options?: CookieSerializeOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isDate as c,isFunction as d,isSet as f,isString as s}from"@stryke/type-checks";const r=/^[\t\u0020-\u007E\u0080-\u00FF]+$/;export function stringifyCookie(n,p,m){const i=m??{},a=i.encode??encodeURIComponent;if(!d(a))throw new Error("option encode is invalid");if(!r.test(n))throw new Error("argument name is invalid");const o=a(p);if(o&&!r.test(o))throw new Error("argument val is invalid");let e=`${n}=${o}`;if(!f(i.maxAge)){const t=Number(i.maxAge);if(Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("option maxAge is invalid");e+=`; Max-Age=${Math.floor(t)}`}if(i.domain){if(!r.test(i.domain))throw new Error("option domain is invalid");e+=`; Domain=${i.domain}`}if(i.path){if(!r.test(i.path))throw new Error("option path is invalid");e+=`; Path=${i.path}`}if(i.expires){if(!c(i.expires)||Number.isNaN(i.expires.valueOf()))throw new Error("option expires is invalid");e+=`; Expires=${i.expires.toUTCString()}`}if(i.httpOnly&&(e+="; HttpOnly"),i.secure&&(e+="; Secure"),i.priority)switch(s(i.priority)?i.priority.toLowerCase():i.priority){case"low":{e+="; Priority=Low";break}case"medium":{e+="; Priority=Medium";break}case"high":{e+="; Priority=High";break}default:throw new Error("option priority is invalid")}if(i.sameSite)switch(s(i.sameSite)?i.sameSite.toLowerCase():i.sameSite){case!0:{e+="; SameSite=Strict";break}case"lax":{e+="; SameSite=Lax";break}case"strict":{e+="; SameSite=Strict";break}case"none":{e+="; SameSite=None";break}default:throw new Error("option sameSite is invalid")}return i.partitioned&&(e+="; Partitioned"),e}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie serialization options
|
|
3
|
+
*/
|
|
4
|
+
export interface CookieSerializeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3 | Domain Set-Cookie attribute}. By default, no
|
|
7
|
+
* domain is set, and most clients will consider the cookie to apply to only
|
|
8
|
+
* the current domain.
|
|
9
|
+
*/
|
|
10
|
+
domain?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Specifies a function that will be used to encode a cookie's value. Since
|
|
13
|
+
* value of a cookie has a limited character set (and must be a simple
|
|
14
|
+
* string), this function can be used to encode a value into a string suited
|
|
15
|
+
* for a cookie's value.
|
|
16
|
+
*
|
|
17
|
+
* The default function is the global `encodeURIComponent`, which will
|
|
18
|
+
* encode a JavaScript string into UTF-8 byte sequences and then URL-encode
|
|
19
|
+
* any that fall outside of the cookie range.
|
|
20
|
+
*/
|
|
21
|
+
encode?: (value: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1 | `Expires` `Set-Cookie` attribute}. By default,
|
|
24
|
+
* no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
|
|
25
|
+
* it on a condition like exiting a web browser application.
|
|
26
|
+
*
|
|
27
|
+
* Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
|
|
28
|
+
* states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
|
|
29
|
+
* possible not all clients by obey this, so if both are set, they should
|
|
30
|
+
* point to the same date and time.
|
|
31
|
+
*/
|
|
32
|
+
expires?: Date | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6 | `HttpOnly` `Set-Cookie` attribute}.
|
|
35
|
+
* When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
|
|
36
|
+
* default, the `HttpOnly` attribute is not set.
|
|
37
|
+
*
|
|
38
|
+
* Note* be careful when setting this to true, as compliant clients will
|
|
39
|
+
* not allow client-side JavaScript to see the cookie in `document.cookie`.
|
|
40
|
+
*/
|
|
41
|
+
httpOnly?: boolean | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Specifies the number (in seconds) to be the value for the `Max-Age`
|
|
44
|
+
* `Set-Cookie` attribute. The given number will be converted to an integer
|
|
45
|
+
* by rounding down. By default, no maximum age is set.
|
|
46
|
+
*
|
|
47
|
+
* Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
|
|
48
|
+
* states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
|
|
49
|
+
* possible not all clients by obey this, so if both are set, they should
|
|
50
|
+
* point to the same date and time.
|
|
51
|
+
*/
|
|
52
|
+
maxAge?: number | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
|
|
55
|
+
* By default, the path is considered the "default path".
|
|
56
|
+
*/
|
|
57
|
+
path?: string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
|
|
60
|
+
*
|
|
61
|
+
* - `'low'` will set the `Priority` attribute to `Low`.
|
|
62
|
+
* - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
|
63
|
+
* - `'high'` will set the `Priority` attribute to `High`.
|
|
64
|
+
*
|
|
65
|
+
* More information about the different priority levels can be found in
|
|
66
|
+
* [the specification][rfc-west-cookie-priority-00-4.1].
|
|
67
|
+
*
|
|
68
|
+
* **note** This is an attribute that has not yet been fully standardized, and may change in the future.
|
|
69
|
+
* This also means many clients may ignore this attribute until they understand it.
|
|
70
|
+
*/
|
|
71
|
+
priority?: "low" | "medium" | "high" | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
|
|
74
|
+
*
|
|
75
|
+
* - `true` will set the `SameSite` attribute to `Strict` for strict same
|
|
76
|
+
* site enforcement.
|
|
77
|
+
* - `false` will not set the `SameSite` attribute.
|
|
78
|
+
* - `'lax'` will set the `SameSite` attribute to Lax for lax same site
|
|
79
|
+
* enforcement.
|
|
80
|
+
* - `'strict'` will set the `SameSite` attribute to Strict for strict same
|
|
81
|
+
* site enforcement.
|
|
82
|
+
* - `'none'` will set the SameSite attribute to None for an explicit
|
|
83
|
+
* cross-site cookie.
|
|
84
|
+
*
|
|
85
|
+
* More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
|
|
86
|
+
*
|
|
87
|
+
* note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
|
|
88
|
+
*/
|
|
89
|
+
sameSite?: true | false | "lax" | "strict" | "none" | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5 | `Secure` `Set-Cookie` attribute}. When truthy, the
|
|
92
|
+
* `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
|
|
93
|
+
*
|
|
94
|
+
* Note* be careful when setting this to `true`, as compliant clients will
|
|
95
|
+
* not send the cookie back to the server in the future if the browser does
|
|
96
|
+
* not have an HTTPS connection.
|
|
97
|
+
*/
|
|
98
|
+
secure?: boolean | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1)
|
|
101
|
+
* attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the
|
|
102
|
+
* `Partitioned` attribute is not set.
|
|
103
|
+
*
|
|
104
|
+
* **note** This is an attribute that has not yet been fully standardized, and may change in the future.
|
|
105
|
+
* This also means many clients may ignore this attribute until they understand it.
|
|
106
|
+
*
|
|
107
|
+
* More information can be found in the [proposal](https://github.com/privacycg/CHIPS).
|
|
108
|
+
*/
|
|
109
|
+
partitioned?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Additional parsing options
|
|
113
|
+
*/
|
|
114
|
+
export interface CookieParseOptions {
|
|
115
|
+
/**
|
|
116
|
+
* Specifies a function that will be used to decode a cookie's value. Since
|
|
117
|
+
* the value of a cookie has a limited character set (and must be a simple
|
|
118
|
+
* string), this function can be used to decode a previously-encoded cookie
|
|
119
|
+
* value into a JavaScript string or other object.
|
|
120
|
+
*
|
|
121
|
+
* The default function is the global `decodeURIComponent`, which will decode
|
|
122
|
+
* any URL-encoded sequences into their byte representations.
|
|
123
|
+
*
|
|
124
|
+
* Note* if an error is thrown from this function, the original, non-decoded
|
|
125
|
+
* cookie value will be returned as the cookie's value.
|
|
126
|
+
*/
|
|
127
|
+
decode?: (value: string) => string;
|
|
128
|
+
/**
|
|
129
|
+
* Custom function to filter parsing specific keys.
|
|
130
|
+
*/
|
|
131
|
+
filter?: (key: string) => boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface SetCookieParseOptions {
|
|
134
|
+
/**
|
|
135
|
+
* Custom decode function to use on cookie values.
|
|
136
|
+
*
|
|
137
|
+
* By default, `decodeURIComponent` is used.
|
|
138
|
+
*
|
|
139
|
+
* **Note:** If decoding fails, the original (undecoded) value will be used
|
|
140
|
+
*/
|
|
141
|
+
decode?: false | ((value: string) => string);
|
|
142
|
+
}
|
|
143
|
+
export interface SetCookie {
|
|
144
|
+
/**
|
|
145
|
+
* Cookie name
|
|
146
|
+
*/
|
|
147
|
+
name: string;
|
|
148
|
+
/**
|
|
149
|
+
* Cookie value
|
|
150
|
+
*/
|
|
151
|
+
value: string;
|
|
152
|
+
/**
|
|
153
|
+
* Cookie path
|
|
154
|
+
*/
|
|
155
|
+
path?: string | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Absolute expiration date for the cookie
|
|
158
|
+
*/
|
|
159
|
+
expires?: Date | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Relative max age of the cookie in seconds from when the client receives it (integer or undefined)
|
|
162
|
+
*
|
|
163
|
+
* Note: when using with express's res.cookie() method, multiply maxAge by 1000 to convert to milliseconds
|
|
164
|
+
*/
|
|
165
|
+
maxAge?: number | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* Domain for the cookie,
|
|
168
|
+
* May begin with "." to indicate the named domain or any subdomain of it
|
|
169
|
+
*/
|
|
170
|
+
domain?: string | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Indicates that this cookie should only be sent over HTTPs
|
|
173
|
+
*/
|
|
174
|
+
secure?: boolean | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Indicates that this cookie should not be accessible to client-side JavaScript
|
|
177
|
+
*/
|
|
178
|
+
httpOnly?: boolean | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Indicates a cookie ought not to be sent along with cross-site requests
|
|
181
|
+
*/
|
|
182
|
+
sameSite?: true | false | "lax" | "strict" | "none" | undefined;
|
|
183
|
+
[key: string]: unknown;
|
|
184
|
+
}
|
package/dist/types.mjs
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stryke/cookie",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A package containing HTTP Cookie utilities used by Storm Software.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "github",
|
|
8
|
+
"url": "https://github.com/storm-software/stryke.git",
|
|
9
|
+
"directory": "packages/cookie"
|
|
10
|
+
},
|
|
11
|
+
"private": false,
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@stryke/convert": "^0.5.0",
|
|
14
|
+
"@stryke/type-checks": "^0.3.9"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": { "access": "public" },
|
|
17
|
+
"devDependencies": {},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"files": ["dist/**/*"],
|
|
20
|
+
"homepage": "https://stormsoftware.com",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://stormsoftware.com/support",
|
|
23
|
+
"email": "support@stormsoftware.com"
|
|
24
|
+
},
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"keywords": [
|
|
27
|
+
"stryke",
|
|
28
|
+
"typescript",
|
|
29
|
+
"utilities",
|
|
30
|
+
"storm-software",
|
|
31
|
+
"storm",
|
|
32
|
+
"storm-ops",
|
|
33
|
+
"cyclone-ui",
|
|
34
|
+
"sullivanpj",
|
|
35
|
+
"monorepo"
|
|
36
|
+
],
|
|
37
|
+
"funding": {
|
|
38
|
+
"type": "github",
|
|
39
|
+
"url": "https://github.com/sponsors/storm-software"
|
|
40
|
+
},
|
|
41
|
+
"author": {
|
|
42
|
+
"name": "Storm Software",
|
|
43
|
+
"email": "contact@stormsoftware.com",
|
|
44
|
+
"url": "https://stormsoftware.com"
|
|
45
|
+
},
|
|
46
|
+
"maintainers": [
|
|
47
|
+
{
|
|
48
|
+
"name": "Storm Software",
|
|
49
|
+
"email": "contact@stormsoftware.com",
|
|
50
|
+
"url": "https://stormsoftware.com"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"contributors": [
|
|
54
|
+
{
|
|
55
|
+
"name": "Storm Software",
|
|
56
|
+
"email": "contact@stormsoftware.com",
|
|
57
|
+
"url": "https://stormsoftware.com"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"exports": {
|
|
61
|
+
"./types": {
|
|
62
|
+
"import": { "types": "./dist/types.d.ts", "default": "./dist/types.mjs" },
|
|
63
|
+
"require": {
|
|
64
|
+
"types": "./dist/types.d.ts",
|
|
65
|
+
"default": "./dist/types.cjs"
|
|
66
|
+
},
|
|
67
|
+
"default": { "types": "./dist/types.d.ts", "default": "./dist/types.mjs" }
|
|
68
|
+
},
|
|
69
|
+
"./stringify": {
|
|
70
|
+
"import": {
|
|
71
|
+
"types": "./dist/stringify.d.ts",
|
|
72
|
+
"default": "./dist/stringify.mjs"
|
|
73
|
+
},
|
|
74
|
+
"require": {
|
|
75
|
+
"types": "./dist/stringify.d.ts",
|
|
76
|
+
"default": "./dist/stringify.cjs"
|
|
77
|
+
},
|
|
78
|
+
"default": {
|
|
79
|
+
"types": "./dist/stringify.d.ts",
|
|
80
|
+
"default": "./dist/stringify.mjs"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"./split": {
|
|
84
|
+
"import": { "types": "./dist/split.d.ts", "default": "./dist/split.mjs" },
|
|
85
|
+
"require": {
|
|
86
|
+
"types": "./dist/split.d.ts",
|
|
87
|
+
"default": "./dist/split.cjs"
|
|
88
|
+
},
|
|
89
|
+
"default": { "types": "./dist/split.d.ts", "default": "./dist/split.mjs" }
|
|
90
|
+
},
|
|
91
|
+
"./parse": {
|
|
92
|
+
"import": { "types": "./dist/parse.d.ts", "default": "./dist/parse.mjs" },
|
|
93
|
+
"require": {
|
|
94
|
+
"types": "./dist/parse.d.ts",
|
|
95
|
+
"default": "./dist/parse.cjs"
|
|
96
|
+
},
|
|
97
|
+
"default": { "types": "./dist/parse.d.ts", "default": "./dist/parse.mjs" }
|
|
98
|
+
},
|
|
99
|
+
"./index": {
|
|
100
|
+
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
|
|
101
|
+
"require": {
|
|
102
|
+
"types": "./dist/index.d.ts",
|
|
103
|
+
"default": "./dist/index.cjs"
|
|
104
|
+
},
|
|
105
|
+
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
|
|
106
|
+
},
|
|
107
|
+
".": {
|
|
108
|
+
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
|
|
109
|
+
"require": {
|
|
110
|
+
"types": "./dist/index.d.ts",
|
|
111
|
+
"default": "./dist/index.cjs"
|
|
112
|
+
},
|
|
113
|
+
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
|
|
114
|
+
},
|
|
115
|
+
"./package.json": "./package.json"
|
|
116
|
+
},
|
|
117
|
+
"main": "./dist/index.cjs",
|
|
118
|
+
"module": "./dist/index.mjs",
|
|
119
|
+
"types": "./dist/index.d.ts",
|
|
120
|
+
"gitHead": "e16a03d7f9db49ef07f8b9368c56182fa84e2bf6"
|
|
121
|
+
}
|