{"_id":"@awesome-cordova-library/oidc","name":"@awesome-cordova-library/oidc","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@awesome-cordova-library/oidc","version":"1.0.0","description":"OIDC cordova plugin.","main":"lib/index.js","types":"lib/index.d.ts","keywords":["cordova","capacitor","ionic","javascript","typescript","mobile","oidc","auth"],"publishConfig":{"access":"public"},"author":{"name":"Jordan AZOULAY","email":"jazoulay@joazco.com","url":"https://github.com/joazco"},"license":"SEE LICENSE IN LICENSE","repository":{"type":"git","url":"git://github.com/joazco/awesome-cordova-library.git"},"bugs":{"url":"https://github.com/joazco/awesome-cordova-library/issues"},"homepage":"https://github.com/joazco/awesome-cordova-library","devDependencies":{"@types/jest":"^27.5.1","@types/react":"~17.0.21","jest":"^28.1.0","prettier":"^2.6.2","ts-jest":"^28.0.3","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^4.7.2"},"scripts":{"build":"rm -rf lib/ && tsc","build-yalc":"npm run build; yalc publish --push --private","test":"jest --config jestconfig.json","format":"prettier --write \"./src/**/*.ts\"","lint":"tslint -p tsconfig.json","prepublish":"npm run format; npm run lint; npm test; npm run build"},"directories":{"lib":"lib"},"dependencies":{},"gitHead":"2a2b9cf007a870056251632315547e6a651d26a0","_id":"@awesome-cordova-library/oidc@1.0.0","_nodeVersion":"16.20.0","_npmVersion":"8.19.4","dist":{"integrity":"sha512-uiYl68HURpA+JPG9lwWHr+V2AVYhDny3mba4RGbBrpGZmUCKC2HmAJyrfU+AfDqJuQ+ziGr7igIcyFYw72BcoA==","shasum":"52d32dac7016129dd842eb2a275deb9ac3fef8cd","tarball":"https://registry.npmjs.org/@awesome-cordova-library/oidc/-/oidc-1.0.0.tgz","fileCount":7,"unpackedSize":12645,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBlesx3rxP4aVDfTokoqAfwq1G2jDcC8DQtnEYZxezYLAiEA0XXVAX0FFEPOu4v+NzjUgCLWFzpdkXxAYa83xJaFEuk="}]},"_npmUser":{"name":"joazco","email":"jazoulay@joazco.com"},"maintainers":[{"name":"joazco","email":"jazoulay@joazco.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oidc_1.0.0_1694507112899_0.14710584773101876"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-12T08:25:12.809Z","1.0.0":"2023-09-12T08:25:13.076Z","modified":"2023-09-12T08:25:13.447Z"},"maintainers":[{"name":"joazco","email":"jazoulay@joazco.com"}],"description":"OIDC cordova plugin.","homepage":"https://github.com/joazco/awesome-cordova-library","keywords":["cordova","capacitor","ionic","javascript","typescript","mobile","oidc","auth"],"repository":{"type":"git","url":"git://github.com/joazco/awesome-cordova-library.git"},"author":{"name":"Jordan AZOULAY","email":"jazoulay@joazco.com","url":"https://github.com/joazco"},"bugs":{"url":"https://github.com/joazco/awesome-cordova-library/issues"},"license":"SEE LICENSE IN LICENSE","readme":"---\nid: oidc\ntitle: OIDC\ntags:\n  - cordova\n  - capacitor\n  - ionic\n  - javascript\n  - typescript\n  - plugin\n  - oidc\n  - auth\n---\n\n# OIDC\n\n[Online documentation](https://awesomecordovalibrary.com)\n\n[Github documentation](https://github.com/mi-corporation/cordova-plugin-oidc-basic)\n\n## Installation\n\n### Cordova\n\n```bash\ncordova plugin add https://github.com/mi-corporation/cordova-plugin-oidc-basic.git --variable ANDROID_REDIRECT_SCHEME=com.example.myapp\nnpm install @awesome-cordova-library/oidc\n```\n\n### Capacitor / Ionic\n\n```bash\nnpm install https://github.com/mi-corporation/cordova-plugin-oidc-basic.git\nnpm install @awesome-cordova-library/oidc\nnpx cap sync\n```\n\n## Vanilla\n\n### Declaration\n\n```typescript\nexport declare type OIDCRequest = {\n  configuration: {\n    authorizationEndpoint: string;\n  };\n  clientId: string;\n  scope: string;\n  state: string;\n  redirectUrl: string;\n  responseType: string;\n  accesTokenExpirationDate: number;\n  tokenType: string;\n  idToken: string;\n  additionalParameters: string;\n  nonce: string;\n  codeVerifier: string;\n  codeChallenge: string;\n  codeChallengeMethod: string;\n  error: string;\n  errorDescription: string;\n  errorUrl: string;\n  idTokenHint: string;\n  postLogoutRedirectUrl: string;\n};\nexport declare type ErrorType = {\n  UNSENDABLE_REQUEST: 'OIDC_UNSENDABLE_REQUEST';\n  ERROR_RESPONSE: 'OIDC_ERROR_RESPONSE';\n  INVALID_RESPONSE: 'OIDC_INVALID_RESPONSE';\n  HTTP_ERROR: 'OIDC_HTTP_ERROR';\n  USER_CANCELLED: 'OIDC_USER_CANCELLED';\n  UNEXPECTED_ERROR: 'OIDC_UNEXPECTED_ERROR';\n};\n/**\n * @author AZOULAY Jordan<jazoulay@joazco.com>\n * OIDC Cordova plugin\n * Also, check out {@link https://github.com/mi-corporation/cordova-plugin-oidc-basic Github}\n * @requires module:https://github.com/mi-corporation/cordova-plugin-oidc-basic.git\n */\nexport default class OIDC {\n  static presentAuthorizationRequest(\n    req: Partial<OIDCRequest>,\n    success: (response: Partial<OIDCRequest>) => void,\n    error: (error: { message: string; oidcType: string; oidcDetails: string; oidcResponse: string }) => void,\n  ): void;\n  static presentEndSessionRequest(\n    req: Partial<OIDCRequest>,\n    success: (response: Partial<OIDCRequest>) => void,\n    error: (error: { message: string; oidcType: string; oidcDetails: string }) => void,\n  ): void;\n  static warnPluginIsUnInstallOrIncompatible(): void;\n}\n```\n\n### Usages\n\n```typescript\nimport OIDC from '@awesome-cordova-library/oidc';\nvar req = {\n  configuration: {\n    authorizationEndpoint: 'https://my-authorization-endpoint/authorize',\n  },\n  clientId: 'my-client-id',\n  scope: 'openid',\n  state: 'my-state', // or leave absent and the plugin will generate random state by default\n  redirectUrl: 'my-redirect-url', // see notes on redirectUrl below\n  responseType: 'code', // authorization code flow\n};\n// Initiate authorization request\nOIDC.presentAuthorizationRequest(\n  req,\n  function (resp) {\n    // Success\n    // Use the following info to perform your token request:\n    // resp.authorizationCode -- The authorization code\n    // resp.request.codeVerifier -- The codeVerifier. Generated by the plugin (currently no option to pass in or disable PKCE). Needed as part of the token request.\n    // resp.request.nonce -- The nonce. Generated by the plugin (currently no option to pass in or disable). Needed as part of ID token validation.\n  },\n  function (err) {\n    // Error. Inspect err.oidcType to see what kind. See below for more on errors and error types.\n    // Example of handling a specific error type:\n    if (err.oidcType === cordova.plugins.oidc.basic.ErrorType.USER_CANCELLED) {\n      // User cancelled the authorizationr request\n    }\n    // Can handle other error types as needed\n  },\n);\n```\n\n## React\n\n### Declaration\n\n```typescript\nconst useOIDC: () => {\n  presentAuthorizationRequest: (req: Partial<OIDCRequest>) => Promise<Partial<OIDCRequest>>;\n  presentEndSessionRequest: (req: Partial<OIDCRequest>) => Promise<Partial<OIDCRequest>>;\n};\n```\n\n### Usages\n\n```typescript\nimport { useMemo } from 'react';\nimport useOIDC from '@awesome-cordova-library/oidc/lib/react';\n\nfunction App() {\n  const req = useMemo(\n    {\n      configuration: {\n        authorizationEndpoint: 'https://my-authorization-endpoint/authorize',\n      },\n      clientId: 'my-client-id',\n      scope: 'openid',\n      state: 'my-state', // or leave absent and the plugin will generate random state by default\n      redirectUrl: 'my-redirect-url', // see notes on redirectUrl below\n      responseType: 'code', // authorization code flow\n    },\n    [],\n  );\n  const { presentAuthorizationRequest } = useOIDC();\n\n  return (\n    <button\n      onClick={() =>\n        presentAuthorizationRequest(req)\n          .then((resp) => {\n            // Success\n            // Use the following info to perform your token request:\n            // resp.authorizationCode -- The authorization code\n            // resp.request.codeVerifier -- The codeVerifier. Generated by the plugin (currently no option to pass in or disable PKCE). Needed as part of the token request.\n            // resp.request.nonce -- The nonce. Generated by the plugin (currently no option to pass in or disable). Needed as part of ID token validation.\n          })\n          .catch((err) => {\n            // Error. Inspect err.oidcType to see what kind. See below for more on errors and error types.\n            // Example of handling a specific error type:\n            if (err.oidcType === cordova.plugins.oidc.basic.ErrorType.USER_CANCELLED) {\n              // User cancelled the authorizationr request\n            }\n            // Can handle other error types as needed\n          })\n      }\n    >\n      Login\n    </button>\n  );\n}\n```\n","readmeFilename":"README.md"}