@blocklet/sdk 1.16.24-beta-a02d4e5e → 1.16.24-beta-64150e24

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.
@@ -2,6 +2,7 @@ import { TNotification, TNotificationInput, TSendOptions } from '../types/notifi
2
2
  export type TNotificationSender = {
3
3
  appDid: string;
4
4
  appSk: string;
5
+ type?: 'server' | 'blocklet';
5
6
  };
6
7
  /**
7
8
  * @param {String|Array} receiver
@@ -14,12 +15,12 @@ export type TNotificationSender = {
14
15
  * @param {Object} options
15
16
  * @returns
16
17
  */
17
- declare const sendToUser: (receiver: string | string[], notification: TNotification | TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: {}, pathname?: string) => Promise<any>;
18
+ declare const sendToUser: (receiver: string | string[], notification: TNotification | TNotificationInput, { appDid, appSk, type }: TNotificationSender, port?: string, options?: {}, pathname?: string) => Promise<any>;
18
19
  declare const sendToAppChannel: (channel: string, event: string, notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: TSendOptions) => Promise<any>;
19
20
  declare const sendToRelay: (topic: string, event: string, data: any, { appDid, appSk }: TNotificationSender, port?: string) => Promise<any>;
20
21
  export { sendToUser, sendToAppChannel, sendToRelay };
21
22
  declare const _default: {
22
- sendToUser: (receiver: string | string[], notification: TNotification | TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: {}, pathname?: string) => Promise<any>;
23
+ sendToUser: (receiver: string | string[], notification: TNotification | TNotificationInput, { appDid, appSk, type }: TNotificationSender, port?: string, options?: {}, pathname?: string) => Promise<any>;
23
24
  sendToAppChannel: (channel: string, event: string, notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: TSendOptions) => Promise<any>;
24
25
  sendToRelay: (topic: string, event: string, data: any, { appDid, appSk }: TNotificationSender, port?: string) => Promise<any>;
25
26
  };
@@ -51,7 +51,7 @@ const getRequestHeaders = () => ({ 'User-Agent': `BlockletSDK/${VERSION}` });
51
51
  * @param {Object} options
52
52
  * @returns
53
53
  */
54
- const sendToUser = async (receiver, notification, { appDid, appSk }, port = process.env.ABT_NODE_SERVICE_PORT, options = {}, pathname = 'send-to-user') => {
54
+ const sendToUser = async (receiver, notification, { appDid, appSk, type }, port = process.env.ABT_NODE_SERVICE_PORT, options = {}, pathname = 'send-to-user') => {
55
55
  if (pathname === 'send-to-user') {
56
56
  await (0, index_1.validateReceiver)(receiver);
57
57
  }
@@ -67,7 +67,11 @@ const sendToUser = async (receiver, notification, { appDid, appSk }, port = proc
67
67
  const { data: res } = await axios.post(`http://127.0.0.1:${port}${constants_1.SERVICE_PREFIX}/api/${pathname}`, {
68
68
  apiVersion: VERSION,
69
69
  data: {
70
- sender: { appDid, token: JWT.sign(appDid, appSk) },
70
+ sender: {
71
+ appDid,
72
+ type,
73
+ token: JWT.sign(appDid, appSk),
74
+ },
71
75
  receiver,
72
76
  notification,
73
77
  options: opt,
@@ -171,7 +171,7 @@ const notificationSchema = Joi.object({
171
171
  checkUrl: Joi.string(),
172
172
  source: Joi.string(),
173
173
  // notification type
174
- title: Joi.string(),
174
+ title: Joi.string().allow(''),
175
175
  body: Joi.string(),
176
176
  severity: Joi.string().valid(...Object.values(SEVERITIES)),
177
177
  blocks: Joi.array().items(attachmentSchema).default([]),
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.24-beta-a02d4e5e",
6
+ "version": "1.16.24-beta-64150e24",
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,15 +27,15 @@
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.24-beta-a02d4e5e",
31
- "@abtnode/constant": "1.16.24-beta-a02d4e5e",
30
+ "@abtnode/client": "1.16.24-beta-64150e24",
31
+ "@abtnode/constant": "1.16.24-beta-64150e24",
32
32
  "@arcblock/did": "1.18.110",
33
33
  "@arcblock/did-auth": "1.18.110",
34
34
  "@arcblock/jwt": "1.18.110",
35
35
  "@arcblock/ws": "1.18.110",
36
- "@blocklet/constant": "1.16.24-beta-a02d4e5e",
37
- "@blocklet/env": "1.16.24-beta-a02d4e5e",
38
- "@blocklet/meta": "1.16.24-beta-a02d4e5e",
36
+ "@blocklet/constant": "1.16.24-beta-64150e24",
37
+ "@blocklet/env": "1.16.24-beta-64150e24",
38
+ "@blocklet/meta": "1.16.24-beta-64150e24",
39
39
  "@did-connect/authenticator": "^2.2.1",
40
40
  "@did-connect/handler": "^2.2.1",
41
41
  "@nedb/core": "^2.1.5",
@@ -76,5 +76,5 @@
76
76
  "ts-node": "^10.9.1",
77
77
  "typescript": "^5.0.4"
78
78
  },
79
- "gitHead": "bfe534f98c5a21bec765cb441a648e9f4edfe607"
79
+ "gitHead": "30c91a8e2790a0527ba336497f5032ba54ed4225"
80
80
  }