@private.me/xbind 1.3.0 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSES.md +212 -0
- package/README.md +388 -6
- package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1 -1920
- package/dist-standalone/_deps/shared/cjs/errors.js +1 -275
- package/dist-standalone/_deps/shared/cjs/index.js +1 -138
- package/dist-standalone/_deps/shared/cjs/types.js +1 -90
- package/dist-standalone/_deps/shared/errors.js +1 -262
- package/dist-standalone/_deps/shared/index.js +1 -77
- package/dist-standalone/_deps/shared/types.js +1 -91
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/search.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/types.js +1 -1
- package/dist-standalone/_deps/ux-helpers/errors.js +1 -1
- package/dist-standalone/_deps/ux-helpers/index.js +1 -1
- package/dist-standalone/_deps/ux-helpers/pagination.js +1 -1
- package/dist-standalone/_deps/ux-helpers/progress.js +1 -1
- package/dist-standalone/_deps/ux-helpers/search.js +1 -1
- package/dist-standalone/_deps/xchange/auto-accept.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/errors.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/index.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -1
- package/dist-standalone/_deps/xchange/errors.js +1 -1
- package/dist-standalone/_deps/xchange/index.js +1 -1
- package/dist-standalone/_deps/xchange/invite-client.js +1 -1
- package/dist-standalone/_deps/xchange/lazy-init.js +1 -1
- package/dist-standalone/_deps/xchange/trust-integration.js +1 -1
- package/dist-standalone/_deps/xchange/xchange.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/index.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/types.js +1 -1
- package/dist-standalone/_deps/xregistry/discovery.js +1 -1
- package/dist-standalone/_deps/xregistry/errors.js +1 -1
- package/dist-standalone/_deps/xregistry/index.js +1 -1
- package/dist-standalone/_deps/xregistry/registry.js +1 -1
- package/dist-standalone/_deps/xregistry/schema.js +1 -1
- package/dist-standalone/_deps/xregistry/types.js +1 -1
- package/dist-standalone/agent-call.js +1 -642
- package/dist-standalone/agent-sdk.js +1 -328
- package/dist-standalone/agent.d.ts +95 -5
- package/dist-standalone/agent.js +1 -1545
- package/dist-standalone/approval.js +1 -193
- package/dist-standalone/async-iterators.d.ts +275 -0
- package/dist-standalone/async-iterators.js +1 -0
- package/dist-standalone/auth.js +1 -219
- package/dist-standalone/auto-accept.js +1 -229
- package/dist-standalone/backup-config.js +1 -201
- package/dist-standalone/backup.d.ts +114 -0
- package/dist-standalone/backup.js +1 -0
- package/dist-standalone/batch-operations.d.ts +297 -0
- package/dist-standalone/batch-operations.js +1 -0
- package/dist-standalone/cancellation.d.ts +301 -0
- package/dist-standalone/cancellation.js +1 -0
- package/dist-standalone/checkpoint.js +1 -186
- package/dist-standalone/circuit-breaker.d.ts +351 -0
- package/dist-standalone/circuit-breaker.js +1 -0
- package/dist-standalone/cjs/agent-call.js +1 -651
- package/dist-standalone/cjs/agent-sdk.js +1 -332
- package/dist-standalone/cjs/agent.js +1 -1582
- package/dist-standalone/cjs/approval.js +1 -199
- package/dist-standalone/cjs/async-iterators.js +1 -0
- package/dist-standalone/cjs/auth.js +1 -225
- package/dist-standalone/cjs/auto-accept.js +1 -233
- package/dist-standalone/cjs/backup-config.js +1 -207
- package/dist-standalone/cjs/backup.js +1 -0
- package/dist-standalone/cjs/batch-operations.js +1 -0
- package/dist-standalone/cjs/cancellation.js +1 -0
- package/dist-standalone/cjs/checkpoint.js +1 -193
- package/dist-standalone/cjs/circuit-breaker.js +1 -0
- package/dist-standalone/cjs/cli/init.js +1 -486
- package/dist-standalone/cjs/config-validation.js +1 -0
- package/dist-standalone/cjs/connect.js +1 -312
- package/dist-standalone/cjs/connection-pool.js +1 -0
- package/dist-standalone/cjs/correlation-id.js +1 -339
- package/dist-standalone/cjs/crypto-utils.js +1 -0
- package/dist-standalone/cjs/debug-mode.js +1 -0
- package/dist-standalone/cjs/did-document.js +1 -101
- package/dist-standalone/cjs/did-privateme.js +1 -130
- package/dist-standalone/cjs/did-web.js +1 -201
- package/dist-standalone/cjs/discovery.js +1 -462
- package/dist-standalone/cjs/dual-mode.js +1 -251
- package/dist-standalone/cjs/email-templates.js +1 -313
- package/dist-standalone/cjs/email-transport.js +1 -239
- package/dist-standalone/cjs/envelope.js +1 -510
- package/dist-standalone/cjs/errors.js +1 -826
- package/dist-standalone/cjs/event-emitter.js +1 -0
- package/dist-standalone/cjs/gateway-state.js +1 -55
- package/dist-standalone/cjs/gateway-transport.js +1 -120
- package/dist-standalone/cjs/graceful-degradation.js +1 -0
- package/dist-standalone/cjs/guardrails.js +1 -223
- package/dist-standalone/cjs/health-check.js +1 -0
- package/dist-standalone/cjs/http-compat.js +1 -272
- package/dist-standalone/cjs/http-status-map.js +1 -571
- package/dist-standalone/cjs/identity.js +1 -541
- package/dist-standalone/cjs/index.js +1 -237
- package/dist-standalone/cjs/invitation.js +1 -421
- package/dist-standalone/cjs/invite.js +1 -328
- package/dist-standalone/cjs/key-agreement.js +1 -246
- package/dist-standalone/cjs/lazy-init.js +1 -300
- package/dist-standalone/cjs/logger.js +1 -0
- package/dist-standalone/cjs/mdns-discovery.js +1 -202
- package/dist-standalone/cjs/nonce-store.js +1 -66
- package/dist-standalone/cjs/pairing-manager.js +1 -223
- package/dist-standalone/cjs/plugin-system.js +1 -0
- package/dist-standalone/cjs/plugins/logging.js +1 -0
- package/dist-standalone/cjs/plugins/metrics.js +1 -0
- package/dist-standalone/cjs/plugins/validation.js +1 -0
- package/dist-standalone/cjs/policy.js +1 -320
- package/dist-standalone/cjs/progress-callbacks.js +1 -0
- package/dist-standalone/cjs/redis-nonce-store.js +1 -76
- package/dist-standalone/cjs/registry-middleware.js +1 -50
- package/dist-standalone/cjs/retry-strategies.js +1 -0
- package/dist-standalone/cjs/retry-transport.js +1 -102
- package/dist-standalone/cjs/runtime/browser.js +1 -0
- package/dist-standalone/cjs/runtime/edge.js +1 -0
- package/dist-standalone/cjs/runtime/react-native.js +1 -0
- package/dist-standalone/cjs/security-policy.js +1 -245
- package/dist-standalone/cjs/serialization.js +1 -0
- package/dist-standalone/cjs/split-channel.js +1 -177
- package/dist-standalone/cjs/subscription-proof.js +1 -230
- package/dist-standalone/cjs/succession.js +1 -148
- package/dist-standalone/cjs/timeouts.js +1 -0
- package/dist-standalone/cjs/trace-context.js +1 -0
- package/dist-standalone/cjs/trace-spans.js +1 -0
- package/dist-standalone/cjs/transport.js +1 -63
- package/dist-standalone/cjs/trust-registry.js +1 -742
- package/dist-standalone/cjs/types/error-response.js +1 -56
- package/dist-standalone/cjs/vault-auth.js +1 -0
- package/dist-standalone/cjs/vault-store-loader.js +1 -0
- package/dist-standalone/cjs/verify.js +1 -25
- package/dist-standalone/cjs/version-info.js +1 -0
- package/dist-standalone/cjs/xfetch.js +1 -252
- package/dist-standalone/cli/init.js +1 -449
- package/dist-standalone/cli/setup.js +1 -514
- package/dist-standalone/cli/types.js +1 -27
- package/dist-standalone/cli/xbind.js +1 -148
- package/dist-standalone/config-validation.d.ts +185 -0
- package/dist-standalone/config-validation.js +1 -0
- package/dist-standalone/connect.js +1 -274
- package/dist-standalone/connection-pool.d.ts +251 -0
- package/dist-standalone/connection-pool.js +1 -0
- package/dist-standalone/correlation-id.js +1 -326
- package/dist-standalone/crypto-utils.d.ts +60 -0
- package/dist-standalone/crypto-utils.js +1 -0
- package/dist-standalone/debug-mode.d.ts +286 -0
- package/dist-standalone/debug-mode.js +1 -0
- package/dist-standalone/did-document.js +1 -96
- package/dist-standalone/did-privateme.js +1 -121
- package/dist-standalone/did-web.js +1 -196
- package/dist-standalone/discovery.js +1 -458
- package/dist-standalone/dual-mode.js +1 -247
- package/dist-standalone/email-templates.js +1 -309
- package/dist-standalone/email-transport.js +1 -232
- package/dist-standalone/envelope.d.ts +29 -1
- package/dist-standalone/envelope.js +1 -497
- package/dist-standalone/errors.d.ts +10 -0
- package/dist-standalone/errors.js +1 -811
- package/dist-standalone/event-emitter.d.ts +395 -0
- package/dist-standalone/event-emitter.js +1 -0
- package/dist-standalone/gateway-state.js +1 -51
- package/dist-standalone/gateway-transport.js +1 -116
- package/dist-standalone/graceful-degradation.d.ts +246 -0
- package/dist-standalone/graceful-degradation.js +1 -0
- package/dist-standalone/guardrails.js +1 -216
- package/dist-standalone/health-check.d.ts +150 -0
- package/dist-standalone/health-check.js +1 -0
- package/dist-standalone/http-compat.js +1 -267
- package/dist-standalone/http-status-map.js +1 -561
- package/dist-standalone/identity.d.ts +64 -1
- package/dist-standalone/identity.js +1 -516
- package/dist-standalone/index.d.ts +45 -3
- package/dist-standalone/index.js +1 -52
- package/dist-standalone/invitation.js +1 -415
- package/dist-standalone/invite.js +1 -324
- package/dist-standalone/key-agreement.d.ts +61 -13
- package/dist-standalone/key-agreement.js +1 -236
- package/dist-standalone/lazy-init.js +1 -295
- package/dist-standalone/logger.d.ts +77 -0
- package/dist-standalone/logger.js +1 -0
- package/dist-standalone/mdns-discovery.js +1 -195
- package/dist-standalone/nonce-store.d.ts +16 -3
- package/dist-standalone/nonce-store.js +1 -62
- package/dist-standalone/package.json +0 -1
- package/dist-standalone/pairing-manager.js +1 -219
- package/dist-standalone/plugin-system.d.ts +145 -0
- package/dist-standalone/plugin-system.js +1 -0
- package/dist-standalone/policy.js +1 -315
- package/dist-standalone/progress-callbacks.d.ts +394 -0
- package/dist-standalone/progress-callbacks.js +1 -0
- package/dist-standalone/redis-nonce-store.js +1 -72
- package/dist-standalone/registry-middleware.js +1 -47
- package/dist-standalone/retry-strategies.d.ts +382 -0
- package/dist-standalone/retry-strategies.js +1 -0
- package/dist-standalone/retry-transport.js +1 -98
- package/dist-standalone/security-policy.js +1 -239
- package/dist-standalone/serialization.d.ts +244 -0
- package/dist-standalone/serialization.js +1 -0
- package/dist-standalone/split-channel.d.ts +49 -1
- package/dist-standalone/split-channel.js +1 -171
- package/dist-standalone/subscription-proof.js +1 -224
- package/dist-standalone/succession.js +1 -142
- package/dist-standalone/timeouts.d.ts +275 -0
- package/dist-standalone/timeouts.js +1 -0
- package/dist-standalone/trace-context.d.ts +252 -0
- package/dist-standalone/trace-context.js +1 -0
- package/dist-standalone/trace-spans.d.ts +360 -0
- package/dist-standalone/trace-spans.js +1 -0
- package/dist-standalone/transport.js +1 -59
- package/dist-standalone/trust-registry.d.ts +106 -5
- package/dist-standalone/trust-registry.js +1 -702
- package/dist-standalone/vault-auth.d.ts +91 -0
- package/dist-standalone/vault-auth.js +1 -0
- package/dist-standalone/vault-store-loader.d.ts +110 -0
- package/dist-standalone/vault-store-loader.js +1 -0
- package/dist-standalone/verify.js +1 -16
- package/dist-standalone/version-info.d.ts +259 -0
- package/dist-standalone/version-info.js +1 -0
- package/dist-standalone/xfetch.js +1 -247
- package/llms.txt +1 -0
- package/package.json +66 -5
- package/share1.dat +0 -0
- package/dist-standalone/_deps/crypto/base64.d.ts +0 -29
- package/dist-standalone/_deps/crypto/base64.js +0 -209
- package/dist-standalone/_deps/crypto/cjs/base64.js +0 -103
- package/dist-standalone/_deps/crypto/cjs/errors.js +0 -119
- package/dist-standalone/_deps/crypto/cjs/hmac.js +0 -71
- package/dist-standalone/_deps/crypto/cjs/index.js +0 -86
- package/dist-standalone/_deps/crypto/cjs/padding.js +0 -57
- package/dist-standalone/_deps/crypto/cjs/share-header.js +0 -68
- package/dist-standalone/_deps/crypto/cjs/shares.js +0 -152
- package/dist-standalone/_deps/crypto/cjs/tlv.js +0 -199
- package/dist-standalone/_deps/crypto/cjs/uuid.js +0 -61
- package/dist-standalone/_deps/crypto/cjs/verify.js +0 -24
- package/dist-standalone/_deps/crypto/cjs/xorida.js +0 -221
- package/dist-standalone/_deps/crypto/errors.d.ts +0 -51
- package/dist-standalone/_deps/crypto/errors.js +0 -109
- package/dist-standalone/_deps/crypto/hmac.d.ts +0 -39
- package/dist-standalone/_deps/crypto/hmac.js +0 -66
- package/dist-standalone/_deps/crypto/index.d.ts +0 -20
- package/dist-standalone/_deps/crypto/index.js +0 -45
- package/dist-standalone/_deps/crypto/padding.d.ts +0 -19
- package/dist-standalone/_deps/crypto/padding.js +0 -53
- package/dist-standalone/_deps/crypto/share-header.d.ts +0 -44
- package/dist-standalone/_deps/crypto/share-header.js +0 -63
- package/dist-standalone/_deps/crypto/shares.d.ts +0 -27
- package/dist-standalone/_deps/crypto/shares.js +0 -148
- package/dist-standalone/_deps/crypto/tlv.d.ts +0 -26
- package/dist-standalone/_deps/crypto/tlv.js +0 -195
- package/dist-standalone/_deps/crypto/uuid.d.ts +0 -22
- package/dist-standalone/_deps/crypto/uuid.js +0 -56
- package/dist-standalone/_deps/crypto/verify.d.ts +0 -15
- package/dist-standalone/_deps/crypto/verify.js +0 -15
- package/dist-standalone/_deps/crypto/xorida.d.ts +0 -44
- package/dist-standalone/_deps/crypto/xorida.js +0 -215
- package/dist-standalone/_deps/shared/errors.d.ts.map +0 -1
- package/dist-standalone/_deps/shared/errors.js.map +0 -1
- package/dist-standalone/_deps/shared/index.d.ts.map +0 -1
- package/dist-standalone/_deps/shared/index.js.map +0 -1
- package/dist-standalone/_deps/shared/types.d.ts.map +0 -1
- package/dist-standalone/_deps/shared/types.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/index.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/search.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/types.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/errors.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/errors.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/index.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/index.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/pagination.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/pagination.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/progress.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/progress.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/search.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/search.js.map +0 -1
- package/dist-standalone/_deps/ux-helpers/types.d.ts.map +0 -1
- package/dist-standalone/_deps/ux-helpers/types.js.map +0 -1
- package/dist-standalone/_deps/xregistry/discovery.d.ts.map +0 -1
- package/dist-standalone/_deps/xregistry/discovery.js.map +0 -1
- package/dist-standalone/_deps/xregistry/errors.d.ts.map +0 -1
- package/dist-standalone/_deps/xregistry/errors.js.map +0 -1
- package/dist-standalone/_deps/xregistry/index.d.ts.map +0 -1
- package/dist-standalone/_deps/xregistry/index.js.map +0 -1
- package/dist-standalone/_deps/xregistry/registry.d.ts.map +0 -1
- package/dist-standalone/_deps/xregistry/registry.js.map +0 -1
- package/dist-standalone/_deps/xregistry/schema.d.ts.map +0 -1
- package/dist-standalone/_deps/xregistry/schema.js.map +0 -1
- package/dist-standalone/_deps/xregistry/types.d.ts.map +0 -1
- package/dist-standalone/_deps/xregistry/types.js.map +0 -1
|
@@ -1,251 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @module dual-mode
|
|
4
|
-
* Dual-mode adapter: XBind + API key fallback.
|
|
5
|
-
*
|
|
6
|
-
* Enables zero-downtime migration:
|
|
7
|
-
* - Try XBind first
|
|
8
|
-
* - Fall back to API key if unavailable
|
|
9
|
-
* - Track usage metrics
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const adapter = new DualModeAdapter({
|
|
14
|
-
* xbind: xbindAgent,
|
|
15
|
-
* fallback: {
|
|
16
|
-
* type: 'api-key',
|
|
17
|
-
* key: process.env.API_KEY,
|
|
18
|
-
* url: 'https://api.example.com',
|
|
19
|
-
* },
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // Will try xBind, fall back to API key
|
|
23
|
-
* const result = await adapter.call('createCharge', { amount: 100 });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.DualModeAdapter = exports.DualModeErrorCode = void 0;
|
|
28
|
-
const shared_1 = require("../_deps/shared/index.js");
|
|
29
|
-
/**
|
|
30
|
-
* Dual-mode error codes.
|
|
31
|
-
*/
|
|
32
|
-
var DualModeErrorCode;
|
|
33
|
-
(function (DualModeErrorCode) {
|
|
34
|
-
DualModeErrorCode["BOTH_FAILED"] = "DUAL_MODE_BOTH_FAILED";
|
|
35
|
-
DualModeErrorCode["XBIND_FAILED"] = "DUAL_MODE_XBIND_FAILED";
|
|
36
|
-
DualModeErrorCode["FALLBACK_FAILED"] = "DUAL_MODE_FALLBACK_FAILED";
|
|
37
|
-
DualModeErrorCode["INVALID_CONFIG"] = "DUAL_MODE_INVALID_CONFIG";
|
|
38
|
-
})(DualModeErrorCode || (exports.DualModeErrorCode = DualModeErrorCode = {}));
|
|
39
|
-
/**
|
|
40
|
-
* Dual-mode adapter.
|
|
41
|
-
*
|
|
42
|
-
* Tries XBind first, falls back to API key if unavailable.
|
|
43
|
-
*/
|
|
44
|
-
class DualModeAdapter {
|
|
45
|
-
xbind;
|
|
46
|
-
fallback;
|
|
47
|
-
metrics;
|
|
48
|
-
/**
|
|
49
|
-
* Create dual-mode adapter.
|
|
50
|
-
*
|
|
51
|
-
* @param options - Configuration
|
|
52
|
-
* @param options.xbind - xBind agent (optional, can be added later)
|
|
53
|
-
* @param options.fallback - Fallback config (optional, can be removed later)
|
|
54
|
-
*/
|
|
55
|
-
constructor(options = {}) {
|
|
56
|
-
this.xbind = options.xbind || null;
|
|
57
|
-
this.fallback = options.fallback || null;
|
|
58
|
-
this.metrics = {
|
|
59
|
-
totalCalls: 0,
|
|
60
|
-
xbindCalls: 0,
|
|
61
|
-
fallbackCalls: 0,
|
|
62
|
-
xbindPercentage: 0,
|
|
63
|
-
lastCall: new Date().toISOString(),
|
|
64
|
-
lastCallMethod: 'xbind',
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Set xBind agent (for gradual rollout).
|
|
69
|
-
*
|
|
70
|
-
* @param agent - xBind agent
|
|
71
|
-
*/
|
|
72
|
-
setXBind(agent) {
|
|
73
|
-
this.xbind = agent;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Remove fallback (complete migration).
|
|
77
|
-
*/
|
|
78
|
-
removeFallback() {
|
|
79
|
-
this.fallback = null;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Call an action (tries XBind first, falls back if needed).
|
|
83
|
-
*
|
|
84
|
-
* @param action - Action name
|
|
85
|
-
* @param params - Action parameters
|
|
86
|
-
* @returns Result or error
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* const result = await adapter.call('createCharge', {
|
|
91
|
-
* amount: 100,
|
|
92
|
-
* currency: 'USD',
|
|
93
|
-
* });
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
async call(action, params = {}) {
|
|
97
|
-
this.metrics.totalCalls++;
|
|
98
|
-
// Try XBind first
|
|
99
|
-
if (this.xbind) {
|
|
100
|
-
try {
|
|
101
|
-
const result = await this.callViaXBind(action, params);
|
|
102
|
-
if (result.ok) {
|
|
103
|
-
this.metrics.xbindCalls++;
|
|
104
|
-
this.updateMetrics('xbind');
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
// XBind failed, try fallback if available
|
|
108
|
-
if (this.fallback) {
|
|
109
|
-
const fallbackResult = await this.callViaFallback(action, params);
|
|
110
|
-
if (fallbackResult.ok) {
|
|
111
|
-
this.metrics.fallbackCalls++;
|
|
112
|
-
this.updateMetrics('fallback');
|
|
113
|
-
return fallbackResult;
|
|
114
|
-
}
|
|
115
|
-
// Both failed
|
|
116
|
-
return (0, shared_1.err)({
|
|
117
|
-
code: DualModeErrorCode.BOTH_FAILED,
|
|
118
|
-
message: 'Both XBind and fallback failed',
|
|
119
|
-
xbindError: result.error,
|
|
120
|
-
fallbackError: fallbackResult.error,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
// No fallback, return XBind error
|
|
124
|
-
return (0, shared_1.err)({
|
|
125
|
-
code: DualModeErrorCode.XBIND_FAILED,
|
|
126
|
-
message: 'XBind failed and no fallback configured',
|
|
127
|
-
xbindError: result.error,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
// XBind exception, try fallback
|
|
132
|
-
if (this.fallback) {
|
|
133
|
-
const fallbackResult = await this.callViaFallback(action, params);
|
|
134
|
-
if (fallbackResult.ok) {
|
|
135
|
-
this.metrics.fallbackCalls++;
|
|
136
|
-
this.updateMetrics('fallback');
|
|
137
|
-
return fallbackResult;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return (0, shared_1.err)({
|
|
141
|
-
code: DualModeErrorCode.XBIND_FAILED,
|
|
142
|
-
message: error instanceof Error ? error.message : 'XBind exception',
|
|
143
|
-
xbindError: error,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// No xBind, try fallback only
|
|
148
|
-
if (this.fallback) {
|
|
149
|
-
const result = await this.callViaFallback(action, params);
|
|
150
|
-
if (result.ok) {
|
|
151
|
-
this.metrics.fallbackCalls++;
|
|
152
|
-
this.updateMetrics('fallback');
|
|
153
|
-
return result;
|
|
154
|
-
}
|
|
155
|
-
return (0, shared_1.err)({
|
|
156
|
-
code: DualModeErrorCode.FALLBACK_FAILED,
|
|
157
|
-
message: 'Fallback failed',
|
|
158
|
-
fallbackError: result.error,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
// Neither XBind nor fallback configured
|
|
162
|
-
return (0, shared_1.err)({
|
|
163
|
-
code: DualModeErrorCode.INVALID_CONFIG,
|
|
164
|
-
message: 'Neither XBind nor fallback configured',
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Get usage metrics.
|
|
169
|
-
*
|
|
170
|
-
* @returns Current metrics
|
|
171
|
-
*/
|
|
172
|
-
getMetrics() {
|
|
173
|
-
return { ...this.metrics };
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Reset metrics.
|
|
177
|
-
*/
|
|
178
|
-
resetMetrics() {
|
|
179
|
-
this.metrics = {
|
|
180
|
-
totalCalls: 0,
|
|
181
|
-
xbindCalls: 0,
|
|
182
|
-
fallbackCalls: 0,
|
|
183
|
-
xbindPercentage: 0,
|
|
184
|
-
lastCall: new Date().toISOString(),
|
|
185
|
-
lastCallMethod: 'xbind',
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Call via XBind.
|
|
190
|
-
*/
|
|
191
|
-
async callViaXBind(action, params) {
|
|
192
|
-
if (!this.xbind) {
|
|
193
|
-
return (0, shared_1.err)({ message: 'XBind not configured' });
|
|
194
|
-
}
|
|
195
|
-
try {
|
|
196
|
-
const result = await this.xbind.send({
|
|
197
|
-
to: this.xbind.did, // TODO: Get target DID from connection
|
|
198
|
-
payload: { action, params },
|
|
199
|
-
scope: action,
|
|
200
|
-
});
|
|
201
|
-
return result;
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
return (0, shared_1.err)({ message: error instanceof Error ? error.message : 'Unknown error' });
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Call via fallback (API key, OAuth, etc.).
|
|
209
|
-
*/
|
|
210
|
-
async callViaFallback(action, params) {
|
|
211
|
-
if (!this.fallback) {
|
|
212
|
-
return (0, shared_1.err)({ message: 'Fallback not configured' });
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
const url = `${this.fallback.url}/${action}`;
|
|
216
|
-
const method = this.fallback.method || 'POST';
|
|
217
|
-
const headers = {
|
|
218
|
-
'Content-Type': 'application/json',
|
|
219
|
-
...this.fallback.headers,
|
|
220
|
-
};
|
|
221
|
-
// Add auth header based on type
|
|
222
|
-
if (this.fallback.type === 'api-key' && this.fallback.key) {
|
|
223
|
-
headers['Authorization'] = `Bearer ${this.fallback.key}`;
|
|
224
|
-
}
|
|
225
|
-
const response = await fetch(url, {
|
|
226
|
-
method,
|
|
227
|
-
headers,
|
|
228
|
-
body: method !== 'GET' ? JSON.stringify(params) : undefined,
|
|
229
|
-
});
|
|
230
|
-
if (!response.ok) {
|
|
231
|
-
return (0, shared_1.err)({ message: `HTTP ${response.status}` });
|
|
232
|
-
}
|
|
233
|
-
const data = await response.json();
|
|
234
|
-
return (0, shared_1.ok)(data);
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
return (0, shared_1.err)({ message: error instanceof Error ? error.message : 'Network error' });
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Update metrics after a call.
|
|
242
|
-
*/
|
|
243
|
-
updateMetrics(method) {
|
|
244
|
-
this.metrics.lastCall = new Date().toISOString();
|
|
245
|
-
this.metrics.lastCallMethod = method;
|
|
246
|
-
this.metrics.xbindPercentage = this.metrics.totalCalls > 0
|
|
247
|
-
? (this.metrics.xbindCalls / this.metrics.totalCalls) * 100
|
|
248
|
-
: 0;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.DualModeAdapter = DualModeAdapter;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DualModeAdapter=exports.DualModeErrorCode=void 0;const shared_1=require("../_deps/shared/index.js");var DualModeErrorCode;!function(a){a.BOTH_FAILED="DUAL_MODE_BOTH_FAILED",a.XBIND_FAILED="DUAL_MODE_XBIND_FAILED",a.FALLBACK_FAILED="DUAL_MODE_FALLBACK_FAILED",a.INVALID_CONFIG="DUAL_MODE_INVALID_CONFIG"}(DualModeErrorCode||(exports.DualModeErrorCode=DualModeErrorCode={}));class DualModeAdapter{xbind;fallback;metrics;constructor(a={}){this.xbind=a.xbind||null,this.fallback=a.fallback||null,this.metrics={totalCalls:0,xbindCalls:0,fallbackCalls:0,xbindPercentage:0,lastCall:(new Date).toISOString(),lastCallMethod:"xbind"}}setXBind(a){this.xbind=a}removeFallback(){this.fallback=null}async call(a,e={}){if(this.metrics.totalCalls++,this.xbind)try{const r=await this.callViaXBind(a,e);if(r.ok)return this.metrics.xbindCalls++,this.updateMetrics("xbind"),r;if(this.fallback){const t=await this.callViaFallback(a,e);return t.ok?(this.metrics.fallbackCalls++,this.updateMetrics("fallback"),t):(0,shared_1.err)({code:DualModeErrorCode.BOTH_FAILED,message:"Both XBind and fallback failed",xbindError:r.error,fallbackError:t.error})}return(0,shared_1.err)({code:DualModeErrorCode.XBIND_FAILED,message:"XBind failed and no fallback configured",xbindError:r.error})}catch(r){if(this.fallback){const r=await this.callViaFallback(a,e);if(r.ok)return this.metrics.fallbackCalls++,this.updateMetrics("fallback"),r}return(0,shared_1.err)({code:DualModeErrorCode.XBIND_FAILED,message:r instanceof Error?r.message:"XBind exception",xbindError:r})}if(this.fallback){const r=await this.callViaFallback(a,e);return r.ok?(this.metrics.fallbackCalls++,this.updateMetrics("fallback"),r):(0,shared_1.err)({code:DualModeErrorCode.FALLBACK_FAILED,message:"Fallback failed",fallbackError:r.error})}return(0,shared_1.err)({code:DualModeErrorCode.INVALID_CONFIG,message:"Neither XBind nor fallback configured"})}getMetrics(){return{...this.metrics}}resetMetrics(){this.metrics={totalCalls:0,xbindCalls:0,fallbackCalls:0,xbindPercentage:0,lastCall:(new Date).toISOString(),lastCallMethod:"xbind"}}async callViaXBind(a,e){if(!this.xbind)return(0,shared_1.err)({message:"XBind not configured"});try{return await this.xbind.send({to:this.xbind.did,payload:{action:a,params:e},scope:a})}catch(a){return(0,shared_1.err)({message:a instanceof Error?a.message:"Unknown error"})}}async callViaFallback(a,e){if(!this.fallback)return(0,shared_1.err)({message:"Fallback not configured"});try{const r=`${this.fallback.url}/${a}`,t=this.fallback.method||"POST",l={"Content-Type":"application/json",...this.fallback.headers};"api-key"===this.fallback.type&&this.fallback.key&&(l.Authorization=`Bearer ${this.fallback.key}`);const s=await fetch(r,{method:t,headers:l,body:"GET"!==t?JSON.stringify(e):void 0});if(!s.ok)return(0,shared_1.err)({message:`HTTP ${s.status}`});const i=await s.json();return(0,shared_1.ok)(i)}catch(a){return(0,shared_1.err)({message:a instanceof Error?a.message:"Network error"})}}updateMetrics(a){this.metrics.lastCall=(new Date).toISOString(),this.metrics.lastCallMethod=a,this.metrics.xbindPercentage=this.metrics.totalCalls>0?this.metrics.xbindCalls/this.metrics.totalCalls*100:0}}exports.DualModeAdapter=DualModeAdapter;
|
|
@@ -1,313 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @module email-templates
|
|
4
|
-
* Branded HTML email templates for xBind invitations.
|
|
5
|
-
*
|
|
6
|
-
* Uses Private.Me brand guidelines:
|
|
7
|
-
* - Colors: Green #10B981, Ink #1F2937, White #FFFFFF
|
|
8
|
-
* - Fonts: Outfit (display), DM Mono (code/DIDs)
|
|
9
|
-
* - Logo: Privacy Mask SVG
|
|
10
|
-
* - Tagline: "APIs have keys. ACIs have identity."
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.renderInviteEmail = renderInviteEmail;
|
|
14
|
-
exports.renderAcceptedEmail = renderAcceptedEmail;
|
|
15
|
-
/**
|
|
16
|
-
* Privacy Mask logo SVG (complete with bottom z-shape).
|
|
17
|
-
* Per brand guidelines section 02.5.
|
|
18
|
-
*/
|
|
19
|
-
const PRIVACY_MASK_SVG = `
|
|
20
|
-
<svg width="32" height="32" viewBox="0 0 300 600" xmlns="http://www.w3.org/2000/svg">
|
|
21
|
-
<defs>
|
|
22
|
-
<linearGradient id="maskGradient" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
23
|
-
<stop offset="0%" style="stop-color:#10B981;stop-opacity:1" />
|
|
24
|
-
<stop offset="100%" style="stop-color:#059669;stop-opacity:1" />
|
|
25
|
-
</linearGradient>
|
|
26
|
-
</defs>
|
|
27
|
-
<!-- Top curve -->
|
|
28
|
-
<path d="M50 100 Q150 50 250 100 L250 300 Q150 350 50 300 Z" fill="url(#maskGradient)"/>
|
|
29
|
-
<!-- Eye holes -->
|
|
30
|
-
<ellipse cx="100" cy="180" rx="25" ry="35" fill="#FFFFFF"/>
|
|
31
|
-
<ellipse cx="200" cy="180" rx="25" ry="35" fill="#FFFFFF"/>
|
|
32
|
-
<!-- Bottom z-shape -->
|
|
33
|
-
<path d="M270 575 L230 575 L270 525 L230 525" stroke="#10B981" stroke-width="8" fill="none"/>
|
|
34
|
-
</svg>
|
|
35
|
-
`;
|
|
36
|
-
/**
|
|
37
|
-
* Render invitation email with branded template.
|
|
38
|
-
*
|
|
39
|
-
* @param data - Template data
|
|
40
|
-
* @returns Rendered HTML email
|
|
41
|
-
*/
|
|
42
|
-
function renderInviteEmail(data) {
|
|
43
|
-
return `
|
|
44
|
-
<!DOCTYPE html>
|
|
45
|
-
<html lang="en">
|
|
46
|
-
<head>
|
|
47
|
-
<meta charset="UTF-8">
|
|
48
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
49
|
-
<title>${escapeHtml(data.agentName)} wants to connect</title>
|
|
50
|
-
<style>
|
|
51
|
-
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=DM+Mono:wght@400;500&display=swap');
|
|
52
|
-
|
|
53
|
-
body {
|
|
54
|
-
margin: 0;
|
|
55
|
-
padding: 0;
|
|
56
|
-
font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
57
|
-
background-color: #F9FAFB;
|
|
58
|
-
color: #1F2937;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.container {
|
|
62
|
-
max-width: 600px;
|
|
63
|
-
margin: 0 auto;
|
|
64
|
-
background-color: #FFFFFF;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.header {
|
|
68
|
-
background: linear-gradient(135deg, #10B981 0%, #059669 100%);
|
|
69
|
-
padding: 40px 24px;
|
|
70
|
-
text-align: center;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.logo {
|
|
74
|
-
margin-bottom: 16px;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.header h1 {
|
|
78
|
-
margin: 0;
|
|
79
|
-
font-size: 24px;
|
|
80
|
-
font-weight: 700;
|
|
81
|
-
color: #FFFFFF;
|
|
82
|
-
line-height: 1.3;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.content {
|
|
86
|
-
padding: 40px 24px;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.content p {
|
|
90
|
-
margin: 0 0 16px 0;
|
|
91
|
-
font-size: 16px;
|
|
92
|
-
line-height: 1.6;
|
|
93
|
-
color: #374151;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.agent-info {
|
|
97
|
-
background-color: #F3F4F6;
|
|
98
|
-
border-left: 4px solid #10B981;
|
|
99
|
-
padding: 16px;
|
|
100
|
-
margin: 24px 0;
|
|
101
|
-
border-radius: 4px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.agent-name {
|
|
105
|
-
font-size: 18px;
|
|
106
|
-
font-weight: 600;
|
|
107
|
-
color: #1F2937;
|
|
108
|
-
margin-bottom: 8px;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.did {
|
|
112
|
-
font-family: 'DM Mono', 'Courier New', monospace;
|
|
113
|
-
font-size: 12px;
|
|
114
|
-
color: #6B7280;
|
|
115
|
-
word-break: break-all;
|
|
116
|
-
line-height: 1.5;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.message-box {
|
|
120
|
-
background-color: #F9FAFB;
|
|
121
|
-
border: 1px solid #E5E7EB;
|
|
122
|
-
padding: 16px;
|
|
123
|
-
margin: 24px 0;
|
|
124
|
-
border-radius: 8px;
|
|
125
|
-
font-style: italic;
|
|
126
|
-
color: #4B5563;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.cta-container {
|
|
130
|
-
text-align: center;
|
|
131
|
-
margin: 32px 0;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.cta-button {
|
|
135
|
-
display: inline-block;
|
|
136
|
-
background-color: #10B981;
|
|
137
|
-
color: #FFFFFF;
|
|
138
|
-
text-decoration: none;
|
|
139
|
-
padding: 14px 32px;
|
|
140
|
-
border-radius: 8px;
|
|
141
|
-
font-size: 16px;
|
|
142
|
-
font-weight: 600;
|
|
143
|
-
transition: background-color 0.2s;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.cta-button:hover {
|
|
147
|
-
background-color: #059669;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.footer {
|
|
151
|
-
padding: 24px;
|
|
152
|
-
text-align: center;
|
|
153
|
-
border-top: 1px solid #E5E7EB;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.tagline {
|
|
157
|
-
font-size: 14px;
|
|
158
|
-
color: #6B7280;
|
|
159
|
-
margin-bottom: 12px;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.brand {
|
|
163
|
-
font-size: 12px;
|
|
164
|
-
color: #9CA3AF;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.security-note {
|
|
168
|
-
font-size: 13px;
|
|
169
|
-
color: #6B7280;
|
|
170
|
-
margin-top: 24px;
|
|
171
|
-
padding-top: 24px;
|
|
172
|
-
border-top: 1px solid #E5E7EB;
|
|
173
|
-
}
|
|
174
|
-
</style>
|
|
175
|
-
</head>
|
|
176
|
-
<body>
|
|
177
|
-
<div class="container">
|
|
178
|
-
<!-- Header -->
|
|
179
|
-
<div class="header">
|
|
180
|
-
<div class="logo">${PRIVACY_MASK_SVG}</div>
|
|
181
|
-
<h1>${escapeHtml(data.agentName)} wants to connect</h1>
|
|
182
|
-
</div>
|
|
183
|
-
|
|
184
|
-
<!-- Content -->
|
|
185
|
-
<div class="content">
|
|
186
|
-
<p>You've been invited to establish an authenticated agent-to-agent connection.</p>
|
|
187
|
-
|
|
188
|
-
<!-- Agent Info -->
|
|
189
|
-
<div class="agent-info">
|
|
190
|
-
<div class="agent-name">From: ${escapeHtml(data.agentName)}</div>
|
|
191
|
-
<div class="did">DID: ${escapeHtml(data.did)}</div>
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
${data.message ? `
|
|
195
|
-
<!-- Custom Message -->
|
|
196
|
-
<div class="message-box">
|
|
197
|
-
"${escapeHtml(data.message)}"
|
|
198
|
-
</div>
|
|
199
|
-
` : ''}
|
|
200
|
-
|
|
201
|
-
<p>Click below to accept this invitation and establish a secure connection. No API keys or manual configuration required.</p>
|
|
202
|
-
|
|
203
|
-
<!-- CTA Button -->
|
|
204
|
-
<div class="cta-container">
|
|
205
|
-
<a href="${escapeHtml(data.acceptUrl)}" class="cta-button">
|
|
206
|
-
Accept Invitation
|
|
207
|
-
</a>
|
|
208
|
-
</div>
|
|
209
|
-
|
|
210
|
-
<!-- Security Note -->
|
|
211
|
-
<div class="security-note">
|
|
212
|
-
<strong>🔒 Secure connection:</strong> This invitation uses cryptographic identity (DID) instead of shared secrets. Your agent will verify the sender's signature before establishing trust.
|
|
213
|
-
</div>
|
|
214
|
-
</div>
|
|
215
|
-
|
|
216
|
-
<!-- Footer -->
|
|
217
|
-
<div class="footer">
|
|
218
|
-
<div class="tagline">APIs have keys. ACIs have identity.</div>
|
|
219
|
-
<div class="brand">
|
|
220
|
-
<strong>private<span style="color: #10B981;">.me</span></strong> • Authenticated Agent Communication
|
|
221
|
-
</div>
|
|
222
|
-
</div>
|
|
223
|
-
</div>
|
|
224
|
-
</body>
|
|
225
|
-
</html>
|
|
226
|
-
`.trim();
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Render connection accepted confirmation email.
|
|
230
|
-
*
|
|
231
|
-
* @param data - Template data
|
|
232
|
-
* @returns Rendered HTML email
|
|
233
|
-
*/
|
|
234
|
-
function renderAcceptedEmail(data) {
|
|
235
|
-
return `
|
|
236
|
-
<!DOCTYPE html>
|
|
237
|
-
<html lang="en">
|
|
238
|
-
<head>
|
|
239
|
-
<meta charset="UTF-8">
|
|
240
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
241
|
-
<title>Connection Accepted</title>
|
|
242
|
-
<style>
|
|
243
|
-
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=DM+Mono:wght@400;500&display=swap');
|
|
244
|
-
body {
|
|
245
|
-
margin: 0;
|
|
246
|
-
padding: 0;
|
|
247
|
-
font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
248
|
-
background-color: #F9FAFB;
|
|
249
|
-
color: #1F2937;
|
|
250
|
-
}
|
|
251
|
-
.container {
|
|
252
|
-
max-width: 600px;
|
|
253
|
-
margin: 0 auto;
|
|
254
|
-
background-color: #FFFFFF;
|
|
255
|
-
}
|
|
256
|
-
.header {
|
|
257
|
-
background: linear-gradient(135deg, #10B981 0%, #059669 100%);
|
|
258
|
-
padding: 40px 24px;
|
|
259
|
-
text-align: center;
|
|
260
|
-
color: #FFFFFF;
|
|
261
|
-
}
|
|
262
|
-
.content {
|
|
263
|
-
padding: 40px 24px;
|
|
264
|
-
}
|
|
265
|
-
.success-icon {
|
|
266
|
-
font-size: 48px;
|
|
267
|
-
text-align: center;
|
|
268
|
-
margin-bottom: 16px;
|
|
269
|
-
}
|
|
270
|
-
.agent-name {
|
|
271
|
-
font-weight: 600;
|
|
272
|
-
color: #10B981;
|
|
273
|
-
}
|
|
274
|
-
</style>
|
|
275
|
-
</head>
|
|
276
|
-
<body>
|
|
277
|
-
<div class="container">
|
|
278
|
-
<div class="header">
|
|
279
|
-
<div class="logo">${PRIVACY_MASK_SVG}</div>
|
|
280
|
-
<h1>Connection Established</h1>
|
|
281
|
-
</div>
|
|
282
|
-
<div class="content">
|
|
283
|
-
<div class="success-icon">✅</div>
|
|
284
|
-
<p><span class="agent-name">${escapeHtml(data.recipientName)}</span> has accepted your invitation.</p>
|
|
285
|
-
<p>You can now send authenticated messages to:</p>
|
|
286
|
-
<div style="font-family: 'DM Mono', monospace; font-size: 12px; color: #6B7280; padding: 16px; background: #F3F4F6; border-radius: 8px; margin: 16px 0;">
|
|
287
|
-
${escapeHtml(data.did)}
|
|
288
|
-
</div>
|
|
289
|
-
<p style="margin-top: 24px; padding-top: 24px; border-top: 1px solid #E5E7EB; font-size: 14px; color: #6B7280;">
|
|
290
|
-
APIs have keys. ACIs have identity.
|
|
291
|
-
</p>
|
|
292
|
-
</div>
|
|
293
|
-
</div>
|
|
294
|
-
</body>
|
|
295
|
-
</html>
|
|
296
|
-
`.trim();
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Escape HTML special characters to prevent injection.
|
|
300
|
-
*
|
|
301
|
-
* @param text - Text to escape
|
|
302
|
-
* @returns Escaped text
|
|
303
|
-
*/
|
|
304
|
-
function escapeHtml(text) {
|
|
305
|
-
const map = {
|
|
306
|
-
'&': '&',
|
|
307
|
-
'<': '<',
|
|
308
|
-
'>': '>',
|
|
309
|
-
'"': '"',
|
|
310
|
-
"'": ''',
|
|
311
|
-
};
|
|
312
|
-
return text.replace(/[&<>"']/g, (char) => map[char] || char);
|
|
313
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.renderInviteEmail=renderInviteEmail,exports.renderAcceptedEmail=renderAcceptedEmail;const PRIVACY_MASK_SVG='\n<svg width="32" height="32" viewBox="0 0 300 600" xmlns="http://www.w3.org/2000/svg">\n <defs>\n <linearGradient id="maskGradient" x1="0%" y1="0%" x2="100%" y2="100%">\n <stop offset="0%" style="stop-color:#10B981;stop-opacity:1" />\n <stop offset="100%" style="stop-color:#059669;stop-opacity:1" />\n </linearGradient>\n </defs>\n \x3c!-- Top curve --\x3e\n <path d="M50 100 Q150 50 250 100 L250 300 Q150 350 50 300 Z" fill="url(#maskGradient)"/>\n \x3c!-- Eye holes --\x3e\n <ellipse cx="100" cy="180" rx="25" ry="35" fill="#FFFFFF"/>\n <ellipse cx="200" cy="180" rx="25" ry="35" fill="#FFFFFF"/>\n \x3c!-- Bottom z-shape --\x3e\n <path d="M270 575 L230 575 L270 525 L230 525" stroke="#10B981" stroke-width="8" fill="none"/>\n</svg>\n';function renderInviteEmail(n){return`\n<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${escapeHtml(n.agentName)} wants to connect</title>\n <style>\n @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=DM+Mono:wght@400;500&display=swap');\n \n body {\n margin: 0;\n padding: 0;\n font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n background-color: #F9FAFB;\n color: #1F2937;\n }\n \n .container {\n max-width: 600px;\n margin: 0 auto;\n background-color: #FFFFFF;\n }\n \n .header {\n background: linear-gradient(135deg, #10B981 0%, #059669 100%);\n padding: 40px 24px;\n text-align: center;\n }\n \n .logo {\n margin-bottom: 16px;\n }\n \n .header h1 {\n margin: 0;\n font-size: 24px;\n font-weight: 700;\n color: #FFFFFF;\n line-height: 1.3;\n }\n \n .content {\n padding: 40px 24px;\n }\n \n .content p {\n margin: 0 0 16px 0;\n font-size: 16px;\n line-height: 1.6;\n color: #374151;\n }\n \n .agent-info {\n background-color: #F3F4F6;\n border-left: 4px solid #10B981;\n padding: 16px;\n margin: 24px 0;\n border-radius: 4px;\n }\n \n .agent-name {\n font-size: 18px;\n font-weight: 600;\n color: #1F2937;\n margin-bottom: 8px;\n }\n \n .did {\n font-family: 'DM Mono', 'Courier New', monospace;\n font-size: 12px;\n color: #6B7280;\n word-break: break-all;\n line-height: 1.5;\n }\n \n .message-box {\n background-color: #F9FAFB;\n border: 1px solid #E5E7EB;\n padding: 16px;\n margin: 24px 0;\n border-radius: 8px;\n font-style: italic;\n color: #4B5563;\n }\n \n .cta-container {\n text-align: center;\n margin: 32px 0;\n }\n \n .cta-button {\n display: inline-block;\n background-color: #10B981;\n color: #FFFFFF;\n text-decoration: none;\n padding: 14px 32px;\n border-radius: 8px;\n font-size: 16px;\n font-weight: 600;\n transition: background-color 0.2s;\n }\n \n .cta-button:hover {\n background-color: #059669;\n }\n \n .footer {\n padding: 24px;\n text-align: center;\n border-top: 1px solid #E5E7EB;\n }\n \n .tagline {\n font-size: 14px;\n color: #6B7280;\n margin-bottom: 12px;\n }\n \n .brand {\n font-size: 12px;\n color: #9CA3AF;\n }\n \n .security-note {\n font-size: 13px;\n color: #6B7280;\n margin-top: 24px;\n padding-top: 24px;\n border-top: 1px solid #E5E7EB;\n }\n </style>\n</head>\n<body>\n <div class="container">\n \x3c!-- Header --\x3e\n <div class="header">\n <div class="logo">${PRIVACY_MASK_SVG}</div>\n <h1>${escapeHtml(n.agentName)} wants to connect</h1>\n </div>\n \n \x3c!-- Content --\x3e\n <div class="content">\n <p>You've been invited to establish an authenticated agent-to-agent connection.</p>\n \n \x3c!-- Agent Info --\x3e\n <div class="agent-info">\n <div class="agent-name">From: ${escapeHtml(n.agentName)}</div>\n <div class="did">DID: ${escapeHtml(n.did)}</div>\n </div>\n \n ${n.message?`\n \x3c!-- Custom Message --\x3e\n <div class="message-box">\n "${escapeHtml(n.message)}"\n </div>\n `:""}\n \n <p>Click below to accept this invitation and establish a secure connection. No API keys or manual configuration required.</p>\n \n \x3c!-- CTA Button --\x3e\n <div class="cta-container">\n <a href="${escapeHtml(n.acceptUrl)}" class="cta-button">\n Accept Invitation\n </a>\n </div>\n \n \x3c!-- Security Note --\x3e\n <div class="security-note">\n <strong>🔒 Secure connection:</strong> This invitation uses cryptographic identity (DID) instead of shared secrets. Your agent will verify the sender's signature before establishing trust.\n </div>\n </div>\n \n \x3c!-- Footer --\x3e\n <div class="footer">\n <div class="tagline">APIs have keys. ACIs have identity.</div>\n <div class="brand">\n <strong>private<span style="color: #10B981;">.me</span></strong> • Authenticated Agent Communication\n </div>\n </div>\n </div>\n</body>\n</html>\n `.trim()}function renderAcceptedEmail(n){return`\n<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>Connection Accepted</title>\n <style>\n @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=DM+Mono:wght@400;500&display=swap');\n body {\n margin: 0;\n padding: 0;\n font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n background-color: #F9FAFB;\n color: #1F2937;\n }\n .container {\n max-width: 600px;\n margin: 0 auto;\n background-color: #FFFFFF;\n }\n .header {\n background: linear-gradient(135deg, #10B981 0%, #059669 100%);\n padding: 40px 24px;\n text-align: center;\n color: #FFFFFF;\n }\n .content {\n padding: 40px 24px;\n }\n .success-icon {\n font-size: 48px;\n text-align: center;\n margin-bottom: 16px;\n }\n .agent-name {\n font-weight: 600;\n color: #10B981;\n }\n </style>\n</head>\n<body>\n <div class="container">\n <div class="header">\n <div class="logo">${PRIVACY_MASK_SVG}</div>\n <h1>Connection Established</h1>\n </div>\n <div class="content">\n <div class="success-icon">✅</div>\n <p><span class="agent-name">${escapeHtml(n.recipientName)}</span> has accepted your invitation.</p>\n <p>You can now send authenticated messages to:</p>\n <div style="font-family: 'DM Mono', monospace; font-size: 12px; color: #6B7280; padding: 16px; background: #F3F4F6; border-radius: 8px; margin: 16px 0;">\n ${escapeHtml(n.did)}\n </div>\n <p style="margin-top: 24px; padding-top: 24px; border-top: 1px solid #E5E7EB; font-size: 14px; color: #6B7280;">\n APIs have keys. ACIs have identity.\n </p>\n </div>\n </div>\n</body>\n</html>\n `.trim()}function escapeHtml(n){const e={"&":"&","<":"<",">":">",'"':""","'":"'"};return n.replace(/[&<>"']/g,n=>e[n]||n)}
|