@icure/api 5.0.5 → 5.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccAuthApi.d.ts +6 -0
- package/icc-api/api/IccAuthApi.js +18 -1
- package/icc-api/api/IccAuthApi.js.map +1 -1
- package/icc-x-api/crypto/shamir.js +1 -1
- package/icc-x-api/crypto/shamir.js.map +1 -1
- package/icc-x-api/filters/CodeIdsByTypeCodeVersionIntervalFilter.d.ts +23 -0
- package/icc-x-api/filters/CodeIdsByTypeCodeVersionIntervalFilter.js +24 -0
- package/icc-x-api/filters/CodeIdsByTypeCodeVersionIntervalFilter.js.map +1 -0
- package/icc-x-api/filters/PatientByHcPartyGenderEducationProfession.js +0 -1
- package/icc-x-api/filters/PatientByHcPartyGenderEducationProfession.js.map +1 -1
- package/icc-x-api/filters/UsersByPatientIdFilter.d.ts +18 -0
- package/icc-x-api/filters/UsersByPatientIdFilter.js +24 -0
- package/icc-x-api/filters/UsersByPatientIdFilter.js.map +1 -0
- package/icc-x-api/icc-crypto-x-api.js +3 -3
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +2 -2
- package/icc-x-api/icc-maintenance-task-x-api.js +4 -4
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +3 -1
- package/icc-x-api/icc-patient-x-api.js +13 -4
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/node-compat.d.ts +1 -2
- package/node-compat.js +2 -3
- package/node-compat.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,12 @@ export declare class IccAuthApi {
|
|
|
19
19
|
constructor(host: string, headers: any, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
20
20
|
setHeaders(h: Array<XHR.Header>): void;
|
|
21
21
|
handleError(e: XHR.XHRError): never;
|
|
22
|
+
/**
|
|
23
|
+
* Check login using groupId/userId and password
|
|
24
|
+
* @summary check
|
|
25
|
+
* @param body
|
|
26
|
+
*/
|
|
27
|
+
check(body?: LoginCredentials): Promise<AuthenticationResponse>;
|
|
22
28
|
/**
|
|
23
29
|
* Login using username and password
|
|
24
30
|
* @summary login
|
|
@@ -26,6 +26,21 @@ class IccAuthApi {
|
|
|
26
26
|
handleError(e) {
|
|
27
27
|
throw e;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Check login using groupId/userId and password
|
|
31
|
+
* @summary check
|
|
32
|
+
* @param body
|
|
33
|
+
*/
|
|
34
|
+
check(body) {
|
|
35
|
+
let _body = null;
|
|
36
|
+
_body = body;
|
|
37
|
+
const _url = this.host + `/auth/check` + '?ts=' + new Date().getTime();
|
|
38
|
+
let headers = this.headers;
|
|
39
|
+
headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
|
|
40
|
+
return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl)
|
|
41
|
+
.then((doc) => new AuthenticationResponse_1.AuthenticationResponse(doc.body))
|
|
42
|
+
.catch((err) => this.handleError(err));
|
|
43
|
+
}
|
|
29
44
|
/**
|
|
30
45
|
* Login using username and password
|
|
31
46
|
* @summary login
|
|
@@ -36,7 +51,9 @@ class IccAuthApi {
|
|
|
36
51
|
_body = body;
|
|
37
52
|
const _url = this.host + `/auth/login` + '?ts=' + new Date().getTime();
|
|
38
53
|
let headers = this.headers;
|
|
39
|
-
headers = headers
|
|
54
|
+
headers = headers
|
|
55
|
+
.filter((h) => { var _a; return h.header !== 'Content-Type' && ((_a = h.header) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'authorization'; })
|
|
56
|
+
.concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
|
|
40
57
|
return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, true)
|
|
41
58
|
.then((doc) => new AuthenticationResponse_1.AuthenticationResponse(doc.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AAM,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QAChJ,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC1B,OAAO,SAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;aAChE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;aACnD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;CACF;AA9GD,gCA8GC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { XHR } from './XHR'\nimport { AuthenticationResponse } from '../model/AuthenticationResponse'\nimport { LoginCredentials } from '../model/LoginCredentials'\n\nexport class IccAuthApi {\n host: string\n headers: Array<XHR.Header>\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n constructor(host: string, headers: any, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>) {\n this.host = host\n this.headers = Object.keys(headers).map((k) => new XHR.Header(k, headers[k]))\n this.fetchImpl = fetchImpl\n }\n\n setHeaders(h: Array<XHR.Header>) {\n this.headers = h\n }\n\n handleError(e: XHR.XHRError): never {\n throw e\n }\n\n /**\n * Check login using groupId/userId and password\n * @summary check\n * @param body\n */\n check(body?: LoginCredentials): Promise<AuthenticationResponse> {\n let _body = null\n _body = body\n\n const _url = this.host + `/auth/check` + '?ts=' + new Date().getTime()\n let headers = this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl)\n .then((doc) => new AuthenticationResponse(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Login using username and password\n * @summary login\n * @param body\n */\n login(body?: LoginCredentials): Promise<AuthenticationResponse> {\n let _body = null\n _body = body\n\n const _url = this.host + `/auth/login` + '?ts=' + new Date().getTime()\n let headers = this.headers\n headers = headers\n .filter((h) => h.header !== 'Content-Type' && h.header?.toLowerCase() !== 'authorization')\n .concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, true)\n .then((doc) => new AuthenticationResponse(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Logout\n * @summary logout\n */\n logout(): Promise<AuthenticationResponse> {\n let _body = null\n\n const _url = this.host + `/auth/logout` + '?ts=' + new Date().getTime()\n let headers = this.headers\n return XHR.sendCommand(\n 'GET',\n _url,\n headers.filter((h) => h.header?.toLowerCase() !== 'authorization'),\n _body,\n this.fetchImpl\n )\n .then((doc) => new AuthenticationResponse(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Logout\n * @summary logout\n */\n logoutPost(): Promise<AuthenticationResponse> {\n let _body = null\n\n const _url = this.host + `/auth/logout` + '?ts=' + new Date().getTime()\n let headers = this.headers\n return XHR.sendCommand(\n 'POST',\n _url,\n headers.filter((h) => h.header?.toLowerCase() !== 'authorization'),\n _body,\n this.fetchImpl\n )\n .then((doc) => new AuthenticationResponse(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Get token for subsequent operation\n * @summary token\n * @param method\n * @param path\n */\n token(method: string, path: string): Promise<string> {\n let _body = null\n\n const _url = this.host + `/auth/token/${encodeURIComponent(String(method))}/${encodeURIComponent(String(path))}` + '?ts=' + new Date().getTime()\n let headers = this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl)\n .then((doc) => JSON.parse(JSON.stringify(doc.body)))\n .catch((err) => this.handleError(err))\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shamir.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/shamir.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IAsBtB,YAAY,SAAiB,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,EAAa;QArBvI,4BAA4B;QAC5B,WAAM,GAAG;YACP,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,EAAE;YACT,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC;YACtC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC;YACzC,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,CAAC;YACf,eAAe,EAAE,CAAC;YAClB,sFAAsF;YACtF,+EAA+E;YAC/E,oEAAoE;YACpE,oBAAoB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,E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AQ;aACT;YAED,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAChC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;gBACxB,IAAI,CAAC,KAAK,CAAC,EAAE;oBACX,SAAQ;iBACT;gBACD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;oBACf,kFAAkF;oBAClF,OAAO,GAAG,CAAC,CAAC,CAAA,CAAC,oFAAoF;oBACjG,MAAK;iBACN;gBACD,OAAO;oBACL,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,oCAAoC;wBAC9H,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;aAClB;YAED,GAAG,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA,CAAC,mIAAmI;SACjM;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF;AAnUD,kCAmUC;AAEY,QAAA,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA","sourcesContent":["export class ShamirClass {\n // Protected settings object\n config = {\n bits: 8, // default number of bits\n radix: 16, // work with HEX by default\n size: Math.pow(2, 8 /* config.bits */),\n max: Math.pow(2, 8 /* config.bits */) - 1,\n minBits: 3,\n maxBits: 16, // this permits 65,535 shares, though going this high is NOT recommended in JS!\n bytesPerChar: 2,\n maxBytesPerChar: 6, // Math.pow(256,7) > Math.pow(2,53)\n // Primitive polynomials (in decimal form) for Galois Fields GF(2^n), for 2 <= n <= 30\n // The index of each term in the array corresponds to the n for that polynomial\n // i.e. to get the polynomial for n=16, use primitivePolynomials[16]\n primitivePolynomials: [null, null, 1, 3, 3, 5, 3, 3, 29, 17, 9, 5, 83, 27, 43, 3, 45, 9, 39, 39, 9, 5, 3, 33, 27, 9, 71, 39, 9, 5, 83],\n // warning for insecure PRNG\n warning: 'WARNING:\\nA secure random number generator was not found.\\nUsing Math.random(), which is NOT cryptographically strong!',\n logs: [] as Array<number>,\n exps: [] as Array<number>,\n }\n private crypto: Crypto\n\n constructor(crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto)) {\n this.crypto = crypto\n }\n\n init() {\n const primitive = this.config.primitivePolynomials[this.config.bits]!\n let x = 1\n\n for (let i = 0; i < this.config.size; i++) {\n this.config.exps[i] = x\n this.config.logs[x] = i\n x <<= 1\n if (x >= this.config.size) {\n x ^= primitive\n x &= this.config.max\n }\n }\n }\n\n // Splits a number string `bits`-length segments, after first\n // optionally zero-padding it to a length that is a multiple of `padLength.\n // Returns array of integers (each less than 2^bits-1), with each element\n // representing a `bits`-length segment of the input string from right to left,\n // i.e. parts[0] represents the right-most `bits`-length segment of the input string.\n split(str: string, padLength = 0) {\n if (padLength) {\n str = this.padLeft(str, padLength)\n }\n const parts = []\n for (var i = str.length; i > this.config.bits; i -= this.config.bits) {\n parts.push(parseInt(str.slice(i - this.config.bits, i), 2))\n }\n parts.push(parseInt(str.slice(0, i), 2))\n return parts\n }\n\n bin2hex(str: string) {\n let hex = '',\n num\n str = this.padLeft(str, 4)\n for (let i = str.length; i >= 4; i -= 4) {\n num = parseInt(str.slice(i - 4, i), 2)\n if (isNaN(num)) {\n throw new Error('Invalid binary character.')\n }\n hex = num.toString(16) + hex\n }\n return hex\n }\n\n hex2bin(str: string) {\n let bin = '',\n num\n for (let i = str.length - 1; i >= 0; i--) {\n num = parseInt(str[i], 16)\n if (isNaN(num)) {\n throw new Error('Invalid hex character.')\n }\n bin = this.padLeft(num.toString(2), 4) + bin\n }\n\n return bin\n }\n\n padLeft(str: string, bits: number = this.config.bits) {\n const missing = str.length % bits\n return (missing ? new Array(bits - missing + 1).join('0') : '') + str\n }\n\n random(bits: number) {\n const construct = (bits: number, arr: Uint32Array, size: number) => {\n let str = '',\n i = 0\n const len = arr.length - 1\n while (i < len || str.length < bits) {\n str += this.padLeft(arr[i].toString(16), size)\n i++\n }\n str = str.substr(-bits / 4)\n return (str.match(/0/g) || []).length === str.length ? null : str\n }\n\n let elems = Math.ceil(bits / 32),\n str = null,\n arr = new Uint32Array(elems)\n\n while (str === null) {\n crypto.getRandomValues(arr)\n str = construct(bits, arr, 8)\n }\n\n return str\n }\n\n share(secretString: string, numShares: number, threshold: number) {\n if (!this.config.logs.length) {\n this.init()\n }\n\n if (numShares % 1 !== 0 || numShares < 2) {\n throw new Error('Number of shares must be an integer between 2 and 2^bits-1 (' + this.config.max + '), inclusive.')\n }\n if (numShares > this.config.max) {\n var neededBits = Math.ceil(Math.log(numShares + 1) / Math.LN2)\n throw new Error(\n 'Number of shares must be an integer between 2 and 2^bits-1 (' +\n this.config.max +\n '), inclusive. To create ' +\n numShares +\n ' shares, use at least ' +\n neededBits +\n ' bits.'\n )\n }\n if (threshold % 1 !== 0 || threshold < 2) {\n throw new Error('Threshold number of shares must be an integer between 2 and 2^bits-1 (' + this.config.max + '), inclusive.')\n }\n if (threshold > this.config.max) {\n var neededBits = Math.ceil(Math.log(threshold + 1) / Math.LN2)\n throw new Error(\n 'Threshold number of shares must be an integer between 2 and 2^bits-1 (' +\n this.config.max +\n '), inclusive. To use a threshold of ' +\n threshold +\n ', use at least ' +\n neededBits +\n ' bits.'\n )\n }\n\n // append a 1 so that we can preserve the correct number of leading zeros in our secret\n const secret = this.split('1' + this.hex2bin(secretString), 0)\n const x = new Array(numShares),\n y = new Array(numShares)\n for (let i = 0, len = secret.length; i < len; i++) {\n const subShares = this._getShares(secret[i], numShares, threshold)\n for (let j = 0; j < numShares; j++) {\n x[j] = x[j] || subShares[j].x.toString(this.config.radix)\n y[j] = this.padLeft(subShares[j].y.toString(2)) + (y[j] ? y[j] : '')\n }\n }\n const padding = this.config.max.toString(this.config.radix).length\n return y.map((b, idx) => this.config.bits.toString(16).toUpperCase() + this.padLeft(x[idx], padding) + this.bin2hex(b))\n }\n\n // This is the basic polynomial generation and evaluation function\n // for a `config.bits`-length secret (NOT an arbitrary length)\n // Note: no error-checking at this stage! If `secrets` is NOT\n // a NUMBER less than 2^bits-1, the output will be incorrect!\n _getShares(secret: number, numShares: number, threshold: number) {\n const shares = []\n const coeffs = [secret]\n\n for (var i = 1; i < threshold; i++) {\n coeffs[i] = parseInt(this.random(this.config.bits), 16)\n }\n for (var i = 1, len = numShares + 1; i < len; i++) {\n shares[i - 1] = {\n x: i,\n y: this.horner(i, coeffs),\n }\n }\n return shares\n }\n\n // Polynomial evaluation at `x` using Horner's Method\n // TODO: this can possibly be sped up using other methods\n // NOTE: fx=fx * x + coeff[i] -> exp(log(fx) + log(x)) + coeff[i],\n // so if fx===0, just set fx to coeff[i] because\n // using the exp/log form will result in incorrect value\n horner(x: number, coeffs: Array<number>) {\n const logx = this.config.logs[x]\n let fx = 0\n for (let i = coeffs.length - 1; i >= 0; i--) {\n if (fx === 0) {\n fx = coeffs[i]\n continue\n }\n fx = this.config.exps[(logx + this.config.logs[fx]) % this.config.max] ^ coeffs[i]\n }\n return fx\n }\n\n processShare(share: string) {\n const bits = parseInt(share[0], 16)\n if (bits && (bits % 1 !== 0 || bits < this.config.minBits || bits > this.config.maxBits)) {\n throw new Error('Number of bits must be an integer between ' + this.config.minBits + ' and ' + this.config.maxBits + ', inclusive.')\n }\n\n const max = Math.pow(2, bits) - 1\n const idLength = max.toString(this.config.radix).length\n\n const id = parseInt(share.substr(1, idLength), this.config.radix)\n if (id % 1 !== 0 || id < 1 || id > max) {\n throw new Error('Share id must be an integer between 1 and ' + this.config.max + ', inclusive.')\n }\n share = share.substr(idLength + 1)\n if (!share.length) {\n throw new Error('Invalid share: zero-length share.')\n }\n return {\n bits: bits,\n id: id,\n value: share,\n }\n }\n\n _combine(at: number, shares: Array<string>) {\n if (!this.config.logs.length) {\n this.init()\n }\n\n const x: Array<number> = []\n const y: Array<Array<number>> = []\n let result = ''\n let idx: number\n\n for (var i = 0, len = shares.length; i < len; i++) {\n const share = this.processShare(shares[i])\n\n if (x.includes(share['id'])) {\n // repeated x value?\n continue\n }\n\n idx = x.push(share['id']) - 1\n const shareValues = this.split(this.hex2bin(share['value']))\n for (let j = 0, len2 = shareValues.length; j < len2; j++) {\n y[j] = y[j] || []\n y[j][idx] = shareValues[j]\n }\n }\n\n for (var i = 0, len = y.length; i < len; i++) {\n result = this.padLeft(this.lagrange(at, x, y[i]).toString(2)) + result\n }\n\n if (at === 0) {\n // reconstructing the secret\n return this.bin2hex(result.slice(result.indexOf('1') + 1))\n } else {\n // generating a new share\n return this.bin2hex(result)\n }\n }\n\n combine(shares: Array<string>) {\n return this._combine(0, shares)\n }\n\n // Generate a new share with id `id` (a number between 1 and 2^bits-1)\n // `id` can be a Number or a String in the default radix (16)\n newShare(id: number | string, shares: Array<string>) {\n if (typeof id === 'string') {\n id = parseInt(id, this.config.radix)\n }\n\n const share = this.processShare(shares[0])\n const max = Math.pow(2, share['bits']) - 1\n\n if (id % 1 !== 0 || id < 1 || id > max) {\n throw new Error('Share id must be an integer between 1 and ' + this.config.max + ', inclusive.')\n }\n\n const padding = max.toString(this.config.radix).length\n return this.config.bits.toString(16).toUpperCase() + this.padLeft(id.toString(this.config.radix), padding) + this._combine(id, shares)\n }\n\n // Evaluate the Lagrange interpolation polynomial at x = `at`\n // using x and y Arrays that are of the same length, with\n // corresponding elements constituting points on the polynomial.\n lagrange(at: number, x: Array<number>, y: Array<number>) {\n let sum = 0,\n product,\n i,\n j,\n len\n for (i = 0, len = x.length; i < len; i++) {\n if (!y[i]) {\n continue\n }\n\n product = this.config.logs[y[i]]\n for (j = 0; j < len; j++) {\n if (i === j) {\n continue\n }\n if (at === x[j]) {\n // happens when computing a share that is in the list of shares used to compute it\n product = -1 // fix for a zero product term, after which the sum should be sum^0 = sum, not sum^1\n break\n }\n product =\n (product + this.config.logs[at ^ x[j]] - this.config.logs[x[i] ^ x[j]] + this.config.max) /* to make sure it's not negative */ %\n this.config.max\n }\n\n sum = product === -1 ? sum : sum ^ this.config.exps[product] // though exps[-1]= undefined and undefined ^ anything = anything in chrome, this behavior may not hold everywhere, so do the check\n }\n return sum\n }\n}\n\nexport const shamir = new ShamirClass()\n"]}
|
|
1
|
+
{"version":3,"file":"shamir.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/shamir.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IAsBtB,YAAY,SAAiB,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,EAAa;QArBvI,4BAA4B;QAC5B,WAAM,GAAG;YACP,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,EAAE;YACT,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC;YACtC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC;YACzC,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,CAAC;YACf,eAAe,EAAE,CAAC;YAClB,sFAAsF;YACtF,+EAA+E;YAC/E,oEAAoE;YACpE,oBAAoB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE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P,CAAC,EACD,CAAC,EACD,GAAG,CAAA;QACL,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACxC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;gBACT,SAAQ;aACT;YAED,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAChC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;gBACxB,IAAI,CAAC,KAAK,CAAC,EAAE;oBACX,SAAQ;iBACT;gBACD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;oBACf,kFAAkF;oBAClF,OAAO,GAAG,CAAC,CAAC,CAAA,CAAC,oFAAoF;oBACjG,MAAK;iBACN;gBACD,OAAO;oBACL,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,oCAAoC;wBAC9H,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;aAClB;YAED,GAAG,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA,CAAC,mIAAmI;SACjM;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF;AAnUD,kCAmUC;AAEY,QAAA,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA","sourcesContent":["export class ShamirClass {\n // Protected settings object\n config = {\n bits: 8, // default number of bits\n radix: 16, // work with HEX by default\n size: Math.pow(2, 8 /* config.bits */),\n max: Math.pow(2, 8 /* config.bits */) - 1,\n minBits: 3,\n maxBits: 16, // this permits 65,535 shares, though going this high is NOT recommended in JS!\n bytesPerChar: 2,\n maxBytesPerChar: 6, // Math.pow(256,7) > Math.pow(2,53)\n // Primitive polynomials (in decimal form) for Galois Fields GF(2^n), for 2 <= n <= 30\n // The index of each term in the array corresponds to the n for that polynomial\n // i.e. to get the polynomial for n=16, use primitivePolynomials[16]\n primitivePolynomials: [null, null, 1, 3, 3, 5, 3, 3, 29, 17, 9, 5, 83, 27, 43, 3, 45, 9, 39, 39, 9, 5, 3, 33, 27, 9, 71, 39, 9, 5, 83],\n // warning for insecure PRNG\n warning: 'WARNING:\\nA secure random number generator was not found.\\nUsing Math.random(), which is NOT cryptographically strong!',\n logs: [] as Array<number>,\n exps: [] as Array<number>,\n }\n private crypto: Crypto\n\n constructor(crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto)) {\n this.crypto = crypto\n }\n\n init() {\n const primitive = this.config.primitivePolynomials[this.config.bits]!\n let x = 1\n\n for (let i = 0; i < this.config.size; i++) {\n this.config.exps[i] = x\n this.config.logs[x] = i\n x <<= 1\n if (x >= this.config.size) {\n x ^= primitive\n x &= this.config.max\n }\n }\n }\n\n // Splits a number string `bits`-length segments, after first\n // optionally zero-padding it to a length that is a multiple of `padLength.\n // Returns array of integers (each less than 2^bits-1), with each element\n // representing a `bits`-length segment of the input string from right to left,\n // i.e. parts[0] represents the right-most `bits`-length segment of the input string.\n split(str: string, padLength = 0) {\n if (padLength) {\n str = this.padLeft(str, padLength)\n }\n const parts = []\n for (var i = str.length; i > this.config.bits; i -= this.config.bits) {\n parts.push(parseInt(str.slice(i - this.config.bits, i), 2))\n }\n parts.push(parseInt(str.slice(0, i), 2))\n return parts\n }\n\n bin2hex(str: string) {\n let hex = '',\n num\n str = this.padLeft(str, 4)\n for (let i = str.length; i >= 4; i -= 4) {\n num = parseInt(str.slice(i - 4, i), 2)\n if (isNaN(num)) {\n throw new Error('Invalid binary character.')\n }\n hex = num.toString(16) + hex\n }\n return hex\n }\n\n hex2bin(str: string) {\n let bin = '',\n num\n for (let i = str.length - 1; i >= 0; i--) {\n num = parseInt(str[i], 16)\n if (isNaN(num)) {\n throw new Error('Invalid hex character.')\n }\n bin = this.padLeft(num.toString(2), 4) + bin\n }\n\n return bin\n }\n\n padLeft(str: string, bits: number = this.config.bits) {\n const missing = str.length % bits\n return (missing ? new Array(bits - missing + 1).join('0') : '') + str\n }\n\n random(bits: number) {\n const construct = (bits: number, arr: Uint32Array, size: number) => {\n let str = '',\n i = 0\n const len = arr.length - 1\n while (i < len || str.length < bits) {\n str += this.padLeft(arr[i].toString(16), size)\n i++\n }\n str = str.substr(-bits / 4)\n return (str.match(/0/g) || []).length === str.length ? null : str\n }\n\n let elems = Math.ceil(bits / 32),\n str = null,\n arr = new Uint32Array(elems)\n\n while (str === null) {\n this.crypto.getRandomValues(arr)\n str = construct(bits, arr, 8)\n }\n\n return str\n }\n\n share(secretString: string, numShares: number, threshold: number) {\n if (!this.config.logs.length) {\n this.init()\n }\n\n if (numShares % 1 !== 0 || numShares < 2) {\n throw new Error('Number of shares must be an integer between 2 and 2^bits-1 (' + this.config.max + '), inclusive.')\n }\n if (numShares > this.config.max) {\n var neededBits = Math.ceil(Math.log(numShares + 1) / Math.LN2)\n throw new Error(\n 'Number of shares must be an integer between 2 and 2^bits-1 (' +\n this.config.max +\n '), inclusive. To create ' +\n numShares +\n ' shares, use at least ' +\n neededBits +\n ' bits.'\n )\n }\n if (threshold % 1 !== 0 || threshold < 2) {\n throw new Error('Threshold number of shares must be an integer between 2 and 2^bits-1 (' + this.config.max + '), inclusive.')\n }\n if (threshold > this.config.max) {\n var neededBits = Math.ceil(Math.log(threshold + 1) / Math.LN2)\n throw new Error(\n 'Threshold number of shares must be an integer between 2 and 2^bits-1 (' +\n this.config.max +\n '), inclusive. To use a threshold of ' +\n threshold +\n ', use at least ' +\n neededBits +\n ' bits.'\n )\n }\n\n // append a 1 so that we can preserve the correct number of leading zeros in our secret\n const secret = this.split('1' + this.hex2bin(secretString), 0)\n const x = new Array(numShares),\n y = new Array(numShares)\n for (let i = 0, len = secret.length; i < len; i++) {\n const subShares = this._getShares(secret[i], numShares, threshold)\n for (let j = 0; j < numShares; j++) {\n x[j] = x[j] || subShares[j].x.toString(this.config.radix)\n y[j] = this.padLeft(subShares[j].y.toString(2)) + (y[j] ? y[j] : '')\n }\n }\n const padding = this.config.max.toString(this.config.radix).length\n return y.map((b, idx) => this.config.bits.toString(16).toUpperCase() + this.padLeft(x[idx], padding) + this.bin2hex(b))\n }\n\n // This is the basic polynomial generation and evaluation function\n // for a `config.bits`-length secret (NOT an arbitrary length)\n // Note: no error-checking at this stage! If `secrets` is NOT\n // a NUMBER less than 2^bits-1, the output will be incorrect!\n _getShares(secret: number, numShares: number, threshold: number) {\n const shares = []\n const coeffs = [secret]\n\n for (var i = 1; i < threshold; i++) {\n coeffs[i] = parseInt(this.random(this.config.bits), 16)\n }\n for (var i = 1, len = numShares + 1; i < len; i++) {\n shares[i - 1] = {\n x: i,\n y: this.horner(i, coeffs),\n }\n }\n return shares\n }\n\n // Polynomial evaluation at `x` using Horner's Method\n // TODO: this can possibly be sped up using other methods\n // NOTE: fx=fx * x + coeff[i] -> exp(log(fx) + log(x)) + coeff[i],\n // so if fx===0, just set fx to coeff[i] because\n // using the exp/log form will result in incorrect value\n horner(x: number, coeffs: Array<number>) {\n const logx = this.config.logs[x]\n let fx = 0\n for (let i = coeffs.length - 1; i >= 0; i--) {\n if (fx === 0) {\n fx = coeffs[i]\n continue\n }\n fx = this.config.exps[(logx + this.config.logs[fx]) % this.config.max] ^ coeffs[i]\n }\n return fx\n }\n\n processShare(share: string) {\n const bits = parseInt(share[0], 16)\n if (bits && (bits % 1 !== 0 || bits < this.config.minBits || bits > this.config.maxBits)) {\n throw new Error('Number of bits must be an integer between ' + this.config.minBits + ' and ' + this.config.maxBits + ', inclusive.')\n }\n\n const max = Math.pow(2, bits) - 1\n const idLength = max.toString(this.config.radix).length\n\n const id = parseInt(share.substr(1, idLength), this.config.radix)\n if (id % 1 !== 0 || id < 1 || id > max) {\n throw new Error('Share id must be an integer between 1 and ' + this.config.max + ', inclusive.')\n }\n share = share.substr(idLength + 1)\n if (!share.length) {\n throw new Error('Invalid share: zero-length share.')\n }\n return {\n bits: bits,\n id: id,\n value: share,\n }\n }\n\n _combine(at: number, shares: Array<string>) {\n if (!this.config.logs.length) {\n this.init()\n }\n\n const x: Array<number> = []\n const y: Array<Array<number>> = []\n let result = ''\n let idx: number\n\n for (var i = 0, len = shares.length; i < len; i++) {\n const share = this.processShare(shares[i])\n\n if (x.includes(share['id'])) {\n // repeated x value?\n continue\n }\n\n idx = x.push(share['id']) - 1\n const shareValues = this.split(this.hex2bin(share['value']))\n for (let j = 0, len2 = shareValues.length; j < len2; j++) {\n y[j] = y[j] || []\n y[j][idx] = shareValues[j]\n }\n }\n\n for (var i = 0, len = y.length; i < len; i++) {\n result = this.padLeft(this.lagrange(at, x, y[i]).toString(2)) + result\n }\n\n if (at === 0) {\n // reconstructing the secret\n return this.bin2hex(result.slice(result.indexOf('1') + 1))\n } else {\n // generating a new share\n return this.bin2hex(result)\n }\n }\n\n combine(shares: Array<string>) {\n return this._combine(0, shares)\n }\n\n // Generate a new share with id `id` (a number between 1 and 2^bits-1)\n // `id` can be a Number or a String in the default radix (16)\n newShare(id: number | string, shares: Array<string>) {\n if (typeof id === 'string') {\n id = parseInt(id, this.config.radix)\n }\n\n const share = this.processShare(shares[0])\n const max = Math.pow(2, share['bits']) - 1\n\n if (id % 1 !== 0 || id < 1 || id > max) {\n throw new Error('Share id must be an integer between 1 and ' + this.config.max + ', inclusive.')\n }\n\n const padding = max.toString(this.config.radix).length\n return this.config.bits.toString(16).toUpperCase() + this.padLeft(id.toString(this.config.radix), padding) + this._combine(id, shares)\n }\n\n // Evaluate the Lagrange interpolation polynomial at x = `at`\n // using x and y Arrays that are of the same length, with\n // corresponding elements constituting points on the polynomial.\n lagrange(at: number, x: Array<number>, y: Array<number>) {\n let sum = 0,\n product,\n i,\n j,\n len\n for (i = 0, len = x.length; i < len; i++) {\n if (!y[i]) {\n continue\n }\n\n product = this.config.logs[y[i]]\n for (j = 0; j < len; j++) {\n if (i === j) {\n continue\n }\n if (at === x[j]) {\n // happens when computing a share that is in the list of shares used to compute it\n product = -1 // fix for a zero product term, after which the sum should be sum^0 = sum, not sum^1\n break\n }\n product =\n (product + this.config.logs[at ^ x[j]] - this.config.logs[x[i] ^ x[j]] + this.config.max) /* to make sure it's not negative */ %\n this.config.max\n }\n\n sum = product === -1 ? sum : sum ^ this.config.exps[product] // though exps[-1]= undefined and undefined ^ anything = anything in chrome, this behavior may not hold everywhere, so do the check\n }\n return sum\n }\n}\n\nexport const shamir = new ShamirClass()\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AbstractFilterCode } from '../../icc-api/model/AbstractFilterCode';
|
|
2
|
+
/**
|
|
3
|
+
* iCure Data Stack API Documentation
|
|
4
|
+
* The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
|
|
5
|
+
*
|
|
6
|
+
* OpenAPI spec version: v1
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by the swagger code generator program.
|
|
10
|
+
* https://github.com/swagger-api/swagger-codegen.git
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CodeIdsByTypeCodeVersionIntervalFilter extends AbstractFilterCode {
|
|
14
|
+
$type: string;
|
|
15
|
+
constructor(json: JSON | any);
|
|
16
|
+
desc?: string;
|
|
17
|
+
startType?: string;
|
|
18
|
+
startCode?: string;
|
|
19
|
+
startVersion?: string;
|
|
20
|
+
endType?: string;
|
|
21
|
+
endCode?: string;
|
|
22
|
+
endVersion?: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeIdsByTypeCodeVersionIntervalFilter = void 0;
|
|
4
|
+
const AbstractFilterCode_1 = require("../../icc-api/model/AbstractFilterCode");
|
|
5
|
+
/**
|
|
6
|
+
* iCure Data Stack API Documentation
|
|
7
|
+
* The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
|
|
8
|
+
*
|
|
9
|
+
* OpenAPI spec version: v1
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* NOTE: This class is auto generated by the swagger code generator program.
|
|
13
|
+
* https://github.com/swagger-api/swagger-codegen.git
|
|
14
|
+
* Do not edit the class manually.
|
|
15
|
+
*/
|
|
16
|
+
class CodeIdsByTypeCodeVersionIntervalFilter extends AbstractFilterCode_1.AbstractFilterCode {
|
|
17
|
+
constructor(json) {
|
|
18
|
+
super(json);
|
|
19
|
+
this.$type = 'CodeIdsByTypeCodeVersionIntervalFilter';
|
|
20
|
+
Object.assign(this, json);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.CodeIdsByTypeCodeVersionIntervalFilter = CodeIdsByTypeCodeVersionIntervalFilter;
|
|
24
|
+
//# sourceMappingURL=CodeIdsByTypeCodeVersionIntervalFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeIdsByTypeCodeVersionIntervalFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/CodeIdsByTypeCodeVersionIntervalFilter.ts"],"names":[],"mappings":";;;AAAA,+EAA2E;AAE3E;;;;;;;;;;GAUG;AAEH,MAAa,sCAAuC,SAAQ,uCAAkB;IAE5E,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,wCAAwC,CAAA;QAItD,MAAM,CAAC,MAAM,CAAC,IAA8C,EAAE,IAAI,CAAC,CAAA;IACrE,CAAC;CASF;AAfD,wFAeC","sourcesContent":["import { AbstractFilterCode } from '../../icc-api/model/AbstractFilterCode'\n\n/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\n\nexport class CodeIdsByTypeCodeVersionIntervalFilter extends AbstractFilterCode {\n $type: string = 'CodeIdsByTypeCodeVersionIntervalFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as CodeIdsByTypeCodeVersionIntervalFilter, json)\n }\n\n desc?: string\n startType?: string\n startCode?: string\n startVersion?: string\n endType?: string\n endCode?: string\n endVersion?: string\n}\n"]}
|
|
@@ -9,7 +9,6 @@ class PatientByHcPartyGenderEducationProfession extends AbstractFilterPatient_1.
|
|
|
9
9
|
constructor(json) {
|
|
10
10
|
super(json);
|
|
11
11
|
this.$type = 'PatientByHcPartyGenderEducationProfession';
|
|
12
|
-
super(json);
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
exports.PatientByHcPartyGenderEducationProfession = PatientByHcPartyGenderEducationProfession;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PatientByHcPartyGenderEducationProfession.js","sourceRoot":"","sources":["../../../icc-x-api/filters/PatientByHcPartyGenderEducationProfession.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"PatientByHcPartyGenderEducationProfession.js","sourceRoot":"","sources":["../../../icc-x-api/filters/PatientByHcPartyGenderEducationProfession.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,qFAA+E;AAI/E,MAAa,yCAA0C,SAAQ,6CAAqB;IAClF,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAQb,UAAK,GAAG,2CAA2C,CAAA;IAPnD,CAAC;CAQF;AAXD,8FAWC","sourcesContent":["/*\n * Copyright (c) 2020. Taktik SA, All rights reserved.\n */\nimport {AbstractFilterPatient} from '../../icc-api/model/AbstractFilterPatient'\nimport {Patient} from '../../icc-api/model/Patient'\nimport GenderEnum = Patient.GenderEnum\n\nexport class PatientByHcPartyGenderEducationProfession extends AbstractFilterPatient {\n constructor(json: JSON | any) {\n super(json)\n }\n\n healthcarePartyId?: string\n gender?: GenderEnum\n education?: string\n profession?: string\n\n $type = 'PatientByHcPartyGenderEducationProfession'\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AbstractFilterUser } from '../../icc-api/model/AbstractFilterUser';
|
|
2
|
+
/**
|
|
3
|
+
* iCure Data Stack API Documentation
|
|
4
|
+
* The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
|
|
5
|
+
*
|
|
6
|
+
* OpenAPI spec version: v1
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by the swagger code generator program.
|
|
10
|
+
* https://github.com/swagger-api/swagger-codegen.git
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
export declare class UsersByPatientIdFilter extends AbstractFilterUser {
|
|
14
|
+
$type: string;
|
|
15
|
+
constructor(json: JSON | any);
|
|
16
|
+
patientId?: string;
|
|
17
|
+
desc?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsersByPatientIdFilter = void 0;
|
|
4
|
+
const AbstractFilterUser_1 = require("../../icc-api/model/AbstractFilterUser");
|
|
5
|
+
/**
|
|
6
|
+
* iCure Data Stack API Documentation
|
|
7
|
+
* The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
|
|
8
|
+
*
|
|
9
|
+
* OpenAPI spec version: v1
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* NOTE: This class is auto generated by the swagger code generator program.
|
|
13
|
+
* https://github.com/swagger-api/swagger-codegen.git
|
|
14
|
+
* Do not edit the class manually.
|
|
15
|
+
*/
|
|
16
|
+
class UsersByPatientIdFilter extends AbstractFilterUser_1.AbstractFilterUser {
|
|
17
|
+
constructor(json) {
|
|
18
|
+
super(json);
|
|
19
|
+
this.$type = 'UsersByPatientIdFilter';
|
|
20
|
+
Object.assign(this, json);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.UsersByPatientIdFilter = UsersByPatientIdFilter;
|
|
24
|
+
//# sourceMappingURL=UsersByPatientIdFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UsersByPatientIdFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/UsersByPatientIdFilter.ts"],"names":[],"mappings":";;;AAAA,+EAA2E;AAE3E;;;;;;;;;;GAUG;AAEH,MAAa,sBAAuB,SAAQ,uCAAkB;IAE5D,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,wBAAwB,CAAA;QAItC,MAAM,CAAC,MAAM,CAAC,IAA8B,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;CAIF;AAVD,wDAUC","sourcesContent":["import { AbstractFilterUser } from '../../icc-api/model/AbstractFilterUser'\n\n/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\n\nexport class UsersByPatientIdFilter extends AbstractFilterUser {\n $type: string = 'UsersByPatientIdFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as UsersByPatientIdFilter, json)\n }\n\n patientId?: string\n desc?: string\n}\n"]}
|
|
@@ -1298,7 +1298,7 @@ class IccCryptoXApi {
|
|
|
1298
1298
|
return Promise.all(tasksForDelegates
|
|
1299
1299
|
.concat(tasksForDelegator)
|
|
1300
1300
|
.map(({ delegateId, maintenanceTask }) => __awaiter(this, void 0, void 0, function* () {
|
|
1301
|
-
const taskToCreate = yield (maintenanceTaskApi === null || maintenanceTaskApi === void 0 ? void 0 : maintenanceTaskApi.newInstance(user, maintenanceTask, delegateId));
|
|
1301
|
+
const taskToCreate = yield (maintenanceTaskApi === null || maintenanceTaskApi === void 0 ? void 0 : maintenanceTaskApi.newInstance(user, maintenanceTask, [delegateId]));
|
|
1302
1302
|
return taskToCreate ? maintenanceTaskApi === null || maintenanceTaskApi === void 0 ? void 0 : maintenanceTaskApi.createMaintenanceTaskWithUser(user, taskToCreate) : undefined;
|
|
1303
1303
|
}))
|
|
1304
1304
|
.filter((createdTask) => createdTask != undefined));
|
|
@@ -1489,7 +1489,7 @@ class IccCryptoXApi {
|
|
|
1489
1489
|
if (edKey) {
|
|
1490
1490
|
const importedEdKey = yield this._AES.importKey('raw', (0, binary_utils_1.hex2ua)(edKey.replace(/-/g, '')));
|
|
1491
1491
|
try {
|
|
1492
|
-
return this._AES[method](importedEdKey, content);
|
|
1492
|
+
return yield this._AES[method](importedEdKey, content);
|
|
1493
1493
|
}
|
|
1494
1494
|
catch (e) {
|
|
1495
1495
|
return content;
|
|
@@ -1498,7 +1498,7 @@ class IccCryptoXApi {
|
|
|
1498
1498
|
const sfks = yield this.extractKeysFromDelegationsForHcpHierarchy(user === null || user === void 0 ? void 0 : user.healthcarePartyId, documentObject === null || documentObject === void 0 ? void 0 : documentObject.id, documentObject === null || documentObject === void 0 ? void 0 : documentObject.encryptionKeys);
|
|
1499
1499
|
const importedEdKey = yield this._AES.importKey('raw', (0, binary_utils_1.hex2ua)(sfks.extractedKeys[0].replace(/-/g, '')));
|
|
1500
1500
|
try {
|
|
1501
|
-
return this._AES[method](importedEdKey, content);
|
|
1501
|
+
return yield this._AES[method](importedEdKey, content);
|
|
1502
1502
|
}
|
|
1503
1503
|
catch (e) {
|
|
1504
1504
|
return content;
|