@draftlab/auth 0.16.0 → 0.17.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/dist/esm/allow.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/allow.ts
2
- import { isDomainMatch } from "./util";
2
+ import { isDomainMatch } from "./util.js";
3
3
  var defaultAllowCheck = (input, req) => {
4
4
  return Promise.resolve((() => {
5
5
  let redirectHostname;
@@ -5,8 +5,8 @@ import {
5
5
  InvalidAuthorizationCodeError,
6
6
  InvalidRefreshTokenError,
7
7
  InvalidSubjectError
8
- } from "./error";
9
- import { generatePKCE } from "./pkce";
8
+ } from "./error.js";
9
+ import { generatePKCE } from "./pkce.js";
10
10
  var createClient = (input) => {
11
11
  const jwksCache = new Map;
12
12
  const issuerCache = new Map;
package/dist/esm/core.js CHANGED
@@ -3,21 +3,21 @@ import { Hono } from "hono";
3
3
  import { deleteCookie, getCookie, setCookie } from "hono/cookie";
4
4
  import { cors } from "hono/cors";
5
5
  import { CompactEncrypt, compactDecrypt, SignJWT } from "jose";
6
- import { defaultAllowCheck } from "./allow";
6
+ import { defaultAllowCheck } from "./allow.js";
7
7
  import {
8
8
  MissingParameterError,
9
9
  OauthError,
10
10
  UnauthorizedClientError,
11
11
  UnknownStateError
12
- } from "./error";
13
- import { encryptionKeys, signingKeys } from "./keys";
14
- import { validatePKCE } from "./pkce";
15
- import { generateSecureToken } from "./random";
16
- import { Revocation } from "./revocation";
17
- import { Storage } from "./storage/storage";
18
- import { setTheme } from "./themes/theme";
19
- import { Select } from "./ui/select";
20
- import { getRelativeUrl, lazy } from "./util";
12
+ } from "./error.js";
13
+ import { encryptionKeys, signingKeys } from "./keys.js";
14
+ import { validatePKCE } from "./pkce.js";
15
+ import { generateSecureToken } from "./random.js";
16
+ import { Revocation } from "./revocation.js";
17
+ import { Storage } from "./storage/storage.js";
18
+ import { setTheme } from "./themes/theme.js";
19
+ import { Select } from "./ui/select.js";
20
+ import { getRelativeUrl, lazy } from "./util.js";
21
21
  var normalizeTimingAsync = async (fn, minTimeMs = 100) => {
22
22
  const startTime = performance.now();
23
23
  const result = await fn();
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { issuer } from "./core";
2
+ import { issuer } from "./core.js";
3
3
  export {
4
4
  issuer
5
5
  };
package/dist/esm/keys.js CHANGED
@@ -7,9 +7,9 @@ import {
7
7
  importPKCS8,
8
8
  importSPKI
9
9
  } from "jose";
10
- import { Mutex } from "./mutex";
11
- import { generateSecureToken } from "./random";
12
- import { Storage } from "./storage/storage";
10
+ import { Mutex } from "./mutex.js";
11
+ import { generateSecureToken } from "./random.js";
12
+ import { Storage } from "./storage/storage.js";
13
13
  var signingAlg = "ES256";
14
14
  var encryptionAlg = "RSA-OAEP-512";
15
15
  var signingKeyMutex = new Mutex;
@@ -1,5 +1,5 @@
1
1
  // src/provider/apple.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var AppleProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/code.ts
2
- import { generateUnbiasedDigits, timingSafeCompare } from "../random";
2
+ import { generateUnbiasedDigits, timingSafeCompare } from "../random.js";
3
3
  var CodeProvider = (config) => {
4
4
  const codeLength = config.length || 6;
5
5
  const generateCode = () => {
@@ -1,5 +1,5 @@
1
1
  // src/provider/discord.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var DiscordProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/facebook.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var FacebookProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/github.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var GithubProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/gitlab.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var GitlabProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/google.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var GoogleProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/linkedin.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var LinkedInProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/magiclink.ts
2
- import { generateUnbiasedDigits, timingSafeCompare } from "../random";
2
+ import { generateUnbiasedDigits, timingSafeCompare } from "../random.js";
3
3
  var MagicLinkProvider = (config) => {
4
4
  const generateToken = () => {
5
5
  return generateUnbiasedDigits(32);
@@ -1,5 +1,5 @@
1
1
  // src/provider/microsoft.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var MicrosoftProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,9 +1,9 @@
1
1
  // src/provider/oauth2.ts
2
2
  import { createRemoteJWKSet, jwtVerify } from "jose";
3
- import { OauthError } from "../error";
4
- import { generatePKCE } from "../pkce";
5
- import { generateSecureToken, timingSafeCompare } from "../random";
6
- import { getRelativeUrl } from "../util";
3
+ import { OauthError } from "../error.js";
4
+ import { generatePKCE } from "../pkce.js";
5
+ import { generateSecureToken, timingSafeCompare } from "../random.js";
6
+ import { getRelativeUrl } from "../util.js";
7
7
  var Oauth2Provider = (config) => {
8
8
  const authQuery = config.query || {};
9
9
  const handleCallbackLogic = async (c, ctx, provider, code) => {
@@ -1,8 +1,8 @@
1
1
  // src/provider/password.ts
2
- import { UnknownStateError } from "../error";
3
- import { generateUnbiasedDigits, timingSafeCompare } from "../random";
4
- import { Storage } from "../storage/storage";
5
- import { getRelativeUrl } from "../util";
2
+ import { UnknownStateError } from "../error.js";
3
+ import { generateUnbiasedDigits, timingSafeCompare } from "../random.js";
4
+ import { Storage } from "../storage/storage.js";
5
+ import { getRelativeUrl } from "../util.js";
6
6
  import { TextEncoder } from "node:util";
7
7
  import * as jose from "jose";
8
8
  import { randomBytes, scrypt, timingSafeEqual } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  // src/provider/reddit.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var RedditProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/slack.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var SlackProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/spotify.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var SpotifyProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/twitch.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var TwitchProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,5 +1,5 @@
1
1
  // src/provider/vercel.ts
2
- import { Oauth2Provider } from "./oauth2";
2
+ import { Oauth2Provider } from "./oauth2.js";
3
3
  var VercelProvider = (config) => {
4
4
  return Oauth2Provider({
5
5
  ...config,
@@ -1,6 +1,6 @@
1
1
  // src/revocation.ts
2
2
  import { createHash } from "node:crypto";
3
- import { Storage } from "./storage/storage";
3
+ import { Storage } from "./storage/storage.js";
4
4
  var hashToken = (token) => {
5
5
  return createHash("sha256").update(token).digest("hex");
6
6
  };
@@ -1,7 +1,7 @@
1
1
  // src/storage/memory.ts
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { writeFile } from "node:fs/promises";
4
- import { joinKey, splitKey } from "./storage";
4
+ import { joinKey, splitKey } from "./storage.js";
5
5
  var MemoryStorage = (options) => {
6
6
  const store = [];
7
7
  const isValidStoreData = (data) => {
@@ -1,5 +1,5 @@
1
1
  // src/storage/turso.ts
2
- import { joinKey, splitKey } from "./storage";
2
+ import { joinKey, splitKey } from "./storage.js";
3
3
  var TursoStorage = (client) => {
4
4
  const TABLE_NAME = "__draftauth__kv_storage";
5
5
  client.execute(`
@@ -1,6 +1,6 @@
1
1
  // src/storage/unstorage.ts
2
2
  import { createStorage } from "unstorage";
3
- import { joinKey, splitKey } from "./storage";
3
+ import { joinKey, splitKey } from "./storage.js";
4
4
  var UnStorage = ({ driver } = {}) => {
5
5
  const store = createStorage({
6
6
  driver
@@ -1,7 +1,7 @@
1
1
  // src/toolkit/client.ts
2
- import { generatePKCE } from "../pkce";
3
- import { createSessionStorage } from "./storage";
4
- import { generateSecureRandom } from "./utils";
2
+ import { generatePKCE } from "../pkce.js";
3
+ import { createSessionStorage } from "./storage.js";
4
+ import { generateSecureRandom } from "./utils.js";
5
5
  var createOAuthClient = (config) => {
6
6
  const storage = config.storage || (typeof sessionStorage !== "undefined" ? createSessionStorage() : null);
7
7
  if (!storage) {
@@ -1,16 +1,16 @@
1
1
  // src/toolkit/index.ts
2
- import { generatePKCE } from "../pkce";
3
- import { createOAuthClient } from "./client";
4
- import { FacebookStrategy } from "./providers/facebook";
5
- import { GitHubStrategy } from "./providers/github";
6
- import { GoogleStrategy } from "./providers/google";
2
+ import { generatePKCE } from "../pkce.js";
3
+ import { createOAuthClient } from "./client.js";
4
+ import { FacebookStrategy } from "./providers/facebook.js";
5
+ import { GitHubStrategy } from "./providers/github.js";
6
+ import { GoogleStrategy } from "./providers/google.js";
7
7
  import {
8
8
  createCookieStorage,
9
9
  createLocalStorage,
10
10
  createMemoryStorage,
11
11
  createSessionStorage
12
- } from "./storage";
13
- import { generateSecureRandom } from "./utils";
12
+ } from "./storage.js";
13
+ import { generateSecureRandom } from "./utils.js";
14
14
  export {
15
15
  generateSecureRandom,
16
16
  generatePKCE,
@@ -1,8 +1,8 @@
1
1
  // src/ui/code.tsx
2
- import { UnknownStateError } from "../error";
3
- import { run } from "../util";
4
- import { Layout } from "./base";
5
- import { FormAlert } from "./form";
2
+ import { UnknownStateError } from "../error.js";
3
+ import { run } from "../util.js";
4
+ import { Layout } from "./base.js";
5
+ import { FormAlert } from "./form.js";
6
6
  import { jsxDEV } from "hono/jsx/jsx-dev-runtime";
7
7
  var DEFAULT_COPY = {
8
8
  email_placeholder: "Email",
@@ -1,8 +1,8 @@
1
1
  // src/ui/magiclink.tsx
2
- import { UnknownStateError } from "../error";
3
- import { run } from "../util";
4
- import { Layout } from "./base";
5
- import { FormAlert } from "./form";
2
+ import { UnknownStateError } from "../error.js";
3
+ import { run } from "../util.js";
4
+ import { Layout } from "./base.js";
5
+ import { FormAlert } from "./form.js";
6
6
  import { jsxDEV } from "hono/jsx/jsx-dev-runtime";
7
7
  var DEFAULT_COPY = {
8
8
  email_placeholder: "Email",
@@ -1,7 +1,7 @@
1
1
  // src/ui/password.tsx
2
- import { run } from "../util";
3
- import { Layout } from "./base";
4
- import { FormAlert } from "./form";
2
+ import { run } from "../util.js";
3
+ import { Layout } from "./base.js";
4
+ import { FormAlert } from "./form.js";
5
5
  import { jsxDEV, Fragment } from "hono/jsx/jsx-dev-runtime";
6
6
  var DEFAULT_COPY = {
7
7
  error_email_taken: "There is already an account with this email.",
@@ -1,5 +1,5 @@
1
1
  // src/ui/select.tsx
2
- import { Layout } from "./base";
2
+ import { Layout } from "./base.js";
3
3
  import {
4
4
  ICON_APPLE,
5
5
  ICON_DISCORD,
@@ -14,7 +14,7 @@ import {
14
14
  ICON_SLACK,
15
15
  ICON_SPOTIFY,
16
16
  ICON_TWITCH
17
- } from "./icon";
17
+ } from "./icon.js";
18
18
  import { jsxDEV } from "hono/jsx/jsx-dev-runtime";
19
19
  var PROVIDER_ICONS = {
20
20
  apple: ICON_APPLE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftlab/auth",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "description": "Core implementation for @draftlab/auth",
6
6
  "author": "Matheus Pergoli",
@@ -37,6 +37,7 @@
37
37
  ],
38
38
  "license": "MIT",
39
39
  "devDependencies": {
40
+ "@types/bun": "^1.3.6",
40
41
  "typescript": "^5.9.3",
41
42
  "@draftlab/tsconfig": "0.1.0"
42
43
  },