@productcraft/auth 0.8.4 → 0.9.0

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
@@ -595,15 +595,18 @@ function getRoleControllerCreateRoleUrl({
595
595
  }
596
596
  async function roleControllerCreateRole({
597
597
  appId,
598
- data
598
+ data,
599
+ headers
599
600
  }, config = {}) {
600
601
  const { client: request = client, ...requestConfig } = config;
602
+ const mappedHeaders = headers ? { "Idempotency-Key": headers.idempotencyKey } : void 0;
601
603
  const requestData = data;
602
604
  const res = await request({
603
605
  method: "POST",
604
606
  url: getRoleControllerCreateRoleUrl({ appId }).url.toString(),
605
607
  data: requestData,
606
- ...requestConfig
608
+ ...requestConfig,
609
+ headers: { ...mappedHeaders, ...requestConfig.headers }
607
610
  });
608
611
  return res.data;
609
612
  }
@@ -715,15 +718,18 @@ function getPermissionControllerCreatePermissionUrl({
715
718
  }
716
719
  async function permissionControllerCreatePermission({
717
720
  appId,
718
- data
721
+ data,
722
+ headers
719
723
  }, config = {}) {
720
724
  const { client: request = client, ...requestConfig } = config;
725
+ const mappedHeaders = headers ? { "Idempotency-Key": headers.idempotencyKey } : void 0;
721
726
  const requestData = data;
722
727
  const res = await request({
723
728
  method: "POST",
724
729
  url: getPermissionControllerCreatePermissionUrl({ appId }).url.toString(),
725
730
  data: requestData,
726
- ...requestConfig
731
+ ...requestConfig,
732
+ headers: { ...mappedHeaders, ...requestConfig.headers }
727
733
  });
728
734
  return res.data;
729
735
  }
@@ -1350,8 +1356,7 @@ function getConsumerAuthControllerRequestPasswordResetUrl({
1350
1356
  }
1351
1357
  async function consumerAuthControllerRequestPasswordReset({
1352
1358
  appSlug,
1353
- data,
1354
- headers
1359
+ data
1355
1360
  }, config = {}) {
1356
1361
  const { client: request = client, ...requestConfig } = config;
1357
1362
  const requestData = data;
@@ -1361,8 +1366,7 @@ async function consumerAuthControllerRequestPasswordReset({
1361
1366
  appSlug
1362
1367
  }).url.toString(),
1363
1368
  data: requestData,
1364
- ...requestConfig,
1365
- headers: { ...headers, ...requestConfig.headers }
1369
+ ...requestConfig
1366
1370
  });
1367
1371
  return res.data;
1368
1372
  }
@@ -1380,8 +1384,7 @@ function getConsumerAuthControllerSendPasswordResetEmailUrl({
1380
1384
  }
1381
1385
  async function consumerAuthControllerSendPasswordResetEmail({
1382
1386
  appSlug,
1383
- data,
1384
- headers
1387
+ data
1385
1388
  }, config = {}) {
1386
1389
  const { client: request = client, ...requestConfig } = config;
1387
1390
  const requestData = data;
@@ -1391,8 +1394,7 @@ async function consumerAuthControllerSendPasswordResetEmail({
1391
1394
  appSlug
1392
1395
  }).url.toString(),
1393
1396
  data: requestData,
1394
- ...requestConfig,
1395
- headers: { ...headers, ...requestConfig.headers }
1397
+ ...requestConfig
1396
1398
  });
1397
1399
  return res.data;
1398
1400
  }
@@ -1436,8 +1438,7 @@ function getConsumerAuthControllerRequestVerificationUrl({
1436
1438
  }
1437
1439
  async function consumerAuthControllerRequestVerification({
1438
1440
  appSlug,
1439
- data,
1440
- headers
1441
+ data
1441
1442
  }, config = {}) {
1442
1443
  const { client: request = client, ...requestConfig } = config;
1443
1444
  const requestData = data;
@@ -1447,8 +1448,7 @@ async function consumerAuthControllerRequestVerification({
1447
1448
  appSlug
1448
1449
  }).url.toString(),
1449
1450
  data: requestData,
1450
- ...requestConfig,
1451
- headers: { ...headers, ...requestConfig.headers }
1451
+ ...requestConfig
1452
1452
  });
1453
1453
  return res.data;
1454
1454
  }
@@ -1466,8 +1466,7 @@ function getConsumerAuthControllerSendVerificationEmailUrl({
1466
1466
  }
1467
1467
  async function consumerAuthControllerSendVerificationEmail({
1468
1468
  appSlug,
1469
- data,
1470
- headers
1469
+ data
1471
1470
  }, config = {}) {
1472
1471
  const { client: request = client, ...requestConfig } = config;
1473
1472
  const requestData = data;
@@ -1477,8 +1476,7 @@ async function consumerAuthControllerSendVerificationEmail({
1477
1476
  appSlug
1478
1477
  }).url.toString(),
1479
1478
  data: requestData,
1480
- ...requestConfig,
1481
- headers: { ...headers, ...requestConfig.headers }
1479
+ ...requestConfig
1482
1480
  });
1483
1481
  return res.data;
1484
1482
  }
@@ -1682,15 +1680,18 @@ function getConsumerMfaControllerStartEnrollmentUrl({
1682
1680
  }
1683
1681
  async function consumerMfaControllerStartEnrollment({
1684
1682
  appSlug,
1685
- data
1683
+ data,
1684
+ headers
1686
1685
  }, config = {}) {
1687
1686
  const { client: request = client, ...requestConfig } = config;
1687
+ const mappedHeaders = headers ? { "Idempotency-Key": headers.idempotencyKey } : void 0;
1688
1688
  const requestData = data;
1689
1689
  const res = await request({
1690
1690
  method: "POST",
1691
1691
  url: getConsumerMfaControllerStartEnrollmentUrl({ appSlug }).url.toString(),
1692
1692
  data: requestData,
1693
- ...requestConfig
1693
+ ...requestConfig,
1694
+ headers: { ...mappedHeaders, ...requestConfig.headers }
1694
1695
  });
1695
1696
  return res.data;
1696
1697
  }
@@ -1787,8 +1788,7 @@ function getConsumerVerifyControllerVerifyUrl({
1787
1788
  }
1788
1789
  async function consumerVerifyControllerVerify({
1789
1790
  appSlug,
1790
- data,
1791
- headers
1791
+ data
1792
1792
  }, config = {}) {
1793
1793
  const { client: request = client, ...requestConfig } = config;
1794
1794
  const requestData = data;
@@ -1796,8 +1796,7 @@ async function consumerVerifyControllerVerify({
1796
1796
  method: "POST",
1797
1797
  url: getConsumerVerifyControllerVerifyUrl({ appSlug }).url.toString(),
1798
1798
  data: requestData,
1799
- ...requestConfig,
1800
- headers: { ...headers, ...requestConfig.headers }
1799
+ ...requestConfig
1801
1800
  });
1802
1801
  return res.data;
1803
1802
  }
@@ -1812,8 +1811,7 @@ function getConsumerVerifyControllerAuthorizeUrl({
1812
1811
  }
1813
1812
  async function consumerVerifyControllerAuthorize({
1814
1813
  appSlug,
1815
- data,
1816
- headers
1814
+ data
1817
1815
  }, config = {}) {
1818
1816
  const { client: request = client, ...requestConfig } = config;
1819
1817
  const requestData = data;
@@ -1821,8 +1819,7 @@ async function consumerVerifyControllerAuthorize({
1821
1819
  method: "POST",
1822
1820
  url: getConsumerVerifyControllerAuthorizeUrl({ appSlug }).url.toString(),
1823
1821
  data: requestData,
1824
- ...requestConfig,
1825
- headers: { ...headers, ...requestConfig.headers }
1822
+ ...requestConfig
1826
1823
  });
1827
1824
  return res.data;
1828
1825
  }
@@ -1840,8 +1837,7 @@ function getConsumerVerifyControllerAuthorizeBatchUrl({
1840
1837
  }
1841
1838
  async function consumerVerifyControllerAuthorizeBatch({
1842
1839
  appSlug,
1843
- data,
1844
- headers
1840
+ data
1845
1841
  }, config = {}) {
1846
1842
  const { client: request = client, ...requestConfig } = config;
1847
1843
  const requestData = data;
@@ -1851,8 +1847,7 @@ async function consumerVerifyControllerAuthorizeBatch({
1851
1847
  appSlug
1852
1848
  }).url.toString(),
1853
1849
  data: requestData,
1854
- ...requestConfig,
1855
- headers: { ...headers, ...requestConfig.headers }
1850
+ ...requestConfig
1856
1851
  });
1857
1852
  return res.data;
1858
1853
  }
@@ -2318,12 +2313,11 @@ var ConsumerScope = class {
2318
2313
  *
2319
2314
  * PAK-required with `auth.user.password-reset.create`: caller must
2320
2315
  * instantiate `Auth` with
2321
- * `auth: { type: "apiKey", key: "pcft_live_..." }`. The
2322
- * kubb-generated `headers.authorization` slot is a stub — the
2323
- * HTTP client's auth middleware overrides whatever's passed.
2316
+ * `auth: { type: "apiKey", key: "pcft_live_..." }`; the HTTP
2317
+ * client's auth middleware sends it.
2324
2318
  */
2325
2319
  requestReset: (data) => consumerAuthControllerRequestPasswordReset(
2326
- { appSlug: this.appSlug, data, headers: { authorization: "" } },
2320
+ { appSlug: this.appSlug, data },
2327
2321
  { client: this.client }
2328
2322
  ),
2329
2323
  /**
@@ -2346,8 +2340,7 @@ var ConsumerScope = class {
2346
2340
  sendPasswordResetEmail: (data) => consumerAuthControllerSendPasswordResetEmail(
2347
2341
  {
2348
2342
  appSlug: this.appSlug,
2349
- data,
2350
- headers: { authorization: "" }
2343
+ data
2351
2344
  },
2352
2345
  { client: this.client }
2353
2346
  ),
@@ -2363,15 +2356,13 @@ var ConsumerScope = class {
2363
2356
  *
2364
2357
  * PAK-required: caller must instantiate `Auth` with
2365
2358
  * `auth: { type: "apiKey", key: "pcft_live_..." }` carrying
2366
- * `auth.user.verify.create` narrowed to this app's URN. The
2367
- * kubb-generated `headers.authorization` slot is a stub — the
2368
- * HTTP client's auth middleware overrides whatever's passed.
2359
+ * `auth.user.verify.create` narrowed to this app's URN; the HTTP
2360
+ * client's auth middleware sends it.
2369
2361
  */
2370
2362
  requestVerification: (data) => consumerAuthControllerRequestVerification(
2371
2363
  {
2372
2364
  appSlug: this.appSlug,
2373
- data,
2374
- headers: { authorization: "" }
2365
+ data
2375
2366
  },
2376
2367
  { client: this.client }
2377
2368
  ),
@@ -2390,8 +2381,7 @@ var ConsumerScope = class {
2390
2381
  sendVerificationEmail: (data) => consumerAuthControllerSendVerificationEmail(
2391
2382
  {
2392
2383
  appSlug: this.appSlug,
2393
- data,
2394
- headers: { authorization: "" }
2384
+ data
2395
2385
  },
2396
2386
  { client: this.client }
2397
2387
  ),
@@ -2486,22 +2476,20 @@ var ConsumerScope = class {
2486
2476
  // ─────────────────────────────────────────────────────────────
2487
2477
  verify = {
2488
2478
  /**
2489
- * The kubb-generated client makes `headers.authorization` a required
2490
- * arg because the server controllers accept the bearer as a fallback
2491
- * to `body.token`. We stub an empty string here — the HTTP client's
2492
- * auth middleware overrides whatever's passed with the configured
2493
- * credential (`PCAuth.apiKey` / `bearer` / `cookie`).
2479
+ * The token under test goes in `data.token`. The server also accepts
2480
+ * it as a bearer; the HTTP client's auth middleware sends the
2481
+ * configured credential (`PCAuth.apiKey` / `bearer` / `cookie`).
2494
2482
  */
2495
2483
  verify: (data) => consumerVerifyControllerVerify(
2496
- { appSlug: this.appSlug, data, headers: { authorization: "" } },
2484
+ { appSlug: this.appSlug, data },
2497
2485
  { client: this.client }
2498
2486
  ),
2499
2487
  authorize: (data) => consumerVerifyControllerAuthorize(
2500
- { appSlug: this.appSlug, data, headers: { authorization: "" } },
2488
+ { appSlug: this.appSlug, data },
2501
2489
  { client: this.client }
2502
2490
  ),
2503
2491
  authorizeBatch: (data) => consumerVerifyControllerAuthorizeBatch(
2504
- { appSlug: this.appSlug, data, headers: { authorization: "" } },
2492
+ { appSlug: this.appSlug, data },
2505
2493
  { client: this.client }
2506
2494
  )
2507
2495
  };