sliftutils 1.7.136 → 1.7.137

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 (51) hide show
  1. package/examplestorage/browser.tsx +3 -2
  2. package/index.d.ts +10 -3
  3. package/misc/dist/strings.ts.cache +2 -2
  4. package/misc/https/certs.d.ts +5 -1
  5. package/misc/https/certs.ts +5 -1
  6. package/misc/https/dist/certs.ts.cache +8 -4
  7. package/misc/https/dist/persistentLocalStorage.ts.cache +2 -2
  8. package/package.json +1 -1
  9. package/security/authorizedKeys/daemon/daemon.ts +4 -3
  10. package/security/authorizedKeys/daemon/dist/changes.ts.cache +2 -2
  11. package/security/authorizedKeys/daemon/dist/git.ts.cache +2 -2
  12. package/security/authorizedKeys/daemon/dist/notify.ts.cache +2 -2
  13. package/security/authorizedKeys/daemon/dist/paths.ts.cache +2 -2
  14. package/security/authorizedKeys/daemon/dist/repoFiles.ts.cache +2 -2
  15. package/security/authorizedKeys/daemon/dist/revocation.ts.cache +0 -0
  16. package/security/authorizedKeys/daemon/dist/sessions.ts.cache +2 -2
  17. package/security/authorizedKeys/daemon/dist/state.ts.cache +2 -2
  18. package/security/authorizedKeys/daemon/dist/trust.ts.cache +126 -4
  19. package/security/authorizedKeys/daemon/revocation.d.ts +4 -7
  20. package/security/authorizedKeys/daemon/revocation.ts +0 -0
  21. package/security/authorizedKeys/daemon/trust.d.ts +12 -1
  22. package/security/authorizedKeys/daemon/trust.ts +124 -1
  23. package/security/authorizedKeys/dist/authorizedKeys.ts.cache +2 -2
  24. package/security/authorizedKeys/dist/keysRepo.ts.cache +2 -2
  25. package/security/authorizedKeys/dist/revokeSource.ts.cache +2 -2
  26. package/security/authorizedKeys/dist/sources.ts.cache +2 -2
  27. package/security/authorizedKeys/dist/unrevoke.ts.cache +5 -186
  28. package/security/authorizedKeys/dist/unrevokeCli.ts.cache +195 -0
  29. package/security/helpers/dist/paths.ts.cache +2 -2
  30. package/security/helpers/dist/remoteSSH.ts.cache +2 -2
  31. package/security/helpers/dist/spawn.ts.cache +2 -2
  32. package/security/keys/dist/deriveKey.ts.cache +2 -2
  33. package/security/keys/dist/sshKeyFile.ts.cache +2 -2
  34. package/security/machines/dist/machines.ts.cache +20 -68
  35. package/security/machines/machines.ts +18 -67
  36. package/security/notifications/dist/discord.ts.cache +2 -2
  37. package/security/signedFiles/dist/manifest.ts.cache +2 -2
  38. package/security/signedFiles/dist/signFiles.ts.cache +16 -52
  39. package/security/signedFiles/dist/sshsig.ts.cache +2 -2
  40. package/storage/remoteStorage/ArchivesRemote.d.ts +2 -1
  41. package/storage/remoteStorage/ArchivesRemote.ts +14 -7
  42. package/storage/remoteStorage/accessPage.tsx +7 -123
  43. package/storage/remoteStorage/createArchives.d.ts +2 -1
  44. package/storage/remoteStorage/createArchives.ts +1 -1
  45. package/storage/remoteStorage/dist/ArchivesRemote.ts.cache +14 -7
  46. package/storage/remoteStorage/dist/createArchives.ts.cache +2 -2
  47. package/storage/remoteStorage/dist/sourceWrapper.ts.cache +3 -3
  48. package/storage/remoteStorage/dist/storageController.ts.cache +8 -7
  49. package/storage/remoteStorage/sourceWrapper.ts +1 -1
  50. package/storage/remoteStorage/storageController.d.ts +1 -0
  51. package/storage/remoteStorage/storageController.ts +8 -6
@@ -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
  };
@@ -134,8 +135,11 @@ class RemoteStorageControllerBase {
134
135
  return {};
135
136
  }
136
137
 
138
+ // Secure because connections use real certificates on real domain names, so TLS itself stops a
139
+ // man-in-the-middle. Otherwise one would be possible: the signed token only names the server's
140
+ // domain, so a middleman on the path to that domain could reuse it against the real server.
137
141
  async authenticate(token: AuthToken): Promise<{ machineId: string; ip: string }> {
138
- let { domain, port } = getStorageServerConfig();
142
+ let { domain, port, rootDomain } = getStorageServerConfig();
139
143
  let caller = SocketFunction.getCaller();
140
144
  verify(token.certPem, token.signature, token.data);
141
145
  let { purpose, time, server } = token.data;
@@ -149,10 +153,8 @@ class RemoteStorageControllerBase {
149
153
  if (tokenDomain !== domain) {
150
154
  throw new Error(`Auth token is for server ${JSON.stringify(server)}, but this server is ${JSON.stringify(`${domain}:${port}`)}`);
151
155
  }
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
- }
156
+ validateCertificate(rootDomain, token.certPem, token.issuerPem);
157
+ let machineId = getMachineId(getCommonName(token.issuerPem), rootDomain);
156
158
  sessions.set(caller.nodeId, machineId);
157
159
  while (sessions.size > MAX_SESSIONS) {
158
160
  let oldest = sessions.keys().next().value;