@leisuresaas/react-native 0.6.3-dev.1 → 0.6.3-dev.3

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.3-dev.1",
3
+ "version": "0.6.3-dev.3",
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,21 +70,33 @@ 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,
83
+ loginWithApple,
84
+ loginWithGoogle,
76
85
  loginWithPlatformAccount,
86
+ logout,
77
87
  logoutProductAccount,
78
88
  refreshProductSession,
89
+ refreshSession,
90
+ register,
79
91
  registerProductAccount,
80
- confirmProductEmailVerification,
81
- confirmProductPasswordReset,
92
+ requestEmailVerification,
93
+ requestPasswordReset,
82
94
  requestProductEmailVerification,
83
95
  requestProductPasswordReset,
84
96
  startPlatformAuthorize,
85
97
  unbindPlatformAccount,
86
98
  } from "./public-auth";
87
- export type { ProductAuthTokens, PublicAuthContext } from "./public-auth";
99
+ export type { AuthTokens, ProductAuthTokens, PublicAuthContext } from "./public-auth";
88
100
  export { getPublicAdsFeed, recordPublicAdEvents } from "./public-ads";
89
101
  export type { PublicAdsRequestContext } from "./public-ads";
90
102
  export { getPublicAppConfig } from "./public-app-config";
@@ -40,6 +40,19 @@ export type AppConfigResponse = {
40
40
  recommended: boolean;
41
41
  reason: string;
42
42
  };
43
+ social_login?: {
44
+ google?: {
45
+ enabled?: boolean;
46
+ web_client_id?: string;
47
+ ios_client_id?: string;
48
+ android_client_ids?: string[];
49
+ };
50
+ apple?: {
51
+ enabled?: boolean;
52
+ services_id?: string;
53
+ bundle_ids?: string[];
54
+ };
55
+ };
43
56
  };
44
57
 
45
58
  function trimSlash(url: string): string {
@@ -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,48 +109,78 @@ 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 loginWithGoogle(
123
+ ctx: PublicAuthContext,
124
+ input: { idToken: string; password?: string; locale?: string },
125
+ ): Promise<AuthTokens> {
126
+ const resp = await publicAuthRequest<TokenJSON>(ctx, "/login/google", {
127
+ id_token: input.idToken, password: input.password ?? "", locale: input.locale ?? "",
128
+ });
129
+ return tokensFromJSON(resp);
130
+ }
131
+
132
+ export async function loginWithApple(
133
+ ctx: PublicAuthContext,
134
+ input: {
135
+ identityToken: string;
136
+ authorizationCode?: string;
137
+ fullName?: string;
138
+ password?: string;
139
+ locale?: string;
140
+ },
141
+ ): Promise<AuthTokens> {
142
+ const resp = await publicAuthRequest<TokenJSON>(ctx, "/login/apple", {
143
+ identity_token: input.identityToken,
144
+ authorization_code: input.authorizationCode ?? "",
145
+ full_name: input.fullName ?? "",
146
+ password: input.password ?? "",
147
+ locale: input.locale ?? "",
148
+ });
149
+ return tokensFromJSON(resp);
150
+ }
151
+
152
+ export async function refreshSession(ctx: PublicAuthContext, refreshToken: string): Promise<AuthTokens> {
123
153
  const resp = await publicAuthRequest<TokenJSON>(ctx, "/refresh", { refresh_token: refreshToken });
124
154
  return tokensFromJSON(resp);
125
155
  }
126
156
 
127
- export async function requestProductPasswordReset(
157
+ export async function requestPasswordReset(
128
158
  ctx: PublicAuthContext,
129
159
  input: { email: string; locale?: string },
130
160
  ): Promise<void> {
131
161
  await publicAuthRequest(ctx, "/password-reset", { email: input.email, locale: input.locale ?? "" });
132
162
  }
133
163
 
134
- export async function requestProductEmailVerification(
164
+ export async function requestEmailVerification(
135
165
  ctx: PublicAuthContext,
136
166
  input: { email: string; locale?: string },
137
167
  ): Promise<void> {
138
168
  await publicAuthRequest(ctx, "/email-verification", { email: input.email, locale: input.locale ?? "" });
139
169
  }
140
170
 
141
- export async function confirmProductEmailVerification(ctx: PublicAuthContext, token: string): Promise<ProductAuthTokens> {
171
+ export async function confirmEmailVerification(ctx: PublicAuthContext, token: string): Promise<AuthTokens> {
142
172
  const resp = await publicAuthRequest<TokenJSON>(ctx, "/email-verification/confirm", { token });
143
173
  return tokensFromJSON(resp);
144
174
  }
145
175
 
146
- export async function confirmProductPasswordReset(
176
+ export async function confirmPasswordReset(
147
177
  ctx: PublicAuthContext,
148
178
  input: { token: string; newPassword: string },
149
179
  ): Promise<void> {
150
180
  await publicAuthRequest(ctx, "/password-reset/confirm", { token: input.token, new_password: input.newPassword });
151
181
  }
152
182
 
153
- export async function changeProductPassword(
183
+ export async function changePassword(
154
184
  ctx: PublicAuthContext,
155
185
  accessToken: string,
156
186
  input: { currentPassword: string; newPassword: string },
@@ -160,7 +190,7 @@ export async function changeProductPassword(
160
190
  }, accessToken);
161
191
  }
162
192
 
163
- export async function logoutProductAccount(
193
+ export async function logout(
164
194
  ctx: PublicAuthContext,
165
195
  accessToken: string,
166
196
  refreshToken?: string,
@@ -168,7 +198,7 @@ export async function logoutProductAccount(
168
198
  await publicAuthRequest(ctx, "/logout", { refresh_token: refreshToken ?? "" }, accessToken);
169
199
  }
170
200
 
171
- export async function deleteProductAccount(ctx: PublicAuthContext, accessToken: string): Promise<void> {
201
+ export async function deleteAccount(ctx: PublicAuthContext, accessToken: string): Promise<void> {
172
202
  await publicAuthRequest(ctx, "/account/delete", {}, accessToken);
173
203
  }
174
204
 
@@ -202,11 +232,34 @@ export async function unbindPlatformAccount(ctx: PublicAuthContext, accessToken:
202
232
  await publicAuthRequest(ctx, "/unbind", {}, accessToken);
203
233
  }
204
234
 
235
+ /** @deprecated Use AuthTokens. */
236
+ export type ProductAuthTokens = AuthTokens;
237
+ /** @deprecated Use register. */
238
+ export const registerProductAccount = register;
239
+ /** @deprecated Use login. */
240
+ export const loginProductAccount = login;
241
+ /** @deprecated Use logout. */
242
+ export const logoutProductAccount = logout;
243
+ /** @deprecated Use refreshSession. */
244
+ export const refreshProductSession = refreshSession;
245
+ /** @deprecated Use deleteAccount. */
246
+ export const deleteProductAccount = deleteAccount;
247
+ /** @deprecated Use changePassword. */
248
+ export const changeProductPassword = changePassword;
249
+ /** @deprecated Use requestPasswordReset. */
250
+ export const requestProductPasswordReset = requestPasswordReset;
251
+ /** @deprecated Use confirmPasswordReset. */
252
+ export const confirmProductPasswordReset = confirmPasswordReset;
253
+ /** @deprecated Use requestEmailVerification. */
254
+ export const requestProductEmailVerification = requestEmailVerification;
255
+ /** @deprecated Use confirmEmailVerification. */
256
+ export const confirmProductEmailVerification = confirmEmailVerification;
257
+
205
258
  /** Opens the platform hosted login and returns a product-pool token. */
206
259
  export async function loginWithPlatformAccount(
207
260
  ctx: PublicAuthContext,
208
261
  input: { redirectUri: string; state?: string },
209
- ): Promise<ProductAuthTokens> {
262
+ ): Promise<AuthTokens> {
210
263
  const request = new AuthSession.AuthRequest({
211
264
  clientId: "publishable",
212
265
  redirectUri: input.redirectUri,