sliftutils 1.7.136 → 1.7.138

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 (38) hide show
  1. package/bin/printmachineid.js +5 -0
  2. package/examplestorage/browser.tsx +2 -2
  3. package/index.d.ts +10 -4
  4. package/misc/dist/strings.ts.cache +2 -2
  5. package/misc/https/certs.d.ts +6 -1
  6. package/misc/https/certs.ts +11 -2
  7. package/misc/https/dist/certs.ts.cache +14 -5
  8. package/misc/https/dist/persistentLocalStorage.ts.cache +14 -4
  9. package/misc/https/persistentLocalStorage.d.ts +1 -0
  10. package/misc/https/persistentLocalStorage.ts +10 -0
  11. package/package.json +5 -3
  12. package/security/authorizedKeys/daemon/daemon.ts +4 -3
  13. package/security/authorizedKeys/daemon/dist/revocation.ts.cache +0 -0
  14. package/security/authorizedKeys/daemon/dist/trust.ts.cache +126 -4
  15. package/security/authorizedKeys/daemon/revocation.d.ts +4 -7
  16. package/security/authorizedKeys/daemon/revocation.ts +0 -0
  17. package/security/authorizedKeys/daemon/trust.d.ts +12 -1
  18. package/security/authorizedKeys/daemon/trust.ts +124 -1
  19. package/security/authorizedKeys/dist/unrevoke.ts.cache +5 -186
  20. package/security/authorizedKeys/dist/unrevokeCli.ts.cache +195 -0
  21. package/security/machines/dist/machines.ts.cache +20 -68
  22. package/security/machines/dist/printMachineId.ts.cache +21 -0
  23. package/security/machines/identity2.ts +94 -6
  24. package/security/machines/machines.ts +27 -76
  25. package/security/machines/printMachineId.ts +19 -0
  26. package/security/signedFiles/dist/signFiles.ts.cache +16 -52
  27. package/storage/remoteStorage/ArchivesRemote.d.ts +1 -1
  28. package/storage/remoteStorage/ArchivesRemote.ts +14 -8
  29. package/storage/remoteStorage/accessPage.tsx +7 -123
  30. package/storage/remoteStorage/createArchives.d.ts +1 -1
  31. package/storage/remoteStorage/createArchives.ts +1 -1
  32. package/storage/remoteStorage/dist/ArchivesRemote.ts.cache +14 -7
  33. package/storage/remoteStorage/dist/createArchives.ts.cache +2 -2
  34. package/storage/remoteStorage/dist/sourceWrapper.ts.cache +3 -3
  35. package/storage/remoteStorage/dist/storageController.ts.cache +8 -7
  36. package/storage/remoteStorage/sourceWrapper.ts +1 -1
  37. package/storage/remoteStorage/storageController.d.ts +1 -1
  38. package/storage/remoteStorage/storageController.ts +10 -10
@@ -5,7 +5,7 @@ import { setHTTPResultHeaders, getCurrentHTTPRequest } from "socket-function/src
5
5
  import { performLocalCall } from "socket-function/src/callManager";
6
6
  import { RequireController } from "socket-function/require/RequireController";
7
7
  import { timeInMinute } from "socket-function/src/misc";
8
- import { getCommonName, getPublicIdentifier, getOwnMachineId, verify, verifyMachineIdForPublicKey } from "../../misc/https/certs";
8
+ import { getCommonName, getMachineId, getOwnMachineId, validateCertificate, verify } from "../../misc/https/certs";
9
9
  import { ArchiveFileInfo, ArchivesConfig, ArchivesSyncStatus, FindConfig, SourceConfig, IMMUTABLE_CACHE_TIME } from "../IArchives";
10
10
  import { ROUTING_FILE, getRoute, routeContains } from "./remoteConfig";
11
11
  import {
@@ -43,6 +43,7 @@ export type AuthTokenData = {
43
43
  };
44
44
  export type AuthToken = {
45
45
  certPem: string;
46
+ issuerPem: string;
46
47
  signature: string;
47
48
  data: AuthTokenData;
48
49
  };
@@ -50,9 +51,8 @@ export type AccessState = {
50
51
  machineId: string;
51
52
  ip: string;
52
53
  hasAccess: boolean;
53
- // Why not, and what to run about it, when there is no access.
54
+ // Why not, including the command that grants access, when there is no access.
54
55
  reason?: string;
55
- addMachineCommand?: string;
56
56
  // Everything the repo trusts, when there is.
57
57
  trustedMachines?: MachineState[];
58
58
  };
@@ -122,7 +122,7 @@ async function requireAccess(account: string): Promise<string> {
122
122
  if (!verdict.accepted) {
123
123
  throw new Error(
124
124
  `${STORAGE_ACCESS_DENIED} ${verdict.reason}`
125
- + ` Machine ${machineId}, address ${ip}, account ${JSON.stringify(account)}.`
125
+ + ` Machine ${machineId} was calling from ${ip}, for account ${JSON.stringify(account)}.`
126
126
  );
127
127
  }
128
128
  return machineId;
@@ -134,8 +134,11 @@ class RemoteStorageControllerBase {
134
134
  return {};
135
135
  }
136
136
 
137
+ // Secure because connections use real certificates on real domain names, so TLS itself stops a
138
+ // man-in-the-middle. Otherwise one would be possible: the signed token only names the server's
139
+ // domain, so a middleman on the path to that domain could reuse it against the real server.
137
140
  async authenticate(token: AuthToken): Promise<{ machineId: string; ip: string }> {
138
- let { domain, port } = getStorageServerConfig();
141
+ let { domain, port, rootDomain } = getStorageServerConfig();
139
142
  let caller = SocketFunction.getCaller();
140
143
  verify(token.certPem, token.signature, token.data);
141
144
  let { purpose, time, server } = token.data;
@@ -149,10 +152,8 @@ class RemoteStorageControllerBase {
149
152
  if (tokenDomain !== domain) {
150
153
  throw new Error(`Auth token is for server ${JSON.stringify(server)}, but this server is ${JSON.stringify(`${domain}:${port}`)}`);
151
154
  }
152
- let machineId = getCommonName(token.certPem).split(".")[0];
153
- if (!verifyMachineIdForPublicKey({ machineId, publicKey: getPublicIdentifier(token.certPem) })) {
154
- throw new Error(`Certificate common name does not match its public key: ${JSON.stringify(getCommonName(token.certPem))}`);
155
- }
155
+ validateCertificate(rootDomain, token.certPem, token.issuerPem);
156
+ let machineId = getMachineId(getCommonName(token.issuerPem), rootDomain);
156
157
  sessions.set(caller.nodeId, machineId);
157
158
  while (sessions.size > MAX_SESSIONS) {
158
159
  let oldest = sessions.keys().next().value;
@@ -183,7 +184,6 @@ class RemoteStorageControllerBase {
183
184
  ip,
184
185
  hasAccess: false,
185
186
  reason: verdict.reason,
186
- addMachineCommand: `yarn addmachine ${rootDomain} ${machineId} ${ip} git`,
187
187
  };
188
188
  }
189
189
  return { machineId, ip, hasAccess: true, trustedMachines: await getTrustedMachines() };