@xenosystem/agent-cli 0.5.107 → 0.5.108
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/dist/cli.js +1 -1
- package/dist/index.js +2 -2
- package/dist/metafile-esm.json +1 -1
- package/dist/sdk-build-identity.json +4 -4
- package/native/xeno-pty/prebuilds/win32-x64/manifest.json +18 -18
- package/node_modules/@xeno-corporation/account/LICENSE +39 -0
- package/node_modules/@xeno-corporation/account/README.md +211 -0
- package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs +60 -0
- package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs.map +1 -0
- package/node_modules/@xeno-corporation/account/dist/index.d.mts +883 -0
- package/node_modules/@xeno-corporation/account/dist/index.d.ts +883 -0
- package/node_modules/@xeno-corporation/account/dist/index.js +2301 -0
- package/node_modules/@xeno-corporation/account/dist/index.js.map +1 -0
- package/node_modules/@xeno-corporation/account/dist/index.mjs +2191 -0
- package/node_modules/@xeno-corporation/account/dist/index.mjs.map +1 -0
- package/node_modules/@xeno-corporation/account/dist/node.d.mts +35 -0
- package/node_modules/@xeno-corporation/account/dist/node.d.ts +35 -0
- package/node_modules/@xeno-corporation/account/dist/node.js +715 -0
- package/node_modules/@xeno-corporation/account/dist/node.js.map +1 -0
- package/node_modules/@xeno-corporation/account/dist/node.mjs +645 -0
- package/node_modules/@xeno-corporation/account/dist/node.mjs.map +1 -0
- package/node_modules/@xeno-corporation/account/dist/tokenStore-CnIo2ILq.d.mts +47 -0
- package/node_modules/@xeno-corporation/account/dist/tokenStore-CnIo2ILq.d.ts +47 -0
- package/node_modules/@xeno-corporation/account/package.json +60 -0
- package/node_modules/zod/LICENSE +21 -0
- package/node_modules/zod/README.md +3028 -0
- package/node_modules/zod/index.d.ts +2 -0
- package/node_modules/zod/lib/ZodError.d.ts +164 -0
- package/node_modules/zod/lib/ZodError.js +137 -0
- package/node_modules/zod/lib/__tests__/Mocker.d.ts +17 -0
- package/node_modules/zod/lib/__tests__/Mocker.js +57 -0
- package/node_modules/zod/lib/benchmarks/datetime.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/datetime.js +54 -0
- package/node_modules/zod/lib/benchmarks/discriminatedUnion.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/discriminatedUnion.js +79 -0
- package/node_modules/zod/lib/benchmarks/index.d.ts +1 -0
- package/node_modules/zod/lib/benchmarks/index.js +59 -0
- package/node_modules/zod/lib/benchmarks/ipv4.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/ipv4.js +54 -0
- package/node_modules/zod/lib/benchmarks/object.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/object.js +70 -0
- package/node_modules/zod/lib/benchmarks/primitives.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/primitives.js +170 -0
- package/node_modules/zod/lib/benchmarks/realworld.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/realworld.js +56 -0
- package/node_modules/zod/lib/benchmarks/string.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/string.js +55 -0
- package/node_modules/zod/lib/benchmarks/union.d.ts +5 -0
- package/node_modules/zod/lib/benchmarks/union.js +79 -0
- package/node_modules/zod/lib/errors.d.ts +5 -0
- package/node_modules/zod/lib/errors.js +17 -0
- package/node_modules/zod/lib/external.d.ts +6 -0
- package/node_modules/zod/lib/external.js +22 -0
- package/node_modules/zod/lib/helpers/enumUtil.d.ts +8 -0
- package/node_modules/zod/lib/helpers/enumUtil.js +2 -0
- package/node_modules/zod/lib/helpers/errorUtil.d.ts +9 -0
- package/node_modules/zod/lib/helpers/errorUtil.js +8 -0
- package/node_modules/zod/lib/helpers/parseUtil.d.ts +78 -0
- package/node_modules/zod/lib/helpers/parseUtil.js +125 -0
- package/node_modules/zod/lib/helpers/partialUtil.d.ts +8 -0
- package/node_modules/zod/lib/helpers/partialUtil.js +2 -0
- package/node_modules/zod/lib/helpers/typeAliases.d.ts +2 -0
- package/node_modules/zod/lib/helpers/typeAliases.js +2 -0
- package/node_modules/zod/lib/helpers/util.d.ts +82 -0
- package/node_modules/zod/lib/helpers/util.js +142 -0
- package/node_modules/zod/lib/index.d.ts +4 -0
- package/node_modules/zod/lib/index.js +33 -0
- package/node_modules/zod/lib/index.mjs +4382 -0
- package/node_modules/zod/lib/index.umd.js +4497 -0
- package/node_modules/zod/lib/locales/en.d.ts +3 -0
- package/node_modules/zod/lib/locales/en.js +129 -0
- package/node_modules/zod/lib/standard-schema.d.ts +102 -0
- package/node_modules/zod/lib/standard-schema.js +2 -0
- package/node_modules/zod/lib/types.d.ts +1062 -0
- package/node_modules/zod/lib/types.js +3823 -0
- package/node_modules/zod/package.json +122 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts","../src/dpop.ts","../src/windows-host.ts","../src/errors.ts","../src/windows-host-helper.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;IAAAA,sBAAmB;;;ACiBZ,SAASC,iBAAiBC,OAAa;AAC5C,QAAMC,MAAM,IAAIC,IAAIF,KAAAA;AACpB,MAAIC,IAAIE,aAAa,SAAU,OAAM,IAAIC,MAAM,yBAAA;AAC/CH,MAAII,OAAO;AACXJ,MAAIK,SAAS;AACbL,MAAIM,WAAW;AACfN,MAAIO,WAAW;AACfP,MAAIQ,WAAWR,IAAIQ,SAASC,YAAW;AACvC,MAAIT,IAAIU,SAAS,MAAOV,KAAIU,OAAO;AACnC,SAAOV,IAAIW,SAAQ;AACrB;AAVgBb;;;ACjBhB,8BAAkC;AAClC,gCAA2D;AAC3D,yBAAgE;AAChE,uBAAqB;;;ACad,IAAMc,eAAN,cAA2BC,MAAAA;EAhBlC,OAgBkCA;;;EACvBC;EACAC;EACAC;EACAC;EACAC;EAET,YAAYC,MAOT;AACD,UAAMA,KAAKC,OAAO;AAClB,SAAKC,OAAO;AACZ,SAAKP,OAAOK,KAAKL;AACjB,SAAKC,aAAaI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AKc,UAAU;IAAEX,KAAK;IAASD,KAAK;IAAME,GAAGI,WAAWJ;IAAGC,GAAGG,WAAWH;EAAE,CAAA,CAAA,EAAIU,OAAO,WAAA;AACrI,QAAMC,MAAML,oBAAAA,QAAOM,iBAAiB;IAAED,KAAKR;IAA4CU,QAAQ;EAAM,CAAA;AACrG,SAAO;IACLR;IACA,MAAMS,YAAYC,MAAmB;AACnC,YAAMC,SAAS;QAAEC,KAAK;QAASC,KAAK;QAAYC,KAAKf;MAAU;AAC/D,YAAMgB,SAAkC;QACtCC,KAAKf,oBAAAA,QAAOgB,WAAU;QACtBC,KAAKR,KAAKS,OAAOC,YAAW;QAC5BC,KAAKC,iBAAiBZ,KAAKa,GAAG;QAC9BC,KAAKC,KAAKC,MAAMC,KAAKC,IAAG,IAAK,GAAA;MAC/B;AACA,UAAIlB,KAAKmB,YAAad,QAAOe,MAAM7B,oBAAAA,QAAOC,WAAW,QAAA,EAAUC,OAAOO,KAAKmB,WAAW,EAAExB,OAAO,WAAA;AAC/F,UAAIK,KAAKqB,MAAOhB,QAAOgB,QAAQrB,KAAKqB;AACpC,YAAMC,IAAIC,OAAOC,KAAK5C,KAAKc,UAAUO,MAAAA,CAAAA,EAASwB,SAAS,WAAA;AACvD,YAAMC,IAAIH,OAAOC,KAAK5C,KAAKc,UAAUW,MAAAA,CAAAA,EAASoB,SAAS,WAAA;AACvD,YAAME,YAAYpC,oBAAAA,QAAOqC,KAAK,UAAUL,OAAOC,KAAK,GAAGF,CAAAA,IAAKI,CAAAA,EAAG,GAAG;QAAE9B;QAAKiC,aAAa;MAAa,CAAA,EAAGJ,SAAS,WAAA;AAC/G,aAAO,GAAGH,CAAAA,IAAKI,CAAAA,IAAKC,SAAAA;IACtB;EACF;AACF;AA3BgBlD;","names":["import_node_crypto","normalizeDpopHtu","value","url","URL","protocol","Error","hash","search","username","password","hostname","toLowerCase","port","toString","AccountError","Error","code","httpStatus","retryable","retryAfterMs","oauthError","args","message","name","defaultRetryable","WINDOWS_ACCOUNT_HOST_HELPER","String","raw","MAX_PIPE_BYTES","refused","AccountError","code","message","retryable","createWindowsAccountHost","options","process","platform","clientId","namespace","timeoutMs","waitMs","lockTimeoutMs","transactionTimeoutMs","test","Number","isSafeInteger","createKey","undefined","systemRoot","env","SystemRoot","SYSTEMROOT","executable","join","child","spawn","WINDOWS_ACCOUNT_HOST_HELPER","windowsHide","stdio","cwd","WINDIR","TEMP","TMP","rpc","WindowsHostRpc","initialization","request","parentPid","pid","kill","value","identity","createHash","update","digest","provider","exportPolicy","isInteger","hardwareImplementation","createdKey","keyName","publicBlob","blob","Buffer","from","length","readUInt32LE","publicJwk","kty","crv","x","subarray","toString","y","jkt","JSON","stringify","publicKey","createPublicKey","key","format","context","AsyncLocalStorage","tail","Promise","resolve","locks","closed","closing","refreshKey","current","failed","validKey","exclusive","work","getStore","prior","release","lease","id","randomUUID","active","acquired","timer","race","run","_resolve","reject","setTimeout","clearTimeout","storageRequest","op","input","store","withExclusive","get","result","set","text","byteLength","delete","dpopSigner","createProof","args","method","url","accessToken","nonce","toUpperCase","URL","username","password","protocol","header","alg","typ","jwk","claims","jti","htm","htu","normalizeDpopHtu","iat","Math","floor","Date","now","ath","a","b","signingInput","signature","hash","bytes","verify","dsaEncoding","custody","kind","hardwareBacked","nonExportable","String","close","activeRequests","deleteCreatedKey","error","exited","pending","Map","buffer","alloc","size","once","fail","stderr","resume","stdout","on","chunk","concat","newline","indexOf","reply","parse","TextDecoder","fatal","decode","item","ok","stream","stdin","values","line","write","clear","exitCode","signalCode","end","createNodeDpopSigner","input","parsed","JSON","parse","kty","crv","x","y","d","Error","privateJwk","publicJwk","jkt","crypto","createHash","update","stringify","digest","key","createPrivateKey","format","createProof","args","header","alg","typ","jwk","claims","jti","randomUUID","htm","method","toUpperCase","htu","normalizeDpopHtu","url","iat","Math","floor","Date","now","accessToken","ath","nonce","a","Buffer","from","toString","b","signature","sign","dsaEncoding"]}
|
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountError,
|
|
3
|
+
__name,
|
|
4
|
+
normalizeDpopHtu
|
|
5
|
+
} from "./chunk-FELZILY4.mjs";
|
|
6
|
+
|
|
7
|
+
// src/node.ts
|
|
8
|
+
import crypto from "node:crypto";
|
|
9
|
+
|
|
10
|
+
// src/windows-host.ts
|
|
11
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { createHash, createPublicKey, randomUUID, verify } from "node:crypto";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
|
|
16
|
+
// src/windows-host-helper.ts
|
|
17
|
+
var WINDOWS_ACCOUNT_HOST_HELPER = String.raw`
|
|
18
|
+
$ErrorActionPreference = 'Stop'
|
|
19
|
+
[Console]::InputEncoding = New-Object System.Text.UTF8Encoding($false, $true)
|
|
20
|
+
[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding($false, $true)
|
|
21
|
+
Add-Type -TypeDefinition @'
|
|
22
|
+
using System;
|
|
23
|
+
using System.Text;
|
|
24
|
+
using System.IO;
|
|
25
|
+
using System.Threading;
|
|
26
|
+
using System.Security.Cryptography;
|
|
27
|
+
using System.Security.AccessControl;
|
|
28
|
+
using System.Security.Principal;
|
|
29
|
+
using System.Runtime.InteropServices;
|
|
30
|
+
public static class XenoAccountWindowsHost {
|
|
31
|
+
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct Credential {
|
|
32
|
+
public uint Flags; public uint Type; public string TargetName; public string Comment;
|
|
33
|
+
public long LastWritten; public uint CredentialBlobSize; public IntPtr CredentialBlob;
|
|
34
|
+
public uint Persist; public uint AttributeCount; public IntPtr Attributes;
|
|
35
|
+
public string TargetAlias; public string UserName;
|
|
36
|
+
}
|
|
37
|
+
[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CredReadW(string target, uint type, uint flags, out IntPtr credential);
|
|
38
|
+
[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CredWriteW(ref Credential credential, uint flags);
|
|
39
|
+
[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CredDeleteW(string target, uint type, uint flags);
|
|
40
|
+
[DllImport("advapi32.dll")] static extern void CredFree(IntPtr credential);
|
|
41
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
|
|
42
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool GetProcessTimes(IntPtr process, out long creation, out long exit, out long kernel, out long user);
|
|
43
|
+
[DllImport("kernel32.dll")] static extern uint WaitForSingleObject(IntPtr process, uint milliseconds);
|
|
44
|
+
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
45
|
+
[DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess();
|
|
46
|
+
[DllImport("ncrypt.dll", CharSet=CharSet.Unicode)] static extern int NCryptGetProperty(IntPtr handle, string name, byte[] output, int size, out int written, int flags);
|
|
47
|
+
static IntPtr parent;
|
|
48
|
+
static CngKey key;
|
|
49
|
+
static Mutex mutex;
|
|
50
|
+
static string lease, prefix, refreshKey, keyName;
|
|
51
|
+
static bool createdKey;
|
|
52
|
+
static volatile bool stopping;
|
|
53
|
+
static Thread monitor;
|
|
54
|
+
static readonly UTF8Encoding Utf8 = new UTF8Encoding(false, true);
|
|
55
|
+
static string Hash(string input) {
|
|
56
|
+
using (var h = SHA256.Create()) return BitConverter.ToString(h.ComputeHash(Utf8.GetBytes(input))).Replace("-", "").ToLowerInvariant();
|
|
57
|
+
}
|
|
58
|
+
static void ParentCurrent() {
|
|
59
|
+
long birth, exit, kernel, user, helperBirth;
|
|
60
|
+
if (parent == IntPtr.Zero || !GetProcessTimes(parent, out birth, out exit, out kernel, out user)
|
|
61
|
+
|| !GetProcessTimes(GetCurrentProcess(), out helperBirth, out exit, out kernel, out user)
|
|
62
|
+
|| birth >= helperBirth || WaitForSingleObject(parent, 0) != 258) throw new IOException("parent unavailable");
|
|
63
|
+
}
|
|
64
|
+
static void AssertLease(string input) {
|
|
65
|
+
ParentCurrent();
|
|
66
|
+
if (lease == null || input != lease) throw new IOException("exclusive lease required");
|
|
67
|
+
}
|
|
68
|
+
static string Target(string input) {
|
|
69
|
+
if (input != refreshKey && input != refreshKey + "/pending") throw new IOException("foreign credential namespace");
|
|
70
|
+
return prefix + Hash(input);
|
|
71
|
+
}
|
|
72
|
+
static bool CredentialExists(string target) {
|
|
73
|
+
IntPtr pointer;
|
|
74
|
+
if (CredReadW(target, 1, 0, out pointer)) { CredFree(pointer); return true; }
|
|
75
|
+
if (Marshal.GetLastWin32Error() == 1168) return false;
|
|
76
|
+
throw new IOException("credential presence unavailable");
|
|
77
|
+
}
|
|
78
|
+
public static object Init(string clientId, string scope, int parentPid, bool create) {
|
|
79
|
+
if (key != null || parent != IntPtr.Zero || !System.Text.RegularExpressions.Regex.IsMatch(clientId, "^xeno-[a-z0-9][a-z0-9-]{0,63}$")
|
|
80
|
+
|| !System.Text.RegularExpressions.Regex.IsMatch(scope, "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$")) throw new IOException("invalid host identity");
|
|
81
|
+
parent = OpenProcess(0x100000 | 0x1000, false, parentPid); ParentCurrent();
|
|
82
|
+
var observedParent = parent;
|
|
83
|
+
monitor = new Thread(() => {
|
|
84
|
+
while (!stopping) {
|
|
85
|
+
uint result = WaitForSingleObject(observedParent, 100);
|
|
86
|
+
if (!stopping && result != 258) Environment.Exit(75);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
monitor.IsBackground = true; monitor.Start();
|
|
90
|
+
var identity = Hash("xeno/account/windows-host/1\0" + scope + "\0" + clientId);
|
|
91
|
+
prefix = "XENO.Account/" + identity + "/"; refreshKey = "xeno.account/" + clientId + "/refresh";
|
|
92
|
+
var owner = WindowsIdentity.GetCurrent().User;
|
|
93
|
+
var acl = new MutexSecurity(); acl.SetAccessRuleProtection(true, false); acl.SetOwner(owner);
|
|
94
|
+
acl.AddAccessRule(new MutexAccessRule(owner, MutexRights.FullControl, AccessControlType.Allow));
|
|
95
|
+
acl.AddAccessRule(new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), MutexRights.FullControl, AccessControlType.Allow));
|
|
96
|
+
bool created;
|
|
97
|
+
mutex = new Mutex(false, "Global\\Xeno.Account." + Hash(owner.Value) + "." + identity, out created, acl);
|
|
98
|
+
var rules = mutex.GetAccessControl().GetAccessRules(true, true, typeof(SecurityIdentifier));
|
|
99
|
+
foreach (MutexAccessRule rule in rules) if (rule.AccessControlType == AccessControlType.Allow && rule.IdentityReference.Value != owner.Value
|
|
100
|
+
&& rule.IdentityReference.Value != "S-1-5-18") throw new IOException("public mutex custody");
|
|
101
|
+
if (mutex.GetAccessControl().GetOwner(typeof(SecurityIdentifier)).Value != owner.Value) throw new IOException("foreign mutex owner");
|
|
102
|
+
keyName = "Xeno.Account." + identity;
|
|
103
|
+
var provider = new CngProvider("Microsoft Platform Crypto Provider");
|
|
104
|
+
bool held = false;
|
|
105
|
+
try {
|
|
106
|
+
try { held = mutex.WaitOne(5000); } catch (AbandonedMutexException) { held = true; throw new IOException("abandoned init"); }
|
|
107
|
+
if (!held) throw new IOException("init lock timeout"); ParentCurrent();
|
|
108
|
+
if (CngKey.Exists(keyName, provider)) key = CngKey.Open(keyName, provider);
|
|
109
|
+
else {
|
|
110
|
+
if (!create) throw new IOException("provisioned key required");
|
|
111
|
+
if (CredentialExists(Target(refreshKey)) || CredentialExists(Target(refreshKey + "/pending")))
|
|
112
|
+
throw new IOException("existing credential cannot change key");
|
|
113
|
+
var options = new CngKeyCreationParameters(); options.Provider = provider;
|
|
114
|
+
options.KeyUsage = CngKeyUsages.Signing; options.ExportPolicy = CngExportPolicies.None;
|
|
115
|
+
key = CngKey.Create(CngAlgorithm.ECDsaP256, keyName, options); createdKey = true;
|
|
116
|
+
}
|
|
117
|
+
if (key.Provider.Provider != "Microsoft Platform Crypto Provider" || key.ExportPolicy != CngExportPolicies.None
|
|
118
|
+
|| key.IsMachineKey || key.AlgorithmGroup != CngAlgorithmGroup.ECDsa || key.KeyUsage != CngKeyUsages.Signing)
|
|
119
|
+
throw new IOException("key custody differs");
|
|
120
|
+
var implementation = new byte[4]; int implementationSize;
|
|
121
|
+
if (NCryptGetProperty(key.ProviderHandle.DangerousGetHandle(), "Impl Type", implementation, 4, out implementationSize, 0) != 0
|
|
122
|
+
|| implementationSize != 4 || (BitConverter.ToInt32(implementation, 0) & 1) == 0) throw new IOException("hardware provider required");
|
|
123
|
+
var blob = key.Export(CngKeyBlobFormat.EccPublicBlob);
|
|
124
|
+
if (blob.Length != 72 || BitConverter.ToUInt32(blob, 0) != 0x31534345 || BitConverter.ToUInt32(blob, 4) != 32) throw new IOException("wrong P256 key");
|
|
125
|
+
ParentCurrent();
|
|
126
|
+
return new { publicBlob = Convert.ToBase64String(blob), provider = key.Provider.Provider,
|
|
127
|
+
exportPolicy = (int)key.ExportPolicy, hardwareImplementation = BitConverter.ToInt32(implementation, 0), createdKey = createdKey, keyName = keyName };
|
|
128
|
+
} finally { if (held) mutex.ReleaseMutex(); }
|
|
129
|
+
}
|
|
130
|
+
public static void Acquire(string input, int milliseconds) {
|
|
131
|
+
ParentCurrent(); if (lease != null || input == null || input.Length != 36 || milliseconds < 1 || milliseconds > 10000) throw new IOException("invalid lease");
|
|
132
|
+
bool held = false;
|
|
133
|
+
try {
|
|
134
|
+
try { held = mutex.WaitOne(milliseconds); } catch (AbandonedMutexException) { held = true; throw new IOException("abandoned lease"); }
|
|
135
|
+
if (!held) throw new IOException("lease timeout"); ParentCurrent(); lease = input;
|
|
136
|
+
} catch { if (held) mutex.ReleaseMutex(); throw; }
|
|
137
|
+
}
|
|
138
|
+
public static void Release(string input) {
|
|
139
|
+
AssertLease(input); lease = null; mutex.ReleaseMutex();
|
|
140
|
+
}
|
|
141
|
+
public static object Get(string input, string locked) {
|
|
142
|
+
AssertLease(locked); var target = Target(input); IntPtr pointer;
|
|
143
|
+
if (!CredReadW(target, 1, 0, out pointer)) {
|
|
144
|
+
if (Marshal.GetLastWin32Error() == 1168) return null;
|
|
145
|
+
throw new IOException("credential read unavailable");
|
|
146
|
+
}
|
|
147
|
+
byte[] bytes = null;
|
|
148
|
+
try {
|
|
149
|
+
var value = (Credential)Marshal.PtrToStructure(pointer, typeof(Credential));
|
|
150
|
+
if (value.Type != 1 || value.TargetName != target || value.Persist != 2 || value.CredentialBlobSize > 2560
|
|
151
|
+
|| value.AttributeCount != 0) throw new IOException("credential profile differs");
|
|
152
|
+
bytes = new byte[value.CredentialBlobSize]; Marshal.Copy(value.CredentialBlob, bytes, 0, bytes.Length);
|
|
153
|
+
var result = Utf8.GetString(bytes); ParentCurrent(); return result;
|
|
154
|
+
} finally { if (bytes != null) Array.Clear(bytes, 0, bytes.Length); CredFree(pointer); }
|
|
155
|
+
}
|
|
156
|
+
public static void Set(string input, string text, string locked) {
|
|
157
|
+
AssertLease(locked); var target = Target(input); var bytes = Utf8.GetBytes(text);
|
|
158
|
+
if (bytes.Length > 2560) throw new IOException("credential bound");
|
|
159
|
+
IntPtr buffer = Marshal.AllocHGlobal(bytes.Length);
|
|
160
|
+
try {
|
|
161
|
+
Marshal.Copy(bytes, 0, buffer, bytes.Length);
|
|
162
|
+
var value = new Credential { Type = 1, TargetName = target, CredentialBlob = buffer,
|
|
163
|
+
CredentialBlobSize = (uint)bytes.Length, Persist = 2, UserName = "XENO Account" };
|
|
164
|
+
if (!CredWriteW(ref value, 0)) throw new IOException("credential write unavailable"); ParentCurrent();
|
|
165
|
+
} finally { for (int i=0;i<bytes.Length;i++) Marshal.WriteByte(buffer, i, 0); Marshal.FreeHGlobal(buffer); Array.Clear(bytes, 0, bytes.Length); }
|
|
166
|
+
}
|
|
167
|
+
public static void Delete(string input, string locked) {
|
|
168
|
+
AssertLease(locked); if (!CredDeleteW(Target(input), 1, 0) && Marshal.GetLastWin32Error() != 1168) throw new IOException("credential deletion unavailable"); ParentCurrent();
|
|
169
|
+
}
|
|
170
|
+
public static object Sign(string encoded) {
|
|
171
|
+
ParentCurrent(); var hash = Convert.FromBase64String(encoded); if (hash.Length != 32) throw new IOException("SHA256 bound");
|
|
172
|
+
using (var signer = new ECDsaCng(key)) {
|
|
173
|
+
var result = signer.SignHash(hash); if (result.Length != 64) throw new IOException("signature bound");
|
|
174
|
+
ParentCurrent(); return Convert.ToBase64String(result);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
public static void Close(bool deleteCreated) {
|
|
178
|
+
bool cleanupHeld = false;
|
|
179
|
+
if (deleteCreated) {
|
|
180
|
+
if (!createdKey || lease != null) throw new IOException("original idle cleanup owner required");
|
|
181
|
+
try { cleanupHeld = mutex.WaitOne(5000); } catch (AbandonedMutexException) { mutex.ReleaseMutex(); throw new IOException("abandoned cleanup"); }
|
|
182
|
+
if (!cleanupHeld) throw new IOException("cleanup timeout");
|
|
183
|
+
try {
|
|
184
|
+
ParentCurrent();
|
|
185
|
+
if (CredentialExists(Target(refreshKey)) || CredentialExists(Target(refreshKey + "/pending"))) throw new IOException("qualification key cleanup requires empty vault");
|
|
186
|
+
} catch { mutex.ReleaseMutex(); throw; }
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
stopping = true;
|
|
190
|
+
if (monitor != null) { if (!monitor.Join(1000)) throw new IOException("parent monitor did not stop"); monitor = null; }
|
|
191
|
+
if (lease != null) { mutex.ReleaseMutex(); lease = null; }
|
|
192
|
+
if (key != null) { if (deleteCreated) key.Delete(); key.Dispose(); key=null; }
|
|
193
|
+
if (mutex != null) { if (cleanupHeld) mutex.ReleaseMutex(); mutex.Dispose(); mutex=null; }
|
|
194
|
+
if (parent != IntPtr.Zero) { CloseHandle(parent); parent=IntPtr.Zero; }
|
|
195
|
+
} catch { Environment.Exit(76); }
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
'@
|
|
199
|
+
try {
|
|
200
|
+
while ($null -ne ($line = [Console]::ReadLine())) {
|
|
201
|
+
if ($line.Length -gt 50000) { break }
|
|
202
|
+
$request = $null
|
|
203
|
+
try {
|
|
204
|
+
$request = $line | ConvertFrom-Json
|
|
205
|
+
$value = $null
|
|
206
|
+
switch ($request.op) {
|
|
207
|
+
'init' { $value = [XenoAccountWindowsHost]::Init($request.clientId, $request.namespace, [int]$request.parentPid, [bool]$request.createKey) }
|
|
208
|
+
'acquire' { [XenoAccountWindowsHost]::Acquire($request.lease, [int]$request.waitMs) }
|
|
209
|
+
'release' { [XenoAccountWindowsHost]::Release($request.lease) }
|
|
210
|
+
'get' { $value = [XenoAccountWindowsHost]::Get($request.key, $request.lease) }
|
|
211
|
+
'set' { [XenoAccountWindowsHost]::Set($request.key, $request.value, $request.lease) }
|
|
212
|
+
'delete' { [XenoAccountWindowsHost]::Delete($request.key, $request.lease) }
|
|
213
|
+
'sign' { $value = [XenoAccountWindowsHost]::Sign($request.hash) }
|
|
214
|
+
'close' { [XenoAccountWindowsHost]::Close([bool]$request.deleteCreatedKey) }
|
|
215
|
+
default { throw 'unsupported request' }
|
|
216
|
+
}
|
|
217
|
+
[Console]::WriteLine((@{id=$request.id;ok=$true;value=$value} | ConvertTo-Json -Depth 4 -Compress))
|
|
218
|
+
if ($request.op -eq 'close') { break }
|
|
219
|
+
} catch {
|
|
220
|
+
[Console]::WriteLine((@{id=$request.id;ok=$false;code='WINDOWS_ACCOUNT_HOST_REFUSED'} | ConvertTo-Json -Compress))
|
|
221
|
+
if ($null -eq $request -or $request.op -eq 'init') { break }
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} finally { [XenoAccountWindowsHost]::Close($false) }
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
// src/windows-host.ts
|
|
228
|
+
var MAX_PIPE_BYTES = 65536;
|
|
229
|
+
function refused() {
|
|
230
|
+
return new AccountError({
|
|
231
|
+
code: "UNREACHABLE",
|
|
232
|
+
message: "Windows account host authority is unavailable",
|
|
233
|
+
retryable: false
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
__name(refused, "refused");
|
|
237
|
+
async function createWindowsAccountHost(options) {
|
|
238
|
+
if (process.platform !== "win32") throw refused();
|
|
239
|
+
const clientId = options.clientId, namespace = options.namespace ?? clientId;
|
|
240
|
+
const timeoutMs = options.timeoutMs ?? 15e3, waitMs = options.lockTimeoutMs ?? 5e3;
|
|
241
|
+
const transactionTimeoutMs = options.transactionTimeoutMs ?? timeoutMs;
|
|
242
|
+
if (typeof clientId !== "string" || typeof namespace !== "string" || !/^xeno-[a-z0-9][a-z0-9-]{0,63}$/.test(clientId) || !/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/.test(namespace) || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1e3 || timeoutMs > 6e4 || !Number.isSafeInteger(waitMs) || waitMs < 1 || waitMs > 1e4 || timeoutMs <= waitMs || !Number.isSafeInteger(transactionTimeoutMs) || transactionTimeoutMs < 100 || transactionTimeoutMs > 6e4 || options.createKey !== void 0 && typeof options.createKey !== "boolean") throw refused();
|
|
243
|
+
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT;
|
|
244
|
+
if (!systemRoot) throw refused();
|
|
245
|
+
const executable = join(systemRoot, "System32/WindowsPowerShell/v1.0/powershell.exe");
|
|
246
|
+
const child = spawn(executable, [
|
|
247
|
+
"-NoLogo",
|
|
248
|
+
"-NoProfile",
|
|
249
|
+
"-NonInteractive",
|
|
250
|
+
"-Command",
|
|
251
|
+
WINDOWS_ACCOUNT_HOST_HELPER
|
|
252
|
+
], {
|
|
253
|
+
windowsHide: true,
|
|
254
|
+
stdio: [
|
|
255
|
+
"pipe",
|
|
256
|
+
"pipe",
|
|
257
|
+
"pipe"
|
|
258
|
+
],
|
|
259
|
+
cwd: systemRoot,
|
|
260
|
+
env: {
|
|
261
|
+
SystemRoot: systemRoot,
|
|
262
|
+
WINDIR: systemRoot,
|
|
263
|
+
TEMP: process.env.TEMP,
|
|
264
|
+
TMP: process.env.TMP
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
const rpc = new WindowsHostRpc(child, timeoutMs);
|
|
268
|
+
let initialization;
|
|
269
|
+
try {
|
|
270
|
+
initialization = await rpc.request("init", {
|
|
271
|
+
clientId,
|
|
272
|
+
namespace,
|
|
273
|
+
parentPid: process.pid,
|
|
274
|
+
createKey: options.createKey === true
|
|
275
|
+
});
|
|
276
|
+
} catch {
|
|
277
|
+
await rpc.kill();
|
|
278
|
+
throw refused();
|
|
279
|
+
}
|
|
280
|
+
if (!initialization || typeof initialization !== "object") {
|
|
281
|
+
await rpc.kill();
|
|
282
|
+
throw refused();
|
|
283
|
+
}
|
|
284
|
+
const value = initialization;
|
|
285
|
+
const identity = createHash("sha256").update(`xeno/account/windows-host/1\0${namespace}\0${clientId}`).digest("hex");
|
|
286
|
+
if (value.provider !== "Microsoft Platform Crypto Provider" || value.exportPolicy !== 0 || !Number.isInteger(value.hardwareImplementation) || (Number(value.hardwareImplementation) & 1) === 0 || typeof value.createdKey !== "boolean" || value.keyName !== `Xeno.Account.${identity}` || typeof value.publicBlob !== "string") {
|
|
287
|
+
await rpc.kill();
|
|
288
|
+
throw refused();
|
|
289
|
+
}
|
|
290
|
+
const blob = Buffer.from(value.publicBlob, "base64");
|
|
291
|
+
if (blob.length !== 72 || blob.readUInt32LE(0) !== 827540293 || blob.readUInt32LE(4) !== 32) {
|
|
292
|
+
await rpc.kill();
|
|
293
|
+
throw refused();
|
|
294
|
+
}
|
|
295
|
+
const publicJwk = {
|
|
296
|
+
kty: "EC",
|
|
297
|
+
crv: "P-256",
|
|
298
|
+
x: blob.subarray(8, 40).toString("base64url"),
|
|
299
|
+
y: blob.subarray(40).toString("base64url")
|
|
300
|
+
};
|
|
301
|
+
const jkt = createHash("sha256").update(JSON.stringify({
|
|
302
|
+
crv: publicJwk.crv,
|
|
303
|
+
kty: publicJwk.kty,
|
|
304
|
+
x: publicJwk.x,
|
|
305
|
+
y: publicJwk.y
|
|
306
|
+
})).digest("base64url");
|
|
307
|
+
const publicKey = createPublicKey({
|
|
308
|
+
key: publicJwk,
|
|
309
|
+
format: "jwk"
|
|
310
|
+
});
|
|
311
|
+
const context = new AsyncLocalStorage();
|
|
312
|
+
let tail = Promise.resolve(), locks = 0, closed = false, closing = false;
|
|
313
|
+
const refreshKey = `xeno.account/${clientId}/refresh`;
|
|
314
|
+
const current = /* @__PURE__ */ __name(() => {
|
|
315
|
+
if (closed || closing || rpc.failed) throw refused();
|
|
316
|
+
}, "current");
|
|
317
|
+
const validKey = /* @__PURE__ */ __name((key) => {
|
|
318
|
+
current();
|
|
319
|
+
if (key !== refreshKey && key !== `${refreshKey}/pending`) throw refused();
|
|
320
|
+
}, "validKey");
|
|
321
|
+
const exclusive = /* @__PURE__ */ __name(async (key, work) => {
|
|
322
|
+
validKey(key);
|
|
323
|
+
if (context.getStore() || locks >= 64) throw refused();
|
|
324
|
+
locks++;
|
|
325
|
+
const prior = tail;
|
|
326
|
+
let release;
|
|
327
|
+
tail = new Promise((resolve) => {
|
|
328
|
+
release = resolve;
|
|
329
|
+
});
|
|
330
|
+
await prior;
|
|
331
|
+
const lease = {
|
|
332
|
+
id: randomUUID(),
|
|
333
|
+
active: true
|
|
334
|
+
};
|
|
335
|
+
let acquired = false;
|
|
336
|
+
try {
|
|
337
|
+
current();
|
|
338
|
+
await rpc.request("acquire", {
|
|
339
|
+
lease: lease.id,
|
|
340
|
+
waitMs
|
|
341
|
+
});
|
|
342
|
+
acquired = true;
|
|
343
|
+
let timer;
|
|
344
|
+
try {
|
|
345
|
+
return await Promise.race([
|
|
346
|
+
context.run(lease, work),
|
|
347
|
+
new Promise((_resolve, reject) => {
|
|
348
|
+
timer = setTimeout(() => {
|
|
349
|
+
lease.active = false;
|
|
350
|
+
void rpc.kill();
|
|
351
|
+
reject(refused());
|
|
352
|
+
}, transactionTimeoutMs);
|
|
353
|
+
})
|
|
354
|
+
]);
|
|
355
|
+
} finally {
|
|
356
|
+
if (timer) clearTimeout(timer);
|
|
357
|
+
}
|
|
358
|
+
} finally {
|
|
359
|
+
lease.active = false;
|
|
360
|
+
try {
|
|
361
|
+
if (acquired && !rpc.failed) await rpc.request("release", {
|
|
362
|
+
lease: lease.id
|
|
363
|
+
});
|
|
364
|
+
} finally {
|
|
365
|
+
locks--;
|
|
366
|
+
release();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}, "exclusive");
|
|
370
|
+
const storageRequest = /* @__PURE__ */ __name(async (op, key, input = {}) => {
|
|
371
|
+
validKey(key);
|
|
372
|
+
const lease = context.getStore();
|
|
373
|
+
if (lease) {
|
|
374
|
+
if (!lease.active) throw refused();
|
|
375
|
+
return rpc.request(op, {
|
|
376
|
+
...input,
|
|
377
|
+
key,
|
|
378
|
+
lease: lease.id
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
return exclusive(refreshKey, () => storageRequest(op, key, input));
|
|
382
|
+
}, "storageRequest");
|
|
383
|
+
const store = {
|
|
384
|
+
withExclusive: exclusive,
|
|
385
|
+
async get(key) {
|
|
386
|
+
const result = await storageRequest("get", key);
|
|
387
|
+
if (result !== null && typeof result !== "string") throw refused();
|
|
388
|
+
return result;
|
|
389
|
+
},
|
|
390
|
+
async set(key, text) {
|
|
391
|
+
if (typeof text !== "string" || Buffer.byteLength(text, "utf8") > 2560) throw refused();
|
|
392
|
+
await storageRequest("set", key, {
|
|
393
|
+
value: text
|
|
394
|
+
});
|
|
395
|
+
},
|
|
396
|
+
async delete(key) {
|
|
397
|
+
await storageRequest("delete", key);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
const dpopSigner = {
|
|
401
|
+
jkt,
|
|
402
|
+
async createProof(args) {
|
|
403
|
+
current();
|
|
404
|
+
if (!args || typeof args.method !== "string" || typeof args.url !== "string" || args.url.length > 8192 || args.accessToken !== void 0 && (typeof args.accessToken !== "string" || args.accessToken.length > 16384 || !/^[\x21-\x7e]+$/.test(args.accessToken)) || args.nonce !== void 0 && (typeof args.nonce !== "string" || args.nonce.length > 4096 || /[\r\n]/.test(args.nonce))) throw refused();
|
|
405
|
+
const method = args.method.toUpperCase();
|
|
406
|
+
let url;
|
|
407
|
+
try {
|
|
408
|
+
url = new URL(args.url);
|
|
409
|
+
} catch {
|
|
410
|
+
throw refused();
|
|
411
|
+
}
|
|
412
|
+
if (!/^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)$/.test(method) || url.username || url.password || url.protocol !== "https:") throw refused();
|
|
413
|
+
const header = {
|
|
414
|
+
alg: "ES256",
|
|
415
|
+
typ: "dpop+jwt",
|
|
416
|
+
jwk: publicJwk
|
|
417
|
+
};
|
|
418
|
+
const claims = {
|
|
419
|
+
jti: randomUUID(),
|
|
420
|
+
htm: method,
|
|
421
|
+
htu: normalizeDpopHtu(args.url),
|
|
422
|
+
iat: Math.floor(Date.now() / 1e3),
|
|
423
|
+
...args.accessToken ? {
|
|
424
|
+
ath: createHash("sha256").update(args.accessToken).digest("base64url")
|
|
425
|
+
} : {},
|
|
426
|
+
...args.nonce ? {
|
|
427
|
+
nonce: args.nonce
|
|
428
|
+
} : {}
|
|
429
|
+
};
|
|
430
|
+
const a = Buffer.from(JSON.stringify(header)).toString("base64url"), b = Buffer.from(JSON.stringify(claims)).toString("base64url");
|
|
431
|
+
const signingInput = Buffer.from(`${a}.${b}`);
|
|
432
|
+
const signature = await rpc.request("sign", {
|
|
433
|
+
hash: createHash("sha256").update(signingInput).digest("base64")
|
|
434
|
+
});
|
|
435
|
+
if (typeof signature !== "string") throw refused();
|
|
436
|
+
const bytes = Buffer.from(signature, "base64");
|
|
437
|
+
if (bytes.length !== 64 || !verify("sha256", signingInput, {
|
|
438
|
+
key: publicKey,
|
|
439
|
+
dsaEncoding: "ieee-p1363"
|
|
440
|
+
}, bytes)) throw refused();
|
|
441
|
+
current();
|
|
442
|
+
return `${a}.${b}.${bytes.toString("base64url")}`;
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
return {
|
|
446
|
+
store,
|
|
447
|
+
dpopSigner,
|
|
448
|
+
custody: {
|
|
449
|
+
kind: "windows-credential-manager+tpm",
|
|
450
|
+
hardwareBacked: true,
|
|
451
|
+
nonExportable: true,
|
|
452
|
+
createdKey: value.createdKey,
|
|
453
|
+
keyName: String(value.keyName)
|
|
454
|
+
},
|
|
455
|
+
async close(input = {}) {
|
|
456
|
+
if (closed) return;
|
|
457
|
+
if (closing || locks || rpc.activeRequests || input.deleteCreatedKey && !value.createdKey) throw refused();
|
|
458
|
+
closing = true;
|
|
459
|
+
try {
|
|
460
|
+
await rpc.request("close", {
|
|
461
|
+
deleteCreatedKey: input.deleteCreatedKey === true
|
|
462
|
+
});
|
|
463
|
+
closed = true;
|
|
464
|
+
} catch (error) {
|
|
465
|
+
if (rpc.failed) closed = true;
|
|
466
|
+
throw error;
|
|
467
|
+
} finally {
|
|
468
|
+
closing = false;
|
|
469
|
+
if (closed) await rpc.kill();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
__name(createWindowsAccountHost, "createWindowsAccountHost");
|
|
475
|
+
var WindowsHostRpc = class WindowsHostRpc2 {
|
|
476
|
+
static {
|
|
477
|
+
__name(this, "WindowsHostRpc");
|
|
478
|
+
}
|
|
479
|
+
child;
|
|
480
|
+
timeoutMs;
|
|
481
|
+
exited;
|
|
482
|
+
failed = false;
|
|
483
|
+
pending = /* @__PURE__ */ new Map();
|
|
484
|
+
buffer = Buffer.alloc(0);
|
|
485
|
+
get activeRequests() {
|
|
486
|
+
return this.pending.size;
|
|
487
|
+
}
|
|
488
|
+
constructor(child, timeoutMs) {
|
|
489
|
+
this.child = child;
|
|
490
|
+
this.timeoutMs = timeoutMs;
|
|
491
|
+
this.exited = new Promise((resolve) => {
|
|
492
|
+
child.once("exit", () => {
|
|
493
|
+
this.fail();
|
|
494
|
+
resolve();
|
|
495
|
+
});
|
|
496
|
+
child.once("error", () => {
|
|
497
|
+
this.fail();
|
|
498
|
+
resolve();
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
child.stderr.resume();
|
|
502
|
+
child.stdout.on("data", (chunk) => {
|
|
503
|
+
this.buffer = Buffer.concat([
|
|
504
|
+
this.buffer,
|
|
505
|
+
chunk
|
|
506
|
+
]);
|
|
507
|
+
if (this.buffer.byteLength > MAX_PIPE_BYTES) {
|
|
508
|
+
this.fail();
|
|
509
|
+
void this.kill();
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
for (let newline; (newline = this.buffer.indexOf(10)) >= 0; ) {
|
|
513
|
+
const bytes = this.buffer.subarray(0, newline);
|
|
514
|
+
this.buffer = this.buffer.subarray(newline + 1);
|
|
515
|
+
let reply;
|
|
516
|
+
try {
|
|
517
|
+
reply = JSON.parse(new TextDecoder("utf-8", {
|
|
518
|
+
fatal: true
|
|
519
|
+
}).decode(bytes));
|
|
520
|
+
} catch {
|
|
521
|
+
this.fail();
|
|
522
|
+
void this.kill();
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
const item = reply && this.pending.get(reply.id);
|
|
526
|
+
if (!item || typeof reply.ok !== "boolean") {
|
|
527
|
+
this.fail();
|
|
528
|
+
void this.kill();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
clearTimeout(item.timer);
|
|
532
|
+
this.pending.delete(reply.id);
|
|
533
|
+
if (reply.ok) item.resolve(reply.value);
|
|
534
|
+
else item.reject(refused());
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
for (const stream of [
|
|
538
|
+
child.stdin,
|
|
539
|
+
child.stdout,
|
|
540
|
+
child.stderr
|
|
541
|
+
]) {
|
|
542
|
+
stream.on("error", () => {
|
|
543
|
+
this.fail();
|
|
544
|
+
void this.kill();
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
request(op, values = {}) {
|
|
549
|
+
if (this.failed || this.pending.size >= 128) return Promise.reject(refused());
|
|
550
|
+
const id = randomUUID(), line = JSON.stringify({
|
|
551
|
+
...values,
|
|
552
|
+
id,
|
|
553
|
+
op
|
|
554
|
+
}) + "\n";
|
|
555
|
+
if (Buffer.byteLength(line) > MAX_PIPE_BYTES) return Promise.reject(refused());
|
|
556
|
+
return new Promise((resolve, reject) => {
|
|
557
|
+
const timer = setTimeout(() => {
|
|
558
|
+
this.fail();
|
|
559
|
+
void this.kill();
|
|
560
|
+
}, this.timeoutMs);
|
|
561
|
+
this.pending.set(id, {
|
|
562
|
+
resolve,
|
|
563
|
+
reject,
|
|
564
|
+
timer
|
|
565
|
+
});
|
|
566
|
+
try {
|
|
567
|
+
this.child.stdin.write(line);
|
|
568
|
+
} catch {
|
|
569
|
+
this.fail();
|
|
570
|
+
void this.kill();
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
fail() {
|
|
575
|
+
this.failed = true;
|
|
576
|
+
for (const item of this.pending.values()) {
|
|
577
|
+
clearTimeout(item.timer);
|
|
578
|
+
item.reject(refused());
|
|
579
|
+
}
|
|
580
|
+
this.pending.clear();
|
|
581
|
+
}
|
|
582
|
+
async kill() {
|
|
583
|
+
this.fail();
|
|
584
|
+
if (this.child.exitCode !== null || this.child.signalCode !== null) return;
|
|
585
|
+
this.child.stdin.end();
|
|
586
|
+
this.child.kill();
|
|
587
|
+
await this.exited;
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
// src/node.ts
|
|
592
|
+
function createNodeDpopSigner(input) {
|
|
593
|
+
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
594
|
+
if (parsed.kty !== "EC" || parsed.crv !== "P-256" || !parsed.x || !parsed.y || !parsed.d) {
|
|
595
|
+
throw new Error("DPoP private JWK must be a P-256 EC key");
|
|
596
|
+
}
|
|
597
|
+
const privateJwk = parsed;
|
|
598
|
+
const publicJwk = {
|
|
599
|
+
kty: "EC",
|
|
600
|
+
crv: "P-256",
|
|
601
|
+
x: privateJwk.x,
|
|
602
|
+
y: privateJwk.y
|
|
603
|
+
};
|
|
604
|
+
const jkt = crypto.createHash("sha256").update(JSON.stringify({
|
|
605
|
+
crv: "P-256",
|
|
606
|
+
kty: "EC",
|
|
607
|
+
x: privateJwk.x,
|
|
608
|
+
y: privateJwk.y
|
|
609
|
+
})).digest("base64url");
|
|
610
|
+
const key = crypto.createPrivateKey({
|
|
611
|
+
key: privateJwk,
|
|
612
|
+
format: "jwk"
|
|
613
|
+
});
|
|
614
|
+
return {
|
|
615
|
+
jkt,
|
|
616
|
+
async createProof(args) {
|
|
617
|
+
const header = {
|
|
618
|
+
alg: "ES256",
|
|
619
|
+
typ: "dpop+jwt",
|
|
620
|
+
jwk: publicJwk
|
|
621
|
+
};
|
|
622
|
+
const claims = {
|
|
623
|
+
jti: crypto.randomUUID(),
|
|
624
|
+
htm: args.method.toUpperCase(),
|
|
625
|
+
htu: normalizeDpopHtu(args.url),
|
|
626
|
+
iat: Math.floor(Date.now() / 1e3)
|
|
627
|
+
};
|
|
628
|
+
if (args.accessToken) claims.ath = crypto.createHash("sha256").update(args.accessToken).digest("base64url");
|
|
629
|
+
if (args.nonce) claims.nonce = args.nonce;
|
|
630
|
+
const a = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
631
|
+
const b = Buffer.from(JSON.stringify(claims)).toString("base64url");
|
|
632
|
+
const signature = crypto.sign("sha256", Buffer.from(`${a}.${b}`), {
|
|
633
|
+
key,
|
|
634
|
+
dsaEncoding: "ieee-p1363"
|
|
635
|
+
}).toString("base64url");
|
|
636
|
+
return `${a}.${b}.${signature}`;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
__name(createNodeDpopSigner, "createNodeDpopSigner");
|
|
641
|
+
export {
|
|
642
|
+
createNodeDpopSigner,
|
|
643
|
+
createWindowsAccountHost
|
|
644
|
+
};
|
|
645
|
+
//# sourceMappingURL=node.mjs.map
|