@blocklet/sdk 1.8.68 → 1.8.69-beta-54faead3

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.
@@ -22,26 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __rest = (this && this.__rest) || function (s, e) {
35
- var t = {};
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
- t[p] = s[p];
38
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
- t[p[i]] = s[p[i]];
42
- }
43
- return t;
44
- };
45
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
27
  };
@@ -56,19 +36,21 @@ const inMobileWallet = (didwallet) => {
56
36
  };
57
37
  class WalletHandlers extends did_auth_1.WalletHandlers {
58
38
  /**
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
39
+ * @param {boolean} params.autoConnect enable auto connect to wallet (wallet does not need to scan qr code)
40
+ * @param {boolean} params.connectedDidOnly only current login did or connected did can connect
41
+ * @param {function} [params.sendNotificationFn] use in a non-blocklet environment
42
+ * @param {function} [params.sendToRelayFn]
62
43
  */
63
- constructor(_a) {
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
- // }
69
- super(Object.assign({ options: Object.assign(Object.assign({}, options), {
70
- sessionDidKey: autoConnect && connectedDidOnly ? CONNECTED_DID_KEY : options === null || options === void 0 ? void 0 : options.sessionDidKey,
71
- }) }, opts));
44
+ constructor({ autoConnect = true, connectedDidOnly = false, sendNotificationFn = null, sendToRelayFn = null, options = {}, ...opts }) {
45
+ super({
46
+ options: {
47
+ ...options,
48
+ ...{
49
+ sessionDidKey: autoConnect && connectedDidOnly ? CONNECTED_DID_KEY : options?.sessionDidKey,
50
+ },
51
+ },
52
+ ...opts,
53
+ });
72
54
  this.getConnectedDid = ({ req, didwallet, extraParams }) => {
73
55
  if (extraParams && extraParams.autoConnect === 'false') {
74
56
  return null;
@@ -83,12 +65,16 @@ class WalletHandlers extends did_auth_1.WalletHandlers {
83
65
  };
84
66
  this.enableConnect = !!autoConnect;
85
67
  this.sendNotificationFn = sendNotificationFn || notification_1.sendToUser.bind(notification_1.default);
68
+ this.sendToRelayFn = sendToRelayFn || notification_1.sendToRelay.bind(notification_1.default);
69
+ // @ts-ignore
70
+ this.on('updated', (session) => {
71
+ this.sendToRelayFn(session.token, 'updated', session).catch(console.error);
72
+ });
86
73
  }
87
- attach(_a) {
88
- var { onStart = noop } = _a, opts = __rest(_a, ["onStart"]);
89
- const realOnStart = (params) => __awaiter(this, void 0, void 0, function* () {
74
+ attach({ onStart = noop, ...opts }) {
75
+ const realOnStart = async (params) => {
90
76
  // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1.
91
- const extra = (yield onStart(params)) || {};
77
+ const extra = (await onStart(params)) || {};
92
78
  const connectedDid = this.getConnectedDid(params);
93
79
  // fill extra
94
80
  extra.connectedDid = connectedDid || '';
@@ -96,9 +82,8 @@ class WalletHandlers extends did_auth_1.WalletHandlers {
96
82
  // send notification to wallet to trigger wallet to auto connect
97
83
  if (connectedDid) {
98
84
  // wallet use check url to check status of the session
99
- let checkUrl = '';
85
+ let checkUrl;
100
86
  try {
101
- // @ts-expect-error TS(2322) FIXME: Type 'URL' is not assignable to type 'string'.
102
87
  checkUrl = new URL(decodeURIComponent(new URL(params.deepLink).searchParams.get('url')));
103
88
  checkUrl.pathname = checkUrl.pathname.replace(/auth$/, 'status');
104
89
  }
@@ -122,9 +107,12 @@ class WalletHandlers extends did_auth_1.WalletHandlers {
122
107
  });
123
108
  }
124
109
  return extra;
125
- });
110
+ };
126
111
  // @ts-expect-error TS(2345) FIXME: Argument of type '{ onStart: (params: any) => Prom... Remove this comment to see the full error message
127
- super.attach(Object.assign({ onStart: realOnStart }, opts));
112
+ super.attach({
113
+ onStart: realOnStart,
114
+ ...opts,
115
+ });
128
116
  }
129
117
  }
130
118
  module.exports = WalletHandlers;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.68",
6
+ "version": "1.8.69-beta-54faead3",
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,24 +26,26 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.8.68",
30
- "@abtnode/constant": "1.8.68",
31
- "@arcblock/did-auth": "1.18.42",
32
- "@arcblock/jwt": "1.18.42",
33
- "@arcblock/ws": "1.18.42",
34
- "@blocklet/constant": "1.8.68",
35
- "@blocklet/meta": "1.8.68",
36
- "@did-connect/authenticator": "^2.1.34",
37
- "@did-connect/handler": "^2.1.34",
29
+ "@abtnode/client": "1.8.69-beta-54faead3",
30
+ "@abtnode/constant": "1.8.69-beta-54faead3",
31
+ "@arcblock/did-auth": "1.18.57",
32
+ "@arcblock/jwt": "1.18.57",
33
+ "@arcblock/ws": "1.18.57",
34
+ "@blocklet/constant": "1.8.69-beta-54faead3",
35
+ "@blocklet/meta": "1.8.69-beta-54faead3",
36
+ "@did-connect/authenticator": "^2.1.41",
37
+ "@did-connect/handler": "^2.1.41",
38
38
  "@nedb/core": "^2.1.5",
39
- "@ocap/mcrypto": "1.18.42",
40
- "@ocap/wallet": "1.18.42",
39
+ "@ocap/mcrypto": "1.18.57",
40
+ "@ocap/wallet": "1.18.57",
41
41
  "axios": "^0.27.2",
42
+ "cheerio": "^1.0.0-rc.12",
42
43
  "fs-extra": "^10.1.0",
43
44
  "joi": "17.7.0",
44
45
  "json-stable-stringify": "^1.0.1",
45
46
  "lodash": "^4.17.21",
46
47
  "lru-cache": "^6.0.0",
48
+ "ufo": "^1.1.1",
47
49
  "url-join": "^4.0.1"
48
50
  },
49
51
  "resolutions": {
@@ -61,12 +63,12 @@
61
63
  "detect-port": "^1.5.1",
62
64
  "eslint": "^8.25.0",
63
65
  "jest": "^29.2.0",
64
- "joi-to-typescript": "^4.0.6",
66
+ "joi-to-typescript": "^4.0.7",
65
67
  "json-stable-stringify": "^1.0.1",
66
68
  "prettier": "^2.7.1",
67
69
  "ts-jest": "^29.0.3",
68
70
  "ts-node": "^10.9.1",
69
71
  "typescript": "^4.8.4"
70
72
  },
71
- "gitHead": "1392044ac5677bde567797adeb9a6d3f0b9264b8"
73
+ "gitHead": "3dec0c85a77de5ba2d37c19ac769b126bfaafc86"
72
74
  }