@cyphlens/2fa-sse-sdk 1.0.6 → 1.0.8
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/README.md +4 -4
- package/dist/bundle.min.js +1 -1
- package/dist/bundle.min.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -41,12 +41,12 @@ Include the SDK directly in your HTML:
|
|
|
41
41
|
|
|
42
42
|
#### 1. ES Modules (ESM) - Modern JavaScript
|
|
43
43
|
```javascript
|
|
44
|
-
import Cyphlens from "@cyphlens/2fa-sse-sdk";
|
|
44
|
+
import { Cyphlens, EventType } from "@cyphlens/2fa-sse-sdk";
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
#### 2. CommonJS (CJS) - Node.js
|
|
48
48
|
```javascript
|
|
49
|
-
const Cyphlens = require("@cyphlens/2fa-sse-sdk");
|
|
49
|
+
const { Cyphlens, EventType } = require("@cyphlens/2fa-sse-sdk");
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
#### 3. Browser (IIFE)
|
|
@@ -71,7 +71,7 @@ const cyphlensClient = new Cyphlens("https://your-api-base-url/b2b/v1");
|
|
|
71
71
|
```javascript
|
|
72
72
|
// Define the callback for handling events
|
|
73
73
|
const onData = (eventType, data) => {
|
|
74
|
-
if (eventType ===
|
|
74
|
+
if (eventType === EventType.MFASwipe) {
|
|
75
75
|
const twoFactorEvent = data;
|
|
76
76
|
console.log("2FA Status:", twoFactorEvent.status);
|
|
77
77
|
// Handle status change (e.g., update UI or trigger logic)
|
|
@@ -111,7 +111,7 @@ Stops the event listener and closes the connection.
|
|
|
111
111
|
---
|
|
112
112
|
|
|
113
113
|
## Event Types
|
|
114
|
-
- **`
|
|
114
|
+
- **`EventType.MFASwipe`**: Triggered when a 2FA swipe event occurs.
|
|
115
115
|
- **data**: `{ status: string, ... }` - Contains the event details, including the 2FA status.
|
|
116
116
|
|
|
117
117
|
---
|
package/dist/bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Cyphlens=function(){"use strict";var t,e;!function(t){t.MFASwipe="MFA.SWIPE",t.Disconnect="DISCONNECT"}(t||(t={})),function(t){t.Pending="PENDING",t.Success="SUCCESS",t.Expired="EXPIRED"}(e||(e={}));class s{constructor(t="https://api.cyphme.com/b2c/v1"){this.eventSource=null,this.timeoutId=null,this.onVisibilityChange=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&/iP(ad|od|hone)/i.test(navigator.userAgent)&&"visible"===document.visibilityState&&this.sessionID&&this.start()},this.baseUrl=t}setBaseUrl(t){this.baseUrl=t}start(){return this.sessionID?(this.stop(),this.eventSource=new EventSource(`${this.baseUrl}/cyphlens/status-events?sid=${this.sessionID}`),this.eventSource.addEventListener(t.MFASwipe,
|
|
1
|
+
var Cyphlens=function(){"use strict";var t,e;!function(t){t.MFASwipe="MFA.SWIPE",t.Disconnect="DISCONNECT"}(t||(t={})),function(t){t.Pending="PENDING",t.Success="SUCCESS",t.Expired="EXPIRED"}(e||(e={}));class s{constructor(t="https://api.cyphme.com/b2c/v1"){this.eventSource=null,this.timeoutId=null,this.onVisibilityChange=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&/iP(ad|od|hone)/i.test(navigator.userAgent)&&"visible"===document.visibilityState&&this.sessionID&&this.start()},this.baseUrl=t}setBaseUrl(t){this.baseUrl=t}start(){return this.sessionID?(this.stop(),this.eventSource=new EventSource(`${this.baseUrl}/cyphlens/status-events?sid=${this.sessionID}`),this.eventSource.addEventListener(t.MFASwipe,e=>{try{const s=JSON.parse(e.data);this.setupTimeout(s.expiresAt),this.onSuccess?.(t.MFASwipe,s)}catch(t){console.error("Error parsing event data:",t);const e=new Event("Something went wrong");this.onError?.(e)}}),this.eventSource.addEventListener("error",t=>{this.onError?.(t),this.stop()}),this.eventSource):null}setupTimeout(t){this.timeoutId&&clearTimeout(this.timeoutId);const e=t-Date.now()+5e3;this.timeoutId=setTimeout(()=>this.stop(),e)}listen(t,e,s){return this.sessionID=t,this.onSuccess=e,this.onError=s,"undefined"!=typeof document&&document.addEventListener("visibilitychange",this.onVisibilityChange),this.start()}stop(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}}return s.EventType=t,s.StatusType=e,s}();
|
|
2
2
|
//# sourceMappingURL=bundle.min.js.map
|
package/dist/bundle.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.min.js","sources":["../src/types.ts","../src/index.ts","../src/index.iife.js"],"sourcesContent":[null,null,"// we are using a separate index.iife.js file as entry point to generate bundle.min.js to have only one default export\nimport { Cyphlens, EventType, StatusType } from \"./index.ts\"\n\nCyphlens.EventType = EventType;\nCyphlens.StatusType = StatusType;\nexport default Cyphlens;\n"],"names":["EventType","StatusType","Cyphlens","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","
|
|
1
|
+
{"version":3,"file":"bundle.min.js","sources":["../src/types.ts","../src/index.ts","../src/index.iife.js"],"sourcesContent":[null,null,"// we are using a separate index.iife.js file as entry point to generate bundle.min.js to have only one default export\nimport { Cyphlens, EventType, StatusType } from \"./index.ts\"\n\nCyphlens.EventType = EventType;\nCyphlens.StatusType = StatusType;\nexport default Cyphlens;\n"],"names":["EventType","StatusType","Cyphlens","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","onSuccess","error","console","errorEvent","Event","onError","clearTimeout","timeoutDuration","Date","now","setTimeout","listen","sessionId","onData","close"],"mappings":"qCAAA,IAAYA,EAKAC,GALZ,SAAYD,GACVA,EAAA,SAAA,YACAA,EAAA,WAAA,YACD,CAHD,CAAYA,IAAAA,EAAS,CAAA,IAKrB,SAAYC,GACVA,EAAA,QAAA,UACAA,EAAA,QAAA,UACAA,EAAA,QAAA,SACD,CAJD,CAAYA,IAAAA,EAAU,CAAA,UCkBTC,EAYX,WAAAC,CAAYC,EAAkB,iCAVtBC,KAAAC,YAAkC,KAIlCD,KAAAE,UAAkD,KAwGzCF,KAAAG,mBAAqB,KACb,iCAAiCC,KAAKC,UAAUC,YACjD,kBAAkBF,KAAKC,UAAUC,YACJ,YAA7BC,SAASC,iBAAiCR,KAAKS,WACnET,KAAKU,SArGPV,KAAKD,QAAUA,CACjB,CAMA,UAAAY,CAAWZ,GACTC,KAAKD,QAAUA,CACjB,CAMQ,KAAAW,GACN,OAAKV,KAAKS,WAEVT,KAAKY,OAELZ,KAAKC,YAAc,IAAIY,YAAY,GAAGb,KAAKD,sCAAsCC,KAAKS,aAGtFT,KAAKC,YAAYa,iBAAiBnB,EAAUoB,SAAWC,IACrD,IACE,MAAMC,EAAuBC,KAAKC,MAAMH,EAAMC,MAC9CjB,KAAKoB,aAAaH,EAAKI,WACvBrB,KAAKsB,YAAY3B,EAAUoB,SAAUE,EACvC,CAAE,MAAOM,GACPC,QAAQD,MAAM,4BAA6BA,GAC3C,MAAME,EAAa,IAAIC,MAAM,wBAC7B1B,KAAK2B,UAAUF,EACjB,IAIFzB,KAAKC,YAAYa,iBAAiB,QAAUE,IAC1ChB,KAAK2B,UAAUX,GACfhB,KAAKY,SAGAZ,KAAKC,aAzBgB,IA0B9B,CAMQ,YAAAmB,CAAaC,GACfrB,KAAKE,WACP0B,aAAa5B,KAAKE,WAIpB,MAAM2B,EAAkBR,EAAYS,KAAKC,MAAQ,IACjD/B,KAAKE,UAAY8B,WAAW,IAAMhC,KAAKY,OAAQiB,EACjD,CASA,MAAAI,CAAOC,EAAmBC,EAAwBR,GAUhD,OATA3B,KAAKS,UAAYyB,EACjBlC,KAAKsB,UAAYa,EACjBnC,KAAK2B,QAAUA,EAGS,oBAAbpB,UACTA,SAASO,iBAAiB,mBAAoBd,KAAKG,oBAG9CH,KAAKU,OACd,CAKA,IAAAE,GACMZ,KAAKC,cACPD,KAAKC,YAAYmC,QACjBpC,KAAKC,YAAc,MAEjBD,KAAKE,YACP0B,aAAa5B,KAAKE,WAClBF,KAAKE,UAAY,KAErB,SC3HFL,EAASF,UAAYA,EACrBE,EAASD,WAAaA"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t,e;!function(t){t.MFASwipe="MFA.SWIPE",t.Disconnect="DISCONNECT"}(t||(t={})),function(t){t.Pending="PENDING",t.Success="SUCCESS",t.Expired="EXPIRED"}(e||(e={}));class s{constructor(t="https://api.cyphme.com/b2c/v1"){this.eventSource=null,this.timeoutId=null,this.onVisibilityChange=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&/iP(ad|od|hone)/i.test(navigator.userAgent)&&"visible"===document.visibilityState&&this.sessionID&&this.start()},this.baseUrl=t}setBaseUrl(t){this.baseUrl=t}start(){return this.sessionID?(this.stop(),this.eventSource=new EventSource(`${this.baseUrl}/cyphlens/status-events?sid=${this.sessionID}`),this.eventSource.addEventListener(t.MFASwipe,
|
|
1
|
+
var t,e;!function(t){t.MFASwipe="MFA.SWIPE",t.Disconnect="DISCONNECT"}(t||(t={})),function(t){t.Pending="PENDING",t.Success="SUCCESS",t.Expired="EXPIRED"}(e||(e={}));class s{constructor(t="https://api.cyphme.com/b2c/v1"){this.eventSource=null,this.timeoutId=null,this.onVisibilityChange=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&/iP(ad|od|hone)/i.test(navigator.userAgent)&&"visible"===document.visibilityState&&this.sessionID&&this.start()},this.baseUrl=t}setBaseUrl(t){this.baseUrl=t}start(){return this.sessionID?(this.stop(),this.eventSource=new EventSource(`${this.baseUrl}/cyphlens/status-events?sid=${this.sessionID}`),this.eventSource.addEventListener(t.MFASwipe,e=>{try{const s=JSON.parse(e.data);this.setupTimeout(s.expiresAt),this.onSuccess?.(t.MFASwipe,s)}catch(t){console.error("Error parsing event data:",t);const e=new Event("Something went wrong");this.onError?.(e)}}),this.eventSource.addEventListener("error",t=>{this.onError?.(t),this.stop()}),this.eventSource):null}setupTimeout(t){this.timeoutId&&clearTimeout(this.timeoutId);const e=t-Date.now()+5e3;this.timeoutId=setTimeout(()=>this.stop(),e)}listen(t,e,s){return this.sessionID=t,this.onSuccess=e,this.onError=s,"undefined"!=typeof document&&document.addEventListener("visibilitychange",this.onVisibilityChange),this.start()}stop(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}}export{s as Cyphlens,t as EventType,e as StatusType};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["EventType","StatusType","Cyphlens","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["EventType","StatusType","Cyphlens","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","onSuccess","error","console","errorEvent","Event","onError","clearTimeout","timeoutDuration","Date","now","setTimeout","list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,GAUhD,OATA3B,KAAKS,UAAYyB,EACjBlC,KAAKsB,UAAYa,EACjBnC,KAAK2B,QAAUA,EAGS,oBAAbpB,UACTA,SAASO,iBAAiB,mBAAoBd,KAAKG,oBAG9CH,KAAKU,OACd,CAKA,IAAAE,GACMZ,KAAKC,cACPD,KAAKC,YAAYmC,QACjBpC,KAAKC,YAAc,MAEjBD,KAAKE,YACP0B,aAAa5B,KAAKE,WAClBF,KAAKE,UAAY,KAErB"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t,e;exports.EventType=void 0,(t=exports.EventType||(exports.EventType={})).MFASwipe="MFA.SWIPE",t.Disconnect="DISCONNECT",exports.StatusType=void 0,(e=exports.StatusType||(exports.StatusType={})).Pending="PENDING",e.Success="SUCCESS",e.Expired="EXPIRED";exports.Cyphlens=class{constructor(t="https://api.cyphme.com/b2c/v1"){this.eventSource=null,this.timeoutId=null,this.onVisibilityChange=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&/iP(ad|od|hone)/i.test(navigator.userAgent)&&"visible"===document.visibilityState&&this.sessionID&&this.start()},this.baseUrl=t}setBaseUrl(t){this.baseUrl=t}start(){return this.sessionID?(this.stop(),this.eventSource=new EventSource(`${this.baseUrl}/cyphlens/status-events?sid=${this.sessionID}`),this.eventSource.addEventListener(exports.EventType.MFASwipe,
|
|
1
|
+
"use strict";var t,e;exports.EventType=void 0,(t=exports.EventType||(exports.EventType={})).MFASwipe="MFA.SWIPE",t.Disconnect="DISCONNECT",exports.StatusType=void 0,(e=exports.StatusType||(exports.StatusType={})).Pending="PENDING",e.Success="SUCCESS",e.Expired="EXPIRED";exports.Cyphlens=class{constructor(t="https://api.cyphme.com/b2c/v1"){this.eventSource=null,this.timeoutId=null,this.onVisibilityChange=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&/iP(ad|od|hone)/i.test(navigator.userAgent)&&"visible"===document.visibilityState&&this.sessionID&&this.start()},this.baseUrl=t}setBaseUrl(t){this.baseUrl=t}start(){return this.sessionID?(this.stop(),this.eventSource=new EventSource(`${this.baseUrl}/cyphlens/status-events?sid=${this.sessionID}`),this.eventSource.addEventListener(exports.EventType.MFASwipe,t=>{try{const e=JSON.parse(t.data);this.setupTimeout(e.expiresAt),this.onSuccess?.(exports.EventType.MFASwipe,e)}catch(t){console.error("Error parsing event data:",t);const e=new Event("Something went wrong");this.onError?.(e)}}),this.eventSource.addEventListener("error",t=>{this.onError?.(t),this.stop()}),this.eventSource):null}setupTimeout(t){this.timeoutId&&clearTimeout(this.timeoutId);const e=t-Date.now()+5e3;this.timeoutId=setTimeout(()=>this.stop(),e)}listen(t,e,s){return this.sessionID=t,this.onSuccess=e,this.onError=s,"undefined"!=typeof document&&document.addEventListener("visibilitychange",this.onVisibilityChange),this.start()}stop(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["EventType","StatusType","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["EventType","StatusType","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","onSuccess","error","console","errorEvent","Event","onError","clearTimeout","timeoutDuration","Date","now","setTimeout","listen","sessionId","onData","close"],"mappings":"aAAA,IAAYA,EAKAC,EALAD,QAAAA,eAAA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KAAKsB,UAAYa,EACjBnC,KAAK2B,QAAUA,EAGS,oBAAbpB,UACTA,SAASO,iBAAiB,mBAAoBd,KAAKG,oBAG9CH,KAAKU,OACd,CAKA,IAAAE,GACMZ,KAAKC,cACPD,KAAKC,YAAYmC,QACjBpC,KAAKC,YAAc,MAEjBD,KAAKE,YACP0B,aAAa5B,KAAKE,WAClBF,KAAKE,UAAY,KAErB"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Cyphlens={})}(this,
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Cyphlens={})}(this,function(t){"use strict";var e,s;t.EventType=void 0,(e=t.EventType||(t.EventType={})).MFASwipe="MFA.SWIPE",e.Disconnect="DISCONNECT",t.StatusType=void 0,(s=t.StatusType||(t.StatusType={})).Pending="PENDING",s.Success="SUCCESS",s.Expired="EXPIRED";t.Cyphlens=class{constructor(t="https://api.cyphme.com/b2c/v1"){this.eventSource=null,this.timeoutId=null,this.onVisibilityChange=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&/iP(ad|od|hone)/i.test(navigator.userAgent)&&"visible"===document.visibilityState&&this.sessionID&&this.start()},this.baseUrl=t}setBaseUrl(t){this.baseUrl=t}start(){return this.sessionID?(this.stop(),this.eventSource=new EventSource(`${this.baseUrl}/cyphlens/status-events?sid=${this.sessionID}`),this.eventSource.addEventListener(t.EventType.MFASwipe,e=>{try{const s=JSON.parse(e.data);this.setupTimeout(s.expiresAt),this.onSuccess?.(t.EventType.MFASwipe,s)}catch(t){console.error("Error parsing event data:",t);const e=new Event("Something went wrong");this.onError?.(e)}}),this.eventSource.addEventListener("error",t=>{this.onError?.(t),this.stop()}),this.eventSource):null}setupTimeout(t){this.timeoutId&&clearTimeout(this.timeoutId);const e=t-Date.now()+5e3;this.timeoutId=setTimeout(()=>this.stop(),e)}listen(t,e,s){return this.sessionID=t,this.onSuccess=e,this.onError=s,"undefined"!=typeof document&&document.addEventListener("visibilitychange",this.onVisibilityChange),this.start()}stop(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}}});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["EventType","StatusType","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["EventType","StatusType","constructor","baseUrl","this","eventSource","timeoutId","onVisibilityChange","test","navigator","userAgent","document","visibilityState","sessionID","start","setBaseUrl","stop","EventSource","addEventListener","MFASwipe","event","data","JSON","parse","setupTimeout","expiresAt","onSuccess","error","console","errorEvent","Event","onError","clearTimeout","timeoutDuration","Date","now","setTimeout","listen","sessionId","onData","close"],"mappings":"+OAAA,IAAYA,EAKAC,EALAD,EAAAA,eAAAA,GAAAA,EAAAA,EAAAA,YAAAA,YAAS,CAAA,IACnB,SAAA,YACAA,EAAA,WAAA,aAGUC,EAAAA,gBAAAA,GAAAA,EAAAA,EAAAA,aAAAA,aAAU,CAAA,IACpB,QAAA,UACAA,EAAA,QAAA,UACAA,EAAA,QAAA,2BC2BA,WAAAC,CAAYC,EAAkB,iCAVtBC,KAAAC,YAAkC,KAIlCD,KAAAE,UAAkD,KAwGzCF,KAAAG,mBAAqB,KACb,iCA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
|
|
|
1
1
|
import { EventCallback, TwoFactorEvent, EventType, CyphlensErrorCallback, StatusType, DisconnectEvent, CyphlensEvent } from './types';
|
|
2
|
-
export {
|
|
2
|
+
export { EventType, StatusType };
|
|
3
|
+
export type { EventCallback, TwoFactorEvent, CyphlensErrorCallback, DisconnectEvent, CyphlensEvent };
|
|
3
4
|
export declare class Cyphlens {
|
|
4
5
|
private baseUrl;
|
|
5
6
|
private eventSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,SAAS,EACT,UAAU,EACX,CAAC;AAEF,YAAY,EACV,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,aAAa,EACd,CAAA;AAED,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAC,CAAgB;IAClC,OAAO,CAAC,OAAO,CAAC,CAAwB;IACxC,OAAO,CAAC,SAAS,CAA8C;IAE/D;;;OAGG;gBACS,OAAO,GAAE,MAAwC;IAI7D;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;;OAGG;IACH,OAAO,CAAC,KAAK;IA6Bb;;;OAGG;IACH,OAAO,CAAC,YAAY;IAUpB;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,WAAW,GAAG,IAAI;IAatG;;OAEG;IACH,IAAI,IAAI,IAAI;IAWZ;;;;KAIC;IACD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAMjC;CACD;AAEH,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,OAAO,QAAQ,CAAC;IAC1B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,eAAe,CAAC;IACjC,aAAa,EAAE,aAAa,CAAC;IAC7B,qBAAqB,EAAE,qBAAqB,CAAC;CAC9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyphlens/2fa-sse-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Cyphlens SDK for 2FA SSE",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
8
|
-
"browser": "dist/bundle.
|
|
8
|
+
"browser": "dist/bundle.esm.js",
|
|
9
9
|
"types": "dist/types/index.d.ts",
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "restricted"
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist/"
|
|
15
15
|
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.esm.js",
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"types": "./dist/types/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./browser": "./dist/bundle.esm.js"
|
|
23
|
+
},
|
|
16
24
|
"scripts": {
|
|
17
25
|
"build": "rollup -c",
|
|
18
26
|
"test": "jest --coverage"
|