@frontegg/ionic-capacitor 0.0.4

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.
@@ -0,0 +1,21 @@
1
+ import type { ListenerCallback, PluginListenerHandle } from '@capacitor/core';
2
+ import type { IUserProfile } from '@frontegg/rest-api';
3
+ export declare type User = IUserProfile;
4
+ export interface FronteggState {
5
+ accessToken: string | null;
6
+ refreshToken: string | null;
7
+ isAuthenticated: boolean;
8
+ user: User | null;
9
+ showLoader: boolean;
10
+ }
11
+ export declare type SubscribeFunc<T, K extends keyof T> = (value: T[K]) => void;
12
+ export declare type SubscribeMap<T> = {
13
+ [K in keyof T]: Set<SubscribeFunc<T, K>>;
14
+ };
15
+ export interface FronteggNativePlugin {
16
+ login(): void;
17
+ logout(): void;
18
+ addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle> & PluginListenerHandle;
19
+ getConstants(): Promise<Record<string, string>>;
20
+ getAuthState(): Promise<FronteggState>;
21
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ListenerCallback, PluginListenerHandle } from '@capacitor/core';\nimport type { IUserProfile } from '@frontegg/rest-api';\n\n\nexport type User = IUserProfile\nexport interface FronteggState {\n accessToken: string | null;\n refreshToken: string | null;\n isAuthenticated: boolean;\n user: User | null;\n showLoader: boolean;\n}\n\n\nexport type SubscribeFunc<T, K extends keyof T> = (value: T[K]) => void\nexport type SubscribeMap<T> = {\n [K in keyof T]: Set<SubscribeFunc<T, K>>\n}\n\n\nexport interface FronteggNativePlugin {\n login(): void;\n\n logout(): void;\n\n addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle> & PluginListenerHandle\n\n getConstants(): Promise<Record<string, string>>;\n\n getAuthState(): Promise<FronteggState>;\n\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { FronteggState } from './definitions';
2
+ export declare class FronteggService {
3
+ private state;
4
+ private mapListeners;
5
+ constructor();
6
+ getState(): FronteggState;
7
+ get $isLoading(): {
8
+ value: boolean;
9
+ subscribe(listener: import("./definitions").SubscribeFunc<FronteggState, "showLoader">): () => void;
10
+ };
11
+ get $isAuthenticated(): {
12
+ value: boolean;
13
+ subscribe(listener: import("./definitions").SubscribeFunc<FronteggState, "isAuthenticated">): () => void;
14
+ };
15
+ get $user(): {
16
+ value: import("@frontegg/rest-api").IGetUsersV2Response | null;
17
+ subscribe(listener: import("./definitions").SubscribeFunc<FronteggState, "user">): () => void;
18
+ };
19
+ get $accessToken(): {
20
+ value: string | null;
21
+ subscribe(listener: import("./definitions").SubscribeFunc<FronteggState, "accessToken">): () => void;
22
+ };
23
+ /**
24
+ * Call frontegg native login method
25
+ */
26
+ login(): void;
27
+ logout(): void;
28
+ }
@@ -0,0 +1,71 @@
1
+ import { createObservable } from './observables';
2
+ import { registerPlugin } from '@capacitor/core';
3
+ const FronteggNative = registerPlugin('FronteggNative', {
4
+ web: () => import('./web').then(m => new m.FronteggNativeWeb()),
5
+ });
6
+ export class FronteggService {
7
+ constructor() {
8
+ this.state = {
9
+ isAuthenticated: false,
10
+ showLoader: true,
11
+ user: null,
12
+ accessToken: null,
13
+ refreshToken: null,
14
+ };
15
+ this.mapListeners = {
16
+ 'isAuthenticated': new Set(),
17
+ 'showLoader': new Set(),
18
+ 'user': new Set(),
19
+ 'accessToken': new Set(),
20
+ 'refreshToken': new Set(),
21
+ };
22
+ FronteggNative.addListener('onFronteggAuthEvent', (state) => {
23
+ console.log('onFronteggAuthEvent', state);
24
+ const keys = Object.keys(this.mapListeners);
25
+ for (let i = 0; i < keys.length; i++) {
26
+ const key = keys[i];
27
+ if (this.state[key] !== state[key]) {
28
+ console.log('onFronteggAuthEvent key: ', key, 'from:', this.state[key], 'to:', state[key]);
29
+ this.mapListeners[key].forEach((listener) => listener(state[key]));
30
+ }
31
+ }
32
+ this.state = state;
33
+ });
34
+ FronteggNative.getAuthState().then((state) => {
35
+ console.log('getAuthState()', state);
36
+ const keys = Object.keys(this.mapListeners);
37
+ for (let i = 0; i < keys.length; i++) {
38
+ const key = keys[i];
39
+ if (this.state[key] !== state[key]) {
40
+ this.mapListeners[key].forEach((listener) => listener(state[key]));
41
+ }
42
+ }
43
+ this.state = state;
44
+ });
45
+ }
46
+ getState() {
47
+ return this.state;
48
+ }
49
+ get $isLoading() {
50
+ return createObservable(this.mapListeners, this.state, 'showLoader');
51
+ }
52
+ get $isAuthenticated() {
53
+ return createObservable(this.mapListeners, this.state, 'isAuthenticated');
54
+ }
55
+ get $user() {
56
+ return createObservable(this.mapListeners, this.state, 'user');
57
+ }
58
+ get $accessToken() {
59
+ return createObservable(this.mapListeners, this.state, 'accessToken');
60
+ }
61
+ /**
62
+ * Call frontegg native login method
63
+ */
64
+ login() {
65
+ FronteggNative.login();
66
+ }
67
+ logout() {
68
+ FronteggNative.logout();
69
+ }
70
+ }
71
+ //# sourceMappingURL=frontegg.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontegg.service.js","sourceRoot":"","sources":["../../src/frontegg.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAChE,CAAC,CAAC;AAGH,MAAM,OAAO,eAAe;IAI1B;QACE,IAAI,CAAC,KAAK,GAAG;YACX,eAAe,EAAE,KAAK;YACtB,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,I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IAC1B,CAAC;CACF","sourcesContent":["import { FronteggNativePlugin, FronteggState, SubscribeMap } from './definitions';\nimport { createObservable } from './observables';\nimport { registerPlugin } from '@capacitor/core';\n\nconst FronteggNative = registerPlugin<FronteggNativePlugin>('FronteggNative', {\n web: () => import('./web').then(m => new m.FronteggNativeWeb()),\n});\n\n\nexport class FronteggService {\n private state: FronteggState;\n private mapListeners: SubscribeMap<FronteggState>;\n\n constructor() {\n this.state = {\n isAuthenticated: false,\n showLoader: true,\n user: null,\n accessToken: null,\n refreshToken: null,\n }\n this.mapListeners = {\n 'isAuthenticated': new Set(),\n 'showLoader': new Set(),\n 'user': new Set(),\n 'accessToken': new Set(),\n 'refreshToken': new Set(),\n }\n FronteggNative.addListener('onFronteggAuthEvent', (state: FronteggState) => {\n console.log('onFronteggAuthEvent', state)\n\n const keys = Object.keys(this.mapListeners)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i] as keyof FronteggState\n if (this.state[key] !== state[key]) {\n console.log('onFronteggAuthEvent key: ', key, 'from:', this.state[key], 'to:', state[key])\n this.mapListeners[key].forEach((listener: any) => listener(state[key]))\n }\n }\n this.state = state;\n })\n\n FronteggNative.getAuthState().then((state: FronteggState) => {\n console.log('getAuthState()', state)\n\n const keys = Object.keys(this.mapListeners)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i] as keyof FronteggState\n if (this.state[key] !== state[key]) {\n this.mapListeners[key].forEach((listener: any) => listener(state[key]))\n }\n }\n this.state = state\n })\n }\n\n public getState() {\n return this.state;\n }\n\n public get $isLoading() {\n return createObservable(this.mapListeners, this.state, 'showLoader')\n }\n\n public get $isAuthenticated() {\n return createObservable(this.mapListeners, this.state, 'isAuthenticated')\n }\n\n public get $user() {\n return createObservable(this.mapListeners, this.state, 'user')\n }\n\n public get $accessToken() {\n return createObservable(this.mapListeners, this.state, 'accessToken')\n }\n\n /**\n * Call frontegg native login method\n */\n public login(): void {\n FronteggNative.login();\n }\n\n public logout(): void {\n FronteggNative.logout();\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { FronteggService } from './frontegg.service';
2
+ export { FronteggState } from './definitions';
@@ -0,0 +1,2 @@
1
+ export { FronteggService } from './frontegg.service';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { FronteggService } from './frontegg.service';\nexport { FronteggState } from './definitions';\n"]}
@@ -0,0 +1,5 @@
1
+ import { FronteggState, SubscribeFunc, SubscribeMap } from './definitions';
2
+ export declare const createObservable: <T extends "user" | "accessToken" | "refreshToken" | "isAuthenticated" | "showLoader">(map: SubscribeMap<FronteggState>, state: FronteggState, key: T) => {
3
+ value: FronteggState[T];
4
+ subscribe(listener: SubscribeFunc<FronteggState, T>): () => void;
5
+ };
@@ -0,0 +1,13 @@
1
+ export const createObservable = (map, state, key) => {
2
+ return {
3
+ value: state[key],
4
+ subscribe(listener) {
5
+ const mapKey = map[key];
6
+ mapKey.add(listener);
7
+ return () => {
8
+ mapKey.delete(listener);
9
+ };
10
+ }
11
+ };
12
+ };
13
+ //# sourceMappingURL=observables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observables.js","sourceRoot":"","sources":["../../src/observables.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAgC,GAAgC,EAAE,KAAoB,EAAE,GAAM,EAAE,EAAE;IAChI,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;QACjB,SAAS,CAAC,QAAyC;YACjD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAyC,CAAA;YAC/D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACpB,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACzB,CAAC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { FronteggState, SubscribeFunc, SubscribeMap } from './definitions';\n\n\nexport const createObservable = <T extends keyof FronteggState>(map: SubscribeMap<FronteggState>, state: FronteggState, key: T) => {\n return {\n value: state[key],\n subscribe(listener: SubscribeFunc<FronteggState, T>) {\n const mapKey = map[key] as Set<SubscribeFunc<FronteggState, T>>\n mapKey.add(listener)\n return () => {\n mapKey.delete(listener)\n }\n }\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { FronteggNativePlugin, FronteggState } from './definitions';
3
+ export declare class FronteggNativeWeb extends WebPlugin implements FronteggNativePlugin {
4
+ login(): Promise<void>;
5
+ logout(): Promise<void>;
6
+ getConstants(): Promise<Record<string, string>>;
7
+ getAuthState(): Promise<FronteggState>;
8
+ }
@@ -0,0 +1,16 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class FronteggNativeWeb extends WebPlugin {
3
+ async login() {
4
+ throw Error('FronteggNative.login not implemented in web');
5
+ }
6
+ async logout() {
7
+ throw Error('FronteggNative.logout not implemented in web');
8
+ }
9
+ async getConstants() {
10
+ throw Error('FronteggNative.getConstants not implemented in web');
11
+ }
12
+ async getAuthState() {
13
+ throw Error('FronteggNative.getAuthState not implemented in web');
14
+ }
15
+ }
16
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,iBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,KAAK;QACT,MAAM,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAA;IAC7D,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACnE,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACnE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { FronteggNativePlugin, FronteggState } from './definitions';\n\nexport class FronteggNativeWeb\n extends WebPlugin\n implements FronteggNativePlugin {\n\n async login(): Promise<void> {\n throw Error('FronteggNative.login not implemented in web')\n }\n\n async logout(): Promise<void> {\n throw Error('FronteggNative.logout not implemented in web')\n }\n\n async getConstants(): Promise<Record<string, string>> {\n throw Error('FronteggNative.getConstants not implemented in web')\n }\n\n async getAuthState(): Promise<FronteggState> {\n throw Error('FronteggNative.getAuthState not implemented in web')\n }\n}\n"]}
@@ -0,0 +1,110 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const createObservable = (map, state, key) => {
8
+ return {
9
+ value: state[key],
10
+ subscribe(listener) {
11
+ const mapKey = map[key];
12
+ mapKey.add(listener);
13
+ return () => {
14
+ mapKey.delete(listener);
15
+ };
16
+ }
17
+ };
18
+ };
19
+
20
+ const FronteggNative = core.registerPlugin('FronteggNative', {
21
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FronteggNativeWeb()),
22
+ });
23
+ class FronteggService {
24
+ constructor() {
25
+ this.state = {
26
+ isAuthenticated: false,
27
+ showLoader: true,
28
+ user: null,
29
+ accessToken: null,
30
+ refreshToken: null,
31
+ };
32
+ this.mapListeners = {
33
+ 'isAuthenticated': new Set(),
34
+ 'showLoader': new Set(),
35
+ 'user': new Set(),
36
+ 'accessToken': new Set(),
37
+ 'refreshToken': new Set(),
38
+ };
39
+ FronteggNative.addListener('onFronteggAuthEvent', (state) => {
40
+ console.log('onFronteggAuthEvent', state);
41
+ const keys = Object.keys(this.mapListeners);
42
+ for (let i = 0; i < keys.length; i++) {
43
+ const key = keys[i];
44
+ if (this.state[key] !== state[key]) {
45
+ console.log('onFronteggAuthEvent key: ', key, 'from:', this.state[key], 'to:', state[key]);
46
+ this.mapListeners[key].forEach((listener) => listener(state[key]));
47
+ }
48
+ }
49
+ this.state = state;
50
+ });
51
+ FronteggNative.getAuthState().then((state) => {
52
+ console.log('getAuthState()', state);
53
+ const keys = Object.keys(this.mapListeners);
54
+ for (let i = 0; i < keys.length; i++) {
55
+ const key = keys[i];
56
+ if (this.state[key] !== state[key]) {
57
+ this.mapListeners[key].forEach((listener) => listener(state[key]));
58
+ }
59
+ }
60
+ this.state = state;
61
+ });
62
+ }
63
+ getState() {
64
+ return this.state;
65
+ }
66
+ get $isLoading() {
67
+ return createObservable(this.mapListeners, this.state, 'showLoader');
68
+ }
69
+ get $isAuthenticated() {
70
+ return createObservable(this.mapListeners, this.state, 'isAuthenticated');
71
+ }
72
+ get $user() {
73
+ return createObservable(this.mapListeners, this.state, 'user');
74
+ }
75
+ get $accessToken() {
76
+ return createObservable(this.mapListeners, this.state, 'accessToken');
77
+ }
78
+ /**
79
+ * Call frontegg native login method
80
+ */
81
+ login() {
82
+ FronteggNative.login();
83
+ }
84
+ logout() {
85
+ FronteggNative.logout();
86
+ }
87
+ }
88
+
89
+ class FronteggNativeWeb extends core.WebPlugin {
90
+ async login() {
91
+ throw Error('FronteggNative.login not implemented in web');
92
+ }
93
+ async logout() {
94
+ throw Error('FronteggNative.logout not implemented in web');
95
+ }
96
+ async getConstants() {
97
+ throw Error('FronteggNative.getConstants not implemented in web');
98
+ }
99
+ async getAuthState() {
100
+ throw Error('FronteggNative.getAuthState not implemented in web');
101
+ }
102
+ }
103
+
104
+ var web = /*#__PURE__*/Object.freeze({
105
+ __proto__: null,
106
+ FronteggNativeWeb: FronteggNativeWeb
107
+ });
108
+
109
+ exports.FronteggService = FronteggService;
110
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/observables.js","esm/frontegg.service.js","esm/web.js"],"sourcesContent":["export const createObservable = (map, state, key) => {\n return {\n value: state[key],\n subscribe(listener) {\n const mapKey = map[key];\n mapKey.add(listener);\n return () => {\n mapKey.delete(listener);\n };\n }\n };\n};\n//# sourceMappingURL=observables.js.map","import { createObservable } from './observables';\nimport { registerPlugin } from '@capacitor/core';\nconst FronteggNative = registerPlugin('FronteggNative', {\n web: () => import('./web').then(m => new m.FronteggNativeWeb()),\n});\nexport class FronteggService {\n constructor() {\n this.state = {\n isAuthenticated: false,\n showLoader: true,\n user: null,\n accessToken: null,\n refreshToken: null,\n };\n this.mapListeners = {\n 'isAuthenticated': new Set(),\n 'showLoader': new Set(),\n 'user': new Set(),\n 'accessToken': new Set(),\n 'refreshToken': new Set(),\n };\n FronteggNative.addListener('onFronteggAuthEvent', (state) => {\n console.log('onFronteggAuthEvent', state);\n const keys = Object.keys(this.mapListeners);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (this.state[key] !== state[key]) {\n console.log('onFronteggAuthEvent key: ', key, 'from:', this.state[key], 'to:', state[key]);\n this.mapListeners[key].forEach((listener) => listener(state[key]));\n }\n }\n this.state = state;\n });\n FronteggNative.getAuthState().then((state) => {\n console.log('getAuthState()', state);\n const keys = Object.keys(this.mapListeners);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (this.state[key] !== state[key]) {\n this.mapListeners[key].forEach((listener) => listener(state[key]));\n }\n }\n this.state = state;\n });\n }\n getState() {\n return this.state;\n }\n get $isLoading() {\n return createObservable(this.mapListeners, this.state, 'showLoader');\n }\n get $isAuthenticated() {\n return createObservable(this.mapListeners, this.state, 'isAuthenticated');\n }\n get $user() {\n return createObservable(this.mapListeners, this.state, 'user');\n }\n get $accessToken() {\n return createObservable(this.mapListeners, this.state, 'accessToken');\n }\n /**\n * Call frontegg native login method\n */\n login() {\n FronteggNative.login();\n }\n logout() {\n FronteggNative.logout();\n }\n}\n//# sourceMappingURL=frontegg.service.js.map","import { WebPlugin } from '@capacitor/core';\nexport class FronteggNativeWeb extends WebPlugin {\n async login() {\n throw Error('FronteggNative.login not implemented in web');\n }\n async logout() {\n throw Error('FronteggNative.logout not implemented in web');\n }\n async getConstants() {\n throw Error('FronteggNative.getConstants not implemented in web');\n }\n async getAuthState() {\n throw Error('FronteggNative.getAuthState not implemented in web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AAAO,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK;AACrD,IAAI,OAAO;AACX,QAAQ,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;AACzB,QAAQ,SAAS,CAAC,QAAQ,EAAE;AAC5B,YAAY,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;AACpC,YAAY,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACjC,YAAY,OAAO,MAAM;AACzB,gBAAgB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxC,aAAa,CAAC;AACd,SAAS;AACT,KAAK,CAAC;AACN,CAAC;;ACTD,MAAM,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACnE,CAAC,CAAC,CAAC;AACI,MAAM,eAAe,CAAC;AAC7B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,KAAK,GAAG;AACrB,YAAY,eAAe,EAAE,KAAK;AAClC,YAAY,UAAU,EAAE,IAAI;AAC5B,YAAY,IAAI,EAAE,IAAI;AACtB,YAAY,WAAW,EAAE,IAAI;AAC7B,YAAY,YAAY,EAAE,IAAI;AAC9B,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,YAAY,GAAG;AAC5B,YAAY,iBAAiB,EAAE,IAAI,GAAG,EAAE;AACxC,YAAY,YAAY,EAAE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,KAAK,GAAG;AACZ,QAAQ,cAAc,CAAC,KAAK,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,GAAG;AACb,QAAQ,cAAc,CAAC,MAAM,EAAE,CAAC;AAChC,KAAK;AACL;;ACpEO,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,MAAM,KAAK,CAAC,6CAA6C,CAAC,CAAC;AACnE,KAAK;AACL,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAC;AACpE,KAAK;AACL,IAAI,MAAM,YAAY,GAAG;AACzB,QAAQ,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAC;AAC1E,KAAK;AACL,IAAI,MAAM,YAAY,GAAG;AACzB,QAAQ,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAC;AAC1E,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,113 @@
1
+ var capacitorFronteggNative = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const createObservable = (map, state, key) => {
5
+ return {
6
+ value: state[key],
7
+ subscribe(listener) {
8
+ const mapKey = map[key];
9
+ mapKey.add(listener);
10
+ return () => {
11
+ mapKey.delete(listener);
12
+ };
13
+ }
14
+ };
15
+ };
16
+
17
+ const FronteggNative = core.registerPlugin('FronteggNative', {
18
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FronteggNativeWeb()),
19
+ });
20
+ class FronteggService {
21
+ constructor() {
22
+ this.state = {
23
+ isAuthenticated: false,
24
+ showLoader: true,
25
+ user: null,
26
+ accessToken: null,
27
+ refreshToken: null,
28
+ };
29
+ this.mapListeners = {
30
+ 'isAuthenticated': new Set(),
31
+ 'showLoader': new Set(),
32
+ 'user': new Set(),
33
+ 'accessToken': new Set(),
34
+ 'refreshToken': new Set(),
35
+ };
36
+ FronteggNative.addListener('onFronteggAuthEvent', (state) => {
37
+ console.log('onFronteggAuthEvent', state);
38
+ const keys = Object.keys(this.mapListeners);
39
+ for (let i = 0; i < keys.length; i++) {
40
+ const key = keys[i];
41
+ if (this.state[key] !== state[key]) {
42
+ console.log('onFronteggAuthEvent key: ', key, 'from:', this.state[key], 'to:', state[key]);
43
+ this.mapListeners[key].forEach((listener) => listener(state[key]));
44
+ }
45
+ }
46
+ this.state = state;
47
+ });
48
+ FronteggNative.getAuthState().then((state) => {
49
+ console.log('getAuthState()', state);
50
+ const keys = Object.keys(this.mapListeners);
51
+ for (let i = 0; i < keys.length; i++) {
52
+ const key = keys[i];
53
+ if (this.state[key] !== state[key]) {
54
+ this.mapListeners[key].forEach((listener) => listener(state[key]));
55
+ }
56
+ }
57
+ this.state = state;
58
+ });
59
+ }
60
+ getState() {
61
+ return this.state;
62
+ }
63
+ get $isLoading() {
64
+ return createObservable(this.mapListeners, this.state, 'showLoader');
65
+ }
66
+ get $isAuthenticated() {
67
+ return createObservable(this.mapListeners, this.state, 'isAuthenticated');
68
+ }
69
+ get $user() {
70
+ return createObservable(this.mapListeners, this.state, 'user');
71
+ }
72
+ get $accessToken() {
73
+ return createObservable(this.mapListeners, this.state, 'accessToken');
74
+ }
75
+ /**
76
+ * Call frontegg native login method
77
+ */
78
+ login() {
79
+ FronteggNative.login();
80
+ }
81
+ logout() {
82
+ FronteggNative.logout();
83
+ }
84
+ }
85
+
86
+ class FronteggNativeWeb extends core.WebPlugin {
87
+ async login() {
88
+ throw Error('FronteggNative.login not implemented in web');
89
+ }
90
+ async logout() {
91
+ throw Error('FronteggNative.logout not implemented in web');
92
+ }
93
+ async getConstants() {
94
+ throw Error('FronteggNative.getConstants not implemented in web');
95
+ }
96
+ async getAuthState() {
97
+ throw Error('FronteggNative.getAuthState not implemented in web');
98
+ }
99
+ }
100
+
101
+ var web = /*#__PURE__*/Object.freeze({
102
+ __proto__: null,
103
+ FronteggNativeWeb: FronteggNativeWeb
104
+ });
105
+
106
+ exports.FronteggService = FronteggService;
107
+
108
+ Object.defineProperty(exports, '__esModule', { value: true });
109
+
110
+ return exports;
111
+
112
+ })({}, capacitorExports);
113
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/observables.js","esm/frontegg.service.js","esm/web.js"],"sourcesContent":["export const createObservable = (map, state, key) => {\n return {\n value: state[key],\n subscribe(listener) {\n const mapKey = map[key];\n mapKey.add(listener);\n return () => {\n mapKey.delete(listener);\n };\n }\n };\n};\n//# sourceMappingURL=observables.js.map","import { createObservable } from './observables';\nimport { registerPlugin } from '@capacitor/core';\nconst FronteggNative = registerPlugin('FronteggNative', {\n web: () => import('./web').then(m => new m.FronteggNativeWeb()),\n});\nexport class FronteggService {\n constructor() {\n this.state = {\n isAuthenticated: false,\n showLoader: true,\n user: null,\n accessToken: null,\n refreshToken: null,\n };\n this.mapListeners = {\n 'isAuthenticated': new Set(),\n 'showLoader': new Set(),\n 'user': new Set(),\n 'accessToken': new Set(),\n 'refreshToken': new Set(),\n };\n FronteggNative.addListener('onFronteggAuthEvent', (state) => {\n console.log('onFronteggAuthEvent', state);\n const keys = Object.keys(this.mapListeners);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (this.state[key] !== state[key]) {\n console.log('onFronteggAuthEvent key: ', key, 'from:', this.state[key], 'to:', state[key]);\n this.mapListeners[key].forEach((listener) => listener(state[key]));\n }\n }\n this.state = state;\n });\n FronteggNative.getAuthState().then((state) => {\n console.log('getAuthState()', state);\n const keys = Object.keys(this.mapListeners);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (this.state[key] !== state[key]) {\n this.mapListeners[key].forEach((listener) => listener(state[key]));\n }\n }\n this.state = state;\n });\n }\n getState() {\n return this.state;\n }\n get $isLoading() {\n return createObservable(this.mapListeners, this.state, 'showLoader');\n }\n get $isAuthenticated() {\n return createObservable(this.mapListeners, this.state, 'isAuthenticated');\n }\n get $user() {\n return createObservable(this.mapListeners, this.state, 'user');\n }\n get $accessToken() {\n return createObservable(this.mapListeners, this.state, 'accessToken');\n }\n /**\n * Call frontegg native login method\n */\n login() {\n FronteggNative.login();\n }\n logout() {\n FronteggNative.logout();\n }\n}\n//# sourceMappingURL=frontegg.service.js.map","import { WebPlugin } from '@capacitor/core';\nexport class FronteggNativeWeb extends WebPlugin {\n async login() {\n throw Error('FronteggNative.login not implemented in web');\n }\n async logout() {\n throw Error('FronteggNative.logout not implemented in web');\n }\n async getConstants() {\n throw Error('FronteggNative.getConstants not implemented in web');\n }\n async getAuthState() {\n throw Error('FronteggNative.getAuthState not implemented in web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAO,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK;IACrD,IAAI,OAAO;IACX,QAAQ,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;IACzB,QAAQ,SAAS,CAAC,QAAQ,EAAE;IAC5B,YAAY,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,YAAY,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,YAAY,OAAO,MAAM;IACzB,gBAAgB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,aAAa,CAAC;IACd,SAAS;IACT,KAAK,CAAC;IACN,CAAC;;ICTD,MAAM,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;IACI,MAAM,eAAe,CAAC;IAC7B,IAAI,WAAW,GAAG;IAClB,QAAQ,IAAI,CAAC,KAAK,GAAG;IACrB,YAAY,eAAe,EAAE,KAAK;IAClC,YAAY,UAAU,EAAE,IAAI;IAC5B,YAAY,IAAI,EAAE,IAAI;IACtB,YAAY,WAAW,EAAE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,IAAI,IAAI,YAAY,GAAG;IACvB,QAAQ,OAAO,gBAAgB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC9E,KAAK;IACL;IACA;IACA;IACA,IAAI,KAAK,GAAG;IACZ,QAAQ,cAAc,CAAC,KAAK,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,GAAG;IACb,QAAQ,cAAc,CAAC,MAAM,EAAE,CAAC;IAChC,KAAK;IACL;;ICpEO,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,MAAM,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACnE,KAAK;IACL,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACpE,KAAK;IACL,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC1E,KAAK;IACL,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC1E,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,12 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(FronteggNativePlugin, "FronteggNative",
7
+ CAP_PLUGIN_METHOD(login, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(logout, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(getAuthState, CAPPluginReturnPromise);
10
+ CAP_PLUGIN_METHOD(getConstants, CAPPluginReturnPromise);
11
+ )
12
+
@@ -0,0 +1,100 @@
1
+ import FronteggSwift
2
+ import Foundation
3
+ import Combine
4
+ import Capacitor
5
+
6
+ /**
7
+ * Please read the Capacitor iOS Plugin Development Guide
8
+ * here: https://capacitorjs.com/docs/plugins/ios
9
+ */
10
+ @objc(FronteggNativePlugin)
11
+ public class FronteggNativePlugin: CAPPlugin {
12
+ public let fronteggApp = FronteggApp.shared
13
+ var cancellables = Set<AnyCancellable>()
14
+
15
+ override public func load() {
16
+
17
+ let auth = fronteggApp.auth
18
+ var anyChange: AnyPublisher<Void, Never> {
19
+ return Publishers.Merge8 (
20
+ auth.$accessToken.map { _ in },
21
+ auth.$refreshToken.map {_ in },
22
+ auth.$user.map {_ in },
23
+ auth.$isAuthenticated.map {_ in },
24
+ auth.$isLoading.map {_ in },
25
+ auth.$initializing.map {_ in },
26
+ auth.$showLoader.map {_ in },
27
+ auth.$appLink.map {_ in }
28
+ )
29
+ .eraseToAnyPublisher()
30
+ }
31
+
32
+ anyChange.sink(receiveValue: { () in
33
+
34
+ self.sendEvent()
35
+ }).store(in: &cancellables)
36
+
37
+ self.sendEvent()
38
+ }
39
+
40
+ func sendEvent() {
41
+ let auth = fronteggApp.auth
42
+
43
+ var jsonUser: [String: Any]? = nil
44
+ if let userData = try? JSONEncoder().encode(auth.user) {
45
+ jsonUser = try? JSONSerialization.jsonObject(with: userData, options: .allowFragments) as? [String: Any]
46
+ }
47
+
48
+ let body: [String: Any?] = [
49
+ "accessToken": auth.accessToken,
50
+ "refreshToken": auth.refreshToken,
51
+ "user": jsonUser,
52
+ "isAuthenticated": auth.isAuthenticated,
53
+ "isLoading": auth.isLoading,
54
+ "initializing": auth.initializing,
55
+ "showLoader": auth.showLoader,
56
+ "appLink": auth.appLink
57
+ ]
58
+
59
+ self.notifyListeners("onFronteggAuthEvent", data: body as [String : Any])
60
+ }
61
+
62
+ @objc func getConstants(_ call: CAPPluginCall) {
63
+ call.resolve([
64
+ "baseUrl": fronteggApp.baseUrl,
65
+ "clientId": fronteggApp.clientId,
66
+ "bundleId": Bundle.main.bundleIdentifier!
67
+ ])
68
+ }
69
+
70
+ @objc func login(_ call: CAPPluginCall) {
71
+ fronteggApp.auth.login()
72
+ call.resolve()
73
+ }
74
+
75
+ @objc func logout(_ call: CAPPluginCall) {
76
+ fronteggApp.auth.logout()
77
+ call.resolve()
78
+ }
79
+
80
+ @objc func getAuthState(_ call: CAPPluginCall) {
81
+ let auth = fronteggApp.auth
82
+ var jsonUser: [String: Any]? = nil
83
+ if let userData = try? JSONEncoder().encode(auth.user) {
84
+ jsonUser = try? JSONSerialization.jsonObject(with: userData, options: .allowFragments) as? [String: Any]
85
+ }
86
+
87
+ let body: [String: Any?] = [
88
+ "accessToken": auth.accessToken,
89
+ "refreshToken": auth.refreshToken,
90
+ "user": jsonUser,
91
+ "isAuthenticated": auth.isAuthenticated,
92
+ "isLoading": auth.isLoading,
93
+ "initializing": auth.initializing,
94
+ "showLoader": auth.showLoader,
95
+ "appLink": auth.appLink
96
+ ]
97
+ call.resolve(body as? [String: Any] ?? [:])
98
+ }
99
+
100
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>