@agent-cards/sdk 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/PREFLIGHT.md +34 -0
  3. package/README.md +1217 -15
  4. package/dist/aci.d.ts +173 -0
  5. package/dist/aci.generated.d.ts +87 -0
  6. package/dist/aci.generated.js +306 -0
  7. package/dist/aci.js +371 -0
  8. package/dist/adyen-merchant-hosted.generated.d.ts +3 -3
  9. package/dist/adyen-merchant-hosted.generated.js +283 -49
  10. package/dist/agentcard.d.ts +9 -2
  11. package/dist/agentcard.js +4 -2
  12. package/dist/amadeus-checkout.generated.d.ts +57 -0
  13. package/dist/amadeus-checkout.generated.js +549 -0
  14. package/dist/amadeus.d.ts +41 -0
  15. package/dist/amadeus.js +81 -0
  16. package/dist/builtin-registry.generated.js +1 -1
  17. package/dist/card-endpoint.d.ts +177 -0
  18. package/dist/card-endpoint.js +286 -0
  19. package/dist/card-fields.generated.d.ts +5 -3
  20. package/dist/card-fields.generated.js +284 -7
  21. package/dist/cdp.d.ts +6 -1
  22. package/dist/cdp.js +983 -147
  23. package/dist/client.d.ts +493 -13
  24. package/dist/client.js +1100 -82
  25. package/dist/creditguard.generated.d.ts +79 -0
  26. package/dist/creditguard.generated.js +662 -0
  27. package/dist/cse-body.js +11 -1
  28. package/dist/cybersource-flex.d.ts +183 -0
  29. package/dist/cybersource-flex.generated.d.ts +92 -0
  30. package/dist/cybersource-flex.generated.js +689 -0
  31. package/dist/cybersource-flex.js +275 -0
  32. package/dist/datatrans.d.ts +96 -0
  33. package/dist/datatrans.generated.d.ts +64 -0
  34. package/dist/datatrans.generated.js +426 -0
  35. package/dist/datatrans.js +178 -0
  36. package/dist/elavon-converge.d.ts +37 -0
  37. package/dist/elavon-converge.generated.d.ts +49 -0
  38. package/dist/elavon-converge.generated.js +439 -0
  39. package/dist/elavon-converge.js +84 -0
  40. package/dist/eprotect.d.ts +152 -0
  41. package/dist/eprotect.generated.d.ts +77 -0
  42. package/dist/eprotect.generated.js +498 -0
  43. package/dist/eprotect.js +222 -0
  44. package/dist/gmo.d.ts +63 -0
  45. package/dist/gmo.generated.d.ts +60 -0
  46. package/dist/gmo.generated.js +586 -0
  47. package/dist/gmo.js +119 -0
  48. package/dist/hosted-form.d.ts +3 -2
  49. package/dist/hosted-form.js +3 -2
  50. package/dist/index.d.ts +19 -3
  51. package/dist/index.js +6 -1
  52. package/dist/juspay-gate.d.ts +82 -0
  53. package/dist/juspay-gate.js +126 -0
  54. package/dist/juspay.generated.d.ts +89 -0
  55. package/dist/juspay.generated.js +705 -0
  56. package/dist/lifecycle.d.ts +62 -6
  57. package/dist/lifecycle.js +123 -8
  58. package/dist/merchant-card-endpoints.generated.d.ts +63 -0
  59. package/dist/merchant-card-endpoints.generated.js +1103 -0
  60. package/dist/merchant-hosted.d.ts +4 -1
  61. package/dist/merchant-hosted.js +5 -2
  62. package/dist/merchant-session-probe.d.ts +48 -0
  63. package/dist/merchant-session-probe.js +53 -0
  64. package/dist/merchant-session.generated.d.ts +69 -0
  65. package/dist/merchant-session.generated.js +919 -0
  66. package/dist/payrails.d.ts +133 -0
  67. package/dist/payrails.generated.d.ts +73 -0
  68. package/dist/payrails.generated.js +596 -0
  69. package/dist/payrails.js +305 -0
  70. package/dist/pelecard.d.ts +32 -0
  71. package/dist/pelecard.generated.d.ts +32 -0
  72. package/dist/pelecard.generated.js +283 -0
  73. package/dist/pelecard.js +42 -0
  74. package/dist/pre-claim.d.ts +84 -3
  75. package/dist/pre-claim.js +987 -9
  76. package/dist/preflight-catalog.json +2310 -263
  77. package/dist/preflight-schemas.json +187 -6
  78. package/dist/preflight.generated.d.ts +1 -1
  79. package/dist/preflight.generated.js +247 -4
  80. package/dist/preparation.d.ts +5 -2
  81. package/dist/preparation.js +36 -10
  82. package/dist/prepared-processor.d.ts +86 -5
  83. package/dist/prepared-processor.js +157 -6
  84. package/dist/primer.d.ts +53 -0
  85. package/dist/primer.generated.d.ts +38 -0
  86. package/dist/primer.generated.js +624 -0
  87. package/dist/primer.js +82 -0
  88. package/dist/registry.d.ts +114 -12
  89. package/dist/registry.js +85 -11
  90. package/dist/shiji-sts.d.ts +144 -0
  91. package/dist/shiji-sts.generated.d.ts +72 -0
  92. package/dist/shiji-sts.generated.js +913 -0
  93. package/dist/shiji-sts.js +222 -0
  94. package/dist/stripe-checkout.generated.d.ts +1 -1
  95. package/dist/stripe-checkout.generated.js +735 -10
  96. package/dist/stripe-setup.d.ts +16 -0
  97. package/dist/stripe-setup.js +61 -0
  98. package/dist/substitutions.generated.js +187 -29
  99. package/dist/verifone.d.ts +68 -0
  100. package/dist/verifone.generated.d.ts +51 -0
  101. package/dist/verifone.generated.js +1401 -0
  102. package/dist/verifone.js +119 -0
  103. package/dist/voice-types.d.ts +27 -0
  104. package/dist/voice.d.ts +6 -1
  105. package/dist/voice.js +6 -1
  106. package/dist/wspay.d.ts +41 -0
  107. package/dist/wspay.generated.d.ts +41 -0
  108. package/dist/wspay.generated.js +370 -0
  109. package/dist/wspay.js +65 -0
  110. package/examples/preflight/kernel-native/inventory.json +1 -1
  111. package/package.json +3 -3
@@ -100,7 +100,10 @@ export declare function armServedProfiles(entries?: readonly unknown[]): Merchan
100
100
  * under a test_ key.
101
101
  */
102
102
  export declare function declareSandboxMerchant(input: SandboxMerchantDeclaration): MerchantProfile;
103
- /** The armed profile whose endpoint, or a sibling of it (same origin and path shape), a URL is; null for any other URL. */
103
+ /**
104
+ * The armed profile whose endpoint, a sibling of it (same origin and path shape), its then
105
+ * request or one of its other card requests a URL is; null for any other URL.
106
+ */
104
107
  export declare function merchantProfileFor(profiles: readonly MerchantProfile[], url: string): MerchantProfile | null;
105
108
  /** The Fetch.enable globs that pause every armed profile's endpoint and its siblings, a declared endpoint included. */
106
109
  export declare function merchantProfileUrlPatterns(profiles: readonly MerchantProfile[]): string[];
@@ -110,11 +110,14 @@ export function declareSandboxMerchant(input) {
110
110
  return Object.freeze({ id: built.id, merchant: url.hostname, status: 'enabled',
111
111
  sandboxDeclaration: Object.freeze({ endpoint: input.endpoint, clientKey: input.clientKey }) });
112
112
  }
113
- /** How a URL relates to an armed profile: its declared endpoint when it has one, else the reviewed endpoint. */
113
+ /** How a URL relates to an armed profile: its declared endpoint when it has one, else the reviewed requests. */
114
114
  function relationTo(profile, url) {
115
115
  return profile.sandboxDeclaration ? declaredRelation(profile.sandboxDeclaration.endpoint, url) : urlRelation(profile.id, url);
116
116
  }
117
- /** The armed profile whose endpoint, or a sibling of it (same origin and path shape), a URL is; null for any other URL. */
117
+ /**
118
+ * The armed profile whose endpoint, a sibling of it (same origin and path shape), its then
119
+ * request or one of its other card requests a URL is; null for any other URL.
120
+ */
118
121
  export function merchantProfileFor(profiles, url) {
119
122
  if (typeof url !== 'string')
120
123
  return null;
@@ -0,0 +1,48 @@
1
+ /** One cookie of the merchant's jar, name and value only. */
2
+ export interface MerchantSessionCookie {
3
+ name: string;
4
+ value: string;
5
+ }
6
+ /** What a probe create carries: the reviewed profile and the kept cookies, and the names it dropped (never their values). */
7
+ export interface MerchantSessionCapture {
8
+ profile: string;
9
+ cookies: MerchantSessionCookie[];
10
+ dropped: string[];
11
+ }
12
+ /**
13
+ * Why a capture was refused before anything left this process. `signed_in`: the jar holds
14
+ * a sign-in token (phase 1 reads guest checkouts only); `no_session`: nothing but
15
+ * bot-manager cookies, or nothing at all; `invalid_session`: a cookie that is not an RFC
16
+ * 6265 pair, one name twice, or past the limits; `unknown_profile`: no reviewed read.
17
+ */
18
+ export type MerchantSessionRefusal = 'unknown_profile' | 'signed_in' | 'no_session' | 'invalid_session';
19
+ export declare class MerchantSessionRefusedError extends Error {
20
+ readonly profile: string;
21
+ readonly reason: MerchantSessionRefusal;
22
+ constructor(profile: string, reason: MerchantSessionRefusal);
23
+ }
24
+ /** The URL whose cookie jar a capture reads: the block's endpoint and read path. Null for a profile with no reviewed read. */
25
+ export declare function merchantSessionReadUrl(profile: string): string | null;
26
+ /** The capture rules alone, for a jar already read: kept cookies, dropped names, or a MerchantSessionRefusedError. */
27
+ export declare function merchantSessionCapture(profile: string, jar: readonly {
28
+ name: string;
29
+ value: string;
30
+ }[]): MerchantSessionCapture;
31
+ /** The CDP command a capture needs: Network.getCookies on the page session. */
32
+ export interface MerchantSessionCdp {
33
+ send(method: 'Network.getCookies', params: {
34
+ urls: string[];
35
+ }, sessionId?: string): Promise<{
36
+ cookies?: {
37
+ name: string;
38
+ value: string;
39
+ }[];
40
+ } | undefined>;
41
+ }
42
+ /**
43
+ * Read the merchant's cookie jar for a profile's read URL on a CDP page session (the
44
+ * agent's own browser, after the person built the cart by hand) and apply the capture
45
+ * rules. The jar is read the 14b way: Network.getCookies for the exact read URL, so only
46
+ * the cookies the merchant's own page would send there, HttpOnly included.
47
+ */
48
+ export declare function captureMerchantSession(cdp: MerchantSessionCdp, sessionId: string | undefined, profile: string): Promise<MerchantSessionCapture>;
@@ -0,0 +1,53 @@
1
+ // The merchant-session probe's capture (the deterministic merchant total, phase 0): the
2
+ // SDK reads the merchant's cookie jar for a reviewed read URL, the way the card endpoint
3
+ // capture reads it for a paused card request (Network.getCookies, HttpOnly included), and
4
+ // hands the kept cookies to the API's probe create. No card request is paused, no JWE is
5
+ // made and no card is involved: the cardholder's Vault page reads the merchant's own total
6
+ // through the merchant-session relay, once, and records what it saw.
7
+ //
8
+ // The same rules as the API and the Vault run (payment-core merchant-session.js, the SDK's
9
+ // generated copy): every bot-manager cookie is dropped (D19), and a jar that carries a
10
+ // sign-in token is refused before anything leaves this process (D22). The cookies are a
11
+ // merchant session: no event, error or log line from this module names a value.
12
+ import { MERCHANT_SESSION_PROFILES as SHARED_PROFILES, merchantSessionCookies as sharedCookies, } from './merchant-session.generated.js';
13
+ export class MerchantSessionRefusedError extends Error {
14
+ profile;
15
+ reason;
16
+ constructor(profile, reason) {
17
+ super(`refused a merchant read for ${profile} (${reason}). Nothing was sent.`);
18
+ this.profile = profile;
19
+ this.reason = reason;
20
+ this.name = 'MerchantSessionRefusedError';
21
+ }
22
+ }
23
+ const BLOCKS = SHARED_PROFILES;
24
+ const keptCookies = (profile, jar) => sharedCookies(profile, jar);
25
+ /** The URL whose cookie jar a capture reads: the block's endpoint and read path. Null for a profile with no reviewed read. */
26
+ export function merchantSessionReadUrl(profile) {
27
+ const block = BLOCKS.find((entry) => entry.profile === profile);
28
+ return block ? `${block.endpoint}${block.read.path}` : null;
29
+ }
30
+ /** The capture rules alone, for a jar already read: kept cookies, dropped names, or a MerchantSessionRefusedError. */
31
+ export function merchantSessionCapture(profile, jar) {
32
+ if (!merchantSessionReadUrl(profile))
33
+ throw new MerchantSessionRefusedError(profile, 'unknown_profile');
34
+ const kept = keptCookies(profile, (Array.isArray(jar) ? jar : []).map(({ name, value }) => ({ name, value })));
35
+ if (!kept.ok) {
36
+ const reason = kept.code === 'signed_in' || kept.code === 'no_session' || kept.code === 'unknown_profile' ? kept.code : 'invalid_session';
37
+ throw new MerchantSessionRefusedError(profile, reason);
38
+ }
39
+ return { profile, cookies: kept.cookies, dropped: kept.dropped };
40
+ }
41
+ /**
42
+ * Read the merchant's cookie jar for a profile's read URL on a CDP page session (the
43
+ * agent's own browser, after the person built the cart by hand) and apply the capture
44
+ * rules. The jar is read the 14b way: Network.getCookies for the exact read URL, so only
45
+ * the cookies the merchant's own page would send there, HttpOnly included.
46
+ */
47
+ export async function captureMerchantSession(cdp, sessionId, profile) {
48
+ const url = merchantSessionReadUrl(profile);
49
+ if (!url)
50
+ throw new MerchantSessionRefusedError(profile, 'unknown_profile');
51
+ const jar = (await cdp.send('Network.getCookies', { urls: [url] }, sessionId))?.cookies ?? [];
52
+ return merchantSessionCapture(profile, jar);
53
+ }
@@ -0,0 +1,69 @@
1
+ declare var MERCHANT_SESSION_MODE: string;
2
+ declare var MERCHANT_SESSION_USER_AGENT: string;
3
+ declare var MERCHANT_SESSION_BOT_COOKIES: any;
4
+ declare var MERCHANT_SESSION_SIGN_IN_COOKIES: any;
5
+ declare var MERCHANT_SESSION_READ_LIMITS: any;
6
+ declare var MERCHANT_SESSION_RELAY_URL: string;
7
+ declare var MERCHANT_SESSION_COOKIE_LIMITS: any;
8
+ declare var MERCHANT_SESSION_PROFILES: any;
9
+ declare function merchantSessionProfile(id: any): any;
10
+ declare function merchantSessionHosts(): unknown[];
11
+ declare function merchantSessionProfileRefusal(block: any): string | null;
12
+ declare function merchantSessionCookies(id: any, cookies: any): {
13
+ ok: boolean;
14
+ code: any;
15
+ reason: any;
16
+ } | {
17
+ ok: boolean;
18
+ cookies: {
19
+ name: any;
20
+ value: any;
21
+ }[];
22
+ dropped: any[];
23
+ header: string;
24
+ };
25
+ declare function merchantSessionRead(id: any, session: any): any;
26
+ declare var MERCHANT_SESSION_CACHE_FACT_CHARS: number;
27
+ declare function merchantSessionAnswerFacts(response: any): {
28
+ status: any;
29
+ challenge: string | null;
30
+ headerNames: string[];
31
+ cache: {};
32
+ };
33
+ declare function merchantSessionReading(id: any, response: any, { now }?: {}): {
34
+ ok: boolean;
35
+ code: any;
36
+ reason: any;
37
+ } | {
38
+ ok: boolean;
39
+ profile: any;
40
+ totalMinor: number;
41
+ currency: any;
42
+ cartId: string;
43
+ cartIdSha256: string;
44
+ expiresAt: number | null;
45
+ snapshotSha256: string;
46
+ digests: {
47
+ goods: string;
48
+ destination: string;
49
+ recipient: string;
50
+ };
51
+ kountSessionSha256: null;
52
+ } | {
53
+ ok: boolean;
54
+ profile: any;
55
+ totalMinor: number;
56
+ currency: any;
57
+ cartId: null;
58
+ cartIdSha256: null;
59
+ expiresAt: null;
60
+ snapshotSha256: string;
61
+ digests: {
62
+ goods: string;
63
+ destination: string;
64
+ recipient: string;
65
+ };
66
+ kountSessionSha256: string | null;
67
+ };
68
+ declare function sameMerchantSnapshot(a: any, b: any): boolean;
69
+ export { MERCHANT_SESSION_BOT_COOKIES, MERCHANT_SESSION_CACHE_FACT_CHARS, MERCHANT_SESSION_COOKIE_LIMITS, MERCHANT_SESSION_MODE, MERCHANT_SESSION_PROFILES, MERCHANT_SESSION_READ_LIMITS, MERCHANT_SESSION_RELAY_URL, MERCHANT_SESSION_SIGN_IN_COOKIES, MERCHANT_SESSION_USER_AGENT, merchantSessionAnswerFacts, merchantSessionCookies, merchantSessionHosts, merchantSessionProfile, merchantSessionProfileRefusal, merchantSessionRead, merchantSessionReading, sameMerchantSnapshot };