@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,247 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @module dual-mode
|
|
3
|
-
* Dual-mode adapter: XBind + API key fallback.
|
|
4
|
-
*
|
|
5
|
-
* Enables zero-downtime migration:
|
|
6
|
-
* - Try XBind first
|
|
7
|
-
* - Fall back to API key if unavailable
|
|
8
|
-
* - Track usage metrics
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const adapter = new DualModeAdapter({
|
|
13
|
-
* xbind: xbindAgent,
|
|
14
|
-
* fallback: {
|
|
15
|
-
* type: 'api-key',
|
|
16
|
-
* key: process.env.API_KEY,
|
|
17
|
-
* url: 'https://api.example.com',
|
|
18
|
-
* },
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* // Will try xBind, fall back to API key
|
|
22
|
-
* const result = await adapter.call('createCharge', { amount: 100 });
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
import { ok, err } from"./_deps/shared/index.js";
|
|
26
|
-
/**
|
|
27
|
-
* Dual-mode error codes.
|
|
28
|
-
*/
|
|
29
|
-
export var DualModeErrorCode;
|
|
30
|
-
(function (DualModeErrorCode) {
|
|
31
|
-
DualModeErrorCode["BOTH_FAILED"] = "DUAL_MODE_BOTH_FAILED";
|
|
32
|
-
DualModeErrorCode["XBIND_FAILED"] = "DUAL_MODE_XBIND_FAILED";
|
|
33
|
-
DualModeErrorCode["FALLBACK_FAILED"] = "DUAL_MODE_FALLBACK_FAILED";
|
|
34
|
-
DualModeErrorCode["INVALID_CONFIG"] = "DUAL_MODE_INVALID_CONFIG";
|
|
35
|
-
})(DualModeErrorCode || (DualModeErrorCode = {}));
|
|
36
|
-
/**
|
|
37
|
-
* Dual-mode adapter.
|
|
38
|
-
*
|
|
39
|
-
* Tries XBind first, falls back to API key if unavailable.
|
|
40
|
-
*/
|
|
41
|
-
export class DualModeAdapter {
|
|
42
|
-
xbind;
|
|
43
|
-
fallback;
|
|
44
|
-
metrics;
|
|
45
|
-
/**
|
|
46
|
-
* Create dual-mode adapter.
|
|
47
|
-
*
|
|
48
|
-
* @param options - Configuration
|
|
49
|
-
* @param options.xbind - xBind agent (optional, can be added later)
|
|
50
|
-
* @param options.fallback - Fallback config (optional, can be removed later)
|
|
51
|
-
*/
|
|
52
|
-
constructor(options = {}) {
|
|
53
|
-
this.xbind = options.xbind || null;
|
|
54
|
-
this.fallback = options.fallback || null;
|
|
55
|
-
this.metrics = {
|
|
56
|
-
totalCalls: 0,
|
|
57
|
-
xbindCalls: 0,
|
|
58
|
-
fallbackCalls: 0,
|
|
59
|
-
xbindPercentage: 0,
|
|
60
|
-
lastCall: new Date().toISOString(),
|
|
61
|
-
lastCallMethod: 'xbind',
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Set xBind agent (for gradual rollout).
|
|
66
|
-
*
|
|
67
|
-
* @param agent - xBind agent
|
|
68
|
-
*/
|
|
69
|
-
setXBind(agent) {
|
|
70
|
-
this.xbind = agent;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Remove fallback (complete migration).
|
|
74
|
-
*/
|
|
75
|
-
removeFallback() {
|
|
76
|
-
this.fallback = null;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Call an action (tries XBind first, falls back if needed).
|
|
80
|
-
*
|
|
81
|
-
* @param action - Action name
|
|
82
|
-
* @param params - Action parameters
|
|
83
|
-
* @returns Result or error
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* const result = await adapter.call('createCharge', {
|
|
88
|
-
* amount: 100,
|
|
89
|
-
* currency: 'USD',
|
|
90
|
-
* });
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
async call(action, params = {}) {
|
|
94
|
-
this.metrics.totalCalls++;
|
|
95
|
-
// Try XBind first
|
|
96
|
-
if (this.xbind) {
|
|
97
|
-
try {
|
|
98
|
-
const result = await this.callViaXBind(action, params);
|
|
99
|
-
if (result.ok) {
|
|
100
|
-
this.metrics.xbindCalls++;
|
|
101
|
-
this.updateMetrics('xbind');
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
// XBind failed, try fallback if available
|
|
105
|
-
if (this.fallback) {
|
|
106
|
-
const fallbackResult = await this.callViaFallback(action, params);
|
|
107
|
-
if (fallbackResult.ok) {
|
|
108
|
-
this.metrics.fallbackCalls++;
|
|
109
|
-
this.updateMetrics('fallback');
|
|
110
|
-
return fallbackResult;
|
|
111
|
-
}
|
|
112
|
-
// Both failed
|
|
113
|
-
return err({
|
|
114
|
-
code: DualModeErrorCode.BOTH_FAILED,
|
|
115
|
-
message: 'Both XBind and fallback failed',
|
|
116
|
-
xbindError: result.error,
|
|
117
|
-
fallbackError: fallbackResult.error,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
// No fallback, return XBind error
|
|
121
|
-
return err({
|
|
122
|
-
code: DualModeErrorCode.XBIND_FAILED,
|
|
123
|
-
message: 'XBind failed and no fallback configured',
|
|
124
|
-
xbindError: result.error,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
// XBind exception, try fallback
|
|
129
|
-
if (this.fallback) {
|
|
130
|
-
const fallbackResult = await this.callViaFallback(action, params);
|
|
131
|
-
if (fallbackResult.ok) {
|
|
132
|
-
this.metrics.fallbackCalls++;
|
|
133
|
-
this.updateMetrics('fallback');
|
|
134
|
-
return fallbackResult;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return err({
|
|
138
|
-
code: DualModeErrorCode.XBIND_FAILED,
|
|
139
|
-
message: error instanceof Error ? error.message : 'XBind exception',
|
|
140
|
-
xbindError: error,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// No xBind, try fallback only
|
|
145
|
-
if (this.fallback) {
|
|
146
|
-
const result = await this.callViaFallback(action, params);
|
|
147
|
-
if (result.ok) {
|
|
148
|
-
this.metrics.fallbackCalls++;
|
|
149
|
-
this.updateMetrics('fallback');
|
|
150
|
-
return result;
|
|
151
|
-
}
|
|
152
|
-
return err({
|
|
153
|
-
code: DualModeErrorCode.FALLBACK_FAILED,
|
|
154
|
-
message: 'Fallback failed',
|
|
155
|
-
fallbackError: result.error,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
// Neither XBind nor fallback configured
|
|
159
|
-
return err({
|
|
160
|
-
code: DualModeErrorCode.INVALID_CONFIG,
|
|
161
|
-
message: 'Neither XBind nor fallback configured',
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Get usage metrics.
|
|
166
|
-
*
|
|
167
|
-
* @returns Current metrics
|
|
168
|
-
*/
|
|
169
|
-
getMetrics() {
|
|
170
|
-
return { ...this.metrics };
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Reset metrics.
|
|
174
|
-
*/
|
|
175
|
-
resetMetrics() {
|
|
176
|
-
this.metrics = {
|
|
177
|
-
totalCalls: 0,
|
|
178
|
-
xbindCalls: 0,
|
|
179
|
-
fallbackCalls: 0,
|
|
180
|
-
xbindPercentage: 0,
|
|
181
|
-
lastCall: new Date().toISOString(),
|
|
182
|
-
lastCallMethod: 'xbind',
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Call via XBind.
|
|
187
|
-
*/
|
|
188
|
-
async callViaXBind(action, params) {
|
|
189
|
-
if (!this.xbind) {
|
|
190
|
-
return err({ message: 'XBind not configured' });
|
|
191
|
-
}
|
|
192
|
-
try {
|
|
193
|
-
const result = await this.xbind.send({
|
|
194
|
-
to: this.xbind.did, // TODO: Get target DID from connection
|
|
195
|
-
payload: { action, params },
|
|
196
|
-
scope: action,
|
|
197
|
-
});
|
|
198
|
-
return result;
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
return err({ message: error instanceof Error ? error.message : 'Unknown error' });
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Call via fallback (API key, OAuth, etc.).
|
|
206
|
-
*/
|
|
207
|
-
async callViaFallback(action, params) {
|
|
208
|
-
if (!this.fallback) {
|
|
209
|
-
return err({ message: 'Fallback not configured' });
|
|
210
|
-
}
|
|
211
|
-
try {
|
|
212
|
-
const url = `${this.fallback.url}/${action}`;
|
|
213
|
-
const method = this.fallback.method || 'POST';
|
|
214
|
-
const headers = {
|
|
215
|
-
'Content-Type': 'application/json',
|
|
216
|
-
...this.fallback.headers,
|
|
217
|
-
};
|
|
218
|
-
// Add auth header based on type
|
|
219
|
-
if (this.fallback.type === 'api-key' && this.fallback.key) {
|
|
220
|
-
headers['Authorization'] = `Bearer ${this.fallback.key}`;
|
|
221
|
-
}
|
|
222
|
-
const response = await fetch(url, {
|
|
223
|
-
method,
|
|
224
|
-
headers,
|
|
225
|
-
body: method !== 'GET' ? JSON.stringify(params) : undefined,
|
|
226
|
-
});
|
|
227
|
-
if (!response.ok) {
|
|
228
|
-
return err({ message: `HTTP ${response.status}` });
|
|
229
|
-
}
|
|
230
|
-
const data = await response.json();
|
|
231
|
-
return ok(data);
|
|
232
|
-
}
|
|
233
|
-
catch (error) {
|
|
234
|
-
return err({ message: error instanceof Error ? error.message : 'Network error' });
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Update metrics after a call.
|
|
239
|
-
*/
|
|
240
|
-
updateMetrics(method) {
|
|
241
|
-
this.metrics.lastCall = new Date().toISOString();
|
|
242
|
-
this.metrics.lastCallMethod = method;
|
|
243
|
-
this.metrics.xbindPercentage = this.metrics.totalCalls > 0
|
|
244
|
-
? (this.metrics.xbindCalls / this.metrics.totalCalls) * 100
|
|
245
|
-
: 0;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
1
|
+
import{ok,err}from"./_deps/shared/index.js";export 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||(DualModeErrorCode={}));export 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,r={}){if(this.metrics.totalCalls++,this.xbind)try{const e=await this.callViaXBind(a,r);if(e.ok)return this.metrics.xbindCalls++,this.updateMetrics("xbind"),e;if(this.fallback){const t=await this.callViaFallback(a,r);return t.ok?(this.metrics.fallbackCalls++,this.updateMetrics("fallback"),t):err({code:DualModeErrorCode.BOTH_FAILED,message:"Both XBind and fallback failed",xbindError:e.error,fallbackError:t.error})}return err({code:DualModeErrorCode.XBIND_FAILED,message:"XBind failed and no fallback configured",xbindError:e.error})}catch(e){if(this.fallback){const e=await this.callViaFallback(a,r);if(e.ok)return this.metrics.fallbackCalls++,this.updateMetrics("fallback"),e}return err({code:DualModeErrorCode.XBIND_FAILED,message:e instanceof Error?e.message:"XBind exception",xbindError:e})}if(this.fallback){const e=await this.callViaFallback(a,r);return e.ok?(this.metrics.fallbackCalls++,this.updateMetrics("fallback"),e):err({code:DualModeErrorCode.FALLBACK_FAILED,message:"Fallback failed",fallbackError:e.error})}return 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,r){if(!this.xbind)return err({message:"XBind not configured"});try{return await this.xbind.send({to:this.xbind.did,payload:{action:a,params:r},scope:a})}catch(a){return err({message:a instanceof Error?a.message:"Unknown error"})}}async callViaFallback(a,r){if(!this.fallback)return err({message:"Fallback not configured"});try{const e=`${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 i=await fetch(e,{method:t,headers:l,body:"GET"!==t?JSON.stringify(r):void 0});if(!i.ok)return err({message:`HTTP ${i.status}`});const s=await i.json();return ok(s)}catch(a){return 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}}
|
|
@@ -1,309 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @module email-templates
|
|
3
|
-
* Branded HTML email templates for xBind invitations.
|
|
4
|
-
*
|
|
5
|
-
* Uses Private.Me brand guidelines:
|
|
6
|
-
* - Colors: Green #10B981, Ink #1F2937, White #FFFFFF
|
|
7
|
-
* - Fonts: Outfit (display), DM Mono (code/DIDs)
|
|
8
|
-
* - Logo: Privacy Mask SVG
|
|
9
|
-
* - Tagline: "APIs have keys. ACIs have identity."
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Privacy Mask logo SVG (complete with bottom z-shape).
|
|
13
|
-
* Per brand guidelines section 02.5.
|
|
14
|
-
*/
|
|
15
|
-
const PRIVACY_MASK_SVG = `
|
|
16
|
-
<svg width="32" height="32" viewBox="0 0 300 600" xmlns="http://www.w3.org/2000/svg">
|
|
17
|
-
<defs>
|
|
18
|
-
<linearGradient id="maskGradient" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
19
|
-
<stop offset="0%" style="stop-color:#10B981;stop-opacity:1" />
|
|
20
|
-
<stop offset="100%" style="stop-color:#059669;stop-opacity:1" />
|
|
21
|
-
</linearGradient>
|
|
22
|
-
</defs>
|
|
23
|
-
<!-- Top curve -->
|
|
24
|
-
<path d="M50 100 Q150 50 250 100 L250 300 Q150 350 50 300 Z" fill="url(#maskGradient)"/>
|
|
25
|
-
<!-- Eye holes -->
|
|
26
|
-
<ellipse cx="100" cy="180" rx="25" ry="35" fill="#FFFFFF"/>
|
|
27
|
-
<ellipse cx="200" cy="180" rx="25" ry="35" fill="#FFFFFF"/>
|
|
28
|
-
<!-- Bottom z-shape -->
|
|
29
|
-
<path d="M270 575 L230 575 L270 525 L230 525" stroke="#10B981" stroke-width="8" fill="none"/>
|
|
30
|
-
</svg>
|
|
31
|
-
`;
|
|
32
|
-
/**
|
|
33
|
-
* Render invitation email with branded template.
|
|
34
|
-
*
|
|
35
|
-
* @param data - Template data
|
|
36
|
-
* @returns Rendered HTML email
|
|
37
|
-
*/
|
|
38
|
-
export function renderInviteEmail(data) {
|
|
39
|
-
return `
|
|
40
|
-
<!DOCTYPE html>
|
|
41
|
-
<html lang="en">
|
|
42
|
-
<head>
|
|
43
|
-
<meta charset="UTF-8">
|
|
44
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
45
|
-
<title>${escapeHtml(data.agentName)} wants to connect</title>
|
|
46
|
-
<style>
|
|
47
|
-
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=DM+Mono:wght@400;500&display=swap');
|
|
48
|
-
|
|
49
|
-
body {
|
|
50
|
-
margin: 0;
|
|
51
|
-
padding: 0;
|
|
52
|
-
font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
53
|
-
background-color: #F9FAFB;
|
|
54
|
-
color: #1F2937;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.container {
|
|
58
|
-
max-width: 600px;
|
|
59
|
-
margin: 0 auto;
|
|
60
|
-
background-color: #FFFFFF;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.header {
|
|
64
|
-
background: linear-gradient(135deg, #10B981 0%, #059669 100%);
|
|
65
|
-
padding: 40px 24px;
|
|
66
|
-
text-align: center;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.logo {
|
|
70
|
-
margin-bottom: 16px;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.header h1 {
|
|
74
|
-
margin: 0;
|
|
75
|
-
font-size: 24px;
|
|
76
|
-
font-weight: 700;
|
|
77
|
-
color: #FFFFFF;
|
|
78
|
-
line-height: 1.3;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.content {
|
|
82
|
-
padding: 40px 24px;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.content p {
|
|
86
|
-
margin: 0 0 16px 0;
|
|
87
|
-
font-size: 16px;
|
|
88
|
-
line-height: 1.6;
|
|
89
|
-
color: #374151;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.agent-info {
|
|
93
|
-
background-color: #F3F4F6;
|
|
94
|
-
border-left: 4px solid #10B981;
|
|
95
|
-
padding: 16px;
|
|
96
|
-
margin: 24px 0;
|
|
97
|
-
border-radius: 4px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.agent-name {
|
|
101
|
-
font-size: 18px;
|
|
102
|
-
font-weight: 600;
|
|
103
|
-
color: #1F2937;
|
|
104
|
-
margin-bottom: 8px;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.did {
|
|
108
|
-
font-family: 'DM Mono', 'Courier New', monospace;
|
|
109
|
-
font-size: 12px;
|
|
110
|
-
color: #6B7280;
|
|
111
|
-
word-break: break-all;
|
|
112
|
-
line-height: 1.5;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.message-box {
|
|
116
|
-
background-color: #F9FAFB;
|
|
117
|
-
border: 1px solid #E5E7EB;
|
|
118
|
-
padding: 16px;
|
|
119
|
-
margin: 24px 0;
|
|
120
|
-
border-radius: 8px;
|
|
121
|
-
font-style: italic;
|
|
122
|
-
color: #4B5563;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.cta-container {
|
|
126
|
-
text-align: center;
|
|
127
|
-
margin: 32px 0;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.cta-button {
|
|
131
|
-
display: inline-block;
|
|
132
|
-
background-color: #10B981;
|
|
133
|
-
color: #FFFFFF;
|
|
134
|
-
text-decoration: none;
|
|
135
|
-
padding: 14px 32px;
|
|
136
|
-
border-radius: 8px;
|
|
137
|
-
font-size: 16px;
|
|
138
|
-
font-weight: 600;
|
|
139
|
-
transition: background-color 0.2s;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.cta-button:hover {
|
|
143
|
-
background-color: #059669;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.footer {
|
|
147
|
-
padding: 24px;
|
|
148
|
-
text-align: center;
|
|
149
|
-
border-top: 1px solid #E5E7EB;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.tagline {
|
|
153
|
-
font-size: 14px;
|
|
154
|
-
color: #6B7280;
|
|
155
|
-
margin-bottom: 12px;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.brand {
|
|
159
|
-
font-size: 12px;
|
|
160
|
-
color: #9CA3AF;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.security-note {
|
|
164
|
-
font-size: 13px;
|
|
165
|
-
color: #6B7280;
|
|
166
|
-
margin-top: 24px;
|
|
167
|
-
padding-top: 24px;
|
|
168
|
-
border-top: 1px solid #E5E7EB;
|
|
169
|
-
}
|
|
170
|
-
</style>
|
|
171
|
-
</head>
|
|
172
|
-
<body>
|
|
173
|
-
<div class="container">
|
|
174
|
-
<!-- Header -->
|
|
175
|
-
<div class="header">
|
|
176
|
-
<div class="logo">${PRIVACY_MASK_SVG}</div>
|
|
177
|
-
<h1>${escapeHtml(data.agentName)} wants to connect</h1>
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
<!-- Content -->
|
|
181
|
-
<div class="content">
|
|
182
|
-
<p>You've been invited to establish an authenticated agent-to-agent connection.</p>
|
|
183
|
-
|
|
184
|
-
<!-- Agent Info -->
|
|
185
|
-
<div class="agent-info">
|
|
186
|
-
<div class="agent-name">From: ${escapeHtml(data.agentName)}</div>
|
|
187
|
-
<div class="did">DID: ${escapeHtml(data.did)}</div>
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
${data.message ? `
|
|
191
|
-
<!-- Custom Message -->
|
|
192
|
-
<div class="message-box">
|
|
193
|
-
"${escapeHtml(data.message)}"
|
|
194
|
-
</div>
|
|
195
|
-
` : ''}
|
|
196
|
-
|
|
197
|
-
<p>Click below to accept this invitation and establish a secure connection. No API keys or manual configuration required.</p>
|
|
198
|
-
|
|
199
|
-
<!-- CTA Button -->
|
|
200
|
-
<div class="cta-container">
|
|
201
|
-
<a href="${escapeHtml(data.acceptUrl)}" class="cta-button">
|
|
202
|
-
Accept Invitation
|
|
203
|
-
</a>
|
|
204
|
-
</div>
|
|
205
|
-
|
|
206
|
-
<!-- Security Note -->
|
|
207
|
-
<div class="security-note">
|
|
208
|
-
<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.
|
|
209
|
-
</div>
|
|
210
|
-
</div>
|
|
211
|
-
|
|
212
|
-
<!-- Footer -->
|
|
213
|
-
<div class="footer">
|
|
214
|
-
<div class="tagline">APIs have keys. ACIs have identity.</div>
|
|
215
|
-
<div class="brand">
|
|
216
|
-
<strong>private<span style="color: #10B981;">.me</span></strong> • Authenticated Agent Communication
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
</div>
|
|
220
|
-
</body>
|
|
221
|
-
</html>
|
|
222
|
-
`.trim();
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Render connection accepted confirmation email.
|
|
226
|
-
*
|
|
227
|
-
* @param data - Template data
|
|
228
|
-
* @returns Rendered HTML email
|
|
229
|
-
*/
|
|
230
|
-
export function renderAcceptedEmail(data) {
|
|
231
|
-
return `
|
|
232
|
-
<!DOCTYPE html>
|
|
233
|
-
<html lang="en">
|
|
234
|
-
<head>
|
|
235
|
-
<meta charset="UTF-8">
|
|
236
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
237
|
-
<title>Connection Accepted</title>
|
|
238
|
-
<style>
|
|
239
|
-
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=DM+Mono:wght@400;500&display=swap');
|
|
240
|
-
body {
|
|
241
|
-
margin: 0;
|
|
242
|
-
padding: 0;
|
|
243
|
-
font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
244
|
-
background-color: #F9FAFB;
|
|
245
|
-
color: #1F2937;
|
|
246
|
-
}
|
|
247
|
-
.container {
|
|
248
|
-
max-width: 600px;
|
|
249
|
-
margin: 0 auto;
|
|
250
|
-
background-color: #FFFFFF;
|
|
251
|
-
}
|
|
252
|
-
.header {
|
|
253
|
-
background: linear-gradient(135deg, #10B981 0%, #059669 100%);
|
|
254
|
-
padding: 40px 24px;
|
|
255
|
-
text-align: center;
|
|
256
|
-
color: #FFFFFF;
|
|
257
|
-
}
|
|
258
|
-
.content {
|
|
259
|
-
padding: 40px 24px;
|
|
260
|
-
}
|
|
261
|
-
.success-icon {
|
|
262
|
-
font-size: 48px;
|
|
263
|
-
text-align: center;
|
|
264
|
-
margin-bottom: 16px;
|
|
265
|
-
}
|
|
266
|
-
.agent-name {
|
|
267
|
-
font-weight: 600;
|
|
268
|
-
color: #10B981;
|
|
269
|
-
}
|
|
270
|
-
</style>
|
|
271
|
-
</head>
|
|
272
|
-
<body>
|
|
273
|
-
<div class="container">
|
|
274
|
-
<div class="header">
|
|
275
|
-
<div class="logo">${PRIVACY_MASK_SVG}</div>
|
|
276
|
-
<h1>Connection Established</h1>
|
|
277
|
-
</div>
|
|
278
|
-
<div class="content">
|
|
279
|
-
<div class="success-icon">✅</div>
|
|
280
|
-
<p><span class="agent-name">${escapeHtml(data.recipientName)}</span> has accepted your invitation.</p>
|
|
281
|
-
<p>You can now send authenticated messages to:</p>
|
|
282
|
-
<div style="font-family: 'DM Mono', monospace; font-size: 12px; color: #6B7280; padding: 16px; background: #F3F4F6; border-radius: 8px; margin: 16px 0;">
|
|
283
|
-
${escapeHtml(data.did)}
|
|
284
|
-
</div>
|
|
285
|
-
<p style="margin-top: 24px; padding-top: 24px; border-top: 1px solid #E5E7EB; font-size: 14px; color: #6B7280;">
|
|
286
|
-
APIs have keys. ACIs have identity.
|
|
287
|
-
</p>
|
|
288
|
-
</div>
|
|
289
|
-
</div>
|
|
290
|
-
</body>
|
|
291
|
-
</html>
|
|
292
|
-
`.trim();
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Escape HTML special characters to prevent injection.
|
|
296
|
-
*
|
|
297
|
-
* @param text - Text to escape
|
|
298
|
-
* @returns Escaped text
|
|
299
|
-
*/
|
|
300
|
-
function escapeHtml(text) {
|
|
301
|
-
const map = {
|
|
302
|
-
'&': '&',
|
|
303
|
-
'<': '<',
|
|
304
|
-
'>': '>',
|
|
305
|
-
'"': '"',
|
|
306
|
-
"'": ''',
|
|
307
|
-
};
|
|
308
|
-
return text.replace(/[&<>"']/g, (char) => map[char] || char);
|
|
309
|
-
}
|
|
1
|
+
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';export 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()}export 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)}
|