@leisuresaas/react-native 0.6.3-dev.1 → 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 +1 -1
- package/src/index.ts +13 -3
- package/src/public-auth.ts +37 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leisuresaas/react-native",
|
|
3
|
-
"version": "0.6.3-dev.
|
|
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,21 +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,
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
requestEmailVerification,
|
|
91
|
+
requestPasswordReset,
|
|
82
92
|
requestProductEmailVerification,
|
|
83
93
|
requestProductPasswordReset,
|
|
84
94
|
startPlatformAuthorize,
|
|
85
95
|
unbindPlatformAccount,
|
|
86
96
|
} from "./public-auth";
|
|
87
|
-
export type { ProductAuthTokens, PublicAuthContext } from "./public-auth";
|
|
97
|
+
export type { AuthTokens, ProductAuthTokens, PublicAuthContext } from "./public-auth";
|
|
88
98
|
export { getPublicAdsFeed, recordPublicAdEvents } from "./public-ads";
|
|
89
99
|
export type { PublicAdsRequestContext } from "./public-ads";
|
|
90
100
|
export { getPublicAppConfig } from "./public-app-config";
|
package/src/public-auth.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type PublicAuthContext = {
|
|
|
17
17
|
origin?: string;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type
|
|
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):
|
|
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
|
|
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,48 @@ export async function registerProductAccount(
|
|
|
109
109
|
return { verificationRequired: resp.verification_required !== false };
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export async function
|
|
112
|
+
export async function login(
|
|
113
113
|
ctx: PublicAuthContext,
|
|
114
114
|
input: { email: string; password: string; locale?: string },
|
|
115
|
-
): Promise<
|
|
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
|
|
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
|
|
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
|
|
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
|
|
141
|
+
export async function confirmEmailVerification(ctx: PublicAuthContext, token: string): Promise<AuthTokens> {
|
|
142
142
|
const resp = await publicAuthRequest<TokenJSON>(ctx, "/email-verification/confirm", { token });
|
|
143
143
|
return tokensFromJSON(resp);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
export async function
|
|
146
|
+
export async function confirmPasswordReset(
|
|
147
147
|
ctx: PublicAuthContext,
|
|
148
148
|
input: { token: string; newPassword: string },
|
|
149
149
|
): Promise<void> {
|
|
150
150
|
await publicAuthRequest(ctx, "/password-reset/confirm", { token: input.token, new_password: input.newPassword });
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
export async function
|
|
153
|
+
export async function changePassword(
|
|
154
154
|
ctx: PublicAuthContext,
|
|
155
155
|
accessToken: string,
|
|
156
156
|
input: { currentPassword: string; newPassword: string },
|
|
@@ -160,7 +160,7 @@ export async function changeProductPassword(
|
|
|
160
160
|
}, accessToken);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export async function
|
|
163
|
+
export async function logout(
|
|
164
164
|
ctx: PublicAuthContext,
|
|
165
165
|
accessToken: string,
|
|
166
166
|
refreshToken?: string,
|
|
@@ -168,7 +168,7 @@ export async function logoutProductAccount(
|
|
|
168
168
|
await publicAuthRequest(ctx, "/logout", { refresh_token: refreshToken ?? "" }, accessToken);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
export async function
|
|
171
|
+
export async function deleteAccount(ctx: PublicAuthContext, accessToken: string): Promise<void> {
|
|
172
172
|
await publicAuthRequest(ctx, "/account/delete", {}, accessToken);
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -202,11 +202,34 @@ export async function unbindPlatformAccount(ctx: PublicAuthContext, accessToken:
|
|
|
202
202
|
await publicAuthRequest(ctx, "/unbind", {}, accessToken);
|
|
203
203
|
}
|
|
204
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
|
+
|
|
205
228
|
/** Opens the platform hosted login and returns a product-pool token. */
|
|
206
229
|
export async function loginWithPlatformAccount(
|
|
207
230
|
ctx: PublicAuthContext,
|
|
208
231
|
input: { redirectUri: string; state?: string },
|
|
209
|
-
): Promise<
|
|
232
|
+
): Promise<AuthTokens> {
|
|
210
233
|
const request = new AuthSession.AuthRequest({
|
|
211
234
|
clientId: "publishable",
|
|
212
235
|
redirectUri: input.redirectUri,
|