@buoy-gg/license 7.0.41 → 7.0.42

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 (86) hide show
  1. package/lib/commonjs/DeviceRegistrationModal.js +1 -1
  2. package/lib/commonjs/LicenseManager.js +16 -16
  3. package/lib/commonjs/accountAccess.js +1 -1
  4. package/lib/commonjs/api.js +1 -1
  5. package/lib/commonjs/cacheSignature.js +15 -15
  6. package/lib/commonjs/config.js +16 -16
  7. package/lib/commonjs/freeToken.js +5 -5
  8. package/lib/commonjs/hooks.js +16 -16
  9. package/lib/commonjs/index.js +2 -2
  10. package/lib/commonjs/index.web.js +1 -1
  11. package/lib/commonjs/realNow.js +1 -0
  12. package/lib/commonjs/storage.js +1 -1
  13. package/lib/commonjs/tier.js +16 -16
  14. package/lib/commonjs/weekendPro.js +18 -18
  15. package/lib/module/DeviceRegistrationModal.js +1 -1
  16. package/lib/module/LicenseManager.js +15 -15
  17. package/lib/module/accountAccess.js +1 -1
  18. package/lib/module/api.js +1 -1
  19. package/lib/module/cacheSignature.js +15 -15
  20. package/lib/module/config.js +16 -16
  21. package/lib/module/device-info.web.js +1 -1
  22. package/lib/module/freeToken.js +5 -5
  23. package/lib/module/hooks.js +16 -16
  24. package/lib/module/index.js +17 -17
  25. package/lib/module/index.web.js +17 -17
  26. package/lib/module/realNow.js +1 -0
  27. package/lib/module/storage.js +1 -1
  28. package/lib/module/storage.web.js +1 -1
  29. package/lib/module/tier.js +16 -16
  30. package/lib/module/weekendPro.js +17 -17
  31. package/lib/typescript/commonjs/realNow.d.ts +11 -0
  32. package/lib/typescript/module/realNow.d.ts +11 -0
  33. package/lib/web/chunks/LicenseManager-7D2GGBCB.mjs +1 -0
  34. package/lib/web/chunks/chunk-ZSTLYSNF.mjs +68 -0
  35. package/lib/web/index.mjs +3 -7
  36. package/package.json +1 -1
  37. package/lib/typescript/commonjs/DeviceRegistrationModal.d.ts.map +0 -1
  38. package/lib/typescript/commonjs/LicenseManager.d.ts.map +0 -1
  39. package/lib/typescript/commonjs/accountAccess.d.ts.map +0 -1
  40. package/lib/typescript/commonjs/api.d.ts.map +0 -1
  41. package/lib/typescript/commonjs/cacheSignature.d.ts.map +0 -1
  42. package/lib/typescript/commonjs/config.d.ts.map +0 -1
  43. package/lib/typescript/commonjs/device-info.d.ts.map +0 -1
  44. package/lib/typescript/commonjs/device-info.web.d.ts.map +0 -1
  45. package/lib/typescript/commonjs/fingerprint.d.ts.map +0 -1
  46. package/lib/typescript/commonjs/fingerprint.web.d.ts.map +0 -1
  47. package/lib/typescript/commonjs/foreground.d.ts.map +0 -1
  48. package/lib/typescript/commonjs/foreground.web.d.ts.map +0 -1
  49. package/lib/typescript/commonjs/freeToken.d.ts.map +0 -1
  50. package/lib/typescript/commonjs/headless.d.ts.map +0 -1
  51. package/lib/typescript/commonjs/hooks.d.ts.map +0 -1
  52. package/lib/typescript/commonjs/index.d.ts.map +0 -1
  53. package/lib/typescript/commonjs/index.web.d.ts.map +0 -1
  54. package/lib/typescript/commonjs/storage.d.ts.map +0 -1
  55. package/lib/typescript/commonjs/storage.web.d.ts.map +0 -1
  56. package/lib/typescript/commonjs/tier.d.ts.map +0 -1
  57. package/lib/typescript/commonjs/types.d.ts.map +0 -1
  58. package/lib/typescript/commonjs/weekendPro.d.ts.map +0 -1
  59. package/lib/typescript/module/DeviceRegistrationModal.d.ts.map +0 -1
  60. package/lib/typescript/module/LicenseManager.d.ts.map +0 -1
  61. package/lib/typescript/module/accountAccess.d.ts.map +0 -1
  62. package/lib/typescript/module/api.d.ts.map +0 -1
  63. package/lib/typescript/module/cacheSignature.d.ts.map +0 -1
  64. package/lib/typescript/module/config.d.ts.map +0 -1
  65. package/lib/typescript/module/device-info.d.ts.map +0 -1
  66. package/lib/typescript/module/device-info.web.d.ts.map +0 -1
  67. package/lib/typescript/module/fingerprint.d.ts.map +0 -1
  68. package/lib/typescript/module/fingerprint.web.d.ts.map +0 -1
  69. package/lib/typescript/module/foreground.d.ts.map +0 -1
  70. package/lib/typescript/module/foreground.web.d.ts.map +0 -1
  71. package/lib/typescript/module/freeToken.d.ts.map +0 -1
  72. package/lib/typescript/module/headless.d.ts.map +0 -1
  73. package/lib/typescript/module/hooks.d.ts.map +0 -1
  74. package/lib/typescript/module/index.d.ts.map +0 -1
  75. package/lib/typescript/module/index.web.d.ts.map +0 -1
  76. package/lib/typescript/module/storage.d.ts.map +0 -1
  77. package/lib/typescript/module/storage.web.d.ts.map +0 -1
  78. package/lib/typescript/module/tier.d.ts.map +0 -1
  79. package/lib/typescript/module/types.d.ts.map +0 -1
  80. package/lib/typescript/module/weekendPro.d.ts.map +0 -1
  81. package/lib/web/chunks/LicenseManager-AEFCYYMQ.mjs +0 -7
  82. package/lib/web/chunks/LicenseManager-JHLFWSUD.mjs +0 -2
  83. package/lib/web/chunks/LicenseManager-VWEJJHBH.mjs +0 -7
  84. package/lib/web/chunks/chunk-GRUXDUJG.mjs +0 -74
  85. package/lib/web/chunks/chunk-OPWF6JR6.mjs +0 -1480
  86. package/lib/web/chunks/chunk-TVOTAEQX.mjs +0 -1483
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DeviceRegistrationModal=DeviceRegistrationModal;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _LicenseManager=require("./LicenseManager.js");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(d,u){if("function"==typeof WeakMap)var f=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,n){if(!n&&e&&e.__esModule)return e;var t,o,r={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return r;if(t=n?a:f){if(t.has(e))return t.get(e);t.set(e,r)}for(const i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((o=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,i))&&(o.get||o.set)?t(r,i,o):r[i]=e[i]);return r})(d,u)}const buoyColors={base:"#121212",card:"#1A1A1A",hover:"#242424",input:"#2A2A2A",border:"#333333",borderStrong:"#444444",text:"#E0E0E0",textSecondary:"#A0A0A0",textMuted:"#888888",primary:"#20C997",success:"#20C997",warning:"#FFA94D",error:"#EF4444",info:"#00B8E6"};function DeviceRegistrationModal({title:d="Name Your Device",description:u="Give this device a name to help you identify it later.",buttonText:f="Continue",onComplete:a}){const[e,n]=(0,_react.useState)(false);const[t,o]=(0,_react.useState)("");const[r,i]=(0,_react.useState)("");const[s,b]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{const c=_LicenseManager.LicenseManager.onDeviceRegistrationNeeded(l=>{i(l.defaultName);o(l.defaultName);n(true)});return c},[]);const g=(0,_react.useCallback)(async()=>{const c=t.trim()||r;b(true);try{await _LicenseManager.LicenseManager.completeDeviceRegistration(c);n(false);a?.(c)}catch(l){console.warn("[Buoy] Device registration failed:",l);n(false)}finally{b(false)}},[t,r,a]);if(!e)return null;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:e,transparent:true,animationType:"fade",onRequestClose:()=>{g()},children:(0,_jsxRuntime.jsx)(_reactNative.KeyboardAvoidingView,{behavior:_reactNative.Platform.OS==="ios"?"padding":"height",style:styles.overlay,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.accentBar}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.content,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.title,children:d}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.description,children:u}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.input,value:t,onChangeText:o,placeholder:r,placeholderTextColor:buoyColors.textMuted,autoFocus:true,returnKeyType:"done",onSubmitEditing:g,editable:!s,selectionColor:buoyColors.primary}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.button,s&&styles.buttonDisabled],onPress:g,disabled:s,activeOpacity:.8,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.buttonText,children:s?"Registering...":f})})]})]})})})}const styles=_reactNative.StyleSheet.create({overlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.75)",justifyContent:"center",alignItems:"center"},container:{backgroundColor:buoyColors.card,borderRadius:12,width:"85%",maxWidth:400,borderWidth:1,borderColor:buoyColors.border,shadowColor:buoyColors.primary,shadowOffset:{width:0,height:0},shadowOpacity:.2,shadowRadius:20,elevation:20,overflow:"hidden"},accentBar:{height:3,backgroundColor:buoyColors.primary},content:{padding:24},title:{fontSize:20,fontWeight:"600",color:buoyColors.text,marginBottom:8,textAlign:"center"},description:{fontSize:14,color:buoyColors.textSecondary,marginBottom:24,textAlign:"center",lineHeight:20},input:{borderWidth:1,borderColor:buoyColors.border,borderRadius:8,padding:14,fontSize:16,color:buoyColors.text,backgroundColor:buoyColors.input,marginBottom:20},button:{backgroundColor:buoyColors.primary,borderRadius:8,padding:14,alignItems:"center"},buttonDisabled:{backgroundColor:buoyColors.textMuted},buttonText:{color:buoyColors.base,fontSize:16,fontWeight:"600"}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DeviceRegistrationModal=DeviceRegistrationModal;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _LicenseManager=require("./LicenseManager.js");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(d,u){if("function"==typeof WeakMap)var f=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,i){if(!i&&e&&e.__esModule)return e;var t,n,r={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return r;if(t=i?a:f){if(t.has(e))return t.get(e);t.set(e,r)}for(const o in e)"default"!==o&&{}.hasOwnProperty.call(e,o)&&((n=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,o))&&(n.get||n.set)?t(r,o,n):r[o]=e[o]);return r})(d,u)}const buoyColors={base:"#121212",card:"#1A1A1A",hover:"#242424",input:"#2A2A2A",border:"#333333",borderStrong:"#444444",text:"#E0E0E0",textSecondary:"#A0A0A0",textMuted:"#888888",primary:"#20C997",success:"#20C997",warning:"#FFA94D",error:"#EF4444",info:"#00B8E6"};function DeviceRegistrationModal({title:d="Name Your Device",description:u="Give this device a name to help you identify it later.",buttonText:f="Continue",onComplete:a}){const[e,i]=(0,_react.useState)(false);const[t,n]=(0,_react.useState)("");const[r,o]=(0,_react.useState)("");const[s,b]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{const c=_LicenseManager.LicenseManager.onDeviceRegistrationNeeded(l=>{o(l.defaultName);n(l.defaultName);i(true)});return c},[]);const g=(0,_react.useCallback)(async()=>{const c=t.trim()||r;b(true);try{await _LicenseManager.LicenseManager.completeDeviceRegistration(c);i(false);a?.(c)}catch(l){console.warn("[Buoy] Device registration failed:",l);i(false)}finally{b(false)}},[t,r,a]);if(!e)return null;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:e,transparent:true,animationType:"fade",onRequestClose:()=>{g()},children:(0,_jsxRuntime.jsx)(_reactNative.KeyboardAvoidingView,{behavior:_reactNative.Platform.OS==="ios"?"padding":"height",style:styles.overlay,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.accentBar}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.content,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.title,children:d}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.description,children:u}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.input,value:t,onChangeText:n,placeholder:r,placeholderTextColor:buoyColors.textMuted,autoFocus:true,returnKeyType:"done",onSubmitEditing:g,editable:!s,selectionColor:buoyColors.primary}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.button,s&&styles.buttonDisabled],onPress:g,disabled:s,activeOpacity:.8,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.buttonText,children:s?"Registering...":f})})]})]})})})}const styles=_reactNative.StyleSheet.create({overlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.75)",justifyContent:"center",alignItems:"center"},container:{backgroundColor:buoyColors.card,borderRadius:12,width:"85%",maxWidth:400,borderWidth:1,borderColor:buoyColors.border,shadowColor:buoyColors.primary,shadowOffset:{width:0,height:0},shadowOpacity:.2,shadowRadius:20,elevation:20,overflow:"hidden"},accentBar:{height:3,backgroundColor:buoyColors.primary},content:{padding:24},title:{fontSize:20,fontWeight:"600",color:buoyColors.text,marginBottom:8,textAlign:"center"},description:{fontSize:14,color:buoyColors.textSecondary,marginBottom:24,textAlign:"center",lineHeight:20},input:{borderWidth:1,borderColor:buoyColors.border,borderRadius:8,padding:14,fontSize:16,color:buoyColors.text,backgroundColor:buoyColors.input,marginBottom:20},button:{backgroundColor:buoyColors.primary,borderRadius:8,padding:14,alignItems:"center"},buttonDisabled:{backgroundColor:buoyColors.textMuted},buttonText:{color:buoyColors.base,fontSize:16,fontWeight:"600"}});
@@ -1,16 +1,16 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LicenseManager=void 0;var _storage=require("./storage");var _config=require("./config.js");var _api=require("./api.js");var _fingerprint=require("./fingerprint");var _cacheSignature=require("./cacheSignature.js");var _freeToken=require("./freeToken.js");var _tier=require("./tier.js");var _accountAccess=require("./accountAccess.js");var _foreground=require("./foreground");/*!
2
- * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
- *
4
- * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
- * (https://buoy.gg/terms), not an OSS license.
6
- *
7
- * This file is the technological measure that controls access to paid Buoy Pro
8
- * features. Modifying, patching, aliasing, stubbing, or otherwise altering it
9
- * so that Pro features unlock without a valid license is a breach of the EULA
10
- * and, in the United States, circumvention of an access control under
11
- * 17 U.S.C. § 1201 — which applies whether or not any code is copied.
12
- *
13
- * Pro is $9/mo, and is free every weekend for anyone holding a key —
14
- * including a free one (`npx buoy login`). Buy a key at
15
- * https://buoy.gg or use it free on Saturday and Sunday.
16
- */async function boundedStorage(o,e){let t;try{return await Promise.race([o,new Promise(i=>{t=setTimeout(()=>i(e),15e3)})])}finally{if(t)clearTimeout(t)}}function tierOfCache(o){if(o.tier==="pro"||o.tier==="free")return o.tier;return o.isPro?"pro":"free"}class LicenseManagerImpl{state={isInitialized:false,isValidating:false,isPro:false,tier:"free",tierSource:"none",licenseKey:null,error:null,errorKind:null,expiresAt:null};listeners=new Set;revalidationTimer=null;cachedLicense=null;fingerprintPromise=null;initPromise=null;generation=0;persistence=Promise.resolve();verifiedAt=null;expiryTimer=null;removeForegroundListener=null;retryTimer=null;retryAttempt=0;deviceRegistrationCallback=null;pendingRegistration=null;async initialize(){if(this.initPromise)return this.initPromise;if(this.state.isInitialized)return;this.initPromise=this._doInitialize();return this.initPromise}async _doInitialize(){if(this.state.isInitialized)return;const e=this.generation;try{const t=await boundedStorage(this.loadCachedLicense(),null);if(e!==this.generation){this.state.isInitialized=true;this.emit({type:"initialized",isPro:this.state.isPro});this.startRevalidationTimer();return}if(t&&(this.configuredKey===void 0||t.licenseKey===this.configuredKey)){const i=(0,_cacheSignature.verifyCacheSignature)(t);this.cachedLicense=t;this.state.licenseKey=t.licenseKey;if(i&&this.isCacheValid(t))this.applyTier(tierOfCache(t));else this.lock();this.state.expiresAt=t.expiresAt?new Date(t.expiresAt):null;if(i&&this.isCacheValid(t))this.setVerifiedAt(t.cachedAt);if(this.configuredKey===void 0&&t.licenseKey&&!(i&&this.isCacheValid(t)&&this.isCacheFresh(t))){this.validateInBackground(t.licenseKey)}}this.state.isInitialized=true;this.emit({type:"initialized",isPro:this.state.isPro});this.startRevalidationTimer()}catch(t){console.warn("[React Buoy] License initialization failed:",t);this.state.isInitialized=true;this.emit({type:"initialized",isPro:false})}}async configure(e){if(e===void 0){await this.initialize();return this.hasAccountAccess()}const t=e.trim().toUpperCase();const i=++this.generation;this.cancelRetry();this.configuredKey=t||null;if(this.state.licenseKey!==this.configuredKey)this.lock();this.state.licenseKey=this.configuredKey;this.state.isValidating=!!t;this.emit({type:"validating",isPro:this.isPro()});await this.initialize();if(i!==this.generation)return false;if(!t){await this.clearLicense();return false}return this.setLicenseKey(t)}async setLicenseKey(e,t){if(!e||e.trim().length===0){this.state.error="License key is required";this.state.errorKind="verdict";return false}const i=e.trim().toUpperCase();const s=++this.generation;this.cancelRetry();if(!t?.isRetry)this.retryAttempt=0;if(this.state.licenseKey!==i)this.lock();this.state.licenseKey=i;this.state.isValidating=true;this.state.error=null;this.state.errorKind=null;this.emit({type:"validating",isPro:this.isPro()});if((0,_freeToken.isBuoyToken)(i))return this.admitToken(i,s);if(!this.cachedLicense){const a=await boundedStorage(this.loadCachedLicense(),null);if(s!==this.generation)return false;if(a?.licenseKey===i){this.cachedLicense=a;if((0,_cacheSignature.verifyCacheSignature)(a)&&this.isCacheValid(a)){this.applyTier(tierOfCache(a));this.state.expiresAt=a.expiresAt?new Date(a.expiresAt):null;this.setVerifiedAt(a.cachedAt);this.emit({type:"validating",isPro:this.isPro()})}}}const r=this.cachedLicense;if(!t?.force&&r&&r.valid&&r.licenseKey===i&&r.fingerprint&&(0,_cacheSignature.verifyCacheSignature)(r)&&this.isCacheValid(r)&&this.isCacheFresh(r)){this.applyTier(tierOfCache(r));this.state.licenseKey=i;this.state.isValidating=false;this.state.error=null;this.state.errorKind=null;this.state.expiresAt=r.expiresAt?new Date(r.expiresAt):null;this.setVerifiedAt(r.cachedAt);this.emit({type:"validated",isPro:this.state.isPro});return true}const c=await boundedStorage(this.loadHold(),null);if(s!==this.generation)return false;const u=(c?.backoffUntil??0)-Date.now();if(u>0){return this.standDown(i,s,"License server is rate limited; retrying later.",u)}if(!t?.force&&c?.key===i&&c.verdictAt!==void 0&&Date.now()-c.verdictAt>=0&&Date.now()-c.verdictAt<_config.LICENSE_VERDICT_CACHE_DURATION){this.lock();this.state.isValidating=false;this.state.error=c.detail||"License could not be verified";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});return false}let n;try{n=await(0,_api.validateLicense)(i)}catch(a){const h=a instanceof Error?a.message:"Validation failed";if(s!==this.generation)return false;if((0,_api.isTransientLicenseError)(a)){if((0,_api.isRateLimited)(a)){const l=Math.min((0,_api.backoffAfter)(a,_config.LICENSE_QUOTA_COOLDOWN,_config.LICENSE_RATE_LIMIT_DEFAULT_WAIT)*2**this.retryAttempt,_config.LICENSE_QUOTA_COOLDOWN);this.retryAttempt+=1;await this.saveHold({...this.hold,backoffUntil:Date.now()+l});if(s!==this.generation)return false;return this.standDown(i,s,h,l)}this.state.isValidating=false;if(this.cachedLicense&&this.cachedLicense.licenseKey===i&&(0,_cacheSignature.verifyCacheSignature)(this.cachedLicense)&&this.isCacheValid(this.cachedLicense)){this.applyTier(tierOfCache(this.cachedLicense));this.state.error=null;this.state.errorKind=null;this.state.expiresAt=this.cachedLicense.expiresAt?new Date(this.cachedLicense.expiresAt):null;this.setVerifiedAt(this.cachedLicense.cachedAt);if(!this.isPro())this.scheduleRetry(i);this.emit({type:"validated",isPro:this.state.isPro});return true}this.state.error=h;this.state.errorKind="transport";this.scheduleRetry(i);this.emit({type:"error",isPro:this.state.isPro,error:h});return false}this.state.isValidating=false;this.state.error=h;this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:h});return false}try{if(s!==this.generation)return false;const a=(0,_api.parseValidationResult)(n);const h=n.data?.relationships?.product?.data?.id;if((!h||h===_config.KEYGEN_CONFIG.productId)&&a.code==="EXPIRED"&&((0,_tier.isRecognizedAccount)(n.data)||this.cachedLicense?.licenseKey===i&&(0,_cacheSignature.verifyCacheSignature)(this.cachedLicense)&&this.isCacheValid(this.cachedLicense))){const p=Date.now();const T=await this.saveCache({licenseKey:i,licenseId:n.data?.id??"",valid:true,isPro:false,tier:"free",expiresAt:null,cachedAt:p,lastValidatedAt:p,fingerprint:this.cachedLicense?.licenseKey===i?this.cachedLicense.fingerprint:void 0},s);if(s!==this.generation||!T)return false;this.cachedLicense=T;this.applyTier("free");this.state.isValidating=false;this.state.expiresAt=null;this.setVerifiedAt(p);this.emit({type:"validated",isPro:false});return true}if((0,_api.isFatalLicenseError)(a.code)||!(0,_api.isAcceptedValidation)(n)){this.lock();this.state.isValidating=false;this.state.error=a.detail||"License could not be verified";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});await this.clearCachedLicense();await this.saveHold({key:i,code:a.code,detail:this.state.error,verdictAt:Date.now()});return false}if(!n.data){this.lock();this.state.isValidating=false;this.state.error=a.detail||"License not found";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});await this.clearCachedLicense();return false}const l=(0,_tier.resolveTier)(n.data);const _=n.data.id;const g=Date.now();const A=(0,_api.machineCount)(n)>=_config.LICENSE_FLEET_MACHINE_THRESHOLD;const m=(0,_fingerprint.isDevBundle)();const I=m&&!A;const R=l==="free"&&(A||!m);let d=this.cachedLicense?.fingerprint;let f=this.cachedLicense?.deviceName;let v=false;if(!d){d=await boundedStorage(this.getOrCreateDeviceFingerprint(),(0,_fingerprint.generateUUID)());if(s!==this.generation)return false;f=(0,_fingerprint.getDefaultDeviceName)();v=I}let y=false;if(v){if(this.deviceRegistrationCallback){this.pendingRegistration={licenseId:_,licenseKey:i,fingerprint:d};this.deviceRegistrationCallback({fingerprint:d,defaultName:f});y=true}else{this.registerDeviceAsync(_,i,d,f)}}const E={licenseKey:i,licenseId:_,valid:true,isPro:l==="pro",tier:l,expiresAt:n.data.attributes.expiry??null,cachedAt:g,lastValidatedAt:g,fingerprint:y?void 0:d,deviceName:y?void 0:f,quiet:R||void 0};const L=await this.saveCache(E,s);if(s!==this.generation||!L)return false;this.cachedLicense=L;this.applyTier(l);this.state.isValidating=false;this.state.expiresAt=E.expiresAt?new Date(E.expiresAt):null;this.setVerifiedAt(g);if(this.hold)await this.saveHold(null);if(s!==this.generation)return false;this.retryAttempt=0;this.emit({type:"validated",isPro:this.state.isPro});return true}catch(a){const h=a instanceof Error?a.message:"Validation failed";if(s!==this.generation)return false;this.state.isValidating=false;this.state.error=h;this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:h});return false}}scheduleRetry(e){this.cancelRetry();const t=_config.LICENSE_TRANSIENT_RETRY_DELAYS[this.retryAttempt];if(t===void 0)return;this.retryAttempt+=1;const i=this.generation;this.retryTimer=setTimeout(()=>{this.retryTimer=null;if(i!==this.generation)return;if(this.state.isValidating)return;void this.setLicenseKey(e,{force:true,isRetry:true})},t);if(typeof __DEV__!=="undefined"&&__DEV__){global.__LICENSE_MANAGER_RETRY_TIMER__=this.retryTimer}}async admitToken(e,t){const i=(0,_freeToken.verifyFreeToken)(e);if(t!==this.generation)return false;if(!i){this.lock();this.state.isValidating=false;this.state.error="This key is not valid. Check that it was copied completely.";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});await this.clearCachedLicense();return false}const s=Date.now();const r=this.cachedLicense?.fingerprint??await boundedStorage(this.getOrCreateDeviceFingerprint(),(0,_fingerprint.generateUUID)());if(t!==this.generation)return false;const c=await this.saveCache({licenseKey:e,licenseId:`token:${i.accountHash}`,valid:true,isPro:false,tier:"free",expiresAt:null,cachedAt:s,lastValidatedAt:s,fingerprint:r,deviceName:this.cachedLicense?.deviceName??(0,_fingerprint.getDefaultDeviceName)(),quiet:true},t);if(t!==this.generation||!c)return false;this.cachedLicense=c;this.applyTier("free");this.state.isValidating=false;this.state.expiresAt=null;this.setVerifiedAt(s);this.retryAttempt=0;this.emit({type:"validated",isPro:false});return true}standDown(e,t,i,s){if(t!==this.generation)return false;this.state.isValidating=false;const r=this.cachedLicense;if(r&&r.licenseKey===e&&(0,_cacheSignature.verifyCacheSignature)(r)&&this.isCacheValid(r)){this.applyTier(tierOfCache(r));this.state.error=null;this.state.errorKind=null;this.state.expiresAt=r.expiresAt?new Date(r.expiresAt):null;this.setVerifiedAt(r.cachedAt);if(!this.isPro())this.scheduleRetryIn(e,s);this.emit({type:"validated",isPro:this.state.isPro});return true}this.state.error=i;this.state.errorKind="transport";this.scheduleRetryIn(e,s);this.emit({type:"error",isPro:this.state.isPro,error:i});return false}scheduleRetryIn(e,t){this.cancelRetry();const i=this.generation;this.retryTimer=setTimeout(()=>{this.retryTimer=null;if(i!==this.generation)return;if(this.state.isValidating)return;void this.setLicenseKey(e,{force:true,isRetry:true})},Math.max(1,Math.min(t,2147483647)));if(typeof __DEV__!=="undefined"&&__DEV__)devTimers.__LICENSE_MANAGER_RETRY_TIMER__=this.retryTimer}cancelRetry(){if(this.retryTimer){clearTimeout(this.retryTimer);this.retryTimer=null}}async clearLicense(){this.generation+=1;this.cancelRetry();this.retryAttempt=0;this.configuredKey=null;this.state.licenseKey=null;this.lock();this.state.expiresAt=null;this.state.error=null;this.state.errorKind=null;this.cachedLicense=null;this.pendingRegistration=null;this.state.isValidating=false;this.emit({type:"deactivated",isPro:false});await this.clearCachedLicense();if(this.hold?.verdictAt!==void 0){await this.saveHold(this.hold.backoffUntil?{backoffUntil:this.hold.backoffUntil}:null)}}applyTier(e){this.state.tier=e;this.state.tierSource="key";this.state.isPro=e==="pro"}lock(){this.state.tier="free";this.state.tierSource="none";this.state.isPro=false;this.verifiedAt=null;if(this.expiryTimer)clearTimeout(this.expiryTimer);this.expiryTimer=null}getTier(){if(!this.hasAccountAccess())return"free";if(this.state.expiresAt&&Date.now()>=this.state.expiresAt.getTime())return"free";return this.state.tier}isPro(){return this.getTier()==="pro"}hasEntitlement(e){return this.isPro()}getState(){const e=this.getAccountAccess();const t=this.getTier();return{...this.state,tier:t,isPro:t==="pro",access:e}}getAccountAccess(){return(0,_accountAccess.resolveAccountAccess)({initialized:this.state.isInitialized,validating:this.state.isValidating,key:this.state.licenseKey,tierSource:this.state.tierSource,verifiedAt:this.verifiedAt})}hasAccountAccess(){return this.getAccountAccess().status==="admitted"}setVerifiedAt(e){this.verifiedAt=e;if(this.expiryTimer)clearTimeout(this.expiryTimer);const t=e+_config.LICENSE_CACHE_DURATION;const i=this.state.expiresAt?.getTime();const s=i&&i>Date.now()?Math.min(t,i):t;const r=s-Date.now();this.expiryTimer=setTimeout(()=>{this.expiryTimer=null;if(this.verifiedAt!==e)return;this.emit({type:"validated",isPro:this.isPro()});if(Date.now()<t)this.setVerifiedAt(e)},Math.max(1,Math.min(r,2147483647)));if(typeof __DEV__!=="undefined"&&__DEV__)devTimers.__LICENSE_MANAGER_EXPIRY_TIMER__=this.expiryTimer}subscribe(e){this.listeners.add(e);return()=>this.listeners.delete(e)}onDeviceRegistrationNeeded(e){this.deviceRegistrationCallback=e;return()=>{this.deviceRegistrationCallback=null}}async completeDeviceRegistration(e){if(!this.pendingRegistration){console.warn("[Buoy] No pending device registration");return}const{licenseId:t,licenseKey:i,fingerprint:s}=this.pendingRegistration;const r=this.generation;const c=e.trim()||(0,_fingerprint.getDefaultDeviceName)();const u=(0,_fingerprint.getDeviceMetadata)();try{await(0,_api.activateMachine)(t,i,s,c,u)}catch(n){const a=n instanceof Error?n.message:String(n);if(a==="FINGERPRINT_TAKEN"||a==="MACHINE_LIMIT_EXCEEDED"){}else{console.warn("[Buoy] Device registration failed:",a);throw n}}if(r!==this.generation)return;if(this.cachedLicense?.licenseKey===i){const n=await this.saveCache({...this.cachedLicense,fingerprint:s,deviceName:c},r);if(r!==this.generation)return;if(n)this.cachedLicense=n}this.pendingRegistration=null}emit(e){const t=[...this.listeners];t.forEach(i=>{try{i(e)}catch(s){console.warn("[React Buoy] License listener error:",s)}})}isCacheValid(e){const t=Date.now();const i=t-e.cachedAt;if(!e.valid||!Number.isFinite(e.cachedAt)||i<0||i>=_config.LICENSE_CACHE_DURATION){return false}return true}isCacheFresh(e){const t=this.isQuiet(e)?_config.LICENSE_QUIET_VALIDATION_TTL:_config.LICENSE_LAUNCH_VALIDATION_TTL;return Date.now()-(e.lastValidatedAt??0)<t}isQuiet(e){if(e.quiet!==void 0)return e.quiet;return tierOfCache(e)==="free"&&!(0,_fingerprint.isDevBundle)()}async loadHold(){if(this.hold!==void 0)return this.hold;try{const e=await(0,_storage.getLicenseStorage)();const t=await e.getItem(_config.LICENSE_HOLD_STORAGE_KEY);const i=t?JSON.parse(t):null;this.hold=i&&typeof i==="object"?i:null}catch{this.hold=null}return this.hold}async saveHold(e){this.hold=e;try{const t=await(0,_storage.getLicenseStorage)();if(e)await t.setItem(_config.LICENSE_HOLD_STORAGE_KEY,JSON.stringify(e));else await t.removeItem(_config.LICENSE_HOLD_STORAGE_KEY)}catch{}}async persistCache(e){const t=(0,_cacheSignature.signCache)(e);const i=await(0,_storage.getLicenseStorage)();await i.setItem(_config.LICENSE_STORAGE_KEY,JSON.stringify(t));return t}saveCache(e,t){const i=this.persistence.catch(()=>{}).then(async()=>{if(t!==this.generation)return null;const s=await this.persistCache(e);return t===this.generation?s:null});this.persistence=i;return boundedStorage(i,(0,_cacheSignature.signCache)(e))}async loadCachedLicense(){try{await this.persistence.catch(()=>{});const e=await(0,_storage.getLicenseStorage)();const t=await e.getItem(_config.LICENSE_STORAGE_KEY);if(!t)return null;const i=JSON.parse(t);return i}catch(e){console.warn("[Buoy] Error loading cached license:",e);return null}}getOrCreateDeviceFingerprint(){if(!this.fingerprintPromise){this.fingerprintPromise=(async()=>{const e=await(0,_storage.getLicenseStorage)();const t=await e.getItem(_config.DEVICE_FINGERPRINT_STORAGE_KEY);if(t)return t;const i=this.cachedLicense?.fingerprint||(0,_fingerprint.generateUUID)();await e.setItem(_config.DEVICE_FINGERPRINT_STORAGE_KEY,i);return i})()}return this.fingerprintPromise}async clearCachedLicense(){this.cachedLicense=null;const e=this.persistence.catch(()=>{}).then(async()=>{const t=await(0,_storage.getLicenseStorage)();await t.removeItem(_config.LICENSE_STORAGE_KEY)});this.persistence=e;await boundedStorage(e.catch(()=>{}),void 0)}registerDeviceAsync(e,t,i,s){const r=(0,_fingerprint.getDeviceMetadata)();(0,_api.activateMachine)(e,t,i,s,r).catch(c=>{if(c.message!=="FINGERPRINT_TAKEN"&&c.message!=="MACHINE_LIMIT_EXCEEDED"){console.warn("[Buoy] Device registration failed (non-blocking):",c.message)}})}validateInBackground(e){void this.setLicenseKey(e,{force:true,isRetry:true})}refreshAccess(){this.emit({type:"validated",isPro:this.isPro()})}startRevalidationTimer(){if(!this.removeForegroundListener){this.removeForegroundListener=(0,_foreground.subscribeForeground)(()=>this.refreshAccess());if(typeof __DEV__!=="undefined"&&__DEV__)devTimers.__LICENSE_MANAGER_FOREGROUND_OFF__=this.removeForegroundListener}if(this.revalidationTimer){clearInterval(this.revalidationTimer)}this.revalidationTimer=setInterval(()=>{if(!this.state.licenseKey||this.state.isValidating)return;const e=this.cachedLicense;if(e&&e.licenseKey===this.state.licenseKey&&this.isCacheFresh(e))return;this.validateInBackground(this.state.licenseKey)},_config.LICENSE_REVALIDATION_INTERVAL);if(typeof __DEV__!=="undefined"&&__DEV__){global.__LICENSE_MANAGER_TIMER__=this.revalidationTimer}}stopRevalidationTimer(){this.removeForegroundListener?.();this.removeForegroundListener=null;if(this.expiryTimer)clearTimeout(this.expiryTimer);this.expiryTimer=null;if(this.revalidationTimer){clearInterval(this.revalidationTimer);this.revalidationTimer=null}this.cancelRetry()}async forceReregister(){if(this.cachedLicense){this.cachedLicense.fingerprint=void 0;this.cachedLicense.deviceName=void 0}this.fingerprintPromise=null;await this.clearCachedLicense();try{const e=await(0,_storage.getLicenseStorage)();await e.removeItem(_config.DEVICE_FINGERPRINT_STORAGE_KEY)}catch{}}}const LicenseManager=exports.LicenseManager=new LicenseManagerImpl;const devTimers=globalThis;if(typeof __DEV__!=="undefined"&&__DEV__){devTimers.__LICENSE_MANAGER_FOREGROUND_OFF__?.();devTimers.__LICENSE_MANAGER_FOREGROUND_OFF__=void 0;if(devTimers.__LICENSE_MANAGER_EXPIRY_TIMER__)clearTimeout(devTimers.__LICENSE_MANAGER_EXPIRY_TIMER__);if(devTimers.__LICENSE_MANAGER_TIMER__){clearInterval(devTimers.__LICENSE_MANAGER_TIMER__)}if(devTimers.__LICENSE_MANAGER_RETRY_TIMER__){clearTimeout(devTimers.__LICENSE_MANAGER_RETRY_TIMER__);devTimers.__LICENSE_MANAGER_RETRY_TIMER__=void 0}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LicenseManager=void 0;var _storage=require("./storage");var _config=require("./config.js");var _api=require("./api.js");var _fingerprint=require("./fingerprint");var _cacheSignature=require("./cacheSignature.js");var _freeToken=require("./freeToken.js");var _tier=require("./tier.js");var _accountAccess=require("./accountAccess.js");var _foreground=require("./foreground");var _realNow=require("./realNow.js");/*!
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * This file is the technological measure that controls access to paid Buoy Pro
8
+ * features. Modifying, patching, aliasing, stubbing, or otherwise altering it
9
+ * so that Pro features unlock without a valid license is a breach of the EULA
10
+ * and, in the United States, circumvention of an access control under
11
+ * 17 U.S.C. § 1201 — which applies whether or not any code is copied.
12
+ *
13
+ * Pro is $9/mo, and is free every weekend for anyone holding a key —
14
+ * including a free one (`npx buoy login`). Buy a key at
15
+ * https://buoy.gg or use it free on Saturday and Sunday.
16
+ */async function boundedStorage(o,e){let t;try{return await Promise.race([o,new Promise(i=>{t=setTimeout(()=>i(e),15e3)})])}finally{if(t)clearTimeout(t)}}function tierOfCache(o){if(o.tier==="pro"||o.tier==="free")return o.tier;return o.isPro?"pro":"free"}class LicenseManagerImpl{state={isInitialized:false,isValidating:false,isPro:false,tier:"free",tierSource:"none",licenseKey:null,error:null,errorKind:null,expiresAt:null};listeners=new Set;revalidationTimer=null;cachedLicense=null;fingerprintPromise=null;initPromise=null;generation=0;persistence=Promise.resolve();verifiedAt=null;expiryTimer=null;removeForegroundListener=null;retryTimer=null;retryAttempt=0;deviceRegistrationCallback=null;pendingRegistration=null;async initialize(){if(this.initPromise)return this.initPromise;if(this.state.isInitialized)return;this.initPromise=this._doInitialize();return this.initPromise}async _doInitialize(){if(this.state.isInitialized)return;const e=this.generation;try{const t=await boundedStorage(this.loadCachedLicense(),null);if(e!==this.generation){this.state.isInitialized=true;this.emit({type:"initialized",isPro:this.state.isPro});this.startRevalidationTimer();return}if(t&&(this.configuredKey===void 0||t.licenseKey===this.configuredKey)){const i=(0,_cacheSignature.verifyCacheSignature)(t);this.cachedLicense=t;this.state.licenseKey=t.licenseKey;if(i&&this.isCacheValid(t))this.applyTier(tierOfCache(t));else this.lock();this.state.expiresAt=t.expiresAt?new Date(t.expiresAt):null;if(i&&this.isCacheValid(t))this.setVerifiedAt(t.cachedAt);if(this.configuredKey===void 0&&t.licenseKey&&!(i&&this.isCacheValid(t)&&this.isCacheFresh(t))){this.validateInBackground(t.licenseKey)}}this.state.isInitialized=true;this.emit({type:"initialized",isPro:this.state.isPro});this.startRevalidationTimer()}catch(t){console.warn("[React Buoy] License initialization failed:",t);this.state.isInitialized=true;this.emit({type:"initialized",isPro:false})}}async configure(e){if(e===void 0){await this.initialize();return this.hasAccountAccess()}const t=e.trim().toUpperCase();const i=++this.generation;this.cancelRetry();this.configuredKey=t||null;if(this.state.licenseKey!==this.configuredKey)this.lock();this.state.licenseKey=this.configuredKey;this.state.isValidating=!!t;this.emit({type:"validating",isPro:this.isPro()});await this.initialize();if(i!==this.generation)return false;if(!t){await this.clearLicense();return false}return this.setLicenseKey(t)}async setLicenseKey(e,t){if(!e||e.trim().length===0){this.state.error="License key is required";this.state.errorKind="verdict";return false}const i=e.trim().toUpperCase();const s=++this.generation;this.cancelRetry();if(!t?.isRetry)this.retryAttempt=0;if(this.state.licenseKey!==i)this.lock();this.state.licenseKey=i;this.state.isValidating=true;this.state.error=null;this.state.errorKind=null;this.emit({type:"validating",isPro:this.isPro()});if((0,_freeToken.isBuoyToken)(i))return this.admitToken(i,s);if(!this.cachedLicense){const a=await boundedStorage(this.loadCachedLicense(),null);if(s!==this.generation)return false;if(a?.licenseKey===i){this.cachedLicense=a;if((0,_cacheSignature.verifyCacheSignature)(a)&&this.isCacheValid(a)){this.applyTier(tierOfCache(a));this.state.expiresAt=a.expiresAt?new Date(a.expiresAt):null;this.setVerifiedAt(a.cachedAt);this.emit({type:"validating",isPro:this.isPro()})}}}const r=this.cachedLicense;if(!t?.force&&r&&r.valid&&r.licenseKey===i&&r.fingerprint&&(0,_cacheSignature.verifyCacheSignature)(r)&&this.isCacheValid(r)&&this.isCacheFresh(r)){this.applyTier(tierOfCache(r));this.state.licenseKey=i;this.state.isValidating=false;this.state.error=null;this.state.errorKind=null;this.state.expiresAt=r.expiresAt?new Date(r.expiresAt):null;this.setVerifiedAt(r.cachedAt);this.emit({type:"validated",isPro:this.state.isPro});return true}const c=await boundedStorage(this.loadHold(),null);if(s!==this.generation)return false;const u=(c?.backoffUntil??0)-(0,_realNow.realNow)();if(u>0){return this.standDown(i,s,"License server is rate limited; retrying later.",u)}if(!t?.force&&c?.key===i&&c.verdictAt!==void 0&&(0,_realNow.realNow)()-c.verdictAt>=0&&(0,_realNow.realNow)()-c.verdictAt<_config.LICENSE_VERDICT_CACHE_DURATION){this.lock();this.state.isValidating=false;this.state.error=c.detail||"License could not be verified";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});return false}let n;try{n=await(0,_api.validateLicense)(i)}catch(a){const h=a instanceof Error?a.message:"Validation failed";if(s!==this.generation)return false;if((0,_api.isTransientLicenseError)(a)){if((0,_api.isRateLimited)(a)){const l=Math.min((0,_api.backoffAfter)(a,_config.LICENSE_QUOTA_COOLDOWN,_config.LICENSE_RATE_LIMIT_DEFAULT_WAIT)*2**this.retryAttempt,_config.LICENSE_QUOTA_COOLDOWN);this.retryAttempt+=1;await this.saveHold({...this.hold,backoffUntil:(0,_realNow.realNow)()+l});if(s!==this.generation)return false;return this.standDown(i,s,h,l)}this.state.isValidating=false;if(this.cachedLicense&&this.cachedLicense.licenseKey===i&&(0,_cacheSignature.verifyCacheSignature)(this.cachedLicense)&&this.isCacheValid(this.cachedLicense)){this.applyTier(tierOfCache(this.cachedLicense));this.state.error=null;this.state.errorKind=null;this.state.expiresAt=this.cachedLicense.expiresAt?new Date(this.cachedLicense.expiresAt):null;this.setVerifiedAt(this.cachedLicense.cachedAt);if(!this.isPro())this.scheduleRetry(i);this.emit({type:"validated",isPro:this.state.isPro});return true}this.state.error=h;this.state.errorKind="transport";this.scheduleRetry(i);this.emit({type:"error",isPro:this.state.isPro,error:h});return false}this.state.isValidating=false;this.state.error=h;this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:h});return false}try{if(s!==this.generation)return false;const a=(0,_api.parseValidationResult)(n);const h=n.data?.relationships?.product?.data?.id;if((!h||h===_config.KEYGEN_CONFIG.productId)&&a.code==="EXPIRED"&&((0,_tier.isRecognizedAccount)(n.data)||this.cachedLicense?.licenseKey===i&&(0,_cacheSignature.verifyCacheSignature)(this.cachedLicense)&&this.isCacheValid(this.cachedLicense))){const p=(0,_realNow.realNow)();const T=await this.saveCache({licenseKey:i,licenseId:n.data?.id??"",valid:true,isPro:false,tier:"free",expiresAt:null,cachedAt:p,lastValidatedAt:p,fingerprint:this.cachedLicense?.licenseKey===i?this.cachedLicense.fingerprint:void 0},s);if(s!==this.generation||!T)return false;this.cachedLicense=T;this.applyTier("free");this.state.isValidating=false;this.state.expiresAt=null;this.setVerifiedAt(p);this.emit({type:"validated",isPro:false});return true}if((0,_api.isFatalLicenseError)(a.code)||!(0,_api.isAcceptedValidation)(n)){this.lock();this.state.isValidating=false;this.state.error=a.detail||"License could not be verified";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});await this.clearCachedLicense();await this.saveHold({key:i,code:a.code,detail:this.state.error,verdictAt:(0,_realNow.realNow)()});return false}if(!n.data){this.lock();this.state.isValidating=false;this.state.error=a.detail||"License not found";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});await this.clearCachedLicense();return false}const l=(0,_tier.resolveTier)(n.data);const _=n.data.id;const g=(0,_realNow.realNow)();const A=(0,_api.machineCount)(n)>=_config.LICENSE_FLEET_MACHINE_THRESHOLD;const v=(0,_fingerprint.isDevBundle)();const I=v&&!A;const R=l==="free"&&(A||!v);let d=this.cachedLicense?.fingerprint;let f=this.cachedLicense?.deviceName;let m=false;if(!d){d=await boundedStorage(this.getOrCreateDeviceFingerprint(),(0,_fingerprint.generateUUID)());if(s!==this.generation)return false;f=(0,_fingerprint.getDefaultDeviceName)();m=I}let y=false;if(m){if(this.deviceRegistrationCallback){this.pendingRegistration={licenseId:_,licenseKey:i,fingerprint:d};this.deviceRegistrationCallback({fingerprint:d,defaultName:f});y=true}else{this.registerDeviceAsync(_,i,d,f)}}const E={licenseKey:i,licenseId:_,valid:true,isPro:l==="pro",tier:l,expiresAt:n.data.attributes.expiry??null,cachedAt:g,lastValidatedAt:g,fingerprint:y?void 0:d,deviceName:y?void 0:f,quiet:R||void 0};const L=await this.saveCache(E,s);if(s!==this.generation||!L)return false;this.cachedLicense=L;this.applyTier(l);this.state.isValidating=false;this.state.expiresAt=E.expiresAt?new Date(E.expiresAt):null;this.setVerifiedAt(g);if(this.hold)await this.saveHold(null);if(s!==this.generation)return false;this.retryAttempt=0;this.emit({type:"validated",isPro:this.state.isPro});return true}catch(a){const h=a instanceof Error?a.message:"Validation failed";if(s!==this.generation)return false;this.state.isValidating=false;this.state.error=h;this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:h});return false}}scheduleRetry(e){this.cancelRetry();const t=_config.LICENSE_TRANSIENT_RETRY_DELAYS[this.retryAttempt];if(t===void 0)return;this.retryAttempt+=1;const i=this.generation;this.retryTimer=setTimeout(()=>{this.retryTimer=null;if(i!==this.generation)return;if(this.state.isValidating)return;void this.setLicenseKey(e,{force:true,isRetry:true})},t);if(typeof __DEV__!=="undefined"&&__DEV__){global.__LICENSE_MANAGER_RETRY_TIMER__=this.retryTimer}}async admitToken(e,t){const i=(0,_freeToken.verifyFreeToken)(e);if(t!==this.generation)return false;if(!i){this.lock();this.state.isValidating=false;this.state.error="This key is not valid. Check that it was copied completely.";this.state.errorKind="verdict";this.emit({type:"error",isPro:false,error:this.state.error});await this.clearCachedLicense();return false}const s=(0,_realNow.realNow)();const r=this.cachedLicense?.fingerprint??await boundedStorage(this.getOrCreateDeviceFingerprint(),(0,_fingerprint.generateUUID)());if(t!==this.generation)return false;const c=await this.saveCache({licenseKey:e,licenseId:`token:${i.accountHash}`,valid:true,isPro:false,tier:"free",expiresAt:null,cachedAt:s,lastValidatedAt:s,fingerprint:r,deviceName:this.cachedLicense?.deviceName??(0,_fingerprint.getDefaultDeviceName)(),quiet:true},t);if(t!==this.generation||!c)return false;this.cachedLicense=c;this.applyTier("free");this.state.isValidating=false;this.state.expiresAt=null;this.setVerifiedAt(s);this.retryAttempt=0;this.emit({type:"validated",isPro:false});return true}standDown(e,t,i,s){if(t!==this.generation)return false;this.state.isValidating=false;const r=this.cachedLicense;if(r&&r.licenseKey===e&&(0,_cacheSignature.verifyCacheSignature)(r)&&this.isCacheValid(r)){this.applyTier(tierOfCache(r));this.state.error=null;this.state.errorKind=null;this.state.expiresAt=r.expiresAt?new Date(r.expiresAt):null;this.setVerifiedAt(r.cachedAt);if(!this.isPro())this.scheduleRetryIn(e,s);this.emit({type:"validated",isPro:this.state.isPro});return true}this.state.error=i;this.state.errorKind="transport";this.scheduleRetryIn(e,s);this.emit({type:"error",isPro:this.state.isPro,error:i});return false}scheduleRetryIn(e,t){this.cancelRetry();const i=this.generation;this.retryTimer=setTimeout(()=>{this.retryTimer=null;if(i!==this.generation)return;if(this.state.isValidating)return;void this.setLicenseKey(e,{force:true,isRetry:true})},Math.max(1,Math.min(t,2147483647)));if(typeof __DEV__!=="undefined"&&__DEV__)devTimers.__LICENSE_MANAGER_RETRY_TIMER__=this.retryTimer}cancelRetry(){if(this.retryTimer){clearTimeout(this.retryTimer);this.retryTimer=null}}async clearLicense(){this.generation+=1;this.cancelRetry();this.retryAttempt=0;this.configuredKey=null;this.state.licenseKey=null;this.lock();this.state.expiresAt=null;this.state.error=null;this.state.errorKind=null;this.cachedLicense=null;this.pendingRegistration=null;this.state.isValidating=false;this.emit({type:"deactivated",isPro:false});await this.clearCachedLicense();if(this.hold?.verdictAt!==void 0){await this.saveHold(this.hold.backoffUntil?{backoffUntil:this.hold.backoffUntil}:null)}}applyTier(e){this.state.tier=e;this.state.tierSource="key";this.state.isPro=e==="pro"}lock(){this.state.tier="free";this.state.tierSource="none";this.state.isPro=false;this.verifiedAt=null;if(this.expiryTimer)clearTimeout(this.expiryTimer);this.expiryTimer=null}getTier(){if(!this.hasAccountAccess())return"free";if(this.state.expiresAt&&(0,_realNow.realNow)()>=this.state.expiresAt.getTime())return"free";return this.state.tier}isPro(){return this.getTier()==="pro"}hasEntitlement(e){return this.isPro()}getState(){const e=this.getAccountAccess();const t=this.getTier();return{...this.state,tier:t,isPro:t==="pro",access:e}}getAccountAccess(){return(0,_accountAccess.resolveAccountAccess)({initialized:this.state.isInitialized,validating:this.state.isValidating,key:this.state.licenseKey,tierSource:this.state.tierSource,verifiedAt:this.verifiedAt})}hasAccountAccess(){return this.getAccountAccess().status==="admitted"}setVerifiedAt(e){this.verifiedAt=e;if(this.expiryTimer)clearTimeout(this.expiryTimer);const t=e+_config.LICENSE_CACHE_DURATION;const i=this.state.expiresAt?.getTime();const s=i&&i>(0,_realNow.realNow)()?Math.min(t,i):t;const r=s-(0,_realNow.realNow)();this.expiryTimer=setTimeout(()=>{this.expiryTimer=null;if(this.verifiedAt!==e)return;this.emit({type:"validated",isPro:this.isPro()});if((0,_realNow.realNow)()<t)this.setVerifiedAt(e)},Math.max(1,Math.min(r,2147483647)));if(typeof __DEV__!=="undefined"&&__DEV__)devTimers.__LICENSE_MANAGER_EXPIRY_TIMER__=this.expiryTimer}subscribe(e){this.listeners.add(e);return()=>this.listeners.delete(e)}onDeviceRegistrationNeeded(e){this.deviceRegistrationCallback=e;return()=>{this.deviceRegistrationCallback=null}}async completeDeviceRegistration(e){if(!this.pendingRegistration){console.warn("[Buoy] No pending device registration");return}const{licenseId:t,licenseKey:i,fingerprint:s}=this.pendingRegistration;const r=this.generation;const c=e.trim()||(0,_fingerprint.getDefaultDeviceName)();const u=(0,_fingerprint.getDeviceMetadata)();try{await(0,_api.activateMachine)(t,i,s,c,u)}catch(n){const a=n instanceof Error?n.message:String(n);if(a==="FINGERPRINT_TAKEN"||a==="MACHINE_LIMIT_EXCEEDED"){}else{console.warn("[Buoy] Device registration failed:",a);throw n}}if(r!==this.generation)return;if(this.cachedLicense?.licenseKey===i){const n=await this.saveCache({...this.cachedLicense,fingerprint:s,deviceName:c},r);if(r!==this.generation)return;if(n)this.cachedLicense=n}this.pendingRegistration=null}emit(e){const t=[...this.listeners];t.forEach(i=>{try{i(e)}catch(s){console.warn("[React Buoy] License listener error:",s)}})}isCacheValid(e){const t=(0,_realNow.realNow)();const i=t-e.cachedAt;if(!e.valid||!Number.isFinite(e.cachedAt)||i<0||i>=_config.LICENSE_CACHE_DURATION){return false}return true}isCacheFresh(e){const t=this.isQuiet(e)?_config.LICENSE_QUIET_VALIDATION_TTL:_config.LICENSE_LAUNCH_VALIDATION_TTL;return(0,_realNow.realNow)()-(e.lastValidatedAt??0)<t}isQuiet(e){if(e.quiet!==void 0)return e.quiet;return tierOfCache(e)==="free"&&!(0,_fingerprint.isDevBundle)()}async loadHold(){if(this.hold!==void 0)return this.hold;try{const e=await(0,_storage.getLicenseStorage)();const t=await e.getItem(_config.LICENSE_HOLD_STORAGE_KEY);const i=t?JSON.parse(t):null;this.hold=i&&typeof i==="object"?i:null}catch{this.hold=null}return this.hold}async saveHold(e){this.hold=e;try{const t=await(0,_storage.getLicenseStorage)();if(e)await t.setItem(_config.LICENSE_HOLD_STORAGE_KEY,JSON.stringify(e));else await t.removeItem(_config.LICENSE_HOLD_STORAGE_KEY)}catch{}}async persistCache(e){const t=(0,_cacheSignature.signCache)(e);const i=await(0,_storage.getLicenseStorage)();await i.setItem(_config.LICENSE_STORAGE_KEY,JSON.stringify(t));return t}saveCache(e,t){const i=this.persistence.catch(()=>{}).then(async()=>{if(t!==this.generation)return null;const s=await this.persistCache(e);return t===this.generation?s:null});this.persistence=i;return boundedStorage(i,(0,_cacheSignature.signCache)(e))}async loadCachedLicense(){try{await this.persistence.catch(()=>{});const e=await(0,_storage.getLicenseStorage)();const t=await e.getItem(_config.LICENSE_STORAGE_KEY);if(!t)return null;const i=JSON.parse(t);return i}catch(e){console.warn("[Buoy] Error loading cached license:",e);return null}}getOrCreateDeviceFingerprint(){if(!this.fingerprintPromise){this.fingerprintPromise=(async()=>{const e=await(0,_storage.getLicenseStorage)();const t=await e.getItem(_config.DEVICE_FINGERPRINT_STORAGE_KEY);if(t)return t;const i=this.cachedLicense?.fingerprint||(0,_fingerprint.generateUUID)();await e.setItem(_config.DEVICE_FINGERPRINT_STORAGE_KEY,i);return i})()}return this.fingerprintPromise}async clearCachedLicense(){this.cachedLicense=null;const e=this.persistence.catch(()=>{}).then(async()=>{const t=await(0,_storage.getLicenseStorage)();await t.removeItem(_config.LICENSE_STORAGE_KEY)});this.persistence=e;await boundedStorage(e.catch(()=>{}),void 0)}registerDeviceAsync(e,t,i,s){const r=(0,_fingerprint.getDeviceMetadata)();(0,_api.activateMachine)(e,t,i,s,r).catch(c=>{if(c.message!=="FINGERPRINT_TAKEN"&&c.message!=="MACHINE_LIMIT_EXCEEDED"){console.warn("[Buoy] Device registration failed (non-blocking):",c.message)}})}validateInBackground(e){void this.setLicenseKey(e,{force:true,isRetry:true})}refreshAccess(){this.emit({type:"validated",isPro:this.isPro()})}startRevalidationTimer(){if(!this.removeForegroundListener){this.removeForegroundListener=(0,_foreground.subscribeForeground)(()=>this.refreshAccess());if(typeof __DEV__!=="undefined"&&__DEV__)devTimers.__LICENSE_MANAGER_FOREGROUND_OFF__=this.removeForegroundListener}if(this.revalidationTimer){clearInterval(this.revalidationTimer)}this.revalidationTimer=setInterval(()=>{if(!this.state.licenseKey||this.state.isValidating)return;const e=this.cachedLicense;if(e&&e.licenseKey===this.state.licenseKey&&this.isCacheFresh(e))return;this.validateInBackground(this.state.licenseKey)},_config.LICENSE_REVALIDATION_INTERVAL);if(typeof __DEV__!=="undefined"&&__DEV__){global.__LICENSE_MANAGER_TIMER__=this.revalidationTimer}}stopRevalidationTimer(){this.removeForegroundListener?.();this.removeForegroundListener=null;if(this.expiryTimer)clearTimeout(this.expiryTimer);this.expiryTimer=null;if(this.revalidationTimer){clearInterval(this.revalidationTimer);this.revalidationTimer=null}this.cancelRetry()}async forceReregister(){if(this.cachedLicense){this.cachedLicense.fingerprint=void 0;this.cachedLicense.deviceName=void 0}this.fingerprintPromise=null;await this.clearCachedLicense();try{const e=await(0,_storage.getLicenseStorage)();await e.removeItem(_config.DEVICE_FINGERPRINT_STORAGE_KEY)}catch{}}}const LicenseManager=exports.LicenseManager=new LicenseManagerImpl;const devTimers=globalThis;if(typeof __DEV__!=="undefined"&&__DEV__){devTimers.__LICENSE_MANAGER_FOREGROUND_OFF__?.();devTimers.__LICENSE_MANAGER_FOREGROUND_OFF__=void 0;if(devTimers.__LICENSE_MANAGER_EXPIRY_TIMER__)clearTimeout(devTimers.__LICENSE_MANAGER_EXPIRY_TIMER__);if(devTimers.__LICENSE_MANAGER_TIMER__){clearInterval(devTimers.__LICENSE_MANAGER_TIMER__)}if(devTimers.__LICENSE_MANAGER_RETRY_TIMER__){clearTimeout(devTimers.__LICENSE_MANAGER_RETRY_TIMER__);devTimers.__LICENSE_MANAGER_RETRY_TIMER__=void 0}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveAccountAccess=resolveAccountAccess;var _config=require("./config.js");function resolveAccountAccess(i,r=Date.now()){const e=i.verifiedAt!==null&&Number.isFinite(i.verifiedAt)&&i.verifiedAt<=r?i.verifiedAt+_config.LICENSE_CACHE_DURATION:null;if(i.initialized&&i.key&&i.tierSource!=="none"&&e!==null&&r<e){return{status:"admitted",reason:null,validUntil:e}}if(e!==null&&r>=e){return{status:"locked",reason:"verification_expired",validUntil:e}}if(!i.initialized||i.validating){return{status:"initializing",reason:"checking",validUntil:e}}return{status:"locked",reason:e!==null&&r>=e?"verification_expired":"account_required",validUntil:e}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveAccountAccess=resolveAccountAccess;var _config=require("./config.js");var _realNow=require("./realNow.js");function resolveAccountAccess(i,t=(0,_realNow.realNow)()){const e=i.verifiedAt!==null&&Number.isFinite(i.verifiedAt)&&i.verifiedAt<=t?i.verifiedAt+_config.LICENSE_CACHE_DURATION:null;if(i.initialized&&i.key&&i.tierSource!=="none"&&e!==null&&t<e){return{status:"admitted",reason:null,validUntil:e}}if(e!==null&&t>=e){return{status:"locked",reason:"verification_expired",validUntil:e}}if(!i.initialized||i.validating){return{status:"initializing",reason:"checking",validUntil:e}}return{status:"locked",reason:e!==null&&t>=e?"verification_expired":"account_required",validUntil:e}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LicenseTransportError=void 0;exports.activateMachine=activateMachine;exports.backoffAfter=backoffAfter;exports.isAcceptedValidation=isAcceptedValidation;exports.isFatalLicenseError=isFatalLicenseError;exports.isRateLimited=isRateLimited;exports.isTransientLicenseError=isTransientLicenseError;exports.machineCount=machineCount;exports.parseValidationResult=parseValidationResult;exports.validateLicense=validateLicense;var _config=require("./config.js");const{apiUrl}=_config.KEYGEN_CONFIG;class LicenseTransportError extends Error{isTransient=true;constructor(e,n,i=null){super(e);this.name="LicenseTransportError";this.status=n;this.retryAfterMs=i}}exports.LicenseTransportError=LicenseTransportError;function isRateLimited(t){const e=t?.status;return e===429||e===402}function backoffAfter(t,e,n){if(t.status===402)return e;return t.retryAfterMs??n}function readRetryAfter(t){const e=r=>{try{return t.headers?.get?.(r)??null}catch{return null}};const n=e("Retry-After");if(n){const r=Number(n);if(Number.isFinite(r)&&r>=0)return r*1e3;const a=Date.parse(n);if(Number.isFinite(a))return Math.max(0,a-Date.now())}const i=Number(e("X-RateLimit-Reset"));if(Number.isFinite(i)&&i>0)return Math.max(0,i*1e3-Date.now());return null}function isTransientLicenseError(t){if(t instanceof LicenseTransportError)return true;if(t instanceof TypeError)return true;return typeof t==="object"&&t!==null&&t.isTransient===true}async function describeFailure(t){try{const e=await t.json();return e.errors?.[0]?.detail||`HTTP ${t.status}`}catch{return`HTTP ${t.status}`}}function getBaseHeaders(){return{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json"}}async function requestValidation(t,e){const n=`${apiUrl}/validate`;const i={meta:{key:t}};let r;try{r=await fetch(n,{signal:e,method:"POST",headers:getBaseHeaders(),body:JSON.stringify(i)})}catch(a){throw new LicenseTransportError(a instanceof Error?a.message:"Network request failed",null)}if(!r.ok){throw new LicenseTransportError(await describeFailure(r),r.status,r.status===429?readRetryAfter(r):null)}try{const a=await r.json();if(!a||typeof a!=="object"||typeof a.meta?.valid!=="boolean"||typeof a.meta?.code!=="string"||!a.meta.code)throw new Error("Missing license verdict");return a}catch{throw new LicenseTransportError("License server returned an unreadable response",r.status)}}async function validateLicense(t){const e=typeof AbortController==="function"?new AbortController:null;let n;try{return await Promise.race([requestValidation(t,e?.signal),new Promise((i,r)=>{n=setTimeout(()=>{r(new LicenseTransportError("License verification timed out. Please retry.",null));e?.abort()},15e3)})])}finally{if(n)clearTimeout(n)}}function isAcceptedValidation(t){if(!t.data)return false;const e=t.data.relationships?.product?.data?.id;if(e&&e!==_config.KEYGEN_CONFIG.productId)return false;if(t.meta.valid&&t.meta.code==="VALID")return true;return["OVERDUE","NO_MACHINE","NO_MACHINES","TOO_MANY_MACHINES","TOO_MANY_CORES","TOO_MANY_PROCESSES","FINGERPRINT_SCOPE_MISMATCH","HEARTBEAT_NOT_STARTED","HEARTBEAT_DEAD"].includes(t.meta.code)}function machineCount(t){const e=t.data?.relationships?.machines?.meta?.count;return typeof e==="number"&&Number.isFinite(e)?e:0}async function activateMachine(t,e,n,i,r){const a=`${apiUrl}/machines`;const s=await fetch(a,{method:"POST",headers:getBaseHeaders(),body:JSON.stringify({licenseId:t,licenseKey:e,fingerprint:n,name:i,metadata:r||{}})});if(!s.ok){const o=await s.json();const c=o.errors?.[0]?.code;if(c==="FINGERPRINT_TAKEN"){throw new Error("FINGERPRINT_TAKEN")}if(c==="MACHINE_LIMIT_EXCEEDED"){throw new Error("MACHINE_LIMIT_EXCEEDED")}const u=o.errors?.[0]?.detail||`HTTP ${s.status}`;throw new Error(u)}return s.json()}function parseValidationResult(t){const{meta:e,data:n}=t;return{valid:e.valid,code:e.code,detail:e.detail,metadata:n?.attributes?.metadata}}function isFatalLicenseError(t){return["NOT_FOUND","SUSPENDED","EXPIRED","BANNED","PRODUCT_SCOPE_MISMATCH"].includes(t)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LicenseTransportError=void 0;exports.activateMachine=activateMachine;exports.backoffAfter=backoffAfter;exports.isAcceptedValidation=isAcceptedValidation;exports.isFatalLicenseError=isFatalLicenseError;exports.isRateLimited=isRateLimited;exports.isTransientLicenseError=isTransientLicenseError;exports.machineCount=machineCount;exports.parseValidationResult=parseValidationResult;exports.validateLicense=validateLicense;var _config=require("./config.js");var _realNow=require("./realNow.js");const{apiUrl}=_config.KEYGEN_CONFIG;class LicenseTransportError extends Error{isTransient=true;constructor(t,n,i=null){super(t);this.name="LicenseTransportError";this.status=n;this.retryAfterMs=i}}exports.LicenseTransportError=LicenseTransportError;function isRateLimited(e){const t=e?.status;return t===429||t===402}function backoffAfter(e,t,n){if(e.status===402)return t;return e.retryAfterMs??n}function readRetryAfter(e){const t=r=>{try{return e.headers?.get?.(r)??null}catch{return null}};const n=t("Retry-After");if(n){const r=Number(n);if(Number.isFinite(r)&&r>=0)return r*1e3;const a=Date.parse(n);if(Number.isFinite(a))return Math.max(0,a-(0,_realNow.realNow)())}const i=Number(t("X-RateLimit-Reset"));if(Number.isFinite(i)&&i>0)return Math.max(0,i*1e3-(0,_realNow.realNow)());return null}function isTransientLicenseError(e){if(e instanceof LicenseTransportError)return true;if(e instanceof TypeError)return true;return typeof e==="object"&&e!==null&&e.isTransient===true}async function describeFailure(e){try{const t=await e.json();return t.errors?.[0]?.detail||`HTTP ${e.status}`}catch{return`HTTP ${e.status}`}}function getBaseHeaders(){return{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json"}}async function requestValidation(e,t){const n=`${apiUrl}/validate`;const i={meta:{key:e}};let r;try{r=await fetch(n,{signal:t,method:"POST",headers:getBaseHeaders(),body:JSON.stringify(i)})}catch(a){throw new LicenseTransportError(a instanceof Error?a.message:"Network request failed",null)}if(!r.ok){throw new LicenseTransportError(await describeFailure(r),r.status,r.status===429?readRetryAfter(r):null)}try{const a=await r.json();if(!a||typeof a!=="object"||typeof a.meta?.valid!=="boolean"||typeof a.meta?.code!=="string"||!a.meta.code)throw new Error("Missing license verdict");return a}catch{throw new LicenseTransportError("License server returned an unreadable response",r.status)}}async function validateLicense(e){const t=typeof AbortController==="function"?new AbortController:null;let n;try{return await Promise.race([requestValidation(e,t?.signal),new Promise((i,r)=>{n=setTimeout(()=>{r(new LicenseTransportError("License verification timed out. Please retry.",null));t?.abort()},15e3)})])}finally{if(n)clearTimeout(n)}}function isAcceptedValidation(e){if(!e.data)return false;const t=e.data.relationships?.product?.data?.id;if(t&&t!==_config.KEYGEN_CONFIG.productId)return false;if(e.meta.valid&&e.meta.code==="VALID")return true;return["OVERDUE","NO_MACHINE","NO_MACHINES","TOO_MANY_MACHINES","TOO_MANY_CORES","TOO_MANY_PROCESSES","FINGERPRINT_SCOPE_MISMATCH","HEARTBEAT_NOT_STARTED","HEARTBEAT_DEAD"].includes(e.meta.code)}function machineCount(e){const t=e.data?.relationships?.machines?.meta?.count;return typeof t==="number"&&Number.isFinite(t)?t:0}async function activateMachine(e,t,n,i,r){const a=`${apiUrl}/machines`;const s=await fetch(a,{method:"POST",headers:getBaseHeaders(),body:JSON.stringify({licenseId:e,licenseKey:t,fingerprint:n,name:i,metadata:r||{}})});if(!s.ok){const o=await s.json();const c=o.errors?.[0]?.code;if(c==="FINGERPRINT_TAKEN"){throw new Error("FINGERPRINT_TAKEN")}if(c==="MACHINE_LIMIT_EXCEEDED"){throw new Error("MACHINE_LIMIT_EXCEEDED")}const u=o.errors?.[0]?.detail||`HTTP ${s.status}`;throw new Error(u)}return s.json()}function parseValidationResult(e){const{meta:t,data:n}=e;return{valid:t.valid,code:t.code,detail:t.detail,metadata:n?.attributes?.metadata}}function isFatalLicenseError(e){return["NOT_FOUND","SUSPENDED","EXPIRED","BANNED","PRODUCT_SCOPE_MISMATCH"].includes(e)}
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.cacheSignature=cacheSignature;exports.signCache=signCache;exports.verifyCacheSignature=verifyCacheSignature;/*!
2
- * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
- *
4
- * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
- * (https://buoy.gg/terms), not an OSS license.
6
- *
7
- * This file is part of the technological measure that controls access to paid
8
- * Buoy Pro features. Modifying, patching, aliasing, stubbing, or otherwise
9
- * altering it so that Pro features unlock without a valid license is a breach
10
- * of the EULA and, in the United States, circumvention of an access control
11
- * under 17 U.S.C. § 1201 — which applies whether or not any code is copied.
12
- *
13
- * Pro is $9/mo, and is free every weekend for anyone holding a key —
14
- * including a free one (`npx buoy login`). Buy a key at
15
- * https://buoy.gg or use it free on Saturday and Sunday.
16
- */const SIGNATURE_VERSION="v2";const LEGACY_VERSIONS=["v1"];const SIGNING_SALT="buoy.gg/pro:9f3c1d7a4b2e:license-cache";const FIELD_SEPARATOR="\0";function fnv1a(t,e){let n=e>>>0;for(let r=0;r<t.length;r++){n^=t.charCodeAt(r);n=Math.imul(n,16777619)>>>0}return n>>>0}function canonicalize(t,e){const n=[e,t.licenseKey,t.licenseId,t.isPro?"1":"0",t.expiresAt??"",String(t.cachedAt)];if(e!=="v1"){n.push(t.tier??"")}n.push(SIGNING_SALT);return n.join(FIELD_SEPARATOR)}function signatureFor(t,e){const n=canonicalize(t,e);const r=fnv1a(n,2166136261);const i=fnv1a(n,2135587861);return`${e}.${r.toString(16)}${i.toString(16)}`}function cacheSignature(t){return signatureFor(t,SIGNATURE_VERSION)}function signCache(t){return{...t,sig:cacheSignature(t)}}function verifyCacheSignature(t){if(!t||typeof t.sig!=="string"||t.sig.length===0){return false}if(t.sig===cacheSignature(t))return true;return LEGACY_VERSIONS.some(e=>t.sig.startsWith(`${e}.`)&&t.sig===signatureFor(t,e))}
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * This file is part of the technological measure that controls access to paid
8
+ * Buoy Pro features. Modifying, patching, aliasing, stubbing, or otherwise
9
+ * altering it so that Pro features unlock without a valid license is a breach
10
+ * of the EULA and, in the United States, circumvention of an access control
11
+ * under 17 U.S.C. § 1201 — which applies whether or not any code is copied.
12
+ *
13
+ * Pro is $9/mo, and is free every weekend for anyone holding a key —
14
+ * including a free one (`npx buoy login`). Buy a key at
15
+ * https://buoy.gg or use it free on Saturday and Sunday.
16
+ */const SIGNATURE_VERSION="v2";const LEGACY_VERSIONS=["v1"];const SIGNING_SALT="buoy.gg/pro:9f3c1d7a4b2e:license-cache";const FIELD_SEPARATOR="\0";function fnv1a(e,r){let n=r>>>0;for(let i=0;i<e.length;i++){n^=e.charCodeAt(i);n=Math.imul(n,16777619)>>>0}return n>>>0}function canonicalize(e,r){const n=[r,e.licenseKey,e.licenseId,e.isPro?"1":"0",e.expiresAt??"",String(e.cachedAt)];if(r!=="v1"){n.push(e.tier??"")}n.push(SIGNING_SALT);return n.join(FIELD_SEPARATOR)}function signatureFor(e,r){const n=canonicalize(e,r);const i=fnv1a(n,2166136261);const t=fnv1a(n,2135587861);return`${r}.${i.toString(16)}${t.toString(16)}`}function cacheSignature(e){return signatureFor(e,SIGNATURE_VERSION)}function signCache(e){return{...e,sig:cacheSignature(e)}}function verifyCacheSignature(e){if(!e||typeof e.sig!=="string"||e.sig.length===0){return false}if(e.sig===cacheSignature(e))return true;return LEGACY_VERSIONS.some(r=>e.sig.startsWith(`${r}.`)&&e.sig===signatureFor(e,r))}
@@ -1,17 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LICENSE_VERDICT_CACHE_DURATION=exports.LICENSE_TRANSIENT_RETRY_DELAYS=exports.LICENSE_STORAGE_KEY=exports.LICENSE_REVALIDATION_INTERVAL=exports.LICENSE_RATE_LIMIT_DEFAULT_WAIT=exports.LICENSE_QUOTA_COOLDOWN=exports.LICENSE_QUIET_VALIDATION_TTL=exports.LICENSE_LAUNCH_VALIDATION_TTL=exports.LICENSE_HOLD_STORAGE_KEY=exports.LICENSE_FLEET_MACHINE_THRESHOLD=exports.LICENSE_CACHE_DURATION=exports.KEYGEN_POLICIES=exports.KEYGEN_CONFIG=exports.FREE_TOKEN_PUBLIC_KEY=exports.DEVICE_FINGERPRINT_STORAGE_KEY=void 0;/*!
2
- * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
- *
4
- * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
- * (https://buoy.gg/terms), not an OSS license.
6
- *
7
- * This file configures the technological measure that controls access to paid
8
- * Buoy Pro features. Modifying, patching, aliasing, stubbing, or otherwise
9
- * altering it — including repointing `apiUrl` at a stand-in license server — so
10
- * that Pro features unlock without a valid license is a breach of the EULA and,
11
- * in the United States, circumvention of an access control under 17 U.S.C.
12
- * § 1201, which applies whether or not any code is copied.
13
- *
14
- * Pro is $9/mo, and is free every weekend for anyone holding a key —
15
- * including a free one (`npx buoy login`). Buy a key at
16
- * https://buoy.gg or use it free on Saturday and Sunday.
17
- */const KEYGEN_CONFIG=exports.KEYGEN_CONFIG={accountId:"b0eba0e8-e904-4906-b644-38f9aab57bed",productId:"bf67cb43-eeef-40ca-b308-e6e1b22c0eaa",apiUrl:"https://buoy.gg/api/license"};const FREE_TOKEN_PUBLIC_KEY=exports.FREE_TOKEN_PUBLIC_KEY="3b546fc717a62683f3236c70167899a271bee3ffc04df6ec1eea60a394a2f1e9";const KEYGEN_POLICIES=exports.KEYGEN_POLICIES={free:"394e3351-1249-4f73-807a-703408604c0e",solo:"fa5d3c8f-5379-40f1-b63e-ab8a974b2f28",business:"690c2212-8e54-426f-b4b4-002ee1c0ae2b"};const LICENSE_CACHE_DURATION=exports.LICENSE_CACHE_DURATION=30*24*60*60*1e3;const LICENSE_REVALIDATION_INTERVAL=exports.LICENSE_REVALIDATION_INTERVAL=24*60*60*1e3;const LICENSE_STORAGE_KEY=exports.LICENSE_STORAGE_KEY="buoy-gg-license";const DEVICE_FINGERPRINT_STORAGE_KEY=exports.DEVICE_FINGERPRINT_STORAGE_KEY="buoy-gg-device-fingerprint";const LICENSE_LAUNCH_VALIDATION_TTL=exports.LICENSE_LAUNCH_VALIDATION_TTL=60*60*1e3;const LICENSE_TRANSIENT_RETRY_DELAYS=exports.LICENSE_TRANSIENT_RETRY_DELAYS=[5*1e3,20*1e3,60*1e3,5*60*1e3,15*60*1e3];const LICENSE_RATE_LIMIT_DEFAULT_WAIT=exports.LICENSE_RATE_LIMIT_DEFAULT_WAIT=60*1e3;const LICENSE_QUOTA_COOLDOWN=exports.LICENSE_QUOTA_COOLDOWN=60*60*1e3;const LICENSE_VERDICT_CACHE_DURATION=exports.LICENSE_VERDICT_CACHE_DURATION=24*60*60*1e3;const LICENSE_FLEET_MACHINE_THRESHOLD=exports.LICENSE_FLEET_MACHINE_THRESHOLD=50;const LICENSE_QUIET_VALIDATION_TTL=exports.LICENSE_QUIET_VALIDATION_TTL=LICENSE_CACHE_DURATION;const LICENSE_HOLD_STORAGE_KEY=exports.LICENSE_HOLD_STORAGE_KEY="buoy-gg-license-hold";
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * This file configures the technological measure that controls access to paid
8
+ * Buoy Pro features. Modifying, patching, aliasing, stubbing, or otherwise
9
+ * altering it — including repointing `apiUrl` at a stand-in license server — so
10
+ * that Pro features unlock without a valid license is a breach of the EULA and,
11
+ * in the United States, circumvention of an access control under 17 U.S.C.
12
+ * § 1201, which applies whether or not any code is copied.
13
+ *
14
+ * Pro is $9/mo, and is free every weekend for anyone holding a key —
15
+ * including a free one (`npx buoy login`). Buy a key at
16
+ * https://buoy.gg or use it free on Saturday and Sunday.
17
+ */const KEYGEN_CONFIG=exports.KEYGEN_CONFIG={accountId:"b0eba0e8-e904-4906-b644-38f9aab57bed",productId:"bf67cb43-eeef-40ca-b308-e6e1b22c0eaa",apiUrl:"https://buoy.gg/api/license"};const FREE_TOKEN_PUBLIC_KEY=exports.FREE_TOKEN_PUBLIC_KEY="3b546fc717a62683f3236c70167899a271bee3ffc04df6ec1eea60a394a2f1e9";const KEYGEN_POLICIES=exports.KEYGEN_POLICIES={free:"394e3351-1249-4f73-807a-703408604c0e",solo:"fa5d3c8f-5379-40f1-b63e-ab8a974b2f28",business:"690c2212-8e54-426f-b4b4-002ee1c0ae2b"};const LICENSE_CACHE_DURATION=exports.LICENSE_CACHE_DURATION=30*24*60*60*1e3;const LICENSE_REVALIDATION_INTERVAL=exports.LICENSE_REVALIDATION_INTERVAL=24*60*60*1e3;const LICENSE_STORAGE_KEY=exports.LICENSE_STORAGE_KEY="buoy-gg-license";const DEVICE_FINGERPRINT_STORAGE_KEY=exports.DEVICE_FINGERPRINT_STORAGE_KEY="buoy-gg-device-fingerprint";const LICENSE_LAUNCH_VALIDATION_TTL=exports.LICENSE_LAUNCH_VALIDATION_TTL=60*60*1e3;const LICENSE_TRANSIENT_RETRY_DELAYS=exports.LICENSE_TRANSIENT_RETRY_DELAYS=[5*1e3,20*1e3,60*1e3,5*60*1e3,15*60*1e3];const LICENSE_RATE_LIMIT_DEFAULT_WAIT=exports.LICENSE_RATE_LIMIT_DEFAULT_WAIT=60*1e3;const LICENSE_QUOTA_COOLDOWN=exports.LICENSE_QUOTA_COOLDOWN=60*60*1e3;const LICENSE_VERDICT_CACHE_DURATION=exports.LICENSE_VERDICT_CACHE_DURATION=24*60*60*1e3;const LICENSE_FLEET_MACHINE_THRESHOLD=exports.LICENSE_FLEET_MACHINE_THRESHOLD=50;const LICENSE_QUIET_VALIDATION_TTL=exports.LICENSE_QUIET_VALIDATION_TTL=LICENSE_CACHE_DURATION;const LICENSE_HOLD_STORAGE_KEY=exports.LICENSE_HOLD_STORAGE_KEY="buoy-gg-license-hold";
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FREE_TOKEN_PREFIX=void 0;exports.__setFreeTokenPublicKeyForTests=__setFreeTokenPublicKeyForTests;exports.accountHashFor=accountHashFor;exports.isBuoyToken=isBuoyToken;exports.mintFreeToken=mintFreeToken;exports.publicKeyFor=publicKeyFor;exports.verifyFreeToken=verifyFreeToken;var _tweetnacl=_interopRequireDefault(require("tweetnacl"));var _config=require("./config.js");function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}/*!
2
- * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
- *
4
- * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
- * (https://buoy.gg/terms), not an OSS license.
6
- */const FREE_TOKEN_PREFIX=exports.FREE_TOKEN_PREFIX="BUOY1";const FREE_TOKEN_VERSION=1;const FREE_TOKEN_TIER_FREE=1;const FREE_TOKEN_DOMAIN="buoy-free-token-v1:";const PAYLOAD_LENGTH=22;const SIGNATURE_LENGTH=64;const TOKEN_PATTERN=/^BUOY1-([A-Z2-7]+)-([A-Z2-7]+)$/;function isBuoyToken(t){return TOKEN_PATTERN.test(t.trim().toUpperCase())}const B32="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function base32Encode(t){let r="";let e=0;let n=0;for(const o of t){n=n<<8|o;e+=8;while(e>=5){r+=B32[n>>>e-5&31];e-=5}}if(e>0)r+=B32[n<<5-e&31];return r}function base32Decode(t){const r=[];let e=0;let n=0;for(const o of t){const s=B32.indexOf(o);if(s===-1)return null;n=n<<5|s;e+=5;if(e>=8){r.push(n>>>e-8&255);e-=8}}return new Uint8Array(r)}function hexToBytes(t){const r=t.trim().toLowerCase();const e=new Uint8Array(r.length/2);for(let n=0;n<e.length;n+=1)e[n]=parseInt(r.slice(n*2,n*2+2),16);return e}function bytesToHex(t){let r="";for(const e of t)r+=e.toString(16).padStart(2,"0");return r}function utf8(t){if(typeof TextEncoder!=="undefined")return new TextEncoder().encode(t);const r=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)r[e]=t.charCodeAt(e)&255;return r}function concat(t,r){const e=new Uint8Array(t.length+r.length);e.set(t,0);e.set(r,t.length);return e}function signedMessage(t){return concat(utf8(FREE_TOKEN_DOMAIN),t)}function accountHashFor(t){return _tweetnacl.default.hash(utf8(t)).slice(0,16)}function encodePayload(t,r){const e=new Uint8Array(PAYLOAD_LENGTH);e[0]=FREE_TOKEN_VERSION;e[1]=FREE_TOKEN_TIER_FREE;const n=Math.max(0,Math.min(4294967295,Math.floor(t)));e[2]=n>>>24&255;e[3]=n>>>16&255;e[4]=n>>>8&255;e[5]=n&255;e.set(r.slice(0,16),6);return e}function mintFreeToken(t,r,e){const n=encodePayload(r/1e3,accountHashFor(t));const{secretKey:o}=_tweetnacl.default.sign.keyPair.fromSeed(hexToBytes(e));const s=_tweetnacl.default.sign.detached(signedMessage(n),o);return`${FREE_TOKEN_PREFIX}-${base32Encode(n)}-${base32Encode(s)}`}function publicKeyFor(t){return bytesToHex(_tweetnacl.default.sign.keyPair.fromSeed(hexToBytes(t)).publicKey)}let activePublicKey=_config.FREE_TOKEN_PUBLIC_KEY;function __setFreeTokenPublicKeyForTests(t){activePublicKey=t??_config.FREE_TOKEN_PUBLIC_KEY}function verifyFreeToken(t,r=activePublicKey){const e=TOKEN_PATTERN.exec(t.trim().toUpperCase());if(!e)return null;const n=base32Decode(e[1]);const o=base32Decode(e[2]);if(!n||!o)return null;if(n.length!==PAYLOAD_LENGTH||o.length!==SIGNATURE_LENGTH)return null;if(n[0]!==FREE_TOKEN_VERSION||n[1]!==FREE_TOKEN_TIER_FREE)return null;try{if(!_tweetnacl.default.sign.detached.verify(signedMessage(n),o,hexToBytes(r)))return null}catch{return null}const s=(n[2]<<24>>>0)+(n[3]<<16)+(n[4]<<8)+n[5];return{tier:"free",issuedAt:s*1e3,accountHash:bytesToHex(n.slice(6,22))}}
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ */const FREE_TOKEN_PREFIX=exports.FREE_TOKEN_PREFIX="BUOY1";const FREE_TOKEN_VERSION=1;const FREE_TOKEN_TIER_FREE=1;const FREE_TOKEN_DOMAIN="buoy-free-token-v1:";const PAYLOAD_LENGTH=22;const SIGNATURE_LENGTH=64;const TOKEN_PATTERN=/^BUOY1-([A-Z2-7]+)-([A-Z2-7]+)$/;function isBuoyToken(t){return TOKEN_PATTERN.test(t.trim().toUpperCase())}const B32="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function base32Encode(t){let r="";let e=0;let n=0;for(const o of t){n=n<<8|o;e+=8;while(e>=5){r+=B32[n>>>e-5&31];e-=5}}if(e>0)r+=B32[n<<5-e&31];return r}function base32Decode(t){const r=[];let e=0;let n=0;for(const o of t){const s=B32.indexOf(o);if(s===-1)return null;n=n<<5|s;e+=5;if(e>=8){r.push(n>>>e-8&255);e-=8}}return new Uint8Array(r)}function hexToBytes(t){const r=t.trim().toLowerCase();const e=new Uint8Array(r.length/2);for(let n=0;n<e.length;n+=1)e[n]=parseInt(r.slice(n*2,n*2+2),16);return e}function bytesToHex(t){let r="";for(const e of t)r+=e.toString(16).padStart(2,"0");return r}function utf8(t){if(typeof TextEncoder!=="undefined")return new TextEncoder().encode(t);const r=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)r[e]=t.charCodeAt(e)&255;return r}function concat(t,r){const e=new Uint8Array(t.length+r.length);e.set(t,0);e.set(r,t.length);return e}function signedMessage(t){return concat(utf8(FREE_TOKEN_DOMAIN),t)}function accountHashFor(t){return _tweetnacl.default.hash(utf8(t)).slice(0,16)}function encodePayload(t,r){const e=new Uint8Array(PAYLOAD_LENGTH);e[0]=FREE_TOKEN_VERSION;e[1]=FREE_TOKEN_TIER_FREE;const n=Math.max(0,Math.min(4294967295,Math.floor(t)));e[2]=n>>>24&255;e[3]=n>>>16&255;e[4]=n>>>8&255;e[5]=n&255;e.set(r.slice(0,16),6);return e}function mintFreeToken(t,r,e){const n=encodePayload(r/1e3,accountHashFor(t));const{secretKey:o}=_tweetnacl.default.sign.keyPair.fromSeed(hexToBytes(e));const s=_tweetnacl.default.sign.detached(signedMessage(n),o);return`${FREE_TOKEN_PREFIX}-${base32Encode(n)}-${base32Encode(s)}`}function publicKeyFor(t){return bytesToHex(_tweetnacl.default.sign.keyPair.fromSeed(hexToBytes(t)).publicKey)}let activePublicKey=_config.FREE_TOKEN_PUBLIC_KEY;function __setFreeTokenPublicKeyForTests(t){activePublicKey=t??_config.FREE_TOKEN_PUBLIC_KEY}function verifyFreeToken(t,r=activePublicKey){const e=TOKEN_PATTERN.exec(t.trim().toUpperCase());if(!e)return null;const n=base32Decode(e[1]);const o=base32Decode(e[2]);if(!n||!o)return null;if(n.length!==PAYLOAD_LENGTH||o.length!==SIGNATURE_LENGTH)return null;if(n[0]!==FREE_TOKEN_VERSION||n[1]!==FREE_TOKEN_TIER_FREE)return null;try{if(!_tweetnacl.default.sign.detached.verify(signedMessage(n),o,hexToBytes(r)))return null}catch{return null}const s=(n[2]<<24>>>0)+(n[3]<<16)+(n[4]<<8)+n[5];return{tier:"free",issuedAt:s*1e3,accountHash:bytesToHex(n.slice(6,22))}}
@@ -1,17 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useAccountAccess=useAccountAccess;exports.useFeatureAccess=useFeatureAccess;exports.useIsPro=useIsPro;exports.useLicense=useLicense;exports.useProAccess=useProAccess;exports.useTier=useTier;var _react=require("react");var _LicenseManager=require("./LicenseManager.js");var _weekendPro=require("./weekendPro.js");/*!
2
- * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
- *
4
- * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
- * (https://buoy.gg/terms), not an OSS license.
6
- *
7
- * This file is the technological measure that controls access to paid Buoy Pro
8
- * features: `useIsPro()` here is the single gate every Buoy tool consults.
9
- * Modifying, patching, aliasing, stubbing, or otherwise altering it so that Pro
10
- * features unlock without a valid license is a breach of the EULA and, in the
11
- * United States, circumvention of an access control under 17 U.S.C. § 1201 —
12
- * which applies whether or not any code is copied.
13
- *
14
- * Pro is $9/mo, and is free every weekend for anyone holding a key —
15
- * including a free one (`npx buoy login`). Buy a key at
16
- * https://buoy.gg or use it free on Saturday and Sunday.
17
- */function useLicense(){const[n,e]=(0,_react.useState)(_LicenseManager.LicenseManager.getState());(0,_react.useEffect)(()=>{const t=_LicenseManager.LicenseManager.subscribe(c=>{e(_LicenseManager.LicenseManager.getState())});_LicenseManager.LicenseManager.initialize().then(()=>{e(_LicenseManager.LicenseManager.getState())});return t},[]);const r=(0,_react.useCallback)(async t=>{const c=await _LicenseManager.LicenseManager.setLicenseKey(t,{force:true});e(_LicenseManager.LicenseManager.getState());return c},[]);const s=(0,_react.useCallback)(async()=>{await _LicenseManager.LicenseManager.clearLicense();e(_LicenseManager.LicenseManager.getState())},[]);return{...n,setLicenseKey:r,clearLicense:s}}function useAccountAccess(){return useLicense().access}function useTier(){const{tier:n,isInitialized:e}=useLicense();return e?n:"free"}function useFeatureAccess(n){const{isPro:e,isInitialized:r,isValidating:s}=useLicense();const t=e;const c=!r||s;return{hasAccess:t,isPro:e,isLoading:c}}function useIsPro(){const{isPro:n,isInitialized:e,access:r}=useLicense();const s=(0,_weekendPro.weekendPassAppliesTo)(r.status==="admitted",(0,_weekendPro.useWeekendFreePro)());return e&&n||s}function useProAccess(){const{isPro:n,isInitialized:e,access:r}=useLicense();const s=e&&n;const t=(0,_weekendPro.weekendPassAppliesTo)(r.status==="admitted",(0,_weekendPro.useWeekendFreePro)())&&!s;const c=s?"licensed":t?"weekend":null;return{isPro:s||t,isLicensed:s,isWeekendFree:t,reason:c}}
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * This file is the technological measure that controls access to paid Buoy Pro
8
+ * features: `useIsPro()` here is the single gate every Buoy tool consults.
9
+ * Modifying, patching, aliasing, stubbing, or otherwise altering it so that Pro
10
+ * features unlock without a valid license is a breach of the EULA and, in the
11
+ * United States, circumvention of an access control under 17 U.S.C. § 1201 —
12
+ * which applies whether or not any code is copied.
13
+ *
14
+ * Pro is $9/mo, and is free every weekend for anyone holding a key —
15
+ * including a free one (`npx buoy login`). Buy a key at
16
+ * https://buoy.gg or use it free on Saturday and Sunday.
17
+ */function useLicense(){const[t,e]=(0,_react.useState)(_LicenseManager.LicenseManager.getState());(0,_react.useEffect)(()=>{const n=_LicenseManager.LicenseManager.subscribe(r=>{e(_LicenseManager.LicenseManager.getState())});_LicenseManager.LicenseManager.initialize().then(()=>{e(_LicenseManager.LicenseManager.getState())});return n},[]);const c=(0,_react.useCallback)(async n=>{const r=await _LicenseManager.LicenseManager.setLicenseKey(n,{force:true});e(_LicenseManager.LicenseManager.getState());return r},[]);const s=(0,_react.useCallback)(async()=>{await _LicenseManager.LicenseManager.clearLicense();e(_LicenseManager.LicenseManager.getState())},[]);return{...t,setLicenseKey:c,clearLicense:s}}function useAccountAccess(){return useLicense().access}function useTier(){const{tier:t,isInitialized:e}=useLicense();return e?t:"free"}function useFeatureAccess(t){const{isPro:e,isInitialized:c,isValidating:s}=useLicense();const n=e;const r=!c||s;return{hasAccess:n,isPro:e,isLoading:r}}function useIsPro(){const{isPro:t,isInitialized:e,access:c}=useLicense();const s=(0,_weekendPro.weekendPassAppliesTo)(c.status==="admitted",(0,_weekendPro.useWeekendFreePro)());return e&&t||s}function useProAccess(){const{isPro:t,isInitialized:e,access:c}=useLicense();const s=e&&t;const n=(0,_weekendPro.weekendPassAppliesTo)(c.status==="admitted",(0,_weekendPro.useWeekendFreePro)())&&!s;const r=s?"licensed":n?"weekend":null;return{isPro:s||n,isLicensed:s,isWeekendFree:n,reason:r}}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"DeviceRegistrationModal",{enumerable:true,get:function(){return _DeviceRegistrationModal.DeviceRegistrationModal}});Object.defineProperty(exports,"LicenseManager",{enumerable:true,get:function(){return _LicenseManager.LicenseManager}});Object.defineProperty(exports,"LicenseTransportError",{enumerable:true,get:function(){return _api.LicenseTransportError}});exports.hasEntitlement=hasEntitlement;Object.defineProperty(exports,"isBuoyToken",{enumerable:true,get:function(){return _freeToken.isBuoyToken}});exports.isPro=isPro;Object.defineProperty(exports,"isTransientLicenseError",{enumerable:true,get:function(){return _api.isTransientLicenseError}});Object.defineProperty(exports,"isWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.isWeekendFreePro}});Object.defineProperty(exports,"resolveAccountAccess",{enumerable:true,get:function(){return _accountAccess.resolveAccountAccess}});exports.setLicenseKey=setLicenseKey;Object.defineProperty(exports,"useAccountAccess",{enumerable:true,get:function(){return _hooks.useAccountAccess}});Object.defineProperty(exports,"useFeatureAccess",{enumerable:true,get:function(){return _hooks.useFeatureAccess}});Object.defineProperty(exports,"useIsPro",{enumerable:true,get:function(){return _hooks.useIsPro}});Object.defineProperty(exports,"useLicense",{enumerable:true,get:function(){return _hooks.useLicense}});Object.defineProperty(exports,"useProAccess",{enumerable:true,get:function(){return _hooks.useProAccess}});Object.defineProperty(exports,"useTier",{enumerable:true,get:function(){return _hooks.useTier}});Object.defineProperty(exports,"useWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.useWeekendFreePro}});var _LicenseManager=require("./LicenseManager.js");var _DeviceRegistrationModal=require("./DeviceRegistrationModal.js");var _hooks=require("./hooks.js");var _accountAccess=require("./accountAccess.js");var _api=require("./api.js");var _freeToken=require("./freeToken.js");var _weekendPro=require("./weekendPro.js");function _interopRequireWildcard(r,t){if("function"==typeof WeakMap)var u=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,c){if(!c&&e&&e.__esModule)return e;var n,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(n=c?a:u){if(n.has(e))return n.get(e);n.set(e,o)}for(const s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?n(o,s,i):o[s]=e[s]);return o})(r,t)}/*!
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"DeviceRegistrationModal",{enumerable:true,get:function(){return _DeviceRegistrationModal.DeviceRegistrationModal}});Object.defineProperty(exports,"LicenseManager",{enumerable:true,get:function(){return _LicenseManager.LicenseManager}});Object.defineProperty(exports,"LicenseTransportError",{enumerable:true,get:function(){return _api.LicenseTransportError}});exports.hasEntitlement=hasEntitlement;Object.defineProperty(exports,"isBuoyToken",{enumerable:true,get:function(){return _freeToken.isBuoyToken}});exports.isPro=isPro;Object.defineProperty(exports,"isTransientLicenseError",{enumerable:true,get:function(){return _api.isTransientLicenseError}});Object.defineProperty(exports,"isWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.isWeekendFreePro}});Object.defineProperty(exports,"resolveAccountAccess",{enumerable:true,get:function(){return _accountAccess.resolveAccountAccess}});exports.setLicenseKey=setLicenseKey;Object.defineProperty(exports,"useAccountAccess",{enumerable:true,get:function(){return _hooks.useAccountAccess}});Object.defineProperty(exports,"useFeatureAccess",{enumerable:true,get:function(){return _hooks.useFeatureAccess}});Object.defineProperty(exports,"useIsPro",{enumerable:true,get:function(){return _hooks.useIsPro}});Object.defineProperty(exports,"useLicense",{enumerable:true,get:function(){return _hooks.useLicense}});Object.defineProperty(exports,"useProAccess",{enumerable:true,get:function(){return _hooks.useProAccess}});Object.defineProperty(exports,"useTier",{enumerable:true,get:function(){return _hooks.useTier}});Object.defineProperty(exports,"useWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.useWeekendFreePro}});var _LicenseManager=require("./LicenseManager.js");var _DeviceRegistrationModal=require("./DeviceRegistrationModal.js");var _hooks=require("./hooks.js");var _accountAccess=require("./accountAccess.js");var _api=require("./api.js");var _freeToken=require("./freeToken.js");var _weekendPro=require("./weekendPro.js");function _interopRequireWildcard(r,t){if("function"==typeof WeakMap)var i=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,c){if(!c&&e&&e.__esModule)return e;var n,u,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(n=c?a:i){if(n.has(e))return n.get(e);n.set(e,o)}for(const s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((u=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,s))&&(u.get||u.set)?n(o,s,u):o[s]=e[s]);return o})(r,t)}/*!
2
2
  * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
3
  *
4
4
  * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
@@ -15,4 +15,4 @@
15
15
  * Pro is $9/mo, and is free every weekend for anyone holding a key —
16
16
  * including a free one (`npx buoy login`). Buy a key at
17
17
  * https://buoy.gg or use it free on Saturday and Sunday.
18
- */async function setLicenseKey(r){const{LicenseManager:t}=await Promise.resolve().then(()=>_interopRequireWildcard(require("./LicenseManager")));await t.initialize();return t.setLicenseKey(r)}function weekendPassActive(){const{isWeekendFreePro:r,weekendPassAppliesTo:t}=require("./weekendPro");const{LicenseManager:u}=require("./LicenseManager");return t(u.hasAccountAccess(),r())}function isPro(){const{LicenseManager:r}=require("./LicenseManager");if(r.isPro())return true;return weekendPassActive()}function hasEntitlement(r){const{LicenseManager:t}=require("./LicenseManager");if(t.hasEntitlement(r))return true;return weekendPassActive()}
18
+ */async function setLicenseKey(r){const{LicenseManager:t}=await Promise.resolve().then(()=>_interopRequireWildcard(require("./LicenseManager")));await t.initialize();return t.setLicenseKey(r)}function weekendPassActive(){const{isWeekendFreePro:r,weekendPassAppliesTo:t}=require("./weekendPro");const{LicenseManager:i}=require("./LicenseManager");return t(i.hasAccountAccess(),r())}function isPro(){const{LicenseManager:r}=require("./LicenseManager");if(r.isPro())return true;return weekendPassActive()}function hasEntitlement(r){const{LicenseManager:t}=require("./LicenseManager");if(t.hasEntitlement(r))return true;return weekendPassActive()}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"LicenseManager",{enumerable:true,get:function(){return _LicenseManager.LicenseManager}});Object.defineProperty(exports,"LicenseTransportError",{enumerable:true,get:function(){return _api.LicenseTransportError}});exports.hasEntitlement=hasEntitlement;Object.defineProperty(exports,"isBuoyToken",{enumerable:true,get:function(){return _freeToken.isBuoyToken}});exports.isPro=isPro;Object.defineProperty(exports,"isTransientLicenseError",{enumerable:true,get:function(){return _api.isTransientLicenseError}});Object.defineProperty(exports,"isWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.isWeekendFreePro}});Object.defineProperty(exports,"resolveAccountAccess",{enumerable:true,get:function(){return _accountAccess.resolveAccountAccess}});exports.setLicenseKey=setLicenseKey;Object.defineProperty(exports,"useAccountAccess",{enumerable:true,get:function(){return _hooks.useAccountAccess}});Object.defineProperty(exports,"useFeatureAccess",{enumerable:true,get:function(){return _hooks.useFeatureAccess}});Object.defineProperty(exports,"useIsPro",{enumerable:true,get:function(){return _hooks.useIsPro}});Object.defineProperty(exports,"useLicense",{enumerable:true,get:function(){return _hooks.useLicense}});Object.defineProperty(exports,"useProAccess",{enumerable:true,get:function(){return _hooks.useProAccess}});Object.defineProperty(exports,"useTier",{enumerable:true,get:function(){return _hooks.useTier}});Object.defineProperty(exports,"useWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.useWeekendFreePro}});var _LicenseManager=require("./LicenseManager.js");var _weekendPro=require("./weekendPro.js");var _hooks=require("./hooks.js");var _accountAccess=require("./accountAccess.js");var _api=require("./api.js");var _freeToken=require("./freeToken.js");function _interopRequireWildcard(n,u){if("function"==typeof WeakMap)var c=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,i){if(!i&&e&&e.__esModule)return e;var r,o,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(r=i?a:c){if(r.has(e))return r.get(e);r.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((o=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(o.get||o.set)?r(s,t,o):s[t]=e[t]);return s})(n,u)}/*!
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"LicenseManager",{enumerable:true,get:function(){return _LicenseManager.LicenseManager}});Object.defineProperty(exports,"LicenseTransportError",{enumerable:true,get:function(){return _api.LicenseTransportError}});exports.hasEntitlement=hasEntitlement;Object.defineProperty(exports,"isBuoyToken",{enumerable:true,get:function(){return _freeToken.isBuoyToken}});exports.isPro=isPro;Object.defineProperty(exports,"isTransientLicenseError",{enumerable:true,get:function(){return _api.isTransientLicenseError}});Object.defineProperty(exports,"isWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.isWeekendFreePro}});Object.defineProperty(exports,"resolveAccountAccess",{enumerable:true,get:function(){return _accountAccess.resolveAccountAccess}});exports.setLicenseKey=setLicenseKey;Object.defineProperty(exports,"useAccountAccess",{enumerable:true,get:function(){return _hooks.useAccountAccess}});Object.defineProperty(exports,"useFeatureAccess",{enumerable:true,get:function(){return _hooks.useFeatureAccess}});Object.defineProperty(exports,"useIsPro",{enumerable:true,get:function(){return _hooks.useIsPro}});Object.defineProperty(exports,"useLicense",{enumerable:true,get:function(){return _hooks.useLicense}});Object.defineProperty(exports,"useProAccess",{enumerable:true,get:function(){return _hooks.useProAccess}});Object.defineProperty(exports,"useTier",{enumerable:true,get:function(){return _hooks.useTier}});Object.defineProperty(exports,"useWeekendFreePro",{enumerable:true,get:function(){return _weekendPro.useWeekendFreePro}});var _LicenseManager=require("./LicenseManager.js");var _weekendPro=require("./weekendPro.js");var _hooks=require("./hooks.js");var _accountAccess=require("./accountAccess.js");var _api=require("./api.js");var _freeToken=require("./freeToken.js");function _interopRequireWildcard(n,u){if("function"==typeof WeakMap)var i=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,c){if(!c&&e&&e.__esModule)return e;var r,o,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(r=c?a:i){if(r.has(e))return r.get(e);r.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((o=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(o.get||o.set)?r(s,t,o):s[t]=e[t]);return s})(n,u)}/*!
2
2
  * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
3
  *
4
4
  * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.realNow=realNow;function realNow(){const e=globalThis.__buoyRealNow;return typeof e==="function"?e():Date.now()}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getLicenseStorage=getLicenseStorage;const LICENSE_STORAGE_DIR="buoy-license";let _FileSystem=null;let _licenseStorage=null;const _memoryStore=new Map;function loadFileSystem(){if(_FileSystem)return _FileSystem;try{const e=require("expo-file-system/legacy");_FileSystem=e?.default||e;if(_FileSystem?.documentDirectory){return _FileSystem}_FileSystem=null}catch{}try{const e=require("expo-file-system");_FileSystem=e?.default||e;if(_FileSystem?.documentDirectory){return _FileSystem}_FileSystem=null}catch{}return null}function getLicenseStorageDir(){const e=loadFileSystem();if(!e?.documentDirectory)return null;return`${e.documentDirectory}${LICENSE_STORAGE_DIR}/`}function getLicenseFilePath(e){const n=getLicenseStorageDir();if(!n)return null;return`${n}${encodeURIComponent(e)}.json`}function loadAsyncStorage(){try{const e=require("@react-native-async-storage/async-storage");const n=e?.default||e;if(typeof n?.getItem==="function"&&typeof n.setItem==="function"&&typeof n.removeItem==="function"){return n}}catch{}return null}function hasLocalStorage(){try{return typeof localStorage!=="undefined"&&!!localStorage}catch{return false}}async function getLicenseStorage(){if(_licenseStorage)return _licenseStorage;const e=loadFileSystem();let n=null;if(e?.documentDirectory){_licenseStorage={async getItem(t){const r=getLicenseFilePath(t);if(!r)return null;try{const c=await e.getInfoAsync(r);if(!c.exists)return null;return await e.readAsStringAsync(r)}catch{return null}},async setItem(t,r){const c=getLicenseStorageDir();const o=getLicenseFilePath(t);if(!c||!o)return;try{const a=await e.getInfoAsync(c);if(!a.exists){await e.makeDirectoryAsync(c,{intermediates:true})}await e.writeAsStringAsync(o,r)}catch(a){console.warn("[Buoy] License storage write failed:",a)}},async removeItem(t){const r=getLicenseFilePath(t);if(!r)return;try{await e.deleteAsync(r,{idempotent:true})}catch{}}}}else if(n=loadAsyncStorage()){const t=n;_licenseStorage={async getItem(r){try{return await t.getItem(r)}catch{return null}},async setItem(r,c){try{await t.setItem(r,c)}catch(o){console.warn("[Buoy] License storage write failed:",o)}},async removeItem(r){try{await t.removeItem(r)}catch{}}}}else if(hasLocalStorage()){_licenseStorage={async getItem(t){try{return localStorage.getItem(t)}catch{return null}},async setItem(t,r){try{localStorage.setItem(t,r)}catch{}},async removeItem(t){try{localStorage.removeItem(t)}catch{}}}}else{_licenseStorage={async getItem(t){return _memoryStore.get(t)??null},async setItem(t,r){_memoryStore.set(t,r)},async removeItem(t){_memoryStore.delete(t)}}}return _licenseStorage}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getLicenseStorage=getLicenseStorage;const LICENSE_STORAGE_DIR="buoy-license";let _FileSystem=null;let _licenseStorage=null;const _memoryStore=new Map;function loadFileSystem(){if(_FileSystem)return _FileSystem;try{const e=require("expo-file-system/legacy");_FileSystem=e?.default||e;if(_FileSystem?.documentDirectory){return _FileSystem}_FileSystem=null}catch{}try{const e=require("expo-file-system");_FileSystem=e?.default||e;if(_FileSystem?.documentDirectory){return _FileSystem}_FileSystem=null}catch{}return null}function getLicenseStorageDir(){const e=loadFileSystem();if(!e?.documentDirectory)return null;return`${e.documentDirectory}${LICENSE_STORAGE_DIR}/`}function getLicenseFilePath(e){const r=getLicenseStorageDir();if(!r)return null;return`${r}${encodeURIComponent(e)}.json`}function loadAsyncStorage(){try{const e=require("@react-native-async-storage/async-storage");const r=e?.default||e;if(typeof r?.getItem==="function"&&typeof r.setItem==="function"&&typeof r.removeItem==="function"){return r}}catch{}return null}function hasLocalStorage(){try{return typeof localStorage!=="undefined"&&!!localStorage}catch{return false}}async function getLicenseStorage(){if(_licenseStorage)return _licenseStorage;const e=loadFileSystem();let r=null;if(e?.documentDirectory){_licenseStorage={async getItem(t){const n=getLicenseFilePath(t);if(!n)return null;try{const c=await e.getInfoAsync(n);if(!c.exists)return null;return await e.readAsStringAsync(n)}catch{return null}},async setItem(t,n){const c=getLicenseStorageDir();const o=getLicenseFilePath(t);if(!c||!o)return;try{const a=await e.getInfoAsync(c);if(!a.exists){await e.makeDirectoryAsync(c,{intermediates:true})}await e.writeAsStringAsync(o,n)}catch(a){console.warn("[Buoy] License storage write failed:",a)}},async removeItem(t){const n=getLicenseFilePath(t);if(!n)return;try{await e.deleteAsync(n,{idempotent:true})}catch{}}}}else if(r=loadAsyncStorage()){const t=r;_licenseStorage={async getItem(n){try{return await t.getItem(n)}catch{return null}},async setItem(n,c){try{await t.setItem(n,c)}catch(o){console.warn("[Buoy] License storage write failed:",o)}},async removeItem(n){try{await t.removeItem(n)}catch{}}}}else if(hasLocalStorage()){_licenseStorage={async getItem(t){try{return localStorage.getItem(t)}catch{return null}},async setItem(t,n){try{localStorage.setItem(t,n)}catch{}},async removeItem(t){try{localStorage.removeItem(t)}catch{}}}}else{_licenseStorage={async getItem(t){return _memoryStore.get(t)??null},async setItem(t,n){_memoryStore.set(t,n)},async removeItem(t){_memoryStore.delete(t)}}}return _licenseStorage}
@@ -1,17 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isRecognizedAccount=isRecognizedAccount;exports.resolveTier=resolveTier;exports.tierAfterFatalError=tierAfterFatalError;var _config=require("./config.js");/*!
2
- * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
- *
4
- * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
- * (https://buoy.gg/terms), not an OSS license.
6
- *
7
- * This file is part of the technological measure that controls access to paid
8
- * Buoy Pro features: it decides which tier a validated key grants. Modifying,
9
- * patching, aliasing, stubbing, or otherwise altering it so that Pro features
10
- * unlock without a valid license is a breach of the EULA and, in the United
11
- * States, circumvention of an access control under 17 U.S.C. § 1201 — which
12
- * applies whether or not any code is copied.
13
- *
14
- * Pro is $9/mo, and is free every weekend for anyone holding a key —
15
- * including a free one (`npx buoy login`). Buy a key at
16
- * https://buoy.gg or use it free on Saturday and Sunday.
17
- */function resolveTier(r){const e=r.relationships?.policy?.data?.id;if(e===_config.KEYGEN_POLICIES.free)return"free";if(e===_config.KEYGEN_POLICIES.solo||e===_config.KEYGEN_POLICIES.business){return"pro"}const t=r.attributes?.metadata?.plan;if(t==="free")return"free";return"pro"}function tierAfterFatalError(r){return r==="EXPIRED"?"free":null}function isRecognizedAccount(r){if(!r)return false;const e=r.relationships?.product?.data?.id;if(e)return e===_config.KEYGEN_CONFIG.productId;const t=r.relationships?.policy?.data?.id;return Object.values(_config.KEYGEN_POLICIES).some(o=>o===t)}
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * This file is part of the technological measure that controls access to paid
8
+ * Buoy Pro features: it decides which tier a validated key grants. Modifying,
9
+ * patching, aliasing, stubbing, or otherwise altering it so that Pro features
10
+ * unlock without a valid license is a breach of the EULA and, in the United
11
+ * States, circumvention of an access control under 17 U.S.C. § 1201 — which
12
+ * applies whether or not any code is copied.
13
+ *
14
+ * Pro is $9/mo, and is free every weekend for anyone holding a key —
15
+ * including a free one (`npx buoy login`). Buy a key at
16
+ * https://buoy.gg or use it free on Saturday and Sunday.
17
+ */function resolveTier(e){const r=e.relationships?.policy?.data?.id;if(r===_config.KEYGEN_POLICIES.free)return"free";if(r===_config.KEYGEN_POLICIES.solo||r===_config.KEYGEN_POLICIES.business){return"pro"}const t=e.attributes?.metadata?.plan;if(t==="free")return"free";return"pro"}function tierAfterFatalError(e){return e==="EXPIRED"?"free":null}function isRecognizedAccount(e){if(!e)return false;const r=e.relationships?.product?.data?.id;if(r)return r===_config.KEYGEN_CONFIG.productId;const t=e.relationships?.policy?.data?.id;return Object.values(_config.KEYGEN_POLICIES).some(o=>o===t)}
@@ -1,18 +1,18 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isWeekendFreePro=isWeekendFreePro;exports.useWeekendFreePro=useWeekendFreePro;exports.weekendPassAppliesTo=weekendPassAppliesTo;var _react=require("react");/*!
2
- * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
- *
4
- * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
- * (https://buoy.gg/terms), not an OSS license.
6
- *
7
- * Despite its small size, this file is a technological measure that controls
8
- * access to paid Buoy Pro features: every `useIsPro()` gate in every Buoy tool
9
- * unlocks when `isWeekendFreePro()` returns true. Modifying, patching,
10
- * aliasing, stubbing, or otherwise altering it so that Pro features unlock
11
- * without a valid license is a breach of the EULA and, in the United States,
12
- * circumvention of an access control under 17 U.S.C. § 1201 — which applies
13
- * whether or not any code is copied.
14
- *
15
- * Pro is $9/mo, and is free every weekend for anyone holding a key —
16
- * including a free one (`npx buoy login`). Buy a key at
17
- * https://buoy.gg or use it free on Saturday and Sunday.
18
- */function isWeekendFreePro(t=new Date){const e=t.getDay();return e===0||e===6}function useWeekendFreePro(){const[t,e]=(0,_react.useState)(()=>isWeekendFreePro());(0,_react.useEffect)(()=>{const s=setInterval(()=>{const r=isWeekendFreePro();e(n=>n===r?n:r)},60*1e3);return()=>clearInterval(s)},[]);return t}function weekendPassAppliesTo(t,e){return e&&t}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isWeekendFreePro=isWeekendFreePro;exports.useWeekendFreePro=useWeekendFreePro;exports.weekendPassAppliesTo=weekendPassAppliesTo;var _react=require("react");var _realNow=require("./realNow.js");/*!
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * Despite its small size, this file is a technological measure that controls
8
+ * access to paid Buoy Pro features: every `useIsPro()` gate in every Buoy tool
9
+ * unlocks when `isWeekendFreePro()` returns true. Modifying, patching,
10
+ * aliasing, stubbing, or otherwise altering it so that Pro features unlock
11
+ * without a valid license is a breach of the EULA and, in the United States,
12
+ * circumvention of an access control under 17 U.S.C. § 1201 — which applies
13
+ * whether or not any code is copied.
14
+ *
15
+ * Pro is $9/mo, and is free every weekend for anyone holding a key —
16
+ * including a free one (`npx buoy login`). Buy a key at
17
+ * https://buoy.gg or use it free on Saturday and Sunday.
18
+ */function isWeekendFreePro(r=new Date((0,_realNow.realNow)())){const e=r.getDay();return e===0||e===6}function useWeekendFreePro(){const[r,e]=(0,_react.useState)(()=>isWeekendFreePro());(0,_react.useEffect)(()=>{const s=setInterval(()=>{const t=isWeekendFreePro();e(n=>n===t?n:t)},60*1e3);return()=>clearInterval(s)},[]);return r}function weekendPassAppliesTo(r,e){return e&&r}
@@ -1 +1 @@
1
- "use strict";import M,{useState as a,useEffect as S,useCallback as w}from"react";import{Modal as R,View as u,Text as b,TextInput as D,TouchableOpacity as T,StyleSheet as N,KeyboardAvoidingView as k,Platform as B}from"react-native";import{LicenseManager as f}from"./LicenseManager.js";import{jsx as o,jsxs as p}from"react/jsx-runtime";const e={base:"#121212",card:"#1A1A1A",hover:"#242424",input:"#2A2A2A",border:"#333333",borderStrong:"#444444",text:"#E0E0E0",textSecondary:"#A0A0A0",textMuted:"#888888",primary:"#20C997",success:"#20C997",warning:"#FFA94D",error:"#EF4444",info:"#00B8E6"};export function DeviceRegistrationModal({title:x="Name Your Device",description:v="Give this device a name to help you identify it later.",buttonText:C="Continue",onComplete:g}){const[h,s]=a(false);const[l,m]=a("");const[d,A]=a("");const[r,y]=a(false);S(()=>{const i=f.onDeviceRegistrationNeeded(n=>{A(n.defaultName);m(n.defaultName);s(true)});return i},[]);const c=w(async()=>{const i=l.trim()||d;y(true);try{await f.completeDeviceRegistration(i);s(false);g?.(i)}catch(n){console.warn("[Buoy] Device registration failed:",n);s(false)}finally{y(false)}},[l,d,g]);if(!h)return null;return o(R,{visible:h,transparent:true,animationType:"fade",onRequestClose:()=>{c()},children:o(k,{behavior:B.OS==="ios"?"padding":"height",style:t.overlay,children:p(u,{style:t.container,children:[o(u,{style:t.accentBar}),p(u,{style:t.content,children:[o(b,{style:t.title,children:x}),o(b,{style:t.description,children:v}),o(D,{style:t.input,value:l,onChangeText:m,placeholder:d,placeholderTextColor:e.textMuted,autoFocus:true,returnKeyType:"done",onSubmitEditing:c,editable:!r,selectionColor:e.primary}),o(T,{style:[t.button,r&&t.buttonDisabled],onPress:c,disabled:r,activeOpacity:.8,children:o(b,{style:t.buttonText,children:r?"Registering...":C})})]})]})})})}const t=N.create({overlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.75)",justifyContent:"center",alignItems:"center"},container:{backgroundColor:e.card,borderRadius:12,width:"85%",maxWidth:400,borderWidth:1,borderColor:e.border,shadowColor:e.primary,shadowOffset:{width:0,height:0},shadowOpacity:.2,shadowRadius:20,elevation:20,overflow:"hidden"},accentBar:{height:3,backgroundColor:e.primary},content:{padding:24},title:{fontSize:20,fontWeight:"600",color:e.text,marginBottom:8,textAlign:"center"},description:{fontSize:14,color:e.textSecondary,marginBottom:24,textAlign:"center",lineHeight:20},input:{borderWidth:1,borderColor:e.border,borderRadius:8,padding:14,fontSize:16,color:e.text,backgroundColor:e.input,marginBottom:20},button:{backgroundColor:e.primary,borderRadius:8,padding:14,alignItems:"center"},buttonDisabled:{backgroundColor:e.textMuted},buttonText:{color:e.base,fontSize:16,fontWeight:"600"}});
1
+ "use strict";import N,{useState as a,useEffect as w,useCallback as S}from"react";import{Modal as T,View as u,Text as b,TextInput as R,TouchableOpacity as D,StyleSheet as k,KeyboardAvoidingView as B,Platform as E}from"react-native";import{LicenseManager as f}from"./LicenseManager.js";import{jsx as o,jsxs as m}from"react/jsx-runtime";const e={base:"#121212",card:"#1A1A1A",hover:"#242424",input:"#2A2A2A",border:"#333333",borderStrong:"#444444",text:"#E0E0E0",textSecondary:"#A0A0A0",textMuted:"#888888",primary:"#20C997",success:"#20C997",warning:"#FFA94D",error:"#EF4444",info:"#00B8E6"};export function DeviceRegistrationModal({title:x="Name Your Device",description:C="Give this device a name to help you identify it later.",buttonText:v="Continue",onComplete:h}){const[g,s]=a(false);const[l,p]=a("");const[d,A]=a("");const[r,y]=a(false);w(()=>{const i=f.onDeviceRegistrationNeeded(n=>{A(n.defaultName);p(n.defaultName);s(true)});return i},[]);const c=S(async()=>{const i=l.trim()||d;y(true);try{await f.completeDeviceRegistration(i);s(false);h?.(i)}catch(n){console.warn("[Buoy] Device registration failed:",n);s(false)}finally{y(false)}},[l,d,h]);if(!g)return null;return o(T,{visible:g,transparent:true,animationType:"fade",onRequestClose:()=>{c()},children:o(B,{behavior:E.OS==="ios"?"padding":"height",style:t.overlay,children:m(u,{style:t.container,children:[o(u,{style:t.accentBar}),m(u,{style:t.content,children:[o(b,{style:t.title,children:x}),o(b,{style:t.description,children:C}),o(R,{style:t.input,value:l,onChangeText:p,placeholder:d,placeholderTextColor:e.textMuted,autoFocus:true,returnKeyType:"done",onSubmitEditing:c,editable:!r,selectionColor:e.primary}),o(D,{style:[t.button,r&&t.buttonDisabled],onPress:c,disabled:r,activeOpacity:.8,children:o(b,{style:t.buttonText,children:r?"Registering...":v})})]})]})})})}const t=k.create({overlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.75)",justifyContent:"center",alignItems:"center"},container:{backgroundColor:e.card,borderRadius:12,width:"85%",maxWidth:400,borderWidth:1,borderColor:e.border,shadowColor:e.primary,shadowOffset:{width:0,height:0},shadowOpacity:.2,shadowRadius:20,elevation:20,overflow:"hidden"},accentBar:{height:3,backgroundColor:e.primary},content:{padding:24},title:{fontSize:20,fontWeight:"600",color:e.text,marginBottom:8,textAlign:"center"},description:{fontSize:14,color:e.textSecondary,marginBottom:24,textAlign:"center",lineHeight:20},input:{borderWidth:1,borderColor:e.border,borderRadius:8,padding:14,fontSize:16,color:e.text,backgroundColor:e.input,marginBottom:20},button:{backgroundColor:e.primary,borderRadius:8,padding:14,alignItems:"center"},buttonDisabled:{backgroundColor:e.textMuted},buttonText:{color:e.base,fontSize:16,fontWeight:"600"}});