@next-core/easyops-runtime 0.1.0 → 0.2.0

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.
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.authenticate = authenticate;
7
+ exports.getAuth = getAuth;
8
+ exports.isLoggedIn = isLoggedIn;
9
+ exports.logout = logout;
10
+ // import { resetPermissionPreChecks } from "./internal/checkPermissions.js";
11
+
12
+ const auth = {};
13
+
14
+ /** @internal */
15
+
16
+ /** @internal */
17
+ function authenticate(newAuth) {
18
+ Object.assign(auth, {
19
+ org: newAuth.org,
20
+ username: newAuth.username,
21
+ userInstanceId: newAuth.userInstanceId,
22
+ loginFrom: newAuth.loginFrom,
23
+ accessRule: newAuth.accessRule,
24
+ isAdmin: newAuth.isAdmin,
25
+ csrfToken: newAuth.csrfToken,
26
+ license: newAuth.license,
27
+ userShowValue: newAuth.userShowValue
28
+ });
29
+ }
30
+
31
+ /**
32
+ * 获取当前登录认证信息。
33
+ *
34
+ * @returns 当前登录认证信息。
35
+ */
36
+ function getAuth() {
37
+ return {
38
+ ...auth
39
+ };
40
+ }
41
+
42
+ /** @internal */
43
+ function logout() {
44
+ for (const key of Object.keys(auth)) {
45
+ auth[key] = undefined;
46
+ }
47
+ // resetPermissionPreChecks();
48
+ }
49
+
50
+ /**
51
+ * 查看当前是否已登录。
52
+ *
53
+ * @returns 当前是否已登录。
54
+ */
55
+ function isLoggedIn() {
56
+ return auth.username !== undefined;
57
+ }
58
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","names":["auth","authenticate","newAuth","Object","assign","org","username","userInstanceId","loginFrom","accessRule","isAdmin","csrfToken","license","userShowValue","getAuth","logout","key","keys","undefined","isLoggedIn"],"sources":["../../src/auth.ts"],"sourcesContent":["import type { AuthApi_CheckLoginResponseBody } from \"@next-api-sdk/api-gateway-sdk\";\n// import { resetPermissionPreChecks } from \"./internal/checkPermissions.js\";\n\nconst auth: AuthInfo = {};\n\n/** @internal */\nexport type AuthInfo = Omit<AuthApi_CheckLoginResponseBody, \"loggedIn\">;\n\n/** @internal */\nexport function authenticate(newAuth: AuthInfo): void {\n Object.assign(auth, {\n org: newAuth.org,\n username: newAuth.username,\n userInstanceId: newAuth.userInstanceId,\n loginFrom: newAuth.loginFrom,\n accessRule: newAuth.accessRule,\n isAdmin: newAuth.isAdmin,\n csrfToken: newAuth.csrfToken,\n license: newAuth.license,\n userShowValue: newAuth.userShowValue,\n });\n}\n\n/**\n * 获取当前登录认证信息。\n *\n * @returns 当前登录认证信息。\n */\nexport function getAuth(): AuthInfo {\n return {\n ...auth,\n };\n}\n\n/** @internal */\nexport function logout(): void {\n for (const key of Object.keys(auth) as (keyof AuthInfo)[]) {\n auth[key] = undefined;\n }\n // resetPermissionPreChecks();\n}\n\n/**\n * 查看当前是否已登录。\n *\n * @returns 当前是否已登录。\n */\nexport function isLoggedIn(): boolean {\n return auth.username !== undefined;\n}\n"],"mappings":";;;;;;;;;AACA;;AAEA,MAAMA,IAAc,GAAG,CAAC,CAAC;;AAEzB;;AAGA;AACO,SAASC,YAAYA,CAACC,OAAiB,EAAQ;EACpDC,MAAM,CAACC,MAAM,CAACJ,IAAI,EAAE;IAClBK,GAAG,EAAEH,OAAO,CAACG,GAAG;IAChBC,QAAQ,EAAEJ,OAAO,CAACI,QAAQ;IAC1BC,cAAc,EAAEL,OAAO,CAACK,cAAc;IACtCC,SAAS,EAAEN,OAAO,CAACM,SAAS;IAC5BC,UAAU,EAAEP,OAAO,CAACO,UAAU;IAC9BC,OAAO,EAAER,OAAO,CAACQ,OAAO;IACxBC,SAAS,EAAET,OAAO,CAACS,SAAS;IAC5BC,OAAO,EAAEV,OAAO,CAACU,OAAO;IACxBC,aAAa,EAAEX,OAAO,CAACW;EACzB,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAA,EAAa;EAClC,OAAO;IACL,GAAGd;EACL,CAAC;AACH;;AAEA;AACO,SAASe,MAAMA,CAAA,EAAS;EAC7B,KAAK,MAAMC,GAAG,IAAIb,MAAM,CAACc,IAAI,CAACjB,IAAI,CAAC,EAAwB;IACzDA,IAAI,CAACgB,GAAG,CAAC,GAAGE,SAAS;EACvB;EACA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAAA,EAAY;EACpC,OAAOnB,IAAI,CAACM,QAAQ,KAAKY,SAAS;AACpC"}
package/dist/cjs/index.js CHANGED
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.flowApi = exports.checkInstalledApps = void 0;
7
+ exports.flowApi = exports.checkInstalledApps = exports.auth = void 0;
8
8
  Object.defineProperty(exports, "validatePermissions", {
9
9
  enumerable: true,
10
10
  get: function () {
@@ -16,4 +16,6 @@ var _checkInstalledApps = _interopRequireWildcard(require("./checkInstalledApps.
16
16
  exports.checkInstalledApps = _checkInstalledApps;
17
17
  var _flowApi = _interopRequireWildcard(require("./flowApi/index.js"));
18
18
  exports.flowApi = _flowApi;
19
+ var _auth = _interopRequireWildcard(require("./auth.js"));
20
+ exports.auth = _auth;
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_microAppSdk","require","_checkInstalledApps","_interopRequireWildcard","exports","checkInstalledApps","_flowApi","flowApi"],"sources":["../../src/index.ts"],"sourcesContent":["export { PermissionApi_validatePermissions as validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\n\nexport * as checkInstalledApps from \"./checkInstalledApps.js\";\n\nexport * as flowApi from \"./flowApi/index.js\";\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAuG,IAAAC,mBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAAG,OAAA,CAAAC,kBAAA,GAAAH,mBAAA;AAAA,IAAAI,QAAA,GAAAH,uBAAA,CAAAF,OAAA;AAAAG,OAAA,CAAAG,OAAA,GAAAD,QAAA"}
1
+ {"version":3,"file":"index.js","names":["_microAppSdk","require","_checkInstalledApps","_interopRequireWildcard","exports","checkInstalledApps","_flowApi","flowApi","_auth","auth"],"sources":["../../src/index.ts"],"sourcesContent":["export { PermissionApi_validatePermissions as validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nexport * as checkInstalledApps from \"./checkInstalledApps.js\";\nexport * as flowApi from \"./flowApi/index.js\";\nexport * as auth from \"./auth.js\";\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAuG,IAAAC,mBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAAG,OAAA,CAAAC,kBAAA,GAAAH,mBAAA;AAAA,IAAAI,QAAA,GAAAH,uBAAA,CAAAF,OAAA;AAAAG,OAAA,CAAAG,OAAA,GAAAD,QAAA;AAAA,IAAAE,KAAA,GAAAL,uBAAA,CAAAF,OAAA;AAAAG,OAAA,CAAAK,IAAA,GAAAD,KAAA"}
@@ -0,0 +1,48 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ // import { resetPermissionPreChecks } from "./internal/checkPermissions.js";
3
+
4
+ var auth = {};
5
+
6
+ /** @internal */
7
+
8
+ /** @internal */
9
+ export function authenticate(newAuth) {
10
+ Object.assign(auth, {
11
+ org: newAuth.org,
12
+ username: newAuth.username,
13
+ userInstanceId: newAuth.userInstanceId,
14
+ loginFrom: newAuth.loginFrom,
15
+ accessRule: newAuth.accessRule,
16
+ isAdmin: newAuth.isAdmin,
17
+ csrfToken: newAuth.csrfToken,
18
+ license: newAuth.license,
19
+ userShowValue: newAuth.userShowValue
20
+ });
21
+ }
22
+
23
+ /**
24
+ * 获取当前登录认证信息。
25
+ *
26
+ * @returns 当前登录认证信息。
27
+ */
28
+ export function getAuth() {
29
+ return _objectSpread({}, auth);
30
+ }
31
+
32
+ /** @internal */
33
+ export function logout() {
34
+ for (var key of Object.keys(auth)) {
35
+ auth[key] = undefined;
36
+ }
37
+ // resetPermissionPreChecks();
38
+ }
39
+
40
+ /**
41
+ * 查看当前是否已登录。
42
+ *
43
+ * @returns 当前是否已登录。
44
+ */
45
+ export function isLoggedIn() {
46
+ return auth.username !== undefined;
47
+ }
48
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","names":["auth","authenticate","newAuth","Object","assign","org","username","userInstanceId","loginFrom","accessRule","isAdmin","csrfToken","license","userShowValue","getAuth","_objectSpread","logout","key","keys","undefined","isLoggedIn"],"sources":["../../src/auth.ts"],"sourcesContent":["import type { AuthApi_CheckLoginResponseBody } from \"@next-api-sdk/api-gateway-sdk\";\n// import { resetPermissionPreChecks } from \"./internal/checkPermissions.js\";\n\nconst auth: AuthInfo = {};\n\n/** @internal */\nexport type AuthInfo = Omit<AuthApi_CheckLoginResponseBody, \"loggedIn\">;\n\n/** @internal */\nexport function authenticate(newAuth: AuthInfo): void {\n Object.assign(auth, {\n org: newAuth.org,\n username: newAuth.username,\n userInstanceId: newAuth.userInstanceId,\n loginFrom: newAuth.loginFrom,\n accessRule: newAuth.accessRule,\n isAdmin: newAuth.isAdmin,\n csrfToken: newAuth.csrfToken,\n license: newAuth.license,\n userShowValue: newAuth.userShowValue,\n });\n}\n\n/**\n * 获取当前登录认证信息。\n *\n * @returns 当前登录认证信息。\n */\nexport function getAuth(): AuthInfo {\n return {\n ...auth,\n };\n}\n\n/** @internal */\nexport function logout(): void {\n for (const key of Object.keys(auth) as (keyof AuthInfo)[]) {\n auth[key] = undefined;\n }\n // resetPermissionPreChecks();\n}\n\n/**\n * 查看当前是否已登录。\n *\n * @returns 当前是否已登录。\n */\nexport function isLoggedIn(): boolean {\n return auth.username !== undefined;\n}\n"],"mappings":";AACA;;AAEA,IAAMA,IAAc,GAAG,CAAC,CAAC;;AAEzB;;AAGA;AACA,OAAO,SAASC,YAAYA,CAACC,OAAiB,EAAQ;EACpDC,MAAM,CAACC,MAAM,CAACJ,IAAI,EAAE;IAClBK,GAAG,EAAEH,OAAO,CAACG,GAAG;IAChBC,QAAQ,EAAEJ,OAAO,CAACI,QAAQ;IAC1BC,cAAc,EAAEL,OAAO,CAACK,cAAc;IACtCC,SAAS,EAAEN,OAAO,CAACM,SAAS;IAC5BC,UAAU,EAAEP,OAAO,CAACO,UAAU;IAC9BC,OAAO,EAAER,OAAO,CAACQ,OAAO;IACxBC,SAAS,EAAET,OAAO,CAACS,SAAS;IAC5BC,OAAO,EAAEV,OAAO,CAACU,OAAO;IACxBC,aAAa,EAAEX,OAAO,CAACW;EACzB,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAAA,EAAa;EAClC,OAAAC,aAAA,KACKf,IAAI;AAEX;;AAEA;AACA,OAAO,SAASgB,MAAMA,CAAA,EAAS;EAC7B,KAAK,IAAMC,GAAG,IAAId,MAAM,CAACe,IAAI,CAAClB,IAAI,CAAC,EAAwB;IACzDA,IAAI,CAACiB,GAAG,CAAC,GAAGE,SAAS;EACvB;EACA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAA,EAAY;EACpC,OAAOpB,IAAI,CAACM,QAAQ,KAAKa,SAAS;AACpC"}
package/dist/esm/index.js CHANGED
@@ -3,4 +3,6 @@ import * as _checkInstalledApps from "./checkInstalledApps.js";
3
3
  export { _checkInstalledApps as checkInstalledApps };
4
4
  import * as _flowApi from "./flowApi/index.js";
5
5
  export { _flowApi as flowApi };
6
+ import * as _auth from "./auth.js";
7
+ export { _auth as auth };
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["PermissionApi_validatePermissions","validatePermissions","_checkInstalledApps","checkInstalledApps","_flowApi","flowApi"],"sources":["../../src/index.ts"],"sourcesContent":["export { PermissionApi_validatePermissions as validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\n\nexport * as checkInstalledApps from \"./checkInstalledApps.js\";\n\nexport * as flowApi from \"./flowApi/index.js\";\n"],"mappings":"AAAA,SAASA,iCAAiC,IAAIC,mBAAmB,QAAQ,6BAA6B;AAAC,YAAAC,mBAAA,MAEnE,yBAAyB;AAAA,SAAAA,mBAAA,IAAjDC,kBAAkB;AAAA,YAAAC,QAAA,MAEL,oBAAoB;AAAA,SAAAA,QAAA,IAAjCC,OAAO"}
1
+ {"version":3,"file":"index.js","names":["PermissionApi_validatePermissions","validatePermissions","_checkInstalledApps","checkInstalledApps","_flowApi","flowApi","_auth","auth"],"sources":["../../src/index.ts"],"sourcesContent":["export { PermissionApi_validatePermissions as validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nexport * as checkInstalledApps from \"./checkInstalledApps.js\";\nexport * as flowApi from \"./flowApi/index.js\";\nexport * as auth from \"./auth.js\";\n"],"mappings":"AAAA,SAASA,iCAAiC,IAAIC,mBAAmB,QAAQ,6BAA6B;AAAC,YAAAC,mBAAA,MACnE,yBAAyB;AAAA,SAAAA,mBAAA,IAAjDC,kBAAkB;AAAA,YAAAC,QAAA,MACL,oBAAoB;AAAA,SAAAA,QAAA,IAAjCC,OAAO;AAAA,YAAAC,KAAA,MACG,WAAW;AAAA,SAAAA,KAAA,IAArBC,IAAI"}
@@ -0,0 +1,19 @@
1
+ import type { AuthApi_CheckLoginResponseBody } from "@next-api-sdk/api-gateway-sdk";
2
+ /** @internal */
3
+ export type AuthInfo = Omit<AuthApi_CheckLoginResponseBody, "loggedIn">;
4
+ /** @internal */
5
+ export declare function authenticate(newAuth: AuthInfo): void;
6
+ /**
7
+ * 获取当前登录认证信息。
8
+ *
9
+ * @returns 当前登录认证信息。
10
+ */
11
+ export declare function getAuth(): AuthInfo;
12
+ /** @internal */
13
+ export declare function logout(): void;
14
+ /**
15
+ * 查看当前是否已登录。
16
+ *
17
+ * @returns 当前是否已登录。
18
+ */
19
+ export declare function isLoggedIn(): boolean;
@@ -1,3 +1,4 @@
1
1
  export { PermissionApi_validatePermissions as validatePermissions } from "@next-api-sdk/micro-app-sdk";
2
2
  export * as checkInstalledApps from "./checkInstalledApps.js";
3
3
  export * as flowApi from "./flowApi/index.js";
4
+ export * as auth from "./auth.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/easyops-runtime",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/easyops-runtime",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -44,9 +44,9 @@
44
44
  "@next-api-sdk/micro-app-sdk": "^1.1.0",
45
45
  "@next-api-sdk/micro-app-standalone-sdk": "^1.1.0",
46
46
  "@next-core/http": "^1.0.5",
47
- "@next-core/runtime": "^1.11.0",
47
+ "@next-core/runtime": "^1.11.1",
48
48
  "@next-core/types": "^1.3.0",
49
- "@next-core/utils": "^1.5.0",
49
+ "@next-core/utils": "^1.5.1",
50
50
  "js-yaml": "^3.14.1",
51
51
  "lodash": "^4.17.21"
52
52
  },
@@ -54,5 +54,5 @@
54
54
  "@next-core/build-next-libs": "^1.0.4",
55
55
  "@next-core/test-next": "^1.0.5"
56
56
  },
57
- "gitHead": "4befd0b5435dd8701ca18962905e0b27ff58e94f"
57
+ "gitHead": "1e7d86481659627d233451f5dadafdc471e97ec8"
58
58
  }