ru.Bee 1.3.2 → 1.4.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.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rubee +114 -88
  3. data/lib/app/views/app.tsx +27 -0
  4. data/lib/app/views/index.html +47 -0
  5. data/lib/app/views/layout.erb +3 -3
  6. data/lib/app/views/utils/redirectToBackend.tsx +9 -0
  7. data/lib/app/views/welcome_show.erb +1 -1
  8. data/lib/config/base_configuration.rb +15 -6
  9. data/lib/config/routes.rb +2 -1
  10. data/lib/db/create_accounts.rb +8 -8
  11. data/lib/db/create_comments.rb +7 -7
  12. data/lib/db/create_posts.rb +8 -8
  13. data/lib/db/create_users.rb +8 -8
  14. data/lib/db/structure.rb +42 -42
  15. data/lib/esbuild.config.js +33 -0
  16. data/lib/inits/print_colors.rb +1 -1
  17. data/lib/js/app.js +13 -0
  18. data/lib/js/app.js.map +7 -0
  19. data/lib/js/bundle.js +26157 -0
  20. data/lib/js/bundle.js.map +7 -0
  21. data/lib/node_modules/@types/cookie/LICENSE +21 -0
  22. data/lib/node_modules/@types/cookie/README.md +15 -0
  23. data/lib/node_modules/@types/cookie/index.d.ts +154 -0
  24. data/lib/node_modules/@types/cookie/package.json +30 -0
  25. data/lib/node_modules/cookie/LICENSE +24 -0
  26. data/lib/node_modules/cookie/README.md +248 -0
  27. data/lib/node_modules/cookie/dist/index.d.ts +114 -0
  28. data/lib/node_modules/cookie/dist/index.js +239 -0
  29. data/lib/node_modules/cookie/dist/index.js.map +1 -0
  30. data/lib/node_modules/cookie/package.json +42 -0
  31. data/lib/node_modules/js-tokens/CHANGELOG.md +151 -0
  32. data/lib/node_modules/js-tokens/LICENSE +21 -0
  33. data/lib/node_modules/js-tokens/README.md +240 -0
  34. data/lib/node_modules/js-tokens/index.js +23 -0
  35. data/lib/node_modules/js-tokens/package.json +30 -0
  36. data/lib/node_modules/loose-envify/LICENSE +21 -0
  37. data/lib/node_modules/loose-envify/README.md +45 -0
  38. data/lib/node_modules/loose-envify/cli.js +16 -0
  39. data/lib/node_modules/loose-envify/custom.js +4 -0
  40. data/lib/node_modules/loose-envify/index.js +3 -0
  41. data/lib/node_modules/loose-envify/loose-envify.js +36 -0
  42. data/lib/node_modules/loose-envify/package.json +36 -0
  43. data/lib/node_modules/loose-envify/replace.js +65 -0
  44. data/lib/node_modules/react/LICENSE +21 -0
  45. data/lib/node_modules/react/README.md +37 -0
  46. data/lib/node_modules/react/cjs/react-jsx-dev-runtime.development.js +1315 -0
  47. data/lib/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +10 -0
  48. data/lib/node_modules/react/cjs/react-jsx-dev-runtime.profiling.min.js +10 -0
  49. data/lib/node_modules/react/cjs/react-jsx-runtime.development.js +1333 -0
  50. data/lib/node_modules/react/cjs/react-jsx-runtime.production.min.js +11 -0
  51. data/lib/node_modules/react/cjs/react-jsx-runtime.profiling.min.js +11 -0
  52. data/lib/node_modules/react/cjs/react.development.js +2740 -0
  53. data/lib/node_modules/react/cjs/react.production.min.js +26 -0
  54. data/lib/node_modules/react/cjs/react.shared-subset.development.js +20 -0
  55. data/lib/node_modules/react/cjs/react.shared-subset.production.min.js +10 -0
  56. data/lib/node_modules/react/index.js +7 -0
  57. data/lib/node_modules/react/jsx-dev-runtime.js +7 -0
  58. data/lib/node_modules/react/jsx-runtime.js +7 -0
  59. data/lib/node_modules/react/package.json +47 -0
  60. data/lib/node_modules/react/react.shared-subset.js +7 -0
  61. data/lib/node_modules/react/umd/react.development.js +3343 -0
  62. data/lib/node_modules/react/umd/react.production.min.js +31 -0
  63. data/lib/node_modules/react/umd/react.profiling.min.js +31 -0
  64. data/lib/node_modules/react-dom/LICENSE +21 -0
  65. data/lib/node_modules/react-dom/README.md +60 -0
  66. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +7029 -0
  67. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +93 -0
  68. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js +7093 -0
  69. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js +101 -0
  70. data/lib/node_modules/react-dom/cjs/react-dom-server.browser.development.js +7014 -0
  71. data/lib/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js +96 -0
  72. data/lib/node_modules/react-dom/cjs/react-dom-server.node.development.js +7070 -0
  73. data/lib/node_modules/react-dom/cjs/react-dom-server.node.production.min.js +102 -0
  74. data/lib/node_modules/react-dom/cjs/react-dom-test-utils.development.js +1763 -0
  75. data/lib/node_modules/react-dom/cjs/react-dom-test-utils.production.min.js +40 -0
  76. data/lib/node_modules/react-dom/cjs/react-dom.development.js +29923 -0
  77. data/lib/node_modules/react-dom/cjs/react-dom.production.min.js +322 -0
  78. data/lib/node_modules/react-dom/cjs/react-dom.profiling.min.js +366 -0
  79. data/lib/node_modules/react-dom/client.js +25 -0
  80. data/lib/node_modules/react-dom/index.js +38 -0
  81. data/lib/node_modules/react-dom/package.json +62 -0
  82. data/lib/node_modules/react-dom/profiling.js +38 -0
  83. data/lib/node_modules/react-dom/server.browser.js +17 -0
  84. data/lib/node_modules/react-dom/server.js +3 -0
  85. data/lib/node_modules/react-dom/server.node.js +17 -0
  86. data/lib/node_modules/react-dom/test-utils.js +7 -0
  87. data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.development.js +7026 -0
  88. data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.production.min.js +75 -0
  89. data/lib/node_modules/react-dom/umd/react-dom-server.browser.development.js +7011 -0
  90. data/lib/node_modules/react-dom/umd/react-dom-server.browser.production.min.js +76 -0
  91. data/lib/node_modules/react-dom/umd/react-dom-test-utils.development.js +1759 -0
  92. data/lib/node_modules/react-dom/umd/react-dom-test-utils.production.min.js +33 -0
  93. data/lib/node_modules/react-dom/umd/react-dom.development.js +29924 -0
  94. data/lib/node_modules/react-dom/umd/react-dom.production.min.js +267 -0
  95. data/lib/node_modules/react-dom/umd/react-dom.profiling.min.js +285 -0
  96. data/lib/node_modules/react-router/CHANGELOG.md +1526 -0
  97. data/lib/node_modules/react-router/LICENSE.md +23 -0
  98. data/lib/node_modules/react-router/README.md +7 -0
  99. data/lib/node_modules/react-router/dist/development/chunk-KNED5TY2.mjs +10476 -0
  100. data/lib/node_modules/react-router/dist/development/dom-export.d.mts +23 -0
  101. data/lib/node_modules/react-router/dist/development/dom-export.d.ts +23 -0
  102. data/lib/node_modules/react-router/dist/development/dom-export.js +6111 -0
  103. data/lib/node_modules/react-router/dist/development/dom-export.mjs +234 -0
  104. data/lib/node_modules/react-router/dist/development/fog-of-war-1hWhK5ey.d.mts +1690 -0
  105. data/lib/node_modules/react-router/dist/development/fog-of-war-oa9CGk10.d.ts +1690 -0
  106. data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.mts +21 -0
  107. data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.ts +21 -0
  108. data/lib/node_modules/react-router/dist/development/index.d.mts +841 -0
  109. data/lib/node_modules/react-router/dist/development/index.d.ts +841 -0
  110. data/lib/node_modules/react-router/dist/development/index.js +10624 -0
  111. data/lib/node_modules/react-router/dist/development/index.mjs +242 -0
  112. data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.mts +209 -0
  113. data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.ts +209 -0
  114. data/lib/node_modules/react-router/dist/development/lib/types/route-module.js +28 -0
  115. data/lib/node_modules/react-router/dist/development/lib/types/route-module.mjs +10 -0
  116. data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.mts +1716 -0
  117. data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.ts +1716 -0
  118. data/lib/node_modules/react-router/dist/production/chunk-ZIM7OIE3.mjs +10476 -0
  119. data/lib/node_modules/react-router/dist/production/dom-export.d.mts +23 -0
  120. data/lib/node_modules/react-router/dist/production/dom-export.d.ts +23 -0
  121. data/lib/node_modules/react-router/dist/production/dom-export.js +6111 -0
  122. data/lib/node_modules/react-router/dist/production/dom-export.mjs +234 -0
  123. data/lib/node_modules/react-router/dist/production/fog-of-war-1hWhK5ey.d.mts +1690 -0
  124. data/lib/node_modules/react-router/dist/production/fog-of-war-oa9CGk10.d.ts +1690 -0
  125. data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.mts +21 -0
  126. data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.ts +21 -0
  127. data/lib/node_modules/react-router/dist/production/index.d.mts +841 -0
  128. data/lib/node_modules/react-router/dist/production/index.d.ts +841 -0
  129. data/lib/node_modules/react-router/dist/production/index.js +10624 -0
  130. data/lib/node_modules/react-router/dist/production/index.mjs +242 -0
  131. data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.mts +209 -0
  132. data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.ts +209 -0
  133. data/lib/node_modules/react-router/dist/production/lib/types/route-module.js +28 -0
  134. data/lib/node_modules/react-router/dist/production/lib/types/route-module.mjs +10 -0
  135. data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.mts +1716 -0
  136. data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.ts +1716 -0
  137. data/lib/node_modules/react-router/package.json +116 -0
  138. data/lib/node_modules/react-router-dom/LICENSE.md +23 -0
  139. data/lib/node_modules/react-router-dom/README.md +6 -0
  140. data/lib/node_modules/react-router-dom/dist/index.d.mts +2 -0
  141. data/lib/node_modules/react-router-dom/dist/index.d.ts +2 -0
  142. data/lib/node_modules/react-router-dom/dist/index.js +45 -0
  143. data/lib/node_modules/react-router-dom/dist/index.mjs +18 -0
  144. data/lib/node_modules/react-router-dom/package.json +82 -0
  145. data/lib/node_modules/scheduler/LICENSE +21 -0
  146. data/lib/node_modules/scheduler/README.md +9 -0
  147. data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.development.js +700 -0
  148. data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.production.min.js +20 -0
  149. data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.development.js +207 -0
  150. data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.production.min.js +14 -0
  151. data/lib/node_modules/scheduler/cjs/scheduler.development.js +634 -0
  152. data/lib/node_modules/scheduler/cjs/scheduler.production.min.js +19 -0
  153. data/lib/node_modules/scheduler/index.js +7 -0
  154. data/lib/node_modules/scheduler/package.json +36 -0
  155. data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.development.js +699 -0
  156. data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.production.min.js +19 -0
  157. data/lib/node_modules/scheduler/umd/scheduler.development.js +152 -0
  158. data/lib/node_modules/scheduler/umd/scheduler.production.min.js +146 -0
  159. data/lib/node_modules/scheduler/umd/scheduler.profiling.min.js +146 -0
  160. data/lib/node_modules/scheduler/unstable_mock.js +7 -0
  161. data/lib/node_modules/scheduler/unstable_post_task.js +7 -0
  162. data/lib/node_modules/set-cookie-parser/LICENSE +21 -0
  163. data/lib/node_modules/set-cookie-parser/README.md +202 -0
  164. data/lib/node_modules/set-cookie-parser/lib/set-cookie.js +224 -0
  165. data/lib/node_modules/set-cookie-parser/package.json +45 -0
  166. data/lib/node_modules/turbo-stream/LICENSE +7 -0
  167. data/lib/node_modules/turbo-stream/README.md +31 -0
  168. data/lib/node_modules/turbo-stream/dist/flatten.d.ts +2 -0
  169. data/lib/node_modules/turbo-stream/dist/flatten.js +203 -0
  170. data/lib/node_modules/turbo-stream/dist/turbo-stream.d.ts +13 -0
  171. data/lib/node_modules/turbo-stream/dist/turbo-stream.js +207 -0
  172. data/lib/node_modules/turbo-stream/dist/turbo-stream.mjs +673 -0
  173. data/lib/node_modules/turbo-stream/dist/unflatten.d.ts +2 -0
  174. data/lib/node_modules/turbo-stream/dist/unflatten.js +243 -0
  175. data/lib/node_modules/turbo-stream/dist/utils.d.ts +44 -0
  176. data/lib/node_modules/turbo-stream/dist/utils.js +55 -0
  177. data/lib/node_modules/turbo-stream/package.json +50 -0
  178. data/lib/package-lock.json +133 -0
  179. data/lib/package.json +12 -0
  180. data/lib/rubee/async/asyncable.rb +2 -2
  181. data/lib/rubee/async/sidekiq_async.rb +11 -11
  182. data/lib/rubee/async/thread_async.rb +1 -1
  183. data/lib/rubee/async/thread_pool.rb +2 -2
  184. data/lib/rubee/controllers/base_controller.rb +44 -21
  185. data/lib/rubee/controllers/extensions/auth_tokenable.rb +10 -8
  186. data/lib/rubee/controllers/extensions/middlewarable.rb +1 -1
  187. data/lib/rubee/controllers/middlewares/auth_token_middleware.rb +12 -8
  188. data/lib/rubee/extensions/hookable.rb +3 -6
  189. data/lib/rubee/extensions/serializable.rb +3 -3
  190. data/lib/rubee/models/database_objectable.rb +11 -12
  191. data/lib/rubee/models/sequel_object.rb +23 -24
  192. data/lib/rubee.rb +106 -55
  193. data/lib/tests/account_model_test.rb +4 -4
  194. data/lib/tests/auth_tokenable_test.rb +6 -6
  195. data/lib/tests/comment_model_test.rb +7 -7
  196. data/lib/tests/example_models/account.rb +1 -0
  197. data/lib/tests/example_models/comment.rb +1 -0
  198. data/lib/tests/example_models/post.rb +1 -0
  199. data/lib/tests/example_models/user.rb +1 -0
  200. data/lib/tests/rubeeapp_test.rb +21 -6
  201. data/lib/tests/test.db +0 -0
  202. data/lib/tests/test_helper.rb +3 -5
  203. data/lib/tests/user_model_test.rb +71 -54
  204. data/readme.md +104 -2
  205. metadata +170 -3
@@ -0,0 +1,202 @@
1
+ # set-cookie-parser
2
+
3
+ [![Node.js CI](https://github.com/nfriedly/set-cookie-parser/actions/workflows/node.js.yml/badge.svg)](https://github.com/nfriedly/set-cookie-parser/actions/workflows/node.js.yml)
4
+ [![NPM version][npm-image]][npm-url]
5
+ [![npm downloads](https://img.shields.io/npm/dm/set-cookie-parser)][npm-url]
6
+
7
+ ---
8
+
9
+ ℹ️ **Note for current users:** I'm considering some changes for the next major version and would appreciate your feedback: https://github.com/nfriedly/set-cookie-parser/discussions/68
10
+
11
+ ---
12
+
13
+ Parses set-cookie headers into JavaScript objects
14
+
15
+ Accepts a single `set-cookie` header value, an array of `set-cookie` header values, a Node.js response object, or a `fetch()` `Response` object that may have 0 or more `set-cookie` headers.
16
+
17
+ Also accepts an optional options object. Defaults:
18
+
19
+ ```js
20
+ {
21
+ decodeValues: true, // Calls decodeURIComponent on each value - default: true
22
+ map: false, // Return an object instead of an array - default: false
23
+ silent: false, // Suppress the warning that is logged when called on a request instead of a response - default: false
24
+ }
25
+ ```
26
+
27
+ Returns either an array of cookie objects or a map of name => cookie object with `{map: true}`. Each cookie object will have, at a minimum `name` and `value` properties, and may have additional properties depending on the set-cookie header:
28
+
29
+ * `name` - cookie name (string)
30
+ * `value` - cookie value (string)
31
+ * `path` - URL path to limit the scope to (string or undefined)
32
+ * `domain` - domain to expand the scope to (string or undefined, may begin with "." to indicate the named domain or any subdomain of it)
33
+ * `expires` - absolute expiration date for the cookie (Date object or undefined)
34
+ * `maxAge` - relative expiration time of the cookie in seconds from when the client receives it (integer or undefined)
35
+ * Note: when using with [express's res.cookie() method](http://expressjs.com/en/4x/api.html#res.cookie), multiply `maxAge` by 1000 to convert to milliseconds.
36
+ * `secure` - indicates cookie should only be sent over HTTPs (true or undefined)
37
+ * `httpOnly` - indicates cookie should *not* be accessible to client-side JavaScript (true or undefined)
38
+ * `sameSite` - indicates if cookie should be included in cross-site requests ([more info](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value)) (string or undefined)
39
+ * Note: valid values are `"Strict"`, `"Lax"`, and `"None"`, but set-cookie-parser coppies the value verbatim and does *not* perform any validation.
40
+ * `partitioned` - indicates cookie should be scoped to the combination of 3rd party domain + top page domain ([more info](https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies)) (true or undefined)
41
+
42
+ (The output format is loosely based on the input format of https://www.npmjs.com/package/cookie)
43
+
44
+ ## Install
45
+
46
+ ```sh
47
+ $ npm install --save set-cookie-parser
48
+ ```
49
+
50
+
51
+ ## Usage
52
+
53
+ ### Get array of cookie objects
54
+
55
+ ```js
56
+ var http = require('http');
57
+ var setCookie = require('set-cookie-parser');
58
+
59
+ http.get('http://example.com', function(res) {
60
+ var cookies = setCookie.parse(res, {
61
+ decodeValues: true // default: true
62
+ });
63
+
64
+ cookies.forEach(console.log);
65
+ }
66
+ ```
67
+
68
+ Example output:
69
+
70
+ ```js
71
+ [
72
+ {
73
+ name: 'bam',
74
+ value: 'baz'
75
+ },
76
+ {
77
+ name: 'foo',
78
+ value: 'bar',
79
+ path: '/',
80
+ expires: new Date('Tue Jul 01 2025 06:01:11 GMT-0400 (EDT)'),
81
+ maxAge: 1000,
82
+ domain: '.example.com',
83
+ secure: true,
84
+ httpOnly: true,
85
+ sameSite: 'lax'
86
+ }
87
+ ]
88
+ ```
89
+
90
+ ### Get map of cookie objects
91
+
92
+ ```js
93
+ var http = require('http');
94
+ var setCookie = require('set-cookie-parser');
95
+
96
+ http.get('http://example.com', function(res) {
97
+ var cookies = setCookie.parse(res, {
98
+ decodeValues: true, // default: true
99
+ map: true // default: false
100
+ });
101
+
102
+ var desiredCookie = cookies['session'];
103
+ console.log(desiredCookie);
104
+ });
105
+ ```
106
+ Example output:
107
+ ```js
108
+ {
109
+ bam: {
110
+ name: 'bam',
111
+ value: 'baz'
112
+ },
113
+ foo: {
114
+ name: 'foo',
115
+ value: 'bar',
116
+ path: '/',
117
+ expires: new Date('Tue Jul 01 2025 06:01:11 GMT-0400 (EDT)'),
118
+ maxAge: 1000,
119
+ domain: '.example.com',
120
+ secure: true,
121
+ httpOnly: true,
122
+ sameSite: 'lax'
123
+ }
124
+ }
125
+ ```
126
+
127
+ ### Creating a new, modified set-cookie header
128
+
129
+ This library can be used in conjunction with the [cookie](https://www.npmjs.com/package/cookie) library to modify and replace set-cookie headers:
130
+
131
+ ```js
132
+ const libCookie = require('cookie');
133
+ const setCookie = require('set-cookie-parser');
134
+
135
+ function modifySetCookie(res){
136
+ // parse the set-cookie headers with this library
137
+ let cookies = setCookie.parse(res);
138
+
139
+ // modify the cookies here
140
+ // ...
141
+
142
+ // create new set-cookie headers using the cookie library
143
+ res.headers['set-cookie'] = cookies.map(function(cookie) {
144
+ return libCookie.serialize(cookie.name, cookie.value, cookie);
145
+ });
146
+ }
147
+ ```
148
+
149
+ See a real-world example of this in [unblocker](https://github.com/nfriedly/node-unblocker/blob/08a89ec27274b46dcd80d0a324a59406f2bdad3d/lib/cookies.js#L67-L85)
150
+
151
+ ## Usage in React Native (and with some other fetch implementations)
152
+
153
+ React Native follows the Fetch spec more closely and combines all of the Set-Cookie header values into a single string.
154
+ The `splitCookiesString` method reverses this.
155
+
156
+ ```js
157
+ var setCookie = require('set-cookie-parser');
158
+
159
+ var response = fetch(/*...*/);
160
+
161
+ // This is mainly for React Native; Node.js does not combine set-cookie headers.
162
+ var combinedCookieHeader = response.headers.get('Set-Cookie');
163
+ var splitCookieHeaders = setCookie.splitCookiesString(combinedCookieHeader)
164
+ var cookies = setCookie.parse(splitCookieHeaders);
165
+
166
+ console.log(cookies); // should be an array of cookies
167
+ ```
168
+
169
+ This behavior may become a default part of parse in the next major release, but requires the extra step for now.
170
+
171
+ Note that the `fetch()` spec now includes a `getSetCookie()` method that provides un-combined `Set-Cookie` headers. This library will automatically use that method if it is present.
172
+
173
+ ## API
174
+
175
+ ### parse(input, [options])
176
+
177
+ Parses cookies from a string, array of strings, or a http response object.
178
+ Always returns an array, regardless of input format. (Unless the `map` option is set, in which case it always returns an object.)
179
+
180
+ ### parseString(individualSetCookieHeader, [options])
181
+
182
+ Parses a single set-cookie header value string. Options default is `{decodeValues: true}`. Used under-the-hood by `parse()`.
183
+ Returns an object.
184
+
185
+ ### splitCookiesString(combinedSetCookieHeader)
186
+
187
+ It's uncommon, but the HTTP spec does allow for multiple of the same header to have their values combined (comma-separated) into a single header.
188
+ This method splits apart a combined header without choking on commas that appear within a cookie's value (or expiration date).
189
+ Returns an array of strings that may be passed to `parse()`.
190
+
191
+ ## References
192
+
193
+ * [RFC 6265: HTTP State Management Mechanism](https://tools.ietf.org/html/rfc6265)
194
+ * [draft-ietf-httpbis-rfc6265bis-10](https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html)
195
+
196
+ ## License
197
+
198
+ MIT © [Nathan Friedly](http://www.nfriedly.com/)
199
+
200
+
201
+ [npm-image]: https://badge.fury.io/js/set-cookie-parser.svg
202
+ [npm-url]: https://npmjs.org/package/set-cookie-parser
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+
3
+ var defaultParseOptions = {
4
+ decodeValues: true,
5
+ map: false,
6
+ silent: false,
7
+ };
8
+
9
+ function isNonEmptyString(str) {
10
+ return typeof str === "string" && !!str.trim();
11
+ }
12
+
13
+ function parseString(setCookieValue, options) {
14
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
15
+
16
+ var nameValuePairStr = parts.shift();
17
+ var parsed = parseNameValuePair(nameValuePairStr);
18
+ var name = parsed.name;
19
+ var value = parsed.value;
20
+
21
+ options = options
22
+ ? Object.assign({}, defaultParseOptions, options)
23
+ : defaultParseOptions;
24
+
25
+ try {
26
+ value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
27
+ } catch (e) {
28
+ console.error(
29
+ "set-cookie-parser encountered an error while decoding a cookie with value '" +
30
+ value +
31
+ "'. Set options.decodeValues to false to disable this feature.",
32
+ e
33
+ );
34
+ }
35
+
36
+ var cookie = {
37
+ name: name,
38
+ value: value,
39
+ };
40
+
41
+ parts.forEach(function (part) {
42
+ var sides = part.split("=");
43
+ var key = sides.shift().trimLeft().toLowerCase();
44
+ var value = sides.join("=");
45
+ if (key === "expires") {
46
+ cookie.expires = new Date(value);
47
+ } else if (key === "max-age") {
48
+ cookie.maxAge = parseInt(value, 10);
49
+ } else if (key === "secure") {
50
+ cookie.secure = true;
51
+ } else if (key === "httponly") {
52
+ cookie.httpOnly = true;
53
+ } else if (key === "samesite") {
54
+ cookie.sameSite = value;
55
+ } else if (key === "partitioned") {
56
+ cookie.partitioned = true;
57
+ } else {
58
+ cookie[key] = value;
59
+ }
60
+ });
61
+
62
+ return cookie;
63
+ }
64
+
65
+ function parseNameValuePair(nameValuePairStr) {
66
+ // Parses name-value-pair according to rfc6265bis draft
67
+
68
+ var name = "";
69
+ var value = "";
70
+ var nameValueArr = nameValuePairStr.split("=");
71
+ if (nameValueArr.length > 1) {
72
+ name = nameValueArr.shift();
73
+ value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
74
+ } else {
75
+ value = nameValuePairStr;
76
+ }
77
+
78
+ return { name: name, value: value };
79
+ }
80
+
81
+ function parse(input, options) {
82
+ options = options
83
+ ? Object.assign({}, defaultParseOptions, options)
84
+ : defaultParseOptions;
85
+
86
+ if (!input) {
87
+ if (!options.map) {
88
+ return [];
89
+ } else {
90
+ return {};
91
+ }
92
+ }
93
+
94
+ if (input.headers) {
95
+ if (typeof input.headers.getSetCookie === "function") {
96
+ // for fetch responses - they combine headers of the same type in the headers array,
97
+ // but getSetCookie returns an uncombined array
98
+ input = input.headers.getSetCookie();
99
+ } else if (input.headers["set-cookie"]) {
100
+ // fast-path for node.js (which automatically normalizes header names to lower-case
101
+ input = input.headers["set-cookie"];
102
+ } else {
103
+ // slow-path for other environments - see #25
104
+ var sch =
105
+ input.headers[
106
+ Object.keys(input.headers).find(function (key) {
107
+ return key.toLowerCase() === "set-cookie";
108
+ })
109
+ ];
110
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
111
+ if (!sch && input.headers.cookie && !options.silent) {
112
+ console.warn(
113
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
114
+ );
115
+ }
116
+ input = sch;
117
+ }
118
+ }
119
+ if (!Array.isArray(input)) {
120
+ input = [input];
121
+ }
122
+
123
+ if (!options.map) {
124
+ return input.filter(isNonEmptyString).map(function (str) {
125
+ return parseString(str, options);
126
+ });
127
+ } else {
128
+ var cookies = {};
129
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
130
+ var cookie = parseString(str, options);
131
+ cookies[cookie.name] = cookie;
132
+ return cookies;
133
+ }, cookies);
134
+ }
135
+ }
136
+
137
+ /*
138
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
139
+ that are within a single set-cookie field-value, such as in the Expires portion.
140
+
141
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
142
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
143
+ React Native's fetch does this for *every* header, including set-cookie.
144
+
145
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
146
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
147
+ */
148
+ function splitCookiesString(cookiesString) {
149
+ if (Array.isArray(cookiesString)) {
150
+ return cookiesString;
151
+ }
152
+ if (typeof cookiesString !== "string") {
153
+ return [];
154
+ }
155
+
156
+ var cookiesStrings = [];
157
+ var pos = 0;
158
+ var start;
159
+ var ch;
160
+ var lastComma;
161
+ var nextStart;
162
+ var cookiesSeparatorFound;
163
+
164
+ function skipWhitespace() {
165
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
166
+ pos += 1;
167
+ }
168
+ return pos < cookiesString.length;
169
+ }
170
+
171
+ function notSpecialChar() {
172
+ ch = cookiesString.charAt(pos);
173
+
174
+ return ch !== "=" && ch !== ";" && ch !== ",";
175
+ }
176
+
177
+ while (pos < cookiesString.length) {
178
+ start = pos;
179
+ cookiesSeparatorFound = false;
180
+
181
+ while (skipWhitespace()) {
182
+ ch = cookiesString.charAt(pos);
183
+ if (ch === ",") {
184
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
185
+ lastComma = pos;
186
+ pos += 1;
187
+
188
+ skipWhitespace();
189
+ nextStart = pos;
190
+
191
+ while (pos < cookiesString.length && notSpecialChar()) {
192
+ pos += 1;
193
+ }
194
+
195
+ // currently special character
196
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
197
+ // we found cookies separator
198
+ cookiesSeparatorFound = true;
199
+ // pos is inside the next cookie, so back up and return it.
200
+ pos = nextStart;
201
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
202
+ start = pos;
203
+ } else {
204
+ // in param ',' or param separator ';',
205
+ // we continue from that comma
206
+ pos = lastComma + 1;
207
+ }
208
+ } else {
209
+ pos += 1;
210
+ }
211
+ }
212
+
213
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
214
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
215
+ }
216
+ }
217
+
218
+ return cookiesStrings;
219
+ }
220
+
221
+ module.exports = parse;
222
+ module.exports.parse = parse;
223
+ module.exports.parseString = parseString;
224
+ module.exports.splitCookiesString = splitCookiesString;
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "set-cookie-parser",
3
+ "version": "2.7.1",
4
+ "description": "Parses set-cookie headers into objects",
5
+ "homepage": "https://github.com/nfriedly/set-cookie-parser",
6
+ "repository": "nfriedly/set-cookie-parser",
7
+ "author": {
8
+ "name": "Nathan Friedly",
9
+ "url": "http://nfriedly.com/"
10
+ },
11
+ "files": [
12
+ "lib"
13
+ ],
14
+ "main": "./lib/set-cookie.js",
15
+ "sideEffects": false,
16
+ "keywords": [
17
+ "set-cookie",
18
+ "set",
19
+ "cookie",
20
+ "cookies",
21
+ "header",
22
+ "parse",
23
+ "parser"
24
+ ],
25
+ "devDependencies": {
26
+ "eslint": "^8.57.0",
27
+ "eslint-config-prettier": "^9.1.0",
28
+ "eslint-plugin-prettier": "^5.1.3",
29
+ "husky": "^9.0.11",
30
+ "mocha": "^10.3.0",
31
+ "prettier": "^3.2.5",
32
+ "pretty-quick": "^4.0.0",
33
+ "sinon": "^17.0.1"
34
+ },
35
+ "scripts": {
36
+ "lint": "eslint . --ignore-pattern '!.eslintrc.js'",
37
+ "test": "npm run lint && mocha",
38
+ "autofix": "npm run lint -- --fix",
39
+ "precommit": "npm test"
40
+ },
41
+ "license": "MIT",
42
+ "prettier": {
43
+ "trailingComma": "es5"
44
+ }
45
+ }
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2018-19 [these people](https://github.com/rich-harris/devalue/graphs/contributors)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Turbo Stream <br> [![turbo-stream's badge](https://deno.bundlejs.com/?q=turbo-stream&badge=detailed)](https://bundlejs.com/?q=turbo-stream)
2
+
3
+ A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.
4
+
5
+ Decode runtime size: [![turbo-stream's badge](https://deno.bundlejs.com/badge?q=turbo-stream&badge=detailed&treeshake=%5B%7B+decode+%7D%5D)](https://bundlejs.com/?q=turbo-stream&treeshake=%5B%7B+decode+%7D%5D)
6
+
7
+ ## Shout Out!
8
+
9
+ Shout out to Rich Harris and his https://github.com/rich-harris/devalue project. Devalue has heavily influenced this project and portions
10
+ of the code have been directly lifted from it. I highly recommend checking it out if you need something more cusomizable or without streaming support.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install turbo-stream
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```js
21
+ import { decode, encode } from "turbo-stream";
22
+
23
+ const encodedStream = encode(Promise.resolve(42));
24
+ const decoded = await decode(encodedStream);
25
+ console.log(decoded.value); // a Promise
26
+ console.log(await decoded.value); // 42
27
+ await decoded.done; // wait for the stream to finish
28
+ ```
29
+
30
+ Stackblitz: https://stackblitz.com/edit/stackblitz-starters-2wm7dh?file=index.js
31
+ React SSR Example: https://github.com/jacob-ebey/turbo-stream-react-example
@@ -0,0 +1,2 @@
1
+ import { type ThisEncode } from "./utils.js";
2
+ export declare function flatten(this: ThisEncode, input: unknown): number | [number];