@oneaccount/express 0.2.0 → 0.2.4

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/README.md CHANGED
@@ -20,7 +20,7 @@ app.use(express.json());
20
20
  // Initialize SDK
21
21
  const oa = oneAccount({
22
22
  apiKey: process.env.ONEACCOUNT_API_KEY,
23
- accountProUrl: 'https://myaccount.one', // optional
23
+ accountProUrl: 'https://accountpro.replit.app', // optional
24
24
  debug: true, // optional - logs auth errors
25
25
  });
26
26
 
@@ -53,7 +53,7 @@ app.listen(3000);
53
53
  | Option | Type | Default | Description |
54
54
  |--------|------|---------|-------------|
55
55
  | `apiKey` | string | required | Your OneAccount API key |
56
- | `accountProUrl` | string | `https://myaccount.one` | OneAccount server URL |
56
+ | `accountProUrl` | string | `https://accountpro.replit.app` | OneAccount server URL |
57
57
  | `jwksUrl` | string | auto | JWKS endpoint URL (auto-derived from accountProUrl) |
58
58
  | `debug` | boolean | `false` | Log authentication errors |
59
59
 
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccountProClient = void 0;
4
4
  class AccountProClient {
5
5
  constructor(config) {
6
- this.baseUrl = config.accountProUrl || "https://myaccount.one";
6
+ this.baseUrl = config.accountProUrl || "https://accountpro.replit.app";
7
7
  this.apiKey = config.apiKey;
8
8
  this.debug = config.debug || false;
9
9
  }
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ function oneAccount(config) {
12
12
  throw new Error("OneAccount SDK requires an API key");
13
13
  }
14
14
  const resolvedConfig = {
15
- accountProUrl: config.accountProUrl || "https://myaccount.one",
15
+ accountProUrl: config.accountProUrl || "https://accountpro.replit.app",
16
16
  ...config,
17
17
  };
18
18
  const authMiddleware = (0, auth_1.createAuthMiddleware)(resolvedConfig);
@@ -24,8 +24,12 @@ async function fetchJWKS(jwksUrl) {
24
24
  return cachedJWKS;
25
25
  }
26
26
  function rsaPublicKeyFromJWK(jwk) {
27
- const n = Buffer.from(jwk.n, "base64url");
28
- const e = Buffer.from(jwk.e, "base64url");
27
+ // Convert base64url to base64 (some Node versions don't support base64url directly)
28
+ const base64urlToBase64 = (str) => {
29
+ return str.replace(/-/g, '+').replace(/_/g, '/');
30
+ };
31
+ const n = Buffer.from(base64urlToBase64(jwk.n), "base64");
32
+ const e = Buffer.from(base64urlToBase64(jwk.e), "base64");
29
33
  const nLen = n.length;
30
34
  const eLen = e.length;
31
35
  const nLenBytes = nLen < 128
@@ -83,7 +87,7 @@ function extractTokenFromCookies(cookieHeader, cookieName) {
83
87
  }
84
88
  function createAuthMiddleware(config) {
85
89
  const jwksUrl = config.jwksUrl ||
86
- `${config.accountProUrl || "https://myaccount.one"}/.well-known/jwks.json`;
90
+ `${config.accountProUrl || "https://accountpro.replit.app"}/.well-known/jwks.json`;
87
91
  const cookieName = config.cookieName || "auth_token";
88
92
  const autoSetCookie = config.autoSetCookie !== false; // Default to true
89
93
  return async function authMiddleware(req, res, next) {
@@ -135,6 +139,14 @@ function createAuthMiddleware(config) {
135
139
  return next();
136
140
  }
137
141
  const publicKey = rsaPublicKeyFromJWK(key);
142
+ if (config.debug) {
143
+ console.log("[OneAccount] Public key generated:", {
144
+ keyType: typeof publicKey,
145
+ keyLength: publicKey?.length,
146
+ startsWithPem: publicKey?.startsWith('-----BEGIN'),
147
+ kid: key.kid
148
+ });
149
+ }
138
150
  const payload = jsonwebtoken_1.default.verify(token, publicKey, {
139
151
  algorithms: ["RS256"],
140
152
  });
@@ -23,8 +23,12 @@ async function fetchJWKS(jwksUrl) {
23
23
  return cachedJWKS;
24
24
  }
25
25
  function rsaPublicKeyFromJWK(jwk) {
26
- const n = Buffer.from(jwk.n, "base64url");
27
- const e = Buffer.from(jwk.e, "base64url");
26
+ // Convert base64url to base64 (some Node versions don't support base64url directly)
27
+ const base64urlToBase64 = (str) => {
28
+ return str.replace(/-/g, '+').replace(/_/g, '/');
29
+ };
30
+ const n = Buffer.from(base64urlToBase64(jwk.n), "base64");
31
+ const e = Buffer.from(base64urlToBase64(jwk.e), "base64");
28
32
  const nLen = n.length;
29
33
  const eLen = e.length;
30
34
  const nLenBytes = nLen < 128
@@ -70,7 +74,7 @@ function rsaPublicKeyFromJWK(jwk) {
70
74
  }
71
75
  function createBuyerAuthMiddleware(config) {
72
76
  const jwksUrl = config.jwksUrl ||
73
- `${config.accountProUrl || "https://myaccount.one"}/.well-known/jwks.json`;
77
+ `${config.accountProUrl || "https://accountpro.replit.app"}/.well-known/jwks.json`;
74
78
  return async function buyerAuthMiddleware(req, _res, next) {
75
79
  req.buyer = null;
76
80
  const authHeader = req.headers.authorization;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneaccount/express",
3
- "version": "0.2.0",
3
+ "version": "0.2.4",
4
4
  "description": "OneAccount SDK for Express.js - Authentication, entitlements, and Stripe Connect",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",