fluentcart-developer 2.3.4 → 3.0.1

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 (670) hide show
  1. package/LICENSE.md +26 -26
  2. package/README.md +59 -59
  3. package/dist/cards/fluentcart/templates-native.js +1087 -1087
  4. package/dist/cards/fluentcart/tools.d.ts.map +1 -1
  5. package/dist/cards/fluentcart/tools.js +62 -17
  6. package/dist/cards/fluentcart/tools.js.map +1 -1
  7. package/dist/paths.d.ts +1 -1
  8. package/dist/paths.d.ts.map +1 -1
  9. package/dist/paths.js +1 -1
  10. package/dist/paths.js.map +1 -1
  11. package/dist/reference-reader.d.ts +32 -1
  12. package/dist/reference-reader.d.ts.map +1 -1
  13. package/dist/reference-reader.js +111 -22
  14. package/dist/reference-reader.js.map +1 -1
  15. package/dist/server.d.ts.map +1 -1
  16. package/dist/server.js +8 -1
  17. package/dist/server.js.map +1 -1
  18. package/dist/skills/fluentcart-developer/SKILL.md +108 -580
  19. package/dist/skills/fluentcart-developer/examples/README.md +30 -30
  20. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
  21. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
  22. package/dist/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +113 -113
  23. package/dist/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +148 -148
  24. package/dist/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
  25. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/README.md +22 -22
  26. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/sample-plugin-with-licensing-sdk.php +79 -79
  27. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/FluentLicensing.php +303 -303
  28. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/LicenseSettings.php +566 -566
  29. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/PluginUpdater.php +304 -304
  30. package/dist/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +61 -61
  31. package/dist/skills/fluentcart-developer/references/api/authentication.md +452 -0
  32. package/dist/skills/fluentcart-developer/references/api/coupons.md +786 -0
  33. package/dist/skills/fluentcart-developer/references/api/customers.md +889 -0
  34. package/dist/skills/fluentcart-developer/references/api/files.md +609 -0
  35. package/dist/skills/fluentcart-developer/references/api/index.md +432 -0
  36. package/dist/skills/fluentcart-developer/references/api/licensing.md +633 -0
  37. package/dist/skills/fluentcart-developer/references/api/order-bump.md +384 -0
  38. package/dist/skills/fluentcart-developer/references/api/orders.md +814 -0
  39. package/dist/skills/fluentcart-developer/references/api/products.md +866 -0
  40. package/dist/skills/fluentcart-developer/references/api/roles-permissions.md +536 -0
  41. package/dist/skills/fluentcart-developer/references/api/subscriptions.md +827 -0
  42. package/dist/skills/fluentcart-developer/references/database/index.md +44 -0
  43. package/dist/skills/fluentcart-developer/references/database/models/activity.md +178 -0
  44. package/dist/skills/fluentcart-developer/references/database/models/applied-coupon.md +291 -0
  45. package/dist/skills/fluentcart-developer/references/database/models/attribute-group.md +239 -0
  46. package/dist/skills/fluentcart-developer/references/database/models/attribute-relation.md +181 -0
  47. package/dist/skills/fluentcart-developer/references/database/models/attribute-term.md +219 -0
  48. package/dist/skills/fluentcart-developer/references/database/models/cart.md +645 -0
  49. package/dist/skills/fluentcart-developer/references/database/models/coupon.md +427 -0
  50. package/dist/skills/fluentcart-developer/references/database/models/customer-addresses.md +348 -0
  51. package/dist/skills/fluentcart-developer/references/database/models/customer-meta.md +156 -0
  52. package/dist/skills/fluentcart-developer/references/database/models/customer.md +584 -0
  53. package/dist/skills/fluentcart-developer/references/database/models/dynamic-model.md +163 -0
  54. package/dist/skills/fluentcart-developer/references/database/models/label-relationship.md +155 -0
  55. package/dist/skills/fluentcart-developer/references/database/models/label.md +153 -0
  56. package/dist/skills/fluentcart-developer/references/database/models/license-activation.md +182 -0
  57. package/dist/skills/fluentcart-developer/references/database/models/license-meta.md +163 -0
  58. package/dist/skills/fluentcart-developer/references/database/models/license-site.md +208 -0
  59. package/dist/skills/fluentcart-developer/references/database/models/license.md +640 -0
  60. package/dist/skills/fluentcart-developer/references/database/models/meta.md +233 -0
  61. package/dist/skills/fluentcart-developer/references/database/models/order-address.md +391 -0
  62. package/dist/skills/fluentcart-developer/references/database/models/order-download-permission.md +144 -0
  63. package/dist/skills/fluentcart-developer/references/database/models/order-item.md +383 -0
  64. package/dist/skills/fluentcart-developer/references/database/models/order-meta.md +303 -0
  65. package/dist/skills/fluentcart-developer/references/database/models/order-operation.md +158 -0
  66. package/dist/skills/fluentcart-developer/references/database/models/order-promotion-stat.md +175 -0
  67. package/dist/skills/fluentcart-developer/references/database/models/order-promotion.md +250 -0
  68. package/dist/skills/fluentcart-developer/references/database/models/order-tax-rate.md +172 -0
  69. package/dist/skills/fluentcart-developer/references/database/models/order-transaction.md +440 -0
  70. package/dist/skills/fluentcart-developer/references/database/models/order.md +727 -0
  71. package/dist/skills/fluentcart-developer/references/database/models/product-detail.md +397 -0
  72. package/dist/skills/fluentcart-developer/references/database/models/product-download.md +258 -0
  73. package/dist/skills/fluentcart-developer/references/database/models/product-meta.md +153 -0
  74. package/dist/skills/fluentcart-developer/references/database/models/product-variation.md +556 -0
  75. package/dist/skills/fluentcart-developer/references/database/models/product.md +580 -0
  76. package/dist/skills/fluentcart-developer/references/database/models/relationships.md +427 -0
  77. package/dist/skills/fluentcart-developer/references/database/models/scheduled-action.md +175 -0
  78. package/dist/skills/fluentcart-developer/references/database/models/shipping-class.md +148 -0
  79. package/dist/skills/fluentcart-developer/references/database/models/shipping-method.md +280 -0
  80. package/dist/skills/fluentcart-developer/references/database/models/shipping-zone.md +205 -0
  81. package/dist/skills/fluentcart-developer/references/database/models/subscription-meta.md +173 -0
  82. package/dist/skills/fluentcart-developer/references/database/models/subscription.md +528 -0
  83. package/dist/skills/fluentcart-developer/references/database/models/tax-class.md +195 -0
  84. package/dist/skills/fluentcart-developer/references/database/models/tax-rate.md +225 -0
  85. package/dist/skills/fluentcart-developer/references/database/models/user-meta.md +166 -0
  86. package/dist/skills/fluentcart-developer/references/database/models/user.md +220 -0
  87. package/dist/skills/fluentcart-developer/references/database/models.md +404 -0
  88. package/dist/skills/fluentcart-developer/references/database/query-builder.md +860 -0
  89. package/dist/skills/fluentcart-developer/references/database/readme.md +276 -0
  90. package/dist/skills/fluentcart-developer/references/database/schema.md +1002 -0
  91. package/dist/skills/fluentcart-developer/references/engineering/adding-custom-pages-to-the-customer-dashboard.md +395 -0
  92. package/dist/skills/fluentcart-developer/references/engineering/index.md +4 -0
  93. package/dist/skills/fluentcart-developer/references/engineering.md +4 -0
  94. package/dist/skills/fluentcart-developer/references/getting-started.md +249 -0
  95. package/dist/skills/fluentcart-developer/references/guides/frontend.md +519 -0
  96. package/dist/skills/fluentcart-developer/references/guides/index.md +107 -0
  97. package/dist/skills/fluentcart-developer/references/guides/integrations.md +600 -0
  98. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/index.md +237 -0
  99. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/labels-and-tracking.md +481 -0
  100. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/live-rates.md +269 -0
  101. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/reference.md +223 -0
  102. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/settings.md +370 -0
  103. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier.md +237 -0
  104. package/dist/skills/fluentcart-developer/references/{subscription-customization.md → guides/subscriptions.md} +217 -197
  105. package/dist/skills/fluentcart-developer/references/hooks/actions/admin-and-templates.md +1079 -0
  106. package/dist/skills/fluentcart-developer/references/hooks/actions/cart-and-checkout.md +1795 -0
  107. package/dist/skills/fluentcart-developer/references/hooks/actions/customers-and-users.md +327 -0
  108. package/dist/skills/fluentcart-developer/references/hooks/actions/licenses.md +829 -0
  109. package/dist/skills/fluentcart-developer/references/hooks/actions/modules.md +81 -0
  110. package/dist/skills/fluentcart-developer/references/hooks/actions/orders.md +757 -0
  111. package/dist/skills/fluentcart-developer/references/hooks/actions/payments-and-integrations.md +1163 -0
  112. package/dist/skills/fluentcart-developer/references/hooks/actions/pro-modules.md +219 -0
  113. package/dist/skills/fluentcart-developer/references/hooks/actions/products-and-coupons.md +1019 -0
  114. package/dist/skills/fluentcart-developer/references/hooks/actions/subscriptions.md +1290 -0
  115. package/dist/skills/fluentcart-developer/references/hooks/actions.md +16 -0
  116. package/dist/skills/fluentcart-developer/references/hooks/deprecated.md +60 -0
  117. package/dist/skills/fluentcart-developer/references/hooks/filters/cart-and-checkout.md +2032 -0
  118. package/dist/skills/fluentcart-developer/references/hooks/filters/customers-and-subscriptions.md +1746 -0
  119. package/dist/skills/fluentcart-developer/references/hooks/filters/integrations-and-advanced.md +2439 -0
  120. package/dist/skills/fluentcart-developer/references/hooks/filters/modules.md +464 -0
  121. package/dist/skills/fluentcart-developer/references/hooks/filters/orders-and-payments.md +2658 -0
  122. package/dist/skills/fluentcart-developer/references/hooks/filters/pro-modules.md +502 -0
  123. package/dist/skills/fluentcart-developer/references/hooks/filters/products-and-pricing.md +1785 -0
  124. package/dist/skills/fluentcart-developer/references/hooks/filters/settings-and-configuration.md +2966 -0
  125. package/dist/skills/fluentcart-developer/references/hooks/filters.md +14 -0
  126. package/dist/skills/fluentcart-developer/references/hooks/index.md +35 -0
  127. package/dist/skills/fluentcart-developer/references/index.md +625 -0
  128. package/dist/skills/fluentcart-developer/references/{fee-system-guide.md → modules/fee-system.md} +427 -449
  129. package/dist/skills/fluentcart-developer/references/{ghost-product-selling.md → modules/ghost-product-selling.md} +440 -458
  130. package/dist/skills/fluentcart-developer/references/modules/index.md +484 -0
  131. package/dist/skills/fluentcart-developer/references/modules/licensing.md +342 -0
  132. package/dist/skills/fluentcart-developer/references/modules/order-bump.md +433 -0
  133. package/dist/skills/fluentcart-developer/references/modules/payment-methods.md +129 -0
  134. package/dist/skills/fluentcart-developer/references/modules/refunds.md +170 -0
  135. package/dist/skills/fluentcart-developer/references/modules/shipping.md +846 -0
  136. package/dist/skills/fluentcart-developer/references/modules/storage.md +986 -0
  137. package/dist/skills/fluentcart-developer/references/modules/subscription-vendor-ids.md +186 -0
  138. package/dist/skills/fluentcart-developer/references/modules/subscriptions.md +678 -0
  139. package/dist/skills/fluentcart-developer/references/payment-methods-integration/index.md +164 -0
  140. package/dist/skills/fluentcart-developer/references/payment-methods-integration/paddle-example.md +1648 -0
  141. package/dist/skills/fluentcart-developer/references/payment-methods-integration/payment/setting/fields.md +353 -0
  142. package/dist/skills/fluentcart-developer/references/payment-methods-integration/quick-implementation.md +1079 -0
  143. package/dist/skills/fluentcart-developer/references/payment-methods-integration.md +164 -0
  144. package/dist/skills/fluentcart-developer/references/restapi/checkout.md +573 -0
  145. package/dist/skills/fluentcart-developer/references/restapi/coupons.md +958 -0
  146. package/dist/skills/fluentcart-developer/references/restapi/customer-profile.md +1423 -0
  147. package/dist/skills/fluentcart-developer/references/{rest-api-customers.md → restapi/customers.md} +1103 -1121
  148. package/dist/skills/fluentcart-developer/references/restapi/dashboard.md +1083 -0
  149. package/dist/skills/fluentcart-developer/references/restapi/data-export.md +132 -0
  150. package/dist/skills/fluentcart-developer/references/restapi/email-notifications.md +846 -0
  151. package/dist/skills/fluentcart-developer/references/restapi/files.md +313 -0
  152. package/dist/skills/fluentcart-developer/references/restapi/index.md +127 -0
  153. package/dist/skills/fluentcart-developer/references/restapi/integrations.md +1000 -0
  154. package/dist/skills/fluentcart-developer/references/restapi/inventory.md +192 -0
  155. package/dist/skills/fluentcart-developer/references/restapi/labels-and-attributes.md +797 -0
  156. package/dist/skills/fluentcart-developer/references/restapi/licensing.md +1733 -0
  157. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-available-shipping-methods.md +30 -0
  158. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-checkout-summary.md +28 -0
  159. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-country-info.md +29 -0
  160. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-order-info.md +28 -0
  161. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-shipping-methods-list-view.md +30 -0
  162. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/login.md +66 -0
  163. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/place-order.md +179 -0
  164. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/apply-coupon.md +83 -0
  165. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/cancel-coupon.md +87 -0
  166. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/check-product-eligibility.md +59 -0
  167. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/create-coupon.md +230 -0
  168. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/delete-coupon.md +29 -0
  169. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon-settings.md +20 -0
  170. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon.md +27 -0
  171. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupon-codes.md +20 -0
  172. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupons.md +37 -0
  173. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/re-apply-coupons.md +75 -0
  174. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/store-coupon-settings.md +40 -0
  175. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/update-coupon.md +133 -0
  176. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-address-checkout.md +138 -0
  177. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-profile-address.md +119 -0
  178. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/dashboard-overview.md +22 -0
  179. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/delete-profile-address.md +46 -0
  180. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-order-details.md +30 -0
  181. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-portal-sections.md +29 -0
  182. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-profile-details.md +22 -0
  183. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-transaction-billing-address.md +30 -0
  184. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-upgrade-paths.md +31 -0
  185. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-downloads.md +29 -0
  186. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-orders.md +28 -0
  187. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/make-profile-address-primary.md +55 -0
  188. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/pause-subscription.md +29 -0
  189. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/resume-subscription.md +29 -0
  190. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/save-transaction-billing-address.md +92 -0
  191. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/select-address-for-checkout.md +32 -0
  192. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-address.md +115 -0
  193. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-details.md +69 -0
  194. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/attach-user.md +50 -0
  195. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/bulk-actions.md +65 -0
  196. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-address.md +135 -0
  197. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-customer.md +108 -0
  198. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/delete-address.md +62 -0
  199. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/detach-user.md +28 -0
  200. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/find-customer-order.md +27 -0
  201. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-attachable-users.md +20 -0
  202. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-addresses.md +28 -0
  203. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-orders.md +37 -0
  204. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-stats.md +27 -0
  205. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer.md +32 -0
  206. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/list-customers.md +37 -0
  207. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/recalculate-ltv.md +28 -0
  208. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/set-primary-address.md +72 -0
  209. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-additional-info.md +55 -0
  210. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-address.md +144 -0
  211. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-customer.md +123 -0
  212. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/attach-note-to-order.md +49 -0
  213. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-all-pages.md +21 -0
  214. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-single-page.md +55 -0
  215. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/delete-activity.md +28 -0
  216. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-country-info.md +29 -0
  217. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-dashboard-stats.md +22 -0
  218. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-filter-options.md +31 -0
  219. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-data.md +20 -0
  220. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-settings.md +20 -0
  221. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-print-templates.md +20 -0
  222. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-search-options.md +27 -0
  223. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-widgets.md +28 -0
  224. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/initialize-app.md +20 -0
  225. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-activities.md +33 -0
  226. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-attachments.md +21 -0
  227. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-countries.md +20 -0
  228. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/mark-activity-read.md +53 -0
  229. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/run-data-backfills.md +21 -0
  230. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-settings.md +54 -0
  231. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-tax-settings.md +73 -0
  232. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-print-templates.md +64 -0
  233. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/upload-attachment.md +42 -0
  234. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-customers-batch.md +129 -0
  235. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-licenses-batch.md +133 -0
  236. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-orders-batch.md +129 -0
  237. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-subscriptions-batch.md +129 -0
  238. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-customers-export-schema.md +21 -0
  239. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-licenses-export-schema.md +26 -0
  240. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-orders-export-schema.md +21 -0
  241. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-subscriptions-export-schema.md +21 -0
  242. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/enable-notification.md +57 -0
  243. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-digest-settings.md +22 -0
  244. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-notification.md +30 -0
  245. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-reminders.md +22 -0
  246. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-settings.md +22 -0
  247. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-shortcodes.md +22 -0
  248. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/list-notifications.md +20 -0
  249. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-default-template.md +66 -0
  250. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-notification.md +50 -0
  251. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-digest-settings.md +101 -0
  252. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-reminders.md +162 -0
  253. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-settings.md +99 -0
  254. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-digest-test.md +47 -0
  255. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-manual-reminder.md +51 -0
  256. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/update-notification.md +93 -0
  257. package/dist/skills/fluentcart-developer/references/restapi/operations/files/delete-file.md +31 -0
  258. package/dist/skills/fluentcart-developer/references/restapi/operations/files/get-bucket-list.md +28 -0
  259. package/dist/skills/fluentcart-developer/references/restapi/operations/files/list-files.md +30 -0
  260. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-editor-file.md +32 -0
  261. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-file.md +34 -0
  262. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/chained-data-request.md +46 -0
  263. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/change-feed-status.md +51 -0
  264. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/delete-feed.md +27 -0
  265. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-dynamic-options.md +29 -0
  266. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-lists.md +27 -0
  267. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-settings.md +27 -0
  268. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-feeds.md +20 -0
  269. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-settings.md +26 -0
  270. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/install-addon-plugin.md +49 -0
  271. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/list-addons.md +20 -0
  272. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/save-feed-settings.md +52 -0
  273. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/set-global-settings.md +50 -0
  274. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/bulk-update-stock.md +94 -0
  275. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/export-inventory.md +81 -0
  276. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-adjustment-history.md +26 -0
  277. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-inventory-stats.md +21 -0
  278. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/list-inventory.md +33 -0
  279. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/update-stock.md +75 -0
  280. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-attribute-group.md +31 -0
  281. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-label.md +31 -0
  282. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-terms.md +90 -0
  283. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-group.md +28 -0
  284. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-term.md +29 -0
  285. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-group.md +28 -0
  286. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-library.md +20 -0
  287. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-groups.md +32 -0
  288. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-terms.md +33 -0
  289. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-labels.md +20 -0
  290. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-groups.md +51 -0
  291. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-terms.md +56 -0
  292. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-group.md +37 -0
  293. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-term.md +39 -0
  294. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-label-selections.md +32 -0
  295. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-plugin-license.md +41 -0
  296. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-site-admin.md +60 -0
  297. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-plugin-license.md +18 -0
  298. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-admin.md +67 -0
  299. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-customer.md +47 -0
  300. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/delete-license.md +24 -0
  301. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/extend-license-validity.md +47 -0
  302. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-license-details.md +25 -0
  303. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-licenses-admin.md +26 -0
  304. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-activations.md +25 -0
  305. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-details.md +25 -0
  306. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-site.md +30 -0
  307. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-plugin-license-status.md +18 -0
  308. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-product-license-settings.md +24 -0
  309. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-customer-licenses.md +25 -0
  310. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-license-sites.md +33 -0
  311. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-licenses.md +38 -0
  312. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-activate-license.md +54 -0
  313. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-check-license.md +26 -0
  314. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-deactivate-license.md +46 -0
  315. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-download-license-package.md +23 -0
  316. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-get-license-version.md +26 -0
  317. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/regenerate-license-key.md +24 -0
  318. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/save-product-license-settings.md +193 -0
  319. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-activation-limit.md +53 -0
  320. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-status.md +52 -0
  321. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/create-order-bump.md +47 -0
  322. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/delete-order-bump.md +25 -0
  323. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/get-order-bump.md +25 -0
  324. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/list-order-bumps.md +29 -0
  325. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/update-order-bump.md +141 -0
  326. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/accept-dispute.md +47 -0
  327. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/bulk-actions.md +72 -0
  328. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-shipping.md +67 -0
  329. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-tax.md +98 -0
  330. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/change-customer.md +50 -0
  331. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/charge-now.md +29 -0
  332. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-and-change-customer.md +92 -0
  333. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-custom-order-item.md +68 -0
  334. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-order.md +351 -0
  335. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-renewal-now.md +29 -0
  336. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/delete-order.md +28 -0
  337. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/generate-missing-licenses.md +29 -0
  338. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order-transactions.md +27 -0
  339. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order.md +27 -0
  340. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-renewal.md +28 -0
  341. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-shipping-methods.md +28 -0
  342. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-single-transaction.md +28 -0
  343. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-order-currencies.md +22 -0
  344. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-orders.md +42 -0
  345. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-renewals.md +28 -0
  346. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/mark-as-paid.md +61 -0
  347. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/price-order.md +135 -0
  348. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/refund-order.md +72 -0
  349. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/resend-renewal-invoice.md +29 -0
  350. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/skip-renewal.md +48 -0
  351. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-order-statuses.md +28 -0
  352. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-pending-transaction.md +29 -0
  353. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address-id.md +60 -0
  354. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address.md +98 -0
  355. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order.md +172 -0
  356. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-statuses.md +77 -0
  357. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-subscription-details.md +84 -0
  358. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-transaction-status.md +51 -0
  359. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/void-renewal.md +30 -0
  360. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/create-pdf-template.md +42 -0
  361. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/delete-pdf-template.md +26 -0
  362. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/download-pdf-preview.md +44 -0
  363. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-factory-default-templates.md +19 -0
  364. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-status.md +21 -0
  365. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-template.md +26 -0
  366. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-saved-templates.md +21 -0
  367. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-seller-details.md +19 -0
  368. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/list-pdf-templates.md +19 -0
  369. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-pdf-template.md +53 -0
  370. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-seller-details.md +97 -0
  371. package/dist/skills/fluentcart-developer/references/restapi/operations/products/add-product-terms.md +64 -0
  372. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-edit-fetch.md +30 -0
  373. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-insert-products.md +62 -0
  374. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-products.md +59 -0
  375. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-variants.md +83 -0
  376. package/dist/skills/fluentcart-developer/references/restapi/operations/products/change-integration-status.md +64 -0
  377. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-dummy-products.md +45 -0
  378. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-product.md +81 -0
  379. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-variation.md +181 -0
  380. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-downloadable-file.md +27 -0
  381. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product-integration.md +30 -0
  382. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product.md +27 -0
  383. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-taxonomy-term.md +55 -0
  384. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-upgrade-path.md +27 -0
  385. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-variation.md +27 -0
  386. package/dist/skills/fluentcart-developer/references/restapi/operations/products/do-bulk-action.md +56 -0
  387. package/dist/skills/fluentcart-developer/references/restapi/operations/products/duplicate-product.md +56 -0
  388. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-products-by-ids.md +26 -0
  389. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-taxonomy-terms.md +20 -0
  390. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-terms-by-parent.md +60 -0
  391. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-variations-by-ids.md +26 -0
  392. package/dist/skills/fluentcart-developer/references/restapi/operations/products/find-subscription-variants.md +26 -0
  393. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-bundle-info.md +27 -0
  394. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-downloadable-url.md +27 -0
  395. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-max-excerpt-word-count.md +20 -0
  396. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-pricing-widgets.md +27 -0
  397. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-feeds.md +29 -0
  398. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-settings.md +31 -0
  399. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-pricing.md +28 -0
  400. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product.md +28 -0
  401. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-related-products.md +31 -0
  402. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-upgrade-settings.md +27 -0
  403. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-variation-upgrade-paths.md +28 -0
  404. package/dist/skills/fluentcart-developer/references/restapi/operations/products/group-bulk-update-variants.md +103 -0
  405. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-all-variants.md +26 -0
  406. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-product-variations.md +26 -0
  407. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-products.md +34 -0
  408. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-shipping-class.md +27 -0
  409. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-tax-class.md +27 -0
  410. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-bundle-info.md +56 -0
  411. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-product-integration.md +62 -0
  412. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-upgrade-path.md +78 -0
  413. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-product-variant-options.md +29 -0
  414. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-products-by-name.md +28 -0
  415. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-variants-by-name.md +28 -0
  416. package/dist/skills/fluentcart-developer/references/restapi/operations/products/set-variation-media.md +74 -0
  417. package/dist/skills/fluentcart-developer/references/restapi/operations/products/suggest-sku.md +28 -0
  418. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-downloadable-files.md +134 -0
  419. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-taxonomy-terms.md +61 -0
  420. package/dist/skills/fluentcart-developer/references/restapi/operations/products/toggle-product-tax-exemption.md +56 -0
  421. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-downloadable-file.md +98 -0
  422. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-inventory.md +56 -0
  423. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-long-desc-editor-mode.md +49 -0
  424. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-manage-stock.md +53 -0
  425. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-detail.md +58 -0
  426. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-pricing.md +225 -0
  427. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-shipping-class.md +49 -0
  428. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-tax-class.md +49 -0
  429. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-upgrade-path.md +78 -0
  430. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-option.md +79 -0
  431. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-tax-exemption.md +56 -0
  432. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation-pricing-table.md +49 -0
  433. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation.md +105 -0
  434. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/get-product-views.md +34 -0
  435. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/list-products.md +42 -0
  436. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/search-products.md +30 -0
  437. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/channel-rules.md +24 -0
  438. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/country-heat-map.md +22 -0
  439. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupon-overview.md +37 -0
  440. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupons.md +36 -0
  441. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-insights.md +31 -0
  442. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-overview.md +36 -0
  443. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-repeat.md +35 -0
  444. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segment-customers.md +36 -0
  445. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segments.md +30 -0
  446. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-value.md +34 -0
  447. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/dashboard-stats.md +30 -0
  448. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/failed-orders.md +34 -0
  449. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-new-vs-returning-customer.md +34 -0
  450. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-by-day-and-hour.md +34 -0
  451. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-meta.md +29 -0
  452. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-top-sold-products.md +34 -0
  453. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/future-renewals.md +31 -0
  454. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/generate-retention-snapshots.md +24 -0
  455. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-overview.md +30 -0
  456. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-activities.md +26 -0
  457. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-orders.md +20 -0
  458. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-revenue.md +37 -0
  459. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-at-risk.md +35 -0
  460. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-variations.md +33 -0
  461. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments.md +33 -0
  462. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/item-count-distribution.md +34 -0
  463. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-chart.md +30 -0
  464. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-pie-chart.md +22 -0
  465. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-summary.md +22 -0
  466. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/locations.md +43 -0
  467. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-chart.md +37 -0
  468. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-completion-time.md +34 -0
  469. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-mix.md +34 -0
  470. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-value-distribution.md +34 -0
  471. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-disputes.md +38 -0
  472. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-methods.md +36 -0
  473. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods.md +37 -0
  474. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison-launch.md +33 -0
  475. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison.md +40 -0
  476. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-detail.md +37 -0
  477. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-sales.md +37 -0
  478. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/refunds-overview.md +37 -0
  479. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/retention-snapshots-step.md +45 -0
  480. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sales-growth-chart.md +35 -0
  481. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/save-channel-rules.md +73 -0
  482. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/source-channels.md +37 -0
  483. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sources.md +49 -0
  484. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-cohorts.md +33 -0
  485. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-health.md +30 -0
  486. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-rebuys.md +37 -0
  487. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-retention.md +34 -0
  488. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-variations.md +22 -0
  489. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscriptions-overview.md +37 -0
  490. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/weeks-between-refund.md +34 -0
  491. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/assign-role.md +48 -0
  492. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/delete-role-assignment.md +47 -0
  493. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/get-role.md +25 -0
  494. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-managers.md +18 -0
  495. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-roles.md +18 -0
  496. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/search-users.md +25 -0
  497. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/update-role.md +43 -0
  498. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/create-saved-view.md +106 -0
  499. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/delete-saved-view.md +26 -0
  500. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/list-saved-views.md +25 -0
  501. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/update-saved-view.md +83 -0
  502. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-payment-addon.md +44 -0
  503. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-plugin-addon.md +44 -0
  504. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/change-storage-driver-status.md +56 -0
  505. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/check-paypal-webhook.md +26 -0
  506. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/create-storage-bucket.md +63 -0
  507. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/disconnect-payment-method.md +55 -0
  508. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/exchange-paypal-seller-auth-token.md +62 -0
  509. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-active-storage-drivers.md +20 -0
  510. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-checkout-fields.md +22 -0
  511. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-email-shortcodes.md +20 -0
  512. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-config-snippets.md +26 -0
  513. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-status.md +20 -0
  514. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-module-settings.md +20 -0
  515. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-connection-info.md +26 -0
  516. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-settings.md +26 -0
  517. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-permissions.md +22 -0
  518. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-plugin-addons.md +20 -0
  519. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-storage-driver-settings.md +27 -0
  520. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-store-settings.md +26 -0
  521. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-mcp-adapter.md +21 -0
  522. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-payment-addon.md +60 -0
  523. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-plugin-addon.md +64 -0
  524. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-payment-methods.md +20 -0
  525. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-storage-drivers.md +20 -0
  526. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-storage-buckets.md +67 -0
  527. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reorder-payment-methods.md +55 -0
  528. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reset-storage-driver-settings.md +45 -0
  529. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-checkout-fields.md +133 -0
  530. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-confirmation-settings.md +68 -0
  531. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-module-settings.md +68 -0
  532. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-design.md +67 -0
  533. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-settings.md +58 -0
  534. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-permissions.md +68 -0
  535. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-storage-driver-settings.md +62 -0
  536. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-store-settings.md +239 -0
  537. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/setup-paypal-webhook.md +48 -0
  538. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/toggle-mcp.md +40 -0
  539. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-storage-driver-connection.md +62 -0
  540. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-turnstile-keys.md +55 -0
  541. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-class.md +73 -0
  542. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-method.md +110 -0
  543. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-zone.md +56 -0
  544. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-class.md +29 -0
  545. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-method.md +29 -0
  546. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-zone.md +29 -0
  547. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class-profile.md +30 -0
  548. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class.md +29 -0
  549. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-packages.md +22 -0
  550. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-zone.md +27 -0
  551. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-countries.md +22 -0
  552. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-states.md +28 -0
  553. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-classes.md +31 -0
  554. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-zones.md +31 -0
  555. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/save-shipping-packages.md +112 -0
  556. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-class.md +79 -0
  557. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-method.md +113 -0
  558. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-zone.md +62 -0
  559. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-zone-order.md +52 -0
  560. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-auto-renew.md +30 -0
  561. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-subscription.md +52 -0
  562. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/confirm-subscription-switch.md +70 -0
  563. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/fetch-subscription-remote.md +28 -0
  564. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/generate-early-payment-link.md +29 -0
  565. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-customer-subscription.md +27 -0
  566. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-or-create-plan.md +69 -0
  567. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-setup-intent-attempts.md +30 -0
  568. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-subscription.md +28 -0
  569. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/initiate-early-payment.md +31 -0
  570. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-customer-subscriptions.md +27 -0
  571. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-subscriptions.md +39 -0
  572. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/pause-subscription.md +28 -0
  573. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/reactivate-subscription.md +28 -0
  574. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/resume-subscription.md +28 -0
  575. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/switch-payment-method.md +70 -0
  576. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-payment-method.md +69 -0
  577. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-vendor-ids.md +56 -0
  578. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/verify-vendor-ids.md +56 -0
  579. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-class.md +51 -0
  580. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-rate.md +117 -0
  581. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-product-override.md +27 -0
  582. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-shipping-tax-override.md +27 -0
  583. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-class.md +28 -0
  584. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-rate.md +27 -0
  585. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-id.md +27 -0
  586. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-rates.md +28 -0
  587. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-eu-vat-product-overrides.md +20 -0
  588. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-oss-country-rates.md +20 -0
  589. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-preconfigured-tax-rates.md +20 -0
  590. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-product-overrides.md +27 -0
  591. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-tax-settings.md +20 -0
  592. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-all-tax-rates.md +20 -0
  593. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-classes.md +20 -0
  594. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-records.md +37 -0
  595. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/mark-taxes-as-filed.md +58 -0
  596. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/reset-eu-vat-rates.md +21 -0
  597. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-configured-countries.md +57 -0
  598. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-country-tax-id.md +50 -0
  599. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-eu-vat-cross-border-settings.md +127 -0
  600. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-oss-country-rates.md +100 -0
  601. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-product-override.md +110 -0
  602. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-shipping-tax-override.md +52 -0
  603. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-tax-settings.md +166 -0
  604. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-country-status.md +54 -0
  605. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-tax-rate.md +116 -0
  606. package/dist/skills/fluentcart-developer/references/restapi/order-bumps.md +433 -0
  607. package/dist/skills/fluentcart-developer/references/{rest-api-orders.md → restapi/orders.md} +1212 -1462
  608. package/dist/skills/fluentcart-developer/references/restapi/pdf-templates.md +212 -0
  609. package/dist/skills/fluentcart-developer/references/{rest-api-products.md → restapi/products.md} +2485 -2697
  610. package/dist/skills/fluentcart-developer/references/restapi/public-shop.md +191 -0
  611. package/dist/skills/fluentcart-developer/references/restapi/reports.md +3773 -0
  612. package/dist/skills/fluentcart-developer/references/restapi/roles.md +403 -0
  613. package/dist/skills/fluentcart-developer/references/restapi/saved-views.md +136 -0
  614. package/dist/skills/fluentcart-developer/references/restapi/settings.md +1423 -0
  615. package/dist/skills/fluentcart-developer/references/{rest-api-shipping.md → restapi/shipping.md} +905 -800
  616. package/dist/skills/fluentcart-developer/references/restapi/subscriptions.md +1169 -0
  617. package/dist/skills/fluentcart-developer/references/restapi/tax.md +1551 -0
  618. package/dist/skills/fluentcart-developer/references/{rest-api-overview.md → restapi.md} +127 -131
  619. package/dist/skills/fluentcart-developer/scripts/cli.js +1 -1
  620. package/dist/version.d.ts +1 -1
  621. package/dist/version.js +1 -1
  622. package/package.json +66 -65
  623. package/dist/skills/fluentcart-developer/.claude-plugin/plugin.json +0 -12
  624. package/dist/skills/fluentcart-developer/.mcp.json +0 -11
  625. package/dist/skills/fluentcart-developer/references/action-hooks-admin-templates.md +0 -787
  626. package/dist/skills/fluentcart-developer/references/action-hooks-cart-checkout.md +0 -1355
  627. package/dist/skills/fluentcart-developer/references/action-hooks-customers-users.md +0 -266
  628. package/dist/skills/fluentcart-developer/references/action-hooks-licenses.md +0 -855
  629. package/dist/skills/fluentcart-developer/references/action-hooks-orders.md +0 -631
  630. package/dist/skills/fluentcart-developer/references/action-hooks-payments-integrations.md +0 -963
  631. package/dist/skills/fluentcart-developer/references/action-hooks-products-coupons.md +0 -585
  632. package/dist/skills/fluentcart-developer/references/action-hooks-subscriptions.md +0 -661
  633. package/dist/skills/fluentcart-developer/references/customer-dashboard-endpoints.md +0 -169
  634. package/dist/skills/fluentcart-developer/references/database-models-query-builder.md +0 -194
  635. package/dist/skills/fluentcart-developer/references/database-models-reference.md +0 -604
  636. package/dist/skills/fluentcart-developer/references/database-schema-reference.md +0 -947
  637. package/dist/skills/fluentcart-developer/references/engineering-notes.md +0 -154
  638. package/dist/skills/fluentcart-developer/references/filter-hooks-cart-checkout.md +0 -1202
  639. package/dist/skills/fluentcart-developer/references/filter-hooks-customers-subscriptions.md +0 -902
  640. package/dist/skills/fluentcart-developer/references/filter-hooks-integrations-advanced.md +0 -1598
  641. package/dist/skills/fluentcart-developer/references/filter-hooks-orders-payments.md +0 -1319
  642. package/dist/skills/fluentcart-developer/references/filter-hooks-products-pricing.md +0 -628
  643. package/dist/skills/fluentcart-developer/references/filter-hooks-settings-configuration.md +0 -1177
  644. package/dist/skills/fluentcart-developer/references/fluentcart-developer-guide.md +0 -154
  645. package/dist/skills/fluentcart-developer/references/hooks-complete-index.md +0 -834
  646. package/dist/skills/fluentcart-developer/references/models-complete-index.md +0 -912
  647. package/dist/skills/fluentcart-developer/references/modules-and-extensions-reference.md +0 -224
  648. package/dist/skills/fluentcart-developer/references/order-bump-module.md +0 -163
  649. package/dist/skills/fluentcart-developer/references/paddle-gateway-case-study.md +0 -1931
  650. package/dist/skills/fluentcart-developer/references/payment-gateway-integration.md +0 -761
  651. package/dist/skills/fluentcart-developer/references/rest-api-checkout.md +0 -288
  652. package/dist/skills/fluentcart-developer/references/rest-api-coupons.md +0 -801
  653. package/dist/skills/fluentcart-developer/references/rest-api-customer-profile.md +0 -190
  654. package/dist/skills/fluentcart-developer/references/rest-api-dashboard-utilities.md +0 -219
  655. package/dist/skills/fluentcart-developer/references/rest-api-email-notifications.md +0 -619
  656. package/dist/skills/fluentcart-developer/references/rest-api-files.md +0 -290
  657. package/dist/skills/fluentcart-developer/references/rest-api-integrations.md +0 -324
  658. package/dist/skills/fluentcart-developer/references/rest-api-labels-attributes.md +0 -321
  659. package/dist/skills/fluentcart-developer/references/rest-api-licensing.md +0 -174
  660. package/dist/skills/fluentcart-developer/references/rest-api-order-bumps.md +0 -200
  661. package/dist/skills/fluentcart-developer/references/rest-api-public-shop.md +0 -172
  662. package/dist/skills/fluentcart-developer/references/rest-api-reference.md +0 -552
  663. package/dist/skills/fluentcart-developer/references/rest-api-reports.md +0 -377
  664. package/dist/skills/fluentcart-developer/references/rest-api-roles-permissions.md +0 -147
  665. package/dist/skills/fluentcart-developer/references/rest-api-settings.md +0 -528
  666. package/dist/skills/fluentcart-developer/references/rest-api-subscriptions.md +0 -938
  667. package/dist/skills/fluentcart-developer/references/rest-api-tax.md +0 -356
  668. package/dist/skills/fluentcart-developer/references/shipping-module-guide.md +0 -126
  669. package/dist/skills/fluentcart-developer/references/software-licensing-sdk.md +0 -228
  670. package/dist/skills/fluentcart-developer/references/storage-drivers-module.md +0 -140
@@ -22,1104 +22,1104 @@ function banner(appName, title, file, base, productId) {
22
22
  }
23
23
  export function nativeClientTemplate(platform, base, productId, appName) {
24
24
  if (platform === 'swift') {
25
- return `${banner(appName, 'Swift / iOS + macOS', 'LicenseClient.swift', base, productId)}
26
- import Foundation
27
- import Security
28
-
29
- struct LicenseState: Decodable {
30
- let status: String
31
- let entitlements: [Int]?
32
- let licenseToken: String?
33
- let errorType: String?
34
-
35
- enum CodingKeys: String, CodingKey {
36
- case status, entitlements
37
- case licenseToken = "license_token"
38
- case errorType = "error_type"
39
- }
40
-
41
- var isValid: Bool { return status == "valid" }
42
- }
43
-
44
- enum FastrLicense {
45
- static let store = "${base}"
46
- static let productId = ${productId}
47
-
48
- private static func post(_ verb: String, _ fields: [String: String]) -> [String: Any] {
49
- var request = URLRequest(url: URL(string: store + "?fluent-cart=" + verb)!)
50
- request.httpMethod = "POST"
51
- request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
52
-
53
- var components = URLComponents()
54
- components.queryItems = fields.map { URLQueryItem(name: $0.key, value: $0.value) }
55
- request.httpBody = components.percentEncodedQuery?.data(using: .utf8)
56
-
57
- let semaphore = DispatchSemaphore(value: 0)
58
- var body: [String: Any] = [:]
59
-
60
- URLSession.shared.dataTask(with: request) { data, _, _ in
61
- if let data = data,
62
- let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
63
- body = json
64
- }
65
- semaphore.signal()
66
- }.resume()
67
-
68
- _ = semaphore.wait(timeout: .now() + 15)
69
- return body
70
- }
71
-
72
- private static func get(_ query: String) -> [String: Any] {
73
- guard let url = URL(string: store + "?fluent-cart=" + query) else { return [:] }
74
-
75
- let semaphore = DispatchSemaphore(value: 0)
76
- var body: [String: Any] = [:]
77
-
78
- URLSession.shared.dataTask(with: url) { data, _, _ in
79
- if let data = data,
80
- let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
81
- body = json
82
- }
83
- semaphore.signal()
84
- }.resume()
85
-
86
- _ = semaphore.wait(timeout: .now() + 15)
87
- return body
88
- }
89
-
90
- static func activate(key: String, instanceId: String, fingerprint: String, email: String) -> LicenseState? {
91
- let json = post("activate_license", [
92
- "item_id": String(productId),
93
- "license_key": key.trimmingCharacters(in: .whitespacesAndNewlines),
94
- "site_url": instanceId,
95
- "device_fingerprint": fingerprint,
96
- "device_name": ProcessInfo.processInfo.hostName,
97
- "device_type": "Desktop (Swift)",
98
- "os": ProcessInfo.processInfo.operatingSystemVersionString,
99
- "email": email,
100
- "server_version": Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0.0"
101
- ])
102
-
103
- guard let data = try? JSONSerialization.data(withJSONObject: json) else { return nil }
104
- return try? JSONDecoder().decode(LicenseState.self, from: data)
105
- }
106
-
107
- static func check(key: String, instanceId: String, fingerprint: String) -> LicenseState? {
108
- let json = post("check_license", [
109
- "item_id": String(productId),
110
- "license_key": key,
111
- "site_url": instanceId,
112
- "device_fingerprint": fingerprint
113
- ])
114
-
115
- guard let data = try? JSONSerialization.data(withJSONObject: json) else { return nil }
116
- return try? JSONDecoder().decode(LicenseState.self, from: data)
117
- }
118
-
119
- static func deactivate(key: String, instanceId: String) {
120
- _ = post("deactivate_license", [
121
- "item_id": String(productId),
122
- "license_key": key,
123
- "site_url": instanceId
124
- ])
125
- }
126
-
127
- /// SecKey expects PKCS#1 for RSA. A PEM SubjectPublicKeyInfo carries a
128
- /// 24-byte header first, so strip it when present.
129
- static func verifyToken(_ token: String, publicKeyPem: String) -> [String: Any]? {
130
- let parts = token.split(separator: ".")
131
- guard parts.count == 3 else { return nil }
132
-
133
- let pem = publicKeyPem
134
- .replacingOccurrences(of: "-----BEGIN PUBLIC KEY-----", with: "")
135
- .replacingOccurrences(of: "-----END PUBLIC KEY-----", with: "")
136
- .components(separatedBy: .whitespacesAndNewlines).joined()
137
-
138
- guard var der = Data(base64Encoded: pem) else { return nil }
139
- if der.count > 24 { der = der.subdata(in: 24..<der.count) }
140
-
141
- let attributes: [String: Any] = [
142
- kSecAttrKeyType as String: kSecAttrKeyTypeRSA,
143
- kSecAttrKeyClass as String: kSecAttrKeyClassPublic
144
- ]
145
-
146
- guard let key = SecKeyCreateWithData(der as CFData, attributes as CFDictionary, nil),
147
- let signature = base64UrlDecode(String(parts[2])) else { return nil }
148
-
149
- let signed = Data((String(parts[0]) + "." + String(parts[1])).utf8)
150
-
151
- guard SecKeyVerifySignature(key, .rsaSignatureMessagePKCS1v15SHA256, signed as CFData, signature as CFData, nil),
152
- let payload = base64UrlDecode(String(parts[1])),
153
- let claims = try? JSONSerialization.jsonObject(with: payload) as? [String: Any] else { return nil }
154
-
155
- return claims
156
- }
157
-
158
- // Bind the token to THIS installation. verifyToken proves the store signed
159
- // it; it does not check expiry, this machine or this product. claims.fp is
160
- // a server-side HMAC that cannot be recomputed here, so claims.ins is the
161
- // binding a client is able to check.
162
- static func entitlement(
163
- _ token: String,
164
- publicKeyPem: String,
165
- installId: String?,
166
- productId: Int
167
- ) -> (claims: [String: Any]?, reason: String?) {
168
- guard let claims = verifyToken(token, publicKeyPem: publicKeyPem) else {
169
- return (nil, "invalid_or_expired")
170
- }
171
-
172
- if let exp = (claims["exp"] as? NSNumber)?.doubleValue, exp <= Date().timeIntervalSince1970 {
173
- return (nil, "invalid_or_expired")
174
- }
175
-
176
- if productId > 0, let prod = (claims["prod"] as? NSNumber)?.intValue, prod != productId {
177
- return (nil, "wrong_product")
178
- }
179
-
180
- if let installId = installId, !installId.isEmpty,
181
- let ins = claims["ins"] as? String, ins != installId {
182
- return (nil, "wrong_install")
183
- }
184
-
185
- return (claims, nil)
186
- }
187
-
188
- private static func base64UrlDecode(_ value: String) -> Data? {
189
- var base64 = value.replacingOccurrences(of: "-", with: "+").replacingOccurrences(of: "_", with: "/")
190
- base64 += String(repeating: "=", count: (4 - base64.count % 4) % 4)
191
- return Data(base64Encoded: base64)
192
- }
193
-
194
- static func latestRelease(key: String, current: String, platform: String = "any") -> [String: Any] {
195
- var components = URLComponents()
196
- components.queryItems = [
197
- URLQueryItem(name: "product_id", value: String(productId)),
198
- URLQueryItem(name: "platform", value: platform),
199
- URLQueryItem(name: "current_version", value: current),
200
- URLQueryItem(name: "license_key", value: key)
201
- ]
202
-
203
- return get("fastr_release_latest&" + (components.percentEncodedQuery ?? ""))
204
- }
205
-
206
- static func reportUsage(key: String, metric: String, quantity: Int, idempotencyKey: String) -> [String: Any] {
207
- post("fastr_usage_report", [
208
- "license_key": key,
209
- "metric": metric,
210
- "quantity": String(quantity),
211
- "idempotency_key": idempotencyKey
212
- ])
213
- }
214
- }
25
+ return `${banner(appName, 'Swift / iOS + macOS', 'LicenseClient.swift', base, productId)}
26
+ import Foundation
27
+ import Security
28
+
29
+ struct LicenseState: Decodable {
30
+ let status: String
31
+ let entitlements: [Int]?
32
+ let licenseToken: String?
33
+ let errorType: String?
34
+
35
+ enum CodingKeys: String, CodingKey {
36
+ case status, entitlements
37
+ case licenseToken = "license_token"
38
+ case errorType = "error_type"
39
+ }
40
+
41
+ var isValid: Bool { return status == "valid" }
42
+ }
43
+
44
+ enum FastrLicense {
45
+ static let store = "${base}"
46
+ static let productId = ${productId}
47
+
48
+ private static func post(_ verb: String, _ fields: [String: String]) -> [String: Any] {
49
+ var request = URLRequest(url: URL(string: store + "?fluent-cart=" + verb)!)
50
+ request.httpMethod = "POST"
51
+ request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
52
+
53
+ var components = URLComponents()
54
+ components.queryItems = fields.map { URLQueryItem(name: $0.key, value: $0.value) }
55
+ request.httpBody = components.percentEncodedQuery?.data(using: .utf8)
56
+
57
+ let semaphore = DispatchSemaphore(value: 0)
58
+ var body: [String: Any] = [:]
59
+
60
+ URLSession.shared.dataTask(with: request) { data, _, _ in
61
+ if let data = data,
62
+ let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
63
+ body = json
64
+ }
65
+ semaphore.signal()
66
+ }.resume()
67
+
68
+ _ = semaphore.wait(timeout: .now() + 15)
69
+ return body
70
+ }
71
+
72
+ private static func get(_ query: String) -> [String: Any] {
73
+ guard let url = URL(string: store + "?fluent-cart=" + query) else { return [:] }
74
+
75
+ let semaphore = DispatchSemaphore(value: 0)
76
+ var body: [String: Any] = [:]
77
+
78
+ URLSession.shared.dataTask(with: url) { data, _, _ in
79
+ if let data = data,
80
+ let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
81
+ body = json
82
+ }
83
+ semaphore.signal()
84
+ }.resume()
85
+
86
+ _ = semaphore.wait(timeout: .now() + 15)
87
+ return body
88
+ }
89
+
90
+ static func activate(key: String, instanceId: String, fingerprint: String, email: String) -> LicenseState? {
91
+ let json = post("activate_license", [
92
+ "item_id": String(productId),
93
+ "license_key": key.trimmingCharacters(in: .whitespacesAndNewlines),
94
+ "site_url": instanceId,
95
+ "device_fingerprint": fingerprint,
96
+ "device_name": ProcessInfo.processInfo.hostName,
97
+ "device_type": "Desktop (Swift)",
98
+ "os": ProcessInfo.processInfo.operatingSystemVersionString,
99
+ "email": email,
100
+ "server_version": Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0.0"
101
+ ])
102
+
103
+ guard let data = try? JSONSerialization.data(withJSONObject: json) else { return nil }
104
+ return try? JSONDecoder().decode(LicenseState.self, from: data)
105
+ }
106
+
107
+ static func check(key: String, instanceId: String, fingerprint: String) -> LicenseState? {
108
+ let json = post("check_license", [
109
+ "item_id": String(productId),
110
+ "license_key": key,
111
+ "site_url": instanceId,
112
+ "device_fingerprint": fingerprint
113
+ ])
114
+
115
+ guard let data = try? JSONSerialization.data(withJSONObject: json) else { return nil }
116
+ return try? JSONDecoder().decode(LicenseState.self, from: data)
117
+ }
118
+
119
+ static func deactivate(key: String, instanceId: String) {
120
+ _ = post("deactivate_license", [
121
+ "item_id": String(productId),
122
+ "license_key": key,
123
+ "site_url": instanceId
124
+ ])
125
+ }
126
+
127
+ /// SecKey expects PKCS#1 for RSA. A PEM SubjectPublicKeyInfo carries a
128
+ /// 24-byte header first, so strip it when present.
129
+ static func verifyToken(_ token: String, publicKeyPem: String) -> [String: Any]? {
130
+ let parts = token.split(separator: ".")
131
+ guard parts.count == 3 else { return nil }
132
+
133
+ let pem = publicKeyPem
134
+ .replacingOccurrences(of: "-----BEGIN PUBLIC KEY-----", with: "")
135
+ .replacingOccurrences(of: "-----END PUBLIC KEY-----", with: "")
136
+ .components(separatedBy: .whitespacesAndNewlines).joined()
137
+
138
+ guard var der = Data(base64Encoded: pem) else { return nil }
139
+ if der.count > 24 { der = der.subdata(in: 24..<der.count) }
140
+
141
+ let attributes: [String: Any] = [
142
+ kSecAttrKeyType as String: kSecAttrKeyTypeRSA,
143
+ kSecAttrKeyClass as String: kSecAttrKeyClassPublic
144
+ ]
145
+
146
+ guard let key = SecKeyCreateWithData(der as CFData, attributes as CFDictionary, nil),
147
+ let signature = base64UrlDecode(String(parts[2])) else { return nil }
148
+
149
+ let signed = Data((String(parts[0]) + "." + String(parts[1])).utf8)
150
+
151
+ guard SecKeyVerifySignature(key, .rsaSignatureMessagePKCS1v15SHA256, signed as CFData, signature as CFData, nil),
152
+ let payload = base64UrlDecode(String(parts[1])),
153
+ let claims = try? JSONSerialization.jsonObject(with: payload) as? [String: Any] else { return nil }
154
+
155
+ return claims
156
+ }
157
+
158
+ // Bind the token to THIS installation. verifyToken proves the store signed
159
+ // it; it does not check expiry, this machine or this product. claims.fp is
160
+ // a server-side HMAC that cannot be recomputed here, so claims.ins is the
161
+ // binding a client is able to check.
162
+ static func entitlement(
163
+ _ token: String,
164
+ publicKeyPem: String,
165
+ installId: String?,
166
+ productId: Int
167
+ ) -> (claims: [String: Any]?, reason: String?) {
168
+ guard let claims = verifyToken(token, publicKeyPem: publicKeyPem) else {
169
+ return (nil, "invalid_or_expired")
170
+ }
171
+
172
+ if let exp = (claims["exp"] as? NSNumber)?.doubleValue, exp <= Date().timeIntervalSince1970 {
173
+ return (nil, "invalid_or_expired")
174
+ }
175
+
176
+ if productId > 0, let prod = (claims["prod"] as? NSNumber)?.intValue, prod != productId {
177
+ return (nil, "wrong_product")
178
+ }
179
+
180
+ if let installId = installId, !installId.isEmpty,
181
+ let ins = claims["ins"] as? String, ins != installId {
182
+ return (nil, "wrong_install")
183
+ }
184
+
185
+ return (claims, nil)
186
+ }
187
+
188
+ private static func base64UrlDecode(_ value: String) -> Data? {
189
+ var base64 = value.replacingOccurrences(of: "-", with: "+").replacingOccurrences(of: "_", with: "/")
190
+ base64 += String(repeating: "=", count: (4 - base64.count % 4) % 4)
191
+ return Data(base64Encoded: base64)
192
+ }
193
+
194
+ static func latestRelease(key: String, current: String, platform: String = "any") -> [String: Any] {
195
+ var components = URLComponents()
196
+ components.queryItems = [
197
+ URLQueryItem(name: "product_id", value: String(productId)),
198
+ URLQueryItem(name: "platform", value: platform),
199
+ URLQueryItem(name: "current_version", value: current),
200
+ URLQueryItem(name: "license_key", value: key)
201
+ ]
202
+
203
+ return get("fastr_release_latest&" + (components.percentEncodedQuery ?? ""))
204
+ }
205
+
206
+ static func reportUsage(key: String, metric: String, quantity: Int, idempotencyKey: String) -> [String: Any] {
207
+ post("fastr_usage_report", [
208
+ "license_key": key,
209
+ "metric": metric,
210
+ "quantity": String(quantity),
211
+ "idempotency_key": idempotencyKey
212
+ ])
213
+ }
214
+ }
215
215
  `;
216
216
  }
217
217
  if (platform === 'unity_csharp') {
218
- return `${banner(appName, 'Unity / C#', 'FastrLicense.cs', base, productId)}
219
- // UNVERIFIED: this target is emitted but never compiled in CI, because it
220
- // needs the Unity editor. Signature and token binding are written to the same
221
- // contract as the other clients, but only by inspection. Test it in your own
222
- // project before you ship on it.
223
- using System;
224
- using System.Collections.Generic;
225
- using System.Security.Cryptography;
226
- using System.Text;
227
- using System.Text.Json;
228
- using UnityEngine;
229
- using UnityEngine.Networking;
230
-
231
- public static class FastrLicense
232
- {
233
- private const string Store = "${base}";
234
- private const int ProductId = ${productId};
235
-
236
- public sealed class State
237
- {
238
- public string Status = "";
239
- public string Token;
240
- public string ErrorType;
241
- public List<int> Entitlements = new List<int>();
242
- public bool IsValid { get { return Status == "valid"; } }
243
- }
244
-
245
- private static string Call(string verb, Dictionary<string, string> body)
246
- {
247
- var form = new List<string>();
248
- foreach (var pair in body) form.Add(Uri.EscapeDataString(pair.Key) + "=" + Uri.EscapeDataString(pair.Value));
249
-
250
- using (var request = new UnityWebRequest(Store + "?fluent-cart=" + verb, "POST"))
251
- {
252
- request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(string.Join("&", form)));
253
- request.downloadHandler = new DownloadHandlerBuffer();
254
- request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
255
- request.timeout = 15;
256
-
257
- var operation = request.SendWebRequest();
258
- while (!operation.isDone) { }
259
-
260
- return request.downloadHandler.text;
261
- }
262
- }
263
-
264
- private static string Get(string url)
265
- {
266
- using (var request = UnityWebRequest.Get(url))
267
- {
268
- request.timeout = 15;
269
- var operation = request.SendWebRequest();
270
- while (!operation.isDone) { }
271
- return request.downloadHandler.text;
272
- }
273
- }
274
-
275
- private static State Parse(string json)
276
- {
277
- var state = new State();
278
- if (string.IsNullOrEmpty(json)) return state;
279
-
280
- using (var document = JsonDocument.Parse(json))
281
- {
282
- var root = document.RootElement;
283
- if (root.TryGetProperty("status", out var status)) state.Status = status.GetString() ?? "";
284
- if (root.TryGetProperty("license_token", out var token)) state.Token = token.GetString();
285
- if (root.TryGetProperty("error_type", out var error)) state.ErrorType = error.GetString();
286
- if (root.TryGetProperty("entitlements", out var ents) && ents.ValueKind == JsonValueKind.Array)
287
- foreach (var id in ents.EnumerateArray()) state.Entitlements.Add(id.GetInt32());
288
- }
289
-
290
- return state;
291
- }
292
-
293
- public static State Activate(string key, string instanceId, string fingerprint, string email)
294
- {
295
- return Parse(Call("activate_license", new Dictionary<string, string>
296
- {
297
- { "item_id", ProductId.ToString() },
298
- { "license_key", key.Trim() },
299
- { "site_url", instanceId },
300
- { "device_fingerprint", fingerprint },
301
- { "device_name", SystemInfo.deviceName },
302
- { "device_type", "Game (Unity)" },
303
- { "os", SystemInfo.operatingSystem },
304
- { "email", email },
305
- { "server_version", Application.version }
306
- }));
307
- }
308
-
309
- public static State Check(string key, string instanceId, string fingerprint)
310
- {
311
- return Parse(Call("check_license", new Dictionary<string, string>
312
- {
313
- { "item_id", ProductId.ToString() },
314
- { "license_key", key },
315
- { "site_url", instanceId },
316
- { "device_fingerprint", fingerprint }
317
- }));
318
- }
319
-
320
- public static void Deactivate(string key, string instanceId)
321
- {
322
- Call("deactivate_license", new Dictionary<string, string>
323
- {
324
- { "item_id", ProductId.ToString() },
325
- { "license_key", key },
326
- { "site_url", instanceId }
327
- });
328
- }
329
-
330
- /// <summary>Needs .NET Standard 2.1 (Unity 2021.2+) for ImportSubjectPublicKeyInfo.</summary>
331
- public static bool VerifyToken(string token, string publicKeyPem, out Dictionary<string, object> claims)
332
- {
333
- claims = null;
334
-
335
- var parts = token.Split('.');
336
- if (parts.Length != 3) return false;
337
-
338
- var der = Convert.FromBase64String(publicKeyPem
339
- .Replace("-----BEGIN PUBLIC KEY-----", "")
340
- .Replace("-----END PUBLIC KEY-----", "")
341
- .Replace("\\n", "").Replace("\\r", "").Trim());
342
-
343
- using (var rsa = RSA.Create())
344
- {
345
- rsa.ImportSubjectPublicKeyInfo(der, out _);
346
-
347
- var signed = Encoding.UTF8.GetBytes(parts[0] + "." + parts[1]);
348
-
349
- if (!rsa.VerifyData(signed, Base64UrlDecode(parts[2]), HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1))
350
- return false;
351
- }
352
-
353
- claims = JsonSerializer.Deserialize<Dictionary<string, object>>(
354
- Encoding.UTF8.GetString(Base64UrlDecode(parts[1])));
355
-
356
- return claims != null;
357
- }
358
-
359
- /// <summary>
360
- /// Bind the token to this installation. VerifyToken proves the store signed
361
- /// it; it does not check expiry, this machine or this product. claims.fp is
362
- /// a server-side HMAC that cannot be recomputed here, so claims.ins is the
363
- /// binding a client is able to check.
364
- /// </summary>
365
- public static bool Entitlement(
366
- string token,
367
- string publicKeyPem,
368
- string installId,
369
- int productId,
370
- out Dictionary<string, object> claims,
371
- out string reason)
372
- {
373
- reason = "";
374
-
375
- if (!VerifyToken(token, publicKeyPem, out claims))
376
- {
377
- reason = "invalid_or_expired";
378
- return false;
379
- }
380
-
381
- if (!claims.ContainsKey("exp")
382
- || Convert.ToInt64(claims["exp"]) <= DateTimeOffset.UtcNow.ToUnixTimeSeconds())
383
- {
384
- reason = "invalid_or_expired";
385
- return false;
386
- }
387
-
388
- if (productId > 0
389
- && (!claims.ContainsKey("prod") || Convert.ToInt32(claims["prod"]) != productId))
390
- {
391
- reason = "wrong_product";
392
- return false;
393
- }
394
-
395
- if (!string.IsNullOrEmpty(installId)
396
- && claims.ContainsKey("ins")
397
- && Convert.ToString(claims["ins"]) != installId)
398
- {
399
- reason = "wrong_install";
400
- return false;
401
- }
402
-
403
- return true;
404
- }
405
-
406
- private static byte[] Base64UrlDecode(string value)
407
- {
408
- var padded = value.Replace('-', '+').Replace('_', '/');
409
- padded += new string('=', (4 - padded.Length % 4) % 4);
410
- return Convert.FromBase64String(padded);
411
- }
412
-
413
- public static string LatestRelease(string key, string currentVersion)
414
- {
415
- var url = Store + "?fluent-cart=fastr_release_latest"
416
- + "&product_id=" + ProductId
417
- + "&platform=any"
418
- + "&current_version=" + UnityWebRequest.EscapeURL(currentVersion)
419
- + "&license_key=" + UnityWebRequest.EscapeURL(key);
420
-
421
- return Get(url);
422
- }
423
-
424
- public static string ReportUsage(string key, string metric, int quantity, string idempotencyKey)
425
- {
426
- return Call("fastr_usage_report", new Dictionary<string, string>
427
- {
428
- { "license_key", key },
429
- { "metric", metric },
430
- { "quantity", quantity.ToString() },
431
- { "idempotency_key", idempotencyKey }
432
- });
433
- }
434
- }
218
+ return `${banner(appName, 'Unity / C#', 'FastrLicense.cs', base, productId)}
219
+ // UNVERIFIED: this target is emitted but never compiled in CI, because it
220
+ // needs the Unity editor. Signature and token binding are written to the same
221
+ // contract as the other clients, but only by inspection. Test it in your own
222
+ // project before you ship on it.
223
+ using System;
224
+ using System.Collections.Generic;
225
+ using System.Security.Cryptography;
226
+ using System.Text;
227
+ using System.Text.Json;
228
+ using UnityEngine;
229
+ using UnityEngine.Networking;
230
+
231
+ public static class FastrLicense
232
+ {
233
+ private const string Store = "${base}";
234
+ private const int ProductId = ${productId};
235
+
236
+ public sealed class State
237
+ {
238
+ public string Status = "";
239
+ public string Token;
240
+ public string ErrorType;
241
+ public List<int> Entitlements = new List<int>();
242
+ public bool IsValid { get { return Status == "valid"; } }
243
+ }
244
+
245
+ private static string Call(string verb, Dictionary<string, string> body)
246
+ {
247
+ var form = new List<string>();
248
+ foreach (var pair in body) form.Add(Uri.EscapeDataString(pair.Key) + "=" + Uri.EscapeDataString(pair.Value));
249
+
250
+ using (var request = new UnityWebRequest(Store + "?fluent-cart=" + verb, "POST"))
251
+ {
252
+ request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(string.Join("&", form)));
253
+ request.downloadHandler = new DownloadHandlerBuffer();
254
+ request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
255
+ request.timeout = 15;
256
+
257
+ var operation = request.SendWebRequest();
258
+ while (!operation.isDone) { }
259
+
260
+ return request.downloadHandler.text;
261
+ }
262
+ }
263
+
264
+ private static string Get(string url)
265
+ {
266
+ using (var request = UnityWebRequest.Get(url))
267
+ {
268
+ request.timeout = 15;
269
+ var operation = request.SendWebRequest();
270
+ while (!operation.isDone) { }
271
+ return request.downloadHandler.text;
272
+ }
273
+ }
274
+
275
+ private static State Parse(string json)
276
+ {
277
+ var state = new State();
278
+ if (string.IsNullOrEmpty(json)) return state;
279
+
280
+ using (var document = JsonDocument.Parse(json))
281
+ {
282
+ var root = document.RootElement;
283
+ if (root.TryGetProperty("status", out var status)) state.Status = status.GetString() ?? "";
284
+ if (root.TryGetProperty("license_token", out var token)) state.Token = token.GetString();
285
+ if (root.TryGetProperty("error_type", out var error)) state.ErrorType = error.GetString();
286
+ if (root.TryGetProperty("entitlements", out var ents) && ents.ValueKind == JsonValueKind.Array)
287
+ foreach (var id in ents.EnumerateArray()) state.Entitlements.Add(id.GetInt32());
288
+ }
289
+
290
+ return state;
291
+ }
292
+
293
+ public static State Activate(string key, string instanceId, string fingerprint, string email)
294
+ {
295
+ return Parse(Call("activate_license", new Dictionary<string, string>
296
+ {
297
+ { "item_id", ProductId.ToString() },
298
+ { "license_key", key.Trim() },
299
+ { "site_url", instanceId },
300
+ { "device_fingerprint", fingerprint },
301
+ { "device_name", SystemInfo.deviceName },
302
+ { "device_type", "Game (Unity)" },
303
+ { "os", SystemInfo.operatingSystem },
304
+ { "email", email },
305
+ { "server_version", Application.version }
306
+ }));
307
+ }
308
+
309
+ public static State Check(string key, string instanceId, string fingerprint)
310
+ {
311
+ return Parse(Call("check_license", new Dictionary<string, string>
312
+ {
313
+ { "item_id", ProductId.ToString() },
314
+ { "license_key", key },
315
+ { "site_url", instanceId },
316
+ { "device_fingerprint", fingerprint }
317
+ }));
318
+ }
319
+
320
+ public static void Deactivate(string key, string instanceId)
321
+ {
322
+ Call("deactivate_license", new Dictionary<string, string>
323
+ {
324
+ { "item_id", ProductId.ToString() },
325
+ { "license_key", key },
326
+ { "site_url", instanceId }
327
+ });
328
+ }
329
+
330
+ /// <summary>Needs .NET Standard 2.1 (Unity 2021.2+) for ImportSubjectPublicKeyInfo.</summary>
331
+ public static bool VerifyToken(string token, string publicKeyPem, out Dictionary<string, object> claims)
332
+ {
333
+ claims = null;
334
+
335
+ var parts = token.Split('.');
336
+ if (parts.Length != 3) return false;
337
+
338
+ var der = Convert.FromBase64String(publicKeyPem
339
+ .Replace("-----BEGIN PUBLIC KEY-----", "")
340
+ .Replace("-----END PUBLIC KEY-----", "")
341
+ .Replace("\\n", "").Replace("\\r", "").Trim());
342
+
343
+ using (var rsa = RSA.Create())
344
+ {
345
+ rsa.ImportSubjectPublicKeyInfo(der, out _);
346
+
347
+ var signed = Encoding.UTF8.GetBytes(parts[0] + "." + parts[1]);
348
+
349
+ if (!rsa.VerifyData(signed, Base64UrlDecode(parts[2]), HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1))
350
+ return false;
351
+ }
352
+
353
+ claims = JsonSerializer.Deserialize<Dictionary<string, object>>(
354
+ Encoding.UTF8.GetString(Base64UrlDecode(parts[1])));
355
+
356
+ return claims != null;
357
+ }
358
+
359
+ /// <summary>
360
+ /// Bind the token to this installation. VerifyToken proves the store signed
361
+ /// it; it does not check expiry, this machine or this product. claims.fp is
362
+ /// a server-side HMAC that cannot be recomputed here, so claims.ins is the
363
+ /// binding a client is able to check.
364
+ /// </summary>
365
+ public static bool Entitlement(
366
+ string token,
367
+ string publicKeyPem,
368
+ string installId,
369
+ int productId,
370
+ out Dictionary<string, object> claims,
371
+ out string reason)
372
+ {
373
+ reason = "";
374
+
375
+ if (!VerifyToken(token, publicKeyPem, out claims))
376
+ {
377
+ reason = "invalid_or_expired";
378
+ return false;
379
+ }
380
+
381
+ if (!claims.ContainsKey("exp")
382
+ || Convert.ToInt64(claims["exp"]) <= DateTimeOffset.UtcNow.ToUnixTimeSeconds())
383
+ {
384
+ reason = "invalid_or_expired";
385
+ return false;
386
+ }
387
+
388
+ if (productId > 0
389
+ && (!claims.ContainsKey("prod") || Convert.ToInt32(claims["prod"]) != productId))
390
+ {
391
+ reason = "wrong_product";
392
+ return false;
393
+ }
394
+
395
+ if (!string.IsNullOrEmpty(installId)
396
+ && claims.ContainsKey("ins")
397
+ && Convert.ToString(claims["ins"]) != installId)
398
+ {
399
+ reason = "wrong_install";
400
+ return false;
401
+ }
402
+
403
+ return true;
404
+ }
405
+
406
+ private static byte[] Base64UrlDecode(string value)
407
+ {
408
+ var padded = value.Replace('-', '+').Replace('_', '/');
409
+ padded += new string('=', (4 - padded.Length % 4) % 4);
410
+ return Convert.FromBase64String(padded);
411
+ }
412
+
413
+ public static string LatestRelease(string key, string currentVersion)
414
+ {
415
+ var url = Store + "?fluent-cart=fastr_release_latest"
416
+ + "&product_id=" + ProductId
417
+ + "&platform=any"
418
+ + "&current_version=" + UnityWebRequest.EscapeURL(currentVersion)
419
+ + "&license_key=" + UnityWebRequest.EscapeURL(key);
420
+
421
+ return Get(url);
422
+ }
423
+
424
+ public static string ReportUsage(string key, string metric, int quantity, string idempotencyKey)
425
+ {
426
+ return Call("fastr_usage_report", new Dictionary<string, string>
427
+ {
428
+ { "license_key", key },
429
+ { "metric", metric },
430
+ { "quantity", quantity.ToString() },
431
+ { "idempotency_key", idempotencyKey }
432
+ });
433
+ }
434
+ }
435
435
  `;
436
436
  }
437
437
  if (platform === 'java') {
438
- return `${banner(appName, 'Java / JVM', 'FastrLicense.java', base, productId)}
439
- import java.io.ByteArrayOutputStream;
440
- import java.io.InputStream;
441
- import java.io.OutputStream;
442
- import java.net.HttpURLConnection;
443
- import java.net.URL;
444
- import java.net.URLEncoder;
445
- import java.nio.charset.StandardCharsets;
446
- import java.security.KeyFactory;
447
- import java.security.PublicKey;
448
- import java.security.Signature;
449
- import java.security.spec.X509EncodedKeySpec;
450
- import java.util.Base64;
451
- import java.util.LinkedHashMap;
452
- import java.util.Map;
453
-
454
- public final class FastrLicense {
455
-
456
- public static final String STORE = "${base}";
457
- public static final int PRODUCT_ID = ${productId};
458
-
459
- public static final class State {
460
- public String status = "";
461
- public String token;
462
- public String errorType;
463
- public boolean isValid() { return "valid".equals(status); }
464
- }
465
-
466
- private static String post(String verb, Map<String, String> fields) throws Exception {
467
- StringBuilder form = new StringBuilder();
468
- for (Map.Entry<String, String> entry : fields.entrySet()) {
469
- if (form.length() > 0) form.append('&');
470
- form.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
471
- .append('=')
472
- .append(URLEncoder.encode(entry.getValue(), "UTF-8"));
473
- }
474
-
475
- HttpURLConnection connection = (HttpURLConnection) new URL(STORE + "?fluent-cart=" + verb).openConnection();
476
- connection.setRequestMethod("POST");
477
- connection.setDoOutput(true);
478
- connection.setConnectTimeout(15000);
479
- connection.setReadTimeout(15000);
480
- connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
481
-
482
- try (OutputStream out = connection.getOutputStream()) {
483
- out.write(form.toString().getBytes(StandardCharsets.UTF_8));
484
- }
485
-
486
- return read(connection);
487
- }
488
-
489
- private static String read(HttpURLConnection connection) throws Exception {
490
- try (InputStream in = connection.getInputStream()) {
491
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
492
- byte[] chunk = new byte[8192];
493
- int count;
494
- while ((count = in.read(chunk)) != -1) buffer.write(chunk, 0, count);
495
- return buffer.toString("UTF-8");
496
- }
497
- }
498
-
499
- /** Minimal field reader; swap in Jackson or Gson in a real project. */
500
- private static String field(String json, String name) {
501
- int at = json.indexOf("\\"" + name + "\\"");
502
- if (at < 0) return null;
503
-
504
- int colon = json.indexOf(':', at);
505
- if (colon < 0) return null;
506
-
507
- int start = colon + 1;
508
- while (start < json.length() && Character.isWhitespace(json.charAt(start))) start++;
509
- if (start >= json.length()) return null;
510
-
511
- if (json.charAt(start) == '"') {
512
- int end = json.indexOf('"', start + 1);
513
- return end < 0 ? null : json.substring(start + 1, end);
514
- }
515
-
516
- int end = start;
517
- while (end < json.length() && ",}]".indexOf(json.charAt(end)) < 0) end++;
518
- return json.substring(start, end).trim();
519
- }
520
-
521
- private static State parse(String json) {
522
- State state = new State();
523
- String status = field(json, "status");
524
- if (status != null) state.status = status;
525
- state.token = field(json, "license_token");
526
- state.errorType = field(json, "error_type");
527
- return state;
528
- }
529
-
530
- public static State activate(String key, String instanceId, String fingerprint, String email) throws Exception {
531
- Map<String, String> fields = new LinkedHashMap<>();
532
- fields.put("item_id", String.valueOf(PRODUCT_ID));
533
- fields.put("license_key", key.trim());
534
- fields.put("site_url", instanceId);
535
- fields.put("device_fingerprint", fingerprint);
536
- fields.put("device_name", System.getenv().getOrDefault("COMPUTERNAME", "desktop"));
537
- fields.put("device_type", "Desktop (JVM)");
538
- fields.put("os", System.getProperty("os.name") + " " + System.getProperty("os.arch"));
539
- fields.put("email", email);
540
- fields.put("server_version", "1.0.0");
541
- return parse(post("activate_license", fields));
542
- }
543
-
544
- public static State check(String key, String instanceId, String fingerprint) throws Exception {
545
- Map<String, String> fields = new LinkedHashMap<>();
546
- fields.put("item_id", String.valueOf(PRODUCT_ID));
547
- fields.put("license_key", key);
548
- fields.put("site_url", instanceId);
549
- fields.put("device_fingerprint", fingerprint);
550
- return parse(post("check_license", fields));
551
- }
552
-
553
- public static void deactivate(String key, String instanceId) throws Exception {
554
- Map<String, String> fields = new LinkedHashMap<>();
555
- fields.put("item_id", String.valueOf(PRODUCT_ID));
556
- fields.put("license_key", key);
557
- fields.put("site_url", instanceId);
558
- post("deactivate_license", fields);
559
- }
560
-
561
- public static boolean verifyToken(String token, String publicKeyPem) throws Exception {
562
- String[] parts = token.split("\\\\.");
563
- if (parts.length != 3) return false;
564
-
565
- String pem = publicKeyPem
566
- .replace("-----BEGIN PUBLIC KEY-----", "")
567
- .replace("-----END PUBLIC KEY-----", "")
568
- .replaceAll("\\\\s", "");
569
-
570
- PublicKey key = KeyFactory.getInstance("RSA")
571
- .generatePublic(new X509EncodedKeySpec(Base64.getDecoder().decode(pem)));
572
-
573
- Signature verifier = Signature.getInstance("SHA256withRSA");
574
- verifier.initVerify(key);
575
- verifier.update((parts[0] + "." + parts[1]).getBytes(StandardCharsets.UTF_8));
576
-
577
- return verifier.verify(Base64.getUrlDecoder().decode(parts[2]));
578
- }
579
-
580
- // Bind the token to THIS installation. verifyToken proves the store signed
581
- // it and checks nothing else, so a copied token passes. claims.fp is a
582
- // server-side HMAC that cannot be recomputed here, so claims.ins - the
583
- // install id sent as site_url - is the binding a client can check.
584
- // Returns an empty string when entitled, otherwise the reason.
585
- public static String entitlement(String token, String publicKeyPem, String installId, int productId) throws Exception {
586
- if (!verifyToken(token, publicKeyPem)) return "invalid_or_expired";
587
-
588
- String[] parts = token.split("[.]");
589
- String payload = new String(Base64.getUrlDecoder().decode(parts[1]), StandardCharsets.UTF_8);
590
-
591
- String exp = claimValue(payload, "exp");
592
- if (exp != null && Long.parseLong(exp) <= System.currentTimeMillis() / 1000L) {
593
- return "invalid_or_expired";
594
- }
595
-
596
- String prod = claimValue(payload, "prod");
597
- if (productId > 0 && (prod == null || Integer.parseInt(prod) != productId)) {
598
- return "wrong_product";
599
- }
600
-
601
- String ins = claimValue(payload, "ins");
602
- if (installId != null && !installId.isEmpty() && ins != null && !ins.equals(installId)) {
603
- return "wrong_install";
604
- }
605
-
606
- return "";
607
- }
608
-
609
- // Reads a top-level claim without pulling in a JSON library: a quoted value
610
- // is returned as-is, a bare number as its digits. Good enough for the three
611
- // claims this checks, and it fails closed by returning null.
612
- private static String claimValue(String json, String name) {
613
- String needle = "\\"" + name + "\\":";
614
- int at = json.indexOf(needle);
615
- if (at < 0) return null;
616
-
617
- int start = at + needle.length();
618
- if (start >= json.length()) return null;
619
-
620
- if (json.charAt(start) == '"') {
621
- int end = json.indexOf('"', start + 1);
622
- return end < 0 ? null : json.substring(start + 1, end);
623
- }
624
-
625
- int end = start;
626
- while (end < json.length() && "-0123456789".indexOf(json.charAt(end)) >= 0) end++;
627
- return end == start ? null : json.substring(start, end);
628
- }
629
-
630
- public static String latestRelease(String key, String currentVersion, String platform) throws Exception {
631
- String url = STORE + "?fluent-cart=fastr_release_latest"
632
- + "&product_id=" + PRODUCT_ID
633
- + "&platform=" + URLEncoder.encode(platform, "UTF-8")
634
- + "&current_version=" + URLEncoder.encode(currentVersion, "UTF-8")
635
- + "&license_key=" + URLEncoder.encode(key, "UTF-8");
636
-
637
- HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
638
- connection.setConnectTimeout(15000);
639
- connection.setReadTimeout(15000);
640
-
641
- return read(connection);
642
- }
643
-
644
- public static String reportUsage(String key, String metric, int quantity, String idempotencyKey) throws Exception {
645
- Map<String, String> fields = new LinkedHashMap<>();
646
- fields.put("license_key", key);
647
- fields.put("metric", metric);
648
- fields.put("quantity", String.valueOf(quantity));
649
- fields.put("idempotency_key", idempotencyKey);
650
- return post("fastr_usage_report", fields);
651
- }
652
- }
438
+ return `${banner(appName, 'Java / JVM', 'FastrLicense.java', base, productId)}
439
+ import java.io.ByteArrayOutputStream;
440
+ import java.io.InputStream;
441
+ import java.io.OutputStream;
442
+ import java.net.HttpURLConnection;
443
+ import java.net.URL;
444
+ import java.net.URLEncoder;
445
+ import java.nio.charset.StandardCharsets;
446
+ import java.security.KeyFactory;
447
+ import java.security.PublicKey;
448
+ import java.security.Signature;
449
+ import java.security.spec.X509EncodedKeySpec;
450
+ import java.util.Base64;
451
+ import java.util.LinkedHashMap;
452
+ import java.util.Map;
453
+
454
+ public final class FastrLicense {
455
+
456
+ public static final String STORE = "${base}";
457
+ public static final int PRODUCT_ID = ${productId};
458
+
459
+ public static final class State {
460
+ public String status = "";
461
+ public String token;
462
+ public String errorType;
463
+ public boolean isValid() { return "valid".equals(status); }
464
+ }
465
+
466
+ private static String post(String verb, Map<String, String> fields) throws Exception {
467
+ StringBuilder form = new StringBuilder();
468
+ for (Map.Entry<String, String> entry : fields.entrySet()) {
469
+ if (form.length() > 0) form.append('&');
470
+ form.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
471
+ .append('=')
472
+ .append(URLEncoder.encode(entry.getValue(), "UTF-8"));
473
+ }
474
+
475
+ HttpURLConnection connection = (HttpURLConnection) new URL(STORE + "?fluent-cart=" + verb).openConnection();
476
+ connection.setRequestMethod("POST");
477
+ connection.setDoOutput(true);
478
+ connection.setConnectTimeout(15000);
479
+ connection.setReadTimeout(15000);
480
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
481
+
482
+ try (OutputStream out = connection.getOutputStream()) {
483
+ out.write(form.toString().getBytes(StandardCharsets.UTF_8));
484
+ }
485
+
486
+ return read(connection);
487
+ }
488
+
489
+ private static String read(HttpURLConnection connection) throws Exception {
490
+ try (InputStream in = connection.getInputStream()) {
491
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
492
+ byte[] chunk = new byte[8192];
493
+ int count;
494
+ while ((count = in.read(chunk)) != -1) buffer.write(chunk, 0, count);
495
+ return buffer.toString("UTF-8");
496
+ }
497
+ }
498
+
499
+ /** Minimal field reader; swap in Jackson or Gson in a real project. */
500
+ private static String field(String json, String name) {
501
+ int at = json.indexOf("\\"" + name + "\\"");
502
+ if (at < 0) return null;
503
+
504
+ int colon = json.indexOf(':', at);
505
+ if (colon < 0) return null;
506
+
507
+ int start = colon + 1;
508
+ while (start < json.length() && Character.isWhitespace(json.charAt(start))) start++;
509
+ if (start >= json.length()) return null;
510
+
511
+ if (json.charAt(start) == '"') {
512
+ int end = json.indexOf('"', start + 1);
513
+ return end < 0 ? null : json.substring(start + 1, end);
514
+ }
515
+
516
+ int end = start;
517
+ while (end < json.length() && ",}]".indexOf(json.charAt(end)) < 0) end++;
518
+ return json.substring(start, end).trim();
519
+ }
520
+
521
+ private static State parse(String json) {
522
+ State state = new State();
523
+ String status = field(json, "status");
524
+ if (status != null) state.status = status;
525
+ state.token = field(json, "license_token");
526
+ state.errorType = field(json, "error_type");
527
+ return state;
528
+ }
529
+
530
+ public static State activate(String key, String instanceId, String fingerprint, String email) throws Exception {
531
+ Map<String, String> fields = new LinkedHashMap<>();
532
+ fields.put("item_id", String.valueOf(PRODUCT_ID));
533
+ fields.put("license_key", key.trim());
534
+ fields.put("site_url", instanceId);
535
+ fields.put("device_fingerprint", fingerprint);
536
+ fields.put("device_name", System.getenv().getOrDefault("COMPUTERNAME", "desktop"));
537
+ fields.put("device_type", "Desktop (JVM)");
538
+ fields.put("os", System.getProperty("os.name") + " " + System.getProperty("os.arch"));
539
+ fields.put("email", email);
540
+ fields.put("server_version", "1.0.0");
541
+ return parse(post("activate_license", fields));
542
+ }
543
+
544
+ public static State check(String key, String instanceId, String fingerprint) throws Exception {
545
+ Map<String, String> fields = new LinkedHashMap<>();
546
+ fields.put("item_id", String.valueOf(PRODUCT_ID));
547
+ fields.put("license_key", key);
548
+ fields.put("site_url", instanceId);
549
+ fields.put("device_fingerprint", fingerprint);
550
+ return parse(post("check_license", fields));
551
+ }
552
+
553
+ public static void deactivate(String key, String instanceId) throws Exception {
554
+ Map<String, String> fields = new LinkedHashMap<>();
555
+ fields.put("item_id", String.valueOf(PRODUCT_ID));
556
+ fields.put("license_key", key);
557
+ fields.put("site_url", instanceId);
558
+ post("deactivate_license", fields);
559
+ }
560
+
561
+ public static boolean verifyToken(String token, String publicKeyPem) throws Exception {
562
+ String[] parts = token.split("\\\\.");
563
+ if (parts.length != 3) return false;
564
+
565
+ String pem = publicKeyPem
566
+ .replace("-----BEGIN PUBLIC KEY-----", "")
567
+ .replace("-----END PUBLIC KEY-----", "")
568
+ .replaceAll("\\\\s", "");
569
+
570
+ PublicKey key = KeyFactory.getInstance("RSA")
571
+ .generatePublic(new X509EncodedKeySpec(Base64.getDecoder().decode(pem)));
572
+
573
+ Signature verifier = Signature.getInstance("SHA256withRSA");
574
+ verifier.initVerify(key);
575
+ verifier.update((parts[0] + "." + parts[1]).getBytes(StandardCharsets.UTF_8));
576
+
577
+ return verifier.verify(Base64.getUrlDecoder().decode(parts[2]));
578
+ }
579
+
580
+ // Bind the token to THIS installation. verifyToken proves the store signed
581
+ // it and checks nothing else, so a copied token passes. claims.fp is a
582
+ // server-side HMAC that cannot be recomputed here, so claims.ins - the
583
+ // install id sent as site_url - is the binding a client can check.
584
+ // Returns an empty string when entitled, otherwise the reason.
585
+ public static String entitlement(String token, String publicKeyPem, String installId, int productId) throws Exception {
586
+ if (!verifyToken(token, publicKeyPem)) return "invalid_or_expired";
587
+
588
+ String[] parts = token.split("[.]");
589
+ String payload = new String(Base64.getUrlDecoder().decode(parts[1]), StandardCharsets.UTF_8);
590
+
591
+ String exp = claimValue(payload, "exp");
592
+ if (exp != null && Long.parseLong(exp) <= System.currentTimeMillis() / 1000L) {
593
+ return "invalid_or_expired";
594
+ }
595
+
596
+ String prod = claimValue(payload, "prod");
597
+ if (productId > 0 && (prod == null || Integer.parseInt(prod) != productId)) {
598
+ return "wrong_product";
599
+ }
600
+
601
+ String ins = claimValue(payload, "ins");
602
+ if (installId != null && !installId.isEmpty() && ins != null && !ins.equals(installId)) {
603
+ return "wrong_install";
604
+ }
605
+
606
+ return "";
607
+ }
608
+
609
+ // Reads a top-level claim without pulling in a JSON library: a quoted value
610
+ // is returned as-is, a bare number as its digits. Good enough for the three
611
+ // claims this checks, and it fails closed by returning null.
612
+ private static String claimValue(String json, String name) {
613
+ String needle = "\\"" + name + "\\":";
614
+ int at = json.indexOf(needle);
615
+ if (at < 0) return null;
616
+
617
+ int start = at + needle.length();
618
+ if (start >= json.length()) return null;
619
+
620
+ if (json.charAt(start) == '"') {
621
+ int end = json.indexOf('"', start + 1);
622
+ return end < 0 ? null : json.substring(start + 1, end);
623
+ }
624
+
625
+ int end = start;
626
+ while (end < json.length() && "-0123456789".indexOf(json.charAt(end)) >= 0) end++;
627
+ return end == start ? null : json.substring(start, end);
628
+ }
629
+
630
+ public static String latestRelease(String key, String currentVersion, String platform) throws Exception {
631
+ String url = STORE + "?fluent-cart=fastr_release_latest"
632
+ + "&product_id=" + PRODUCT_ID
633
+ + "&platform=" + URLEncoder.encode(platform, "UTF-8")
634
+ + "&current_version=" + URLEncoder.encode(currentVersion, "UTF-8")
635
+ + "&license_key=" + URLEncoder.encode(key, "UTF-8");
636
+
637
+ HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
638
+ connection.setConnectTimeout(15000);
639
+ connection.setReadTimeout(15000);
640
+
641
+ return read(connection);
642
+ }
643
+
644
+ public static String reportUsage(String key, String metric, int quantity, String idempotencyKey) throws Exception {
645
+ Map<String, String> fields = new LinkedHashMap<>();
646
+ fields.put("license_key", key);
647
+ fields.put("metric", metric);
648
+ fields.put("quantity", String.valueOf(quantity));
649
+ fields.put("idempotency_key", idempotencyKey);
650
+ return post("fastr_usage_report", fields);
651
+ }
652
+ }
653
653
  `;
654
654
  }
655
655
  if (platform === 'php') {
656
- return `<?php
657
-
658
- declare(strict_types=1);
659
-
660
- ${banner(appName, 'PHP (no WordPress)', 'FastrLicense.php', base, productId)}
661
-
662
- final class FastrLicense
663
- {
664
- public const STORE = '${base}';
665
- public const PRODUCT_ID = ${productId};
666
-
667
- private static function post(string $verb, array $fields): array
668
- {
669
- $handle = curl_init(self::STORE . '?fluent-cart=' . $verb);
670
- curl_setopt_array($handle, [
671
- CURLOPT_POST => true,
672
- CURLOPT_POSTFIELDS => http_build_query($fields),
673
- CURLOPT_RETURNTRANSFER => true,
674
- CURLOPT_TIMEOUT => 15,
675
- ]);
676
-
677
- $body = curl_exec($handle);
678
- curl_close($handle);
679
-
680
- $json = is_string($body) ? json_decode($body, true) : null;
681
-
682
- return is_array($json) ? $json : [];
683
- }
684
-
685
- public static function activate(string $key, string $instanceId, string $fingerprint, string $email): array
686
- {
687
- return self::post('activate_license', [
688
- 'item_id' => (string) self::PRODUCT_ID,
689
- 'license_key' => trim($key),
690
- 'site_url' => $instanceId,
691
- 'device_fingerprint' => $fingerprint,
692
- 'device_name' => gethostname() ?: 'desktop',
693
- 'device_type' => 'CLI (PHP)',
694
- 'os' => PHP_OS_FAMILY,
695
- 'email' => $email,
696
- 'server_version' => '1.0.0',
697
- ]);
698
- }
699
-
700
- public static function check(string $key, string $instanceId, string $fingerprint): array
701
- {
702
- return self::post('check_license', [
703
- 'item_id' => (string) self::PRODUCT_ID,
704
- 'license_key' => $key,
705
- 'site_url' => $instanceId,
706
- 'device_fingerprint' => $fingerprint,
707
- ]);
708
- }
709
-
710
- public static function deactivate(string $key, string $instanceId): array
711
- {
712
- return self::post('deactivate_license', [
713
- 'item_id' => (string) self::PRODUCT_ID,
714
- 'license_key' => $key,
715
- 'site_url' => $instanceId,
716
- ]);
717
- }
718
-
719
- /** The signed offline licence; pass it to verifyToken(). */
720
- public static function token(array $state): ?string
721
- {
722
- return $state['license_token'] ?? null;
723
- }
724
-
725
- /** Valid only when status === 'valid'. key_mismatch arrives as 200 + success. */
726
- public static function isValid(array $state): bool
727
- {
728
- return ($state['status'] ?? '') === 'valid';
729
- }
730
-
731
- public static function verifyToken(string $token, string $publicKeyPem): ?array
732
- {
733
- $parts = explode('.', $token);
734
-
735
- if (count($parts) !== 3) {
736
- return null;
737
- }
738
-
739
- $signature = self::base64UrlDecode($parts[2]);
740
-
741
- if ($signature === null || openssl_verify($parts[0] . '.' . $parts[1], $signature, $publicKeyPem, OPENSSL_ALGO_SHA256) !== 1) {
742
- return null;
743
- }
744
-
745
- $payload = self::base64UrlDecode($parts[1]);
746
- $claims = $payload === null ? null : json_decode($payload, true);
747
-
748
- if (!is_array($claims)) {
749
- return null;
750
- }
751
-
752
- if (isset($claims['exp']) && (int) $claims['exp'] < time()) {
753
- return null;
754
- }
755
-
756
- return $claims;
757
- }
758
-
759
- /**
760
- * Bind the token to THIS installation.
761
- *
762
- * verifyToken proves the store signed it and that it has not expired. It
763
- * does not prove the token was issued for this machine or this product, so
764
- * a copied token passes. claims.fp is a server-side HMAC and cannot be
765
- * recomputed here, so claims.ins - the install id sent as site_url - is the
766
- * binding a client is able to check.
767
- *
768
- * @return array{ok:bool,reason?:string,claims?:array}
769
- */
770
- public static function entitlement(string $token, string $publicKeyPem, string $installId = '', int $productId = 0): array
771
- {
772
- $claims = self::verifyToken($token, $publicKeyPem);
773
-
774
- if ($claims === null) {
775
- return ['ok' => false, 'reason' => 'invalid_or_expired'];
776
- }
777
-
778
- if ($productId > 0 && (int) ($claims['prod'] ?? -1) !== $productId) {
779
- return ['ok' => false, 'reason' => 'wrong_product'];
780
- }
781
-
782
- if ($installId !== '' && isset($claims['ins']) && (string) $claims['ins'] !== $installId) {
783
- return ['ok' => false, 'reason' => 'wrong_install'];
784
- }
785
-
786
- return ['ok' => true, 'claims' => $claims];
787
- }
788
-
789
- public static function latestRelease(string $key, string $currentVersion, string $platform = 'any'): array
790
- {
791
- $query = http_build_query([
792
- 'product_id' => self::PRODUCT_ID,
793
- 'platform' => $platform,
794
- 'current_version' => $currentVersion,
795
- 'license_key' => $key,
796
- ]);
797
-
798
- $body = @file_get_contents(self::STORE . '?fluent-cart=fastr_release_latest&' . $query);
799
- $json = is_string($body) ? json_decode($body, true) : null;
800
-
801
- return is_array($json) ? $json : [];
802
- }
803
-
804
- public static function reportUsage(string $key, string $metric, int $quantity, string $idempotencyKey): array
805
- {
806
- return self::post('fastr_usage_report', [
807
- 'license_key' => $key,
808
- 'metric' => $metric,
809
- 'quantity' => (string) $quantity,
810
- 'idempotency_key' => $idempotencyKey,
811
- ]);
812
- }
813
-
814
- private static function base64UrlDecode(string $value): ?string
815
- {
816
- $padded = strtr($value, '-_', '+/');
817
- $padded .= str_repeat('=', (4 - strlen($padded) % 4) % 4);
818
-
819
- $decoded = base64_decode($padded, true);
820
-
821
- return $decoded === false ? null : $decoded;
822
- }
823
- }
656
+ return `<?php
657
+
658
+ declare(strict_types=1);
659
+
660
+ ${banner(appName, 'PHP (no WordPress)', 'FastrLicense.php', base, productId)}
661
+
662
+ final class FastrLicense
663
+ {
664
+ public const STORE = '${base}';
665
+ public const PRODUCT_ID = ${productId};
666
+
667
+ private static function post(string $verb, array $fields): array
668
+ {
669
+ $handle = curl_init(self::STORE . '?fluent-cart=' . $verb);
670
+ curl_setopt_array($handle, [
671
+ CURLOPT_POST => true,
672
+ CURLOPT_POSTFIELDS => http_build_query($fields),
673
+ CURLOPT_RETURNTRANSFER => true,
674
+ CURLOPT_TIMEOUT => 15,
675
+ ]);
676
+
677
+ $body = curl_exec($handle);
678
+ curl_close($handle);
679
+
680
+ $json = is_string($body) ? json_decode($body, true) : null;
681
+
682
+ return is_array($json) ? $json : [];
683
+ }
684
+
685
+ public static function activate(string $key, string $instanceId, string $fingerprint, string $email): array
686
+ {
687
+ return self::post('activate_license', [
688
+ 'item_id' => (string) self::PRODUCT_ID,
689
+ 'license_key' => trim($key),
690
+ 'site_url' => $instanceId,
691
+ 'device_fingerprint' => $fingerprint,
692
+ 'device_name' => gethostname() ?: 'desktop',
693
+ 'device_type' => 'CLI (PHP)',
694
+ 'os' => PHP_OS_FAMILY,
695
+ 'email' => $email,
696
+ 'server_version' => '1.0.0',
697
+ ]);
698
+ }
699
+
700
+ public static function check(string $key, string $instanceId, string $fingerprint): array
701
+ {
702
+ return self::post('check_license', [
703
+ 'item_id' => (string) self::PRODUCT_ID,
704
+ 'license_key' => $key,
705
+ 'site_url' => $instanceId,
706
+ 'device_fingerprint' => $fingerprint,
707
+ ]);
708
+ }
709
+
710
+ public static function deactivate(string $key, string $instanceId): array
711
+ {
712
+ return self::post('deactivate_license', [
713
+ 'item_id' => (string) self::PRODUCT_ID,
714
+ 'license_key' => $key,
715
+ 'site_url' => $instanceId,
716
+ ]);
717
+ }
718
+
719
+ /** The signed offline licence; pass it to verifyToken(). */
720
+ public static function token(array $state): ?string
721
+ {
722
+ return $state['license_token'] ?? null;
723
+ }
724
+
725
+ /** Valid only when status === 'valid'. key_mismatch arrives as 200 + success. */
726
+ public static function isValid(array $state): bool
727
+ {
728
+ return ($state['status'] ?? '') === 'valid';
729
+ }
730
+
731
+ public static function verifyToken(string $token, string $publicKeyPem): ?array
732
+ {
733
+ $parts = explode('.', $token);
734
+
735
+ if (count($parts) !== 3) {
736
+ return null;
737
+ }
738
+
739
+ $signature = self::base64UrlDecode($parts[2]);
740
+
741
+ if ($signature === null || openssl_verify($parts[0] . '.' . $parts[1], $signature, $publicKeyPem, OPENSSL_ALGO_SHA256) !== 1) {
742
+ return null;
743
+ }
744
+
745
+ $payload = self::base64UrlDecode($parts[1]);
746
+ $claims = $payload === null ? null : json_decode($payload, true);
747
+
748
+ if (!is_array($claims)) {
749
+ return null;
750
+ }
751
+
752
+ if (isset($claims['exp']) && (int) $claims['exp'] < time()) {
753
+ return null;
754
+ }
755
+
756
+ return $claims;
757
+ }
758
+
759
+ /**
760
+ * Bind the token to THIS installation.
761
+ *
762
+ * verifyToken proves the store signed it and that it has not expired. It
763
+ * does not prove the token was issued for this machine or this product, so
764
+ * a copied token passes. claims.fp is a server-side HMAC and cannot be
765
+ * recomputed here, so claims.ins - the install id sent as site_url - is the
766
+ * binding a client is able to check.
767
+ *
768
+ * @return array{ok:bool,reason?:string,claims?:array}
769
+ */
770
+ public static function entitlement(string $token, string $publicKeyPem, string $installId = '', int $productId = 0): array
771
+ {
772
+ $claims = self::verifyToken($token, $publicKeyPem);
773
+
774
+ if ($claims === null) {
775
+ return ['ok' => false, 'reason' => 'invalid_or_expired'];
776
+ }
777
+
778
+ if ($productId > 0 && (int) ($claims['prod'] ?? -1) !== $productId) {
779
+ return ['ok' => false, 'reason' => 'wrong_product'];
780
+ }
781
+
782
+ if ($installId !== '' && isset($claims['ins']) && (string) $claims['ins'] !== $installId) {
783
+ return ['ok' => false, 'reason' => 'wrong_install'];
784
+ }
785
+
786
+ return ['ok' => true, 'claims' => $claims];
787
+ }
788
+
789
+ public static function latestRelease(string $key, string $currentVersion, string $platform = 'any'): array
790
+ {
791
+ $query = http_build_query([
792
+ 'product_id' => self::PRODUCT_ID,
793
+ 'platform' => $platform,
794
+ 'current_version' => $currentVersion,
795
+ 'license_key' => $key,
796
+ ]);
797
+
798
+ $body = @file_get_contents(self::STORE . '?fluent-cart=fastr_release_latest&' . $query);
799
+ $json = is_string($body) ? json_decode($body, true) : null;
800
+
801
+ return is_array($json) ? $json : [];
802
+ }
803
+
804
+ public static function reportUsage(string $key, string $metric, int $quantity, string $idempotencyKey): array
805
+ {
806
+ return self::post('fastr_usage_report', [
807
+ 'license_key' => $key,
808
+ 'metric' => $metric,
809
+ 'quantity' => (string) $quantity,
810
+ 'idempotency_key' => $idempotencyKey,
811
+ ]);
812
+ }
813
+
814
+ private static function base64UrlDecode(string $value): ?string
815
+ {
816
+ $padded = strtr($value, '-_', '+/');
817
+ $padded .= str_repeat('=', (4 - strlen($padded) % 4) % 4);
818
+
819
+ $decoded = base64_decode($padded, true);
820
+
821
+ return $decoded === false ? null : $decoded;
822
+ }
823
+ }
824
824
  `;
825
825
  }
826
- return `${banner(appName, 'C (libcurl + OpenSSL)', 'fastr_license.c', base, productId)}
827
- #include <curl/curl.h>
828
- #include <openssl/bio.h>
829
- #include <openssl/evp.h>
830
- #include <openssl/pem.h>
831
- #include <stdio.h>
832
- #include <stdlib.h>
833
- #include <string.h>
834
-
835
- #define FASTR_STORE "${base}"
836
- #define FASTR_PRODUCT ${productId}
837
-
838
- /* The activate/check body carries "license_token"; hand it to
839
- * fastr_verify_token() so the app can run offline without a heartbeat. */
840
- struct buffer { char *data; size_t size; };
841
-
842
- static size_t on_body(void *chunk, size_t size, size_t count, void *user)
843
- {
844
- struct buffer *buffer = (struct buffer *) user;
845
- size_t total = size * count;
846
-
847
- char *grown = realloc(buffer->data, buffer->size + total + 1);
848
- if (grown == NULL) return 0;
849
-
850
- buffer->data = grown;
851
- memcpy(buffer->data + buffer->size, chunk, total);
852
- buffer->size += total;
853
- buffer->data[buffer->size] = '\\0';
854
-
855
- return total;
856
- }
857
-
858
- /* POST a form to ?fluent-cart=<verb>. Caller frees the returned buffer. */
859
- static char *fastr_post(const char *verb, const char *form)
860
- {
861
- CURL *curl = curl_easy_init();
862
- if (curl == NULL) return NULL;
863
-
864
- struct buffer response = { NULL, 0 };
865
- char url[512];
866
- snprintf(url, sizeof(url), "%s?fluent-cart=%s", FASTR_STORE, verb);
867
-
868
- curl_easy_setopt(curl, CURLOPT_URL, url);
869
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, form);
870
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, on_body);
871
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
872
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15L);
873
-
874
- CURLcode result = curl_easy_perform(curl);
875
- curl_easy_cleanup(curl);
876
-
877
- if (result != CURLE_OK) { free(response.data); return NULL; }
878
-
879
- return response.data;
880
- }
881
-
882
- /* Valid only when the body carries "status":"valid". key_mismatch and
883
- * invalid_activation arrive as HTTP 200 with success=true. */
884
- static int fastr_status_is_valid(const char *json)
885
- {
886
- return json != NULL && strstr(json, "\\"status\\":\\"valid\\"") != NULL;
887
- }
888
-
889
- char *fastr_activate(const char *license_key, const char *instance_id,
890
- const char *fingerprint, const char *email)
891
- {
892
- char form[1024];
893
- snprintf(form, sizeof(form),
894
- "item_id=%d&license_key=%s&site_url=%s&device_fingerprint=%s"
895
- "&device_type=CLI%%20(C)&server_version=1.0.0&email=%s",
896
- FASTR_PRODUCT, license_key, instance_id, fingerprint, email);
897
-
898
- return fastr_post("activate_license", form);
899
- }
900
-
901
- char *fastr_check(const char *license_key, const char *instance_id, const char *fingerprint)
902
- {
903
- char form[512];
904
- snprintf(form, sizeof(form),
905
- "item_id=%d&license_key=%s&site_url=%s&device_fingerprint=%s",
906
- FASTR_PRODUCT, license_key, instance_id, fingerprint);
907
-
908
- return fastr_post("check_license", form);
909
- }
910
-
911
- char *fastr_deactivate(const char *license_key, const char *instance_id)
912
- {
913
- char form[512];
914
- snprintf(form, sizeof(form),
915
- "item_id=%d&license_key=%s&site_url=%s",
916
- FASTR_PRODUCT, license_key, instance_id);
917
-
918
- return fastr_post("deactivate_license", form);
919
- }
920
-
921
- char *fastr_report_usage(const char *license_key, const char *metric,
922
- int quantity, const char *idempotency_key)
923
- {
924
- char form[512];
925
- snprintf(form, sizeof(form),
926
- "license_key=%s&metric=%s&quantity=%d&idempotency_key=%s",
927
- license_key, metric, quantity, idempotency_key);
928
-
929
- return fastr_post("fastr_usage_report", form);
930
- }
931
-
932
- char *fastr_latest_release(const char *license_key, const char *current_version)
933
- {
934
- CURL *curl = curl_easy_init();
935
- if (curl == NULL) return NULL;
936
-
937
- struct buffer response = { NULL, 0 };
938
- char url[512];
939
- snprintf(url, sizeof(url),
940
- "%s?fluent-cart=fastr_release_latest&product_id=%d"
941
- "&platform=any&current_version=%s&license_key=%s",
942
- FASTR_STORE, FASTR_PRODUCT, current_version, license_key);
943
-
944
- curl_easy_setopt(curl, CURLOPT_URL, url);
945
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, on_body);
946
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
947
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15L);
948
-
949
- CURLcode result = curl_easy_perform(curl);
950
- curl_easy_cleanup(curl);
951
-
952
- if (result != CURLE_OK) { free(response.data); return NULL; }
953
-
954
- return response.data;
955
- }
956
-
957
- /* RS256 verification. Returns 1 when the signature is good. */
958
- int fastr_verify_token(const char *token, const char *public_key_pem)
959
- {
960
- /* strdup allocates exactly strlen+1, and the base64 padding below is
961
- * strcat-ed onto a slice of this buffer, so it needs headroom. */
962
- size_t token_size = strlen(token) + 8;
963
- char *copy = (char *) malloc(token_size);
964
- if (copy == NULL) return 0;
965
- memcpy(copy, token, token_size > 1 ? strlen(token) + 1 : 1);
966
-
967
- char *header = strtok(copy, ".");
968
- char *payload = strtok(NULL, ".");
969
- char *signature_part = strtok(NULL, ".");
970
-
971
- if (header == NULL || payload == NULL || signature_part == NULL) { free(copy); return 0; }
972
-
973
- char signed_input[4096];
974
- snprintf(signed_input, sizeof(signed_input), "%s.%s", header, payload);
975
-
976
- BIO *bio = BIO_new_mem_buf(public_key_pem, -1);
977
- if (bio == NULL) { free(copy); return 0; }
978
-
979
- EVP_PKEY *key = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
980
- BIO_free(bio);
981
-
982
- if (key == NULL) { free(copy); return 0; }
983
-
984
- for (char *p = signature_part; *p; p++) {
985
- if (*p == '-') *p = '+';
986
- else if (*p == '_') *p = '/';
987
- }
988
-
989
- size_t signature_len = strlen(signature_part);
990
- size_t padding = (4 - signature_len % 4) % 4;
991
- for (size_t i = 0; i < padding; i++) strcat(signature_part, "=");
992
-
993
- unsigned char signature[1024];
994
- int decoded = EVP_DecodeBlock(signature, (unsigned char *) signature_part, (int) strlen(signature_part));
995
-
996
- if (decoded < 0) { EVP_PKEY_free(key); free(copy); return 0; }
997
-
998
- decoded -= (int) padding;
999
-
1000
- EVP_MD_CTX *ctx = EVP_MD_CTX_new();
1001
- int ok = 0;
1002
-
1003
- if (ctx != NULL &&
1004
- EVP_DigestVerifyInit(ctx, NULL, EVP_sha256(), NULL, key) == 1 &&
1005
- EVP_DigestVerifyUpdate(ctx, signed_input, strlen(signed_input)) == 1) {
1006
- ok = EVP_DigestVerifyFinal(ctx, signature, (size_t) decoded) == 1;
1007
- }
1008
-
1009
- if (ctx != NULL) EVP_MD_CTX_free(ctx);
1010
- EVP_PKEY_free(key);
1011
- free(copy);
1012
-
1013
- return ok;
1014
- }
1015
-
1016
- /* Reads a top-level claim from a decoded JWT payload: a quoted string or a
1017
- * bare integer. Returns 0 when the claim is absent. */
1018
- static int fastr_claim(const char *json, const char *name, char *out, size_t out_size)
1019
- {
1020
- if (json == NULL || name == NULL || out == NULL || out_size == 0) return 0;
1021
-
1022
- char needle[64];
1023
- int written = snprintf(needle, sizeof(needle), "\\"%s\\":", name);
1024
- if (written <= 0 || (size_t) written >= sizeof(needle)) return 0;
1025
-
1026
- const char *at = strstr(json, needle);
1027
- if (at == NULL) return 0;
1028
-
1029
- at += strlen(needle);
1030
-
1031
- size_t i = 0;
1032
-
1033
- if (*at == '"') {
1034
- ++at;
1035
- while (at[i] != '"' && at[i] != '\0' && i + 1 < out_size) {
1036
- out[i] = at[i];
1037
- ++i;
1038
- }
1039
- } else {
1040
- while ((at[i] == '-' || (at[i] >= '0' && at[i] <= '9')) && i + 1 < out_size) {
1041
- out[i] = at[i];
1042
- ++i;
1043
- }
1044
- }
1045
-
1046
- out[i] = '\0';
1047
-
1048
- return i > 0 ? 1 : 0;
1049
- }
1050
-
1051
- /* Returns NULL when the token entitles this install and product to run,
1052
- * otherwise a short reason.
1053
- *
1054
- * fastr_verify_token() proves the store signed the token and that it has not
1055
- * expired. It does not prove the token was issued for this machine or this
1056
- * product, so a token copied from another install passes it. claims.ins - the
1057
- * install id sent as site_url - is the binding a client can check. claims.fp is
1058
- * a server-side HMAC and cannot be recomputed here.
1059
- */
1060
- const char *fastr_entitlement(const char *token, const char *public_key_pem, const char *install_id, int product_id)
1061
- {
1062
- if (!fastr_verify_token(token, public_key_pem)) return "invalid_or_expired";
1063
-
1064
- size_t token_len = strlen(token);
1065
- char *copy = (char *) malloc(token_len + 8);
1066
-
1067
- if (copy == NULL) return "invalid_or_expired";
1068
-
1069
- memcpy(copy, token, token_len + 1);
1070
-
1071
- char *first = strchr(copy, '.');
1072
- if (first == NULL) { free(copy); return "invalid_or_expired"; }
1073
-
1074
- char *payload = first + 1;
1075
- char *second = strchr(payload, '.');
1076
-
1077
- if (second == NULL) { free(copy); return "invalid_or_expired"; }
1078
-
1079
- *second = '\0';
1080
-
1081
- for (char *p = payload; *p; ++p) {
1082
- if (*p == '-') *p = '+';
1083
- else if (*p == '_') *p = '/';
1084
- }
1085
-
1086
- size_t payload_len = strlen(payload);
1087
- size_t padding = (4 - payload_len % 4) % 4;
1088
-
1089
- for (size_t i = 0; i < padding; ++i) strcat(payload, "=");
1090
-
1091
- unsigned char decoded[8192];
1092
- int size = EVP_DecodeBlock(decoded, (unsigned char *) payload, (int) strlen(payload));
1093
-
1094
- free(copy);
1095
-
1096
- if (size <= 0) return "invalid_or_expired";
1097
-
1098
- size -= (int) padding;
1099
-
1100
- if (size <= 0 || (size_t) size >= sizeof(decoded)) return "invalid_or_expired";
1101
-
1102
- decoded[size] = '\0';
1103
-
1104
- const char *json = (const char *) decoded;
1105
- char claim[160];
1106
-
1107
- if (!fastr_claim(json, "exp", claim, sizeof(claim))) return "invalid_or_expired";
1108
- if (atoll(claim) <= 0 || atoll(claim) <= (long long) time(NULL)) return "invalid_or_expired";
1109
-
1110
- if (product_id > 0) {
1111
- if (!fastr_claim(json, "prod", claim, sizeof(claim))) return "wrong_product";
1112
- if (atoi(claim) != product_id) return "wrong_product";
1113
- }
1114
-
1115
- if (install_id != NULL && install_id[0] != '\0') {
1116
- if (fastr_claim(json, "ins", claim, sizeof(claim)) && strcmp(claim, install_id) != 0) {
1117
- return "wrong_install";
1118
- }
1119
- }
1120
-
1121
- return NULL;
1122
- }
826
+ return `${banner(appName, 'C (libcurl + OpenSSL)', 'fastr_license.c', base, productId)}
827
+ #include <curl/curl.h>
828
+ #include <openssl/bio.h>
829
+ #include <openssl/evp.h>
830
+ #include <openssl/pem.h>
831
+ #include <stdio.h>
832
+ #include <stdlib.h>
833
+ #include <string.h>
834
+
835
+ #define FASTR_STORE "${base}"
836
+ #define FASTR_PRODUCT ${productId}
837
+
838
+ /* The activate/check body carries "license_token"; hand it to
839
+ * fastr_verify_token() so the app can run offline without a heartbeat. */
840
+ struct buffer { char *data; size_t size; };
841
+
842
+ static size_t on_body(void *chunk, size_t size, size_t count, void *user)
843
+ {
844
+ struct buffer *buffer = (struct buffer *) user;
845
+ size_t total = size * count;
846
+
847
+ char *grown = realloc(buffer->data, buffer->size + total + 1);
848
+ if (grown == NULL) return 0;
849
+
850
+ buffer->data = grown;
851
+ memcpy(buffer->data + buffer->size, chunk, total);
852
+ buffer->size += total;
853
+ buffer->data[buffer->size] = '\\0';
854
+
855
+ return total;
856
+ }
857
+
858
+ /* POST a form to ?fluent-cart=<verb>. Caller frees the returned buffer. */
859
+ static char *fastr_post(const char *verb, const char *form)
860
+ {
861
+ CURL *curl = curl_easy_init();
862
+ if (curl == NULL) return NULL;
863
+
864
+ struct buffer response = { NULL, 0 };
865
+ char url[512];
866
+ snprintf(url, sizeof(url), "%s?fluent-cart=%s", FASTR_STORE, verb);
867
+
868
+ curl_easy_setopt(curl, CURLOPT_URL, url);
869
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, form);
870
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, on_body);
871
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
872
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15L);
873
+
874
+ CURLcode result = curl_easy_perform(curl);
875
+ curl_easy_cleanup(curl);
876
+
877
+ if (result != CURLE_OK) { free(response.data); return NULL; }
878
+
879
+ return response.data;
880
+ }
881
+
882
+ /* Valid only when the body carries "status":"valid". key_mismatch and
883
+ * invalid_activation arrive as HTTP 200 with success=true. */
884
+ static int fastr_status_is_valid(const char *json)
885
+ {
886
+ return json != NULL && strstr(json, "\\"status\\":\\"valid\\"") != NULL;
887
+ }
888
+
889
+ char *fastr_activate(const char *license_key, const char *instance_id,
890
+ const char *fingerprint, const char *email)
891
+ {
892
+ char form[1024];
893
+ snprintf(form, sizeof(form),
894
+ "item_id=%d&license_key=%s&site_url=%s&device_fingerprint=%s"
895
+ "&device_type=CLI%%20(C)&server_version=1.0.0&email=%s",
896
+ FASTR_PRODUCT, license_key, instance_id, fingerprint, email);
897
+
898
+ return fastr_post("activate_license", form);
899
+ }
900
+
901
+ char *fastr_check(const char *license_key, const char *instance_id, const char *fingerprint)
902
+ {
903
+ char form[512];
904
+ snprintf(form, sizeof(form),
905
+ "item_id=%d&license_key=%s&site_url=%s&device_fingerprint=%s",
906
+ FASTR_PRODUCT, license_key, instance_id, fingerprint);
907
+
908
+ return fastr_post("check_license", form);
909
+ }
910
+
911
+ char *fastr_deactivate(const char *license_key, const char *instance_id)
912
+ {
913
+ char form[512];
914
+ snprintf(form, sizeof(form),
915
+ "item_id=%d&license_key=%s&site_url=%s",
916
+ FASTR_PRODUCT, license_key, instance_id);
917
+
918
+ return fastr_post("deactivate_license", form);
919
+ }
920
+
921
+ char *fastr_report_usage(const char *license_key, const char *metric,
922
+ int quantity, const char *idempotency_key)
923
+ {
924
+ char form[512];
925
+ snprintf(form, sizeof(form),
926
+ "license_key=%s&metric=%s&quantity=%d&idempotency_key=%s",
927
+ license_key, metric, quantity, idempotency_key);
928
+
929
+ return fastr_post("fastr_usage_report", form);
930
+ }
931
+
932
+ char *fastr_latest_release(const char *license_key, const char *current_version)
933
+ {
934
+ CURL *curl = curl_easy_init();
935
+ if (curl == NULL) return NULL;
936
+
937
+ struct buffer response = { NULL, 0 };
938
+ char url[512];
939
+ snprintf(url, sizeof(url),
940
+ "%s?fluent-cart=fastr_release_latest&product_id=%d"
941
+ "&platform=any&current_version=%s&license_key=%s",
942
+ FASTR_STORE, FASTR_PRODUCT, current_version, license_key);
943
+
944
+ curl_easy_setopt(curl, CURLOPT_URL, url);
945
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, on_body);
946
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
947
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15L);
948
+
949
+ CURLcode result = curl_easy_perform(curl);
950
+ curl_easy_cleanup(curl);
951
+
952
+ if (result != CURLE_OK) { free(response.data); return NULL; }
953
+
954
+ return response.data;
955
+ }
956
+
957
+ /* RS256 verification. Returns 1 when the signature is good. */
958
+ int fastr_verify_token(const char *token, const char *public_key_pem)
959
+ {
960
+ /* strdup allocates exactly strlen+1, and the base64 padding below is
961
+ * strcat-ed onto a slice of this buffer, so it needs headroom. */
962
+ size_t token_size = strlen(token) + 8;
963
+ char *copy = (char *) malloc(token_size);
964
+ if (copy == NULL) return 0;
965
+ memcpy(copy, token, token_size > 1 ? strlen(token) + 1 : 1);
966
+
967
+ char *header = strtok(copy, ".");
968
+ char *payload = strtok(NULL, ".");
969
+ char *signature_part = strtok(NULL, ".");
970
+
971
+ if (header == NULL || payload == NULL || signature_part == NULL) { free(copy); return 0; }
972
+
973
+ char signed_input[4096];
974
+ snprintf(signed_input, sizeof(signed_input), "%s.%s", header, payload);
975
+
976
+ BIO *bio = BIO_new_mem_buf(public_key_pem, -1);
977
+ if (bio == NULL) { free(copy); return 0; }
978
+
979
+ EVP_PKEY *key = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
980
+ BIO_free(bio);
981
+
982
+ if (key == NULL) { free(copy); return 0; }
983
+
984
+ for (char *p = signature_part; *p; p++) {
985
+ if (*p == '-') *p = '+';
986
+ else if (*p == '_') *p = '/';
987
+ }
988
+
989
+ size_t signature_len = strlen(signature_part);
990
+ size_t padding = (4 - signature_len % 4) % 4;
991
+ for (size_t i = 0; i < padding; i++) strcat(signature_part, "=");
992
+
993
+ unsigned char signature[1024];
994
+ int decoded = EVP_DecodeBlock(signature, (unsigned char *) signature_part, (int) strlen(signature_part));
995
+
996
+ if (decoded < 0) { EVP_PKEY_free(key); free(copy); return 0; }
997
+
998
+ decoded -= (int) padding;
999
+
1000
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
1001
+ int ok = 0;
1002
+
1003
+ if (ctx != NULL &&
1004
+ EVP_DigestVerifyInit(ctx, NULL, EVP_sha256(), NULL, key) == 1 &&
1005
+ EVP_DigestVerifyUpdate(ctx, signed_input, strlen(signed_input)) == 1) {
1006
+ ok = EVP_DigestVerifyFinal(ctx, signature, (size_t) decoded) == 1;
1007
+ }
1008
+
1009
+ if (ctx != NULL) EVP_MD_CTX_free(ctx);
1010
+ EVP_PKEY_free(key);
1011
+ free(copy);
1012
+
1013
+ return ok;
1014
+ }
1015
+
1016
+ /* Reads a top-level claim from a decoded JWT payload: a quoted string or a
1017
+ * bare integer. Returns 0 when the claim is absent. */
1018
+ static int fastr_claim(const char *json, const char *name, char *out, size_t out_size)
1019
+ {
1020
+ if (json == NULL || name == NULL || out == NULL || out_size == 0) return 0;
1021
+
1022
+ char needle[64];
1023
+ int written = snprintf(needle, sizeof(needle), "\\"%s\\":", name);
1024
+ if (written <= 0 || (size_t) written >= sizeof(needle)) return 0;
1025
+
1026
+ const char *at = strstr(json, needle);
1027
+ if (at == NULL) return 0;
1028
+
1029
+ at += strlen(needle);
1030
+
1031
+ size_t i = 0;
1032
+
1033
+ if (*at == '"') {
1034
+ ++at;
1035
+ while (at[i] != '"' && at[i] != '\0' && i + 1 < out_size) {
1036
+ out[i] = at[i];
1037
+ ++i;
1038
+ }
1039
+ } else {
1040
+ while ((at[i] == '-' || (at[i] >= '0' && at[i] <= '9')) && i + 1 < out_size) {
1041
+ out[i] = at[i];
1042
+ ++i;
1043
+ }
1044
+ }
1045
+
1046
+ out[i] = '\0';
1047
+
1048
+ return i > 0 ? 1 : 0;
1049
+ }
1050
+
1051
+ /* Returns NULL when the token entitles this install and product to run,
1052
+ * otherwise a short reason.
1053
+ *
1054
+ * fastr_verify_token() proves the store signed the token and that it has not
1055
+ * expired. It does not prove the token was issued for this machine or this
1056
+ * product, so a token copied from another install passes it. claims.ins - the
1057
+ * install id sent as site_url - is the binding a client can check. claims.fp is
1058
+ * a server-side HMAC and cannot be recomputed here.
1059
+ */
1060
+ const char *fastr_entitlement(const char *token, const char *public_key_pem, const char *install_id, int product_id)
1061
+ {
1062
+ if (!fastr_verify_token(token, public_key_pem)) return "invalid_or_expired";
1063
+
1064
+ size_t token_len = strlen(token);
1065
+ char *copy = (char *) malloc(token_len + 8);
1066
+
1067
+ if (copy == NULL) return "invalid_or_expired";
1068
+
1069
+ memcpy(copy, token, token_len + 1);
1070
+
1071
+ char *first = strchr(copy, '.');
1072
+ if (first == NULL) { free(copy); return "invalid_or_expired"; }
1073
+
1074
+ char *payload = first + 1;
1075
+ char *second = strchr(payload, '.');
1076
+
1077
+ if (second == NULL) { free(copy); return "invalid_or_expired"; }
1078
+
1079
+ *second = '\0';
1080
+
1081
+ for (char *p = payload; *p; ++p) {
1082
+ if (*p == '-') *p = '+';
1083
+ else if (*p == '_') *p = '/';
1084
+ }
1085
+
1086
+ size_t payload_len = strlen(payload);
1087
+ size_t padding = (4 - payload_len % 4) % 4;
1088
+
1089
+ for (size_t i = 0; i < padding; ++i) strcat(payload, "=");
1090
+
1091
+ unsigned char decoded[8192];
1092
+ int size = EVP_DecodeBlock(decoded, (unsigned char *) payload, (int) strlen(payload));
1093
+
1094
+ free(copy);
1095
+
1096
+ if (size <= 0) return "invalid_or_expired";
1097
+
1098
+ size -= (int) padding;
1099
+
1100
+ if (size <= 0 || (size_t) size >= sizeof(decoded)) return "invalid_or_expired";
1101
+
1102
+ decoded[size] = '\0';
1103
+
1104
+ const char *json = (const char *) decoded;
1105
+ char claim[160];
1106
+
1107
+ if (!fastr_claim(json, "exp", claim, sizeof(claim))) return "invalid_or_expired";
1108
+ if (atoll(claim) <= 0 || atoll(claim) <= (long long) time(NULL)) return "invalid_or_expired";
1109
+
1110
+ if (product_id > 0) {
1111
+ if (!fastr_claim(json, "prod", claim, sizeof(claim))) return "wrong_product";
1112
+ if (atoi(claim) != product_id) return "wrong_product";
1113
+ }
1114
+
1115
+ if (install_id != NULL && install_id[0] != '\0') {
1116
+ if (fastr_claim(json, "ins", claim, sizeof(claim)) && strcmp(claim, install_id) != 0) {
1117
+ return "wrong_install";
1118
+ }
1119
+ }
1120
+
1121
+ return NULL;
1122
+ }
1123
1123
  `;
1124
1124
  }
1125
1125
  //# sourceMappingURL=templates-native.js.map