@shware/http 1.2.4 → 1.2.7
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/dist/hono/geolocation.cjs +34 -30
- package/dist/hono/geolocation.cjs.map +1 -1
- package/dist/hono/geolocation.d.cts +1 -1
- package/dist/hono/geolocation.d.ts +1 -1
- package/dist/hono/geolocation.mjs +34 -30
- package/dist/hono/geolocation.mjs.map +1 -1
- package/dist/hono/index.d.cts +3 -1
- package/dist/hono/index.d.ts +3 -1
- package/dist/hono/validator.d.cts +16 -13
- package/dist/hono/validator.d.ts +16 -13
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/dist/utils/__tests__/base62.test.cjs +29 -0
- package/dist/utils/__tests__/base62.test.cjs.map +1 -0
- package/dist/utils/__tests__/base62.test.d.cts +2 -0
- package/dist/utils/__tests__/base62.test.d.ts +2 -0
- package/dist/utils/__tests__/base62.test.mjs +27 -0
- package/dist/utils/__tests__/base62.test.mjs.map +1 -0
- package/dist/utils/base62.cjs +85 -0
- package/dist/utils/base62.cjs.map +1 -0
- package/dist/utils/base62.d.cts +6 -0
- package/dist/utils/base62.d.ts +6 -0
- package/dist/utils/base62.mjs +60 -0
- package/dist/utils/base62.mjs.map +1 -0
- package/package.json +7 -7
|
@@ -25,36 +25,35 @@ __export(geolocation_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(geolocation_exports);
|
|
26
26
|
var import_adapter = require("hono/adapter");
|
|
27
27
|
var import_ip = require("../utils/ip.cjs");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
28
|
+
function getGeolocationFromCloudflareWorker(c) {
|
|
29
|
+
return {
|
|
30
|
+
ip_address: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
|
|
31
|
+
city: c.req.header("cf-ipcity") ?? null,
|
|
32
|
+
country: c.req.header("cf-ipcountry") ?? null,
|
|
33
|
+
continent: c.req.header("cf-ipcontinent") ?? null,
|
|
34
|
+
longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
|
|
35
|
+
latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : null,
|
|
36
|
+
region: c.req.header("cf-region-code") ?? null,
|
|
37
|
+
metro_code: c.req.header("cf-metro-code") ?? null,
|
|
38
|
+
postal_code: c.req.header("cf-postal-code") ?? null,
|
|
39
|
+
time_zone: c.req.header("cf-timezone") ?? null
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function getGeolocationFromVercel(c) {
|
|
43
|
+
return {
|
|
44
|
+
ip_address: c.req.header("x-real-ip") ?? null,
|
|
45
|
+
city: c.req.header("x-vercel-ip-city") ?? null,
|
|
46
|
+
country: c.req.header("x-vercel-ip-country") ?? null,
|
|
47
|
+
continent: c.req.header("x-vercel-ip-continent") ?? null,
|
|
48
|
+
longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : null,
|
|
49
|
+
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : null,
|
|
50
|
+
region: c.req.header("x-vercel-ip-country-region") ?? null,
|
|
51
|
+
metro_code: null,
|
|
52
|
+
postal_code: c.req.header("x-vercel-ip-postal-code") ?? null,
|
|
53
|
+
time_zone: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function getGeolocationFromCloudfront(c) {
|
|
58
57
|
return {
|
|
59
58
|
ip_address: (0, import_ip.extractIpAddress)(c.req.header("CloudFront-Viewer-Address")),
|
|
60
59
|
city: c.req.header("CloudFront-Viewer-City") ?? null,
|
|
@@ -68,6 +67,11 @@ function geolocation(c) {
|
|
|
68
67
|
time_zone: c.req.header("CloudFront-Viewer-Time-Zone") ?? null
|
|
69
68
|
};
|
|
70
69
|
}
|
|
70
|
+
function geolocation(c) {
|
|
71
|
+
if ((0, import_adapter.getRuntimeKey)() === "workerd") return getGeolocationFromCloudflareWorker(c);
|
|
72
|
+
if (c.req.header("x-vercel-id")) return getGeolocationFromVercel(c);
|
|
73
|
+
return getGeolocationFromCloudfront(c);
|
|
74
|
+
}
|
|
71
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
76
|
0 && (module.exports = {
|
|
73
77
|
geolocation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport { extractIpAddress } from '../utils/ip';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip_address: string | null;\n city: string | null;\n country: string | null; // ISO 3166-1 alpha-2\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null; // ISO 3166-2\n metro_code: string | null;\n postal_code: string | null;\n time_zone: string | null;\n};\n\
|
|
1
|
+
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport { extractIpAddress } from '../utils/ip';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip_address: string | null;\n city: string | null;\n country: string | null; // ISO 3166-1 alpha-2\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null; // ISO 3166-2\n metro_code: string | null;\n postal_code: string | null;\n time_zone: string | null;\n};\n\n/** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */\nfunction getGeolocationFromCloudflareWorker(c: Context): Geolocation {\n return {\n ip_address: c.req.header('true-client-ip') ?? c.req.header('cf-connecting-ip') ?? null,\n city: c.req.header('cf-ipcity') ?? null,\n country: c.req.header('cf-ipcountry') ?? null,\n continent: c.req.header('cf-ipcontinent') ?? null,\n longitude: c.req.header('cf-iplongitude') ? Number(c.req.header('cf-iplongitude')) : null,\n latitude: c.req.header('cf-iplatitude') ? Number(c.req.header('cf-iplatitude')) : null,\n region: c.req.header('cf-region-code') ?? null,\n metro_code: c.req.header('cf-metro-code') ?? null,\n postal_code: c.req.header('cf-postal-code') ?? null,\n time_zone: c.req.header('cf-timezone') ?? null,\n };\n}\n\n/** https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts */\nfunction getGeolocationFromVercel(c: Context): Geolocation {\n return {\n ip_address: c.req.header('x-real-ip') ?? null,\n city: c.req.header('x-vercel-ip-city') ?? null,\n country: c.req.header('x-vercel-ip-country') ?? null,\n continent: c.req.header('x-vercel-ip-continent') ?? null,\n longitude: c.req.header('x-vercel-ip-longitude')\n ? Number(c.req.header('x-vercel-ip-longitude'))\n : null,\n latitude: c.req.header('x-vercel-ip-latitude')\n ? Number(c.req.header('x-vercel-ip-latitude'))\n : null,\n region: c.req.header('x-vercel-ip-country-region') ?? null,\n metro_code: null,\n postal_code: c.req.header('x-vercel-ip-postal-code') ?? null,\n time_zone: null,\n };\n}\n\n/** ref: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-cloudfront-headers.html#cloudfront-headers-viewer-location */\nfunction getGeolocationFromCloudfront(c: Context): Geolocation {\n return {\n ip_address: extractIpAddress(c.req.header('CloudFront-Viewer-Address')),\n city: c.req.header('CloudFront-Viewer-City') ?? null,\n country: c.req.header('CloudFront-Viewer-Country') ?? null,\n continent: null,\n longitude: c.req.header('CloudFront-Viewer-Longitude')\n ? Number(c.req.header('CloudFront-Viewer-Longitude'))\n : null,\n latitude: c.req.header('CloudFront-Viewer-Latitude')\n ? Number(c.req.header('CloudFront-Viewer-Latitude'))\n : null,\n region: c.req.header('CloudFront-Viewer-Country-Region') ?? null,\n metro_code: c.req.header('CloudFront-Viewer-Metro-Code') ?? null,\n postal_code: c.req.header('CloudFront-Viewer-Postal-Code') ?? null,\n time_zone: c.req.header('CloudFront-Viewer-Time-Zone') ?? null,\n };\n}\n\nexport function geolocation(c: Context): Geolocation {\n if (getRuntimeKey() === 'workerd') return getGeolocationFromCloudflareWorker(c);\n if (c.req.header('x-vercel-id')) return getGeolocationFromVercel(c);\n return getGeolocationFromCloudfront(c);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAC9B,gBAAiC;AAiBjC,SAAS,mCAAmC,GAAyB;AACnE,SAAO;AAAA,IACL,YAAY,EAAE,IAAI,OAAO,gBAAgB,KAAK,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,IAClF,MAAM,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACnC,SAAS,EAAE,IAAI,OAAO,cAAc,KAAK;AAAA,IACzC,WAAW,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC7C,WAAW,EAAE,IAAI,OAAO,gBAAgB,IAAI,OAAO,EAAE,IAAI,OAAO,gBAAgB,CAAC,IAAI;AAAA,IACrF,UAAU,EAAE,IAAI,OAAO,eAAe,IAAI,OAAO,EAAE,IAAI,OAAO,eAAe,CAAC,IAAI;AAAA,IAClF,QAAQ,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC1C,YAAY,EAAE,IAAI,OAAO,eAAe,KAAK;AAAA,IAC7C,aAAa,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC/C,WAAW,EAAE,IAAI,OAAO,aAAa,KAAK;AAAA,EAC5C;AACF;AAGA,SAAS,yBAAyB,GAAyB;AACzD,SAAO;AAAA,IACL,YAAY,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACzC,MAAM,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,IAC1C,SAAS,EAAE,IAAI,OAAO,qBAAqB,KAAK;AAAA,IAChD,WAAW,EAAE,IAAI,OAAO,uBAAuB,KAAK;AAAA,IACpD,WAAW,EAAE,IAAI,OAAO,uBAAuB,IAC3C,OAAO,EAAE,IAAI,OAAO,uBAAuB,CAAC,IAC5C;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,sBAAsB,IACzC,OAAO,EAAE,IAAI,OAAO,sBAAsB,CAAC,IAC3C;AAAA,IACJ,QAAQ,EAAE,IAAI,OAAO,4BAA4B,KAAK;AAAA,IACtD,YAAY;AAAA,IACZ,aAAa,EAAE,IAAI,OAAO,yBAAyB,KAAK;AAAA,IACxD,WAAW;AAAA,EACb;AACF;AAGA,SAAS,6BAA6B,GAAyB;AAC7D,SAAO;AAAA,IACL,gBAAY,4BAAiB,EAAE,IAAI,OAAO,2BAA2B,CAAC;AAAA,IACtE,MAAM,EAAE,IAAI,OAAO,wBAAwB,KAAK;AAAA,IAChD,SAAS,EAAE,IAAI,OAAO,2BAA2B,KAAK;AAAA,IACtD,WAAW;AAAA,IACX,WAAW,EAAE,IAAI,OAAO,6BAA6B,IACjD,OAAO,EAAE,IAAI,OAAO,6BAA6B,CAAC,IAClD;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,4BAA4B,IAC/C,OAAO,EAAE,IAAI,OAAO,4BAA4B,CAAC,IACjD;AAAA,IACJ,QAAQ,EAAE,IAAI,OAAO,kCAAkC,KAAK;AAAA,IAC5D,YAAY,EAAE,IAAI,OAAO,8BAA8B,KAAK;AAAA,IAC5D,aAAa,EAAE,IAAI,OAAO,+BAA+B,KAAK;AAAA,IAC9D,WAAW,EAAE,IAAI,OAAO,6BAA6B,KAAK;AAAA,EAC5D;AACF;AAEO,SAAS,YAAY,GAAyB;AACnD,UAAI,8BAAc,MAAM,UAAW,QAAO,mCAAmC,CAAC;AAC9E,MAAI,EAAE,IAAI,OAAO,aAAa,EAAG,QAAO,yBAAyB,CAAC;AAClE,SAAO,6BAA6B,CAAC;AACvC;","names":[]}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
// src/hono/geolocation.ts
|
|
2
2
|
import { getRuntimeKey } from "hono/adapter";
|
|
3
3
|
import { extractIpAddress } from "../utils/ip.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
4
|
+
function getGeolocationFromCloudflareWorker(c) {
|
|
5
|
+
return {
|
|
6
|
+
ip_address: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
|
|
7
|
+
city: c.req.header("cf-ipcity") ?? null,
|
|
8
|
+
country: c.req.header("cf-ipcountry") ?? null,
|
|
9
|
+
continent: c.req.header("cf-ipcontinent") ?? null,
|
|
10
|
+
longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
|
|
11
|
+
latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : null,
|
|
12
|
+
region: c.req.header("cf-region-code") ?? null,
|
|
13
|
+
metro_code: c.req.header("cf-metro-code") ?? null,
|
|
14
|
+
postal_code: c.req.header("cf-postal-code") ?? null,
|
|
15
|
+
time_zone: c.req.header("cf-timezone") ?? null
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function getGeolocationFromVercel(c) {
|
|
19
|
+
return {
|
|
20
|
+
ip_address: c.req.header("x-real-ip") ?? null,
|
|
21
|
+
city: c.req.header("x-vercel-ip-city") ?? null,
|
|
22
|
+
country: c.req.header("x-vercel-ip-country") ?? null,
|
|
23
|
+
continent: c.req.header("x-vercel-ip-continent") ?? null,
|
|
24
|
+
longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : null,
|
|
25
|
+
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : null,
|
|
26
|
+
region: c.req.header("x-vercel-ip-country-region") ?? null,
|
|
27
|
+
metro_code: null,
|
|
28
|
+
postal_code: c.req.header("x-vercel-ip-postal-code") ?? null,
|
|
29
|
+
time_zone: null
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function getGeolocationFromCloudfront(c) {
|
|
34
33
|
return {
|
|
35
34
|
ip_address: extractIpAddress(c.req.header("CloudFront-Viewer-Address")),
|
|
36
35
|
city: c.req.header("CloudFront-Viewer-City") ?? null,
|
|
@@ -44,6 +43,11 @@ function geolocation(c) {
|
|
|
44
43
|
time_zone: c.req.header("CloudFront-Viewer-Time-Zone") ?? null
|
|
45
44
|
};
|
|
46
45
|
}
|
|
46
|
+
function geolocation(c) {
|
|
47
|
+
if (getRuntimeKey() === "workerd") return getGeolocationFromCloudflareWorker(c);
|
|
48
|
+
if (c.req.header("x-vercel-id")) return getGeolocationFromVercel(c);
|
|
49
|
+
return getGeolocationFromCloudfront(c);
|
|
50
|
+
}
|
|
47
51
|
export {
|
|
48
52
|
geolocation
|
|
49
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport { extractIpAddress } from '../utils/ip';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip_address: string | null;\n city: string | null;\n country: string | null; // ISO 3166-1 alpha-2\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null; // ISO 3166-2\n metro_code: string | null;\n postal_code: string | null;\n time_zone: string | null;\n};\n\
|
|
1
|
+
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport { extractIpAddress } from '../utils/ip';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip_address: string | null;\n city: string | null;\n country: string | null; // ISO 3166-1 alpha-2\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null; // ISO 3166-2\n metro_code: string | null;\n postal_code: string | null;\n time_zone: string | null;\n};\n\n/** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */\nfunction getGeolocationFromCloudflareWorker(c: Context): Geolocation {\n return {\n ip_address: c.req.header('true-client-ip') ?? c.req.header('cf-connecting-ip') ?? null,\n city: c.req.header('cf-ipcity') ?? null,\n country: c.req.header('cf-ipcountry') ?? null,\n continent: c.req.header('cf-ipcontinent') ?? null,\n longitude: c.req.header('cf-iplongitude') ? Number(c.req.header('cf-iplongitude')) : null,\n latitude: c.req.header('cf-iplatitude') ? Number(c.req.header('cf-iplatitude')) : null,\n region: c.req.header('cf-region-code') ?? null,\n metro_code: c.req.header('cf-metro-code') ?? null,\n postal_code: c.req.header('cf-postal-code') ?? null,\n time_zone: c.req.header('cf-timezone') ?? null,\n };\n}\n\n/** https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts */\nfunction getGeolocationFromVercel(c: Context): Geolocation {\n return {\n ip_address: c.req.header('x-real-ip') ?? null,\n city: c.req.header('x-vercel-ip-city') ?? null,\n country: c.req.header('x-vercel-ip-country') ?? null,\n continent: c.req.header('x-vercel-ip-continent') ?? null,\n longitude: c.req.header('x-vercel-ip-longitude')\n ? Number(c.req.header('x-vercel-ip-longitude'))\n : null,\n latitude: c.req.header('x-vercel-ip-latitude')\n ? Number(c.req.header('x-vercel-ip-latitude'))\n : null,\n region: c.req.header('x-vercel-ip-country-region') ?? null,\n metro_code: null,\n postal_code: c.req.header('x-vercel-ip-postal-code') ?? null,\n time_zone: null,\n };\n}\n\n/** ref: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-cloudfront-headers.html#cloudfront-headers-viewer-location */\nfunction getGeolocationFromCloudfront(c: Context): Geolocation {\n return {\n ip_address: extractIpAddress(c.req.header('CloudFront-Viewer-Address')),\n city: c.req.header('CloudFront-Viewer-City') ?? null,\n country: c.req.header('CloudFront-Viewer-Country') ?? null,\n continent: null,\n longitude: c.req.header('CloudFront-Viewer-Longitude')\n ? Number(c.req.header('CloudFront-Viewer-Longitude'))\n : null,\n latitude: c.req.header('CloudFront-Viewer-Latitude')\n ? Number(c.req.header('CloudFront-Viewer-Latitude'))\n : null,\n region: c.req.header('CloudFront-Viewer-Country-Region') ?? null,\n metro_code: c.req.header('CloudFront-Viewer-Metro-Code') ?? null,\n postal_code: c.req.header('CloudFront-Viewer-Postal-Code') ?? null,\n time_zone: c.req.header('CloudFront-Viewer-Time-Zone') ?? null,\n };\n}\n\nexport function geolocation(c: Context): Geolocation {\n if (getRuntimeKey() === 'workerd') return getGeolocationFromCloudflareWorker(c);\n if (c.req.header('x-vercel-id')) return getGeolocationFromVercel(c);\n return getGeolocationFromCloudfront(c);\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AAiBjC,SAAS,mCAAmC,GAAyB;AACnE,SAAO;AAAA,IACL,YAAY,EAAE,IAAI,OAAO,gBAAgB,KAAK,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,IAClF,MAAM,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACnC,SAAS,EAAE,IAAI,OAAO,cAAc,KAAK;AAAA,IACzC,WAAW,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC7C,WAAW,EAAE,IAAI,OAAO,gBAAgB,IAAI,OAAO,EAAE,IAAI,OAAO,gBAAgB,CAAC,IAAI;AAAA,IACrF,UAAU,EAAE,IAAI,OAAO,eAAe,IAAI,OAAO,EAAE,IAAI,OAAO,eAAe,CAAC,IAAI;AAAA,IAClF,QAAQ,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC1C,YAAY,EAAE,IAAI,OAAO,eAAe,KAAK;AAAA,IAC7C,aAAa,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC/C,WAAW,EAAE,IAAI,OAAO,aAAa,KAAK;AAAA,EAC5C;AACF;AAGA,SAAS,yBAAyB,GAAyB;AACzD,SAAO;AAAA,IACL,YAAY,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACzC,MAAM,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,IAC1C,SAAS,EAAE,IAAI,OAAO,qBAAqB,KAAK;AAAA,IAChD,WAAW,EAAE,IAAI,OAAO,uBAAuB,KAAK;AAAA,IACpD,WAAW,EAAE,IAAI,OAAO,uBAAuB,IAC3C,OAAO,EAAE,IAAI,OAAO,uBAAuB,CAAC,IAC5C;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,sBAAsB,IACzC,OAAO,EAAE,IAAI,OAAO,sBAAsB,CAAC,IAC3C;AAAA,IACJ,QAAQ,EAAE,IAAI,OAAO,4BAA4B,KAAK;AAAA,IACtD,YAAY;AAAA,IACZ,aAAa,EAAE,IAAI,OAAO,yBAAyB,KAAK;AAAA,IACxD,WAAW;AAAA,EACb;AACF;AAGA,SAAS,6BAA6B,GAAyB;AAC7D,SAAO;AAAA,IACL,YAAY,iBAAiB,EAAE,IAAI,OAAO,2BAA2B,CAAC;AAAA,IACtE,MAAM,EAAE,IAAI,OAAO,wBAAwB,KAAK;AAAA,IAChD,SAAS,EAAE,IAAI,OAAO,2BAA2B,KAAK;AAAA,IACtD,WAAW;AAAA,IACX,WAAW,EAAE,IAAI,OAAO,6BAA6B,IACjD,OAAO,EAAE,IAAI,OAAO,6BAA6B,CAAC,IAClD;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,4BAA4B,IAC/C,OAAO,EAAE,IAAI,OAAO,4BAA4B,CAAC,IACjD;AAAA,IACJ,QAAQ,EAAE,IAAI,OAAO,kCAAkC,KAAK;AAAA,IAC5D,YAAY,EAAE,IAAI,OAAO,8BAA8B,KAAK;AAAA,IAC5D,aAAa,EAAE,IAAI,OAAO,+BAA+B,KAAK;AAAA,IAC9D,WAAW,EAAE,IAAI,OAAO,6BAA6B,KAAK;AAAA,EAC5D;AACF;AAEO,SAAS,YAAY,GAAyB;AACnD,MAAI,cAAc,MAAM,UAAW,QAAO,mCAAmC,CAAC;AAC9E,MAAI,EAAE,IAAI,OAAO,aAAa,EAAG,QAAO,yBAAyB,CAAC;AAClE,SAAO,6BAA6B,CAAC;AACvC;","names":[]}
|
package/dist/hono/index.d.cts
CHANGED
|
@@ -4,9 +4,11 @@ export { geolocation } from './geolocation.cjs';
|
|
|
4
4
|
export { AuthorizerConfig, authorizer } from './authorizer.cjs';
|
|
5
5
|
export { CSRFConfig, CSRFIgnoreRule, csrf } from './csrf.cjs';
|
|
6
6
|
import 'zod/mini';
|
|
7
|
+
import 'hono/utils/http-status';
|
|
8
|
+
import 'hono/utils/headers';
|
|
9
|
+
import 'hono/types';
|
|
7
10
|
import 'hono';
|
|
8
11
|
import 'zod/v4/core';
|
|
9
12
|
import 'zod';
|
|
10
13
|
import 'axios';
|
|
11
14
|
import 'hono/request-id';
|
|
12
|
-
import 'hono/types';
|
package/dist/hono/index.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ export { geolocation } from './geolocation.js';
|
|
|
4
4
|
export { AuthorizerConfig, authorizer } from './authorizer.js';
|
|
5
5
|
export { CSRFConfig, CSRFIgnoreRule, csrf } from './csrf.js';
|
|
6
6
|
import 'zod/mini';
|
|
7
|
+
import 'hono/utils/http-status';
|
|
8
|
+
import 'hono/utils/headers';
|
|
9
|
+
import 'hono/types';
|
|
7
10
|
import 'hono';
|
|
8
11
|
import 'zod/v4/core';
|
|
9
12
|
import 'zod';
|
|
10
13
|
import 'axios';
|
|
11
14
|
import 'hono/request-id';
|
|
12
|
-
import 'hono/types';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as zod_mini from 'zod/mini';
|
|
2
2
|
import { ZodMiniType } from 'zod/mini';
|
|
3
|
+
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
4
|
+
import * as hono_utils_headers from 'hono/utils/headers';
|
|
5
|
+
import * as hono_types from 'hono/types';
|
|
3
6
|
import * as hono from 'hono';
|
|
4
7
|
import { ValidationTargets } from 'hono';
|
|
5
8
|
import * as zod_v4_core from 'zod/v4/core';
|
|
@@ -7,22 +10,22 @@ import { ZodType, output } from 'zod';
|
|
|
7
10
|
|
|
8
11
|
declare function zValidator<S extends ZodType | ZodMiniType>(target: keyof ValidationTargets, schema: S): hono.MiddlewareHandler<any, string, {
|
|
9
12
|
in: {
|
|
10
|
-
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T ? T extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T extends Response
|
|
11
|
-
form: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
12
|
-
query: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
13
|
-
param: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
14
|
-
header: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
15
|
-
cookie: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
13
|
+
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T ? T extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T extends Response | hono.TypedResponse<any, any, any> ? never : T : never : never;
|
|
14
|
+
form: { [K2 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_1 ? T_1 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_1 extends Response | hono.TypedResponse<any, any, any> ? never : T_1 : never : never)]: Record<string, hono_types.ParsedFormValue | hono_types.ParsedFormValue[]>[K2]; };
|
|
15
|
+
query: { [K2_1 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_2 ? T_2 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_2 extends Response | hono.TypedResponse<any, any, any> ? never : T_2 : never : never)]: Record<string, string | string[]>[K2_1]; };
|
|
16
|
+
param: { [K2_2 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_3 ? T_3 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_3 extends Response | hono.TypedResponse<any, any, any> ? never : T_3 : never : never)]: Record<string, string>[K2_2]; };
|
|
17
|
+
header: { [K2_3 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_4 ? T_4 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_4 extends Response | hono.TypedResponse<any, any, any> ? never : T_4 : never : never)]: Record<hono_utils_headers.RequestHeader | hono_utils_headers.CustomHeader, string>[K2_3]; };
|
|
18
|
+
cookie: { [K2_4 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_5 ? T_5 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_5 extends Response | hono.TypedResponse<any, any, any> ? never : T_5 : never : never)]: Record<string, string>[K2_4]; };
|
|
16
19
|
};
|
|
17
20
|
out: {
|
|
18
|
-
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
19
|
-
form: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
20
|
-
query: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
21
|
-
param: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
22
|
-
header: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
23
|
-
cookie: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
21
|
+
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_6 ? T_6 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_6 extends Response | hono.TypedResponse<any, any, any> ? never : T_6 : never : never;
|
|
22
|
+
form: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_7 ? T_7 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_7 extends Response | hono.TypedResponse<any, any, any> ? never : T_7 : never : never;
|
|
23
|
+
query: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_8 ? T_8 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_8 extends Response | hono.TypedResponse<any, any, any> ? never : T_8 : never : never;
|
|
24
|
+
param: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_9 ? T_9 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_9 extends Response | hono.TypedResponse<any, any, any> ? never : T_9 : never : never;
|
|
25
|
+
header: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_10 ? T_10 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_10 extends Response | hono.TypedResponse<any, any, any> ? never : T_10 : never : never;
|
|
26
|
+
cookie: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_11 ? T_11 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_11 extends Response | hono.TypedResponse<any, any, any> ? never : T_11 : never : never;
|
|
24
27
|
};
|
|
25
|
-
}>;
|
|
28
|
+
}, (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_12 ? T_12 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_12 extends hono.TypedResponse<infer T_13, infer S_1 extends hono_utils_http_status.StatusCode, infer F extends string> ? hono.TypedResponse<T_13, S_1, F> : T_12 extends Response ? T_12 : T_12 extends undefined ? never : never : never : never>;
|
|
26
29
|
declare const bigintId: zod_mini.ZodMiniPipe<zod_mini.ZodMiniString<string>, zod_mini.ZodMiniTransform<bigint, string>>;
|
|
27
30
|
|
|
28
31
|
export { bigintId, zValidator };
|
package/dist/hono/validator.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as zod_mini from 'zod/mini';
|
|
2
2
|
import { ZodMiniType } from 'zod/mini';
|
|
3
|
+
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
4
|
+
import * as hono_utils_headers from 'hono/utils/headers';
|
|
5
|
+
import * as hono_types from 'hono/types';
|
|
3
6
|
import * as hono from 'hono';
|
|
4
7
|
import { ValidationTargets } from 'hono';
|
|
5
8
|
import * as zod_v4_core from 'zod/v4/core';
|
|
@@ -7,22 +10,22 @@ import { ZodType, output } from 'zod';
|
|
|
7
10
|
|
|
8
11
|
declare function zValidator<S extends ZodType | ZodMiniType>(target: keyof ValidationTargets, schema: S): hono.MiddlewareHandler<any, string, {
|
|
9
12
|
in: {
|
|
10
|
-
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T ? T extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T extends Response
|
|
11
|
-
form: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
12
|
-
query: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
13
|
-
param: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
14
|
-
header: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
15
|
-
cookie: ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
13
|
+
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T ? T extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T extends Response | hono.TypedResponse<any, any, any> ? never : T : never : never;
|
|
14
|
+
form: { [K2 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_1 ? T_1 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_1 extends Response | hono.TypedResponse<any, any, any> ? never : T_1 : never : never)]: Record<string, hono_types.ParsedFormValue | hono_types.ParsedFormValue[]>[K2]; };
|
|
15
|
+
query: { [K2_1 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_2 ? T_2 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_2 extends Response | hono.TypedResponse<any, any, any> ? never : T_2 : never : never)]: Record<string, string | string[]>[K2_1]; };
|
|
16
|
+
param: { [K2_2 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_3 ? T_3 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_3 extends Response | hono.TypedResponse<any, any, any> ? never : T_3 : never : never)]: Record<string, string>[K2_2]; };
|
|
17
|
+
header: { [K2_3 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_4 ? T_4 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_4 extends Response | hono.TypedResponse<any, any, any> ? never : T_4 : never : never)]: Record<hono_utils_headers.RequestHeader | hono_utils_headers.CustomHeader, string>[K2_3]; };
|
|
18
|
+
cookie: { [K2_4 in keyof ((S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_5 ? T_5 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_5 extends Response | hono.TypedResponse<any, any, any> ? never : T_5 : never : never)]: Record<string, string>[K2_4]; };
|
|
16
19
|
};
|
|
17
20
|
out: {
|
|
18
|
-
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
19
|
-
form: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
20
|
-
query: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
21
|
-
param: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
22
|
-
header: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
23
|
-
cookie: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer
|
|
21
|
+
json: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_6 ? T_6 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_6 extends Response | hono.TypedResponse<any, any, any> ? never : T_6 : never : never;
|
|
22
|
+
form: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_7 ? T_7 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_7 extends Response | hono.TypedResponse<any, any, any> ? never : T_7 : never : never;
|
|
23
|
+
query: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_8 ? T_8 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_8 extends Response | hono.TypedResponse<any, any, any> ? never : T_8 : never : never;
|
|
24
|
+
param: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_9 ? T_9 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_9 extends Response | hono.TypedResponse<any, any, any> ? never : T_9 : never : never;
|
|
25
|
+
header: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_10 ? T_10 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_10 extends Response | hono.TypedResponse<any, any, any> ? never : T_10 : never : never;
|
|
26
|
+
cookie: (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_11 ? T_11 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_11 extends Response | hono.TypedResponse<any, any, any> ? never : T_11 : never : never;
|
|
24
27
|
};
|
|
25
|
-
}>;
|
|
28
|
+
}, (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) extends infer T_12 ? T_12 extends (S extends ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>> ? output<S> : output<S>) ? T_12 extends hono.TypedResponse<infer T_13, infer S_1 extends hono_utils_http_status.StatusCode, infer F extends string> ? hono.TypedResponse<T_13, S_1, F> : T_12 extends Response ? T_12 : T_12 extends undefined ? never : never : never : never>;
|
|
26
29
|
declare const bigintId: zod_mini.ZodMiniPipe<zod_mini.ZodMiniString<string>, zod_mini.ZodMiniTransform<bigint, string>>;
|
|
27
30
|
|
|
28
31
|
export { bigintId, zValidator };
|
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
MAX_LENGTH: () => MAX_LENGTH,
|
|
40
40
|
PurchaseError: () => import_error.PurchaseError,
|
|
41
41
|
TokenBucket: () => import_token_bucket.TokenBucket,
|
|
42
|
+
base62: () => import_base62.base62,
|
|
42
43
|
getErrorMessage: () => import_parse.getErrorMessage,
|
|
43
44
|
getNextPageParam: () => import_response.getNextPageParam,
|
|
44
45
|
getPreviousPageParam: () => import_response.getPreviousPageParam,
|
|
@@ -58,6 +59,7 @@ var import_response = require("./response.cjs");
|
|
|
58
59
|
__reExport(index_exports, require("./vaild.cjs"), module.exports);
|
|
59
60
|
__reExport(index_exports, require("./snowflake.cjs"), module.exports);
|
|
60
61
|
var MAX_LENGTH = __toESM(require("./max-length/index.cjs"), 1);
|
|
62
|
+
var import_base62 = require("./utils/base62.cjs");
|
|
61
63
|
var import_string = require("./utils/string.cjs");
|
|
62
64
|
var import_timing = require("./utils/timing.cjs");
|
|
63
65
|
var import_promise = require("./utils/promise.cjs");
|
|
@@ -74,6 +76,7 @@ var import_iso_3601_1 = require("./iso/iso_3601_1.cjs");
|
|
|
74
76
|
MAX_LENGTH,
|
|
75
77
|
PurchaseError,
|
|
76
78
|
TokenBucket,
|
|
79
|
+
base62,
|
|
77
80
|
getErrorMessage,
|
|
78
81
|
getNextPageParam,
|
|
79
82
|
getPreviousPageParam,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport {\n LoginTimeoutError,\n LoginCanceledError,\n CheckoutCreateError,\n PurchaseError,\n} from './error/index';\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './error/reason';\nexport * from './error/detail';\nexport * from './error/status';\nexport { getErrorMessage } from './error/parse';\nexport {\n pageParamsSchema,\n Cursor,\n initialPageParam,\n getPreviousPageParam,\n getNextPageParam,\n} from './response';\nexport type {\n Empty,\n EntityId,\n Entity,\n Response,\n InitParams,\n NextParams,\n PrevParams,\n PageParams,\n ParentPageParams,\n Page,\n} from './response';\n\nexport * from './vaild';\nexport * from './snowflake';\n\nexport * as MAX_LENGTH from './max-length/index';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { once } from './utils/promise';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n\nexport { ISO_3601_1, type ISO3166CountryCode } from './iso/iso_3601_1';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,mBAKO;AAUP,0BAAc,+BA5Bd;AA6BA,0BAAc,+BA7Bd;AA8BA,mBAAgC;AAChC,sBAMO;AAcP,0BAAc,wBAnDd;AAoDA,0BAAc,4BApDd;AAsDA,iBAA4B;AAC5B,oBAAwB;AACxB,oBAAuB;AACvB,qBAAqB;AACrB,uBAA0B;AAC1B,0BAAqD;AAErD,wBAAoD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport {\n LoginTimeoutError,\n LoginCanceledError,\n CheckoutCreateError,\n PurchaseError,\n} from './error/index';\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './error/reason';\nexport * from './error/detail';\nexport * from './error/status';\nexport { getErrorMessage } from './error/parse';\nexport {\n pageParamsSchema,\n Cursor,\n initialPageParam,\n getPreviousPageParam,\n getNextPageParam,\n} from './response';\nexport type {\n Empty,\n EntityId,\n Entity,\n Response,\n InitParams,\n NextParams,\n PrevParams,\n PageParams,\n ParentPageParams,\n Page,\n} from './response';\n\nexport * from './vaild';\nexport * from './snowflake';\n\nexport * as MAX_LENGTH from './max-length/index';\nexport { base62 } from './utils/base62';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { once } from './utils/promise';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n\nexport { ISO_3601_1, type ISO3166CountryCode } from './iso/iso_3601_1';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,mBAKO;AAUP,0BAAc,+BA5Bd;AA6BA,0BAAc,+BA7Bd;AA8BA,mBAAgC;AAChC,sBAMO;AAcP,0BAAc,wBAnDd;AAoDA,0BAAc,4BApDd;AAsDA,iBAA4B;AAC5B,oBAAuB;AACvB,oBAAwB;AACxB,oBAAuB;AACvB,qBAAqB;AACrB,uBAA0B;AAC1B,0BAAqD;AAErD,wBAAoD;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -7,6 +7,7 @@ export { Cursor, Empty, Entity, EntityId, InitParams, NextParams, Page, PagePara
|
|
|
7
7
|
export { Result, valid } from './vaild.cjs';
|
|
8
8
|
export { UidGenerator, uid } from './snowflake.cjs';
|
|
9
9
|
export { i as MAX_LENGTH } from './index-BnPgRQDl.cjs';
|
|
10
|
+
export { base62 } from './utils/base62.cjs';
|
|
10
11
|
export { hasText } from './utils/string.cjs';
|
|
11
12
|
export { timing } from './utils/timing.cjs';
|
|
12
13
|
export { once } from './utils/promise.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { Cursor, Empty, Entity, EntityId, InitParams, NextParams, Page, PagePara
|
|
|
7
7
|
export { Result, valid } from './vaild.js';
|
|
8
8
|
export { UidGenerator, uid } from './snowflake.js';
|
|
9
9
|
export { i as MAX_LENGTH } from './index-BnPgRQDl.js';
|
|
10
|
+
export { base62 } from './utils/base62.js';
|
|
10
11
|
export { hasText } from './utils/string.js';
|
|
11
12
|
export { timing } from './utils/timing.js';
|
|
12
13
|
export { once } from './utils/promise.js';
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
export * from "./vaild.mjs";
|
|
19
19
|
export * from "./snowflake.mjs";
|
|
20
20
|
import * as MAX_LENGTH from "./max-length/index.mjs";
|
|
21
|
+
import { base62 } from "./utils/base62.mjs";
|
|
21
22
|
import { hasText } from "./utils/string.mjs";
|
|
22
23
|
import { timing } from "./utils/timing.mjs";
|
|
23
24
|
import { once } from "./utils/promise.mjs";
|
|
@@ -33,6 +34,7 @@ export {
|
|
|
33
34
|
MAX_LENGTH,
|
|
34
35
|
PurchaseError,
|
|
35
36
|
TokenBucket,
|
|
37
|
+
base62,
|
|
36
38
|
getErrorMessage,
|
|
37
39
|
getNextPageParam,
|
|
38
40
|
getPreviousPageParam,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport {\n LoginTimeoutError,\n LoginCanceledError,\n CheckoutCreateError,\n PurchaseError,\n} from './error/index';\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './error/reason';\nexport * from './error/detail';\nexport * from './error/status';\nexport { getErrorMessage } from './error/parse';\nexport {\n pageParamsSchema,\n Cursor,\n initialPageParam,\n getPreviousPageParam,\n getNextPageParam,\n} from './response';\nexport type {\n Empty,\n EntityId,\n Entity,\n Response,\n InitParams,\n NextParams,\n PrevParams,\n PageParams,\n ParentPageParams,\n Page,\n} from './response';\n\nexport * from './vaild';\nexport * from './snowflake';\n\nexport * as MAX_LENGTH from './max-length/index';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { once } from './utils/promise';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n\nexport { ISO_3601_1, type ISO3166CountryCode } from './iso/iso_3601_1';\n"],"mappings":";AAaA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,cAAc;AACd,cAAc;AACd,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAcP,cAAc;AACd,cAAc;AAEd,YAAY,gBAAgB;AAC5B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,mBAA4C;AAErD,SAAS,kBAA2C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport {\n LoginTimeoutError,\n LoginCanceledError,\n CheckoutCreateError,\n PurchaseError,\n} from './error/index';\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './error/reason';\nexport * from './error/detail';\nexport * from './error/status';\nexport { getErrorMessage } from './error/parse';\nexport {\n pageParamsSchema,\n Cursor,\n initialPageParam,\n getPreviousPageParam,\n getNextPageParam,\n} from './response';\nexport type {\n Empty,\n EntityId,\n Entity,\n Response,\n InitParams,\n NextParams,\n PrevParams,\n PageParams,\n ParentPageParams,\n Page,\n} from './response';\n\nexport * from './vaild';\nexport * from './snowflake';\n\nexport * as MAX_LENGTH from './max-length/index';\nexport { base62 } from './utils/base62';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { once } from './utils/promise';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n\nexport { ISO_3601_1, type ISO3166CountryCode } from './iso/iso_3601_1';\n"],"mappings":";AAaA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,cAAc;AACd,cAAc;AACd,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAcP,cAAc;AACd,cAAc;AAEd,YAAY,gBAAgB;AAC5B,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,mBAA4C;AAErD,SAAS,kBAA2C;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/utils/__tests__/base62.test.ts
|
|
4
|
+
var import_base62 = require("../base62.cjs");
|
|
5
|
+
describe("base62", () => {
|
|
6
|
+
it("should encode", () => {
|
|
7
|
+
const buffer = Buffer.from([1]);
|
|
8
|
+
const encoded = import_base62.base62.encode(buffer);
|
|
9
|
+
expect(encoded).toEqual("1");
|
|
10
|
+
});
|
|
11
|
+
it("should decode", () => {
|
|
12
|
+
const encoded = "1";
|
|
13
|
+
const decoded = import_base62.base62.decode(encoded);
|
|
14
|
+
expect(decoded).toEqual(Buffer.from([1]));
|
|
15
|
+
});
|
|
16
|
+
it("should encode and decode", () => {
|
|
17
|
+
const buffer = Buffer.from("hello", "utf-8");
|
|
18
|
+
const encoded = import_base62.base62.encode(buffer);
|
|
19
|
+
const decoded = import_base62.base62.decode(encoded, buffer.length);
|
|
20
|
+
expect(decoded).toEqual(buffer);
|
|
21
|
+
});
|
|
22
|
+
it("should encode and decode with leading zeros", () => {
|
|
23
|
+
const buffer = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
24
|
+
const encoded = import_base62.base62.encode(buffer);
|
|
25
|
+
const decoded = import_base62.base62.decode(encoded, buffer.length);
|
|
26
|
+
expect(decoded).toEqual(buffer);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=base62.test.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/__tests__/base62.test.ts"],"sourcesContent":["import { base62 } from '../base62';\n\ndescribe('base62', () => {\n it('should encode', () => {\n const buffer = Buffer.from([1]);\n const encoded = base62.encode(buffer);\n expect(encoded).toEqual('1');\n });\n\n it('should decode', () => {\n const encoded = '1';\n const decoded = base62.decode(encoded);\n expect(decoded).toEqual(Buffer.from([1]));\n });\n\n it('should encode and decode', () => {\n const buffer = Buffer.from('hello', 'utf-8');\n const encoded = base62.encode(buffer);\n const decoded = base62.decode(encoded, buffer.length);\n expect(decoded).toEqual(buffer);\n });\n\n it('should encode and decode with leading zeros', () => {\n const buffer = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n const encoded = base62.encode(buffer);\n const decoded = base62.decode(encoded, buffer.length);\n expect(decoded).toEqual(buffer);\n });\n});\n"],"mappings":";;;AAAA,oBAAuB;AAEvB,SAAS,UAAU,MAAM;AACvB,KAAG,iBAAiB,MAAM;AACxB,UAAM,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC;AAC9B,UAAM,UAAU,qBAAO,OAAO,MAAM;AACpC,WAAO,OAAO,EAAE,QAAQ,GAAG;AAAA,EAC7B,CAAC;AAED,KAAG,iBAAiB,MAAM;AACxB,UAAM,UAAU;AAChB,UAAM,UAAU,qBAAO,OAAO,OAAO;AACrC,WAAO,OAAO,EAAE,QAAQ,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAAA,EAC1C,CAAC;AAED,KAAG,4BAA4B,MAAM;AACnC,UAAM,SAAS,OAAO,KAAK,SAAS,OAAO;AAC3C,UAAM,UAAU,qBAAO,OAAO,MAAM;AACpC,UAAM,UAAU,qBAAO,OAAO,SAAS,OAAO,MAAM;AACpD,WAAO,OAAO,EAAE,QAAQ,MAAM;AAAA,EAChC,CAAC;AAED,KAAG,+CAA+C,MAAM;AACtD,UAAM,SAAS,OAAO,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;AAC3E,UAAM,UAAU,qBAAO,OAAO,MAAM;AACpC,UAAM,UAAU,qBAAO,OAAO,SAAS,OAAO,MAAM;AACpD,WAAO,OAAO,EAAE,QAAQ,MAAM;AAAA,EAChC,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/utils/__tests__/base62.test.ts
|
|
2
|
+
import { base62 } from "../base62.mjs";
|
|
3
|
+
describe("base62", () => {
|
|
4
|
+
it("should encode", () => {
|
|
5
|
+
const buffer = Buffer.from([1]);
|
|
6
|
+
const encoded = base62.encode(buffer);
|
|
7
|
+
expect(encoded).toEqual("1");
|
|
8
|
+
});
|
|
9
|
+
it("should decode", () => {
|
|
10
|
+
const encoded = "1";
|
|
11
|
+
const decoded = base62.decode(encoded);
|
|
12
|
+
expect(decoded).toEqual(Buffer.from([1]));
|
|
13
|
+
});
|
|
14
|
+
it("should encode and decode", () => {
|
|
15
|
+
const buffer = Buffer.from("hello", "utf-8");
|
|
16
|
+
const encoded = base62.encode(buffer);
|
|
17
|
+
const decoded = base62.decode(encoded, buffer.length);
|
|
18
|
+
expect(decoded).toEqual(buffer);
|
|
19
|
+
});
|
|
20
|
+
it("should encode and decode with leading zeros", () => {
|
|
21
|
+
const buffer = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
22
|
+
const encoded = base62.encode(buffer);
|
|
23
|
+
const decoded = base62.decode(encoded, buffer.length);
|
|
24
|
+
expect(decoded).toEqual(buffer);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=base62.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/__tests__/base62.test.ts"],"sourcesContent":["import { base62 } from '../base62';\n\ndescribe('base62', () => {\n it('should encode', () => {\n const buffer = Buffer.from([1]);\n const encoded = base62.encode(buffer);\n expect(encoded).toEqual('1');\n });\n\n it('should decode', () => {\n const encoded = '1';\n const decoded = base62.decode(encoded);\n expect(decoded).toEqual(Buffer.from([1]));\n });\n\n it('should encode and decode', () => {\n const buffer = Buffer.from('hello', 'utf-8');\n const encoded = base62.encode(buffer);\n const decoded = base62.decode(encoded, buffer.length);\n expect(decoded).toEqual(buffer);\n });\n\n it('should encode and decode with leading zeros', () => {\n const buffer = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n const encoded = base62.encode(buffer);\n const decoded = base62.decode(encoded, buffer.length);\n expect(decoded).toEqual(buffer);\n });\n});\n"],"mappings":";AAAA,SAAS,cAAc;AAEvB,SAAS,UAAU,MAAM;AACvB,KAAG,iBAAiB,MAAM;AACxB,UAAM,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC;AAC9B,UAAM,UAAU,OAAO,OAAO,MAAM;AACpC,WAAO,OAAO,EAAE,QAAQ,GAAG;AAAA,EAC7B,CAAC;AAED,KAAG,iBAAiB,MAAM;AACxB,UAAM,UAAU;AAChB,UAAM,UAAU,OAAO,OAAO,OAAO;AACrC,WAAO,OAAO,EAAE,QAAQ,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAAA,EAC1C,CAAC;AAED,KAAG,4BAA4B,MAAM;AACnC,UAAM,SAAS,OAAO,KAAK,SAAS,OAAO;AAC3C,UAAM,UAAU,OAAO,OAAO,MAAM;AACpC,UAAM,UAAU,OAAO,OAAO,SAAS,OAAO,MAAM;AACpD,WAAO,OAAO,EAAE,QAAQ,MAAM;AAAA,EAChC,CAAC;AAED,KAAG,+CAA+C,MAAM;AACtD,UAAM,SAAS,OAAO,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;AAC3E,UAAM,UAAU,OAAO,OAAO,MAAM;AACpC,UAAM,UAAU,OAAO,OAAO,SAAS,OAAO,MAAM;AACpD,WAAO,OAAO,EAAE,QAAQ,MAAM;AAAA,EAChC,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/base62.ts
|
|
21
|
+
var base62_exports = {};
|
|
22
|
+
__export(base62_exports, {
|
|
23
|
+
base62: () => base62
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(base62_exports);
|
|
26
|
+
var base62 = {
|
|
27
|
+
encode: (buffer) => {
|
|
28
|
+
const base = 62n;
|
|
29
|
+
const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
30
|
+
let leadingZeros = 0;
|
|
31
|
+
for (const byte of buffer) {
|
|
32
|
+
if (byte === 0) leadingZeros++;
|
|
33
|
+
else break;
|
|
34
|
+
}
|
|
35
|
+
let num = BigInt("0x" + buffer.toString("hex"));
|
|
36
|
+
if (num === 0n) return "0".repeat(buffer.length);
|
|
37
|
+
const chars = [];
|
|
38
|
+
while (num > 0n) {
|
|
39
|
+
const remainder = num % base;
|
|
40
|
+
chars.push(charset[Number(remainder)]);
|
|
41
|
+
num /= base;
|
|
42
|
+
}
|
|
43
|
+
return "0".repeat(leadingZeros) + chars.reverse().join("");
|
|
44
|
+
},
|
|
45
|
+
decode: (string, expectedLength) => {
|
|
46
|
+
const base = 62n;
|
|
47
|
+
const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
48
|
+
let leadingZeros = 0;
|
|
49
|
+
for (const ch of string) {
|
|
50
|
+
if (ch === "0") leadingZeros++;
|
|
51
|
+
else break;
|
|
52
|
+
}
|
|
53
|
+
if (leadingZeros === string.length) {
|
|
54
|
+
return Buffer.alloc(expectedLength ?? leadingZeros);
|
|
55
|
+
}
|
|
56
|
+
let num = 0n;
|
|
57
|
+
for (let i = leadingZeros; i < string.length; i++) {
|
|
58
|
+
const ch = string[i];
|
|
59
|
+
const idx = charset.indexOf(ch);
|
|
60
|
+
if (idx === -1) {
|
|
61
|
+
throw new Error(`Invalid base62 character: ${ch}`);
|
|
62
|
+
}
|
|
63
|
+
num = num * base + BigInt(idx);
|
|
64
|
+
}
|
|
65
|
+
let hex = num.toString(16);
|
|
66
|
+
if (hex.length % 2 !== 0) hex = "0" + hex;
|
|
67
|
+
let buf = Buffer.from(hex, "hex");
|
|
68
|
+
if (leadingZeros > 0) {
|
|
69
|
+
buf = Buffer.concat([Buffer.alloc(leadingZeros), buf]);
|
|
70
|
+
}
|
|
71
|
+
if (expectedLength !== void 0) {
|
|
72
|
+
if (buf.length < expectedLength) {
|
|
73
|
+
buf = Buffer.concat([Buffer.alloc(expectedLength - buf.length), buf]);
|
|
74
|
+
} else if (buf.length > expectedLength) {
|
|
75
|
+
buf = buf.subarray(buf.length - expectedLength);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return buf;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
base62
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=base62.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/base62.ts"],"sourcesContent":["export const base62 = {\n encode: (buffer: Buffer): string => {\n const base = 62n;\n const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n let leadingZeros = 0;\n for (const byte of buffer) {\n if (byte === 0) leadingZeros++;\n else break;\n }\n\n let num = BigInt('0x' + buffer.toString('hex'));\n if (num === 0n) return '0'.repeat(buffer.length);\n\n const chars: string[] = [];\n while (num > 0n) {\n const remainder = num % base;\n chars.push(charset[Number(remainder)]!);\n num /= base;\n }\n\n return '0'.repeat(leadingZeros) + chars.reverse().join('');\n },\n decode: (string: string, expectedLength?: number): Buffer => {\n const base = 62n;\n const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n\n let leadingZeros = 0;\n for (const ch of string) {\n if (ch === '0') leadingZeros++;\n else break;\n }\n\n if (leadingZeros === string.length) {\n return Buffer.alloc(expectedLength ?? leadingZeros);\n }\n\n let num = 0n;\n for (let i = leadingZeros; i < string.length; i++) {\n const ch = string[i];\n const idx = charset.indexOf(ch);\n if (idx === -1) {\n throw new Error(`Invalid base62 character: ${ch}`);\n }\n num = num * base + BigInt(idx);\n }\n\n let hex = num.toString(16);\n if (hex.length % 2 !== 0) hex = '0' + hex;\n let buf = Buffer.from(hex, 'hex');\n\n if (leadingZeros > 0) {\n buf = Buffer.concat([Buffer.alloc(leadingZeros), buf]);\n }\n\n if (expectedLength !== undefined) {\n if (buf.length < expectedLength) {\n buf = Buffer.concat([Buffer.alloc(expectedLength - buf.length), buf]);\n } else if (buf.length > expectedLength) {\n buf = buf.subarray(buf.length - expectedLength);\n }\n }\n\n return buf;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,SAAS;AAAA,EACpB,QAAQ,CAAC,WAA2B;AAClC,UAAM,OAAO;AACb,UAAM,UAAU;AAChB,QAAI,eAAe;AACnB,eAAW,QAAQ,QAAQ;AACzB,UAAI,SAAS,EAAG;AAAA,UACX;AAAA,IACP;AAEA,QAAI,MAAM,OAAO,OAAO,OAAO,SAAS,KAAK,CAAC;AAC9C,QAAI,QAAQ,GAAI,QAAO,IAAI,OAAO,OAAO,MAAM;AAE/C,UAAM,QAAkB,CAAC;AACzB,WAAO,MAAM,IAAI;AACf,YAAM,YAAY,MAAM;AACxB,YAAM,KAAK,QAAQ,OAAO,SAAS,CAAC,CAAE;AACtC,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,OAAO,YAAY,IAAI,MAAM,QAAQ,EAAE,KAAK,EAAE;AAAA,EAC3D;AAAA,EACA,QAAQ,CAAC,QAAgB,mBAAoC;AAC3D,UAAM,OAAO;AACb,UAAM,UAAU;AAEhB,QAAI,eAAe;AACnB,eAAW,MAAM,QAAQ;AACvB,UAAI,OAAO,IAAK;AAAA,UACX;AAAA,IACP;AAEA,QAAI,iBAAiB,OAAO,QAAQ;AAClC,aAAO,OAAO,MAAM,kBAAkB,YAAY;AAAA,IACpD;AAEA,QAAI,MAAM;AACV,aAAS,IAAI,cAAc,IAAI,OAAO,QAAQ,KAAK;AACjD,YAAM,KAAK,OAAO,CAAC;AACnB,YAAM,MAAM,QAAQ,QAAQ,EAAE;AAC9B,UAAI,QAAQ,IAAI;AACd,cAAM,IAAI,MAAM,6BAA6B,EAAE,EAAE;AAAA,MACnD;AACA,YAAM,MAAM,OAAO,OAAO,GAAG;AAAA,IAC/B;AAEA,QAAI,MAAM,IAAI,SAAS,EAAE;AACzB,QAAI,IAAI,SAAS,MAAM,EAAG,OAAM,MAAM;AACtC,QAAI,MAAM,OAAO,KAAK,KAAK,KAAK;AAEhC,QAAI,eAAe,GAAG;AACpB,YAAM,OAAO,OAAO,CAAC,OAAO,MAAM,YAAY,GAAG,GAAG,CAAC;AAAA,IACvD;AAEA,QAAI,mBAAmB,QAAW;AAChC,UAAI,IAAI,SAAS,gBAAgB;AAC/B,cAAM,OAAO,OAAO,CAAC,OAAO,MAAM,iBAAiB,IAAI,MAAM,GAAG,GAAG,CAAC;AAAA,MACtE,WAAW,IAAI,SAAS,gBAAgB;AACtC,cAAM,IAAI,SAAS,IAAI,SAAS,cAAc;AAAA,MAChD;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/utils/base62.ts
|
|
2
|
+
var base62 = {
|
|
3
|
+
encode: (buffer) => {
|
|
4
|
+
const base = 62n;
|
|
5
|
+
const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
6
|
+
let leadingZeros = 0;
|
|
7
|
+
for (const byte of buffer) {
|
|
8
|
+
if (byte === 0) leadingZeros++;
|
|
9
|
+
else break;
|
|
10
|
+
}
|
|
11
|
+
let num = BigInt("0x" + buffer.toString("hex"));
|
|
12
|
+
if (num === 0n) return "0".repeat(buffer.length);
|
|
13
|
+
const chars = [];
|
|
14
|
+
while (num > 0n) {
|
|
15
|
+
const remainder = num % base;
|
|
16
|
+
chars.push(charset[Number(remainder)]);
|
|
17
|
+
num /= base;
|
|
18
|
+
}
|
|
19
|
+
return "0".repeat(leadingZeros) + chars.reverse().join("");
|
|
20
|
+
},
|
|
21
|
+
decode: (string, expectedLength) => {
|
|
22
|
+
const base = 62n;
|
|
23
|
+
const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
24
|
+
let leadingZeros = 0;
|
|
25
|
+
for (const ch of string) {
|
|
26
|
+
if (ch === "0") leadingZeros++;
|
|
27
|
+
else break;
|
|
28
|
+
}
|
|
29
|
+
if (leadingZeros === string.length) {
|
|
30
|
+
return Buffer.alloc(expectedLength ?? leadingZeros);
|
|
31
|
+
}
|
|
32
|
+
let num = 0n;
|
|
33
|
+
for (let i = leadingZeros; i < string.length; i++) {
|
|
34
|
+
const ch = string[i];
|
|
35
|
+
const idx = charset.indexOf(ch);
|
|
36
|
+
if (idx === -1) {
|
|
37
|
+
throw new Error(`Invalid base62 character: ${ch}`);
|
|
38
|
+
}
|
|
39
|
+
num = num * base + BigInt(idx);
|
|
40
|
+
}
|
|
41
|
+
let hex = num.toString(16);
|
|
42
|
+
if (hex.length % 2 !== 0) hex = "0" + hex;
|
|
43
|
+
let buf = Buffer.from(hex, "hex");
|
|
44
|
+
if (leadingZeros > 0) {
|
|
45
|
+
buf = Buffer.concat([Buffer.alloc(leadingZeros), buf]);
|
|
46
|
+
}
|
|
47
|
+
if (expectedLength !== void 0) {
|
|
48
|
+
if (buf.length < expectedLength) {
|
|
49
|
+
buf = Buffer.concat([Buffer.alloc(expectedLength - buf.length), buf]);
|
|
50
|
+
} else if (buf.length > expectedLength) {
|
|
51
|
+
buf = buf.subarray(buf.length - expectedLength);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return buf;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
base62
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=base62.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/base62.ts"],"sourcesContent":["export const base62 = {\n encode: (buffer: Buffer): string => {\n const base = 62n;\n const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n let leadingZeros = 0;\n for (const byte of buffer) {\n if (byte === 0) leadingZeros++;\n else break;\n }\n\n let num = BigInt('0x' + buffer.toString('hex'));\n if (num === 0n) return '0'.repeat(buffer.length);\n\n const chars: string[] = [];\n while (num > 0n) {\n const remainder = num % base;\n chars.push(charset[Number(remainder)]!);\n num /= base;\n }\n\n return '0'.repeat(leadingZeros) + chars.reverse().join('');\n },\n decode: (string: string, expectedLength?: number): Buffer => {\n const base = 62n;\n const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n\n let leadingZeros = 0;\n for (const ch of string) {\n if (ch === '0') leadingZeros++;\n else break;\n }\n\n if (leadingZeros === string.length) {\n return Buffer.alloc(expectedLength ?? leadingZeros);\n }\n\n let num = 0n;\n for (let i = leadingZeros; i < string.length; i++) {\n const ch = string[i];\n const idx = charset.indexOf(ch);\n if (idx === -1) {\n throw new Error(`Invalid base62 character: ${ch}`);\n }\n num = num * base + BigInt(idx);\n }\n\n let hex = num.toString(16);\n if (hex.length % 2 !== 0) hex = '0' + hex;\n let buf = Buffer.from(hex, 'hex');\n\n if (leadingZeros > 0) {\n buf = Buffer.concat([Buffer.alloc(leadingZeros), buf]);\n }\n\n if (expectedLength !== undefined) {\n if (buf.length < expectedLength) {\n buf = Buffer.concat([Buffer.alloc(expectedLength - buf.length), buf]);\n } else if (buf.length > expectedLength) {\n buf = buf.subarray(buf.length - expectedLength);\n }\n }\n\n return buf;\n },\n};\n"],"mappings":";AAAO,IAAM,SAAS;AAAA,EACpB,QAAQ,CAAC,WAA2B;AAClC,UAAM,OAAO;AACb,UAAM,UAAU;AAChB,QAAI,eAAe;AACnB,eAAW,QAAQ,QAAQ;AACzB,UAAI,SAAS,EAAG;AAAA,UACX;AAAA,IACP;AAEA,QAAI,MAAM,OAAO,OAAO,OAAO,SAAS,KAAK,CAAC;AAC9C,QAAI,QAAQ,GAAI,QAAO,IAAI,OAAO,OAAO,MAAM;AAE/C,UAAM,QAAkB,CAAC;AACzB,WAAO,MAAM,IAAI;AACf,YAAM,YAAY,MAAM;AACxB,YAAM,KAAK,QAAQ,OAAO,SAAS,CAAC,CAAE;AACtC,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,OAAO,YAAY,IAAI,MAAM,QAAQ,EAAE,KAAK,EAAE;AAAA,EAC3D;AAAA,EACA,QAAQ,CAAC,QAAgB,mBAAoC;AAC3D,UAAM,OAAO;AACb,UAAM,UAAU;AAEhB,QAAI,eAAe;AACnB,eAAW,MAAM,QAAQ;AACvB,UAAI,OAAO,IAAK;AAAA,UACX;AAAA,IACP;AAEA,QAAI,iBAAiB,OAAO,QAAQ;AAClC,aAAO,OAAO,MAAM,kBAAkB,YAAY;AAAA,IACpD;AAEA,QAAI,MAAM;AACV,aAAS,IAAI,cAAc,IAAI,OAAO,QAAQ,KAAK;AACjD,YAAM,KAAK,OAAO,CAAC;AACnB,YAAM,MAAM,QAAQ,QAAQ,EAAE;AAC9B,UAAI,QAAQ,IAAI;AACd,cAAM,IAAI,MAAM,6BAA6B,EAAE,EAAE;AAAA,MACnD;AACA,YAAM,MAAM,OAAO,OAAO,GAAG;AAAA,IAC/B;AAEA,QAAI,MAAM,IAAI,SAAS,EAAE;AACzB,QAAI,IAAI,SAAS,MAAM,EAAG,OAAM,MAAM;AACtC,QAAI,MAAM,OAAO,KAAK,KAAK,KAAK;AAEhC,QAAI,eAAe,GAAG;AACpB,YAAM,OAAO,OAAO,CAAC,OAAO,MAAM,YAAY,GAAG,GAAG,CAAC;AAAA,IACvD;AAEA,QAAI,mBAAmB,QAAW;AAChC,UAAI,IAAI,SAAS,gBAAgB;AAC/B,cAAM,OAAO,OAAO,CAAC,OAAO,MAAM,iBAAiB,IAAI,MAAM,GAAG,GAAG,CAAC;AAAA,MACtE,WAAW,IAAI,SAAS,gBAAgB;AACtC,cAAM,IAAI,SAAS,IAAI,SAAS,cAAc;AAAA,MAChD;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shware/http",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
],
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/jest": "^30.0.0",
|
|
42
|
-
"@types/node": "^24.
|
|
43
|
-
"@types/react": "^19.2.
|
|
42
|
+
"@types/node": "^24.9.2",
|
|
43
|
+
"@types/react": "^19.2.2",
|
|
44
44
|
"jest": "^30.2.0",
|
|
45
|
-
"ts-jest": "^29.4.
|
|
45
|
+
"ts-jest": "^29.4.5",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
|
-
"@repo/
|
|
48
|
-
"@repo/
|
|
47
|
+
"@repo/eslint-config": "0.0.7",
|
|
48
|
+
"@repo/typescript-config": "0.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"zod": "^4.1.
|
|
51
|
+
"zod": "^4.1.12"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"axios": "^1.10.0",
|