@ozyman42/ozy-cli 0.4.7 → 0.4.8-darwin-x64.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.
Files changed (207) hide show
  1. package/multi-call-binary +0 -0
  2. package/package.json +11 -52
  3. package/bin/ozy +0 -191
  4. package/bin/ozy-signing-agent +0 -191
  5. package/bin/ozy-ssh-keygen +0 -191
  6. package/bin/ozy-virtual-security-key +0 -191
  7. package/dist/commands/git/hosts.js +0 -18
  8. package/dist/commands/git/hosts.js.map +0 -1
  9. package/dist/commands/git/index.js +0 -8
  10. package/dist/commands/git/index.js.map +0 -1
  11. package/dist/commands/git/setup.js +0 -145
  12. package/dist/commands/git/setup.js.map +0 -1
  13. package/dist/commands/index.js +0 -13
  14. package/dist/commands/index.js.map +0 -1
  15. package/dist/commands/npm/index.js +0 -7
  16. package/dist/commands/npm/index.js.map +0 -1
  17. package/dist/commands/npm/setup/git-remote.js +0 -66
  18. package/dist/commands/npm/setup/git-remote.js.map +0 -1
  19. package/dist/commands/npm/setup/index.js +0 -168
  20. package/dist/commands/npm/setup/index.js.map +0 -1
  21. package/dist/commands/npm/setup/npm-auth.js +0 -62
  22. package/dist/commands/npm/setup/npm-auth.js.map +0 -1
  23. package/dist/commands/npm/setup/package-json-validate.js +0 -47
  24. package/dist/commands/npm/setup/package-json-validate.js.map +0 -1
  25. package/dist/commands/npm/setup/package-registry.js +0 -20
  26. package/dist/commands/npm/setup/package-registry.js.map +0 -1
  27. package/dist/commands/npm/setup/setup.test.js +0 -95
  28. package/dist/commands/npm/setup/setup.test.js.map +0 -1
  29. package/dist/commands/npm/setup/trusted-publishing.js +0 -84
  30. package/dist/commands/npm/setup/trusted-publishing.js.map +0 -1
  31. package/dist/commands/npm/setup/workflow.js +0 -19
  32. package/dist/commands/npm/setup/workflow.js.map +0 -1
  33. package/dist/commands/ssh/get-sk-credential.js +0 -104
  34. package/dist/commands/ssh/get-sk-credential.js.map +0 -1
  35. package/dist/commands/ssh/index.js +0 -7
  36. package/dist/commands/ssh/index.js.map +0 -1
  37. package/dist/commands/upgrade.js +0 -199
  38. package/dist/commands/upgrade.js.map +0 -1
  39. package/dist/common/command.js +0 -15
  40. package/dist/common/command.js.map +0 -1
  41. package/dist/common/constants.js +0 -25
  42. package/dist/common/constants.js.map +0 -1
  43. package/dist/common/effective-modules-extensions.js +0 -13
  44. package/dist/common/effective-modules-extensions.js.map +0 -1
  45. package/dist/common/log.js +0 -4
  46. package/dist/common/log.js.map +0 -1
  47. package/dist/common/render-caller-tree.js +0 -20
  48. package/dist/common/render-caller-tree.js.map +0 -1
  49. package/dist/entrypoints/ozy-signing-agent.js +0 -48
  50. package/dist/entrypoints/ozy-signing-agent.js.map +0 -1
  51. package/dist/entrypoints/ozy-ssh-keygen.js +0 -9
  52. package/dist/entrypoints/ozy-ssh-keygen.js.map +0 -1
  53. package/dist/entrypoints/ozy-virtual-security-key.js +0 -18
  54. package/dist/entrypoints/ozy-virtual-security-key.js.map +0 -1
  55. package/dist/entrypoints/ozy.js +0 -3
  56. package/dist/entrypoints/ozy.js.map +0 -1
  57. package/dist/index.js +0 -2
  58. package/dist/index.js.map +0 -1
  59. package/dist/internal/thing.js +0 -4
  60. package/dist/internal/thing.js.map +0 -1
  61. package/dist/modules/cli/agent-client/impl.js +0 -109
  62. package/dist/modules/cli/agent-client/impl.js.map +0 -1
  63. package/dist/modules/cli/agent-client/interface.js +0 -11
  64. package/dist/modules/cli/agent-client/interface.js.map +0 -1
  65. package/dist/modules/cli/git/impl.js +0 -124
  66. package/dist/modules/cli/git/impl.js.map +0 -1
  67. package/dist/modules/cli/git/interface.js +0 -3
  68. package/dist/modules/cli/git/interface.js.map +0 -1
  69. package/dist/modules/cli/git/submodule/fix.js +0 -257
  70. package/dist/modules/cli/git/submodule/fix.js.map +0 -1
  71. package/dist/modules/cli/git/submodule/git-state.js +0 -154
  72. package/dist/modules/cli/git/submodule/git-state.js.map +0 -1
  73. package/dist/modules/cli/git/submodule/gitmodules.js +0 -113
  74. package/dist/modules/cli/git/submodule/gitmodules.js.map +0 -1
  75. package/dist/modules/cli/git/submodule/printer.js +0 -232
  76. package/dist/modules/cli/git/submodule/printer.js.map +0 -1
  77. package/dist/modules/cli/git/submodule/resolve-git-dir.js +0 -16
  78. package/dist/modules/cli/git/submodule/resolve-git-dir.js.map +0 -1
  79. package/dist/modules/cli/github/impl.js +0 -137
  80. package/dist/modules/cli/github/impl.js.map +0 -1
  81. package/dist/modules/cli/github/interface.js +0 -2
  82. package/dist/modules/cli/github/interface.js.map +0 -1
  83. package/dist/modules/cli/index.js +0 -9
  84. package/dist/modules/cli/index.js.map +0 -1
  85. package/dist/modules/common/crypto/impl.js +0 -133
  86. package/dist/modules/common/crypto/impl.js.map +0 -1
  87. package/dist/modules/common/crypto/interface.js +0 -2
  88. package/dist/modules/common/crypto/interface.js.map +0 -1
  89. package/dist/modules/common/index.js +0 -10
  90. package/dist/modules/common/index.js.map +0 -1
  91. package/dist/modules/common/kep-map-store/impl.js +0 -42
  92. package/dist/modules/common/kep-map-store/impl.js.map +0 -1
  93. package/dist/modules/common/kep-map-store/interface.js +0 -2
  94. package/dist/modules/common/kep-map-store/interface.js.map +0 -1
  95. package/dist/modules/common/os-platform/caller-info.js +0 -132
  96. package/dist/modules/common/os-platform/caller-info.js.map +0 -1
  97. package/dist/modules/common/os-platform/impl.js +0 -87
  98. package/dist/modules/common/os-platform/impl.js.map +0 -1
  99. package/dist/modules/common/os-platform/interface.js +0 -2
  100. package/dist/modules/common/os-platform/interface.js.map +0 -1
  101. package/dist/modules/common/os-platform/virtual-hid/index.js +0 -12
  102. package/dist/modules/common/os-platform/virtual-hid/index.js.map +0 -1
  103. package/dist/modules/common/os-platform/virtual-hid/linux.js +0 -5
  104. package/dist/modules/common/os-platform/virtual-hid/linux.js.map +0 -1
  105. package/dist/modules/common/os-platform/virtual-hid/mac.js +0 -119
  106. package/dist/modules/common/os-platform/virtual-hid/mac.js.map +0 -1
  107. package/dist/modules/common/os-platform/virtual-hid/windows.js +0 -5
  108. package/dist/modules/common/os-platform/virtual-hid/windows.js.map +0 -1
  109. package/dist/modules/common/ssh-config/impl.js +0 -116
  110. package/dist/modules/common/ssh-config/impl.js.map +0 -1
  111. package/dist/modules/common/ssh-config/interface.js +0 -10
  112. package/dist/modules/common/ssh-config/interface.js.map +0 -1
  113. package/dist/modules/ssh-agent/index.js +0 -8
  114. package/dist/modules/ssh-agent/index.js.map +0 -1
  115. package/dist/modules/ssh-agent/session/impl.js +0 -265
  116. package/dist/modules/ssh-agent/session/impl.js.map +0 -1
  117. package/dist/modules/ssh-agent/session/interface-rpc.js +0 -20
  118. package/dist/modules/ssh-agent/session/interface-rpc.js.map +0 -1
  119. package/dist/modules/ssh-agent/session/interface.js +0 -32
  120. package/dist/modules/ssh-agent/session/interface.js.map +0 -1
  121. package/dist/modules/ssh-agent/session/passkey-prf-page.js +0 -204
  122. package/dist/modules/ssh-agent/session/passkey-prf-page.js.map +0 -1
  123. package/dist/modules/ssh-agent/session/prf-flow.js +0 -103
  124. package/dist/modules/ssh-agent/session/prf-flow.js.map +0 -1
  125. package/dist/modules/ssh-agent/ssh-agent/impl.js +0 -117
  126. package/dist/modules/ssh-agent/ssh-agent/impl.js.map +0 -1
  127. package/dist/modules/ssh-agent/ssh-agent/interface.js +0 -2
  128. package/dist/modules/ssh-agent/ssh-agent/interface.js.map +0 -1
  129. package/dist/scripts/build.js +0 -410
  130. package/dist/scripts/build.js.map +0 -1
  131. package/dist/scripts/check-npm-version.js +0 -8
  132. package/dist/scripts/check-npm-version.js.map +0 -1
  133. package/dist/scripts/kill-existing-agent.js +0 -21
  134. package/dist/scripts/kill-existing-agent.js.map +0 -1
  135. package/dist/scripts/publish.js +0 -46
  136. package/dist/scripts/publish.js.map +0 -1
  137. package/src/commands/git/hosts.ts +0 -20
  138. package/src/commands/git/index.ts +0 -9
  139. package/src/commands/git/setup.ts +0 -182
  140. package/src/commands/index.ts +0 -15
  141. package/src/commands/npm/index.ts +0 -8
  142. package/src/commands/npm/setup/git-remote.ts +0 -78
  143. package/src/commands/npm/setup/index.ts +0 -189
  144. package/src/commands/npm/setup/npm-auth.ts +0 -58
  145. package/src/commands/npm/setup/package-json-validate.ts +0 -68
  146. package/src/commands/npm/setup/package-registry.ts +0 -24
  147. package/src/commands/npm/setup/publish-workflow.yml +0 -35
  148. package/src/commands/npm/setup/setup.test.ts +0 -117
  149. package/src/commands/npm/setup/trusted-publishing.ts +0 -106
  150. package/src/commands/npm/setup/workflow.ts +0 -20
  151. package/src/commands/ssh/get-sk-credential.ts +0 -110
  152. package/src/commands/ssh/index.ts +0 -8
  153. package/src/commands/upgrade.ts +0 -220
  154. package/src/common/command.ts +0 -16
  155. package/src/common/constants.ts +0 -26
  156. package/src/common/effective-modules-extensions.ts +0 -24
  157. package/src/common/log.ts +0 -3
  158. package/src/common/render-caller-tree.ts +0 -22
  159. package/src/entrypoints/ozy-signing-agent.ts +0 -48
  160. package/src/entrypoints/ozy-ssh-keygen.ts +0 -10
  161. package/src/entrypoints/ozy-virtual-security-key.ts +0 -21
  162. package/src/entrypoints/ozy.ts +0 -2
  163. package/src/index.ts +0 -1
  164. package/src/internal/thing.ts +0 -3
  165. package/src/modules/cli/agent-client/impl.ts +0 -152
  166. package/src/modules/cli/agent-client/interface.ts +0 -17
  167. package/src/modules/cli/git/impl.ts +0 -133
  168. package/src/modules/cli/git/interface.ts +0 -23
  169. package/src/modules/cli/git/submodule/fix.ts +0 -298
  170. package/src/modules/cli/git/submodule/git-state.ts +0 -217
  171. package/src/modules/cli/git/submodule/gitmodules.ts +0 -126
  172. package/src/modules/cli/git/submodule/printer.ts +0 -256
  173. package/src/modules/cli/git/submodule/resolve-git-dir.ts +0 -14
  174. package/src/modules/cli/github/impl.ts +0 -169
  175. package/src/modules/cli/github/interface.ts +0 -29
  176. package/src/modules/cli/index.ts +0 -16
  177. package/src/modules/common/crypto/impl.ts +0 -173
  178. package/src/modules/common/crypto/interface.ts +0 -20
  179. package/src/modules/common/index.ts +0 -19
  180. package/src/modules/common/kep-map-store/impl.ts +0 -47
  181. package/src/modules/common/kep-map-store/interface.ts +0 -9
  182. package/src/modules/common/os-platform/caller-info.ts +0 -152
  183. package/src/modules/common/os-platform/impl.ts +0 -86
  184. package/src/modules/common/os-platform/interface.ts +0 -16
  185. package/src/modules/common/os-platform/virtual-hid/index.ts +0 -12
  186. package/src/modules/common/os-platform/virtual-hid/linux.ts +0 -7
  187. package/src/modules/common/os-platform/virtual-hid/mac.ts +0 -150
  188. package/src/modules/common/os-platform/virtual-hid/windows.ts +0 -7
  189. package/src/modules/common/ssh-config/impl.ts +0 -130
  190. package/src/modules/common/ssh-config/interface.ts +0 -33
  191. package/src/modules/ssh-agent/index.ts +0 -13
  192. package/src/modules/ssh-agent/session/agent-notes.md +0 -210
  193. package/src/modules/ssh-agent/session/design.md +0 -2
  194. package/src/modules/ssh-agent/session/html-refactor.md +0 -23
  195. package/src/modules/ssh-agent/session/impl.ts +0 -328
  196. package/src/modules/ssh-agent/session/interface-rpc.ts +0 -24
  197. package/src/modules/ssh-agent/session/interface.ts +0 -62
  198. package/src/modules/ssh-agent/session/passkey-prf-page.ts +0 -224
  199. package/src/modules/ssh-agent/session/prf-flow.ts +0 -152
  200. package/src/modules/ssh-agent/ssh-agent/impl.ts +0 -136
  201. package/src/modules/ssh-agent/ssh-agent/interface.ts +0 -9
  202. package/src/scripts/build.ts +0 -504
  203. package/src/scripts/check-npm-version.ts +0 -7
  204. package/src/scripts/command-launcher.js.ejs +0 -168
  205. package/src/scripts/kill-existing-agent.ts +0 -22
  206. package/src/scripts/publish.ts +0 -47
  207. package/src/scripts/windows-bin-shims.md +0 -1104
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl.js","sourceRoot":"","sources":["../../../../../../../src/modules/common/os-platform/impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,UAAU,E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IAAI,EAAE,IAAI,IAAI;4BAAE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;wBAC3F,OAAO,sBAAsB,CAAC,EAAE,CAAC,CAAC;oBACpC,CAAC,CAAC,CAAC,CAAC;oBACJ,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;YACD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oCAAoC,UAAU,KAAK,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;SAC9G,CAAC,CAAC;IACL,CAAC;IACD,kBAAkB,CAAC,SAAkD,IAAI,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CACjH"}
@@ -1,2 +0,0 @@
1
- import { Effect } from "effect";
2
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../../../../src/modules/common/os-platform/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,12 +0,0 @@
1
- import { Effect } from "effect";
2
- import { registerVirtualHIDMac } from "./mac";
3
- import { registerVirtualHIDLinux } from "./linux";
4
- import { registerVirtualHIDWindows } from "./windows";
5
- export function registerVirtualHID(onMessage) {
6
- if (process.platform === 'darwin')
7
- return registerVirtualHIDMac(onMessage);
8
- if (process.platform === 'win32')
9
- return registerVirtualHIDWindows(onMessage);
10
- return registerVirtualHIDLinux(onMessage);
11
- }
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../src/modules/common/os-platform/virtual-hid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,UAAU,kBAAkB,CAChC,SAAkD;IAElD,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC3E,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,yBAAyB,CAAC,SAAS,CAAC,CAAC;IAC9E,OAAO,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,5 +0,0 @@
1
- import { Effect } from "effect";
2
- export function registerVirtualHIDLinux(_onMessage) {
3
- return Effect.fail('registerVirtualHID is not yet supported on Linux');
4
- }
5
- //# sourceMappingURL=linux.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"linux.js","sourceRoot":"","sources":["../../../../../../../../src/modules/common/os-platform/virtual-hid/linux.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,UAAU,uBAAuB,CACrC,UAAmD;IAEnD,OAAO,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;AACzE,CAAC"}
@@ -1,119 +0,0 @@
1
- import { Effect, Option, pipe } from "effect";
2
- import { JSCallback, dlopen, FFIType, ptr, toArrayBuffer } from "bun:ffi";
3
- // FIDO Alliance usage page (0xF1D0), 64-byte in/out reports, no report IDs
4
- const FIDO2_HID_DESCRIPTOR = new Uint8Array([
5
- 0x06, 0xD0, 0xF1, // Usage Page (FIDO Alliance 0xF1D0, little-endian)
6
- 0x09, 0x01, // Usage (U2F HID Authenticator Device)
7
- 0xA1, 0x01, // Collection (Application)
8
- 0x09, 0x20, // Usage (Input report data)
9
- 0x15, 0x00, // Logical Minimum (0)
10
- 0x26, 0xFF, 0x00, // Logical Maximum (255)
11
- 0x75, 0x08, // Report Size (8 bits)
12
- 0x95, 0x40, // Report Count (64)
13
- 0x81, 0x02, // Input (Data, Variable, Absolute)
14
- 0x09, 0x21, // Usage (Output report data)
15
- 0x15, 0x00, // Logical Minimum (0)
16
- 0x26, 0xFF, 0x00, // Logical Maximum (255)
17
- 0x75, 0x08, // Report Size (8 bits)
18
- 0x95, 0x40, // Report Count (64)
19
- 0x91, 0x02, // Output (Data, Variable, Absolute)
20
- 0xC0, // End Collection
21
- ]);
22
- const kIOHIDReportTypeOutput = 1;
23
- const kIOReturnSuccess = 0;
24
- const kCFStringEncodingUTF8 = 0x08000100;
25
- const kCFPropertyListImmutable = 0;
26
- // Kept at module scope to prevent GC while the virtual device is running
27
- let _vhidCallback = null;
28
- _vhidCallback;
29
- const fromPtr = (label, p) => pipe(Option.fromNullishOr(p), Effect.fromOption, Effect.mapError(() => `${label} returned NULL`));
30
- // Build the device properties as an XML plist. CFPropertyListCreateWithData parses this
31
- // into a fully-initialized CFDictionary (with correct hash/equal callbacks), avoiding
32
- // the need to pass raw CFDictionaryKeyCallBacks structs via FFI.
33
- function buildDevicePropertiesPlist() {
34
- const descriptorB64 = Buffer.from(FIDO2_HID_DESCRIPTOR).toString('base64');
35
- const xml = [
36
- '<?xml version="1.0" encoding="UTF-8"?>',
37
- '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
38
- '<plist version="1.0">',
39
- '<dict>',
40
- ' <key>ReportDescriptor</key>',
41
- ` <data>${descriptorB64}</data>`,
42
- ' <key>VendorID</key>',
43
- ' <integer>4617</integer>', // 0x1209 - pid.codes open-source VID
44
- ' <key>ProductID</key>',
45
- ' <integer>1</integer>',
46
- ' <key>VersionNumber</key>',
47
- ' <integer>256</integer>', // 0x0100
48
- ' <key>Product</key>',
49
- ' <string>Ozy Virtual FIDO2 Key</string>',
50
- '</dict>',
51
- '</plist>',
52
- ].join('\n');
53
- return new TextEncoder().encode(xml);
54
- }
55
- export function registerVirtualHIDMac(onMessage) {
56
- return Effect.gen(function* () {
57
- console.log('[vhid] loading frameworks');
58
- const IOKit = yield* Effect.try({
59
- try: () => dlopen('/System/Library/Frameworks/IOKit.framework/IOKit', {
60
- IOHIDUserDeviceCreate: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.ptr },
61
- IOHIDUserDeviceRegisterSetReportCallback: { args: [FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.void },
62
- IOHIDUserDeviceScheduleWithRunLoop: { args: [FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.void },
63
- IOHIDUserDeviceHandleReport: { args: [FFIType.ptr, FFIType.ptr, FFIType.i64], returns: FFIType.i32 },
64
- }),
65
- catch: (e) => `Failed to load IOKit: ${e}`,
66
- });
67
- const CF = yield* Effect.try({
68
- try: () => dlopen('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation', {
69
- CFRunLoopGetCurrent: { args: [], returns: FFIType.ptr },
70
- CFRunLoopRunInMode: { args: [FFIType.ptr, FFIType.f64, FFIType.bool], returns: FFIType.i32 },
71
- CFStringCreateWithCString: { args: [FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.ptr },
72
- CFDataCreate: { args: [FFIType.ptr, FFIType.ptr, FFIType.i64], returns: FFIType.ptr },
73
- CFPropertyListCreateWithData: { args: [FFIType.ptr, FFIType.ptr, FFIType.u64, FFIType.ptr, FFIType.ptr], returns: FFIType.ptr },
74
- CFRelease: { args: [FFIType.ptr], returns: FFIType.void },
75
- }),
76
- catch: (e) => `Failed to load CoreFoundation: ${e}`,
77
- });
78
- console.log('[vhid] frameworks loaded');
79
- const encoder = new TextEncoder();
80
- const makeCFString = (s) =>
81
- // TextEncoder gives a Uint8Array with its own ArrayBuffer (byteOffset=0, pool-safe)
82
- fromPtr(`CFStringCreateWithCString("${s}")`, CF.symbols.CFStringCreateWithCString(null, ptr(encoder.encode(s + '\0')), kCFStringEncodingUTF8));
83
- const makeCFData = (data) => fromPtr('CFDataCreate', CF.symbols.CFDataCreate(null, ptr(data), BigInt(data.length)));
84
- console.log('[vhid] building device properties plist');
85
- const plistBytes = buildDevicePropertiesPlist();
86
- const plistData = yield* makeCFData(plistBytes);
87
- const dict = yield* fromPtr('CFPropertyListCreateWithData', CF.symbols.CFPropertyListCreateWithData(null, plistData, BigInt(kCFPropertyListImmutable), null, null));
88
- CF.symbols.CFRelease(plistData);
89
- console.log('[vhid] device properties dict =', dict);
90
- console.log('[vhid] creating IOHIDUserDevice');
91
- const device = yield* fromPtr('IOHIDUserDeviceCreate', IOKit.symbols.IOHIDUserDeviceCreate(null, dict));
92
- CF.symbols.CFRelease(dict);
93
- console.log('[vhid] IOHIDUserDeviceCreate =', device);
94
- const callback = yield* Effect.try({
95
- try: () => new JSCallback((_refcon, _result, _sender, type, _reportID, report, reportLength) => {
96
- if (type !== kIOHIDReportTypeOutput)
97
- return kIOReturnSuccess;
98
- const incoming = Buffer.from(toArrayBuffer(report, 0, reportLength));
99
- console.log(`[vhid] received ${incoming.length} bytes: ${incoming.toString('hex')}`);
100
- Effect.runPromise(onMessage(incoming)).then(response => {
101
- const responseBuf = new Uint8Array(64);
102
- response.copy(Buffer.from(responseBuf.buffer), 0, 0, Math.min(response.length, 64));
103
- IOKit.symbols.IOHIDUserDeviceHandleReport(device, ptr(responseBuf), BigInt(responseBuf.length));
104
- }).catch(() => { });
105
- return kIOReturnSuccess;
106
- }, { returns: 'i32', args: ['ptr', 'i32', 'ptr', 'i32', 'u32', 'ptr', 'i64'] }),
107
- catch: (e) => `Failed to create JSCallback: ${e}`,
108
- });
109
- _vhidCallback = callback;
110
- IOKit.symbols.IOHIDUserDeviceRegisterSetReportCallback(device, callback.ptr, null);
111
- const runLoop = CF.symbols.CFRunLoopGetCurrent();
112
- const runLoopMode = yield* makeCFString('kCFRunLoopDefaultMode');
113
- IOKit.symbols.IOHIDUserDeviceScheduleWithRunLoop(device, runLoop, runLoopMode);
114
- console.log('[vhid] virtual FIDO2 device active, pumping run loop');
115
- // Pump CFRunLoop from Bun's libuv event loop without blocking
116
- setInterval(() => CF.symbols.CFRunLoopRunInMode(runLoopMode, 0.0, false), 10);
117
- });
118
- }
119
- //# sourceMappingURL=mac.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mac.js","sourceRoot":"","sources":["../../../../../../../../src/modules/common/os-platform/virtual-hid/mac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1E,2EAA2E;AAC3E,MAAM,oBAAoB,GAAG,IAAI,UAAU,CAAC;IAC1C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,mDAAmD;IACrE,IAAI,EAAE,IAAI,EAAQ,uCAAuC;IACzD,IAAI,EAAE,IAAI,EAAQ,2BAA2B;IAC7C,IAAI,EAAE,IAAI,EAAQ,8BAA8B;IAChD,IAAI,EAAE,IAAI,EAAQ,wBAAwB;IAC1C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,0BAA0B;IAC5C,IAAI,EAAE,IAAI,EAAQ,yBAAyB;IAC3C,IAAI,EAAE,IAAI,EAAQ,sBAAsB;IACxC,IAAI,EAAE,IAAI,EAAQ,qCAAqC;IACvD,IAAI,EAAE,IAAI,EAAQ,+BAA+B;IACjD,IAAI,EAAE,IAAI,EAAQ,wBAAwB;IAC1C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,0BAA0B;IAC5C,IAAI,EAAE,IAAI,EAAQ,yBAAyB;IAC3C,IAAI,EAAE,IAAI,EAAQ,sBAAsB;IACxC,IAAI,EAAE,IAAI,EAAQ,sCAAsC;IACxD,IAAI,EAAc,iBAAiB;CACpC,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,gBAAgB,GAAG,CAAC,CA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CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;QACpE,8DAA8D;QAC9D,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,5 +0,0 @@
1
- import { Effect } from "effect";
2
- export function registerVirtualHIDWindows(_onMessage) {
3
- return Effect.fail('registerVirtualHID is not yet supported on Windows');
4
- }
5
- //# sourceMappingURL=windows.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"windows.js","sourceRoot":"","sources":["../../../../../../../../src/modules/common/os-platform/virtual-hid/windows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,UAAU,yBAAyB,CACvC,UAAmD;IAEnD,OAAO,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;AAC3E,CAAC"}
@@ -1,116 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { writeFileSync } from "node:fs";
4
- import { Effect, Option, Schema } from "effect";
5
- import SSHConfig, { LineType } from "ssh-config";
6
- import expandTilde from "expand-tilde";
7
- import { implementing } from "effective-modules";
8
- import { commonModules } from "@/modules/common";
9
- import { SSHConfigSection } from "./interface";
10
- const SSH_CONFIG_PATH = "~/.ssh/config";
11
- const SSH_DIR = "~/.ssh";
12
- export class SSHConfigImpl extends implementing(commonModules.SSHConfig) {
13
- *loadSSHConfigRaw() {
14
- const configPath = expandTilde(SSH_CONFIG_PATH);
15
- const exists = yield* Effect.promise(() => fs.exists(configPath));
16
- const text = exists
17
- ? yield* Effect.tryPromise({
18
- try: () => fs.readFile(configPath, "utf8"),
19
- catch: (e) => `Failed to read ssh config at ${configPath}: ${e instanceof Error ? e.message : String(e)}`,
20
- })
21
- : "";
22
- return yield* Effect.try({
23
- try: () => SSHConfig.parse(text),
24
- catch: (e) => `ParseError: unable to parse ssh config at ${configPath}\n${e instanceof Error ? e.message : String(e)}`,
25
- });
26
- }
27
- *getSSHConfig() {
28
- const configPath = expandTilde(SSH_CONFIG_PATH);
29
- const exists = yield* Effect.promise(() => fs.exists(configPath));
30
- if (!exists)
31
- return yield* Effect.fail(`SSHConfigFileMissingError: No file found at ${configPath}`);
32
- const parsed = yield* this.loadSSHConfigRaw();
33
- const hosts = {};
34
- for (const line of parsed) {
35
- if (line.type === LineType.COMMENT)
36
- continue;
37
- const { param, value: host } = line;
38
- if (param !== "Host")
39
- return yield* Effect.fail(`EntryNotAHostKeyValuePairError: unexpected top-level entry '${param}=${JSON.stringify(host)}'`);
40
- if (typeof host !== "string")
41
- return yield* Effect.fail(`EntryNotAHostKeyValuePairError: Host value is not a string: ${JSON.stringify(host)}`);
42
- if (!("config" in line))
43
- return yield* Effect.fail(`EntryNotAHostKeyValuePairError: non-section Host entry '${host}'`);
44
- if (host in hosts)
45
- return yield* Effect.fail(`DuplicateHostError: duplicate Host '${host}' in ${configPath}`);
46
- const kv = {};
47
- for (const inner of line.config) {
48
- if (inner.type === LineType.COMMENT)
49
- continue;
50
- if (typeof inner.value !== "string")
51
- return yield* Effect.fail(`MalformedError: Host '${host}' key '${inner.param}' has non-string value`);
52
- kv[inner.param] = inner.value;
53
- }
54
- const section = yield* Schema.decodeUnknownEffect(SSHConfigSection)(kv).pipe(Effect.mapError(e => `MalformedError: malformed section at Host '${host}': ${String(e)}`));
55
- hosts[host] = section;
56
- }
57
- return hosts;
58
- }
59
- *writeHost({ section }) {
60
- const configPath = expandTilde(SSH_CONFIG_PATH);
61
- const cfg = yield* this.loadSSHConfigRaw();
62
- const newEntries = Object.entries(section)
63
- .filter(([, v]) => v !== undefined)
64
- .map(([k, v]) => ({ type: LineType.DIRECTIVE, before: ' ', param: k, separator: ' ', value: v, after: '\n' }));
65
- const existingIdx = cfg.findIndex((e) => e.param === "Host" && e.value === section.HostName);
66
- if (existingIdx >= 0) {
67
- cfg[existingIdx].config = newEntries;
68
- }
69
- else {
70
- const record = { Host: section.HostName };
71
- for (const [k, v] of Object.entries(section)) {
72
- if (v !== undefined)
73
- record[k] = v;
74
- }
75
- cfg.append(record);
76
- }
77
- yield* Effect.try({
78
- try: () => writeFileSync(configPath, SSHConfig.stringify(cfg), { mode: 0o600 }),
79
- catch: (e) => `Failed to write ssh config: ${e instanceof Error ? e.message : String(e)}`,
80
- });
81
- }
82
- *listPubkeyFiles() {
83
- const sshDir = expandTilde(SSH_DIR);
84
- const entries = yield* Effect.tryPromise({
85
- try: () => fs.readdir(sshDir),
86
- catch: (e) => `Failed to read ${sshDir}: ${e instanceof Error ? e.message : String(e)}`,
87
- });
88
- const pubkeyFiles = entries.filter(f => f.endsWith('.pub'));
89
- const results = [];
90
- for (const file of pubkeyFiles) {
91
- const content = yield* Effect.tryPromise({
92
- try: () => fs.readFile(join(sshDir, file), 'utf8'),
93
- catch: (e) => `Failed to read ${file}: ${e instanceof Error ? e.message : String(e)}`,
94
- });
95
- results.push({ name: file.slice(0, -'.pub'.length), content: content.trim() });
96
- }
97
- return results;
98
- }
99
- getPubkeyPath(name) {
100
- return `${expandTilde(SSH_DIR)}/${name}.pub`;
101
- }
102
- *writePubkey({ name, comment, pubkey }) {
103
- const sshDir = expandTilde(SSH_DIR);
104
- const pubkeyPath = `${sshDir}/${name}.pub`;
105
- const content = Option.match(comment, {
106
- onNone: () => pubkey.authorizedKey,
107
- onSome: (c) => `${pubkey.authorizedKey} ${c}`,
108
- });
109
- yield* Effect.try({
110
- try: () => writeFileSync(pubkeyPath, content + "\n", { mode: 0o600 }),
111
- catch: (e) => `Failed to write pubkey to ${pubkeyPath}: ${e instanceof Error ? e.message : String(e)}`,
112
- });
113
- return { pubkeyPath };
114
- }
115
- }
116
- //# sourceMappingURL=impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl.js","sourceRoot":"","sources":["../../../../../../../src/modules/common/ssh-config/impl.ts"],"names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AC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC;IAC/C,CAAC;IAED,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAoB;QACtD,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,GAAG,MAAM,IAAI,IAAI,MAAM,CAAC;QAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;YACpC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa;YAClC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,aAAa,IAAI,CAAC,EAAE;SAC9C,CAAC,CAAC;QAEH,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;YAChB,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YACrE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,6BAA6B,UAAU,KAAK,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;SACvG,CAAC,CAAC;QAEH,OAAO,EAAC,UAAU,EAAC,CAAC;IACtB,CAAC;CACF"}
@@ -1,10 +0,0 @@
1
- import { Schema } from "effect";
2
- export const SSHConfigSection = Schema.Struct({
3
- HostName: Schema.String,
4
- User: Schema.String,
5
- IdentityFile: Schema.optional(Schema.String),
6
- AddKeysToAgent: Schema.optional(Schema.String),
7
- IdentitiesOnly: Schema.optional(Schema.String),
8
- IdentityAgent: Schema.optional(Schema.String),
9
- });
10
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../../../../src/modules/common/ssh-config/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5C,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9C,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9C,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CAC9C,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- import { interfaces } from "effective-modules";
2
- export var AgentModules;
3
- (function (AgentModules) {
4
- AgentModules["SSHAgent"] = "SSHAgent";
5
- AgentModules["Session"] = "Session";
6
- })(AgentModules || (AgentModules = {}));
7
- export const agentModules = interfaces(AgentModules);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/modules/ssh-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;AACrB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAGnC,YAAY,CAAC,CAAC"}
@@ -1,265 +0,0 @@
1
- import { Deferred, Effect, Option, pipe, Result, Layer } from "effect";
2
- import { effunct, implementing } from "effective-modules";
3
- import { SSHPubkey, CredentialId, SSHKeyPair } from "@/modules/common/crypto/impl";
4
- import { renderCallerTree } from "@/common/render-caller-tree";
5
- import { BunHttpServer } from "@effect/platform-bun";
6
- import { randomUUID } from "node:crypto";
7
- import { agentModules } from "@/modules/ssh-agent";
8
- import { commonModules } from "@/modules/common";
9
- import { SessionError, SetupOutput, StartSessionInput } from "./interface";
10
- import { AgentRpcGroup } from "./interface-rpc";
11
- import { prfFlow, PrfInput } from "./prf-flow";
12
- import { AGENT_PORT_FILE_PATH, CURRENT_VERSION, DEFAULT_SESSION_TIMEOUT_SECONDS } from "@/common/constants";
13
- import { HttpRouter, HttpServer } from "effect/unstable/http";
14
- import { RpcServer, RpcSerialization } from "effect/unstable/rpc";
15
- import { writeFileSync } from "node:fs";
16
- import { using } from "@/common/effective-modules-extensions";
17
- const { OSPlatform, Crypto, KeyMapStore } = commonModules;
18
- const { Session } = agentModules;
19
- const SIGN_REQUESTS_COLLECTION_TIMEOUT_SECONDS = 3;
20
- export class SessionImpl extends implementing(Session).uses(OSPlatform, Crypto, KeyMapStore) {
21
- activeSession = Option.none();
22
- keyCache = new Map();
23
- *abortSession(session, onlyCheckRequestsAccumulated) {
24
- if (session.completed)
25
- return;
26
- let timeout = session.definition.timeoutSeconds;
27
- if (onlyCheckRequestsAccumulated) {
28
- const expected = session.definition.expectedSignRequests.length;
29
- const actual = session.receivedSignRequests.length;
30
- if (expected === actual) {
31
- yield* Effect.log(`All sign requests were received for session ${session.id} within ${SIGN_REQUESTS_COLLECTION_TIMEOUT_SECONDS} seconds`);
32
- return;
33
- }
34
- else {
35
- yield* Effect.log(`After ${SIGN_REQUESTS_COLLECTION_TIMEOUT_SECONDS} seconds only ${actual}/${expected} sign requests were received for session ${session.id}. Aborting`);
36
- timeout = SIGN_REQUESTS_COLLECTION_TIMEOUT_SECONDS;
37
- }
38
- }
39
- else {
40
- yield* Effect.log(`Aborting session ${session.id} after ${timeout} seconds`);
41
- }
42
- if (Option.isSome(this.activeSession) && this.activeSession.value.id === session.id) {
43
- this.activeSession = Option.none();
44
- }
45
- // Fail all the sign requests.
46
- const error = SessionError.cases.SessionTimedOut.make({
47
- seconds: timeout
48
- });
49
- session.completed = true;
50
- for (let i = 0; i < session.definition.expectedSignRequests.length; ++i) {
51
- const maybeReceived = Option.fromNullishOr(session.receivedSignRequests[i]);
52
- if (Option.isNone(maybeReceived))
53
- continue;
54
- const { deferredResponse } = maybeReceived.value;
55
- yield* Deferred.fail(deferredResponse, error);
56
- }
57
- }
58
- *startSession({ expectedCommonAncestorPID, expectedSignRequests, timeoutSeconds, pubkey }) {
59
- if (Option.isSome(this.activeSession)) {
60
- const activeId = this.activeSession.value.id;
61
- yield* Effect.log(`Blocked attempt to start session while ongoing active session ${activeId}`);
62
- return yield* Effect.fail(SessionError.cases.InterruptingSession.make({ id: activeId }));
63
- }
64
- const maybeCredential = yield* pipe(effunct(this.dependencies.KeyMapStore.getCredentialByPubkey)(SSHPubkey.fromAuthorizedKey(pubkey)), Effect.catch(err => Effect.fail(SessionError.cases.InternalError.make({
65
- reason: `Failed to read from key map store: ${err}`
66
- }))));
67
- if (Option.isNone(maybeCredential)) {
68
- return yield* Effect.fail(SessionError.cases.PubkeyNotRegistered.make({
69
- pubkey
70
- }));
71
- }
72
- const id = randomUUID();
73
- const session = {
74
- definition: { expectedCommonAncestorPID, expectedSignRequests, timeoutSeconds, pubkey },
75
- receivedSignRequests: [],
76
- id,
77
- totalReceived: 0,
78
- pubkey,
79
- credentialId: maybeCredential.value,
80
- completed: false
81
- };
82
- this.activeSession = Option.some(session);
83
- const n = expectedSignRequests.length;
84
- yield* Effect.log(`Starting session ${id} for ${new CredentialId(maybeCredential.value).humanReadableName} (${maybeCredential.value}). Expecting ${n} sign request${n === 1 ? '' : 's'}`);
85
- // 2 timeouts.
86
- // - One for just collecting all requests in the session.
87
- Effect.runFork(pipe(effunct(this.abortSession)(session, true), Effect.delay(`${SIGN_REQUESTS_COLLECTION_TIMEOUT_SECONDS} seconds`)));
88
- // - Another which abandons the session if the actual prf flow hasn't happened yet
89
- Effect.runFork(pipe(effunct(this.abortSession)(session, false), Effect.delay(`${timeoutSeconds} seconds`)));
90
- }
91
- isSignRequestInSession(session, signRequest) {
92
- if (session.pubkey !== signRequest.pubkey.authorizedKey) {
93
- return Option.none();
94
- }
95
- const trustedParentPid = session.definition.expectedCommonAncestorPID;
96
- let foundTrustedParentPid = false;
97
- for (let i = 0; i < signRequest.callerTree.length; ++i) {
98
- if (signRequest.callerTree[i].pid === trustedParentPid) {
99
- foundTrustedParentPid = true;
100
- break;
101
- }
102
- }
103
- if (!foundTrustedParentPid) {
104
- return Option.none();
105
- }
106
- for (let i = 0; i < session.definition.expectedSignRequests.length; ++i) {
107
- const { expectedCallerChain } = session.definition.expectedSignRequests[i];
108
- let j = 0;
109
- for (; j < expectedCallerChain.length; ++j) {
110
- const expected = expectedCallerChain[j];
111
- const actual = signRequest.callerTree[j];
112
- if (actual.command !== expected.command ||
113
- Option.getOrNull(actual.directory) !== Option.getOrNull(expected.directory)) {
114
- break;
115
- }
116
- }
117
- if (j === expectedCallerChain.length) {
118
- // Found match
119
- return Option.some({ index: i });
120
- }
121
- }
122
- return Option.none();
123
- }
124
- *cacheKey(keyPair, credentialId, cacheMinutes) {
125
- const pubkey = keyPair.pubkey.authorizedKey;
126
- this.keyCache.set(pubkey, keyPair);
127
- Effect.runFork(pipe(Effect.sync(() => { this.keyCache.delete(pubkey); }), Effect.andThen(Effect.log(`Cache entry revoked for ${pubkey} (${credentialId.humanReadableName}) after ${cacheMinutes} minutes`)), Effect.delay(`${cacheMinutes} minutes`)));
128
- yield* Effect.log(`Cached key ${pubkey} (${credentialId.humanReadableName}) for ${cacheMinutes} minutes`);
129
- }
130
- *resolveAllSignRequests(session) {
131
- // By setting it to none here, we technically do allow parallel sessions, the
132
- // caveat is there's an expectation that all requests for a session are retrieved
133
- // in a short time frame. In the future we may have a backlog of non matching signing requests
134
- // and sessions
135
- this.activeSession = Option.none();
136
- const credential = new CredentialId(session.credentialId);
137
- const cachedKeyPair = this.keyCache.get(session.pubkey);
138
- let prfResult;
139
- if (cachedKeyPair) {
140
- yield* Effect.log(`Using cached key for session ${session.id}`);
141
- prfResult = Result.succeed({ keyPair: cachedKeyPair, credentialId: credential });
142
- }
143
- else {
144
- prfResult = yield* pipe(effunct(prfFlow)(PrfInput.DerivePubkeyForRequests({ session })), Effect.scoped, Effect.provide(this.context), Effect.result);
145
- if (Result.isSuccess(prfResult)) {
146
- const { keyPair } = prfResult.success;
147
- const derivedPubkey = keyPair.pubkey.authorizedKey;
148
- if (derivedPubkey !== session.pubkey) {
149
- yield* Effect.log(`PRF derived pubkey ${derivedPubkey} but session expects ${session.pubkey}`);
150
- prfResult = Result.fail(SessionError.cases.InternalError.make({
151
- reason: `PRF derived pubkey ${derivedPubkey} does not match session pubkey ${session.pubkey}`
152
- }));
153
- }
154
- else if (prfResult.success.cacheMinutes !== undefined) {
155
- yield* this.cacheKey(keyPair, credential, prfResult.success.cacheMinutes);
156
- }
157
- }
158
- }
159
- session.completed = true;
160
- if (Result.isFailure(prfResult)) {
161
- yield* Effect.log(`PRF flow failed for session ${session.id}: ${JSON.stringify(prfResult.failure)}`);
162
- }
163
- else {
164
- yield* Effect.log(`PRF flow succeeded for session ${session.id}`);
165
- }
166
- let totalSigned = 0;
167
- for (const req of session.receivedSignRequests) {
168
- if (Result.isSuccess(prfResult)) {
169
- const { keyPair } = prfResult.success;
170
- const sigResult = yield* Effect.result(Effect.try({
171
- try: () => keyPair.sign(req.signRequest.data),
172
- catch: (e) => SessionError.cases.InternalError.make({ reason: String(e) }),
173
- }));
174
- if (Result.isSuccess(sigResult)) {
175
- totalSigned++;
176
- yield* Effect.log(`(${totalSigned}/${session.receivedSignRequests.length}) Signed ${req.signRequest.data.length} bytes for session ${session.id}`);
177
- yield* Deferred.succeed(req.deferredResponse, sigResult.success);
178
- }
179
- else {
180
- yield* Effect.log(`Signing failed for session ${session.id}: ${JSON.stringify(sigResult.failure)}`);
181
- yield* Deferred.fail(req.deferredResponse, sigResult.failure);
182
- }
183
- }
184
- else {
185
- yield* Deferred.fail(req.deferredResponse, prfResult.failure);
186
- }
187
- }
188
- }
189
- *sign(signRequest) {
190
- const { pubkey, callerTree } = signRequest;
191
- // On the no active session case. We create one.
192
- if (Option.isNone(this.activeSession)) {
193
- yield* Effect.log(`Received sign request when no session exists. Chain:\n${renderCallerTree(callerTree.slice(-3))}`);
194
- yield* this.startSession({
195
- expectedCommonAncestorPID: callerTree[callerTree.length - 1].pid,
196
- expectedSignRequests: [{
197
- expectedCallerChain: callerTree
198
- }],
199
- timeoutSeconds: DEFAULT_SESSION_TIMEOUT_SECONDS,
200
- pubkey: pubkey.authorizedKey
201
- });
202
- }
203
- if (Option.isNone(this.activeSession)) {
204
- return yield* Effect.fail(SessionError.cases.InternalError.make({
205
- reason: "Invariant violation. Active session not set after calling startSession"
206
- }));
207
- }
208
- const session = this.activeSession.value;
209
- const maybeIndex = this.isSignRequestInSession(session, signRequest);
210
- if (Option.isNone(maybeIndex)) {
211
- // TODO: we could instead create a queue of backed-up sign requests and give
212
- // a very short window for each session to collect its requests.
213
- return yield* Effect.fail(SessionError.cases.InterruptingSession.make({
214
- id: session.id
215
- }));
216
- }
217
- const { index } = maybeIndex.value;
218
- const deferredResponse = yield* Deferred.make();
219
- session.receivedSignRequests[index] = {
220
- deferredResponse,
221
- signRequest
222
- };
223
- session.totalReceived++;
224
- const totalExpected = session.definition.expectedSignRequests.length;
225
- yield* Effect.log(`Got matching signature request. ${totalExpected - session.totalReceived} remaining`);
226
- if (session.totalReceived > totalExpected) {
227
- return yield* Effect.fail(SessionError.cases.InternalError.make({
228
- reason: `Only expected to get ${totalExpected} signature requests. Got ${session.totalReceived} instead`
229
- }));
230
- }
231
- if (session.totalReceived === totalExpected) {
232
- yield* Effect.log(`All ${totalExpected} expected signature requests received for session ${session.id}. Initiating passkey verification.`);
233
- yield* this.resolveAllSignRequests(session);
234
- }
235
- return yield* Deferred.await(deferredResponse);
236
- }
237
- *setup(input) {
238
- const { keyPair, credentialId: derivedCredentialId, cacheMinutes } = yield* pipe(effunct(prfFlow)(PrfInput.DerivePubkeyOnly({ pubkey: input.pubkey, credentialId: input.credentialId, username: input.username })), Effect.scoped, Effect.provide(this.context));
239
- const derivedPubkey = keyPair.pubkey.authorizedKey;
240
- if (Option.isSome(input.pubkey) && derivedPubkey !== input.pubkey.value) {
241
- return yield* Effect.fail(SessionError.cases.PubkeyMismatch.make({ expected: input.pubkey.value, derived: derivedPubkey }));
242
- }
243
- yield* Effect.log(`Derived key for ${derivedCredentialId.humanReadableName} (${derivedCredentialId.base58})`);
244
- yield* pipe(effunct(this.dependencies.KeyMapStore.addKey)(keyPair.pubkey, derivedCredentialId.base58), Effect.mapError(reason => SessionError.cases.InternalError.make({ reason })));
245
- if (cacheMinutes !== undefined) {
246
- yield* this.cacheKey(keyPair, derivedCredentialId, cacheMinutes);
247
- }
248
- return { pubkey: derivedPubkey, credentialId: derivedCredentialId.base58 };
249
- }
250
- static makeRpcLayer() {
251
- const writePortFile = Layer.effectDiscard(Effect.gen(function* () {
252
- const server = yield* HttpServer.HttpServer;
253
- if (server.address._tag !== "TcpAddress") {
254
- return Effect.die(`Invariant server address of ${JSON.stringify(server.address)}`);
255
- }
256
- writeFileSync(AGENT_PORT_FILE_PATH, server.address.port.toString());
257
- }));
258
- return pipe(RpcServer.layerHttp({ group: AgentRpcGroup, path: "/rpc", protocol: "http" }), Layer.provideMerge(AgentRpcGroup.toLayer({
259
- GetVersion: () => Effect.succeed({ version: CURRENT_VERSION }),
260
- StartSession: using(Session).startSession,
261
- Setup: using(Session).setup,
262
- })), HttpRouter.serve, Layer.provideMerge(writePortFile), Layer.provideMerge(BunHttpServer.layer({ port: 0 })), Layer.provideMerge(RpcSerialization.layerJson), Layer.provideMerge(this.Layer));
263
- }
264
- }
265
- //# sourceMappingURL=impl.js.map