@epic-web/workshop-utils 6.83.0 → 6.84.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.
Files changed (2) hide show
  1. package/dist/db.server.js +24 -0
  2. package/package.json +1 -1
package/dist/db.server.js CHANGED
@@ -124,6 +124,20 @@ function tryGetWorkshopProductHost() {
124
124
  return undefined;
125
125
  }
126
126
  }
127
+ const AuthInfosSchema = z.record(z.string(), AuthInfoSchema);
128
+ function getAuthInfosFromEnv() {
129
+ const raw = process.env.EPICSHOP_AUTH_INFOS?.trim();
130
+ if (!raw)
131
+ return null;
132
+ try {
133
+ const json = Buffer.from(raw, 'base64').toString('utf-8');
134
+ const parsed = JSON.parse(json);
135
+ return AuthInfosSchema.parse(parsed);
136
+ }
137
+ catch {
138
+ return null;
139
+ }
140
+ }
127
141
  export async function logout({ productHost } = {}) {
128
142
  const host = productHost ?? tryGetWorkshopProductHost();
129
143
  if (host) {
@@ -206,6 +220,11 @@ export async function readDb() {
206
220
  }
207
221
  export async function getAuthInfo({ productHost, } = {}) {
208
222
  const host = productHost ?? tryGetWorkshopProductHost();
223
+ // Check env first (before database)
224
+ const envAuthInfos = getAuthInfosFromEnv();
225
+ if (envAuthInfos && host && host in envAuthInfos) {
226
+ return envAuthInfos[host];
227
+ }
209
228
  const data = await readDb();
210
229
  if (host && typeof data?.authInfos === 'object') {
211
230
  if (host in data.authInfos) {
@@ -227,6 +246,11 @@ export async function getAuthInfo({ productHost, } = {}) {
227
246
  * Returns an array of normalized product hosts (e.g., 'www.epicweb.dev').
228
247
  */
229
248
  export async function getLoggedInProductHosts() {
249
+ // Check env first (before database)
250
+ const envAuthInfos = getAuthInfosFromEnv();
251
+ if (envAuthInfos) {
252
+ return Object.keys(envAuthInfos);
253
+ }
230
254
  const data = await readDb();
231
255
  const loggedInHosts = [];
232
256
  // Get hosts from the new authInfos record
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epic-web/workshop-utils",
3
- "version": "6.83.0",
3
+ "version": "6.84.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },