diff --git a/.github/workflows/onPublishAlpha.yaml b/.github/workflows/onPublishAlpha.yaml new file mode 100644 index 0000000..3832033 --- /dev/null +++ b/.github/workflows/onPublishAlpha.yaml @@ -0,0 +1,64 @@ +name: "(▶) Publish Alpha Version" +on: + workflow_dispatch: + +env: + CI: true + +jobs: + createAlphaVersion: + name: 'Create Alpha Version' + runs-on: macos-12 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + + - name: Lint files + run: npm run lint + + - name: Check licenses + id: check_licenses + run: | + npm install -g license-checker + license-checker --failOn "AGPL-1.0-only;AGPL-1.0-or-later;AGPL-3.0-only;AGPL-3.0-or-later;GPL-1.0-only;GPL-1.0-or-later;GPL-2.0-only;GPL-2.0-or-later;GPL-3.0-only;GPL-3.0-or-later;LGPL-2.0-only;LGPL-2.0-or-later;LGPL-2.1-only;LGPL-2.1-or-later;LGPL-3.0-only;LGPL-3.0-or-later;LGPLLR;MPL-1.1" + + - name: Git Identity + run: | + git config --global user.name 'frontegg' + git config --global user.email 'frontegg@users.noreply.github.com' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Authenticate with Registry + run: | + echo "init-author-name=Frontegg LTD" > .npmrc + echo "init-author-email=hello@frontegg.com" >> .npmrc + echo "init-author-url=https://frontegg.com" >> .npmrc + echo "init-license=MIT" >> .npmrc + echo "always-auth=true" >> .npmrc + echo "registry=https://registry.npmjs.org" >> .npmrc + echo "@frontegg:registry=https://registry.npmjs.org" >> .npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc + npm whoami + env: + NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + + - name: Publish Pre-Release version to NPM + id: publish_pre_release_version + run: | + version=$(node -p 'require("./package.json").version') + echo "::set-output name=LIB_VERSION::${version}" + echo "Publishing DEV version - v${version}-alpha.${{ github.run_id }}" + yarn version --new-version "${version}-alpha.${{ github.run_id }}" --no-git-tag-version --no-commit-hooks + git add . + git commit -m "chore: prelrease version" + + npm run build + npm publish --tag next + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/src/frontegg.service.ts b/src/frontegg.service.ts index 325e168..833160e 100644 --- a/src/frontegg.service.ts +++ b/src/frontegg.service.ts @@ -15,7 +15,6 @@ const FronteggNative = registerPlugin('FronteggNative', { web: () => import('./web').then(m => new m.FronteggNativeWeb()), }); - export class FronteggService { private state: FronteggState; private logger: Logger; @@ -59,20 +58,22 @@ export class FronteggService { initializing: new Set(), }; - FronteggNative.addListener( 'onFronteggAuthEvent', (state: FronteggState) => { - this.logger.info('onFronteggAuthEvent', JSON.stringify({ - isAuthenticated: state.isAuthenticated, - showLoader: state.isLoading, - user: `${state.user}`, // prevent log full user object // null | undefined | [object Object] - accessToken: state.accessToken ? '****' : null, - refreshToken: state.refreshToken, - selectedRegion: state.selectedRegion, - refreshingToken: state.refreshingToken, - initializing: state.initializing, - })); + this.logger.info( + 'onFronteggAuthEvent', + JSON.stringify({ + isAuthenticated: state.isAuthenticated, + showLoader: state.isLoading, + user: `${state.user}`, // prevent log full user object // null | undefined | [object Object] + accessToken: state.accessToken ? '****' : null, + refreshToken: state.refreshToken, + selectedRegion: state.selectedRegion, + refreshingToken: state.refreshingToken, + initializing: state.initializing, + }), + ); const keys = this.orderedListenerKeys; keys.forEach(key => { @@ -96,9 +97,7 @@ export class FronteggService { const key = item as keyof FronteggState; (this.state as any)[key] = state[key]; - this.mapListeners[key].forEach((listener: any) => - listener(state[key]), - ); + this.mapListeners[key].forEach((listener: any) => listener(state[key])); } this.state.initializing = false; @@ -202,31 +201,33 @@ export class FronteggService { return FronteggNative.login(); } - /** * Wait for loader to finish * @private */ public async waitForLoader(): Promise { // eslint-disable-next-line no-async-promise-executor - return new Promise(async (resolve) => { - console.log('checking is loading') + return new Promise(async resolve => { + console.log('checking is loading'); const { isLoading, initializing } = this.getState(); - console.log('checking is loading', JSON.stringify({isLoading, initializing})) + console.log( + 'checking is loading', + JSON.stringify({ isLoading, initializing }), + ); if (!isLoading && !initializing) { - resolve(true) + resolve(true); return; } - console.log('isLoading is true, waiting for it to be false') - const unsubscribe = this.$isLoading.subscribe((isLoading) => { - console.log('isLoading', isLoading) + console.log('isLoading is true, waiting for it to be false'); + const unsubscribe = this.$isLoading.subscribe(isLoading => { + console.log('isLoading', isLoading); if (!isLoading) { resolve(true); unsubscribe(); } }); - }) + }); } /** @@ -240,19 +241,15 @@ export class FronteggService { data: string, ephemeralSession = true, ): Promise { - - const state = await this.getNativeState() - console.log('direct login action', state) - await this.waitForLoader() + const state = await this.getNativeState(); + console.log('direct login action', state); + await this.waitForLoader(); if (state.isAuthenticated) { - return true + return true; } - this.state.isLoading = true; - this.mapListeners.isLoading.forEach((listener: any) => - listener(true), - ); + this.mapListeners.isLoading.forEach((listener: any) => listener(true)); return FronteggNative.directLoginAction({ type, data, ephemeralSession }); }