@absolutejs/auth 0.13.0 → 0.13.2

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.js CHANGED
@@ -346,7 +346,7 @@ var providers = defineProviders({
346
346
  "id"
347
347
  ]);
348
348
  if (typeof subject !== "number") {
349
- throw new Error("Invalid identity data shape");
349
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
350
350
  }
351
351
  return subject;
352
352
  },
@@ -398,8 +398,8 @@ var providers = defineProviders({
398
398
  },
399
399
  extractSubjectFromIdentity(identity) {
400
400
  const subject = extractPropFromIdentity(identity, ["account_id"]);
401
- if (typeof subject !== "string") {
402
- throw new Error("Invalid identity data shape");
401
+ if (typeof subject !== "number") {
402
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
403
403
  }
404
404
  return subject;
405
405
  },
@@ -506,8 +506,8 @@ var providers = defineProviders({
506
506
  authorizationUrl: "https://bitbucket.org/site/oauth2/authorize",
507
507
  extractSubjectFromIdentity(identity) {
508
508
  const subject = extractPropFromIdentity(identity, ["uuid"]);
509
- if (typeof subject !== "string") {
510
- throw new Error("Invalid identity data shape");
509
+ if (typeof subject !== "number") {
510
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
511
511
  }
512
512
  return subject;
513
513
  },
@@ -530,8 +530,8 @@ var providers = defineProviders({
530
530
  authorizationUrl: "https://account.box.com/api/oauth2/authorize",
531
531
  extractSubjectFromIdentity(identity) {
532
532
  const subject = extractPropFromIdentity(identity, ["id"]);
533
- if (typeof subject !== "string") {
534
- throw new Error("Invalid identity data shape");
533
+ if (typeof subject !== "number") {
534
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
535
535
  }
536
536
  return subject;
537
537
  },
@@ -563,8 +563,8 @@ var providers = defineProviders({
563
563
  "Response",
564
564
  "membershipId"
565
565
  ]);
566
- if (typeof subject !== "string") {
567
- throw new Error("Invalid identity data shape");
566
+ if (typeof subject !== "number") {
567
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
568
568
  }
569
569
  return subject;
570
570
  },
@@ -590,8 +590,8 @@ var providers = defineProviders({
590
590
  authorizationUrl: "https://www.coinbase.com/oauth/authorize",
591
591
  extractSubjectFromIdentity(identity) {
592
592
  const subject = extractPropFromIdentity(identity, ["data", "id"]);
593
- if (typeof subject !== "string") {
594
- throw new Error("Invalid identity data shape");
593
+ if (typeof subject !== "number") {
594
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
595
595
  }
596
596
  return subject;
597
597
  },
@@ -634,7 +634,7 @@ var providers = defineProviders({
634
634
  extractSubjectFromIdentity(identity) {
635
635
  const subject = extractPropFromIdentity(identity, ["data", "id"]);
636
636
  if (typeof subject !== "number") {
637
- throw new Error("Invalid identity data shape");
637
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
638
638
  }
639
639
  return subject;
640
640
  },
@@ -658,7 +658,7 @@ var providers = defineProviders({
658
658
  extractSubjectFromIdentity(identity) {
659
659
  const subject = extractPropFromIdentity(identity, ["id"]);
660
660
  if (typeof subject !== "number") {
661
- throw new Error("Invalid identity data shape");
661
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
662
662
  }
663
663
  return subject;
664
664
  },
@@ -681,8 +681,8 @@ var providers = defineProviders({
681
681
  authorizationUrl: "https://www.dropbox.com/oauth2/authorize",
682
682
  extractSubjectFromIdentity(identity) {
683
683
  const subject = extractPropFromIdentity(identity, ["account_id"]);
684
- if (typeof subject !== "string") {
685
- throw new Error("Invalid identity data shape");
684
+ if (typeof subject !== "number") {
685
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
686
686
  }
687
687
  return subject;
688
688
  },
@@ -710,8 +710,8 @@ var providers = defineProviders({
710
710
  authorizationUrl: "https://www.epicgames.com/id/authorize",
711
711
  extractSubjectFromIdentity(identity) {
712
712
  const subject = extractPropFromIdentity(identity, ["account_id"]);
713
- if (typeof subject !== "string") {
714
- throw new Error("Invalid identity data shape");
713
+ if (typeof subject !== "number") {
714
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
715
715
  }
716
716
  return subject;
717
717
  },
@@ -739,7 +739,7 @@ var providers = defineProviders({
739
739
  "user_id"
740
740
  ]);
741
741
  if (typeof subject !== "number") {
742
- throw new Error("Invalid identity data shape");
742
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
743
743
  }
744
744
  return subject;
745
745
  },
@@ -781,11 +781,9 @@ var providers = defineProviders({
781
781
  figma: {
782
782
  authorizationUrl: "https://www.figma.com/oauth",
783
783
  extractSubjectFromIdentity(identity) {
784
- const subject = extractPropFromIdentity(identity, [
785
- "user_id_string"
786
- ]);
784
+ const subject = extractPropFromIdentity(identity, ["id"]);
787
785
  if (typeof subject !== "string") {
788
- throw new Error("Invalid identity data shape");
786
+ throw new Error(`Invalid identity data shape: expected string, got ${typeof subject}`);
789
787
  }
790
788
  return subject;
791
789
  },
@@ -829,7 +827,7 @@ var providers = defineProviders({
829
827
  extractSubjectFromIdentity(identity) {
830
828
  const subject = extractPropFromIdentity(identity, ["id"]);
831
829
  if (typeof subject !== "number") {
832
- throw new Error("Invalid identity data shape");
830
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
833
831
  }
834
832
  return subject;
835
833
  },
@@ -978,7 +976,7 @@ var providers = defineProviders({
978
976
  "user_id"
979
977
  ]);
980
978
  if (typeof subject !== "number") {
981
- throw new Error("Invalid identity data shape");
979
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
982
980
  }
983
981
  return subject;
984
982
  },
@@ -1008,8 +1006,8 @@ var providers = defineProviders({
1008
1006
  authorizationUrl: "https://lichess.org/oauth/authorize",
1009
1007
  extractSubjectFromIdentity(identity) {
1010
1008
  const subject = extractPropFromIdentity(identity, ["id"]);
1011
- if (typeof subject !== "string") {
1012
- throw new Error("Invalid identity data shape");
1009
+ if (typeof subject !== "number") {
1010
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1013
1011
  }
1014
1012
  return subject;
1015
1013
  },
@@ -1056,8 +1054,8 @@ var providers = defineProviders({
1056
1054
  "viewer",
1057
1055
  "id"
1058
1056
  ]);
1059
- if (typeof subject !== "string") {
1060
- throw new Error("Invalid identity data shape");
1057
+ if (typeof subject !== "number") {
1058
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1061
1059
  }
1062
1060
  return subject;
1063
1061
  },
@@ -1111,8 +1109,8 @@ var providers = defineProviders({
1111
1109
  authorizationUrl: (config) => `${config.baseURL}/oauth/authorize`,
1112
1110
  extractSubjectFromIdentity(identity) {
1113
1111
  const subject = extractPropFromIdentity(identity, ["id"]);
1114
- if (typeof subject !== "string") {
1115
- throw new Error("Invalid identity data shape");
1112
+ if (typeof subject !== "number") {
1113
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1116
1114
  }
1117
1115
  return subject;
1118
1116
  },
@@ -1142,8 +1140,8 @@ var providers = defineProviders({
1142
1140
  authorizationUrl: "https://auth.mercadolibre.com/authorization",
1143
1141
  extractSubjectFromIdentity(identity) {
1144
1142
  const subject = extractPropFromIdentity(identity, ["id"]);
1145
- if (typeof subject !== "string") {
1146
- throw new Error("Invalid identity data shape");
1143
+ if (typeof subject !== "number") {
1144
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1147
1145
  }
1148
1146
  return subject;
1149
1147
  },
@@ -1167,8 +1165,8 @@ var providers = defineProviders({
1167
1165
  authorizationUrl: "https://auth.mercadopago.com/authorization",
1168
1166
  extractSubjectFromIdentity(identity) {
1169
1167
  const subject = extractPropFromIdentity(identity, ["id"]);
1170
- if (typeof subject !== "string") {
1171
- throw new Error("Invalid identity data shape");
1168
+ if (typeof subject !== "number") {
1169
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1172
1170
  }
1173
1171
  return subject;
1174
1172
  },
@@ -1211,7 +1209,7 @@ var providers = defineProviders({
1211
1209
  extractSubjectFromIdentity(identity) {
1212
1210
  const subject = extractPropFromIdentity(identity, ["id"]);
1213
1211
  if (typeof subject !== "number") {
1214
- throw new Error("Invalid identity data shape");
1212
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1215
1213
  }
1216
1214
  return subject;
1217
1215
  },
@@ -1238,8 +1236,8 @@ var providers = defineProviders({
1238
1236
  "response",
1239
1237
  "id"
1240
1238
  ]);
1241
- if (typeof subject !== "string") {
1242
- throw new Error("Invalid identity data shape");
1239
+ if (typeof subject !== "number") {
1240
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1243
1241
  }
1244
1242
  return subject;
1245
1243
  },
@@ -1262,8 +1260,8 @@ var providers = defineProviders({
1262
1260
  authorizationUrl: "https://api.notion.com/v1/oauth/authorize",
1263
1261
  extractSubjectFromIdentity(identity) {
1264
1262
  const subject = extractPropFromIdentity(identity, ["id"]);
1265
- if (typeof subject !== "string") {
1266
- throw new Error("Invalid identity data shape");
1263
+ if (typeof subject !== "number") {
1264
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1267
1265
  }
1268
1266
  return subject;
1269
1267
  },
@@ -1315,7 +1313,7 @@ var providers = defineProviders({
1315
1313
  extractSubjectFromIdentity(identity) {
1316
1314
  const subject = extractPropFromIdentity(identity, ["id"]);
1317
1315
  if (typeof subject !== "number") {
1318
- throw new Error("Invalid identity data shape");
1316
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1319
1317
  }
1320
1318
  return subject;
1321
1319
  },
@@ -1338,8 +1336,8 @@ var providers = defineProviders({
1338
1336
  authorizationUrl: "https://www.patreon.com/oauth2/authorize",
1339
1337
  extractSubjectFromIdentity(identity) {
1340
1338
  const subject = extractPropFromIdentity(identity, ["data", "id"]);
1341
- if (typeof subject !== "string") {
1342
- throw new Error("Invalid identity data shape");
1339
+ if (typeof subject !== "number") {
1340
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1343
1341
  }
1344
1342
  return subject;
1345
1343
  },
@@ -1388,7 +1386,7 @@ var providers = defineProviders({
1388
1386
  extractSubjectFromIdentity(identity) {
1389
1387
  const subject = extractPropFromIdentity(identity, ["x_user_id"]);
1390
1388
  if (typeof subject !== "number") {
1391
- throw new Error("Invalid identity data shape");
1389
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1392
1390
  }
1393
1391
  return subject;
1394
1392
  },
@@ -1413,7 +1411,7 @@ var providers = defineProviders({
1413
1411
  extractSubjectFromIdentity(identity) {
1414
1412
  const subject = extractPropFromIdentity(identity, ["x_user_id"]);
1415
1413
  if (typeof subject !== "number") {
1416
- throw new Error("Invalid identity data shape");
1414
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1417
1415
  }
1418
1416
  return subject;
1419
1417
  },
@@ -1437,8 +1435,8 @@ var providers = defineProviders({
1437
1435
  authorizationUrl: "https://www.reddit.com/api/v1/authorize",
1438
1436
  extractSubjectFromIdentity(identity) {
1439
1437
  const subject = extractPropFromIdentity(identity, ["id"]);
1440
- if (typeof subject !== "string") {
1441
- throw new Error("Invalid identity data shape");
1438
+ if (typeof subject !== "number") {
1439
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1442
1440
  }
1443
1441
  return subject;
1444
1442
  },
@@ -1513,7 +1511,7 @@ var providers = defineProviders({
1513
1511
  extractSubjectFromIdentity(identity) {
1514
1512
  const subject = extractPropFromIdentity(identity, ["id"]);
1515
1513
  if (typeof subject !== "number") {
1516
- throw new Error("Invalid identity data shape");
1514
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1517
1515
  }
1518
1516
  return subject;
1519
1517
  },
@@ -1560,8 +1558,8 @@ var providers = defineProviders({
1560
1558
  authorizationUrl: "https://accounts.spotify.com/authorize",
1561
1559
  extractSubjectFromIdentity(identity) {
1562
1560
  const subject = extractPropFromIdentity(identity, ["id"]);
1563
- if (typeof subject !== "string") {
1564
- throw new Error("Invalid identity data shape");
1561
+ if (typeof subject !== "number") {
1562
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1565
1563
  }
1566
1564
  return subject;
1567
1565
  },
@@ -1589,8 +1587,8 @@ var providers = defineProviders({
1589
1587
  "currentUser",
1590
1588
  "id"
1591
1589
  ]);
1592
- if (typeof subject !== "string") {
1593
- throw new Error("Invalid identity data shape");
1590
+ if (typeof subject !== "number") {
1591
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1594
1592
  }
1595
1593
  return subject;
1596
1594
  },
@@ -1621,7 +1619,7 @@ var providers = defineProviders({
1621
1619
  extractSubjectFromIdentity(identity) {
1622
1620
  const subject = extractPropFromIdentity(identity, ["id"]);
1623
1621
  if (typeof subject !== "number") {
1624
- throw new Error("Invalid identity data shape");
1622
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1625
1623
  }
1626
1624
  return subject;
1627
1625
  },
@@ -1654,8 +1652,8 @@ var providers = defineProviders({
1654
1652
  authorizationUrl: (config) => `${config.baseURL}/webman/sso/SSOOauth.cgi?client_id=${config.clientId}&response_type=code&redirect_uri=${config.redirectUri}`,
1655
1653
  extractSubjectFromIdentity(identity) {
1656
1654
  const subject = extractPropFromIdentity(identity, ["data", "id"]);
1657
- if (typeof subject !== "string") {
1658
- throw new Error("Invalid identity data shape");
1655
+ if (typeof subject !== "number") {
1656
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1659
1657
  }
1660
1658
  return subject;
1661
1659
  },
@@ -1684,8 +1682,8 @@ var providers = defineProviders({
1684
1682
  "data",
1685
1683
  "open_id"
1686
1684
  ]);
1687
- if (typeof subject !== "string") {
1688
- throw new Error("Invalid identity data shape");
1685
+ if (typeof subject !== "number") {
1686
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1689
1687
  }
1690
1688
  return subject;
1691
1689
  },
@@ -1715,8 +1713,8 @@ var providers = defineProviders({
1715
1713
  authorizationUrl: "https://v5api.tiltify.com/oauth/authorize",
1716
1714
  extractSubjectFromIdentity(identity) {
1717
1715
  const subject = extractPropFromIdentity(identity, ["data", "id"]);
1718
- if (typeof subject !== "string") {
1719
- throw new Error("Invalid identity data shape");
1716
+ if (typeof subject !== "number") {
1717
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1720
1718
  }
1721
1719
  return subject;
1722
1720
  },
@@ -1743,8 +1741,8 @@ var providers = defineProviders({
1743
1741
  "user",
1744
1742
  "name"
1745
1743
  ]);
1746
- if (typeof subject !== "string") {
1747
- throw new Error("Invalid identity data shape");
1744
+ if (typeof subject !== "number") {
1745
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1748
1746
  }
1749
1747
  return subject;
1750
1748
  },
@@ -1797,8 +1795,8 @@ var providers = defineProviders({
1797
1795
  authorizationUrl: "https://twitter.com/i/oauth2/authorize",
1798
1796
  extractSubjectFromIdentity(identity) {
1799
1797
  const subject = extractPropFromIdentity(identity, ["data", "id"]);
1800
- if (typeof subject !== "string") {
1801
- throw new Error("Invalid identity data shape");
1798
+ if (typeof subject !== "number") {
1799
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1802
1800
  }
1803
1801
  return subject;
1804
1802
  },
@@ -1832,7 +1830,7 @@ var providers = defineProviders({
1832
1830
  "id"
1833
1831
  ]);
1834
1832
  if (typeof subject !== "number") {
1835
- throw new Error("Invalid identity data shape");
1833
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1836
1834
  }
1837
1835
  return subject;
1838
1836
  },
@@ -1859,7 +1857,7 @@ var providers = defineProviders({
1859
1857
  "userid"
1860
1858
  ]);
1861
1859
  if (typeof subject !== "number") {
1862
- throw new Error("Invalid identity data shape");
1860
+ throw new Error(`Invalid identity data shape: expected number, got ${typeof subject}`);
1863
1861
  }
1864
1862
  return subject;
1865
1863
  },
@@ -1965,8 +1963,8 @@ var providers = defineProviders({
1965
1963
  },
1966
1964
  extractSubjectFromIdentity(identity) {
1967
1965
  const subject = extractPropFromIdentity(identity, ["id"]);
1968
- if (typeof subject !== "string") {
1969
- throw new Error("Invalid identity data shape");
1966
+ if (typeof subject !== "number") {
1967
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
1970
1968
  }
1971
1969
  return subject;
1972
1970
  },
@@ -1996,8 +1994,8 @@ var providers = defineProviders({
1996
1994
  authorizationUrl: "https://zoom.us/oauth/authorize",
1997
1995
  extractSubjectFromIdentity(identity) {
1998
1996
  const subject = extractPropFromIdentity(identity, ["id"]);
1999
- if (typeof subject !== "string") {
2000
- throw new Error("Invalid identity data shape");
1997
+ if (typeof subject !== "number") {
1998
+ throw new Error(`Invalid identity data shape: expected string got ${typeof subject}`);
2001
1999
  }
2002
2000
  return subject;
2003
2001
  },
@@ -2702,12 +2700,17 @@ var absoluteAuth = async ({
2702
2700
  refreshRoute,
2703
2701
  revokeRoute,
2704
2702
  onAuthorizeSuccess,
2703
+ onAuthorizeError,
2705
2704
  onProfileSuccess,
2705
+ onProfileError,
2706
2706
  onCallbackSuccess,
2707
+ onCallbackError,
2707
2708
  onStatus,
2708
2709
  onRefreshSuccess,
2710
+ onRefreshError,
2709
2711
  onSignOut,
2710
- onRevocationSuccess
2712
+ onRevocationSuccess,
2713
+ onRevocationError
2711
2714
  }) => {
2712
2715
  const entryPromises = [];
2713
2716
  for (const [providerName, providerConfig] of Object.entries(providersConfiguration)) {
@@ -2723,12 +2726,29 @@ var absoluteAuth = async ({
2723
2726
  ]));
2724
2727
  }
2725
2728
  const clientProviders = Object.fromEntries(await Promise.all(entryPromises));
2726
- return new Elysia10().use(signout({ onSignOut, signoutRoute })).use(revoke({ clientProviders, onRevocationSuccess, revokeRoute })).use(status({ onStatus, statusRoute })).use(refresh({ clientProviders, onRefreshSuccess, refreshRoute })).use(authorize({ authorizeRoute, clientProviders, onAuthorizeSuccess })).use(callback({
2729
+ return new Elysia10().use(signout({ onSignOut, signoutRoute })).use(revoke({
2730
+ clientProviders,
2731
+ onRevocationError,
2732
+ onRevocationSuccess,
2733
+ revokeRoute
2734
+ })).use(status({ onStatus, statusRoute })).use(refresh({
2735
+ clientProviders,
2736
+ onRefreshError,
2737
+ onRefreshSuccess,
2738
+ refreshRoute
2739
+ })).use(authorize({
2740
+ authorizeRoute,
2741
+ clientProviders,
2742
+ onAuthorizeError,
2743
+ onAuthorizeSuccess
2744
+ })).use(callback({
2727
2745
  callbackRoute,
2728
2746
  clientProviders,
2747
+ onCallbackError,
2729
2748
  onCallbackSuccess
2730
2749
  })).use(profile({
2731
2750
  clientProviders,
2751
+ onProfileError,
2732
2752
  onProfileSuccess,
2733
2753
  profileRoute
2734
2754
  })).use(protectRoute());
@@ -2755,5 +2775,5 @@ export {
2755
2775
  absoluteAuth
2756
2776
  };
2757
2777
 
2758
- //# debugId=2E7A925803CF255964756E2164756E21
2778
+ //# debugId=21F30351EC82AA0A64756E2164756E21
2759
2779
  //# sourceMappingURL=index.js.map