zklicensing 0.1.0-beta.2 → 0.1.0-beta.21
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/README.md +417 -201
- package/build/agent.d.ts +371 -0
- package/build/agent.d.ts.map +1 -0
- package/build/agent.js +553 -0
- package/build/agent.js.map +1 -0
- package/build/agentActions.d.ts +841 -0
- package/build/agentActions.d.ts.map +1 -0
- package/build/agentActions.js +581 -0
- package/build/agentActions.js.map +1 -0
- package/build/agentRecord.d.ts +83 -0
- package/build/agentRecord.d.ts.map +1 -0
- package/build/agentRecord.js +69 -0
- package/build/agentRecord.js.map +1 -0
- package/build/agentVendor.d.ts +220 -0
- package/build/agentVendor.d.ts.map +1 -0
- package/build/agentVendor.js +306 -0
- package/build/agentVendor.js.map +1 -0
- package/build/appsLookup.d.ts +14 -0
- package/build/appsLookup.d.ts.map +1 -0
- package/build/appsLookup.js +12 -0
- package/build/appsLookup.js.map +1 -0
- package/build/archiveBootstrap.d.ts +31 -5
- package/build/archiveBootstrap.d.ts.map +1 -0
- package/build/archiveBootstrap.js +140 -47
- package/build/archiveBootstrap.js.map +1 -0
- package/build/atomicJson.d.ts +5 -0
- package/build/atomicJson.d.ts.map +1 -0
- package/build/atomicJson.js +55 -0
- package/build/atomicJson.js.map +1 -0
- package/build/bindClient.d.ts +85 -0
- package/build/bindClient.d.ts.map +1 -0
- package/build/bindClient.js +187 -0
- package/build/bindClient.js.map +1 -0
- package/build/buyClient.d.ts +27 -4
- package/build/buyClient.d.ts.map +1 -0
- package/build/buyClient.js +72 -26
- package/build/buyClient.js.map +1 -0
- package/build/chainHead.d.ts +61 -0
- package/build/chainHead.d.ts.map +1 -0
- package/build/chainHead.js +88 -0
- package/build/chainHead.js.map +1 -0
- package/build/compactMerkleMap.d.ts +72 -0
- package/build/compactMerkleMap.d.ts.map +1 -0
- package/build/compactMerkleMap.js +224 -0
- package/build/compactMerkleMap.js.map +1 -0
- package/build/contractInterface.d.ts +191 -51
- package/build/contractInterface.d.ts.map +1 -0
- package/build/contractInterface.js +234 -43
- package/build/contractInterface.js.map +1 -0
- package/build/contractTypes.d.ts +9 -0
- package/build/contractTypes.d.ts.map +1 -0
- package/build/contractTypes.js +28 -0
- package/build/contractTypes.js.map +1 -0
- package/build/countryStats.d.ts +12 -3
- package/build/countryStats.d.ts.map +1 -0
- package/build/countryStats.js +87 -23
- package/build/countryStats.js.map +1 -0
- package/build/deployClient.d.ts +138 -24
- package/build/deployClient.d.ts.map +1 -0
- package/build/deployClient.js +91 -31
- package/build/deployClient.js.map +1 -0
- package/build/deviceIdentity.d.ts +68 -0
- package/build/deviceIdentity.d.ts.map +1 -0
- package/build/deviceIdentity.js +209 -0
- package/build/deviceIdentity.js.map +1 -0
- package/build/freezeClient.d.ts +26 -6
- package/build/freezeClient.d.ts.map +1 -0
- package/build/freezeClient.js +30 -6
- package/build/freezeClient.js.map +1 -0
- package/build/generationClient.d.ts +6 -3
- package/build/generationClient.d.ts.map +1 -0
- package/build/generationClient.js +25 -38
- package/build/generationClient.js.map +1 -0
- package/build/holderSecret.d.ts +70 -0
- package/build/holderSecret.d.ts.map +1 -0
- package/build/holderSecret.js +76 -0
- package/build/holderSecret.js.map +1 -0
- package/build/index.d.ts +38 -38
- package/build/index.d.ts.map +1 -0
- package/build/index.js +97 -121
- package/build/index.js.map +1 -0
- package/build/keysClient.d.ts +142 -0
- package/build/keysClient.d.ts.map +1 -0
- package/build/keysClient.js +109 -0
- package/build/keysClient.js.map +1 -0
- package/build/licenseLeaf.d.ts +76 -0
- package/build/licenseLeaf.d.ts.map +1 -0
- package/build/licenseLeaf.js +189 -0
- package/build/licenseLeaf.js.map +1 -0
- package/build/licenseRecord.d.ts +68 -5
- package/build/licenseRecord.d.ts.map +1 -0
- package/build/licenseRecord.js +26 -1
- package/build/licenseRecord.js.map +1 -0
- package/build/licenseStore.d.ts +81 -4
- package/build/licenseStore.d.ts.map +1 -0
- package/build/licenseStore.js +400 -30
- package/build/licenseStore.js.map +1 -0
- package/build/licenseTrustless.d.ts +43 -0
- package/build/licenseTrustless.d.ts.map +1 -0
- package/build/licenseTrustless.js +180 -0
- package/build/licenseTrustless.js.map +1 -0
- package/build/manifestVerify.d.ts +29 -1
- package/build/manifestVerify.d.ts.map +1 -0
- package/build/manifestVerify.js +46 -4
- package/build/manifestVerify.js.map +1 -0
- package/build/minaPriceHistory.d.ts +9 -0
- package/build/minaPriceHistory.d.ts.map +1 -0
- package/build/minaPriceHistory.js +152 -0
- package/build/minaPriceHistory.js.map +1 -0
- package/build/onChainRoot.d.ts +60 -0
- package/build/onChainRoot.d.ts.map +1 -0
- package/build/onChainRoot.js +74 -0
- package/build/onChainRoot.js.map +1 -0
- package/build/ownershipLicenseHash.d.ts +25 -0
- package/build/ownershipLicenseHash.d.ts.map +1 -0
- package/build/ownershipLicenseHash.js +29 -0
- package/build/ownershipLicenseHash.js.map +1 -0
- package/build/ownershipSignature.d.ts +153 -0
- package/build/ownershipSignature.d.ts.map +1 -0
- package/build/ownershipSignature.js +297 -0
- package/build/ownershipSignature.js.map +1 -0
- package/build/permitCheckFlow.d.ts +155 -0
- package/build/permitCheckFlow.d.ts.map +1 -0
- package/build/permitCheckFlow.js +196 -0
- package/build/permitCheckFlow.js.map +1 -0
- package/build/permitDescribe.d.ts +124 -0
- package/build/permitDescribe.d.ts.map +1 -0
- package/build/permitDescribe.js +324 -0
- package/build/permitDescribe.js.map +1 -0
- package/build/permitInterface.d.ts +85 -0
- package/build/permitInterface.d.ts.map +1 -0
- package/build/permitInterface.js +121 -0
- package/build/permitInterface.js.map +1 -0
- package/build/permitMessages.d.ts +313 -0
- package/build/permitMessages.d.ts.map +1 -0
- package/build/permitMessages.js +462 -0
- package/build/permitMessages.js.map +1 -0
- package/build/permitProof.d.ts +108 -0
- package/build/permitProof.d.ts.map +1 -0
- package/build/permitProof.js +202 -0
- package/build/permitProof.js.map +1 -0
- package/build/permitRegistryRebuild.d.ts +166 -0
- package/build/permitRegistryRebuild.d.ts.map +1 -0
- package/build/permitRegistryRebuild.js +347 -0
- package/build/permitRegistryRebuild.js.map +1 -0
- package/build/permitTree.d.ts +88 -0
- package/build/permitTree.d.ts.map +1 -0
- package/build/permitTree.js +230 -0
- package/build/permitTree.js.map +1 -0
- package/build/permitsClient.d.ts +680 -0
- package/build/permitsClient.d.ts.map +1 -0
- package/build/permitsClient.js +597 -0
- package/build/permitsClient.js.map +1 -0
- package/build/proveErrors.d.ts +50 -0
- package/build/proveErrors.d.ts.map +1 -0
- package/build/proveErrors.js +76 -0
- package/build/proveErrors.js.map +1 -0
- package/build/receipt.d.ts +95 -0
- package/build/receipt.d.ts.map +1 -0
- package/build/receipt.js +84 -0
- package/build/receipt.js.map +1 -0
- package/build/refundClient.d.ts +7 -12
- package/build/refundClient.d.ts.map +1 -0
- package/build/refundClient.js +52 -21
- package/build/refundClient.js.map +1 -0
- package/build/registryTrustVerify.d.ts +78 -0
- package/build/registryTrustVerify.d.ts.map +1 -0
- package/build/registryTrustVerify.js +129 -0
- package/build/registryTrustVerify.js.map +1 -0
- package/build/releaseClient.d.ts +26 -0
- package/build/releaseClient.d.ts.map +1 -0
- package/build/releaseClient.js +65 -0
- package/build/releaseClient.js.map +1 -0
- package/build/renewClient.d.ts +28 -2
- package/build/renewClient.d.ts.map +1 -0
- package/build/renewClient.js +31 -27
- package/build/renewClient.js.map +1 -0
- package/build/seatName.d.ts +8 -0
- package/build/seatName.d.ts.map +1 -0
- package/build/seatName.js +136 -0
- package/build/seatName.js.map +1 -0
- package/build/slotConstants.d.ts +15 -0
- package/build/slotConstants.d.ts.map +1 -0
- package/build/slotConstants.js +17 -0
- package/build/slotConstants.js.map +1 -0
- package/build/statsClient.d.ts +61 -7
- package/build/statsClient.d.ts.map +1 -0
- package/build/statsClient.js +44 -5
- package/build/statsClient.js.map +1 -0
- package/build/successorChain.d.ts +35 -0
- package/build/successorChain.d.ts.map +1 -0
- package/build/successorChain.js +69 -0
- package/build/successorChain.js.map +1 -0
- package/build/taxId.d.ts +44 -0
- package/build/taxId.d.ts.map +1 -0
- package/build/taxId.js +212 -0
- package/build/taxId.js.map +1 -0
- package/build/trustAnchorVerify.d.ts +49 -0
- package/build/trustAnchorVerify.d.ts.map +1 -0
- package/build/trustAnchorVerify.js +432 -0
- package/build/trustAnchorVerify.js.map +1 -0
- package/build/trustAnchorVerifyCli.d.ts +45 -0
- package/build/trustAnchorVerifyCli.d.ts.map +1 -0
- package/build/trustAnchorVerifyCli.js +235 -0
- package/build/trustAnchorVerifyCli.js.map +1 -0
- package/build/txBroadcastClient.d.ts +26 -0
- package/build/txBroadcastClient.d.ts.map +1 -0
- package/build/txBroadcastClient.js +20 -0
- package/build/txBroadcastClient.js.map +1 -0
- package/build/unbindClient.d.ts +77 -0
- package/build/unbindClient.d.ts.map +1 -0
- package/build/unbindClient.js +169 -0
- package/build/unbindClient.js.map +1 -0
- package/build/units.d.ts +28 -0
- package/build/units.d.ts.map +1 -0
- package/build/units.js +65 -0
- package/build/units.js.map +1 -0
- package/build/vatRates.d.ts +54 -0
- package/build/vatRates.d.ts.map +1 -0
- package/build/vatRates.js +82 -0
- package/build/vatRates.js.map +1 -0
- package/build/vatRatesData.d.ts +5 -0
- package/build/vatRatesData.d.ts.map +1 -0
- package/build/vatRatesData.js +42 -0
- package/build/vatRatesData.js.map +1 -0
- package/build/vendorAccountClient.d.ts +66 -0
- package/build/vendorAccountClient.d.ts.map +1 -0
- package/build/vendorAccountClient.js +47 -0
- package/build/vendorAccountClient.js.map +1 -0
- package/build/verifyCore.d.ts +4 -1
- package/build/verifyCore.d.ts.map +1 -0
- package/build/verifyCore.js +21 -10
- package/build/verifyCore.js.map +1 -0
- package/build/verifyOffline.d.ts +85 -0
- package/build/verifyOffline.d.ts.map +1 -0
- package/build/verifyOffline.js +139 -0
- package/build/verifyOffline.js.map +1 -0
- package/build/verifyService.d.ts.map +1 -0
- package/build/verifyService.js +571 -501
- package/build/verifyService.js.map +1 -0
- package/build/verifyWithAncestors.d.ts +19 -0
- package/build/verifyWithAncestors.d.ts.map +1 -0
- package/build/verifyWithAncestors.js +127 -0
- package/build/verifyWithAncestors.js.map +1 -0
- package/build/zipToState.d.ts +2 -0
- package/build/zipToState.d.ts.map +1 -0
- package/build/zipToState.js +94 -0
- package/build/zipToState.js.map +1 -0
- package/package.json +141 -16
- package/src/agent.ts +682 -0
- package/src/agentActions.ts +637 -0
- package/src/agentRecord.ts +121 -0
- package/src/agentVendor.ts +356 -0
- package/src/appsLookup.ts +48 -0
- package/src/archiveBootstrap.ts +386 -0
- package/src/atomicJson.ts +53 -0
- package/src/bindClient.ts +297 -0
- package/src/buyClient.ts +344 -0
- package/src/chainHead.ts +106 -0
- package/src/compactMerkleMap.ts +222 -0
- package/src/contractInterface.ts +465 -0
- package/src/contractTypes.ts +31 -0
- package/src/countryStats.ts +200 -0
- package/src/deployClient.ts +517 -0
- package/src/deviceIdentity.ts +249 -0
- package/src/freezeClient.ts +162 -0
- package/src/generationClient.ts +145 -0
- package/src/holderSecret.ts +91 -0
- package/src/index.ts +362 -0
- package/src/keysClient.ts +135 -0
- package/src/licenseLeaf.ts +221 -0
- package/src/licenseRecord.ts +190 -0
- package/src/licenseStore.ts +767 -0
- package/src/licenseTrustless.ts +207 -0
- package/src/manifestVerify.ts +164 -0
- package/src/minaPriceHistory.ts +166 -0
- package/src/onChainRoot.ts +90 -0
- package/src/ownershipLicenseHash.ts +31 -0
- package/src/ownershipSignature.ts +421 -0
- package/src/permitCheckFlow.ts +227 -0
- package/src/permitDescribe.ts +362 -0
- package/src/permitInterface.ts +146 -0
- package/src/permitMessages.ts +572 -0
- package/src/permitProof.ts +230 -0
- package/src/permitRegistryRebuild.ts +423 -0
- package/src/permitTree.ts +232 -0
- package/src/permitsClient.ts +746 -0
- package/src/proveErrors.ts +98 -0
- package/src/receipt.ts +156 -0
- package/src/refundClient.ts +177 -0
- package/src/registryTrustVerify.ts +192 -0
- package/src/releaseClient.ts +101 -0
- package/src/renewClient.ts +234 -0
- package/src/seatName.ts +165 -0
- package/src/slotConstants.ts +18 -0
- package/src/statsClient.ts +249 -0
- package/src/successorChain.ts +87 -0
- package/src/taxId.ts +227 -0
- package/src/trustAnchorVerify.ts +550 -0
- package/src/trustAnchorVerifyCli.ts +234 -0
- package/src/txBroadcastClient.ts +48 -0
- package/src/unbindClient.ts +233 -0
- package/src/units.ts +74 -0
- package/src/vatRates.ts +100 -0
- package/src/vatRatesData.ts +43 -0
- package/src/vendorAccountClient.ts +120 -0
- package/src/verifyCore.ts +100 -0
- package/src/verifyOffline.ts +212 -0
- package/src/verifyService.ts +982 -0
- package/src/verifyWithAncestors.ts +163 -0
- package/src/zipToState.ts +94 -0
- package/build/licenseProof.d.ts +0 -26
- package/build/licenseProof.js +0 -41
- package/build/migrateClient.d.ts +0 -43
- package/build/migrateClient.js +0 -47
- package/build/ownership.d.ts +0 -34
- package/build/ownership.js +0 -147
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Copyright (c) 2025-2026 zkLicensing project developers
|
|
2
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
3
|
+
/**
|
|
4
|
+
* seatName.ts
|
|
5
|
+
*
|
|
6
|
+
* Human-readable device names for the device-binding slot list
|
|
7
|
+
* ("Silent Otter", "Curious Panda"). Meant for the SDK UI so a buyer
|
|
8
|
+
* looking at their bound-devices panel sees "the laptop I left in the
|
|
9
|
+
* office" instead of an opaque device commitment.
|
|
10
|
+
*
|
|
11
|
+
* The name is purely cosmetic — the on-chain circuit never gates on it,
|
|
12
|
+
* verifyOffline never inspects it, and unbind targets `slotIndex`, not
|
|
13
|
+
* name. It exists solely so the SDK's device-manager UI has something
|
|
14
|
+
* readable to render next to each slot.
|
|
15
|
+
*
|
|
16
|
+
* Names are NOT persisted on-chain and NOT persisted off-chain either —
|
|
17
|
+
* `seatNameFor` derives the label deterministically from three on-chain
|
|
18
|
+
* fields (`licenseHash`, `slotIndex`, `boundAtSlot`), so every viewer of
|
|
19
|
+
* the same license computes the same name for a given occupied slot with
|
|
20
|
+
* no naming sidecar and no stored state.
|
|
21
|
+
*
|
|
22
|
+
* The wordlists are intentionally boring: no scary animals, no negative
|
|
23
|
+
* adjectives, no cultural landmines, no words with awkward secondary
|
|
24
|
+
* meanings. Order and word choice are stable — changing them shifts every
|
|
25
|
+
* slot's name on the next mint, which would be jarring for users looking
|
|
26
|
+
* at their device list.
|
|
27
|
+
*/
|
|
28
|
+
// 250 friendly adjectives. Short, common, unambiguously positive or
|
|
29
|
+
// neutral. Ordering is alphabetical for maintainability — the derivation
|
|
30
|
+
// is index-based so order does not affect behavior.
|
|
31
|
+
const ADJECTIVES = [
|
|
32
|
+
'Agile', 'Alert', 'Amber', 'Ample', 'Ancient', 'Apricot', 'Arctic', 'Ashen',
|
|
33
|
+
'Aspen', 'Autumn', 'Azure', 'Balmy', 'Bashful', 'Beaming', 'Beige', 'Bold',
|
|
34
|
+
'Bouncy', 'Brave', 'Breezy', 'Bright', 'Brisk', 'Bronze', 'Bubbly', 'Busy',
|
|
35
|
+
'Calm', 'Candid', 'Cedar', 'Cheery', 'Chic', 'Chipper', 'Chunky', 'Classic',
|
|
36
|
+
'Clean', 'Clever', 'Cloudy', 'Clumsy', 'Coastal', 'Comet', 'Cool', 'Copper',
|
|
37
|
+
'Coral', 'Cosmic', 'Cosy', 'Crafty', 'Creamy', 'Crimson', 'Crisp', 'Cuddly',
|
|
38
|
+
'Curious', 'Daisy', 'Dandy', 'Dapper', 'Daring', 'Dawn', 'Deft', 'Delta',
|
|
39
|
+
'Devout', 'Dewy', 'Diamond', 'Doughty', 'Dreamy', 'Dusky', 'Dusty', 'Eager',
|
|
40
|
+
'Earnest', 'Earthy', 'Easy', 'Ebony', 'Elder', 'Elm', 'Ember', 'Emerald',
|
|
41
|
+
'Epic', 'Fabled', 'Faint', 'Fair', 'Fancy', 'Fearless', 'Feisty', 'Fern',
|
|
42
|
+
'Fiery', 'Fine', 'Firm', 'Flaxen', 'Fleet', 'Floral', 'Fluffy', 'Foggy',
|
|
43
|
+
'Fond', 'Forest', 'Frank', 'Freckled', 'Friendly', 'Frosty', 'Frugal', 'Furry',
|
|
44
|
+
'Fuzzy', 'Gallant', 'Genial', 'Gentle', 'Gilded', 'Ginger', 'Glad', 'Glassy',
|
|
45
|
+
'Gleaming', 'Glossy', 'Glowing', 'Golden', 'Graceful', 'Grand', 'Grassy',
|
|
46
|
+
'Green', 'Handy', 'Happy', 'Hardy', 'Hazel', 'Hearty', 'Helpful', 'Honest',
|
|
47
|
+
'Humble', 'Icy', 'Indigo', 'Inky', 'Iron', 'Ivory', 'Jade', 'Jaunty', 'Jazzy',
|
|
48
|
+
'Jolly', 'Jovial', 'Joyful', 'Juniper', 'Keen', 'Kind', 'Lanky', 'Lark',
|
|
49
|
+
'Lavender', 'Lazy', 'Leaf', 'Lilac', 'Limber', 'Lively', 'Lofty', 'Loyal',
|
|
50
|
+
'Lucky', 'Lush', 'Marble', 'Matte', 'Meadow', 'Mellow', 'Merry', 'Mighty',
|
|
51
|
+
'Milky', 'Mindful', 'Minty', 'Misty', 'Modest', 'Mossy', 'Nautical', 'Nectar',
|
|
52
|
+
'Nifty', 'Nimble', 'Noble', 'Nutmeg', 'Oaken', 'Ochre', 'Olive', 'Onyx',
|
|
53
|
+
'Opal', 'Orange', 'Orchid', 'Pale', 'Patient', 'Peachy', 'Pearl', 'Pebble',
|
|
54
|
+
'Perky', 'Piney', 'Placid', 'Playful', 'Plucky', 'Plum', 'Plush', 'Polar',
|
|
55
|
+
'Polite', 'Prairie', 'Proud', 'Prudent', 'Punchy', 'Purple', 'Quaint', 'Quick',
|
|
56
|
+
'Quiet', 'Radiant', 'Rainy', 'Rapid', 'Rare', 'Ready', 'Ripe', 'River',
|
|
57
|
+
'Rocky', 'Rosy', 'Royal', 'Ruby', 'Rugged', 'Rustic', 'Saffron', 'Sage',
|
|
58
|
+
'Sandy', 'Sapphire', 'Scarlet', 'Serene', 'Shady', 'Sharp', 'Shy', 'Silent',
|
|
59
|
+
'Silken', 'Silky', 'Silver', 'Sincere', 'Sleek', 'Sleepy', 'Slender', 'Small',
|
|
60
|
+
'Smart', 'Smiling', 'Snowy', 'Solar', 'Solid', 'Sonic', 'Soulful', 'Speedy',
|
|
61
|
+
'Spirited', 'Splendid', 'Sprightly', 'Spry', 'Starry', 'Steady', 'Stellar',
|
|
62
|
+
'Sterling', 'Stormy', 'Stout', 'Sunny', 'Sunset', 'Swift', 'Tangy', 'Teal',
|
|
63
|
+
'Tender', 'Thankful', 'Thoughtful', 'Thrifty', 'Tidy', 'Timber', 'Tiny',
|
|
64
|
+
'Topaz', 'Tranquil', 'Trusty', 'Turquoise', 'Twilight', 'Upright', 'Valiant',
|
|
65
|
+
'Velvet', 'Verdant', 'Violet', 'Vivid', 'Warm', 'Whimsical', 'Willow',
|
|
66
|
+
'Windy', 'Winsome', 'Wise', 'Witty', 'Woodland', 'Woolly', 'Zealous', 'Zesty',
|
|
67
|
+
];
|
|
68
|
+
// 250 friendly animals. Common, recognisable, unambiguously non-threatening
|
|
69
|
+
// (no predators-of-humans, no venomous ones, no polarising taxidermy). Two-
|
|
70
|
+
// word species (mountain goat, sea otter) are collapsed to the base name so
|
|
71
|
+
// the final "Adjective Animal" reads cleanly. Ordering is alphabetical.
|
|
72
|
+
const ANIMALS = [
|
|
73
|
+
'Alpaca', 'Anteater', 'Antelope', 'Ape', 'Armadillo', 'Auk', 'Aurochs',
|
|
74
|
+
'Axolotl', 'Baboon', 'Badger', 'Barnacle', 'Bat', 'Beagle', 'Bear', 'Beaver',
|
|
75
|
+
'Bee', 'Beetle', 'Bison', 'Blackbird', 'Bluebird', 'Boar', 'Bobcat', 'Bonobo',
|
|
76
|
+
'Booby', 'Buffalo', 'Bulldog', 'Bullfinch', 'Bumblebee', 'Butterfly', 'Camel',
|
|
77
|
+
'Capybara', 'Cardinal', 'Caribou', 'Cassowary', 'Cat', 'Caterpillar',
|
|
78
|
+
'Catfish', 'Chameleon', 'Chamois', 'Cheetah', 'Chickadee', 'Chinchilla',
|
|
79
|
+
'Chipmunk', 'Clam', 'Clownfish', 'Coati', 'Cobra', 'Cockatoo', 'Codfish',
|
|
80
|
+
'Colt', 'Condor', 'Coot', 'Cormorant', 'Corgi', 'Cougar', 'Cow', 'Coyote',
|
|
81
|
+
'Crab', 'Crane', 'Cricket', 'Crow', 'Cub', 'Cuckoo', 'Curlew', 'Deer',
|
|
82
|
+
'Dingo', 'Dolphin', 'Donkey', 'Dormouse', 'Dove', 'Dragonfly', 'Drake',
|
|
83
|
+
'Duck', 'Duckling', 'Eagle', 'Echidna', 'Eel', 'Egret', 'Elephant', 'Elk',
|
|
84
|
+
'Emu', 'Falcon', 'Fawn', 'Ferret', 'Finch', 'Firefly', 'Fish', 'Flamingo',
|
|
85
|
+
'Fox', 'Frog', 'Gecko', 'Gerbil', 'Gibbon', 'Giraffe', 'Gnu', 'Goat',
|
|
86
|
+
'Godwit', 'Goldfinch', 'Goldfish', 'Goose', 'Gorilla', 'Grebe', 'Griffon',
|
|
87
|
+
'Grouse', 'Guanaco', 'Guineafowl', 'Gull', 'Guppy', 'Hamster', 'Hare',
|
|
88
|
+
'Harrier', 'Hawk', 'Hedgehog', 'Heron', 'Herring', 'Hippo', 'Hoatzin',
|
|
89
|
+
'Hoopoe', 'Hornbill', 'Horse', 'Hound', 'Hummingbird', 'Ibex', 'Ibis',
|
|
90
|
+
'Iguana', 'Impala', 'Jackal', 'Jackrabbit', 'Jaguar', 'Jay', 'Jellyfish',
|
|
91
|
+
'Kakapo', 'Kangaroo', 'Kestrel', 'Kingfisher', 'Kinkajou', 'Kite', 'Kitten',
|
|
92
|
+
'Kiwi', 'Koala', 'Kookaburra', 'Ladybug', 'Lamb', 'Lapwing', 'Lark',
|
|
93
|
+
'Lemming', 'Lemur', 'Leopard', 'Lion', 'Lizard', 'Llama', 'Lobster',
|
|
94
|
+
'Lorikeet', 'Loris', 'Lynx', 'Macaque', 'Macaw', 'Magpie', 'Mallard',
|
|
95
|
+
'Manatee', 'Mandrill', 'Mantis', 'Marmoset', 'Marmot', 'Marten', 'Meerkat',
|
|
96
|
+
'Mink', 'Minnow', 'Mole', 'Mongoose', 'Monkey', 'Moose', 'Moth', 'Mouse',
|
|
97
|
+
'Mule', 'Muntjac', 'Muskrat', 'Narwhal', 'Newt', 'Nightingale', 'Numbat',
|
|
98
|
+
'Nuthatch', 'Ocelot', 'Octopus', 'Okapi', 'Opossum', 'Orangutan', 'Oriole',
|
|
99
|
+
'Ostrich', 'Otter', 'Owl', 'Ox', 'Oyster', 'Panda', 'Pangolin', 'Panther',
|
|
100
|
+
'Parakeet', 'Parrot', 'Partridge', 'Peacock', 'Pelican', 'Penguin', 'Perch',
|
|
101
|
+
'Pheasant', 'Pig', 'Pigeon', 'Piglet', 'Pika', 'Pipit', 'Platypus', 'Plover',
|
|
102
|
+
'Pointer', 'Polecat', 'Pony', 'Porcupine', 'Porpoise', 'Possum', 'Prawn',
|
|
103
|
+
'Ptarmigan', 'Puffin', 'Puma', 'Pup', 'Puppy', 'Quail', 'Quokka', 'Rabbit',
|
|
104
|
+
'Raccoon', 'Ram', 'Rat', 'Raven', 'Reindeer', 'Rhino', 'Roadrunner', 'Robin',
|
|
105
|
+
'Rook', 'Salamander', 'Salmon', 'Sandpiper', 'Sardine', 'Scallop', 'Seahorse',
|
|
106
|
+
'Seal', 'Serval', 'Shrew', 'Shrimp', 'Skunk', 'Sloth', 'Snail', 'Snake',
|
|
107
|
+
'Snipe', 'Sparrow', 'Spider', 'Squid', 'Squirrel', 'Starling', 'Stoat',
|
|
108
|
+
'Stork', 'Sturgeon', 'Swallow', 'Swan', 'Tamarin', 'Tanager', 'Tapir',
|
|
109
|
+
'Tarsier', 'Teal', 'Tern', 'Terrier', 'Thrush', 'Tiger', 'Toad', 'Toucan',
|
|
110
|
+
'Trout', 'Tuna', 'Turkey', 'Turtle', 'Vole', 'Wagtail', 'Walrus', 'Wapiti',
|
|
111
|
+
'Warbler', 'Wasp', 'Weasel', 'Whale', 'Whippet', 'Wolf', 'Wolverine',
|
|
112
|
+
'Wombat', 'Woodchuck', 'Woodpecker', 'Wren', 'Yak', 'Zebra',
|
|
113
|
+
];
|
|
114
|
+
// Total combinations = ADJECTIVES.length * ANIMALS.length. Exposed for
|
|
115
|
+
// diagnostics and for tests that want to assert the name space is large
|
|
116
|
+
// enough to cover the expected ceiling of licenses × cap.
|
|
117
|
+
export const SEAT_NAME_COMBINATIONS = ADJECTIVES.length * ANIMALS.length;
|
|
118
|
+
// FNV-1a — a fast, non-cryptographic 32-bit hash. Uniform enough over 250
|
|
119
|
+
// buckets that the modulo bias (~1 in 17M) is invisible in practice. Not
|
|
120
|
+
// used for security; just to derive a stable pair of small indices from
|
|
121
|
+
// the seat's on-chain identity fields.
|
|
122
|
+
function fnv1a(s, seed) {
|
|
123
|
+
let h = seed >>> 0;
|
|
124
|
+
for (let i = 0; i < s.length; i++) {
|
|
125
|
+
h ^= s.charCodeAt(i);
|
|
126
|
+
h = Math.imul(h, 0x01000193);
|
|
127
|
+
}
|
|
128
|
+
return h >>> 0;
|
|
129
|
+
}
|
|
130
|
+
export function seatNameFor(input) {
|
|
131
|
+
const key = `${input.licenseHash}|${input.slotIndex}|${input.boundAtSlot}`;
|
|
132
|
+
const adj = ADJECTIVES[fnv1a(key, 0x811c9dc5) % ADJECTIVES.length];
|
|
133
|
+
const animal = ANIMALS[fnv1a(key, 0xdeadbeef) % ANIMALS.length];
|
|
134
|
+
return `${adj} ${animal}`;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=seatName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seatName.js","sourceRoot":"","sources":["../src/seatName.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,oCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,oEAAoE;AACpE,yEAAyE;AACzE,oDAAoD;AACpD,MAAM,UAAU,GAAsB;IACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,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AAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AA0BD,MAAM,UAAU,WAAW,CAAC,KAAoB;IAC9C,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;IAC3E,MAAM,GAAG,GAAM,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,OAAO,CAAI,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnE,OAAO,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slot math of the licensing contract (90 s per slot after the Mesa
|
|
3
|
+
* upgrade), as plain numbers. No o1js: the package root imports these, and
|
|
4
|
+
* o1js is an optional peer dependency (README, Publishing to npm).
|
|
5
|
+
* contractInterface re-exports them.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MONTHLY_SLOTS_N = 28800;
|
|
8
|
+
export declare const ONE_YEAR_SLOTS_N = 350640;
|
|
9
|
+
export declare const FIVE_YEAR_SLOTS_N = 1753200;
|
|
10
|
+
export declare const PERPETUAL_SLOTS_N = 350640000;
|
|
11
|
+
export declare const REFUND_WINDOW_N = 13440;
|
|
12
|
+
export declare const GRACE_PERIOD_N = 6720;
|
|
13
|
+
export declare const MS_PER_SLOT_N = 90000;
|
|
14
|
+
export declare const SLOTS_PER_DAY_N = 960;
|
|
15
|
+
//# sourceMappingURL=slotConstants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slotConstants.d.ts","sourceRoot":"","sources":["../src/slotConstants.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,eAAO,MAAM,eAAe,QAAY,CAAC;AACzC,eAAO,MAAM,gBAAgB,SAAY,CAAC;AAC1C,eAAO,MAAM,iBAAiB,UAAa,CAAC;AAC5C,eAAO,MAAM,iBAAiB,YAAe,CAAC;AAC9C,eAAO,MAAM,eAAe,QAAY,CAAC;AACzC,eAAO,MAAM,cAAc,OAAY,CAAC;AACxC,eAAO,MAAM,aAAa,QAAc,CAAC;AACzC,eAAO,MAAM,eAAe,MAAS,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) 2025-2026 zkLicensing project developers
|
|
2
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
3
|
+
/**
|
|
4
|
+
* Slot math of the licensing contract (90 s per slot after the Mesa
|
|
5
|
+
* upgrade), as plain numbers. No o1js: the package root imports these, and
|
|
6
|
+
* o1js is an optional peer dependency (README, Publishing to npm).
|
|
7
|
+
* contractInterface re-exports them.
|
|
8
|
+
*/
|
|
9
|
+
export const MONTHLY_SLOTS_N = 28_800; // 30 days × 24 × 40
|
|
10
|
+
export const ONE_YEAR_SLOTS_N = 350_640; // 365.25 days × 24 × 40 (Julian year)
|
|
11
|
+
export const FIVE_YEAR_SLOTS_N = 1_753_200; // 5 × ONE_YEAR_SLOTS_N
|
|
12
|
+
export const PERPETUAL_SLOTS_N = 350_640_000; // 1000 × ONE_YEAR_SLOTS_N ("perpetual — until vendor sunset")
|
|
13
|
+
export const REFUND_WINDOW_N = 13_440;
|
|
14
|
+
export const GRACE_PERIOD_N = 6_720;
|
|
15
|
+
export const MS_PER_SLOT_N = 90_000; // Mesa slot duration in ms
|
|
16
|
+
export const SLOTS_PER_DAY_N = 960; // 86_400_000 / MS_PER_SLOT_N
|
|
17
|
+
//# sourceMappingURL=slotConstants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slotConstants.js","sourceRoot":"","sources":["../src/slotConstants.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,oCAAoC;AAEpC;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAM,MAAM,CAAC,CAAM,oBAAoB;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAK,OAAO,CAAC,CAAK,sCAAsC;AACrF,MAAM,CAAC,MAAM,iBAAiB,GAAI,SAAS,CAAC,CAAG,uBAAuB;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAI,WAAW,CAAC,CAAC,8DAA8D;AAC7G,MAAM,CAAC,MAAM,eAAe,GAAM,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAO,KAAK,CAAC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAQ,MAAM,CAAC,CAAI,2BAA2B;AACxE,MAAM,CAAC,MAAM,eAAe,GAAM,GAAG,CAAC,CAAO,6BAA6B"}
|
package/build/statsClient.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* statsClient.ts
|
|
3
3
|
*
|
|
4
|
-
* Browser-safe HTTP client for the vendor-facing
|
|
4
|
+
* Browser-safe HTTP client for the vendor-facing backend endpoints that back
|
|
5
5
|
* the dashboard: GET /stats, GET /transactions, and GET /apps/vendor/:addr.
|
|
6
6
|
*
|
|
7
|
-
* Types mirror the
|
|
7
|
+
* Types mirror the backend's response shapes so a dashboard implementation
|
|
8
8
|
* (this repo's zklicensing.com dashboard or a third-party one) doesn't have
|
|
9
9
|
* to re-derive them. New optional fields on the server should be added here
|
|
10
|
-
* as `?:` so older clients still typecheck against a newer
|
|
10
|
+
* as `?:` so older clients still typecheck against a newer backend.
|
|
11
11
|
*/
|
|
12
12
|
import type { CountryBreakdown } from './countryStats.js';
|
|
13
|
-
|
|
13
|
+
import type { FiatRateSnapshot } from './licenseRecord.js';
|
|
14
|
+
export type Tier = 'monthly' | 'yearly' | 'fiveYear' | 'perpetual';
|
|
14
15
|
export type AppRecord = {
|
|
15
16
|
appId: string;
|
|
16
17
|
name: string;
|
|
@@ -18,12 +19,13 @@ export type AppRecord = {
|
|
|
18
19
|
longDescription?: string;
|
|
19
20
|
category: string;
|
|
20
21
|
website: string;
|
|
21
|
-
zkAppAddress
|
|
22
|
+
zkAppAddress?: string;
|
|
22
23
|
vendorAddress: string;
|
|
23
24
|
priceMonthlyMina: number;
|
|
24
25
|
priceYearlyMina: number;
|
|
25
26
|
priceFiveYearMina: number;
|
|
26
|
-
|
|
27
|
+
pricePerpetualMina: number;
|
|
28
|
+
txHash?: string;
|
|
27
29
|
verificationKeyHash?: string;
|
|
28
30
|
logo?: string;
|
|
29
31
|
iconUrl?: string;
|
|
@@ -31,13 +33,40 @@ export type AppRecord = {
|
|
|
31
33
|
contactEmail?: string;
|
|
32
34
|
supportEmail?: string;
|
|
33
35
|
country?: string;
|
|
34
|
-
status?: 'pending' | 'active' | 'inactive' | 'rejected';
|
|
36
|
+
status?: 'pending' | 'active' | 'inactive' | 'rejected' | 'not-deployed';
|
|
35
37
|
rejectionReason?: string;
|
|
36
38
|
createdAt: string;
|
|
37
39
|
approvedAt?: string;
|
|
40
|
+
network?: 'devnet' | 'mainnet';
|
|
41
|
+
alsoOnNetworks?: ('devnet' | 'mainnet')[];
|
|
42
|
+
firstEventSlot?: number;
|
|
43
|
+
lastSyncedSlot?: number;
|
|
44
|
+
onChainVersion?: number;
|
|
45
|
+
deploymentHistory?: unknown[];
|
|
38
46
|
pendingEdit?: Partial<AppRecord> & {
|
|
39
47
|
editedAt: string;
|
|
40
48
|
};
|
|
49
|
+
statusHistory?: {
|
|
50
|
+
status: string;
|
|
51
|
+
at: string;
|
|
52
|
+
actor: string;
|
|
53
|
+
note?: string;
|
|
54
|
+
}[];
|
|
55
|
+
legalName?: string;
|
|
56
|
+
billingAddress?: {
|
|
57
|
+
line1: string;
|
|
58
|
+
line2?: string;
|
|
59
|
+
city: string;
|
|
60
|
+
postalCode: string;
|
|
61
|
+
};
|
|
62
|
+
invoiceEmail?: string;
|
|
63
|
+
vatId?: string;
|
|
64
|
+
companyRegistrationRegistry?: string;
|
|
65
|
+
companyRegistrationNumber?: string;
|
|
66
|
+
termsOfServiceUrl?: string;
|
|
67
|
+
privacyPolicyUrl?: string;
|
|
68
|
+
refundPolicyUrl?: string;
|
|
69
|
+
registrationFeeMina?: number;
|
|
41
70
|
};
|
|
42
71
|
export type VendorStatsResponse = {
|
|
43
72
|
apps: AppRecord[];
|
|
@@ -45,6 +74,7 @@ export type VendorStatsResponse = {
|
|
|
45
74
|
totalLicenses: number;
|
|
46
75
|
totalRevenueMina: number;
|
|
47
76
|
pendingRevenueMina?: number;
|
|
77
|
+
refundedRevenueMina?: number;
|
|
48
78
|
renewalRate: number | null;
|
|
49
79
|
monthlyRevenueMina: {
|
|
50
80
|
month: string;
|
|
@@ -54,6 +84,7 @@ export type VendorStatsResponse = {
|
|
|
54
84
|
monthly: number;
|
|
55
85
|
yearly: number;
|
|
56
86
|
fiveYear: number;
|
|
87
|
+
perpetual: number;
|
|
57
88
|
};
|
|
58
89
|
deltas: {
|
|
59
90
|
revenuePct: number | null;
|
|
@@ -64,10 +95,21 @@ export type Transaction = {
|
|
|
64
95
|
type: 'purchase' | 'renewal' | 'release' | 'refund';
|
|
65
96
|
appId: string;
|
|
66
97
|
appName: string;
|
|
98
|
+
vendorAddress?: string;
|
|
67
99
|
tier: Tier | null;
|
|
68
100
|
amountMina: number;
|
|
69
101
|
txHash: string;
|
|
70
102
|
date: string;
|
|
103
|
+
buyerCountry?: string;
|
|
104
|
+
buyerZip?: string;
|
|
105
|
+
ipCountry?: string | null;
|
|
106
|
+
fiatSnapshot?: FiatRateSnapshot;
|
|
107
|
+
waiverGivenBy?: {
|
|
108
|
+
agent: string;
|
|
109
|
+
owner: string;
|
|
110
|
+
statementSha256: string;
|
|
111
|
+
issuedAt: string;
|
|
112
|
+
};
|
|
71
113
|
};
|
|
72
114
|
export type TransactionsResponse = {
|
|
73
115
|
transactions: Transaction[];
|
|
@@ -78,19 +120,31 @@ export type VendorAppsResponse = {
|
|
|
78
120
|
export declare function fetchVendorStats(opts: {
|
|
79
121
|
keeperUrl: string;
|
|
80
122
|
vendorAddress: string;
|
|
123
|
+
network: 'devnet' | 'mainnet';
|
|
124
|
+
adminToken?: string;
|
|
125
|
+
vendorSessionToken?: string;
|
|
126
|
+
tzOffsetMinutes?: number;
|
|
81
127
|
fetcher?: typeof fetch;
|
|
82
128
|
signal?: AbortSignal;
|
|
83
129
|
}): Promise<VendorStatsResponse | null>;
|
|
84
130
|
export declare function fetchTransactions(opts: {
|
|
85
131
|
keeperUrl: string;
|
|
86
132
|
vendorAddress: string;
|
|
133
|
+
network: 'devnet' | 'mainnet';
|
|
134
|
+
adminToken?: string;
|
|
135
|
+
vendorSessionToken?: string;
|
|
87
136
|
days?: number;
|
|
137
|
+
from?: string;
|
|
138
|
+
to?: string;
|
|
88
139
|
fetcher?: typeof fetch;
|
|
89
140
|
signal?: AbortSignal;
|
|
90
141
|
}): Promise<TransactionsResponse | null>;
|
|
91
142
|
export declare function fetchVendorApps(opts: {
|
|
92
143
|
keeperUrl: string;
|
|
93
144
|
vendorAddress: string;
|
|
145
|
+
adminToken?: string;
|
|
146
|
+
vendorSessionToken?: string;
|
|
147
|
+
network?: 'devnet' | 'mainnet';
|
|
94
148
|
fetcher?: typeof fetch;
|
|
95
149
|
signal?: AbortSignal;
|
|
96
150
|
}): Promise<VendorAppsResponse | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statsClient.d.ts","sourceRoot":"","sources":["../src/statsClient.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KA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right (c) 2025-2026 zkLicensing project developers
|
|
2
|
-
//
|
|
2
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
3
3
|
function baseUrl(url) {
|
|
4
4
|
return url.replace(/\/+$/, '');
|
|
5
5
|
}
|
|
6
|
+
// Admin __all mode: pass `adminToken` and omit `vendorAddress` (or pass '__all').
|
|
7
|
+
// Fetches aggregate over every registered app. Server gates with Bearer auth.
|
|
8
|
+
// tzOffsetMinutes: signed minutes east of UTC — shifts tax-year cutovers on the
|
|
9
|
+
// countryBreakdown so a UK vendor's 2026 doesn't include a Dec 31 23:30 PST
|
|
10
|
+
// purchase. Default omitted → UTC bucketing preserved for existing callers.
|
|
6
11
|
export async function fetchVendorStats(opts) {
|
|
7
12
|
const fetcher = opts.fetcher ?? fetch;
|
|
8
|
-
const
|
|
13
|
+
const headers = {};
|
|
14
|
+
if (opts.adminToken)
|
|
15
|
+
headers.Authorization = `Bearer ${opts.adminToken}`;
|
|
16
|
+
else if (opts.vendorSessionToken)
|
|
17
|
+
headers.Authorization = `VendorSession ${opts.vendorSessionToken}`;
|
|
18
|
+
const tzQ = typeof opts.tzOffsetMinutes === 'number' ? `&tz=${opts.tzOffsetMinutes}` : '';
|
|
19
|
+
const resp = await fetcher(`${baseUrl(opts.keeperUrl)}/stats?vendor=${encodeURIComponent(opts.vendorAddress)}&network=${opts.network}${tzQ}`, { signal: opts.signal, headers });
|
|
9
20
|
if (!resp.ok)
|
|
10
21
|
return null;
|
|
11
22
|
return await resp.json();
|
|
12
23
|
}
|
|
13
24
|
export async function fetchTransactions(opts) {
|
|
14
25
|
const fetcher = opts.fetcher ?? fetch;
|
|
15
|
-
const
|
|
16
|
-
|
|
26
|
+
const headers = {};
|
|
27
|
+
if (opts.adminToken)
|
|
28
|
+
headers.Authorization = `Bearer ${opts.adminToken}`;
|
|
29
|
+
else if (opts.vendorSessionToken)
|
|
30
|
+
headers.Authorization = `VendorSession ${opts.vendorSessionToken}`;
|
|
31
|
+
const qs = new URLSearchParams({ vendor: opts.vendorAddress, network: opts.network });
|
|
32
|
+
if (opts.from && opts.to) {
|
|
33
|
+
qs.set('from', opts.from);
|
|
34
|
+
qs.set('to', opts.to);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
qs.set('days', String(opts.days ?? 30));
|
|
38
|
+
}
|
|
39
|
+
const resp = await fetcher(`${baseUrl(opts.keeperUrl)}/transactions?${qs.toString()}`, { signal: opts.signal, headers });
|
|
17
40
|
if (!resp.ok)
|
|
18
41
|
return null;
|
|
19
42
|
return await resp.json();
|
|
20
43
|
}
|
|
44
|
+
// Admin all-apps mode: pass `adminToken` and set `vendorAddress` to '__all'.
|
|
45
|
+
// Hits GET /apps (no auth needed today; the admin overload just uses a
|
|
46
|
+
// different URL) so vendors visiting their own dashboard still hit the same
|
|
47
|
+
// per-vendor endpoint.
|
|
21
48
|
export async function fetchVendorApps(opts) {
|
|
22
49
|
const fetcher = opts.fetcher ?? fetch;
|
|
23
|
-
const
|
|
50
|
+
const headers = {};
|
|
51
|
+
if (opts.adminToken)
|
|
52
|
+
headers.Authorization = `Bearer ${opts.adminToken}`;
|
|
53
|
+
else if (opts.vendorSessionToken)
|
|
54
|
+
headers.Authorization = `VendorSession ${opts.vendorSessionToken}`;
|
|
55
|
+
const isAdminAll = opts.adminToken && opts.vendorAddress === '__all';
|
|
56
|
+
if (!isAdminAll && !opts.network) {
|
|
57
|
+
throw new Error("fetchVendorApps: `network` is required for the per-vendor path");
|
|
58
|
+
}
|
|
59
|
+
const url = isAdminAll
|
|
60
|
+
? `${baseUrl(opts.keeperUrl)}/apps?all=1`
|
|
61
|
+
: `${baseUrl(opts.keeperUrl)}/apps/vendor/${encodeURIComponent(opts.vendorAddress)}?network=${opts.network}`;
|
|
62
|
+
const resp = await fetcher(url, { signal: opts.signal, headers });
|
|
24
63
|
if (!resp.ok)
|
|
25
64
|
return null;
|
|
26
65
|
return await resp.json();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statsCl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AE,CAAC;IAC3C,IAAI,IAAI,CAAC,UAAU;QAAE,OAAO,CAAC,aAAa,GAAG,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;SACpE,IAAI,IAAI,CAAC,kBAAkB;QAAE,OAAO,CAAC,aAAa,GAAG,iBAAiB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACrG,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,CAAC;IACrE,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,GAAG,GAAG,UAAU;QACpB,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa;QACzC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/G,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,MAAM,IAAI,CAAC,IAAI,EAAwB,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ZkappAccount } from './chainHead.js';
|
|
2
|
+
/** Where a contract kind keeps its lineage in state. */
|
|
3
|
+
export type LineageLayout = {
|
|
4
|
+
/** Contract name for error messages. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** State index and value that mark the contract retired. */
|
|
7
|
+
retiredAt: number;
|
|
8
|
+
retiredValue: string;
|
|
9
|
+
/** The tree root a retirement freezes, and where a successor keeps the root it started from. */
|
|
10
|
+
rootAt: number;
|
|
11
|
+
ancestorsRootAt: number;
|
|
12
|
+
successorXAt: number;
|
|
13
|
+
successorIsOddAt: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const LICENSING_LINEAGE: LineageLayout;
|
|
16
|
+
/** A retired registry's authority-keys hash is RETIRED_KEYS_HASH (1). */
|
|
17
|
+
export declare const PERMIT_LINEAGE: LineageLayout;
|
|
18
|
+
export declare const MAX_LINEAGE_HOPS = 32;
|
|
19
|
+
/**
|
|
20
|
+
* Follows `start`'s successors to the current contract. Returns it with
|
|
21
|
+
* its account (`found: false` when `start` isn't on chain). Throws when a
|
|
22
|
+
* named successor is deployed but isn't a published release (`canonicalVks`)
|
|
23
|
+
* or didn't start from the frozen root.
|
|
24
|
+
*/
|
|
25
|
+
export declare function currentOnChain(args: {
|
|
26
|
+
start: string;
|
|
27
|
+
layout: LineageLayout;
|
|
28
|
+
canonicalVks: readonly string[];
|
|
29
|
+
graphqlUrl: string;
|
|
30
|
+
fetcher?: typeof fetch;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
address: string;
|
|
33
|
+
account: ZkappAccount;
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=successorChain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"successorChain.d.ts","sourceRoot":"","sources":["../src/successorChain.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAIrE,wDAAwD;AACxD,MAAM,MAAM,aAAa,GAAG;IAC1B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,aAK/B,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,cAAc,EAAE,aAK5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC,CAsBtD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright (c) 2025-2026 zkLicensing project developers
|
|
2
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
3
|
+
/**
|
|
4
|
+
* successorChain.ts — the current contract of a lineage (licensing app
|
|
5
|
+
* generations, permit registry generations), from chain state alone.
|
|
6
|
+
*
|
|
7
|
+
* A retired contract names its successor in its state (its retirement,
|
|
8
|
+
* which the vendor or authority signed, stored it), and the successor's
|
|
9
|
+
* initialization checked on chain that the predecessor named it. Each hop
|
|
10
|
+
* here also checks the successor runs a published release and started
|
|
11
|
+
* from the predecessor's frozen root. A successor not deployed yet
|
|
12
|
+
* (between retirement and deployment, e.g. across a hard fork) leaves the
|
|
13
|
+
* retired contract current.
|
|
14
|
+
*/
|
|
15
|
+
import { Field, PublicKey } from 'o1js';
|
|
16
|
+
import { readZkappAccount } from './chainHead.js';
|
|
17
|
+
import { LICENSING_APP_STATE } from './contractInterface.js';
|
|
18
|
+
import { PERMIT_REGISTRY_STATE } from './permitInterface.js';
|
|
19
|
+
export const LICENSING_LINEAGE = {
|
|
20
|
+
name: 'LicensingApp',
|
|
21
|
+
retiredAt: LICENSING_APP_STATE.retired, retiredValue: '1',
|
|
22
|
+
rootAt: LICENSING_APP_STATE.licensesRoot, ancestorsRootAt: LICENSING_APP_STATE.ancestorsRoot,
|
|
23
|
+
successorXAt: LICENSING_APP_STATE.successorX, successorIsOddAt: LICENSING_APP_STATE.successorIsOdd,
|
|
24
|
+
};
|
|
25
|
+
/** A retired registry's authority-keys hash is RETIRED_KEYS_HASH (1). */
|
|
26
|
+
export const PERMIT_LINEAGE = {
|
|
27
|
+
name: 'PermitRegistry',
|
|
28
|
+
retiredAt: PERMIT_REGISTRY_STATE.authorityKeysHash, retiredValue: '1',
|
|
29
|
+
rootAt: PERMIT_REGISTRY_STATE.permitsRoot, ancestorsRootAt: PERMIT_REGISTRY_STATE.ancestorsRoot,
|
|
30
|
+
successorXAt: PERMIT_REGISTRY_STATE.successorX, successorIsOddAt: PERMIT_REGISTRY_STATE.successorIsOdd,
|
|
31
|
+
};
|
|
32
|
+
export const MAX_LINEAGE_HOPS = 32;
|
|
33
|
+
/**
|
|
34
|
+
* Follows `start`'s successors to the current contract. Returns it with
|
|
35
|
+
* its account (`found: false` when `start` isn't on chain). Throws when a
|
|
36
|
+
* named successor is deployed but isn't a published release (`canonicalVks`)
|
|
37
|
+
* or didn't start from the frozen root.
|
|
38
|
+
*/
|
|
39
|
+
export async function currentOnChain(args) {
|
|
40
|
+
const { layout: l } = args;
|
|
41
|
+
const read = (address) => readZkappAccount({ address, graphqlUrl: args.graphqlUrl, fetcher: args.fetcher });
|
|
42
|
+
let address = args.start;
|
|
43
|
+
let account = await read(address);
|
|
44
|
+
for (let hop = 0; hop < MAX_LINEAGE_HOPS; hop++) {
|
|
45
|
+
const st = account.appState;
|
|
46
|
+
if (!account.found || !st || st[l.retiredAt] !== l.retiredValue)
|
|
47
|
+
return { address, account };
|
|
48
|
+
let next;
|
|
49
|
+
try {
|
|
50
|
+
next = PublicKey.fromFields([Field(st[l.successorXAt]), Field(st[l.successorIsOddAt])]).toBase58();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { address, account };
|
|
54
|
+
}
|
|
55
|
+
const succ = await read(next);
|
|
56
|
+
if (!succ.found || !succ.appState)
|
|
57
|
+
return { address, account }; // not deployed yet
|
|
58
|
+
if (!succ.vkHash || !args.canonicalVks.includes(succ.vkHash)) {
|
|
59
|
+
throw new Error(`The successor ${next} of ${address} is not a published ${l.name} release`);
|
|
60
|
+
}
|
|
61
|
+
if (succ.appState[l.ancestorsRootAt] !== st[l.rootAt]) {
|
|
62
|
+
throw new Error(`The successor ${next} of ${address} did not start from its frozen root`);
|
|
63
|
+
}
|
|
64
|
+
address = next;
|
|
65
|
+
account = succ;
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`${l.name} lineage of ${args.start} is longer than ${MAX_LINEAGE_HOPS} generations`);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=successorChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"successorChain.js","sourceRoot":"","sources":["../src/successorChain.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,oCAAoC;AAEpC;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAqB,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAgB7D,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC9C,IAAI,EAAE,cAAc;IACpB,SAAS,EAAE,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG;IACzD,MAAM,EAAE,mBAAmB,CAAC,YAAY,EAAE,eAAe,EAAE,mBAAmB,CAAC,aAAa;IAC5F,YAAY,EAAE,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,CAAC,cAAc;CACnG,CAAC;AAEF,yEAAyE;AACzE,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,IAAI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CAAC,CAAC,QAAQ,EAAE,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAAC,CAAC;QAClJ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,mBAAmB;QACnF,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,OAAO,OAAO,uBAAuB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC;QAC9F,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,OAAO,OAAO,qCAAqC,CAAC,CAAC;QAC5F,CAAC;QACD,OAAO,GAAG,IAAI,CAAC;QACf,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,eAAe,IAAI,CAAC,KAAK,mBAAmB,gBAAgB,cAAc,CAAC,CAAC;AACvG,CAAC"}
|
package/build/taxId.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* taxId.ts — `zklicensing/tax-id`
|
|
3
|
+
*
|
|
4
|
+
* Vendor tax identifiers: every vendor must have one. This module checks
|
|
5
|
+
* the format (and, where the scheme has one, the check digit) for the
|
|
6
|
+
* vendor's country, offline. EU VAT numbers are additionally looked up in
|
|
7
|
+
* VIES by the keeper; this module only says which numbers go to VIES.
|
|
8
|
+
*
|
|
9
|
+
* checkTaxId('FI', 'FI 1234 5678') → { ok, scheme: 'eu-vat', normalized: 'FI12345678', vies: { countryCode: 'FI', number: '12345678' } }
|
|
10
|
+
* checkTaxId('NO', '974 760 673 MVA') → { ok, scheme: 'no-mva', normalized: 'NO974760673MVA' }
|
|
11
|
+
* checkTaxId('BR', '…') → { ok, scheme: 'other', review: true } (no known format: admin review)
|
|
12
|
+
*
|
|
13
|
+
* Pure and browser-safe: the site uses it for live form feedback.
|
|
14
|
+
*/
|
|
15
|
+
export type TaxIdScheme = 'eu-vat' | 'gb-vat' | 'no-mva' | 'ch-uid' | 'au-abn' | 'nz-gst' | 'ca-bn' | 'us-ein' | 'jp-invoice' | 'in-gstin' | 'sg-gst' | 'other';
|
|
16
|
+
export type TaxIdResult = {
|
|
17
|
+
ok: true;
|
|
18
|
+
scheme: TaxIdScheme;
|
|
19
|
+
/** Canonical form to store and show. */
|
|
20
|
+
normalized: string;
|
|
21
|
+
/** EU numbers only: what to look up in VIES (Greece is `EL`, Northern Ireland `XI`). */
|
|
22
|
+
vies?: {
|
|
23
|
+
countryCode: string;
|
|
24
|
+
number: string;
|
|
25
|
+
};
|
|
26
|
+
/** True when the country has no known format: accepted for an admin to review. */
|
|
27
|
+
review?: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
ok: false;
|
|
30
|
+
scheme: TaxIdScheme;
|
|
31
|
+
error: string;
|
|
32
|
+
example?: string;
|
|
33
|
+
};
|
|
34
|
+
/** True for the 27 EU member states (ISO codes; Greece is GR here). */
|
|
35
|
+
export declare function isEuCountry(country: string): boolean;
|
|
36
|
+
/** An example of the expected format for `country`, for form placeholders. */
|
|
37
|
+
export declare function taxIdExample(country: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Checks `taxId` for a vendor in `country` (ISO 3166-1 alpha-2): the format
|
|
40
|
+
* and, where the scheme has one, the check digit. Spaces, dots and dashes
|
|
41
|
+
* are ignored; letters are upper-cased.
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkTaxId(country: string, taxId: string): TaxIdResult;
|
|
44
|
+
//# sourceMappingURL=taxId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taxId.d.ts","sourceRoot":"","sources":["../src/taxId.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,WAAW,GACnB,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GACzE,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE9D,MAAM,MAAM,WAAW,GACnB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,EAAE,WAAW,CAAC;IACpB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,IAAI,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAiCxE,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQpD;AAsDD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAuFtE"}
|