@icure/api 7.1.22 → 7.1.24

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.
Files changed (33) hide show
  1. package/icc-api/api/IccAuthApi.d.ts +2 -1
  2. package/icc-api/api/IccAuthApi.js +3 -2
  3. package/icc-api/api/IccAuthApi.js.map +1 -1
  4. package/icc-api/api/IccUserApi.d.ts +6 -0
  5. package/icc-api/api/IccUserApi.js +13 -0
  6. package/icc-api/api/IccUserApi.js.map +1 -1
  7. package/icc-api/api/XHR.d.ts +1 -1
  8. package/icc-api/api/XHR.js +4 -3
  9. package/icc-api/api/XHR.js.map +1 -1
  10. package/icc-x-api/auth/AuthService.d.ts +2 -1
  11. package/icc-x-api/auth/AuthService.js.map +1 -1
  12. package/icc-x-api/auth/AuthenticationProvider.d.ts +1 -1
  13. package/icc-x-api/auth/AuthenticationProvider.js +1 -1
  14. package/icc-x-api/auth/AuthenticationProvider.js.map +1 -1
  15. package/icc-x-api/auth/EnsembleAuthService.d.ts +1 -1
  16. package/icc-x-api/auth/EnsembleAuthService.js +2 -2
  17. package/icc-x-api/auth/EnsembleAuthService.js.map +1 -1
  18. package/icc-x-api/auth/JwtAuthService.d.ts +0 -2
  19. package/icc-x-api/auth/JwtAuthService.js +3 -15
  20. package/icc-x-api/auth/JwtAuthService.js.map +1 -1
  21. package/icc-x-api/auth/JwtUtils.d.ts +10 -0
  22. package/icc-x-api/auth/JwtUtils.js +31 -0
  23. package/icc-x-api/auth/JwtUtils.js.map +1 -0
  24. package/icc-x-api/auth/SmartAuthProvider.d.ts +120 -0
  25. package/icc-x-api/auth/SmartAuthProvider.js +375 -0
  26. package/icc-x-api/auth/SmartAuthProvider.js.map +1 -0
  27. package/icc-x-api/icc-contact-x-api.d.ts +3 -3
  28. package/icc-x-api/icc-contact-x-api.js +20 -28
  29. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  30. package/icc-x-api/index.d.ts +54 -0
  31. package/icc-x-api/index.js +11 -11
  32. package/icc-x-api/index.js.map +1 -1
  33. package/package.json +1 -1
@@ -30,14 +30,14 @@ class EnsembleAuthService {
30
30
  var _a, _b;
31
31
  return (_b = (_a = this.jwtAuth) === null || _a === void 0 ? void 0 : _a.getIcureTokens()) !== null && _b !== void 0 ? _b : Promise.resolve();
32
32
  }
33
- getAuthHeaders() {
33
+ getAuthHeaders(minimumAuthenticationClass) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  this.currentState = !!this.currentState ? this.stateMap[this.currentState].next : this.currentState;
36
36
  if (!!this.currentState) {
37
37
  // If I have a state I return the headers, otherwise I return empty headers
38
38
  // And delegate the responsibility of handling the error to the next call
39
39
  return !!this.stateMap[this.currentState].state
40
- ? this.stateMap[this.currentState].state.getAuthHeaders().catch((e) => {
40
+ ? this.stateMap[this.currentState].state.getAuthHeaders(minimumAuthenticationClass).catch((e) => {
41
41
  if (e instanceof XHRError && e.statusCode === 417) {
42
42
  throw e;
43
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EnsembleAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/EnsembleAuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+CAA2C;AAK3C,IAAO,QAAQ,GAAG,SAAG,CAAC,QAAQ,CAAA;AAG9B,MAAa,mBAAmB;IAK9B,YACmB,OAAsD,EACtD,WAA0B,EAC1B,SAA2B;QAF3B,YAAO,GAAP,OAAO,CAA+C;QACtD,gBAAW,GAAX,WAAW,CAAe;QAC1B,cAAS,GAAT,SAAS,CAAkB;QANtC,UAAK,GAAiB,IAAI,CAAA;QAQhC,IAAI,CAAC,QAAQ,GAAG;YACd,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;YACnC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAC7C,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,E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AC,KAAK,CAAA;aACjB;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;aACvC;QACH,CAAC;KAAA;IAED,gBAAgB,CAAC,KAAY;;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE;YACvB,MAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,0CAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AAvDD,kDAuDC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { JwtBridgedAuthService } from './JwtBridgedAuthService'\nimport { NoAuthService } from './NoAuthService'\nimport { BasicAuthService } from './BasicAuthService'\nimport Header = XHR.Header\nimport XHRError = XHR.XHRError\nimport { JwtAuthService } from './JwtAuthService'\n\nexport class EnsembleAuthService implements AuthService {\n private currentState: string | null\n private error: Error | null = null\n private stateMap: { [key: string]: { state: AuthService | null; next: string | null } }\n\n constructor(\n private readonly jwtAuth: JwtBridgedAuthService | JwtAuthService | null,\n private readonly sessionAuth: NoAuthService,\n private readonly basicAuth: BasicAuthService\n ) {\n this.stateMap = {\n start: { state: null, next: 'jwt' },\n jwt: { state: this.jwtAuth, next: 'session' },\n session: { state: this.sessionAuth, next: 'basic' },\n basic: { state: this.basicAuth, next: null },\n }\n this.currentState = 'start'\n }\n\n getIcureTokens(): Promise<{ token: string; refreshToken: string } | undefined> {\n return this.jwtAuth?.getIcureTokens() ?? (Promise.resolve() as Promise<undefined>)\n }\n\n async getAuthHeaders(): Promise<Array<Header>> {\n this.currentState = !!this.currentState ? this.stateMap[this.currentState].next : this.currentState\n\n if (!!this.currentState) {\n // If I have a state I return the headers, otherwise I return empty headers\n // And delegate the responsibility of handling the error to the next call\n return !!this.stateMap[this.currentState].state\n ? this.stateMap[this.currentState].state!.getAuthHeaders().catch((e) => {\n if (e instanceof XHRError && e.statusCode === 417) {\n throw e\n }\n // If I get an error, it is also responsibility of the next call, but I give a warning\n console.warn(e.message)\n this.error = e\n\n return []\n })\n : Promise.resolve([])\n } else if (!!this.error) {\n // If I have no more states, I throw the last error or a default one\n throw this.error\n } else {\n throw new Error('Cannot authenticate')\n }\n }\n\n invalidateHeader(error: Error): void {\n this.error = error\n if (!!this.currentState) {\n this.stateMap[this.currentState].state?.invalidateHeader(error)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"EnsembleAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/EnsembleAuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+CAA2C;AAK3C,IAAO,QAAQ,GAAG,SAAG,CAAC,QAAQ,CAAA;AAG9B,MAAa,mBAAmB;IAK9B,YACmB,OAAsD,EACtD,WAA0B,EAC1B,SAA2B;QAF3B,YAAO,GAAP,OAAO,CAA+C;QACtD,gBAAW,GAAX,WAAW,CAAe;QAC1B,cAAS,GAAT,SAAS,CAAkB;QANtC,UAAK,GAAiB,IAAI,CAAA;QAQhC,IAAI,CAAC,QAAQ,GAAG;YACd,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;YACnC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAC7C,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE;YACnD,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE;SAC7C,CAAA;QACD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAA;IAC7B,CAAC;IAED,cAAc;;QACZ,OAAO,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,cAAc,EAAE,mCAAK,OAAO,CAAC,OAAO,EAAyB,CAAA;IACpF,CAAC;IAEK,cAAc,CAAC,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,0CAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AAvDD,kDAuDC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { JwtBridgedAuthService } from './JwtBridgedAuthService'\nimport { NoAuthService } from './NoAuthService'\nimport { BasicAuthService } from './BasicAuthService'\nimport Header = XHR.Header\nimport XHRError = XHR.XHRError\nimport { JwtAuthService } from './JwtAuthService'\n\nexport class EnsembleAuthService implements AuthService {\n private currentState: string | null\n private error: Error | null = null\n private stateMap: { [key: string]: { state: AuthService | null; next: string | null } }\n\n constructor(\n private readonly jwtAuth: JwtBridgedAuthService | JwtAuthService | null,\n private readonly sessionAuth: NoAuthService,\n private readonly basicAuth: BasicAuthService\n ) {\n this.stateMap = {\n start: { state: null, next: 'jwt' },\n jwt: { state: this.jwtAuth, next: 'session' },\n session: { state: this.sessionAuth, next: 'basic' },\n basic: { state: this.basicAuth, next: null },\n }\n this.currentState = 'start'\n }\n\n getIcureTokens(): Promise<{ token: string; refreshToken: string } | undefined> {\n return this.jwtAuth?.getIcureTokens() ?? (Promise.resolve() as Promise<undefined>)\n }\n\n async getAuthHeaders(minimumAuthenticationClass: number | undefined): Promise<Array<Header>> {\n this.currentState = !!this.currentState ? this.stateMap[this.currentState].next : this.currentState\n\n if (!!this.currentState) {\n // If I have a state I return the headers, otherwise I return empty headers\n // And delegate the responsibility of handling the error to the next call\n return !!this.stateMap[this.currentState].state\n ? this.stateMap[this.currentState].state!.getAuthHeaders(minimumAuthenticationClass).catch((e) => {\n if (e instanceof XHRError && e.statusCode === 417) {\n throw e\n }\n // If I get an error, it is also responsibility of the next call, but I give a warning\n console.warn(e.message)\n this.error = e\n\n return []\n })\n : Promise.resolve([])\n } else if (!!this.error) {\n // If I have no more states, I throw the last error or a default one\n throw this.error\n } else {\n throw new Error('Cannot authenticate')\n }\n }\n\n invalidateHeader(error: Error): void {\n this.error = error\n if (!!this.currentState) {\n this.stateMap[this.currentState].state?.invalidateHeader(error)\n }\n }\n}\n"]}
@@ -20,8 +20,6 @@ export declare class JwtAuthService implements AuthService {
20
20
  } | undefined>;
21
21
  getAuthHeaders(): Promise<Array<Header>>;
22
22
  private _refreshAuthJwt;
23
- private _isJwtInvalidOrExpired;
24
- private _base64Decode;
25
23
  invalidateHeader(error: Error): void;
26
24
  isInErrorState(): boolean;
27
25
  }
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.JwtAuthService = void 0;
13
13
  const XHR_1 = require("../../icc-api/api/XHR");
14
- const utils_1 = require("../utils");
14
+ const JwtUtils_1 = require("./JwtUtils");
15
15
  /**
16
16
  * Differs from JwtBridgedAuthService in that it cannot create new refresh tokens
17
17
  */
@@ -36,7 +36,7 @@ class JwtAuthService {
36
36
  .then((x) => {
37
37
  const authJwt = x === null || x === void 0 ? void 0 : x.authJwt;
38
38
  const refreshJwt = x === null || x === void 0 ? void 0 : x.refreshJwt;
39
- if ((!authJwt || this._isJwtInvalidOrExpired(authJwt)) && refreshJwt) {
39
+ if ((!authJwt || (0, JwtUtils_1.isJwtInvalidOrExpired)(authJwt)) && refreshJwt) {
40
40
  // If it does not have the JWT, tries to get it
41
41
  // If the JWT is expired, tries to refresh it
42
42
  this._currentPromise = this._refreshAuthJwt(refreshJwt).then((updatedTokens) => {
@@ -62,7 +62,7 @@ class JwtAuthService {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
63
  // If I do not have a refresh JWT or the refresh JWT is expired,
64
64
  // I have to log in again
65
- if (this._isJwtInvalidOrExpired(refreshJwt)) {
65
+ if ((0, JwtUtils_1.isJwtInvalidOrExpired)(refreshJwt)) {
66
66
  throw Error('Missing or expired refresh token: please log in again');
67
67
  }
68
68
  else {
@@ -73,18 +73,6 @@ class JwtAuthService {
73
73
  }
74
74
  });
75
75
  }
76
- _isJwtInvalidOrExpired(jwt) {
77
- const parts = jwt.split('.');
78
- if (parts.length !== 3) {
79
- return true;
80
- }
81
- const payload = this._base64Decode(parts[1]);
82
- // Using the 'exp' string is safe to use as it is part of the JWT RFC and cannot be modified by us.
83
- return !('exp' in payload) || payload['exp'] * 1000 < new Date().getTime();
84
- }
85
- _base64Decode(encodedString) {
86
- return JSON.parse((0, utils_1.a2b)(encodedString));
87
- }
88
76
  invalidateHeader(error) {
89
77
  this._error = error;
90
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JwtAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/JwtAuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+CAA2C;AAI3C,oCAA8B;AAI9B;;GAEG;AACH,MAAa,cAAc;IAIzB,YAA6B,OAAmB,EAAE,UAAoD;QAAzE,YAAO,GAAP,OAAO,CAAY;QAHxC,WAAM,GAAiB,IAAI,CAAA;QAC3B,oBAAe,GAAiE,OAAO,CAAC,OAAO,CAAC,SAAgB,CAAC,CAAA;QAGvH,IAAI,CAAC,CAAC,UAAU,EAAE;YAChB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACnD;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAiB,CAAC,CAAA;IAC/D,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IAC7G,CAAC;IAEK,cAAc;;YAClB,OAAO,IAAI,CAAC,eAAe;iBACxB,IAAI,CAAC,CAAC,CAAC,E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AM;gBACL,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;oBAClF,OAAO,EAAE,eAAe,CAAC,KAAM;oBAC/B,UAAU,EAAE,UAAU;iBACvB,CAAC,CAAC,CAAA;aACJ;QACH,CAAC;KAAA;IAEO,sBAAsB,CAAC,GAAW;QACxC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB,OAAO,IAAI,CAAA;SACZ;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5C,mGAAmG;QACnG,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAC5E,CAAC;IAEO,aAAa,CAAC,aAAqB;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,WAAG,EAAC,aAAa,CAAC,CAAC,CAAA;IACvC,CAAC;IAED,gBAAgB,CAAC,KAAY;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;CACF;AAjFD,wCAiFC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { IccAuthApi, OAuthThirdParty } from '../../icc-api'\nimport { LoginCredentials } from '../../icc-api/model/LoginCredentials'\nimport Header = XHR.Header\nimport { a2b } from '../utils'\nimport { AuthenticationResponse } from '../../icc-api/model/AuthenticationResponse'\nimport XHRError = XHR.XHRError\n\n/**\n * Differs from JwtBridgedAuthService in that it cannot create new refresh tokens\n */\nexport class JwtAuthService implements AuthService {\n private _error: Error | null = null\n private _currentPromise: Promise<{ authJwt: string; refreshJwt: string } | undefined> = Promise.resolve(undefined as any)\n\n constructor(private readonly authApi: IccAuthApi, initialJwt?: { authJwt: string; refreshJwt: string }) {\n if (!!initialJwt) {\n this._currentPromise = Promise.resolve(initialJwt)\n }\n }\n\n get refreshToken(): Promise<string | undefined> {\n return this._currentPromise.then((x) => x?.refreshJwt as any)\n }\n\n getIcureTokens(): Promise<{ token: string; refreshToken: string } | undefined> {\n return this._currentPromise.then((x) => (x ? { token: x.authJwt, refreshToken: x.refreshJwt } : undefined))\n }\n\n async getAuthHeaders(): Promise<Array<Header>> {\n return this._currentPromise\n .then((x) => {\n const authJwt = x?.authJwt\n const refreshJwt = x?.refreshJwt\n\n if ((!authJwt || this._isJwtInvalidOrExpired(authJwt)) && refreshJwt) {\n // If it does not have the JWT, tries to get it\n // If the JWT is expired, tries to refresh it\n\n this._currentPromise = this._refreshAuthJwt(refreshJwt).then((updatedTokens) => {\n // If here the token is null,\n // it goes in a suspension status\n if (!updatedTokens.authJwt) {\n throw new Error('Your iCure back-end version does not support JWT authentication')\n }\n\n return updatedTokens\n })\n } else if (!!this._error) {\n throw this._error\n }\n return this._currentPromise\n })\n .then((x) => {\n return x?.authJwt ? [new XHR.Header('Authorization', `Bearer ${x.authJwt}`)] : Promise.reject('Cannot provide auth: No JWT')\n })\n }\n\n private async _refreshAuthJwt(refreshJwt: string): Promise<{ authJwt: string; refreshJwt: string }> {\n // If I do not have a refresh JWT or the refresh JWT is expired,\n // I have to log in again\n if (this._isJwtInvalidOrExpired(refreshJwt)) {\n throw Error('Missing or expired refresh token: please log in again')\n } else {\n return this.authApi.refreshAuthenticationJWT(refreshJwt).then((refreshResponse) => ({\n authJwt: refreshResponse.token!,\n refreshJwt: refreshJwt,\n }))\n }\n }\n\n private _isJwtInvalidOrExpired(jwt: string): boolean {\n const parts = jwt.split('.')\n if (parts.length !== 3) {\n return true\n }\n const payload = this._base64Decode(parts[1])\n // Using the 'exp' string is safe to use as it is part of the JWT RFC and cannot be modified by us.\n return !('exp' in payload) || payload['exp'] * 1000 < new Date().getTime()\n }\n\n private _base64Decode(encodedString: string): any {\n return JSON.parse(a2b(encodedString))\n }\n\n invalidateHeader(error: Error): void {\n this._error = error\n }\n\n isInErrorState(): boolean {\n return !!this._error\n }\n}\n"]}
1
+ {"version":3,"file":"JwtAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/JwtAuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+CAA2C;AAO3C,yCAAkD;AAElD;;GAEG;AACH,MAAa,cAAc;IAIzB,YAA6B,OAAmB,EAAE,UAAoD;QAAzE,YAAO,GAAP,OAAO,CAAY;QAHxC,WAAM,GAAiB,IAAI,CAAA;QAC3B,oBAAe,GAAiE,OAAO,CAAC,OAAO,CAAC,SAAgB,CAAC,CAAA;QAGvH,IAAI,CAAC,CAAC,UAAU,EAAE;YAChB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACnD;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAiB,CAAC,CAAA;IAC/D,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IAC7G,CAAC;IAEK,cAAc;;YAClB,OAAO,IAAI,CAAC,eAAe;iBACxB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;gBACV,MAAM,OAAO,GAAG,CAAC,aAAD,CAAC,uBAAD,CAAC,C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AAC,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;oBAClF,OAAO,EAAE,eAAe,CAAC,KAAM;oBAC/B,UAAU,EAAE,UAAU;iBACvB,CAAC,CAAC,CAAA;aACJ;QACH,CAAC;KAAA;IAED,gBAAgB,CAAC,KAAY;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;CACF;AAnED,wCAmEC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { IccAuthApi, OAuthThirdParty } from '../../icc-api'\nimport { LoginCredentials } from '../../icc-api/model/LoginCredentials'\nimport Header = XHR.Header\nimport { a2b } from '../utils'\nimport { AuthenticationResponse } from '../../icc-api/model/AuthenticationResponse'\nimport XHRError = XHR.XHRError\nimport { isJwtInvalidOrExpired } from './JwtUtils'\n\n/**\n * Differs from JwtBridgedAuthService in that it cannot create new refresh tokens\n */\nexport class JwtAuthService implements AuthService {\n private _error: Error | null = null\n private _currentPromise: Promise<{ authJwt: string; refreshJwt: string } | undefined> = Promise.resolve(undefined as any)\n\n constructor(private readonly authApi: IccAuthApi, initialJwt?: { authJwt: string; refreshJwt: string }) {\n if (!!initialJwt) {\n this._currentPromise = Promise.resolve(initialJwt)\n }\n }\n\n get refreshToken(): Promise<string | undefined> {\n return this._currentPromise.then((x) => x?.refreshJwt as any)\n }\n\n getIcureTokens(): Promise<{ token: string; refreshToken: string } | undefined> {\n return this._currentPromise.then((x) => (x ? { token: x.authJwt, refreshToken: x.refreshJwt } : undefined))\n }\n\n async getAuthHeaders(): Promise<Array<Header>> {\n return this._currentPromise\n .then((x) => {\n const authJwt = x?.authJwt\n const refreshJwt = x?.refreshJwt\n\n if ((!authJwt || isJwtInvalidOrExpired(authJwt)) && refreshJwt) {\n // If it does not have the JWT, tries to get it\n // If the JWT is expired, tries to refresh it\n\n this._currentPromise = this._refreshAuthJwt(refreshJwt).then((updatedTokens) => {\n // If here the token is null,\n // it goes in a suspension status\n if (!updatedTokens.authJwt) {\n throw new Error('Your iCure back-end version does not support JWT authentication')\n }\n\n return updatedTokens\n })\n } else if (!!this._error) {\n throw this._error\n }\n return this._currentPromise\n })\n .then((x) => {\n return x?.authJwt ? [new XHR.Header('Authorization', `Bearer ${x.authJwt}`)] : Promise.reject('Cannot provide auth: No JWT')\n })\n }\n\n private async _refreshAuthJwt(refreshJwt: string): Promise<{ authJwt: string; refreshJwt: string }> {\n // If I do not have a refresh JWT or the refresh JWT is expired,\n // I have to log in again\n if (isJwtInvalidOrExpired(refreshJwt)) {\n throw Error('Missing or expired refresh token: please log in again')\n } else {\n return this.authApi.refreshAuthenticationJWT(refreshJwt).then((refreshResponse) => ({\n authJwt: refreshResponse.token!,\n refreshJwt: refreshJwt,\n }))\n }\n }\n\n invalidateHeader(error: Error): void {\n this._error = error\n }\n\n isInErrorState(): boolean {\n return !!this._error\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @internal this function is for internal use only and may be changed without notice
3
+ * Returns true if the jwt is invalid or expired, false otherwise.
4
+ */
5
+ export declare function isJwtInvalidOrExpired(jwt: string): boolean;
6
+ /**
7
+ * @internal this function is for internal use only and may be changed without notice
8
+ * Get the claims of the jwt.
9
+ */
10
+ export declare function decodeJwtClaims(jwt: string): any;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeJwtClaims = exports.isJwtInvalidOrExpired = void 0;
4
+ const utils_1 = require("../utils");
5
+ /**
6
+ * @internal this function is for internal use only and may be changed without notice
7
+ * Returns true if the jwt is invalid or expired, false otherwise.
8
+ */
9
+ function isJwtInvalidOrExpired(jwt) {
10
+ try {
11
+ const claims = decodeJwtClaims(jwt);
12
+ // Using the 'exp' string is safe to use as it is part of the JWT RFC and cannot be modified by us.
13
+ return !('exp' in claims) || claims['exp'] * 1000 < new Date().getTime();
14
+ }
15
+ catch (e) {
16
+ return true;
17
+ }
18
+ }
19
+ exports.isJwtInvalidOrExpired = isJwtInvalidOrExpired;
20
+ /**
21
+ * @internal this function is for internal use only and may be changed without notice
22
+ * Get the claims of the jwt.
23
+ */
24
+ function decodeJwtClaims(jwt) {
25
+ const parts = jwt.split('.');
26
+ if (parts.length !== 3)
27
+ throw new Error('Invalid JWT: should be 3 parts');
28
+ return JSON.parse((0, utils_1.a2b)(parts[1]));
29
+ }
30
+ exports.decodeJwtClaims = decodeJwtClaims;
31
+ //# sourceMappingURL=JwtUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JwtUtils.js","sourceRoot":"","sources":["../../../icc-x-api/auth/JwtUtils.ts"],"names":[],"mappings":";;;AAAA,oCAA8B;AAE9B;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,IAAI;QACF,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;QACnC,mGAAmG;QACnG,OAAO,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;KACzE;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AARD,sDAQC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,WAAG,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAClC,CAAC;AAJD,0CAIC","sourcesContent":["import { a2b } from '../utils'\n\n/**\n * @internal this function is for internal use only and may be changed without notice\n * Returns true if the jwt is invalid or expired, false otherwise.\n */\nexport function isJwtInvalidOrExpired(jwt: string): boolean {\n try {\n const claims = decodeJwtClaims(jwt)\n // Using the 'exp' string is safe to use as it is part of the JWT RFC and cannot be modified by us.\n return !('exp' in claims) || claims['exp'] * 1000 < new Date().getTime()\n } catch (e) {\n return true\n }\n}\n\n/**\n * @internal this function is for internal use only and may be changed without notice\n * Get the claims of the jwt.\n */\nexport function decodeJwtClaims(jwt: string): any {\n const parts = jwt.split('.')\n if (parts.length !== 3) throw new Error('Invalid JWT: should be 3 parts')\n return JSON.parse(a2b(parts[1]))\n}\n"]}
@@ -0,0 +1,120 @@
1
+ import { AuthenticationProvider } from './AuthenticationProvider';
2
+ import { UserGroup } from '../../icc-api/model/UserGroup';
3
+ import { AuthService } from './AuthService';
4
+ import { IccAuthApi } from '../../icc-api';
5
+ /**
6
+ * Needed by a {@link SmartAuthProvider} to get the secrets (password, token, etc.) for authentication to the iCure SDK as needed.
7
+ */
8
+ export interface AuthSecretProvider {
9
+ /**
10
+ * Provides a secret for authentication to the iCure SDK.
11
+ *
12
+ * ## Accepted secrets
13
+ *
14
+ * The method will be provided with an array of the secrets types that are acceptable (`acceptedSecrets`). Usually this array will contain multiple
15
+ * elements, but this depends on the group configuration, the user (if he has 2fa setup or not), or the operation being performed. For groups using
16
+ * default configurations and for patients without 2fa enabled for example the array will always contain the {@link AuthSecretType.PASSWORD} element.
17
+ * Usually the array contain also the {@link AuthSecretType.LONG_LIVED_TOKEN} element, but if the user is attempting to perform a sensitive operations
18
+ * such as changing his password the default group configuration does not allow for the user to authenticate using a JWT obtained from a long-lived
19
+ * token for this operation, meaning the array will not contain the {@link AuthSecretType.LONG_LIVED_TOKEN} element.
20
+ *
21
+ * Regardless of the number of elements in the array only one secret of the accepted types is sufficient for the operation to succeed.
22
+ *
23
+ * ## TWO_FACTOR_AUTHENTICATION_TOKEN secret type
24
+ *
25
+ * The {@link AuthSecretType.TWO_FACTOR_AUTHENTICATION_TOKEN} secret type is only used when the user has 2fa enabled. In this case the SDK will call
26
+ * this method twice, once containing the {@link AuthSecretType.PASSWORD} element in the `acceptedSecrets` array, and if the provided secret is a
27
+ * valid password the SDK will immediately call this method again, this time containing the {@link AuthSecretType.TWO_FACTOR_AUTHENTICATION_TOKEN}
28
+ * instead of the {@link AuthSecretType.PASSWORD} element.
29
+ *
30
+ * Any future call to this method from the same provider instance will not contain the {@link AuthSecretType.PASSWORD} element anymore, as it is
31
+ * cached, but it may contain the {@link AuthSecretType.TWO_FACTOR_AUTHENTICATION_TOKEN} element instead.
32
+ *
33
+ * Note that the 2fa token is not needed for logging in through a long-lived or short-lived token, it is only used in combination with a password.
34
+ * If the user is using 2fa, and you get in input as `acceptedSecrets` an array `[PASSWORD, LONG_LIVED_TOKEN, SHORT_LIVED_TOKEN]`, and you pass to
35
+ * authenticate a long-lived token, the SDK will not call this method again to ask for the 2fa token.
36
+ *
37
+ * @param acceptedSecrets the types of secrets that are acceptable for the operation being performed.
38
+ * @param previousAttempts the secrets that were previously attempted by the SDK for this operation. This array will be empty the first time this
39
+ * method is called for a given operation, but it may contain multiple elements if the SDK has already called this method multiple times because the
40
+ * previously returned secrets were not valid. The first element is the first secret that was attempted, and the last element is the most recently
41
+ * attempted.
42
+ * @return a promise that resolves with the secret and the secret type to use for authentication. If the promise rejects then the ongoing SDK
43
+ * operation will fail without being re-attempted.
44
+ */
45
+ getSecret(acceptedSecrets: AuthSecretType[], previousAttempts: {
46
+ secret: string;
47
+ secretType: AuthSecretType;
48
+ }[]): Promise<{
49
+ secret: string;
50
+ secretType: AuthSecretType;
51
+ }>;
52
+ }
53
+ /**
54
+ * Represents a type of secret that can be used for authentication with iCure.
55
+ */
56
+ export declare enum AuthSecretType {
57
+ /**
58
+ * Password chosen by the user.
59
+ */
60
+ PASSWORD = "PASSWORD",
61
+ /**
62
+ * Time based one time password provided by authenticator applications, generated on the basis of a timestamp and a shared secret between the iCure
63
+ * server and the authenticator application.
64
+ */
65
+ TWO_FACTOR_AUTHENTICATION_TOKEN = "TWO_FACTOR_AUTHENTICATION_TOKEN",
66
+ /**
67
+ * A short-lived iCure token, an internal authentication token that lasts 5 minutes or less. Unlike passwords these tokens usually are generated by
68
+ * some component of iCure, and are not chosen by the user.
69
+ */
70
+ SHORT_LIVED_TOKEN = "SHORT_LIVED_TOKEN",
71
+ /**
72
+ * A long-lived iCure token, an internal authentication token that lasts longer than 5 minutes. Unlike passwords these tokens usually are generated
73
+ * by some component of iCure, and are not chosen by the user.
74
+ */
75
+ LONG_LIVED_TOKEN = "LONG_LIVED_TOKEN"
76
+ }
77
+ /**
78
+ * @internal this class is meant for internal use only and may be changed without notice. The SmartAuthProvider will be initialised automatically
79
+ * by the iCure api depending on the authentication options you provide.
80
+ *
81
+ * An authentication provider that automatically requests secrets for authentication as needed.
82
+ *
83
+ * This authentication provider can be initialised already with some secrets or tokens, and the provider will cache them and use them as needed for
84
+ * as long as they remain valid. If at any point however the provider needs an updated secret or a secret of a different kind it will automatically
85
+ * request this to the {@link SmartAuthProvider} to get the secret.
86
+ *
87
+ * An advantage of using this provider over others is that in case all the cached tokens and secrets were to expire while performing a request,
88
+ * instead of having the request fail the provider will ask for new secrets from the {@link SmartAuthProvider} and the request will automatically
89
+ * be retried with the new secret. Additionally, the provider may request updated secrets also for performing some sensitive operations (e.g. changing
90
+ * password of the user) even if the cached tokens and/or did not expire. This could be the case for example if the cached secret is a long-lived
91
+ * token, but in order to change the password the user needs to provide his current password.
92
+ *
93
+ * Note that in this context the cache of secrets and token is in memory only, and is not persisted in any way. Different instances of this provider
94
+ * will not share the same cache.
95
+ *
96
+ */
97
+ export declare class SmartAuthProvider implements AuthenticationProvider {
98
+ private readonly tokenProvider;
99
+ private readonly groupId;
100
+ /**
101
+ * Initialises a {@link SmartAuthProvider}.
102
+ * @param authApi an "anonymous" {@link IccAuthApi} to use for authentication.
103
+ * @param login
104
+ * @param secretProvider
105
+ * @param props optional initialisation properties.
106
+ */
107
+ static initialise(authApi: IccAuthApi, login: string, secretProvider: AuthSecretProvider, props?: {
108
+ initialSecret?: string;
109
+ initialAuthToken?: string;
110
+ initialRefreshToken?: string;
111
+ loginGroupId?: string;
112
+ }): SmartAuthProvider;
113
+ private constructor();
114
+ getAuthService(): AuthService;
115
+ switchGroup(newGroupId: string, matches: Array<UserGroup>): Promise<AuthenticationProvider>;
116
+ getIcureTokens(): Promise<{
117
+ token: string;
118
+ refreshToken: string;
119
+ } | undefined>;
120
+ }