@otim/sdk-core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE +201 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/abi-Bd3X6gV9.d.mts +154 -0
  4. package/dist/abi-Bd3X6gV9.d.mts.map +1 -0
  5. package/dist/abi-CQuxrNCU.d.cts +154 -0
  6. package/dist/abi-CQuxrNCU.d.cts.map +1 -0
  7. package/dist/account/index.cjs +7 -0
  8. package/dist/account/index.d.cts +3 -0
  9. package/dist/account/index.d.mts +3 -0
  10. package/dist/account/index.mjs +3 -0
  11. package/dist/account-Bwm5PTcc.cjs +56 -0
  12. package/dist/account-Bwm5PTcc.cjs.map +1 -0
  13. package/dist/account-p4sxzIt3.mjs +26 -0
  14. package/dist/account-p4sxzIt3.mjs.map +1 -0
  15. package/dist/clients/index.cjs +7 -0
  16. package/dist/clients/index.d.cts +3 -0
  17. package/dist/clients/index.d.mts +3 -0
  18. package/dist/clients/index.mjs +3 -0
  19. package/dist/clients-DBRhkU4y.cjs +297 -0
  20. package/dist/clients-DBRhkU4y.cjs.map +1 -0
  21. package/dist/clients-DMKeLhcJ.mjs +268 -0
  22. package/dist/clients-DMKeLhcJ.mjs.map +1 -0
  23. package/dist/config/index.cjs +10 -0
  24. package/dist/config/index.d.cts +3 -0
  25. package/dist/config/index.d.mts +3 -0
  26. package/dist/config/index.mjs +3 -0
  27. package/dist/config-C_nc1DXn.mjs +67 -0
  28. package/dist/config-C_nc1DXn.mjs.map +1 -0
  29. package/dist/config-CjGpscVk.cjs +114 -0
  30. package/dist/config-CjGpscVk.cjs.map +1 -0
  31. package/dist/context/index.cjs +5 -0
  32. package/dist/context/index.d.cts +2 -0
  33. package/dist/context/index.d.mts +2 -0
  34. package/dist/context/index.mjs +3 -0
  35. package/dist/context-B-Wcmhb3.cjs +38 -0
  36. package/dist/context-B-Wcmhb3.cjs.map +1 -0
  37. package/dist/context-uTye69B0.mjs +20 -0
  38. package/dist/context-uTye69B0.mjs.map +1 -0
  39. package/dist/index-B4fkcFy5.d.mts +54 -0
  40. package/dist/index-B4fkcFy5.d.mts.map +1 -0
  41. package/dist/index-BnP8vpJJ.d.cts +25 -0
  42. package/dist/index-BnP8vpJJ.d.cts.map +1 -0
  43. package/dist/index-C1HSAemv.d.cts +20 -0
  44. package/dist/index-C1HSAemv.d.cts.map +1 -0
  45. package/dist/index-C4N2Xixk.d.mts +27 -0
  46. package/dist/index-C4N2Xixk.d.mts.map +1 -0
  47. package/dist/index-CcCMIBgF.d.mts +20 -0
  48. package/dist/index-CcCMIBgF.d.mts.map +1 -0
  49. package/dist/index-DK-40z4V.d.cts +54 -0
  50. package/dist/index-DK-40z4V.d.cts.map +1 -0
  51. package/dist/index-DW_zBRKz.d.mts +25 -0
  52. package/dist/index-DW_zBRKz.d.mts.map +1 -0
  53. package/dist/index-De8OZ-Be.d.cts +96 -0
  54. package/dist/index-De8OZ-Be.d.cts.map +1 -0
  55. package/dist/index-UnaahQgb.d.cts +27 -0
  56. package/dist/index-UnaahQgb.d.cts.map +1 -0
  57. package/dist/index-e5BLgzcW.d.mts +96 -0
  58. package/dist/index-e5BLgzcW.d.mts.map +1 -0
  59. package/dist/index.cjs +31 -0
  60. package/dist/index.d.cts +8 -0
  61. package/dist/index.d.mts +8 -0
  62. package/dist/index.mjs +7 -0
  63. package/dist/misc-CX4pLJaA.d.mts +42 -0
  64. package/dist/misc-CX4pLJaA.d.mts.map +1 -0
  65. package/dist/misc-CpZxSPCP.d.cts +42 -0
  66. package/dist/misc-CpZxSPCP.d.cts.map +1 -0
  67. package/dist/utils/index.cjs +6 -0
  68. package/dist/utils/index.d.cts +4 -0
  69. package/dist/utils/index.d.mts +4 -0
  70. package/dist/utils/index.mjs +3 -0
  71. package/dist/utils-CVQFvsfl.cjs +104 -0
  72. package/dist/utils-CVQFvsfl.cjs.map +1 -0
  73. package/dist/utils-DziAHBiz.mjs +81 -0
  74. package/dist/utils-DziAHBiz.mjs.map +1 -0
  75. package/package.json +162 -0
@@ -0,0 +1,297 @@
1
+ let __otim_utils_helpers = require("@otim/utils/helpers");
2
+ let __otim_sdk_core_config = require("@otim/sdk-core/config");
3
+ let __otim_sdk_core_context = require("@otim/sdk-core/context");
4
+ let __otim_utils_chains = require("@otim/utils/chains");
5
+ let __otim_utils_payments = require("@otim/utils/payments");
6
+ let __otim_utils_schemas = require("@otim/utils/schemas");
7
+ let viem = require("viem");
8
+ let __otim_turnkey_signing = require("@otim/turnkey/signing");
9
+ let viem_accounts = require("viem/accounts");
10
+ let __otim_sdk_core_account = require("@otim/sdk-core/account");
11
+
12
+ //#region src/clients/auth.ts
13
+ var AuthClient = class {
14
+ constructor(apiClient, account, context) {
15
+ this.apiClient = apiClient;
16
+ this.account = account;
17
+ this.context = context;
18
+ }
19
+ async login({ address }) {
20
+ (0, __otim_sdk_core_context.assertRequiresAuth)(this.context);
21
+ const message = (0, __otim_sdk_core_config.createLoginSiweMessage)(address, Date.now().toString());
22
+ const vrsParsedSignature = (0, __otim_utils_helpers.parseSignatureToVRS)(await this.account.signMessage({ message }));
23
+ return (await this.apiClient.auth.login({
24
+ siwe: message,
25
+ signature: vrsParsedSignature
26
+ })).data;
27
+ }
28
+ async getCurrentUser() {
29
+ return (await this.apiClient.auth.me()).data;
30
+ }
31
+ };
32
+
33
+ //#endregion
34
+ //#region src/clients/config.ts
35
+ var ConfigClient = class {
36
+ constructor(apiClient) {
37
+ this.apiClient = apiClient;
38
+ }
39
+ async getMaxPriorityFeeEstimate({ chainId }) {
40
+ return (await this.apiClient.config.getMaxPriorityFeePerGasEstimate({ chainId })).data;
41
+ }
42
+ };
43
+
44
+ //#endregion
45
+ //#region src/clients/delegation.ts
46
+ var DelegationClient = class {
47
+ constructor(apiClient) {
48
+ this.apiClient = apiClient;
49
+ }
50
+ async getDelegateAddress({ chainId }) {
51
+ return (await this.apiClient.config.getDelegateAddress({ chainId })).data;
52
+ }
53
+ async getDelegationStatus(options) {
54
+ return (await this.apiClient.account.getDelegationStatus({
55
+ address: options.address,
56
+ chainId: options.chainId
57
+ })).data;
58
+ }
59
+ async createDelegation(delegationRequest) {
60
+ await this.apiClient.account.createDelegation(delegationRequest);
61
+ }
62
+ };
63
+
64
+ //#endregion
65
+ //#region src/clients/helpers/payment-signer.ts
66
+ async function createPaymentSigner(params) {
67
+ const { context, buildResponse, publicClient, delegateAddressMap } = params;
68
+ if ((0, __otim_sdk_core_account.isApiAccountConfig)(context.config)) return new __otim_turnkey_signing.UnifiedPaymentSigner({
69
+ buildResponse,
70
+ signingService: new __otim_turnkey_signing.ApiKeyClientSigningService(context.config.publicKey, context.config.privateKey),
71
+ publicClient,
72
+ delegateAddressMap
73
+ }).signAll();
74
+ const walletClient = (0, viem.createWalletClient)({
75
+ account: (0, viem_accounts.privateKeyToAccount)(context.config.privateKey),
76
+ transport: (0, viem.http)()
77
+ });
78
+ return new __otim_turnkey_signing.UnifiedPaymentSigner({
79
+ buildResponse,
80
+ signingService: __otim_turnkey_signing.ServerWalletSigningService.fromViemWallet(walletClient),
81
+ publicClient,
82
+ delegateAddressMap
83
+ }).signAll();
84
+ }
85
+
86
+ //#endregion
87
+ //#region src/clients/payment-requests.ts
88
+ var PaymentRequestsClient = class {
89
+ constructor(apiClient, account, context) {
90
+ this.apiClient = apiClient;
91
+ this.account = account;
92
+ this.context = context;
93
+ }
94
+ async create(params) {
95
+ const { chainId, token = "USDC", recipient, amount, payer, note, dueDate, metadata: customMetadata } = params;
96
+ if (dueDate) (0, __otim_utils_helpers.validateIso8601Date)(dueDate);
97
+ const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);
98
+ const metadata = this.buildMetadata({
99
+ token,
100
+ amount,
101
+ recipient,
102
+ note,
103
+ dueDate,
104
+ customMetadata
105
+ });
106
+ const payload = this.createPayload({
107
+ chainId,
108
+ recipient,
109
+ amount,
110
+ payer,
111
+ metadata,
112
+ feeTokenAddress
113
+ });
114
+ const buildResponse = await this.buildAndEnhancePaymentRequest(payload);
115
+ await this.activate({
116
+ buildResponse,
117
+ settlementChainId: chainId
118
+ });
119
+ return {
120
+ requestId: buildResponse.requestId,
121
+ ephemeralWalletAddress: buildResponse.ephemeralWalletAddress
122
+ };
123
+ }
124
+ async activate(params) {
125
+ (0, __otim_sdk_core_context.assertServerContext)(this.context);
126
+ const { buildResponse, settlementChainId } = params;
127
+ const publicClient = this.createPublicClient(settlementChainId);
128
+ const instructions = [...buildResponse.completionInstructions, ...buildResponse.instructions];
129
+ const delegateAddressMap = await this.fetchDelegateAddresses(instructions);
130
+ const { signedAuthorization, completionInstructions, instructions: signedInstructions } = await createPaymentSigner({
131
+ context: this.context,
132
+ buildResponse,
133
+ publicClient,
134
+ delegateAddressMap
135
+ });
136
+ await this.apiClient.payments.newPaymentRequest({
137
+ requestId: buildResponse.requestId,
138
+ signedAuthorization,
139
+ completionInstructions,
140
+ instructions: signedInstructions
141
+ });
142
+ }
143
+ validateAndGetTokenAddress(chainId, token) {
144
+ const tokenAddress = (0, __otim_utils_chains.getTokenAddress)(chainId, token);
145
+ if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
146
+ if (!(0, __otim_utils_chains.getTokenMetadata)(token)) throw new Error(`Token ${token} metadata not found`);
147
+ return __otim_utils_schemas.hexStringSchema.parse(tokenAddress);
148
+ }
149
+ buildMetadata(params) {
150
+ const { token, amount, recipient, note, dueDate, customMetadata } = params;
151
+ const baseMetadata = (0, __otim_utils_payments.buildPaymentMetadata)({
152
+ tokenSymbol: token,
153
+ amountInUSD: amount,
154
+ fromAccountAddress: recipient,
155
+ note,
156
+ dueDate,
157
+ hasInvoiceMetadata: false
158
+ });
159
+ return customMetadata ? {
160
+ ...baseMetadata,
161
+ ...customMetadata
162
+ } : baseMetadata;
163
+ }
164
+ createPayload(params) {
165
+ const { chainId, recipient, amount, payer, metadata, feeTokenAddress } = params;
166
+ const chainTokenConfigs = (0, __otim_utils_payments.createChainTokenConfigs)(Object.values(__otim_utils_chains.supportedChains.mainnet).flatMap((chain) => (0, __otim_utils_chains.getChainTokens)(chain.id)));
167
+ return (0, __otim_utils_payments.createComprehensivePaymentRequest)({
168
+ settlementChainId: chainId,
169
+ recipient,
170
+ amount: amount.toString(),
171
+ ephemeralWalletAddress: recipient,
172
+ chainTokenConfigs,
173
+ payerAddress: payer ?? null,
174
+ metadata,
175
+ feeToken: feeTokenAddress
176
+ });
177
+ }
178
+ async buildAndEnhancePaymentRequest(payload) {
179
+ const actionNames = (0, __otim_utils_payments.extractActionNamesMap)(payload.completionInstructions, payload.instructions);
180
+ return (0, __otim_utils_payments.addActionNamesToInstructions)((await this.apiClient.payments.buildPaymentRequest(payload)).data, actionNames);
181
+ }
182
+ createPublicClient(chainId) {
183
+ const chain = (0, __otim_utils_chains.getChainById)(chainId);
184
+ if (!chain) throw new Error(`Chain with id ${chainId} not found`);
185
+ return (0, viem.createPublicClient)({
186
+ chain,
187
+ transport: (0, viem.http)()
188
+ });
189
+ }
190
+ async fetchDelegateAddresses(instructions) {
191
+ const chainIds = Array.from(new Set(instructions.map((instruction) => instruction.chainId)));
192
+ const addresses = await Promise.all(chainIds.map(async (chainId) => {
193
+ const response = await this.apiClient.config.getDelegateAddress({ chainId });
194
+ return [chainId, __otim_utils_schemas.hexStringSchema.parse(response.data.otimDelegateAddress)];
195
+ }));
196
+ return new Map(addresses);
197
+ }
198
+ async getDetails(request) {
199
+ return this.apiClient.payments.getPaymentRequestDetails(request);
200
+ }
201
+ async listOutgoingPaymentRequests(request) {
202
+ return this.apiClient.payments.getOutgoingPaymentsList(request);
203
+ }
204
+ async listIncomingPaymentRequests(request) {
205
+ return this.apiClient.payments.getIncomingPaymentsList(request);
206
+ }
207
+ async list(request) {
208
+ return this.apiClient.payments.getPaymentRequests(request);
209
+ }
210
+ };
211
+
212
+ //#endregion
213
+ //#region \0@oxc-project+runtime@0.97.0/helpers/typeof.js
214
+ function _typeof(o) {
215
+ "@babel/helpers - typeof";
216
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
217
+ return typeof o$1;
218
+ } : function(o$1) {
219
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
220
+ }, _typeof(o);
221
+ }
222
+
223
+ //#endregion
224
+ //#region \0@oxc-project+runtime@0.97.0/helpers/toPrimitive.js
225
+ function toPrimitive(t, r) {
226
+ if ("object" != _typeof(t) || !t) return t;
227
+ var e = t[Symbol.toPrimitive];
228
+ if (void 0 !== e) {
229
+ var i = e.call(t, r || "default");
230
+ if ("object" != _typeof(i)) return i;
231
+ throw new TypeError("@@toPrimitive must return a primitive value.");
232
+ }
233
+ return ("string" === r ? String : Number)(t);
234
+ }
235
+
236
+ //#endregion
237
+ //#region \0@oxc-project+runtime@0.97.0/helpers/toPropertyKey.js
238
+ function toPropertyKey(t) {
239
+ var i = toPrimitive(t, "string");
240
+ return "symbol" == _typeof(i) ? i : i + "";
241
+ }
242
+
243
+ //#endregion
244
+ //#region \0@oxc-project+runtime@0.97.0/helpers/defineProperty.js
245
+ function _defineProperty(e, r, t) {
246
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
247
+ value: t,
248
+ enumerable: !0,
249
+ configurable: !0,
250
+ writable: !0
251
+ }) : e[r] = t, e;
252
+ }
253
+
254
+ //#endregion
255
+ //#region src/clients/orchestration.ts
256
+ var OrchestrationClient = class {
257
+ constructor(apiClient, account, context) {
258
+ this.apiClient = apiClient;
259
+ this.account = account;
260
+ this.context = context;
261
+ _defineProperty(this, "paymentRequests", void 0);
262
+ this.paymentRequests = new PaymentRequestsClient(apiClient, account, context);
263
+ }
264
+ };
265
+
266
+ //#endregion
267
+ Object.defineProperty(exports, 'AuthClient', {
268
+ enumerable: true,
269
+ get: function () {
270
+ return AuthClient;
271
+ }
272
+ });
273
+ Object.defineProperty(exports, 'ConfigClient', {
274
+ enumerable: true,
275
+ get: function () {
276
+ return ConfigClient;
277
+ }
278
+ });
279
+ Object.defineProperty(exports, 'DelegationClient', {
280
+ enumerable: true,
281
+ get: function () {
282
+ return DelegationClient;
283
+ }
284
+ });
285
+ Object.defineProperty(exports, 'OrchestrationClient', {
286
+ enumerable: true,
287
+ get: function () {
288
+ return OrchestrationClient;
289
+ }
290
+ });
291
+ Object.defineProperty(exports, 'PaymentRequestsClient', {
292
+ enumerable: true,
293
+ get: function () {
294
+ return PaymentRequestsClient;
295
+ }
296
+ });
297
+ //# sourceMappingURL=clients-DBRhkU4y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clients-DBRhkU4y.cjs","names":["apiClient: APIClient","account: OtimAccount","context: OtimClientContext","apiClient: APIClient","apiClient: APIClient","UnifiedPaymentSigner","ApiKeyClientSigningService","ServerWalletSigningService","apiClient: APIClient","account: OtimAccount","context: OtimClientContext","hexStringSchema","supportedChains","apiClient: APIClient","account: OtimAccount","context: OtimClientContext"],"sources":["../src/clients/auth.ts","../src/clients/config.ts","../src/clients/delegation.ts","../src/clients/helpers/payment-signer.ts","../src/clients/payment-requests.ts","../src/clients/orchestration.ts"],"sourcesContent":["import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type { APIClient, AuthLoginResponse, MeResponse } from \"@otim/utils/api\";\nimport type { Address } from \"viem\";\n\nimport { parseSignatureToVRS } from \"@otim/utils/helpers\";\n\nimport { createLoginSiweMessage } from \"@otim/sdk-core/config\";\nimport { assertRequiresAuth } from \"@otim/sdk-core/context\";\n\nexport interface LoginOptions {\n address: Address;\n}\n\nexport class AuthClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {}\n\n async login({ address }: LoginOptions): Promise<AuthLoginResponse> {\n assertRequiresAuth(this.context);\n\n const message = createLoginSiweMessage(address, Date.now().toString());\n const signature = await this.account.signMessage({ message });\n const vrsParsedSignature = parseSignatureToVRS(signature);\n\n const response = await this.apiClient.auth.login({\n siwe: message,\n signature: vrsParsedSignature,\n });\n\n return response.data;\n }\n\n async getCurrentUser(): Promise<MeResponse> {\n const response = await this.apiClient.auth.me();\n return response.data;\n }\n}\n","import type {\n APIClient,\n GetMaxPriorityFeePerGasEstimateRequest,\n GetMaxPriorityFeePerGasEstimateResponse,\n} from \"@otim/utils/api\";\n\nexport class ConfigClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getMaxPriorityFeeEstimate({\n chainId,\n }: GetMaxPriorityFeePerGasEstimateRequest): Promise<GetMaxPriorityFeePerGasEstimateResponse> {\n const response =\n await this.apiClient.config.getMaxPriorityFeePerGasEstimate({ chainId });\n\n return response.data;\n }\n}\n","import type {\n APIClient,\n DelegationCreateRequest,\n DelegationStatusRequest,\n DelegationStatusResponse,\n GetDelegateAddressRequest,\n GetDelegateAddressResponse,\n} from \"@otim/utils/api\";\n\nexport class DelegationClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getDelegateAddress({\n chainId,\n }: GetDelegateAddressRequest): Promise<GetDelegateAddressResponse> {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n\n return response.data;\n }\n\n async getDelegationStatus(\n options: DelegationStatusRequest,\n ): Promise<DelegationStatusResponse> {\n const response = await this.apiClient.account.getDelegationStatus({\n address: options.address,\n chainId: options.chainId,\n });\n\n return response.data;\n }\n\n async createDelegation(\n delegationRequest: DelegationCreateRequest,\n ): Promise<void> {\n await this.apiClient.account.createDelegation(delegationRequest);\n }\n}\n","import type { OtimServerClientContext } from \"@otim/sdk-core/context\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport {\n ApiKeyClientSigningService,\n ServerWalletSigningService,\n UnifiedPaymentSigner,\n} from \"@otim/turnkey/signing\";\nimport { createWalletClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\n\nimport { isApiAccountConfig } from \"@otim/sdk-core/account\";\n\nexport interface CreatePaymentSignerParams {\n context: OtimServerClientContext;\n buildResponse: PaymentResponseWithActionNames;\n publicClient: PublicClient;\n delegateAddressMap: Map<number, Address>;\n}\n\ntype CreatePaymentSignerResult = Awaited<\n ReturnType<UnifiedPaymentSigner[\"signAll\"]>\n>;\n\nexport async function createPaymentSigner(\n params: CreatePaymentSignerParams,\n): Promise<CreatePaymentSignerResult> {\n const { context, buildResponse, publicClient, delegateAddressMap } = params;\n\n if (isApiAccountConfig(context.config)) {\n const signingService = new ApiKeyClientSigningService(\n context.config.publicKey,\n context.config.privateKey,\n );\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n }\n\n const account = privateKeyToAccount(context.config.privateKey);\n const walletClient = createWalletClient({\n account,\n transport: http(),\n });\n\n const signingService =\n ServerWalletSigningService.fromViemWallet(walletClient);\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type {\n APIClient,\n GetPaymentRequestsRequest,\n GetPaymentRequestsResponse,\n PaginatedServiceResponse,\n PaymentRequestBuildRequest,\n PaymentRequestDetailsRequest,\n PaymentRequestDetailsResponse,\n PaymentsListRequest,\n ServiceResponse,\n} from \"@otim/utils/api\";\nimport type { SupportedChainId } from \"@otim/utils/chains\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { PaymentRequestMetadata } from \"@otim/utils/payments\";\nimport type { Address, Payments } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport {\n getChainById,\n getChainTokens,\n getTokenAddress,\n getTokenMetadata,\n supportedChains,\n} from \"@otim/utils/chains\";\nimport { validateIso8601Date } from \"@otim/utils/helpers\";\nimport {\n addActionNamesToInstructions,\n buildPaymentMetadata,\n createChainTokenConfigs,\n createComprehensivePaymentRequest,\n extractActionNamesMap,\n} from \"@otim/utils/payments\";\nimport { hexStringSchema } from \"@otim/utils/schemas\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { assertServerContext } from \"@otim/sdk-core/context\";\n\nimport { createPaymentSigner } from \"./helpers/payment-signer\";\n\nexport interface CreatePaymentRequestParameters {\n amount: number;\n chainId: SupportedChainId;\n recipient: Address;\n token?: \"USDC\" | \"USDT\";\n payer?: Nullable<Address>;\n /**\n * ISO 8601 date format (e.g., \"2024-12-31T23:59:59.000Z\")\n */\n dueDate?: string;\n metadata?: PaymentRequestMetadata;\n note?: string;\n}\n\nexport interface CreatePaymentRequestResponse {\n requestId: string;\n ephemeralWalletAddress: Address;\n}\n\nexport interface ActivatePaymentRequestParams {\n buildResponse: PaymentResponseWithActionNames;\n settlementChainId: number;\n}\n\ntype PaymentInstruction =\n PaymentResponseWithActionNames[\"completionInstructions\"][number];\n\nexport class PaymentRequestsClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {}\n\n async create(\n params: CreatePaymentRequestParameters,\n ): Promise<CreatePaymentRequestResponse> {\n const {\n chainId,\n token = \"USDC\",\n recipient,\n amount,\n payer,\n note,\n dueDate,\n metadata: customMetadata,\n } = params;\n\n if (dueDate) {\n validateIso8601Date(dueDate);\n }\n\n const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);\n const metadata = this.buildMetadata({\n token,\n amount,\n recipient,\n note,\n dueDate,\n customMetadata,\n });\n const payload = this.createPayload({\n chainId,\n recipient,\n amount,\n payer,\n metadata,\n feeTokenAddress,\n });\n\n const buildResponse = await this.buildAndEnhancePaymentRequest(payload);\n\n await this.activate({ buildResponse, settlementChainId: chainId });\n\n return {\n requestId: buildResponse.requestId,\n ephemeralWalletAddress: buildResponse.ephemeralWalletAddress,\n };\n }\n\n async activate(params: ActivatePaymentRequestParams): Promise<void> {\n assertServerContext(this.context);\n\n const { buildResponse, settlementChainId } = params;\n const publicClient = this.createPublicClient(settlementChainId);\n\n const instructions = [\n ...buildResponse.completionInstructions,\n ...buildResponse.instructions,\n ];\n\n const delegateAddressMap = await this.fetchDelegateAddresses(instructions);\n\n const {\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n } = await createPaymentSigner({\n context: this.context,\n buildResponse,\n publicClient,\n delegateAddressMap,\n });\n\n await this.apiClient.payments.newPaymentRequest({\n requestId: buildResponse.requestId,\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n });\n }\n\n private validateAndGetTokenAddress(chainId: number, token: string): Address {\n const tokenAddress = getTokenAddress(chainId, token);\n if (!tokenAddress) {\n throw new Error(`Token ${token} not supported on chain ${chainId}`);\n }\n\n const tokenMetadata = getTokenMetadata(token);\n if (!tokenMetadata) {\n throw new Error(`Token ${token} metadata not found`);\n }\n\n return hexStringSchema.parse(tokenAddress);\n }\n\n private buildMetadata(params: {\n token: string;\n amount: number;\n recipient: Address;\n note?: string;\n dueDate?: string;\n customMetadata?: PaymentRequestMetadata;\n }): PaymentRequestMetadata {\n const { token, amount, recipient, note, dueDate, customMetadata } = params;\n\n const baseMetadata = buildPaymentMetadata({\n tokenSymbol: token,\n amountInUSD: amount,\n fromAccountAddress: recipient,\n note,\n dueDate,\n hasInvoiceMetadata: false,\n });\n\n return customMetadata\n ? { ...baseMetadata, ...customMetadata }\n : baseMetadata;\n }\n\n private createPayload(params: {\n chainId: number;\n recipient: Address;\n amount: number;\n payer?: Address | null;\n metadata: PaymentRequestMetadata;\n feeTokenAddress: Address;\n }): PaymentRequestBuildRequest {\n const { chainId, recipient, amount, payer, metadata, feeTokenAddress } =\n params;\n\n const tokens = Object.values(supportedChains.mainnet).flatMap((chain) =>\n getChainTokens(chain.id),\n );\n\n const chainTokenConfigs = createChainTokenConfigs(tokens);\n\n return createComprehensivePaymentRequest({\n settlementChainId: chainId,\n recipient,\n amount: amount.toString(),\n ephemeralWalletAddress: recipient,\n chainTokenConfigs,\n payerAddress: payer ?? null,\n metadata,\n feeToken: feeTokenAddress,\n });\n }\n\n private async buildAndEnhancePaymentRequest(\n payload: PaymentRequestBuildRequest,\n ): Promise<PaymentResponseWithActionNames> {\n const actionNames = extractActionNamesMap(\n payload.completionInstructions,\n payload.instructions,\n );\n\n const response = await this.apiClient.payments.buildPaymentRequest(payload);\n\n return addActionNamesToInstructions(response.data, actionNames);\n }\n\n private createPublicClient(chainId: number): PublicClient {\n const chain = getChainById(chainId);\n if (!chain) {\n throw new Error(`Chain with id ${chainId} not found`);\n }\n\n return createPublicClient({ chain, transport: http() });\n }\n\n private async fetchDelegateAddresses(\n instructions: PaymentInstruction[],\n ): Promise<Map<number, Address>> {\n const chainIds = Array.from(\n new Set(instructions.map((instruction) => instruction.chainId)),\n );\n\n const addresses = await Promise.all(\n chainIds.map(async (chainId) => {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n const address = hexStringSchema.parse(\n response.data.otimDelegateAddress,\n );\n return [chainId, address] as const;\n }),\n );\n\n return new Map(addresses);\n }\n\n async getDetails(\n request: PaymentRequestDetailsRequest,\n ): Promise<ServiceResponse<PaymentRequestDetailsResponse>> {\n return this.apiClient.payments.getPaymentRequestDetails(request);\n }\n\n async listOutgoingPaymentRequests(\n request: PaymentsListRequest,\n ): Promise<PaginatedServiceResponse<Payments>> {\n return this.apiClient.payments.getOutgoingPaymentsList(request);\n }\n\n async listIncomingPaymentRequests(\n request: PaymentsListRequest,\n ): Promise<PaginatedServiceResponse<Payments>> {\n return this.apiClient.payments.getIncomingPaymentsList(request);\n }\n\n async list(\n request: GetPaymentRequestsRequest,\n ): Promise<PaginatedServiceResponse<GetPaymentRequestsResponse>> {\n return this.apiClient.payments.getPaymentRequests(request);\n }\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type { APIClient } from \"@otim/utils/api\";\n\nimport { PaymentRequestsClient } from \"./payment-requests\";\n\nexport class OrchestrationClient {\n public readonly paymentRequests: PaymentRequestsClient;\n\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {\n this.paymentRequests = new PaymentRequestsClient(\n apiClient,\n account,\n context,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,aAAb,MAAwB;CACtB,YACE,AAAiBA,WACjB,AAAiBC,SACjB,AAAiBC,SACjB;EAHiB;EACA;EACA;;CAGnB,MAAM,MAAM,EAAE,WAAqD;AACjE,kDAAmB,KAAK,QAAQ;EAEhC,MAAM,6DAAiC,SAAS,KAAK,KAAK,CAAC,UAAU,CAAC;EAEtE,MAAM,mEADY,MAAM,KAAK,QAAQ,YAAY,EAAE,SAAS,CAAC,CACJ;AAOzD,UALiB,MAAM,KAAK,UAAU,KAAK,MAAM;GAC/C,MAAM;GACN,WAAW;GACZ,CAAC,EAEc;;CAGlB,MAAM,iBAAsC;AAE1C,UADiB,MAAM,KAAK,UAAU,KAAK,IAAI,EAC/B;;;;;;AChCpB,IAAa,eAAb,MAA0B;CACxB,YAAY,AAAiBC,WAAsB;EAAtB;;CAE7B,MAAM,0BAA0B,EAC9B,WAC2F;AAI3F,UAFE,MAAM,KAAK,UAAU,OAAO,gCAAgC,EAAE,SAAS,CAAC,EAE1D;;;;;;ACNpB,IAAa,mBAAb,MAA8B;CAC5B,YAAY,AAAiBC,WAAsB;EAAtB;;CAE7B,MAAM,mBAAmB,EACvB,WACiE;AAKjE,UAJiB,MAAM,KAAK,UAAU,OAAO,mBAAmB,EAC9D,SACD,CAAC,EAEc;;CAGlB,MAAM,oBACJ,SACmC;AAMnC,UALiB,MAAM,KAAK,UAAU,QAAQ,oBAAoB;GAChE,SAAS,QAAQ;GACjB,SAAS,QAAQ;GAClB,CAAC,EAEc;;CAGlB,MAAM,iBACJ,mBACe;AACf,QAAM,KAAK,UAAU,QAAQ,iBAAiB,kBAAkB;;;;;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BAAiB,QAAQ,YAAY;AAGvD,sCAA0B;GAAE;GAAO,2BAAiB;GAAE,CAAC;;CAGzD,MAAc,uBACZ,cAC+B;EAC/B,MAAM,WAAW,MAAM,KACrB,IAAI,IAAI,aAAa,KAAK,gBAAgB,YAAY,QAAQ,CAAC,CAChE;EAED,MAAM,YAAY,MAAM,QAAQ,IAC9B,SAAS,IAAI,OAAO,YAAY;GAC9B,MAAM,WAAW,MAAM,KAAK,UAAU,OAAO,mBAAmB,EAC9D,SACD,CAAC;AAIF,UAAO,CAAC,SAHQD,qCAAgB,MAC9B,SAAS,KAAK,oBACf,CACwB;IACzB,CACH;AAED,SAAO,IAAI,IAAI,UAAU;;CAG3B,MAAM,WACJ,SACyD;AACzD,SAAO,KAAK,UAAU,SAAS,yBAAyB,QAAQ;;CAGlE,MAAM,4BACJ,SAC6C;AAC7C,SAAO,KAAK,UAAU,SAAS,wBAAwB,QAAQ;;CAGjE,MAAM,4BACJ,SAC6C;AAC7C,SAAO,KAAK,UAAU,SAAS,wBAAwB,QAAQ;;CAGjE,MAAM,KACJ,SAC+D;AAC/D,SAAO,KAAK,UAAU,SAAS,mBAAmB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxR9D,IAAa,sBAAb,MAAiC;CAG/B,YACE,AAAiBE,WACjB,AAAiBC,SACjB,AAAiBC,SACjB;EAHiB;EACA;EACA;wBALH;AAOd,OAAK,kBAAkB,IAAI,sBACzB,WACA,SACA,QACD"}
@@ -0,0 +1,268 @@
1
+ import { parseSignatureToVRS, validateIso8601Date } from "@otim/utils/helpers";
2
+ import { createLoginSiweMessage } from "@otim/sdk-core/config";
3
+ import { assertRequiresAuth, assertServerContext } from "@otim/sdk-core/context";
4
+ import { getChainById, getChainTokens, getTokenAddress, getTokenMetadata, supportedChains } from "@otim/utils/chains";
5
+ import { addActionNamesToInstructions, buildPaymentMetadata, createChainTokenConfigs, createComprehensivePaymentRequest, extractActionNamesMap } from "@otim/utils/payments";
6
+ import { hexStringSchema } from "@otim/utils/schemas";
7
+ import { createPublicClient, createWalletClient, http } from "viem";
8
+ import { ApiKeyClientSigningService, ServerWalletSigningService, UnifiedPaymentSigner } from "@otim/turnkey/signing";
9
+ import { privateKeyToAccount } from "viem/accounts";
10
+ import { isApiAccountConfig } from "@otim/sdk-core/account";
11
+
12
+ //#region src/clients/auth.ts
13
+ var AuthClient = class {
14
+ constructor(apiClient, account, context) {
15
+ this.apiClient = apiClient;
16
+ this.account = account;
17
+ this.context = context;
18
+ }
19
+ async login({ address }) {
20
+ assertRequiresAuth(this.context);
21
+ const message = createLoginSiweMessage(address, Date.now().toString());
22
+ const vrsParsedSignature = parseSignatureToVRS(await this.account.signMessage({ message }));
23
+ return (await this.apiClient.auth.login({
24
+ siwe: message,
25
+ signature: vrsParsedSignature
26
+ })).data;
27
+ }
28
+ async getCurrentUser() {
29
+ return (await this.apiClient.auth.me()).data;
30
+ }
31
+ };
32
+
33
+ //#endregion
34
+ //#region src/clients/config.ts
35
+ var ConfigClient = class {
36
+ constructor(apiClient) {
37
+ this.apiClient = apiClient;
38
+ }
39
+ async getMaxPriorityFeeEstimate({ chainId }) {
40
+ return (await this.apiClient.config.getMaxPriorityFeePerGasEstimate({ chainId })).data;
41
+ }
42
+ };
43
+
44
+ //#endregion
45
+ //#region src/clients/delegation.ts
46
+ var DelegationClient = class {
47
+ constructor(apiClient) {
48
+ this.apiClient = apiClient;
49
+ }
50
+ async getDelegateAddress({ chainId }) {
51
+ return (await this.apiClient.config.getDelegateAddress({ chainId })).data;
52
+ }
53
+ async getDelegationStatus(options) {
54
+ return (await this.apiClient.account.getDelegationStatus({
55
+ address: options.address,
56
+ chainId: options.chainId
57
+ })).data;
58
+ }
59
+ async createDelegation(delegationRequest) {
60
+ await this.apiClient.account.createDelegation(delegationRequest);
61
+ }
62
+ };
63
+
64
+ //#endregion
65
+ //#region src/clients/helpers/payment-signer.ts
66
+ async function createPaymentSigner(params) {
67
+ const { context, buildResponse, publicClient, delegateAddressMap } = params;
68
+ if (isApiAccountConfig(context.config)) return new UnifiedPaymentSigner({
69
+ buildResponse,
70
+ signingService: new ApiKeyClientSigningService(context.config.publicKey, context.config.privateKey),
71
+ publicClient,
72
+ delegateAddressMap
73
+ }).signAll();
74
+ const walletClient = createWalletClient({
75
+ account: privateKeyToAccount(context.config.privateKey),
76
+ transport: http()
77
+ });
78
+ return new UnifiedPaymentSigner({
79
+ buildResponse,
80
+ signingService: ServerWalletSigningService.fromViemWallet(walletClient),
81
+ publicClient,
82
+ delegateAddressMap
83
+ }).signAll();
84
+ }
85
+
86
+ //#endregion
87
+ //#region src/clients/payment-requests.ts
88
+ var PaymentRequestsClient = class {
89
+ constructor(apiClient, account, context) {
90
+ this.apiClient = apiClient;
91
+ this.account = account;
92
+ this.context = context;
93
+ }
94
+ async create(params) {
95
+ const { chainId, token = "USDC", recipient, amount, payer, note, dueDate, metadata: customMetadata } = params;
96
+ if (dueDate) validateIso8601Date(dueDate);
97
+ const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);
98
+ const metadata = this.buildMetadata({
99
+ token,
100
+ amount,
101
+ recipient,
102
+ note,
103
+ dueDate,
104
+ customMetadata
105
+ });
106
+ const payload = this.createPayload({
107
+ chainId,
108
+ recipient,
109
+ amount,
110
+ payer,
111
+ metadata,
112
+ feeTokenAddress
113
+ });
114
+ const buildResponse = await this.buildAndEnhancePaymentRequest(payload);
115
+ await this.activate({
116
+ buildResponse,
117
+ settlementChainId: chainId
118
+ });
119
+ return {
120
+ requestId: buildResponse.requestId,
121
+ ephemeralWalletAddress: buildResponse.ephemeralWalletAddress
122
+ };
123
+ }
124
+ async activate(params) {
125
+ assertServerContext(this.context);
126
+ const { buildResponse, settlementChainId } = params;
127
+ const publicClient = this.createPublicClient(settlementChainId);
128
+ const instructions = [...buildResponse.completionInstructions, ...buildResponse.instructions];
129
+ const delegateAddressMap = await this.fetchDelegateAddresses(instructions);
130
+ const { signedAuthorization, completionInstructions, instructions: signedInstructions } = await createPaymentSigner({
131
+ context: this.context,
132
+ buildResponse,
133
+ publicClient,
134
+ delegateAddressMap
135
+ });
136
+ await this.apiClient.payments.newPaymentRequest({
137
+ requestId: buildResponse.requestId,
138
+ signedAuthorization,
139
+ completionInstructions,
140
+ instructions: signedInstructions
141
+ });
142
+ }
143
+ validateAndGetTokenAddress(chainId, token) {
144
+ const tokenAddress = getTokenAddress(chainId, token);
145
+ if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
146
+ if (!getTokenMetadata(token)) throw new Error(`Token ${token} metadata not found`);
147
+ return hexStringSchema.parse(tokenAddress);
148
+ }
149
+ buildMetadata(params) {
150
+ const { token, amount, recipient, note, dueDate, customMetadata } = params;
151
+ const baseMetadata = buildPaymentMetadata({
152
+ tokenSymbol: token,
153
+ amountInUSD: amount,
154
+ fromAccountAddress: recipient,
155
+ note,
156
+ dueDate,
157
+ hasInvoiceMetadata: false
158
+ });
159
+ return customMetadata ? {
160
+ ...baseMetadata,
161
+ ...customMetadata
162
+ } : baseMetadata;
163
+ }
164
+ createPayload(params) {
165
+ const { chainId, recipient, amount, payer, metadata, feeTokenAddress } = params;
166
+ const chainTokenConfigs = createChainTokenConfigs(Object.values(supportedChains.mainnet).flatMap((chain) => getChainTokens(chain.id)));
167
+ return createComprehensivePaymentRequest({
168
+ settlementChainId: chainId,
169
+ recipient,
170
+ amount: amount.toString(),
171
+ ephemeralWalletAddress: recipient,
172
+ chainTokenConfigs,
173
+ payerAddress: payer ?? null,
174
+ metadata,
175
+ feeToken: feeTokenAddress
176
+ });
177
+ }
178
+ async buildAndEnhancePaymentRequest(payload) {
179
+ const actionNames = extractActionNamesMap(payload.completionInstructions, payload.instructions);
180
+ return addActionNamesToInstructions((await this.apiClient.payments.buildPaymentRequest(payload)).data, actionNames);
181
+ }
182
+ createPublicClient(chainId) {
183
+ const chain = getChainById(chainId);
184
+ if (!chain) throw new Error(`Chain with id ${chainId} not found`);
185
+ return createPublicClient({
186
+ chain,
187
+ transport: http()
188
+ });
189
+ }
190
+ async fetchDelegateAddresses(instructions) {
191
+ const chainIds = Array.from(new Set(instructions.map((instruction) => instruction.chainId)));
192
+ const addresses = await Promise.all(chainIds.map(async (chainId) => {
193
+ const response = await this.apiClient.config.getDelegateAddress({ chainId });
194
+ return [chainId, hexStringSchema.parse(response.data.otimDelegateAddress)];
195
+ }));
196
+ return new Map(addresses);
197
+ }
198
+ async getDetails(request) {
199
+ return this.apiClient.payments.getPaymentRequestDetails(request);
200
+ }
201
+ async listOutgoingPaymentRequests(request) {
202
+ return this.apiClient.payments.getOutgoingPaymentsList(request);
203
+ }
204
+ async listIncomingPaymentRequests(request) {
205
+ return this.apiClient.payments.getIncomingPaymentsList(request);
206
+ }
207
+ async list(request) {
208
+ return this.apiClient.payments.getPaymentRequests(request);
209
+ }
210
+ };
211
+
212
+ //#endregion
213
+ //#region \0@oxc-project+runtime@0.97.0/helpers/typeof.js
214
+ function _typeof(o) {
215
+ "@babel/helpers - typeof";
216
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
217
+ return typeof o$1;
218
+ } : function(o$1) {
219
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
220
+ }, _typeof(o);
221
+ }
222
+
223
+ //#endregion
224
+ //#region \0@oxc-project+runtime@0.97.0/helpers/toPrimitive.js
225
+ function toPrimitive(t, r) {
226
+ if ("object" != _typeof(t) || !t) return t;
227
+ var e = t[Symbol.toPrimitive];
228
+ if (void 0 !== e) {
229
+ var i = e.call(t, r || "default");
230
+ if ("object" != _typeof(i)) return i;
231
+ throw new TypeError("@@toPrimitive must return a primitive value.");
232
+ }
233
+ return ("string" === r ? String : Number)(t);
234
+ }
235
+
236
+ //#endregion
237
+ //#region \0@oxc-project+runtime@0.97.0/helpers/toPropertyKey.js
238
+ function toPropertyKey(t) {
239
+ var i = toPrimitive(t, "string");
240
+ return "symbol" == _typeof(i) ? i : i + "";
241
+ }
242
+
243
+ //#endregion
244
+ //#region \0@oxc-project+runtime@0.97.0/helpers/defineProperty.js
245
+ function _defineProperty(e, r, t) {
246
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
247
+ value: t,
248
+ enumerable: !0,
249
+ configurable: !0,
250
+ writable: !0
251
+ }) : e[r] = t, e;
252
+ }
253
+
254
+ //#endregion
255
+ //#region src/clients/orchestration.ts
256
+ var OrchestrationClient = class {
257
+ constructor(apiClient, account, context) {
258
+ this.apiClient = apiClient;
259
+ this.account = account;
260
+ this.context = context;
261
+ _defineProperty(this, "paymentRequests", void 0);
262
+ this.paymentRequests = new PaymentRequestsClient(apiClient, account, context);
263
+ }
264
+ };
265
+
266
+ //#endregion
267
+ export { AuthClient as a, ConfigClient as i, PaymentRequestsClient as n, DelegationClient as r, OrchestrationClient as t };
268
+ //# sourceMappingURL=clients-DMKeLhcJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clients-DMKeLhcJ.mjs","names":["apiClient: APIClient","account: OtimAccount","context: OtimClientContext","apiClient: APIClient","apiClient: APIClient","apiClient: APIClient","account: OtimAccount","context: OtimClientContext","apiClient: APIClient","account: OtimAccount","context: OtimClientContext"],"sources":["../src/clients/auth.ts","../src/clients/config.ts","../src/clients/delegation.ts","../src/clients/helpers/payment-signer.ts","../src/clients/payment-requests.ts","../src/clients/orchestration.ts"],"sourcesContent":["import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type { APIClient, AuthLoginResponse, MeResponse } from \"@otim/utils/api\";\nimport type { Address } from \"viem\";\n\nimport { parseSignatureToVRS } from \"@otim/utils/helpers\";\n\nimport { createLoginSiweMessage } from \"@otim/sdk-core/config\";\nimport { assertRequiresAuth } from \"@otim/sdk-core/context\";\n\nexport interface LoginOptions {\n address: Address;\n}\n\nexport class AuthClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {}\n\n async login({ address }: LoginOptions): Promise<AuthLoginResponse> {\n assertRequiresAuth(this.context);\n\n const message = createLoginSiweMessage(address, Date.now().toString());\n const signature = await this.account.signMessage({ message });\n const vrsParsedSignature = parseSignatureToVRS(signature);\n\n const response = await this.apiClient.auth.login({\n siwe: message,\n signature: vrsParsedSignature,\n });\n\n return response.data;\n }\n\n async getCurrentUser(): Promise<MeResponse> {\n const response = await this.apiClient.auth.me();\n return response.data;\n }\n}\n","import type {\n APIClient,\n GetMaxPriorityFeePerGasEstimateRequest,\n GetMaxPriorityFeePerGasEstimateResponse,\n} from \"@otim/utils/api\";\n\nexport class ConfigClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getMaxPriorityFeeEstimate({\n chainId,\n }: GetMaxPriorityFeePerGasEstimateRequest): Promise<GetMaxPriorityFeePerGasEstimateResponse> {\n const response =\n await this.apiClient.config.getMaxPriorityFeePerGasEstimate({ chainId });\n\n return response.data;\n }\n}\n","import type {\n APIClient,\n DelegationCreateRequest,\n DelegationStatusRequest,\n DelegationStatusResponse,\n GetDelegateAddressRequest,\n GetDelegateAddressResponse,\n} from \"@otim/utils/api\";\n\nexport class DelegationClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getDelegateAddress({\n chainId,\n }: GetDelegateAddressRequest): Promise<GetDelegateAddressResponse> {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n\n return response.data;\n }\n\n async getDelegationStatus(\n options: DelegationStatusRequest,\n ): Promise<DelegationStatusResponse> {\n const response = await this.apiClient.account.getDelegationStatus({\n address: options.address,\n chainId: options.chainId,\n });\n\n return response.data;\n }\n\n async createDelegation(\n delegationRequest: DelegationCreateRequest,\n ): Promise<void> {\n await this.apiClient.account.createDelegation(delegationRequest);\n }\n}\n","import type { OtimServerClientContext } from \"@otim/sdk-core/context\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport {\n ApiKeyClientSigningService,\n ServerWalletSigningService,\n UnifiedPaymentSigner,\n} from \"@otim/turnkey/signing\";\nimport { createWalletClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\n\nimport { isApiAccountConfig } from \"@otim/sdk-core/account\";\n\nexport interface CreatePaymentSignerParams {\n context: OtimServerClientContext;\n buildResponse: PaymentResponseWithActionNames;\n publicClient: PublicClient;\n delegateAddressMap: Map<number, Address>;\n}\n\ntype CreatePaymentSignerResult = Awaited<\n ReturnType<UnifiedPaymentSigner[\"signAll\"]>\n>;\n\nexport async function createPaymentSigner(\n params: CreatePaymentSignerParams,\n): Promise<CreatePaymentSignerResult> {\n const { context, buildResponse, publicClient, delegateAddressMap } = params;\n\n if (isApiAccountConfig(context.config)) {\n const signingService = new ApiKeyClientSigningService(\n context.config.publicKey,\n context.config.privateKey,\n );\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n }\n\n const account = privateKeyToAccount(context.config.privateKey);\n const walletClient = createWalletClient({\n account,\n transport: http(),\n });\n\n const signingService =\n ServerWalletSigningService.fromViemWallet(walletClient);\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type {\n APIClient,\n GetPaymentRequestsRequest,\n GetPaymentRequestsResponse,\n PaginatedServiceResponse,\n PaymentRequestBuildRequest,\n PaymentRequestDetailsRequest,\n PaymentRequestDetailsResponse,\n PaymentsListRequest,\n ServiceResponse,\n} from \"@otim/utils/api\";\nimport type { SupportedChainId } from \"@otim/utils/chains\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { PaymentRequestMetadata } from \"@otim/utils/payments\";\nimport type { Address, Payments } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport {\n getChainById,\n getChainTokens,\n getTokenAddress,\n getTokenMetadata,\n supportedChains,\n} from \"@otim/utils/chains\";\nimport { validateIso8601Date } from \"@otim/utils/helpers\";\nimport {\n addActionNamesToInstructions,\n buildPaymentMetadata,\n createChainTokenConfigs,\n createComprehensivePaymentRequest,\n extractActionNamesMap,\n} from \"@otim/utils/payments\";\nimport { hexStringSchema } from \"@otim/utils/schemas\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { assertServerContext } from \"@otim/sdk-core/context\";\n\nimport { createPaymentSigner } from \"./helpers/payment-signer\";\n\nexport interface CreatePaymentRequestParameters {\n amount: number;\n chainId: SupportedChainId;\n recipient: Address;\n token?: \"USDC\" | \"USDT\";\n payer?: Nullable<Address>;\n /**\n * ISO 8601 date format (e.g., \"2024-12-31T23:59:59.000Z\")\n */\n dueDate?: string;\n metadata?: PaymentRequestMetadata;\n note?: string;\n}\n\nexport interface CreatePaymentRequestResponse {\n requestId: string;\n ephemeralWalletAddress: Address;\n}\n\nexport interface ActivatePaymentRequestParams {\n buildResponse: PaymentResponseWithActionNames;\n settlementChainId: number;\n}\n\ntype PaymentInstruction =\n PaymentResponseWithActionNames[\"completionInstructions\"][number];\n\nexport class PaymentRequestsClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {}\n\n async create(\n params: CreatePaymentRequestParameters,\n ): Promise<CreatePaymentRequestResponse> {\n const {\n chainId,\n token = \"USDC\",\n recipient,\n amount,\n payer,\n note,\n dueDate,\n metadata: customMetadata,\n } = params;\n\n if (dueDate) {\n validateIso8601Date(dueDate);\n }\n\n const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);\n const metadata = this.buildMetadata({\n token,\n amount,\n recipient,\n note,\n dueDate,\n customMetadata,\n });\n const payload = this.createPayload({\n chainId,\n recipient,\n amount,\n payer,\n metadata,\n feeTokenAddress,\n });\n\n const buildResponse = await this.buildAndEnhancePaymentRequest(payload);\n\n await this.activate({ buildResponse, settlementChainId: chainId });\n\n return {\n requestId: buildResponse.requestId,\n ephemeralWalletAddress: buildResponse.ephemeralWalletAddress,\n };\n }\n\n async activate(params: ActivatePaymentRequestParams): Promise<void> {\n assertServerContext(this.context);\n\n const { buildResponse, settlementChainId } = params;\n const publicClient = this.createPublicClient(settlementChainId);\n\n const instructions = [\n ...buildResponse.completionInstructions,\n ...buildResponse.instructions,\n ];\n\n const delegateAddressMap = await this.fetchDelegateAddresses(instructions);\n\n const {\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n } = await createPaymentSigner({\n context: this.context,\n buildResponse,\n publicClient,\n delegateAddressMap,\n });\n\n await this.apiClient.payments.newPaymentRequest({\n requestId: buildResponse.requestId,\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n });\n }\n\n private validateAndGetTokenAddress(chainId: number, token: string): Address {\n const tokenAddress = getTokenAddress(chainId, token);\n if (!tokenAddress) {\n throw new Error(`Token ${token} not supported on chain ${chainId}`);\n }\n\n const tokenMetadata = getTokenMetadata(token);\n if (!tokenMetadata) {\n throw new Error(`Token ${token} metadata not found`);\n }\n\n return hexStringSchema.parse(tokenAddress);\n }\n\n private buildMetadata(params: {\n token: string;\n amount: number;\n recipient: Address;\n note?: string;\n dueDate?: string;\n customMetadata?: PaymentRequestMetadata;\n }): PaymentRequestMetadata {\n const { token, amount, recipient, note, dueDate, customMetadata } = params;\n\n const baseMetadata = buildPaymentMetadata({\n tokenSymbol: token,\n amountInUSD: amount,\n fromAccountAddress: recipient,\n note,\n dueDate,\n hasInvoiceMetadata: false,\n });\n\n return customMetadata\n ? { ...baseMetadata, ...customMetadata }\n : baseMetadata;\n }\n\n private createPayload(params: {\n chainId: number;\n recipient: Address;\n amount: number;\n payer?: Address | null;\n metadata: PaymentRequestMetadata;\n feeTokenAddress: Address;\n }): PaymentRequestBuildRequest {\n const { chainId, recipient, amount, payer, metadata, feeTokenAddress } =\n params;\n\n const tokens = Object.values(supportedChains.mainnet).flatMap((chain) =>\n getChainTokens(chain.id),\n );\n\n const chainTokenConfigs = createChainTokenConfigs(tokens);\n\n return createComprehensivePaymentRequest({\n settlementChainId: chainId,\n recipient,\n amount: amount.toString(),\n ephemeralWalletAddress: recipient,\n chainTokenConfigs,\n payerAddress: payer ?? null,\n metadata,\n feeToken: feeTokenAddress,\n });\n }\n\n private async buildAndEnhancePaymentRequest(\n payload: PaymentRequestBuildRequest,\n ): Promise<PaymentResponseWithActionNames> {\n const actionNames = extractActionNamesMap(\n payload.completionInstructions,\n payload.instructions,\n );\n\n const response = await this.apiClient.payments.buildPaymentRequest(payload);\n\n return addActionNamesToInstructions(response.data, actionNames);\n }\n\n private createPublicClient(chainId: number): PublicClient {\n const chain = getChainById(chainId);\n if (!chain) {\n throw new Error(`Chain with id ${chainId} not found`);\n }\n\n return createPublicClient({ chain, transport: http() });\n }\n\n private async fetchDelegateAddresses(\n instructions: PaymentInstruction[],\n ): Promise<Map<number, Address>> {\n const chainIds = Array.from(\n new Set(instructions.map((instruction) => instruction.chainId)),\n );\n\n const addresses = await Promise.all(\n chainIds.map(async (chainId) => {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n const address = hexStringSchema.parse(\n response.data.otimDelegateAddress,\n );\n return [chainId, address] as const;\n }),\n );\n\n return new Map(addresses);\n }\n\n async getDetails(\n request: PaymentRequestDetailsRequest,\n ): Promise<ServiceResponse<PaymentRequestDetailsResponse>> {\n return this.apiClient.payments.getPaymentRequestDetails(request);\n }\n\n async listOutgoingPaymentRequests(\n request: PaymentsListRequest,\n ): Promise<PaginatedServiceResponse<Payments>> {\n return this.apiClient.payments.getOutgoingPaymentsList(request);\n }\n\n async listIncomingPaymentRequests(\n request: PaymentsListRequest,\n ): Promise<PaginatedServiceResponse<Payments>> {\n return this.apiClient.payments.getIncomingPaymentsList(request);\n }\n\n async list(\n request: GetPaymentRequestsRequest,\n ): Promise<PaginatedServiceResponse<GetPaymentRequestsResponse>> {\n return this.apiClient.payments.getPaymentRequests(request);\n }\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type { APIClient } from \"@otim/utils/api\";\n\nimport { PaymentRequestsClient } from \"./payment-requests\";\n\nexport class OrchestrationClient {\n public readonly paymentRequests: PaymentRequestsClient;\n\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {\n this.paymentRequests = new PaymentRequestsClient(\n apiClient,\n account,\n context,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,aAAb,MAAwB;CACtB,YACE,AAAiBA,WACjB,AAAiBC,SACjB,AAAiBC,SACjB;EAHiB;EACA;EACA;;CAGnB,MAAM,MAAM,EAAE,WAAqD;AACjE,qBAAmB,KAAK,QAAQ;EAEhC,MAAM,UAAU,uBAAuB,SAAS,KAAK,KAAK,CAAC,UAAU,CAAC;EAEtE,MAAM,qBAAqB,oBADT,MAAM,KAAK,QAAQ,YAAY,EAAE,SAAS,CAAC,CACJ;AAOzD,UALiB,MAAM,KAAK,UAAU,KAAK,MAAM;GAC/C,MAAM;GACN,WAAW;GACZ,CAAC,EAEc;;CAGlB,MAAM,iBAAsC;AAE1C,UADiB,MAAM,KAAK,UAAU,KAAK,IAAI,EAC/B;;;;;;AChCpB,IAAa,eAAb,MAA0B;CACxB,YAAY,AAAiBC,WAAsB;EAAtB;;CAE7B,MAAM,0BAA0B,EAC9B,WAC2F;AAI3F,UAFE,MAAM,KAAK,UAAU,OAAO,gCAAgC,EAAE,SAAS,CAAC,EAE1D;;;;;;ACNpB,IAAa,mBAAb,MAA8B;CAC5B,YAAY,AAAiBC,WAAsB;EAAtB;;CAE7B,MAAM,mBAAmB,EACvB,WACiE;AAKjE,UAJiB,MAAM,KAAK,UAAU,OAAO,mBAAmB,EAC9D,SACD,CAAC,EAEc;;CAGlB,MAAM,oB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const require_config = require('../config-CjGpscVk.cjs');
2
+
3
+ exports.Environment = require_config.Environment;
4
+ exports.SIWE_CHAIN_ID = require_config.SIWE_CHAIN_ID;
5
+ exports.SIWE_VERSION = require_config.SIWE_VERSION;
6
+ exports.createLoginSiweMessage = require_config.createLoginSiweMessage;
7
+ exports.env = require_config.env;
8
+ exports.getApiUrl = require_config.getApiUrl;
9
+ exports.getTurnkeyApiUrl = require_config.getTurnkeyApiUrl;
10
+ exports.isEnvironment = require_config.isEnvironment;
@@ -0,0 +1,3 @@
1
+ import "../abi-CQuxrNCU.cjs";
2
+ import { a as env, c as isEnvironment, i as Environment, n as SIWE_VERSION, o as getApiUrl, r as createLoginSiweMessage, s as getTurnkeyApiUrl, t as SIWE_CHAIN_ID } from "../index-UnaahQgb.cjs";
3
+ export { Environment, Environment as EnvironmentType, SIWE_CHAIN_ID, SIWE_VERSION, createLoginSiweMessage, env, getApiUrl, getTurnkeyApiUrl, isEnvironment };
@@ -0,0 +1,3 @@
1
+ import "../abi-Bd3X6gV9.mjs";
2
+ import { a as env, c as isEnvironment, i as Environment, n as SIWE_VERSION, o as getApiUrl, r as createLoginSiweMessage, s as getTurnkeyApiUrl, t as SIWE_CHAIN_ID } from "../index-C4N2Xixk.mjs";
3
+ export { Environment, Environment as EnvironmentType, SIWE_CHAIN_ID, SIWE_VERSION, createLoginSiweMessage, env, getApiUrl, getTurnkeyApiUrl, isEnvironment };
@@ -0,0 +1,3 @@
1
+ import { a as env, c as isEnvironment, i as Environment, n as SIWE_VERSION, o as getApiUrl, r as createLoginSiweMessage, s as getTurnkeyApiUrl, t as SIWE_CHAIN_ID } from "../config-C_nc1DXn.mjs";
2
+
3
+ export { Environment, SIWE_CHAIN_ID, SIWE_VERSION, createLoginSiweMessage, env, getApiUrl, getTurnkeyApiUrl, isEnvironment };