@unifold/core 0.1.82 → 0.1.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -41,7 +41,7 @@ function generatePrefixedKSUID(prefix) {
41
41
  }
42
42
 
43
43
  // src/lib/client-headers.ts
44
- var SDK_VERSION = true ? "0.1.82" : "0.0.0-dev";
44
+ var SDK_VERSION = true ? "0.1.83" : "0.0.0-dev";
45
45
  var CLIENT_VERSION_HEADER = "x-unifold-client-version";
46
46
  var CLIENT_USER_AGENT_HEADER = "x-unifold-client-user-agent";
47
47
  function detectRuntime() {
@@ -474,11 +474,13 @@ async function getBankTransferProviders(publishableKey, options = {}) {
474
474
  }
475
475
  const queryString = params.toString();
476
476
  const url = `${API_BASE_URL}/v1/public/onramps/bank_transfer/providers${queryString ? `?${queryString}` : ""}`;
477
+ const LATEST_API_VERSION = "2026-08-15";
477
478
  const response = await apiFetch(url, {
478
479
  method: "GET",
479
480
  headers: {
480
481
  accept: "application/json",
481
- "x-publishable-key": pk
482
+ "x-publishable-key": pk,
483
+ "x-unifold-version": LATEST_API_VERSION
482
484
  }
483
485
  });
484
486
  if (!response.ok) {
@@ -1303,6 +1305,173 @@ async function getCashAppSessionStatus(externalId, publishableKey) {
1303
1305
  }
1304
1306
  return response.json();
1305
1307
  }
1308
+ var HEADLESS_INTERAC_BASE = "/v1/public/onramps/headless/interac";
1309
+ var InteracApiResponseError = class extends Error {
1310
+ constructor(message, statusCode, errorType, providerMessage) {
1311
+ super(message);
1312
+ this.statusCode = statusCode;
1313
+ this.errorType = errorType;
1314
+ this.providerMessage = providerMessage;
1315
+ this.name = "InteracApiResponseError";
1316
+ }
1317
+ };
1318
+ function throwInteracError(prefix, response, error) {
1319
+ const providerMessage = error.details?.paytrie_error?.message;
1320
+ const detailMessage = providerMessage || error.message || response.statusText;
1321
+ throw new InteracApiResponseError(
1322
+ `${prefix}: ${detailMessage}`,
1323
+ response.status,
1324
+ error.error_type,
1325
+ providerMessage
1326
+ );
1327
+ }
1328
+ async function interacFetch(prefix, path, publishableKey, init = {}, accessToken) {
1329
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1330
+ validatePublishableKey(pk);
1331
+ const response = await apiFetch(`${API_BASE_URL}${HEADLESS_INTERAC_BASE}${path}`, {
1332
+ ...init,
1333
+ headers: {
1334
+ accept: "application/json",
1335
+ "x-publishable-key": pk,
1336
+ ...init.body ? { "Content-Type": "application/json" } : {},
1337
+ ...accessToken ? { "x-interac-token": accessToken } : {},
1338
+ ...init.headers
1339
+ }
1340
+ });
1341
+ if (!response.ok) {
1342
+ const error = await response.json().catch(() => ({ message: response.statusText }));
1343
+ throwInteracError(prefix, response, error);
1344
+ }
1345
+ return response;
1346
+ }
1347
+ async function startInterac(email, publishableKey) {
1348
+ const response = await interacFetch("Failed to start Interac flow", "/start", publishableKey, {
1349
+ method: "POST",
1350
+ body: JSON.stringify({ email })
1351
+ });
1352
+ return response.json();
1353
+ }
1354
+ async function getInteracStatus(email, publishableKey, accessToken) {
1355
+ const response = await interacFetch(
1356
+ "Failed to resolve Interac status",
1357
+ "/status",
1358
+ publishableKey,
1359
+ // With a token, the token itself identifies the account — no email.
1360
+ { method: "POST", body: JSON.stringify(email ? { email } : {}) },
1361
+ accessToken
1362
+ );
1363
+ return response.json();
1364
+ }
1365
+ async function createInteracUser(request, publishableKey) {
1366
+ const response = await interacFetch("Failed to create Interac user", "/users", publishableKey, {
1367
+ method: "POST",
1368
+ body: JSON.stringify(request)
1369
+ });
1370
+ return response.json();
1371
+ }
1372
+ async function requestInteracOtp(email, publishableKey) {
1373
+ await interacFetch("Failed to request Interac login code", "/otp", publishableKey, {
1374
+ method: "POST",
1375
+ body: JSON.stringify({ email })
1376
+ });
1377
+ }
1378
+ async function verifyInteracOtp(email, code, publishableKey) {
1379
+ const response = await interacFetch(
1380
+ "Failed to verify Interac login code",
1381
+ "/otp/verify",
1382
+ publishableKey,
1383
+ { method: "POST", body: JSON.stringify({ email, code }) }
1384
+ );
1385
+ return response.json();
1386
+ }
1387
+ async function updateInteracUser(request, publishableKey, accessToken) {
1388
+ const response = await interacFetch(
1389
+ "Failed to update Interac user",
1390
+ "/users",
1391
+ publishableKey,
1392
+ { method: "PUT", body: JSON.stringify(request) },
1393
+ accessToken
1394
+ );
1395
+ return response.json();
1396
+ }
1397
+ async function sendInteracPhoneVerification(phone, publishableKey, accessToken) {
1398
+ await interacFetch(
1399
+ "Failed to send phone verification code",
1400
+ "/phone",
1401
+ publishableKey,
1402
+ { method: "POST", body: JSON.stringify({ phone }) },
1403
+ accessToken
1404
+ );
1405
+ }
1406
+ async function verifyInteracPhone(email, code, publishableKey, accessToken) {
1407
+ const response = await interacFetch(
1408
+ "Failed to verify phone code",
1409
+ "/phone/verify",
1410
+ publishableKey,
1411
+ { method: "POST", body: JSON.stringify(email ? { email, code } : { code }) },
1412
+ accessToken
1413
+ );
1414
+ return response.json();
1415
+ }
1416
+ async function getInteracKycUrl(email, publishableKey, accessToken) {
1417
+ const response = await interacFetch(
1418
+ "Failed to get verification link",
1419
+ "/kyc_url",
1420
+ publishableKey,
1421
+ { method: "POST", body: JSON.stringify(email ? { email } : {}) },
1422
+ accessToken
1423
+ );
1424
+ return response.json();
1425
+ }
1426
+ async function getInteracQuote(sourceAmount, destinationNetwork, publishableKey) {
1427
+ const query = new URLSearchParams({
1428
+ source_amount: String(sourceAmount),
1429
+ destination_network: destinationNetwork
1430
+ });
1431
+ const response = await interacFetch(
1432
+ "Failed to get Interac quote",
1433
+ `/quotes?${query.toString()}`,
1434
+ publishableKey,
1435
+ { method: "GET" }
1436
+ );
1437
+ return response.json();
1438
+ }
1439
+ async function getInteracLimits(publishableKey) {
1440
+ const response = await interacFetch("Failed to get Interac limits", "/limits", publishableKey, {
1441
+ method: "GET"
1442
+ });
1443
+ return response.json();
1444
+ }
1445
+ async function createInteracSession(request, publishableKey, accessToken) {
1446
+ const response = await interacFetch(
1447
+ "Failed to create Interac session",
1448
+ "/sessions",
1449
+ publishableKey,
1450
+ { method: "POST", body: JSON.stringify(request) },
1451
+ accessToken
1452
+ );
1453
+ return response.json();
1454
+ }
1455
+ async function cancelInteracSession(sessionId, publishableKey, accessToken) {
1456
+ const response = await interacFetch(
1457
+ "Failed to cancel Interac session",
1458
+ `/sessions/${encodeURIComponent(sessionId)}/cancel`,
1459
+ publishableKey,
1460
+ { method: "POST" },
1461
+ accessToken
1462
+ );
1463
+ return response.json();
1464
+ }
1465
+ async function getInteracSession(sessionId, publishableKey, accessToken) {
1466
+ const response = await interacFetch(
1467
+ "Failed to get Interac session",
1468
+ `/sessions/${encodeURIComponent(sessionId)}`,
1469
+ publishableKey,
1470
+ { method: "GET" },
1471
+ accessToken
1472
+ );
1473
+ return response.json();
1474
+ }
1306
1475
  async function stripeGetDefaultToken(params, publishableKey) {
1307
1476
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1308
1477
  validatePublishableKey(pk);
@@ -1672,7 +1841,142 @@ async function jsonOrThrow(response, label) {
1672
1841
  }
1673
1842
  return response.json();
1674
1843
  }
1675
- async function createOnrampVerificationSession(request, publishableKey) {
1844
+ var IDENTITY_BASE = "/v1/public/identity";
1845
+ var BANK_TRANSFER_BASE = "/v1/public/onramps/bank_transfer";
1846
+ var ONRAMP_TOS_BASE = "/v1/public/onramps/terms_of_service";
1847
+ function identityHeaders(pk, json = false, onrampToken) {
1848
+ return {
1849
+ accept: "application/json",
1850
+ "x-publishable-key": pk,
1851
+ ...json ? { "Content-Type": "application/json" } : {},
1852
+ ...onrampToken ? { "x-onramp-token": onrampToken } : {}
1853
+ };
1854
+ }
1855
+ async function patchIdentityInformation(request, publishableKey, onrampToken) {
1856
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1857
+ validatePublishableKey(pk);
1858
+ const response = await apiFetch(`${API_BASE_URL}${IDENTITY_BASE}/information`, {
1859
+ method: "PATCH",
1860
+ headers: identityHeaders(pk, true, onrampToken),
1861
+ body: JSON.stringify(request)
1862
+ });
1863
+ return jsonOrThrow(response, "Failed to submit identity information");
1864
+ }
1865
+ async function createIdentityVerificationSession(ctx, publishableKey, onrampToken) {
1866
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1867
+ validatePublishableKey(pk);
1868
+ const response = await apiFetch(`${API_BASE_URL}${IDENTITY_BASE}/verification_sessions`, {
1869
+ method: "POST",
1870
+ headers: identityHeaders(pk, true, onrampToken),
1871
+ body: JSON.stringify(ctx)
1872
+ });
1873
+ return jsonOrThrow(
1874
+ response,
1875
+ "Failed to create identity verification session"
1876
+ );
1877
+ }
1878
+ var BankTransferCapabilityStatus = /* @__PURE__ */ ((BankTransferCapabilityStatus2) => {
1879
+ BankTransferCapabilityStatus2["IDENTITY_REQUIRED"] = "identity_required";
1880
+ BankTransferCapabilityStatus2["TOS_REQUIRED"] = "tos_required";
1881
+ BankTransferCapabilityStatus2["UNDER_REVIEW"] = "under_review";
1882
+ BankTransferCapabilityStatus2["AWAITING_QUESTIONNAIRE"] = "awaiting_questionnaire";
1883
+ BankTransferCapabilityStatus2["INCOMPLETE"] = "incomplete";
1884
+ BankTransferCapabilityStatus2["PREPARING"] = "preparing";
1885
+ BankTransferCapabilityStatus2["ACTIVE"] = "active";
1886
+ BankTransferCapabilityStatus2["REJECTED"] = "rejected";
1887
+ return BankTransferCapabilityStatus2;
1888
+ })(BankTransferCapabilityStatus || {});
1889
+ var BankTransferSessionStatus = /* @__PURE__ */ ((BankTransferSessionStatus2) => {
1890
+ BankTransferSessionStatus2["AWAITING_FUNDS"] = "awaiting_funds";
1891
+ BankTransferSessionStatus2["PROCESSING"] = "processing";
1892
+ BankTransferSessionStatus2["COMPLETED"] = "completed";
1893
+ BankTransferSessionStatus2["FAILED"] = "failed";
1894
+ BankTransferSessionStatus2["EXPIRED"] = "expired";
1895
+ return BankTransferSessionStatus2;
1896
+ })(BankTransferSessionStatus || {});
1897
+ async function createBankTransferCapability(request, publishableKey, onrampToken) {
1898
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1899
+ validatePublishableKey(pk);
1900
+ const response = await apiFetch(`${API_BASE_URL}${BANK_TRANSFER_BASE}/capabilities`, {
1901
+ method: "POST",
1902
+ headers: identityHeaders(pk, true, onrampToken),
1903
+ body: JSON.stringify(request)
1904
+ });
1905
+ return jsonOrThrow(
1906
+ response,
1907
+ "Failed to resolve bank-transfer capability"
1908
+ );
1909
+ }
1910
+ async function createBankTransferVirtualAccount(request, publishableKey, onrampToken) {
1911
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1912
+ validatePublishableKey(pk);
1913
+ const response = await apiFetch(`${API_BASE_URL}${BANK_TRANSFER_BASE}/virtual_accounts`, {
1914
+ method: "POST",
1915
+ headers: identityHeaders(pk, true, onrampToken),
1916
+ body: JSON.stringify(request)
1917
+ });
1918
+ return jsonOrThrow(
1919
+ response,
1920
+ "Failed to open bank-transfer virtual account"
1921
+ );
1922
+ }
1923
+ async function getBankTransferVirtualAccount(id, publishableKey, onrampToken) {
1924
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1925
+ validatePublishableKey(pk);
1926
+ const response = await apiFetch(
1927
+ `${API_BASE_URL}${BANK_TRANSFER_BASE}/virtual_accounts/${encodeURIComponent(id)}`,
1928
+ {
1929
+ method: "GET",
1930
+ headers: identityHeaders(pk, false, onrampToken)
1931
+ }
1932
+ );
1933
+ return jsonOrThrow(
1934
+ response,
1935
+ "Failed to fetch bank-transfer virtual account"
1936
+ );
1937
+ }
1938
+ async function createBankTransferSession(request, publishableKey, onrampToken) {
1939
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1940
+ validatePublishableKey(pk);
1941
+ const response = await apiFetch(`${API_BASE_URL}${BANK_TRANSFER_BASE}/sessions`, {
1942
+ method: "POST",
1943
+ headers: identityHeaders(pk, true, onrampToken),
1944
+ body: JSON.stringify(request)
1945
+ });
1946
+ return jsonOrThrow(response, "Failed to create bank-transfer session");
1947
+ }
1948
+ async function getBankTransferSession(id, publishableKey, onrampToken) {
1949
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1950
+ validatePublishableKey(pk);
1951
+ const response = await apiFetch(
1952
+ `${API_BASE_URL}${BANK_TRANSFER_BASE}/sessions/${encodeURIComponent(id)}`,
1953
+ {
1954
+ method: "GET",
1955
+ headers: identityHeaders(pk, false, onrampToken)
1956
+ }
1957
+ );
1958
+ return jsonOrThrow(response, "Failed to fetch bank-transfer session");
1959
+ }
1960
+ async function getOnrampTos(publishableKey) {
1961
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1962
+ validatePublishableKey(pk);
1963
+ const response = await apiFetch(`${API_BASE_URL}${ONRAMP_TOS_BASE}`, {
1964
+ method: "GET",
1965
+ headers: identityHeaders(pk)
1966
+ });
1967
+ return jsonOrThrow(response, "Failed to fetch terms of service");
1968
+ }
1969
+ async function acceptOnrampTos(request, publishableKey, onrampToken) {
1970
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1971
+ validatePublishableKey(pk);
1972
+ const response = await apiFetch(`${API_BASE_URL}${ONRAMP_TOS_BASE}`, {
1973
+ method: "POST",
1974
+ headers: identityHeaders(pk, true, onrampToken),
1975
+ body: JSON.stringify(request)
1976
+ });
1977
+ return jsonOrThrow(response, "Failed to accept terms of service");
1978
+ }
1979
+ async function createOnrampVerificationSession(request, publishableKey, priorToken) {
1676
1980
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
1677
1981
  validatePublishableKey(pk);
1678
1982
  const response = await apiFetch(`${API_BASE_URL}${VERIFICATION_BASE}`, {
@@ -1680,7 +1984,8 @@ async function createOnrampVerificationSession(request, publishableKey) {
1680
1984
  headers: {
1681
1985
  accept: "application/json",
1682
1986
  "x-publishable-key": pk,
1683
- "Content-Type": "application/json"
1987
+ "Content-Type": "application/json",
1988
+ ...priorToken ? { "x-onramp-token": priorToken } : {}
1684
1989
  },
1685
1990
  body: JSON.stringify(request)
1686
1991
  });
@@ -3899,6 +4204,8 @@ var en_default = {
3899
4204
  var i18n = en_default;
3900
4205
  export {
3901
4206
  ActionType,
4207
+ BankTransferCapabilityStatus,
4208
+ BankTransferSessionStatus,
3902
4209
  CheckoutEventType,
3903
4210
  DETECTION_ARM_DELAY_MS,
3904
4211
  DETECTION_POLL_INTERVAL_MS,
@@ -3912,6 +4219,7 @@ export {
3912
4219
  IneligibilityReason,
3913
4220
  IntegrationProvider,
3914
4221
  IntegrationTransferError,
4222
+ InteracApiResponseError,
3915
4223
  LOOKBACK_MS,
3916
4224
  OnrampSession,
3917
4225
  OnrampSessionEventType,
@@ -3922,19 +4230,27 @@ export {
3922
4230
  StripeApiResponseError,
3923
4231
  UnifoldClient,
3924
4232
  WithdrawEventType,
4233
+ acceptOnrampTos,
3925
4234
  authenticateIntegrationOAuth,
3926
4235
  buildHypercoreTransaction,
3927
4236
  buildSolanaTransaction,
4237
+ cancelInteracSession,
3928
4238
  checkHypercoreActivation,
3929
4239
  confirmIntegrationTransfer,
4240
+ createBankTransferCapability,
4241
+ createBankTransferSession,
4242
+ createBankTransferVirtualAccount,
3930
4243
  createCashAppSession,
3931
4244
  createCoinbaseApplePaySession,
3932
4245
  createCoinbaseGooglePaySession,
3933
4246
  createCoinbaseWalletPaySession,
3934
4247
  createDepositAddress,
3935
4248
  createExchangeSession,
4249
+ createIdentityVerificationSession,
3936
4250
  createIntegrationExchangeSession,
3937
4251
  createIntegrationTransfer,
4252
+ createInteracSession,
4253
+ createInteracUser,
3938
4254
  createOnrampSession,
3939
4255
  createOnrampVerificationSession,
3940
4256
  createUnifoldClient,
@@ -3948,6 +4264,8 @@ export {
3948
4264
  getApplePayLimitUpgradeStatus,
3949
4265
  getApplePayProviders,
3950
4266
  getBankTransferProviders,
4267
+ getBankTransferSession,
4268
+ getBankTransferVirtualAccount,
3951
4269
  getCashAppLimits,
3952
4270
  getCashAppSessionStatus,
3953
4271
  getChainName,
@@ -3970,10 +4288,16 @@ export {
3970
4288
  getIntegrationExchanges,
3971
4289
  getIntegrationHoldings,
3972
4290
  getIntegrationTransferDefaultToken,
4291
+ getInteracKycUrl,
4292
+ getInteracLimits,
4293
+ getInteracQuote,
4294
+ getInteracSession,
4295
+ getInteracStatus,
3973
4296
  getIpAddress,
3974
4297
  getOnrampQuotes,
3975
4298
  getOnrampSessionStartUrl,
3976
4299
  getOnrampSessionStatus,
4300
+ getOnrampTos,
3977
4301
  getOnrampVerificationSession,
3978
4302
  getPreferredIconUrl,
3979
4303
  getProjectConfig,
@@ -3997,18 +4321,22 @@ export {
3997
4321
  mapDirectExecution,
3998
4322
  mapOnrampQuote,
3999
4323
  mapWalletToDepositAddress,
4324
+ patchIdentityInformation,
4000
4325
  pollDirectExecutions,
4001
4326
  queryExecutions,
4002
4327
  refreshIntegrationToken,
4003
4328
  requestCoinbaseApplePayLimitUpgrade,
4004
4329
  requestCoinbaseWalletPayLimitUpgrade,
4330
+ requestInteracOtp,
4005
4331
  retrievePaymentIntent,
4006
4332
  revokeIntegrationToken,
4007
4333
  sendHypercoreTransaction,
4334
+ sendInteracPhoneVerification,
4008
4335
  sendOnrampVerificationOtp,
4009
4336
  sendSolanaTransaction,
4010
4337
  setApiConfig,
4011
4338
  startIntegrationOAuth,
4339
+ startInterac,
4012
4340
  stripeConfirmSession,
4013
4341
  stripeCreateAuthIntent,
4014
4342
  stripeCreateSession,
@@ -4023,7 +4351,10 @@ export {
4023
4351
  stripeListWallets,
4024
4352
  stripeRefreshQuote,
4025
4353
  stripeRefreshToken,
4354
+ updateInteracUser,
4026
4355
  useUserIp,
4356
+ verifyInteracOtp,
4357
+ verifyInteracPhone,
4027
4358
  verifyOnrampVerificationOtp,
4028
4359
  verifyRecipientAddress
4029
4360
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/core",
3
- "version": "0.1.82",
3
+ "version": "0.1.83",
4
4
  "description": "Unifold Core SDK - Core types, API client, and business logic",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",