@blocklet/sdk 1.8.66-beta-7f4224af → 1.8.66

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.
@@ -11,7 +11,6 @@ type $TSFixMe = any;
11
11
  * @returns
12
12
  */
13
13
  declare const doSendToUser: (receiver: string | string[], notification: TNotificationInput, options?: TSendOptions) => Promise<any>;
14
- declare const doSendToRelay: (topic: string, event: string, data: any) => Promise<any>;
15
14
  /**
16
15
  *
17
16
  * @param {Notification} notification
@@ -31,11 +30,9 @@ export declare const _message: {
31
30
  off: any;
32
31
  };
33
32
  export { doSendToUser as sendToUser };
34
- export { doSendToRelay as sendToRelay };
35
33
  export { broadcast };
36
34
  declare const _default: {
37
35
  sendToUser: (receiver: string | string[], notification: TNotificationInput, options?: TSendOptions) => Promise<any>;
38
- sendToRelay: (topic: string, event: string, data: any) => Promise<any>;
39
36
  broadcast: (notification: TNotificationInput, options?: TSendOptions) => Promise<any>;
40
37
  on: (event: string, cb?: any) => EventEmitter;
41
38
  off: any;
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.broadcast = exports.sendToRelay = exports.sendToUser = exports._message = exports.off = exports.on = void 0;
38
+ exports.broadcast = exports.sendToUser = exports._message = exports.off = exports.on = void 0;
39
39
  /* eslint-disable @typescript-eslint/naming-convention */
40
40
  const Jwt = __importStar(require("@arcblock/jwt"));
41
41
  const events_1 = __importDefault(require("events"));
@@ -63,11 +63,6 @@ const doSendToUser = (receiver, notification, options) => __awaiter(void 0, void
63
63
  return (0, send_notification_1.sendToUser)(receiver, notification, getSender(), process.env.ABT_NODE_SERVICE_PORT, options);
64
64
  });
65
65
  exports.sendToUser = doSendToUser;
66
- const doSendToRelay = (topic, event, data) => __awaiter(void 0, void 0, void 0, function* () {
67
- (0, check_blocklet_env_1.default)();
68
- return (0, send_notification_1.sendToRelay)(topic, event, data, getSender(), process.env.ABT_NODE_SERVICE_PORT);
69
- });
70
- exports.sendToRelay = doSendToRelay;
71
66
  /**
72
67
  *
73
68
  * @param {Notification} notification
@@ -183,7 +178,6 @@ exports._message = {
183
178
  };
184
179
  exports.default = {
185
180
  sendToUser: doSendToUser,
186
- sendToRelay: doSendToRelay,
187
181
  broadcast,
188
182
  on: exports.on,
189
183
  off: exports.off,
@@ -16,11 +16,10 @@ export type TNotificationSender = {
16
16
  */
17
17
  declare const sendToUser: (receiver: string | string[], notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: {}) => Promise<any>;
18
18
  declare const sendToAppChannel: (channel: string, event: string, notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: TSendOptions) => Promise<any>;
19
- declare const sendToRelay: (topic: string, event: string, data: any, { appDid, appSk }: TNotificationSender, port?: string) => Promise<any>;
20
- export { sendToUser, sendToAppChannel, sendToRelay };
19
+ export { sendToUser };
20
+ export { sendToAppChannel };
21
21
  declare const _default: {
22
22
  sendToUser: (receiver: string | string[], notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: {}) => Promise<any>;
23
23
  sendToAppChannel: (channel: string, event: string, notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: TSendOptions) => Promise<any>;
24
- sendToRelay: (topic: string, event: string, data: any, { appDid, appSk }: TNotificationSender, port?: string) => Promise<any>;
25
24
  };
26
25
  export default _default;
@@ -35,12 +35,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.sendToRelay = exports.sendToAppChannel = exports.sendToUser = void 0;
38
+ exports.sendToAppChannel = exports.sendToUser = void 0;
39
39
  const axios_1 = __importDefault(require("axios"));
40
40
  const pick_1 = __importDefault(require("lodash/pick"));
41
41
  const JWT = __importStar(require("@arcblock/jwt"));
42
42
  const constant_1 = __importDefault(require("@abtnode/constant"));
43
- const channel_1 = require("@blocklet/meta/lib/channel");
44
43
  const index_1 = require("../validators/index");
45
44
  const constants_1 = require("./constants");
46
45
  const version_1 = require("../version");
@@ -127,39 +126,7 @@ const sendToAppChannel = (channel, event, notification, { appDid, appSk }, port
127
126
  }
128
127
  });
129
128
  exports.sendToAppChannel = sendToAppChannel;
130
- const sendToRelay = (topic, event, data, { appDid, appSk }, port = process.env.ABT_NODE_SERVICE_PORT) => __awaiter(void 0, void 0, void 0, function* () {
131
- if (!topic) {
132
- throw new Error('topic is required');
133
- }
134
- if (!event) {
135
- throw new Error('event is required');
136
- }
137
- if (!data) {
138
- throw new Error('data is required');
139
- }
140
- try {
141
- const { data: res } = yield axios.post(`http://127.0.0.1:${port}${constants_1.SERVICE_PREFIX}/relay/api/send-to-relay-channel`, {
142
- apiVersion: VERSION,
143
- data: {
144
- sender: { appDid, token: JWT.sign(appDid, appSk) },
145
- channel: (0, channel_1.getRelayChannel)(appDid, topic),
146
- event,
147
- data,
148
- },
149
- }, {
150
- timeout: 60 * 1000,
151
- headers: getRequestHeaders(),
152
- });
153
- return res;
154
- }
155
- catch (err) {
156
- console.error(err.response ? err.response.data : err);
157
- throw new Error(err.response ? err.response.data : err.message);
158
- }
159
- });
160
- exports.sendToRelay = sendToRelay;
161
129
  exports.default = {
162
130
  sendToUser,
163
131
  sendToAppChannel,
164
- sendToRelay,
165
132
  };
@@ -1,15 +1,13 @@
1
1
  import { WalletHandlers as Handler } from '@arcblock/did-auth';
2
2
  declare class WalletHandlers extends Handler {
3
3
  enableConnect: boolean;
4
- sendNotificationFn: Function;
5
- sendToRelayFn: Function;
4
+ sendNotificationFn: $TSFixMe;
6
5
  /**
7
- * @param {boolean} params.autoConnect enable auto connect to wallet (wallet does not need to scan qr code)
8
- * @param {boolean} params.connectedDidOnly only current login did or connected did can connect
9
- * @param {function} [params.sendNotificationFn] use in a non-blocklet environment
10
- * @param {function} [params.sendToRelayFn]
6
+ * @param {boolean} autoConnect enable auto connect to wallet (wallet does not need to scan qr code)
7
+ * @param {boolean} connectedDidOnly only current login did or connected did can connect
8
+ * @param {function} sendNotificationFn use in a non-blocklet environment
11
9
  */
12
- constructor({ autoConnect, connectedDidOnly, sendNotificationFn, sendToRelayFn, options, ...opts }: any);
10
+ constructor({ autoConnect, connectedDidOnly, sendNotificationFn, options, ...opts }: $TSFixMe);
13
11
  getConnectedDid: ({ req, didwallet, extraParams }: $TSFixMe) => any;
14
12
  attach({ onStart, ...opts }: {
15
13
  [x: string]: any;
@@ -56,13 +56,16 @@ const inMobileWallet = (didwallet) => {
56
56
  };
57
57
  class WalletHandlers extends did_auth_1.WalletHandlers {
58
58
  /**
59
- * @param {boolean} params.autoConnect enable auto connect to wallet (wallet does not need to scan qr code)
60
- * @param {boolean} params.connectedDidOnly only current login did or connected did can connect
61
- * @param {function} [params.sendNotificationFn] use in a non-blocklet environment
62
- * @param {function} [params.sendToRelayFn]
59
+ * @param {boolean} autoConnect enable auto connect to wallet (wallet does not need to scan qr code)
60
+ * @param {boolean} connectedDidOnly only current login did or connected did can connect
61
+ * @param {function} sendNotificationFn use in a non-blocklet environment
63
62
  */
64
63
  constructor(_a) {
65
- var { autoConnect = true, connectedDidOnly = false, sendNotificationFn = null, sendToRelayFn = null, options = {} } = _a, opts = __rest(_a, ["autoConnect", "connectedDidOnly", "sendNotificationFn", "sendToRelayFn", "options"]);
64
+ var { autoConnect = true, connectedDidOnly = false, sendNotificationFn, options = {} } = _a, opts = __rest(_a, ["autoConnect", "connectedDidOnly", "sendNotificationFn", "options"]);
65
+ // FIXME: wait check
66
+ // if (autoConnect && connectedDidOnly) {
67
+ // options.sessionDidKey = CONNECTED_DID_KEY;
68
+ // }
66
69
  super(Object.assign({ options: Object.assign(Object.assign({}, options), {
67
70
  sessionDidKey: autoConnect && connectedDidOnly ? CONNECTED_DID_KEY : options === null || options === void 0 ? void 0 : options.sessionDidKey,
68
71
  }) }, opts));
@@ -80,11 +83,6 @@ class WalletHandlers extends did_auth_1.WalletHandlers {
80
83
  };
81
84
  this.enableConnect = !!autoConnect;
82
85
  this.sendNotificationFn = sendNotificationFn || notification_1.sendToUser.bind(notification_1.default);
83
- this.sendToRelayFn = sendToRelayFn || notification_1.sendToRelay.bind(notification_1.default);
84
- // @ts-ignore
85
- this.on('updated', (session) => {
86
- this.sendToRelayFn({ topic: session.token, event: 'updated', data: session }).catch(console.error);
87
- });
88
86
  }
89
87
  attach(_a) {
90
88
  var { onStart = noop } = _a, opts = __rest(_a, ["onStart"]);
@@ -98,8 +96,9 @@ class WalletHandlers extends did_auth_1.WalletHandlers {
98
96
  // send notification to wallet to trigger wallet to auto connect
99
97
  if (connectedDid) {
100
98
  // wallet use check url to check status of the session
101
- let checkUrl;
99
+ let checkUrl = '';
102
100
  try {
101
+ // @ts-expect-error TS(2322) FIXME: Type 'URL' is not assignable to type 'string'.
103
102
  checkUrl = new URL(decodeURIComponent(new URL(params.deepLink).searchParams.get('url')));
104
103
  checkUrl.pathname = checkUrl.pathname.replace(/auth$/, 'status');
105
104
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.66-beta-7f4224af",
6
+ "version": "1.8.66",
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",
@@ -26,19 +26,18 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.8.66-beta-7f4224af",
30
- "@abtnode/constant": "1.8.66-beta-7f4224af",
31
- "@abtnode/util": "1.8.66-beta-7f4224af",
32
- "@arcblock/did-auth": "1.18.47",
33
- "@arcblock/jwt": "1.18.47",
34
- "@arcblock/ws": "1.18.47",
35
- "@blocklet/constant": "1.8.66-beta-7f4224af",
36
- "@blocklet/meta": "1.8.66-beta-7f4224af",
37
- "@did-connect/authenticator": "^2.1.35",
38
- "@did-connect/handler": "^2.1.35",
29
+ "@abtnode/client": "1.8.66",
30
+ "@abtnode/constant": "1.8.66",
31
+ "@arcblock/did-auth": "1.18.42",
32
+ "@arcblock/jwt": "1.18.42",
33
+ "@arcblock/ws": "1.18.42",
34
+ "@blocklet/constant": "1.8.66",
35
+ "@blocklet/meta": "1.8.66",
36
+ "@did-connect/authenticator": "^2.1.34",
37
+ "@did-connect/handler": "^2.1.34",
39
38
  "@nedb/core": "^2.1.5",
40
- "@ocap/mcrypto": "1.18.47",
41
- "@ocap/wallet": "1.18.47",
39
+ "@ocap/mcrypto": "1.18.42",
40
+ "@ocap/wallet": "1.18.42",
42
41
  "axios": "^0.27.2",
43
42
  "fs-extra": "^10.1.0",
44
43
  "joi": "17.7.0",
@@ -69,5 +68,5 @@
69
68
  "ts-node": "^10.9.1",
70
69
  "typescript": "^4.8.4"
71
70
  },
72
- "gitHead": "72d418f63ecb76b1d5d62edbcc5f336cb62bf308"
71
+ "gitHead": "282247fd0ce6702e1d6920e90e2b3be0408cf879"
73
72
  }