@stripe/link-sdk 0.4.0 → 0.4.2
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/__tests__/config.test.d.ts +2 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/errors.test.d.ts +2 -0
- package/dist/__tests__/errors.test.d.ts.map +1 -0
- package/dist/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/config.d.ts +36 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +7 -442
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/resources/__tests__/balances.test.d.ts +2 -0
- package/dist/resources/__tests__/balances.test.d.ts.map +1 -0
- package/dist/resources/__tests__/factory.test.d.ts +2 -0
- package/dist/resources/__tests__/factory.test.d.ts.map +1 -0
- package/dist/resources/__tests__/payment-methods.test.d.ts +2 -0
- package/dist/resources/__tests__/payment-methods.test.d.ts.map +1 -0
- package/dist/resources/__tests__/report.test.d.ts +2 -0
- package/dist/resources/__tests__/report.test.d.ts.map +1 -0
- package/dist/resources/__tests__/shipping-address.test.d.ts +2 -0
- package/dist/resources/__tests__/shipping-address.test.d.ts.map +1 -0
- package/dist/resources/__tests__/sources.test.d.ts +2 -0
- package/dist/resources/__tests__/sources.test.d.ts.map +1 -0
- package/dist/resources/__tests__/spend-request.test.d.ts +2 -0
- package/dist/resources/__tests__/spend-request.test.d.ts.map +1 -0
- package/dist/resources/__tests__/transactions.test.d.ts +2 -0
- package/dist/resources/__tests__/transactions.test.d.ts.map +1 -0
- package/dist/resources/__tests__/user-info.test.d.ts +2 -0
- package/dist/resources/__tests__/user-info.test.d.ts.map +1 -0
- package/dist/resources/__tests__/web-bot-auth.test.d.ts +2 -0
- package/dist/resources/__tests__/web-bot-auth.test.d.ts.map +1 -0
- package/dist/resources/balances.d.ts +10 -0
- package/dist/resources/balances.d.ts.map +1 -0
- package/dist/resources/base.d.ts +31 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/interfaces.d.ts +118 -0
- package/dist/resources/interfaces.d.ts.map +1 -0
- package/dist/resources/payment-methods.d.ts +9 -0
- package/dist/resources/payment-methods.d.ts.map +1 -0
- package/dist/resources/report.d.ts +8 -0
- package/dist/resources/report.d.ts.map +1 -0
- package/dist/resources/shipping-address.d.ts +9 -0
- package/dist/resources/shipping-address.d.ts.map +1 -0
- package/dist/resources/sources.d.ts +10 -0
- package/dist/resources/sources.d.ts.map +1 -0
- package/dist/resources/spend-request.d.ts +27 -0
- package/dist/resources/spend-request.d.ts.map +1 -0
- package/dist/resources/transactions.d.ts +10 -0
- package/dist/resources/transactions.d.ts.map +1 -0
- package/dist/resources/user-info.d.ts +9 -0
- package/dist/resources/user-info.d.ts.map +1 -0
- package/dist/resources/web-bot-auth.d.ts +10 -0
- package/dist/resources/web-bot-auth.d.ts.map +1 -0
- package/dist/types/index.d.ts +255 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/config.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/errors.test.ts"],"names":[],"mappings":""}
|
package/dist/client.d.ts
ADDED
|
@@ -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"}
|
package/dist/config.d.ts
ADDED
|
@@ -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"}
|
package/dist/errors.d.ts
ADDED
|
@@ -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,442 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
payment_details?: string;
|
|
262
|
-
credential_type?: CredentialType;
|
|
263
|
-
network_id?: string;
|
|
264
|
-
execution_method?: 'link_pay_token';
|
|
265
|
-
merchant_account_id?: string;
|
|
266
|
-
amount?: number;
|
|
267
|
-
currency?: string;
|
|
268
|
-
merchant_name?: string;
|
|
269
|
-
merchant_url?: string;
|
|
270
|
-
context: string;
|
|
271
|
-
line_items?: LineItem[];
|
|
272
|
-
totals?: Total[];
|
|
273
|
-
request_approval?: boolean;
|
|
274
|
-
test?: boolean;
|
|
275
|
-
approval_details?: ApprovalDetail;
|
|
276
|
-
metadata?: Record<string, string>;
|
|
277
|
-
}
|
|
278
|
-
interface UpdateSpendRequestParams {
|
|
279
|
-
payment_details?: string;
|
|
280
|
-
amount?: number;
|
|
281
|
-
merchant_url?: string;
|
|
282
|
-
profile_id?: string;
|
|
283
|
-
merchant_id?: string;
|
|
284
|
-
currency?: string;
|
|
285
|
-
line_items?: LineItem[];
|
|
286
|
-
totals?: Total[];
|
|
287
|
-
}
|
|
288
|
-
interface ISpendRequestResource {
|
|
289
|
-
list(opts?: {
|
|
290
|
-
includeHistory?: boolean;
|
|
291
|
-
}): Promise<SpendRequest[]>;
|
|
292
|
-
create(params: CreateSpendRequestParams): Promise<SpendRequest>;
|
|
293
|
-
update(id: string, params: UpdateSpendRequestParams): Promise<SpendRequest>;
|
|
294
|
-
requestApproval(id: string): Promise<RequestApprovalResponse>;
|
|
295
|
-
cancel(id: string): Promise<SpendRequest>;
|
|
296
|
-
retrieve(id: string, opts?: {
|
|
297
|
-
include?: string[];
|
|
298
|
-
}): Promise<SpendRequest | null>;
|
|
299
|
-
}
|
|
300
|
-
interface IPaymentMethodsResource {
|
|
301
|
-
list(): Promise<PaymentMethod[]>;
|
|
302
|
-
}
|
|
303
|
-
interface IShippingAddressResource {
|
|
304
|
-
list(): Promise<ShippingAddressRecord[]>;
|
|
305
|
-
}
|
|
306
|
-
interface IUserInfoResource {
|
|
307
|
-
retrieve(): Promise<UserInfo>;
|
|
308
|
-
}
|
|
309
|
-
interface IWebBotAuthResource {
|
|
310
|
-
signUrl(url: string): Promise<WebBotAuthBlock>;
|
|
311
|
-
}
|
|
312
|
-
interface ListTransactionsParams {
|
|
313
|
-
limit?: number;
|
|
314
|
-
starting_after?: string;
|
|
315
|
-
ending_before?: string;
|
|
316
|
-
start_date?: string;
|
|
317
|
-
end_date?: string;
|
|
318
|
-
category?: string;
|
|
319
|
-
origin?: TransactionOrigin;
|
|
320
|
-
sources?: string[];
|
|
321
|
-
}
|
|
322
|
-
interface ITransactionsResource {
|
|
323
|
-
list(params?: ListTransactionsParams): Promise<TransactionsPage>;
|
|
324
|
-
}
|
|
325
|
-
interface ListSourcesParams {
|
|
326
|
-
limit?: number;
|
|
327
|
-
starting_after?: string;
|
|
328
|
-
ending_before?: string;
|
|
329
|
-
}
|
|
330
|
-
interface ISourcesResource {
|
|
331
|
-
list(params?: ListSourcesParams): Promise<SourcesPage>;
|
|
332
|
-
}
|
|
333
|
-
interface ListBalancesParams {
|
|
334
|
-
sources?: string[];
|
|
335
|
-
limit?: number;
|
|
336
|
-
starting_after?: string;
|
|
337
|
-
ending_before?: string;
|
|
338
|
-
}
|
|
339
|
-
interface IBalancesResource {
|
|
340
|
-
list(params?: ListBalancesParams): Promise<BalancesPage>;
|
|
341
|
-
}
|
|
342
|
-
declare const REPORT_OUTCOMES: readonly ["success", "blocked", "abandoned"];
|
|
343
|
-
type ReportOutcome = (typeof REPORT_OUTCOMES)[number];
|
|
344
|
-
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"];
|
|
345
|
-
type ReportTag = (typeof REPORT_TAGS)[number];
|
|
346
|
-
/**
|
|
347
|
-
* Server-side cap on `attempt_trace`. Longer values are truncated by the API
|
|
348
|
-
* rather than rejected, so callers do not need to pre-trim.
|
|
349
|
-
*/
|
|
350
|
-
declare const REPORT_ATTEMPT_TRACE_MAX_LENGTH = 8000;
|
|
351
|
-
interface CreateReportParams {
|
|
352
|
-
domain: string;
|
|
353
|
-
outcome: ReportOutcome;
|
|
354
|
-
spend_request_id: string;
|
|
355
|
-
tags?: ReportTag[];
|
|
356
|
-
step?: string;
|
|
357
|
-
freeform_context?: string;
|
|
358
|
-
attempt_trace?: string;
|
|
359
|
-
}
|
|
360
|
-
interface ReportRecord {
|
|
361
|
-
object: string;
|
|
362
|
-
created_at: string;
|
|
363
|
-
domain: string;
|
|
364
|
-
outcome: string;
|
|
365
|
-
spend_request_id: string;
|
|
366
|
-
status: string;
|
|
367
|
-
}
|
|
368
|
-
interface IReportResource {
|
|
369
|
-
create(params: CreateReportParams): Promise<ReportRecord>;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
interface LinkSdkLogger {
|
|
373
|
-
debug(message: string): void;
|
|
374
|
-
}
|
|
375
|
-
interface LinkClientOptions {
|
|
376
|
-
verbose?: boolean;
|
|
377
|
-
defaultHeaders?: Record<string, string>;
|
|
378
|
-
fetch?: typeof globalThis.fetch;
|
|
379
|
-
apiBaseUrl?: string;
|
|
380
|
-
spendRequestBaseUrl?: string;
|
|
381
|
-
logger?: LinkSdkLogger;
|
|
382
|
-
}
|
|
383
|
-
type LinkOptions = LinkClientOptions & ({
|
|
384
|
-
accessToken: string;
|
|
385
|
-
getAccessToken?: never;
|
|
386
|
-
} | {
|
|
387
|
-
accessToken?: never;
|
|
388
|
-
getAccessToken: AccessTokenProvider;
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
declare class Link {
|
|
392
|
-
readonly spendRequests: ISpendRequestResource;
|
|
393
|
-
readonly paymentMethods: IPaymentMethodsResource;
|
|
394
|
-
readonly shippingAddresses: IShippingAddressResource;
|
|
395
|
-
readonly userInfo: IUserInfoResource;
|
|
396
|
-
readonly transactions: ITransactionsResource;
|
|
397
|
-
readonly sources: ISourcesResource;
|
|
398
|
-
readonly balances: IBalancesResource;
|
|
399
|
-
readonly webBotAuth: IWebBotAuthResource;
|
|
400
|
-
readonly reports: IReportResource;
|
|
401
|
-
constructor(options: LinkOptions);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
declare class LinkSdkError extends Error {
|
|
405
|
-
readonly code: string;
|
|
406
|
-
constructor(message: string, options?: {
|
|
407
|
-
code?: string;
|
|
408
|
-
cause?: unknown;
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
declare class LinkResponseError extends LinkSdkError {
|
|
412
|
-
readonly status: number;
|
|
413
|
-
constructor(operation: string, status: number, options?: {
|
|
414
|
-
cause?: unknown;
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
declare class LinkConfigurationError extends LinkSdkError {
|
|
418
|
-
constructor(message: string, options?: {
|
|
419
|
-
cause?: unknown;
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
declare class LinkTransportError extends LinkSdkError {
|
|
423
|
-
constructor(message: string, options?: {
|
|
424
|
-
cause?: unknown;
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
declare class LinkApiError extends LinkSdkError {
|
|
428
|
-
readonly status: number;
|
|
429
|
-
readonly rawBody: string | undefined;
|
|
430
|
-
readonly details?: unknown;
|
|
431
|
-
constructor(message: string, options: {
|
|
432
|
-
status: number;
|
|
433
|
-
code?: string;
|
|
434
|
-
rawBody?: string;
|
|
435
|
-
details?: unknown;
|
|
436
|
-
cause?: unknown;
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
declare function getDuplicateSpendRequest(error: unknown): SpendRequest | null;
|
|
441
|
-
|
|
442
|
-
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 {
|
|
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(),
|