@reason-machines/cli-linux-x64 0.2.509 → 0.2.511

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 (114) hide show
  1. package/THIRD_PARTY_NOTICES.txt +0 -50
  2. package/bin/reason +2 -2
  3. package/bin/vm-hands/api-68t0w5r8.js +2 -0
  4. package/bin/vm-hands/api-credentials-d98wm1c4.js +2 -0
  5. package/bin/vm-hands/connect-cli-3z1w0fn6.js +2 -0
  6. package/bin/vm-hands/credentials-pgsb4v9j.js +2 -0
  7. package/bin/vm-hands/custom-endpoint-device-57hkdy1z.js +2 -0
  8. package/bin/vm-hands/desktop-account-j6fjngt1.js +2 -0
  9. package/bin/vm-hands/device-workspace-qjyzphga.js +2 -0
  10. package/bin/vm-hands/{fsevents-x66t2ncp.js → fsevents-sw63c1nr.js} +1 -1
  11. package/bin/vm-hands/hands-worker-source-xjbrgfar.js +2 -0
  12. package/bin/vm-hands/{index-rdm4a3y7.js → index-j4gb3cze.js} +10 -10
  13. package/bin/vm-hands/install-receipt-y7exc4wh.js +2 -0
  14. package/bin/vm-hands/local-automation-780w99r4.js +2 -0
  15. package/bin/vm-hands/local-capabilities-e8s80r9j.js +2 -0
  16. package/bin/vm-hands/local-desktop-users-q0391ha1.js +2 -0
  17. package/bin/vm-hands/local-display-mac-7pg0n3zs.js +2 -0
  18. package/bin/vm-hands/local-display-session-j1znexft.js +2 -0
  19. package/bin/vm-hands/local-display-video-ahs5g3ba.js +2 -0
  20. package/bin/vm-hands/local-managed-process-6d7b6ch1.js +2 -0
  21. package/bin/vm-hands/local-pty-session-q06ff8yk.js +2 -0
  22. package/bin/vm-hands/managed-runtime-ycrdc7n6.js +2 -0
  23. package/bin/vm-hands/network-contract-6mkf58vs.js +2 -0
  24. package/bin/vm-hands/package-sng72tm1.js +2 -0
  25. package/bin/vm-hands/permissions-bdxyn8v7.js +2 -0
  26. package/bin/vm-hands/reason-hands-protocol-zf7bpqwe.js +2 -0
  27. package/bin/vm-hands/serve-service-yvvgyrxa.js +2 -0
  28. package/bin/vm-hands/status-9ep9pqvv.js +10 -0
  29. package/bin/vm-hands/version-qrc35j69.js +2 -0
  30. package/bin/vm-hands/{vm-hands-entry-lite-kkfefpq6.js → vm-hands-entry-lite-024t90qh.js} +3 -3
  31. package/bin/vm-hands/{vm-hands-entry-lite-7777m86y.js → vm-hands-entry-lite-0gj3p9tg.js} +2 -2
  32. package/bin/vm-hands/{vm-hands-entry-lite-p62aaxk9.js → vm-hands-entry-lite-0pae1q0k.js} +3 -3
  33. package/bin/vm-hands/{vm-hands-entry-lite-18cpkdc1.js → vm-hands-entry-lite-0q01asmp.js} +39 -39
  34. package/bin/vm-hands/{vm-hands-entry-lite-y2khvb5c.js → vm-hands-entry-lite-0sh835na.js} +2 -2
  35. package/bin/vm-hands/{vm-hands-entry-lite-5gevvgec.js → vm-hands-entry-lite-1ek3r3w9.js} +1 -1
  36. package/bin/vm-hands/{vm-hands-entry-lite-c67nmnex.js → vm-hands-entry-lite-1zd088yv.js} +25 -25
  37. package/bin/vm-hands/{vm-hands-entry-lite-t6f1f51j.js → vm-hands-entry-lite-359n9b0z.js} +9 -9
  38. package/bin/vm-hands/{vm-hands-entry-lite-38g65s5x.js → vm-hands-entry-lite-39qv4sqt.js} +2 -2
  39. package/bin/vm-hands/{vm-hands-entry-lite-8pgdcdsm.js → vm-hands-entry-lite-3p7zk3yt.js} +4 -4
  40. package/bin/vm-hands/{vm-hands-entry-lite-1kkqgavp.js → vm-hands-entry-lite-4qzz0969.js} +20 -20
  41. package/bin/vm-hands/{vm-hands-entry-lite-w1958mev.js → vm-hands-entry-lite-5np5k3wb.js} +4 -4
  42. package/bin/vm-hands/vm-hands-entry-lite-60pnam39.js +3 -0
  43. package/bin/vm-hands/vm-hands-entry-lite-64b6nx6h.js +2 -0
  44. package/bin/vm-hands/{vm-hands-entry-lite-4483nna7.js → vm-hands-entry-lite-6g8b6jw5.js} +4 -4
  45. package/bin/vm-hands/{vm-hands-entry-lite-txd50spx.js → vm-hands-entry-lite-70hq7mrs.js} +2 -2
  46. package/bin/vm-hands/{vm-hands-entry-lite-fzbqk2qx.js → vm-hands-entry-lite-7p4qsm5s.js} +2 -2
  47. package/bin/vm-hands/vm-hands-entry-lite-9bp1d166.js +3 -0
  48. package/bin/vm-hands/{vm-hands-entry-lite-bw9g69x1.js → vm-hands-entry-lite-abq9tw0y.js} +5 -5
  49. package/bin/vm-hands/{vm-hands-entry-lite-51y3fyms.js → vm-hands-entry-lite-cb6z6b7g.js} +2 -2
  50. package/bin/vm-hands/{vm-hands-entry-lite-np07qyeq.js → vm-hands-entry-lite-ckezse0f.js} +2 -2
  51. package/bin/vm-hands/{vm-hands-entry-lite-3c5n0wm3.js → vm-hands-entry-lite-cy9ckdxb.js} +1 -1
  52. package/bin/vm-hands/{vm-hands-entry-lite-rzpg99eh.js → vm-hands-entry-lite-dbkb8zn6.js} +4 -4
  53. package/bin/vm-hands/{vm-hands-entry-lite-hqm76r37.js → vm-hands-entry-lite-dcrz19xf.js} +3 -3
  54. package/bin/vm-hands/{vm-hands-entry-lite-as5c1hre.js → vm-hands-entry-lite-j5yc1ejg.js} +3 -3
  55. package/bin/vm-hands/{vm-hands-entry-lite-4kp6abst.js → vm-hands-entry-lite-jzw126a4.js} +2 -2
  56. package/bin/vm-hands/{vm-hands-entry-lite-eabever7.js → vm-hands-entry-lite-k1wghndy.js} +4 -4
  57. package/bin/vm-hands/{vm-hands-entry-lite-cswyn85b.js → vm-hands-entry-lite-m7pkmatv.js} +2 -2
  58. package/bin/vm-hands/{vm-hands-entry-lite-hyv23rd9.js → vm-hands-entry-lite-psjcmgj8.js} +4 -4
  59. package/bin/vm-hands/{vm-hands-entry-lite-f62fvme8.js → vm-hands-entry-lite-pwmvq53c.js} +4 -4
  60. package/bin/vm-hands/{vm-hands-entry-lite-yg9zb1nr.js → vm-hands-entry-lite-qny40hr2.js} +5 -5
  61. package/bin/vm-hands/{vm-hands-entry-lite-vph99v9r.js → vm-hands-entry-lite-qz74j563.js} +2 -2
  62. package/bin/vm-hands/{vm-hands-entry-lite-w2n56kvf.js → vm-hands-entry-lite-qzcac2mf.js} +4 -4
  63. package/bin/vm-hands/{vm-hands-entry-lite-t8c42p62.js → vm-hands-entry-lite-s455zena.js} +2 -2
  64. package/bin/vm-hands/{vm-hands-entry-lite-rfz60hb3.js → vm-hands-entry-lite-s85p7tqp.js} +2 -2
  65. package/bin/vm-hands/{vm-hands-entry-lite-pdn0nt11.js → vm-hands-entry-lite-svd5v9dr.js} +2 -2
  66. package/bin/vm-hands/{vm-hands-entry-lite-wrvz9jxy.js → vm-hands-entry-lite-td73npv3.js} +2 -2
  67. package/bin/vm-hands/{vm-hands-entry-lite-3zeavsfr.js → vm-hands-entry-lite-vs47bs09.js} +1 -1
  68. package/bin/vm-hands/vm-hands-entry-lite-vwxg4fhe.js +42 -0
  69. package/bin/vm-hands/{vm-hands-entry-lite-12r5xwkb.js → vm-hands-entry-lite-wng9s3k8.js} +10 -10
  70. package/bin/vm-hands/{vm-hands-entry-lite-nqdstx24.js → vm-hands-entry-lite-wp0d65yx.js} +2 -2
  71. package/bin/vm-hands/{vm-hands-entry-lite-tvgb94jk.js → vm-hands-entry-lite-wx1fmrbs.js} +3 -3
  72. package/bin/vm-hands/vm-hands-entry-lite-x6akmegv.js +2 -0
  73. package/bin/vm-hands/{vm-hands-entry-lite-x1b0sm48.js → vm-hands-entry-lite-ymqb2927.js} +2 -2
  74. package/bin/vm-hands/{vm-hands-entry-lite-f5501hn3.js → vm-hands-entry-lite-zc8fsn2e.js} +2 -2
  75. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  76. package/bin/vm-hands/{vm-hands-executor-6ex6edrw.js → vm-hands-executor-hggcrys1.js} +3 -3
  77. package/bin/vm-hands/vm-hands-op-runner-3p2cgtjy.js +2 -0
  78. package/bin/vm-hands/{vm-hands-runtime-c68t42yc.js → vm-hands-runtime-490vccjv.js} +3 -3
  79. package/bin/vm-hands/worker-preview-readiness-6kk98y4k.js +2 -0
  80. package/bin/vm-hands/worker-sandbox-j6cmex8e.js +2 -0
  81. package/package.json +1 -1
  82. package/bin/vm-hands/api-credentials-87hn92f0.js +0 -2
  83. package/bin/vm-hands/api-yg04rftf.js +0 -2
  84. package/bin/vm-hands/connect-cli-f1hg3trw.js +0 -2
  85. package/bin/vm-hands/credentials-zsgek373.js +0 -2
  86. package/bin/vm-hands/custom-endpoint-device-0a5wjyh6.js +0 -2
  87. package/bin/vm-hands/desktop-account-ythxv2x5.js +0 -2
  88. package/bin/vm-hands/device-workspace-pt07525s.js +0 -2
  89. package/bin/vm-hands/hands-worker-source-5sk272dx.js +0 -2
  90. package/bin/vm-hands/install-receipt-d5489knb.js +0 -2
  91. package/bin/vm-hands/local-automation-627gg3ya.js +0 -2
  92. package/bin/vm-hands/local-capabilities-1tap81zp.js +0 -2
  93. package/bin/vm-hands/local-desktop-users-gham2z3k.js +0 -2
  94. package/bin/vm-hands/local-display-mac-fnp3317m.js +0 -2
  95. package/bin/vm-hands/local-display-session-q2vbnpr2.js +0 -2
  96. package/bin/vm-hands/local-display-video-4kcndnqg.js +0 -2
  97. package/bin/vm-hands/local-managed-process-nzpq335j.js +0 -2
  98. package/bin/vm-hands/local-pty-session-7yr8cm6d.js +0 -2
  99. package/bin/vm-hands/managed-runtime-ptn52m9d.js +0 -2
  100. package/bin/vm-hands/network-contract-cvqgd243.js +0 -2
  101. package/bin/vm-hands/package-datdmd5r.js +0 -2
  102. package/bin/vm-hands/permissions-xp4389xm.js +0 -2
  103. package/bin/vm-hands/reason-hands-protocol-8fgk2s53.js +0 -2
  104. package/bin/vm-hands/serve-service-5q4prte5.js +0 -2
  105. package/bin/vm-hands/status-dqabww8t.js +0 -10
  106. package/bin/vm-hands/version-q9df1yye.js +0 -2
  107. package/bin/vm-hands/vm-hands-entry-lite-439wxzv9.js +0 -2
  108. package/bin/vm-hands/vm-hands-entry-lite-h3r57pgb.js +0 -2
  109. package/bin/vm-hands/vm-hands-entry-lite-js4cr7bc.js +0 -3
  110. package/bin/vm-hands/vm-hands-entry-lite-t5r1sy9z.js +0 -3
  111. package/bin/vm-hands/vm-hands-entry-lite-vx0ht58w.js +0 -42
  112. package/bin/vm-hands/vm-hands-op-runner-p3h06gcq.js +0 -2
  113. package/bin/vm-hands/worker-preview-readiness-5myda114.js +0 -2
  114. package/bin/vm-hands/worker-sandbox-phfz1pj5.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{_,Xr,_t,ke}from"./vm-hands-entry-lite-nqdstx24.js";import{Po}from"./vm-hands-entry-lite-7777m86y.js";import{a}from"./vm-hands-entry-lite-y2khvb5c.js";import{t,i,s,n}from"./vm-hands-entry-lite-w2n56kvf.js";import{createHmac as bt,createPublicKey as be,randomBytes as mt,randomUUID as me,verify as he}from"crypto";import{chmodSync as L,existsSync as z,mkdirSync as Se,readFileSync as Ie,realpathSync as St,renameSync as De,statSync as It,unlinkSync as Le,writeFileSync as we}from"fs";import{basename as Dt,dirname as w,isAbsolute as Ae,join as m,resolve as Lt}from"path";var $e=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var Z="REASON_DESKTOP_RUNTIME",q="REASON_DESKTOP_RUNTIME_CHANNEL",Q="REASON_DESKTOP_RUNTIME_INSTANCE_ID",ee="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",We={[Z]:"ARA_DESKTOP_RUNTIME",[q]:"ARA_DESKTOP_RUNTIME_CHANNEL",[Q]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[ee]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function x(r){if(r===void 0)return;if(!/^[a-f0-9]{64}$/.test(r))throw Error("Invalid desktop workspace scope.");return r}import{chmodSync as h,existsSync as g,mkdirSync as S,readFileSync as N,realpathSync as te,renameSync as ne,unlinkSync as I,writeFileSync as k}from"fs";import{createPrivateKey as ie,createPublicKey as re,generateKeyPairSync as oe,randomUUID as ae,sign as se}from"crypto";import{createRequire as ce}from"module";import{homedir as le,platform as T}from"os";import{dirname as de,join as f}from"path";var O=1,ue=16384,y=65536,pe=128,ge=128,U=65536;class l extends Error{code;nativeStatus;constructor(r,e){super(`Reason Device proof boundary failed (${r}).${e===void 0?"":` Native status: ${e}.`}`);this.code=r;this.nativeStatus=e;this.name="LocalCredentialBoundaryError"}}var D=null;function F(){if(!D)try{D=ce(import.meta.url)("bun:ffi")}catch{throw new l("native_boundary_unavailable")}return D}function fe(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost"&&e.hostname!=="[::1]"&&e.hostname!=="::1")return null;return e.origin}catch{return null}}function ye(r){if(!r||typeof r!=="object"||Array.isArray(r))throw new l("invalid_credential_record");let e=r,o=fe(e.apiOrigin);if(e.version!==O||!o||typeof e.orgId!=="string"||e.orgId.length<1||e.orgId.length>160||typeof e.deviceId!=="string"||e.deviceId.length<1||e.deviceId.length>160||typeof e.credential!=="string"||!/^(?:reason|ara)_dev_/.test(e.credential)||e.credential.length>4096)throw new l("invalid_credential_record");return{version:O,apiOrigin:o,orgId:e.orgId,deviceId:e.deviceId,credential:e.credential}}function Wt(r=process.execPath){let e=r;try{e=te(r)}catch{}return Po(de(e))}function u(r){return F().ptr(r)}function ve(r){if(!g(r))throw new l("native_boundary_unavailable");let{dlopen:e,FFIType:o}=F();try{return e(r,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(c){if(c instanceof l)throw c;throw new l("native_boundary_unavailable")}}function K(r){return Buffer.from(r).toString("base64url")}function v(r){if(typeof r!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(r))return!1;try{let e=Buffer.from(r,"base64url");return e.byteLength===65&&e[0]===4}catch{return!1}}function M(r){if(r.byteLength<8||r.byteLength>72||r[0]!==48)return!1;let e=r[1];return e!==void 0&&e<128&&e+2===r.byteLength}class Ke{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(r=Wt(),e=T(),o){this.libraryPath=r;this.runtimePlatform=e;this.workspaceScope=o;x(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new l("unsupported_platform");this.library??=ve(this.libraryPath);let r=new TextEncoder().encode(this.workspaceScope??""),e=this.library.symbols.ara_device_configure_scope(u(r.length?r:new Uint8Array(1)),BigInt(r.length));if(e!==0)throw new l("native_boundary_unavailable",e);return this.library.symbols}publicKey(r){let e=new Uint8Array(pe),o=new BigUint64Array(1),c=r==="load"?this.symbols().ara_device_key_load_public(u(e),BigInt(e.byteLength),u(o)):this.symbols().ara_device_key_create_fresh_public(u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l(r==="load"?"proof_key_read_failed":"proof_key_generation_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new l("invalid_public_key");let p=K(e.subarray(0,d));if(!v(p))throw new l("invalid_public_key");return p}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=new Uint8Array(ge),o=new BigUint64Array(1),c=this.symbols().ara_device_key_sign(u(r),BigInt(r.byteLength),u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l("proof_sign_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>e.byteLength)throw new l("invalid_signature");let p=e.subarray(0,d);if(!M(p))throw new l("invalid_signature");return K(p)}privateKeyIsNonExtractable(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_is_non_extractable(u(r));if(e!==0||r[0]!==1)throw new l("proof_key_read_failed",e);return!0}deleteKey(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_delete(u(r));if(e!==0)throw new l("proof_key_delete_failed",e);return r[0]===1}loadBinding(){let r=new Uint8Array(y),e=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("binding_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_binding");return r.slice(0,c)}createBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_create(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_create_failed",e)}updateBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_update(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_update_failed",e)}deleteBinding(){let r=new Uint8Array(1),e=this.symbols().ara_device_binding_delete(u(r));if(e!==0)throw new l("binding_delete_failed",e);return r[0]===1}loadLegacyCredential(){let r=new Uint8Array(ue),e=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("legacy_credential_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(r.subarray(0,c));return ye(JSON.parse(d))}catch(d){if(d instanceof l)throw d;throw new l("invalid_credential_record")}}deleteLegacyCredential(){let r=new Uint8Array(1),e=this.symbols().ara_device_keychain_delete(u(r));if(e!==0)throw new l("legacy_credential_delete_failed",e);return r[0]===1}}function C(r){let e=r.export({format:"jwk"});if(e.crv!=="P-256"||typeof e.x!=="string"||typeof e.y!=="string")throw new l("invalid_public_key");let o=Buffer.from(e.x,"base64url"),c=Buffer.from(e.y,"base64url");if(o.byteLength!==32||c.byteLength!==32)throw new l("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,c]).toString("base64url");if(!v(d))throw new l("invalid_public_key");return d}function _e(){let r=process.env.XDG_CONFIG_HOME?.trim()||f(le(),".config");_t(r);let e=f(r,"ara");return Xr(e)?e:f(r,"reason")}class Nr{directory;constructor(r=_e()){this.directory=r}keyPath(){return f(this.directory,"local-device.key")}bindingPath(){return f(this.directory,"local-device.binding")}loadPrivateKeyObject(){let r=this.keyPath();if(!g(r))throw new l("proof_key_read_failed");try{let e=N(r,"utf8");return ie({key:e,format:"pem"})}catch{throw new l("proof_key_read_failed")}}loadPublicKey(){let r=this.loadPrivateKeyObject(),e=re(r);return C(e)}createFreshPublicKey(){S(this.directory,{recursive:!0,mode:448});let{privateKey:r,publicKey:e}=oe("ec",{namedCurve:"P-256"}),o=r.export({type:"pkcs8",format:"pem"}),c=this.keyPath();return k(c,o,{mode:384}),h(c,384),C(e)}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=this.loadPrivateKeyObject(),o;try{o=se("sha256",r,e)}catch{throw new l("proof_sign_failed")}if(!M(o))throw new l("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let r=this.keyPath();if(!g(r))return!1;return I(r),!0}loadBinding(){let r=this.bindingPath();if(!g(r))return null;try{return new Uint8Array(N(r))}catch{return null}}createBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(g(e))throw new l("binding_create_failed");k(e,r,{mode:384}),h(e,384)}updateBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(!g(e))throw new l("binding_update_failed");let o=`${e}.${ae()}`;try{k(o,r,{mode:384,flag:"wx"}),h(o,384),ne(o,e)}finally{if(g(o))I(o)}}deleteBinding(){let r=this.bindingPath();if(!g(r))return!1;return I(r),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function V(){return T()==="darwin"?new Ke:new Nr}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),B=i({id:b,kind:n("permission_denied"),operation:s(["bash","read","write","edit"]),provenance:s(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var A=4;var P="macos-keychain-p256-v1",Pe=1,Ee=`ARA-DEVICE-BINDING-V1
3
- `;function Re(r){return r===void 0||typeof r==="number"&&Number.isInteger(r)&&r>=1&&r<=4}function G(r,e=Date.now()){let o=B.safeParse(r);if(!o.success)return!1;let c=o.data,d=typeof c.occurredAt==="string"?Date.parse(c.occurredAt):NaN,p=typeof c.expiresAt==="string"?Date.parse(c.expiresAt):NaN;return c.kind==="permission_denied"&&["bash","read","write","edit"].includes(c.operation)&&["sandbox_policy","os_permission_unknown"].includes(c.provenance)&&Number.isFinite(d)&&d<=e&&p>e&&p>d&&p-d<=600000}function Vt(r,e,o=Date.now()){if(!r||!e||r.state!=="connected"||r.deviceId!==e.deviceId)return null;let c=Date.parse(r.lastHeartbeatAt??""),d=r.permissionRecovery;if(!(o-c>=0&&o-c<30000)||!G(d,o)||d.deviceId!==e.deviceId||d.organizationId!==e.orgId)return null;try{process.kill(r.pid,0)}catch{return null}return d}function H(r={},e=a()){let o=_({env:{...process.env,...r}}),c=r.XDG_CONFIG_HOME?.trim()||m(e,".config");return ke(c,...o==="staging"?["staging"]:[])}function Lr(r={},e=a()){return m(H(r,e),"local-device.json")}function xe(r={},e=a()){return m(H(r,e),"local-daemon.json")}function Ne(r,e){Se(w(r),{recursive:!0,mode:448}),L(w(r),448);let o=`${r}.${process.pid}.${me()}.tmp`;try{we(o,`${JSON.stringify(e,null,2)}
4
- `,{mode:384,flag:"wx"}),L(o,384),De(o,r),L(r,384)}finally{if(z(o))Le(o)}return r}function E(r){if(!z(r))return null;try{return JSON.parse(Ie(r,"utf8"))}catch{return null}}function Oe(r){if(!Array.isArray(r))return null;let e=[];for(let o of r){if(!o||typeof o!=="object")return null;let c=o;if(typeof c.id!=="string"||typeof c.label!=="string"||typeof c.path!=="string"||typeof c.pathFingerprint!=="string"||!c.permissions||typeof c.permissions.read!=="boolean"||typeof c.permissions.write!=="boolean"||typeof c.permissions.execute!=="boolean"||typeof c.permissions.discover_environment!=="boolean"||typeof c.permissions.expose_mcp!=="boolean")return null;e.push({id:c.id,label:c.label,path:c.path,pathFingerprint:c.pathFingerprint,permissions:c.permissions})}return e}function J(r,e,o=[]){let c=Object.keys(r);return e.every((d)=>Object.hasOwn(r,d))&&c.every((d)=>e.includes(d)||o.includes(d))}function Ce(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost")return null;return e.origin}catch{return null}}function Y(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r,o=Oe(e.roots),c=Ce(e.apiOrigin);if(!c||typeof e.orgId!=="string"||typeof e.deviceId!=="string"||typeof e.displayName!=="string"||typeof e.registeredAt!=="string"||!Re(e.handsSlots)||e.worker!==void 0&&(!e.worker||!/^[a-f0-9]{64}$/.test(e.worker.configDigest)||!["persistent","ephemeral"].includes(e.worker.lifetime)||!Number.isFinite(Date.parse(e.worker.expiresAt)))||!o)return null;return{apiOrigin:c,orgId:e.orgId,deviceId:e.deviceId,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:o}}function Te(r){return{version:A,apiOrigin:r.apiOrigin,orgId:r.orgId,deviceId:r.deviceId,devicePublicKey:r.devicePublicKey,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:r.roots.map((e)=>({id:e.id,label:e.label,path:e.path,pathFingerprint:e.pathFingerprint,permissions:{read:e.permissions.read,write:e.permissions.write,execute:e.permissions.execute,discover_environment:e.permissions.discover_environment,expose_mcp:e.permissions.expose_mcp}})),credentialStorage:P}}function X(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r;if(!J(e,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Y(e);if(!o||e.version!==A||e.credentialStorage!==P||!v(e.devicePublicKey))return null;return{version:A,...o,devicePublicKey:e.devicePublicKey,credentialStorage:P}}function Ue(r){return new TextEncoder().encode(`${Ee}${JSON.stringify(Te(r))}`)}function Fe(r){let e=Buffer.from(r,"base64url");return be({format:"jwk",key:{kty:"EC",crv:"P-256",x:e.subarray(1,33).toString("base64url"),y:e.subarray(33,65).toString("base64url")}})}function Me(r){let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r))}catch{throw new l("invalid_binding")}if(!e||typeof e!=="object"||Array.isArray(e))throw new l("invalid_binding");let o=e;if(!J(o,["version","state","signature"])||o.version!==Pe||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new l("invalid_binding");let c=X(o.state);if(!c)throw new l("invalid_binding");let d=!1;try{d=he("sha256",Ue(c),Fe(c.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new l("invalid_binding");return c}function je(r){let{credentialStorage:e,...o}=r;return o}function Mr(r=Lr(),e={}){let o=E(r),c=e.proofStore??e.credentialStore??V(),d=c.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&Ve(o))return null;if(o!==null)throw new l("invalid_binding");return null}let p=Me(d),W=c.loadPublicKey();if(c.privateKeyIsNonExtractable(),W!==p.devicePublicKey)throw new l("invalid_public_key");let R=X(o);if(e.repair!==!1&&(!R||JSON.stringify(R)!==JSON.stringify(p)))Ne(r,p);return je(p)}function Ve(r){let e=r,o=Y(r);if(!o)return null;if(e.version===2){if(typeof e.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(e.deviceCredential)||e.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(e.version!==3||e.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in e)return null;return{state:o,credentialSource:"keychain-v3"}}function pt(r=xe()){let e=E(r);if(!e||typeof e!=="object")return null;let o=e;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!G(o.permissionRecovery))delete o.permissionRecovery;return o}var Gt=1;function Be(r=Lr()){return m(w(r),"local-device.proxy.json")}function j(r=Be()){let e=E(r);if(!e||typeof e!=="object"||Array.isArray(e))return null;let o=e;if(o.version!==Gt||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!Ae(o.caFile)))return null;return{version:Gt,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}
5
- export{l,Wt,Ke,Nr,Vt,Lr,Mr,pt,Gt,j};
2
+ import{_,Yr,_t,ke}from"./vm-hands-entry-lite-wp0d65yx.js";import{Oo}from"./vm-hands-entry-lite-0gj3p9tg.js";import{a}from"./vm-hands-entry-lite-0sh835na.js";import{t,i,s,n}from"./vm-hands-entry-lite-qzcac2mf.js";import{createHmac as bt,createPublicKey as be,randomBytes as mt,randomUUID as me,verify as he}from"crypto";import{chmodSync as L,existsSync as z,mkdirSync as Se,readFileSync as Ie,realpathSync as St,renameSync as De,statSync as It,unlinkSync as Le,writeFileSync as we}from"fs";import{basename as Dt,dirname as w,isAbsolute as Ae,join as m,resolve as Lt}from"path";var $e=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var Z="REASON_DESKTOP_RUNTIME",q="REASON_DESKTOP_RUNTIME_CHANNEL",Q="REASON_DESKTOP_RUNTIME_INSTANCE_ID",ee="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",We={[Z]:"ARA_DESKTOP_RUNTIME",[q]:"ARA_DESKTOP_RUNTIME_CHANNEL",[Q]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[ee]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function x(r){if(r===void 0)return;if(!/^[a-f0-9]{64}$/.test(r))throw Error("Invalid desktop workspace scope.");return r}import{chmodSync as h,existsSync as g,mkdirSync as S,readFileSync as N,realpathSync as te,renameSync as ne,unlinkSync as I,writeFileSync as k}from"fs";import{createPrivateKey as ie,createPublicKey as re,generateKeyPairSync as oe,randomUUID as ae,sign as se}from"crypto";import{createRequire as ce}from"module";import{homedir as le,platform as T}from"os";import{dirname as de,join as f}from"path";var O=1,ue=16384,y=65536,pe=128,ge=128,U=65536;class l extends Error{code;nativeStatus;constructor(r,e){super(`Reason Device proof boundary failed (${r}).${e===void 0?"":` Native status: ${e}.`}`);this.code=r;this.nativeStatus=e;this.name="LocalCredentialBoundaryError"}}var D=null;function F(){if(!D)try{D=ce(import.meta.url)("bun:ffi")}catch{throw new l("native_boundary_unavailable")}return D}function fe(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost"&&e.hostname!=="[::1]"&&e.hostname!=="::1")return null;return e.origin}catch{return null}}function ye(r){if(!r||typeof r!=="object"||Array.isArray(r))throw new l("invalid_credential_record");let e=r,o=fe(e.apiOrigin);if(e.version!==O||!o||typeof e.orgId!=="string"||e.orgId.length<1||e.orgId.length>160||typeof e.deviceId!=="string"||e.deviceId.length<1||e.deviceId.length>160||typeof e.credential!=="string"||!/^(?:reason|ara)_dev_/.test(e.credential)||e.credential.length>4096)throw new l("invalid_credential_record");return{version:O,apiOrigin:o,orgId:e.orgId,deviceId:e.deviceId,credential:e.credential}}function Gt(r=process.execPath){let e=r;try{e=te(r)}catch{}return Oo(de(e))}function u(r){return F().ptr(r)}function ve(r){if(!g(r))throw new l("native_boundary_unavailable");let{dlopen:e,FFIType:o}=F();try{return e(r,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(c){if(c instanceof l)throw c;throw new l("native_boundary_unavailable")}}function K(r){return Buffer.from(r).toString("base64url")}function v(r){if(typeof r!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(r))return!1;try{let e=Buffer.from(r,"base64url");return e.byteLength===65&&e[0]===4}catch{return!1}}function M(r){if(r.byteLength<8||r.byteLength>72||r[0]!==48)return!1;let e=r[1];return e!==void 0&&e<128&&e+2===r.byteLength}class Ke{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(r=Gt(),e=T(),o){this.libraryPath=r;this.runtimePlatform=e;this.workspaceScope=o;x(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new l("unsupported_platform");this.library??=ve(this.libraryPath);let r=new TextEncoder().encode(this.workspaceScope??""),e=this.library.symbols.ara_device_configure_scope(u(r.length?r:new Uint8Array(1)),BigInt(r.length));if(e!==0)throw new l("native_boundary_unavailable",e);return this.library.symbols}publicKey(r){let e=new Uint8Array(pe),o=new BigUint64Array(1),c=r==="load"?this.symbols().ara_device_key_load_public(u(e),BigInt(e.byteLength),u(o)):this.symbols().ara_device_key_create_fresh_public(u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l(r==="load"?"proof_key_read_failed":"proof_key_generation_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new l("invalid_public_key");let p=K(e.subarray(0,d));if(!v(p))throw new l("invalid_public_key");return p}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=new Uint8Array(ge),o=new BigUint64Array(1),c=this.symbols().ara_device_key_sign(u(r),BigInt(r.byteLength),u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l("proof_sign_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>e.byteLength)throw new l("invalid_signature");let p=e.subarray(0,d);if(!M(p))throw new l("invalid_signature");return K(p)}privateKeyIsNonExtractable(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_is_non_extractable(u(r));if(e!==0||r[0]!==1)throw new l("proof_key_read_failed",e);return!0}deleteKey(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_delete(u(r));if(e!==0)throw new l("proof_key_delete_failed",e);return r[0]===1}loadBinding(){let r=new Uint8Array(y),e=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("binding_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_binding");return r.slice(0,c)}createBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_create(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_create_failed",e)}updateBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_update(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_update_failed",e)}deleteBinding(){let r=new Uint8Array(1),e=this.symbols().ara_device_binding_delete(u(r));if(e!==0)throw new l("binding_delete_failed",e);return r[0]===1}loadLegacyCredential(){let r=new Uint8Array(ue),e=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("legacy_credential_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(r.subarray(0,c));return ye(JSON.parse(d))}catch(d){if(d instanceof l)throw d;throw new l("invalid_credential_record")}}deleteLegacyCredential(){let r=new Uint8Array(1),e=this.symbols().ara_device_keychain_delete(u(r));if(e!==0)throw new l("legacy_credential_delete_failed",e);return r[0]===1}}function C(r){let e=r.export({format:"jwk"});if(e.crv!=="P-256"||typeof e.x!=="string"||typeof e.y!=="string")throw new l("invalid_public_key");let o=Buffer.from(e.x,"base64url"),c=Buffer.from(e.y,"base64url");if(o.byteLength!==32||c.byteLength!==32)throw new l("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,c]).toString("base64url");if(!v(d))throw new l("invalid_public_key");return d}function _e(){let r=process.env.XDG_CONFIG_HOME?.trim()||f(le(),".config");_t(r);let e=f(r,"ara");return Yr(e)?e:f(r,"reason")}class Lr{directory;constructor(r=_e()){this.directory=r}keyPath(){return f(this.directory,"local-device.key")}bindingPath(){return f(this.directory,"local-device.binding")}loadPrivateKeyObject(){let r=this.keyPath();if(!g(r))throw new l("proof_key_read_failed");try{let e=N(r,"utf8");return ie({key:e,format:"pem"})}catch{throw new l("proof_key_read_failed")}}loadPublicKey(){let r=this.loadPrivateKeyObject(),e=re(r);return C(e)}createFreshPublicKey(){S(this.directory,{recursive:!0,mode:448});let{privateKey:r,publicKey:e}=oe("ec",{namedCurve:"P-256"}),o=r.export({type:"pkcs8",format:"pem"}),c=this.keyPath();return k(c,o,{mode:384}),h(c,384),C(e)}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=this.loadPrivateKeyObject(),o;try{o=se("sha256",r,e)}catch{throw new l("proof_sign_failed")}if(!M(o))throw new l("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let r=this.keyPath();if(!g(r))return!1;return I(r),!0}loadBinding(){let r=this.bindingPath();if(!g(r))return null;try{return new Uint8Array(N(r))}catch{return null}}createBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(g(e))throw new l("binding_create_failed");k(e,r,{mode:384}),h(e,384)}updateBinding(r){if(r.byteLength<1||r.byteLength>y)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(!g(e))throw new l("binding_update_failed");let o=`${e}.${ae()}`;try{k(o,r,{mode:384,flag:"wx"}),h(o,384),ne(o,e)}finally{if(g(o))I(o)}}deleteBinding(){let r=this.bindingPath();if(!g(r))return!1;return I(r),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function V(){return T()==="darwin"?new Ke:new Lr}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),B=i({id:b,kind:n("permission_denied"),operation:s(["bash","read","write","edit"]),provenance:s(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var A=4;var P="macos-keychain-p256-v1",Pe=1,Ee=`ARA-DEVICE-BINDING-V1
3
+ `;function Re(r){return r===void 0||typeof r==="number"&&Number.isInteger(r)&&r>=1&&r<=4}function G(r,e=Date.now()){let o=B.safeParse(r);if(!o.success)return!1;let c=o.data,d=typeof c.occurredAt==="string"?Date.parse(c.occurredAt):NaN,p=typeof c.expiresAt==="string"?Date.parse(c.expiresAt):NaN;return c.kind==="permission_denied"&&["bash","read","write","edit"].includes(c.operation)&&["sandbox_policy","os_permission_unknown"].includes(c.provenance)&&Number.isFinite(d)&&d<=e&&p>e&&p>d&&p-d<=600000}function Kt(r,e,o=Date.now()){if(!r||!e||r.state!=="connected"||r.deviceId!==e.deviceId)return null;let c=Date.parse(r.lastHeartbeatAt??""),d=r.permissionRecovery;if(!(o-c>=0&&o-c<30000)||!G(d,o)||d.deviceId!==e.deviceId||d.organizationId!==e.orgId)return null;try{process.kill(r.pid,0)}catch{return null}return d}function H(r={},e=a()){let o=_({env:{...process.env,...r}}),c=r.XDG_CONFIG_HOME?.trim()||m(e,".config");return ke(c,...o==="staging"?["staging"]:[])}function Mr(r={},e=a()){return m(H(r,e),"local-device.json")}function xe(r={},e=a()){return m(H(r,e),"local-daemon.json")}function Ne(r,e){Se(w(r),{recursive:!0,mode:448}),L(w(r),448);let o=`${r}.${process.pid}.${me()}.tmp`;try{we(o,`${JSON.stringify(e,null,2)}
4
+ `,{mode:384,flag:"wx"}),L(o,384),De(o,r),L(r,384)}finally{if(z(o))Le(o)}return r}function E(r){if(!z(r))return null;try{return JSON.parse(Ie(r,"utf8"))}catch{return null}}function Oe(r){if(!Array.isArray(r))return null;let e=[];for(let o of r){if(!o||typeof o!=="object")return null;let c=o;if(typeof c.id!=="string"||typeof c.label!=="string"||typeof c.path!=="string"||typeof c.pathFingerprint!=="string"||!c.permissions||typeof c.permissions.read!=="boolean"||typeof c.permissions.write!=="boolean"||typeof c.permissions.execute!=="boolean"||typeof c.permissions.discover_environment!=="boolean"||typeof c.permissions.expose_mcp!=="boolean")return null;e.push({id:c.id,label:c.label,path:c.path,pathFingerprint:c.pathFingerprint,permissions:c.permissions})}return e}function J(r,e,o=[]){let c=Object.keys(r);return e.every((d)=>Object.hasOwn(r,d))&&c.every((d)=>e.includes(d)||o.includes(d))}function Ce(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost")return null;return e.origin}catch{return null}}function Y(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r,o=Oe(e.roots),c=Ce(e.apiOrigin);if(!c||typeof e.orgId!=="string"||typeof e.deviceId!=="string"||typeof e.displayName!=="string"||typeof e.registeredAt!=="string"||!Re(e.handsSlots)||e.worker!==void 0&&(!e.worker||!/^[a-f0-9]{64}$/.test(e.worker.configDigest)||!["persistent","ephemeral"].includes(e.worker.lifetime)||!Number.isFinite(Date.parse(e.worker.expiresAt)))||!o)return null;return{apiOrigin:c,orgId:e.orgId,deviceId:e.deviceId,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:o}}function Te(r){return{version:A,apiOrigin:r.apiOrigin,orgId:r.orgId,deviceId:r.deviceId,devicePublicKey:r.devicePublicKey,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:r.roots.map((e)=>({id:e.id,label:e.label,path:e.path,pathFingerprint:e.pathFingerprint,permissions:{read:e.permissions.read,write:e.permissions.write,execute:e.permissions.execute,discover_environment:e.permissions.discover_environment,expose_mcp:e.permissions.expose_mcp}})),credentialStorage:P}}function X(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r;if(!J(e,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Y(e);if(!o||e.version!==A||e.credentialStorage!==P||!v(e.devicePublicKey))return null;return{version:A,...o,devicePublicKey:e.devicePublicKey,credentialStorage:P}}function Ue(r){return new TextEncoder().encode(`${Ee}${JSON.stringify(Te(r))}`)}function Fe(r){let e=Buffer.from(r,"base64url");return be({format:"jwk",key:{kty:"EC",crv:"P-256",x:e.subarray(1,33).toString("base64url"),y:e.subarray(33,65).toString("base64url")}})}function Me(r){let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r))}catch{throw new l("invalid_binding")}if(!e||typeof e!=="object"||Array.isArray(e))throw new l("invalid_binding");let o=e;if(!J(o,["version","state","signature"])||o.version!==Pe||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new l("invalid_binding");let c=X(o.state);if(!c)throw new l("invalid_binding");let d=!1;try{d=he("sha256",Ue(c),Fe(c.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new l("invalid_binding");return c}function je(r){let{credentialStorage:e,...o}=r;return o}function $r(r=Mr(),e={}){let o=E(r),c=e.proofStore??e.credentialStore??V(),d=c.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&Ve(o))return null;if(o!==null)throw new l("invalid_binding");return null}let p=Me(d),W=c.loadPublicKey();if(c.privateKeyIsNonExtractable(),W!==p.devicePublicKey)throw new l("invalid_public_key");let R=X(o);if(e.repair!==!1&&(!R||JSON.stringify(R)!==JSON.stringify(p)))Ne(r,p);return je(p)}function Ve(r){let e=r,o=Y(r);if(!o)return null;if(e.version===2){if(typeof e.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(e.deviceCredential)||e.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(e.version!==3||e.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in e)return null;return{state:o,credentialSource:"keychain-v3"}}function pt(r=xe()){let e=E(r);if(!e||typeof e!=="object")return null;let o=e;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!G(o.permissionRecovery))delete o.permissionRecovery;return o}var Jt=1;function Be(r=Mr()){return m(w(r),"local-device.proxy.json")}function j(r=Be()){let e=E(r);if(!e||typeof e!=="object"||Array.isArray(e))return null;let o=e;if(o.version!==Jt||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!Ae(o.caFile)))return null;return{version:Jt,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}
5
+ export{l,Gt,Ke,Lr,Kt,Mr,$r,pt,Jt,j};