@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/env.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as PmtHouseClient } from './client-GP-mTEI7.cjs';
1
+ import { P as PmtHouseClient } from './client-CEBVgCD7.cjs';
2
2
  import './tokens.cjs';
3
3
  import './types-CcP67AZm.cjs';
4
4
 
package/dist/env.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as PmtHouseClient } from './client-BhNz0ZAA.js';
1
+ import { P as PmtHouseClient } from './client-D-p6v8ju.js';
2
2
  import './tokens.js';
3
3
  import './types-CcP67AZm.js';
4
4
 
package/dist/env.js CHANGED
@@ -1224,8 +1224,13 @@ var PmtHouseClient = class {
1224
1224
  params.set("subject_token", input.userJwt);
1225
1225
  params.set("subject_token_type", SUBJECT_ACCESS_TOKEN_TYPE2);
1226
1226
  params.set("requested_token_type", REQUESTED_ACCESS_TOKEN_TYPE);
1227
- const resourceCandidate = typeof input.resource === "string" && input.resource.trim() !== "" ? input.resource.trim() : this.issuerUrl;
1228
- params.set("resource", stripTrailingSlashes(resourceCandidate));
1227
+ if (typeof input.scope === "string" && input.scope.trim() !== "") {
1228
+ params.set("scope", input.scope.trim());
1229
+ }
1230
+ if (!input.omitResource) {
1231
+ const resourceCandidate = typeof input.resource === "string" && input.resource.trim() !== "" ? input.resource.trim() : this.issuerUrl;
1232
+ params.set("resource", stripTrailingSlashes(resourceCandidate));
1233
+ }
1229
1234
  try {
1230
1235
  const response = await genericTokenEndpointRequest(
1231
1236
  as,
@@ -1511,18 +1516,31 @@ var PmtHouseClient = class {
1511
1516
  };
1512
1517
  }
1513
1518
  /**
1514
- * Upsert an external user, mint a short-lived JWT, and exchange for an opaque signer session.
1519
+ * Upsert an external user, mint a short-lived JWT, and exchange it for a
1520
+ * long-lived opaque (`pmth_*`) signer session.
1521
+ *
1522
+ * Performs the *documented* remote-signer-session exchange (see
1523
+ * `builder-api.md` → "Remote signer session exchange"): the RFC 8693 token
1524
+ * exchange is sent with `scope=sign:job` and **no `resource` indicator**,
1525
+ * which selects the PymtHouse gateway/opaque path. A prior implementation set
1526
+ * `resource = issuer`, which routed to the signer-JWT path and returned a JWT
1527
+ * that {@link parseSignerSessionExchange} then rejected as non-opaque.
1515
1528
  */
1516
1529
  async mintSignerSessionForExternalUser(input) {
1530
+ const scope = input.scope ?? SIGN_JOB_SCOPE;
1517
1531
  await this.upsertAppUser({
1518
1532
  externalUserId: input.externalUserId,
1519
1533
  email: input.email,
1520
1534
  status: "active"
1521
1535
  });
1522
- const exchange = await this.mintUserSignerSessionToken({
1536
+ const userToken = await this.mintUserAccessToken({
1523
1537
  externalUserId: input.externalUserId,
1524
- scope: input.scope ?? SIGN_JOB_SCOPE,
1525
- resource: this.issuerUrl
1538
+ scope
1539
+ });
1540
+ const exchange = await this.exchangeForSignerSession({
1541
+ userJwt: userToken.access_token,
1542
+ omitResource: true,
1543
+ scope
1526
1544
  });
1527
1545
  return parseSignerSessionExchange(exchange);
1528
1546
  }