@coinbase/cdp-sdk 1.34.0 → 1.35.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.
- package/CHANGELOG.md +18 -0
- package/README.md +36 -15
- package/_cjs/accounts/evm/networkCapabilities.js +4 -4
- package/_cjs/accounts/evm/networkCapabilities.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +12 -2
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +8 -2
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_cjs/actions/evm/listTokenBalances.js +1 -1
- package/_cjs/actions/evm/listTokenBalances.js.map +1 -1
- package/_cjs/client/cdp.js +4 -0
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/end-user/endUser.js +28 -0
- package/_cjs/client/end-user/endUser.js.map +1 -0
- package/_cjs/client/end-user/endUser.types.js +3 -0
- package/_cjs/client/end-user/endUser.types.js.map +1 -0
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +78 -2
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.js +20 -0
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -0
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.msw.js +61 -0
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.msw.js.map +1 -0
- package/_cjs/openapi-client/generated/index.msw.js +2 -0
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js +39 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +84 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +6 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/policies/evmSchema.js +52 -9
- package/_cjs/policies/evmSchema.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/networkCapabilities.js +4 -4
- package/_esm/accounts/evm/networkCapabilities.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +12 -2
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +8 -2
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_esm/actions/evm/listTokenBalances.js +1 -1
- package/_esm/actions/evm/listTokenBalances.js.map +1 -1
- package/_esm/client/cdp.js +4 -0
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/end-user/endUser.js +24 -0
- package/_esm/client/end-user/endUser.js.map +1 -0
- package/_esm/client/end-user/endUser.types.js +2 -0
- package/_esm/client/end-user/endUser.types.js.map +1 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +76 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.js +16 -0
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -0
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.msw.js +52 -0
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.msw.js.map +1 -0
- package/_esm/openapi-client/generated/index.msw.js +2 -0
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js +33 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +74 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +6 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/policies/evmSchema.js +51 -8
- package/_esm/policies/evmSchema.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/networkCapabilities.d.ts +4 -4
- package/_types/accounts/evm/toNetworkScopedEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +3 -3
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/auth/utils/jwt.d.ts +1 -1
- package/_types/client/cdp.d.ts +3 -0
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/end-user/endUser.d.ts +16 -0
- package/_types/client/end-user/endUser.d.ts.map +1 -0
- package/_types/client/end-user/endUser.types.d.ts +10 -0
- package/_types/client/end-user/endUser.types.d.ts.map +1 -0
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +353 -19
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts +20 -0
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts.map +1 -0
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.msw.d.ts +9 -0
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.msw.d.ts.map +1 -0
- package/_types/openapi-client/generated/index.msw.d.ts +2 -0
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts +30 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts +10 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +6 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/evmSchema.d.ts +180 -101
- package/_types/policies/evmSchema.d.ts.map +1 -1
- package/_types/policies/types.d.ts +38 -38
- package/_types/version.d.ts +1 -1
- package/accounts/evm/networkCapabilities.ts +4 -4
- package/accounts/evm/toNetworkScopedEvmServerAccount.ts +18 -5
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +15 -4
- package/accounts/evm/types.ts +9 -5
- package/actions/evm/listTokenBalances.ts +1 -1
- package/auth/utils/jwt.ts +1 -1
- package/client/cdp.ts +5 -0
- package/client/end-user/endUser.ts +27 -0
- package/client/end-user/endUser.types.ts +9 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +429 -20
- package/openapi-client/generated/end-user-accounts/end-user-accounts.msw.ts +95 -0
- package/openapi-client/generated/end-user-accounts/end-user-accounts.ts +39 -0
- package/openapi-client/generated/index.msw.ts +2 -0
- package/openapi-client/generated/x402-facilitator/x402-facilitator.msw.ts +136 -0
- package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +70 -0
- package/openapi-client/index.ts +6 -0
- package/package.json +1 -1
- package/policies/evmSchema.ts +66 -9
- package/version.ts +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ValidateAccessTokenOptions } from "./endUser.types.js";
|
|
2
|
+
import { Analytics } from "../../analytics.js";
|
|
3
|
+
import { CdpOpenApiClient, type EndUser } from "../../openapi-client/index.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The CDP end user client.
|
|
7
|
+
*/
|
|
8
|
+
export class CDPEndUserClient {
|
|
9
|
+
/**
|
|
10
|
+
* Validates an end user's access token. Throws an error if the access token is invalid.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The options for validating an access token.
|
|
13
|
+
*
|
|
14
|
+
* @returns The end user object if the access token is valid.
|
|
15
|
+
*/
|
|
16
|
+
async validateAccessToken(options: ValidateAccessTokenOptions): Promise<EndUser> {
|
|
17
|
+
Analytics.trackAction({
|
|
18
|
+
action: "validate_access_token",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const { accessToken } = options;
|
|
22
|
+
|
|
23
|
+
return CdpOpenApiClient.validateEndUserAccessToken({
|
|
24
|
+
accessToken,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -5,30 +5,103 @@
|
|
|
5
5
|
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
6
|
* OpenAPI spec version: 2.0.0
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The type of authentication information.
|
|
10
|
+
*/
|
|
11
|
+
export type EmailAuthenticationType =
|
|
12
|
+
(typeof EmailAuthenticationType)[keyof typeof EmailAuthenticationType];
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
15
|
+
export const EmailAuthenticationType = {
|
|
16
|
+
email: "email",
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Information about an end user who authenticates using a one-time password sent to their email address.
|
|
21
|
+
*/
|
|
22
|
+
export interface EmailAuthentication {
|
|
23
|
+
/** The type of authentication information. */
|
|
24
|
+
type: EmailAuthenticationType;
|
|
25
|
+
/** The email address of the end user. */
|
|
26
|
+
email: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The type of authentication information.
|
|
31
|
+
*/
|
|
32
|
+
export type SmsAuthenticationType =
|
|
33
|
+
(typeof SmsAuthenticationType)[keyof typeof SmsAuthenticationType];
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
36
|
+
export const SmsAuthenticationType = {
|
|
37
|
+
sms: "sms",
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Information about an end user who authenticates using a one-time password sent to their phone number via SMS.
|
|
42
|
+
*/
|
|
43
|
+
export interface SmsAuthentication {
|
|
44
|
+
/** The type of authentication information. */
|
|
45
|
+
type: SmsAuthenticationType;
|
|
14
46
|
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
Account names are guaranteed to be unique across all EVM accounts in the developer's CDP Project.
|
|
18
|
-
* @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
|
|
47
|
+
* The phone number of the end user in E.164 format.
|
|
48
|
+
* @pattern ^\+[1-9]\d{1,14}$
|
|
19
49
|
*/
|
|
20
|
-
|
|
21
|
-
/** The list of policy IDs that apply to the account. This will include both the project-level policy and the account-level policy, if one exists. */
|
|
22
|
-
policies?: string[];
|
|
23
|
-
/** The UTC ISO 8601 timestamp at which the account was created. */
|
|
24
|
-
createdAt?: string;
|
|
25
|
-
/** The UTC ISO 8601 timestamp at which the account was last updated. */
|
|
26
|
-
updatedAt?: string;
|
|
50
|
+
phoneNumber: string;
|
|
27
51
|
}
|
|
28
52
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The type of authentication information.
|
|
55
|
+
*/
|
|
56
|
+
export type DeveloperJWTAuthenticationType =
|
|
57
|
+
(typeof DeveloperJWTAuthenticationType)[keyof typeof DeveloperJWTAuthenticationType];
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
60
|
+
export const DeveloperJWTAuthenticationType = {
|
|
61
|
+
jwt: "jwt",
|
|
62
|
+
} as const;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Information about an end user who authenticates using a JWT issued by the developer.
|
|
66
|
+
*/
|
|
67
|
+
export interface DeveloperJWTAuthentication {
|
|
68
|
+
/** The type of authentication information. */
|
|
69
|
+
type: DeveloperJWTAuthenticationType;
|
|
70
|
+
/** The key ID of the JWK used to sign the JWT. */
|
|
71
|
+
kid: string;
|
|
72
|
+
/** The unique identifier for the end user that is captured in the `sub` claim of the JWT. */
|
|
73
|
+
sub: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Information about how the end user is authenticated.
|
|
78
|
+
*/
|
|
79
|
+
export type AuthenticationMethod =
|
|
80
|
+
| EmailAuthentication
|
|
81
|
+
| SmsAuthentication
|
|
82
|
+
| DeveloperJWTAuthentication;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The list of valid authentication methods linked to the end user.
|
|
86
|
+
*/
|
|
87
|
+
export type AuthenticationMethods = AuthenticationMethod[];
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Information about the end user.
|
|
91
|
+
*/
|
|
92
|
+
export interface EndUser {
|
|
93
|
+
/**
|
|
94
|
+
* A stable, unique identifier for the end user. The `userId` must be unique across all end users in the developer's CDP Project. It must be between 1 and 100 characters long and can only contain alphanumeric characters and hyphens.
|
|
95
|
+
* @pattern ^[a-zA-Z0-9-]{1,100}$
|
|
96
|
+
*/
|
|
97
|
+
userId: string;
|
|
98
|
+
authenticationMethods: AuthenticationMethods;
|
|
99
|
+
/** The list of EVM accounts associated with the end user. Currently, only one EVM account is supported per end user. */
|
|
100
|
+
evmAccounts: string[];
|
|
101
|
+
/** The list of EVM smart accounts associated with the end user. Currently, only one EVM smart account is supported per end user. */
|
|
102
|
+
evmSmartAccounts: string[];
|
|
103
|
+
/** The list of Solana accounts associated with the end user. Currently, only one Solana account is supported per end user. */
|
|
104
|
+
solanaAccounts: string[];
|
|
32
105
|
}
|
|
33
106
|
|
|
34
107
|
/**
|
|
@@ -79,6 +152,32 @@ export interface Error {
|
|
|
79
152
|
errorLink?: string;
|
|
80
153
|
}
|
|
81
154
|
|
|
155
|
+
export interface EvmAccount {
|
|
156
|
+
/**
|
|
157
|
+
* The 0x-prefixed, checksum EVM address.
|
|
158
|
+
* @pattern ^0x[0-9a-fA-F]{40}$
|
|
159
|
+
*/
|
|
160
|
+
address: string;
|
|
161
|
+
/**
|
|
162
|
+
* An optional name for the account.
|
|
163
|
+
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
|
|
164
|
+
Account names are guaranteed to be unique across all EVM accounts in the developer's CDP Project.
|
|
165
|
+
* @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
|
|
166
|
+
*/
|
|
167
|
+
name?: string;
|
|
168
|
+
/** The list of policy IDs that apply to the account. This will include both the project-level policy and the account-level policy, if one exists. */
|
|
169
|
+
policies?: string[];
|
|
170
|
+
/** The UTC ISO 8601 timestamp at which the account was created. */
|
|
171
|
+
createdAt?: string;
|
|
172
|
+
/** The UTC ISO 8601 timestamp at which the account was last updated. */
|
|
173
|
+
updatedAt?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface ListResponse {
|
|
177
|
+
/** The token for the next page of items, if any. */
|
|
178
|
+
nextPageToken?: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
82
181
|
/**
|
|
83
182
|
* The domain of the EIP-712 typed data.
|
|
84
183
|
*/
|
|
@@ -1984,6 +2083,252 @@ export interface AccountTokenAddressesResponse {
|
|
|
1984
2083
|
totalCount?: number;
|
|
1985
2084
|
}
|
|
1986
2085
|
|
|
2086
|
+
/**
|
|
2087
|
+
* The version of the x402 protocol.
|
|
2088
|
+
*/
|
|
2089
|
+
export type X402Version = (typeof X402Version)[keyof typeof X402Version];
|
|
2090
|
+
|
|
2091
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2092
|
+
export const X402Version = {
|
|
2093
|
+
NUMBER_1: 1,
|
|
2094
|
+
} as const;
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* The authorization data for the ERC-3009 authorization message.
|
|
2098
|
+
*/
|
|
2099
|
+
export type X402ExactEvmPayloadAuthorization = {
|
|
2100
|
+
/**
|
|
2101
|
+
* The 0x-prefixed, checksum EVM address of the sender of the payment.
|
|
2102
|
+
* @pattern ^0x[0-9a-fA-F]{40}$
|
|
2103
|
+
*/
|
|
2104
|
+
from: string;
|
|
2105
|
+
/**
|
|
2106
|
+
* The 0x-prefixed, checksum EVM address of the recipient of the payment.
|
|
2107
|
+
* @pattern ^0x[0-9a-fA-F]{40}$
|
|
2108
|
+
*/
|
|
2109
|
+
to: string;
|
|
2110
|
+
/** The value of the payment, in atomic units of the payment asset. */
|
|
2111
|
+
value: string;
|
|
2112
|
+
/** The unix timestamp after which the payment is valid. */
|
|
2113
|
+
validAfter: string;
|
|
2114
|
+
/** The unix timestamp before which the payment is valid. */
|
|
2115
|
+
validBefore: string;
|
|
2116
|
+
/** The hex-encoded nonce of the payment. */
|
|
2117
|
+
nonce: string;
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
/**
|
|
2121
|
+
* The x402 protocol exact scheme payload for EVM networks. The scheme is implemented using ERC-3009. For more details, please see [EVM Exact Scheme Details](https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md).
|
|
2122
|
+
*/
|
|
2123
|
+
export interface X402ExactEvmPayload {
|
|
2124
|
+
/** The EIP-712 hex-encoded signature of the ERC-3009 authorization message. */
|
|
2125
|
+
signature: string;
|
|
2126
|
+
/** The authorization data for the ERC-3009 authorization message. */
|
|
2127
|
+
authorization: X402ExactEvmPayloadAuthorization;
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`.
|
|
2132
|
+
*/
|
|
2133
|
+
export type X402PaymentPayloadScheme =
|
|
2134
|
+
(typeof X402PaymentPayloadScheme)[keyof typeof X402PaymentPayloadScheme];
|
|
2135
|
+
|
|
2136
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2137
|
+
export const X402PaymentPayloadScheme = {
|
|
2138
|
+
exact: "exact",
|
|
2139
|
+
} as const;
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* The network of the blockchain to send payment on.
|
|
2143
|
+
*/
|
|
2144
|
+
export type X402PaymentPayloadNetwork =
|
|
2145
|
+
(typeof X402PaymentPayloadNetwork)[keyof typeof X402PaymentPayloadNetwork];
|
|
2146
|
+
|
|
2147
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2148
|
+
export const X402PaymentPayloadNetwork = {
|
|
2149
|
+
"base-sepolia": "base-sepolia",
|
|
2150
|
+
base: "base",
|
|
2151
|
+
} as const;
|
|
2152
|
+
|
|
2153
|
+
/**
|
|
2154
|
+
* The x402 protocol payment payload that the client attaches to x402-paid API requests to the resource server in the X-PAYMENT header.
|
|
2155
|
+
*/
|
|
2156
|
+
export interface X402PaymentPayload {
|
|
2157
|
+
x402Version: X402Version;
|
|
2158
|
+
/** The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`. */
|
|
2159
|
+
scheme: X402PaymentPayloadScheme;
|
|
2160
|
+
/** The network of the blockchain to send payment on. */
|
|
2161
|
+
network: X402PaymentPayloadNetwork;
|
|
2162
|
+
/** The payload of the payment depending on the x402Version, scheme, and network. */
|
|
2163
|
+
payload: X402ExactEvmPayload;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`.
|
|
2168
|
+
*/
|
|
2169
|
+
export type X402PaymentRequirementsScheme =
|
|
2170
|
+
(typeof X402PaymentRequirementsScheme)[keyof typeof X402PaymentRequirementsScheme];
|
|
2171
|
+
|
|
2172
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2173
|
+
export const X402PaymentRequirementsScheme = {
|
|
2174
|
+
exact: "exact",
|
|
2175
|
+
} as const;
|
|
2176
|
+
|
|
2177
|
+
/**
|
|
2178
|
+
* The network of the blockchain to send payment on.
|
|
2179
|
+
*/
|
|
2180
|
+
export type X402PaymentRequirementsNetwork =
|
|
2181
|
+
(typeof X402PaymentRequirementsNetwork)[keyof typeof X402PaymentRequirementsNetwork];
|
|
2182
|
+
|
|
2183
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2184
|
+
export const X402PaymentRequirementsNetwork = {
|
|
2185
|
+
"base-sepolia": "base-sepolia",
|
|
2186
|
+
base: "base",
|
|
2187
|
+
} as const;
|
|
2188
|
+
|
|
2189
|
+
/**
|
|
2190
|
+
* The optional JSON schema describing the resource output.
|
|
2191
|
+
*/
|
|
2192
|
+
export type X402PaymentRequirementsOutputSchema = { [key: string]: unknown };
|
|
2193
|
+
|
|
2194
|
+
/**
|
|
2195
|
+
* The optional additional scheme-specific payment info.
|
|
2196
|
+
*/
|
|
2197
|
+
export type X402PaymentRequirementsExtra = { [key: string]: unknown };
|
|
2198
|
+
|
|
2199
|
+
/**
|
|
2200
|
+
* The x402 protocol payment requirements that the resource server expects the client's payment payload to meet.
|
|
2201
|
+
*/
|
|
2202
|
+
export interface X402PaymentRequirements {
|
|
2203
|
+
/** The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`. */
|
|
2204
|
+
scheme: X402PaymentRequirementsScheme;
|
|
2205
|
+
/** The network of the blockchain to send payment on. */
|
|
2206
|
+
network: X402PaymentRequirementsNetwork;
|
|
2207
|
+
/** The maximum amount required to pay for the resource in atomic units of the payment asset. */
|
|
2208
|
+
maxAmountRequired: string;
|
|
2209
|
+
/** The URL of the resource to pay for. */
|
|
2210
|
+
resource: string;
|
|
2211
|
+
/** The description of the resource. */
|
|
2212
|
+
description: string;
|
|
2213
|
+
/** The MIME type of the resource response. */
|
|
2214
|
+
mimeType: string;
|
|
2215
|
+
/** The optional JSON schema describing the resource output. */
|
|
2216
|
+
outputSchema?: X402PaymentRequirementsOutputSchema;
|
|
2217
|
+
/**
|
|
2218
|
+
* The destination to pay value to.
|
|
2219
|
+
|
|
2220
|
+
For EVM networks, payTo will be a 0x-prefixed, checksum EVM address.
|
|
2221
|
+
|
|
2222
|
+
For Solana-based networks, payTo will be a base58-encoded Solana address.
|
|
2223
|
+
* @pattern ^0x[a-fA-F0-9]{40}|[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
|
|
2224
|
+
*/
|
|
2225
|
+
payTo: string;
|
|
2226
|
+
/** The maximum time in seconds for the resource server to respond. */
|
|
2227
|
+
maxTimeoutSeconds: number;
|
|
2228
|
+
/**
|
|
2229
|
+
* The asset to pay with.
|
|
2230
|
+
|
|
2231
|
+
For EVM networks, the asset will be a 0x-prefixed, checksum EVM address.
|
|
2232
|
+
|
|
2233
|
+
For Solana-based networks, the asset will be a base58-encoded Solana address.
|
|
2234
|
+
* @pattern ^0x[a-fA-F0-9]{40}|[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
|
|
2235
|
+
*/
|
|
2236
|
+
asset: string;
|
|
2237
|
+
/** The optional additional scheme-specific payment info. */
|
|
2238
|
+
extra?: X402PaymentRequirementsExtra;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* The reason the payment is invalid on the x402 protocol.
|
|
2243
|
+
*/
|
|
2244
|
+
export type X402VerifyInvalidReason =
|
|
2245
|
+
(typeof X402VerifyInvalidReason)[keyof typeof X402VerifyInvalidReason];
|
|
2246
|
+
|
|
2247
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2248
|
+
export const X402VerifyInvalidReason = {
|
|
2249
|
+
insufficient_funds: "insufficient_funds",
|
|
2250
|
+
invalid_scheme: "invalid_scheme",
|
|
2251
|
+
invalid_network: "invalid_network",
|
|
2252
|
+
invalid_x402_version: "invalid_x402_version",
|
|
2253
|
+
invalid_payment_requirements: "invalid_payment_requirements",
|
|
2254
|
+
invalid_payload: "invalid_payload",
|
|
2255
|
+
invalid_exact_evm_payload_authorization_value: "invalid_exact_evm_payload_authorization_value",
|
|
2256
|
+
invalid_exact_evm_payload_authorization_valid_after:
|
|
2257
|
+
"invalid_exact_evm_payload_authorization_valid_after",
|
|
2258
|
+
invalid_exact_evm_payload_authorization_valid_before:
|
|
2259
|
+
"invalid_exact_evm_payload_authorization_valid_before",
|
|
2260
|
+
invalid_exact_evm_payload_authorization_typed_data_message:
|
|
2261
|
+
"invalid_exact_evm_payload_authorization_typed_data_message",
|
|
2262
|
+
invalid_exact_evm_payload_authorization_from_address_kyt:
|
|
2263
|
+
"invalid_exact_evm_payload_authorization_from_address_kyt",
|
|
2264
|
+
invalid_exact_evm_payload_authorization_to_address_kyt:
|
|
2265
|
+
"invalid_exact_evm_payload_authorization_to_address_kyt",
|
|
2266
|
+
invalid_exact_evm_payload_signature: "invalid_exact_evm_payload_signature",
|
|
2267
|
+
invalid_exact_evm_payload_signature_address: "invalid_exact_evm_payload_signature_address",
|
|
2268
|
+
} as const;
|
|
2269
|
+
|
|
2270
|
+
/**
|
|
2271
|
+
* The reason the payment settlement errored on the x402 protocol.
|
|
2272
|
+
*/
|
|
2273
|
+
export type X402SettleErrorReason =
|
|
2274
|
+
(typeof X402SettleErrorReason)[keyof typeof X402SettleErrorReason];
|
|
2275
|
+
|
|
2276
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2277
|
+
export const X402SettleErrorReason = {
|
|
2278
|
+
insufficient_funds: "insufficient_funds",
|
|
2279
|
+
invalid_scheme: "invalid_scheme",
|
|
2280
|
+
invalid_network: "invalid_network",
|
|
2281
|
+
invalid_x402_version: "invalid_x402_version",
|
|
2282
|
+
invalid_payment_requirements: "invalid_payment_requirements",
|
|
2283
|
+
invalid_payload: "invalid_payload",
|
|
2284
|
+
invalid_exact_evm_payload_authorization_value: "invalid_exact_evm_payload_authorization_value",
|
|
2285
|
+
invalid_exact_evm_payload_authorization_valid_after:
|
|
2286
|
+
"invalid_exact_evm_payload_authorization_valid_after",
|
|
2287
|
+
invalid_exact_evm_payload_authorization_valid_before:
|
|
2288
|
+
"invalid_exact_evm_payload_authorization_valid_before",
|
|
2289
|
+
invalid_exact_evm_payload_authorization_typed_data_message:
|
|
2290
|
+
"invalid_exact_evm_payload_authorization_typed_data_message",
|
|
2291
|
+
invalid_exact_evm_payload_authorization_from_address_kyt:
|
|
2292
|
+
"invalid_exact_evm_payload_authorization_from_address_kyt",
|
|
2293
|
+
invalid_exact_evm_payload_authorization_to_address_kyt:
|
|
2294
|
+
"invalid_exact_evm_payload_authorization_to_address_kyt",
|
|
2295
|
+
invalid_exact_evm_payload_signature_address: "invalid_exact_evm_payload_signature_address",
|
|
2296
|
+
} as const;
|
|
2297
|
+
|
|
2298
|
+
/**
|
|
2299
|
+
* The scheme of the payment protocol.
|
|
2300
|
+
*/
|
|
2301
|
+
export type X402SupportedPaymentKindScheme =
|
|
2302
|
+
(typeof X402SupportedPaymentKindScheme)[keyof typeof X402SupportedPaymentKindScheme];
|
|
2303
|
+
|
|
2304
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2305
|
+
export const X402SupportedPaymentKindScheme = {
|
|
2306
|
+
exact: "exact",
|
|
2307
|
+
} as const;
|
|
2308
|
+
|
|
2309
|
+
/**
|
|
2310
|
+
* The network of the blockchain.
|
|
2311
|
+
*/
|
|
2312
|
+
export type X402SupportedPaymentKindNetwork =
|
|
2313
|
+
(typeof X402SupportedPaymentKindNetwork)[keyof typeof X402SupportedPaymentKindNetwork];
|
|
2314
|
+
|
|
2315
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2316
|
+
export const X402SupportedPaymentKindNetwork = {
|
|
2317
|
+
"base-sepolia": "base-sepolia",
|
|
2318
|
+
base: "base",
|
|
2319
|
+
} as const;
|
|
2320
|
+
|
|
2321
|
+
/**
|
|
2322
|
+
* The supported payment kind for the x402 protocol. A kind is comprised of a scheme and a network, which together uniquely identify a way to move money on the x402 protocol. For more details, please see [x402 Schemes](https://github.com/coinbase/x402?tab=readme-ov-file#schemes).
|
|
2323
|
+
*/
|
|
2324
|
+
export interface X402SupportedPaymentKind {
|
|
2325
|
+
x402Version: X402Version;
|
|
2326
|
+
/** The scheme of the payment protocol. */
|
|
2327
|
+
scheme: X402SupportedPaymentKindScheme;
|
|
2328
|
+
/** The network of the blockchain. */
|
|
2329
|
+
network: X402SupportedPaymentKindNetwork;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
1987
2332
|
/**
|
|
1988
2333
|
* The action of the payment method.
|
|
1989
2334
|
*/
|
|
@@ -2363,6 +2708,50 @@ export type UnauthorizedErrorResponse = Error;
|
|
|
2363
2708
|
*/
|
|
2364
2709
|
export type TimedOutErrorResponse = Error;
|
|
2365
2710
|
|
|
2711
|
+
export type X402VerifyResponseResponse = {
|
|
2712
|
+
/** Indicates whether the payment is valid. */
|
|
2713
|
+
isValid: boolean;
|
|
2714
|
+
invalidReason?: X402VerifyInvalidReason;
|
|
2715
|
+
/**
|
|
2716
|
+
* The onchain address of the client that is paying for the resource.
|
|
2717
|
+
|
|
2718
|
+
For EVM networks, the payer will be a 0x-prefixed, checksum EVM address.
|
|
2719
|
+
|
|
2720
|
+
For Solana-based networks, the payer will be a base58-encoded Solana address.
|
|
2721
|
+
* @pattern ^0x[a-fA-F0-9]{40}|[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
|
|
2722
|
+
*/
|
|
2723
|
+
payer: string;
|
|
2724
|
+
};
|
|
2725
|
+
|
|
2726
|
+
export type X402SettleResponseResponse = {
|
|
2727
|
+
/** Indicates whether the payment settlement is successful. */
|
|
2728
|
+
success: boolean;
|
|
2729
|
+
errorReason?: X402SettleErrorReason;
|
|
2730
|
+
/**
|
|
2731
|
+
* The onchain address of the client that is paying for the resource.
|
|
2732
|
+
|
|
2733
|
+
For EVM networks, the payer will be a 0x-prefixed, checksum EVM address.
|
|
2734
|
+
|
|
2735
|
+
For Solana-based networks, the payer will be a base58-encoded Solana address.
|
|
2736
|
+
* @pattern ^0x[a-fA-F0-9]{40}|[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
|
|
2737
|
+
*/
|
|
2738
|
+
payer: string;
|
|
2739
|
+
/**
|
|
2740
|
+
* The transaction of the settlement.
|
|
2741
|
+
For EVM networks, the transaction will be a 0x-prefixed, EVM transaction hash.
|
|
2742
|
+
For Solana-based networks, the transaction will be a base58-encoded Solana signature.
|
|
2743
|
+
* @pattern ^0x[a-fA-F0-9]{40}|[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
|
|
2744
|
+
*/
|
|
2745
|
+
transaction: string;
|
|
2746
|
+
/** The network where the settlement occurred. */
|
|
2747
|
+
network: string;
|
|
2748
|
+
};
|
|
2749
|
+
|
|
2750
|
+
export type X402SupportedPaymentKindsResponseResponse = {
|
|
2751
|
+
/** The list of supported payment kinds. */
|
|
2752
|
+
kinds: X402SupportedPaymentKind[];
|
|
2753
|
+
};
|
|
2754
|
+
|
|
2366
2755
|
/**
|
|
2367
2756
|
* Rate limit exceeded.
|
|
2368
2757
|
*/
|
|
@@ -2384,6 +2773,14 @@ Refer to our [Idempotency docs](https://docs.cdp.coinbase.com/api-reference/v2/i
|
|
|
2384
2773
|
*/
|
|
2385
2774
|
export type IdempotencyKeyParameter = string;
|
|
2386
2775
|
|
|
2776
|
+
/**
|
|
2777
|
+
* The request body for a developer to verify an end user's access token.
|
|
2778
|
+
*/
|
|
2779
|
+
export type ValidateEndUserAccessTokenBody = {
|
|
2780
|
+
/** The access token in JWT format to verify. */
|
|
2781
|
+
accessToken: string;
|
|
2782
|
+
};
|
|
2783
|
+
|
|
2387
2784
|
export type ListEvmAccountsParams = {
|
|
2388
2785
|
/**
|
|
2389
2786
|
* The number of accounts to return per page.
|
|
@@ -2971,6 +3368,18 @@ export type ListDataTokenBalances200AllOf = {
|
|
|
2971
3368
|
|
|
2972
3369
|
export type ListDataTokenBalances200 = ListDataTokenBalances200AllOf & ListResponse;
|
|
2973
3370
|
|
|
3371
|
+
export type VerifyX402PaymentBody = {
|
|
3372
|
+
x402Version: X402Version;
|
|
3373
|
+
paymentPayload: X402PaymentPayload;
|
|
3374
|
+
paymentRequirements: X402PaymentRequirements;
|
|
3375
|
+
};
|
|
3376
|
+
|
|
3377
|
+
export type SettleX402PaymentBody = {
|
|
3378
|
+
x402Version: X402Version;
|
|
3379
|
+
paymentPayload: X402PaymentPayload;
|
|
3380
|
+
paymentRequirements: X402PaymentRequirements;
|
|
3381
|
+
};
|
|
3382
|
+
|
|
2974
3383
|
export type GetCryptoRailsParams = {
|
|
2975
3384
|
/**
|
|
2976
3385
|
* Comma separated list of networks to filter the rails by.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
DeveloperJWTAuthentication,
|
|
14
|
+
EmailAuthentication,
|
|
15
|
+
EndUser,
|
|
16
|
+
SmsAuthentication,
|
|
17
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
18
|
+
|
|
19
|
+
export const getValidateEndUserAccessTokenResponseEmailAuthenticationMock = (
|
|
20
|
+
overrideResponse: Partial<EmailAuthentication> = {},
|
|
21
|
+
): EmailAuthentication => ({
|
|
22
|
+
...{ type: faker.helpers.arrayElement(["email"] as const), email: faker.internet.email() },
|
|
23
|
+
...overrideResponse,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const getValidateEndUserAccessTokenResponseSmsAuthenticationMock = (
|
|
27
|
+
overrideResponse: Partial<SmsAuthentication> = {},
|
|
28
|
+
): SmsAuthentication => ({
|
|
29
|
+
...{
|
|
30
|
+
type: faker.helpers.arrayElement(["sms"] as const),
|
|
31
|
+
phoneNumber: faker.helpers.fromRegExp("^\+[1-9]\d{1,14}$"),
|
|
32
|
+
},
|
|
33
|
+
...overrideResponse,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const getValidateEndUserAccessTokenResponseDeveloperJWTAuthenticationMock = (
|
|
37
|
+
overrideResponse: Partial<DeveloperJWTAuthentication> = {},
|
|
38
|
+
): DeveloperJWTAuthentication => ({
|
|
39
|
+
...{
|
|
40
|
+
type: faker.helpers.arrayElement(["jwt"] as const),
|
|
41
|
+
kid: faker.string.alpha(20),
|
|
42
|
+
sub: faker.string.alpha(20),
|
|
43
|
+
},
|
|
44
|
+
...overrideResponse,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const getValidateEndUserAccessTokenResponseMock = (
|
|
48
|
+
overrideResponse: Partial<EndUser> = {},
|
|
49
|
+
): EndUser => ({
|
|
50
|
+
userId: faker.helpers.fromRegExp("^[a-zA-Z0-9-]{1,100}$"),
|
|
51
|
+
authenticationMethods: Array.from(
|
|
52
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
53
|
+
(_, i) => i + 1,
|
|
54
|
+
).map(() =>
|
|
55
|
+
faker.helpers.arrayElement([
|
|
56
|
+
{ ...getValidateEndUserAccessTokenResponseEmailAuthenticationMock() },
|
|
57
|
+
{ ...getValidateEndUserAccessTokenResponseSmsAuthenticationMock() },
|
|
58
|
+
{ ...getValidateEndUserAccessTokenResponseDeveloperJWTAuthenticationMock() },
|
|
59
|
+
]),
|
|
60
|
+
),
|
|
61
|
+
evmAccounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
62
|
+
() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
|
|
63
|
+
),
|
|
64
|
+
evmSmartAccounts: Array.from(
|
|
65
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
66
|
+
(_, i) => i + 1,
|
|
67
|
+
).map(() => faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$")),
|
|
68
|
+
solanaAccounts: Array.from(
|
|
69
|
+
{ length: faker.number.int({ min: 1, max: 10 }) },
|
|
70
|
+
(_, i) => i + 1,
|
|
71
|
+
).map(() => faker.helpers.fromRegExp("^[1-9A-HJ-NP-Za-km-z]{32,44}$")),
|
|
72
|
+
...overrideResponse,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const getValidateEndUserAccessTokenMockHandler = (
|
|
76
|
+
overrideResponse?:
|
|
77
|
+
| EndUser
|
|
78
|
+
| ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<EndUser> | EndUser),
|
|
79
|
+
) => {
|
|
80
|
+
return http.post("*/v2/end-users/auth/validate-token", async info => {
|
|
81
|
+
await delay(0);
|
|
82
|
+
|
|
83
|
+
return new HttpResponse(
|
|
84
|
+
JSON.stringify(
|
|
85
|
+
overrideResponse !== undefined
|
|
86
|
+
? typeof overrideResponse === "function"
|
|
87
|
+
? await overrideResponse(info)
|
|
88
|
+
: overrideResponse
|
|
89
|
+
: getValidateEndUserAccessTokenResponseMock(),
|
|
90
|
+
),
|
|
91
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
export const getEndUserAccountsMock = () => [getValidateEndUserAccessTokenMockHandler()];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
EndUser,
|
|
10
|
+
ValidateEndUserAccessTokenBody,
|
|
11
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
12
|
+
|
|
13
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
14
|
+
|
|
15
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Validates the end user's access token and returns the end user's information. Returns an error if the access token is invalid or expired.
|
|
19
|
+
|
|
20
|
+
This API is intended to be used by the developer's own backend, and is authenticated using the developer's CDP API key.
|
|
21
|
+
* @summary Validate end user access token
|
|
22
|
+
*/
|
|
23
|
+
export const validateEndUserAccessToken = (
|
|
24
|
+
validateEndUserAccessTokenBody: ValidateEndUserAccessTokenBody,
|
|
25
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
26
|
+
) => {
|
|
27
|
+
return cdpApiClient<EndUser>(
|
|
28
|
+
{
|
|
29
|
+
url: `/v2/end-users/auth/validate-token`,
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: { "Content-Type": "application/json" },
|
|
32
|
+
data: validateEndUserAccessTokenBody,
|
|
33
|
+
},
|
|
34
|
+
options,
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
export type ValidateEndUserAccessTokenResult = NonNullable<
|
|
38
|
+
Awaited<ReturnType<typeof validateEndUserAccessToken>>
|
|
39
|
+
>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./end-user-accounts/end-user-accounts.msw.js";
|
|
1
2
|
export * from "./evm-accounts/evm-accounts.msw.js";
|
|
2
3
|
export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
|
|
3
4
|
export * from "./evm-swaps/evm-swaps.msw.js";
|
|
@@ -9,3 +10,4 @@ export * from "./payments-alpha/payments-alpha.msw.js";
|
|
|
9
10
|
export * from "./policy-engine/policy-engine.msw.js";
|
|
10
11
|
export * from "./solana-accounts/solana-accounts.msw.js";
|
|
11
12
|
export * from "./solana-token-balances/solana-token-balances.msw.js";
|
|
13
|
+
export * from "./x402-facilitator/x402-facilitator.msw.js";
|