@productcraft/auth 0.8.3 → 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/README.md +11 -11
- package/dist/index.cjs +43 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +347 -69
- package/dist/index.d.ts +347 -69
- package/dist/index.js +43 -55
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -593,15 +593,18 @@ function getRoleControllerCreateRoleUrl({
|
|
|
593
593
|
}
|
|
594
594
|
async function roleControllerCreateRole({
|
|
595
595
|
appId,
|
|
596
|
-
data
|
|
596
|
+
data,
|
|
597
|
+
headers
|
|
597
598
|
}, config = {}) {
|
|
598
599
|
const { client: request = client, ...requestConfig } = config;
|
|
600
|
+
const mappedHeaders = headers ? { "Idempotency-Key": headers.idempotencyKey } : void 0;
|
|
599
601
|
const requestData = data;
|
|
600
602
|
const res = await request({
|
|
601
603
|
method: "POST",
|
|
602
604
|
url: getRoleControllerCreateRoleUrl({ appId }).url.toString(),
|
|
603
605
|
data: requestData,
|
|
604
|
-
...requestConfig
|
|
606
|
+
...requestConfig,
|
|
607
|
+
headers: { ...mappedHeaders, ...requestConfig.headers }
|
|
605
608
|
});
|
|
606
609
|
return res.data;
|
|
607
610
|
}
|
|
@@ -713,15 +716,18 @@ function getPermissionControllerCreatePermissionUrl({
|
|
|
713
716
|
}
|
|
714
717
|
async function permissionControllerCreatePermission({
|
|
715
718
|
appId,
|
|
716
|
-
data
|
|
719
|
+
data,
|
|
720
|
+
headers
|
|
717
721
|
}, config = {}) {
|
|
718
722
|
const { client: request = client, ...requestConfig } = config;
|
|
723
|
+
const mappedHeaders = headers ? { "Idempotency-Key": headers.idempotencyKey } : void 0;
|
|
719
724
|
const requestData = data;
|
|
720
725
|
const res = await request({
|
|
721
726
|
method: "POST",
|
|
722
727
|
url: getPermissionControllerCreatePermissionUrl({ appId }).url.toString(),
|
|
723
728
|
data: requestData,
|
|
724
|
-
...requestConfig
|
|
729
|
+
...requestConfig,
|
|
730
|
+
headers: { ...mappedHeaders, ...requestConfig.headers }
|
|
725
731
|
});
|
|
726
732
|
return res.data;
|
|
727
733
|
}
|
|
@@ -1348,8 +1354,7 @@ function getConsumerAuthControllerRequestPasswordResetUrl({
|
|
|
1348
1354
|
}
|
|
1349
1355
|
async function consumerAuthControllerRequestPasswordReset({
|
|
1350
1356
|
appSlug,
|
|
1351
|
-
data
|
|
1352
|
-
headers
|
|
1357
|
+
data
|
|
1353
1358
|
}, config = {}) {
|
|
1354
1359
|
const { client: request = client, ...requestConfig } = config;
|
|
1355
1360
|
const requestData = data;
|
|
@@ -1359,8 +1364,7 @@ async function consumerAuthControllerRequestPasswordReset({
|
|
|
1359
1364
|
appSlug
|
|
1360
1365
|
}).url.toString(),
|
|
1361
1366
|
data: requestData,
|
|
1362
|
-
...requestConfig
|
|
1363
|
-
headers: { ...headers, ...requestConfig.headers }
|
|
1367
|
+
...requestConfig
|
|
1364
1368
|
});
|
|
1365
1369
|
return res.data;
|
|
1366
1370
|
}
|
|
@@ -1378,8 +1382,7 @@ function getConsumerAuthControllerSendPasswordResetEmailUrl({
|
|
|
1378
1382
|
}
|
|
1379
1383
|
async function consumerAuthControllerSendPasswordResetEmail({
|
|
1380
1384
|
appSlug,
|
|
1381
|
-
data
|
|
1382
|
-
headers
|
|
1385
|
+
data
|
|
1383
1386
|
}, config = {}) {
|
|
1384
1387
|
const { client: request = client, ...requestConfig } = config;
|
|
1385
1388
|
const requestData = data;
|
|
@@ -1389,8 +1392,7 @@ async function consumerAuthControllerSendPasswordResetEmail({
|
|
|
1389
1392
|
appSlug
|
|
1390
1393
|
}).url.toString(),
|
|
1391
1394
|
data: requestData,
|
|
1392
|
-
...requestConfig
|
|
1393
|
-
headers: { ...headers, ...requestConfig.headers }
|
|
1395
|
+
...requestConfig
|
|
1394
1396
|
});
|
|
1395
1397
|
return res.data;
|
|
1396
1398
|
}
|
|
@@ -1434,8 +1436,7 @@ function getConsumerAuthControllerRequestVerificationUrl({
|
|
|
1434
1436
|
}
|
|
1435
1437
|
async function consumerAuthControllerRequestVerification({
|
|
1436
1438
|
appSlug,
|
|
1437
|
-
data
|
|
1438
|
-
headers
|
|
1439
|
+
data
|
|
1439
1440
|
}, config = {}) {
|
|
1440
1441
|
const { client: request = client, ...requestConfig } = config;
|
|
1441
1442
|
const requestData = data;
|
|
@@ -1445,8 +1446,7 @@ async function consumerAuthControllerRequestVerification({
|
|
|
1445
1446
|
appSlug
|
|
1446
1447
|
}).url.toString(),
|
|
1447
1448
|
data: requestData,
|
|
1448
|
-
...requestConfig
|
|
1449
|
-
headers: { ...headers, ...requestConfig.headers }
|
|
1449
|
+
...requestConfig
|
|
1450
1450
|
});
|
|
1451
1451
|
return res.data;
|
|
1452
1452
|
}
|
|
@@ -1464,8 +1464,7 @@ function getConsumerAuthControllerSendVerificationEmailUrl({
|
|
|
1464
1464
|
}
|
|
1465
1465
|
async function consumerAuthControllerSendVerificationEmail({
|
|
1466
1466
|
appSlug,
|
|
1467
|
-
data
|
|
1468
|
-
headers
|
|
1467
|
+
data
|
|
1469
1468
|
}, config = {}) {
|
|
1470
1469
|
const { client: request = client, ...requestConfig } = config;
|
|
1471
1470
|
const requestData = data;
|
|
@@ -1475,8 +1474,7 @@ async function consumerAuthControllerSendVerificationEmail({
|
|
|
1475
1474
|
appSlug
|
|
1476
1475
|
}).url.toString(),
|
|
1477
1476
|
data: requestData,
|
|
1478
|
-
...requestConfig
|
|
1479
|
-
headers: { ...headers, ...requestConfig.headers }
|
|
1477
|
+
...requestConfig
|
|
1480
1478
|
});
|
|
1481
1479
|
return res.data;
|
|
1482
1480
|
}
|
|
@@ -1680,15 +1678,18 @@ function getConsumerMfaControllerStartEnrollmentUrl({
|
|
|
1680
1678
|
}
|
|
1681
1679
|
async function consumerMfaControllerStartEnrollment({
|
|
1682
1680
|
appSlug,
|
|
1683
|
-
data
|
|
1681
|
+
data,
|
|
1682
|
+
headers
|
|
1684
1683
|
}, config = {}) {
|
|
1685
1684
|
const { client: request = client, ...requestConfig } = config;
|
|
1685
|
+
const mappedHeaders = headers ? { "Idempotency-Key": headers.idempotencyKey } : void 0;
|
|
1686
1686
|
const requestData = data;
|
|
1687
1687
|
const res = await request({
|
|
1688
1688
|
method: "POST",
|
|
1689
1689
|
url: getConsumerMfaControllerStartEnrollmentUrl({ appSlug }).url.toString(),
|
|
1690
1690
|
data: requestData,
|
|
1691
|
-
...requestConfig
|
|
1691
|
+
...requestConfig,
|
|
1692
|
+
headers: { ...mappedHeaders, ...requestConfig.headers }
|
|
1692
1693
|
});
|
|
1693
1694
|
return res.data;
|
|
1694
1695
|
}
|
|
@@ -1785,8 +1786,7 @@ function getConsumerVerifyControllerVerifyUrl({
|
|
|
1785
1786
|
}
|
|
1786
1787
|
async function consumerVerifyControllerVerify({
|
|
1787
1788
|
appSlug,
|
|
1788
|
-
data
|
|
1789
|
-
headers
|
|
1789
|
+
data
|
|
1790
1790
|
}, config = {}) {
|
|
1791
1791
|
const { client: request = client, ...requestConfig } = config;
|
|
1792
1792
|
const requestData = data;
|
|
@@ -1794,8 +1794,7 @@ async function consumerVerifyControllerVerify({
|
|
|
1794
1794
|
method: "POST",
|
|
1795
1795
|
url: getConsumerVerifyControllerVerifyUrl({ appSlug }).url.toString(),
|
|
1796
1796
|
data: requestData,
|
|
1797
|
-
...requestConfig
|
|
1798
|
-
headers: { ...headers, ...requestConfig.headers }
|
|
1797
|
+
...requestConfig
|
|
1799
1798
|
});
|
|
1800
1799
|
return res.data;
|
|
1801
1800
|
}
|
|
@@ -1810,8 +1809,7 @@ function getConsumerVerifyControllerAuthorizeUrl({
|
|
|
1810
1809
|
}
|
|
1811
1810
|
async function consumerVerifyControllerAuthorize({
|
|
1812
1811
|
appSlug,
|
|
1813
|
-
data
|
|
1814
|
-
headers
|
|
1812
|
+
data
|
|
1815
1813
|
}, config = {}) {
|
|
1816
1814
|
const { client: request = client, ...requestConfig } = config;
|
|
1817
1815
|
const requestData = data;
|
|
@@ -1819,8 +1817,7 @@ async function consumerVerifyControllerAuthorize({
|
|
|
1819
1817
|
method: "POST",
|
|
1820
1818
|
url: getConsumerVerifyControllerAuthorizeUrl({ appSlug }).url.toString(),
|
|
1821
1819
|
data: requestData,
|
|
1822
|
-
...requestConfig
|
|
1823
|
-
headers: { ...headers, ...requestConfig.headers }
|
|
1820
|
+
...requestConfig
|
|
1824
1821
|
});
|
|
1825
1822
|
return res.data;
|
|
1826
1823
|
}
|
|
@@ -1838,8 +1835,7 @@ function getConsumerVerifyControllerAuthorizeBatchUrl({
|
|
|
1838
1835
|
}
|
|
1839
1836
|
async function consumerVerifyControllerAuthorizeBatch({
|
|
1840
1837
|
appSlug,
|
|
1841
|
-
data
|
|
1842
|
-
headers
|
|
1838
|
+
data
|
|
1843
1839
|
}, config = {}) {
|
|
1844
1840
|
const { client: request = client, ...requestConfig } = config;
|
|
1845
1841
|
const requestData = data;
|
|
@@ -1849,8 +1845,7 @@ async function consumerVerifyControllerAuthorizeBatch({
|
|
|
1849
1845
|
appSlug
|
|
1850
1846
|
}).url.toString(),
|
|
1851
1847
|
data: requestData,
|
|
1852
|
-
...requestConfig
|
|
1853
|
-
headers: { ...headers, ...requestConfig.headers }
|
|
1848
|
+
...requestConfig
|
|
1854
1849
|
});
|
|
1855
1850
|
return res.data;
|
|
1856
1851
|
}
|
|
@@ -2316,12 +2311,11 @@ var ConsumerScope = class {
|
|
|
2316
2311
|
*
|
|
2317
2312
|
* PAK-required with `auth.user.password-reset.create`: caller must
|
|
2318
2313
|
* instantiate `Auth` with
|
|
2319
|
-
* `auth: { type: "apiKey", key: "pcft_live_..." }
|
|
2320
|
-
*
|
|
2321
|
-
* HTTP client's auth middleware overrides whatever's passed.
|
|
2314
|
+
* `auth: { type: "apiKey", key: "pcft_live_..." }`; the HTTP
|
|
2315
|
+
* client's auth middleware sends it.
|
|
2322
2316
|
*/
|
|
2323
2317
|
requestReset: (data) => consumerAuthControllerRequestPasswordReset(
|
|
2324
|
-
{ appSlug: this.appSlug, data
|
|
2318
|
+
{ appSlug: this.appSlug, data },
|
|
2325
2319
|
{ client: this.client }
|
|
2326
2320
|
),
|
|
2327
2321
|
/**
|
|
@@ -2344,8 +2338,7 @@ var ConsumerScope = class {
|
|
|
2344
2338
|
sendPasswordResetEmail: (data) => consumerAuthControllerSendPasswordResetEmail(
|
|
2345
2339
|
{
|
|
2346
2340
|
appSlug: this.appSlug,
|
|
2347
|
-
data
|
|
2348
|
-
headers: { authorization: "" }
|
|
2341
|
+
data
|
|
2349
2342
|
},
|
|
2350
2343
|
{ client: this.client }
|
|
2351
2344
|
),
|
|
@@ -2361,15 +2354,13 @@ var ConsumerScope = class {
|
|
|
2361
2354
|
*
|
|
2362
2355
|
* PAK-required: caller must instantiate `Auth` with
|
|
2363
2356
|
* `auth: { type: "apiKey", key: "pcft_live_..." }` carrying
|
|
2364
|
-
* `auth.user.verify.create` narrowed to this app's URN
|
|
2365
|
-
*
|
|
2366
|
-
* HTTP client's auth middleware overrides whatever's passed.
|
|
2357
|
+
* `auth.user.verify.create` narrowed to this app's URN; the HTTP
|
|
2358
|
+
* client's auth middleware sends it.
|
|
2367
2359
|
*/
|
|
2368
2360
|
requestVerification: (data) => consumerAuthControllerRequestVerification(
|
|
2369
2361
|
{
|
|
2370
2362
|
appSlug: this.appSlug,
|
|
2371
|
-
data
|
|
2372
|
-
headers: { authorization: "" }
|
|
2363
|
+
data
|
|
2373
2364
|
},
|
|
2374
2365
|
{ client: this.client }
|
|
2375
2366
|
),
|
|
@@ -2388,8 +2379,7 @@ var ConsumerScope = class {
|
|
|
2388
2379
|
sendVerificationEmail: (data) => consumerAuthControllerSendVerificationEmail(
|
|
2389
2380
|
{
|
|
2390
2381
|
appSlug: this.appSlug,
|
|
2391
|
-
data
|
|
2392
|
-
headers: { authorization: "" }
|
|
2382
|
+
data
|
|
2393
2383
|
},
|
|
2394
2384
|
{ client: this.client }
|
|
2395
2385
|
),
|
|
@@ -2484,22 +2474,20 @@ var ConsumerScope = class {
|
|
|
2484
2474
|
// ─────────────────────────────────────────────────────────────
|
|
2485
2475
|
verify = {
|
|
2486
2476
|
/**
|
|
2487
|
-
* The
|
|
2488
|
-
*
|
|
2489
|
-
*
|
|
2490
|
-
* auth middleware overrides whatever's passed with the configured
|
|
2491
|
-
* credential (`PCAuth.apiKey` / `bearer` / `cookie`).
|
|
2477
|
+
* The token under test goes in `data.token`. The server also accepts
|
|
2478
|
+
* it as a bearer; the HTTP client's auth middleware sends the
|
|
2479
|
+
* configured credential (`PCAuth.apiKey` / `bearer` / `cookie`).
|
|
2492
2480
|
*/
|
|
2493
2481
|
verify: (data) => consumerVerifyControllerVerify(
|
|
2494
|
-
{ appSlug: this.appSlug, data
|
|
2482
|
+
{ appSlug: this.appSlug, data },
|
|
2495
2483
|
{ client: this.client }
|
|
2496
2484
|
),
|
|
2497
2485
|
authorize: (data) => consumerVerifyControllerAuthorize(
|
|
2498
|
-
{ appSlug: this.appSlug, data
|
|
2486
|
+
{ appSlug: this.appSlug, data },
|
|
2499
2487
|
{ client: this.client }
|
|
2500
2488
|
),
|
|
2501
2489
|
authorizeBatch: (data) => consumerVerifyControllerAuthorizeBatch(
|
|
2502
|
-
{ appSlug: this.appSlug, data
|
|
2490
|
+
{ appSlug: this.appSlug, data },
|
|
2503
2491
|
{ client: this.client }
|
|
2504
2492
|
)
|
|
2505
2493
|
};
|