@p2pdotme/sdk 1.2.21 → 1.2.23

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/zkkyc.cjs CHANGED
@@ -1581,46 +1581,51 @@ function createReclaimFlow(params) {
1581
1581
  });
1582
1582
  const { ReclaimProofRequest, transformForOnchain } = mod;
1583
1583
  const {
1584
- appId,
1585
- appSecret,
1586
- providerIds,
1584
+ sessionEndpoint,
1585
+ tenant,
1587
1586
  platform,
1588
1587
  walletAddress,
1589
1588
  redirectUrl,
1590
1589
  sessionId: existingSessionId,
1591
- contextDescription,
1590
+ locale,
1592
1591
  onStatus,
1593
1592
  signal,
1594
1593
  pollingIntervalMs = 5e3
1595
1594
  } = params;
1596
1595
  const socialName = SOCIAL_PLATFORM_NAMES[platform];
1597
- const providerId = providerIds[platform];
1598
1596
  let reclaimProofRequest = null;
1599
1597
  let sessionId;
1600
1598
  let requestUrl = "";
1601
1599
  if (existingSessionId) {
1602
1600
  sessionId = existingSessionId;
1603
1601
  } else {
1604
- reclaimProofRequest = await ReclaimProofRequest.init(appId, appSecret, providerId, {
1605
- launchOptions: {
1606
- canUseDeferredDeepLinksFlow: true,
1607
- verificationMode: "app"
1608
- },
1609
- useAppClip: true,
1610
- log: true
1602
+ if (!redirectUrl) {
1603
+ throw new ZkkycError("redirectUrl is required to start a Reclaim session", {
1604
+ code: "VALIDATION_ERROR"
1605
+ });
1606
+ }
1607
+ const response = await fetch(`${sessionEndpoint.replace(/\/$/, "")}/v1/reclaim/sessions`, {
1608
+ method: "POST",
1609
+ headers: { "Content-Type": "application/json" },
1610
+ body: JSON.stringify({ tenant, platform, walletAddress, redirectUrl, locale }),
1611
+ signal
1611
1612
  });
1612
- const statusUrl = reclaimProofRequest.getStatusUrl();
1613
- sessionId = statusUrl.split("/").pop() || "";
1614
- if (redirectUrl) {
1615
- const separator = redirectUrl.includes("?") ? "&" : "?";
1616
- reclaimProofRequest.setRedirectUrl(
1617
- `${redirectUrl}${separator}sessionId=${sessionId}&socialPlatform=${socialName}`
1618
- );
1613
+ if (!response.ok) {
1614
+ const body = await response.text().catch(() => "");
1615
+ throw new ZkkycError(`Reclaim session creation failed: ${response.status} ${body}`, {
1616
+ code: "RECLAIM_SESSION_ENDPOINT_FAILED",
1617
+ context: { status: response.status, platform }
1618
+ });
1619
1619
  }
1620
- reclaimProofRequest.addContext(
1621
- walletAddress,
1622
- contextDescription ?? `Social verification for ${socialName}`
1623
- );
1620
+ const data = await response.json();
1621
+ if (!data?.config || !data?.sessionId) {
1622
+ throw new ZkkycError("Reclaim session service returned an incomplete response", {
1623
+ code: "RECLAIM_SESSION_ENDPOINT_FAILED",
1624
+ context: { platform }
1625
+ });
1626
+ }
1627
+ reclaimProofRequest = await ReclaimProofRequest.fromJsonString(data.config);
1628
+ sessionId = data.sessionId;
1624
1629
  requestUrl = await reclaimProofRequest.getRequestUrl();
1625
1630
  onStatus?.({ type: "session_created", sessionId, requestUrl });
1626
1631
  }