@authress/login-react-native 0.0.0 → 0.1.7
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 +2 -2
- package/src/loginClient.ts +16 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authress/login-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Authress authentication SDK for React Native. Implements the full OAuth 2.0+ flow with native mobile storage and deep link handling for iOS and Android.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "git+https://github.com/Authress/
|
|
41
|
+
"url": "git+https://github.com/Authress/login-react-native"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"authentication",
|
package/src/loginClient.ts
CHANGED
|
@@ -43,12 +43,12 @@ export class LoginClient {
|
|
|
43
43
|
authStorageManager.restoreCookies(this.settings.authressApiUrl);
|
|
44
44
|
|
|
45
45
|
// Automatically handle deep link callbacks — no Linking boilerplate needed in app code
|
|
46
|
-
Linking.addEventListener('url', ({ url }) => {
|
|
46
|
+
Linking.addEventListener('url', async ({ url }) => {
|
|
47
47
|
if (!url.startsWith(this.settings.redirectUri)) { return; }
|
|
48
48
|
const parsed = new URL(url);
|
|
49
49
|
const code = parsed.searchParams.get('code') ?? '';
|
|
50
50
|
const authenticationRequestId = parsed.searchParams.get('authenticationRequestId') ?? '';
|
|
51
|
-
this.completeAuthenticationRequest({ code, authenticationRequestId });
|
|
51
|
+
await this.completeAuthenticationRequest({ code, authenticationRequestId });
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -89,6 +89,7 @@ export class LoginClient {
|
|
|
89
89
|
private async _doSessionCheck(): Promise<boolean> {
|
|
90
90
|
const sessionResult = await this.httpClient.patch('/session', {});
|
|
91
91
|
if (sessionResult.isErr()) {
|
|
92
|
+
this.logger.warn({ title: '[Authress Login SDK] Session check result — user does not have an existing session', error: sessionResult.error });
|
|
92
93
|
return false;
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -162,6 +163,7 @@ export class LoginClient {
|
|
|
162
163
|
|
|
163
164
|
if (tokenResult.isErr()) {
|
|
164
165
|
const error = tokenResult.error;
|
|
166
|
+
this.logger?.log({ title: '[Authress Login SDK] completeAuthenticationRequest token exchange failed', params, error });
|
|
165
167
|
// already-used code — auth is done, clean up and return silently
|
|
166
168
|
if (error.name !== 'AuthressHttpNetworkError' && error.status < 500) {
|
|
167
169
|
return ok();
|
|
@@ -282,7 +284,10 @@ export class LoginClient {
|
|
|
282
284
|
if (payload.iss !== expectedOrigin) {return err(new NotLoggedInError());}
|
|
283
285
|
|
|
284
286
|
const profileResult = await this.httpClient.get<UserProfile>('/session/profile');
|
|
285
|
-
if (profileResult.isErr()) {
|
|
287
|
+
if (profileResult.isErr()) {
|
|
288
|
+
this.logger.error({ title: '[Authress Login SDK] Failed to fetch user profile', error: profileResult.error });
|
|
289
|
+
return profileResult;
|
|
290
|
+
}
|
|
286
291
|
|
|
287
292
|
return ok(profileResult.value.data);
|
|
288
293
|
}
|
|
@@ -320,7 +325,10 @@ export class LoginClient {
|
|
|
320
325
|
};
|
|
321
326
|
|
|
322
327
|
const postResult = await this.httpClient.post<{ authenticationUrl: string; authenticationRequestId: string }>('/authentication', body);
|
|
323
|
-
if (postResult.isErr()) {
|
|
328
|
+
if (postResult.isErr()) {
|
|
329
|
+
this.logger.error({ title: '[Authress Login SDK] Failed to start identity link', options, error: postResult.error });
|
|
330
|
+
return postResult;
|
|
331
|
+
}
|
|
324
332
|
|
|
325
333
|
const { authenticationUrl, authenticationRequestId } = postResult.value.data;
|
|
326
334
|
const pendingAuth: PendingAuthentication = {
|
|
@@ -365,7 +373,10 @@ export class LoginClient {
|
|
|
365
373
|
if (tokenResult.isErr()) { return err(new NotLoggedInError()); }
|
|
366
374
|
|
|
367
375
|
const result = await this.httpClient.delete(`/session/devices/${deviceId}`);
|
|
368
|
-
if (result.isErr()) {
|
|
376
|
+
if (result.isErr()) {
|
|
377
|
+
this.logger.warn({ title: '[Authress Login SDK] Failed to delete device', deviceId, error: result.error });
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
369
380
|
return ok();
|
|
370
381
|
}
|
|
371
382
|
}
|