{"_id":"@almight-sdk/auth","name":"@almight-sdk/auth","dist-tags":{"canary":"0.0.1-alpha.98","latest":"0.0.1-alpha.98"},"versions":{"0.0.1-alpha.98":{"name":"@almight-sdk/auth","version":"0.0.1-alpha.98","publishConfig":{"access":"public"},"description":"> TODO: description","author":{"name":"Piyush Jaiswal","email":"iampiyushjaiswal103@gmail.com"},"homepage":"https://github.com/Byta-Tigris/almight-js#readme","private":false,"license":"ISC","main":"lib/index.js","typings":"lib/index.d.ts","directories":{"lib":"lib","test":"__tests__"},"repository":{"type":"git","url":"git+https://github.com/Byta-Tigris/almight-js.git"},"scripts":{"test":"env TS_NODE_PROJECT=\"tsconfig.json\" mocha --exit -r ts-node/register","tsc":"tsc"},"bugs":{"url":"https://github.com/Byta-Tigris/almight/issues"},"dependencies":{"@almight-sdk/connector":"^0.0.1-alpha.98+a13a035","@almight-sdk/core":"^0.0.1-alpha.98+a13a035","@almight-sdk/utils":"^0.0.1-alpha.98+a13a035","axios":"^0.27.2","bn.js":"^5.2.1","dotenv":"^16.0.1"},"gitHead":"a13a03528b4249d3e4d93d4dd5be8f090ddb0d0a","_id":"@almight-sdk/auth@0.0.1-alpha.98","_nodeVersion":"16.14.0","_npmVersion":"lerna/4.0.0/node@v16.14.0+x64 (linux)","dist":{"integrity":"sha512-RAor5TbKBWl7Qi4XDX/iVCPYIdvBXuf7AgSXWcz9iK8DVDmApSi+WDOFnq+TqjG3liEpekMxRXszhOGN9usXCg==","shasum":"f4c42b169e6624e540de0c7a8c4b91bb14dbb307","tarball":"https://registry.npmjs.org/@almight-sdk/auth/-/auth-0.0.1-alpha.98.tgz","fileCount":33,"unpackedSize":104947,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID8ogPfzlu3qFau1C2phGJhzrxKPDg+34IoaA29+zcSqAiBxrpmgaqtAA+rLsGv6ESPyWdYijxG/nCklub+xOwK7yQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJin9YWACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmouVw//faPFMd311QNAL2vt7zddBb2bSWo4xgxTiPiOmpCFIbbc6cAg\r\nasnUt5q8VyiEEAYEgjCiGxCJaoWVdOYbVsyRZjJmnSbEWC+w9JyjiqnBfsw4\r\nBoCXhsuMgHj/9U2tFUC6i6ONvJPjwXRvQYEE/9iwbi0aAEPjd43S2CkxG89H\r\n7z4tLBR3QKvm2a57XbbA8riVjc+FdSg45beAcMeapDptQT7yUwqHR8OkPv+7\r\nUo9Ks9fwNoIuOE9FHloLs1nZy5ZjrBh+sRYP6P84TDHx+ptCkX+WJ25bwG4+\r\n6J6LzEBcrUqRd4ChM03j4WnI47HnYW8FbIq1ZDQaLom/VpREArrruAkaPkNb\r\nzeeJf3IaOXeYXXgg4oSXIsLmWrYoYtGWk8xiwH9vaIONaK0smkdlV7IxTHzu\r\nJ2T1/84rDYFUiKWiehXMl3VDc9ACxuqR4/qAxb/O3Rr/huwE3W4Aq7qN4+fd\r\ncBqxAn+Xwf9DmkfXd4zy2aC1vD+jauisLAlnKUizSyvs8yx2XchO02bva9UR\r\n215odhuC1f32WJ01/eSQfmx2lOWq0yxZhBHyYfYeIM/z5eP11UXq3j1r2kcG\r\n1Rws6TbUmgqUGCpogG1Hl1bseWKhCHQAAapzVvc6Arh8BRnQ4NMlMu5E1oZF\r\nobA/GbY77Eb3Ogew3TzbmLiYLsZEZpkd8rM=\r\n=fkXj\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"piyushjaiswal103","email":"bytatigrisdev@gmail.com"},"maintainers":[{"name":"piyushjaiswal103","email":"bytatigrisdev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth_0.0.1-alpha.98_1654642198132_0.6529432672830116"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-07T22:49:58.065Z","0.0.1-alpha.98":"2022-06-07T22:49:58.334Z","modified":"2022-06-07T22:49:58.466Z"},"maintainers":[{"name":"piyushjaiswal103","email":"bytatigrisdev@gmail.com"}],"description":"> TODO: description","homepage":"https://github.com/Byta-Tigris/almight-js#readme","repository":{"type":"git","url":"git+https://github.com/Byta-Tigris/almight-js.git"},"author":{"name":"Piyush Jaiswal","email":"iampiyushjaiswal103@gmail.com"},"bugs":{"url":"https://github.com/Byta-Tigris/almight/issues"},"license":"ISC","readme":"# `All-In-One Authentication System`\n\n\n\n### Implementation of Authentication System on web\n\n```ts\nimport {Iframe, User} from \"almight-sdk/auth\";\nimport {WebWalletConnector} from \"almight-sdk/connector\";\nimport {WebStorage} from \"almight-sdk/utils/storage\";\n\n// Typescript code for authentication implementation on web\n// Initialise the AlmightApp \nconst app = new AlmightApp(apiKey:\"\");\n\n\nconst auth_app = new AuthenticationApp({\n    app: app, //AlmightApp\n    frame: Iframe, // Iframe will be spawned for authentication\n    storage: WebStorage, // Storage API which is used to store authentication datas\n    //Wallet connector that provides API for wallet communication from  web\n    walletConnector: WebWalletConnector,\n    onSuccess: (user: User) => {\n        // code after successful authentication\n    },\n    onError: (error: Error) => {\n        // code for error handling\n    }\n});\n\n```\n\nThe Authentication flow will be decided by the _*Provider*_ provided in the `auth_app.authenticateWithProvider` function. \nThe function will start an  `Popup iframe` for authentication. In case of Web2 sign-in such as Google Signin, Fb Signin, Github Signin, Twitter Signin the default OAuth method of authentication will be implemented to authenticate the user. \nIn case of Web3 wallet based authentications, `WebWalletConnector` will be used to establish connection with the wallet. \n* If the Dapp is running on **desktop browser**, it will show options to connect using browser extension or QR scan.\n* If the Dapp is running on **mobile browser**, it will show options to connect using `deeplinks` or QR scan\n* In case of native mobile apps, `CustomeChromeTab` or `SafariViewController` will be used to replace iframe and authentication flow of **mobile browser** will be followed\n\n```ts\n// Starting the authentication flow for Web2 Google Sign-in or Web3 Wallet sign-in\n\n\nauth_app.authenticateWithProvider(Providers.Google);\n\n// The authentication app will verify the user's identification.\n// upon successfull identification the JWT of the user will stored in the cookie\n// User's meta-data such as email, name and image_url will be stored in Session storage\n// And onSuccess callback will be called with user data as argument\n\n// On authentication failure the error message will be delivered to the user\n// through onError callback\n\n```\n\n```ts\n// Whenever a user re-visits on the Dapp\n// isAuthenticated API must be implemented to check if the user is authenticated\n// isAuthenticated API will also pull the user's meta-data and will store in the Session storage\nconst isAuthenticated = await auth_app.isAuthenticated();\n```\n\nThe Implementation for authentication will work perfectly on react-native after  adding permissions and config files to user Storage and ChromeCustomTab or SafariViewController and replacing\n* `Iframe` to `ReactNativeFrame` (which will determine to use ChromeCustomTab or SafariViewController )\n* `WebStorage` to `ReactNativeStorage`\n\nAnd they'll need to add\n```ts\n// This method will bind an even listener to capture response from ChromeCustomTab or SafariViewController\nauth_app.bindReactNativeIntentListener(Linking);\n```\n\n","readmeFilename":"README.md"}