@xenosystem/primitives 0.0.0-stage → 0.2.0
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 +29 -2
- package/dist/cjs/dirs/atomic.d.ts +9 -0
- package/dist/cjs/dirs/atomic.js +59 -0
- package/dist/cjs/dirs/check-cli.d.ts +2 -0
- package/dist/cjs/dirs/check-cli.js +50 -0
- package/dist/cjs/dirs/check.d.ts +49 -0
- package/dist/cjs/dirs/check.js +158 -0
- package/dist/cjs/dirs/cli.d.ts +2 -0
- package/dist/cjs/dirs/cli.js +72 -0
- package/dist/cjs/dirs/dirs.d.ts +57 -0
- package/dist/cjs/dirs/dirs.js +135 -0
- package/dist/cjs/dirs/doctor.d.ts +31 -0
- package/dist/cjs/dirs/doctor.js +80 -0
- package/dist/cjs/dirs/errors.d.ts +8 -0
- package/dist/cjs/dirs/errors.js +19 -0
- package/dist/cjs/dirs/host.d.ts +4 -0
- package/dist/cjs/dirs/host.js +26 -0
- package/dist/cjs/dirs/index.d.ts +13 -0
- package/dist/cjs/dirs/index.js +55 -0
- package/dist/cjs/dirs/inputs.d.ts +14 -0
- package/dist/cjs/dirs/inputs.js +14 -0
- package/dist/cjs/dirs/layout.d.ts +16 -0
- package/dist/cjs/dirs/layout.js +25 -0
- package/dist/cjs/dirs/lock.d.ts +38 -0
- package/dist/cjs/dirs/lock.js +128 -0
- package/dist/cjs/dirs/migrate.d.ts +134 -0
- package/dist/cjs/dirs/migrate.js +437 -0
- package/dist/cjs/dirs/procinfo.d.ts +10 -0
- package/dist/cjs/dirs/procinfo.js +67 -0
- package/dist/cjs/dirs/registry.d.ts +27 -0
- package/dist/cjs/dirs/registry.js +78 -0
- package/dist/cjs/dirs/roots.d.ts +23 -0
- package/dist/cjs/dirs/roots.js +114 -0
- package/dist/cjs/dirs/segments.d.ts +7 -0
- package/dist/cjs/dirs/segments.js +39 -0
- package/dist/cjs/generated/contract.d.ts +134 -0
- package/dist/cjs/generated/contract.js +233 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/secrets/envelope.d.ts +37 -0
- package/dist/cjs/secrets/envelope.js +90 -0
- package/dist/cjs/secrets/errors.d.ts +10 -0
- package/dist/cjs/secrets/errors.js +20 -0
- package/dist/cjs/secrets/index.d.ts +4 -0
- package/dist/cjs/secrets/index.js +17 -0
- package/dist/cjs/secrets/keystore.d.ts +37 -0
- package/dist/cjs/secrets/keystore.js +41 -0
- package/dist/cjs/secrets/os-stores.d.ts +17 -0
- package/dist/cjs/secrets/os-stores.js +195 -0
- package/dist/cjs/secrets/store.d.ts +32 -0
- package/dist/cjs/secrets/store.js +161 -0
- package/dist/cjs/secrets/testing.d.ts +5 -0
- package/dist/cjs/secrets/testing.js +20 -0
- package/dist/cjs/updates/index.d.ts +67 -0
- package/dist/cjs/updates/index.js +102 -0
- package/dist/esm/dirs/atomic.d.ts +9 -0
- package/dist/esm/dirs/atomic.js +56 -0
- package/dist/esm/dirs/check-cli.d.ts +2 -0
- package/dist/esm/dirs/check-cli.js +48 -0
- package/dist/esm/dirs/check.d.ts +49 -0
- package/dist/esm/dirs/check.js +152 -0
- package/dist/esm/dirs/cli.d.ts +2 -0
- package/dist/esm/dirs/cli.js +70 -0
- package/dist/esm/dirs/dirs.d.ts +57 -0
- package/dist/esm/dirs/dirs.js +129 -0
- package/dist/esm/dirs/doctor.d.ts +31 -0
- package/dist/esm/dirs/doctor.js +77 -0
- package/dist/esm/dirs/errors.d.ts +8 -0
- package/dist/esm/dirs/errors.js +14 -0
- package/dist/esm/dirs/host.d.ts +4 -0
- package/dist/esm/dirs/host.js +21 -0
- package/dist/esm/dirs/index.d.ts +13 -0
- package/dist/esm/dirs/index.js +13 -0
- package/dist/esm/dirs/inputs.d.ts +14 -0
- package/dist/esm/dirs/inputs.js +11 -0
- package/dist/esm/dirs/layout.d.ts +16 -0
- package/dist/esm/dirs/layout.js +21 -0
- package/dist/esm/dirs/lock.d.ts +38 -0
- package/dist/esm/dirs/lock.js +124 -0
- package/dist/esm/dirs/migrate.d.ts +134 -0
- package/dist/esm/dirs/migrate.js +428 -0
- package/dist/esm/dirs/procinfo.d.ts +10 -0
- package/dist/esm/dirs/procinfo.js +62 -0
- package/dist/esm/dirs/registry.d.ts +27 -0
- package/dist/esm/dirs/registry.js +71 -0
- package/dist/esm/dirs/roots.d.ts +23 -0
- package/dist/esm/dirs/roots.js +107 -0
- package/dist/esm/dirs/segments.d.ts +7 -0
- package/dist/esm/dirs/segments.js +35 -0
- package/dist/esm/generated/contract.d.ts +134 -0
- package/dist/esm/generated/contract.js +230 -0
- package/dist/esm/secrets/envelope.d.ts +37 -0
- package/dist/esm/secrets/envelope.js +81 -0
- package/dist/esm/secrets/errors.d.ts +10 -0
- package/dist/esm/secrets/errors.js +15 -0
- package/dist/esm/secrets/index.d.ts +4 -0
- package/dist/esm/secrets/index.js +4 -0
- package/dist/esm/secrets/keystore.d.ts +37 -0
- package/dist/esm/secrets/keystore.js +37 -0
- package/dist/esm/secrets/os-stores.d.ts +17 -0
- package/dist/esm/secrets/os-stores.js +189 -0
- package/dist/esm/secrets/store.d.ts +32 -0
- package/dist/esm/secrets/store.js +156 -0
- package/dist/esm/secrets/testing.d.ts +5 -0
- package/dist/esm/secrets/testing.js +12 -0
- package/dist/esm/updates/index.d.ts +67 -0
- package/dist/esm/updates/index.js +97 -0
- package/package.json +42 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecretsError = void 0;
|
|
4
|
+
exports.isSecretsError = isSecretsError;
|
|
5
|
+
/**
|
|
6
|
+
* Every error this family throws. Messages never contain a secret value; they may name the area and the secret's
|
|
7
|
+
* name (names are not secret). `code` is stable and is what callers branch on.
|
|
8
|
+
*/
|
|
9
|
+
class SecretsError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
constructor(code, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'SecretsError';
|
|
14
|
+
this.code = code;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.SecretsError = SecretsError;
|
|
18
|
+
function isSecretsError(e, code) {
|
|
19
|
+
return e instanceof SecretsError && (code === undefined || e.code === code);
|
|
20
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SecretsError, isSecretsError, type SecretsErrorCode } from './errors.ts';
|
|
2
|
+
export { SecretStore, createSecretStore, type SecretStoreOptions } from './store.ts';
|
|
3
|
+
export { electronSafeStorageKeyStore, unprotectedKeyStore, type BlobLocation, type KeyStore, type SafeStorageLike, } from './keystore.ts';
|
|
4
|
+
export { createLibsecretKeyStore, createMacKeychainKeyStore, createOsKeyStore, createWindowsCredentialKeyStore, type OsStoreOptions, } from './os-stores.ts';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWindowsCredentialKeyStore = exports.createOsKeyStore = exports.createMacKeychainKeyStore = exports.createLibsecretKeyStore = exports.unprotectedKeyStore = exports.electronSafeStorageKeyStore = exports.createSecretStore = exports.SecretStore = exports.isSecretsError = exports.SecretsError = void 0;
|
|
4
|
+
var errors_ts_1 = require("./errors.js");
|
|
5
|
+
Object.defineProperty(exports, "SecretsError", { enumerable: true, get: function () { return errors_ts_1.SecretsError; } });
|
|
6
|
+
Object.defineProperty(exports, "isSecretsError", { enumerable: true, get: function () { return errors_ts_1.isSecretsError; } });
|
|
7
|
+
var store_ts_1 = require("./store.js");
|
|
8
|
+
Object.defineProperty(exports, "SecretStore", { enumerable: true, get: function () { return store_ts_1.SecretStore; } });
|
|
9
|
+
Object.defineProperty(exports, "createSecretStore", { enumerable: true, get: function () { return store_ts_1.createSecretStore; } });
|
|
10
|
+
var keystore_ts_1 = require("./keystore.js");
|
|
11
|
+
Object.defineProperty(exports, "electronSafeStorageKeyStore", { enumerable: true, get: function () { return keystore_ts_1.electronSafeStorageKeyStore; } });
|
|
12
|
+
Object.defineProperty(exports, "unprotectedKeyStore", { enumerable: true, get: function () { return keystore_ts_1.unprotectedKeyStore; } });
|
|
13
|
+
var os_stores_ts_1 = require("./os-stores.js");
|
|
14
|
+
Object.defineProperty(exports, "createLibsecretKeyStore", { enumerable: true, get: function () { return os_stores_ts_1.createLibsecretKeyStore; } });
|
|
15
|
+
Object.defineProperty(exports, "createMacKeychainKeyStore", { enumerable: true, get: function () { return os_stores_ts_1.createMacKeychainKeyStore; } });
|
|
16
|
+
Object.defineProperty(exports, "createOsKeyStore", { enumerable: true, get: function () { return os_stores_ts_1.createOsKeyStore; } });
|
|
17
|
+
Object.defineProperty(exports, "createWindowsCredentialKeyStore", { enumerable: true, get: function () { return os_stores_ts_1.createWindowsCredentialKeyStore; } });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the per-machine master key rests. The OS store holds a KEY, never payloads (a Windows credential blob is
|
|
3
|
+
* capped at 2,560 bytes). `protection` is a statement about the platform backend, not a preference: a store that only
|
|
4
|
+
* offers an unprotected backend declares `unprotected`, and the secret store then refuses (no plaintext fallback).
|
|
5
|
+
*/
|
|
6
|
+
export interface KeyStore {
|
|
7
|
+
/** Stable identifier for diagnostics, e.g. `windows-credential-manager`. Never a secret. */
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly protection: 'os-protected' | 'unprotected';
|
|
10
|
+
/** Why a store is `unprotected` (shown to the person). */
|
|
11
|
+
readonly reason?: string;
|
|
12
|
+
getKey(): Promise<Uint8Array | null>;
|
|
13
|
+
putKey(key: Uint8Array): Promise<void>;
|
|
14
|
+
/** Removes the key; every secret sealed with it becomes unreadable. Used by tests and by account reset. */
|
|
15
|
+
deleteKey(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/** A store that has no protected backend on this machine. Every secret operation refuses with `reason`. */
|
|
18
|
+
export declare function unprotectedKeyStore(id: string, reason: string): KeyStore;
|
|
19
|
+
export interface SafeStorageLike {
|
|
20
|
+
isEncryptionAvailable(): boolean;
|
|
21
|
+
encryptString(plain: string): Uint8Array;
|
|
22
|
+
decryptString(encrypted: Uint8Array): string;
|
|
23
|
+
/** Linux only: `basic_text` means "no secret store; encrypted with a hardcoded password". */
|
|
24
|
+
getSelectedStorageBackend?(): string;
|
|
25
|
+
}
|
|
26
|
+
/** A way to protect bytes with the OS and a place to keep the protected blob. */
|
|
27
|
+
export interface BlobLocation {
|
|
28
|
+
read(): Promise<Uint8Array | null>;
|
|
29
|
+
write(blob: Uint8Array): Promise<void>;
|
|
30
|
+
remove(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A KeyStore for products that already ship Electron's safeStorage. The master key is encrypted with safeStorage and
|
|
34
|
+
* the blob kept at `location` (the caller chooses it, under a `secrets` kind path). `basic_text` and `unknown`
|
|
35
|
+
* backends, and `isEncryptionAvailable() === false`, are refused: that is the spec's hard-fail rule.
|
|
36
|
+
*/
|
|
37
|
+
export declare function electronSafeStorageKeyStore(safeStorage: SafeStorageLike, location: BlobLocation): KeyStore;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unprotectedKeyStore = unprotectedKeyStore;
|
|
4
|
+
exports.electronSafeStorageKeyStore = electronSafeStorageKeyStore;
|
|
5
|
+
const errors_ts_1 = require("./errors.js");
|
|
6
|
+
/** A store that has no protected backend on this machine. Every secret operation refuses with `reason`. */
|
|
7
|
+
function unprotectedKeyStore(id, reason) {
|
|
8
|
+
const refuse = () => { throw new errors_ts_1.SecretsError('unprotected-store', reason); };
|
|
9
|
+
return { id, protection: 'unprotected', reason, getKey: async () => refuse(), putKey: async () => refuse(), deleteKey: async () => refuse() };
|
|
10
|
+
}
|
|
11
|
+
const UNPROTECTED_BACKENDS = new Set(['basic_text', 'unknown']);
|
|
12
|
+
/**
|
|
13
|
+
* A KeyStore for products that already ship Electron's safeStorage. The master key is encrypted with safeStorage and
|
|
14
|
+
* the blob kept at `location` (the caller chooses it, under a `secrets` kind path). `basic_text` and `unknown`
|
|
15
|
+
* backends, and `isEncryptionAvailable() === false`, are refused: that is the spec's hard-fail rule.
|
|
16
|
+
*/
|
|
17
|
+
function electronSafeStorageKeyStore(safeStorage, location) {
|
|
18
|
+
const backend = safeStorage.getSelectedStorageBackend?.();
|
|
19
|
+
const available = safeStorage.isEncryptionAvailable();
|
|
20
|
+
if (!available || (backend !== undefined && UNPROTECTED_BACKENDS.has(backend))) {
|
|
21
|
+
return unprotectedKeyStore('electron-safe-storage', backend !== undefined && UNPROTECTED_BACKENDS.has(backend)
|
|
22
|
+
? `this machine offers only an unprotected store (Electron backend "${backend}"); secrets are not saved`
|
|
23
|
+
: 'the operating system encryption service is not available; secrets are not saved');
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
id: `electron-safe-storage${backend ? `:${backend}` : ''}`,
|
|
27
|
+
protection: 'os-protected',
|
|
28
|
+
async getKey() {
|
|
29
|
+
const blob = await location.read();
|
|
30
|
+
if (blob === null)
|
|
31
|
+
return null;
|
|
32
|
+
return Buffer.from(safeStorage.decryptString(blob), 'base64');
|
|
33
|
+
},
|
|
34
|
+
async putKey(key) {
|
|
35
|
+
await location.write(safeStorage.encryptString(Buffer.from(key).toString('base64')));
|
|
36
|
+
},
|
|
37
|
+
async deleteKey() {
|
|
38
|
+
await location.remove();
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type KeyStore } from './keystore.ts';
|
|
2
|
+
export interface OsStoreOptions {
|
|
3
|
+
/** Defaults to the contract's secretsKeyService / secretsKeyAccount. Tests pass unique names. */
|
|
4
|
+
service?: string;
|
|
5
|
+
account?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Windows Credential Manager (generic credential, persisted to this machine only; the system encrypts it with DPAPI).
|
|
9
|
+
* The key travels to PowerShell on stdin, never on the command line, and no PowerShell output is surfaced in errors.
|
|
10
|
+
* Slow (about a second per call: PowerShell + a small compiled P/Invoke); callers cache the key per process, and the
|
|
11
|
+
* Rust crate talks to the same entry directly.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createWindowsCredentialKeyStore(options?: OsStoreOptions): KeyStore;
|
|
14
|
+
export declare function createMacKeychainKeyStore(options?: OsStoreOptions): KeyStore;
|
|
15
|
+
export declare function createLibsecretKeyStore(options?: OsStoreOptions): KeyStore;
|
|
16
|
+
/** The key store for this machine's operating system. May be `unprotected`, in which case the secret store refuses. */
|
|
17
|
+
export declare function createOsKeyStore(options?: OsStoreOptions): KeyStore;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWindowsCredentialKeyStore = createWindowsCredentialKeyStore;
|
|
4
|
+
exports.createMacKeychainKeyStore = createMacKeychainKeyStore;
|
|
5
|
+
exports.createLibsecretKeyStore = createLibsecretKeyStore;
|
|
6
|
+
exports.createOsKeyStore = createOsKeyStore;
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const contract_ts_1 = require("../generated/contract.js");
|
|
9
|
+
const errors_ts_1 = require("./errors.js");
|
|
10
|
+
const keystore_ts_1 = require("./keystore.js");
|
|
11
|
+
const names = (o) => ({ service: o.service ?? contract_ts_1.INPUTS_JSON.secretsKeyService, account: o.account ?? contract_ts_1.INPUTS_JSON.secretsKeyAccount });
|
|
12
|
+
/** Runs a program with stdin; the output is returned, stderr is never surfaced (it can echo input). */
|
|
13
|
+
function run(file, args, stdin, timeoutMs = 120_000) {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const child = (0, node_child_process_1.execFile)(file, args, { timeout: timeoutMs, windowsHide: true, maxBuffer: 1 << 20 }, (err, stdout) => {
|
|
16
|
+
const code = err ? (typeof err.code === 'number' ? (err.code) : -1) : 0;
|
|
17
|
+
if (err && code === -1)
|
|
18
|
+
return reject(new errors_ts_1.SecretsError('key-unavailable', `could not run ${file}`));
|
|
19
|
+
resolve({ code, stdout: String(stdout) });
|
|
20
|
+
});
|
|
21
|
+
if (stdin !== null)
|
|
22
|
+
child.stdin?.end(stdin);
|
|
23
|
+
else
|
|
24
|
+
child.stdin?.end();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const hex = (b) => Buffer.from(b).toString('hex');
|
|
28
|
+
// ---- Windows: Credential Manager (DPAPI-backed) ----------------------------------------------------------------
|
|
29
|
+
const WINDOWS_SCRIPT = String.raw `
|
|
30
|
+
$ErrorActionPreference = 'Stop'
|
|
31
|
+
Add-Type -TypeDefinition @'
|
|
32
|
+
using System;
|
|
33
|
+
using System.ComponentModel;
|
|
34
|
+
using System.Runtime.InteropServices;
|
|
35
|
+
public static class XenoCred {
|
|
36
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
37
|
+
struct CREDENTIAL {
|
|
38
|
+
public uint Flags; public uint Type; public string TargetName; public string Comment;
|
|
39
|
+
public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten;
|
|
40
|
+
public uint CredentialBlobSize; public IntPtr CredentialBlob; public uint Persist;
|
|
41
|
+
public uint AttributeCount; public IntPtr Attributes; public string TargetAlias; public string UserName;
|
|
42
|
+
}
|
|
43
|
+
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern bool CredReadW(string t, uint type, uint flags, out IntPtr cred);
|
|
44
|
+
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern bool CredWriteW(ref CREDENTIAL cred, uint flags);
|
|
45
|
+
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern bool CredDeleteW(string t, uint type, uint flags);
|
|
46
|
+
[DllImport("advapi32.dll")] static extern void CredFree(IntPtr p);
|
|
47
|
+
const int NOT_FOUND = 1168;
|
|
48
|
+
public static byte[] Read(string target) {
|
|
49
|
+
IntPtr p;
|
|
50
|
+
if (!CredReadW(target, 1, 0, out p)) { int e = Marshal.GetLastWin32Error(); if (e == NOT_FOUND) return null; throw new Win32Exception(e); }
|
|
51
|
+
try {
|
|
52
|
+
CREDENTIAL c = (CREDENTIAL)Marshal.PtrToStructure(p, typeof(CREDENTIAL));
|
|
53
|
+
byte[] b = new byte[c.CredentialBlobSize];
|
|
54
|
+
Marshal.Copy(c.CredentialBlob, b, 0, b.Length);
|
|
55
|
+
return b;
|
|
56
|
+
} finally { CredFree(p); }
|
|
57
|
+
}
|
|
58
|
+
public static void Write(string target, string account, byte[] blob) {
|
|
59
|
+
CREDENTIAL c = new CREDENTIAL();
|
|
60
|
+
c.Type = 1; c.TargetName = target; c.UserName = account; c.Persist = 2;
|
|
61
|
+
c.CredentialBlobSize = (uint)blob.Length; c.CredentialBlob = Marshal.AllocHGlobal(blob.Length);
|
|
62
|
+
try {
|
|
63
|
+
Marshal.Copy(blob, 0, c.CredentialBlob, blob.Length);
|
|
64
|
+
if (!CredWriteW(ref c, 0)) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
65
|
+
} finally {
|
|
66
|
+
for (int i = 0; i < blob.Length; i++) Marshal.WriteByte(c.CredentialBlob, i, 0);
|
|
67
|
+
Marshal.FreeHGlobal(c.CredentialBlob);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
public static void Delete(string target) {
|
|
71
|
+
if (!CredDeleteW(target, 1, 0)) { int e = Marshal.GetLastWin32Error(); if (e != NOT_FOUND) throw new Win32Exception(e); }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
'@
|
|
75
|
+
$req = [Console]::In.ReadToEnd() | ConvertFrom-Json
|
|
76
|
+
$target = $req.target
|
|
77
|
+
switch ($req.op) {
|
|
78
|
+
'get' {
|
|
79
|
+
$b = [XenoCred]::Read($target)
|
|
80
|
+
if ($null -eq $b) { '{"found":false}' } else { '{"found":true,"key":"' + [Convert]::ToBase64String($b) + '"}' }
|
|
81
|
+
}
|
|
82
|
+
'put' { [XenoCred]::Write($target, $req.account, [Convert]::FromBase64String($req.key)); '{"ok":true}' }
|
|
83
|
+
'delete' { [XenoCred]::Delete($target); '{"ok":true}' }
|
|
84
|
+
default { throw 'unknown op' }
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
/**
|
|
88
|
+
* Windows Credential Manager (generic credential, persisted to this machine only; the system encrypts it with DPAPI).
|
|
89
|
+
* The key travels to PowerShell on stdin, never on the command line, and no PowerShell output is surfaced in errors.
|
|
90
|
+
* Slow (about a second per call: PowerShell + a small compiled P/Invoke); callers cache the key per process, and the
|
|
91
|
+
* Rust crate talks to the same entry directly.
|
|
92
|
+
*/
|
|
93
|
+
function createWindowsCredentialKeyStore(options = {}) {
|
|
94
|
+
if (process.platform !== 'win32')
|
|
95
|
+
return (0, keystore_ts_1.unprotectedKeyStore)('windows-credential-manager', 'Windows Credential Manager is only available on Windows');
|
|
96
|
+
const { service, account } = names(options);
|
|
97
|
+
const target = `${service}:${account}`;
|
|
98
|
+
const ps = `${process.env['SystemRoot'] ?? 'C:\\Windows'}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
99
|
+
const encoded = Buffer.from(WINDOWS_SCRIPT, 'utf16le').toString('base64');
|
|
100
|
+
const call = async (req) => {
|
|
101
|
+
const r = await run(ps, ['-NoProfile', '-NonInteractive', '-EncodedCommand', encoded], JSON.stringify({ target, account, ...req }));
|
|
102
|
+
if (r.code !== 0)
|
|
103
|
+
throw new errors_ts_1.SecretsError('key-unavailable', `Windows Credential Manager call failed (exit ${r.code})`);
|
|
104
|
+
try {
|
|
105
|
+
return JSON.parse(r.stdout.trim());
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
throw new errors_ts_1.SecretsError('key-unavailable', 'Windows Credential Manager returned an unreadable reply');
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
id: 'windows-credential-manager',
|
|
113
|
+
protection: 'os-protected',
|
|
114
|
+
async getKey() {
|
|
115
|
+
const r = await call({ op: 'get' });
|
|
116
|
+
return r['found'] === true && typeof r['key'] === 'string' ? Buffer.from(r['key'], 'base64') : null;
|
|
117
|
+
},
|
|
118
|
+
async putKey(key) { await call({ op: 'put', key: Buffer.from(key).toString('base64') }); },
|
|
119
|
+
async deleteKey() { await call({ op: 'delete' }); },
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// ---- macOS: Keychain via `security -i` (secret on stdin, never on argv) ----------------------------------------
|
|
123
|
+
// UNVERIFIED on a real Mac in this repository's CI: written to the same interface and reviewed against `man security`.
|
|
124
|
+
function createMacKeychainKeyStore(options = {}) {
|
|
125
|
+
if (process.platform !== 'darwin')
|
|
126
|
+
return (0, keystore_ts_1.unprotectedKeyStore)('macos-keychain', 'the macOS Keychain is only available on macOS');
|
|
127
|
+
const { service, account } = names(options);
|
|
128
|
+
const sec = '/usr/bin/security';
|
|
129
|
+
return {
|
|
130
|
+
id: 'macos-keychain',
|
|
131
|
+
protection: 'os-protected',
|
|
132
|
+
async getKey() {
|
|
133
|
+
const r = await run(sec, ['find-generic-password', '-s', service, '-a', account, '-w'], null);
|
|
134
|
+
if (r.code === 44)
|
|
135
|
+
return null; // errSecItemNotFound
|
|
136
|
+
if (r.code !== 0)
|
|
137
|
+
throw new errors_ts_1.SecretsError('key-unavailable', `Keychain read failed (exit ${r.code})`);
|
|
138
|
+
return Buffer.from(r.stdout.trim(), 'hex');
|
|
139
|
+
},
|
|
140
|
+
async putKey(key) {
|
|
141
|
+
// `security -i` reads commands from stdin, so the key is not visible in the process list.
|
|
142
|
+
const r = await run(sec, ['-i'], `add-generic-password -U -s ${service} -a ${account} -w ${hex(key)}\n`);
|
|
143
|
+
if (r.code !== 0)
|
|
144
|
+
throw new errors_ts_1.SecretsError('key-unavailable', `Keychain write failed (exit ${r.code})`);
|
|
145
|
+
},
|
|
146
|
+
async deleteKey() {
|
|
147
|
+
const r = await run(sec, ['delete-generic-password', '-s', service, '-a', account], null);
|
|
148
|
+
if (r.code !== 0 && r.code !== 44)
|
|
149
|
+
throw new errors_ts_1.SecretsError('key-unavailable', `Keychain delete failed (exit ${r.code})`);
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// ---- Linux: libsecret via `secret-tool` (secret on stdin) ------------------------------------------------------
|
|
154
|
+
// UNVERIFIED against a live Secret Service in this repository's CI. Without a working service it refuses, which is the
|
|
155
|
+
// verified path: there is no plaintext fallback.
|
|
156
|
+
function createLibsecretKeyStore(options = {}) {
|
|
157
|
+
if (process.platform !== 'linux')
|
|
158
|
+
return (0, keystore_ts_1.unprotectedKeyStore)('libsecret', 'libsecret is only available on Linux');
|
|
159
|
+
const { service, account } = names(options);
|
|
160
|
+
const attrs = ['service', service, 'account', account];
|
|
161
|
+
// Probe now: a missing tool or an unreachable Secret Service means this machine has no protected store.
|
|
162
|
+
const probe = (0, node_child_process_1.spawnSync)('secret-tool', ['lookup', ...attrs], { encoding: 'utf8', timeout: 15_000 });
|
|
163
|
+
if (probe.error)
|
|
164
|
+
return (0, keystore_ts_1.unprotectedKeyStore)('libsecret', 'secret-tool (libsecret) is not installed; secrets are not saved');
|
|
165
|
+
if (probe.status !== 0 && String(probe.stderr ?? '').trim() !== '') {
|
|
166
|
+
return (0, keystore_ts_1.unprotectedKeyStore)('libsecret', 'no Secret Service (GNOME Keyring, KWallet) is reachable; secrets are not saved');
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
id: 'libsecret',
|
|
170
|
+
protection: 'os-protected',
|
|
171
|
+
async getKey() {
|
|
172
|
+
const r = await run('secret-tool', ['lookup', ...attrs], null);
|
|
173
|
+
if (r.code !== 0 || r.stdout.trim() === '')
|
|
174
|
+
return null;
|
|
175
|
+
return Buffer.from(r.stdout.trim(), 'hex');
|
|
176
|
+
},
|
|
177
|
+
async putKey(key) {
|
|
178
|
+
const r = await run('secret-tool', ['store', '--label=XENO secrets key', ...attrs], hex(key));
|
|
179
|
+
if (r.code !== 0)
|
|
180
|
+
throw new errors_ts_1.SecretsError('key-unavailable', `Secret Service write failed (exit ${r.code})`);
|
|
181
|
+
},
|
|
182
|
+
async deleteKey() {
|
|
183
|
+
await run('secret-tool', ['clear', ...attrs], null);
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** The key store for this machine's operating system. May be `unprotected`, in which case the secret store refuses. */
|
|
188
|
+
function createOsKeyStore(options = {}) {
|
|
189
|
+
switch (process.platform) {
|
|
190
|
+
case 'win32': return createWindowsCredentialKeyStore(options);
|
|
191
|
+
case 'darwin': return createMacKeychainKeyStore(options);
|
|
192
|
+
case 'linux': return createLibsecretKeyStore(options);
|
|
193
|
+
default: return (0, keystore_ts_1.unprotectedKeyStore)('unsupported', `no protected key store is implemented for ${process.platform}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type XenoDirs } from '../dirs/index.ts';
|
|
2
|
+
import type { KeyStore } from './keystore.ts';
|
|
3
|
+
export interface SecretStoreOptions {
|
|
4
|
+
dirs: XenoDirs;
|
|
5
|
+
keyStore: KeyStore;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Envelope-encrypted secrets at `secrets/<area>/<name>.secret` (XENO LOCAL HOME - SPEC.md section 6).
|
|
9
|
+
* It refuses outright when the key store is not OS-protected: there is no plaintext fallback. It never creates a new
|
|
10
|
+
* master key while secrets sealed with an old one exist, because that would silently orphan them.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SecretStore {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(options: SecretStoreOptions);
|
|
15
|
+
/** Whether this machine can keep secrets, and if not, why. Safe to show to a person. */
|
|
16
|
+
status(): {
|
|
17
|
+
available: boolean;
|
|
18
|
+
keyStore: string;
|
|
19
|
+
reason?: string;
|
|
20
|
+
};
|
|
21
|
+
set(area: string, name: string, value: string | Uint8Array): Promise<void>;
|
|
22
|
+
/** The secret's bytes, or null when it does not exist. */
|
|
23
|
+
get(area: string, name: string): Promise<Buffer | null>;
|
|
24
|
+
getString(area: string, name: string): Promise<string | null>;
|
|
25
|
+
has(area: string, name: string): Promise<boolean>;
|
|
26
|
+
delete(area: string, name: string): Promise<boolean>;
|
|
27
|
+
/** Names (never values) stored in an area. */
|
|
28
|
+
list(area: string): Promise<string[]>;
|
|
29
|
+
/** Drops the in-memory copy of the master key. */
|
|
30
|
+
forgetKey(): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createSecretStore(options: SecretStoreOptions): SecretStore;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecretStore = void 0;
|
|
4
|
+
exports.createSecretStore = createSecretStore;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const index_ts_1 = require("../dirs/index.js");
|
|
8
|
+
const envelope_ts_1 = require("./envelope.js");
|
|
9
|
+
const errors_ts_1 = require("./errors.js");
|
|
10
|
+
const SUFFIX = '.secret';
|
|
11
|
+
/**
|
|
12
|
+
* Envelope-encrypted secrets at `secrets/<area>/<name>.secret` (XENO LOCAL HOME - SPEC.md section 6).
|
|
13
|
+
* It refuses outright when the key store is not OS-protected: there is no plaintext fallback. It never creates a new
|
|
14
|
+
* master key while secrets sealed with an old one exist, because that would silently orphan them.
|
|
15
|
+
*/
|
|
16
|
+
class SecretStore {
|
|
17
|
+
#dirs;
|
|
18
|
+
#keyStore;
|
|
19
|
+
#key = null;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.#dirs = options.dirs;
|
|
22
|
+
this.#keyStore = options.keyStore;
|
|
23
|
+
}
|
|
24
|
+
/** Whether this machine can keep secrets, and if not, why. Safe to show to a person. */
|
|
25
|
+
status() {
|
|
26
|
+
return this.#keyStore.protection === 'os-protected'
|
|
27
|
+
? { available: true, keyStore: this.#keyStore.id }
|
|
28
|
+
: { available: false, keyStore: this.#keyStore.id, reason: this.#keyStore.reason ?? 'no protected store is available' };
|
|
29
|
+
}
|
|
30
|
+
#requireProtected() {
|
|
31
|
+
if (this.#keyStore.protection !== 'os-protected') {
|
|
32
|
+
throw new errors_ts_1.SecretsError('unprotected-store', this.#keyStore.reason ?? 'this machine offers only an unprotected store; secrets are not saved');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
#file(area, name) {
|
|
36
|
+
(0, index_ts_1.assertSegment)(name, 'secret name');
|
|
37
|
+
return this.#dirs.path('secrets', area, name + SUFFIX);
|
|
38
|
+
}
|
|
39
|
+
async #anySecretExists() {
|
|
40
|
+
for (const a of index_ts_1.AREAS) {
|
|
41
|
+
if (!a.uses.includes('secrets') || a.slugPattern !== undefined)
|
|
42
|
+
continue;
|
|
43
|
+
try {
|
|
44
|
+
const names = await node_fs_1.promises.readdir(this.#dirs.path('secrets', a.area));
|
|
45
|
+
if (names.some((n) => n.endsWith(SUFFIX)))
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
if (e.code !== 'ENOENT')
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
async #masterKey(create) {
|
|
56
|
+
if (this.#key !== null)
|
|
57
|
+
return this.#key;
|
|
58
|
+
this.#requireProtected();
|
|
59
|
+
const found = await this.#keyStore.getKey();
|
|
60
|
+
if (found !== null) {
|
|
61
|
+
if (found.length !== envelope_ts_1.KEY_BYTES)
|
|
62
|
+
throw new errors_ts_1.SecretsError('key-unavailable', 'the stored master key has the wrong length');
|
|
63
|
+
return (this.#key = Buffer.from(found));
|
|
64
|
+
}
|
|
65
|
+
if (!create)
|
|
66
|
+
return null;
|
|
67
|
+
return this.#dirs.withLock('platform', 'secrets-key', async () => {
|
|
68
|
+
const again = await this.#keyStore.getKey();
|
|
69
|
+
if (again !== null)
|
|
70
|
+
return (this.#key = Buffer.from(again));
|
|
71
|
+
if (await this.#anySecretExists()) {
|
|
72
|
+
throw new errors_ts_1.SecretsError('key-unavailable', 'secrets exist but the master key is missing from the OS store; refusing to create a new key that would orphan them');
|
|
73
|
+
}
|
|
74
|
+
const fresh = (0, node_crypto_1.randomBytes)(envelope_ts_1.KEY_BYTES);
|
|
75
|
+
await this.#keyStore.putKey(fresh);
|
|
76
|
+
const check = await this.#keyStore.getKey();
|
|
77
|
+
if (check === null || !fresh.equals(Buffer.from(check)))
|
|
78
|
+
throw new errors_ts_1.SecretsError('key-unavailable', 'the OS store did not keep the master key');
|
|
79
|
+
return (this.#key = fresh);
|
|
80
|
+
}, { owner: 'secrets master key', timeoutMs: 60_000 });
|
|
81
|
+
}
|
|
82
|
+
async set(area, name, value) {
|
|
83
|
+
this.#file(area, name); // validates area, kind and name before anything is created
|
|
84
|
+
this.#requireProtected();
|
|
85
|
+
this.#dirs.assertWritable(); // a newer layout must refuse before a master key is created
|
|
86
|
+
const key = (await this.#masterKey(true));
|
|
87
|
+
const bytes = typeof value === 'string' ? Buffer.from(value, 'utf8') : Buffer.from(value);
|
|
88
|
+
const sealed = (0, envelope_ts_1.sealSecret)(key, area, name, bytes);
|
|
89
|
+
bytes.fill(0);
|
|
90
|
+
await this.#dirs.writeFile('secrets', area, [name + SUFFIX], JSON.stringify(sealed) + '\n');
|
|
91
|
+
}
|
|
92
|
+
/** The secret's bytes, or null when it does not exist. */
|
|
93
|
+
async get(area, name) {
|
|
94
|
+
const path = this.#file(area, name);
|
|
95
|
+
this.#requireProtected();
|
|
96
|
+
let text;
|
|
97
|
+
try {
|
|
98
|
+
text = await node_fs_1.promises.readFile(path, 'utf8');
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
if (e.code === 'ENOENT')
|
|
102
|
+
return null;
|
|
103
|
+
throw e;
|
|
104
|
+
}
|
|
105
|
+
const key = await this.#masterKey(false);
|
|
106
|
+
if (key === null)
|
|
107
|
+
throw new errors_ts_1.SecretsError('key-unavailable', `${area}/${name} exists but the master key is missing from the OS store`);
|
|
108
|
+
return (0, envelope_ts_1.openSecret)(key, (0, envelope_ts_1.parseEnvelope)(text), area, name);
|
|
109
|
+
}
|
|
110
|
+
async getString(area, name) {
|
|
111
|
+
const b = await this.get(area, name);
|
|
112
|
+
if (b === null)
|
|
113
|
+
return null;
|
|
114
|
+
const s = b.toString('utf8');
|
|
115
|
+
b.fill(0);
|
|
116
|
+
return s;
|
|
117
|
+
}
|
|
118
|
+
async has(area, name) {
|
|
119
|
+
try {
|
|
120
|
+
await node_fs_1.promises.access(this.#file(area, name));
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
if (e.code === 'ENOENT')
|
|
125
|
+
return false;
|
|
126
|
+
throw e;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async delete(area, name) {
|
|
130
|
+
try {
|
|
131
|
+
await node_fs_1.promises.unlink(this.#file(area, name));
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
if (e.code === 'ENOENT')
|
|
136
|
+
return false;
|
|
137
|
+
throw e;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/** Names (never values) stored in an area. */
|
|
141
|
+
async list(area) {
|
|
142
|
+
try {
|
|
143
|
+
const names = await node_fs_1.promises.readdir(this.#dirs.path('secrets', area));
|
|
144
|
+
return names.filter((n) => n.endsWith(SUFFIX)).map((n) => n.slice(0, -SUFFIX.length)).sort();
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
if (e.code === 'ENOENT')
|
|
148
|
+
return [];
|
|
149
|
+
throw e;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** Drops the in-memory copy of the master key. */
|
|
153
|
+
forgetKey() {
|
|
154
|
+
this.#key?.fill(0);
|
|
155
|
+
this.#key = null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.SecretStore = SecretStore;
|
|
159
|
+
function createSecretStore(options) {
|
|
160
|
+
return new SecretStore(options);
|
|
161
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyIdOf = exports.parseEnvelope = exports.openSecret = exports.sealSecret = void 0;
|
|
4
|
+
exports.createMemoryKeyStore = createMemoryKeyStore;
|
|
5
|
+
function createMemoryKeyStore(initial = null) {
|
|
6
|
+
let key = initial === null ? null : Buffer.from(initial);
|
|
7
|
+
return {
|
|
8
|
+
id: 'memory-test-only',
|
|
9
|
+
protection: 'os-protected',
|
|
10
|
+
async getKey() { return key === null ? null : Buffer.from(key); },
|
|
11
|
+
async putKey(k) { key = Buffer.from(k); },
|
|
12
|
+
async deleteKey() { key = null; },
|
|
13
|
+
snapshot() { return key === null ? null : Buffer.from(key); },
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
var envelope_ts_1 = require("./envelope.js");
|
|
17
|
+
Object.defineProperty(exports, "sealSecret", { enumerable: true, get: function () { return envelope_ts_1.sealSecret; } });
|
|
18
|
+
Object.defineProperty(exports, "openSecret", { enumerable: true, get: function () { return envelope_ts_1.openSecret; } });
|
|
19
|
+
Object.defineProperty(exports, "parseEnvelope", { enumerable: true, get: function () { return envelope_ts_1.parseEnvelope; } });
|
|
20
|
+
Object.defineProperty(exports, "keyIdOf", { enumerable: true, get: function () { return envelope_ts_1.keyIdOf; } });
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@xenosystem/primitives/updates` — an installed XENO app updates only for an account allowed to.
|
|
3
|
+
*
|
|
4
|
+
* Owner, 2026-10-25: "nobody without a plan should be able to download them." The platform serves each app's
|
|
5
|
+
* update feed behind sign-in and the plan (`GET /api/updates/<slug>/feed/latest.yml`, xeno-platform
|
|
6
|
+
* `productDownloadRoutes.js`): every installer URL in it is a five-minute grant for exactly that version, and
|
|
7
|
+
* the sha512 is untouched, so electron-updater still verifies the bytes. This family points an app's
|
|
8
|
+
* electron-updater at that feed with the account's own token. It is the ONE place every app does this, so the
|
|
9
|
+
* gate cannot be implemented differently, or forgotten, per app (`docs/DOWNLOAD-GATE.md` Phase 3b).
|
|
10
|
+
*
|
|
11
|
+
* Model-free and dependency-free: the app passes its own `autoUpdater` and a function that returns its current
|
|
12
|
+
* access token (its account SDK). Nothing here stores a token, and no token appears in any result or error.
|
|
13
|
+
*
|
|
14
|
+
* Outcomes are states, not exceptions, because "not signed in" and "no plan" are normal for a free install:
|
|
15
|
+
* signed-out no token: the network is never touched
|
|
16
|
+
* not-entitled the platform said 401/403: the account has no plan that allows updates
|
|
17
|
+
* up-to-date / available / error
|
|
18
|
+
*/
|
|
19
|
+
/** The slice of electron-updater's `autoUpdater` this uses. */
|
|
20
|
+
export interface AutoUpdaterLike {
|
|
21
|
+
setFeedURL(options: {
|
|
22
|
+
provider: 'generic';
|
|
23
|
+
url: string;
|
|
24
|
+
}): void;
|
|
25
|
+
requestHeaders: Record<string, string> | null;
|
|
26
|
+
disableDifferentialDownload: boolean;
|
|
27
|
+
autoDownload: boolean;
|
|
28
|
+
checkForUpdates(): Promise<{
|
|
29
|
+
updateInfo: {
|
|
30
|
+
version: string;
|
|
31
|
+
};
|
|
32
|
+
} | null>;
|
|
33
|
+
}
|
|
34
|
+
export interface GrantedUpdaterOptions {
|
|
35
|
+
/** The product's catalog slug: `hub`, `canvas`, … */
|
|
36
|
+
slug: string;
|
|
37
|
+
/** The platform origin, e.g. `https://xenosystem.ai`. */
|
|
38
|
+
platformBase: string;
|
|
39
|
+
/** The account's current access token, refreshed by the app's account SDK; `null` when signed out. */
|
|
40
|
+
getAccessToken: () => Promise<string | null>;
|
|
41
|
+
updater: AutoUpdaterLike;
|
|
42
|
+
/** The running app's version (`app.getVersion()`). */
|
|
43
|
+
currentVersion: string;
|
|
44
|
+
}
|
|
45
|
+
export type UpdateCheck = {
|
|
46
|
+
state: 'signed-out';
|
|
47
|
+
} | {
|
|
48
|
+
state: 'not-entitled';
|
|
49
|
+
} | {
|
|
50
|
+
state: 'up-to-date';
|
|
51
|
+
version: string;
|
|
52
|
+
} | {
|
|
53
|
+
state: 'available';
|
|
54
|
+
version: string;
|
|
55
|
+
} | {
|
|
56
|
+
state: 'error';
|
|
57
|
+
code: string;
|
|
58
|
+
};
|
|
59
|
+
/** The gated feed for a product. electron-updater appends `/latest.yml` (or `-linux`/`-mac`) itself. */
|
|
60
|
+
export declare function gatedFeedUrl(platformBase: string, slug: string): string;
|
|
61
|
+
/** Compare dotted versions numerically; a pre-release tag sorts below its release. */
|
|
62
|
+
export declare function isNewer(candidate: string, current: string): boolean;
|
|
63
|
+
export declare function createGrantedUpdater(options: GrantedUpdaterOptions): {
|
|
64
|
+
feedUrl: string;
|
|
65
|
+
/** Configure the updater with a FRESH token and ask the gated feed. Call before every check. */
|
|
66
|
+
check(): Promise<UpdateCheck>;
|
|
67
|
+
};
|