build: fix build and add examples
This commit is contained in:
parent
f00c1d1aef
commit
58d7b3c89e
Binary file not shown.
Before Width: | Height: | Size: 134 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 MiB |
@ -1,265 +0,0 @@
|
||||
name: Build, Lint & Test Lib
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build_job:
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
|
||||
runs-on: ubuntu-latest
|
||||
name: Built, Lint and Test Library
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Installing Dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Linting Library
|
||||
run: npm run lint-lib
|
||||
|
||||
- name: Testing Frontend
|
||||
run: npm run test-lib-ci
|
||||
|
||||
- name: Coveralls
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
path-to-lcov: './coverage/oidc-client-rx/lcov.info'
|
||||
|
||||
- name: Coveralls Finished
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
parallel-finished: true
|
||||
|
||||
- name: Building Frontend
|
||||
run: npm run build-lib-prod
|
||||
|
||||
- name: Copying essential additional files
|
||||
run: npm run copy-files
|
||||
|
||||
- name: Show files
|
||||
run: ls
|
||||
|
||||
- name: Upload Artefact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: angular_auth_oidc_client_artefact
|
||||
path: dist/oidc-client-rx
|
||||
|
||||
AngularLatestVersion:
|
||||
needs: build_job
|
||||
runs-on: ubuntu-latest
|
||||
name: Angular latest
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Download Artefact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: angular_auth_oidc_client_artefact
|
||||
path: oidc-client-rx-artefact
|
||||
|
||||
- name: Install AngularCLI globally
|
||||
run: sudo npm install -g @angular/cli
|
||||
|
||||
- name: Show ng Version
|
||||
run: ng version
|
||||
|
||||
- name: Create Angular Project
|
||||
run: sudo ng new oidc-client-rx-test --skip-git
|
||||
|
||||
- name: Npm Install & Install Library from local artefact
|
||||
run: |
|
||||
sudo cp -R oidc-client-rx-artefact oidc-client-rx-test/
|
||||
cd oidc-client-rx-test
|
||||
sudo npm install --unsafe-perm=true
|
||||
sudo ng add ./oidc-client-rx-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
|
||||
|
||||
- name: Test Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: npm test -- --watch=false --browsers=ChromeHeadless
|
||||
|
||||
- name: Build Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: sudo npm run build
|
||||
|
||||
AngularLatestVersionWithSchematics:
|
||||
needs: build_job
|
||||
runs-on: ubuntu-latest
|
||||
name: Angular latest & Schematics Job
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Download Artefact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: angular_auth_oidc_client_artefact
|
||||
path: oidc-client-rx-artefact
|
||||
|
||||
- name: Install AngularCLI globally
|
||||
run: sudo npm install -g @angular/cli
|
||||
|
||||
- name: Show ng Version
|
||||
run: ng version
|
||||
|
||||
- name: Create Angular Project
|
||||
run: sudo ng new oidc-client-rx-test --skip-git
|
||||
|
||||
- name: Npm Install & Install Library from local artefact
|
||||
run: |
|
||||
sudo cp -R oidc-client-rx-artefact oidc-client-rx-test/
|
||||
cd oidc-client-rx-test
|
||||
sudo npm install --unsafe-perm=true
|
||||
sudo ng add ./oidc-client-rx-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "Default config" --use-local-package=true --skip-confirmation
|
||||
|
||||
- name: Test Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: npm test -- --watch=false --browsers=ChromeHeadless
|
||||
|
||||
- name: Build Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: sudo npm run build
|
||||
|
||||
AngularLatestVersionWithNgModuleSchematics:
|
||||
needs: build_job
|
||||
runs-on: ubuntu-latest
|
||||
name: Angular latest Standalone & Schematics Job
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Download Artefact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: angular_auth_oidc_client_artefact
|
||||
path: oidc-client-rx-artefact
|
||||
|
||||
- name: Install AngularCLI globally
|
||||
run: sudo npm install -g @angular/cli
|
||||
|
||||
- name: Show ng Version
|
||||
run: ng version
|
||||
|
||||
- name: Create Angular Project
|
||||
run: sudo ng new oidc-client-rx-test --skip-git --standalone=false
|
||||
|
||||
- name: Npm Install & Install Library from local artefact
|
||||
run: |
|
||||
sudo cp -R oidc-client-rx-artefact oidc-client-rx-test/
|
||||
cd oidc-client-rx-test
|
||||
sudo npm install --unsafe-perm=true
|
||||
sudo ng add ./oidc-client-rx-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
|
||||
|
||||
- name: Test Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: npm test -- --watch=false --browsers=ChromeHeadless
|
||||
|
||||
- name: Build Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: sudo npm run build
|
||||
|
||||
Angular16VersionWithRxJs6:
|
||||
needs: build_job
|
||||
runs-on: ubuntu-latest
|
||||
name: Angular 16 & RxJs 6
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Download Artefact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: angular_auth_oidc_client_artefact
|
||||
path: oidc-client-rx-artefact
|
||||
|
||||
- name: Install AngularCLI globally
|
||||
run: sudo npm install -g @angular/cli@16
|
||||
|
||||
- name: Show ng Version
|
||||
run: ng version
|
||||
|
||||
- name: Create Angular Project
|
||||
run: sudo ng new oidc-client-rx-test --skip-git
|
||||
|
||||
- name: npm install RxJs 6
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: sudo npm install rxjs@6.5.3
|
||||
|
||||
- name: Npm Install & Install Library from local artefact
|
||||
run: |
|
||||
sudo cp -R oidc-client-rx-artefact oidc-client-rx-test/
|
||||
cd oidc-client-rx-test
|
||||
sudo npm install --unsafe-perm=true
|
||||
sudo ng add ./oidc-client-rx-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
|
||||
|
||||
- name: Test Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: npm test -- --watch=false --browsers=ChromeHeadless
|
||||
|
||||
- name: Build Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: sudo npm run build
|
||||
|
||||
LibWithAngularV16:
|
||||
needs: build_job
|
||||
runs-on: ubuntu-latest
|
||||
name: Angular V16
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Download Artefact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: angular_auth_oidc_client_artefact
|
||||
path: oidc-client-rx-artefact
|
||||
|
||||
- name: Install AngularCLI globally
|
||||
run: sudo npm install -g @angular/cli@16
|
||||
|
||||
- name: Show ng Version
|
||||
run: ng version
|
||||
|
||||
- name: Create Angular Project
|
||||
run: sudo ng new oidc-client-rx-test --skip-git
|
||||
|
||||
- name: Npm Install & Install Library from local artefact
|
||||
run: |
|
||||
sudo cp -R oidc-client-rx-artefact oidc-client-rx-test/
|
||||
cd oidc-client-rx-test
|
||||
sudo npm install --unsafe-perm=true
|
||||
sudo ng add ./oidc-client-rx-artefact --authority-url-or-tenant-id "my-authority-url" --flow-type "OIDC Code Flow PKCE using refresh tokens" --use-local-package=true --skip-confirmation
|
||||
|
||||
- name: Test Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: npm test -- --watch=false --browsers=ChromeHeadless
|
||||
|
||||
- name: Build Angular Application
|
||||
working-directory: ./oidc-client-rx-test
|
||||
run: sudo npm run build
|
@ -1,61 +0,0 @@
|
||||
name: Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build_and_deploy_job:
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
|
||||
runs-on: ubuntu-latest
|
||||
name: Build and Deploy Docs Job
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Installing Dependencies
|
||||
run: sudo npm install
|
||||
|
||||
- name: Installing Dependencies for docs - in docs folder
|
||||
run: sudo npm install
|
||||
working-directory: docs/site/oidc-client-rx
|
||||
|
||||
- name: Building Documentation
|
||||
run: sudo npm run build
|
||||
working-directory: docs/site/oidc-client-rx
|
||||
|
||||
- name: Build And Deploy
|
||||
if: ${{ github.actor == 'damienbod' || github.actor == 'FabianGosebrink' }}
|
||||
id: builddeploy
|
||||
uses: Azure/static-web-apps-deploy@v1
|
||||
with:
|
||||
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
|
||||
action: 'upload'
|
||||
###### Repository/Build Configurations - These values can be configured to match you app requirements. ######
|
||||
app_location: '/docs/site/oidc-client-rx' # App source code path
|
||||
app_artifact_location: 'build' # Built app content directory - optional
|
||||
###### End of Repository/Build Configurations ######
|
||||
|
||||
close_pull_request_job:
|
||||
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
||||
runs-on: ubuntu-latest
|
||||
name: Close Pull Request Job
|
||||
steps:
|
||||
- name: Close Pull Request
|
||||
id: closepullrequest
|
||||
uses: Azure/static-web-apps-deploy@v1
|
||||
with:
|
||||
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
|
||||
action: 'close'
|
@ -1,27 +0,0 @@
|
||||
name: Playwright Tests
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
- name: Install dependencies
|
||||
run: npm install -g pnpm && pnpm install
|
||||
- name: Install Playwright Browsers
|
||||
run: pnpm exec playwright install --with-deps
|
||||
- name: Run Playwright tests
|
||||
run: pnpm exec playwright test
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
retention-days: 30
|
55
.github/workflows/build.yml
vendored
Normal file
55
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
name: Build, Lint & Test Lib
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build_job:
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action != 'closed')
|
||||
runs-on: ubuntu-latest
|
||||
name: Build, Lint and Test Library
|
||||
steps:
|
||||
- name: Check Permissions When Workflow Dispatch
|
||||
id: check_admin
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node and Install Dependencies
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
run_install: |
|
||||
- recursive: true
|
||||
args: [--frozen-lockfile]
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Linting Library
|
||||
run: npm run lint
|
||||
|
||||
- name: Testing Frontend
|
||||
run: npm run test-ci
|
||||
|
||||
- name: 'Report Coverage'
|
||||
if: always()
|
||||
uses: davelosert/vitest-coverage-report-action@v2
|
||||
|
||||
- name: Building Frontend
|
||||
run: npm run build
|
||||
|
||||
- name: Show files
|
||||
run: ls
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: oidc_client_rx_artifact
|
||||
path: dist
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
|
||||
# compiled output
|
||||
/dist
|
||||
**/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
# Only exists if Bazel was run
|
||||
@ -45,7 +46,6 @@ testem.log
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
/.angulardoc.json
|
||||
debug.log
|
||||
|
||||
/.husky
|
||||
@ -55,3 +55,5 @@ debug.log
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
/.vitest
|
||||
/.rslib
|
||||
**/*.tsbuildinfo
|
||||
|
13
README.md
13
README.md
@ -2,6 +2,7 @@
|
||||
<img src="./assets/logo-512.png" height="150" alt="OUTPOSTS">
|
||||
<div style="color: #232848; font-weight: 700;">OIDC-CLIENT-RX</div>
|
||||
<div align="center">
|
||||
<img src="https://img.shields.io/github/actions/workflow/status/lonelyhentxi/oidc-client-rx/build?branch=main" alt="build-status" />
|
||||
<img src="https://img.shields.io/badge/status-work--in--progress-blue" alt="status-badge" />
|
||||
</div>
|
||||
</h1>
|
||||
@ -10,7 +11,17 @@
|
||||
|
||||
## Quick Start
|
||||
|
||||
@TODO Coming Soon
|
||||
@TODO Add More Detailed Informations
|
||||
|
||||
```sh
|
||||
# or yarn/npm
|
||||
pnpm install oidc-client-rx
|
||||
```
|
||||
|
||||
```ts
|
||||
import {} from ''
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
"style": {
|
||||
"noNonNullAssertion": "off",
|
||||
"noParameterAssign": "off",
|
||||
"useFilenamingConvention": "warn",
|
||||
"useFilenamingConvention": "off",
|
||||
"noParameterProperties": "off"
|
||||
},
|
||||
"suspicious": {
|
||||
|
13
examples/react-tanstack-router/.gitignore
vendored
Normal file
13
examples/react-tanstack-router/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# Local
|
||||
.DS_Store
|
||||
*.local
|
||||
*.log*
|
||||
|
||||
# Dist
|
||||
node_modules
|
||||
dist/
|
||||
|
||||
# IDE
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
29
examples/react-tanstack-router/README.md
Normal file
29
examples/react-tanstack-router/README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Rsbuild project
|
||||
|
||||
## Setup
|
||||
|
||||
Install the dependencies:
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
## Get started
|
||||
|
||||
Start the dev server:
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Build the app for production:
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Preview the production build locally:
|
||||
|
||||
```bash
|
||||
pnpm preview
|
||||
```
|
23
examples/react-tanstack-router/package.json
Normal file
23
examples/react-tanstack-router/package.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "react-tanstack-router",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "rsbuild dev",
|
||||
"build": "rsbuild build",
|
||||
"preview": "rsbuild preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/react-router": "^1.99.6",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rsbuild/core": "^1.2.3",
|
||||
"@rsbuild/plugin-react": "^1.1.0",
|
||||
"@types/react": "^19.0.8",
|
||||
"@types/react-dom": "^19.0.3",
|
||||
"oidc-client-rx": "workspace:*",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
0
examples/react-tanstack-router/public/.gitkeep
Normal file
0
examples/react-tanstack-router/public/.gitkeep
Normal file
6
examples/react-tanstack-router/rsbuild.config.ts
Normal file
6
examples/react-tanstack-router/rsbuild.config.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { defineConfig } from '@rsbuild/core';
|
||||
import { pluginReact } from '@rsbuild/plugin-react';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [pluginReact()],
|
||||
});
|
26
examples/react-tanstack-router/src/App.css
Normal file
26
examples/react-tanstack-router/src/App.css
Normal file
@ -0,0 +1,26 @@
|
||||
body {
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||
background-image: linear-gradient(to bottom, #020917, #101725);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
line-height: 1.1;
|
||||
text-align: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.content h1 {
|
||||
font-size: 3.6rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.content p {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 400;
|
||||
opacity: 0.5;
|
||||
}
|
15
examples/react-tanstack-router/src/App.tsx
Normal file
15
examples/react-tanstack-router/src/App.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
import { useOidcClient } from 'oidc-client-rx/adapters/react';
|
||||
import './App.css';
|
||||
|
||||
const App = () => {
|
||||
const { oidcSecurityService } = useOidcClient();
|
||||
|
||||
return (
|
||||
<div className="content">
|
||||
<h1>Rsbuild with React</h1>
|
||||
<p>Start building amazing things with Rsbuild.</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
1
examples/react-tanstack-router/src/env.d.ts
vendored
Normal file
1
examples/react-tanstack-router/src/env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="@rsbuild/core/types" />
|
40
examples/react-tanstack-router/src/index.tsx
Normal file
40
examples/react-tanstack-router/src/index.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
import { type Injector, ReflectiveInjector } from '@outposts/injection-js';
|
||||
import { LogLevel, OidcSecurityService, provideAuth } from 'oidc-client-rx';
|
||||
import { InjectorProvider } from 'oidc-client-rx/adapters/react';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
|
||||
const rootEl = document.getElementById('root');
|
||||
|
||||
if (rootEl) {
|
||||
const injector = ReflectiveInjector.resolveAndCreate(
|
||||
provideAuth({
|
||||
config: {
|
||||
authority: '<your authority address here>',
|
||||
redirectUrl: window.location.origin,
|
||||
postLogoutRedirectUri: window.location.origin,
|
||||
clientId: '<your clientId>',
|
||||
scope: 'openid profile email offline_access',
|
||||
responseType: 'code',
|
||||
silentRenew: true,
|
||||
useRefreshToken: true,
|
||||
logLevel: LogLevel.Debug,
|
||||
},
|
||||
})
|
||||
) as Injector;
|
||||
|
||||
// if needed, check when init
|
||||
const oidcSecurityService = injector.get(OidcSecurityService);
|
||||
oidcSecurityService.checkAuthMultiple();
|
||||
|
||||
const root = ReactDOM.createRoot(rootEl);
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<InjectorProvider injector={injector}>
|
||||
<App />
|
||||
</InjectorProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
}
|
18
examples/react-tanstack-router/tsconfig.json
Normal file
18
examples/react-tanstack-router/tsconfig.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"rootDir": ".",
|
||||
"lib": ["ES2021", "DOM", "DOM.Iterable"],
|
||||
"useDefineForClassFields": true,
|
||||
"resolveJsonModule": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"noEmit": true,
|
||||
"outDir": "./dist",
|
||||
"declarationDir": "./dist",
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
41
lefthook.yml
41
lefthook.yml
@ -1,41 +0,0 @@
|
||||
# EXAMPLE USAGE
|
||||
# Refer for explanation to following link:
|
||||
# https://github.com/evilmartians/lefthook/blob/master/docs/full_guide.md
|
||||
#
|
||||
pre-push:
|
||||
commands:
|
||||
fix-prettier:
|
||||
tags: frontend security
|
||||
glob: '*.{js,ts}'
|
||||
run: npm run fix-prettier {staged_files}
|
||||
|
||||
pre-commit:
|
||||
parallel: true
|
||||
commands:
|
||||
check-blockwords:
|
||||
run: npm run check-blockwords
|
||||
|
||||
lint:
|
||||
run: npm run lint-lib
|
||||
#
|
||||
# pre-commit:
|
||||
# parallel: true
|
||||
# commands:
|
||||
# eslint:
|
||||
# glob: "*.{js,ts}"
|
||||
# run: yarn eslint {staged_files}
|
||||
# rubocop:
|
||||
# tags: backend style
|
||||
# glob: "*.rb"
|
||||
# exclude: "application.rb|routes.rb"
|
||||
# run: bundle exec rubocop --force-exclusion {all_files}
|
||||
# govet:
|
||||
# tags: backend style
|
||||
# files: git ls-files -m
|
||||
# glob: "*.go"
|
||||
# run: go vet {files}
|
||||
# scripts:
|
||||
# "hello.js":
|
||||
# runner: node
|
||||
# "any.go":
|
||||
# runner: go run
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @license oidc-client-rx
|
||||
* MIT license
|
||||
*/
|
3006
package-lock.json
generated
3006
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@ -17,6 +17,16 @@
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./adapters/react": {
|
||||
"types": "./dist/adapters/react/index.d.ts",
|
||||
"import": "./dist/adapters/react/index.js",
|
||||
"require": "./dist/adapters/react.cjs"
|
||||
},
|
||||
"./adapters/tanstack-router": {
|
||||
"types": "./dist/adapters/tanstack-router/index.d.ts",
|
||||
"import": "./dist/adapters/tanstack-router/index.js",
|
||||
"require": "./dist/adapters/tanstack-router.cjs"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
@ -30,31 +40,31 @@
|
||||
"test-ci": "vitest --watch=false --coverage",
|
||||
"pack": "npm run build && npm pack ./dist",
|
||||
"publish": "npm run build && npm publish ./dist",
|
||||
"coverage": "vitest run --coverage",
|
||||
"lint": "ultracite lint",
|
||||
"format": "ultracite format",
|
||||
"cli": "tsx scripts/cli.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ngify/http": "^2.0.4",
|
||||
"injection-js": "git+https://github.com/mgechev/injection-js.git#81a10e0",
|
||||
"reflect-metadata": "^0.2.2"
|
||||
"@outposts/injection-js": "^2.5.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tanstack/react-router": "*",
|
||||
"react": ">=16.8.0",
|
||||
"rxjs": "^7.4.0||>=8.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@biomejs/js-api": "0.7.1",
|
||||
"@biomejs/wasm-nodejs": "^1.9.4",
|
||||
"@evilmartians/lefthook": "^1.0.3",
|
||||
"@playwright/test": "^1.49.1",
|
||||
"@rslib/core": "^0.3.1",
|
||||
"@rslib/core": "^0.4.0",
|
||||
"@swc/core": "^1.10.12",
|
||||
"@tanstack/react-router": "^1.99.6",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^22.12.0",
|
||||
"@vitest/browser": "^3.0.4",
|
||||
"@types/react": "^19.0.8",
|
||||
"@vitest/coverage-v8": "^3.0.4",
|
||||
"commander": "^13.1.0",
|
||||
"jsdom": "^26.0.0",
|
||||
@ -62,6 +72,8 @@
|
||||
"oxc-parser": "^0.48.1",
|
||||
"oxc-walker": "^0.2.2",
|
||||
"playwright": "^1.50.0",
|
||||
"react": "^19.0.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rfc4648": "^1.5.0",
|
||||
"rxjs": "^7.4.0",
|
||||
"tsx": "^4.19.2",
|
||||
@ -71,6 +83,14 @@
|
||||
"vite-tsconfig-paths": "^5.1.4",
|
||||
"vitest": "^3.0.4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react": {
|
||||
"optional": true
|
||||
},
|
||||
"@tanstack/react-router": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
"rxjs",
|
||||
"oidc",
|
||||
@ -86,6 +106,11 @@
|
||||
"certified",
|
||||
"oauth",
|
||||
"authorization",
|
||||
"reactivex"
|
||||
]
|
||||
"reactivex",
|
||||
"injection-js",
|
||||
"injection"
|
||||
],
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": ["core-js"]
|
||||
}
|
||||
}
|
||||
|
922
pnpm-lock.yaml
generated
922
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
- 'examples/*'
|
@ -2,17 +2,31 @@ import { defineConfig } from '@rslib/core';
|
||||
|
||||
export default defineConfig({
|
||||
source: {
|
||||
tsconfigPath: './tsconfig.lib.json'
|
||||
tsconfigPath: './tsconfig.lib.json',
|
||||
},
|
||||
lib: [
|
||||
{
|
||||
format: 'esm',
|
||||
syntax: 'es2021',
|
||||
dts: true,
|
||||
bundle: false,
|
||||
dts: {
|
||||
bundle: false,
|
||||
build: true,
|
||||
distPath: './dist',
|
||||
},
|
||||
},
|
||||
{
|
||||
format: 'cjs',
|
||||
syntax: 'es2021',
|
||||
dts: false,
|
||||
bundle: true,
|
||||
source: {
|
||||
entry: {
|
||||
index: './src/index.ts',
|
||||
'adapters/react': './src/adapters/react/index.ts',
|
||||
'adapters/tanstack-router': './src/adapters/tanstack-router/index.ts',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
output: {
|
||||
|
47
src/adapters/react/index.ts
Normal file
47
src/adapters/react/index.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import type { InjectionToken, Injector, Type } from '@outposts/injection-js';
|
||||
import {
|
||||
type PropsWithChildren,
|
||||
createContext,
|
||||
createElement,
|
||||
useContext,
|
||||
useMemo,
|
||||
} from 'react';
|
||||
import { OidcSecurityService } from '../..';
|
||||
|
||||
export const InjectorContextVoidInjector: Injector = {
|
||||
get: <T>(_token: Type<T> | InjectionToken<T>, _notFoundValue?: T): T => {
|
||||
throw new Error('Please wrap with a InjectorContext.Provider first');
|
||||
},
|
||||
};
|
||||
|
||||
export const InjectorContext = createContext<Injector>(
|
||||
InjectorContextVoidInjector
|
||||
);
|
||||
|
||||
export function InjectorProvider({
|
||||
injector,
|
||||
...props
|
||||
}: PropsWithChildren<{ injector: Injector }>) {
|
||||
return createElement(InjectorContext, {
|
||||
...props,
|
||||
value: injector,
|
||||
});
|
||||
}
|
||||
|
||||
export function useInjector() {
|
||||
return useContext(InjectorContext);
|
||||
}
|
||||
|
||||
export function useOidcClient() {
|
||||
const injector = useInjector();
|
||||
|
||||
const oidcSecurityService = useMemo(
|
||||
() => injector.get(OidcSecurityService),
|
||||
[injector]
|
||||
);
|
||||
|
||||
return {
|
||||
injector,
|
||||
oidcSecurityService,
|
||||
};
|
||||
}
|
45
src/adapters/tanstack-router/index.ts
Normal file
45
src/adapters/tanstack-router/index.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { InjectionToken, inject } from '@outposts/injection-js';
|
||||
import type {
|
||||
AnyRoute,
|
||||
Router,
|
||||
TrailingSlashOption,
|
||||
} from '@tanstack/react-router';
|
||||
import { AbstractRouter } from 'src/router';
|
||||
import type { AuthFeature } from '../../provide-auth';
|
||||
|
||||
export type TanStackRouter = Router<AnyRoute, TrailingSlashOption, boolean>;
|
||||
|
||||
export const TANSTACK_ROUTER = new InjectionToken<TanStackRouter>(
|
||||
'TANSTACK_ROUTER'
|
||||
);
|
||||
|
||||
export class TanStackRouterAdapter implements AbstractRouter<string> {
|
||||
private router = inject(TANSTACK_ROUTER);
|
||||
|
||||
navigateByUrl(url: string): void {
|
||||
this.router.navigate({
|
||||
href: url,
|
||||
});
|
||||
}
|
||||
|
||||
getCurrentNavigation() {
|
||||
return {
|
||||
extractedUrl: this.router.state.location.href,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function withTanstackRouter(router: TanStackRouter): AuthFeature {
|
||||
return {
|
||||
ɵproviders: [
|
||||
{
|
||||
provide: TANSTACK_ROUTER,
|
||||
useValue: router,
|
||||
},
|
||||
{
|
||||
provide: AbstractRouter,
|
||||
useClass: TanStackRouterAdapter,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { HttpHeaders } from '@ngify/http';
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { HttpParams } from '../http';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HttpClient, type HttpHeaders } from '@ngify/http';
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { HttpParams } from '../http';
|
||||
|
||||
@ -13,7 +13,7 @@ export class HttpBaseService {
|
||||
): Observable<T> {
|
||||
return this.http.get<T>(url, {
|
||||
...options,
|
||||
params: options.params.toNgify(),
|
||||
params: options.params?.toNgify(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ export class HttpBaseService {
|
||||
): Observable<T> {
|
||||
return this.http.post<T>(url, body, {
|
||||
...options,
|
||||
params: options.params.toNgify(),
|
||||
params: options.params?.toNgify(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { InjectionToken, type Provider } from 'injection-js';
|
||||
import { InjectionToken, type Provider } from '@outposts/injection-js';
|
||||
import {
|
||||
type StsConfigLoader,
|
||||
StsConfigStaticLoader,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { BehaviorSubject, type Observable, throwError } from 'rxjs';
|
||||
import { distinctUntilChanged } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, forkJoin, of, throwError } from 'rxjs';
|
||||
import { catchError, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { AutoLoginService } from '../auto-login/auto-login.service';
|
||||
|
@ -3,7 +3,7 @@ import {
|
||||
Injector,
|
||||
ReflectiveInjector,
|
||||
type Type,
|
||||
} from 'injection-js';
|
||||
} from '@outposts/injection-js';
|
||||
import type { PassedInitialConfig } from './auth-config';
|
||||
import type { Module } from './injection';
|
||||
import { _provideAuth } from './provide-auth';
|
||||
@ -34,7 +34,7 @@ export class AuthModule extends Injector {
|
||||
}
|
||||
|
||||
get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T): T;
|
||||
get(token: any, notFoundValue?: any);
|
||||
get(token: any, notFoundValue?: any): any;
|
||||
get(token: unknown, notFoundValue?: unknown): any {
|
||||
return this.injector.get(token, notFoundValue);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TestBed, mockRouterProvider } from '@/testing';
|
||||
import { type MockRouter, TestBed, mockRouterProvider } from '@/testing';
|
||||
import {
|
||||
AbstractRouter,
|
||||
type ActivatedRouteSnapshot,
|
||||
@ -43,7 +43,7 @@ describe('AutoLoginPartialRoutesGuard', () => {
|
||||
let storagePersistenceService: StoragePersistenceService;
|
||||
let configurationService: ConfigurationService;
|
||||
let autoLoginService: AutoLoginService;
|
||||
let router: AbstractRouter;
|
||||
let router: MockRouter;
|
||||
|
||||
beforeEach(() => {
|
||||
authStateService = TestBed.inject(AuthStateService);
|
||||
@ -293,11 +293,6 @@ describe('AutoLoginPartialRoutesGuard', () => {
|
||||
extractedUrl: router.parseUrl(
|
||||
'some-url12/with/some-param?queryParam=true'
|
||||
),
|
||||
extras: {},
|
||||
id: 1,
|
||||
initialUrl: router.parseUrl(''),
|
||||
previousNavigation: null,
|
||||
trigger: 'imperative',
|
||||
});
|
||||
|
||||
await firstValueFrom(guard.canLoad());
|
||||
@ -342,7 +337,7 @@ describe('AutoLoginPartialRoutesGuard', () => {
|
||||
let storagePersistenceService: StoragePersistenceService;
|
||||
let configurationService: ConfigurationService;
|
||||
let autoLoginService: AutoLoginService;
|
||||
let router: AbstractRouter;
|
||||
let router: MockRouter;
|
||||
|
||||
beforeEach(() => {
|
||||
authStateService = TestBed.inject(AuthStateService);
|
||||
@ -398,11 +393,6 @@ describe('AutoLoginPartialRoutesGuard', () => {
|
||||
extractedUrl: router.parseUrl(
|
||||
'some-url12/with/some-param?queryParam=true'
|
||||
),
|
||||
extras: {},
|
||||
id: 1,
|
||||
initialUrl: router.parseUrl(''),
|
||||
previousNavigation: null,
|
||||
trigger: 'imperative',
|
||||
});
|
||||
|
||||
vi.spyOn(authStateService, 'areAuthStorageTokensValid').mockReturnValue(
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import type { AuthOptions } from '../auth-options';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { injectAbstractType } from '../injection';
|
||||
import { AbstractRouter } from '../router';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, type Subscription, interval } from 'rxjs';
|
||||
import { DOCUMENT } from '../dom';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, ReplaySubject, forkJoin, of, throwError } from 'rxjs';
|
||||
import { catchError, map, share, switchMap } from 'rxjs/operators';
|
||||
import { AuthStateService } from '../auth-state/auth-state.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, throwError } from 'rxjs';
|
||||
import { catchError, finalize } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import {
|
||||
type Observable,
|
||||
TimeoutError,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { inject, Injectable } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, throwError } from 'rxjs';
|
||||
import { map, retry } from 'rxjs/operators';
|
||||
import { DataService } from '../../api/data.service';
|
||||
@ -42,7 +42,7 @@ export class AuthWellKnownDataService {
|
||||
introspectionEndpoint: wellKnownEndpoints.introspection_endpoint,
|
||||
parEndpoint:
|
||||
wellKnownEndpoints.pushed_authorization_request_endpoint,
|
||||
} as AuthWellKnownEndpoints)
|
||||
}) as AuthWellKnownEndpoints
|
||||
),
|
||||
map((mappedWellKnownEndpoints) => ({
|
||||
...mappedWellKnownEndpoints,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { EventTypes } from '../../public-events/event-types';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, forkJoin, of } from 'rxjs';
|
||||
import { concatMap, map } from 'rxjs/operators';
|
||||
import { injectAbstractType } from '../injection/inject';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { Provider } from 'injection-js';
|
||||
import type { Provider } from '@outposts/injection-js';
|
||||
import { type Observable, forkJoin, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TestBed, mockImplementationWhenArgsEqual } from '@/testing';
|
||||
import { TestBed } from '@/testing';
|
||||
import { mockImplementationWhenArgs, spyOnWithOrigin } from '@/testing/spy';
|
||||
import { vi } from 'vitest';
|
||||
import { LogLevel } from '../../logging/log-level';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { LoggerService } from '../../logging/logger.service';
|
||||
import type { OpenIdConfiguration } from '../openid-configuration';
|
||||
import type { Level, RuleValidationResult } from './rule';
|
||||
|
@ -1,3 +1,3 @@
|
||||
import { InjectionToken } from "injection-js";
|
||||
import { InjectionToken } from '@outposts/injection-js';
|
||||
|
||||
export const DOCUMENT = new InjectionToken<Document>('document');
|
||||
export const DOCUMENT = new InjectionToken<Document>('document');
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
|
||||
@Injectable()
|
||||
export class JwkExtractor {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HttpHeaders } from '@ngify/http';
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError, timer } from 'rxjs';
|
||||
import { catchError, mergeMap, retryWhen, switchMap } from 'rxjs/operators';
|
||||
import { DataService } from '../../api/data.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError } from 'rxjs';
|
||||
import { catchError, switchMap, tap } from 'rxjs/operators';
|
||||
import { AuthStateService } from '../../auth-state/auth-state.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of } from 'rxjs';
|
||||
import type { OpenIdConfiguration } from '../../config/openid-configuration';
|
||||
import { DOCUMENT } from '../../dom';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError } from 'rxjs';
|
||||
import { AuthStateService } from '../../auth-state/auth-state.service';
|
||||
import type { OpenIdConfiguration } from '../../config/openid-configuration';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HttpHeaders } from '@ngify/http';
|
||||
import { inject, Injectable } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError, timer } from 'rxjs';
|
||||
import { catchError, mergeMap, retryWhen, switchMap } from 'rxjs/operators';
|
||||
import { DataService } from '../../api/data.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { AuthStateService } from '../../auth-state/auth-state.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError } from 'rxjs';
|
||||
import { catchError, switchMap } from 'rxjs/operators';
|
||||
import { AuthStateService } from '../../auth-state/auth-state.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
import { StoragePersistenceService } from '../storage/storage-persistence.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { Observable } from 'rxjs';
|
||||
import { concatMap } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../../config/openid-configuration';
|
||||
import { LoggerService } from '../../logging/logger.service';
|
||||
import { CryptoService } from '../../utils/crypto/crypto.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { AuthStateService } from '../auth-state/auth-state.service';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HttpResponse } from '@ngify/http';
|
||||
import { inject, Injectable } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, throwError } from 'rxjs';
|
||||
import { catchError, retry } from 'rxjs/operators';
|
||||
import { DataService } from '../api/data.service';
|
||||
|
@ -8,9 +8,13 @@ import {
|
||||
withInterceptors,
|
||||
withLegacyInterceptors,
|
||||
} from '@ngify/http';
|
||||
import { InjectionToken, Optional, type Provider } from 'injection-js';
|
||||
import {
|
||||
InjectionToken,
|
||||
Optional,
|
||||
type Provider,
|
||||
} from '@outposts/injection-js';
|
||||
import type { ArrayOrNullableOne } from '../utils/types';
|
||||
export { HttpParams, HttpParamsOptions } from './params';
|
||||
export { HttpParams, type HttpParamsOptions } from './params';
|
||||
|
||||
export const HTTP_FEATURES = new InjectionToken<HttpFeature[]>('HTTP_FEATURES');
|
||||
|
||||
|
@ -88,6 +88,7 @@ function paramParser(
|
||||
// The `window.location.search` can be used while creating an instance of the `HttpParams` class
|
||||
// (e.g. `new HttpParams({ fromString: window.location.search })`). The `window.location.search`
|
||||
// may start with the `?` char, so we strip it if it's present.
|
||||
// biome-ignore lint/performance/useTopLevelRegex: <explanation>
|
||||
const params: string[] = rawParams.replace(/^\?/, '').split('&');
|
||||
params.forEach((param: string) => {
|
||||
const eqIdx = param.indexOf('=');
|
||||
@ -304,7 +305,7 @@ export class HttpParams {
|
||||
toNgify(): NgifyHttpParams {
|
||||
this.init();
|
||||
return new NgifyHttpParams().appendAll(
|
||||
Object.fromEntries(this.map.entries())
|
||||
Object.fromEntries(this.map!.entries())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { DOCUMENT } from '../dom';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import {
|
||||
Observable,
|
||||
ReplaySubject,
|
||||
@ -82,14 +82,14 @@ export class RefreshSessionIframeService {
|
||||
): void {
|
||||
const instanceId = Math.random();
|
||||
|
||||
const oidcSilentRenewInit$ = fromEventPattern(
|
||||
const oidcSilentRenewInit$ = fromEventPattern<CustomEvent>(
|
||||
(handler) =>
|
||||
this.document.defaultView.window.addEventListener(
|
||||
this.document.defaultView?.window?.addEventListener(
|
||||
'oidc-silent-renew-init',
|
||||
handler
|
||||
),
|
||||
(handler) =>
|
||||
this.document.defaultView.window.removeEventListener(
|
||||
this.document.defaultView?.window?.removeEventListener(
|
||||
'oidc-silent-renew-init',
|
||||
handler
|
||||
)
|
||||
@ -104,12 +104,12 @@ export class RefreshSessionIframeService {
|
||||
}
|
||||
this.silentRenewEventHandlerSubscription = fromEventPattern<CustomEvent>(
|
||||
(handler) =>
|
||||
this.document.defaultView.window.addEventListener(
|
||||
this.document.defaultView?.window?.addEventListener(
|
||||
'oidc-silent-renew-message',
|
||||
handler
|
||||
),
|
||||
(handler) =>
|
||||
this.document.defaultView.window.removeEventListener(
|
||||
this.document.defaultView?.window?.removeEventListener(
|
||||
'oidc-silent-renew-message',
|
||||
handler
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, Subject, of, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { AuthStateService } from '../auth-state/auth-state.service';
|
||||
|
@ -1,7 +0,0 @@
|
||||
import { InjectionToken } from 'injection-js';
|
||||
import type { Observable } from 'rxjs';
|
||||
|
||||
export const APP_INITIALIZER = new InjectionToken<
|
||||
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
|
||||
readonly (() => void | Observable<unknown> | Promise<unknown>)[]
|
||||
>('APP_INITIALIZER');
|
@ -1,3 +1,2 @@
|
||||
export type { Module } from './module';
|
||||
export { APP_INITIALIZER } from './convention';
|
||||
export { injectAbstractType } from './inject';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { inject } from 'injection-js';
|
||||
import { inject } from '@outposts/injection-js';
|
||||
|
||||
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
||||
export interface AbstractType<T> extends Function {
|
||||
|
@ -1,3 +1,3 @@
|
||||
import type { Injector } from 'injection-js';
|
||||
import type { Injector } from '@outposts/injection-js';
|
||||
|
||||
export type Module = (parentInjector: Injector) => Injector;
|
||||
|
@ -6,7 +6,7 @@ import type {
|
||||
HttpInterceptorFn,
|
||||
HttpRequest,
|
||||
} from '@ngify/http';
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { Observable } from 'rxjs';
|
||||
import { AuthStateService } from '../auth-state/auth-state.service';
|
||||
import { ConfigurationService } from '../config/config.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
||||
@Injectable()
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
|
||||
/**
|
||||
* Implement this class-interface to create a custom logger service.
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
import type { AbstractLoggerService } from './abstract-logger.service';
|
||||
|
||||
@Injectable()
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { injectAbstractType } from '../injection/inject';
|
||||
import { AbstractLoggerService } from './abstract-logger.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError } from 'rxjs';
|
||||
import type { AuthOptions } from '../auth-options';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError } from 'rxjs';
|
||||
import { map, switchMap, take } from 'rxjs/operators';
|
||||
import type { AuthOptions } from '../../auth-options';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HttpHeaders } from '@ngify/http';
|
||||
import { inject, Injectable } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, throwError } from 'rxjs';
|
||||
import { catchError, map, retry, switchMap } from 'rxjs/operators';
|
||||
import { DataService } from '../../api/data.service';
|
||||
@ -74,7 +74,8 @@ export class ParService {
|
||||
};
|
||||
}),
|
||||
catchError((error) => {
|
||||
const errorMessage = 'There was an error on ParService postParRequest';
|
||||
const errorMessage =
|
||||
'There was an error on ParService postParRequest';
|
||||
|
||||
this.loggerService.logError(configuration, errorMessage, error);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError } from 'rxjs';
|
||||
import { switchMap, take, tap } from 'rxjs/operators';
|
||||
import type { AuthOptions } from '../../auth-options';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { DOCUMENT } from '../../dom';
|
||||
import { inject, Injectable } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, Subject } from 'rxjs';
|
||||
import type { OpenIdConfiguration } from '../../config/openid-configuration';
|
||||
import { DOCUMENT } from '../../dom';
|
||||
import { LoggerService } from '../../logging/logger.service';
|
||||
import { StoragePersistenceService } from '../../storage/storage-persistence.service';
|
||||
import type { PopupOptions } from './popup-options';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { inject, Injectable } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../../config/openid-configuration';
|
||||
import { LoggerService } from '../../logging/logger.service';
|
||||
import { FlowHelper } from '../../utils/flowHelper/flow-helper.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, map, of, switchMap } from 'rxjs';
|
||||
import type { AuthOptions } from '../../auth-options';
|
||||
import { AuthWellKnownService } from '../../config/auth-well-known/auth-well-known.service';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HttpHeaders } from '@ngify/http';
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { type Observable, of, throwError } from 'rxjs';
|
||||
import { catchError, concatMap, retry, switchMap } from 'rxjs/operators';
|
||||
import { DataService } from '../api/data.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import { BehaviorSubject, type Observable } from 'rxjs';
|
||||
import { concatMap, map, switchMap } from 'rxjs/operators';
|
||||
import type { AuthOptions, LogoutAuthOptions } from './auth-options';
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { TestBed } from '@/testing';
|
||||
import { mockClass, mockProvider } from '@/testing/mock';
|
||||
import { APP_INITIALIZER } from 'oidc-client-rx';
|
||||
import { mockProvider } from '@/testing/mock';
|
||||
import { of } from 'rxjs';
|
||||
import { vi } from 'vitest';
|
||||
import { PASSED_CONFIG } from './auth-config';
|
||||
import { ConfigurationService } from './config/config.service';
|
||||
import {
|
||||
@ -10,8 +8,7 @@ import {
|
||||
StsConfigLoader,
|
||||
StsConfigStaticLoader,
|
||||
} from './config/loader/config-loader';
|
||||
import { OidcSecurityService } from './oidc.security.service';
|
||||
import { provideAuth, withAppInitializerAuthCheck } from './provide-auth';
|
||||
import { provideAuth } from './provide-auth';
|
||||
|
||||
describe('provideAuth', () => {
|
||||
describe('APP_CONFIG', () => {
|
||||
@ -59,37 +56,37 @@ describe('provideAuth', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('features', () => {
|
||||
let oidcSecurityServiceMock: OidcSecurityService;
|
||||
let spy: any;
|
||||
// describe('features', () => {
|
||||
// let oidcSecurityServiceMock: OidcSecurityService;
|
||||
// let spy: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
//@ts-ignore
|
||||
// beforeEach(async () => {
|
||||
// //@ts-ignore
|
||||
|
||||
oidcSecurityServiceMock = new (mockClass(OidcSecurityService))();
|
||||
spy = vi.spyOn(oidcSecurityServiceMock, 'checkAuthMultiple');
|
||||
await TestBed.configureTestingModule({
|
||||
providers: [
|
||||
provideAuth(
|
||||
{ config: { authority: 'something' } },
|
||||
withAppInitializerAuthCheck()
|
||||
),
|
||||
mockProvider(ConfigurationService),
|
||||
{
|
||||
provide: OidcSecurityService,
|
||||
useValue: oidcSecurityServiceMock,
|
||||
},
|
||||
],
|
||||
}).compileComponents();
|
||||
});
|
||||
// oidcSecurityServiceMock = new (mockClass(OidcSecurityService))();
|
||||
// spy = vi.spyOn(oidcSecurityServiceMock, 'checkAuthMultiple');
|
||||
// await TestBed.configureTestingModule({
|
||||
// providers: [
|
||||
// provideAuth(
|
||||
// { config: { authority: 'something' } },
|
||||
// withAppInitializerAuthCheck()
|
||||
// ),
|
||||
// mockProvider(ConfigurationService),
|
||||
// {
|
||||
// provide: OidcSecurityService,
|
||||
// useValue: oidcSecurityServiceMock,
|
||||
// },
|
||||
// ],
|
||||
// }).compileComponents();
|
||||
// });
|
||||
|
||||
it('should provide APP_INITIALIZER config', () => {
|
||||
const config = TestBed.inject(APP_INITIALIZER);
|
||||
expect(
|
||||
config.length,
|
||||
'Expected an APP_INITIALIZER to be registered'
|
||||
).toBe(1);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
// it('should provide APP_INITIALIZER config', () => {
|
||||
// const config = TestBed.inject(APP_INITIALIZER);
|
||||
// expect(
|
||||
// config.length,
|
||||
// 'Expected an APP_INITIALIZER to be registered'
|
||||
// ).toBe(1);
|
||||
// expect(spy).toHaveBeenCalledTimes(1);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
@ -1,15 +1,12 @@
|
||||
import type { Provider } from 'injection-js';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import type { Provider } from '@outposts/injection-js';
|
||||
import {
|
||||
PASSED_CONFIG,
|
||||
type PassedInitialConfig,
|
||||
createStaticLoader,
|
||||
} from './auth-config';
|
||||
import { StsConfigLoader } from './config/loader/config-loader';
|
||||
import { APP_INITIALIZER } from './injection';
|
||||
import { AbstractLoggerService } from './logging/abstract-logger.service';
|
||||
import { ConsoleLoggerService } from './logging/console-logger.service';
|
||||
import { OidcSecurityService } from './oidc.security.service';
|
||||
import { AbstractSecurityStorage } from './storage/abstract-security-storage';
|
||||
import { DefaultSessionStorageService } from './storage/default-sessionstorage.service';
|
||||
|
||||
@ -51,26 +48,3 @@ export function _provideAuth(passedConfig: PassedInitialConfig): Provider[] {
|
||||
{ provide: AbstractLoggerService, useClass: ConsoleLoggerService },
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures an app initializer, which is called before the app starts, and
|
||||
* resolves any OAuth callback variables.
|
||||
* When used, it replaces the need to manually call
|
||||
* `OidcSecurityService.checkAuth(...)` or
|
||||
* `OidcSecurityService.checkAuthMultiple(...)`.
|
||||
*
|
||||
* @see https://angular.dev/api/core/APP_INITIALIZER
|
||||
*/
|
||||
export function withAppInitializerAuthCheck(): AuthFeature {
|
||||
return {
|
||||
ɵproviders: [
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: (oidcSecurityService: OidcSecurityService) =>
|
||||
oidcSecurityService.checkAuthMultiple(),
|
||||
multi: true,
|
||||
deps: [OidcSecurityService],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
/*
|
||||
* Public API Surface of oidc-client-rx
|
||||
*/
|
||||
|
||||
export * from '.';
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
import { type Observable, ReplaySubject } from 'rxjs';
|
||||
import type { EventTypes } from './event-types';
|
||||
import type { OidcClientNotification } from './notification';
|
||||
|
@ -14,24 +14,15 @@ export interface UrlTree {
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export interface NavigationExtras {
|
||||
[key: string]: any;
|
||||
export interface Navigation<URL extends UrlTree = UrlTree> {
|
||||
extractedUrl: URL;
|
||||
}
|
||||
|
||||
export interface Navigation {
|
||||
id: number;
|
||||
initialUrl: UrlTree;
|
||||
extractedUrl: UrlTree;
|
||||
finalUrl?: UrlTree | undefined;
|
||||
trigger: 'imperative' | 'popstate' | 'hashchange';
|
||||
previousNavigation: Navigation | null;
|
||||
extras?: NavigationExtras;
|
||||
}
|
||||
|
||||
export abstract class AbstractRouter {
|
||||
export abstract class AbstractRouter<
|
||||
URL extends UrlTree = UrlTree,
|
||||
NAVIGATION extends Navigation<URL> = Navigation<URL>,
|
||||
> {
|
||||
abstract navigateByUrl(url: string): void;
|
||||
|
||||
abstract getCurrentNavigation(): Navigation;
|
||||
|
||||
abstract parseUrl(_url: string): any;
|
||||
abstract getCurrentNavigation(): NAVIGATION;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
|
||||
/**
|
||||
* Implement this class-interface to create a custom storage.
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable, inject } from 'injection-js';
|
||||
import { Injectable, inject } from '@outposts/injection-js';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { injectAbstractType } from '../injection';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from 'injection-js';
|
||||
import { Injectable } from '@outposts/injection-js';
|
||||
import type { AbstractSecurityStorage } from './abstract-security-storage';
|
||||
|
||||
@Injectable()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user