@stripe/link-sdk 0.4.1 → 0.5.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 (60) hide show
  1. package/README.md +1 -0
  2. package/dist/__tests__/config.test.d.ts +2 -0
  3. package/dist/__tests__/config.test.d.ts.map +1 -0
  4. package/dist/__tests__/errors.test.d.ts +2 -0
  5. package/dist/__tests__/errors.test.d.ts.map +1 -0
  6. package/dist/client.d.ts +16 -0
  7. package/dist/client.d.ts.map +1 -0
  8. package/dist/config.d.ts +36 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/errors.d.ts +36 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/index.d.ts +7 -443
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +4 -2
  15. package/dist/index.js.map +1 -1
  16. package/dist/resources/__tests__/balances.test.d.ts +2 -0
  17. package/dist/resources/__tests__/balances.test.d.ts.map +1 -0
  18. package/dist/resources/__tests__/factory.test.d.ts +2 -0
  19. package/dist/resources/__tests__/factory.test.d.ts.map +1 -0
  20. package/dist/resources/__tests__/payment-methods.test.d.ts +2 -0
  21. package/dist/resources/__tests__/payment-methods.test.d.ts.map +1 -0
  22. package/dist/resources/__tests__/report.test.d.ts +2 -0
  23. package/dist/resources/__tests__/report.test.d.ts.map +1 -0
  24. package/dist/resources/__tests__/shipping-address.test.d.ts +2 -0
  25. package/dist/resources/__tests__/shipping-address.test.d.ts.map +1 -0
  26. package/dist/resources/__tests__/sources.test.d.ts +2 -0
  27. package/dist/resources/__tests__/sources.test.d.ts.map +1 -0
  28. package/dist/resources/__tests__/spend-request.test.d.ts +2 -0
  29. package/dist/resources/__tests__/spend-request.test.d.ts.map +1 -0
  30. package/dist/resources/__tests__/transactions.test.d.ts +2 -0
  31. package/dist/resources/__tests__/transactions.test.d.ts.map +1 -0
  32. package/dist/resources/__tests__/user-info.test.d.ts +2 -0
  33. package/dist/resources/__tests__/user-info.test.d.ts.map +1 -0
  34. package/dist/resources/__tests__/web-bot-auth.test.d.ts +2 -0
  35. package/dist/resources/__tests__/web-bot-auth.test.d.ts.map +1 -0
  36. package/dist/resources/balances.d.ts +10 -0
  37. package/dist/resources/balances.d.ts.map +1 -0
  38. package/dist/resources/base.d.ts +31 -0
  39. package/dist/resources/base.d.ts.map +1 -0
  40. package/dist/resources/interfaces.d.ts +118 -0
  41. package/dist/resources/interfaces.d.ts.map +1 -0
  42. package/dist/resources/payment-methods.d.ts +9 -0
  43. package/dist/resources/payment-methods.d.ts.map +1 -0
  44. package/dist/resources/report.d.ts +8 -0
  45. package/dist/resources/report.d.ts.map +1 -0
  46. package/dist/resources/shipping-address.d.ts +9 -0
  47. package/dist/resources/shipping-address.d.ts.map +1 -0
  48. package/dist/resources/sources.d.ts +10 -0
  49. package/dist/resources/sources.d.ts.map +1 -0
  50. package/dist/resources/spend-request.d.ts +27 -0
  51. package/dist/resources/spend-request.d.ts.map +1 -0
  52. package/dist/resources/transactions.d.ts +10 -0
  53. package/dist/resources/transactions.d.ts.map +1 -0
  54. package/dist/resources/user-info.d.ts +9 -0
  55. package/dist/resources/user-info.d.ts.map +1 -0
  56. package/dist/resources/web-bot-auth.d.ts +10 -0
  57. package/dist/resources/web-bot-auth.d.ts.map +1 -0
  58. package/dist/types/index.d.ts +255 -0
  59. package/dist/types/index.d.ts.map +1 -0
  60. package/package.json +6 -6
package/README.md CHANGED
@@ -106,6 +106,7 @@ switch (result.status) {
106
106
  }
107
107
  case 'denied':
108
108
  case 'expired':
109
+ case 'submitted':
109
110
  case 'succeeded':
110
111
  case 'failed':
111
112
  case 'canceled':
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/config.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=errors.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/errors.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { LinkOptions } from '@/config';
2
+ import type { IBalancesResource, IPaymentMethodsResource, IReportResource, IShippingAddressResource, ISourcesResource, ISpendRequestResource, ITransactionsResource, IUserInfoResource, IWebBotAuthResource } from '@/resources/interfaces';
3
+ export declare class Link {
4
+ readonly spendRequests: ISpendRequestResource;
5
+ readonly paymentMethods: IPaymentMethodsResource;
6
+ readonly shippingAddresses: IShippingAddressResource;
7
+ readonly userInfo: IUserInfoResource;
8
+ readonly transactions: ITransactionsResource;
9
+ readonly sources: ISourcesResource;
10
+ readonly balances: IBalancesResource;
11
+ readonly webBotAuth: IWebBotAuthResource;
12
+ readonly reports: IReportResource;
13
+ constructor(options: LinkOptions);
14
+ }
15
+ export default Link;
16
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAUhC,qBAAa,IAAI;IACf,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,uBAAuB,CAAC;IACjD,QAAQ,CAAC,iBAAiB,EAAE,wBAAwB,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,qBAAqB,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC,YAAY,OAAO,EAAE,WAAW,EAU/B;CACF;eAEc,IAAI"}
@@ -0,0 +1,36 @@
1
+ import type { AccessTokenProvider } from '@/resources/interfaces';
2
+ export interface LinkSdkLogger {
3
+ debug(message: string): void;
4
+ }
5
+ interface LinkClientOptions {
6
+ verbose?: boolean;
7
+ defaultHeaders?: Record<string, string>;
8
+ fetch?: typeof globalThis.fetch;
9
+ apiBaseUrl?: string;
10
+ spendRequestBaseUrl?: string;
11
+ logger?: LinkSdkLogger;
12
+ }
13
+ export type LinkOptions = LinkClientOptions & ({
14
+ accessToken: string;
15
+ getAccessToken?: never;
16
+ } | {
17
+ accessToken?: never;
18
+ getAccessToken: AccessTokenProvider;
19
+ });
20
+ export interface ResolvedLinkSdkConfig {
21
+ verbose: boolean;
22
+ getAccessToken: AccessTokenProvider;
23
+ canRefreshAccessToken: boolean;
24
+ fetch?: typeof globalThis.fetch;
25
+ apiBaseUrl: string;
26
+ spendRequestBaseUrl: string;
27
+ logger: LinkSdkLogger;
28
+ }
29
+ export interface LinkSdkConfigDefaults {
30
+ apiBaseUrl?: string;
31
+ spendRequestBaseUrl?: string;
32
+ }
33
+ export declare function resolveLinkSdkConfig(options: LinkOptions, defaults?: LinkSdkConfigDefaults): ResolvedLinkSdkConfig;
34
+ export declare function requireFetchImplementation(config: Pick<ResolvedLinkSdkConfig, 'fetch'>): typeof globalThis.fetch;
35
+ export {};
36
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,UAAU,iBAAiB;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,GAAG,iBAAiB,GACzC,CACI;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,GAC/C;IAAE,WAAW,CAAC,EAAE,KAAK,CAAC;IAAC,cAAc,EAAE,mBAAmB,CAAA;CAAE,CAC/D,CAAC;AAEJ,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,mBAAmB,CAAC;IACpC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,aAAa,CAAC;CACvB;AAmBD,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAQD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,WAAW,EACpB,QAAQ,GAAE,qBAA0B,GACnC,qBAAqB,CAkDvB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,GAC3C,OAAO,UAAU,CAAC,KAAK,CAQzB"}
@@ -0,0 +1,36 @@
1
+ export declare class LinkSdkError extends Error {
2
+ readonly code: string;
3
+ constructor(message: string, options?: {
4
+ code?: string;
5
+ cause?: unknown;
6
+ });
7
+ }
8
+ export declare class LinkResponseError extends LinkSdkError {
9
+ readonly status: number;
10
+ constructor(operation: string, status: number, options?: {
11
+ cause?: unknown;
12
+ });
13
+ }
14
+ export declare class LinkConfigurationError extends LinkSdkError {
15
+ constructor(message: string, options?: {
16
+ cause?: unknown;
17
+ });
18
+ }
19
+ export declare class LinkTransportError extends LinkSdkError {
20
+ constructor(message: string, options?: {
21
+ cause?: unknown;
22
+ });
23
+ }
24
+ export declare class LinkApiError extends LinkSdkError {
25
+ readonly status: number;
26
+ readonly rawBody: string | undefined;
27
+ readonly details?: unknown;
28
+ constructor(message: string, options: {
29
+ status: number;
30
+ code?: string;
31
+ rawBody?: string;
32
+ details?: unknown;
33
+ cause?: unknown;
34
+ });
35
+ }
36
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAIxE;CACF;AAED,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YACE,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAa9B;CACF;AAED,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAEzD;CACF;AAED,qBAAa,kBAAmB,SAAQ,YAAY;IAClD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAEzD;CACF;AAED,qBAAa,YAAa,SAAQ,YAAY;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B,YACE,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,EAMF;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,443 +1,7 @@
1
- type JsonPrimitive = string | number | boolean | null;
2
- type JsonValue = JsonPrimitive | JsonValue[] | {
3
- [key: string]: JsonValue;
4
- };
5
- interface LineItem {
6
- name: string;
7
- url?: string;
8
- image_url?: string;
9
- description?: string;
10
- sku?: string;
11
- totals?: Total[];
12
- quantity?: number;
13
- unit_amount?: number;
14
- product_url?: string;
15
- }
16
- interface Total {
17
- type: string;
18
- display_text: string;
19
- amount: number;
20
- }
21
- interface BillingAddress {
22
- name: string;
23
- line1: string;
24
- line2?: string;
25
- city?: string;
26
- state?: string;
27
- postal_code?: string;
28
- country: string;
29
- }
30
- interface Card {
31
- id: string;
32
- brand: string;
33
- exp_month: number;
34
- exp_year: number;
35
- number: string;
36
- cvc?: string;
37
- billing_address?: BillingAddress;
38
- valid_until?: string;
39
- }
40
- /** Known statuses, while remaining forward-compatible with new API values. */
41
- type SpendRequestStatus = 'created' | 'pending_approval' | 'expired' | 'approved' | 'denied' | 'succeeded' | 'failed' | 'canceled' | 'requires_action' | (string & Record<never, never>);
42
- type NextActionType = 'ssn_verification' | 'identity_verification' | 'contact_support' | 'select_payment_method' | 'add_payment_method' | 'update_payment_method' | 're_authorize' | 'three_d_secure' | 'three_d_secure_retry';
43
- type NextActionResolution = 'auto_resume' | 'create_new_spend_request' | 'create_new_spend_request_after_completion';
44
- interface NextAction {
45
- type: NextActionType;
46
- resolution: NextActionResolution;
47
- display_message: string;
48
- action_url: string | null;
49
- expires_at?: number | null;
50
- }
51
- interface SpendRequestStatusDetails {
52
- requires_action?: {
53
- failure_code?: string;
54
- next_action: NextAction;
55
- };
56
- }
57
- type CredentialType = 'shared_payment_token' | 'card';
58
- interface ApprovalDetail {
59
- approved_at: number;
60
- approval_method: 'click' | 'programmatic' | 'voice';
61
- app_name: string;
62
- external_user_id: string;
63
- ip_address?: string;
64
- user_agent?: string;
65
- device_type?: 'mobile' | 'web';
66
- agent_log_id?: string;
67
- external_user_name?: string;
68
- external_session_id?: string;
69
- authentication_method?: 'biometric_face' | 'biometric_fingerprint' | 'passkey';
70
- }
71
- interface SharedPaymentToken {
72
- id: string;
73
- billing_address?: BillingAddress;
74
- valid_until?: string;
75
- }
76
- interface RefundDetails {
77
- amount: number;
78
- currency: string;
79
- state: string;
80
- created: number;
81
- }
82
- interface PaymentStatusDetails {
83
- outcome: 'success' | 'failure';
84
- code?: string | null;
85
- decline_code?: string | null;
86
- amount: number;
87
- currency: string;
88
- created?: number | null;
89
- refund_details?: RefundDetails | null;
90
- }
91
- interface SpendRequest {
92
- id: string;
93
- merchant_name?: string;
94
- merchant_url?: string;
95
- context?: string;
96
- amount?: number;
97
- currency?: string;
98
- line_items?: LineItem[];
99
- totals?: Total[];
100
- payment_method?: string;
101
- payment_details?: string;
102
- credential_type?: CredentialType;
103
- network_id?: string;
104
- card_brand?: string;
105
- card_last4?: string;
106
- status: SpendRequestStatus;
107
- approval_url?: string;
108
- card?: Card;
109
- shared_payment_token?: SharedPaymentToken | null;
110
- link_pay_token?: string;
111
- payment_status_details?: PaymentStatusDetails | null;
112
- status_details?: SpendRequestStatusDetails | null;
113
- link_transaction_id?: string;
114
- activity_url?: string;
115
- metadata?: Record<string, string>;
116
- expires_at?: number;
117
- created_at: string;
118
- updated_at: string;
119
- }
120
- interface RequestApprovalResponse {
121
- id: string;
122
- approval_url: string;
123
- }
124
- interface CardDetails {
125
- brand: string;
126
- last4: string;
127
- exp_month: number;
128
- exp_year: number;
129
- }
130
- interface BankAccountDetails {
131
- last4: string;
132
- bank_name?: string;
133
- }
134
- type AgentWalletVerificationStatus = 'not_required' | 'ssn_verification' | 'identity_verification' | 'contact_support' | 'complete';
135
- interface AgentWalletSpendLimits {
136
- per_transaction: {
137
- limit: number | null;
138
- };
139
- daily: {
140
- limit: number | null;
141
- used: number;
142
- remaining: number | null;
143
- };
144
- thirty_day: {
145
- limit: number | null;
146
- used: number;
147
- remaining: number | null;
148
- };
149
- }
150
- interface AgentWalletVerificationRequirement {
151
- status: AgentWalletVerificationStatus;
152
- action_url: string | null;
153
- }
154
- interface UserInfo {
155
- email?: string | null;
156
- name?: string | null;
157
- first_name?: string | null;
158
- last_name?: string | null;
159
- phone?: string | null;
160
- agent_wallet_spend_limits?: AgentWalletSpendLimits;
161
- agent_wallet_verification_requirement?: AgentWalletVerificationRequirement;
162
- }
163
- interface ProductCapability {
164
- eligible: boolean;
165
- ineligibility_reasons: string[];
166
- }
167
- interface PaymentMethod {
168
- id: string;
169
- type: string;
170
- is_default: boolean;
171
- name: string;
172
- nickname?: string;
173
- card_details?: CardDetails;
174
- bank_account_details?: BankAccountDetails;
175
- capabilities?: Record<string, ProductCapability>;
176
- }
177
- interface ShippingAddress {
178
- name: string | null;
179
- line_1: string | null;
180
- line_2: string | null;
181
- locality: string | null;
182
- dependent_locality: string | null;
183
- administrative_area: string | null;
184
- postal_code: string | null;
185
- sorting_code: string | null;
186
- country_code: string | null;
187
- }
188
- interface ShippingAddressRecord {
189
- id: string;
190
- is_default: boolean;
191
- nickname: string | null;
192
- address: ShippingAddress | null;
193
- }
194
- type TransactionOrigin = 'link' | 'external_connection';
195
- interface Transaction {
196
- id: string;
197
- source_id: string | null;
198
- amount: number;
199
- currency: string;
200
- created_date: string;
201
- description: string;
202
- origin: TransactionOrigin;
203
- category: string | null;
204
- status: string;
205
- }
206
- interface TransactionsPage {
207
- data: Transaction[];
208
- has_more?: boolean;
209
- [key: string]: unknown;
210
- }
211
- interface Source {
212
- id?: string | null;
213
- name?: string | null;
214
- type?: string | null;
215
- capabilities?: Record<string, unknown> | null;
216
- external_connection?: Record<string, unknown> | null;
217
- granted_actions?: string[] | null;
218
- bank_account?: Record<string, unknown> | null;
219
- card?: Record<string, unknown> | null;
220
- [key: string]: unknown;
221
- }
222
- interface SourcesPage {
223
- data: Source[];
224
- has_more?: boolean;
225
- [key: string]: unknown;
226
- }
227
- interface CashBalance {
228
- available: Record<string, number>;
229
- }
230
- interface CreditBalance {
231
- used: Record<string, number>;
232
- }
233
- interface Balance {
234
- source_id: string;
235
- type: 'cash' | 'credit';
236
- cash?: CashBalance | null;
237
- credit?: CreditBalance | null;
238
- current: number;
239
- currency: string;
240
- as_of: string;
241
- [key: string]: unknown;
242
- }
243
- interface BalancesPage {
244
- data: Balance[];
245
- has_more?: boolean;
246
- [key: string]: unknown;
247
- }
248
- interface WebBotAuthBlock {
249
- signature: string;
250
- signature_input: string;
251
- signature_agent: string;
252
- authority: string;
253
- expires_at: string;
254
- }
255
-
256
- interface GetAccessTokenOptions {
257
- forceRefresh?: boolean;
258
- }
259
- type AccessTokenProvider = (options?: GetAccessTokenOptions) => Promise<string> | string;
260
- interface CreateSpendRequestParams {
261
- idempotency_key?: string;
262
- payment_details?: string;
263
- credential_type?: CredentialType;
264
- network_id?: string;
265
- execution_method?: 'link_pay_token';
266
- merchant_account_id?: string;
267
- amount?: number;
268
- currency?: string;
269
- merchant_name?: string;
270
- merchant_url?: string;
271
- context: string;
272
- line_items?: LineItem[];
273
- totals?: Total[];
274
- request_approval?: boolean;
275
- test?: boolean;
276
- approval_details?: ApprovalDetail;
277
- metadata?: Record<string, string>;
278
- }
279
- interface UpdateSpendRequestParams {
280
- payment_details?: string;
281
- amount?: number;
282
- merchant_url?: string;
283
- profile_id?: string;
284
- merchant_id?: string;
285
- currency?: string;
286
- line_items?: LineItem[];
287
- totals?: Total[];
288
- }
289
- interface ISpendRequestResource {
290
- list(opts?: {
291
- includeHistory?: boolean;
292
- }): Promise<SpendRequest[]>;
293
- create(params: CreateSpendRequestParams): Promise<SpendRequest>;
294
- update(id: string, params: UpdateSpendRequestParams): Promise<SpendRequest>;
295
- requestApproval(id: string): Promise<RequestApprovalResponse>;
296
- cancel(id: string): Promise<SpendRequest>;
297
- retrieve(id: string, opts?: {
298
- include?: string[];
299
- }): Promise<SpendRequest | null>;
300
- }
301
- interface IPaymentMethodsResource {
302
- list(): Promise<PaymentMethod[]>;
303
- }
304
- interface IShippingAddressResource {
305
- list(): Promise<ShippingAddressRecord[]>;
306
- }
307
- interface IUserInfoResource {
308
- retrieve(): Promise<UserInfo>;
309
- }
310
- interface IWebBotAuthResource {
311
- signUrl(url: string): Promise<WebBotAuthBlock>;
312
- }
313
- interface ListTransactionsParams {
314
- limit?: number;
315
- starting_after?: string;
316
- ending_before?: string;
317
- start_date?: string;
318
- end_date?: string;
319
- category?: string;
320
- origin?: TransactionOrigin;
321
- sources?: string[];
322
- }
323
- interface ITransactionsResource {
324
- list(params?: ListTransactionsParams): Promise<TransactionsPage>;
325
- }
326
- interface ListSourcesParams {
327
- limit?: number;
328
- starting_after?: string;
329
- ending_before?: string;
330
- }
331
- interface ISourcesResource {
332
- list(params?: ListSourcesParams): Promise<SourcesPage>;
333
- }
334
- interface ListBalancesParams {
335
- sources?: string[];
336
- limit?: number;
337
- starting_after?: string;
338
- ending_before?: string;
339
- }
340
- interface IBalancesResource {
341
- list(params?: ListBalancesParams): Promise<BalancesPage>;
342
- }
343
- declare const REPORT_OUTCOMES: readonly ["success", "blocked", "abandoned"];
344
- type ReportOutcome = (typeof REPORT_OUTCOMES)[number];
345
- declare const REPORT_TAGS: readonly ["stripe_checkout", "captcha", "anti_bot_script", "cdn_block", "waf_block", "dns_block", "rate_limited", "login_required", "3ds_challenge", "page_inaccessible", "timeout", "site_error", "payment_declined", "other"];
346
- type ReportTag = (typeof REPORT_TAGS)[number];
347
- /**
348
- * Server-side cap on `attempt_trace`. Longer values are truncated by the API
349
- * rather than rejected, so callers do not need to pre-trim.
350
- */
351
- declare const REPORT_ATTEMPT_TRACE_MAX_LENGTH = 8000;
352
- interface CreateReportParams {
353
- domain: string;
354
- outcome: ReportOutcome;
355
- spend_request_id: string;
356
- tags?: ReportTag[];
357
- step?: string;
358
- freeform_context?: string;
359
- attempt_trace?: string;
360
- }
361
- interface ReportRecord {
362
- object: string;
363
- created_at: string;
364
- domain: string;
365
- outcome: string;
366
- spend_request_id: string;
367
- status: string;
368
- }
369
- interface IReportResource {
370
- create(params: CreateReportParams): Promise<ReportRecord>;
371
- }
372
-
373
- interface LinkSdkLogger {
374
- debug(message: string): void;
375
- }
376
- interface LinkClientOptions {
377
- verbose?: boolean;
378
- defaultHeaders?: Record<string, string>;
379
- fetch?: typeof globalThis.fetch;
380
- apiBaseUrl?: string;
381
- spendRequestBaseUrl?: string;
382
- logger?: LinkSdkLogger;
383
- }
384
- type LinkOptions = LinkClientOptions & ({
385
- accessToken: string;
386
- getAccessToken?: never;
387
- } | {
388
- accessToken?: never;
389
- getAccessToken: AccessTokenProvider;
390
- });
391
-
392
- declare class Link {
393
- readonly spendRequests: ISpendRequestResource;
394
- readonly paymentMethods: IPaymentMethodsResource;
395
- readonly shippingAddresses: IShippingAddressResource;
396
- readonly userInfo: IUserInfoResource;
397
- readonly transactions: ITransactionsResource;
398
- readonly sources: ISourcesResource;
399
- readonly balances: IBalancesResource;
400
- readonly webBotAuth: IWebBotAuthResource;
401
- readonly reports: IReportResource;
402
- constructor(options: LinkOptions);
403
- }
404
-
405
- declare class LinkSdkError extends Error {
406
- readonly code: string;
407
- constructor(message: string, options?: {
408
- code?: string;
409
- cause?: unknown;
410
- });
411
- }
412
- declare class LinkResponseError extends LinkSdkError {
413
- readonly status: number;
414
- constructor(operation: string, status: number, options?: {
415
- cause?: unknown;
416
- });
417
- }
418
- declare class LinkConfigurationError extends LinkSdkError {
419
- constructor(message: string, options?: {
420
- cause?: unknown;
421
- });
422
- }
423
- declare class LinkTransportError extends LinkSdkError {
424
- constructor(message: string, options?: {
425
- cause?: unknown;
426
- });
427
- }
428
- declare class LinkApiError extends LinkSdkError {
429
- readonly status: number;
430
- readonly rawBody: string | undefined;
431
- readonly details?: unknown;
432
- constructor(message: string, options: {
433
- status: number;
434
- code?: string;
435
- rawBody?: string;
436
- details?: unknown;
437
- cause?: unknown;
438
- });
439
- }
440
-
441
- declare function getDuplicateSpendRequest(error: unknown): SpendRequest | null;
442
-
443
- export { type AccessTokenProvider, type AgentWalletSpendLimits, type AgentWalletVerificationRequirement, type AgentWalletVerificationStatus, type ApprovalDetail, type Balance, type BalancesPage, type BankAccountDetails, type BillingAddress, type Card, type CardDetails, type CashBalance, type CreateReportParams, type CreateSpendRequestParams, type CredentialType, type CreditBalance, type GetAccessTokenOptions, type IBalancesResource, type IPaymentMethodsResource, type IReportResource, type IShippingAddressResource, type ISourcesResource, type ISpendRequestResource, type ITransactionsResource, type IUserInfoResource, type IWebBotAuthResource, type JsonPrimitive, type JsonValue, type LineItem, Link, LinkApiError, LinkConfigurationError, type LinkOptions, LinkResponseError, LinkSdkError, type LinkSdkLogger, LinkTransportError, type ListBalancesParams, type ListSourcesParams, type ListTransactionsParams, type NextAction, type NextActionResolution, type NextActionType, type PaymentMethod, type PaymentStatusDetails, type ProductCapability, REPORT_ATTEMPT_TRACE_MAX_LENGTH, REPORT_OUTCOMES, REPORT_TAGS, type RefundDetails, type ReportOutcome, type ReportRecord, type ReportTag, type RequestApprovalResponse, type SharedPaymentToken, type ShippingAddress, type ShippingAddressRecord, type Source, type SourcesPage, type SpendRequest, type SpendRequestStatus, type SpendRequestStatusDetails, type Total, type Transaction, type TransactionOrigin, type TransactionsPage, type UpdateSpendRequestParams, type UserInfo, type WebBotAuthBlock, Link as default, getDuplicateSpendRequest };
1
+ export { default, Link } from './client';
2
+ export type { LinkOptions, LinkSdkLogger } from './config';
3
+ export { LinkApiError, LinkConfigurationError, LinkResponseError, LinkSdkError, LinkTransportError, } from './errors';
4
+ export * from './resources/interfaces';
5
+ export { getDuplicateSpendRequest } from './resources/spend-request';
6
+ export * from './types/index';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,8 @@
1
+ // src/resources/balances.ts
2
+ import { z } from "zod";
3
+
1
4
  // src/errors.ts
2
- import { ZodError, prettifyError } from "zod";
5
+ import { prettifyError, ZodError } from "zod";
3
6
  var LinkSdkError = class extends Error {
4
7
  code;
5
8
  constructor(message, options) {
@@ -215,7 +218,6 @@ var BaseResource = class {
215
218
  };
216
219
 
217
220
  // src/resources/balances.ts
218
- import { z } from "zod";
219
221
  var currencyAmountsSchema = z.record(z.string(), z.number());
220
222
  var balanceSchema = z.looseObject({
221
223
  source_id: z.string(),