@leisuresaas/react-native 0.6.2 → 0.6.3-dev.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leisuresaas/react-native",
3
- "version": "0.6.2",
3
+ "version": "0.6.3-dev.2",
4
4
  "description": "React Native SDK for LeisureSaas: OAuth, Public Ads/App Config, Drive User Plane (publishable keys). Frontend-only — no Integration Key.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/index.ts CHANGED
@@ -70,19 +70,31 @@ export {
70
70
  } from "./hosted-ui-link";
71
71
  export {
72
72
  bindPlatformAccount,
73
+ changePassword,
73
74
  changeProductPassword,
75
+ confirmEmailVerification,
76
+ confirmPasswordReset,
77
+ confirmProductEmailVerification,
78
+ confirmProductPasswordReset,
79
+ deleteAccount,
74
80
  deleteProductAccount,
81
+ login,
75
82
  loginProductAccount,
76
83
  loginWithPlatformAccount,
84
+ logout,
77
85
  logoutProductAccount,
78
86
  refreshProductSession,
87
+ refreshSession,
88
+ register,
79
89
  registerProductAccount,
90
+ requestEmailVerification,
91
+ requestPasswordReset,
80
92
  requestProductEmailVerification,
81
93
  requestProductPasswordReset,
82
94
  startPlatformAuthorize,
83
95
  unbindPlatformAccount,
84
96
  } from "./public-auth";
85
- export type { ProductAuthTokens, PublicAuthContext } from "./public-auth";
97
+ export type { AuthTokens, ProductAuthTokens, PublicAuthContext } from "./public-auth";
86
98
  export { getPublicAdsFeed, recordPublicAdEvents } from "./public-ads";
87
99
  export type { PublicAdsRequestContext } from "./public-ads";
88
100
  export { getPublicAppConfig } from "./public-app-config";
@@ -17,7 +17,7 @@ export type PublicAuthContext = {
17
17
  origin?: string;
18
18
  };
19
19
 
20
- export type ProductAuthTokens = {
20
+ export type AuthTokens = {
21
21
  accessToken: string;
22
22
  refreshToken: string;
23
23
  accessExpiresAtUnix: number;
@@ -84,7 +84,7 @@ async function publicAuthRequest<T>(
84
84
  return JSON.parse(text) as T;
85
85
  }
86
86
 
87
- function tokensFromJSON(data: TokenJSON): ProductAuthTokens {
87
+ function tokensFromJSON(data: TokenJSON): AuthTokens {
88
88
  const accessToken = data.access_token?.trim() ?? "";
89
89
  if (!accessToken) {
90
90
  throw new LeisureSaasHttpError(502, "missing access_token");
@@ -99,7 +99,7 @@ function tokensFromJSON(data: TokenJSON): ProductAuthTokens {
99
99
  };
100
100
  }
101
101
 
102
- export async function registerProductAccount(
102
+ export async function register(
103
103
  ctx: PublicAuthContext,
104
104
  input: { email: string; password: string; name?: string; locale?: string },
105
105
  ): Promise<{ verificationRequired: boolean }> {
@@ -109,36 +109,48 @@ export async function registerProductAccount(
109
109
  return { verificationRequired: resp.verification_required !== false };
110
110
  }
111
111
 
112
- export async function loginProductAccount(
112
+ export async function login(
113
113
  ctx: PublicAuthContext,
114
114
  input: { email: string; password: string; locale?: string },
115
- ): Promise<ProductAuthTokens> {
115
+ ): Promise<AuthTokens> {
116
116
  const resp = await publicAuthRequest<TokenJSON>(ctx, "/login", {
117
117
  email: input.email, password: input.password, locale: input.locale ?? "",
118
118
  });
119
119
  return tokensFromJSON(resp);
120
120
  }
121
121
 
122
- export async function refreshProductSession(ctx: PublicAuthContext, refreshToken: string): Promise<ProductAuthTokens> {
122
+ export async function refreshSession(ctx: PublicAuthContext, refreshToken: string): Promise<AuthTokens> {
123
123
  const resp = await publicAuthRequest<TokenJSON>(ctx, "/refresh", { refresh_token: refreshToken });
124
124
  return tokensFromJSON(resp);
125
125
  }
126
126
 
127
- export async function requestProductPasswordReset(
127
+ export async function requestPasswordReset(
128
128
  ctx: PublicAuthContext,
129
129
  input: { email: string; locale?: string },
130
130
  ): Promise<void> {
131
131
  await publicAuthRequest(ctx, "/password-reset", { email: input.email, locale: input.locale ?? "" });
132
132
  }
133
133
 
134
- export async function requestProductEmailVerification(
134
+ export async function requestEmailVerification(
135
135
  ctx: PublicAuthContext,
136
136
  input: { email: string; locale?: string },
137
137
  ): Promise<void> {
138
138
  await publicAuthRequest(ctx, "/email-verification", { email: input.email, locale: input.locale ?? "" });
139
139
  }
140
140
 
141
- export async function changeProductPassword(
141
+ export async function confirmEmailVerification(ctx: PublicAuthContext, token: string): Promise<AuthTokens> {
142
+ const resp = await publicAuthRequest<TokenJSON>(ctx, "/email-verification/confirm", { token });
143
+ return tokensFromJSON(resp);
144
+ }
145
+
146
+ export async function confirmPasswordReset(
147
+ ctx: PublicAuthContext,
148
+ input: { token: string; newPassword: string },
149
+ ): Promise<void> {
150
+ await publicAuthRequest(ctx, "/password-reset/confirm", { token: input.token, new_password: input.newPassword });
151
+ }
152
+
153
+ export async function changePassword(
142
154
  ctx: PublicAuthContext,
143
155
  accessToken: string,
144
156
  input: { currentPassword: string; newPassword: string },
@@ -148,7 +160,7 @@ export async function changeProductPassword(
148
160
  }, accessToken);
149
161
  }
150
162
 
151
- export async function logoutProductAccount(
163
+ export async function logout(
152
164
  ctx: PublicAuthContext,
153
165
  accessToken: string,
154
166
  refreshToken?: string,
@@ -156,7 +168,7 @@ export async function logoutProductAccount(
156
168
  await publicAuthRequest(ctx, "/logout", { refresh_token: refreshToken ?? "" }, accessToken);
157
169
  }
158
170
 
159
- export async function deleteProductAccount(ctx: PublicAuthContext, accessToken: string): Promise<void> {
171
+ export async function deleteAccount(ctx: PublicAuthContext, accessToken: string): Promise<void> {
160
172
  await publicAuthRequest(ctx, "/account/delete", {}, accessToken);
161
173
  }
162
174
 
@@ -190,11 +202,34 @@ export async function unbindPlatformAccount(ctx: PublicAuthContext, accessToken:
190
202
  await publicAuthRequest(ctx, "/unbind", {}, accessToken);
191
203
  }
192
204
 
205
+ /** @deprecated Use AuthTokens. */
206
+ export type ProductAuthTokens = AuthTokens;
207
+ /** @deprecated Use register. */
208
+ export const registerProductAccount = register;
209
+ /** @deprecated Use login. */
210
+ export const loginProductAccount = login;
211
+ /** @deprecated Use logout. */
212
+ export const logoutProductAccount = logout;
213
+ /** @deprecated Use refreshSession. */
214
+ export const refreshProductSession = refreshSession;
215
+ /** @deprecated Use deleteAccount. */
216
+ export const deleteProductAccount = deleteAccount;
217
+ /** @deprecated Use changePassword. */
218
+ export const changeProductPassword = changePassword;
219
+ /** @deprecated Use requestPasswordReset. */
220
+ export const requestProductPasswordReset = requestPasswordReset;
221
+ /** @deprecated Use confirmPasswordReset. */
222
+ export const confirmProductPasswordReset = confirmPasswordReset;
223
+ /** @deprecated Use requestEmailVerification. */
224
+ export const requestProductEmailVerification = requestEmailVerification;
225
+ /** @deprecated Use confirmEmailVerification. */
226
+ export const confirmProductEmailVerification = confirmEmailVerification;
227
+
193
228
  /** Opens the platform hosted login and returns a product-pool token. */
194
229
  export async function loginWithPlatformAccount(
195
230
  ctx: PublicAuthContext,
196
231
  input: { redirectUri: string; state?: string },
197
- ): Promise<ProductAuthTokens> {
232
+ ): Promise<AuthTokens> {
198
233
  const request = new AuthSession.AuthRequest({
199
234
  clientId: "publishable",
200
235
  redirectUri: input.redirectUri,