
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@arcana/auth
Advanced tools
Arcana SDK to perform logins on your app.
npm install --save @arcana/auth
yarn add @arcana/auth
<script src="https://cdn.jsdelivr.net/npm/@arcana/auth"></script>
<script src="https://unpkg.com/@arcana/auth"></script>
const { AuthProvider, SocialLoginType } = window.arcana.auth;
// or
import { AuthProvider } from '@arcana/auth';
const auth = await AuthProvider.init({
appId: `${appId}`,
flow: 'redirect', /* can be 'popup' or 'redirect' */
redirectUri:'' /* can be ignored for redirect flow if same as login page */
});
await auth.loginWithSocial(SocialLoginType.google);
const result = await auth.loginWithOtp(`${emailAddress}`, PasswordlessOptions);
PasswordlessOptions:
{ withUI: true }
- the user is redirected to email-sent
or error
page{ withUI: false }
- gets a json
response back with no redirection{ withUI: true }
const loggedIn = auth.isLoggedIn(); /* boolean response */
The user info is saved in memory after successful login, before unload
event of the page it gets stored in session-storage
and is refetched to memory and removed from session-storage
after successful page reload.
const userInfo = auth.getUserInfo();
/*
UserInfo: {
loginType: 'google',
userInfo: {
id: 'abc@example.com',
name: 'ABC DEF',
email: '',
picture: ''
},
privateKey: ''
}
*/
const publicKey = await auth.getPublicKey({
verifier: SocialLoginType.google,
id: `${email}`,
}, PublickeyOutput);
PublickeyOutput:
point
output will be an object with { x: string, y: string }
compressed
output will be a string
like 0x03...
uncompressed
output will be a string
like 0x04...
uncompressed
await auth.logout();
enum PublicKeyOutput {
point = 'point',
compressed = 'compressed',
uncompressed = 'uncompressed',
}
enum SocialLoginType {
google = 'google',
reddit = 'reddit',
discord = 'discord',
twitch = 'twitch',
github = 'github',
twitter = 'twitter',
passwordless = 'passwordless',
}
interface InitParams {
appId: string;
network?: 'dev' | 'testnet'; /* defaults to testnet */
flow?: 'popup' | 'redirect'; /* defaults to redirect */
debug?: boolean; /* defaults to false */
}
interface UserInfo {
loginType: SocialLoginType;
userInfo: {
id: string;
email?: string;
name?: string;
picture?: string;
};
privateKey: string;
}
interface PasswordlessOptions {
withUI?: boolean;
}
login.js
window.onload = async () => {
const auth = await AuthProvider.init({
appId: `${appId}`,
flow: 'redirect',
redirectUri:'path/to/redirect'
});
googleLoginBtn.addEventListener('click', async () => {
await auth.loginWithSocial(SocialLoginType.google);
});
}
redirect.js
window.onload = async () => {
const auth = await AuthProvider.init({
appId: `${appId}`,
flow: 'redirect',
redirectUri:'path/to/redirect'
});
if(auth.isLoggedIn()) {
const info = auth.getUserInfo();
}
}
Skip redirectUri
in params if the it is same as login page. For example:
index.js
window.onload = async () => {
const auth = await AuthProvider.init({
appId: `${appId}`,
flow: 'redirect',
});
if(auth.isLoggedIn()) {
/* already logged in, get user info and use */
const info = auth.getUserInfo();
} else {
/* add handler to handle login function */
googleLoginBtn.addEventListener('click', async () => {
await auth.loginWithSocial(SocialLoginType.google);
});
}
}
login.js
window.onload = async () => {
const auth = await AuthProvider.init({
appId: `${appId}`,
redirectUri:'path/to/redirect'
});
googleLoginBtn.addEventListener('click', async () => {
await auth.loginWithSocial(SocialLoginType.google);
if(auth.isLoggedIn()) {
const info = auth.getUserInfo();
// Store info and redirect accordingly
}
});
}
redirect.js
window.onload = async () => {
AuthProvider.handleRedirectPage(<origin>);
};
SocialLoginType
- discord, twitter, github, google, twitch, redditorigin
- Base url of your app.FAQs
Arcana Auth
The npm package @arcana/auth receives a total of 615 weekly downloads. As such, @arcana/auth popularity was classified as not popular.
We found that @arcana/auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.