@amos.com/amos-js 0.10.2 → 0.10.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/dist/index.js +3 -3
- package/dist/index.mjs +319 -258
- package/dist/log.d.ts +12 -0
- package/dist/types.d.ts +10 -0
- package/package.json +1 -1
- package/src/log.ts +74 -0
- package/src/messaging.ts +19 -0
- package/src/plaid-bank-ui.ts +11 -0
- package/src/types.ts +11 -0
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forward an info log to the embed iframe so Rollbar records it with
|
|
3
|
+
* Amos credentials. Payload shape matches dashboard/embed API traces:
|
|
4
|
+
* `endpoint`, `headers`, `body`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function reportParentInfoLog({ iframe, message, endpoint, headers, body, }: {
|
|
7
|
+
iframe: HTMLIFrameElement;
|
|
8
|
+
message: string;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
body?: unknown;
|
|
12
|
+
}): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -267,6 +267,16 @@ export type Message = {
|
|
|
267
267
|
requestId: string;
|
|
268
268
|
link_token?: string;
|
|
269
269
|
error?: string;
|
|
270
|
+
} | {
|
|
271
|
+
/**
|
|
272
|
+
* Parent → embed: info telemetry for Rollbar. The iframe reports
|
|
273
|
+
* `message` with `endpoint`, `headers`, and `body`.
|
|
274
|
+
*/
|
|
275
|
+
type: "PARENT_INFO_LOG";
|
|
276
|
+
message: string;
|
|
277
|
+
endpoint?: string;
|
|
278
|
+
headers?: Record<string, string>;
|
|
279
|
+
body?: unknown;
|
|
270
280
|
};
|
|
271
281
|
/**
|
|
272
282
|
* Identity helper that brands an object as a typed `Message`.
|
package/package.json
CHANGED
package/src/log.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createMessage } from "./types";
|
|
2
|
+
|
|
3
|
+
const SENSITIVE_HEADER_NAMES = new Set([
|
|
4
|
+
"authorization",
|
|
5
|
+
"cookie",
|
|
6
|
+
"set-cookie",
|
|
7
|
+
"x-api-key",
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
const SENSITIVE_BODY_KEYS = new Set([
|
|
11
|
+
"authorization",
|
|
12
|
+
"encrypted_account_number",
|
|
13
|
+
"link_token",
|
|
14
|
+
"public_token",
|
|
15
|
+
"token",
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
function redactHeaders(
|
|
19
|
+
headers: Record<string, string>,
|
|
20
|
+
): Record<string, string> {
|
|
21
|
+
const redacted: Record<string, string> = {};
|
|
22
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
23
|
+
redacted[key] = SENSITIVE_HEADER_NAMES.has(key.toLowerCase())
|
|
24
|
+
? "[REDACTED]"
|
|
25
|
+
: value;
|
|
26
|
+
}
|
|
27
|
+
return redacted;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function redactBody(body: unknown): unknown {
|
|
31
|
+
if (Array.isArray(body)) {
|
|
32
|
+
return body.map(redactBody);
|
|
33
|
+
}
|
|
34
|
+
if (body !== null && typeof body === "object") {
|
|
35
|
+
const redacted: Record<string, unknown> = {};
|
|
36
|
+
for (const [key, value] of Object.entries(body)) {
|
|
37
|
+
redacted[key] = SENSITIVE_BODY_KEYS.has(key)
|
|
38
|
+
? "[REDACTED]"
|
|
39
|
+
: redactBody(value);
|
|
40
|
+
}
|
|
41
|
+
return redacted;
|
|
42
|
+
}
|
|
43
|
+
return body;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Forward an info log to the embed iframe so Rollbar records it with
|
|
48
|
+
* Amos credentials. Payload shape matches dashboard/embed API traces:
|
|
49
|
+
* `endpoint`, `headers`, `body`.
|
|
50
|
+
*/
|
|
51
|
+
export function reportParentInfoLog({
|
|
52
|
+
iframe,
|
|
53
|
+
message,
|
|
54
|
+
endpoint,
|
|
55
|
+
headers = {},
|
|
56
|
+
body,
|
|
57
|
+
}: {
|
|
58
|
+
iframe: HTMLIFrameElement;
|
|
59
|
+
message: string;
|
|
60
|
+
endpoint: string;
|
|
61
|
+
headers?: Record<string, string>;
|
|
62
|
+
body?: unknown;
|
|
63
|
+
}): void {
|
|
64
|
+
iframe.contentWindow?.postMessage(
|
|
65
|
+
createMessage({
|
|
66
|
+
type: "PARENT_INFO_LOG",
|
|
67
|
+
message,
|
|
68
|
+
endpoint,
|
|
69
|
+
headers: redactHeaders(headers),
|
|
70
|
+
body: redactBody(body),
|
|
71
|
+
}),
|
|
72
|
+
new URL(iframe.src).origin,
|
|
73
|
+
);
|
|
74
|
+
}
|
package/src/messaging.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { components } from "@amos.com/node";
|
|
2
2
|
import { decodeJwt } from "./jwt";
|
|
3
|
+
import { reportParentInfoLog } from "./log";
|
|
3
4
|
import { getBankPlaidSession } from "./plaid-session";
|
|
4
5
|
import {
|
|
5
6
|
type Appearance,
|
|
@@ -292,6 +293,24 @@ function postConfirmIntent({
|
|
|
292
293
|
resetIframeFields(iframe);
|
|
293
294
|
}
|
|
294
295
|
|
|
296
|
+
const origin = getIframeTargetOrigin(iframe);
|
|
297
|
+
reportParentInfoLog({
|
|
298
|
+
iframe,
|
|
299
|
+
message:
|
|
300
|
+
type === "CONFIRM_PAYMENT_INTENT"
|
|
301
|
+
? "confirmPaymentIntent"
|
|
302
|
+
: "confirmSetupIntent",
|
|
303
|
+
endpoint:
|
|
304
|
+
type === "CONFIRM_PAYMENT_INTENT"
|
|
305
|
+
? "POST /embed/payment_intents/{id}/confirm_with_payment_method"
|
|
306
|
+
: "POST /embed/setup_intents/{id}/confirm_with_payment_method",
|
|
307
|
+
headers: {
|
|
308
|
+
origin: window.location.origin,
|
|
309
|
+
"iframe-origin": origin,
|
|
310
|
+
},
|
|
311
|
+
body: { id, token, ...(plaid ? { plaid } : {}) },
|
|
312
|
+
});
|
|
313
|
+
|
|
295
314
|
iframe.contentWindow?.postMessage(
|
|
296
315
|
createMessage({
|
|
297
316
|
type,
|
package/src/plaid-bank-ui.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reportParentInfoLog } from "./log";
|
|
1
2
|
import { requestPlaidLinkToken } from "./messaging";
|
|
2
3
|
import type { PaymentMethodFormListenerOptions } from "./payment-method-form";
|
|
3
4
|
import {
|
|
@@ -309,6 +310,16 @@ export function attachPlaidBankUi({
|
|
|
309
310
|
thresholdKnown = true;
|
|
310
311
|
achThreshold = event.data.achThreshold ?? undefined;
|
|
311
312
|
requireVerification = event.data.requireVerification === true;
|
|
313
|
+
reportParentInfoLog({
|
|
314
|
+
iframe,
|
|
315
|
+
message: "merchant ach_threshold",
|
|
316
|
+
endpoint: "ACH_THRESHOLD",
|
|
317
|
+
headers: { origin: event.origin },
|
|
318
|
+
body: {
|
|
319
|
+
achThreshold,
|
|
320
|
+
requireVerification,
|
|
321
|
+
},
|
|
322
|
+
});
|
|
312
323
|
if (linked && !requiresConnect()) {
|
|
313
324
|
unlink();
|
|
314
325
|
return;
|
package/src/types.ts
CHANGED
|
@@ -557,6 +557,17 @@ export type Message =
|
|
|
557
557
|
requestId: string;
|
|
558
558
|
link_token?: string;
|
|
559
559
|
error?: string;
|
|
560
|
+
}
|
|
561
|
+
| {
|
|
562
|
+
/**
|
|
563
|
+
* Parent → embed: info telemetry for Rollbar. The iframe reports
|
|
564
|
+
* `message` with `endpoint`, `headers`, and `body`.
|
|
565
|
+
*/
|
|
566
|
+
type: "PARENT_INFO_LOG";
|
|
567
|
+
message: string;
|
|
568
|
+
endpoint?: string;
|
|
569
|
+
headers?: Record<string, string>;
|
|
570
|
+
body?: unknown;
|
|
560
571
|
};
|
|
561
572
|
|
|
562
573
|
/**
|