@pymthouse/builder-sdk 0.4.5 → 0.4.6

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.cjs CHANGED
@@ -1469,8 +1469,13 @@ var PmtHouseClient = class {
1469
1469
  params.set("subject_token", input.userJwt);
1470
1470
  params.set("subject_token_type", SUBJECT_ACCESS_TOKEN_TYPE2);
1471
1471
  params.set("requested_token_type", REQUESTED_ACCESS_TOKEN_TYPE);
1472
- const resourceCandidate = typeof input.resource === "string" && input.resource.trim() !== "" ? input.resource.trim() : this.issuerUrl;
1473
- params.set("resource", stripTrailingSlashes(resourceCandidate));
1472
+ if (typeof input.scope === "string" && input.scope.trim() !== "") {
1473
+ params.set("scope", input.scope.trim());
1474
+ }
1475
+ if (!input.omitResource) {
1476
+ const resourceCandidate = typeof input.resource === "string" && input.resource.trim() !== "" ? input.resource.trim() : this.issuerUrl;
1477
+ params.set("resource", stripTrailingSlashes(resourceCandidate));
1478
+ }
1474
1479
  try {
1475
1480
  const response = await oauth4webapi.genericTokenEndpointRequest(
1476
1481
  as,
@@ -1756,18 +1761,31 @@ var PmtHouseClient = class {
1756
1761
  };
1757
1762
  }
1758
1763
  /**
1759
- * Upsert an external user, mint a short-lived JWT, and exchange for an opaque signer session.
1764
+ * Upsert an external user, mint a short-lived JWT, and exchange it for a
1765
+ * long-lived opaque (`pmth_*`) signer session.
1766
+ *
1767
+ * Performs the *documented* remote-signer-session exchange (see
1768
+ * `builder-api.md` → "Remote signer session exchange"): the RFC 8693 token
1769
+ * exchange is sent with `scope=sign:job` and **no `resource` indicator**,
1770
+ * which selects the PymtHouse gateway/opaque path. A prior implementation set
1771
+ * `resource = issuer`, which routed to the signer-JWT path and returned a JWT
1772
+ * that {@link parseSignerSessionExchange} then rejected as non-opaque.
1760
1773
  */
1761
1774
  async mintSignerSessionForExternalUser(input) {
1775
+ const scope = input.scope ?? SIGN_JOB_SCOPE;
1762
1776
  await this.upsertAppUser({
1763
1777
  externalUserId: input.externalUserId,
1764
1778
  email: input.email,
1765
1779
  status: "active"
1766
1780
  });
1767
- const exchange = await this.mintUserSignerSessionToken({
1781
+ const userToken = await this.mintUserAccessToken({
1768
1782
  externalUserId: input.externalUserId,
1769
- scope: input.scope ?? SIGN_JOB_SCOPE,
1770
- resource: this.issuerUrl
1783
+ scope
1784
+ });
1785
+ const exchange = await this.exchangeForSignerSession({
1786
+ userJwt: userToken.access_token,
1787
+ omitResource: true,
1788
+ scope
1771
1789
  });
1772
1790
  return parseSignerSessionExchange(exchange);
1773
1791
  }