@ours.network/install 1.2.1-nightly.54 → 1.2.1-nightly.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -690,6 +690,8 @@ Fleet and Messenger task builds. Do not advertise it as available in `@latest`.
690
690
  Use an owned private directory and a 0600 downloaded payload:
691
691
 
692
692
  ```sh
693
+ OURS_ACCOUNT_ORIGIN=https://accounts.example.com \
694
+ OURS_WORKSPACE_HOST=alice-home.workspaces.example.com \
693
695
  node /absolute/task-ours-network/packages/installer/install.mjs \
694
696
  --setup-workspace-file /absolute/private/workspace.payload \
695
697
  --workspace-fleet-bin /absolute/task-ours-fleet/dist/cli.js \
@@ -719,9 +721,18 @@ Google/Cloudflare prerequisites and account-server setup. On uncertain enrollmen
719
721
  check account status before requesting a new payload; do not reset identities or
720
722
  replay a consumed invitation.
721
723
 
722
- Workspace setup accepts exactly https://app.ours.network and the controlled test
723
- account origin https://app.ours-tunnel.com. To move an existing same workspace to
724
- the other origin, obtain a fresh payload from the moved account server and add
724
+ Workspace setup requires the trusted invocation configuration `OURS_ACCOUNT_ORIGIN`
725
+ to name the exact HTTPS account origin. The generated App command also carries
726
+ `OURS_WORKSPACE_HOST`, the exact account-record hostname; it takes precedence over
727
+ `OURS_WORKSPACE_DOMAIN`. An operator bootstrap without an exact host may instead
728
+ configure `OURS_WORKSPACE_DOMAIN`, accepting one DNS label under that suffix. A
729
+ missing configuration has no historical-domain fallback. Never obtain these trust
730
+ values from a grant, redeemed envelope, or query. Grant origins are checked before
731
+ redemption; envelope origins and hosts are checked before setup/enrollment, and
732
+ the same trusted configuration is forwarded to Fleet. A v2 grant has no hostname.
733
+
734
+ To move an existing same workspace to another configured origin, obtain a fresh
735
+ payload from the moved account server, select that trusted origin explicitly, and add
725
736
  `--workspace-migrate-app-origin`. Fleet verifies the signed binding receipt before
726
737
  changing local origin trust, preserves identities/config/device records, and
727
738
  restarts the runtime. An implicit origin change is rejected. Browser account
@@ -3168,9 +3168,9 @@
3168
3168
  "license": "ISC"
3169
3169
  },
3170
3170
  "node_modules/ret": {
3171
- "version": "0.5.0",
3172
- "resolved": "https://registry.npmjs.org/ret/-/ret-0.5.0.tgz",
3173
- "integrity": "sha512-I1XxrZSQ+oErkRR4jYbAyEEu2I0avBvvMM5JN+6EBprOGRCs63ENqZ3vjavq8fBw2+62G5LF5XelKwuJpcvcxw==",
3171
+ "version": "0.5.1",
3172
+ "resolved": "https://registry.npmjs.org/ret/-/ret-0.5.1.tgz",
3173
+ "integrity": "sha512-Z/nyvABwcRnRD2mMP7Kz6G1dFZZqX1mNErOnxF42OCQKE07b9k9hK9SQxHL3LFEZUdzQaLM4dId1E/E6Vm4WhA==",
3174
3174
  "license": "MIT",
3175
3175
  "engines": {
3176
3176
  "node": ">=10"
@@ -3367,9 +3367,9 @@
3367
3367
  "license": "ISC"
3368
3368
  },
3369
3369
  "node_modules/set-cookie-parser": {
3370
- "version": "3.1.3",
3371
- "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-3.1.3.tgz",
3372
- "integrity": "sha512-xletSdAI5efyVJjsatBbzDkXl3M/Zmad3xfnQe7ZXuBB0yNwW7C2WFsNGjdRNfZunmNHQuX79xs/ACMTLCdcew==",
3370
+ "version": "3.1.4",
3371
+ "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-3.1.4.tgz",
3372
+ "integrity": "sha512-iEmdEew+Tn1BwMGMP8LzGBEPC7Mf1sySjglCeEPb/Vchm9bnGezePvacYcId+fGprQzIng+TBkzqfJ/qS7AsBg==",
3373
3373
  "license": "MIT"
3374
3374
  },
3375
3375
  "node_modules/setprototypeof": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "channel": "nightly",
4
- "installerVersion": "1.2.1-nightly.54",
4
+ "installerVersion": "1.2.1-nightly.55",
5
5
  "packages": {
6
6
  "@ours.network/sdk": {
7
7
  "version": "3.8.1-nightly.18",
@@ -2,7 +2,7 @@
2
2
  "release": {
3
3
  "schema": 1,
4
4
  "channel": "nightly",
5
- "installerVersion": "1.2.1-nightly.54",
5
+ "installerVersion": "1.2.1-nightly.55",
6
6
  "packages": {
7
7
  "@ours.network/sdk": {
8
8
  "version": "3.8.1-nightly.18",
@@ -2,12 +2,25 @@ import { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync,
2
2
  import { join,resolve } from 'node:path';
3
3
  import {parseSetupArgs} from './setup-options.mjs';
4
4
  import {preflightSetup} from './setup.mjs';
5
+ // Invocation configuration is trusted; an incoming grant/envelope never selects its authority.
6
+ const dnsName=value=>typeof value==='string' && value.length<=253 && value.includes('.') && value.split('.').every(label=>/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label));
7
+ function configuredOrigin(value,env) {
8
+ const configured=env.OURS_ACCOUNT_ORIGIN;
9
+ let url;try{url=new URL(configured);}catch{return false;}
10
+ return typeof configured==='string' && url.protocol==='https:' && url.origin===configured && !url.username && !url.password && !url.hostname.includes('*') && value===configured;
11
+ }
12
+ function configuredHost(value,env) {
13
+ if(!dnsName(value))return false;
14
+ if(env.OURS_WORKSPACE_HOST!==undefined)return dnsName(env.OURS_WORKSPACE_HOST) && value===env.OURS_WORKSPACE_HOST;
15
+ const domain=env.OURS_WORKSPACE_DOMAIN;
16
+ return dnsName(domain) && value.endsWith('.'+domain) && !value.slice(0,-domain.length-1).includes('.');
17
+ }
5
18
  /** Base64 is transport, not encryption. Broad provider credentials are never accepted. */
6
- export function decodeWorkspacePayload(encoded,now=Date.now()) {
19
+ export function decodeWorkspacePayload(encoded,now=Date.now(),env={}) {
7
20
  if(typeof encoded!=='string' || encoded.length>32768 || !/^[A-Za-z0-9_-]+$/.test(encoded.trim()))throw Error('Invalid private workspace payload');
8
21
  let p;try{p=JSON.parse(Buffer.from(encoded.trim(),'base64url'));}catch{throw Error('Invalid private workspace payload');}
9
22
  const allowed=['version','appOrigin','hostname','rootName','fullName','name','surname','connectorToken','invitation','serverCid','challenge','renewal'];
10
- if(!p || typeof p!=='object' || Array.isArray(p) || Object.keys(p).some(k=>!allowed.includes(k)) || p.version!==1 || !['https://app.ours.network','https://app.ours-tunnel.com'].includes(p.appOrigin) || !/^[a-z0-9][a-z0-9-]{2,60}\.ours-tunnel\.com$/.test(p.hostname) || !/^[a-z0-9-]{2,30}@[a-z0-9-]{2,30}$/.test(p.rootName) || !/^[a-f0-9]{64}$/i.test(p.serverCid))throw Error('Invalid workspace payload boundary');
23
+ if(!p || typeof p!=='object' || Array.isArray(p) || Object.keys(p).some(k=>!allowed.includes(k)) || p.version!==1 || !configuredOrigin(p.appOrigin,env) || !configuredHost(p.hostname,env) || !/^[a-z0-9-]{2,30}@[a-z0-9-]{2,30}$/.test(p.rootName) || !/^[a-f0-9]{64}$/i.test(p.serverCid))throw Error('Invalid workspace payload boundary');
11
24
  for(const key of ['fullName','name','surname']){const value=p[key];if(value==null || value===''){p[key]=null;continue;}if(typeof value!=='string' || value.length>8192 || /[\x00-\x1f\x7f]/.test(value))throw Error('Invalid private workspace profile');p[key]=value.trim()||null;}
12
25
  if(p.renewal!==undefined && typeof p.renewal!=='boolean')throw Error('Invalid workspace renewal');
13
26
  for(const key of ['connectorToken','invitation'])if(!(key==='connectorToken' && p[key]===undefined && p.renewal===true) && (typeof p[key]!=='string' || !p[key].trim() || p[key].length>8192 || /[\x00-\x1f\x7f]/.test(p[key])))throw Error('Invalid private workspace payload');
@@ -17,19 +30,19 @@ export function decodeWorkspacePayload(encoded,now=Date.now()) {
17
30
  // A v1 envelope is local. A v2 grant is one-use, so it is parsed here and redeemed only after the
18
31
  // payload-independent checks in runWorkspaceSetup (arguments, host state, read-only setup and Fleet
19
32
  // settings preflight, Fleet/tunnel availability, dry run) pass.
20
- function workspaceGrant(input){
33
+ function workspaceGrant(input,env){
21
34
  if(typeof input!=='string' || !/^[A-Za-z0-9_-]{1,32768}$/.test(input.trim()))throw Error('Invalid workspace setup input');
22
35
  let grant;try{grant=JSON.parse(Buffer.from(input.trim(),'base64url'));}catch{throw Error('Invalid workspace setup input');}
23
36
  if(grant?.version===1)return null;
24
37
  const now=Date.now();
25
38
  if(grant?.version!==2 || Object.keys(grant).sort().join(',')!=='appOrigin,code,expiresAt,version'
26
- || !['https://app.ours.network','https://app.ours-tunnel.com'].includes(grant.appOrigin)
39
+ || !configuredOrigin(grant.appOrigin,env)
27
40
  || !/^[A-Za-z0-9_-]{43}$/.test(grant.code) || !Number.isSafeInteger(grant.expiresAt) || grant.expiresAt<=now || grant.expiresAt>now+16*60000)
28
41
  throw Error('Workspace setup grant is invalid or expired; get a fresh command from the App');
29
42
  return grant;
30
43
  }
31
44
  // Redeem only the minimal public grant; the private envelope stays in process/file transport.
32
- async function redeemWorkspaceGrant(grant,request){
45
+ async function redeemWorkspaceGrant(grant,request,env){
33
46
  let response;
34
47
  try{response=await request(grant.appOrigin+'/account-api/workspace-install-redeem',{method:'POST',redirect:'error',credentials:'omit',signal:AbortSignal.timeout(30000),headers:{'Content-Type':'application/json',Origin:grant.appOrigin},body:JSON.stringify({code:grant.code})});}
35
48
  catch{throw Error('Workspace grant redemption could not be confirmed; check the App before requesting a fresh command');}
@@ -42,7 +55,7 @@ async function redeemWorkspaceGrant(grant,request){
42
55
  result=JSON.parse(Buffer.concat(chunks).toString('utf8'));
43
56
  }catch{throw Error('Invalid workspace setup response; get a fresh command from the App');}
44
57
  if(typeof result?.payload!=='string' || !/^[A-Za-z0-9_-]{1,32768}$/.test(result.payload))throw Error('Invalid workspace setup response');
45
- const payload=decodeWorkspacePayload(result.payload);
58
+ const payload=decodeWorkspacePayload(result.payload,Date.now(),env);
46
59
  if(payload.appOrigin!==grant.appOrigin)throw Error('Workspace setup response origin mismatch');
47
60
  return result.payload;
48
61
  }
@@ -59,8 +72,9 @@ export async function runWorkspaceSetup(args,effects,runSetup,request=fetch){
59
72
  if(values['--setup-workspace-file']){const path=resolve(values['--setup-workspace-file']),stat=lstatSync(path);if(!stat.isFile() || stat.isSymbolicLink() || stat.nlink!==1 || stat.uid!==process.getuid?.() || stat.size>32768 || (stat.mode&0o077)!==0)throw Error('Setup file must be owned and private (chmod 600)');encoded=readFileSync(path,'utf8').trim();}
60
73
  else if(values['--setup-workspace']==='-'){const chunks=[];let bytes=0;for await(const chunk of process.stdin){bytes+=chunk.length;if(bytes>32768)throw Error('Private payload too large');chunks.push(chunk);}encoded=Buffer.concat(chunks).toString().trim();}
61
74
  else encoded=values['--setup-workspace'];
62
- const grant=workspaceGrant(encoded);
63
- let p=grant?null:decodeWorkspacePayload(encoded);const fleetBin=values['--workspace-fleet-bin'] || 'ours-fleet';
75
+ const authority={OURS_ACCOUNT_ORIGIN:effects.env?.OURS_ACCOUNT_ORIGIN,OURS_WORKSPACE_HOST:effects.env?.OURS_WORKSPACE_HOST,OURS_WORKSPACE_DOMAIN:effects.env?.OURS_WORKSPACE_DOMAIN};
76
+ const grant=workspaceGrant(encoded,authority);
77
+ let p=grant?null:decodeWorkspacePayload(encoded,Date.now(),authority);const fleetBin=values['--workspace-fleet-bin'] || 'ours-fleet';
64
78
  const parsed=parseSetupArgs(rest,{home:effects.home,validate:false});
65
79
  if(parsed.scope==='server')throw Error('Workspace setup requires all or client scope');
66
80
  if(parsed.identityName!==undefined || parsed.integrations!==undefined)throw Error('Workspace setup supplies identity and client integration selection');
@@ -115,7 +129,7 @@ export async function runWorkspaceSetup(args,effects,runSetup,request=fetch){
115
129
  }
116
130
  if(grant){
117
131
  // Checks below depend on the private envelope, so a failure here leaves the grant spent.
118
- encoded=await redeemWorkspaceGrant(grant,request);p=decodeWorkspacePayload(encoded);
132
+ encoded=await redeemWorkspaceGrant(grant,request,authority);p=decodeWorkspacePayload(encoded,Date.now(),authority);
119
133
  resumable();
120
134
  parseSetupArgs(setupOptions(p.rootName),{home:effects.home});
121
135
  await requireOptionalProfile();
@@ -125,7 +139,7 @@ export async function runWorkspaceSetup(args,effects,runSetup,request=fetch){
125
139
  const result=await runSetup(setupOptions(p.rootName),effects);if(result!==0)return result;
126
140
  }
127
141
  const selected=existingProfile || effects.readManagedClientProfile();if(!selected)throw Error('Workspace client profile was not installed');
128
- const env={OURS_CONFIG:existingProfile || managedPath};
142
+ const env={...authority,OURS_CONFIG:existingProfile || managedPath};
129
143
  for(const key of ['OURS_PORT','OURS_STATE_DIR','OURS_API_TOKEN','OURS_DAEMON_ID','OURS_DAEMON_URL','OURS_DAEMON_CREDENTIAL_PATH'])env[key]=undefined;
130
144
  if(!existsSync(fleetConfig)){
131
145
  const initArgs=['init',...(fleetSettings?['--settings',fleetSettings]:[])];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ours.network/install",
3
- "version": "1.2.1-nightly.54",
3
+ "version": "1.2.1-nightly.55",
4
4
  "private": false,
5
5
  "description": "The all-in-one ours.network installer: one shared daemon, MCP, cowork, Telegram, Fleet initialization, harness plugins, Human identity, progress UI, and guided next steps.",
6
6
  "type": "module",