@apolitical/auth 0.1.0 → 0.1.1-rc.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.1] - 2021-05-13
9
+ ### Fixed
10
+ - Set context function error handling
11
+
8
12
  ## [0.1.0] - 2021-05-11
9
13
  ### Changed
10
14
  - The `environment` is now defined externally
package/build/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("auth0-js")):"function"==typeof define&&define.amd?define(["auth0-js"],r):"object"==typeof exports?exports.ApoliticalAuth=r(require("auth0-js")):e.ApoliticalAuth=r(e["auth0-js"])}(this,(function(e){return function(){"use strict";var r={852:function(r){r.exports=e}},n={};function t(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,t),i.exports}t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,{a:r}),r},t.d=function(e,r){for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return function(){t.r(o),t.d(o,{passwordlessLogin:function(){return P},sendVerificationEmail:function(){return T},setContext:function(){return u}});var e=t(852),r=t.n(e),n={PLACEHOLDERS:{ORIGIN:"{{ORIGIN}}"},ENVIRONMENTS:{BETA:"beta",RC:"rc"},AUTH0:{CONNECTION:"email",DEFAULT_REDIRECT_URI:"user-onboarding/authorisation",DEFAULT_PAGE:"authorisation",RESPONSE_TYPE:"token id_token",PASSWORDLESS_LOGIN:{SIGNUP_PAGE:"signup-authorisation"},PASSWORDLESS_START:{SEND:"code",REDIRECT_URI:"signup/verify-email"},SCOPE:"openid profile email"}};const{PLACEHOLDERS:{ORIGIN:i},ENVIRONMENTS:{BETA:s,RC:c}}=n;let a=null;const u=({configs:e,environment:r,origin:n})=>{a=e[r],r!==s&&r!==c||(a.audience=a.audience.replace(i,n),a.redirectUri=a.redirectUri.replace(i,n))},E=()=>a,{AUTH0:{CONNECTION:d,DEFAULT_REDIRECT_URI:p,DEFAULT_PAGE:l,RESPONSE_TYPE:f,PASSWORDLESS_LOGIN:{SIGNUP_PAGE:S},PASSWORDLESS_START:{REDIRECT_URI:R,SEND:O},SCOPE:A}}=n,T=async e=>{const n=E(),t=new(r().WebAuth)(Object.assign({},n,{redirectUri:n.redirectUri.replace(p,R),responseType:f,scope:A}));try{return new Promise(((r,n)=>{t.passwordlessStart({connection:d,send:O,email:e.toLowerCase()},(function(e,t){e&&n(e),r(t)}))}))}catch(e){throw new Error(`Cannot start passwordless login: ${e.message}`)}},P=(e,n)=>{const t=E(),o=new(r().WebAuth)(Object.assign({},t,{redirectUri:t.redirectUri.replace(l,S),responseType:f,scope:A}));try{return new Promise(((r,t)=>{o.passwordlessLogin({connection:d,email:e,verificationCode:n},(function(e,n){e&&("access_denied"===e.code?t(new Error(`Wrong code, access denied: ${e}`)):t(new Error(e))),r(n)}))}))}catch(e){throw new Error(`Cannot complete passwordless login: ${e.message}`)}}}(),o}()}));
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("auth0-js")):"function"==typeof define&&define.amd?define(["auth0-js"],n):"object"==typeof exports?exports.ApoliticalAuth=n(require("auth0-js")):e.ApoliticalAuth=n(e["auth0-js"])}(this,(function(e){return function(){"use strict";var n={852:function(n){n.exports=e}},r={};function t(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,t),i.exports}t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return function(){t.r(o),t.d(o,{passwordlessLogin:function(){return P},sendVerificationEmail:function(){return T},setContext:function(){return u}});var e=t(852),n=t.n(e),r={PLACEHOLDERS:{ORIGIN:"{{ORIGIN}}"},ENVIRONMENTS:{BETA:"beta",RC:"rc"},AUTH0:{CONNECTION:"email",DEFAULT_REDIRECT_URI:"user-onboarding/authorisation",DEFAULT_PAGE:"authorisation",RESPONSE_TYPE:"token id_token",PASSWORDLESS_LOGIN:{SIGNUP_PAGE:"signup-authorisation"},PASSWORDLESS_START:{SEND:"code",REDIRECT_URI:"signup/verify-email"},SCOPE:"openid profile email"}};const{PLACEHOLDERS:{ORIGIN:i},ENVIRONMENTS:{BETA:s,RC:c}}=r;let a=null;const u=({configs:e,environment:n,origin:r})=>{if(!e)throw new Error("Cannot set context: REACT_APP_AUTH0_CONFIGS not defined");if(!e[n])throw new Error(`Cannot set context: REACT_APP_AUTH0_CONFIGS not defined for environment - ${JSON.stringify({configs:e,environment:n})}`);if(a=e[n],n===s||n===c){if(!r)throw new Error(`Cannot set context: Origin not defined - ${JSON.stringify(r)}`);a.audience=a.audience.replace(i,r),a.redirectUri=a.redirectUri.replace(i,r)}},E=()=>a,{AUTH0:{CONNECTION:d,DEFAULT_REDIRECT_URI:f,DEFAULT_PAGE:p,RESPONSE_TYPE:S,PASSWORDLESS_LOGIN:{SIGNUP_PAGE:l},PASSWORDLESS_START:{REDIRECT_URI:O,SEND:A},SCOPE:R}}=r,T=async e=>{const r=E(),t=new(n().WebAuth)(Object.assign({},r,{redirectUri:r.redirectUri.replace(f,O),responseType:S,scope:R}));try{return new Promise(((n,r)=>{t.passwordlessStart({connection:d,send:A,email:e.toLowerCase()},(function(e,t){e&&r(e),n(t)}))}))}catch(e){throw new Error(`Cannot start passwordless login: ${e.message}`)}},P=(e,r)=>{const t=E(),o=new(n().WebAuth)(Object.assign({},t,{redirectUri:t.redirectUri.replace(p,l),responseType:S,scope:R}));try{return new Promise(((n,t)=>{o.passwordlessLogin({connection:d,email:e,verificationCode:r},(function(e,r){e&&("access_denied"===e.code?t(new Error(`Wrong code, access denied: ${e}`)):t(new Error(e))),n(r)}))}))}catch(e){throw new Error(`Cannot complete passwordless login: ${e.message}`)}}}(),o}()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/auth",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-rc.1",
4
4
  "description": "Browser (and Node.js) library to manage authentication using Auth0",
5
5
  "author": "Apolitical Group Limited <engineering@apolitical.co>",
6
6
  "license": "MIT",