@miqro/core 1.3.9 → 1.4.2

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 (114) hide show
  1. package/README.md +0 -18
  2. package/dist/handler/app.d.ts +1 -2
  3. package/dist/handler/app.js +2 -3
  4. package/dist/handler/app.js.map +1 -1
  5. package/dist/handler/common/context.d.ts +2 -10
  6. package/dist/handler/common/context.js +4 -4
  7. package/dist/handler/common/context.js.map +1 -1
  8. package/dist/handler/common/index.js.map +1 -1
  9. package/dist/handler/common/router-utils.js.map +1 -1
  10. package/dist/handler/middleware/cookie.js +2 -2
  11. package/dist/handler/middleware/cookie.js.map +1 -1
  12. package/dist/handler/middleware/form.js.map +1 -1
  13. package/dist/handler/middleware/index.js.map +1 -1
  14. package/dist/handler/middleware/json.js.map +1 -1
  15. package/dist/handler/middleware/session.js.map +1 -1
  16. package/dist/handler/middleware/text.js.map +1 -1
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.js +0 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/util/cli/index.d.ts +2 -1
  21. package/dist/util/cli/index.js.map +1 -1
  22. package/dist/util/error/configfilenotfound.js.map +1 -1
  23. package/dist/util/error/forbiddenerror.js.map +1 -1
  24. package/dist/util/error/notfound.js.map +1 -1
  25. package/dist/util/error/notimplemented.js.map +1 -1
  26. package/dist/util/error/parsererror.js.map +1 -1
  27. package/dist/util/error/unauthorizederror.js.map +1 -1
  28. package/dist/util/index.js +0 -2
  29. package/dist/util/index.js.map +1 -1
  30. package/dist/util/session/service.js +2 -2
  31. package/dist/util/session/service.js.map +1 -1
  32. package/package.json +12 -5
  33. package/src/handler/app.ts +2 -2
  34. package/src/handler/common/context.ts +5 -14
  35. package/src/handler/common/index.ts +1 -2
  36. package/src/handler/common/router-utils.ts +44 -51
  37. package/src/handler/middleware/cookie.ts +12 -12
  38. package/src/handler/middleware/form.ts +1 -1
  39. package/src/handler/middleware/index.ts +24 -24
  40. package/src/handler/middleware/json.ts +1 -1
  41. package/src/handler/middleware/session.ts +128 -128
  42. package/src/handler/middleware/text.ts +1 -1
  43. package/src/index.ts +0 -1
  44. package/src/util/cli/index.ts +2 -1
  45. package/src/util/error/configfilenotfound.ts +1 -1
  46. package/src/util/error/forbiddenerror.ts +1 -1
  47. package/src/util/error/notfound.ts +1 -1
  48. package/src/util/error/notimplemented.ts +1 -1
  49. package/src/util/error/parsererror.ts +1 -1
  50. package/src/util/error/unauthorizederror.ts +1 -1
  51. package/src/util/index.ts +0 -2
  52. package/src/util/parser/common.ts +1 -1
  53. package/src/util/parser/index.ts +0 -3
  54. package/src/util/request/index.ts +1 -1
  55. package/src/util/session/index.ts +1 -1
  56. package/src/util/session/service.ts +126 -126
  57. package/dist/test/common/app.d.ts +0 -3
  58. package/dist/test/common/app.js +0 -51
  59. package/dist/test/common/app.js.map +0 -1
  60. package/dist/test/common/common.d.ts +0 -6
  61. package/dist/test/common/common.js +0 -15
  62. package/dist/test/common/common.js.map +0 -1
  63. package/dist/test/common/index.d.ts +0 -3
  64. package/dist/test/common/index.js +0 -16
  65. package/dist/test/common/index.js.map +0 -1
  66. package/dist/test/common/runner.d.ts +0 -28
  67. package/dist/test/common/runner.js +0 -88
  68. package/dist/test/common/runner.js.map +0 -1
  69. package/dist/test/index.d.ts +0 -1
  70. package/dist/test/index.js +0 -14
  71. package/dist/test/index.js.map +0 -1
  72. package/dist/test/main.d.ts +0 -1
  73. package/dist/test/main.js +0 -31
  74. package/dist/test/main.js.map +0 -1
  75. package/dist/util/cookie/cookie.d.ts +0 -50
  76. package/dist/util/cookie/cookie.js +0 -168
  77. package/dist/util/cookie/cookie.js.map +0 -1
  78. package/dist/util/cookie/index.d.ts +0 -16
  79. package/dist/util/cookie/index.js +0 -9
  80. package/dist/util/cookie/index.js.map +0 -1
  81. package/dist/util/uuid/index.d.ts +0 -7
  82. package/dist/util/uuid/index.js +0 -8
  83. package/dist/util/uuid/index.js.map +0 -1
  84. package/dist/util/uuid/regex.d.ts +0 -2
  85. package/dist/util/uuid/regex.js +0 -5
  86. package/dist/util/uuid/regex.js.map +0 -1
  87. package/dist/util/uuid/rng.d.ts +0 -1
  88. package/dist/util/uuid/rng.js +0 -18
  89. package/dist/util/uuid/rng.js.map +0 -1
  90. package/dist/util/uuid/stringify.d.ts +0 -2
  91. package/dist/util/uuid/stringify.js +0 -50
  92. package/dist/util/uuid/stringify.js.map +0 -1
  93. package/dist/util/uuid/v4.d.ts +0 -5
  94. package/dist/util/uuid/v4.js +0 -27
  95. package/dist/util/uuid/v4.js.map +0 -1
  96. package/dist/util/uuid/validate.d.ts +0 -2
  97. package/dist/util/uuid/validate.js +0 -12
  98. package/dist/util/uuid/validate.js.map +0 -1
  99. package/src/test/common/app.ts +0 -45
  100. package/src/test/common/common.ts +0 -17
  101. package/src/test/common/index.ts +0 -3
  102. package/src/test/common/runner.ts +0 -116
  103. package/src/test/index.ts +0 -1
  104. package/src/test/main.ts +0 -32
  105. package/src/util/cookie/cookie.ts +0 -207
  106. package/src/util/cookie/index.ts +0 -6
  107. package/src/util/uuid/index.ts +0 -5
  108. package/src/util/uuid/regex.ts +0 -2
  109. package/src/util/uuid/rng.ts +0 -14
  110. package/src/util/uuid/stringify.ts +0 -53
  111. package/src/util/uuid/v4.ts +0 -30
  112. package/src/util/uuid/validate.ts +0 -8
  113. package/test.md +0 -0
  114. package/tsconfig-test.json +0 -13
@@ -1,207 +0,0 @@
1
- // https://github.com/jshttp/cookie/blob/master/index.js
2
- /*!
3
- * cookie
4
- * Copyright(c) 2012-2014 Roman Shtylman
5
- * Copyright(c) 2015 Douglas Christopher Wilson
6
- * MIT Licensed
7
- */
8
-
9
- 'use strict';
10
-
11
- /**
12
- * Module exports.
13
- * @public
14
- */
15
-
16
- /**
17
- * Parse a cookie header.
18
- *
19
- * Parse the given cookie header string into an object
20
- * The object has the various cookies as keys(names) => values
21
- *
22
- * @param {string} str
23
- * @param {object} [options]
24
- * @return {object}
25
- * @public
26
- */
27
- export const parse = (str: string, options?: {
28
- decode?: (value: string) => string;
29
- }): NodeJS.Dict<string> => {
30
- if (typeof str !== 'string') {
31
- throw new TypeError('argument str must be a string');
32
- }
33
-
34
- const obj: NodeJS.Dict<string> = {}
35
- const opt = options || {};
36
- const pairs = str.split(pairSplitRegExp);
37
- const dec = opt.decode || decode;
38
-
39
- for (let i = 0; i < pairs.length; i++) {
40
- const pair = pairs[i];
41
- let eq_idx = pair.indexOf('=');
42
-
43
- // skip things that don't look like key=value
44
- if (eq_idx < 0) {
45
- continue;
46
- }
47
-
48
- const key = pair.substr(0, eq_idx).trim()
49
- let val = pair.substr(++eq_idx, pair.length).trim();
50
-
51
- // quoted values
52
- if ('"' == val[0]) {
53
- val = val.slice(1, -1);
54
- }
55
- // only assign once
56
- if (undefined == obj[key]) {
57
- obj[key] = tryDecode(val, dec);
58
- }
59
- }
60
-
61
- return obj;
62
- }
63
-
64
- /**
65
- * Serialize data into a cookie header.
66
- *
67
- * Serialize the a name value pair into a cookie string suitable for
68
- * http headers. An optional options object specified cookie parameters.
69
- *
70
- * serialize('foo', 'bar', { httpOnly: true })
71
- * => "foo=bar; httpOnly"
72
- *
73
- * @param {string} name
74
- * @param {string} val
75
- * @param {object} [options]
76
- * @return {string}
77
- * @public
78
- */
79
- export const serialize = (name: string, val: string, options?: {
80
- encode?: (uriComponent: string | number | boolean) => string;
81
- maxAge?: number | null;
82
- domain?: string;
83
- httpOnly?: boolean;
84
- secure?: boolean;
85
- path?: string;
86
- expires?: Date;
87
- sameSite?: "lax" | "strict" | "none" | true;
88
- }): string => {
89
- const opt = options || {};
90
- const enc = opt.encode || encode;
91
-
92
- if (typeof enc !== 'function') {
93
- throw new TypeError('option encode is invalid');
94
- }
95
-
96
- if (!fieldContentRegExp.test(name)) {
97
- throw new TypeError('argument name is invalid');
98
- }
99
-
100
- const value = enc(val);
101
-
102
- if (value && !fieldContentRegExp.test(value)) {
103
- throw new TypeError('argument val is invalid');
104
- }
105
-
106
- let str = name + '=' + value;
107
-
108
- if (null != opt.maxAge) {
109
- const maxAge = opt.maxAge - 0;
110
-
111
- if (isNaN(maxAge) || !isFinite(maxAge)) {
112
- throw new TypeError('option maxAge is invalid')
113
- }
114
-
115
- str += '; Max-Age=' + Math.floor(maxAge);
116
- }
117
-
118
- if (opt.domain) {
119
- if (!fieldContentRegExp.test(opt.domain)) {
120
- throw new TypeError('option domain is invalid');
121
- }
122
-
123
- str += '; Domain=' + opt.domain;
124
- }
125
-
126
- if (opt.path) {
127
- if (!fieldContentRegExp.test(opt.path)) {
128
- throw new TypeError('option path is invalid');
129
- }
130
-
131
- str += '; Path=' + opt.path;
132
- }
133
-
134
- if (opt.expires) {
135
- if (typeof opt.expires.toUTCString !== 'function') {
136
- throw new TypeError('option expires is invalid');
137
- }
138
-
139
- str += '; Expires=' + opt.expires.toUTCString();
140
- }
141
-
142
- if (opt.httpOnly) {
143
- str += '; HttpOnly';
144
- }
145
-
146
- if (opt.secure) {
147
- str += '; Secure';
148
- }
149
-
150
- if (opt.sameSite) {
151
- const sameSite = typeof opt.sameSite === 'string'
152
- ? opt.sameSite.toLowerCase() : opt.sameSite;
153
-
154
- switch (sameSite) {
155
- case true:
156
- str += '; SameSite=Strict';
157
- break;
158
- case 'lax':
159
- str += '; SameSite=Lax';
160
- break;
161
- case 'strict':
162
- str += '; SameSite=Strict';
163
- break;
164
- case 'none':
165
- str += '; SameSite=None';
166
- break;
167
- default:
168
- throw new TypeError('option sameSite is invalid');
169
- }
170
- }
171
-
172
- return str;
173
- }
174
-
175
- /**
176
- * Module variables.
177
- * @private
178
- */
179
-
180
- const decode = decodeURIComponent;
181
- const encode = encodeURIComponent;
182
- const pairSplitRegExp = /; */;
183
-
184
- /**
185
- * RegExp to match field-content in RFC 7230 sec 3.2
186
- *
187
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
188
- * field-vchar = VCHAR / obs-text
189
- * obs-text = %x80-FF
190
- */
191
-
192
- const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
193
-
194
- /**
195
- * Try decoding a string using a decoding function.
196
- *
197
- * @param {string} str
198
- * @param {function} decode
199
- * @private
200
- */
201
- const tryDecode = (str: string, decode: (str: string) => string): string => {
202
- try {
203
- return decode(str);
204
- } catch (e) {
205
- return str;
206
- }
207
- }
@@ -1,6 +0,0 @@
1
- import { parse, serialize } from "./cookie";
2
-
3
- export const COOKIE = {
4
- parse,
5
- serialize
6
- }
@@ -1,5 +0,0 @@
1
- import { v4 } from './v4';
2
-
3
- export const UUID = {
4
- v4
5
- };
@@ -1,2 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/regex.js
2
- export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
@@ -1,14 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/rng.js
2
-
3
- import crypto from 'crypto';
4
-
5
- const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
6
- let poolPtr = rnds8Pool.length;
7
-
8
- export default function rng() {
9
- if (poolPtr > rnds8Pool.length - 16) {
10
- crypto.randomFillSync(rnds8Pool);
11
- poolPtr = 0;
12
- }
13
- return rnds8Pool.slice(poolPtr, (poolPtr += 16));
14
- }
@@ -1,53 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/stringify.js
2
-
3
- import validate from './validate';
4
-
5
- /**
6
- * Convert array of 16 byte values to UUID string format of the form:
7
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
8
- */
9
- const byteToHex: string[] = [];
10
-
11
- for (let i = 0; i < 256; ++i) {
12
- byteToHex.push((i + 0x100).toString(16).substr(1));
13
- }
14
-
15
- const stringify = (arr: Uint8Array, offset = 0): string => {
16
- // Note: Be careful editing this code! It's been tuned for performance
17
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
18
- const uuid = (
19
- byteToHex[arr[offset + 0]] +
20
- byteToHex[arr[offset + 1]] +
21
- byteToHex[arr[offset + 2]] +
22
- byteToHex[arr[offset + 3]] +
23
- '-' +
24
- byteToHex[arr[offset + 4]] +
25
- byteToHex[arr[offset + 5]] +
26
- '-' +
27
- byteToHex[arr[offset + 6]] +
28
- byteToHex[arr[offset + 7]] +
29
- '-' +
30
- byteToHex[arr[offset + 8]] +
31
- byteToHex[arr[offset + 9]] +
32
- '-' +
33
- byteToHex[arr[offset + 10]] +
34
- byteToHex[arr[offset + 11]] +
35
- byteToHex[arr[offset + 12]] +
36
- byteToHex[arr[offset + 13]] +
37
- byteToHex[arr[offset + 14]] +
38
- byteToHex[arr[offset + 15]]
39
- ).toLowerCase();
40
-
41
- // Consistency check for valid UUID. If this throws, it's likely due to one
42
- // of the following:
43
- // - One or more input array values don't map to a hex octet (leading to
44
- // "undefined" in the uuid)
45
- // - Invalid input values for the RFC `version` or `variant` fields
46
- if (!validate(uuid)) {
47
- throw TypeError('Stringified UUID is invalid');
48
- }
49
-
50
- return uuid;
51
- }
52
-
53
- export default stringify;
@@ -1,30 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/v4.js
2
-
3
- import rng from './rng';
4
- import stringify from './stringify';
5
-
6
- export const v4 = (options?: {
7
- random?: Uint8Array;
8
- rng?: () => Uint8Array;
9
- }, buf?: Buffer, offset?: number) => {
10
- options = options || {};
11
-
12
- const rnds: Uint8Array = options.random || (options.rng || rng)();
13
-
14
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
15
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
16
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
17
-
18
- // Copy bytes to buffer, if provided
19
- if (buf) {
20
- offset = offset || 0;
21
-
22
- for (let i = 0; i < 16; ++i) {
23
- buf[offset + i] = rnds[i];
24
- }
25
-
26
- return buf;
27
- }
28
-
29
- return stringify(rnds);
30
- }
@@ -1,8 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/validate.js
2
- import REGEX from './regex';
3
-
4
- const validate = (uuid: string) => {
5
- return typeof uuid === 'string' && REGEX.test(uuid);
6
- }
7
-
8
- export default validate;
package/test.md DELETED
File without changes
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./test-dist/",
5
- },
6
- "include": [
7
- "src/**/*",
8
- "test/**/*"
9
- ],
10
- "exclude": [
11
- "node_modules/"
12
- ]
13
- }