prostgles-client 4.0.200 → 4.0.202

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/Auth.d.ts CHANGED
@@ -34,6 +34,61 @@ type AuthStateLoggedIn = LoginSignupOptions & {
34
34
  };
35
35
  export type AuthHandler = AuthStateLoggedOut | AuthStateLoggedIn;
36
36
  export declare const setupAuth: ({ authData: authConfig, socket, onReload }: Args) => AuthHandler;
37
- export declare const postAuthData: (path: string, data: object) => Promise<any>;
37
+ export declare const authRequest: <T extends (import("prostgles-types").CommonAuthFailure & {
38
+ /**
39
+ * This is a client-only property that is obtained from server redirect response
40
+ */
41
+ redirect_url?: string | undefined;
42
+ }) | ({
43
+ success: false;
44
+ code: "no-match";
45
+ message?: string | undefined;
46
+ } & {
47
+ /**
48
+ * This is a client-only property that is obtained from server redirect response
49
+ */
50
+ redirect_url?: string | undefined;
51
+ }) | ({
52
+ success: false;
53
+ code: "inactive-account";
54
+ message?: string | undefined;
55
+ } & {
56
+ /**
57
+ * This is a client-only property that is obtained from server redirect response
58
+ */
59
+ redirect_url?: string | undefined;
60
+ }) | ({
61
+ success: false;
62
+ code: "totp-token-missing" | "invalid-username" | "username-missing" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
63
+ message?: string | undefined;
64
+ } & {
65
+ /**
66
+ * This is a client-only property that is obtained from server redirect response
67
+ */
68
+ redirect_url?: string | undefined;
69
+ }) | (AuthResponse.AuthSuccess & {
70
+ /**
71
+ * This is a client-only property that is obtained from server redirect response
72
+ */
73
+ redirect_url?: string | undefined;
74
+ }) | ({
75
+ success: false;
76
+ code: "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
77
+ message?: string | undefined;
78
+ } & {
79
+ /**
80
+ * This is a client-only property that is obtained from server redirect response
81
+ */
82
+ redirect_url?: string | undefined;
83
+ }) | ({
84
+ success: false;
85
+ code: "provider-issue";
86
+ message?: string | undefined;
87
+ } & {
88
+ /**
89
+ * This is a client-only property that is obtained from server redirect response
90
+ */
91
+ redirect_url?: string | undefined;
92
+ })>(path: string, data: object, method?: "GET") => Promise<T>;
38
93
  export {};
39
94
  //# sourceMappingURL=Auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../lib/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAGT,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAIzB,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACvC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF,KAAK,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC;AAEzE,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CACjD,YAAY,CAAC,oBAAoB,GACjC,YAAY,CAAC,oBAAoB,GACjC,YAAY,CAAC,oBAAoB,GACjC,YAAY,CAAC,oBAAoB,GACjC,YAAY,CAAC,oBAAoB,GACjC,YAAY,CAAC,oBAAoB,CACpC,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CACtD,YAAY,CAAC,oBAAoB,GAAG,YAAY,CAAC,oBAAoB,CACtE,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,CAC7B,MAAM,EAAE,WAAW,CAAC,YAAY,KAC7B,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACvC,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,SAAS,KAAK,OAA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AAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAEjE,eAAO,MAAM,SAAS,+CAAgD,IAAI,KAAG,WAmF5E,CAAC;AAEF,eAAO,MAAM,WAAW;IAjItB;;OAEG;;;;;;;IAFH;;OAEG;;;;;;;IAFH;;OAEG;;;;;;;IAFH;;OAEG;;;IAFH;;OAEG;;;;;;;IAFH;;OAEG;;;;;;;IAFH;;OAEG;;UAgIG,MAAM,QACN,MAAM,WACH,KAAK,eAgCf,CAAC"}
package/dist/Auth.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.postAuthData = exports.setupAuth = void 0;
3
+ exports.authRequest = exports.setupAuth = void 0;
4
4
  const prostgles_types_1 = require("prostgles-types");
5
5
  const prostgles_1 = require("./prostgles");
6
6
  const setupAuth = ({ authData: authConfig, socket, onReload }) => {
@@ -50,12 +50,12 @@ const setupAuth = ({ authData: authConfig, socket, onReload }) => {
50
50
  loginSignupOptions.login =
51
51
  loginType &&
52
52
  (async (params) => {
53
- return (0, exports.postAuthData)(addSearchInCaseItHasReturnUrl("/login"), params);
53
+ return (0, exports.authRequest)(addSearchInCaseItHasReturnUrl("/login"), params);
54
54
  });
55
55
  loginSignupOptions.signupWithEmailAndPassword =
56
56
  signupWithEmailAndPassword &&
57
57
  ((params) => {
58
- return (0, exports.postAuthData)(addSearchInCaseItHasReturnUrl(signupWithEmailAndPassword.url), params);
58
+ return (0, exports.authRequest)(addSearchInCaseItHasReturnUrl(signupWithEmailAndPassword.url), params);
59
59
  });
60
60
  }
61
61
  if (!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.user)) {
@@ -75,14 +75,14 @@ const setupAuth = ({ authData: authConfig, socket, onReload }) => {
75
75
  };
76
76
  };
77
77
  exports.setupAuth = setupAuth;
78
- const postAuthData = async (path, data) => {
78
+ const authRequest = async (path, data, method) => {
79
79
  const rawResponse = await fetch(path, {
80
- method: "POST",
80
+ method: method !== null && method !== void 0 ? method : "POST",
81
81
  headers: {
82
82
  Accept: "application/json",
83
83
  "Content-Type": "application/json",
84
84
  },
85
- body: JSON.stringify(data),
85
+ ...(method !== "GET" && { body: JSON.stringify(data) }),
86
86
  });
87
87
  if (!rawResponse.ok) {
88
88
  const error = await rawResponse
@@ -103,4 +103,4 @@ const postAuthData = async (path, data) => {
103
103
  }
104
104
  return responseObject;
105
105
  };
106
- exports.postAuthData = postAuthData;
106
+ exports.authRequest = authRequest;