zklicensing 0.1.0-beta.2 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +132 -23
  2. package/build/archiveBootstrap.d.ts.map +1 -0
  3. package/build/archiveBootstrap.js +1 -1
  4. package/build/archiveBootstrap.js.map +1 -0
  5. package/build/buyClient.d.ts +2 -0
  6. package/build/buyClient.d.ts.map +1 -0
  7. package/build/buyClient.js +8 -2
  8. package/build/buyClient.js.map +1 -0
  9. package/build/contractInterface.d.ts.map +1 -0
  10. package/build/contractInterface.js +1 -1
  11. package/build/contractInterface.js.map +1 -0
  12. package/build/countryStats.d.ts +6 -1
  13. package/build/countryStats.d.ts.map +1 -0
  14. package/build/countryStats.js +33 -9
  15. package/build/countryStats.js.map +1 -0
  16. package/build/deployClient.d.ts.map +1 -0
  17. package/build/deployClient.js +1 -1
  18. package/build/deployClient.js.map +1 -0
  19. package/build/freezeClient.d.ts.map +1 -0
  20. package/build/freezeClient.js +1 -1
  21. package/build/freezeClient.js.map +1 -0
  22. package/build/generationClient.d.ts.map +1 -0
  23. package/build/generationClient.js +1 -1
  24. package/build/generationClient.js.map +1 -0
  25. package/build/index.d.ts.map +1 -0
  26. package/build/index.js +1 -1
  27. package/build/index.js.map +1 -0
  28. package/build/licenseProof.d.ts.map +1 -0
  29. package/build/licenseProof.js +1 -1
  30. package/build/licenseProof.js.map +1 -0
  31. package/build/licenseRecord.d.ts +10 -0
  32. package/build/licenseRecord.d.ts.map +1 -0
  33. package/build/licenseRecord.js +1 -1
  34. package/build/licenseRecord.js.map +1 -0
  35. package/build/licenseStore.d.ts +1 -1
  36. package/build/licenseStore.d.ts.map +1 -0
  37. package/build/licenseStore.js +4 -2
  38. package/build/licenseStore.js.map +1 -0
  39. package/build/manifestVerify.d.ts.map +1 -0
  40. package/build/manifestVerify.js +1 -1
  41. package/build/manifestVerify.js.map +1 -0
  42. package/build/migrateClient.d.ts +5 -21
  43. package/build/migrateClient.d.ts.map +1 -0
  44. package/build/migrateClient.js +29 -17
  45. package/build/migrateClient.js.map +1 -0
  46. package/build/ownership.d.ts.map +1 -0
  47. package/build/ownership.js +1 -1
  48. package/build/ownership.js.map +1 -0
  49. package/build/proveErrors.d.ts +35 -0
  50. package/build/proveErrors.d.ts.map +1 -0
  51. package/build/proveErrors.js +49 -0
  52. package/build/proveErrors.js.map +1 -0
  53. package/build/proveRetry.d.ts +38 -0
  54. package/build/proveRetry.d.ts.map +1 -0
  55. package/build/proveRetry.js +89 -0
  56. package/build/proveRetry.js.map +1 -0
  57. package/build/refundClient.d.ts.map +1 -0
  58. package/build/refundClient.js +1 -1
  59. package/build/refundClient.js.map +1 -0
  60. package/build/renewClient.d.ts +1 -0
  61. package/build/renewClient.d.ts.map +1 -0
  62. package/build/renewClient.js +9 -3
  63. package/build/renewClient.js.map +1 -0
  64. package/build/statsClient.d.ts +28 -0
  65. package/build/statsClient.d.ts.map +1 -0
  66. package/build/statsClient.js +34 -5
  67. package/build/statsClient.js.map +1 -0
  68. package/build/txBroadcastClient.d.ts +26 -0
  69. package/build/txBroadcastClient.d.ts.map +1 -0
  70. package/build/txBroadcastClient.js +20 -0
  71. package/build/txBroadcastClient.js.map +1 -0
  72. package/build/vendorAccountClient.d.ts +55 -0
  73. package/build/vendorAccountClient.d.ts.map +1 -0
  74. package/build/vendorAccountClient.js +44 -0
  75. package/build/vendorAccountClient.js.map +1 -0
  76. package/build/verifyCore.d.ts.map +1 -0
  77. package/build/verifyCore.js +1 -1
  78. package/build/verifyCore.js.map +1 -0
  79. package/build/verifyService.d.ts.map +1 -0
  80. package/build/verifyService.js +1 -1
  81. package/build/verifyService.js.map +1 -0
  82. package/build/zipToState.d.ts +2 -0
  83. package/build/zipToState.d.ts.map +1 -0
  84. package/build/zipToState.js +94 -0
  85. package/build/zipToState.js.map +1 -0
  86. package/package.json +19 -4
  87. package/src/archiveBootstrap.ts +285 -0
  88. package/src/buyClient.ts +259 -0
  89. package/src/contractInterface.d.ts +55 -0
  90. package/src/contractInterface.ts +242 -0
  91. package/src/countryStats.ts +171 -0
  92. package/src/deployClient.ts +388 -0
  93. package/src/freezeClient.ts +117 -0
  94. package/src/generationClient.ts +164 -0
  95. package/src/index.ts +392 -0
  96. package/src/licenseProof.d.ts +26 -0
  97. package/src/licenseProof.ts +48 -0
  98. package/src/licenseRecord.ts +91 -0
  99. package/src/licenseStore.ts +358 -0
  100. package/src/manifestVerify.ts +106 -0
  101. package/src/migrateClient.ts +82 -0
  102. package/src/ownership.ts +198 -0
  103. package/src/proveErrors.ts +70 -0
  104. package/src/refundClient.ts +144 -0
  105. package/src/renewClient.ts +209 -0
  106. package/src/statsClient.ts +190 -0
  107. package/src/txBroadcastClient.ts +48 -0
  108. package/src/vendorAccountClient.ts +106 -0
  109. package/src/verifyCore.ts +84 -0
  110. package/src/verifyService.ts +799 -0
  111. package/src/zipToState.ts +94 -0
@@ -0,0 +1,94 @@
1
+ // Copyright (c) 2025-2026 zkLicensing project developers
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+
4
+ /**
5
+ * zipToState.ts
6
+ *
7
+ * US ZIP-code prefix → 2-letter state code lookup. Used by countryStats.ts to
8
+ * roll US buyers up into per-state buckets for sales-tax reporting. Prefix is
9
+ * the first three digits of the ZIP; every US ZIP starts with three digits
10
+ * that resolve to exactly one state (source: USPS ZIP Code Directory).
11
+ *
12
+ * Data model: inclusive [lo, hi] prefix ranges → state code. Ranges are
13
+ * ordered by lo for readability but the lookup does a linear scan since the
14
+ * table is small (~55 rows) and this runs once per record on a background
15
+ * aggregation, not in a hot loop.
16
+ *
17
+ * Coverage: 50 states, DC, military APO/FPO (AA/AE/AP), Puerto Rico (PR), Guam
18
+ * and adjacent Pacific territories (GU). US Virgin Islands (VI), American
19
+ * Samoa (AS), and Northern Mariana Islands (MP) share prefixes with the
20
+ * Pacific block; we return 'GU' for that range — good enough for
21
+ * digital-goods reporting where those territories don't have their own tax.
22
+ * Returns undefined for prefixes that don't map (very few — USPS reserves
23
+ * some for future assignment).
24
+ */
25
+
26
+ const RANGES: ReadonlyArray<readonly [number, number, string]> = [
27
+ [ 5, 5, 'NY'],
28
+ [ 6, 9, 'PR'],
29
+ [ 10, 27, 'MA'],
30
+ [ 28, 29, 'RI'],
31
+ [ 30, 38, 'NH'],
32
+ [ 39, 49, 'ME'],
33
+ [ 50, 59, 'VT'],
34
+ [ 60, 69, 'CT'],
35
+ [ 70, 89, 'NJ'],
36
+ [ 90, 99, 'AE'],
37
+ [100, 149, 'NY'],
38
+ [150, 196, 'PA'],
39
+ [197, 199, 'DE'],
40
+ [200, 205, 'DC'],
41
+ [206, 219, 'MD'],
42
+ [220, 246, 'VA'],
43
+ [247, 268, 'WV'],
44
+ [270, 289, 'NC'],
45
+ [290, 299, 'SC'],
46
+ [300, 319, 'GA'],
47
+ [320, 349, 'FL'],
48
+ [350, 369, 'AL'],
49
+ [370, 385, 'TN'],
50
+ [386, 397, 'MS'],
51
+ [398, 399, 'GA'],
52
+ [400, 427, 'KY'],
53
+ [430, 459, 'OH'],
54
+ [460, 479, 'IN'],
55
+ [480, 499, 'MI'],
56
+ [500, 528, 'IA'],
57
+ [530, 549, 'WI'],
58
+ [550, 567, 'MN'],
59
+ [570, 577, 'SD'],
60
+ [580, 588, 'ND'],
61
+ [590, 599, 'MT'],
62
+ [600, 629, 'IL'],
63
+ [630, 658, 'MO'],
64
+ [660, 679, 'KS'],
65
+ [680, 693, 'NE'],
66
+ [700, 714, 'LA'],
67
+ [716, 729, 'AR'],
68
+ [730, 749, 'OK'],
69
+ [750, 799, 'TX'],
70
+ [800, 816, 'CO'],
71
+ [820, 831, 'WY'],
72
+ [832, 838, 'ID'],
73
+ [840, 847, 'UT'],
74
+ [850, 865, 'AZ'],
75
+ [870, 884, 'NM'],
76
+ [889, 898, 'NV'],
77
+ [900, 961, 'CA'],
78
+ [962, 966, 'AP'],
79
+ [967, 968, 'HI'],
80
+ [969, 969, 'GU'],
81
+ [970, 979, 'OR'],
82
+ [980, 994, 'WA'],
83
+ [995, 999, 'AK'],
84
+ ];
85
+
86
+ export function zipToState(zip: string): string | undefined {
87
+ const m = /^(\d{3})/.exec(zip);
88
+ if (!m) return undefined;
89
+ const n = parseInt(m[1], 10);
90
+ for (const [lo, hi, st] of RANGES) {
91
+ if (n >= lo && n <= hi) return st;
92
+ }
93
+ return undefined;
94
+ }