@authyo/auth-js
v1.0.1
Published
Authyo passwordless authentication SDK for web apps (TypeScript).
Maintainers
Readme
@authyo/auth-js
Authyo passwordless authentication SDK for web apps (TypeScript). Wraps the Authyo REST endpoints with a small, typed client.
Install
npm install @authyo/auth-js
# or
yarn add @authyo/auth-jsQuick start
import { AuthyoClient, AuthMethod } from "@authyo/auth-js";
const authyo = new AuthyoClient({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
baseUrl: "https://app.authyo.io" // optional, defaults to this
});
// Send OTP
await authyo.sendOtp({
to: "[email protected]",
authWay: "Email" satisfies AuthMethod,
otpLength: 6
});
// Verify OTP
const verified = await authyo.verifyOtp("123456", "MASK_ID_FROM_SEND");
// Verify token
const tokenResult = await authyo.verifyToken("JWT_OR_TOKEN");
// Revoke session
await authyo.revokeSession("JWT_OR_TOKEN");API
All methods include clientId and clientSecret in headers.
getConfiguration()— GET/api/v1/user/getappcustomizationsendOtp({ to, authWay, otpLength, expiry, deviceInfo })— POST/api/v1/auth/sendotpverifyOtp(otp, maskId)— GET/api/v1/auth/verifyotpverifyToken(token)— POST/api/v1/auth/verifytokenrevokeSession(token)— POST/api/v1/auth/revokesession
Notes
- Runs in browsers (uses
fetchandwindowfor device info). For Node, ensurefetchis available (Node 18+ or a polyfill). - Do not bundle
clientSecretinto public assets you cannot control; keep it server-side when possible.
Build
npm run build— emits ESM and types todist/- Output is tree-shakeable (
sideEffects: false)
License
MIT
