@qelos/plugin-play 3.7.7 → 3.8.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.
package/LICENSE CHANGED
@@ -16,16 +16,16 @@ For full license details, see [Apache License 2.0](https://www.apache.org/licens
16
16
 
17
17
  ## Restriction on Managed Services - Custom Clause
18
18
 
19
- While the software is open and free to use for internal or personal purposes, **you are not permitted to offer this software or any derivative of it as a paid managed service** or **Software as a Service (SaaS)** without explicit permission from Qelos LTD.
19
+ While the software is open and free to use for internal or personal purposes, **you are not permitted to offer this software or any derivative of it as a paid managed service** or **Software as a Service (SaaS)** without explicit permission from Velocitech LTD.
20
20
 
21
21
  ### Key Restriction:
22
22
  - You **may not** sell, offer, or commercialize this software as a managed service, SaaS, or any similar hosted service.
23
23
 
24
24
  ### How to Obtain Permission:
25
- If you wish to offer a managed or commercial version of this software, you must obtain a **commercial license** from Qelos LTD. Please contact us at [support@qelos.io](mailto:support@qelos.io) for details.
25
+ If you wish to offer a managed or commercial version of this software, you must obtain a **commercial license** from Velocitech LTD. Please contact us at [support@qelos.io](mailto:support@qelos.io) for details.
26
26
 
27
27
  ## Additional Notes
28
28
 
29
- This license ensures the software remains free for personal use and community development, while protecting Qelos LTD’s right to control the commercialization of managed services based on the software.
29
+ This license ensures the software remains free for personal use and community development, while protecting Velocitech LTD’s right to control the commercialization of managed services based on the software.
30
30
 
31
31
  For any questions regarding the license, feel free to reach out at [support@qelos.io].
@@ -4,7 +4,7 @@ export interface QelosRouteParams extends RouteOptions {
4
4
  verifyToken: boolean;
5
5
  }
6
6
  export declare const endpoints: Map<string, QelosRouteParams>;
7
- export declare const internalEndpoints: Map<string, RouteOptions<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify/types/route").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyLoggerInstance>>;
7
+ export declare const internalEndpoints: Map<string, RouteOptions<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify/types/route").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>>;
8
8
  export declare function addProxyEndpoint(path: string, options: Partial<QelosRouteParams>): void;
9
9
  export declare function addEndpoint(path: string, options: Partial<QelosRouteParams>): void;
10
10
  export declare function addInternalEndpoint(path: string, options: Partial<RouteOptions>): void;
package/dist/sdk.d.ts CHANGED
@@ -6,7 +6,17 @@ export declare function authenticate(): Promise<{
6
6
  refreshToken: string;
7
7
  };
8
8
  }>;
9
- export declare function getSdkForUrl<T = any>(appUrl: string, refreshToken?: string, accessToken?: string): QelosAdministratorSDK;
9
+ export declare function getSdkForUrl<T = any>({ appUrl, refreshToken, accessToken, username, password, onRefresh }: {
10
+ appUrl: string;
11
+ refreshToken?: string;
12
+ accessToken?: string;
13
+ username?: string;
14
+ password?: string;
15
+ onRefresh?: ({ refreshToken, token }: {
16
+ refreshToken: string;
17
+ token: string;
18
+ }) => void;
19
+ }): QelosAdministratorSDK;
10
20
  export declare function getSdk(): QelosAdministratorSDK;
11
21
  export declare function getSdkForTenant(tenantPayload: StandardPayload): Promise<QelosAdministratorSDK | null>;
12
22
  export declare function getEncryptedDataForTenant(tenantPayload: StandardPayload, encryptedId?: string): Promise<any>;
package/dist/sdk.js CHANGED
@@ -4,11 +4,17 @@ import config from './config';
4
4
  import logger from './logger';
5
5
  let localSdk;
6
6
  export function authenticate() {
7
- return localSdk.authentication.oAuthSignin({ username: config.qelosUsername, password: config.qelosPassword });
7
+ return localSdk.authentication.oAuthSignin({
8
+ username: config.qelosUsername,
9
+ password: config.qelosPassword,
10
+ });
8
11
  }
9
12
  async function bootstrapAuthenticate() {
10
13
  try {
11
- await localSdk.authentication.oAuthSignin({ username: config.qelosUsername, password: config.qelosPassword });
14
+ await localSdk.authentication.oAuthSignin({
15
+ username: config.qelosUsername,
16
+ password: config.qelosPassword,
17
+ });
12
18
  console.log('authenticated successfully to ' + config.qelosUrl);
13
19
  }
14
20
  catch (err) {
@@ -17,11 +23,18 @@ async function bootstrapAuthenticate() {
17
23
  process.exit(1);
18
24
  }
19
25
  }
20
- export function getSdkForUrl(appUrl, refreshToken, accessToken) {
26
+ export function getSdkForUrl({ appUrl, refreshToken, accessToken, username, password, onRefresh }) {
27
+ let sdk;
21
28
  const options = {
22
29
  appUrl,
23
30
  forceRefresh: true,
24
31
  fetch: globalThis.fetch || undiciFetch,
32
+ onFailedRefreshToken: async () => {
33
+ const res = await sdk.authentication.oAuthSignin({ username, password });
34
+ if (onRefresh) {
35
+ onRefresh(res.payload);
36
+ }
37
+ },
25
38
  ...(config.sdkOptions || {}),
26
39
  };
27
40
  if (refreshToken) {
@@ -30,13 +43,20 @@ export function getSdkForUrl(appUrl, refreshToken, accessToken) {
30
43
  if (accessToken) {
31
44
  options.accessToken = accessToken;
32
45
  }
33
- return new QelosAdministratorSDK(options);
46
+ sdk = new QelosAdministratorSDK(options);
47
+ return sdk;
34
48
  }
35
49
  export function getSdk() {
36
50
  if (localSdk) {
37
51
  return localSdk;
38
52
  }
39
- localSdk = getSdkForUrl(config.qelosUrl);
53
+ localSdk = getSdkForUrl({
54
+ appUrl: config.qelosUrl,
55
+ refreshToken: null,
56
+ accessToken: null,
57
+ username: config.qelosUsername,
58
+ password: config.qelosPassword,
59
+ });
40
60
  bootstrapAuthenticate().catch();
41
61
  return localSdk;
42
62
  }
@@ -46,7 +66,17 @@ export async function getSdkForTenant(tenantPayload) {
46
66
  if (!data.appUrl) {
47
67
  return null;
48
68
  }
49
- const sdk = getSdkForUrl(data.appUrl, data.currentAuthPayload?.refreshToken, data.currentAuthPayload?.token);
69
+ const sdk = getSdkForUrl({
70
+ appUrl: data.appUrl,
71
+ refreshToken: data.currentAuthPayload?.refreshToken,
72
+ accessToken: data.currentAuthPayload?.token,
73
+ username: data.username,
74
+ password: data.password,
75
+ onRefresh: (payload) => {
76
+ data.currentAuthPayload = payload;
77
+ setEncryptedDataForTenant(tenantPayload, config.userPayloadSecret, data);
78
+ }
79
+ });
50
80
  return sdk;
51
81
  }
52
82
  catch (e) {
package/dist/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAElE,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,IAAI,QAA4D,CAAC;AAEjE,MAAM,UAAU,YAAY;IAC1B,OAAO,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;AACjH,CAAC;AAED,KAAK,UAAU,qBAAqB;IAClC,IAAI;QACF,MAAM,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QAC9G,OAAO,CAAC,GAAG,CAAC,gCAAgC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;KAChE;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAU,MAAc,EAAE,YAAqB,EAAE,WAAoB;IAC/F,MAAM,OAAO,GAAoB;QAC/B,MAAM;QACN,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,UAAU,CAAC,KAAK,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;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,IAAI,CAAC,kBAAkB,EAAE,YAAY;YACnD,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE,KAAK;YAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;gBACrB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC;gBAClC,yBAAyB,CAAC,aAAa,EAAE,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YAC3E,CAAC;SACF,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,aAA8B,EAC9B,cAAsB,EAAE;IAExB,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,aAA8B,EAC9B,cAAsB,EAAE,EACxB,IAAS;IAET,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAC/E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qelos/plugin-play",
3
- "version": "3.7.7",
3
+ "version": "3.8.1",
4
4
  "description": "Play a plugin for Qelos!",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -15,15 +15,15 @@
15
15
  "dependencies": {
16
16
  "@fastify/cookie": "^8.3.0",
17
17
  "@fastify/static": "^6.12.0",
18
- "@qelos/cache-manager": "^3.7.7",
19
- "@qelos/sdk": "^3.7.7",
20
- "@qelos/web-sdk": "^3.7.7",
21
- "fastify": "~4.3.0",
18
+ "@qelos/cache-manager": "^3.8.1",
19
+ "@qelos/sdk": "^3.8.1",
20
+ "@qelos/web-sdk": "^3.8.1",
21
+ "fastify": "~4.15.0",
22
22
  "jsonwebtoken": "^9.0.2",
23
23
  "undici": "^6.20.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "typescript": "^4.9.5"
27
27
  },
28
- "gitHead": "3d16633c443daab6a480b7ee511b1154d40afe4d"
28
+ "gitHead": "870f8846e1cdcc13af9327c6e70844a33a9f9cba"
29
29
  }
package/src/sdk.ts CHANGED
@@ -8,13 +8,19 @@ import logger from './logger';
8
8
  let localSdk: QelosAdministratorSDK<{ tokenIdentifier: string }>;
9
9
 
10
10
  export function authenticate() {
11
- return localSdk.authentication.oAuthSignin({ username: config.qelosUsername, password: config.qelosPassword });
11
+ return localSdk.authentication.oAuthSignin({
12
+ username: config.qelosUsername,
13
+ password: config.qelosPassword,
14
+ });
12
15
  }
13
16
 
14
17
  async function bootstrapAuthenticate() {
15
18
  try {
16
- await localSdk.authentication.oAuthSignin({ username: config.qelosUsername, password: config.qelosPassword });
17
- console.log('authenticated successfully to ' + config.qelosUrl)
19
+ await localSdk.authentication.oAuthSignin({
20
+ username: config.qelosUsername,
21
+ password: config.qelosPassword,
22
+ });
23
+ console.log('authenticated successfully to ' + config.qelosUrl);
18
24
  } catch (err) {
19
25
  console.log('could not authenticate to own qelos app');
20
26
  logger.error('connect to qelos error: ', err);
@@ -22,11 +28,32 @@ async function bootstrapAuthenticate() {
22
28
  }
23
29
  }
24
30
 
25
- export function getSdkForUrl<T = any>(appUrl: string, refreshToken?: string, accessToken?: string): QelosAdministratorSDK {
31
+ export function getSdkForUrl<T = any>({
32
+ appUrl,
33
+ refreshToken,
34
+ accessToken,
35
+ username,
36
+ password,
37
+ onRefresh
38
+ }: {
39
+ appUrl: string;
40
+ refreshToken?: string;
41
+ accessToken?: string;
42
+ username?: string;
43
+ password?: string;
44
+ onRefresh?: ({ refreshToken, token }: { refreshToken: string, token: string }) => void
45
+ }): QelosAdministratorSDK {
46
+ let sdk: QelosAdministratorSDK;
26
47
  const options: QelosSDKOptions = {
27
48
  appUrl,
28
49
  forceRefresh: true,
29
- fetch: globalThis.fetch || undiciFetch as any as FetchLike,
50
+ fetch: globalThis.fetch || (undiciFetch as any as FetchLike),
51
+ onFailedRefreshToken: async () => {
52
+ const res = await sdk.authentication.oAuthSignin({ username, password });
53
+ if (onRefresh) {
54
+ onRefresh(res.payload)
55
+ }
56
+ },
30
57
  ...(config.sdkOptions || {}),
31
58
  };
32
59
  if (refreshToken) {
@@ -35,36 +62,65 @@ export function getSdkForUrl<T = any>(appUrl: string, refreshToken?: string, acc
35
62
  if (accessToken) {
36
63
  options.accessToken = accessToken;
37
64
  }
38
- return new QelosAdministratorSDK<T>(options);
65
+ sdk = new QelosAdministratorSDK<T>(options);
66
+ return sdk;
39
67
  }
40
68
 
41
69
  export function getSdk(): QelosAdministratorSDK {
42
70
  if (localSdk) {
43
71
  return localSdk;
44
72
  }
45
- localSdk = getSdkForUrl<{ tokenIdentifier: string }>(config.qelosUrl);
73
+ localSdk = getSdkForUrl<{ tokenIdentifier: string }>({
74
+ appUrl: config.qelosUrl,
75
+ refreshToken: null,
76
+ accessToken: null,
77
+ username: config.qelosUsername,
78
+ password: config.qelosPassword,
79
+ });
46
80
  bootstrapAuthenticate().catch();
47
81
  return localSdk;
48
82
  }
49
83
 
50
- export async function getSdkForTenant(tenantPayload: StandardPayload): Promise<QelosAdministratorSDK | null> {
84
+ export async function getSdkForTenant(
85
+ tenantPayload: StandardPayload
86
+ ): Promise<QelosAdministratorSDK | null> {
51
87
  try {
52
- const data = await getEncryptedDataForTenant(tenantPayload, config.userPayloadSecret);
88
+ const data = await getEncryptedDataForTenant(
89
+ tenantPayload,
90
+ config.userPayloadSecret
91
+ );
53
92
  if (!data.appUrl) {
54
93
  return null;
55
94
  }
56
- const sdk = getSdkForUrl(data.appUrl, data.currentAuthPayload?.refreshToken, data.currentAuthPayload?.token);
95
+ const sdk = getSdkForUrl({
96
+ appUrl: data.appUrl,
97
+ refreshToken: data.currentAuthPayload?.refreshToken,
98
+ accessToken: data.currentAuthPayload?.token,
99
+ username: data.username,
100
+ password: data.password,
101
+ onRefresh: (payload) => {
102
+ data.currentAuthPayload = payload;
103
+ setEncryptedDataForTenant(tenantPayload, config.userPayloadSecret, data);
104
+ }
105
+ });
57
106
  return sdk;
58
107
  } catch (e) {
59
- logger.log(e)
108
+ logger.log(e);
60
109
  return null;
61
110
  }
62
111
  }
63
112
 
64
- export function getEncryptedDataForTenant(tenantPayload: StandardPayload, encryptedId: string = '') {
113
+ export function getEncryptedDataForTenant(
114
+ tenantPayload: StandardPayload,
115
+ encryptedId: string = ''
116
+ ) {
65
117
  return getSdk().users.getEncryptedData(tenantPayload.sub, encryptedId);
66
118
  }
67
119
 
68
- export function setEncryptedDataForTenant(tenantPayload: StandardPayload, encryptedId: string = '', data: any) {
120
+ export function setEncryptedDataForTenant(
121
+ tenantPayload: StandardPayload,
122
+ encryptedId: string = '',
123
+ data: any
124
+ ) {
69
125
  return getSdk().users.setEncryptedData(tenantPayload.sub, encryptedId, data);
70
126
  }