@conto_finance/sdk 0.6.2-beta.1 → 0.7.1
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/README.md +8 -3
- package/dist/browserbase.d.mts +2 -1
- package/dist/browserbase.d.ts +2 -1
- package/dist/browserbase.js +5 -2
- package/dist/browserbase.mjs +1 -1
- package/dist/checkout-verifier.d.mts +2 -1
- package/dist/checkout-verifier.d.ts +2 -1
- package/dist/{chunk-VSIO6PYA.mjs → chunk-JBTJXIMI.mjs} +5 -2
- package/dist/chunk-PVMUL3JC.mjs +30 -0
- package/dist/index.d.mts +135 -4
- package/dist/index.d.ts +135 -4
- package/dist/index.js +119 -13
- package/dist/index.mjs +97 -13
- package/dist/link-wallet.d.mts +8 -2
- package/dist/link-wallet.d.ts +8 -2
- package/dist/link-wallet.js +33 -11
- package/dist/link-wallet.mjs +9 -11
- package/dist/playwright.d.mts +2 -1
- package/dist/playwright.d.ts +2 -1
- package/dist/playwright.js +5 -2
- package/dist/playwright.mjs +1 -1
- package/package.json +6 -7
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
linkTime,
|
|
3
|
+
safeLinkApprovalUrl
|
|
4
|
+
} from "./chunk-PVMUL3JC.mjs";
|
|
1
5
|
import {
|
|
2
6
|
BrowserCheckoutTargetVerificationError,
|
|
3
7
|
canonicalizeBrowserCheckoutTarget,
|
|
@@ -18,7 +22,7 @@ var require_package = __commonJS({
|
|
|
18
22
|
"package.json"(exports, module) {
|
|
19
23
|
module.exports = {
|
|
20
24
|
name: "@conto_finance/sdk",
|
|
21
|
-
version: "0.
|
|
25
|
+
version: "0.7.1",
|
|
22
26
|
description: "Conto SDK for AI agent payment authorization",
|
|
23
27
|
main: "./dist/index.js",
|
|
24
28
|
module: "./dist/index.mjs",
|
|
@@ -51,8 +55,7 @@ var require_package = __commonJS({
|
|
|
51
55
|
}
|
|
52
56
|
},
|
|
53
57
|
publishConfig: {
|
|
54
|
-
access: "public"
|
|
55
|
-
tag: "beta"
|
|
58
|
+
access: "public"
|
|
56
59
|
},
|
|
57
60
|
engines: {
|
|
58
61
|
node: ">=20.19.0"
|
|
@@ -90,7 +93,7 @@ var require_package = __commonJS({
|
|
|
90
93
|
email: "support@conto.finance"
|
|
91
94
|
},
|
|
92
95
|
dependencies: {
|
|
93
|
-
"@sentry/node": "^
|
|
96
|
+
"@sentry/node": "^11.8.0"
|
|
94
97
|
},
|
|
95
98
|
peerDependencies: {
|
|
96
99
|
"playwright-core": ">=1.50.0"
|
|
@@ -104,10 +107,10 @@ var require_package = __commonJS({
|
|
|
104
107
|
esbuild: "0.28.1"
|
|
105
108
|
},
|
|
106
109
|
devDependencies: {
|
|
107
|
-
"@types/node": "
|
|
110
|
+
"@types/node": "26.6.5",
|
|
108
111
|
"playwright-core": "1.61.0",
|
|
109
|
-
tsup: "^
|
|
110
|
-
typescript: "^
|
|
112
|
+
tsup: "^9.0.0",
|
|
113
|
+
typescript: "^6.0.3"
|
|
111
114
|
}
|
|
112
115
|
};
|
|
113
116
|
}
|
|
@@ -1229,6 +1232,25 @@ var WalletsClient = class {
|
|
|
1229
1232
|
{}
|
|
1230
1233
|
);
|
|
1231
1234
|
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Get a one-time message for a self-custody wallet's address to sign. It
|
|
1237
|
+
* expires after 10 minutes and replaces any earlier challenge.
|
|
1238
|
+
*/
|
|
1239
|
+
async createOwnershipChallenge(walletId) {
|
|
1240
|
+
return this.client.request(
|
|
1241
|
+
"POST",
|
|
1242
|
+
`/api/wallets/${encodeURIComponent(walletId)}/ownership-proof/challenge`,
|
|
1243
|
+
{}
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1246
|
+
/** Prove your organization controls a self-custody wallet's address. */
|
|
1247
|
+
async proveOwnership(walletId, input) {
|
|
1248
|
+
return this.client.request(
|
|
1249
|
+
"POST",
|
|
1250
|
+
`/api/wallets/${encodeURIComponent(walletId)}/ownership-proof`,
|
|
1251
|
+
input
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1232
1254
|
};
|
|
1233
1255
|
var PoliciesClient = class {
|
|
1234
1256
|
constructor(client) {
|
|
@@ -1481,6 +1503,8 @@ var LinkCardError = class extends ContoError {
|
|
|
1481
1503
|
this.name = "LinkCardError";
|
|
1482
1504
|
this.checkpoint = input.checkpoint;
|
|
1483
1505
|
if (input.linkRequestId) this.linkRequestId = input.linkRequestId;
|
|
1506
|
+
const approvalUrl = safeLinkApprovalUrl(input.approvalUrl);
|
|
1507
|
+
if (approvalUrl) this.approvalUrl = approvalUrl;
|
|
1484
1508
|
this.holdReleased = input.holdReleased;
|
|
1485
1509
|
}
|
|
1486
1510
|
};
|
|
@@ -2788,6 +2812,11 @@ async function closeLinkRequest(wallet, id) {
|
|
|
2788
2812
|
return status !== void 0 && LINK_CLOSED_STATUSES.has(status);
|
|
2789
2813
|
}
|
|
2790
2814
|
}
|
|
2815
|
+
function assertLinkApprovalCallback(callback) {
|
|
2816
|
+
if (callback !== void 0 && typeof callback !== "function") {
|
|
2817
|
+
throw checkoutError("onLinkApproval must be a function");
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2791
2820
|
function linkCreatedNothing(error) {
|
|
2792
2821
|
return errorCode(error) === "LINK_WALLET_UNAVAILABLE" || errorReason(error) === "invalid_input";
|
|
2793
2822
|
}
|
|
@@ -2797,6 +2826,23 @@ var LinkFailureSignal = class extends Error {
|
|
|
2797
2826
|
this.failure = failure;
|
|
2798
2827
|
}
|
|
2799
2828
|
};
|
|
2829
|
+
function linkApprovalDetails(request) {
|
|
2830
|
+
const approvalUrl = safeLinkApprovalUrl(request.approvalUrl);
|
|
2831
|
+
const approvalExpiresAt = linkTime(request.approvalExpiresAt);
|
|
2832
|
+
return {
|
|
2833
|
+
...approvalUrl ? { approvalUrl } : {},
|
|
2834
|
+
...approvalExpiresAt ? { approvalExpiresAt } : {}
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
function notifyLinkApproval(callback, event) {
|
|
2838
|
+
try {
|
|
2839
|
+
const result = callback(Object.freeze(event));
|
|
2840
|
+
if (result !== null && typeof result === "object" && "then" in result) {
|
|
2841
|
+
Promise.resolve(result).catch(() => void 0);
|
|
2842
|
+
}
|
|
2843
|
+
} catch {
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2800
2846
|
var _client4, _CheckoutClient_instances, linkCardFor_fn;
|
|
2801
2847
|
var CheckoutClient = class {
|
|
2802
2848
|
constructor(client) {
|
|
@@ -2982,7 +3028,9 @@ var CheckoutClient = class {
|
|
|
2982
3028
|
* 1. Conto runs checkpoint 1 and holds the spend. When a rule requires the
|
|
2983
3029
|
* owner's approval, this waits for it.
|
|
2984
3030
|
* 2. Only then does the wallet ask Link for a card for exactly the approved
|
|
2985
|
-
* amount at this merchant. The person approves it in
|
|
3031
|
+
* amount at this merchant. The person approves it in Link. Pass
|
|
3032
|
+
* onLinkApproval to get Link's approval page, so they can approve on the
|
|
3033
|
+
* web without the Link app.
|
|
2986
3034
|
* 3. The card is returned. It never reaches Conto.
|
|
2987
3035
|
*
|
|
2988
3036
|
* Then fill in the card, call confirm(result.checkpoint, { amountMinor,
|
|
@@ -2998,10 +3046,18 @@ var CheckoutClient = class {
|
|
|
2998
3046
|
* Link request.
|
|
2999
3047
|
*/
|
|
3000
3048
|
async getLinkCard(input) {
|
|
3001
|
-
const {
|
|
3049
|
+
const {
|
|
3050
|
+
wallet,
|
|
3051
|
+
ownerApprovalTimeoutMs,
|
|
3052
|
+
linkApprovalTimeoutMs,
|
|
3053
|
+
onLinkApproval,
|
|
3054
|
+
signal,
|
|
3055
|
+
...beginInput
|
|
3056
|
+
} = input;
|
|
3002
3057
|
if (!wallet || typeof wallet.createCardRequest !== "function") {
|
|
3003
3058
|
throw checkoutError("wallet must be a LinkWallet, such as linkCliWallet()");
|
|
3004
3059
|
}
|
|
3060
|
+
assertLinkApprovalCallback(onLinkApproval);
|
|
3005
3061
|
let checkpoint = await this.begin({ ...beginInput, checkoutMethod: "LINK" });
|
|
3006
3062
|
if (checkpoint.stage === "AWAITING_APPROVAL") {
|
|
3007
3063
|
checkpoint = await this.waitForApproval(checkpoint, {
|
|
@@ -3009,7 +3065,11 @@ var CheckoutClient = class {
|
|
|
3009
3065
|
...signal ? { signal } : {}
|
|
3010
3066
|
});
|
|
3011
3067
|
}
|
|
3012
|
-
return __privateMethod(this, _CheckoutClient_instances, linkCardFor_fn).call(this, checkpoint, wallet,
|
|
3068
|
+
return __privateMethod(this, _CheckoutClient_instances, linkCardFor_fn).call(this, checkpoint, wallet, {
|
|
3069
|
+
linkApprovalTimeoutMs,
|
|
3070
|
+
signal,
|
|
3071
|
+
onLinkApproval
|
|
3072
|
+
});
|
|
3013
3073
|
}
|
|
3014
3074
|
/**
|
|
3015
3075
|
* The final total differs from the one the Link card covers. This cancels
|
|
@@ -3018,10 +3078,18 @@ var CheckoutClient = class {
|
|
|
3018
3078
|
* for it. Confirm the returned checkpoint with the same total.
|
|
3019
3079
|
*/
|
|
3020
3080
|
async replaceLinkCard(previous, input) {
|
|
3021
|
-
const {
|
|
3081
|
+
const {
|
|
3082
|
+
wallet,
|
|
3083
|
+
amountMinor,
|
|
3084
|
+
ownerApprovalTimeoutMs,
|
|
3085
|
+
linkApprovalTimeoutMs,
|
|
3086
|
+
onLinkApproval,
|
|
3087
|
+
signal
|
|
3088
|
+
} = input;
|
|
3022
3089
|
if (!Number.isSafeInteger(amountMinor) || amountMinor <= 0) {
|
|
3023
3090
|
throw checkoutError("amountMinor must be a positive integer number of cents");
|
|
3024
3091
|
}
|
|
3092
|
+
assertLinkApprovalCallback(onLinkApproval);
|
|
3025
3093
|
if (amountMinor === previous.checkpoint.amountMinor) return previous;
|
|
3026
3094
|
const old = previous.checkpoint;
|
|
3027
3095
|
if (!await closeLinkRequest(wallet, previous.linkRequestId)) {
|
|
@@ -3060,12 +3128,17 @@ var CheckoutClient = class {
|
|
|
3060
3128
|
...signal ? { signal } : {}
|
|
3061
3129
|
});
|
|
3062
3130
|
}
|
|
3063
|
-
return __privateMethod(this, _CheckoutClient_instances, linkCardFor_fn).call(this, checkpoint, wallet,
|
|
3131
|
+
return __privateMethod(this, _CheckoutClient_instances, linkCardFor_fn).call(this, checkpoint, wallet, {
|
|
3132
|
+
linkApprovalTimeoutMs,
|
|
3133
|
+
signal,
|
|
3134
|
+
onLinkApproval
|
|
3135
|
+
});
|
|
3064
3136
|
}
|
|
3065
3137
|
};
|
|
3066
3138
|
_client4 = new WeakMap();
|
|
3067
3139
|
_CheckoutClient_instances = new WeakSet();
|
|
3068
|
-
linkCardFor_fn = async function(checkpoint, wallet,
|
|
3140
|
+
linkCardFor_fn = async function(checkpoint, wallet, options) {
|
|
3141
|
+
const { linkApprovalTimeoutMs = 10 * 6e4, signal, onLinkApproval } = options;
|
|
3069
3142
|
if (checkpoint.stage !== "APPROVED") {
|
|
3070
3143
|
throw checkoutError(
|
|
3071
3144
|
`Conto has not approved a card for this checkpoint (stage ${checkpoint.stage}). Do not pay.`,
|
|
@@ -3075,6 +3148,7 @@ linkCardFor_fn = async function(checkpoint, wallet, linkApprovalTimeoutMs = 10 *
|
|
|
3075
3148
|
const deadline = Date.now() + linkApprovalTimeoutMs;
|
|
3076
3149
|
const call = signal ? { signal } : {};
|
|
3077
3150
|
let linkRequestId;
|
|
3151
|
+
let approvalUrl;
|
|
3078
3152
|
let createStarted = false;
|
|
3079
3153
|
try {
|
|
3080
3154
|
const cardRequest = linkCardRequest(checkpoint);
|
|
@@ -3095,6 +3169,13 @@ linkCardFor_fn = async function(checkpoint, wallet, linkApprovalTimeoutMs = 10 *
|
|
|
3095
3169
|
message: "Link returned a request for a different amount."
|
|
3096
3170
|
});
|
|
3097
3171
|
}
|
|
3172
|
+
if (LINK_WAITING_STATUSES.has(request.status)) {
|
|
3173
|
+
const details = linkApprovalDetails(request);
|
|
3174
|
+
approvalUrl = details.approvalUrl;
|
|
3175
|
+
if (onLinkApproval) {
|
|
3176
|
+
notifyLinkApproval(onLinkApproval, { checkpoint, linkRequestId: request.id, ...details });
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3098
3179
|
while (linkRequestWaiting(request)) {
|
|
3099
3180
|
const remainingSeconds = Math.floor((deadline - Date.now()) / 1e3);
|
|
3100
3181
|
if (remainingSeconds <= 0) {
|
|
@@ -3109,6 +3190,7 @@ linkCardFor_fn = async function(checkpoint, wallet, linkApprovalTimeoutMs = 10 *
|
|
|
3109
3190
|
...call,
|
|
3110
3191
|
timeoutSeconds: remainingSeconds
|
|
3111
3192
|
});
|
|
3193
|
+
approvalUrl = LINK_WAITING_STATUSES.has(request.status) ? linkApprovalDetails(request).approvalUrl ?? approvalUrl : void 0;
|
|
3112
3194
|
if (linkRequestWaiting(request) && Date.now() - started < 1e3) {
|
|
3113
3195
|
await sleep2(1e3, signal);
|
|
3114
3196
|
}
|
|
@@ -3140,6 +3222,7 @@ linkCardFor_fn = async function(checkpoint, wallet, linkApprovalTimeoutMs = 10 *
|
|
|
3140
3222
|
code: "LINK_CARD_NOT_CANCELLED",
|
|
3141
3223
|
checkpoint,
|
|
3142
3224
|
linkRequestId,
|
|
3225
|
+
...approvalUrl ? { approvalUrl } : {},
|
|
3143
3226
|
holdReleased: false,
|
|
3144
3227
|
retryGuidance: "Retry with the same input to resume this Link request, or cancel it with wallet.cancel(error.linkRequestId) and then call checkout.cancel(error.checkpoint.id)."
|
|
3145
3228
|
});
|
|
@@ -3153,6 +3236,7 @@ linkCardFor_fn = async function(checkpoint, wallet, linkApprovalTimeoutMs = 10 *
|
|
|
3153
3236
|
code: failure.code,
|
|
3154
3237
|
checkpoint,
|
|
3155
3238
|
...linkRequestId ? { linkRequestId } : {},
|
|
3239
|
+
...linkRequestId && approvalUrl ? { approvalUrl } : {},
|
|
3156
3240
|
holdReleased
|
|
3157
3241
|
});
|
|
3158
3242
|
}
|
package/dist/link-wallet.d.mts
CHANGED
|
@@ -38,8 +38,13 @@ interface LinkSpendRequest {
|
|
|
38
38
|
amountMinor?: number;
|
|
39
39
|
merchantName?: string;
|
|
40
40
|
merchantUrl?: string;
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The Stripe Link page where the person can approve the request on the web
|
|
43
|
+
* while signed in to Link. Only an HTTPS link.com address is kept.
|
|
44
|
+
*/
|
|
42
45
|
approvalUrl?: string;
|
|
46
|
+
/** When Link stops accepting approval for the request, as an ISO 8601 time. */
|
|
47
|
+
approvalExpiresAt?: string;
|
|
43
48
|
/** Set with requires_action. `auto_resume` means Link continues once the person finishes the step. */
|
|
44
49
|
actionResolution?: string;
|
|
45
50
|
/** Set with requires_action when Link gives the person a page to finish the step. */
|
|
@@ -117,4 +122,5 @@ declare function isLinkRequestId(value: unknown): value is string;
|
|
|
117
122
|
*/
|
|
118
123
|
declare function linkCliWallet(options?: LinkCliWalletOptions): LinkWallet;
|
|
119
124
|
|
|
120
|
-
export {
|
|
125
|
+
export { LinkWalletError, isLinkRequestId, linkCliWallet };
|
|
126
|
+
export type { LinkCallOptions, LinkCardCredential, LinkCardRequestInput, LinkCliWalletOptions, LinkSpendRequest, LinkSpendRequestStatus, LinkWaitOptions, LinkWallet, LinkWalletErrorReason };
|
package/dist/link-wallet.d.ts
CHANGED
|
@@ -38,8 +38,13 @@ interface LinkSpendRequest {
|
|
|
38
38
|
amountMinor?: number;
|
|
39
39
|
merchantName?: string;
|
|
40
40
|
merchantUrl?: string;
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The Stripe Link page where the person can approve the request on the web
|
|
43
|
+
* while signed in to Link. Only an HTTPS link.com address is kept.
|
|
44
|
+
*/
|
|
42
45
|
approvalUrl?: string;
|
|
46
|
+
/** When Link stops accepting approval for the request, as an ISO 8601 time. */
|
|
47
|
+
approvalExpiresAt?: string;
|
|
43
48
|
/** Set with requires_action. `auto_resume` means Link continues once the person finishes the step. */
|
|
44
49
|
actionResolution?: string;
|
|
45
50
|
/** Set with requires_action when Link gives the person a page to finish the step. */
|
|
@@ -117,4 +122,5 @@ declare function isLinkRequestId(value: unknown): value is string;
|
|
|
117
122
|
*/
|
|
118
123
|
declare function linkCliWallet(options?: LinkCliWalletOptions): LinkWallet;
|
|
119
124
|
|
|
120
|
-
export {
|
|
125
|
+
export { LinkWalletError, isLinkRequestId, linkCliWallet };
|
|
126
|
+
export type { LinkCallOptions, LinkCardCredential, LinkCardRequestInput, LinkCliWalletOptions, LinkSpendRequest, LinkSpendRequestStatus, LinkWaitOptions, LinkWallet, LinkWalletErrorReason };
|
package/dist/link-wallet.js
CHANGED
|
@@ -40,6 +40,34 @@ var import_node_fs = require("fs");
|
|
|
40
40
|
var import_promises = require("fs/promises");
|
|
41
41
|
var import_node_os = require("os");
|
|
42
42
|
var import_node_path = __toESM(require("path"));
|
|
43
|
+
|
|
44
|
+
// src/link-approval.ts
|
|
45
|
+
function safeLinkApprovalUrl(value) {
|
|
46
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 2048) return void 0;
|
|
47
|
+
let url;
|
|
48
|
+
try {
|
|
49
|
+
url = new URL(value);
|
|
50
|
+
} catch {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
if (url.protocol !== "https:" || url.username !== "" || url.password !== "" || url.port !== "" || !(url.hostname === "link.com" || url.hostname.endsWith(".link.com"))) {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
url.hash = "";
|
|
57
|
+
return url.toString();
|
|
58
|
+
}
|
|
59
|
+
function linkTime(value) {
|
|
60
|
+
let ms = Number.NaN;
|
|
61
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
62
|
+
ms = value < 1e12 ? value * 1e3 : value;
|
|
63
|
+
} else if (typeof value === "string" && value.length > 0 && value.length <= 64) {
|
|
64
|
+
ms = Date.parse(value);
|
|
65
|
+
}
|
|
66
|
+
const date = new Date(ms);
|
|
67
|
+
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/link-wallet.ts
|
|
43
71
|
var LinkWalletError = class extends Error {
|
|
44
72
|
constructor(reason, message, linkCode) {
|
|
45
73
|
super(message);
|
|
@@ -102,13 +130,16 @@ function parseSpendRequest(value) {
|
|
|
102
130
|
const status = typeof data.status === "string" && KNOWN_STATUSES.has(data.status) ? data.status : "unknown";
|
|
103
131
|
const nextAction = record(record(record(data.status_details).requires_action).next_action);
|
|
104
132
|
const amount = data.amount;
|
|
133
|
+
const approvalUrl = safeLinkApprovalUrl(data.approval_url);
|
|
134
|
+
const approvalExpiresAt = linkTime(data.approval_window_expires_at);
|
|
105
135
|
return {
|
|
106
136
|
id,
|
|
107
137
|
status,
|
|
108
138
|
...Number.isSafeInteger(amount) ? { amountMinor: amount } : {},
|
|
109
139
|
...text(data.merchant_name) ? { merchantName: text(data.merchant_name) } : {},
|
|
110
140
|
...httpsUrl(data.merchant_url) ? { merchantUrl: httpsUrl(data.merchant_url) } : {},
|
|
111
|
-
...
|
|
141
|
+
...approvalUrl ? { approvalUrl } : {},
|
|
142
|
+
...approvalExpiresAt ? { approvalExpiresAt } : {},
|
|
112
143
|
...text(nextAction.resolution) ? { actionResolution: text(nextAction.resolution) } : {},
|
|
113
144
|
...httpsUrl(nextAction.action_url) ? { actionUrl: httpsUrl(nextAction.action_url) } : {}
|
|
114
145
|
};
|
|
@@ -116,15 +147,6 @@ function parseSpendRequest(value) {
|
|
|
116
147
|
function invalidCard() {
|
|
117
148
|
return new LinkWalletError("invalid_response", "Link returned card data this SDK cannot read.");
|
|
118
149
|
}
|
|
119
|
-
function validUntil(value) {
|
|
120
|
-
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
121
|
-
return new Date(value < 1e12 ? value * 1e3 : value).toISOString();
|
|
122
|
-
}
|
|
123
|
-
if (typeof value === "string" && !Number.isNaN(Date.parse(value))) {
|
|
124
|
-
return new Date(value).toISOString();
|
|
125
|
-
}
|
|
126
|
-
return void 0;
|
|
127
|
-
}
|
|
128
150
|
function parseCard(value) {
|
|
129
151
|
const card = record(value);
|
|
130
152
|
const number = typeof card.number === "string" ? card.number.replace(/[\s-]/g, "") : "";
|
|
@@ -136,7 +158,7 @@ function parseCard(value) {
|
|
|
136
158
|
if (!/^\d{12,19}$/.test(number) || !/^\d{3,4}$/.test(securityValue) || !Number.isInteger(expMonth) || expMonth < 1 || expMonth > 12 || !Number.isInteger(expYear) || expYear < 2e3) {
|
|
137
159
|
throw invalidCard();
|
|
138
160
|
}
|
|
139
|
-
const until =
|
|
161
|
+
const until = linkTime(card.valid_until);
|
|
140
162
|
const brand = text(card.brand);
|
|
141
163
|
return {
|
|
142
164
|
number,
|
package/dist/link-wallet.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
linkTime,
|
|
3
|
+
safeLinkApprovalUrl
|
|
4
|
+
} from "./chunk-PVMUL3JC.mjs";
|
|
1
5
|
import "./chunk-TGOYFBKZ.mjs";
|
|
2
6
|
|
|
3
7
|
// src/link-wallet.ts
|
|
@@ -68,13 +72,16 @@ function parseSpendRequest(value) {
|
|
|
68
72
|
const status = typeof data.status === "string" && KNOWN_STATUSES.has(data.status) ? data.status : "unknown";
|
|
69
73
|
const nextAction = record(record(record(data.status_details).requires_action).next_action);
|
|
70
74
|
const amount = data.amount;
|
|
75
|
+
const approvalUrl = safeLinkApprovalUrl(data.approval_url);
|
|
76
|
+
const approvalExpiresAt = linkTime(data.approval_window_expires_at);
|
|
71
77
|
return {
|
|
72
78
|
id,
|
|
73
79
|
status,
|
|
74
80
|
...Number.isSafeInteger(amount) ? { amountMinor: amount } : {},
|
|
75
81
|
...text(data.merchant_name) ? { merchantName: text(data.merchant_name) } : {},
|
|
76
82
|
...httpsUrl(data.merchant_url) ? { merchantUrl: httpsUrl(data.merchant_url) } : {},
|
|
77
|
-
...
|
|
83
|
+
...approvalUrl ? { approvalUrl } : {},
|
|
84
|
+
...approvalExpiresAt ? { approvalExpiresAt } : {},
|
|
78
85
|
...text(nextAction.resolution) ? { actionResolution: text(nextAction.resolution) } : {},
|
|
79
86
|
...httpsUrl(nextAction.action_url) ? { actionUrl: httpsUrl(nextAction.action_url) } : {}
|
|
80
87
|
};
|
|
@@ -82,15 +89,6 @@ function parseSpendRequest(value) {
|
|
|
82
89
|
function invalidCard() {
|
|
83
90
|
return new LinkWalletError("invalid_response", "Link returned card data this SDK cannot read.");
|
|
84
91
|
}
|
|
85
|
-
function validUntil(value) {
|
|
86
|
-
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
87
|
-
return new Date(value < 1e12 ? value * 1e3 : value).toISOString();
|
|
88
|
-
}
|
|
89
|
-
if (typeof value === "string" && !Number.isNaN(Date.parse(value))) {
|
|
90
|
-
return new Date(value).toISOString();
|
|
91
|
-
}
|
|
92
|
-
return void 0;
|
|
93
|
-
}
|
|
94
92
|
function parseCard(value) {
|
|
95
93
|
const card = record(value);
|
|
96
94
|
const number = typeof card.number === "string" ? card.number.replace(/[\s-]/g, "") : "";
|
|
@@ -102,7 +100,7 @@ function parseCard(value) {
|
|
|
102
100
|
if (!/^\d{12,19}$/.test(number) || !/^\d{3,4}$/.test(securityValue) || !Number.isInteger(expMonth) || expMonth < 1 || expMonth > 12 || !Number.isInteger(expYear) || expYear < 2e3) {
|
|
103
101
|
throw invalidCard();
|
|
104
102
|
}
|
|
105
|
-
const until =
|
|
103
|
+
const until = linkTime(card.valid_until);
|
|
106
104
|
const brand = text(card.brand);
|
|
107
105
|
return {
|
|
108
106
|
number,
|
package/dist/playwright.d.mts
CHANGED
|
@@ -256,4 +256,5 @@ declare function createGuardedPlaywrightCheckoutRuntimeHost(config: GuardedPlayw
|
|
|
256
256
|
*/
|
|
257
257
|
declare function createGuardedPlaywrightCheckoutHttpHandler(config: GuardedPlaywrightCheckoutHttpHandlerConfig): GuardedPlaywrightCheckoutHttpHandler;
|
|
258
258
|
|
|
259
|
-
export {
|
|
259
|
+
export { createEncryptedPlaywrightCheckoutTargetStore, createGuardedPlaywrightCheckoutHttpHandler, createGuardedPlaywrightCheckoutRuntime, createGuardedPlaywrightCheckoutRuntimeHost, createInMemoryPlaywrightCheckoutTargetStore, createPlaywrightCdpSessionRegistry, createPlaywrightCheckoutAdapter, createPlaywrightSessionObserver };
|
|
260
|
+
export type { DiscoverPlaywrightCheckoutTargetInput, DiscoveredPlaywrightCheckoutTarget, EncryptedPlaywrightCheckoutTargetStoreConfig, GuardedPlaywrightCheckoutClient, GuardedPlaywrightCheckoutHttpHandler, GuardedPlaywrightCheckoutHttpHandlerConfig, GuardedPlaywrightCheckoutHttpRequest, GuardedPlaywrightCheckoutRuntime, GuardedPlaywrightCheckoutRuntimeConfig, GuardedPlaywrightCheckoutRuntimeHost, GuardedPlaywrightCheckoutRuntimeHostConfig, PlaywrightCdpSessionRegistry, PlaywrightCdpSessionRegistryConfig, PlaywrightCheckoutAdapter, PlaywrightCheckoutAdapterConfig, PlaywrightCheckoutDispatchResult, PlaywrightCheckoutTargetBlobStore, PlaywrightCheckoutTargetRegistration, PlaywrightCheckoutTargetStore, PlaywrightSessionInteractiveTarget, PlaywrightSessionObservation, PlaywrightSessionObserver, PlaywrightSessionObserverConfig };
|
package/dist/playwright.d.ts
CHANGED
|
@@ -256,4 +256,5 @@ declare function createGuardedPlaywrightCheckoutRuntimeHost(config: GuardedPlayw
|
|
|
256
256
|
*/
|
|
257
257
|
declare function createGuardedPlaywrightCheckoutHttpHandler(config: GuardedPlaywrightCheckoutHttpHandlerConfig): GuardedPlaywrightCheckoutHttpHandler;
|
|
258
258
|
|
|
259
|
-
export {
|
|
259
|
+
export { createEncryptedPlaywrightCheckoutTargetStore, createGuardedPlaywrightCheckoutHttpHandler, createGuardedPlaywrightCheckoutRuntime, createGuardedPlaywrightCheckoutRuntimeHost, createInMemoryPlaywrightCheckoutTargetStore, createPlaywrightCdpSessionRegistry, createPlaywrightCheckoutAdapter, createPlaywrightSessionObserver };
|
|
260
|
+
export type { DiscoverPlaywrightCheckoutTargetInput, DiscoveredPlaywrightCheckoutTarget, EncryptedPlaywrightCheckoutTargetStoreConfig, GuardedPlaywrightCheckoutClient, GuardedPlaywrightCheckoutHttpHandler, GuardedPlaywrightCheckoutHttpHandlerConfig, GuardedPlaywrightCheckoutHttpRequest, GuardedPlaywrightCheckoutRuntime, GuardedPlaywrightCheckoutRuntimeConfig, GuardedPlaywrightCheckoutRuntimeHost, GuardedPlaywrightCheckoutRuntimeHostConfig, PlaywrightCdpSessionRegistry, PlaywrightCdpSessionRegistryConfig, PlaywrightCheckoutAdapter, PlaywrightCheckoutAdapterConfig, PlaywrightCheckoutDispatchResult, PlaywrightCheckoutTargetBlobStore, PlaywrightCheckoutTargetRegistration, PlaywrightCheckoutTargetStore, PlaywrightSessionInteractiveTarget, PlaywrightSessionObservation, PlaywrightSessionObserver, PlaywrightSessionObserverConfig };
|
package/dist/playwright.js
CHANGED
|
@@ -322,13 +322,16 @@ function createEncryptedPlaywrightCheckoutTargetStore(config) {
|
|
|
322
322
|
if (envelope.version !== TARGET_STORE_ENVELOPE_VERSION || typeof envelope.iv !== "string" || typeof envelope.ciphertext !== "string" || typeof envelope.tag !== "string") {
|
|
323
323
|
throw new Error("invalid envelope");
|
|
324
324
|
}
|
|
325
|
+
const tag = Buffer.from(envelope.tag, "base64url");
|
|
326
|
+
if (tag.length !== 16) throw new Error("invalid envelope");
|
|
325
327
|
const decipher = (0, import_node_crypto2.createDecipheriv)(
|
|
326
328
|
"aes-256-gcm",
|
|
327
329
|
key,
|
|
328
|
-
Buffer.from(envelope.iv, "base64url")
|
|
330
|
+
Buffer.from(envelope.iv, "base64url"),
|
|
331
|
+
{ authTagLength: 16 }
|
|
329
332
|
);
|
|
330
333
|
decipher.setAAD(Buffer.from(storageKey));
|
|
331
|
-
decipher.setAuthTag(
|
|
334
|
+
decipher.setAuthTag(tag);
|
|
332
335
|
const plaintext = Buffer.concat([
|
|
333
336
|
decipher.update(Buffer.from(envelope.ciphertext, "base64url")),
|
|
334
337
|
decipher.final()
|
package/dist/playwright.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conto_finance/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Conto SDK for AI agent payment authorization",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
|
-
"access": "public"
|
|
37
|
-
"tag": "beta"
|
|
36
|
+
"access": "public"
|
|
38
37
|
},
|
|
39
38
|
"engines": {
|
|
40
39
|
"node": ">=20.19.0"
|
|
@@ -72,7 +71,7 @@
|
|
|
72
71
|
"email": "support@conto.finance"
|
|
73
72
|
},
|
|
74
73
|
"dependencies": {
|
|
75
|
-
"@sentry/node": "^
|
|
74
|
+
"@sentry/node": "^11.8.0"
|
|
76
75
|
},
|
|
77
76
|
"peerDependencies": {
|
|
78
77
|
"playwright-core": ">=1.50.0"
|
|
@@ -86,9 +85,9 @@
|
|
|
86
85
|
"esbuild": "0.28.1"
|
|
87
86
|
},
|
|
88
87
|
"devDependencies": {
|
|
89
|
-
"@types/node": "
|
|
88
|
+
"@types/node": "26.6.5",
|
|
90
89
|
"playwright-core": "1.61.0",
|
|
91
|
-
"tsup": "^
|
|
92
|
-
"typescript": "^
|
|
90
|
+
"tsup": "^9.0.0",
|
|
91
|
+
"typescript": "^6.0.3"
|
|
93
92
|
}
|
|
94
93
|
}
|