@synqauth/react-native 0.2.0 → 0.3.0
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 +1 -1
- package/dist/index.d.ts +22 -2
- package/dist/index.js +25 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Synq for React Native: sign-in through the system browser, with tokens in the de
|
|
|
4
4
|
|
|
5
5
|
Synq is customer identity for businesses: an OpenID Connect issuer for each of your brands, with Solana wallet, social, email and passkey sign-in. The documentation is at [docs.synq.build](https://docs.synq.build).
|
|
6
6
|
|
|
7
|
-
This package is at 0.x
|
|
7
|
+
This package is at 0.x, so a minor release can change its API: see its CHANGELOG.md.
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountClient, AuthorizationUrlOptions, ChallengeMethod, ChallengeProblem, DeniedReason, IdTokenClaims, RedirectReason, Session, StartSignInOptions, SynqClient, SynqError, SynqStorage } from "@synqauth/js";
|
|
1
|
+
import { AccountClient, AuthorizationUrlOptions, AvatarInfo, AvatarPerson, AvatarStyle, ChallengeMethod, ChallengeProblem, DeniedReason, IdTokenClaims, RedirectReason, Session, StartSignInOptions, SynqClient, SynqError, SynqStorage } from "@synqauth/js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
//#region src/storage.d.ts
|
|
4
4
|
/** The part of `expo-secure-store` the SDK uses: pass the module itself. */
|
|
@@ -128,6 +128,26 @@ interface UseUser {
|
|
|
128
128
|
}
|
|
129
129
|
/** Who is signed in, and their account. */
|
|
130
130
|
export declare function useUser(): UseUser;
|
|
131
|
+
/** What `useAvatar()` answers: what the avatar is drawn from, and Synq's own default as SVG. */
|
|
132
|
+
interface UseAvatar extends AvatarInfo {
|
|
133
|
+
/**
|
|
134
|
+
* Synq's own default for them, as SVG markup (`avatarSvg`): draw it with
|
|
135
|
+
* react-native-svg's `SvgXml`, clipped to a circle, where no picture of
|
|
136
|
+
* theirs or of the app's own shows.
|
|
137
|
+
*/
|
|
138
|
+
readonly svg: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* What the avatar of `user` is drawn from (AERO-2704): the signed-in person
|
|
142
|
+
* by default, from their ID token, or anyone as Synq names them (`id` and
|
|
143
|
+
* `username` from the management API work too). Show `picture` when its
|
|
144
|
+
* `source` is one the app shows; else the app's own art from `seed`
|
|
145
|
+
* (`defaultPick` over its set); else `defaultPicture`; else `svg`. Null
|
|
146
|
+
* while there is nobody.
|
|
147
|
+
*/
|
|
148
|
+
export declare function useAvatar(user?: AvatarPerson | null, options?: {
|
|
149
|
+
style?: AvatarStyle;
|
|
150
|
+
}): UseAvatar | null;
|
|
131
151
|
/** What `useAuth()` answers: signing in and out, each answering `{ data, error }`. */
|
|
132
152
|
interface UseAuth {
|
|
133
153
|
readonly isLoaded: boolean;
|
|
@@ -217,4 +237,4 @@ interface UseSignIn {
|
|
|
217
237
|
*/
|
|
218
238
|
export declare function useSignIn(options?: StartSignInOptions): UseSignIn;
|
|
219
239
|
//#endregion
|
|
220
|
-
export type { SecureStoreModule, SignInHandover, SignInProblem, SignInStep, SynqNative, SynqNativeOptions, SynqNativeProviderProps, SynqResult, UseAuth, UseSession, UseSignIn, UseUser, WebBrowserModule };
|
|
240
|
+
export type { SecureStoreModule, SignInHandover, SignInProblem, SignInStep, SynqNative, SynqNativeOptions, SynqNativeProviderProps, SynqResult, UseAuth, UseAvatar, UseSession, UseSignIn, UseUser, WebBrowserModule };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SynqError, accountApiUrl, createAccountClient, createSynqClient, isSynqError } from "@synqauth/js";
|
|
1
|
+
import { SynqError, accountApiUrl, avatarOf, avatarSvg, createAccountClient, createSynqClient, isSynqError } from "@synqauth/js";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/storage.ts
|
|
@@ -213,6 +213,29 @@ function useUser() {
|
|
|
213
213
|
account
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* What the avatar of `user` is drawn from (AERO-2704): the signed-in person
|
|
218
|
+
* by default, from their ID token, or anyone as Synq names them (`id` and
|
|
219
|
+
* `username` from the management API work too). Show `picture` when its
|
|
220
|
+
* `source` is one the app shows; else the app's own art from `seed`
|
|
221
|
+
* (`defaultPick` over its set); else `defaultPicture`; else `svg`. Null
|
|
222
|
+
* while there is nobody.
|
|
223
|
+
*/
|
|
224
|
+
function useAvatar(user, options = {}) {
|
|
225
|
+
const { state } = useSynq();
|
|
226
|
+
const person = user ?? state.session?.claims ?? null;
|
|
227
|
+
return useMemo(() => {
|
|
228
|
+
if (!person) return null;
|
|
229
|
+
const avatar = avatarOf(person);
|
|
230
|
+
return {
|
|
231
|
+
...avatar,
|
|
232
|
+
svg: avatarSvg(avatar.seed, {
|
|
233
|
+
style: options.style,
|
|
234
|
+
initials: avatar.initials
|
|
235
|
+
})
|
|
236
|
+
};
|
|
237
|
+
}, [person, options.style]);
|
|
238
|
+
}
|
|
216
239
|
/** Signing in and out. */
|
|
217
240
|
function useAuth() {
|
|
218
241
|
const { synq, state } = useSynq();
|
|
@@ -407,4 +430,4 @@ function useSignIn(options = {}) {
|
|
|
407
430
|
};
|
|
408
431
|
}
|
|
409
432
|
//#endregion
|
|
410
|
-
export { CHUNK_SIZE, SynqNativeProvider, createSynqNative, secureStorage, useAuth, useSession, useSignIn, useUser };
|
|
433
|
+
export { CHUNK_SIZE, SynqNativeProvider, createSynqNative, secureStorage, useAuth, useAvatar, useSession, useSignIn, useUser };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synqauth/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Synq for React Native: sign-in through the system browser, with tokens in the device's secure storage.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@synqauth/js": "0.
|
|
30
|
+
"@synqauth/js": "0.3.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=19.0.0"
|