@nhost/nhost-js 4.0.0 → 4.1.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.
Files changed (80) hide show
  1. package/README.md +9 -10
  2. package/dist/middlewareWithAdminSession-BtFo6WUj.js +2 -0
  3. package/dist/middlewareWithAdminSession-BtFo6WUj.js.map +1 -0
  4. package/dist/middlewareWithAdminSession-w7fkl0J9.mjs +106 -0
  5. package/dist/middlewareWithAdminSession-w7fkl0J9.mjs.map +1 -0
  6. package/dist/nhost-js/auth.cjs.js +1 -1
  7. package/dist/nhost-js/auth.cjs.js.map +1 -1
  8. package/dist/nhost-js/auth.es.js +48 -0
  9. package/dist/nhost-js/auth.es.js.map +1 -1
  10. package/dist/nhost-js/fetch.cjs.js +1 -1
  11. package/dist/nhost-js/fetch.cjs.js.map +1 -1
  12. package/dist/nhost-js/fetch.es.js +19 -79
  13. package/dist/nhost-js/fetch.es.js.map +1 -1
  14. package/dist/nhost-js/functions.cjs.js +1 -1
  15. package/dist/nhost-js/functions.cjs.js.map +1 -1
  16. package/dist/nhost-js/functions.es.js +7 -2
  17. package/dist/nhost-js/functions.es.js.map +1 -1
  18. package/dist/nhost-js/graphql.cjs.js +1 -1
  19. package/dist/nhost-js/graphql.cjs.js.map +1 -1
  20. package/dist/nhost-js/graphql.es.js +7 -2
  21. package/dist/nhost-js/graphql.es.js.map +1 -1
  22. package/dist/nhost-js/session.es.js +1 -1
  23. package/dist/nhost-js/storage.cjs.js.map +1 -1
  24. package/dist/nhost-js/storage.es.js.map +1 -1
  25. package/dist/nhost-js.cjs.js +1 -1
  26. package/dist/nhost-js.cjs.js.map +1 -1
  27. package/dist/nhost-js.es.js +78 -65
  28. package/dist/nhost-js.es.js.map +1 -1
  29. package/dist/nhost-js.umd.js +1 -1
  30. package/dist/nhost-js.umd.js.map +1 -1
  31. package/dist/refreshSession-Bw715ZmX.js.map +1 -1
  32. package/dist/{refreshSession-WwGlzgtM.mjs → refreshSession-CG8GIEun.mjs} +5 -2
  33. package/dist/refreshSession-CG8GIEun.mjs.map +1 -0
  34. package/dist/src/auth/client.d.ts +72 -1
  35. package/dist/src/auth/client.d.ts.map +1 -1
  36. package/dist/src/auth/client.js +56 -0
  37. package/dist/src/auth/client.js.map +1 -1
  38. package/dist/src/fetch/index.d.ts +15 -0
  39. package/dist/src/fetch/index.d.ts.map +1 -1
  40. package/dist/src/fetch/index.js +15 -0
  41. package/dist/src/fetch/index.js.map +1 -1
  42. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +1 -1
  43. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js.map +1 -1
  44. package/dist/src/fetch/middlewareWithAdminSession.d.ts +87 -0
  45. package/dist/src/fetch/middlewareWithAdminSession.d.ts.map +1 -0
  46. package/dist/src/fetch/middlewareWithAdminSession.js +79 -0
  47. package/dist/src/fetch/middlewareWithAdminSession.js.map +1 -0
  48. package/dist/src/fetch/middlewareWithHeaders.d.ts +23 -0
  49. package/dist/src/fetch/middlewareWithHeaders.d.ts.map +1 -0
  50. package/dist/src/fetch/middlewareWithHeaders.js +31 -0
  51. package/dist/src/fetch/middlewareWithHeaders.js.map +1 -0
  52. package/dist/src/fetch/middlewareWithRole.d.ts +44 -0
  53. package/dist/src/fetch/middlewareWithRole.d.ts.map +1 -0
  54. package/dist/src/fetch/middlewareWithRole.js +50 -0
  55. package/dist/src/fetch/middlewareWithRole.js.map +1 -0
  56. package/dist/src/functions/client.d.ts +6 -1
  57. package/dist/src/functions/client.d.ts.map +1 -1
  58. package/dist/src/functions/client.js +6 -1
  59. package/dist/src/functions/client.js.map +1 -1
  60. package/dist/src/graphql/client.d.ts +4 -0
  61. package/dist/src/graphql/client.d.ts.map +1 -1
  62. package/dist/src/graphql/client.js +6 -1
  63. package/dist/src/graphql/client.js.map +1 -1
  64. package/dist/src/index.d.ts +12 -2
  65. package/dist/src/index.d.ts.map +1 -1
  66. package/dist/src/index.js +12 -2
  67. package/dist/src/index.js.map +1 -1
  68. package/dist/src/nhost.d.ts +109 -0
  69. package/dist/src/nhost.d.ts.map +1 -1
  70. package/dist/src/nhost.js +167 -49
  71. package/dist/src/nhost.js.map +1 -1
  72. package/dist/src/session/refreshSession.d.ts.map +1 -1
  73. package/dist/src/session/refreshSession.js +3 -1
  74. package/dist/src/session/refreshSession.js.map +1 -1
  75. package/dist/src/storage/client.d.ts +3 -0
  76. package/dist/src/storage/client.d.ts.map +1 -1
  77. package/dist/src/storage/client.js.map +1 -1
  78. package/dist/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +2 -2
  80. package/dist/refreshSession-WwGlzgtM.mjs.map +0 -1
@@ -434,6 +434,28 @@ const createAPIClient = (baseURL, chainFunctions = []) => {
434
434
  const url = encodedParameters ? `${baseURL}/signin/provider/${provider}?${encodedParameters}` : `${baseURL}/signin/provider/${provider}`;
435
435
  return url;
436
436
  };
437
+ const getProviderTokens = async (provider, options) => {
438
+ const url = `${baseURL}/signin/provider/${provider}/callback/tokens`;
439
+ const res = await fetch(url, {
440
+ ...options,
441
+ method: "GET",
442
+ headers: {
443
+ ...options?.headers
444
+ }
445
+ });
446
+ if (res.status >= 300) {
447
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
448
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
449
+ throw new FetchError(payload2, res.status, res.headers);
450
+ }
451
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
452
+ const payload = responseBody ? JSON.parse(responseBody) : {};
453
+ return {
454
+ body: payload,
455
+ status: res.status,
456
+ headers: res.headers
457
+ };
458
+ };
437
459
  const signInWebauthn = async (body, options) => {
438
460
  const url = `${baseURL}/signin/webauthn`;
439
461
  const res = await fetch(url, {
@@ -602,6 +624,30 @@ const createAPIClient = (baseURL, chainFunctions = []) => {
602
624
  headers: res.headers
603
625
  };
604
626
  };
627
+ const refreshProviderToken = async (provider, body, options) => {
628
+ const url = `${baseURL}/token/provider/${provider}`;
629
+ const res = await fetch(url, {
630
+ ...options,
631
+ method: "POST",
632
+ headers: {
633
+ "Content-Type": "application/json",
634
+ ...options?.headers
635
+ },
636
+ body: JSON.stringify(body)
637
+ });
638
+ if (res.status >= 300) {
639
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
640
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
641
+ throw new FetchError(payload2, res.status, res.headers);
642
+ }
643
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
644
+ const payload = responseBody ? JSON.parse(responseBody) : {};
645
+ return {
646
+ body: payload,
647
+ status: res.status,
648
+ headers: res.headers
649
+ };
650
+ };
605
651
  const verifyToken = async (body, options) => {
606
652
  const url = `${baseURL}/token/verify`;
607
653
  const res = await fetch(url, {
@@ -890,6 +936,7 @@ const createAPIClient = (baseURL, chainFunctions = []) => {
890
936
  verifySignInPasswordlessSms,
891
937
  signInPAT,
892
938
  signInProviderURL,
939
+ getProviderTokens,
893
940
  signInWebauthn,
894
941
  verifySignInWebauthn,
895
942
  signOut,
@@ -897,6 +944,7 @@ const createAPIClient = (baseURL, chainFunctions = []) => {
897
944
  signUpWebauthn,
898
945
  verifySignUpWebauthn,
899
946
  refreshToken,
947
+ refreshProviderToken,
900
948
  verifyToken,
901
949
  getUser,
902
950
  deanonymizeUser,