@blocklet/sdk 1.16.49-beta-20250822-070545-6d3344cc → 1.16.49-beta-20250823-082650-626c1473
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/lib/config.js +5 -5
- package/lib/connect/authenticator.d.ts +2 -0
- package/lib/connect/authenticator.js +3 -2
- package/lib/did.d.ts +5 -3
- package/lib/did.js +4 -7
- package/lib/index.d.ts +6 -3
- package/lib/index.js +5 -4
- package/lib/middlewares/auth.d.ts +2 -2
- package/lib/middlewares/auth.js +2 -2
- package/lib/service/{auth.d.ts → blocklet.d.ts} +6 -3
- package/lib/service/{auth.js → blocklet.js} +41 -5
- package/lib/wallet-authenticator.d.ts +2 -0
- package/lib/wallet-authenticator.js +3 -2
- package/package.json +9 -9
- package/service/auth.js +4 -1
- package/service/blocklet.js +1 -0
package/lib/config.js
CHANGED
|
@@ -25,11 +25,11 @@ const notification_1 = __importDefault(require("./service/notification"));
|
|
|
25
25
|
const server_version_1 = __importDefault(require("./util/server-version"));
|
|
26
26
|
const parse_env_file_1 = require("./util/parse-env-file");
|
|
27
27
|
const parse_docker_endpoint_1 = require("./util/parse-docker-endpoint");
|
|
28
|
-
const
|
|
28
|
+
const blocklet_1 = __importDefault(require("./service/blocklet"));
|
|
29
29
|
const debug = (0, debug_1.default)('@blocklet/sdk:config');
|
|
30
30
|
const events = new events_1.EventEmitter();
|
|
31
31
|
exports.events = events;
|
|
32
|
-
let
|
|
32
|
+
let blockletClient;
|
|
33
33
|
const Events = {
|
|
34
34
|
componentAdded: 'componentAdded',
|
|
35
35
|
componentUpdated: 'componentUpdated',
|
|
@@ -330,10 +330,10 @@ const fetchBlockletJs = async (type = 'js') => {
|
|
|
330
330
|
};
|
|
331
331
|
const fetchBlockletData = async () => {
|
|
332
332
|
try {
|
|
333
|
-
if (!
|
|
334
|
-
|
|
333
|
+
if (!blockletClient) {
|
|
334
|
+
blockletClient = new blocklet_1.default();
|
|
335
335
|
}
|
|
336
|
-
const { blocklet } = await
|
|
336
|
+
const { blocklet } = await blockletClient.getBlocklet();
|
|
337
337
|
blockletSettings.federated = blocklet.settings?.federated;
|
|
338
338
|
blockletSettings.enableBlacklist = blocklet.settings?.session?.enableBlacklist;
|
|
339
339
|
return blocklet;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Authenticator } from '@did-connect/authenticator';
|
|
2
2
|
declare class BlockletAuthenticator extends Authenticator {
|
|
3
3
|
constructor(options?: {});
|
|
4
|
+
/** @deprecated Use blockletClient instead */
|
|
4
5
|
private authClient;
|
|
6
|
+
private blockletClient;
|
|
5
7
|
}
|
|
6
8
|
export = BlockletAuthenticator;
|
|
@@ -6,7 +6,7 @@ const authenticator_1 = require("@did-connect/authenticator");
|
|
|
6
6
|
const wallet_1 = __importDefault(require("../wallet"));
|
|
7
7
|
const check_blocklet_env_1 = __importDefault(require("../util/check-blocklet-env"));
|
|
8
8
|
const shared_1 = require("./shared");
|
|
9
|
-
const
|
|
9
|
+
const blocklet_1 = __importDefault(require("../service/blocklet"));
|
|
10
10
|
class BlockletAuthenticator extends authenticator_1.Authenticator {
|
|
11
11
|
constructor(options = {}) {
|
|
12
12
|
(0, check_blocklet_env_1.default)();
|
|
@@ -15,7 +15,8 @@ class BlockletAuthenticator extends authenticator_1.Authenticator {
|
|
|
15
15
|
wallet: (0, wallet_1.default)(),
|
|
16
16
|
...(0, shared_1.getAuthenticatorProps)(options),
|
|
17
17
|
});
|
|
18
|
-
this.
|
|
18
|
+
this.blockletClient = new blocklet_1.default();
|
|
19
|
+
this.authClient = this.blockletClient;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
module.exports = BlockletAuthenticator;
|
package/lib/did.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import toBlockletDid from '@blocklet/meta/lib/did';
|
|
2
2
|
import { getConnectedAccounts, getConnectedDids, getPermanentDid, getWallet, getWalletDid } from '@blocklet/meta/lib/did-utils';
|
|
3
|
-
import
|
|
4
|
-
declare function getUserInfo(userDid: string, { authClient }?: {
|
|
5
|
-
|
|
3
|
+
import BlockletService from './service/blocklet';
|
|
4
|
+
declare function getUserInfo(userDid: string, { blockletClient, authClient, }?: {
|
|
5
|
+
blockletClient?: BlockletService;
|
|
6
|
+
/** @deprecated Use blockletClient instead */
|
|
7
|
+
authClient?: BlockletService;
|
|
6
8
|
}): Promise<import("@blocklet/server-js").UserInfo>;
|
|
7
9
|
export { getUserInfo, toBlockletDid, getConnectedAccounts, getConnectedDids, getPermanentDid, getWallet, getWalletDid };
|
package/lib/did.js
CHANGED
|
@@ -13,13 +13,10 @@ Object.defineProperty(exports, "getConnectedDids", { enumerable: true, get: func
|
|
|
13
13
|
Object.defineProperty(exports, "getPermanentDid", { enumerable: true, get: function () { return did_utils_1.getPermanentDid; } });
|
|
14
14
|
Object.defineProperty(exports, "getWallet", { enumerable: true, get: function () { return did_utils_1.getWallet; } });
|
|
15
15
|
Object.defineProperty(exports, "getWalletDid", { enumerable: true, get: function () { return did_utils_1.getWalletDid; } });
|
|
16
|
-
const
|
|
17
|
-
async function getUserInfo(userDid, { authClient = undefined } = {}) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
authClient = new auth_1.default();
|
|
21
|
-
}
|
|
22
|
-
const { user } = await authClient.getUser(userDid, {
|
|
16
|
+
const blocklet_1 = __importDefault(require("./service/blocklet"));
|
|
17
|
+
async function getUserInfo(userDid, { blockletClient = undefined, authClient = undefined, } = {}) {
|
|
18
|
+
const client = blockletClient || authClient || new blocklet_1.default();
|
|
19
|
+
const { user } = await client.getUser(userDid, {
|
|
23
20
|
enableConnectedAccount: true,
|
|
24
21
|
});
|
|
25
22
|
return user;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TTheme, type TNavigationItem } from '@blocklet/meta/lib/types';
|
|
2
2
|
import env from '@blocklet/env';
|
|
3
|
-
import
|
|
3
|
+
import BlockletService from './service/blocklet';
|
|
4
4
|
import Notification from './service/notification';
|
|
5
5
|
import WalletAuthenticator from './wallet-authenticator';
|
|
6
6
|
import WalletHandlers from './wallet-handler';
|
|
@@ -12,8 +12,11 @@ import getWallet from './wallet';
|
|
|
12
12
|
import Component from './component/index';
|
|
13
13
|
import Security from './security/index';
|
|
14
14
|
import config, { TComponent } from './config';
|
|
15
|
-
|
|
16
|
-
export {
|
|
15
|
+
/** @deprecated Use BlockletService instead */
|
|
16
|
+
export { BlockletService as AuthService };
|
|
17
|
+
/** @deprecated Use BlockletService instead */
|
|
18
|
+
export { BlockletService as Auth };
|
|
19
|
+
export { BlockletService };
|
|
17
20
|
export { Notification as NotificationService };
|
|
18
21
|
export { Notification };
|
|
19
22
|
export { WalletHandlers };
|
package/lib/index.js
CHANGED
|
@@ -17,12 +17,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.config = exports.Security = exports.Component = exports.component = exports.middlewares = exports.env = exports.getWallet = exports.Database = exports.createConnectHandlers = exports.BlockletAuthenticator = exports.WalletAuthenticator = exports.WalletHandlers = exports.Notification = exports.NotificationService = exports.Auth = exports.AuthService = void 0;
|
|
20
|
+
exports.config = exports.Security = exports.Component = exports.component = exports.middlewares = exports.env = exports.getWallet = exports.Database = exports.createConnectHandlers = exports.BlockletAuthenticator = exports.WalletAuthenticator = exports.WalletHandlers = exports.Notification = exports.NotificationService = exports.BlockletService = exports.Auth = exports.AuthService = void 0;
|
|
21
21
|
const env_1 = __importDefault(require("@blocklet/env"));
|
|
22
22
|
exports.env = env_1.default;
|
|
23
|
-
const
|
|
24
|
-
exports.AuthService =
|
|
25
|
-
exports.Auth =
|
|
23
|
+
const blocklet_1 = __importDefault(require("./service/blocklet"));
|
|
24
|
+
exports.AuthService = blocklet_1.default;
|
|
25
|
+
exports.Auth = blocklet_1.default;
|
|
26
|
+
exports.BlockletService = blocklet_1.default;
|
|
26
27
|
const notification_1 = __importDefault(require("./service/notification"));
|
|
27
28
|
exports.NotificationService = notification_1.default;
|
|
28
29
|
exports.Notification = notification_1.default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import
|
|
2
|
+
import BlockletService from '../service/blocklet';
|
|
3
3
|
import { SessionUser, AuthMethod, KycMethod } from '../util/login';
|
|
4
4
|
type AuthOptions = {
|
|
5
5
|
roles?: string[];
|
|
@@ -12,6 +12,6 @@ declare const AuthMiddleware: {
|
|
|
12
12
|
({ roles, permissions, kyc, methods, getClient }?: AuthOptions): (req: Request & {
|
|
13
13
|
user?: SessionUser;
|
|
14
14
|
}, res: Response, next: NextFunction) => Promise<void>;
|
|
15
|
-
getServiceClient: () =>
|
|
15
|
+
getServiceClient: () => BlockletService;
|
|
16
16
|
};
|
|
17
17
|
export = AuthMiddleware;
|
package/lib/middlewares/auth.js
CHANGED
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const lru_cache_1 = require("lru-cache");
|
|
6
|
-
const
|
|
6
|
+
const blocklet_1 = __importDefault(require("../service/blocklet"));
|
|
7
7
|
const login_1 = require("../util/login");
|
|
8
8
|
const clients = {};
|
|
9
9
|
const getServiceClient = () => {
|
|
10
10
|
const appId = process.env.BLOCKLET_APP_ID;
|
|
11
11
|
if (!clients[appId]) {
|
|
12
|
-
clients[appId] = new
|
|
12
|
+
clients[appId] = new blocklet_1.default();
|
|
13
13
|
}
|
|
14
14
|
return clients[appId];
|
|
15
15
|
};
|
|
@@ -9,10 +9,10 @@ type RequestHeaders = {
|
|
|
9
9
|
cookie: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
declare class
|
|
12
|
+
declare class BlockletService {
|
|
13
13
|
constructor(httpEndpoint?: string);
|
|
14
14
|
}
|
|
15
|
-
interface
|
|
15
|
+
interface BlockletService {
|
|
16
16
|
login: (params: object) => Promise<{
|
|
17
17
|
user: Object;
|
|
18
18
|
token: string;
|
|
@@ -77,5 +77,8 @@ interface AuthService {
|
|
|
77
77
|
verifyAccessKey(params: OmitTeamDid<Client.RequestVerifyAccessKeyInput>): Promise<Client.ResponseAccessKey>;
|
|
78
78
|
getAccessKeys(params: OmitTeamDid<Client.RequestAccessKeysInput>): Promise<Client.ResponseAccessKeys>;
|
|
79
79
|
getAccessKey(params: OmitTeamDid<Client.RequestAccessKeyInput>): Promise<Client.ResponseAccessKey>;
|
|
80
|
+
getUserFollowers(args?: OmitTeamDid<Client.RequestUserFollowsInput>): Promise<Client.ResponseUserFollows>;
|
|
81
|
+
getUserFollowing(args?: OmitTeamDid<Client.RequestUserFollowsInput>): Promise<Client.ResponseUserFollows>;
|
|
82
|
+
getUserFollowStats(args?: OmitTeamDid<Client.RequestUserFollowsStatsInput>): Promise<Client.ResponseFollowStats>;
|
|
80
83
|
}
|
|
81
|
-
export =
|
|
84
|
+
export = BlockletService;
|
|
@@ -62,7 +62,7 @@ const fixAvatar = (user) => {
|
|
|
62
62
|
}
|
|
63
63
|
return user;
|
|
64
64
|
};
|
|
65
|
-
class
|
|
65
|
+
class BlockletClient extends server_js_1.default {
|
|
66
66
|
constructor(httpEndpoint) {
|
|
67
67
|
(0, check_blocklet_env_1.default)();
|
|
68
68
|
super(httpEndpoint || `http://${(0, parse_docker_endpoint_1.getServerHost)()}:${process.env.ABT_NODE_PORT}/api/gql`.trim(), `BlockletSDK/${VERSION}`);
|
|
@@ -81,13 +81,13 @@ class AuthClient extends server_js_1.default {
|
|
|
81
81
|
return headers;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
//
|
|
84
|
+
// Blocklet 相关的功能 API 都在这里
|
|
85
85
|
// core/state/lib/api/team.js L42
|
|
86
86
|
// 所有可配置调用的函数在这里,如果需要额外增加,则需要在这里新增对应的函数
|
|
87
87
|
// core/gql/lib/config.js L25
|
|
88
|
-
class
|
|
88
|
+
class BlockletService {
|
|
89
89
|
constructor(httpEndpoint) {
|
|
90
|
-
const client = new
|
|
90
|
+
const client = new BlockletClient(httpEndpoint);
|
|
91
91
|
const apiList = [
|
|
92
92
|
// session
|
|
93
93
|
'login',
|
|
@@ -106,6 +106,9 @@ class AuthService {
|
|
|
106
106
|
'updateUserApproval',
|
|
107
107
|
'updateUserTags',
|
|
108
108
|
'updateUserExtra',
|
|
109
|
+
'getUserFollowers',
|
|
110
|
+
'getUserFollowing',
|
|
111
|
+
'getUserFollowStats',
|
|
109
112
|
// updateUserInfo
|
|
110
113
|
'updateUserAddress',
|
|
111
114
|
'updateUserInfo',
|
|
@@ -296,6 +299,39 @@ class AuthService {
|
|
|
296
299
|
throw new Error((0, error_1.formatError)(err));
|
|
297
300
|
}
|
|
298
301
|
};
|
|
302
|
+
this.getUserFollowers = async (args) => {
|
|
303
|
+
try {
|
|
304
|
+
const res = await client.getUserFollowers({
|
|
305
|
+
input: { teamDid, ...args },
|
|
306
|
+
});
|
|
307
|
+
return res;
|
|
308
|
+
}
|
|
309
|
+
catch (err) {
|
|
310
|
+
throw new Error((0, error_1.formatError)(err));
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
this.getUserFollowing = async (args) => {
|
|
314
|
+
try {
|
|
315
|
+
const res = await client.getUserFollowing({
|
|
316
|
+
input: { teamDid, ...args },
|
|
317
|
+
});
|
|
318
|
+
return res;
|
|
319
|
+
}
|
|
320
|
+
catch (err) {
|
|
321
|
+
throw new Error((0, error_1.formatError)(err));
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
this.getUserFollowStats = async (args) => {
|
|
325
|
+
try {
|
|
326
|
+
const res = await client.getUserFollowStats({
|
|
327
|
+
input: { teamDid, ...args },
|
|
328
|
+
});
|
|
329
|
+
return res;
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
throw new Error((0, error_1.formatError)(err));
|
|
333
|
+
}
|
|
334
|
+
};
|
|
299
335
|
// eslint-disable-next-line no-constructor-return
|
|
300
336
|
return new Proxy(this, {
|
|
301
337
|
get(target, propKey) {
|
|
@@ -307,4 +343,4 @@ class AuthService {
|
|
|
307
343
|
});
|
|
308
344
|
}
|
|
309
345
|
}
|
|
310
|
-
module.exports =
|
|
346
|
+
module.exports = BlockletService;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { WalletAuthenticator as Authenticator } from '@arcblock/did-connect-js';
|
|
2
2
|
declare class WalletAuthenticator extends Authenticator {
|
|
3
3
|
constructor(options?: {});
|
|
4
|
+
/** @deprecated Use blockletClient instead */
|
|
4
5
|
private authClient;
|
|
6
|
+
private blockletClient;
|
|
5
7
|
}
|
|
6
8
|
export = WalletAuthenticator;
|
|
@@ -6,7 +6,7 @@ const did_connect_js_1 = require("@arcblock/did-connect-js");
|
|
|
6
6
|
const wallet_1 = __importDefault(require("./wallet"));
|
|
7
7
|
const check_blocklet_env_1 = __importDefault(require("./util/check-blocklet-env"));
|
|
8
8
|
const shared_1 = require("./connect/shared");
|
|
9
|
-
const
|
|
9
|
+
const blocklet_1 = __importDefault(require("./service/blocklet"));
|
|
10
10
|
class WalletAuthenticator extends did_connect_js_1.WalletAuthenticator {
|
|
11
11
|
constructor(options = {}) {
|
|
12
12
|
(0, check_blocklet_env_1.default)();
|
|
@@ -14,7 +14,8 @@ class WalletAuthenticator extends did_connect_js_1.WalletAuthenticator {
|
|
|
14
14
|
wallet: (0, wallet_1.default)().toJSON(),
|
|
15
15
|
...(0, shared_1.getAuthenticatorProps)(options),
|
|
16
16
|
});
|
|
17
|
-
this.
|
|
17
|
+
this.blockletClient = new blocklet_1.default();
|
|
18
|
+
this.authClient = this.blockletClient;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
module.exports = WalletAuthenticator;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.49-beta-
|
|
6
|
+
"version": "1.16.49-beta-20250823-082650-626c1473",
|
|
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,18 +27,18 @@
|
|
|
27
27
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abtnode/constant": "1.16.49-beta-
|
|
31
|
-
"@abtnode/db-cache": "1.16.49-beta-
|
|
32
|
-
"@abtnode/util": "1.16.49-beta-
|
|
30
|
+
"@abtnode/constant": "1.16.49-beta-20250823-082650-626c1473",
|
|
31
|
+
"@abtnode/db-cache": "1.16.49-beta-20250823-082650-626c1473",
|
|
32
|
+
"@abtnode/util": "1.16.49-beta-20250823-082650-626c1473",
|
|
33
33
|
"@arcblock/did": "1.22.2",
|
|
34
34
|
"@arcblock/did-connect-js": "1.22.2",
|
|
35
35
|
"@arcblock/jwt": "1.22.2",
|
|
36
36
|
"@arcblock/ws": "1.22.2",
|
|
37
|
-
"@blocklet/constant": "1.16.49-beta-
|
|
38
|
-
"@blocklet/env": "1.16.49-beta-
|
|
37
|
+
"@blocklet/constant": "1.16.49-beta-20250823-082650-626c1473",
|
|
38
|
+
"@blocklet/env": "1.16.49-beta-20250823-082650-626c1473",
|
|
39
39
|
"@blocklet/error": "^0.2.5",
|
|
40
|
-
"@blocklet/meta": "1.16.49-beta-
|
|
41
|
-
"@blocklet/server-js": "1.16.49-beta-
|
|
40
|
+
"@blocklet/meta": "1.16.49-beta-20250823-082650-626c1473",
|
|
41
|
+
"@blocklet/server-js": "1.16.49-beta-20250823-082650-626c1473",
|
|
42
42
|
"@blocklet/theme": "^3.1.25",
|
|
43
43
|
"@did-connect/authenticator": "^2.2.8",
|
|
44
44
|
"@did-connect/handler": "^2.2.8",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"ts-node": "^10.9.1",
|
|
86
86
|
"typescript": "^5.6.3"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "54d2281fc6f72dadd12ed86b38d5a4e150bcaba8"
|
|
89
89
|
}
|
package/service/auth.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../lib/service/blocklet');
|