@blocklet/aigne-hub 0.4.61 → 0.5.1

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.
@@ -12,7 +12,7 @@ async function appStatus({ description }, { useAIKitService, ...options } = {})
12
12
  ? api_1.aiKitApi.get('/api/app/status', {
13
13
  params: { description },
14
14
  responseType: options.responseType,
15
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)({}) },
15
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)({})) },
16
16
  })
17
17
  : (0, component_1.call)({
18
18
  name: 'ai-kit',
@@ -44,7 +44,7 @@ async function cancelSubscription({ useAIKitService, ...options } = {}) {
44
44
  const response = await (0, api_1.catchAndRethrowUpstreamError)(useAIKitService
45
45
  ? api_1.aiKitApi.post('/api/app/subscription/cancel', {}, {
46
46
  responseType: options.responseType,
47
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)({}) },
47
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)({})) },
48
48
  })
49
49
  : (0, component_1.call)({
50
50
  name: 'ai-kit',
@@ -60,7 +60,7 @@ async function recoverSubscription({ useAIKitService, ...options } = {}) {
60
60
  const response = await (0, api_1.catchAndRethrowUpstreamError)(useAIKitService
61
61
  ? api_1.aiKitApi.post('/api/app/subscription/recover', {}, {
62
62
  responseType: options.responseType,
63
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)({}) },
63
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)({})) },
64
64
  })
65
65
  : (0, component_1.call)({
66
66
  name: 'ai-kit',
@@ -15,29 +15,32 @@ const constants_1 = require("../constants");
15
15
  const auth_1 = require("../utils/auth");
16
16
  function proxyToAIKit(path, { useAIKitService, proxyReqHeaders = ['accept', 'content-type'], proxyResHeaders = ['content-type', 'cache-control'], } = {}) {
17
17
  const parseReqBody = path !== '/api/v1/audio/transcriptions';
18
- return (req, res, next) => {
18
+ return async (req, res, next) => {
19
19
  var _a;
20
20
  const url = (0, ufo_1.parseURL)((0, ufo_1.withQuery)((0, ufo_1.joinURL)(useAIKitService ? constants_1.AI_KIT_BASE_URL : (0, component_1.getComponentWebEndpoint)('ai-kit'), path), req.query));
21
21
  const userDid = ((_a = req.user) === null || _a === void 0 ? void 0 : _a.did) || (req === null || req === void 0 ? void 0 : req.get('x-app-user-did'));
22
+ let additionalHeaders = {};
23
+ if (useAIKitService) {
24
+ additionalHeaders = await (0, auth_1.getRemoteComponentCallHeaders)(req.body || {}, userDid);
25
+ }
26
+ else {
27
+ const { iat, exp, sig, version } = await (0, verify_sign_1.getSignData)({
28
+ data: req.body,
29
+ params: req.query,
30
+ method: req.method,
31
+ url: (0, ufo_1.stringifyParsedURL)(url),
32
+ });
33
+ additionalHeaders = {
34
+ 'x-component-sig': sig,
35
+ 'x-component-sig-iat': iat,
36
+ 'x-component-sig-exp': exp,
37
+ 'x-component-sig-version': version,
38
+ };
39
+ }
22
40
  const proxyReq = (url.protocol === 'https:' ? https_1.default : http_1.default).request((0, ufo_1.stringifyParsedURL)(url), {
23
41
  headers: {
24
42
  ...(0, pick_1.default)(req.headers, ...proxyReqHeaders),
25
- ...(useAIKitService
26
- ? (0, auth_1.getRemoteComponentCallHeaders)(req.body || {}, userDid)
27
- : (() => {
28
- const { iat, exp, sig, version } = (0, verify_sign_1.getSignData)({
29
- data: req.body,
30
- params: req.query,
31
- method: req.method,
32
- url: (0, ufo_1.stringifyParsedURL)(url),
33
- });
34
- return {
35
- 'x-component-sig': sig,
36
- 'x-component-sig-iat': iat,
37
- 'x-component-sig-exp': exp,
38
- 'x-component-sig-version': version,
39
- };
40
- })()),
43
+ ...additionalHeaders,
41
44
  },
42
45
  method: req.method,
43
46
  }, (proxyRes) => {
@@ -25,7 +25,7 @@ async function status({ useAIKitService, ...options } = {}) {
25
25
  ? api_1.aiKitApi
26
26
  .get('/api/v1/status', {
27
27
  responseType: options.responseType,
28
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)({}) },
28
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)({})) },
29
29
  })
30
30
  .then((res) => res.data)
31
31
  : (0, component_1.call)({ name: 'ai-kit', method: 'GET', path: '/api/v1/status', responseType: options === null || options === void 0 ? void 0 : options.responseType }).then((res) => res.data));
@@ -40,7 +40,7 @@ async function chatCompletions(input, { useAIKitService, ...options } = {}) {
40
40
  method: 'POST',
41
41
  data: (0, json_stable_stringify_1.default)(input),
42
42
  headers: {
43
- ...(0, auth_1.getRemoteComponentCallHeaders)(input),
43
+ ...(await (0, auth_1.getRemoteComponentCallHeaders)(input)),
44
44
  Accept: 'text/event-stream',
45
45
  'Content-Type': 'application/json',
46
46
  },
@@ -89,7 +89,7 @@ async function imageGenerations(input, { useAIKitService, ...options } = {}) {
89
89
  const response = await (0, api_1.catchAndRethrowUpstreamError)(useAIKitService
90
90
  ? api_1.aiKitApi.post('/api/v1/image/generations', input, {
91
91
  responseType: options.responseType,
92
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)(input) },
92
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)(input)) },
93
93
  })
94
94
  : // @ts-ignore
95
95
  (0, component_1.call)({
@@ -107,7 +107,7 @@ async function embeddings(input, { useAIKitService, ...options } = {}) {
107
107
  const response = await (0, api_1.catchAndRethrowUpstreamError)(useAIKitService
108
108
  ? api_1.aiKitApi.post('/api/v1/embeddings', input, {
109
109
  responseType: options.responseType,
110
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)(input) },
110
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)(input)) },
111
111
  })
112
112
  : (0, component_1.call)({
113
113
  name: 'ai-kit',
@@ -127,10 +127,10 @@ async function audioTranscriptions(input, { useAIKitService, ...options } = {})
127
127
  const response = await (0, api_1.catchAndRethrowUpstreamError)(useAIKitService
128
128
  ? api_1.aiKitApi.post('/api/v1/audio/transcriptions', form, {
129
129
  responseType: options.responseType,
130
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)({}) },
130
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)({})) },
131
131
  })
132
- : (() => {
133
- const { iat, exp, sig, version } = (0, verify_sign_1.getSignData)({
132
+ : (async () => {
133
+ const { iat, exp, sig, version } = await (0, verify_sign_1.getSignData)({
134
134
  data: {},
135
135
  params: {},
136
136
  method: 'post',
@@ -154,7 +154,7 @@ async function audioSpeech(input, { useAIKitService } = {}) {
154
154
  const response = await (0, api_1.catchAndRethrowUpstreamError)(useAIKitService
155
155
  ? api_1.aiKitApi.post('/api/v1/audio/speech', input, {
156
156
  responseType: 'stream',
157
- headers: { ...(0, auth_1.getRemoteComponentCallHeaders)(input) },
157
+ headers: { ...(await (0, auth_1.getRemoteComponentCallHeaders)(input)) },
158
158
  })
159
159
  : (0, component_1.call)({
160
160
  name: 'ai-kit',
@@ -6,46 +6,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ensureAdmin = exports.wallet = void 0;
8
8
  exports.appIdFromPublicKey = appIdFromPublicKey;
9
- exports.verifyRemoteComponentCall = verifyRemoteComponentCall;
10
- exports.signRemoteComponentCall = signRemoteComponentCall;
11
9
  exports.getRemoteComponentCallHeaders = getRemoteComponentCallHeaders;
12
10
  exports.ensureRemoteComponentCall = ensureRemoteComponentCall;
13
11
  const did_1 = require("@arcblock/did");
14
12
  const middlewares_1 = require("@blocklet/sdk/lib/middlewares");
15
- const wallet_1 = __importDefault(require("@blocklet/sdk/lib/wallet"));
13
+ const wallet_1 = require("@blocklet/sdk/lib/wallet");
16
14
  const mcrypto_1 = require("@ocap/mcrypto");
17
15
  const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
18
16
  const error_1 = require("../error");
19
17
  const TOKEN_EXPIRES_IN_SECONDS = 60 * 10;
20
- exports.wallet = (0, wallet_1.default)();
18
+ exports.wallet = (0, wallet_1.getWallet)();
21
19
  const ADMIN_ROLES = ['owner', 'admin'];
22
20
  exports.ensureAdmin = (0, middlewares_1.auth)({ roles: ADMIN_ROLES });
23
21
  const signer = (0, mcrypto_1.getSigner)((0, did_1.DidType)('default').pk);
22
+ const getStringify = ({ appId, timestamp, data, userDid, }) => {
23
+ return (0, json_stable_stringify_1.default)({ appId, timestamp, data: data || {}, userDid });
24
+ };
24
25
  function hashData({ appId, timestamp, data, userDid, }) {
25
26
  const hasher = (0, mcrypto_1.getHasher)((0, did_1.DidType)('default').hash);
26
- return hasher((0, json_stable_stringify_1.default)({ appId, timestamp, data: data || {}, userDid }), 1);
27
+ return hasher(getStringify({ appId, timestamp, data, userDid }), 1);
27
28
  }
28
29
  function appIdFromPublicKey(publicKey) {
29
30
  return (0, did_1.fromPublicKey)(publicKey, (0, did_1.DidType)({ role: mcrypto_1.types.RoleType.ROLE_APPLICATION, pk: mcrypto_1.types.KeyType.ED25519, hash: mcrypto_1.types.HashType.SHA3 }));
30
31
  }
31
- function verifyRemoteComponentCall({ appId, timestamp, data, sig, pk, userDid, expiresIn = TOKEN_EXPIRES_IN_SECONDS, }) {
32
+ async function verifyRemoteComponentCall({ appId, timestamp, data, sig, pk, userDid, expiresIn = TOKEN_EXPIRES_IN_SECONDS, }) {
32
33
  if (Math.abs(Date.now() / 1000 - timestamp) > expiresIn) {
33
34
  throw new error_1.StatusCodeError(401, 'signature expired');
34
35
  }
35
36
  return signer.verify(hashData({ appId, timestamp, data, userDid }), sig, pk);
36
37
  }
37
- function signRemoteComponentCall({ data, userDid }) {
38
+ async function signRemoteComponentCall({ data, userDid }) {
38
39
  const appId = exports.wallet.address;
39
40
  const timestamp = Math.round(Date.now() / 1000);
41
+ const sig = await exports.wallet.sign(getStringify({ appId, timestamp, data, userDid }));
40
42
  return {
41
43
  appId,
42
44
  timestamp,
43
45
  userDid,
44
- sig: signer.sign(hashData({ appId, timestamp, data, userDid }), exports.wallet.secretKey),
46
+ sig,
45
47
  };
46
48
  }
47
- function getRemoteComponentCallHeaders(data, userDid) {
48
- const { appId, timestamp, sig } = signRemoteComponentCall({ data, userDid });
49
+ async function getRemoteComponentCallHeaders(data = {}, userDid) {
50
+ const { appId, timestamp, sig } = await signRemoteComponentCall({ data, userDid });
49
51
  return {
50
52
  'x-app-id': appId,
51
53
  'x-timestamp': timestamp.toString(),
@@ -67,14 +69,14 @@ function ensureRemoteComponentCall(getPublicKey, fallback) {
67
69
  if (appIdFromPublicKey(pk) !== appId) {
68
70
  throw new error_1.StatusCodeError(401, 'appId and public key not match');
69
71
  }
70
- if (!verifyRemoteComponentCall({
72
+ if (!(await verifyRemoteComponentCall({
71
73
  appId,
72
74
  sig,
73
75
  timestamp: parseInt(timestamp, 10),
74
76
  data: req.body,
75
77
  pk,
76
78
  userDid,
77
- })) {
79
+ }))) {
78
80
  throw new error_1.StatusCodeError(401, 'Validate signature error');
79
81
  }
80
82
  req.appClient = {
@@ -6,7 +6,7 @@ export async function appStatus({ description }, { useAIKitService, ...options }
6
6
  ? aiKitApi.get('/api/app/status', {
7
7
  params: { description },
8
8
  responseType: options.responseType,
9
- headers: { ...getRemoteComponentCallHeaders({}) },
9
+ headers: { ...(await getRemoteComponentCallHeaders({})) },
10
10
  })
11
11
  : call({
12
12
  name: 'ai-kit',
@@ -38,7 +38,7 @@ export async function cancelSubscription({ useAIKitService, ...options } = {}) {
38
38
  const response = await catchAndRethrowUpstreamError(useAIKitService
39
39
  ? aiKitApi.post('/api/app/subscription/cancel', {}, {
40
40
  responseType: options.responseType,
41
- headers: { ...getRemoteComponentCallHeaders({}) },
41
+ headers: { ...(await getRemoteComponentCallHeaders({})) },
42
42
  })
43
43
  : call({
44
44
  name: 'ai-kit',
@@ -54,7 +54,7 @@ export async function recoverSubscription({ useAIKitService, ...options } = {})
54
54
  const response = await catchAndRethrowUpstreamError(useAIKitService
55
55
  ? aiKitApi.post('/api/app/subscription/recover', {}, {
56
56
  responseType: options.responseType,
57
- headers: { ...getRemoteComponentCallHeaders({}) },
57
+ headers: { ...(await getRemoteComponentCallHeaders({})) },
58
58
  })
59
59
  : call({
60
60
  name: 'ai-kit',
@@ -9,29 +9,32 @@ import { AI_KIT_BASE_URL } from '../constants';
9
9
  import { getRemoteComponentCallHeaders } from '../utils/auth';
10
10
  export function proxyToAIKit(path, { useAIKitService, proxyReqHeaders = ['accept', 'content-type'], proxyResHeaders = ['content-type', 'cache-control'], } = {}) {
11
11
  const parseReqBody = path !== '/api/v1/audio/transcriptions';
12
- return (req, res, next) => {
12
+ return async (req, res, next) => {
13
13
  var _a;
14
14
  const url = parseURL(withQuery(joinURL(useAIKitService ? AI_KIT_BASE_URL : getComponentWebEndpoint('ai-kit'), path), req.query));
15
15
  const userDid = ((_a = req.user) === null || _a === void 0 ? void 0 : _a.did) || (req === null || req === void 0 ? void 0 : req.get('x-app-user-did'));
16
+ let additionalHeaders = {};
17
+ if (useAIKitService) {
18
+ additionalHeaders = await getRemoteComponentCallHeaders(req.body || {}, userDid);
19
+ }
20
+ else {
21
+ const { iat, exp, sig, version } = await getSignData({
22
+ data: req.body,
23
+ params: req.query,
24
+ method: req.method,
25
+ url: stringifyParsedURL(url),
26
+ });
27
+ additionalHeaders = {
28
+ 'x-component-sig': sig,
29
+ 'x-component-sig-iat': iat,
30
+ 'x-component-sig-exp': exp,
31
+ 'x-component-sig-version': version,
32
+ };
33
+ }
16
34
  const proxyReq = (url.protocol === 'https:' ? https : http).request(stringifyParsedURL(url), {
17
35
  headers: {
18
36
  ...pick(req.headers, ...proxyReqHeaders),
19
- ...(useAIKitService
20
- ? getRemoteComponentCallHeaders(req.body || {}, userDid)
21
- : (() => {
22
- const { iat, exp, sig, version } = getSignData({
23
- data: req.body,
24
- params: req.query,
25
- method: req.method,
26
- url: stringifyParsedURL(url),
27
- });
28
- return {
29
- 'x-component-sig': sig,
30
- 'x-component-sig-iat': iat,
31
- 'x-component-sig-exp': exp,
32
- 'x-component-sig-version': version,
33
- };
34
- })()),
37
+ ...additionalHeaders,
35
38
  },
36
39
  method: req.method,
37
40
  }, (proxyRes) => {
@@ -14,7 +14,7 @@ export async function status({ useAIKitService, ...options } = {}) {
14
14
  ? aiKitApi
15
15
  .get('/api/v1/status', {
16
16
  responseType: options.responseType,
17
- headers: { ...getRemoteComponentCallHeaders({}) },
17
+ headers: { ...(await getRemoteComponentCallHeaders({})) },
18
18
  })
19
19
  .then((res) => res.data)
20
20
  : call({ name: 'ai-kit', method: 'GET', path: '/api/v1/status', responseType: options === null || options === void 0 ? void 0 : options.responseType }).then((res) => res.data));
@@ -29,7 +29,7 @@ export async function chatCompletions(input, { useAIKitService, ...options } = {
29
29
  method: 'POST',
30
30
  data: stringify(input),
31
31
  headers: {
32
- ...getRemoteComponentCallHeaders(input),
32
+ ...(await getRemoteComponentCallHeaders(input)),
33
33
  Accept: 'text/event-stream',
34
34
  'Content-Type': 'application/json',
35
35
  },
@@ -78,7 +78,7 @@ export async function imageGenerations(input, { useAIKitService, ...options } =
78
78
  const response = await catchAndRethrowUpstreamError(useAIKitService
79
79
  ? aiKitApi.post('/api/v1/image/generations', input, {
80
80
  responseType: options.responseType,
81
- headers: { ...getRemoteComponentCallHeaders(input) },
81
+ headers: { ...(await getRemoteComponentCallHeaders(input)) },
82
82
  })
83
83
  : // @ts-ignore
84
84
  call({
@@ -96,7 +96,7 @@ export async function embeddings(input, { useAIKitService, ...options } = {}) {
96
96
  const response = await catchAndRethrowUpstreamError(useAIKitService
97
97
  ? aiKitApi.post('/api/v1/embeddings', input, {
98
98
  responseType: options.responseType,
99
- headers: { ...getRemoteComponentCallHeaders(input) },
99
+ headers: { ...(await getRemoteComponentCallHeaders(input)) },
100
100
  })
101
101
  : call({
102
102
  name: 'ai-kit',
@@ -116,10 +116,10 @@ export async function audioTranscriptions(input, { useAIKitService, ...options }
116
116
  const response = await catchAndRethrowUpstreamError(useAIKitService
117
117
  ? aiKitApi.post('/api/v1/audio/transcriptions', form, {
118
118
  responseType: options.responseType,
119
- headers: { ...getRemoteComponentCallHeaders({}) },
119
+ headers: { ...(await getRemoteComponentCallHeaders({})) },
120
120
  })
121
- : (() => {
122
- const { iat, exp, sig, version } = getSignData({
121
+ : (async () => {
122
+ const { iat, exp, sig, version } = await getSignData({
123
123
  data: {},
124
124
  params: {},
125
125
  method: 'post',
@@ -143,7 +143,7 @@ export async function audioSpeech(input, { useAIKitService } = {}) {
143
143
  const response = await catchAndRethrowUpstreamError(useAIKitService
144
144
  ? aiKitApi.post('/api/v1/audio/speech', input, {
145
145
  responseType: 'stream',
146
- headers: { ...getRemoteComponentCallHeaders(input) },
146
+ headers: { ...(await getRemoteComponentCallHeaders(input)) },
147
147
  })
148
148
  : call({
149
149
  name: 'ai-kit',
@@ -1,7 +1,7 @@
1
1
  /// <reference path="./auth.type.d.ts" />
2
2
  import { DidType, fromPublicKey } from '@arcblock/did';
3
3
  import { auth } from '@blocklet/sdk/lib/middlewares';
4
- import getWallet from '@blocklet/sdk/lib/wallet';
4
+ import { getWallet } from '@blocklet/sdk/lib/wallet';
5
5
  import { getHasher, getSigner, types } from '@ocap/mcrypto';
6
6
  import stringify from 'json-stable-stringify';
7
7
  import { StatusCodeError } from '../error';
@@ -10,31 +10,35 @@ export const wallet = getWallet();
10
10
  const ADMIN_ROLES = ['owner', 'admin'];
11
11
  export const ensureAdmin = auth({ roles: ADMIN_ROLES });
12
12
  const signer = getSigner(DidType('default').pk);
13
+ const getStringify = ({ appId, timestamp, data, userDid, }) => {
14
+ return stringify({ appId, timestamp, data: data || {}, userDid });
15
+ };
13
16
  function hashData({ appId, timestamp, data, userDid, }) {
14
17
  const hasher = getHasher(DidType('default').hash);
15
- return hasher(stringify({ appId, timestamp, data: data || {}, userDid }), 1);
18
+ return hasher(getStringify({ appId, timestamp, data, userDid }), 1);
16
19
  }
17
20
  export function appIdFromPublicKey(publicKey) {
18
21
  return fromPublicKey(publicKey, DidType({ role: types.RoleType.ROLE_APPLICATION, pk: types.KeyType.ED25519, hash: types.HashType.SHA3 }));
19
22
  }
20
- export function verifyRemoteComponentCall({ appId, timestamp, data, sig, pk, userDid, expiresIn = TOKEN_EXPIRES_IN_SECONDS, }) {
23
+ async function verifyRemoteComponentCall({ appId, timestamp, data, sig, pk, userDid, expiresIn = TOKEN_EXPIRES_IN_SECONDS, }) {
21
24
  if (Math.abs(Date.now() / 1000 - timestamp) > expiresIn) {
22
25
  throw new StatusCodeError(401, 'signature expired');
23
26
  }
24
27
  return signer.verify(hashData({ appId, timestamp, data, userDid }), sig, pk);
25
28
  }
26
- export function signRemoteComponentCall({ data, userDid }) {
29
+ async function signRemoteComponentCall({ data, userDid }) {
27
30
  const appId = wallet.address;
28
31
  const timestamp = Math.round(Date.now() / 1000);
32
+ const sig = await wallet.sign(getStringify({ appId, timestamp, data, userDid }));
29
33
  return {
30
34
  appId,
31
35
  timestamp,
32
36
  userDid,
33
- sig: signer.sign(hashData({ appId, timestamp, data, userDid }), wallet.secretKey),
37
+ sig,
34
38
  };
35
39
  }
36
- export function getRemoteComponentCallHeaders(data, userDid) {
37
- const { appId, timestamp, sig } = signRemoteComponentCall({ data, userDid });
40
+ export async function getRemoteComponentCallHeaders(data = {}, userDid) {
41
+ const { appId, timestamp, sig } = await signRemoteComponentCall({ data, userDid });
38
42
  return {
39
43
  'x-app-id': appId,
40
44
  'x-timestamp': timestamp.toString(),
@@ -56,14 +60,14 @@ export function ensureRemoteComponentCall(getPublicKey, fallback) {
56
60
  if (appIdFromPublicKey(pk) !== appId) {
57
61
  throw new StatusCodeError(401, 'appId and public key not match');
58
62
  }
59
- if (!verifyRemoteComponentCall({
63
+ if (!(await verifyRemoteComponentCall({
60
64
  appId,
61
65
  sig,
62
66
  timestamp: parseInt(timestamp, 10),
63
67
  data: req.body,
64
68
  pk,
65
69
  userDid,
66
- })) {
70
+ }))) {
67
71
  throw new StatusCodeError(401, 'Validate signature error');
68
72
  }
69
73
  req.appClient = {
@@ -3,4 +3,4 @@ export declare function proxyToAIKit(path: '/api/v1/status' | '/api/v1/chat/comp
3
3
  useAIKitService?: boolean;
4
4
  proxyReqHeaders?: string[];
5
5
  proxyResHeaders?: string[];
6
- }): (req: Request, res: Response, next: NextFunction) => void;
6
+ }): (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -1,33 +1,14 @@
1
1
  import type { BytesType } from '@ocap/util';
2
- import type { WalletObject } from '@ocap/wallet';
3
2
  import type { NextFunction, Request, Response } from 'express';
4
- export declare const wallet: WalletObject;
3
+ export declare const wallet: import("@ocap/wallet").WalletObject<string>;
5
4
  export declare const ensureAdmin: (req: Request & {
6
5
  user?: import("@blocklet/sdk/lib/util/login").SessionUser;
7
6
  }, res: Response, next: NextFunction) => Promise<void>;
8
7
  export declare function appIdFromPublicKey(publicKey: BytesType): string;
9
- export declare function verifyRemoteComponentCall({ appId, timestamp, data, sig, pk, userDid, expiresIn, }: {
10
- appId: string;
11
- timestamp: number;
12
- data: object;
13
- sig: string;
14
- pk: BytesType;
15
- userDid?: string;
16
- expiresIn?: number;
17
- }): boolean;
18
- export declare function signRemoteComponentCall({ data, userDid }: {
19
- data: object;
20
- userDid?: string;
21
- }): {
22
- appId: string;
23
- timestamp: number;
24
- userDid: string | undefined;
25
- sig: string;
26
- };
27
- export declare function getRemoteComponentCallHeaders(data: object, userDid?: string): {
8
+ export declare function getRemoteComponentCallHeaders(data?: object, userDid?: string): Promise<{
28
9
  'x-app-id': string;
29
10
  'x-timestamp': string;
30
11
  'x-component-sig': string;
31
12
  'x-app-user-did': string;
32
- };
13
+ }>;
33
14
  export declare function ensureRemoteComponentCall(getPublicKey: (appId: string) => Promise<BytesType>, fallback?: (req: Request, res: Response, next: NextFunction) => any): (req: Request, res: Response, next: NextFunction) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/aigne-hub",
3
- "version": "0.4.61",
3
+ "version": "0.5.1",
4
4
  "description": "The react.js component library for AIGNE Hub",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -100,12 +100,12 @@
100
100
  "react": "^18.2.0"
101
101
  },
102
102
  "dependencies": {
103
- "@arcblock/did": "^1.25.6",
104
- "@arcblock/ux": "^3.1.46",
103
+ "@arcblock/did": "^1.26.3",
104
+ "@arcblock/ux": "^3.1.53",
105
105
  "@blocklet/error": "0.2.5",
106
- "@blocklet/logger": "^1.16.53-beta-20251011-054719-4ed2f6b7",
107
- "@blocklet/payment-js": "^1.21.11",
108
- "@blocklet/sdk": "^1.16.53-beta-20251011-054719-4ed2f6b7",
106
+ "@blocklet/logger": "^1.16.54-beta-20251028-092308-569763e6",
107
+ "@blocklet/payment-js": "^1.22.0",
108
+ "@blocklet/sdk": "^1.16.54-beta-20251028-092308-569763e6",
109
109
  "@emotion/css": "^11.13.5",
110
110
  "@emotion/react": "^11.14.0",
111
111
  "@emotion/styled": "^11.14.1",
@@ -113,8 +113,8 @@
113
113
  "@mui/lab": "^7.0.0-beta.14",
114
114
  "@mui/material": "^7.2.0",
115
115
  "@mui/system": "^7.2.0",
116
- "@ocap/mcrypto": "^1.25.6",
117
- "@ocap/util": "^1.25.6",
116
+ "@ocap/mcrypto": "^1.26.3",
117
+ "@ocap/util": "^1.26.3",
118
118
  "@types/express": "^5.0.3",
119
119
  "ahooks": "^3.8.1",
120
120
  "axios": "^1.7.4",