@secrecy/lib 1.41.0 → 1.42.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/lib/base-client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getLink } from '@secrecy/lib-utils';
|
|
2
1
|
import { usersCache } from './cache.js';
|
|
3
2
|
import { getStorage } from './client/storage.js';
|
|
4
3
|
import { createTRPCClient, } from './client.js';
|
|
5
4
|
import { getPreferedEmail } from './utils.js';
|
|
5
|
+
import { getLink } from './utils/links.js';
|
|
6
6
|
async function getPublicUser(client, id) {
|
|
7
7
|
let user = usersCache.get(id);
|
|
8
8
|
if (user !== undefined) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const secrecyApplications = [
|
|
2
|
+
'app',
|
|
3
|
+
'api',
|
|
4
|
+
'auth',
|
|
5
|
+
'admin',
|
|
6
|
+
'dashboard',
|
|
7
|
+
'me',
|
|
8
|
+
];
|
|
9
|
+
function getEnv() {
|
|
10
|
+
if (typeof window === 'undefined') {
|
|
11
|
+
return process.env.VERCEL_ENV
|
|
12
|
+
? process.env.VERCEL_ENV
|
|
13
|
+
: 'production';
|
|
14
|
+
}
|
|
15
|
+
if (window.location.hostname.includes('secrecy.tech')) {
|
|
16
|
+
return 'production';
|
|
17
|
+
}
|
|
18
|
+
if (window.location.hostname.includes('localhost')) {
|
|
19
|
+
return 'development';
|
|
20
|
+
}
|
|
21
|
+
return 'preview';
|
|
22
|
+
}
|
|
23
|
+
const env = getEnv();
|
|
24
|
+
const vercelUrl = process.env.VERCEL_URL ?? process.env.NEXT_PUBLIC_VERCEL_URL ?? 'secrecy.tech';
|
|
25
|
+
function withPath(origin, path) {
|
|
26
|
+
if (!path) {
|
|
27
|
+
return origin;
|
|
28
|
+
}
|
|
29
|
+
return `${origin.endsWith('/') ? origin : `${origin}/`}${path.startsWith('/') ? `${path.slice(1)}` : `${path}`}`;
|
|
30
|
+
}
|
|
31
|
+
function getLocalLink({ app, path, }) {
|
|
32
|
+
const sd = secrecyApplications.find((domain) => domain === app);
|
|
33
|
+
return withPath(`http://localhost:3000/${sd ?? ''}`, path);
|
|
34
|
+
}
|
|
35
|
+
function getPreviewLink({ app, path, }) {
|
|
36
|
+
const sd = secrecyApplications.find((domain) => domain === app);
|
|
37
|
+
return withPath(`https://${vercelUrl}/${sd ?? ''}`, path);
|
|
38
|
+
}
|
|
39
|
+
function getProductionLink({ app, path, }) {
|
|
40
|
+
const sd = secrecyApplications.find((domain) => domain === app);
|
|
41
|
+
return withPath(`https://${sd ? `${sd}.` : ''}secrecy.tech`, path);
|
|
42
|
+
}
|
|
43
|
+
export const getLink = env === 'production'
|
|
44
|
+
? getProductionLink
|
|
45
|
+
: env === 'preview'
|
|
46
|
+
? getPreviewLink
|
|
47
|
+
: getLocalLink;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const secrecyApplications: readonly ["app", "api", "auth", "admin", "dashboard", "me"];
|
|
2
|
+
export type VercelEnv = 'production' | 'development' | 'preview';
|
|
3
|
+
export type SecrecyAppSubdomain = (typeof secrecyApplications)[number];
|
|
4
|
+
declare function getProductionLink({ app, path, }: {
|
|
5
|
+
app: SecrecyAppSubdomain;
|
|
6
|
+
path?: string;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare const getLink: typeof getProductionLink;
|
|
9
|
+
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@secrecy/lib",
|
|
3
3
|
"author": "Anonymize <anonymize@gmail.com>",
|
|
4
4
|
"description": "Anonymize Secrecy Library",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.42.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/anonymize-org/lib.git"
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"typescript": "^5.5.4"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@secrecy/lib-utils": "^1.0.18",
|
|
77
76
|
"@secrecy/trpc-api-types": "1.33.0-dev.13",
|
|
78
77
|
"@trpc/client": "10.45.2",
|
|
79
78
|
"@trpc/server": "10.45.2",
|