@xwiki/cristal-electron-authentication-github-renderer 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { GitHubAuthenticationState } from '@xwiki/cristal-authentication-github-state';
2
- import { CristalApp } from '@xwiki/cristal-api';
3
- import { AuthenticationManager, UserDetails } from '@xwiki/cristal-authentication-api';
2
+ import { CristalApp } from '@xwiki/platform-api';
3
+ import { AuthenticationManager, UserDetails } from '@xwiki/platform-authentication-api';
4
4
  declare class GitHubAuthenticationManager implements AuthenticationManager {
5
5
  private readonly cristalApp;
6
6
  private readonly authenticationState;
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/GitHubAuthenticationManager.ts","../src/index.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp } from \"@xwiki/cristal-api\";\nimport type {\n AuthenticationManager,\n UserDetails,\n} from \"@xwiki/cristal-authentication-api\";\n\ninterface AuthenticationWindow extends Window {\n authenticationGitHub: {\n login: (\n baseUrl: string,\n deviceCode: string,\n interval: string,\n expiresIn: string,\n ) => Promise<void>;\n\n isLoggedIn(): Promise<boolean>;\n\n getUserDetails(): Promise<UserDetails>;\n\n getAuthorizationValue(): Promise<{\n tokenType: string;\n accessToken: string;\n }>;\n\n logout(): Promise<void>;\n };\n}\ndeclare const window: AuthenticationWindow;\n\n@injectable()\nclass GitHubAuthenticationManager implements AuthenticationManager {\n constructor(\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(GitHubAuthenticationState)\n private readonly authenticationState: GitHubAuthenticationState,\n ) {}\n\n private readonly localStorageDeviceCode = \"authentication.device_code\";\n\n private readonly localStorageUserCode = \"authentication.user_code\";\n\n private readonly localStorageExpiresIn = \"authentication.expires_in\";\n\n private readonly localStorageInterval = \"authentication.interval\";\n\n async start(): Promise<void> {\n const authorizationUrl = new URL(\n `${this.cristalApp.getWikiConfig().authenticationBaseURL}/device-login`,\n );\n\n const response = await fetch(authorizationUrl);\n const jsonResponse: {\n device_code: string;\n user_code: string;\n expires_in: number;\n interval: number;\n } = await response.json();\n\n window.localStorage.setItem(\n this.localStorageDeviceCode,\n jsonResponse.device_code,\n );\n window.localStorage.setItem(\n this.localStorageUserCode,\n jsonResponse.user_code,\n );\n window.localStorage.setItem(\n this.localStorageExpiresIn,\n jsonResponse.expires_in.toString(),\n );\n window.localStorage.setItem(\n this.localStorageInterval,\n jsonResponse.interval.toString(),\n );\n this.authenticationState.modalOpened.value = true;\n }\n\n async callback(): Promise<void> {\n return window.authenticationGitHub.login(\n this.cristalApp.getWikiConfig().authenticationBaseURL!,\n window.localStorage.getItem(this.localStorageDeviceCode)!,\n window.localStorage.getItem(this.localStorageInterval)!,\n window.localStorage.getItem(this.localStorageExpiresIn)!,\n );\n }\n\n async getAuthorizationHeader(): Promise<string | undefined> {\n const authenticated = await this.isAuthenticated();\n if (authenticated) {\n const { tokenType, accessToken } =\n await window.authenticationGitHub.getAuthorizationValue();\n return `${tokenType} ${accessToken}`;\n }\n }\n\n async isAuthenticated(): Promise<boolean> {\n return window.authenticationGitHub.isLoggedIn();\n }\n\n async getUserDetails(): Promise<UserDetails> {\n return window.authenticationGitHub.getUserDetails();\n }\n\n async logout(): Promise<void> {\n await window.authenticationGitHub.logout();\n }\n}\n\nexport { GitHubAuthenticationManager };\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationManager } from \"./GitHubAuthenticationManager\";\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport type { AuthenticationManager } from \"@xwiki/cristal-authentication-api\";\nimport type { Container } from \"inversify\";\n\n/**\n * @beta\n */\nclass ComponentInit {\n constructor(container: Container) {\n container\n .bind<AuthenticationManager>(\"AuthenticationManager\")\n .to(GitHubAuthenticationManager)\n .inSingletonScope()\n .whenNamed(\"GitHub\");\n container\n .bind<GitHubAuthenticationState>(GitHubAuthenticationState)\n .toSelf()\n .inSingletonScope();\n }\n}\n\nexport { ComponentInit, GitHubAuthenticationState };\n"],"names":["GitHubAuthenticationManager","cristalApp","authenticationState","authorizationUrl","jsonResponse","tokenType","accessToken","__decorateClass","injectable","__decorateParam","GitHubAuthenticationState","ComponentInit","container"],"mappings":";;;;;;;;AAoDA,IAAMA,IAAN,MAAmE;AAAA,EACjE,YACyCC,GAEtBC,GACjB;AAHuC,SAAA,aAAAD,GAEtB,KAAA,sBAAAC;AAAA,EAChB;AAAA,EAEc,yBAAyB;AAAA,EAEzB,uBAAuB;AAAA,EAEvB,wBAAwB;AAAA,EAExB,u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AAA,EAGIC,OAAO,YAAY,CAAA;AAAA,EACnBA,OAAOC,CAAyB,CAAA;AAAA,GAH/BV,CAAA;ACxBN,MAAMW,EAAc;AAAA,EAClB,YAAYC,GAAsB;AAChC,IAAAA,EACG,KAA4B,uBAAuB,EACnD,GAAGZ,CAA2B,EAC9B,iBAAA,EACA,UAAU,QAAQ,GACrBY,EACG,KAAgCF,CAAyB,EACzD,OAAA,EACA,iBAAA;AAAA,EACL;AACF;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/GitHubAuthenticationManager.ts","../src/index.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp } from \"@xwiki/platform-api\";\nimport type {\n AuthenticationManager,\n UserDetails,\n} from \"@xwiki/platform-authentication-api\";\n\ninterface AuthenticationWindow extends Window {\n authenticationGitHub: {\n login: (\n baseUrl: string,\n deviceCode: string,\n interval: string,\n expiresIn: string,\n ) => Promise<void>;\n\n isLoggedIn(): Promise<boolean>;\n\n getUserDetails(): Promise<UserDetails>;\n\n getAuthorizationValue(): Promise<{\n tokenType: string;\n accessToken: string;\n }>;\n\n logout(): Promise<void>;\n };\n}\ndeclare const window: AuthenticationWindow;\n\n@injectable()\nclass GitHubAuthenticationManager implements AuthenticationManager {\n constructor(\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(GitHubAuthenticationState)\n private readonly authenticationState: GitHubAuthenticationState,\n ) {}\n\n private readonly localStorageDeviceCode = \"authentication.device_code\";\n\n private readonly localStorageUserCode = \"authentication.user_code\";\n\n private readonly localStorageExpiresIn = \"authentication.expires_in\";\n\n private readonly localStorageInterval = \"authentication.interval\";\n\n async start(): Promise<void> {\n const authorizationUrl = new URL(\n `${this.cristalApp.getWikiConfig().authenticationBaseURL}/device-login`,\n );\n\n const response = await fetch(authorizationUrl);\n const jsonResponse: {\n device_code: string;\n user_code: string;\n expires_in: number;\n interval: number;\n } = await response.json();\n\n window.localStorage.setItem(\n this.localStorageDeviceCode,\n jsonResponse.device_code,\n );\n window.localStorage.setItem(\n this.localStorageUserCode,\n jsonResponse.user_code,\n );\n window.localStorage.setItem(\n this.localStorageExpiresIn,\n jsonResponse.expires_in.toString(),\n );\n window.localStorage.setItem(\n this.localStorageInterval,\n jsonResponse.interval.toString(),\n );\n this.authenticationState.modalOpened.value = true;\n }\n\n async callback(): Promise<void> {\n return window.authenticationGitHub.login(\n this.cristalApp.getWikiConfig().authenticationBaseURL!,\n window.localStorage.getItem(this.localStorageDeviceCode)!,\n window.localStorage.getItem(this.localStorageInterval)!,\n window.localStorage.getItem(this.localStorageExpiresIn)!,\n );\n }\n\n async getAuthorizationHeader(): Promise<string | undefined> {\n const authenticated = await this.isAuthenticated();\n if (authenticated) {\n const { tokenType, accessToken } =\n await window.authenticationGitHub.getAuthorizationValue();\n return `${tokenType} ${accessToken}`;\n }\n }\n\n async isAuthenticated(): Promise<boolean> {\n return window.authenticationGitHub.isLoggedIn();\n }\n\n async getUserDetails(): Promise<UserDetails> {\n return window.authenticationGitHub.getUserDetails();\n }\n\n async logout(): Promise<void> {\n await window.authenticationGitHub.logout();\n }\n}\n\nexport { GitHubAuthenticationManager };\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationManager } from \"./GitHubAuthenticationManager\";\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport type { AuthenticationManager } from \"@xwiki/platform-authentication-api\";\nimport type { Container } from \"inversify\";\n\n/**\n * @beta\n */\nclass ComponentInit {\n constructor(container: Container) {\n container\n .bind<AuthenticationManager>(\"AuthenticationManager\")\n .to(GitHubAuthenticationManager)\n .inSingletonScope()\n .whenNamed(\"GitHub\");\n container\n .bind<GitHubAuthenticationState>(GitHubAuthenticationState)\n .toSelf()\n .inSingletonScope();\n }\n}\n\nexport { ComponentInit, GitHubAuthenticationState };\n"],"names":["GitHubAuthenticationManager","cristalApp","authenticationState","authorizationUrl","jsonResponse","tokenType","accessToken","__decorateClass","injectable","__decorateParam","GitHubAuthenticationState","ComponentInit","container"],"mappings":";;;;;;;;AAoDA,IAAMA,IAAN,MAAmE;AAAA,EACjE,YACyCC,GAEtBC,GACjB;AAHuC,SAAA,aAAAD,GAEtB,KAAA,sBAAAC;AAAA,EAChB;AAAA,EAEc,yBAAyB;AAAA,EAEzB,uBAAuB;AAAA,EAEvB,wBAAwB;AAAA,EAExB,uBAAuB;AAAA,EAExC,MAAM,QAAuB;AAC3B,UAAMC,IAAmB,IAAI;AAAA,MAC3B,GAAG,KAAK,WAAW,cAAA,EAAgB,qBAAqB;AAAA,IAAA,GAIpDC,IAKF,OANa,MAAM,MAAM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,uBAAuB,EACnD,GAAGZ,CAA2B,EAC9B,iBAAA,EACA,UAAU,QAAQ,GACrBY,EACG,KAAgCF,CAAyB,EACzD,OAAA,EACA,iBAAA;AAAA,EACL;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/GitHubAuthenticationManager.ts","../src/index.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp } from \"@xwiki/cristal-api\";\nimport type {\n AuthenticationManager,\n UserDetails,\n} from \"@xwiki/cristal-authentication-api\";\n\ninterface AuthenticationWindow extends Window {\n authenticationGitHub: {\n login: (\n baseUrl: string,\n deviceCode: string,\n interval: string,\n expiresIn: string,\n ) => Promise<void>;\n\n isLoggedIn(): Promise<boolean>;\n\n getUserDetails(): Promise<UserDetails>;\n\n getAuthorizationValue(): Promise<{\n tokenType: string;\n accessToken: string;\n }>;\n\n logout(): Promise<void>;\n };\n}\ndeclare const window: AuthenticationWindow;\n\n@injectable()\nclass GitHubAuthenticationManager implements AuthenticationManager {\n constructor(\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(GitHubAuthenticationState)\n private readonly authenticationState: GitHubAuthenticationState,\n ) {}\n\n private readonly localStorageDeviceCode = \"authentication.device_code\";\n\n private readonly localStorageUserCode = \"authentication.user_code\";\n\n private readonly localStorageExpiresIn = \"authentication.expires_in\";\n\n private readonly localStorageInterval = \"authentication.interval\";\n\n async start(): Promise<void> {\n const authorizationUrl = new URL(\n `${this.cristalApp.getWikiConfig().authenticationBaseURL}/device-login`,\n );\n\n const response = await fetch(authorizationUrl);\n const jsonResponse: {\n device_code: string;\n user_code: string;\n expires_in: number;\n interval: number;\n } = await response.json();\n\n window.localStorage.setItem(\n this.localStorageDeviceCode,\n jsonResponse.device_code,\n );\n window.localStorage.setItem(\n this.localStorageUserCode,\n jsonResponse.user_code,\n );\n window.localStorage.setItem(\n this.localStorageExpiresIn,\n jsonResponse.expires_in.toString(),\n );\n window.localStorage.setItem(\n this.localStorageInterval,\n jsonResponse.interval.toString(),\n );\n this.authenticationState.modalOpened.value = true;\n }\n\n async callback(): Promise<void> {\n return window.authenticationGitHub.login(\n this.cristalApp.getWikiConfig().authenticationBaseURL!,\n window.localStorage.getItem(this.localStorageDeviceCode)!,\n window.localStorage.getItem(this.localStorageInterval)!,\n window.localStorage.getItem(this.localStorageExpiresIn)!,\n );\n }\n\n async getAuthorizationHeader(): Promise<string | undefined> {\n const authenticated = await this.isAuthenticated();\n if (authenticated) {\n const { tokenType, accessToken } =\n await window.authenticationGitHub.getAuthorizationValue();\n return `${tokenType} ${accessToken}`;\n }\n }\n\n async isAuthenticated(): Promise<boolean> {\n return window.authenticationGitHub.isLoggedIn();\n }\n\n async getUserDetails(): Promise<UserDetails> {\n return window.authenticationGitHub.getUserDetails();\n }\n\n async logout(): Promise<void> {\n await window.authenticationGitHub.logout();\n }\n}\n\nexport { GitHubAuthenticationManager };\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationManager } from \"./GitHubAuthenticationManager\";\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport type { AuthenticationManager } from \"@xwiki/cristal-authentication-api\";\nimport type { Container } from \"inversify\";\n\n/**\n * @beta\n */\nclass ComponentInit {\n constructor(container: Container) {\n container\n .bind<AuthenticationManager>(\"AuthenticationManager\")\n .to(GitHubAuthenticationManager)\n .inSingletonScope()\n .whenNamed(\"GitHub\");\n container\n .bind<GitHubAuthenticationState>(GitHubAuthenticationState)\n .toSelf()\n .inSingletonScope();\n }\n}\n\nexport { ComponentInit, GitHubAuthenticationState };\n"],"names":["GitHubAuthenticationManager","cristalApp","authenticationState","authorizationUrl","jsonResponse","tokenType","accessToken","__decorateClass","injectable","__decorateParam","GitHubAuthenticationState","ComponentInit","container"],"mappings":"8lBAoDA,IAAMA,EAAN,KAAmE,CACjE,YACyCC,EAEtBC,EACjB,CAHuC,KAAA,WAAAD,EAEtB,KAAA,oBAAAC,CAChB,CAEc,uBAAyB,6BAEzB,qBAAuB,2BAEvB,sBAAwB,4BAExB,qBAAuB,0BAExC,MAAM,OAAuB,CAC3B,MAAMC,EAAmB,IAAI,IAC3B,GAAG,KAAK,WAAW,cAAA,EAAgB,qBAAqB,eAAA,EAIpDC,EAKF,MANa,MAAM,MAAMD,CAAgB,GAM1B,KAAA,EAEnB,OAAO,aAAa,QAClB,KAAK,uBACLC,EAAa,WAAA,EAEf,OAAO,aAAa,QAClB,KAAK,qBACLA,EAAa,SAAA,EAEf,OAAO,aAAa,QAClB,KAAK,sBACLA,EAAa,WAAW,SAAA,CAAS,EAEnC,OAAO,aAAa,QAClB,KAAK,qBACLA,EAAa,SAAS,SAAA,CAAS,EAEjC,KAAK,oBAAoB,YAAY,MAAQ,EAC/C,CAEA,MAAM,UAA0B,CAC9B,OAAO,OAAO,qBAAqB,MACjC,KAAK,WAAW,cAAA,EAAgB,sBAChC,OAAO,aAAa,QAAQ,KAAK,sBAAsB,EACvD,OAAO,aAAa,QAAQ,KAAK,oBAAoB,EACrD,OAAO,aAAa,QAAQ,KAAK,qBAAqB,CAAA,CAE1D,CAEA,MAAM,wBAAsD,CAE1D,GADsB,MAAM,KAAK,gBAAA,EACd,CACjB,KAAM,CAAE,UAAAC,EAAW,YAAAC,CAAA,EACjB,MAAM,OAAO,qBAAqB,sBAAA,EACpC,MAAO,GAAGD,CAAS,IAAIC,CAAW,EACpC,CACF,CAEA,MAAM,iBAAoC,CACxC,OAAO,OAAO,qBAAqB,WAAA,CACrC,CAEA,MAAM,gBAAuC,CAC3C,OAAO,OAAO,qBAAqB,eAAA,CACrC,CAEA,MAAM,QAAwB,CAC5B,MAAM,OAAO,qBAAqB,OAAA,CACpC,CACF,EA5EMN,EAANO,EAAA,CADCC,aAAA,EAGIC,aAAO,YAAY,CAAA,EACnBA,aAAOC,2BAAyB,CAAA,CAAA,EAH/BV,CAAA,ECxBN,MAAMW,CAAc,CAClB,YAAYC,EAAsB,CAChCA,EACG,KAA4B,uBAAuB,EACnD,GAAGZ,CAA2B,EAC9B,iBAAA,EACA,UAAU,QAAQ,EACrBY,EACG,KAAgCF,EAAAA,yBAAyB,EACzD,OAAA,EACA,iBAAA,CACL,CACF"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/GitHubAuthenticationManager.ts","../src/index.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp } from \"@xwiki/platform-api\";\nimport type {\n AuthenticationManager,\n UserDetails,\n} from \"@xwiki/platform-authentication-api\";\n\ninterface AuthenticationWindow extends Window {\n authenticationGitHub: {\n login: (\n baseUrl: string,\n deviceCode: string,\n interval: string,\n expiresIn: string,\n ) => Promise<void>;\n\n isLoggedIn(): Promise<boolean>;\n\n getUserDetails(): Promise<UserDetails>;\n\n getAuthorizationValue(): Promise<{\n tokenType: string;\n accessToken: string;\n }>;\n\n logout(): Promise<void>;\n };\n}\ndeclare const window: AuthenticationWindow;\n\n@injectable()\nclass GitHubAuthenticationManager implements AuthenticationManager {\n constructor(\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(GitHubAuthenticationState)\n private readonly authenticationState: GitHubAuthenticationState,\n ) {}\n\n private readonly localStorageDeviceCode = \"authentication.device_code\";\n\n private readonly localStorageUserCode = \"authentication.user_code\";\n\n private readonly localStorageExpiresIn = \"authentication.expires_in\";\n\n private readonly localStorageInterval = \"authentication.interval\";\n\n async start(): Promise<void> {\n const authorizationUrl = new URL(\n `${this.cristalApp.getWikiConfig().authenticationBaseURL}/device-login`,\n );\n\n const response = await fetch(authorizationUrl);\n const jsonResponse: {\n device_code: string;\n user_code: string;\n expires_in: number;\n interval: number;\n } = await response.json();\n\n window.localStorage.setItem(\n this.localStorageDeviceCode,\n jsonResponse.device_code,\n );\n window.localStorage.setItem(\n this.localStorageUserCode,\n jsonResponse.user_code,\n );\n window.localStorage.setItem(\n this.localStorageExpiresIn,\n jsonResponse.expires_in.toString(),\n );\n window.localStorage.setItem(\n this.localStorageInterval,\n jsonResponse.interval.toString(),\n );\n this.authenticationState.modalOpened.value = true;\n }\n\n async callback(): Promise<void> {\n return window.authenticationGitHub.login(\n this.cristalApp.getWikiConfig().authenticationBaseURL!,\n window.localStorage.getItem(this.localStorageDeviceCode)!,\n window.localStorage.getItem(this.localStorageInterval)!,\n window.localStorage.getItem(this.localStorageExpiresIn)!,\n );\n }\n\n async getAuthorizationHeader(): Promise<string | undefined> {\n const authenticated = await this.isAuthenticated();\n if (authenticated) {\n const { tokenType, accessToken } =\n await window.authenticationGitHub.getAuthorizationValue();\n return `${tokenType} ${accessToken}`;\n }\n }\n\n async isAuthenticated(): Promise<boolean> {\n return window.authenticationGitHub.isLoggedIn();\n }\n\n async getUserDetails(): Promise<UserDetails> {\n return window.authenticationGitHub.getUserDetails();\n }\n\n async logout(): Promise<void> {\n await window.authenticationGitHub.logout();\n }\n}\n\nexport { GitHubAuthenticationManager };\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { GitHubAuthenticationManager } from \"./GitHubAuthenticationManager\";\nimport { GitHubAuthenticationState } from \"@xwiki/cristal-authentication-github-state\";\nimport type { AuthenticationManager } from \"@xwiki/platform-authentication-api\";\nimport type { Container } from \"inversify\";\n\n/**\n * @beta\n */\nclass ComponentInit {\n constructor(container: Container) {\n container\n .bind<AuthenticationManager>(\"AuthenticationManager\")\n .to(GitHubAuthenticationManager)\n .inSingletonScope()\n .whenNamed(\"GitHub\");\n container\n .bind<GitHubAuthenticationState>(GitHubAuthenticationState)\n .toSelf()\n .inSingletonScope();\n }\n}\n\nexport { ComponentInit, GitHubAuthenticationState };\n"],"names":["GitHubAuthenticationManager","cristalApp","authenticationState","authorizationUrl","jsonResponse","tokenType","accessToken","__decorateClass","injectable","__decorateParam","GitHubAuthenticationState","ComponentInit","container"],"mappings":"8lBAoDA,IAAMA,EAAN,KAAmE,CACjE,YACyCC,EAEtBC,EACjB,CAHuC,KAAA,WAAAD,EAEtB,KAAA,oBAAAC,CAChB,CAEc,uBAAyB,6BAEzB,qBAAuB,2BAEvB,sBAAwB,4BAExB,qBAAuB,0BAExC,MAAM,OAAuB,CAC3B,MAAMC,EAAmB,IAAI,IAC3B,GAAG,KAAK,WAAW,cAAA,EAAgB,qBAAqB,eAAA,EAIpDC,EAKF,MANa,MAAM,MAAMD,CAAgB,GAM1B,KAAA,EAEnB,OAAO,aAAa,QAClB,KAAK,uBACLC,EAAa,WAAA,EAEf,OAAO,aAAa,QAClB,KAAK,qBACLA,EAAa,SAAA,EAEf,OAAO,aAAa,QAClB,KAAK,sBACLA,EAAa,WAAW,SAAA,CAAS,EAEnC,OAAO,aAAa,QAClB,KAAK,qBACLA,EAAa,SAAS,SAAA,CAAS,EAEjC,KAAK,oBAAoB,YAAY,MAAQ,EAC/C,CAEA,MAAM,UAA0B,CAC9B,OAAO,OAAO,qBAAqB,MACjC,KAAK,WAAW,cAAA,EAAgB,sBAChC,OAAO,aAAa,QAAQ,KAAK,sBAAsB,EACvD,OAAO,aAAa,QAAQ,KAAK,oBAAoB,EACrD,OAAO,aAAa,QAAQ,KAAK,qBAAqB,CAAA,CAE1D,CAEA,MAAM,wBAAsD,CAE1D,GADsB,MAAM,KAAK,gBAAA,EACd,CACjB,KAAM,CAAE,UAAAC,EAAW,YAAAC,CAAA,EACjB,MAAM,OAAO,qBAAqB,sBAAA,EACpC,MAAO,GAAGD,CAAS,IAAIC,CAAW,EACpC,CACF,CAEA,MAAM,iBAAoC,CACxC,OAAO,OAAO,qBAAqB,WAAA,CACrC,CAEA,MAAM,gBAAuC,CAC3C,OAAO,OAAO,qBAAqB,eAAA,CACrC,CAEA,MAAM,QAAwB,CAC5B,MAAM,OAAO,qBAAqB,OAAA,CACpC,CACF,EA5EMN,EAANO,EAAA,CADCC,aAAA,EAGIC,aAAO,YAAY,CAAA,EACnBA,aAAOC,2BAAyB,CAAA,CAAA,EAH/BV,CAAA,ECxBN,MAAMW,CAAc,CAClB,YAAYC,EAAsB,CAChCA,EACG,KAA4B,uBAAuB,EACnD,GAAGZ,CAA2B,EAC9B,iBAAA,EACA,UAAU,QAAQ,EACrBY,EACG,KAAgCF,EAAAA,yBAAyB,EACzD,OAAA,EACA,iBAAA,CACL,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-electron-authentication-github-renderer",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
@@ -28,21 +28,21 @@
28
28
  "main": "./dist/index.es.js",
29
29
  "types": "./dist/index.d.ts",
30
30
  "dependencies": {
31
- "@xwiki/cristal-authentication-api": "0.24.0",
32
- "@xwiki/cristal-authentication-github-state": "0.24.0",
33
- "@xwiki/cristal-api": "0.24.0"
31
+ "@xwiki/platform-api": "18.0.0-1766398944",
32
+ "@xwiki/platform-authentication-api": "18.0.0-1766398944",
33
+ "@xwiki/cristal-authentication-github-state": "0.25.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "inversify": "7.x",
37
37
  "reflect-metadata": "0.x"
38
38
  },
39
39
  "devDependencies": {
40
- "inversify": "7.10.4",
40
+ "inversify": "7.10.6",
41
41
  "reflect-metadata": "0.2.2",
42
42
  "typescript": "5.9.3",
43
- "vite": "7.1.12",
44
- "vue": "3.5.22",
45
- "@xwiki/cristal-dev-config": "0.24.0"
43
+ "vite": "7.2.7",
44
+ "vue": "3.5.25",
45
+ "@xwiki/cristal-dev-config": "0.25.0"
46
46
  },
47
47
  "scripts": {
48
48
  "api-extractor:local": "api-extractor run --local",
@@ -20,11 +20,11 @@
20
20
 
21
21
  import { GitHubAuthenticationState } from "@xwiki/cristal-authentication-github-state";
22
22
  import { inject, injectable } from "inversify";
23
- import type { CristalApp } from "@xwiki/cristal-api";
23
+ import type { CristalApp } from "@xwiki/platform-api";
24
24
  import type {
25
25
  AuthenticationManager,
26
26
  UserDetails,
27
- } from "@xwiki/cristal-authentication-api";
27
+ } from "@xwiki/platform-authentication-api";
28
28
 
29
29
  interface AuthenticationWindow extends Window {
30
30
  authenticationGitHub: {
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  import { GitHubAuthenticationManager } from "./GitHubAuthenticationManager";
22
22
  import { GitHubAuthenticationState } from "@xwiki/cristal-authentication-github-state";
23
- import type { AuthenticationManager } from "@xwiki/cristal-authentication-api";
23
+ import type { AuthenticationManager } from "@xwiki/platform-authentication-api";
24
24
  import type { Container } from "inversify";
25
25
 
26
26
  /**
package/CHANGELOG.md DELETED
@@ -1,131 +0,0 @@
1
- # @xwiki/cristal-electron-authentication-github-renderer
2
-
3
- ## 0.23.0
4
-
5
- ### Minor Changes
6
-
7
- - Cristal 0.23 Release
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies
12
- - @xwiki/cristal-api@0.23.0
13
- - @xwiki/cristal-authentication-api@0.23.0
14
- - @xwiki/cristal-authentication-github-state@0.23.0
15
-
16
- ## 0.22.0
17
-
18
- ### Minor Changes
19
-
20
- - Cristal 0.22 Release
21
-
22
- ### Patch Changes
23
-
24
- - Updated dependencies
25
- - @xwiki/cristal-api@0.22.0
26
- - @xwiki/cristal-authentication-api@0.22.0
27
- - @xwiki/cristal-authentication-github-state@0.22.0
28
-
29
- ## 0.21.0
30
-
31
- ### Minor Changes
32
-
33
- - Cristal 0.21 Release
34
-
35
- ### Patch Changes
36
-
37
- - Updated dependencies
38
- - @xwiki/cristal-api@0.21.0
39
- - @xwiki/cristal-authentication-api@0.21.0
40
- - @xwiki/cristal-authentication-github-state@0.21.0
41
-
42
- ## 0.20.0
43
-
44
- ### Minor Changes
45
-
46
- - Cristal 0.20 Release
47
-
48
- ### Patch Changes
49
-
50
- - Updated dependencies
51
- - @xwiki/cristal-api@0.20.0
52
- - @xwiki/cristal-authentication-api@0.20.0
53
- - @xwiki/cristal-authentication-github-state@0.20.0
54
-
55
- ## 0.20.0-rc.0
56
-
57
- ### Minor Changes
58
-
59
- - Cristal 0.20-rc-1 Release
60
-
61
- ### Patch Changes
62
-
63
- - Updated dependencies
64
- - @xwiki/cristal-api@0.20.0-rc.0
65
- - @xwiki/cristal-authentication-api@0.20.0-rc.0
66
- - @xwiki/cristal-authentication-github-state@0.20.0-rc.0
67
-
68
- ## 0.19.0
69
-
70
- ### Minor Changes
71
-
72
- - 3eea53e: Cristal 0.19 Release
73
-
74
- ### Patch Changes
75
-
76
- - Updated dependencies [3eea53e]
77
- - @xwiki/cristal-api@0.19.0
78
- - @xwiki/cristal-authentication-api@0.19.0
79
- - @xwiki/cristal-authentication-github-state@0.19.0
80
-
81
- ## 0.18.0
82
-
83
- ### Minor Changes
84
-
85
- - Cristal 0.18 Release
86
-
87
- ### Patch Changes
88
-
89
- - Updated dependencies
90
- - @xwiki/cristal-api@0.18.0
91
- - @xwiki/cristal-authentication-api@0.18.0
92
- - @xwiki/cristal-authentication-github-state@0.18.0
93
-
94
- ## 0.17.0
95
-
96
- ### Minor Changes
97
-
98
- - Cristal 0.17 Release
99
-
100
- ### Patch Changes
101
-
102
- - Updated dependencies
103
- - @xwiki/cristal-api@0.17.0
104
- - @xwiki/cristal-authentication-api@0.17.0
105
- - @xwiki/cristal-authentication-github-state@0.17.0
106
-
107
- ## 0.16.0
108
-
109
- ### Minor Changes
110
-
111
- - Cristal 0.16 Release
112
-
113
- ### Patch Changes
114
-
115
- - Updated dependencies
116
- - @xwiki/cristal-api@0.16.0
117
- - @xwiki/cristal-authentication-api@0.16.0
118
- - @xwiki/cristal-authentication-github-state@0.16.0
119
-
120
- ## 0.15.0
121
-
122
- ### Minor Changes
123
-
124
- - Cristal 0.15 Release
125
-
126
- ### Patch Changes
127
-
128
- - Updated dependencies
129
- - @xwiki/cristal-api@0.15.0
130
- - @xwiki/cristal-authentication-api@0.15.0
131
- - @xwiki/cristal-authentication-github-state@0.15.0