@blocklet/sdk 1.16.44-beta-20250529-223630-10e16ac8 → 1.16.44-beta-20250603-231026-30a9d27f

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.
@@ -10,6 +10,7 @@ const crypto_1 = __importDefault(require("crypto"));
10
10
  const constant_1 = require("@blocklet/constant");
11
11
  const theme_1 = require("@blocklet/theme");
12
12
  const config_1 = require("../config");
13
+ const constants_1 = require("../util/constants");
13
14
  // Cache configurations
14
15
  const DEFAULT_CACHE_TTL = 1 * 60 * 1000; // 1 minute
15
16
  const cache = new Map();
@@ -67,49 +68,6 @@ const tryWithTimeout = (asyncFn, timeout) => {
67
68
  }
68
69
  });
69
70
  };
70
- const buildThemeStyles = (theme) => {
71
- const { light, dark } = theme;
72
- return `
73
- <style id="blocklet-theme-style">
74
- :root {
75
- --blocklet-background-default-color: ${light.palette?.background?.default ?? '#fff'};
76
- --blocklet-text-primary-color: ${light.palette?.text?.primary ?? '#000'};
77
- }
78
-
79
- [data-theme='dark'] {
80
- --blocklet-background-default-color: ${dark.palette?.background?.default ?? '#000'};
81
- --blocklet-text-primary-color: ${dark.palette?.text?.primary ?? '#fff'};
82
- }
83
-
84
- html, body {
85
- background-color: var(--blocklet-background-default-color);
86
- color: var(--blocklet-text-primary-color);
87
- }
88
- </style>
89
- `;
90
- };
91
- const buildThemeScript = (theme) => {
92
- return `
93
- <script id="blocklet-theme-script">
94
- (function() {
95
- try {
96
- const BLOCKLET_THEME_PREFER_KEY = '${theme_1.BLOCKLET_THEME_PREFER_KEY}';
97
- ${theme_1.isValidThemeMode.toString()}
98
- ${theme_1.getDefaultThemePrefer.toString()}
99
-
100
- const prefer = getDefaultThemePrefer(${JSON.stringify({ theme: { prefer: theme.prefer } })});
101
- if(prefer === 'dark') {
102
- document.documentElement.setAttribute('data-theme', 'dark');
103
- } else {
104
- document.documentElement.removeAttribute('data-theme');
105
- }
106
- } catch (e) {
107
- console.error('Theme init error:', e);
108
- }
109
- })();
110
- </script>
111
- `;
112
- };
113
71
  const fallback = (file, options = {}) => {
114
72
  const filePath = options.root ? (0, path_1.join)(options.root, file) : file;
115
73
  // Check file existence during initialization
@@ -149,7 +107,7 @@ const fallback = (file, options = {}) => {
149
107
  validatePageData(pageData, options.maxLength || 1000);
150
108
  pageData.title = (0, escape_1.default)(pageData.title || config_1.env.appName);
151
109
  pageData.description = (0, escape_1.default)(pageData.description || config_1.env.appDescription);
152
- pageData.ogImage = pageData.ogImage || (0, ufo_1.joinURL)(config_1.env.appUrl || '/', '/.well-known/service/blocklet/og.png');
110
+ pageData.ogImage = pageData.ogImage || (0, ufo_1.joinURL)(config_1.env.appUrl || '/', constants_1.SERVICE_PREFIX, '/blocklet/og.png');
153
111
  let source = await fs_1.default.promises.readFile(filePath, 'utf8');
154
112
  // Optimize string replacements
155
113
  if (pageData.title) {
@@ -176,8 +134,8 @@ const fallback = (file, options = {}) => {
176
134
  .replace('<script src="__meta__.js"></script>', `<script>${blockletJs}</script>`);
177
135
  }
178
136
  // Inject theme styles and script
179
- const themeStyles = buildThemeStyles(theme);
180
- const themeScript = buildThemeScript(theme);
137
+ const themeStyles = (0, theme_1.buildThemeStyles)(theme);
138
+ const themeScript = (0, theme_1.buildThemeScript)(theme);
181
139
  // 注入主题样式
182
140
  if (!source.includes('<style id="blocklet-theme">')) {
183
141
  source = source.replace(HEAD_END_TAG, `${themeStyles}${HEAD_END_TAG}`);
@@ -84,6 +84,7 @@ declare const _default: {
84
84
  componentCall?: boolean;
85
85
  signedToken?: boolean;
86
86
  accessKey?: boolean;
87
+ signedTokenKey?: string;
87
88
  }) => (req: import("express").Request & {
88
89
  user?: import("../util/login").SessionUser;
89
90
  }, res: import("express").Response, next: import("express").NextFunction) => Promise<void>;
@@ -6,6 +6,7 @@ type SessionOptions = {
6
6
  componentCall?: boolean;
7
7
  signedToken?: boolean;
8
8
  accessKey?: boolean;
9
+ signedTokenKey?: string;
9
10
  };
10
11
  declare const sessionMiddleware: (options?: SessionOptions) => (req: Request & {
11
12
  user?: SessionUser;
@@ -3,7 +3,7 @@ const get_token_from_req_1 = require("@abtnode/util/lib/get-token-from-req");
3
3
  const login_1 = require("../util/login");
4
4
  const verify_session_1 = require("../util/verify-session");
5
5
  const sessionMiddleware = (options = {}) => {
6
- const { loginToken = true, componentCall = false, signedToken = '', strictMode = false, accessKey = false } = options;
6
+ const { loginToken = true, componentCall = false, signedToken = '', strictMode = false, accessKey = false, signedTokenKey = '__jwt', } = options;
7
7
  return async (req, res, next) => {
8
8
  let result = null;
9
9
  try {
@@ -31,7 +31,7 @@ const sessionMiddleware = (options = {}) => {
31
31
  }
32
32
  // authenticate by signed tmp token: which expires in 5 minutes
33
33
  if (!result && signedToken) {
34
- const token = req.query.__jwt || '';
34
+ const token = req.query[signedTokenKey] || '';
35
35
  result = await (0, verify_session_1.verifySignedToken)({ token, strictMode });
36
36
  }
37
37
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.44-beta-20250529-223630-10e16ac8",
6
+ "version": "1.16.44-beta-20250603-231026-30a9d27f",
7
7
  "description": "graphql client to read/write data on abt node",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
@@ -27,24 +27,24 @@
27
27
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
28
28
  "license": "Apache-2.0",
29
29
  "dependencies": {
30
- "@abtnode/client": "1.16.44-beta-20250529-223630-10e16ac8",
31
- "@abtnode/constant": "1.16.44-beta-20250529-223630-10e16ac8",
32
- "@abtnode/util": "1.16.44-beta-20250529-223630-10e16ac8",
33
- "@arcblock/did": "1.20.11",
34
- "@arcblock/did-auth": "1.20.11",
35
- "@arcblock/jwt": "1.20.11",
36
- "@arcblock/ws": "1.20.11",
37
- "@blocklet/constant": "1.16.44-beta-20250529-223630-10e16ac8",
38
- "@blocklet/env": "1.16.44-beta-20250529-223630-10e16ac8",
39
- "@blocklet/error": "^0.2.4",
40
- "@blocklet/meta": "1.16.44-beta-20250529-223630-10e16ac8",
41
- "@blocklet/theme": "^2.13.55",
30
+ "@abtnode/client": "1.16.44-beta-20250603-231026-30a9d27f",
31
+ "@abtnode/constant": "1.16.44-beta-20250603-231026-30a9d27f",
32
+ "@abtnode/util": "1.16.44-beta-20250603-231026-30a9d27f",
33
+ "@arcblock/did": "1.20.12",
34
+ "@arcblock/did-auth": "1.20.12",
35
+ "@arcblock/jwt": "1.20.12",
36
+ "@arcblock/ws": "1.20.12",
37
+ "@blocklet/constant": "1.16.44-beta-20250603-231026-30a9d27f",
38
+ "@blocklet/env": "1.16.44-beta-20250603-231026-30a9d27f",
39
+ "@blocklet/error": "^0.2.5",
40
+ "@blocklet/meta": "1.16.44-beta-20250603-231026-30a9d27f",
41
+ "@blocklet/theme": "^2.13.61",
42
42
  "@did-connect/authenticator": "^2.2.8",
43
43
  "@did-connect/handler": "^2.2.8",
44
44
  "@nedb/core": "^2.1.5",
45
- "@ocap/mcrypto": "1.20.11",
46
- "@ocap/util": "1.20.11",
47
- "@ocap/wallet": "1.20.11",
45
+ "@ocap/mcrypto": "1.20.12",
46
+ "@ocap/util": "1.20.12",
47
+ "@ocap/wallet": "1.20.12",
48
48
  "axios": "^1.7.9",
49
49
  "cheerio": "1.0.0-rc.12",
50
50
  "debug": "^4.3.7",
@@ -84,5 +84,5 @@
84
84
  "ts-node": "^10.9.1",
85
85
  "typescript": "^5.6.3"
86
86
  },
87
- "gitHead": "381ba5459e32dd7bc94f7ea62df65b72644d6d16"
87
+ "gitHead": "c76d07121652516f178de4188d8694fc130767b8"
88
88
  }