@private.me/xbind 1.3.5 → 3.0.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 (306) hide show
  1. package/LICENSES.md +212 -0
  2. package/README.md +388 -6
  3. package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1 -1920
  4. package/dist-standalone/_deps/shared/cjs/errors.js +1 -639
  5. package/dist-standalone/_deps/shared/cjs/index.js +1 -496
  6. package/dist-standalone/_deps/shared/cjs/types.js +1 -317
  7. package/dist-standalone/_deps/shared/errors.js +1 -255
  8. package/dist-standalone/_deps/shared/index.js +1 -74
  9. package/dist-standalone/_deps/shared/types.js +1 -90
  10. package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -1
  11. package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -1
  12. package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +1 -1
  13. package/dist-standalone/_deps/ux-helpers/cjs/progress.js +1 -1
  14. package/dist-standalone/_deps/ux-helpers/cjs/search.js +1 -1
  15. package/dist-standalone/_deps/ux-helpers/cjs/types.js +1 -1
  16. package/dist-standalone/_deps/ux-helpers/errors.js +1 -1
  17. package/dist-standalone/_deps/ux-helpers/index.js +1 -1
  18. package/dist-standalone/_deps/ux-helpers/pagination.js +1 -1
  19. package/dist-standalone/_deps/ux-helpers/progress.js +1 -1
  20. package/dist-standalone/_deps/ux-helpers/search.js +1 -1
  21. package/dist-standalone/_deps/xchange/auto-accept.js +1 -1
  22. package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -1
  23. package/dist-standalone/_deps/xchange/cjs/errors.js +1 -1
  24. package/dist-standalone/_deps/xchange/cjs/index.js +1 -1
  25. package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -1
  26. package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -1
  27. package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -1
  28. package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -1
  29. package/dist-standalone/_deps/xchange/errors.js +1 -1
  30. package/dist-standalone/_deps/xchange/index.js +1 -1
  31. package/dist-standalone/_deps/xchange/invite-client.js +1 -1
  32. package/dist-standalone/_deps/xchange/lazy-init.js +1 -1
  33. package/dist-standalone/_deps/xchange/trust-integration.js +1 -1
  34. package/dist-standalone/_deps/xchange/xchange.js +1 -1
  35. package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -1
  36. package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -1
  37. package/dist-standalone/_deps/xregistry/cjs/index.js +1 -1
  38. package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -1
  39. package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -1
  40. package/dist-standalone/_deps/xregistry/cjs/types.js +1 -1
  41. package/dist-standalone/_deps/xregistry/discovery.js +1 -1
  42. package/dist-standalone/_deps/xregistry/errors.js +1 -1
  43. package/dist-standalone/_deps/xregistry/index.js +1 -1
  44. package/dist-standalone/_deps/xregistry/registry.js +1 -1
  45. package/dist-standalone/_deps/xregistry/schema.js +1 -1
  46. package/dist-standalone/_deps/xregistry/types.js +1 -1
  47. package/dist-standalone/agent-call.js +1 -642
  48. package/dist-standalone/agent-sdk.js +1 -328
  49. package/dist-standalone/agent.d.ts +95 -5
  50. package/dist-standalone/agent.js +1 -1545
  51. package/dist-standalone/approval.js +1 -193
  52. package/dist-standalone/async-iterators.d.ts +275 -0
  53. package/dist-standalone/async-iterators.js +1 -0
  54. package/dist-standalone/auth.js +1 -219
  55. package/dist-standalone/auto-accept.js +1 -229
  56. package/dist-standalone/backup-config.js +1 -201
  57. package/dist-standalone/backup.d.ts +114 -0
  58. package/dist-standalone/backup.js +1 -0
  59. package/dist-standalone/batch-operations.d.ts +297 -0
  60. package/dist-standalone/batch-operations.js +1 -0
  61. package/dist-standalone/cancellation.d.ts +301 -0
  62. package/dist-standalone/cancellation.js +1 -0
  63. package/dist-standalone/checkpoint.js +1 -186
  64. package/dist-standalone/circuit-breaker.d.ts +351 -0
  65. package/dist-standalone/circuit-breaker.js +1 -0
  66. package/dist-standalone/cjs/agent-call.js +1 -651
  67. package/dist-standalone/cjs/agent-sdk.js +1 -332
  68. package/dist-standalone/cjs/agent.js +1 -1582
  69. package/dist-standalone/cjs/approval.js +1 -199
  70. package/dist-standalone/cjs/async-iterators.js +1 -0
  71. package/dist-standalone/cjs/auth.js +1 -225
  72. package/dist-standalone/cjs/auto-accept.js +1 -233
  73. package/dist-standalone/cjs/backup-config.js +1 -207
  74. package/dist-standalone/cjs/backup.js +1 -0
  75. package/dist-standalone/cjs/batch-operations.js +1 -0
  76. package/dist-standalone/cjs/cancellation.js +1 -0
  77. package/dist-standalone/cjs/checkpoint.js +1 -193
  78. package/dist-standalone/cjs/circuit-breaker.js +1 -0
  79. package/dist-standalone/cjs/cli/init.js +1 -486
  80. package/dist-standalone/cjs/config-validation.js +1 -0
  81. package/dist-standalone/cjs/connect.js +1 -312
  82. package/dist-standalone/cjs/connection-pool.js +1 -0
  83. package/dist-standalone/cjs/correlation-id.js +1 -339
  84. package/dist-standalone/cjs/crypto-utils.js +1 -0
  85. package/dist-standalone/cjs/debug-mode.js +1 -0
  86. package/dist-standalone/cjs/did-document.js +1 -101
  87. package/dist-standalone/cjs/did-privateme.js +1 -130
  88. package/dist-standalone/cjs/did-web.js +1 -201
  89. package/dist-standalone/cjs/discovery.js +1 -462
  90. package/dist-standalone/cjs/dual-mode.js +1 -251
  91. package/dist-standalone/cjs/email-templates.js +1 -313
  92. package/dist-standalone/cjs/email-transport.js +1 -239
  93. package/dist-standalone/cjs/envelope.js +1 -510
  94. package/dist-standalone/cjs/errors.js +1 -826
  95. package/dist-standalone/cjs/event-emitter.js +1 -0
  96. package/dist-standalone/cjs/gateway-state.js +1 -55
  97. package/dist-standalone/cjs/gateway-transport.js +1 -120
  98. package/dist-standalone/cjs/graceful-degradation.js +1 -0
  99. package/dist-standalone/cjs/guardrails.js +1 -223
  100. package/dist-standalone/cjs/health-check.js +1 -0
  101. package/dist-standalone/cjs/http-compat.js +1 -272
  102. package/dist-standalone/cjs/http-status-map.js +1 -571
  103. package/dist-standalone/cjs/identity.js +1 -540
  104. package/dist-standalone/cjs/index.js +1 -237
  105. package/dist-standalone/cjs/invitation.js +1 -421
  106. package/dist-standalone/cjs/invite.js +1 -328
  107. package/dist-standalone/cjs/key-agreement.js +1 -246
  108. package/dist-standalone/cjs/lazy-init.js +1 -300
  109. package/dist-standalone/cjs/logger.js +1 -0
  110. package/dist-standalone/cjs/mdns-discovery.js +1 -202
  111. package/dist-standalone/cjs/nonce-store.js +1 -66
  112. package/dist-standalone/cjs/pairing-manager.js +1 -223
  113. package/dist-standalone/cjs/plugin-system.js +1 -0
  114. package/dist-standalone/cjs/plugins/logging.js +1 -0
  115. package/dist-standalone/cjs/plugins/metrics.js +1 -0
  116. package/dist-standalone/cjs/plugins/validation.js +1 -0
  117. package/dist-standalone/cjs/policy.js +1 -320
  118. package/dist-standalone/cjs/progress-callbacks.js +1 -0
  119. package/dist-standalone/cjs/redis-nonce-store.js +1 -76
  120. package/dist-standalone/cjs/registry-middleware.js +1 -50
  121. package/dist-standalone/cjs/retry-strategies.js +1 -0
  122. package/dist-standalone/cjs/retry-transport.js +1 -102
  123. package/dist-standalone/cjs/runtime/browser.js +1 -0
  124. package/dist-standalone/cjs/runtime/edge.js +1 -0
  125. package/dist-standalone/cjs/runtime/react-native.js +1 -0
  126. package/dist-standalone/cjs/security-policy.js +1 -245
  127. package/dist-standalone/cjs/serialization.js +1 -0
  128. package/dist-standalone/cjs/split-channel.js +1 -177
  129. package/dist-standalone/cjs/subscription-proof.js +1 -230
  130. package/dist-standalone/cjs/succession.js +1 -148
  131. package/dist-standalone/cjs/timeouts.js +1 -0
  132. package/dist-standalone/cjs/trace-context.js +1 -0
  133. package/dist-standalone/cjs/trace-spans.js +1 -0
  134. package/dist-standalone/cjs/transport.js +1 -63
  135. package/dist-standalone/cjs/trust-registry.js +1 -742
  136. package/dist-standalone/cjs/types/error-response.js +1 -56
  137. package/dist-standalone/cjs/vault-auth.js +1 -0
  138. package/dist-standalone/cjs/vault-store-loader.js +1 -0
  139. package/dist-standalone/cjs/verify.js +1 -25
  140. package/dist-standalone/cjs/version-info.js +1 -0
  141. package/dist-standalone/cjs/xfetch.js +1 -252
  142. package/dist-standalone/cli/init.js +1 -449
  143. package/dist-standalone/cli/setup.js +1 -514
  144. package/dist-standalone/cli/types.js +1 -27
  145. package/dist-standalone/cli/xbind.js +1 -148
  146. package/dist-standalone/config-validation.d.ts +185 -0
  147. package/dist-standalone/config-validation.js +1 -0
  148. package/dist-standalone/connect.js +1 -274
  149. package/dist-standalone/connection-pool.d.ts +251 -0
  150. package/dist-standalone/connection-pool.js +1 -0
  151. package/dist-standalone/correlation-id.js +1 -326
  152. package/dist-standalone/crypto-utils.d.ts +60 -0
  153. package/dist-standalone/crypto-utils.js +1 -0
  154. package/dist-standalone/debug-mode.d.ts +286 -0
  155. package/dist-standalone/debug-mode.js +1 -0
  156. package/dist-standalone/did-document.js +1 -96
  157. package/dist-standalone/did-privateme.js +1 -121
  158. package/dist-standalone/did-web.js +1 -196
  159. package/dist-standalone/discovery.js +1 -458
  160. package/dist-standalone/dual-mode.js +1 -247
  161. package/dist-standalone/email-templates.js +1 -309
  162. package/dist-standalone/email-transport.js +1 -232
  163. package/dist-standalone/envelope.d.ts +29 -1
  164. package/dist-standalone/envelope.js +1 -497
  165. package/dist-standalone/errors.d.ts +10 -0
  166. package/dist-standalone/errors.js +1 -811
  167. package/dist-standalone/event-emitter.d.ts +395 -0
  168. package/dist-standalone/event-emitter.js +1 -0
  169. package/dist-standalone/gateway-state.js +1 -51
  170. package/dist-standalone/gateway-transport.js +1 -116
  171. package/dist-standalone/graceful-degradation.d.ts +246 -0
  172. package/dist-standalone/graceful-degradation.js +1 -0
  173. package/dist-standalone/guardrails.js +1 -216
  174. package/dist-standalone/health-check.d.ts +150 -0
  175. package/dist-standalone/health-check.js +1 -0
  176. package/dist-standalone/http-compat.js +1 -267
  177. package/dist-standalone/http-status-map.js +1 -561
  178. package/dist-standalone/identity.d.ts +64 -1
  179. package/dist-standalone/identity.js +1 -515
  180. package/dist-standalone/index.d.ts +45 -3
  181. package/dist-standalone/index.js +1 -52
  182. package/dist-standalone/invitation.js +1 -415
  183. package/dist-standalone/invite.js +1 -324
  184. package/dist-standalone/key-agreement.d.ts +61 -13
  185. package/dist-standalone/key-agreement.js +1 -236
  186. package/dist-standalone/lazy-init.js +1 -295
  187. package/dist-standalone/logger.d.ts +77 -0
  188. package/dist-standalone/logger.js +1 -0
  189. package/dist-standalone/mdns-discovery.js +1 -195
  190. package/dist-standalone/nonce-store.d.ts +16 -3
  191. package/dist-standalone/nonce-store.js +1 -62
  192. package/dist-standalone/package.json +0 -1
  193. package/dist-standalone/pairing-manager.js +1 -219
  194. package/dist-standalone/plugin-system.d.ts +145 -0
  195. package/dist-standalone/plugin-system.js +1 -0
  196. package/dist-standalone/policy.js +1 -315
  197. package/dist-standalone/progress-callbacks.d.ts +394 -0
  198. package/dist-standalone/progress-callbacks.js +1 -0
  199. package/dist-standalone/redis-nonce-store.js +1 -72
  200. package/dist-standalone/registry-middleware.js +1 -47
  201. package/dist-standalone/retry-strategies.d.ts +382 -0
  202. package/dist-standalone/retry-strategies.js +1 -0
  203. package/dist-standalone/retry-transport.js +1 -98
  204. package/dist-standalone/security-policy.js +1 -239
  205. package/dist-standalone/serialization.d.ts +244 -0
  206. package/dist-standalone/serialization.js +1 -0
  207. package/dist-standalone/split-channel.d.ts +49 -1
  208. package/dist-standalone/split-channel.js +1 -171
  209. package/dist-standalone/subscription-proof.js +1 -224
  210. package/dist-standalone/succession.js +1 -142
  211. package/dist-standalone/timeouts.d.ts +275 -0
  212. package/dist-standalone/timeouts.js +1 -0
  213. package/dist-standalone/trace-context.d.ts +252 -0
  214. package/dist-standalone/trace-context.js +1 -0
  215. package/dist-standalone/trace-spans.d.ts +360 -0
  216. package/dist-standalone/trace-spans.js +1 -0
  217. package/dist-standalone/transport.js +1 -59
  218. package/dist-standalone/trust-registry.d.ts +106 -5
  219. package/dist-standalone/trust-registry.js +1 -702
  220. package/dist-standalone/vault-auth.d.ts +91 -0
  221. package/dist-standalone/vault-auth.js +1 -0
  222. package/dist-standalone/vault-store-loader.d.ts +110 -0
  223. package/dist-standalone/vault-store-loader.js +1 -0
  224. package/dist-standalone/verify.js +1 -16
  225. package/dist-standalone/version-info.d.ts +259 -0
  226. package/dist-standalone/version-info.js +1 -0
  227. package/dist-standalone/xfetch.js +1 -247
  228. package/llms.txt +1 -0
  229. package/package.json +65 -5
  230. package/share1.dat +0 -0
  231. package/dist-standalone/_deps/crypto/base64.d.ts +0 -29
  232. package/dist-standalone/_deps/crypto/base64.js +0 -222
  233. package/dist-standalone/_deps/crypto/cjs/base64.js +0 -665
  234. package/dist-standalone/_deps/crypto/cjs/errors.js +0 -675
  235. package/dist-standalone/_deps/crypto/cjs/hmac.js +0 -473
  236. package/dist-standalone/_deps/crypto/cjs/index.js +0 -852
  237. package/dist-standalone/_deps/crypto/cjs/package.json +0 -1
  238. package/dist-standalone/_deps/crypto/cjs/padding.js +0 -511
  239. package/dist-standalone/_deps/crypto/cjs/share-header.js +0 -372
  240. package/dist-standalone/_deps/crypto/cjs/shares.js +0 -874
  241. package/dist-standalone/_deps/crypto/cjs/tlv.js +0 -1021
  242. package/dist-standalone/_deps/crypto/cjs/uuid.js +0 -443
  243. package/dist-standalone/_deps/crypto/cjs/verify.js +0 -414
  244. package/dist-standalone/_deps/crypto/cjs/xorida.js +0 -923
  245. package/dist-standalone/_deps/crypto/errors.d.ts +0 -51
  246. package/dist-standalone/_deps/crypto/errors.js +0 -199
  247. package/dist-standalone/_deps/crypto/hmac.d.ts +0 -39
  248. package/dist-standalone/_deps/crypto/hmac.js +0 -134
  249. package/dist-standalone/_deps/crypto/index.d.ts +0 -20
  250. package/dist-standalone/_deps/crypto/index.js +0 -145
  251. package/dist-standalone/_deps/crypto/padding.d.ts +0 -19
  252. package/dist-standalone/_deps/crypto/padding.js +0 -159
  253. package/dist-standalone/_deps/crypto/share-header.d.ts +0 -44
  254. package/dist-standalone/_deps/crypto/share-header.js +0 -92
  255. package/dist-standalone/_deps/crypto/shares.d.ts +0 -27
  256. package/dist-standalone/_deps/crypto/shares.js +0 -295
  257. package/dist-standalone/_deps/crypto/tlv.d.ts +0 -26
  258. package/dist-standalone/_deps/crypto/tlv.js +0 -364
  259. package/dist-standalone/_deps/crypto/uuid.d.ts +0 -22
  260. package/dist-standalone/_deps/crypto/uuid.js +0 -136
  261. package/dist-standalone/_deps/crypto/verify.d.ts +0 -15
  262. package/dist-standalone/_deps/crypto/verify.js +0 -71
  263. package/dist-standalone/_deps/crypto/xorida.d.ts +0 -44
  264. package/dist-standalone/_deps/crypto/xorida.js +0 -366
  265. package/dist-standalone/_deps/shared/errors.d.ts.map +0 -1
  266. package/dist-standalone/_deps/shared/errors.js.map +0 -1
  267. package/dist-standalone/_deps/shared/index.d.ts.map +0 -1
  268. package/dist-standalone/_deps/shared/index.js.map +0 -1
  269. package/dist-standalone/_deps/shared/types.d.ts.map +0 -1
  270. package/dist-standalone/_deps/shared/types.js.map +0 -1
  271. package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts.map +0 -1
  272. package/dist-standalone/_deps/ux-helpers/cjs/errors.js.map +0 -1
  273. package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts.map +0 -1
  274. package/dist-standalone/_deps/ux-helpers/cjs/index.js.map +0 -1
  275. package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts.map +0 -1
  276. package/dist-standalone/_deps/ux-helpers/cjs/pagination.js.map +0 -1
  277. package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts.map +0 -1
  278. package/dist-standalone/_deps/ux-helpers/cjs/progress.js.map +0 -1
  279. package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts.map +0 -1
  280. package/dist-standalone/_deps/ux-helpers/cjs/search.js.map +0 -1
  281. package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts.map +0 -1
  282. package/dist-standalone/_deps/ux-helpers/cjs/types.js.map +0 -1
  283. package/dist-standalone/_deps/ux-helpers/errors.d.ts.map +0 -1
  284. package/dist-standalone/_deps/ux-helpers/errors.js.map +0 -1
  285. package/dist-standalone/_deps/ux-helpers/index.d.ts.map +0 -1
  286. package/dist-standalone/_deps/ux-helpers/index.js.map +0 -1
  287. package/dist-standalone/_deps/ux-helpers/pagination.d.ts.map +0 -1
  288. package/dist-standalone/_deps/ux-helpers/pagination.js.map +0 -1
  289. package/dist-standalone/_deps/ux-helpers/progress.d.ts.map +0 -1
  290. package/dist-standalone/_deps/ux-helpers/progress.js.map +0 -1
  291. package/dist-standalone/_deps/ux-helpers/search.d.ts.map +0 -1
  292. package/dist-standalone/_deps/ux-helpers/search.js.map +0 -1
  293. package/dist-standalone/_deps/ux-helpers/types.d.ts.map +0 -1
  294. package/dist-standalone/_deps/ux-helpers/types.js.map +0 -1
  295. package/dist-standalone/_deps/xregistry/discovery.d.ts.map +0 -1
  296. package/dist-standalone/_deps/xregistry/discovery.js.map +0 -1
  297. package/dist-standalone/_deps/xregistry/errors.d.ts.map +0 -1
  298. package/dist-standalone/_deps/xregistry/errors.js.map +0 -1
  299. package/dist-standalone/_deps/xregistry/index.d.ts.map +0 -1
  300. package/dist-standalone/_deps/xregistry/index.js.map +0 -1
  301. package/dist-standalone/_deps/xregistry/registry.d.ts.map +0 -1
  302. package/dist-standalone/_deps/xregistry/registry.js.map +0 -1
  303. package/dist-standalone/_deps/xregistry/schema.d.ts.map +0 -1
  304. package/dist-standalone/_deps/xregistry/schema.js.map +0 -1
  305. package/dist-standalone/_deps/xregistry/types.d.ts.map +0 -1
  306. package/dist-standalone/_deps/xregistry/types.js.map +0 -1
@@ -1,247 +1 @@
1
- /**
2
- * @module xfetch
3
- * Drop-in fetch() replacement with auto-upgrade to xBind
4
- *
5
- * Provides transparent upgrade from HTTP to xBind when both parties support it.
6
- * Falls back to regular HTTP fetch() when xBind is not available.
7
- */
8
- import { Agent } from './agent.js';
9
- import { AgentError, AgentErrorCode } from './agent-call.js';
10
- /**
11
- * Check if endpoint supports xBind
12
- *
13
- * Sends OPTIONS request with xBind capability header.
14
- * Endpoint responds with xBind-Support header if available.
15
- *
16
- * @param url - Target URL
17
- * @returns Capability check result
18
- */
19
- async function checkXBindSupport(url) {
20
- try {
21
- const response = await fetch(url, {
22
- method: 'OPTIONS',
23
- headers: {
24
- 'X-Capability-Check': 'xbind',
25
- },
26
- });
27
- const supported = response.headers.get('X-xBind-Support') === 'true';
28
- if (!supported) {
29
- return { supported: false };
30
- }
31
- return {
32
- supported: true,
33
- endpoint: response.headers.get('X-xBind-Endpoint') || undefined,
34
- peerDID: response.headers.get('X-xBind-DID') || undefined,
35
- version: response.headers.get('X-xBind-Version') || undefined,
36
- };
37
- }
38
- catch (error) {
39
- // Network error or CORS - assume no xBind support
40
- return { supported: false };
41
- }
42
- }
43
- /**
44
- * Send request via xBind transport
45
- *
46
- * @param url - Target URL
47
- * @param capability - xBind capability info
48
- * @param options - Request options
49
- * @param agent - Agent instance
50
- * @returns xBind response
51
- */
52
- async function sendViaXBind(url, capability, options, agent) {
53
- const startTime = Date.now();
54
- // TODO: Integrate with Agent.send() when transport layer is ready
55
- // For now, placeholder that will be completed by transport layer work
56
- throw new AgentError(AgentErrorCode.NETWORK_ERROR, 'xBind transport not yet implemented - requires transport layer (xchange/xfetch integration)', {
57
- url,
58
- peerDID: capability.peerDID,
59
- nextSteps: [
60
- 'Complete Agent.send() integration',
61
- 'Implement xBind message envelope',
62
- 'Add DID-based authentication',
63
- ],
64
- });
65
- }
66
- /**
67
- * Send request via standard HTTP fetch
68
- *
69
- * @param url - Target URL
70
- * @param options - Request options
71
- * @returns HTTP response wrapped as XFetchResponse
72
- */
73
- async function sendViaHTTP(url, options) {
74
- const startTime = Date.now();
75
- // Remove xFetch-specific options before passing to fetch
76
- const { forceXBind, disableXBind, agent, retry, ...fetchOptions } = options;
77
- const response = await fetch(url, fetchOptions);
78
- const latency = Date.now() - startTime;
79
- // Wrap Response with xFetch metadata
80
- return Object.assign(response, {
81
- usedXBind: false,
82
- transport: {
83
- protocol: url.startsWith('https') ? 'https' : 'http',
84
- latency,
85
- },
86
- });
87
- }
88
- /**
89
- * Retry logic with exponential backoff
90
- *
91
- * @param fn - Function to retry
92
- * @param options - Retry configuration
93
- * @returns Result of function
94
- */
95
- async function withRetry(fn, options) {
96
- const maxAttempts = options?.maxAttempts ?? 3;
97
- const initialDelay = options?.initialDelay ?? 1000;
98
- const multiplier = options?.multiplier ?? 2;
99
- let lastError;
100
- let delay = initialDelay;
101
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
102
- try {
103
- return await fn();
104
- }
105
- catch (error) {
106
- lastError = error instanceof Error ? error : new Error(String(error));
107
- // Don't retry on client errors (4xx)
108
- if (error instanceof Response && error.status >= 400 && error.status < 500) {
109
- throw error;
110
- }
111
- if (attempt < maxAttempts) {
112
- await new Promise((resolve) => setTimeout(resolve, delay));
113
- delay *= multiplier;
114
- }
115
- }
116
- }
117
- throw lastError;
118
- }
119
- /**
120
- * xFetch - Drop-in fetch() replacement with auto-upgrade to xBind
121
- *
122
- * @param url - Target URL
123
- * @param options - Request options (extends fetch RequestInit)
124
- * @returns Response with xBind metadata
125
- *
126
- * @example
127
- * ```typescript
128
- * // Basic usage (auto-upgrades to xBind if supported)
129
- * const response = await xfetch('https://api.example.com/data');
130
- * console.log('Used xBind?', response.usedXBind);
131
- * const data = await response.json();
132
- * ```
133
- *
134
- * @example
135
- * ```typescript
136
- * // Force xBind (fail if not supported)
137
- * const response = await xfetch('https://api.example.com/secure', {
138
- * forceXBind: true,
139
- * });
140
- * ```
141
- *
142
- * @example
143
- * ```typescript
144
- * // Disable xBind (HTTP only)
145
- * const response = await xfetch('https://api.example.com/public', {
146
- * disableXBind: true,
147
- * });
148
- * ```
149
- *
150
- * @example
151
- * ```typescript
152
- * // With retry and timeout
153
- * const response = await xfetch('https://api.example.com/data', {
154
- * timeout: 10000,
155
- * retry: {
156
- * maxAttempts: 5,
157
- * initialDelay: 500,
158
- * multiplier: 2,
159
- * },
160
- * });
161
- * ```
162
- */
163
- export async function xfetch(url, options = {}) {
164
- // Validate URL
165
- let parsedURL;
166
- try {
167
- parsedURL = new URL(url);
168
- }
169
- catch (error) {
170
- throw new AgentError(AgentErrorCode.INVALID_PARAMS, `Invalid URL: ${url}`, { url, error });
171
- }
172
- // Only support HTTP(S) protocols
173
- if (!['http:', 'https:'].includes(parsedURL.protocol)) {
174
- throw new AgentError(AgentErrorCode.INVALID_PARAMS, `Unsupported protocol: ${parsedURL.protocol}`, { url, protocol: parsedURL.protocol });
175
- }
176
- // Apply timeout if specified
177
- const timeout = options.timeout ?? 30000;
178
- const controller = new AbortController();
179
- const timeoutId = setTimeout(() => controller.abort(), timeout);
180
- try {
181
- // Merge abort signals if user provided one
182
- const signal = options.signal
183
- ? AbortSignal.any?.([options.signal, controller.signal]) ?? controller.signal
184
- : controller.signal;
185
- const requestOptions = {
186
- ...options,
187
- signal,
188
- };
189
- // If xBind is explicitly disabled, use HTTP directly
190
- if (options.disableXBind) {
191
- return await withRetry(() => sendViaHTTP(url, requestOptions), options.retry);
192
- }
193
- // Check if endpoint supports xBind
194
- const capability = await checkXBindSupport(url);
195
- // If xBind is forced but not supported, fail
196
- if (options.forceXBind && !capability.supported) {
197
- throw new AgentError(AgentErrorCode.NETWORK_ERROR, `xBind required but endpoint does not support it: ${url}`, { url, forceXBind: true, capability });
198
- }
199
- // If xBind is supported, use it
200
- if (capability.supported) {
201
- // Create or use provided agent
202
- const agent = options.agent ?? await Agent.from({ identity: 'ephemeral', identityTTL: 3600000 });
203
- return await withRetry(() => sendViaXBind(url, capability, requestOptions, agent), options.retry);
204
- }
205
- // Fallback to HTTP
206
- return await withRetry(() => sendViaHTTP(url, requestOptions), options.retry);
207
- }
208
- finally {
209
- clearTimeout(timeoutId);
210
- }
211
- }
212
- /**
213
- * Check if a URL supports xBind
214
- *
215
- * Utility function for checking xBind support before making a request.
216
- *
217
- * @param url - URL to check
218
- * @returns True if endpoint supports xBind
219
- *
220
- * @example
221
- * ```typescript
222
- * const supported = await isXBindSupported('https://api.example.com');
223
- * if (supported) {
224
- * console.log('Endpoint supports xBind - request will be upgraded');
225
- * }
226
- * ```
227
- */
228
- export async function isXBindSupported(url) {
229
- const capability = await checkXBindSupport(url);
230
- return capability.supported;
231
- }
232
- /**
233
- * Get xBind capability information for a URL
234
- *
235
- * @param url - URL to check
236
- * @returns Capability information
237
- *
238
- * @example
239
- * ```typescript
240
- * const info = await getXBindCapability('https://api.example.com');
241
- * console.log('Peer DID:', info.peerDID);
242
- * console.log('xBind version:', info.version);
243
- * ```
244
- */
245
- export async function getXBindCapability(url) {
246
- return checkXBindSupport(url);
247
- }
1
+ import{Agent}from"./agent.js";import{AgentError,AgentErrorCode}from"./agent-call.js";async function checkXBindSupport(t){try{const e=await fetch(t,{method:"OPTIONS",headers:{"X-Capability-Check":"xbind"}});return"true"===e.headers.get("X-xBind-Support")?{supported:!0,endpoint:e.headers.get("X-xBind-Endpoint")||void 0,peerDID:e.headers.get("X-xBind-DID")||void 0,version:e.headers.get("X-xBind-Version")||void 0}:{supported:!1}}catch(t){return{supported:!1}}}async function sendViaXBind(t,e,r,o){const n=Date.now();if(!e.peerDID)throw new AgentError(AgentErrorCode.NETWORK_ERROR,"Server supports xBind but did not provide X-xBind-DID header",{url:t,capability:e});const i=e.peerDID,a=e.endpoint||t,s=new Uint8Array(16);crypto.getRandomValues(s);const d=Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join(""),c=`xfetch_${Date.now()}_${d}`,p={correlationId:c,method:r.method||"GET",url:t,headers:r.headers||{},body:r.body?"string"==typeof r.body?r.body:JSON.stringify(r.body):void 0};return new Promise((e,s)=>{const d=setTimeout(()=>{s(new AgentError(AgentErrorCode.TIMEOUT,"xBind request timed out waiting for response",{url:t,correlationId:c,timeout:r.timeout||3e4}))},r.timeout||3e4);(async()=>{try{const u=await o.send({to:i,payload:p,scope:"xfetch",action:"http_request"});if(!u.ok)return clearTimeout(d),void s(new AgentError(AgentErrorCode.NETWORK_ERROR,`Failed to send xBind request: ${u.error}`,{url:t,error:u.error}));const l=`${a}/response/${c}`,g=100,h=(r.timeout||3e4)/g;for(let t=0;t<h;t++){await new Promise(t=>setTimeout(t,g));try{const t=await fetch(l);if(200===t.status){clearTimeout(d);const r=Date.now()-n;return void e(Object.assign(t,{usedXBind:!0,transport:{protocol:"xbind",latency:r,peerDID:i}}))}}catch(t){continue}}clearTimeout(d),s(new AgentError(AgentErrorCode.TIMEOUT,"Response not available after polling",{url:t,correlationId:c,polls:h}))}catch(e){clearTimeout(d),s(e instanceof AgentError?e:new AgentError(AgentErrorCode.NETWORK_ERROR,"xBind request failed",{url:t,error:String(e)}))}})()})}async function sendViaHTTP(t,e){const r=Date.now(),{forceXBind:o,disableXBind:n,agent:i,retry:a,...s}=e,d=await fetch(t,s),c=Date.now()-r;return Object.assign(d,{usedXBind:!1,transport:{protocol:t.startsWith("https")?"https":"http",latency:c}})}async function withRetry(t,e){const r=e?.maxAttempts??3,o=e?.initialDelay??1e3,n=e?.multiplier??2;let i,a=o;for(let e=1;e<=r;e++)try{return await t()}catch(t){if(i=t instanceof Error?t:new Error(String(t)),t instanceof Response&&t.status>=400&&t.status<500)throw t;e<r&&(await new Promise(t=>setTimeout(t,a)),a*=n)}throw i}export async function xfetch(t,e={}){let r;try{r=new URL(t)}catch(e){throw new AgentError(AgentErrorCode.INVALID_PARAMS,`Invalid URL: ${t}`,{url:t,error:e})}if(!["http:","https:"].includes(r.protocol))throw new AgentError(AgentErrorCode.INVALID_PARAMS,`Unsupported protocol: ${r.protocol}`,{url:t,protocol:r.protocol});const o=e.timeout??3e4,n=new AbortController,i=setTimeout(()=>n.abort(),o);try{const r=e.signal?AbortSignal.any?.([e.signal,n.signal])??n.signal:n.signal,o={...e,signal:r};if(e.disableXBind)return await withRetry(()=>sendViaHTTP(t,o),e.retry);const i=await checkXBindSupport(t);if(e.forceXBind&&!i.supported)throw new AgentError(AgentErrorCode.NETWORK_ERROR,`xBind required but endpoint does not support it: ${t}`,{url:t,forceXBind:!0,capability:i});if(i.supported){const r=e.agent??await Agent.from({identity:"ephemeral",identityTTL:36e5});return await withRetry(()=>sendViaXBind(t,i,o,r),e.retry)}return await withRetry(()=>sendViaHTTP(t,o),e.retry)}finally{clearTimeout(i)}}export async function isXBindSupported(t){return(await checkXBindSupport(t)).supported}export async function getXBindCapability(t){return checkXBindSupport(t)}
package/llms.txt CHANGED
@@ -798,3 +798,4 @@ All IP protection measures active (obfuscation + Full Control + xGhost pattern).
798
798
  - White paper: https://private.me/docs/xbind.html
799
799
  - npm: https://npmjs.com/package/@private.me/xbind
800
800
  - GitHub: https://github.com/xail-io/xail/tree/main/packages/xbind
801
+ docs/api/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@private.me/xbind",
3
- "version": "1.3.5",
3
+ "version": "3.0.0",
4
4
  "description": "Identity-based M2M authentication (Contains encryption - export restrictions apply)",
5
5
  "license": "Proprietary",
6
6
  "author": "Private.Me Contributors",
@@ -27,8 +27,51 @@
27
27
  "default": "./dist-standalone/cjs/index.js"
28
28
  }
29
29
  },
30
- "./_deps/*": "./dist-standalone/_deps/*/index.js"
30
+ "./agent": {
31
+ "types": "./dist-standalone/agent.d.ts",
32
+ "import": "./dist-standalone/agent.js",
33
+ "require": "./dist-standalone/cjs/agent.js"
34
+ },
35
+ "./identity": {
36
+ "types": "./dist-standalone/identity.d.ts",
37
+ "import": "./dist-standalone/identity.js",
38
+ "require": "./dist-standalone/cjs/identity.js"
39
+ },
40
+ "./trust-registry": {
41
+ "types": "./dist-standalone/trust-registry.d.ts",
42
+ "import": "./dist-standalone/trust-registry.js",
43
+ "require": "./dist-standalone/cjs/trust-registry.js"
44
+ },
45
+ "./key-agreement": {
46
+ "types": "./dist-standalone/key-agreement.d.ts",
47
+ "import": "./dist-standalone/key-agreement.js",
48
+ "require": "./dist-standalone/cjs/key-agreement.js"
49
+ },
50
+ "./errors": {
51
+ "types": "./dist-standalone/errors.d.ts",
52
+ "import": "./dist-standalone/errors.js",
53
+ "require": "./dist-standalone/cjs/errors.js"
54
+ },
55
+ "./runtime/edge": {
56
+ "types": "./dist-standalone/runtime/edge.d.ts",
57
+ "import": "./dist-standalone/runtime/edge.js",
58
+ "require": "./dist-standalone/cjs/runtime/edge.js"
59
+ },
60
+ "./_deps/*": "./dist-standalone/_deps/*/index.js",
61
+ "./package.json": "./package.json"
31
62
  },
63
+ "sideEffects": false,
64
+ "packageManager": "pnpm@10.29.2",
65
+ "size-limit": [
66
+ {
67
+ "path": "dist-standalone/index.js",
68
+ "limit": "350 KB",
69
+ "ignore": [
70
+ "dist-standalone/_deps/**"
71
+ ],
72
+ "comment": "Reduced from 500KB after crypto package excluded (Vault Store architecture)"
73
+ }
74
+ ],
32
75
  "bin": {
33
76
  "xbind": "./dist-standalone/cli/xbind.js",
34
77
  "xbind-init": "./dist-standalone/cli/init.js",
@@ -40,24 +83,38 @@
40
83
  "dist-standalone/cli/**",
41
84
  "dist-standalone/cjs/**",
42
85
  "dist-standalone/_deps/**",
86
+ "!dist-standalone/_deps/crypto/**",
43
87
  "dist-standalone/package.json",
88
+ "dist-standalone/vault-store-loader.js",
89
+ "dist-standalone/vault-store-loader.d.ts",
44
90
  "share1.dat",
45
91
  "README.md",
46
92
  "LICENSE.md",
93
+ "LICENSES.md",
47
94
  "AGENTS.md",
48
95
  "llms.txt"
49
96
  ],
50
97
  "scripts": {
51
- "build": "pnpm clean:xbind && node scripts/build-with-deps.mjs && node generate-shares.mjs",
98
+ "build": "pnpm clean:xbind && node scripts/build-with-deps.mjs && node generate-shares.mjs && pnpm build:optimize",
99
+ "build:optimize": "find dist-standalone -name '*.map' -type f -delete && node scripts/minify.mjs",
52
100
  "clean:xbind": "rm -rf dist dist-standalone .turbo",
53
101
  "obfuscate": "echo 'Obfuscation skipped - core IP already protected in crypto package'",
54
102
  "lint": "eslint src/",
55
103
  "typecheck": "tsc --noEmit",
56
104
  "test": "vitest run",
57
105
  "test:coverage": "vitest run --coverage",
106
+ "docs": "typedoc",
107
+ "docs:watch": "typedoc --watch",
108
+ "docs:json": "typedoc --json docs/api-reference/documentation.json",
109
+ "audit": "bash ../../scripts/audit-dependencies.sh $(pwd)",
110
+ "audit:fix": "npm audit fix",
111
+ "license-check": "bash ../../scripts/check-crypto-licenses.sh $(pwd)",
112
+ "sbom:generate": "bash ../../scripts/generate-sbom.sh -f both .",
113
+ "sbom:validate": "bash ../../scripts/validate-sbom.sh .",
58
114
  "clean": "rm -rf dist dist-standalone .turbo",
115
+ "size-check": "bash ../../scripts/validate-package-size.sh $(pwd) --max-size-kb=3000",
59
116
  "prepublish-check": "bash scripts/prepublish-check.sh",
60
- "prepublishOnly": "node -e \"const pkg=require('./package.json');if(pkg.license!=='Proprietary'){console.error('❌ package.json license must be: Proprietary');process.exit(1)}\" && bash ../../scripts/gold-automation.sh $(pwd) && bash ../../scripts/hooks/prepublish-crypto-check.sh && bash ../../scripts/hooks/prepublish-tarball-validation.sh $(pwd)"
117
+ "prepublishOnly": "node -e \"const pkg=require('./package.json');if(pkg.license!=='Proprietary'){console.error('❌ package.json license must be: Proprietary');process.exit(1)}\" && bash ../../scripts/validate-semver.sh $(pwd) --strict && bash ../../scripts/audit-dependencies.sh $(pwd) && bash ../../scripts/generate-sbom.sh -f both . && bash ../../scripts/validate-package-size.sh $(pwd) --max-size-kb=3000 && bash ../../scripts/gold-automation.sh $(pwd) && bash ../../scripts/hooks/prepublish-crypto-check.sh && bash ../../scripts/hooks/prepublish-tarball-validation.sh $(pwd) && bash ../../scripts/validate-vault-store.sh $(pwd)"
61
118
  },
62
119
  "dependencies": {
63
120
  "@private.me/xbind": "^1.3.0",
@@ -68,7 +125,10 @@
68
125
  "comment_vendored": "mldsa-wasm@0.0.4 vendored in dist-standalone/_deps/ (L3 fix)",
69
126
  "devDependencies": {
70
127
  "@types/node": "^25.6.0",
71
- "@types/nodemailer": "8.0.0"
128
+ "@types/nodemailer": "8.0.0",
129
+ "glob": "^13.0.6",
130
+ "terser": "^5.48.0",
131
+ "typedoc": "^0.28.19"
72
132
  },
73
133
  "imports": {
74
134
  "#deps/shared": "./dist-standalone/_deps/shared/index.js",
package/share1.dat CHANGED
Binary file
@@ -1,29 +0,0 @@
1
- /**
2
- * Encode bytes to standard Base64 (RFC 4648).
3
- *
4
- * @param data - Bytes to encode
5
- * @returns Base64-encoded string with padding
6
- */
7
- export declare function toBase64(data: Uint8Array): string;
8
- /**
9
- * Decode standard Base64 string to bytes.
10
- *
11
- * @param str - Base64-encoded string
12
- * @returns Decoded bytes
13
- */
14
- export declare function fromBase64(str: string): Uint8Array;
15
- /**
16
- * Encode bytes to Base64url (RFC 4648 Section 5).
17
- * Uses URL-safe characters (-_ instead of +/) and no padding.
18
- *
19
- * @param data - Bytes to encode
20
- * @returns Base64url-encoded string without padding
21
- */
22
- export declare function toBase64Url(data: Uint8Array): string;
23
- /**
24
- * Decode Base64url string to bytes.
25
- *
26
- * @param str - Base64url-encoded string
27
- * @returns Decoded bytes
28
- */
29
- export declare function fromBase64Url(str: string): Uint8Array;
@@ -1,222 +0,0 @@
1
- function a0_0x1a56(_0x117fe5, _0x2d1341) {
2
- _0x117fe5 = _0x117fe5 - 0x137;
3
- const _0x1feac7 = a0_0x1fea();
4
- let _0x1a56c9 = _0x1feac7[_0x117fe5];
5
- if (a0_0x1a56['MLtNOO'] === undefined) {
6
- var _0x12ed9d = function (_0x52f94e) {
7
- const _0x285d42 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';
8
- let _0x220f0f = '', _0x126d3b = '';
9
- for (let _0x72b6b7 = 0x0, _0x4d0738, _0x3e902c, _0x1471ac = 0x0; _0x3e902c = _0x52f94e['charAt'](_0x1471ac++); ~_0x3e902c && (_0x4d0738 = _0x72b6b7 % 0x4 ? _0x4d0738 * 0x40 + _0x3e902c : _0x3e902c, _0x72b6b7++ % 0x4) ? _0x220f0f += String['fromCharCode'](0xff & _0x4d0738 >> (-0x2 * _0x72b6b7 & 0x6)) : 0x0) {
10
- _0x3e902c = _0x285d42['indexOf'](_0x3e902c);
11
- }
12
- for (let _0x3503b2 = 0x0, _0x5ec380 = _0x220f0f['length']; _0x3503b2 < _0x5ec380; _0x3503b2++) {
13
- _0x126d3b += '%' + ('00' + _0x220f0f['charCodeAt'](_0x3503b2)['toString'](0x10))['slice'](-0x2);
14
- }
15
- return decodeURIComponent(_0x126d3b);
16
- };
17
- a0_0x1a56['HKytOx'] = _0x12ed9d, a0_0x1a56['FOcusJ'] = {}, a0_0x1a56['MLtNOO'] = !![];
18
- }
19
- const _0x7c7f86 = _0x1feac7[0x0], _0x46e4cd = _0x117fe5 + _0x7c7f86, _0x536556 = a0_0x1a56['FOcusJ'][_0x46e4cd];
20
- return !_0x536556 ? (_0x1a56c9 = a0_0x1a56['HKytOx'](_0x1a56c9), a0_0x1a56['FOcusJ'][_0x46e4cd] = _0x1a56c9) : _0x1a56c9 = _0x536556, _0x1a56c9;
21
- }
22
- function a0_0x1fea() {
23
- const _0x10e439 = [
24
- 'nJf4rMLLtNa',
25
- 'mZiXmdjtug5hwvC',
26
- 'z0LOuKi',
27
- 'v256tvG',
28
- 't3Dprg0',
29
- 'mtC1mNjlEhv5DG',
30
- 'swzXrLC',
31
- 'ndy1mdeYBfzxugT1',
32
- 'C1fvywO',
33
- 'wKLsDvq',
34
- 'C1r0r0m',
35
- 'sMHPB2e',
36
- 'CvLewe4',
37
- 'mtmXmJmWmZvIqwHZCxK',
38
- 'BgvUz3rO',
39
- 'z0Hdsg4',
40
- 'ugPgv1e',
41
- 'r2LcAuS',
42
- 'sgvIshi',
43
- 'qujdrevgr0HjsKTmtu5puffsu1rvvLDywvPHyMnKzwzNAgLQA2XTBM9WCxjZDhv2D3H5EJaXmJm0nty3odKRlW',
44
- 'mtbWqvjqENq',
45
- 'mJaXnJmYoe5mCMHeAq',
46
- 's3fhBLO',
47
- 'AvD4A3q',
48
- 'sg5AzeS',
49
- 'u09MB2G',
50
- 't1HVuLG',
51
- 'rxLOvKq',
52
- 'mtbOywPIseS',
53
- 'mtq4nJuXmdriDxP2Eu0',
54
- 'zMXVB3i',
55
- 'C2v0',
56
- 'CMvWBgfJzq',
57
- 'mZGZnJi3mLngr0zOqG',
58
- 'z2v0',
59
- 'ndK4ndjzBw1TENO'
60
- ];
61
- a0_0x1fea = function () {
62
- return _0x10e439;
63
- };
64
- return a0_0x1fea();
65
- }
66
- const a0_0x120b36 = a0_0x1a56;
67
- (function (_0x210da6, _0x4aa025) {
68
- const a0_0x8226aa = {
69
- _0x5e7a46: 0x147,
70
- _0x132b9b: 0x14f,
71
- _0x4842b6: 0x139,
72
- _0x1f3a87: 0x149,
73
- _0x429453: 0x141,
74
- _0x1367da: 0x155,
75
- _0x5329d6: 0x138
76
- }, _0x2ca543 = a0_0x1a56, _0x506e18 = _0x210da6();
77
- while (!![]) {
78
- try {
79
- const _0x2cb49d = -parseInt(_0x2ca543(0x148)) / 0x1 * (parseInt(_0x2ca543(a0_0x8226aa._0x5e7a46)) / 0x2) + parseInt(_0x2ca543(a0_0x8226aa._0x132b9b)) / 0x3 + -parseInt(_0x2ca543(a0_0x8226aa._0x4842b6)) / 0x4 * (-parseInt(_0x2ca543(0x140)) / 0x5) + parseInt(_0x2ca543(0x14d)) / 0x6 * (parseInt(_0x2ca543(a0_0x8226aa._0x1f3a87)) / 0x7) + -parseInt(_0x2ca543(a0_0x8226aa._0x429453)) / 0x8 + parseInt(_0x2ca543(a0_0x8226aa._0x1367da)) / 0x9 * (parseInt(_0x2ca543(a0_0x8226aa._0x5329d6)) / 0xa) + parseInt(_0x2ca543(0x145)) / 0xb;
80
- if (_0x2cb49d === _0x4aa025)
81
- break;
82
- else
83
- _0x506e18['push'](_0x506e18['shift']());
84
- } catch (_0x2e7a6b) {
85
- _0x506e18['push'](_0x506e18['shift']());
86
- }
87
- }
88
- }(a0_0x1fea, 0xe340c));
89
- const CHARS = a0_0x120b36(0x137), URL_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
90
- export function toBase64(_0x1fb314) {
91
- return encode(_0x1fb314, CHARS, !![]);
92
- }
93
- export function fromBase64(_0x1e6caa) {
94
- const _0x44599e = a0_0x1a56, _0xe56bee = {
95
- 'HnZdK': function (_0x3c1faf, _0x492e04, _0x4cc08a) {
96
- return _0x3c1faf(_0x492e04, _0x4cc08a);
97
- }
98
- };
99
- return _0xe56bee[_0x44599e(0x13c)](decode, _0x1e6caa, CHARS);
100
- }
101
- export function toBase64Url(_0x4655d5) {
102
- return encode(_0x4655d5, URL_CHARS, ![]);
103
- }
104
- export function fromBase64Url(_0x5f0a55) {
105
- const _0x413957 = a0_0x1a56, _0x4e499f = {
106
- 'OXoRX': function (_0x1ccb30, _0x3f2cea, _0x1789f6) {
107
- return _0x1ccb30(_0x3f2cea, _0x1789f6);
108
- }
109
- };
110
- return _0x4e499f[_0x413957(0x13e)](decode, _0x5f0a55, URL_CHARS);
111
- }
112
- function encode(_0x4e5d82, _0x5e5dba, _0x522ba5) {
113
- const a0_0x43f2f3 = {
114
- _0x4370a2: 0x13b,
115
- _0x456b7a: 0x156,
116
- _0x47f355: 0x158
117
- }, _0x54ac56 = a0_0x1a56, _0x536e1f = {
118
- 'iWxkt': function (_0x319a25, _0xe45684) {
119
- return _0x319a25 < _0xe45684;
120
- },
121
- 'qYDXN': function (_0xa1982, _0x5f0ad9) {
122
- return _0xa1982 + _0x5f0ad9;
123
- },
124
- 'SOfoh': function (_0x418270, _0x293b0c) {
125
- return _0x418270 | _0x293b0c;
126
- },
127
- 'Jmvyp': function (_0x5e46d, _0x26f2c0) {
128
- return _0x5e46d << _0x26f2c0;
129
- },
130
- 'EyhVD': function (_0x28821d, _0x570435) {
131
- return _0x28821d & _0x570435;
132
- },
133
- 'oxoab': function (_0x16e5c7, _0x7b08db) {
134
- return _0x16e5c7 % _0x7b08db;
135
- },
136
- 'ZIRuT': function (_0x2292b7, _0x3e8dd8) {
137
- return _0x2292b7 === _0x3e8dd8;
138
- },
139
- 'PjFWQ': function (_0x4b6ed0, _0x26cc76) {
140
- return _0x4b6ed0 === _0x26cc76;
141
- }
142
- };
143
- let _0x12c5c4 = '';
144
- for (let _0x4587e3 = 0x0; _0x536e1f[_0x54ac56(a0_0x43f2f3._0x4370a2)](_0x4587e3, _0x4e5d82[_0x54ac56(a0_0x43f2f3._0x456b7a)]); _0x4587e3 += 0x3) {
145
- const _0x330004 = _0x4e5d82[_0x4587e3], _0x29f7a7 = _0x536e1f[_0x54ac56(0x154)](_0x4587e3, 0x1) < _0x4e5d82[_0x54ac56(a0_0x43f2f3._0x456b7a)] ? _0x4e5d82[_0x4587e3 + 0x1] : 0x0, _0x1a4eb5 = _0x4587e3 + 0x2 < _0x4e5d82[_0x54ac56(a0_0x43f2f3._0x456b7a)] ? _0x4e5d82[_0x4587e3 + 0x2] : 0x0;
146
- _0x12c5c4 += _0x5e5dba[_0x330004 >> 0x2], _0x12c5c4 += _0x5e5dba[(_0x330004 & 0x3) << 0x4 | _0x29f7a7 >> 0x4], _0x4587e3 + 0x1 < _0x4e5d82[_0x54ac56(0x156)] && (_0x12c5c4 += _0x5e5dba[_0x536e1f[_0x54ac56(0x13d)](_0x536e1f['Jmvyp'](_0x29f7a7 & 0xf, 0x2), _0x1a4eb5 >> 0x6)]), _0x4587e3 + 0x2 < _0x4e5d82[_0x54ac56(a0_0x43f2f3._0x456b7a)] && (_0x12c5c4 += _0x5e5dba[_0x536e1f[_0x54ac56(0x13f)](_0x1a4eb5, 0x3f)]);
147
- }
148
- if (_0x522ba5) {
149
- const _0x180ba1 = _0x536e1f['oxoab'](_0x4e5d82[_0x54ac56(0x156)], 0x3);
150
- if (_0x536e1f[_0x54ac56(0x151)](_0x180ba1, 0x1))
151
- _0x12c5c4 += '==';
152
- else {
153
- if (_0x536e1f[_0x54ac56(a0_0x43f2f3._0x47f355)](_0x180ba1, 0x2))
154
- _0x12c5c4 += '=';
155
- }
156
- }
157
- return _0x12c5c4;
158
- }
159
- function buildLookup(_0x4b5260) {
160
- const _0x4d3d7e = a0_0x1a56, _0xbaf997 = new Map();
161
- for (let _0x40d789 = 0x0; _0x40d789 < _0x4b5260[_0x4d3d7e(0x156)]; _0x40d789++) {
162
- _0xbaf997[_0x4d3d7e(0x143)](_0x4b5260[_0x40d789], _0x40d789);
163
- }
164
- return _0xbaf997;
165
- }
166
- const STD_LOOKUP = buildLookup(CHARS), URL_LOOKUP = buildLookup(URL_CHARS);
167
- function decode(_0x530b35, _0x5712f3) {
168
- const a0_0x346104 = {
169
- _0x1d0c6a: 0x146,
170
- _0x28ad0f: 0x157,
171
- _0x51aede: 0x146,
172
- _0x3c4488: 0x153,
173
- _0x3a6441: 0x14b,
174
- _0x17787e: 0x156,
175
- _0x3a4226: 0x150,
176
- _0x41a44d: 0x15a,
177
- _0x564a2b: 0x14e
178
- }, _0x3da2ed = a0_0x1a56, _0x4a79b9 = {
179
- 'sTtGC': function (_0x4bf897, _0x5e0f4a) {
180
- return _0x4bf897 === _0x5e0f4a;
181
- },
182
- 'gIhRB': function (_0x4e17b8, _0x2b1f61) {
183
- return _0x4e17b8 * _0x2b1f61;
184
- },
185
- 'Jhioa': function (_0x2502d2, _0x3c409d) {
186
- return _0x2502d2 < _0x3c409d;
187
- },
188
- 'KqGnZ': function (_0x2ecf46, _0x49abf6) {
189
- return _0x2ecf46 + _0x49abf6;
190
- },
191
- 'gHCHn': function (_0x9039ae, _0x2d4434) {
192
- return _0x9039ae + _0x2d4434;
193
- },
194
- 'OwODm': function (_0x4fcffa, _0x2fe23f) {
195
- return _0x4fcffa < _0x2fe23f;
196
- },
197
- 'DOIiV': function (_0x4669e0, _0x3f2048) {
198
- return _0x4669e0 | _0x3f2048;
199
- },
200
- 'GiBiK': function (_0x54aa2c, _0x215098) {
201
- return _0x54aa2c << _0x215098;
202
- },
203
- 'WnzMX': function (_0xb5a354, _0x42f674) {
204
- return _0xb5a354 + _0x42f674;
205
- },
206
- 'sQUaj': function (_0x3f50ee, _0x244d7) {
207
- return _0x3f50ee >> _0x244d7;
208
- },
209
- 'HebHr': function (_0x5af300, _0x173576) {
210
- return _0x5af300 << _0x173576;
211
- },
212
- 'IfqFW': function (_0xeceb64, _0x1dba8c) {
213
- return _0xeceb64 & _0x1dba8c;
214
- }
215
- }, _0x40e8ae = _0x4a79b9[_0x3da2ed(0x152)](_0x5712f3, CHARS) ? STD_LOOKUP : URL_LOOKUP, _0x2951c0 = _0x530b35['replace'](/\s/g, ''), _0x5b19bf = _0x2951c0[_0x3da2ed(0x144)](/=+$/, ''), _0x3c1971 = Math[_0x3da2ed(0x142)](_0x4a79b9[_0x3da2ed(0x14a)](_0x5b19bf[_0x3da2ed(0x156)], 0x3) / 0x4), _0x2623d4 = new Uint8Array(_0x3c1971);
216
- let _0x853ef9 = 0x0;
217
- for (let _0x36c788 = 0x0; _0x4a79b9['Jhioa'](_0x36c788, _0x5b19bf['length']); _0x36c788 += 0x4) {
218
- const _0xe90d5b = _0x40e8ae[_0x3da2ed(0x146)](_0x5b19bf[_0x36c788]) ?? 0x0, _0x2fd19a = _0x40e8ae[_0x3da2ed(a0_0x346104._0x1d0c6a)](_0x5b19bf[_0x4a79b9[_0x3da2ed(0x13a)](_0x36c788, 0x1)]) ?? 0x0, _0x2c0a49 = _0x4a79b9[_0x3da2ed(a0_0x346104._0x28ad0f)](_0x36c788, 0x2) < _0x5b19bf[_0x3da2ed(0x156)] ? _0x40e8ae['get'](_0x5b19bf[_0x36c788 + 0x2]) ?? 0x0 : 0x0, _0x3dd321 = _0x4a79b9[_0x3da2ed(0x14c)](_0x36c788 + 0x3, _0x5b19bf['length']) ? _0x40e8ae[_0x3da2ed(a0_0x346104._0x51aede)](_0x5b19bf[_0x4a79b9[_0x3da2ed(a0_0x346104._0x28ad0f)](_0x36c788, 0x3)]) ?? 0x0 : 0x0;
219
- _0x2623d4[_0x853ef9++] = _0x4a79b9['DOIiV'](_0x4a79b9[_0x3da2ed(0x159)](_0xe90d5b, 0x2), _0x2fd19a >> 0x4), _0x4a79b9[_0x3da2ed(a0_0x346104._0x3c4488)](_0x4a79b9[_0x3da2ed(a0_0x346104._0x3a6441)](_0x36c788, 0x2), _0x5b19bf[_0x3da2ed(a0_0x346104._0x17787e)]) && (_0x2623d4[_0x853ef9++] = (_0x2fd19a & 0xf) << 0x4 | _0x4a79b9[_0x3da2ed(a0_0x346104._0x3a4226)](_0x2c0a49, 0x2)), _0x4a79b9['gHCHn'](_0x36c788, 0x3) < _0x5b19bf[_0x3da2ed(a0_0x346104._0x17787e)] && (_0x2623d4[_0x853ef9++] = _0x4a79b9['DOIiV'](_0x4a79b9[_0x3da2ed(a0_0x346104._0x41a44d)](_0x4a79b9[_0x3da2ed(a0_0x346104._0x564a2b)](_0x2c0a49, 0x3), 0x6), _0x3dd321));
220
- }
221
- return _0x2623d4;
222
- }