
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
@pageql/pageql-auth
Advanced tools
PageQL Authentiction and Authorization helpers for Svelte
Get started by installing to an existing Svelte project
npm install -D @pageql/pageql-auth
Adding PageQL to your rollup config
import { pageqlPreproccesor } from '@pageql/pageql-auth';
...
plugins: [
svelte({
...
preprocess: [
pageqlPreproccesor(),
]
}),
...
]
...
Init PageQL on App.svelte (_layout.svelte if you're using Sapper)
<script>
/* PageQL BoilerPlate*/
import pageqlConfig from "../pageql.config.js";
import { writable } from "svelte/store";
window.pageql = {};
window.pageql.authState = writable({ loggedIn: false });
window.pageql.auth = pageqlConfig.auth;
window.pageql.user = {};
const authState = window.pageql.authState;
/* PageQL BoilerPlate*/
</script>
...
Setup your pageql.config.js
in your project's root
export default {
auth: {
checkRole: (requiredRole) => {
//Used by pageql:authRole directive
//Return false if user's role fails to hit specifications
//Returning false hides the component
return !window.pageql.user.role.includes(requiredRole);
},
doLogin: (loginCallback, event) => {
//Used by pageql:authLogin directive
//Can get value of "password" input with event.target.password.value
//Do login logic here
window.pageql.user = {
name: event.target.email.value,
role: [
"admin"
], //Get from login response
};
window.pageql.authState.set({ loggedIn: true });
loginCallback();
},
doLogout: (logoutCallback, event) => {
//Used by pageql:authLogout directive
window.pageql.authState.set({ loggedIn: false });
logoutCallback();
},
doRegister: (registerCallback, event) => {
//Used by pageql:authRegister directive
//Can get value of "password" input with event.target.password.value
//Do register logic here
window.pageql.user = {
name: event.target.email.value,
role: [
"admin"
], //Get from login response
};
window.pageql.authState.set({ loggedIn: true });
registerCallback();
},
getUserId: () => {
//Custom functions like this can be defined and accessed anywhere with window.pageql.auth.getUserId()
return "my-user-id";
},
getTenantId: () => {
//You can remove this if you're not using multi tenant!
return "1";
}
},
}
FAQs
PageQL Authentiction and Authorization helpers for Svelte
We found that @pageql/pageql-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.