Registry / security / learn-auth-sdk

learn-auth-sdk

JSON →
library0.3.1jsnpmunverified

An open-source Auth SDK designed for decentralized tenant backends using Cloudflare D1. Version 0.3.1 is the current stable release. It offers multi-tenant RBAC authentication with TypeScript support. Differentiates by targeting Cloudflare Workers and D1 databases, unlike general-purpose auth libraries. Release cadence is rapid as it is in early development.

npm install learn-auth-sdk
INSTALL
IMPORT
SIG · LEARN-AUTH-SDK
L
learn-auth-sdk
securityjavascriptv0.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LearnAuth
import { LearnAuth } from 'learn-auth-sdk'
const LearnAuth = require('learn-auth-sdk')
ESM-only; CommonJS require not supported.
createAuthClient
import { createAuthClient } from 'learn-auth-sdk'
import createAuthClient from 'learn-auth-sdk'
Named export, not default.
type AuthConfig
import type { AuthConfig } from 'learn-auth-sdk'
import { AuthConfig } from 'learn-auth-sdk'
TypeScript type-only import to avoid runtime overhead.

Initializes LearnAuth with a Cloudflare D1 database and registers a new user.

import { LearnAuth, createAuthClient } from 'learn-auth-sdk'; import { D1Database } from '@cloudflare/workers-types'; const env = { DB: {} as D1Database }; const auth = new LearnAuth({ database: env.DB, secret: process.env.AUTH_SECRET ?? 'default-secret' }); const client = createAuthClient(auth); async function example() { const user = await client.register({ email: 'user@example.com', password: 'securePassword123' }); console.log('Registered user:', user); } example().catch(console.error);
Debug
Known issues
breakingAPI changed from v0.2.x to v0.3.0: createAuthClient now requires a LearnAuth instance instead of options object.
fix
Update calls to createAuthClient: pass new LearnAuth(config) instead of inline config.
affects: >=0.3.0
gotchaOnly works in Cloudflare Workers environment due to D1 dependency.
fix
Use only in Cloudflare Workers or Node.js with a D1-compatible adapter.
affects: *
deprecatedThe 'databaseUrl' option in LearnAuth constructor is deprecated; use 'database' with a D1 binding instead.
fix
Replace 'databaseUrl' with 'database' pointing to a D1Database instance.
affects: >=0.3.0
Errors
Common errors & fixes
Cannot find module 'learn-auth-sdk' or its corresponding type declarations.
Package not installed or TypeScript not configured to resolve module.
fix
Install the package: npm install learn-auth-sdk. Ensure tsconfig.json includes 'node_modules' in 'paths' or use 'moduleResolution': 'node'.
TypeError: Class extends value undefined is not a constructor or null
Circular dependency or missing import of a required submodule.
fix
Ensure you import all necessary symbols: import { LearnAuth } from 'learn-auth-sdk' and not a subpath.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
better-authrequiredCore dependency for authentication logic
Agent activity
11 hits · last 30 days
node
8
Resources
learn-auth-sdk — npm install learn-auth-sdk · libregistry