@authara/react-native 0.1.1 → 0.2.1
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/README.md +20 -0
- package/dist/buttons.d.ts +1 -0
- package/dist/buttons.js +2 -2
- package/dist/client.d.ts +2 -0
- package/dist/client.js +4 -0
- package/dist/nitro-google-signin.js +2 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -50,6 +50,26 @@ then each request retries once with `Authorization: Bearer …`.
|
|
|
50
50
|
`baseUrl` must use HTTPS. Local development can explicitly opt in to HTTP with
|
|
51
51
|
`allowInsecureHttp: true`; never enable it in production.
|
|
52
52
|
|
|
53
|
+
### Application API clients
|
|
54
|
+
|
|
55
|
+
An application with its own authenticated API can read the current in-memory
|
|
56
|
+
access token without taking ownership of Authara's token lifecycle. Subscribe
|
|
57
|
+
to session changes to synchronize the application's transport, and ask Authara
|
|
58
|
+
to rotate the token after that API returns 401:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const unsubscribe = authara.subscribe(() => {
|
|
62
|
+
appApi.setAccessToken(authara.getAccessToken());
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
appApi.setRefreshHandler(() => authara.refreshAccessToken());
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`refreshAccessToken()` shares concurrent rotation work and returns the current
|
|
69
|
+
access token or `null`. Refresh tokens remain private and persisted only through
|
|
70
|
+
the configured `AutharaTokenStorage`. Unsubscribe when the application bridge
|
|
71
|
+
is disposed.
|
|
72
|
+
|
|
53
73
|
## Native provider adapters
|
|
54
74
|
|
|
55
75
|
Authara accepts small adapters so applications can control their native setup,
|
package/dist/buttons.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface GoogleButtonVisualProps extends AutharaButtonVisualProps {
|
|
|
28
28
|
border?: boolean;
|
|
29
29
|
shape?: "pill" | "circle" | "square" | "rectangular";
|
|
30
30
|
logoAlignment?: "left" | "center";
|
|
31
|
+
onCancel?: () => void;
|
|
31
32
|
}
|
|
32
33
|
export interface AppleButtonVisualProps extends AutharaButtonVisualProps {
|
|
33
34
|
locale?: string;
|
package/dist/buttons.js
CHANGED
|
@@ -99,12 +99,12 @@ function ProviderButton({ provider, providerLabel, action, audience, authenticat
|
|
|
99
99
|
}
|
|
100
100
|
export function GoogleButton(props) {
|
|
101
101
|
const internal = props;
|
|
102
|
-
const { action = "login", audience, authenticationChallengeId, recoveryLinkId, onSuccess, onError, variant = "text", size = "large", label = action === "login" ? "sign-in" : "continue", mode = "light", theme, border, shape = "rectangular", logoAlignment = "center", buttonText, width, locale, ...buttonProps } = internal;
|
|
102
|
+
const { action = "login", audience, authenticationChallengeId, recoveryLinkId, onSuccess, onError, onCancel, variant = "text", size = "large", label = action === "login" ? "sign-in" : "continue", mode = "light", theme, border, shape = "rectangular", logoAlignment = "center", buttonText, width, locale, ...buttonProps } = internal;
|
|
103
103
|
void locale;
|
|
104
104
|
const resolvedMode = useResolvedColorMode(mode);
|
|
105
105
|
const visibleLabel = buttonText ??
|
|
106
106
|
(variant === "provider" ? "Google" : autharaButtonLabel(label, "Google"));
|
|
107
|
-
return (_jsx(ProviderButton, { ...buttonProps, provider: "google", providerLabel: "Google", action: action, audience: audience, authenticationChallengeId: authenticationChallengeId, recoveryLinkId: recoveryLinkId, onSuccess: onSuccess, onError: onError, variant: variant, label: visibleLabel, appearance: googleButtonAppearance({
|
|
107
|
+
return (_jsx(ProviderButton, { ...buttonProps, provider: "google", providerLabel: "Google", action: action, audience: audience, authenticationChallengeId: authenticationChallengeId, recoveryLinkId: recoveryLinkId, onSuccess: onSuccess, onError: onError, onCancel: onCancel, variant: variant, label: visibleLabel, appearance: googleButtonAppearance({
|
|
108
108
|
variant,
|
|
109
109
|
size,
|
|
110
110
|
width,
|
package/dist/client.d.ts
CHANGED
|
@@ -46,10 +46,12 @@ export declare class AutharaClient {
|
|
|
46
46
|
private readonly listeners;
|
|
47
47
|
constructor(options: AutharaClientOptions);
|
|
48
48
|
getSessionSnapshot: () => AutharaSessionSnapshot;
|
|
49
|
+
getAccessToken: () => string | null;
|
|
49
50
|
subscribe: (listener: () => void) => (() => void);
|
|
50
51
|
protected setCurrentUser(user: AuthUser | null): void;
|
|
51
52
|
protected restoreTokens(): Promise<boolean>;
|
|
52
53
|
signOut(): Promise<void>;
|
|
54
|
+
refreshAccessToken(): Promise<string | null>;
|
|
53
55
|
protected request<T>(method: string, path: string, options?: {
|
|
54
56
|
query?: Record<string, QueryValue | undefined>;
|
|
55
57
|
body?: unknown;
|
package/dist/client.js
CHANGED
|
@@ -37,6 +37,7 @@ export class AutharaClient {
|
|
|
37
37
|
this.fetchImpl = fetchImpl;
|
|
38
38
|
}
|
|
39
39
|
getSessionSnapshot = () => this.snapshot;
|
|
40
|
+
getAccessToken = () => this.accessToken;
|
|
40
41
|
subscribe = (listener) => {
|
|
41
42
|
this.listeners.add(listener);
|
|
42
43
|
return () => this.listeners.delete(listener);
|
|
@@ -94,6 +95,9 @@ export class AutharaClient {
|
|
|
94
95
|
await this.removeStoredRefreshToken(generation);
|
|
95
96
|
}
|
|
96
97
|
}
|
|
98
|
+
async refreshAccessToken() {
|
|
99
|
+
return (await this.refresh()) ? this.accessToken : null;
|
|
100
|
+
}
|
|
97
101
|
async request(method, path, options = {}) {
|
|
98
102
|
let generation = this.sessionGeneration;
|
|
99
103
|
const query = { ...options.query };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GoogleOneTapSignIn, isCancelledResponse, isSuccessResponse, } from "react-native-nitro-google-signin";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
|
+
import { AutharaProviderCancellationError } from "./button-error.js";
|
|
3
4
|
export function createNitroGoogleSignIn(config = {}) {
|
|
4
5
|
return {
|
|
5
6
|
async authorize(options) {
|
|
@@ -15,7 +16,7 @@ export function createNitroGoogleSignIn(config = {}) {
|
|
|
15
16
|
await GoogleOneTapSignIn.checkPlayServices(true);
|
|
16
17
|
const response = await GoogleOneTapSignIn.presentExplicitSignIn();
|
|
17
18
|
if (isCancelledResponse(response)) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new AutharaProviderCancellationError("Google");
|
|
19
20
|
}
|
|
20
21
|
if (!isSuccessResponse(response) || !response.data.idToken) {
|
|
21
22
|
throw new Error("Google did not return an ID token");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authara/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Official React Native client, hooks, and native-provider buttons for Authara",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"prepublishOnly": "npm run check:generated && npm run build"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"expo-apple-authentication": ">=7 <9",
|
|
74
|
-
"expo-auth-session": ">=6 <8",
|
|
75
|
-
"expo-secure-store": ">=14 <16",
|
|
73
|
+
"expo-apple-authentication": ">=7 <9 || >=56 <58",
|
|
74
|
+
"expo-auth-session": ">=6 <8 || >=56 <58",
|
|
75
|
+
"expo-secure-store": ">=14 <16 || >=56 <58",
|
|
76
76
|
"react": "^18.0.0 || ^19.0.0",
|
|
77
77
|
"react-native": ">=0.76",
|
|
78
78
|
"react-native-nitro-google-signin": ">=2 <3",
|