@things-factory/auth-base 6.0.43 → 6.0.53

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.
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../client/auth.ts","../../../node_modules/@operato/shell/dist/src/types/domain.d.ts","../../../node_modules/@operato/shell/dist/src/types/user.d.ts","../../../node_modules/@operato/shell/dist/src/types/role.d.ts","../../../node_modules/@operato/shell/dist/src/types/privilege.d.ts","../../../node_modules/@operato/shell/dist/src/types/index.d.ts","../../../node_modules/redux/index.d.ts","../../../node_modules/pwa-helpers/lazy-reducer-enhancer.d.ts","../../../node_modules/@operato/shell/dist/src/store.d.ts","../../../node_modules/@operato/shell/dist/src/actions/app.d.ts","../../../node_modules/@operato/shell/dist/src/actions/route.d.ts","../../../node_modules/@operato/shell/dist/src/actions/const.d.ts","../../../node_modules/@operato/shell/dist/src/actions/index.d.ts","../../../node_modules/@lit/reactive-element/css-tag.d.ts","../../../node_modules/@lit/reactive-element/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/reactive-element.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/@types/trusted-types/index.d.ts","../../../node_modules/lit-html/directive.d.ts","../../../node_modules/lit-html/lit-html.d.ts","../../../node_modules/lit-element/lit-element.d.ts","../../../node_modules/lit-html/is-server.d.ts","../../../node_modules/lit/index.d.ts","../../../node_modules/@operato/shell/dist/src/app/pages/page-view.d.ts","../../../node_modules/@operato/shell/dist/src/index.d.ts","../../../node_modules/redux-thunk/es/types.d.ts","../../../node_modules/redux-thunk/es/index.d.ts","../client/actions/auth.ts","../client/reducers/auth.ts","../client/bootstrap.ts","../client/index.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/dom-events.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/readline/promises.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/test.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@jest/expect-utils/build/index.d.ts","../../../node_modules/chalk/index.d.ts","../../../node_modules/@sinclair/typebox/typebox.d.ts","../../../node_modules/@jest/schemas/build/index.d.ts","../../../node_modules/pretty-format/build/index.d.ts","../../../node_modules/jest-diff/build/index.d.ts","../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../node_modules/expect/build/index.d.ts","../../../node_modules/@types/jest/index.d.ts"],"fileInfos":[{"version":"8730f4bf322026ff5229336391a18bcaa1f94d4f82416c8b2f3954e2ccaae2ba","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","4b421cbfb3a38a27c279dec1e9112c3d1da296f77a1a85ddadf7e7a425d45d18","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9",{"version":"3aafcb693fe5b5c3bd277bd4c3a617b53db474fe498fc5df067c5603b1eebde7","affectsGlobalScope":true},{"version":"f3d4da15233e593eacb3965cde7960f3fddf5878528d882bcedd5cbaba0193c7","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"5f406584aef28a331c36523df688ca3650288d14f39c5d2e555c95f0d2ff8f6f","affectsGlobalScope":true},{"version":"22f230e544b35349cfb3bd9110b6ef37b41c6d6c43c3314a31bd0d9652fcec72","affectsGlobalScope":true},{"version":"7ea0b55f6b315cf9ac2ad622b0a7813315bb6e97bf4bb3fbf8f8affbca7dc695","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"eb26de841c52236d8222f87e9e6a235332e0788af8c87a71e9e210314300410a","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"5e5e095c4470c8bab227dbbc61374878ecead104c74ab9960d3adcccfee23205","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"2768ef564cfc0689a1b76106c421a2909bdff0acbe87da010785adab80efdd5c","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},"f1c9fe42b65437a61104e601eb298c5c859fb522b483f1bdb700eed67a16f980",{"version":"64a5230ae6777f94cc6bfb1091d5a6001957dcedca03877acda0505921f693b7","signature":"d6f41b971ee3fe8297ead6d46b1fb928a8ae09f587846d1ab16e1d406e87763c"},"4d4cf93a6b4c81851ad759e4569b6feb7a701e80b13a6f9d8d9c6012bbb86bd6","2e6035af8f3e43bf95e4983329c8277d66f9b271106af27b99a85d1c1b9daf4a","774308610e8d4a9954cd93840f99decbf340accfe3ad7365547950ede8162c92","36c15dd26c66c97b9df26ce34baacdb13fc760c5b9a2d789dcc317d27b189257","44a967eeba769bc2a7ea7df4338fa7921cff46a21070f623c13a9053af6bf75d",{"version":"fd624f7d7b264922476685870f08c5e1c6d6a0f05dee2429a9747b41f6b699d4","affectsGlobalScope":true},"701978f3975f96e76e3ffc2e1762e3a97e3d323812049fb6fdfd559579b89708",{"version":"4ab17f80ced148d509345cee706b2b85941515dd76e32cf47118bcdf6a4bd56a","affectsGlobalScope":true},"641089f0b8094ef74b9d4b3364d5dec1592d5e3b8a51c1ba491bc8872049e79a","9197b3ca76c01df6120b4ee288fe2d08f8a2089221da97956bee402de0ffd37e","7af29b0589483f7bb8a99405ddb849f34bc053146184561ed4179e02f5fe4d0f","d8afb84d78023735e55f1b96e06b3e221eb7ce5473ca1c93564d30e7efb0f991","52dd370c807255c61765347fc90a9bee3c522b8744dc222714e2bf6b5be3a823","1e5743b25a63fd34ffbae89adcbf248ee17db6ed08d90079ffa93803c3e80d2a","3cbcdf2a84c93c6b62d8d4584f613c8af7c6330ac2ba1ff781d10a3e0935beb9","2fcd2d22b1f30555e785105597cd8f57ed50300e213c4f1bbca6ae149f782c38",{"version":"3c150a2e1758724811db3bdc5c773421819343b1627714e09f29b1f40a5dfb26","affectsGlobalScope":true},"c567d37119d6f56381af48eb7516030ccf35a36f9aca045e238d9c207a7c536c","26a397eed716192f4eef41e2c11baf9aaeb3a035c65294dbac431bf2d358ed86","eba7cf33380cc3a3cf614faf67300e14d0bdff9ea6c5cd6f4b040b1756a48ab1","5e7e090243bf203382a5cb04eabbdc38d78f6d5922f16f543e4da8fa007d5ff9","cd823094ded7c8ac4f94ab6dc387dab699293eb8323d9f948304efc07e4ae7b2","6bf72b2541469cac7a7882468d25a04fdff489625452ff7d3e670c764e5a9ba1","9d696793a977926a52f6a244917ef8ca205f1a105654a0ec277105e35570bf57","d50a158fc581be7b1c51253ad33cb29c0a8ce3c42ca38775ffadf104c36376d0","1f2cdbf59d0b7933678a64ac26ae2818c48ff9ebf93249dde775dc3e173e16bf",{"version":"d9ada24b70b5731f77ad997ad1bb671b80dcdff931e7c46171fef07ee0dad104","signature":"64b224909f444ceb75c3306e078b6cd5f484b1487ffe18e13f150c9d2689dcd8"},{"version":"d3a72e3acec55990c739ec2c7ec487ace738418d0650356c2db86b67a3d1b818","signature":"6a716b8d3a52002354a3e530ee6c90d52209af1f53eaefb9c4527228bf0a6f67"},{"version":"8d55dba17babd73716321b2ed065017dcbe6c84fc21aa0cab4e3cc48fbdc526e","signature":"aac4ddff3d5c1247433870879e9838b1e23b81a9b62c75f59c3e1b64802f2b16"},{"version":"f528a2210943d5d3f1f4a154387da39afab55e9e91ca68f6fb4e3ef8a43a9823","signature":"0d1e9013237428428f2c4b8c4c64e3b5fce66d8140bc75629c0cc320c85c4925"},"7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"57b6cb95756d1fe3bfeb20205de27b0c5406e4a86e130c6dfa6bd92af641e09d","affectsGlobalScope":true},"11e2d554398d2bd460e7d06b2fa5827a297c8acfbe00b4f894a224ac0862857f",{"version":"e193e634a99c9c1d71f1c6e4e1567a4a73584328d21ea02dd5cddbaad6693f61","affectsGlobalScope":true},"374ca798f244e464346f14301dc2a8b4b111af1a83b49fffef5906c338a1f922","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","e596c9bb2f29a2699fdd4ae89139612652245192f67f45617c5a4b20832aaae9","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","1cdcfc1f624d6c08aa12c73935f6e13f095919cd99edf95752951796eb225729","216717f17c095cde1dc19375e1ab3af0a4a485355860c077a4f9d6ea59fab5b5","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"80473bd0dd90ca1e166514c2dfead9d5803f9c51418864ca35abbeec6e6847e1","1c84b46267610a34028edfd0d035509341751262bac1062857f3c8df7aff7153","e6c86d83bd526c8bdb5d0bf935b8e72ce983763d600743f74d812fdf4abf4df6","a3d541d303ee505053f5dcbf9fafb65cac3d5631037501cd616195863a6c5740","8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true},"bcebb922784739bdb34c18ee51095d25a92b560c78ccd2eaacd6bd00f7443d83","7ee6ed878c4528215c82b664fe0cfe80e8b4da6c0d4cc80869367868774db8b1","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"0715e4cd28ad471b2a93f3e552ff51a3ae423417a01a10aa1d3bc7c6b95059d6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","7d55d78cd47cf5280643b53434b16c2d9d11d144126932759fbdd51da525eec4","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","f69ff39996a61a0dd10f4bce73272b52e8024a4d58b13ab32bf4712909d0a2b7",{"version":"3c4ba1dd9b12ffa284b565063108f2f031d150ea15b8fafbdc17f5d2a07251f3","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","c4577fb855ca259bdbf3ea663ca73988ce5f84251a92b4aef80a1f4122b6f98e","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"ff07a9a03c65732ccc59b3c65bc584173da093bd563a6565411c01f5703bd3cb","affectsGlobalScope":true},"6de4a219df57d2b27274d59b67708f13c2cbf7ed211abe57d8f9ab8b25cde776","0fe8985a28f82c450a04a6edf1279d7181c0893f37da7d2a27f8efd4fd5edb03","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"d8d555f3d607ecaa18d55de6995ea8f206342ecc93305919eac945c7c78c78c6","6c1e688f95fcaf53b1e41c0fdadf2c1cfc96fa924eaf7f9fdb60f96deb0a4986","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","db25694be959314fd1e868d72e567746db1db9e2001fae545d12d2a8c1bba1b8","43883cf3635bb1846cbdc6c363787b76227677388c74f7313e3f0edb380840fa","2d47012580f859dae201d2eef898a416bdae719dffc087dfd06aefe3de2f9c8d","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","2cec1a31729b9b01e9294c33fc9425d336eff067282809761ad2e74425d6d2a5",{"version":"458e2fd1185e659cb800ef68d01ef77de70dcab8860bedf6d94eaebe736751f1","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"noImplicitAny":false,"outDir":"./","sourceMap":true,"strict":true,"target":4,"useDefineForClassFields":false},"fileIdsList":[[122],[122,132],[58,59,122],[54,55,56,122],[67,122],[50,53,57,68,122],[51,52,122],[46,47,48,49,122],[47,48,122],[46,47,49,122],[122,134,137],[76,122],[79,122],[80,85,113,122],[81,92,93,100,110,121,122],[81,82,92,100,122],[83,122],[84,85,93,101,122],[85,110,118,122],[86,88,92,100,122],[87,122],[88,89,122],[92,122],[90,92,122],[92,93,94,110,121,122],[92,93,94,107,110,113,122],[122,126],[88,95,100,110,121,122],[92,93,95,96,100,110,118,121,122],[95,97,110,118,121,122],[76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128],[92,98,122],[99,121,122],[88,92,100,110,122],[101,122],[102,122],[79,103,122],[104,120,122,126],[105,122],[106,122],[92,107,108,122],[107,109,122,124],[80,92,110,111,112,113,122],[80,110,112,122],[110,111,122],[113,122],[114,122],[92,116,117,122],[116,117,122],[85,100,110,118,122],[119,122],[100,120,122],[80,95,106,121,122],[85,122],[110,122,123],[122,124],[122,125],[80,85,92,94,103,110,121,122,124,126],[110,122,127],[61,122],[122,130,136],[122,134],[122,131,135],[60,64,122],[64,122],[62,63,122],[60,64,65,66,122],[122,133],[51,122],[51,70,122],[44,51,71,122],[44,122],[44,45,69,72,73,122],[44,45,122],[44,72,122],[51,71],[45]],"referencedMap":[[130,1],[133,2],[58,1],[59,1],[60,3],[54,1],[56,1],[57,4],[55,1],[68,5],[69,6],[53,7],[46,1],[50,8],[49,9],[48,10],[47,1],[132,1],[138,11],[76,12],[77,12],[79,13],[80,14],[81,15],[82,16],[83,17],[84,18],[85,19],[86,20],[87,21],[88,22],[89,22],[91,23],[90,24],[92,23],[93,25],[94,26],[78,27],[128,1],[95,28],[96,29],[97,30],[129,31],[98,32],[99,33],[100,34],[101,35],[102,36],[103,37],[104,38],[105,39],[106,40],[107,41],[108,41],[109,42],[110,43],[112,44],[111,45],[113,46],[114,47],[115,1],[116,48],[117,49],[118,50],[119,51],[120,52],[121,53],[122,54],[123,55],[124,56],[125,57],[126,58],[127,59],[62,60],[61,1],[131,1],[137,61],[135,62],[136,63],[65,64],[63,65],[66,1],[64,66],[67,67],[134,68],[52,69],[71,70],[70,69],[51,1],[44,1],[8,1],[9,1],[11,1],[10,1],[2,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[3,1],[4,1],[23,1],[20,1],[21,1],[22,1],[24,1],[25,1],[26,1],[5,1],[27,1],[28,1],[29,1],[30,1],[6,1],[34,1],[31,1],[32,1],[33,1],[35,1],[7,1],[36,1],[41,1],[42,1],[37,1],[38,1],[39,1],[40,1],[1,1],[43,1],[72,71],[45,72],[74,73],[75,74],[73,75]],"exportedModulesMap":[[130,1],[133,2],[58,1],[59,1],[60,3],[54,1],[56,1],[57,4],[55,1],[68,5],[69,6],[53,7],[46,1],[50,8],[49,9],[48,10],[47,1],[132,1],[138,11],[76,12],[77,12],[79,13],[80,14],[81,15],[82,16],[83,17],[84,18],[85,19],[86,20],[87,21],[88,22],[89,22],[91,23],[90,24],[92,23],[93,25],[94,26],[78,27],[128,1],[95,28],[96,29],[97,30],[129,31],[98,32],[99,33],[100,34],[101,35],[102,36],[103,37],[104,38],[105,39],[106,40],[107,41],[108,41],[109,42],[110,43],[112,44],[111,45],[113,46],[114,47],[115,1],[116,48],[117,49],[118,50],[119,51],[120,52],[121,53],[122,54],[123,55],[124,56],[125,57],[126,58],[127,59],[62,60],[61,1],[131,1],[137,61],[135,62],[136,63],[65,64],[63,65],[66,1],[64,66],[67,67],[134,68],[52,69],[71,70],[70,69],[51,1],[44,1],[8,1],[9,1],[11,1],[10,1],[2,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[3,1],[4,1],[23,1],[20,1],[21,1],[22,1],[24,1],[25,1],[26,1],[5,1],[27,1],[28,1],[29,1],[30,1],[6,1],[34,1],[31,1],[32,1],[33,1],[35,1],[7,1],[36,1],[41,1],[42,1],[37,1],[38,1],[39,1],[40,1],[1,1],[43,1],[72,76],[75,77]],"semanticDiagnosticsPerFile":[130,133,58,59,60,54,56,57,55,68,69,53,46,50,49,48,47,132,138,76,77,79,80,81,82,83,84,85,86,87,88,89,91,90,92,93,94,78,128,95,96,97,129,98,99,100,101,102,103,104,105,106,107,108,109,110,112,111,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,62,61,131,137,135,136,65,63,66,64,67,134,52,71,70,51,44,8,9,11,10,2,12,13,14,15,16,17,18,19,3,4,23,20,21,22,24,25,26,5,27,28,29,30,6,34,31,32,33,35,7,36,41,42,37,38,39,40,1,43,72,45,74,75,73]},"version":"4.9.5"}
1
+ {"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../client/auth.ts","../../../node_modules/@operato/shell/dist/src/types/domain.d.ts","../../../node_modules/@operato/shell/dist/src/types/user.d.ts","../../../node_modules/@operato/shell/dist/src/types/role.d.ts","../../../node_modules/@operato/shell/dist/src/types/privilege.d.ts","../../../node_modules/@operato/shell/dist/src/types/index.d.ts","../../../node_modules/redux/index.d.ts","../../../node_modules/pwa-helpers/lazy-reducer-enhancer.d.ts","../../../node_modules/@operato/shell/dist/src/store.d.ts","../../../node_modules/@operato/shell/dist/src/actions/app.d.ts","../../../node_modules/@operato/shell/dist/src/actions/route.d.ts","../../../node_modules/@operato/shell/dist/src/actions/const.d.ts","../../../node_modules/@operato/shell/dist/src/actions/index.d.ts","../../../node_modules/@lit/reactive-element/css-tag.d.ts","../../../node_modules/@lit/reactive-element/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/reactive-element.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/@types/trusted-types/index.d.ts","../../../node_modules/lit-html/directive.d.ts","../../../node_modules/lit-html/lit-html.d.ts","../../../node_modules/lit-element/lit-element.d.ts","../../../node_modules/lit-html/is-server.d.ts","../../../node_modules/lit/index.d.ts","../../../node_modules/@operato/shell/dist/src/app/pages/page-view.d.ts","../../../node_modules/@operato/shell/dist/src/index.d.ts","../../../node_modules/redux-thunk/es/types.d.ts","../../../node_modules/redux-thunk/es/index.d.ts","../client/actions/auth.ts","../client/reducers/auth.ts","../client/bootstrap.ts","../client/index.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/dom-events.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/readline/promises.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/test.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@jest/expect-utils/build/index.d.ts","../../../node_modules/chalk/index.d.ts","../../../node_modules/@sinclair/typebox/typebox.d.ts","../../../node_modules/@jest/schemas/build/index.d.ts","../../../node_modules/pretty-format/build/index.d.ts","../../../node_modules/jest-diff/build/index.d.ts","../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../node_modules/expect/build/index.d.ts","../../../node_modules/@types/jest/index.d.ts"],"fileInfos":[{"version":"8730f4bf322026ff5229336391a18bcaa1f94d4f82416c8b2f3954e2ccaae2ba","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","4b421cbfb3a38a27c279dec1e9112c3d1da296f77a1a85ddadf7e7a425d45d18","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9",{"version":"3aafcb693fe5b5c3bd277bd4c3a617b53db474fe498fc5df067c5603b1eebde7","affectsGlobalScope":true},{"version":"f3d4da15233e593eacb3965cde7960f3fddf5878528d882bcedd5cbaba0193c7","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"5f406584aef28a331c36523df688ca3650288d14f39c5d2e555c95f0d2ff8f6f","affectsGlobalScope":true},{"version":"22f230e544b35349cfb3bd9110b6ef37b41c6d6c43c3314a31bd0d9652fcec72","affectsGlobalScope":true},{"version":"7ea0b55f6b315cf9ac2ad622b0a7813315bb6e97bf4bb3fbf8f8affbca7dc695","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"eb26de841c52236d8222f87e9e6a235332e0788af8c87a71e9e210314300410a","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"5e5e095c4470c8bab227dbbc61374878ecead104c74ab9960d3adcccfee23205","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"2768ef564cfc0689a1b76106c421a2909bdff0acbe87da010785adab80efdd5c","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},"f1c9fe42b65437a61104e601eb298c5c859fb522b483f1bdb700eed67a16f980",{"version":"64a5230ae6777f94cc6bfb1091d5a6001957dcedca03877acda0505921f693b7","signature":"d6f41b971ee3fe8297ead6d46b1fb928a8ae09f587846d1ab16e1d406e87763c"},"4d4cf93a6b4c81851ad759e4569b6feb7a701e80b13a6f9d8d9c6012bbb86bd6","2e6035af8f3e43bf95e4983329c8277d66f9b271106af27b99a85d1c1b9daf4a","774308610e8d4a9954cd93840f99decbf340accfe3ad7365547950ede8162c92","36c15dd26c66c97b9df26ce34baacdb13fc760c5b9a2d789dcc317d27b189257","44a967eeba769bc2a7ea7df4338fa7921cff46a21070f623c13a9053af6bf75d",{"version":"fd624f7d7b264922476685870f08c5e1c6d6a0f05dee2429a9747b41f6b699d4","affectsGlobalScope":true},"701978f3975f96e76e3ffc2e1762e3a97e3d323812049fb6fdfd559579b89708",{"version":"4ab17f80ced148d509345cee706b2b85941515dd76e32cf47118bcdf6a4bd56a","affectsGlobalScope":true},"641089f0b8094ef74b9d4b3364d5dec1592d5e3b8a51c1ba491bc8872049e79a","9197b3ca76c01df6120b4ee288fe2d08f8a2089221da97956bee402de0ffd37e","7af29b0589483f7bb8a99405ddb849f34bc053146184561ed4179e02f5fe4d0f","d8afb84d78023735e55f1b96e06b3e221eb7ce5473ca1c93564d30e7efb0f991","52dd370c807255c61765347fc90a9bee3c522b8744dc222714e2bf6b5be3a823","1e5743b25a63fd34ffbae89adcbf248ee17db6ed08d90079ffa93803c3e80d2a","3cbcdf2a84c93c6b62d8d4584f613c8af7c6330ac2ba1ff781d10a3e0935beb9","2fcd2d22b1f30555e785105597cd8f57ed50300e213c4f1bbca6ae149f782c38",{"version":"3c150a2e1758724811db3bdc5c773421819343b1627714e09f29b1f40a5dfb26","affectsGlobalScope":true},"c567d37119d6f56381af48eb7516030ccf35a36f9aca045e238d9c207a7c536c","26a397eed716192f4eef41e2c11baf9aaeb3a035c65294dbac431bf2d358ed86","eba7cf33380cc3a3cf614faf67300e14d0bdff9ea6c5cd6f4b040b1756a48ab1","5e7e090243bf203382a5cb04eabbdc38d78f6d5922f16f543e4da8fa007d5ff9","cd823094ded7c8ac4f94ab6dc387dab699293eb8323d9f948304efc07e4ae7b2","6bf72b2541469cac7a7882468d25a04fdff489625452ff7d3e670c764e5a9ba1","9d696793a977926a52f6a244917ef8ca205f1a105654a0ec277105e35570bf57","d50a158fc581be7b1c51253ad33cb29c0a8ce3c42ca38775ffadf104c36376d0","1f2cdbf59d0b7933678a64ac26ae2818c48ff9ebf93249dde775dc3e173e16bf",{"version":"d9ada24b70b5731f77ad997ad1bb671b80dcdff931e7c46171fef07ee0dad104","signature":"64b224909f444ceb75c3306e078b6cd5f484b1487ffe18e13f150c9d2689dcd8"},{"version":"d3a72e3acec55990c739ec2c7ec487ace738418d0650356c2db86b67a3d1b818","signature":"6a716b8d3a52002354a3e530ee6c90d52209af1f53eaefb9c4527228bf0a6f67"},{"version":"8d55dba17babd73716321b2ed065017dcbe6c84fc21aa0cab4e3cc48fbdc526e","signature":"aac4ddff3d5c1247433870879e9838b1e23b81a9b62c75f59c3e1b64802f2b16"},{"version":"f528a2210943d5d3f1f4a154387da39afab55e9e91ca68f6fb4e3ef8a43a9823","signature":"0d1e9013237428428f2c4b8c4c64e3b5fce66d8140bc75629c0cc320c85c4925"},"7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"8d81612302e009aacd595b125ae1530b6342f690eb83da7788503617d1362185","affectsGlobalScope":true},"11e2d554398d2bd460e7d06b2fa5827a297c8acfbe00b4f894a224ac0862857f",{"version":"e193e634a99c9c1d71f1c6e4e1567a4a73584328d21ea02dd5cddbaad6693f61","affectsGlobalScope":true},"374ca798f244e464346f14301dc2a8b4b111af1a83b49fffef5906c338a1f922","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","e596c9bb2f29a2699fdd4ae89139612652245192f67f45617c5a4b20832aaae9","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","1cdcfc1f624d6c08aa12c73935f6e13f095919cd99edf95752951796eb225729","216717f17c095cde1dc19375e1ab3af0a4a485355860c077a4f9d6ea59fab5b5","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"80473bd0dd90ca1e166514c2dfead9d5803f9c51418864ca35abbeec6e6847e1","1c84b46267610a34028edfd0d035509341751262bac1062857f3c8df7aff7153","e6c86d83bd526c8bdb5d0bf935b8e72ce983763d600743f74d812fdf4abf4df6","a3d541d303ee505053f5dcbf9fafb65cac3d5631037501cd616195863a6c5740","8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true},"bcebb922784739bdb34c18ee51095d25a92b560c78ccd2eaacd6bd00f7443d83","7ee6ed878c4528215c82b664fe0cfe80e8b4da6c0d4cc80869367868774db8b1","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"0715e4cd28ad471b2a93f3e552ff51a3ae423417a01a10aa1d3bc7c6b95059d6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","4f3fdeba4e28e21aa719c081b8dc8f91d47e12e773389b9d35679c08151c9d37","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","f69ff39996a61a0dd10f4bce73272b52e8024a4d58b13ab32bf4712909d0a2b7",{"version":"3c4ba1dd9b12ffa284b565063108f2f031d150ea15b8fafbdc17f5d2a07251f3","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","c4577fb855ca259bdbf3ea663ca73988ce5f84251a92b4aef80a1f4122b6f98e","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"ff07a9a03c65732ccc59b3c65bc584173da093bd563a6565411c01f5703bd3cb","affectsGlobalScope":true},"6de4a219df57d2b27274d59b67708f13c2cbf7ed211abe57d8f9ab8b25cde776","0fe8985a28f82c450a04a6edf1279d7181c0893f37da7d2a27f8efd4fd5edb03","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"d8d555f3d607ecaa18d55de6995ea8f206342ecc93305919eac945c7c78c78c6","6c1e688f95fcaf53b1e41c0fdadf2c1cfc96fa924eaf7f9fdb60f96deb0a4986","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","db25694be959314fd1e868d72e567746db1db9e2001fae545d12d2a8c1bba1b8","43883cf3635bb1846cbdc6c363787b76227677388c74f7313e3f0edb380840fa","2d47012580f859dae201d2eef898a416bdae719dffc087dfd06aefe3de2f9c8d","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","2cec1a31729b9b01e9294c33fc9425d336eff067282809761ad2e74425d6d2a5",{"version":"5bc4bb5796ce660d9869477983aac87734e19fecd1ad60fb0b13ffe1f1a450ed","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"noImplicitAny":false,"outDir":"./","sourceMap":true,"strict":true,"target":4,"useDefineForClassFields":false},"fileIdsList":[[122],[122,132],[58,59,122],[54,55,56,122],[67,122],[50,53,57,68,122],[51,52,122],[46,47,48,49,122],[47,48,122],[46,47,49,122],[122,134,137],[76,122],[79,122],[80,85,113,122],[81,92,93,100,110,121,122],[81,82,92,100,122],[83,122],[84,85,93,101,122],[85,110,118,122],[86,88,92,100,122],[87,122],[88,89,122],[92,122],[90,92,122],[92,93,94,110,121,122],[92,93,94,107,110,113,122],[122,126],[88,95,100,110,121,122],[92,93,95,96,100,110,118,121,122],[95,97,110,118,121,122],[76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128],[92,98,122],[99,121,122],[88,92,100,110,122],[101,122],[102,122],[79,103,122],[104,120,122,126],[105,122],[106,122],[92,107,108,122],[107,109,122,124],[80,92,110,111,112,113,122],[80,110,112,122],[110,111,122],[113,122],[114,122],[92,116,117,122],[116,117,122],[85,100,110,118,122],[119,122],[100,120,122],[80,95,106,121,122],[85,122],[110,122,123],[122,124],[122,125],[80,85,92,94,103,110,121,122,124,126],[110,122,127],[61,122],[122,130,136],[122,134],[122,131,135],[60,64,122],[64,122],[62,63,122],[60,64,65,66,122],[122,133],[51,122],[51,70,122],[44,51,71,122],[44,122],[44,45,69,72,73,122],[44,45,122],[44,72,122],[51,71],[45]],"referencedMap":[[130,1],[133,2],[58,1],[59,1],[60,3],[54,1],[56,1],[57,4],[55,1],[68,5],[69,6],[53,7],[46,1],[50,8],[49,9],[48,10],[47,1],[132,1],[138,11],[76,12],[77,12],[79,13],[80,14],[81,15],[82,16],[83,17],[84,18],[85,19],[86,20],[87,21],[88,22],[89,22],[91,23],[90,24],[92,23],[93,25],[94,26],[78,27],[128,1],[95,28],[96,29],[97,30],[129,31],[98,32],[99,33],[100,34],[101,35],[102,36],[103,37],[104,38],[105,39],[106,40],[107,41],[108,41],[109,42],[110,43],[112,44],[111,45],[113,46],[114,47],[115,1],[116,48],[117,49],[118,50],[119,51],[120,52],[121,53],[122,54],[123,55],[124,56],[125,57],[126,58],[127,59],[62,60],[61,1],[131,1],[137,61],[135,62],[136,63],[65,64],[63,65],[66,1],[64,66],[67,67],[134,68],[52,69],[71,70],[70,69],[51,1],[44,1],[8,1],[9,1],[11,1],[10,1],[2,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[3,1],[4,1],[23,1],[20,1],[21,1],[22,1],[24,1],[25,1],[26,1],[5,1],[27,1],[28,1],[29,1],[30,1],[6,1],[34,1],[31,1],[32,1],[33,1],[35,1],[7,1],[36,1],[41,1],[42,1],[37,1],[38,1],[39,1],[40,1],[1,1],[43,1],[72,71],[45,72],[74,73],[75,74],[73,75]],"exportedModulesMap":[[130,1],[133,2],[58,1],[59,1],[60,3],[54,1],[56,1],[57,4],[55,1],[68,5],[69,6],[53,7],[46,1],[50,8],[49,9],[48,10],[47,1],[132,1],[138,11],[76,12],[77,12],[79,13],[80,14],[81,15],[82,16],[83,17],[84,18],[85,19],[86,20],[87,21],[88,22],[89,22],[91,23],[90,24],[92,23],[93,25],[94,26],[78,27],[128,1],[95,28],[96,29],[97,30],[129,31],[98,32],[99,33],[100,34],[101,35],[102,36],[103,37],[104,38],[105,39],[106,40],[107,41],[108,41],[109,42],[110,43],[112,44],[111,45],[113,46],[114,47],[115,1],[116,48],[117,49],[118,50],[119,51],[120,52],[121,53],[122,54],[123,55],[124,56],[125,57],[126,58],[127,59],[62,60],[61,1],[131,1],[137,61],[135,62],[136,63],[65,64],[63,65],[66,1],[64,66],[67,67],[134,68],[52,69],[71,70],[70,69],[51,1],[44,1],[8,1],[9,1],[11,1],[10,1],[2,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[3,1],[4,1],[23,1],[20,1],[21,1],[22,1],[24,1],[25,1],[26,1],[5,1],[27,1],[28,1],[29,1],[30,1],[6,1],[34,1],[31,1],[32,1],[33,1],[35,1],[7,1],[36,1],[41,1],[42,1],[37,1],[38,1],[39,1],[40,1],[1,1],[43,1],[72,76],[75,77]],"semanticDiagnosticsPerFile":[130,133,58,59,60,54,56,57,55,68,69,53,46,50,49,48,47,132,138,76,77,79,80,81,82,83,84,85,86,87,88,89,91,90,92,93,94,78,128,95,96,97,129,98,99,100,101,102,103,104,105,106,107,108,109,110,112,111,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,62,61,131,137,135,136,65,63,66,64,67,134,52,71,70,51,44,8,9,11,10,2,12,13,14,15,16,17,18,19,3,4,23,20,21,22,24,25,26,5,27,28,29,30,6,34,31,32,33,35,7,36,41,42,37,38,39,40,1,43,72,45,74,75,73]},"version":"4.9.5"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const shell_1 = require("@things-factory/shell");
5
+ const privilege_1 = require("./service/privilege/privilege");
4
6
  require("./routes");
5
7
  tslib_1.__exportStar(require("./service"), exports);
6
8
  tslib_1.__exportStar(require("./migrations"), exports);
@@ -14,4 +16,14 @@ tslib_1.__exportStar(require("./utils/check-user-belongs-domain"), exports);
14
16
  tslib_1.__exportStar(require("./utils/access-token-cookie"), exports);
15
17
  tslib_1.__exportStar(require("./errors"), exports);
16
18
  tslib_1.__exportStar(require("./types"), exports);
19
+ process.on('bootstrap-module-start', async ({ app, config, client }) => {
20
+ const privileges = process['PRIVILEGES'];
21
+ const privilegeRepository = (0, shell_1.getRepository)(privilege_1.Privilege);
22
+ for (const [category, name] of Object.values(privileges)) {
23
+ if (0 == (await privilegeRepository.count({ where: { category, name } }))) {
24
+ await privilegeRepository.save({ category, name });
25
+ }
26
+ }
27
+ console.log('[auth-base:bootstrap] Synchronization for privilege master has just done.');
28
+ });
17
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oBAAiB;AAEjB,oDAAyB;AACzB,uDAA4B;AAE5B,wDAA6B;AAC7B,mDAAwB;AACxB,mDAAwB;AAExB,mEAAwC;AACxC,mEAAwC;AACxC,6DAAkC;AAClC,4EAAiD;AACjD,sEAA2C;AAC3C,mDAAwB;AAExB,kDAAuB","sourcesContent":["import './routes'\n\nexport * from './service'\nexport * from './migrations'\n\nexport * from './middlewares'\nexport * from './routes'\nexport * from './router'\n\nexport * from './utils/get-domain-users'\nexport * from './utils/get-user-domains'\nexport * from './utils/get-secret'\nexport * from './utils/check-user-belongs-domain'\nexport * from './utils/access-token-cookie'\nexport * from './errors'\n\nexport * from './types'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AACrD,6DAAyD;AAEzD,oBAAiB;AAEjB,oDAAyB;AACzB,uDAA4B;AAE5B,wDAA6B;AAC7B,mDAAwB;AACxB,mDAAwB;AAExB,mEAAwC;AACxC,mEAAwC;AACxC,6DAAkC;AAClC,4EAAiD;AACjD,sEAA2C;AAC3C,mDAAwB;AAExB,kDAAuB;AAEvB,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IACxC,MAAM,mBAAmB,GAAG,IAAA,qBAAa,EAAC,qBAAS,CAAC,CAAA;IAEpD,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,UAA8B,CAAC,EAAE;QAC5E,IAAI,CAAC,IAAI,CAAC,MAAM,mBAAmB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE;YACzE,MAAM,mBAAmB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;SACnD;KACF;IAED,OAAO,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAA;AAC1F,CAAC,CAAC,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { Privilege } from './service/privilege/privilege'\n\nimport './routes'\n\nexport * from './service'\nexport * from './migrations'\n\nexport * from './middlewares'\nexport * from './routes'\nexport * from './router'\n\nexport * from './utils/get-domain-users'\nexport * from './utils/get-user-domains'\nexport * from './utils/get-secret'\nexport * from './utils/check-user-belongs-domain'\nexport * from './utils/access-token-cookie'\nexport * from './errors'\n\nexport * from './types'\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n const privileges = process['PRIVILEGES']\n const privilegeRepository = getRepository(Privilege)\n\n for (const [category, name] of Object.values(privileges as [string, string])) {\n if (0 == (await privilegeRepository.count({ where: { category, name } }))) {\n await privilegeRepository.save({ category, name })\n }\n }\n\n console.log('[auth-base:bootstrap] Synchronization for privilege master has just done.')\n})\n"]}
@@ -19,12 +19,12 @@ export * from './partner/partner-types';
19
19
  export * from './privilege/privilege-types';
20
20
  export * from './role/role-types';
21
21
  export * from './user/user-types';
22
- export declare const entities: (typeof import("./privilege/privilege").Privilege | typeof import("./role/role").Role | typeof import("./user/user").User | typeof import("./verification-token/verification-token").VerificationToken | typeof import("./verification-token/verification-token").VerificationTokenType | typeof import("./password-history/password-history").PasswordHistory | typeof import("./invitation/invitation").Invitation | typeof import("./application/application").Application | typeof import("./login-history/login-history").LoginHistory | typeof import("./appliance/appliance").Appliance | typeof import("./granted-role/granted-role").GrantedRole | typeof import("./partner/partner").Partner)[];
22
+ export declare const entities: (typeof import("./user/user").User | typeof import("./role/role").Role | typeof import("./application/application").Application | typeof import("./appliance/appliance").Appliance | typeof import("./privilege/privilege").Privilege | typeof import("./partner/partner").Partner | typeof import("./granted-role/granted-role").GrantedRole | typeof import("./invitation/invitation").Invitation | typeof import("./password-history/password-history").PasswordHistory | typeof import("./verification-token/verification-token").VerificationToken | typeof import("./verification-token/verification-token").VerificationTokenType | typeof import("./login-history/login-history").LoginHistory)[];
23
23
  export declare const schema: {
24
24
  typeDefs: {
25
25
  privilegeDirectiveTypeDefs: import("graphql").DocumentNode;
26
26
  };
27
- resolverClasses: (typeof import("./app-binding/app-binding-query").AppBindingQuery | typeof import("./app-binding/app-binding-mutation").AppBindingMutation | typeof import("./appliance/appliance-query").ApplianceQuery | typeof import("./appliance/appliance-mutation").ApplianceMutation | typeof import("./application/application-query").ApplicationQuery | typeof import("./application/application-mutation").ApplicationMutation | typeof import("./domain-generator/domain-generator-mutation").DomainGeneratorMutation | typeof import("./granted-role/granted-role-query").GrantedRoleQuery | typeof import("./granted-role/granted-role-mutation").GrantedRoleMutation | typeof import("./invitation/invitation-query").InvitationQuery | typeof import("./invitation/invitation-mutation").InvitationMutation | typeof import("./login-history/login-history-query").LoginHistoryQuery | typeof import("./partner/partner-query").PartnerQuery | typeof import("./partner/partner-mutation").PartnerMutation | typeof import("./privilege/privilege-query").PrivilegeQuery | typeof import("./privilege/privilege-mutation").PrivilegeMutation | typeof import("./role/role-query").RoleQuery | typeof import("./role/role-mutation").RoleMutation | typeof import("./user/user-query").UserQuery | typeof import("./user/user-mutation").UserMutation | typeof import("./user/domain-query").DomainQuery)[];
27
+ resolverClasses: (typeof import("./application/application-query").ApplicationQuery | typeof import("./application/application-mutation").ApplicationMutation | typeof import("./appliance/appliance-query").ApplianceQuery | typeof import("./appliance/appliance-mutation").ApplianceMutation | typeof import("./privilege/privilege-query").PrivilegeQuery | typeof import("./privilege/privilege-mutation").PrivilegeMutation | typeof import("./role/role-query").RoleQuery | typeof import("./role/role-mutation").RoleMutation | typeof import("./user/user-query").UserQuery | typeof import("./user/user-mutation").UserMutation | typeof import("./user/domain-query").DomainQuery | typeof import("./partner/partner-query").PartnerQuery | typeof import("./partner/partner-mutation").PartnerMutation | typeof import("./granted-role/granted-role-query").GrantedRoleQuery | typeof import("./granted-role/granted-role-mutation").GrantedRoleMutation | typeof import("./invitation/invitation-query").InvitationQuery | typeof import("./invitation/invitation-mutation").InvitationMutation | typeof import("./app-binding/app-binding-query").AppBindingQuery | typeof import("./app-binding/app-binding-mutation").AppBindingMutation | typeof import("./domain-generator/domain-generator-mutation").DomainGeneratorMutation | typeof import("./login-history/login-history-query").LoginHistoryQuery)[];
28
28
  directives: {
29
29
  privilege: (schema: import("graphql").GraphQLSchema) => import("graphql").GraphQLSchema;
30
30
  };
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
5
5
  const graphql_1 = require("graphql");
6
6
  const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
7
7
  const utils_1 = require("@graphql-tools/utils");
8
- const shell_1 = require("@things-factory/shell");
9
8
  const user_1 = require("../user/user");
10
9
  process['PRIVILEGES'] = {};
11
10
  const DIRECTIVE = 'privilege';
@@ -40,37 +39,7 @@ const privilegeDirectiveResolver = (schema) => (0, utils_1.mapSchema)(schema, {
40
39
  }
41
40
  if (!category || !privilege)
42
41
  throw new Error(`Unauthorized!`);
43
- const result = await (0, shell_1.getRepository)(user_1.User).query(`
44
- SELECT
45
- COUNT(1) AS has_privilege
46
- FROM
47
- privileges
48
- WHERE
49
- category = '${category}'
50
- AND
51
- name = '${privilege}'
52
- AND
53
- id
54
- IN (
55
- SELECT
56
- RP.privileges_id
57
- FROM
58
- users_roles UR
59
- INNER JOIN
60
- roles_privileges RP
61
- ON
62
- UR.roles_id = RP.roles_id
63
- LEFT JOIN
64
- roles R
65
- ON
66
- R.id = UR.roles_id
67
- WHERE
68
- UR.users_id = '${user === null || user === void 0 ? void 0 : user.id}'
69
- AND
70
- R.domain_id = '${domain === null || domain === void 0 ? void 0 : domain.id}'
71
- )
72
- `);
73
- if (result[0].has_privilege > 0) {
42
+ if (await user_1.User.hasPrivilege(privilege, category, domain, user)) {
74
43
  return await resolve.call(this, source, args, context, info);
75
44
  }
76
45
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"privilege-directive.js","sourceRoot":"","sources":["../../../server/service/privilege/privilege-directive.ts"],"names":[],"mappings":";;;;AAAA,qCAA6D;AAC7D,sEAA6B;AAE7B,gDAA0E;AAC1E,iDAAqD;AAErD,uCAAmC;AAEnC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,CAAA;AAE1B,MAAM,SAAS,GAAG,WAAW,CAAA;AAEhB,QAAA,0BAA0B,GAAG,IAAA,qBAAG,EAAA;;;;;;;CAO5C,CAAA;AACM,MAAM,0BAA0B,GAAG,CAAC,MAAqB,EAAE,EAAE,CAClE,IAAA,iBAAS,EAAC,MAAM,EAAE;IAChB,CAAC,kBAAU,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;;QACtE,MAAM,kBAAkB,GAAG,MAAA,IAAA,oBAAY,EAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,0C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AC,CAAC,KAAK,CAC5C;;;;;;kCAMsB,QAAQ;;8BAEZ,SAAS;;;;;;;;;;;;;;;;;uCAiBA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,EAAE;;uCAER,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE;;iBAEhC,CACN,CAAA;gBAED,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,GAAG,CAAC,EAAE;oBAC/B,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;iBAC7D;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;iBACjC;YACH,CAAC,CAAA;YAED,OAAO,WAAW,CAAA;SACnB;IACH,CAAC;CACF,CAAC,CAAA;AAxES,QAAA,0BAA0B,8BAwEnC","sourcesContent":["import { defaultFieldResolver, GraphQLSchema } from 'graphql'\nimport gql from 'graphql-tag'\n\nimport { getDirective, MapperKind, mapSchema } from '@graphql-tools/utils'\nimport { getRepository } from '@things-factory/shell'\n\nimport { User } from '../user/user'\n\nprocess['PRIVILEGES'] = {}\n\nconst DIRECTIVE = 'privilege'\n\nexport const privilegeDirectiveTypeDefs = gql`\n directive @privilege(\n category: String\n privilege: String\n domainOwnerGranted: Boolean\n superUserGranted: Boolean\n ) on FIELD_DEFINITION\n`\nexport const privilegeDirectiveResolver = (schema: GraphQLSchema) =>\n mapSchema(schema, {\n [MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName, schema) => {\n const privilegeDirective = getDirective(schema, fieldConfig, DIRECTIVE)?.[0]\n if (privilegeDirective) {\n const { resolve = defaultFieldResolver, args } = fieldConfig\n\n if (!args) {\n throw new Error(`Unexpected Error. args should be defined in @privilige directive for field ${fieldName}.`)\n }\n\n const { domainOwnerGranted, superUserGranted, category, privilege } = privilegeDirective\n if (category && privilege) {\n process['PRIVILEGES'][`${category} ${privilege}`] = [category, privilege]\n }\n\n fieldConfig.resolve = async function (source, args, context, info) {\n const { domain, user } = context.state\n\n if (domainOwnerGranted && (await process.domainOwnerGranted(domain, user))) {\n return await resolve.call(this, source, args, context, info)\n }\n\n if (superUserGranted && (await process.superUserGranted(domain, user))) {\n return await resolve.call(this, source, args, context, info)\n }\n\n if (!category || !privilege) throw new Error(`Unauthorized!`)\n\n const result = await getRepository(User).query(\n `\n SELECT \n COUNT(1) AS has_privilege\n FROM\n privileges\n WHERE\n category = '${category}'\n AND\n name = '${privilege}'\n AND\n id\n IN (\n SELECT\n RP.privileges_id\n FROM\n users_roles UR\n INNER JOIN\n roles_privileges RP\n ON\n UR.roles_id = RP.roles_id\n LEFT JOIN\n roles R\n ON\n R.id = UR.roles_id\n WHERE\n UR.users_id = '${user?.id}'\n AND\n R.domain_id = '${domain?.id}'\n )\n `\n )\n\n if (result[0].has_privilege > 0) {\n return await resolve.call(this, source, args, context, info)\n } else {\n throw new Error(`Unauthorized!`)\n }\n }\n\n return fieldConfig\n }\n }\n })\n"]}
1
+ {"version":3,"file":"privilege-directive.js","sourceRoot":"","sources":["../../../server/service/privilege/privilege-directive.ts"],"names":[],"mappings":";;;;AAAA,qCAA6D;AAC7D,sEAA6B;AAE7B,gDAA0E;AAC1E,uCAAmC;AAEnC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,CAAA;AAE1B,MAAM,SAAS,GAAG,WAAW,CAAA;AAEhB,QAAA,0BAA0B,GAAG,IAAA,qBAAG,EAAA;;;;;;;CAO5C,CAAA;AACM,MAAM,0BAA0B,GAAG,CAAC,MAAqB,EAAE,EAAE,CAClE,IAAA,iBAAS,EAAC,MAAM,EAAE;IAChB,CAAC,kBAAU,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;;QACtE,MAAM,kBAAkB,GAAG,MAAA,IAAA,oBAAY,EAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,0CA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,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;oBAC9D,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;iBAC7D;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;iBACjC;YACH,CAAC,CAAA;YAED,OAAO,WAAW,CAAA;SACnB;IACH,CAAC;CACF,CAAC,CAAA;AAvCS,QAAA,0BAA0B,8BAuCnC","sourcesContent":["import { defaultFieldResolver, GraphQLSchema } from 'graphql'\nimport gql from 'graphql-tag'\n\nimport { getDirective, MapperKind, mapSchema } from '@graphql-tools/utils'\nimport { User } from '../user/user'\n\nprocess['PRIVILEGES'] = {}\n\nconst DIRECTIVE = 'privilege'\n\nexport const privilegeDirectiveTypeDefs = gql`\n directive @privilege(\n category: String\n privilege: String\n domainOwnerGranted: Boolean\n superUserGranted: Boolean\n ) on FIELD_DEFINITION\n`\nexport const privilegeDirectiveResolver = (schema: GraphQLSchema) =>\n mapSchema(schema, {\n [MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName, schema) => {\n const privilegeDirective = getDirective(schema, fieldConfig, DIRECTIVE)?.[0]\n if (privilegeDirective) {\n const { resolve = defaultFieldResolver, args } = fieldConfig\n\n if (!args) {\n throw new Error(`Unexpected Error. args should be defined in @privilige directive for field ${fieldName}.`)\n }\n\n const { domainOwnerGranted, superUserGranted, category, privilege } = privilegeDirective\n if (category && privilege) {\n process['PRIVILEGES'][`${category} ${privilege}`] = [category, privilege]\n }\n\n fieldConfig.resolve = async function (source, args, context, info) {\n const { domain, user } = context.state\n\n if (domainOwnerGranted && (await process.domainOwnerGranted(domain, user))) {\n return await resolve.call(this, source, args, context, info)\n }\n\n if (superUserGranted && (await process.superUserGranted(domain, user))) {\n return await resolve.call(this, source, args, context, info)\n }\n\n if (!category || !privilege) throw new Error(`Unauthorized!`)\n\n if (await User.hasPrivilege(privilege, category, domain, user)) {\n return await resolve.call(this, source, args, context, info)\n } else {\n throw new Error(`Unauthorized!`)\n }\n }\n\n return fieldConfig\n }\n }\n })\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Privilege } from './privilege';
2
2
  import { NewPrivilege, PrivilegePatch } from './privilege-types';
3
3
  export declare class PrivilegeMutation {
4
+ synchronizePrivilegeMaster(privilege: NewPrivilege, context: ResolverContext): Promise<Boolean>;
4
5
  createPrivilege(privilege: NewPrivilege, context: ResolverContext): Promise<Privilege>;
5
6
  updatePrivilege(name: string, category: string, patch: PrivilegePatch, context: ResolverContext): Promise<Privilege>;
6
7
  deletePrivilege(name: string, category: string, context: ResolverContext): Promise<boolean>;
@@ -9,6 +9,16 @@ const role_1 = require("../role/role");
9
9
  const privilege_1 = require("./privilege");
10
10
  const privilege_types_1 = require("./privilege-types");
11
11
  let PrivilegeMutation = class PrivilegeMutation {
12
+ async synchronizePrivilegeMaster(privilege, context) {
13
+ const privileges = process['PRIVILEGES'];
14
+ const privilegeRepository = (0, shell_1.getRepository)(privilege_1.Privilege);
15
+ for (const [category, name] of Object.values(privileges)) {
16
+ if (0 == (await privilegeRepository.count({ where: { category, name } }))) {
17
+ await privilegeRepository.save({ category, name });
18
+ }
19
+ }
20
+ return true;
21
+ }
12
22
  async createPrivilege(privilege, context) {
13
23
  if (privilege.roles && privilege.roles.length) {
14
24
  privilege.roles = await (0, shell_1.getRepository)(role_1.Role).findBy({
@@ -39,6 +49,18 @@ let PrivilegeMutation = class PrivilegeMutation {
39
49
  }
40
50
  };
41
51
  tslib_1.__decorate([
52
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted:true)'),
53
+ (0, type_graphql_1.Mutation)(returns => Boolean, {
54
+ description: 'To synchronize privilege master from API schema.'
55
+ }),
56
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('privilege')),
57
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
58
+ tslib_1.__metadata("design:type", Function),
59
+ tslib_1.__metadata("design:paramtypes", [privilege_types_1.NewPrivilege, Object]),
60
+ tslib_1.__metadata("design:returntype", Promise)
61
+ ], PrivilegeMutation.prototype, "synchronizePrivilegeMaster", null);
62
+ tslib_1.__decorate([
63
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted:true)'),
42
64
  (0, type_graphql_1.Mutation)(returns => privilege_1.Privilege, { description: 'To create new privilege' }),
43
65
  tslib_1.__param(0, (0, type_graphql_1.Arg)('privilege')),
44
66
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -47,6 +69,7 @@ tslib_1.__decorate([
47
69
  tslib_1.__metadata("design:returntype", Promise)
48
70
  ], PrivilegeMutation.prototype, "createPrivilege", null);
49
71
  tslib_1.__decorate([
72
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted:true)'),
50
73
  (0, type_graphql_1.Mutation)(returns => privilege_1.Privilege, { description: 'To modify privilege information' }),
51
74
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
52
75
  tslib_1.__param(1, (0, type_graphql_1.Arg)('category')),
@@ -57,6 +80,7 @@ tslib_1.__decorate([
57
80
  tslib_1.__metadata("design:returntype", Promise)
58
81
  ], PrivilegeMutation.prototype, "updatePrivilege", null);
59
82
  tslib_1.__decorate([
83
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted:true)'),
60
84
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete privilege' }),
61
85
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
62
86
  tslib_1.__param(1, (0, type_graphql_1.Arg)('category')),
@@ -1 +1 @@
1
- {"version":3,"file":"privilege-mutation.js","sourceRoot":"","sources":["../../../server/service/privilege/privilege-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA2D;AAC3D,qCAA4B;AAE5B,iDAAqD;AAErD,uCAAmC;AACnC,2CAAuC;AACvC,uDAAgE;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAEtB,AAAN,KAAK,CAAC,eAAe,CACD,SAAuB,EAClC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AAA,kBAAG,GAAE,CAAA;;;;wDAIP;AAzDU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,iBAAiB,CA0D7B;AA1DY,8CAAiB","sourcesContent":["import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Role } from '../role/role'\nimport { Privilege } from './privilege'\nimport { NewPrivilege, PrivilegePatch } from './privilege-types'\n\n@Resolver(Privilege)\nexport class PrivilegeMutation {\n @Mutation(returns => Privilege, { description: 'To create new privilege' })\n async createPrivilege(\n @Arg('privilege') privilege: NewPrivilege,\n @Ctx() context: ResolverContext\n ): Promise<Privilege> {\n if (privilege.roles && privilege.roles.length) {\n privilege.roles = await getRepository(Role).findBy({ \n id: In(privilege.roles.map((role: Partial<Role>) => role.id)) \n })\n }\n\n return await getRepository(Privilege).save({\n creator: context.state.user,\n updater: context.state.user,\n ...privilege\n })\n }\n\n @Mutation(returns => Privilege, { description: 'To modify privilege information' })\n async updatePrivilege(\n @Arg('name') name: string,\n @Arg('category') category: string,\n @Arg('patch') patch: PrivilegePatch,\n @Ctx() context: ResolverContext\n ): Promise<Privilege> {\n const repository = getRepository(Privilege)\n const privilege = await repository.findOne({\n where: { name, category },\n relations: ['roles', 'creator', 'updater']\n })\n\n const roleIds = privilege.roles.map(role => role.id)\n if (patch.roles && patch.roles.length) {\n patch.roles.forEach(({ id }) => {\n if (!roleIds.includes(id)) {\n roleIds.push(id)\n }\n })\n }\n\n return await repository.save({\n ...privilege,\n ...patch,\n roles: await getRepository(Role).findByIds(roleIds),\n updater: context.state.user\n })\n }\n\n @Mutation(returns => Boolean, { description: 'To delete privilege' })\n async deletePrivilege(\n @Arg('name') name: string,\n @Arg('category') category: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n await getRepository(Privilege).delete({ name, category })\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"privilege-mutation.js","sourceRoot":"","sources":["../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C,qBAAS,CAAC;GACP,iBAAiB,CAiF7B;AAjFY,8CAAiB","sourcesContent":["import { Arg, Ctx, Mutation, Resolver, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Role } from '../role/role'\nimport { Privilege } from './privilege'\nimport { NewPrivilege, PrivilegePatch } from './privilege-types'\n\n@Resolver(Privilege)\nexport class PrivilegeMutation {\n @Directive('@privilege(superUserGranted:true)')\n @Mutation(returns => Boolean, {\n description: 'To synchronize privilege master from API schema.'\n })\n async synchronizePrivilegeMaster(\n @Arg('privilege') privilege: NewPrivilege,\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const privileges = process['PRIVILEGES']\n const privilegeRepository = getRepository(Privilege)\n\n for (const [category, name] of Object.values(privileges as [string, string])) {\n if (0 == (await privilegeRepository.count({ where: { category, name } }))) {\n await privilegeRepository.save({ category, name })\n }\n }\n\n return true\n }\n\n @Directive('@privilege(superUserGranted:true)')\n @Mutation(returns => Privilege, { description: 'To create new privilege' })\n async createPrivilege(\n @Arg('privilege') privilege: NewPrivilege,\n @Ctx() context: ResolverContext\n ): Promise<Privilege> {\n if (privilege.roles && privilege.roles.length) {\n privilege.roles = await getRepository(Role).findBy({\n id: In(privilege.roles.map((role: Partial<Role>) => role.id))\n })\n }\n\n return await getRepository(Privilege).save({\n creator: context.state.user,\n updater: context.state.user,\n ...privilege\n })\n }\n\n @Directive('@privilege(superUserGranted:true)')\n @Mutation(returns => Privilege, { description: 'To modify privilege information' })\n async updatePrivilege(\n @Arg('name') name: string,\n @Arg('category') category: string,\n @Arg('patch') patch: PrivilegePatch,\n @Ctx() context: ResolverContext\n ): Promise<Privilege> {\n const repository = getRepository(Privilege)\n const privilege = await repository.findOne({\n where: { name, category },\n relations: ['roles', 'creator', 'updater']\n })\n\n const roleIds = privilege.roles.map(role => role.id)\n if (patch.roles && patch.roles.length) {\n patch.roles.forEach(({ id }) => {\n if (!roleIds.includes(id)) {\n roleIds.push(id)\n }\n })\n }\n\n return await repository.save({\n ...privilege,\n ...patch,\n roles: await getRepository(Role).findByIds(roleIds),\n updater: context.state.user\n })\n }\n\n @Directive('@privilege(superUserGranted:true)')\n @Mutation(returns => Boolean, { description: 'To delete privilege' })\n async deletePrivilege(\n @Arg('name') name: string,\n @Arg('category') category: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n await getRepository(Privilege).delete({ name, category })\n return true\n }\n}\n"]}
@@ -6,6 +6,7 @@ import { PrivilegeList } from './privilege-types';
6
6
  export declare class PrivilegeQuery {
7
7
  privilege(name: string, category: string): Promise<Privilege>;
8
8
  privileges(params: ListParam, context: ResolverContext): Promise<PrivilegeList>;
9
+ hasPrivilege(name: string, category: string, context: ResolverContext): Promise<Boolean>;
9
10
  description(privilege: Privilege, context: ResolverContext): Promise<string>;
10
11
  roles(privilege: Privilege): Promise<Role[]>;
11
12
  updater(privilege: Privilege): Promise<User>;
@@ -15,11 +15,17 @@ let PrivilegeQuery = class PrivilegeQuery {
15
15
  });
16
16
  }
17
17
  async privileges(params, context) {
18
- const queryBuilder = (0, shell_1.getRepository)(privilege_1.Privilege).createQueryBuilder();
19
- (0, shell_1.buildQuery)(queryBuilder, params, context, { domainRef: false });
20
- const [items, total] = await queryBuilder.getManyAndCount();
18
+ const [items, total] = await (0, shell_1.getQueryBuilderFromListParams)({
19
+ params,
20
+ repository: (0, shell_1.getRepository)(privilege_1.Privilege),
21
+ searchables: ['name', 'category']
22
+ }).getManyAndCount();
21
23
  return { items, total };
22
24
  }
25
+ async hasPrivilege(name, category, context) {
26
+ const { domain, user } = context.state;
27
+ return await user_1.User.hasPrivilege(name, category, domain, user);
28
+ }
23
29
  async description(privilege, context) {
24
30
  const { t } = context;
25
31
  const { name, category } = privilege;
@@ -46,6 +52,7 @@ let PrivilegeQuery = class PrivilegeQuery {
46
52
  }
47
53
  };
48
54
  tslib_1.__decorate([
55
+ (0, type_graphql_1.Directive)('@privilege(category: "privilege", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
49
56
  (0, type_graphql_1.Query)(returns => privilege_1.Privilege, { description: 'To fetch privilege' }),
50
57
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
51
58
  tslib_1.__param(1, (0, type_graphql_1.Arg)('category')),
@@ -54,6 +61,7 @@ tslib_1.__decorate([
54
61
  tslib_1.__metadata("design:returntype", Promise)
55
62
  ], PrivilegeQuery.prototype, "privilege", null);
56
63
  tslib_1.__decorate([
64
+ (0, type_graphql_1.Directive)('@privilege(category: "privilege", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
57
65
  (0, type_graphql_1.Query)(returns => privilege_types_1.PrivilegeList, { description: 'To fetch multiple privileges' }),
58
66
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
59
67
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
@@ -61,6 +69,15 @@ tslib_1.__decorate([
61
69
  tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
62
70
  tslib_1.__metadata("design:returntype", Promise)
63
71
  ], PrivilegeQuery.prototype, "privileges", null);
72
+ tslib_1.__decorate([
73
+ (0, type_graphql_1.Query)(returns => Boolean, { description: 'To query whether I have the given permission' }),
74
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
75
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('category')),
76
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
77
+ tslib_1.__metadata("design:type", Function),
78
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
79
+ tslib_1.__metadata("design:returntype", Promise)
80
+ ], PrivilegeQuery.prototype, "hasPrivilege", null);
64
81
  tslib_1.__decorate([
65
82
  (0, type_graphql_1.FieldResolver)(type => String),
66
83
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -1 +1 @@
1
- {"version":3,"file":"privilege-query.js","sourceRoot":"","sources":["../../../server/service/privilege/privilege-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,iDAA4E;AAE5E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,CAAA;IAAwB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,qBAAS;;iDAa7C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,WAAI,CAAC,CAAC;IACjB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;2CAOvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,WAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;6CAEzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,WAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;6CAEzC;AApDU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,cAAc,CAqD1B;AArDY,wCAAc","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { buildQuery, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Role } from '../role/role'\nimport { User } from '../user/user'\nimport { Privilege } from './privilege'\nimport { PrivilegeList } from './privilege-types'\n\n@Resolver(Privilege)\nexport class PrivilegeQuery {\n @Query(returns => Privilege, { description: 'To fetch privilege' })\n async privilege(@Arg('name') name: string, @Arg('category') category: string): Promise<Privilege> {\n return await getRepository(Privilege).findOne({\n where: { name, category }\n })\n }\n\n @Query(returns => PrivilegeList, { description: 'To fetch multiple privileges' })\n async privileges(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<PrivilegeList> {\n const queryBuilder = getRepository(Privilege).createQueryBuilder()\n buildQuery(queryBuilder, params, context, { domainRef: false })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async description(@Root() privilege: Privilege, @Ctx() context: ResolverContext) {\n const { t } = context\n const { name, category } = privilege\n\n const keyname = `privilege.name.${name}`\n const keycategory = `privilege.category.${category}`\n const tname = t(keyname)\n const tcategory = t(keycategory)\n\n return t('privilege.description', {\n name: tname === keyname ? name : tname,\n category: tcategory === keycategory ? category : tcategory\n })\n }\n\n @FieldResolver(type => [Role])\n async roles(@Root() privilege: Privilege) {\n return (\n await getRepository(Privilege).findOne({\n where: { id: privilege.id },\n relations: ['roles']\n })\n ).roles\n }\n\n @FieldResolver(type => User)\n async updater(@Root() privilege: Privilege): Promise<User> {\n return await getRepository(User).findOneBy({ id: privilege.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() privilege: Privilege): Promise<User> {\n return await getRepository(User).findOneBy({ id: privilege.creatorId })\n }\n}\n"]}
1
+ {"version":3,"file":"privilege-query.js","sourceRoot":"","sources":["../../../server/service/privilege/privilege-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,iDAA+F;AAE/F,uCAAmC;AACnC,uCAAmC;AACnC,2CAAuC;AACvC,uDAAiD;AAG1C,IAAM,cAAc,GAApB,MAAM,cAAc;IAGnB,AAAN,KAAK,CAAC,SAAS,CAAc,IAAY,EAAmB,QAAgB;QAC1E,OAAO,MAAM,IAAA,qBAAa,EAAC,qBAAS,CAAC,CAAC,OAAO,CAAC;YAC5C,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B,CAAC,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,UAAU,CAAS,MAAiB,EAAS,OAAwB;QACzE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,qCAA6B,EAAC;YACzD,MAAM;YACN,UAAU,EAAE,IAAA,qBAAa,EAAC,qBAAS,CAAC;YACpC,WAAW,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;SAClC,CAAC,CAAC,eAAe,EAAE,CAAA;QAEpB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGK,AAAN,KAAK,CAAC,YAAY,CACH,IAAY,EACR,QAAgB,EAC1B,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,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;2CAOvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,WAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;6CAEzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,WAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;6CAEzC;AAjEU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,cAAc,CAkE1B;AAlEY,wCAAc","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Role } from '../role/role'\nimport { User } from '../user/user'\nimport { Privilege } from './privilege'\nimport { PrivilegeList } from './privilege-types'\n\n@Resolver(Privilege)\nexport class PrivilegeQuery {\n @Directive('@privilege(category: \"privilege\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Privilege, { description: 'To fetch privilege' })\n async privilege(@Arg('name') name: string, @Arg('category') category: string): Promise<Privilege> {\n return await getRepository(Privilege).findOne({\n where: { name, category }\n })\n }\n\n @Directive('@privilege(category: \"privilege\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => PrivilegeList, { description: 'To fetch multiple privileges' })\n async privileges(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<PrivilegeList> {\n const [items, total] = await getQueryBuilderFromListParams({\n params,\n repository: getRepository(Privilege),\n searchables: ['name', 'category']\n }).getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => Boolean, { description: 'To query whether I have the given permission' })\n async hasPrivilege(\n @Arg('name') name: string,\n @Arg('category') category: string,\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { domain, user } = context.state\n return await User.hasPrivilege(name, category, domain, user)\n }\n\n @FieldResolver(type => String)\n async description(@Root() privilege: Privilege, @Ctx() context: ResolverContext) {\n const { t } = context\n const { name, category } = privilege\n\n const keyname = `privilege.name.${name}`\n const keycategory = `privilege.category.${category}`\n const tname = t(keyname)\n const tcategory = t(keycategory)\n\n return t('privilege.description', {\n name: tname === keyname ? name : tname,\n category: tcategory === keycategory ? category : tcategory\n })\n }\n\n @FieldResolver(type => [Role])\n async roles(@Root() privilege: Privilege) {\n return (\n await getRepository(Privilege).findOne({\n where: { id: privilege.id },\n relations: ['roles']\n })\n ).roles\n }\n\n @FieldResolver(type => User)\n async updater(@Root() privilege: Privilege): Promise<User> {\n return await getRepository(User).findOneBy({ id: privilege.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() privilege: Privilege): Promise<User> {\n return await getRepository(User).findOneBy({ id: privilege.creatorId })\n }\n}\n"]}
@@ -36,4 +36,5 @@ export declare class User {
36
36
  static encode(password: string, salt: any): string;
37
37
  static verify(hashed: any, password: any, salt: any): boolean;
38
38
  static checkAuth(decoded: any): Promise<User>;
39
+ static hasPrivilege(name: string, category: string, domain: Domain, user: User): Promise<boolean>;
39
40
  }
@@ -71,7 +71,7 @@ let User = User_1 = class User {
71
71
  .digest('base64'));
72
72
  }
73
73
  static async checkAuth(decoded) {
74
- const repository = (0, typeorm_1.getRepository)(User_1);
74
+ const repository = (0, shell_1.getRepository)(User_1);
75
75
  var user = await repository.findOne({
76
76
  where: { id: decoded.id },
77
77
  relations: ['domains'],
@@ -109,6 +109,21 @@ let User = User_1 = class User {
109
109
  return user;
110
110
  }
111
111
  }
112
+ static async hasPrivilege(name, category, domain, user) {
113
+ const result = await (0, shell_1.getRepository)(User_1).query(`SELECT COUNT(1) AS has_privilege FROM privileges
114
+ WHERE category = '${category}'
115
+ AND name = '${name}'
116
+ AND id IN (
117
+ SELECT RP.privileges_id
118
+ FROM users_roles UR
119
+ INNER JOIN roles_privileges RP ON UR.roles_id = RP.roles_id
120
+ LEFT JOIN roles R ON R.id = UR.roles_id
121
+ WHERE UR.users_id = '${user === null || user === void 0 ? void 0 : user.id}'
122
+ AND R.domain_id = '${domain === null || domain === void 0 ? void 0 : domain.id}'
123
+ )
124
+ `);
125
+ return result[0].has_privilege > 0;
126
+ }
112
127
  };
113
128
  tslib_1.__decorate([
114
129
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../server/service/user/user.ts"],"names":[],"mappings":";;;;;AAAA,4DAA2B;AAC3B,wEAA8B;AAC9B,+CAAoD;AACpD,qCAYgB;AAEhB,6CAA4C;AAC5C,iDAA8C;AAE9C,yEAA8E;AAC9E,wDAAmD;AACnD,uDAA+C;AAC/C,uCAAmC;AAEnC,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,qCAAuB,CAAA;IACvB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,4DAA8C,CAAA;AAChD,CAAC,EAPW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAOrB;AAMM,IAAM,IAAI,YAAV,MAAM,IAAI;IAgHf,8BAA8B;IAC9B,KAAK,CAAC,IAAI,CAAC,OAAQ;QACjB,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QAEnD,IAAI,IAAI,GAAG;YACT,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE;gBACN,SAAS;aACV;SACF,CAAA;QAED,OAAO,MAAM,sBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAM,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Q,EAAE,IAAI,EAAE,CAAC;sCACjB,IAAI;qCAAA;AAEb;IAAC,IAAA,oBAAU,EAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;uCACxB;AAEjB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;uCAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;IAEf,8BAA8B;;uCAFf;AA9GJ,IAAI;IAJhB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClE,IAAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/D,IAAA,yBAAU,GAAE;GACA,IAAI,CAiNhB;AAjNY,oBAAI","sourcesContent":["import crypto from 'crypto'\nimport jwt from 'jsonwebtoken'\nimport { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n getRepository,\n Index,\n JoinTable,\n ManyToMany,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { validatePasswordByRule } from '../../controllers/utils/password-rule'\nimport { AuthError } from '../../errors/auth-error'\nimport { SECRET } from '../../utils/get-secret'\nimport { Role } from '../role/role'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum UserStatus {\n INACTIVE = 'inactive',\n ACTIVATED = 'activated',\n DELETED = 'deleted',\n LOCKED = 'locked',\n BANNED = 'banned',\n PWD_RESET_REQUIRED = 'password_reset_required'\n}\n\n@Entity()\n@Index('ix_user_0', (user: User) => [user.email], { unique: true })\n@Index('ix_user_1', (user: User) => [user.id], { unique: true })\n@ObjectType()\nexport class User {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @ManyToMany(type => Domain)\n @JoinTable({ name: 'users_domains' })\n @Field(type => [Domain])\n domains?: Domain[]\n\n @Column()\n @Field()\n email: string\n\n @Column({\n nullable: true,\n type:\n DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'longtext'\n : DATABASE_TYPE == 'oracle'\n ? 'clob'\n : 'varchar'\n })\n password: string\n\n @ManyToMany(type => Role, role => role.users)\n @JoinTable({ name: 'users_roles' })\n @Field(type => [Role])\n roles?: Role[]\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n userType: string // default: 'user', enum: 'user', 'application', 'appliance'\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n reference: string\n\n @Column({\n nullable: true\n })\n salt: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n locale: string\n\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: UserStatus,\n default: UserStatus.INACTIVE\n })\n @Field(type => String)\n status: UserStatus\n\n @Column({\n type: 'smallint',\n default: 0\n })\n failCount: number\n\n @Column({\n nullable: true\n })\n passwordUpdatedAt: Date\n\n @Field({ nullable: true })\n owner: boolean /* should not be a column */\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((user: User) => user.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((user: User) => user.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n /* signing for jsonwebtoken */\n async sign(options?) {\n var { expiresIn = '7d', subdomain } = options || {}\n\n var user = {\n id: this.id,\n userType: this.userType,\n status: this.status,\n domain: {\n subdomain\n }\n }\n\n return await jwt.sign(user, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject: 'user'\n })\n }\n\n /* validate password through password rule */\n static validatePasswordByRule(password, lng) {\n validatePasswordByRule(password, lng)\n }\n\n /* generate salt */\n static generateSalt() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n /* encode password */\n static encode(password: string, salt) {\n return crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64')\n }\n\n /* verify password */\n static verify(hashed, password, salt) {\n return (\n hashed ==\n crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64') ||\n hashed ==\n crypto\n .createHmac('sha1', salt || SECRET)\n .update(password)\n .digest('base64')\n )\n }\n\n static async checkAuth(decoded) {\n const repository = getRepository(User)\n var user = await repository.findOne({\n where: { id: decoded.id },\n relations: ['domains'],\n cache: true\n })\n\n if (!user)\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n else {\n switch (user.status) {\n case UserStatus.INACTIVE:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_ACTIVATED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.LOCKED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_LOCKED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.DELETED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_DELETED\n })\n }\n\n const { defaultPassword } = config.get('password')\n\n if (defaultPassword && user.password === this.encode(defaultPassword, user.salt)) {\n user.status = UserStatus.PWD_RESET_REQUIRED\n }\n\n return user\n }\n }\n}\n"]}
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../server/service/user/user.ts"],"names":[],"mappings":";;;;;AAAA,4DAA2B;AAC3B,wEAA8B;AAC9B,+CAAoD;AACpD,qCAWgB;AAEhB,6CAA4C;AAC5C,iDAA6D;AAE7D,yEAA8E;AAC9E,wDAAmD;AACnD,uDAA+C;AAC/C,uCAAmC;AAEnC,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,qCAAuB,CAAA;IACvB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,4DAA8C,CAAA;AAChD,CAAC,EAPW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAOrB;AAMM,IAAM,IAAI,YAAV,MAAM,IAAI;IAgHf,8BAA8B;IAC9B,KAAK,CAAC,IAAI,CAAC,OAAQ;QACjB,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QAEnD,IAAI,IAAI,GAAG;YACT,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE;gBACN,SAAS;aACV;SACF,CAAA;QAED,OAAO,MAAM,sBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAM,EAAE;YAClC,SAAS;YACT,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,MAAM;SAChB,CAAC,CAAA;IACJ,CAAC;IAED,6CAA6C;IAC7C,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,GAAG;QACzC,IAAA,sCAAsB,EAAC,QAAQ,EAAE,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,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;uCACxB;AAEjB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,MAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,IAAI;qCAAA;AAEb;IAAC,IAAA,oBAAU,EAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;uCACxB;AAEjB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;uCAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;IAEf,8BAA8B;;uCAFf;AA9GJ,IAAI;IAJhB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClE,IAAA,eAAK,EAAC,WAAW,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/D,IAAA,yBAAU,GAAE;GACA,IAAI,CAoOhB;AApOY,oBAAI","sourcesContent":["import crypto from 'crypto'\nimport jwt from 'jsonwebtoken'\nimport { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n JoinTable,\n ManyToMany,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { validatePasswordByRule } from '../../controllers/utils/password-rule'\nimport { AuthError } from '../../errors/auth-error'\nimport { SECRET } from '../../utils/get-secret'\nimport { Role } from '../role/role'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum UserStatus {\n INACTIVE = 'inactive',\n ACTIVATED = 'activated',\n DELETED = 'deleted',\n LOCKED = 'locked',\n BANNED = 'banned',\n PWD_RESET_REQUIRED = 'password_reset_required'\n}\n\n@Entity()\n@Index('ix_user_0', (user: User) => [user.email], { unique: true })\n@Index('ix_user_1', (user: User) => [user.id], { unique: true })\n@ObjectType()\nexport class User {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @ManyToMany(type => Domain)\n @JoinTable({ name: 'users_domains' })\n @Field(type => [Domain])\n domains?: Domain[]\n\n @Column()\n @Field()\n email: string\n\n @Column({\n nullable: true,\n type:\n DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'longtext'\n : DATABASE_TYPE == 'oracle'\n ? 'clob'\n : 'varchar'\n })\n password: string\n\n @ManyToMany(type => Role, role => role.users)\n @JoinTable({ name: 'users_roles' })\n @Field(type => [Role])\n roles?: Role[]\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n userType: string // default: 'user', enum: 'user', 'application', 'appliance'\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n reference: string\n\n @Column({\n nullable: true\n })\n salt: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n locale: string\n\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: UserStatus,\n default: UserStatus.INACTIVE\n })\n @Field(type => String)\n status: UserStatus\n\n @Column({\n type: 'smallint',\n default: 0\n })\n failCount: number\n\n @Column({\n nullable: true\n })\n passwordUpdatedAt: Date\n\n @Field({ nullable: true })\n owner: boolean /* should not be a column */\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((user: User) => user.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((user: User) => user.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n /* signing for jsonwebtoken */\n async sign(options?) {\n var { expiresIn = '7d', subdomain } = options || {}\n\n var user = {\n id: this.id,\n userType: this.userType,\n status: this.status,\n domain: {\n subdomain\n }\n }\n\n return await jwt.sign(user, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject: 'user'\n })\n }\n\n /* validate password through password rule */\n static validatePasswordByRule(password, lng) {\n validatePasswordByRule(password, lng)\n }\n\n /* generate salt */\n static generateSalt() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n /* encode password */\n static encode(password: string, salt) {\n return crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64')\n }\n\n /* verify password */\n static verify(hashed, password, salt) {\n return (\n hashed ==\n crypto\n .createHmac('sha256', salt || SECRET)\n .update(password)\n .digest('base64') ||\n hashed ==\n crypto\n .createHmac('sha1', salt || SECRET)\n .update(password)\n .digest('base64')\n )\n }\n\n static async checkAuth(decoded) {\n const repository = getRepository(User)\n var user = await repository.findOne({\n where: { id: decoded.id },\n relations: ['domains'],\n cache: true\n })\n\n if (!user)\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_FOUND\n })\n else {\n switch (user.status) {\n case UserStatus.INACTIVE:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_NOT_ACTIVATED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.LOCKED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_LOCKED,\n detail: {\n email: user.email\n }\n })\n case UserStatus.DELETED:\n throw new AuthError({\n errorCode: AuthError.ERROR_CODES.USER_DELETED\n })\n }\n\n const { defaultPassword } = config.get('password')\n\n if (defaultPassword && user.password === this.encode(defaultPassword, user.salt)) {\n user.status = UserStatus.PWD_RESET_REQUIRED\n }\n\n return user\n }\n }\n\n static async hasPrivilege(name: string, category: string, domain: Domain, user: User) {\n const result = await getRepository(User).query(\n `SELECT COUNT(1) AS has_privilege FROM privileges\n WHERE category = '${category}'\n AND name = '${name}'\n AND id IN (\n SELECT RP.privileges_id\n FROM users_roles UR\n INNER JOIN roles_privileges RP ON UR.roles_id = RP.roles_id\n LEFT JOIN roles R ON R.id = UR.roles_id\n WHERE UR.users_id = '${user?.id}'\n AND R.domain_id = '${domain?.id}'\n )\n `\n )\n\n return result[0].has_privilege > 0\n }\n}\n"]}