@abtnode/auth 1.16.45-beta-20250625-064956-91b0fb8f → 1.16.45-beta-20250626-115702-00b49b4c

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/launcher.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const Joi = require('joi');
2
2
  const axios = require('@abtnode/util/lib/axios');
3
+ const pick = require('lodash/pick');
3
4
  const { joinURL } = require('ufo');
4
5
  const pRetry = require('p-retry');
5
6
  const { stableStringify } = require('@arcblock/vc');
@@ -9,6 +10,8 @@ const { formatError } = require('@blocklet/error');
9
10
 
10
11
  const logger = require('@abtnode/logger')('@abtnode/auth:launcher');
11
12
 
13
+ const { version } = require('../package.json');
14
+
12
15
  const LAUNCHER_BLOCKLET_DID = 'z8iZkFBbrVQxZHvcWWB3Sa2TrfGmSeFz9MSU7';
13
16
 
14
17
  const schema = Joi.object({
@@ -17,6 +20,13 @@ const schema = Joi.object({
17
20
  locale: Joi.string().optional(),
18
21
  }).unknown(true);
19
22
 
23
+ const getLauncherInfo = async (launcherUrl) => {
24
+ const baseURL = new URL(launcherUrl).origin;
25
+ const { data: meta } = await axios.get(joinURL(baseURL, '__blocklet__.js?type=json'));
26
+ const component = meta.componentMountPoints?.find((x) => x.did === LAUNCHER_BLOCKLET_DID);
27
+ return { ...pick(meta, ['appId', 'appPk', 'appPid', 'appUrl']), mountPoint: component?.mountPoint || '/' };
28
+ };
29
+
20
30
  // eslint-disable-next-line require-await
21
31
  const doRequest = async (serverSk, { launcherUrl, pathname, payload, method = 'post', locale = 'en' }) => {
22
32
  if (!serverSk) {
@@ -26,14 +36,12 @@ const doRequest = async (serverSk, { launcherUrl, pathname, payload, method = 'p
26
36
  const wallet = getNodeWallet(serverSk);
27
37
 
28
38
  const fn = async () => {
29
- const baseURL = new URL(launcherUrl).origin;
30
- const { data: launcherMeta } = await axios.get(joinURL(baseURL, '__blocklet__.js?type=json'));
31
- const mountPoint = launcherMeta.componentMountPoints?.find((x) => x.did === LAUNCHER_BLOCKLET_DID);
32
- if (!mountPoint) {
39
+ const launcherInfo = await getLauncherInfo(launcherUrl);
40
+ if (!launcherInfo.mountPoint) {
33
41
  throw new Error('launcher blocklet mount point not found');
34
42
  }
35
43
 
36
- const url = joinURL(baseURL, mountPoint.mountPoint, pathname);
44
+ const url = joinURL(launcherInfo.appUrl, launcherInfo.mountPoint, pathname);
37
45
 
38
46
  let params = method === 'get' ? payload : {};
39
47
  params = { ...(params || {}), locale };
@@ -46,6 +54,7 @@ const doRequest = async (serverSk, { launcherUrl, pathname, payload, method = 'p
46
54
  params,
47
55
  headers: {
48
56
  'x-server-sig': toBase58(wallet.sign(stableStringify(payload))),
57
+ 'User-Agent': `ABTNode/${version}`,
49
58
  },
50
59
  };
51
60
  if (method === 'post') {
@@ -129,6 +138,7 @@ module.exports = {
129
138
  doRequest,
130
139
  getLauncherSession,
131
140
  getLauncherUser,
141
+ getLauncherInfo,
132
142
  sendEmailWithLauncher,
133
143
  LAUNCHER_BLOCKLET_DID,
134
144
  };
package/lib/passkey.js CHANGED
@@ -834,9 +834,10 @@ function createPasskeyHandlers(node, mode, createToken) {
834
834
  logger.info('passkey.auth.connectOwner', { teamDid, userDid: user.did });
835
835
  }
836
836
 
837
+ logger.info('passkey.auth.result', { action: passkeySession.data.action, teamDid, userDid: user.did });
837
838
  return res.send(result);
838
839
  } catch (error) {
839
- console.error(error);
840
+ logger.error('passkey.auth.handleAuthResponse.error', { error });
840
841
  return res.status(400).send({ error: 'An error occurred during authentication. Please try again.' });
841
842
  } finally {
842
843
  await node.endSession({ id: req.passkeySession.id });
package/lib/server.js CHANGED
@@ -689,8 +689,17 @@ const createLaunchBlockletHandler =
689
689
  },
690
690
  context = null
691
691
  ) => {
692
- const { locale, blockletMetaUrl, title, description, chainHost, launcherSessionId, launcherUrl, onlyRequired } =
693
- parseBooleanString(extraParams, ['onlyRequired']);
692
+ const {
693
+ locale,
694
+ blockletMetaUrl,
695
+ title,
696
+ description,
697
+ chainHost,
698
+ launcherSessionId,
699
+ launcherUrl,
700
+ onlyRequired,
701
+ autoStart,
702
+ } = parseBooleanString(extraParams, ['onlyRequired', 'autoStart']);
694
703
  logger.info('createLaunchBlockletHandler', extraParams);
695
704
 
696
705
  const claim = claims.find((x) => x.type === 'keyPair');
@@ -855,6 +864,7 @@ const createLaunchBlockletHandler =
855
864
  node,
856
865
  sessionId,
857
866
  justCreate: !blockletMetaUrl,
867
+ autoStart,
858
868
  provider,
859
869
  context: {
860
870
  visitorId: extraParams.visitorId,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.45-beta-20250625-064956-91b0fb8f",
6
+ "version": "1.16.45-beta-20250626-115702-00b49b4c",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -20,9 +20,9 @@
20
20
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@abtnode/constant": "1.16.45-beta-20250625-064956-91b0fb8f",
24
- "@abtnode/logger": "1.16.45-beta-20250625-064956-91b0fb8f",
25
- "@abtnode/util": "1.16.45-beta-20250625-064956-91b0fb8f",
23
+ "@abtnode/constant": "1.16.45-beta-20250626-115702-00b49b4c",
24
+ "@abtnode/logger": "1.16.45-beta-20250626-115702-00b49b4c",
25
+ "@abtnode/util": "1.16.45-beta-20250626-115702-00b49b4c",
26
26
  "@arcblock/did": "1.20.14",
27
27
  "@arcblock/did-auth": "1.20.14",
28
28
  "@arcblock/did-ext": "1.20.14",
@@ -31,10 +31,10 @@
31
31
  "@arcblock/nft-display": "^2.13.70",
32
32
  "@arcblock/validator": "1.20.14",
33
33
  "@arcblock/vc": "1.20.14",
34
- "@blocklet/constant": "1.16.45-beta-20250625-064956-91b0fb8f",
34
+ "@blocklet/constant": "1.16.45-beta-20250626-115702-00b49b4c",
35
35
  "@blocklet/error": "^0.2.5",
36
- "@blocklet/meta": "1.16.45-beta-20250625-064956-91b0fb8f",
37
- "@blocklet/sdk": "1.16.45-beta-20250625-064956-91b0fb8f",
36
+ "@blocklet/meta": "1.16.45-beta-20250626-115702-00b49b4c",
37
+ "@blocklet/sdk": "1.16.45-beta-20250626-115702-00b49b4c",
38
38
  "@ocap/client": "1.20.14",
39
39
  "@ocap/mcrypto": "1.20.14",
40
40
  "@ocap/util": "1.20.14",
@@ -56,5 +56,5 @@
56
56
  "devDependencies": {
57
57
  "jest": "^29.7.0"
58
58
  },
59
- "gitHead": "90b9c4c9352f9ae33139f4e376b97b3be43698fa"
59
+ "gitHead": "8a70f88f034e2926185d4d0b9503ab8430a772a1"
60
60
  }