@shware/http 0.4.1 → 0.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.
@@ -0,0 +1,71 @@
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/hono/authorizer.ts
21
+ var authorizer_exports = {};
22
+ __export(authorizer_exports, {
23
+ Authorizer: () => Authorizer
24
+ });
25
+ module.exports = __toCommonJS(authorizer_exports);
26
+ var import_router = require("hono/router");
27
+ var import_reg_exp_router = require("hono/router/reg-exp-router");
28
+ var import_smart_router = require("hono/router/smart-router");
29
+ var import_trie_router = require("hono/router/trie-router");
30
+ var import_status = require("../status.cjs");
31
+ var Authorizer = class _Authorizer {
32
+ router = new import_smart_router.SmartRouter({
33
+ routers: [new import_reg_exp_router.RegExpRouter(), new import_trie_router.TrieRouter()]
34
+ });
35
+ auth;
36
+ constructor(auth) {
37
+ this.auth = auth;
38
+ }
39
+ static create = (auth) => new _Authorizer(auth);
40
+ match(path, methods) {
41
+ if (methods) {
42
+ for (const method of methods) {
43
+ this.router.add(method, path, null);
44
+ }
45
+ } else {
46
+ this.router.add(import_router.METHOD_NAME_ALL, path, null);
47
+ }
48
+ return this;
49
+ }
50
+ build = () => {
51
+ return async (c, next) => {
52
+ if (c.req.method === "OPTIONS") {
53
+ await next();
54
+ return;
55
+ }
56
+ const [matched] = this.router.match(c.req.method, c.req.path);
57
+ if (matched.length === 0) {
58
+ await next();
59
+ return;
60
+ }
61
+ const authenticated = await this.auth.isAuthenticated(c.req.raw);
62
+ if (!authenticated) throw import_status.Status.unauthorized().error();
63
+ await next();
64
+ };
65
+ };
66
+ };
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ Authorizer
70
+ });
71
+ //# sourceMappingURL=authorizer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hono/authorizer.ts"],"sourcesContent":["import { METHOD_NAME_ALL } from 'hono/router';\nimport { RegExpRouter } from 'hono/router/reg-exp-router';\nimport { SmartRouter } from 'hono/router/smart-router';\nimport { TrieRouter } from 'hono/router/trie-router';\nimport { Status } from '../status';\nimport type { MiddlewareHandler } from 'hono';\n\ntype Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\ntype Auth = {\n isAuthenticated: (request: Request) => Promise<boolean>;\n};\n\nexport class Authorizer {\n private readonly router = new SmartRouter<null>({\n routers: [new RegExpRouter(), new TrieRouter()],\n });\n\n private readonly auth: Auth;\n\n private constructor(auth: Auth) {\n this.auth = auth;\n }\n\n static create = (auth: Auth) => new Authorizer(auth);\n\n match(path: string, methods?: [Methods, ...Methods[]]) {\n if (methods) {\n for (const method of methods) {\n this.router.add(method, path, null);\n }\n } else {\n this.router.add(METHOD_NAME_ALL, path, null);\n }\n return this;\n }\n\n build = (): MiddlewareHandler => {\n return async (c, next) => {\n if (c.req.method === 'OPTIONS') {\n await next();\n return;\n }\n\n const [matched] = this.router.match(c.req.method, c.req.path);\n if (matched.length === 0) {\n await next();\n return;\n }\n\n const authenticated = await this.auth.isAuthenticated(c.req.raw);\n if (!authenticated) throw Status.unauthorized().error();\n await next();\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgC;AAChC,4BAA6B;AAC7B,0BAA4B;AAC5B,yBAA2B;AAC3B,oBAAuB;AAShB,IAAM,aAAN,MAAM,YAAW;AAAA,EACL,SAAS,IAAI,gCAAkB;AAAA,IAC9C,SAAS,CAAC,IAAI,mCAAa,GAAG,IAAI,8BAAW,CAAC;AAAA,EAChD,CAAC;AAAA,EAEgB;AAAA,EAET,YAAY,MAAY;AAC9B,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,SAAS,CAAC,SAAe,IAAI,YAAW,IAAI;AAAA,EAEnD,MAAM,MAAc,SAAmC;AACrD,QAAI,SAAS;AACX,iBAAW,UAAU,SAAS;AAC5B,aAAK,OAAO,IAAI,QAAQ,MAAM,IAAI;AAAA,MACpC;AAAA,IACF,OAAO;AACL,WAAK,OAAO,IAAI,+BAAiB,MAAM,IAAI;AAAA,IAC7C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAyB;AAC/B,WAAO,OAAO,GAAG,SAAS;AACxB,UAAI,EAAE,IAAI,WAAW,WAAW;AAC9B,cAAM,KAAK;AACX;AAAA,MACF;AAEA,YAAM,CAAC,OAAO,IAAI,KAAK,OAAO,MAAM,EAAE,IAAI,QAAQ,EAAE,IAAI,IAAI;AAC5D,UAAI,QAAQ,WAAW,GAAG;AACxB,cAAM,KAAK;AACX;AAAA,MACF;AAEA,YAAM,gBAAgB,MAAM,KAAK,KAAK,gBAAgB,EAAE,IAAI,GAAG;AAC/D,UAAI,CAAC,cAAe,OAAM,qBAAO,aAAa,EAAE,MAAM;AACtD,YAAM,KAAK;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,16 @@
1
+ import { MiddlewareHandler } from 'hono';
2
+
3
+ type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
4
+ type Auth = {
5
+ isAuthenticated: (request: Request) => Promise<boolean>;
6
+ };
7
+ declare class Authorizer {
8
+ private readonly router;
9
+ private readonly auth;
10
+ private constructor();
11
+ static create: (auth: Auth) => Authorizer;
12
+ match(path: string, methods?: [Methods, ...Methods[]]): this;
13
+ build: () => MiddlewareHandler;
14
+ }
15
+
16
+ export { Authorizer };
@@ -0,0 +1,16 @@
1
+ import { MiddlewareHandler } from 'hono';
2
+
3
+ type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
4
+ type Auth = {
5
+ isAuthenticated: (request: Request) => Promise<boolean>;
6
+ };
7
+ declare class Authorizer {
8
+ private readonly router;
9
+ private readonly auth;
10
+ private constructor();
11
+ static create: (auth: Auth) => Authorizer;
12
+ match(path: string, methods?: [Methods, ...Methods[]]): this;
13
+ build: () => MiddlewareHandler;
14
+ }
15
+
16
+ export { Authorizer };
@@ -0,0 +1,46 @@
1
+ // src/hono/authorizer.ts
2
+ import { METHOD_NAME_ALL } from "hono/router";
3
+ import { RegExpRouter } from "hono/router/reg-exp-router";
4
+ import { SmartRouter } from "hono/router/smart-router";
5
+ import { TrieRouter } from "hono/router/trie-router";
6
+ import { Status } from "../status.mjs";
7
+ var Authorizer = class _Authorizer {
8
+ router = new SmartRouter({
9
+ routers: [new RegExpRouter(), new TrieRouter()]
10
+ });
11
+ auth;
12
+ constructor(auth) {
13
+ this.auth = auth;
14
+ }
15
+ static create = (auth) => new _Authorizer(auth);
16
+ match(path, methods) {
17
+ if (methods) {
18
+ for (const method of methods) {
19
+ this.router.add(method, path, null);
20
+ }
21
+ } else {
22
+ this.router.add(METHOD_NAME_ALL, path, null);
23
+ }
24
+ return this;
25
+ }
26
+ build = () => {
27
+ return async (c, next) => {
28
+ if (c.req.method === "OPTIONS") {
29
+ await next();
30
+ return;
31
+ }
32
+ const [matched] = this.router.match(c.req.method, c.req.path);
33
+ if (matched.length === 0) {
34
+ await next();
35
+ return;
36
+ }
37
+ const authenticated = await this.auth.isAuthenticated(c.req.raw);
38
+ if (!authenticated) throw Status.unauthorized().error();
39
+ await next();
40
+ };
41
+ };
42
+ };
43
+ export {
44
+ Authorizer
45
+ };
46
+ //# sourceMappingURL=authorizer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hono/authorizer.ts"],"sourcesContent":["import { METHOD_NAME_ALL } from 'hono/router';\nimport { RegExpRouter } from 'hono/router/reg-exp-router';\nimport { SmartRouter } from 'hono/router/smart-router';\nimport { TrieRouter } from 'hono/router/trie-router';\nimport { Status } from '../status';\nimport type { MiddlewareHandler } from 'hono';\n\ntype Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\ntype Auth = {\n isAuthenticated: (request: Request) => Promise<boolean>;\n};\n\nexport class Authorizer {\n private readonly router = new SmartRouter<null>({\n routers: [new RegExpRouter(), new TrieRouter()],\n });\n\n private readonly auth: Auth;\n\n private constructor(auth: Auth) {\n this.auth = auth;\n }\n\n static create = (auth: Auth) => new Authorizer(auth);\n\n match(path: string, methods?: [Methods, ...Methods[]]) {\n if (methods) {\n for (const method of methods) {\n this.router.add(method, path, null);\n }\n } else {\n this.router.add(METHOD_NAME_ALL, path, null);\n }\n return this;\n }\n\n build = (): MiddlewareHandler => {\n return async (c, next) => {\n if (c.req.method === 'OPTIONS') {\n await next();\n return;\n }\n\n const [matched] = this.router.match(c.req.method, c.req.path);\n if (matched.length === 0) {\n await next();\n return;\n }\n\n const authenticated = await this.auth.isAuthenticated(c.req.raw);\n if (!authenticated) throw Status.unauthorized().error();\n await next();\n };\n };\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAShB,IAAM,aAAN,MAAM,YAAW;AAAA,EACL,SAAS,IAAI,YAAkB;AAAA,IAC9C,SAAS,CAAC,IAAI,aAAa,GAAG,IAAI,WAAW,CAAC;AAAA,EAChD,CAAC;AAAA,EAEgB;AAAA,EAET,YAAY,MAAY;AAC9B,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,SAAS,CAAC,SAAe,IAAI,YAAW,IAAI;AAAA,EAEnD,MAAM,MAAc,SAAmC;AACrD,QAAI,SAAS;AACX,iBAAW,UAAU,SAAS;AAC5B,aAAK,OAAO,IAAI,QAAQ,MAAM,IAAI;AAAA,MACpC;AAAA,IACF,OAAO;AACL,WAAK,OAAO,IAAI,iBAAiB,MAAM,IAAI;AAAA,IAC7C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAyB;AAC/B,WAAO,OAAO,GAAG,SAAS;AACxB,UAAI,EAAE,IAAI,WAAW,WAAW;AAC9B,cAAM,KAAK;AACX;AAAA,MACF;AAEA,YAAM,CAAC,OAAO,IAAI,KAAK,OAAO,MAAM,EAAE,IAAI,QAAQ,EAAE,IAAI,IAAI;AAC5D,UAAI,QAAQ,WAAW,GAAG;AACxB,cAAM,KAAK;AACX;AAAA,MACF;AAEA,YAAM,gBAAgB,MAAM,KAAK,KAAK,gBAAgB,EAAE,IAAI,GAAG;AAC/D,UAAI,CAAC,cAAe,OAAM,OAAO,aAAa,EAAE,MAAM;AACtD,YAAM,KAAK;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/hono/index.ts
21
21
  var hono_exports = {};
22
22
  __export(hono_exports, {
23
+ Authorizer: () => import_authorizer.Authorizer,
23
24
  errorHandler: () => import_handler.errorHandler,
24
25
  geolocation: () => import_geolocation.geolocation,
25
26
  zValidator: () => import_validator.zValidator
@@ -28,8 +29,10 @@ module.exports = __toCommonJS(hono_exports);
28
29
  var import_validator = require("./validator.cjs");
29
30
  var import_handler = require("./handler.cjs");
30
31
  var import_geolocation = require("./geolocation.cjs");
32
+ var import_authorizer = require("./authorizer.cjs");
31
33
  // Annotate the CommonJS export names for ESM import in node:
32
34
  0 && (module.exports = {
35
+ Authorizer,
33
36
  errorHandler,
34
37
  geolocation,
35
38
  zValidator
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2B;AAC3B,qBAA6B;AAC7B,yBAA4B;","names":[]}
1
+ {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\nexport { Authorizer } from './authorizer';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2B;AAC3B,qBAA6B;AAC7B,yBAA4B;AAC5B,wBAA2B;","names":[]}
@@ -1,6 +1,7 @@
1
1
  export { zValidator } from './validator.cjs';
2
2
  export { errorHandler } from './handler.cjs';
3
3
  export { geolocation } from './geolocation.cjs';
4
+ export { Authorizer } from './authorizer.cjs';
4
5
  import 'hono/utils/headers';
5
6
  import 'hono/types';
6
7
  import 'hono';
@@ -1,6 +1,7 @@
1
1
  export { zValidator } from './validator.js';
2
2
  export { errorHandler } from './handler.js';
3
3
  export { geolocation } from './geolocation.js';
4
+ export { Authorizer } from './authorizer.js';
4
5
  import 'hono/utils/headers';
5
6
  import 'hono/types';
6
7
  import 'hono';
@@ -2,7 +2,9 @@
2
2
  import { zValidator } from "./validator.mjs";
3
3
  import { errorHandler } from "./handler.mjs";
4
4
  import { geolocation } from "./geolocation.mjs";
5
+ import { Authorizer } from "./authorizer.mjs";
5
6
  export {
7
+ Authorizer,
6
8
  errorHandler,
7
9
  geolocation,
8
10
  zValidator
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;","names":[]}
1
+ {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\nexport { Authorizer } from './authorizer';\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;","names":[]}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * A Universally Unique Identifier (UUID) is a 36-character alphanumeric string that's typically represented in the following format:
3
+ * - Format: 8-4-4-4-12
4
+ * */
5
+ declare const UUID = 36;
6
+ /**
7
+ * The length of an Apple device's unique device identifier (UDID) depends on the model of the device:
8
+ * - iPhone X and earlier: The UDID is a 40-character alphanumeric string
9
+ * - iPhone XS and later: The UDID is a 24-character string with a dash after the 8th digit
10
+ * */
11
+ declare const UDID = 40;
12
+ /**
13
+ * Apple's Identifier for Vendors (IDFV).
14
+ * - `var identifierForVendor: UUID? { get }` An alphanumeric string that uniquely identifies a device to the app’s vendor.
15
+ * - Reference: [identifierForVendor](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)
16
+ * */
17
+ declare const IDFV = 36;
18
+ /**
19
+ * Apple's Identifier for Advertisers (IDFA).
20
+ * - `var advertisingIdentifier: UUID { get }` The UUID that is specific to a device.
21
+ * - Reference: [advertisingIdentifier](https://developer.apple.com/documentation/adsupport/asidentifiermanager/advertisingidentifier)
22
+ * */
23
+ declare const IDFA = 36;
24
+ /**
25
+ * Android Device ID
26
+ * - 64-bit number (expressed as a hexadecimal string)
27
+ * - Reference: [ANDROID_ID](https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID)
28
+ * */
29
+ declare const ANDROID_ID = 16;
30
+ /**
31
+ * - Web Device ID: UUID v4
32
+ * - iOS Device ID: IDFV
33
+ * - Android Device ID: ANDROID_ID
34
+ * */
35
+ declare const DEVICE_ID: number;
36
+ /**
37
+ * - The advertising ID is represented using version 3 of the universally unique identifier (UUID) format or an equivalent 128-bit format.
38
+ * - If this permission is not declared, the returned value will be 00000000-0000-0000-0000-000000000000 starting early 2022.
39
+ * - Reference: [AD_ID](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#public-string-getid)
40
+ * */
41
+ declare const AAID = 36;
42
+ /**
43
+ * - Web: UUID
44
+ * - iOS: IDFA
45
+ * - Android: AAID
46
+ * */
47
+ declare const ADVERTISING_ID: number;
48
+ /**
49
+ * - An IPv4 address is at most 4 sets of 3 numbers (12 characters), each set separated by a dot (.). That makes 15 characters.
50
+ * - An IPv6 address, at its longest, would be 8 sets of 4 characters (32 total), each set separated by a colon. That makes 39 characters.
51
+ * */
52
+ declare const IPv4 = 15;
53
+ declare const IPv6 = 39;
54
+ declare const IPv4_MAPPED_IPv6 = 45;
55
+ declare const IP: number;
56
+ /**
57
+ * - The longest string in the database is America/Argentina/ComodRivadavia. It's 32 characters long.
58
+ * - The mysql.time_zone_name table has a Name column defined with 64 characters.
59
+ * - It makes sense to use VARCHAR(64) for storing this information.
60
+ * - Reference: [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
61
+ * */
62
+ declare const TIMEZONE_LONGEST: number;
63
+ declare const TIMEZONE: number;
64
+ /**
65
+ * Reference: [List of ISO 3166 country codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
66
+ * */
67
+ declare const COUNTRY_CODE_ALPHA_2 = 2;
68
+ declare const COUNTRY_CODE_ALPHA_3 = 3;
69
+ declare const COUNTRY_CODE: number;
70
+ /**
71
+ * Reference: [RFC5646 Tags for Identifying Languages](https://www.rfc-editor.org/rfc/rfc5646#section-4.4.1)
72
+ * The following illustration shows how the 35-character recommendation was derived:
73
+ * ```
74
+ * language = 8 ; longest allowed registered value
75
+ * ; longer than primary+extlang
76
+ * ; which requires 7 characters
77
+ * script = 5 ; if not suppressed: see Section 4.1
78
+ * region = 4 ; UN M.49 numeric region code
79
+ * ; ISO 3166-1 codes require 3
80
+ * variant1 = 9 ; needs 'language' as a prefix
81
+ * variant2 = 9 ; very rare, as it needs
82
+ * ; 'language-variant1' as a prefix
83
+ *
84
+ * total = 35 characters
85
+ * ```
86
+ * */
87
+ declare const LANGUAGE_CODE = 35;
88
+ /**
89
+ * Mailbox = Local-part "@" ( Domain / address-literal )
90
+ * - Local-part: The maximum total length of a user name or other local-part is 64 octets.
91
+ * - Domain: The maximum total length of a domain name or number is 255 octets.
92
+ * - Maximum length of an email address: 64 + 1 + 255 = 320
93
+ * - Reference: [Simple Mail Transfer Protocol - Size Limits and Minimums](https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1)
94
+ * */
95
+ declare const EMAIL_LOCAL_PART = 64;
96
+ declare const EMAIL_DOMAIN = 255;
97
+ declare const EMAIL: number;
98
+ /**
99
+ * Reference: [E.164](https://en.wikipedia.org/wiki/E.164)
100
+ * */
101
+ declare const PHONE_NUMBER = 15;
102
+
103
+ declare const index_AAID: typeof AAID;
104
+ declare const index_ADVERTISING_ID: typeof ADVERTISING_ID;
105
+ declare const index_ANDROID_ID: typeof ANDROID_ID;
106
+ declare const index_COUNTRY_CODE: typeof COUNTRY_CODE;
107
+ declare const index_COUNTRY_CODE_ALPHA_2: typeof COUNTRY_CODE_ALPHA_2;
108
+ declare const index_COUNTRY_CODE_ALPHA_3: typeof COUNTRY_CODE_ALPHA_3;
109
+ declare const index_DEVICE_ID: typeof DEVICE_ID;
110
+ declare const index_EMAIL: typeof EMAIL;
111
+ declare const index_EMAIL_DOMAIN: typeof EMAIL_DOMAIN;
112
+ declare const index_EMAIL_LOCAL_PART: typeof EMAIL_LOCAL_PART;
113
+ declare const index_IDFA: typeof IDFA;
114
+ declare const index_IDFV: typeof IDFV;
115
+ declare const index_IP: typeof IP;
116
+ declare const index_IPv4: typeof IPv4;
117
+ declare const index_IPv4_MAPPED_IPv6: typeof IPv4_MAPPED_IPv6;
118
+ declare const index_IPv6: typeof IPv6;
119
+ declare const index_LANGUAGE_CODE: typeof LANGUAGE_CODE;
120
+ declare const index_PHONE_NUMBER: typeof PHONE_NUMBER;
121
+ declare const index_TIMEZONE: typeof TIMEZONE;
122
+ declare const index_TIMEZONE_LONGEST: typeof TIMEZONE_LONGEST;
123
+ declare const index_UDID: typeof UDID;
124
+ declare const index_UUID: typeof UUID;
125
+ declare namespace index {
126
+ export { index_AAID as AAID, index_ADVERTISING_ID as ADVERTISING_ID, index_ANDROID_ID as ANDROID_ID, index_COUNTRY_CODE as COUNTRY_CODE, index_COUNTRY_CODE_ALPHA_2 as COUNTRY_CODE_ALPHA_2, index_COUNTRY_CODE_ALPHA_3 as COUNTRY_CODE_ALPHA_3, index_DEVICE_ID as DEVICE_ID, index_EMAIL as EMAIL, index_EMAIL_DOMAIN as EMAIL_DOMAIN, index_EMAIL_LOCAL_PART as EMAIL_LOCAL_PART, index_IDFA as IDFA, index_IDFV as IDFV, index_IP as IP, index_IPv4 as IPv4, index_IPv4_MAPPED_IPv6 as IPv4_MAPPED_IPv6, index_IPv6 as IPv6, index_LANGUAGE_CODE as LANGUAGE_CODE, index_PHONE_NUMBER as PHONE_NUMBER, index_TIMEZONE as TIMEZONE, index_TIMEZONE_LONGEST as TIMEZONE_LONGEST, index_UDID as UDID, index_UUID as UUID };
127
+ }
128
+
129
+ export { ANDROID_ID as A, COUNTRY_CODE_ALPHA_2 as C, DEVICE_ID as D, EMAIL_LOCAL_PART as E, IDFV as I, LANGUAGE_CODE as L, PHONE_NUMBER as P, TIMEZONE_LONGEST as T, UUID as U, UDID as a, IDFA as b, AAID as c, ADVERTISING_ID as d, IPv4 as e, IPv6 as f, IPv4_MAPPED_IPv6 as g, IP as h, index as i, TIMEZONE as j, COUNTRY_CODE_ALPHA_3 as k, COUNTRY_CODE as l, EMAIL_DOMAIN as m, EMAIL as n };
@@ -0,0 +1,129 @@
1
+ /**
2
+ * A Universally Unique Identifier (UUID) is a 36-character alphanumeric string that's typically represented in the following format:
3
+ * - Format: 8-4-4-4-12
4
+ * */
5
+ declare const UUID = 36;
6
+ /**
7
+ * The length of an Apple device's unique device identifier (UDID) depends on the model of the device:
8
+ * - iPhone X and earlier: The UDID is a 40-character alphanumeric string
9
+ * - iPhone XS and later: The UDID is a 24-character string with a dash after the 8th digit
10
+ * */
11
+ declare const UDID = 40;
12
+ /**
13
+ * Apple's Identifier for Vendors (IDFV).
14
+ * - `var identifierForVendor: UUID? { get }` An alphanumeric string that uniquely identifies a device to the app’s vendor.
15
+ * - Reference: [identifierForVendor](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)
16
+ * */
17
+ declare const IDFV = 36;
18
+ /**
19
+ * Apple's Identifier for Advertisers (IDFA).
20
+ * - `var advertisingIdentifier: UUID { get }` The UUID that is specific to a device.
21
+ * - Reference: [advertisingIdentifier](https://developer.apple.com/documentation/adsupport/asidentifiermanager/advertisingidentifier)
22
+ * */
23
+ declare const IDFA = 36;
24
+ /**
25
+ * Android Device ID
26
+ * - 64-bit number (expressed as a hexadecimal string)
27
+ * - Reference: [ANDROID_ID](https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID)
28
+ * */
29
+ declare const ANDROID_ID = 16;
30
+ /**
31
+ * - Web Device ID: UUID v4
32
+ * - iOS Device ID: IDFV
33
+ * - Android Device ID: ANDROID_ID
34
+ * */
35
+ declare const DEVICE_ID: number;
36
+ /**
37
+ * - The advertising ID is represented using version 3 of the universally unique identifier (UUID) format or an equivalent 128-bit format.
38
+ * - If this permission is not declared, the returned value will be 00000000-0000-0000-0000-000000000000 starting early 2022.
39
+ * - Reference: [AD_ID](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#public-string-getid)
40
+ * */
41
+ declare const AAID = 36;
42
+ /**
43
+ * - Web: UUID
44
+ * - iOS: IDFA
45
+ * - Android: AAID
46
+ * */
47
+ declare const ADVERTISING_ID: number;
48
+ /**
49
+ * - An IPv4 address is at most 4 sets of 3 numbers (12 characters), each set separated by a dot (.). That makes 15 characters.
50
+ * - An IPv6 address, at its longest, would be 8 sets of 4 characters (32 total), each set separated by a colon. That makes 39 characters.
51
+ * */
52
+ declare const IPv4 = 15;
53
+ declare const IPv6 = 39;
54
+ declare const IPv4_MAPPED_IPv6 = 45;
55
+ declare const IP: number;
56
+ /**
57
+ * - The longest string in the database is America/Argentina/ComodRivadavia. It's 32 characters long.
58
+ * - The mysql.time_zone_name table has a Name column defined with 64 characters.
59
+ * - It makes sense to use VARCHAR(64) for storing this information.
60
+ * - Reference: [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
61
+ * */
62
+ declare const TIMEZONE_LONGEST: number;
63
+ declare const TIMEZONE: number;
64
+ /**
65
+ * Reference: [List of ISO 3166 country codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
66
+ * */
67
+ declare const COUNTRY_CODE_ALPHA_2 = 2;
68
+ declare const COUNTRY_CODE_ALPHA_3 = 3;
69
+ declare const COUNTRY_CODE: number;
70
+ /**
71
+ * Reference: [RFC5646 Tags for Identifying Languages](https://www.rfc-editor.org/rfc/rfc5646#section-4.4.1)
72
+ * The following illustration shows how the 35-character recommendation was derived:
73
+ * ```
74
+ * language = 8 ; longest allowed registered value
75
+ * ; longer than primary+extlang
76
+ * ; which requires 7 characters
77
+ * script = 5 ; if not suppressed: see Section 4.1
78
+ * region = 4 ; UN M.49 numeric region code
79
+ * ; ISO 3166-1 codes require 3
80
+ * variant1 = 9 ; needs 'language' as a prefix
81
+ * variant2 = 9 ; very rare, as it needs
82
+ * ; 'language-variant1' as a prefix
83
+ *
84
+ * total = 35 characters
85
+ * ```
86
+ * */
87
+ declare const LANGUAGE_CODE = 35;
88
+ /**
89
+ * Mailbox = Local-part "@" ( Domain / address-literal )
90
+ * - Local-part: The maximum total length of a user name or other local-part is 64 octets.
91
+ * - Domain: The maximum total length of a domain name or number is 255 octets.
92
+ * - Maximum length of an email address: 64 + 1 + 255 = 320
93
+ * - Reference: [Simple Mail Transfer Protocol - Size Limits and Minimums](https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1)
94
+ * */
95
+ declare const EMAIL_LOCAL_PART = 64;
96
+ declare const EMAIL_DOMAIN = 255;
97
+ declare const EMAIL: number;
98
+ /**
99
+ * Reference: [E.164](https://en.wikipedia.org/wiki/E.164)
100
+ * */
101
+ declare const PHONE_NUMBER = 15;
102
+
103
+ declare const index_AAID: typeof AAID;
104
+ declare const index_ADVERTISING_ID: typeof ADVERTISING_ID;
105
+ declare const index_ANDROID_ID: typeof ANDROID_ID;
106
+ declare const index_COUNTRY_CODE: typeof COUNTRY_CODE;
107
+ declare const index_COUNTRY_CODE_ALPHA_2: typeof COUNTRY_CODE_ALPHA_2;
108
+ declare const index_COUNTRY_CODE_ALPHA_3: typeof COUNTRY_CODE_ALPHA_3;
109
+ declare const index_DEVICE_ID: typeof DEVICE_ID;
110
+ declare const index_EMAIL: typeof EMAIL;
111
+ declare const index_EMAIL_DOMAIN: typeof EMAIL_DOMAIN;
112
+ declare const index_EMAIL_LOCAL_PART: typeof EMAIL_LOCAL_PART;
113
+ declare const index_IDFA: typeof IDFA;
114
+ declare const index_IDFV: typeof IDFV;
115
+ declare const index_IP: typeof IP;
116
+ declare const index_IPv4: typeof IPv4;
117
+ declare const index_IPv4_MAPPED_IPv6: typeof IPv4_MAPPED_IPv6;
118
+ declare const index_IPv6: typeof IPv6;
119
+ declare const index_LANGUAGE_CODE: typeof LANGUAGE_CODE;
120
+ declare const index_PHONE_NUMBER: typeof PHONE_NUMBER;
121
+ declare const index_TIMEZONE: typeof TIMEZONE;
122
+ declare const index_TIMEZONE_LONGEST: typeof TIMEZONE_LONGEST;
123
+ declare const index_UDID: typeof UDID;
124
+ declare const index_UUID: typeof UUID;
125
+ declare namespace index {
126
+ export { index_AAID as AAID, index_ADVERTISING_ID as ADVERTISING_ID, index_ANDROID_ID as ANDROID_ID, index_COUNTRY_CODE as COUNTRY_CODE, index_COUNTRY_CODE_ALPHA_2 as COUNTRY_CODE_ALPHA_2, index_COUNTRY_CODE_ALPHA_3 as COUNTRY_CODE_ALPHA_3, index_DEVICE_ID as DEVICE_ID, index_EMAIL as EMAIL, index_EMAIL_DOMAIN as EMAIL_DOMAIN, index_EMAIL_LOCAL_PART as EMAIL_LOCAL_PART, index_IDFA as IDFA, index_IDFV as IDFV, index_IP as IP, index_IPv4 as IPv4, index_IPv4_MAPPED_IPv6 as IPv4_MAPPED_IPv6, index_IPv6 as IPv6, index_LANGUAGE_CODE as LANGUAGE_CODE, index_PHONE_NUMBER as PHONE_NUMBER, index_TIMEZONE as TIMEZONE, index_TIMEZONE_LONGEST as TIMEZONE_LONGEST, index_UDID as UDID, index_UUID as UUID };
127
+ }
128
+
129
+ export { ANDROID_ID as A, COUNTRY_CODE_ALPHA_2 as C, DEVICE_ID as D, EMAIL_LOCAL_PART as E, IDFV as I, LANGUAGE_CODE as L, PHONE_NUMBER as P, TIMEZONE_LONGEST as T, UUID as U, UDID as a, IDFA as b, AAID as c, ADVERTISING_ID as d, IPv4 as e, IPv6 as f, IPv4_MAPPED_IPv6 as g, IP as h, index as i, TIMEZONE as j, COUNTRY_CODE_ALPHA_3 as k, COUNTRY_CODE as l, EMAIL_DOMAIN as m, EMAIL as n };
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -16,11 +18,20 @@ var __copyProps = (to, from, except, desc) => {
16
18
  return to;
17
19
  };
18
20
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
 
21
31
  // src/index.ts
22
32
  var index_exports = {};
23
33
  __export(index_exports, {
34
+ MAX_LENGTH: () => MAX_LENGTH,
24
35
  TokenBucket: () => import_token_bucket.TokenBucket,
25
36
  hasText: () => import_string.hasText,
26
37
  invariant: () => import_invariant.invariant,
@@ -33,6 +44,7 @@ __reExport(index_exports, require("./status.cjs"), module.exports);
33
44
  __reExport(index_exports, require("./vaild.cjs"), module.exports);
34
45
  __reExport(index_exports, require("./snowflake.cjs"), module.exports);
35
46
  __reExport(index_exports, require("./response.cjs"), module.exports);
47
+ var MAX_LENGTH = __toESM(require("./max-length/index.cjs"), 1);
36
48
  var import_string = require("./utils/string.cjs");
37
49
  var import_timing = require("./utils/timing.cjs");
38
50
  var import_webhook = require("./webhook.cjs");
@@ -40,6 +52,7 @@ var import_invariant = require("./utils/invariant.cjs");
40
52
  var import_token_bucket = require("./utils/token-bucket.cjs");
41
53
  // Annotate the CommonJS export names for ESM import in node:
42
54
  0 && (module.exports = {
55
+ MAX_LENGTH,
43
56
  TokenBucket,
44
57
  hasText,
45
58
  invariant,
@@ -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 type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { verifyStandardWebhook } from './webhook';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,0BAAc,yBAvBd;AAwBA,0BAAc,yBAxBd;AAyBA,0BAAc,wBAzBd;AA0BA,0BAAc,4BA1Bd;AA2BA,0BAAc,2BA3Bd;AA4BA,oBAAwB;AACxB,oBAAuB;AACvB,qBAAsC;AACtC,uBAA0B;AAC1B,0BAAqD;","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 type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport * as MAX_LENGTH from './max-length/index';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { verifyStandardWebhook } from './webhook';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,0BAAc,yBAvBd;AAwBA,0BAAc,yBAxBd;AAyBA,0BAAc,wBAzBd;AA0BA,0BAAc,4BA1Bd;AA2BA,0BAAc,2BA3Bd;AA4BA,iBAA4B;AAC5B,oBAAwB;AACxB,oBAAuB;AACvB,qBAAsC;AACtC,uBAA0B;AAC1B,0BAAqD;","names":[]}
package/dist/index.d.cts CHANGED
@@ -4,6 +4,7 @@ export { Code, DEFAULT_MESSAGES, ErrorBody, Status, StatusCode, StatusError } fr
4
4
  export { Result, valid } from './vaild.cjs';
5
5
  export { UidGenerator, uid } from './snowflake.cjs';
6
6
  export { Cursor, Empty, Entity, EntityId, InitParams, NextParams, PageParams, PagedResponse, ParentPageParams, PrevParams, Response, pageParamsSchema } from './response.cjs';
7
+ export { i as MAX_LENGTH } from './index-BnPgRQDl.cjs';
7
8
  export { hasText } from './utils/string.cjs';
8
9
  export { timing } from './utils/timing.cjs';
9
10
  export { verifyStandardWebhook } from './webhook.cjs';
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { Code, DEFAULT_MESSAGES, ErrorBody, Status, StatusCode, StatusError } fr
4
4
  export { Result, valid } from './vaild.js';
5
5
  export { UidGenerator, uid } from './snowflake.js';
6
6
  export { Cursor, Empty, Entity, EntityId, InitParams, NextParams, PageParams, PagedResponse, ParentPageParams, PrevParams, Response, pageParamsSchema } from './response.js';
7
+ export { i as MAX_LENGTH } from './index-BnPgRQDl.js';
7
8
  export { hasText } from './utils/string.js';
8
9
  export { timing } from './utils/timing.js';
9
10
  export { verifyStandardWebhook } from './webhook.js';
package/dist/index.mjs CHANGED
@@ -4,12 +4,14 @@ export * from "./status.mjs";
4
4
  export * from "./vaild.mjs";
5
5
  export * from "./snowflake.mjs";
6
6
  export * from "./response.mjs";
7
+ import * as MAX_LENGTH from "./max-length/index.mjs";
7
8
  import { hasText } from "./utils/string.mjs";
8
9
  import { timing } from "./utils/timing.mjs";
9
10
  import { verifyStandardWebhook } from "./webhook.mjs";
10
11
  import { invariant } from "./utils/invariant.mjs";
11
12
  import { TokenBucket } from "./utils/token-bucket.mjs";
12
13
  export {
14
+ MAX_LENGTH,
13
15
  TokenBucket,
14
16
  hasText,
15
17
  invariant,
@@ -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 type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { verifyStandardWebhook } from './webhook';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n"],"mappings":";AAuBA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;AAC1B,SAAS,mBAA4C;","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 type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport * as MAX_LENGTH from './max-length/index';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { verifyStandardWebhook } from './webhook';\nexport { invariant } from './utils/invariant';\nexport { TokenBucket, type TokenBucketOptions } from './utils/token-bucket';\n"],"mappings":";AAuBA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,YAAY,gBAAgB;AAC5B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;AAC1B,SAAS,mBAA4C;","names":[]}
@@ -0,0 +1,94 @@
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/max-length/index.ts
21
+ var max_length_exports = {};
22
+ __export(max_length_exports, {
23
+ AAID: () => AAID,
24
+ ADVERTISING_ID: () => ADVERTISING_ID,
25
+ ANDROID_ID: () => ANDROID_ID,
26
+ COUNTRY_CODE: () => COUNTRY_CODE,
27
+ COUNTRY_CODE_ALPHA_2: () => COUNTRY_CODE_ALPHA_2,
28
+ COUNTRY_CODE_ALPHA_3: () => COUNTRY_CODE_ALPHA_3,
29
+ DEVICE_ID: () => DEVICE_ID,
30
+ EMAIL: () => EMAIL,
31
+ EMAIL_DOMAIN: () => EMAIL_DOMAIN,
32
+ EMAIL_LOCAL_PART: () => EMAIL_LOCAL_PART,
33
+ IDFA: () => IDFA,
34
+ IDFV: () => IDFV,
35
+ IP: () => IP,
36
+ IPv4: () => IPv4,
37
+ IPv4_MAPPED_IPv6: () => IPv4_MAPPED_IPv6,
38
+ IPv6: () => IPv6,
39
+ LANGUAGE_CODE: () => LANGUAGE_CODE,
40
+ PHONE_NUMBER: () => PHONE_NUMBER,
41
+ TIMEZONE: () => TIMEZONE,
42
+ TIMEZONE_LONGEST: () => TIMEZONE_LONGEST,
43
+ UDID: () => UDID,
44
+ UUID: () => UUID
45
+ });
46
+ module.exports = __toCommonJS(max_length_exports);
47
+ var UUID = 36;
48
+ var UDID = 40;
49
+ var IDFV = UUID;
50
+ var IDFA = UUID;
51
+ var ANDROID_ID = 16;
52
+ var DEVICE_ID = Math.max(UUID, IDFV, ANDROID_ID);
53
+ var AAID = UUID;
54
+ var ADVERTISING_ID = Math.max(UUID, IDFA, AAID);
55
+ var IPv4 = 15;
56
+ var IPv6 = 39;
57
+ var IPv4_MAPPED_IPv6 = 45;
58
+ var IP = Math.max(IPv4, IPv6, IPv4_MAPPED_IPv6);
59
+ var TIMEZONE_LONGEST = "America/Argentina/ComodRivadavia".length;
60
+ var TIMEZONE = Math.max(64, TIMEZONE_LONGEST);
61
+ var COUNTRY_CODE_ALPHA_2 = 2;
62
+ var COUNTRY_CODE_ALPHA_3 = 3;
63
+ var COUNTRY_CODE = Math.max(COUNTRY_CODE_ALPHA_2, COUNTRY_CODE_ALPHA_3);
64
+ var LANGUAGE_CODE = 35;
65
+ var EMAIL_LOCAL_PART = 64;
66
+ var EMAIL_DOMAIN = 255;
67
+ var EMAIL = EMAIL_LOCAL_PART + 1 + EMAIL_DOMAIN;
68
+ var PHONE_NUMBER = 15;
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ AAID,
72
+ ADVERTISING_ID,
73
+ ANDROID_ID,
74
+ COUNTRY_CODE,
75
+ COUNTRY_CODE_ALPHA_2,
76
+ COUNTRY_CODE_ALPHA_3,
77
+ DEVICE_ID,
78
+ EMAIL,
79
+ EMAIL_DOMAIN,
80
+ EMAIL_LOCAL_PART,
81
+ IDFA,
82
+ IDFV,
83
+ IP,
84
+ IPv4,
85
+ IPv4_MAPPED_IPv6,
86
+ IPv6,
87
+ LANGUAGE_CODE,
88
+ PHONE_NUMBER,
89
+ TIMEZONE,
90
+ TIMEZONE_LONGEST,
91
+ UDID,
92
+ UUID
93
+ });
94
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/max-length/index.ts"],"sourcesContent":["// noinspection UnnecessaryLocalVariableJS,JSUnusedGlobalSymbols\n\n/**\n * A Universally Unique Identifier (UUID) is a 36-character alphanumeric string that's typically represented in the following format:\n * - Format: 8-4-4-4-12\n * */\nexport const UUID = 36;\n\n/**\n * The length of an Apple device's unique device identifier (UDID) depends on the model of the device:\n * - iPhone X and earlier: The UDID is a 40-character alphanumeric string\n * - iPhone XS and later: The UDID is a 24-character string with a dash after the 8th digit\n * */\nexport const UDID = 40;\n\n/**\n * Apple's Identifier for Vendors (IDFV).\n * - `var identifierForVendor: UUID? { get }` An alphanumeric string that uniquely identifies a device to the app’s vendor.\n * - Reference: [identifierForVendor](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)\n * */\nexport const IDFV = UUID;\n\n/**\n * Apple's Identifier for Advertisers (IDFA).\n * - `var advertisingIdentifier: UUID { get }` The UUID that is specific to a device.\n * - Reference: [advertisingIdentifier](https://developer.apple.com/documentation/adsupport/asidentifiermanager/advertisingidentifier)\n * */\nexport const IDFA = UUID;\n\n/**\n * Android Device ID\n * - 64-bit number (expressed as a hexadecimal string)\n * - Reference: [ANDROID_ID](https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID)\n * */\nexport const ANDROID_ID = 16;\n\n/**\n * - Web Device ID: UUID v4\n * - iOS Device ID: IDFV\n * - Android Device ID: ANDROID_ID\n * */\nexport const DEVICE_ID = Math.max(UUID, IDFV, ANDROID_ID); // 36\n\n/**\n * - The advertising ID is represented using version 3 of the universally unique identifier (UUID) format or an equivalent 128-bit format.\n * - If this permission is not declared, the returned value will be 00000000-0000-0000-0000-000000000000 starting early 2022.\n * - Reference: [AD_ID](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#public-string-getid)\n * */\nexport const AAID = UUID;\n\n/**\n * - Web: UUID\n * - iOS: IDFA\n * - Android: AAID\n * */\nexport const ADVERTISING_ID = Math.max(UUID, IDFA, AAID); // 36\n\n/**\n * - An IPv4 address is at most 4 sets of 3 numbers (12 characters), each set separated by a dot (.). That makes 15 characters.\n * - An IPv6 address, at its longest, would be 8 sets of 4 characters (32 total), each set separated by a colon. That makes 39 characters.\n * */\nexport const IPv4 = 15;\nexport const IPv6 = 39;\nexport const IPv4_MAPPED_IPv6 = 45;\nexport const IP = Math.max(IPv4, IPv6, IPv4_MAPPED_IPv6); // 45\n\n/**\n * - The longest string in the database is America/Argentina/ComodRivadavia. It's 32 characters long.\n * - The mysql.time_zone_name table has a Name column defined with 64 characters.\n * - It makes sense to use VARCHAR(64) for storing this information.\n * - Reference: [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)\n * */\nexport const TIMEZONE_LONGEST = 'America/Argentina/ComodRivadavia'.length;\nexport const TIMEZONE = Math.max(64, TIMEZONE_LONGEST); // 64\n\n/**\n * Reference: [List of ISO 3166 country codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)\n * */\nexport const COUNTRY_CODE_ALPHA_2 = 2; // US\nexport const COUNTRY_CODE_ALPHA_3 = 3; // USA\nexport const COUNTRY_CODE = Math.max(COUNTRY_CODE_ALPHA_2, COUNTRY_CODE_ALPHA_3); // 3\n\n/**\n * Reference: [RFC5646 Tags for Identifying Languages](https://www.rfc-editor.org/rfc/rfc5646#section-4.4.1)\n * The following illustration shows how the 35-character recommendation was derived:\n * ```\n * language = 8 ; longest allowed registered value\n * ; longer than primary+extlang\n * ; which requires 7 characters\n * script = 5 ; if not suppressed: see Section 4.1\n * region = 4 ; UN M.49 numeric region code\n * ; ISO 3166-1 codes require 3\n * variant1 = 9 ; needs 'language' as a prefix\n * variant2 = 9 ; very rare, as it needs\n * ; 'language-variant1' as a prefix\n *\n * total = 35 characters\n * ```\n * */\nexport const LANGUAGE_CODE = 35;\n\n/**\n * Mailbox = Local-part \"@\" ( Domain / address-literal )\n * - Local-part: The maximum total length of a user name or other local-part is 64 octets.\n * - Domain: The maximum total length of a domain name or number is 255 octets.\n * - Maximum length of an email address: 64 + 1 + 255 = 320\n * - Reference: [Simple Mail Transfer Protocol - Size Limits and Minimums](https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1)\n * */\nexport const EMAIL_LOCAL_PART = 64;\nexport const EMAIL_DOMAIN = 255;\nexport const EMAIL = EMAIL_LOCAL_PART + 1 + EMAIL_DOMAIN; // 320\n\n/**\n * Reference: [E.164](https://en.wikipedia.org/wiki/E.164)\n * */\nexport const PHONE_NUMBER = 15;\n\n/**\n * Reference: [How big can a user agent string get?](https://stackoverflow.com/questions/654921/how-big-can-a-user-agent-string-get)\n * */\n// export const USER_AGENT = 250;\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;AAAA;AAAA;AAAA;AAMO,IAAM,OAAO;AAOb,IAAM,OAAO;AAOb,IAAM,OAAO;AAOb,IAAM,OAAO;AAOb,IAAM,aAAa;AAOnB,IAAM,YAAY,KAAK,IAAI,MAAM,MAAM,UAAU;AAOjD,IAAM,OAAO;AAOb,IAAM,iBAAiB,KAAK,IAAI,MAAM,MAAM,IAAI;AAMhD,IAAM,OAAO;AACb,IAAM,OAAO;AACb,IAAM,mBAAmB;AACzB,IAAM,KAAK,KAAK,IAAI,MAAM,MAAM,gBAAgB;AAQhD,IAAM,mBAAmB,mCAAmC;AAC5D,IAAM,WAAW,KAAK,IAAI,IAAI,gBAAgB;AAK9C,IAAM,uBAAuB;AAC7B,IAAM,uBAAuB;AAC7B,IAAM,eAAe,KAAK,IAAI,sBAAsB,oBAAoB;AAmBxE,IAAM,gBAAgB;AAStB,IAAM,mBAAmB;AACzB,IAAM,eAAe;AACrB,IAAM,QAAQ,mBAAmB,IAAI;AAKrC,IAAM,eAAe;","names":[]}
@@ -0,0 +1 @@
1
+ export { c as AAID, d as ADVERTISING_ID, A as ANDROID_ID, l as COUNTRY_CODE, C as COUNTRY_CODE_ALPHA_2, k as COUNTRY_CODE_ALPHA_3, D as DEVICE_ID, n as EMAIL, m as EMAIL_DOMAIN, E as EMAIL_LOCAL_PART, b as IDFA, I as IDFV, h as IP, e as IPv4, g as IPv4_MAPPED_IPv6, f as IPv6, L as LANGUAGE_CODE, P as PHONE_NUMBER, j as TIMEZONE, T as TIMEZONE_LONGEST, a as UDID, U as UUID } from '../index-BnPgRQDl.cjs';
@@ -0,0 +1 @@
1
+ export { c as AAID, d as ADVERTISING_ID, A as ANDROID_ID, l as COUNTRY_CODE, C as COUNTRY_CODE_ALPHA_2, k as COUNTRY_CODE_ALPHA_3, D as DEVICE_ID, n as EMAIL, m as EMAIL_DOMAIN, E as EMAIL_LOCAL_PART, b as IDFA, I as IDFV, h as IP, e as IPv4, g as IPv4_MAPPED_IPv6, f as IPv6, L as LANGUAGE_CODE, P as PHONE_NUMBER, j as TIMEZONE, T as TIMEZONE_LONGEST, a as UDID, U as UUID } from '../index-BnPgRQDl.js';
@@ -0,0 +1,48 @@
1
+ // src/max-length/index.ts
2
+ var UUID = 36;
3
+ var UDID = 40;
4
+ var IDFV = UUID;
5
+ var IDFA = UUID;
6
+ var ANDROID_ID = 16;
7
+ var DEVICE_ID = Math.max(UUID, IDFV, ANDROID_ID);
8
+ var AAID = UUID;
9
+ var ADVERTISING_ID = Math.max(UUID, IDFA, AAID);
10
+ var IPv4 = 15;
11
+ var IPv6 = 39;
12
+ var IPv4_MAPPED_IPv6 = 45;
13
+ var IP = Math.max(IPv4, IPv6, IPv4_MAPPED_IPv6);
14
+ var TIMEZONE_LONGEST = "America/Argentina/ComodRivadavia".length;
15
+ var TIMEZONE = Math.max(64, TIMEZONE_LONGEST);
16
+ var COUNTRY_CODE_ALPHA_2 = 2;
17
+ var COUNTRY_CODE_ALPHA_3 = 3;
18
+ var COUNTRY_CODE = Math.max(COUNTRY_CODE_ALPHA_2, COUNTRY_CODE_ALPHA_3);
19
+ var LANGUAGE_CODE = 35;
20
+ var EMAIL_LOCAL_PART = 64;
21
+ var EMAIL_DOMAIN = 255;
22
+ var EMAIL = EMAIL_LOCAL_PART + 1 + EMAIL_DOMAIN;
23
+ var PHONE_NUMBER = 15;
24
+ export {
25
+ AAID,
26
+ ADVERTISING_ID,
27
+ ANDROID_ID,
28
+ COUNTRY_CODE,
29
+ COUNTRY_CODE_ALPHA_2,
30
+ COUNTRY_CODE_ALPHA_3,
31
+ DEVICE_ID,
32
+ EMAIL,
33
+ EMAIL_DOMAIN,
34
+ EMAIL_LOCAL_PART,
35
+ IDFA,
36
+ IDFV,
37
+ IP,
38
+ IPv4,
39
+ IPv4_MAPPED_IPv6,
40
+ IPv6,
41
+ LANGUAGE_CODE,
42
+ PHONE_NUMBER,
43
+ TIMEZONE,
44
+ TIMEZONE_LONGEST,
45
+ UDID,
46
+ UUID
47
+ };
48
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/max-length/index.ts"],"sourcesContent":["// noinspection UnnecessaryLocalVariableJS,JSUnusedGlobalSymbols\n\n/**\n * A Universally Unique Identifier (UUID) is a 36-character alphanumeric string that's typically represented in the following format:\n * - Format: 8-4-4-4-12\n * */\nexport const UUID = 36;\n\n/**\n * The length of an Apple device's unique device identifier (UDID) depends on the model of the device:\n * - iPhone X and earlier: The UDID is a 40-character alphanumeric string\n * - iPhone XS and later: The UDID is a 24-character string with a dash after the 8th digit\n * */\nexport const UDID = 40;\n\n/**\n * Apple's Identifier for Vendors (IDFV).\n * - `var identifierForVendor: UUID? { get }` An alphanumeric string that uniquely identifies a device to the app’s vendor.\n * - Reference: [identifierForVendor](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)\n * */\nexport const IDFV = UUID;\n\n/**\n * Apple's Identifier for Advertisers (IDFA).\n * - `var advertisingIdentifier: UUID { get }` The UUID that is specific to a device.\n * - Reference: [advertisingIdentifier](https://developer.apple.com/documentation/adsupport/asidentifiermanager/advertisingidentifier)\n * */\nexport const IDFA = UUID;\n\n/**\n * Android Device ID\n * - 64-bit number (expressed as a hexadecimal string)\n * - Reference: [ANDROID_ID](https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID)\n * */\nexport const ANDROID_ID = 16;\n\n/**\n * - Web Device ID: UUID v4\n * - iOS Device ID: IDFV\n * - Android Device ID: ANDROID_ID\n * */\nexport const DEVICE_ID = Math.max(UUID, IDFV, ANDROID_ID); // 36\n\n/**\n * - The advertising ID is represented using version 3 of the universally unique identifier (UUID) format or an equivalent 128-bit format.\n * - If this permission is not declared, the returned value will be 00000000-0000-0000-0000-000000000000 starting early 2022.\n * - Reference: [AD_ID](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#public-string-getid)\n * */\nexport const AAID = UUID;\n\n/**\n * - Web: UUID\n * - iOS: IDFA\n * - Android: AAID\n * */\nexport const ADVERTISING_ID = Math.max(UUID, IDFA, AAID); // 36\n\n/**\n * - An IPv4 address is at most 4 sets of 3 numbers (12 characters), each set separated by a dot (.). That makes 15 characters.\n * - An IPv6 address, at its longest, would be 8 sets of 4 characters (32 total), each set separated by a colon. That makes 39 characters.\n * */\nexport const IPv4 = 15;\nexport const IPv6 = 39;\nexport const IPv4_MAPPED_IPv6 = 45;\nexport const IP = Math.max(IPv4, IPv6, IPv4_MAPPED_IPv6); // 45\n\n/**\n * - The longest string in the database is America/Argentina/ComodRivadavia. It's 32 characters long.\n * - The mysql.time_zone_name table has a Name column defined with 64 characters.\n * - It makes sense to use VARCHAR(64) for storing this information.\n * - Reference: [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)\n * */\nexport const TIMEZONE_LONGEST = 'America/Argentina/ComodRivadavia'.length;\nexport const TIMEZONE = Math.max(64, TIMEZONE_LONGEST); // 64\n\n/**\n * Reference: [List of ISO 3166 country codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)\n * */\nexport const COUNTRY_CODE_ALPHA_2 = 2; // US\nexport const COUNTRY_CODE_ALPHA_3 = 3; // USA\nexport const COUNTRY_CODE = Math.max(COUNTRY_CODE_ALPHA_2, COUNTRY_CODE_ALPHA_3); // 3\n\n/**\n * Reference: [RFC5646 Tags for Identifying Languages](https://www.rfc-editor.org/rfc/rfc5646#section-4.4.1)\n * The following illustration shows how the 35-character recommendation was derived:\n * ```\n * language = 8 ; longest allowed registered value\n * ; longer than primary+extlang\n * ; which requires 7 characters\n * script = 5 ; if not suppressed: see Section 4.1\n * region = 4 ; UN M.49 numeric region code\n * ; ISO 3166-1 codes require 3\n * variant1 = 9 ; needs 'language' as a prefix\n * variant2 = 9 ; very rare, as it needs\n * ; 'language-variant1' as a prefix\n *\n * total = 35 characters\n * ```\n * */\nexport const LANGUAGE_CODE = 35;\n\n/**\n * Mailbox = Local-part \"@\" ( Domain / address-literal )\n * - Local-part: The maximum total length of a user name or other local-part is 64 octets.\n * - Domain: The maximum total length of a domain name or number is 255 octets.\n * - Maximum length of an email address: 64 + 1 + 255 = 320\n * - Reference: [Simple Mail Transfer Protocol - Size Limits and Minimums](https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1)\n * */\nexport const EMAIL_LOCAL_PART = 64;\nexport const EMAIL_DOMAIN = 255;\nexport const EMAIL = EMAIL_LOCAL_PART + 1 + EMAIL_DOMAIN; // 320\n\n/**\n * Reference: [E.164](https://en.wikipedia.org/wiki/E.164)\n * */\nexport const PHONE_NUMBER = 15;\n\n/**\n * Reference: [How big can a user agent string get?](https://stackoverflow.com/questions/654921/how-big-can-a-user-agent-string-get)\n * */\n// export const USER_AGENT = 250;\n"],"mappings":";AAMO,IAAM,OAAO;AAOb,IAAM,OAAO;AAOb,IAAM,OAAO;AAOb,IAAM,OAAO;AAOb,IAAM,aAAa;AAOnB,IAAM,YAAY,KAAK,IAAI,MAAM,MAAM,UAAU;AAOjD,IAAM,OAAO;AAOb,IAAM,iBAAiB,KAAK,IAAI,MAAM,MAAM,IAAI;AAMhD,IAAM,OAAO;AACb,IAAM,OAAO;AACb,IAAM,mBAAmB;AACzB,IAAM,KAAK,KAAK,IAAI,MAAM,MAAM,gBAAgB;AAQhD,IAAM,mBAAmB,mCAAmC;AAC5D,IAAM,WAAW,KAAK,IAAI,IAAI,gBAAgB;AAK9C,IAAM,uBAAuB;AAC7B,IAAM,uBAAuB;AAC7B,IAAM,eAAe,KAAK,IAAI,sBAAsB,oBAAoB;AAmBxE,IAAM,gBAAgB;AAStB,IAAM,mBAAmB;AACzB,IAAM,eAAe;AACrB,IAAM,QAAQ,mBAAmB,IAAI;AAKrC,IAAM,eAAe;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/http",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -8,6 +8,10 @@
8
8
  "build": "tsup",
9
9
  "test": "jest"
10
10
  },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/ShwareHQ/shware-sdk.git"
14
+ },
11
15
  "exports": {
12
16
  ".": {
13
17
  "types": "./dist/index.d.ts",