build: fix build and add examples

This commit is contained in:
master 2025-02-05 23:55:00 +08:00
parent f00c1d1aef
commit 58d7b3c89e
127 changed files with 1340 additions and 3841 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

View File

@ -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

View File

@ -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'

View File

@ -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
View 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
View File

@ -2,6 +2,7 @@
# compiled output # compiled output
/dist /dist
**/dist
/tmp /tmp
/out-tsc /out-tsc
# Only exists if Bazel was run # Only exists if Bazel was run
@ -45,7 +46,6 @@ testem.log
.DS_Store .DS_Store
Thumbs.db Thumbs.db
/.angulardoc.json
debug.log debug.log
/.husky /.husky
@ -55,3 +55,5 @@ debug.log
/blob-report/ /blob-report/
/playwright/.cache/ /playwright/.cache/
/.vitest /.vitest
/.rslib
**/*.tsbuildinfo

View File

@ -2,6 +2,7 @@
<img src="./assets/logo-512.png" height="150" alt="OUTPOSTS"> <img src="./assets/logo-512.png" height="150" alt="OUTPOSTS">
<div style="color: #232848; font-weight: 700;">OIDC-CLIENT-RX</div> <div style="color: #232848; font-weight: 700;">OIDC-CLIENT-RX</div>
<div align="center"> <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" /> <img src="https://img.shields.io/badge/status-work--in--progress-blue" alt="status-badge" />
</div> </div>
</h1> </h1>
@ -10,7 +11,17 @@
## Quick Start ## Quick Start
@TODO Coming Soon @TODO Add More Detailed Informations
```sh
# or yarn/npm
pnpm install oidc-client-rx
```
```ts
import {} from ''
```
## License ## License

View File

@ -6,7 +6,7 @@
"style": { "style": {
"noNonNullAssertion": "off", "noNonNullAssertion": "off",
"noParameterAssign": "off", "noParameterAssign": "off",
"useFilenamingConvention": "warn", "useFilenamingConvention": "off",
"noParameterProperties": "off" "noParameterProperties": "off"
}, },
"suspicious": { "suspicious": {

View File

@ -0,0 +1,13 @@
# Local
.DS_Store
*.local
*.log*
# Dist
node_modules
dist/
# IDE
.vscode/*
!.vscode/extensions.json
.idea

View 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
```

View 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"
}
}

View File

@ -0,0 +1,6 @@
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
export default defineConfig({
plugins: [pluginReact()],
});

View 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;
}

View 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;

View File

@ -0,0 +1 @@
/// <reference types="@rsbuild/core/types" />

View 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>
);
}

View 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"]
}

View File

@ -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

View File

@ -1,4 +0,0 @@
/**
* @license oidc-client-rx
* MIT license
*/

3006
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,16 @@
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"import": "./dist/index.js", "import": "./dist/index.js",
"require": "./dist/index.cjs" "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", "main": "./dist/index.cjs",
@ -30,31 +40,31 @@
"test-ci": "vitest --watch=false --coverage", "test-ci": "vitest --watch=false --coverage",
"pack": "npm run build && npm pack ./dist", "pack": "npm run build && npm pack ./dist",
"publish": "npm run build && npm publish ./dist", "publish": "npm run build && npm publish ./dist",
"coverage": "vitest run --coverage",
"lint": "ultracite lint", "lint": "ultracite lint",
"format": "ultracite format", "format": "ultracite format",
"cli": "tsx scripts/cli.ts" "cli": "tsx scripts/cli.ts"
}, },
"dependencies": { "dependencies": {
"@ngify/http": "^2.0.4", "@ngify/http": "^2.0.4",
"injection-js": "git+https://github.com/mgechev/injection-js.git#81a10e0", "@outposts/injection-js": "^2.5.1"
"reflect-metadata": "^0.2.2"
}, },
"peerDependencies": { "peerDependencies": {
"@tanstack/react-router": "*",
"react": ">=16.8.0",
"rxjs": "^7.4.0||>=8.0.0" "rxjs": "^7.4.0||>=8.0.0"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "1.9.4", "@biomejs/biome": "1.9.4",
"@biomejs/js-api": "0.7.1", "@biomejs/js-api": "0.7.1",
"@biomejs/wasm-nodejs": "^1.9.4", "@biomejs/wasm-nodejs": "^1.9.4",
"@evilmartians/lefthook": "^1.0.3",
"@playwright/test": "^1.49.1", "@playwright/test": "^1.49.1",
"@rslib/core": "^0.3.1", "@rslib/core": "^0.4.0",
"@swc/core": "^1.10.12", "@swc/core": "^1.10.12",
"@tanstack/react-router": "^1.99.6",
"@types/jsdom": "^21.1.7", "@types/jsdom": "^21.1.7",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^22.12.0", "@types/node": "^22.12.0",
"@vitest/browser": "^3.0.4", "@types/react": "^19.0.8",
"@vitest/coverage-v8": "^3.0.4", "@vitest/coverage-v8": "^3.0.4",
"commander": "^13.1.0", "commander": "^13.1.0",
"jsdom": "^26.0.0", "jsdom": "^26.0.0",
@ -62,6 +72,8 @@
"oxc-parser": "^0.48.1", "oxc-parser": "^0.48.1",
"oxc-walker": "^0.2.2", "oxc-walker": "^0.2.2",
"playwright": "^1.50.0", "playwright": "^1.50.0",
"react": "^19.0.0",
"reflect-metadata": "^0.2.2",
"rfc4648": "^1.5.0", "rfc4648": "^1.5.0",
"rxjs": "^7.4.0", "rxjs": "^7.4.0",
"tsx": "^4.19.2", "tsx": "^4.19.2",
@ -71,6 +83,14 @@
"vite-tsconfig-paths": "^5.1.4", "vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.4" "vitest": "^3.0.4"
}, },
"peerDependenciesMeta": {
"react": {
"optional": true
},
"@tanstack/react-router": {
"optional": true
}
},
"keywords": [ "keywords": [
"rxjs", "rxjs",
"oidc", "oidc",
@ -86,6 +106,11 @@
"certified", "certified",
"oauth", "oauth",
"authorization", "authorization",
"reactivex" "reactivex",
] "injection-js",
"injection"
],
"pnpm": {
"onlyBuiltDependencies": ["core-js"]
}
} }

922
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

2
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,2 @@
packages:
- 'examples/*'

View File

@ -2,17 +2,31 @@ import { defineConfig } from '@rslib/core';
export default defineConfig({ export default defineConfig({
source: { source: {
tsconfigPath: './tsconfig.lib.json' tsconfigPath: './tsconfig.lib.json',
}, },
lib: [ lib: [
{ {
format: 'esm', format: 'esm',
syntax: 'es2021', syntax: 'es2021',
dts: true, bundle: false,
dts: {
bundle: false,
build: true,
distPath: './dist',
},
}, },
{ {
format: 'cjs', format: 'cjs',
syntax: 'es2021', 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: { output: {

View 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,
};
}

View 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,
},
],
};
}

View File

@ -1,5 +1,5 @@
import { HttpHeaders } from '@ngify/http'; 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 { Observable } from 'rxjs';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';
import { HttpParams } from '../http'; import { HttpParams } from '../http';

View File

@ -1,5 +1,5 @@
import { HttpClient, type HttpHeaders } from '@ngify/http'; 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 { Observable } from 'rxjs';
import type { HttpParams } from '../http'; import type { HttpParams } from '../http';
@ -13,7 +13,7 @@ export class HttpBaseService {
): Observable<T> { ): Observable<T> {
return this.http.get<T>(url, { return this.http.get<T>(url, {
...options, ...options,
params: options.params.toNgify(), params: options.params?.toNgify(),
}); });
} }
@ -24,7 +24,7 @@ export class HttpBaseService {
): Observable<T> { ): Observable<T> {
return this.http.post<T>(url, body, { return this.http.post<T>(url, body, {
...options, ...options,
params: options.params.toNgify(), params: options.params?.toNgify(),
}); });
} }
} }

View File

@ -1,4 +1,4 @@
import { InjectionToken, type Provider } from 'injection-js'; import { InjectionToken, type Provider } from '@outposts/injection-js';
import { import {
type StsConfigLoader, type StsConfigLoader,
StsConfigStaticLoader, StsConfigStaticLoader,

View File

@ -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 { BehaviorSubject, type Observable, throwError } from 'rxjs';
import { distinctUntilChanged } from 'rxjs/operators'; import { distinctUntilChanged } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -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 { type Observable, forkJoin, of, throwError } from 'rxjs';
import { catchError, map, switchMap, tap } from 'rxjs/operators'; import { catchError, map, switchMap, tap } from 'rxjs/operators';
import { AutoLoginService } from '../auto-login/auto-login.service'; import { AutoLoginService } from '../auto-login/auto-login.service';

View File

@ -3,7 +3,7 @@ import {
Injector, Injector,
ReflectiveInjector, ReflectiveInjector,
type Type, type Type,
} from 'injection-js'; } from '@outposts/injection-js';
import type { PassedInitialConfig } from './auth-config'; import type { PassedInitialConfig } from './auth-config';
import type { Module } from './injection'; import type { Module } from './injection';
import { _provideAuth } from './provide-auth'; 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<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 { get(token: unknown, notFoundValue?: unknown): any {
return this.injector.get(token, notFoundValue); return this.injector.get(token, notFoundValue);
} }

View File

@ -1,4 +1,4 @@
import { TestBed, mockRouterProvider } from '@/testing'; import { type MockRouter, TestBed, mockRouterProvider } from '@/testing';
import { import {
AbstractRouter, AbstractRouter,
type ActivatedRouteSnapshot, type ActivatedRouteSnapshot,
@ -43,7 +43,7 @@ describe('AutoLoginPartialRoutesGuard', () => {
let storagePersistenceService: StoragePersistenceService; let storagePersistenceService: StoragePersistenceService;
let configurationService: ConfigurationService; let configurationService: ConfigurationService;
let autoLoginService: AutoLoginService; let autoLoginService: AutoLoginService;
let router: AbstractRouter; let router: MockRouter;
beforeEach(() => { beforeEach(() => {
authStateService = TestBed.inject(AuthStateService); authStateService = TestBed.inject(AuthStateService);
@ -293,11 +293,6 @@ describe('AutoLoginPartialRoutesGuard', () => {
extractedUrl: router.parseUrl( extractedUrl: router.parseUrl(
'some-url12/with/some-param?queryParam=true' 'some-url12/with/some-param?queryParam=true'
), ),
extras: {},
id: 1,
initialUrl: router.parseUrl(''),
previousNavigation: null,
trigger: 'imperative',
}); });
await firstValueFrom(guard.canLoad()); await firstValueFrom(guard.canLoad());
@ -342,7 +337,7 @@ describe('AutoLoginPartialRoutesGuard', () => {
let storagePersistenceService: StoragePersistenceService; let storagePersistenceService: StoragePersistenceService;
let configurationService: ConfigurationService; let configurationService: ConfigurationService;
let autoLoginService: AutoLoginService; let autoLoginService: AutoLoginService;
let router: AbstractRouter; let router: MockRouter;
beforeEach(() => { beforeEach(() => {
authStateService = TestBed.inject(AuthStateService); authStateService = TestBed.inject(AuthStateService);
@ -398,11 +393,6 @@ describe('AutoLoginPartialRoutesGuard', () => {
extractedUrl: router.parseUrl( extractedUrl: router.parseUrl(
'some-url12/with/some-param?queryParam=true' 'some-url12/with/some-param?queryParam=true'
), ),
extras: {},
id: 1,
initialUrl: router.parseUrl(''),
previousNavigation: null,
trigger: 'imperative',
}); });
vi.spyOn(authStateService, 'areAuthStorageTokensValid').mockReturnValue( vi.spyOn(authStateService, 'areAuthStorageTokensValid').mockReturnValue(

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import type { Observable } from 'rxjs'; import type { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import type { AuthOptions } from '../auth-options'; import type { AuthOptions } from '../auth-options';

View File

@ -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 type { OpenIdConfiguration } from '../config/openid-configuration';
import { injectAbstractType } from '../injection'; import { injectAbstractType } from '../injection';
import { AbstractRouter } from '../router'; import { AbstractRouter } from '../router';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { Observable, Subject } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { tap } from 'rxjs/operators'; import { tap } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { type Observable, throwError } from 'rxjs'; import { type Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators'; import { catchError, tap } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { type Observable, throwError } from 'rxjs'; import { type Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators'; import { catchError, tap } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -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 { type Observable, type Subscription, interval } from 'rxjs';
import { DOCUMENT } from '../dom'; import { DOCUMENT } from '../dom';

View File

@ -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 { type Observable, ReplaySubject, forkJoin, of, throwError } from 'rxjs';
import { catchError, map, share, switchMap } from 'rxjs/operators'; import { catchError, map, share, switchMap } from 'rxjs/operators';
import { AuthStateService } from '../auth-state/auth-state.service'; import { AuthStateService } from '../auth-state/auth-state.service';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { type Observable, throwError } from 'rxjs'; import { type Observable, throwError } from 'rxjs';
import { catchError, finalize } from 'rxjs/operators'; import { catchError, finalize } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { import {
type Observable, type Observable,
TimeoutError, TimeoutError,

View File

@ -1,4 +1,4 @@
import { inject, Injectable } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { type Observable, throwError } from 'rxjs'; import { type Observable, throwError } from 'rxjs';
import { map, retry } from 'rxjs/operators'; import { map, retry } from 'rxjs/operators';
import { DataService } from '../../api/data.service'; import { DataService } from '../../api/data.service';
@ -42,7 +42,7 @@ export class AuthWellKnownDataService {
introspectionEndpoint: wellKnownEndpoints.introspection_endpoint, introspectionEndpoint: wellKnownEndpoints.introspection_endpoint,
parEndpoint: parEndpoint:
wellKnownEndpoints.pushed_authorization_request_endpoint, wellKnownEndpoints.pushed_authorization_request_endpoint,
} as AuthWellKnownEndpoints) }) as AuthWellKnownEndpoints
), ),
map((mappedWellKnownEndpoints) => ({ map((mappedWellKnownEndpoints) => ({
...mappedWellKnownEndpoints, ...mappedWellKnownEndpoints,

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { type Observable, throwError } from 'rxjs'; import { type Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators'; import { catchError, tap } from 'rxjs/operators';
import { EventTypes } from '../../public-events/event-types'; import { EventTypes } from '../../public-events/event-types';

View File

@ -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 { type Observable, forkJoin, of } from 'rxjs';
import { concatMap, map } from 'rxjs/operators'; import { concatMap, map } from 'rxjs/operators';
import { injectAbstractType } from '../injection/inject'; import { injectAbstractType } from '../injection/inject';

View File

@ -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 { type Observable, forkJoin, of } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../openid-configuration'; import type { OpenIdConfiguration } from '../openid-configuration';

View File

@ -1,4 +1,4 @@
import { TestBed, mockImplementationWhenArgsEqual } from '@/testing'; import { TestBed } from '@/testing';
import { mockImplementationWhenArgs, spyOnWithOrigin } from '@/testing/spy'; import { mockImplementationWhenArgs, spyOnWithOrigin } from '@/testing/spy';
import { vi } from 'vitest'; import { vi } from 'vitest';
import { LogLevel } from '../../logging/log-level'; import { LogLevel } from '../../logging/log-level';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { LoggerService } from '../../logging/logger.service'; import { LoggerService } from '../../logging/logger.service';
import type { OpenIdConfiguration } from '../openid-configuration'; import type { OpenIdConfiguration } from '../openid-configuration';
import type { Level, RuleValidationResult } from './rule'; import type { Level, RuleValidationResult } from './rule';

View File

@ -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');

View File

@ -1,4 +1,4 @@
import { Injectable } from 'injection-js'; import { Injectable } from '@outposts/injection-js';
@Injectable() @Injectable()
export class JwkExtractor { export class JwkExtractor {

View File

@ -1,5 +1,5 @@
import { HttpHeaders } from '@ngify/http'; 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 { type Observable, of, throwError, timer } from 'rxjs';
import { catchError, mergeMap, retryWhen, switchMap } from 'rxjs/operators'; import { catchError, mergeMap, retryWhen, switchMap } from 'rxjs/operators';
import { DataService } from '../../api/data.service'; import { DataService } from '../../api/data.service';

View File

@ -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 Observable, of, throwError } from 'rxjs';
import { catchError, switchMap, tap } from 'rxjs/operators'; import { catchError, switchMap, tap } from 'rxjs/operators';
import { AuthStateService } from '../../auth-state/auth-state.service'; import { AuthStateService } from '../../auth-state/auth-state.service';

View File

@ -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 Observable, of } from 'rxjs';
import type { OpenIdConfiguration } from '../../config/openid-configuration'; import type { OpenIdConfiguration } from '../../config/openid-configuration';
import { DOCUMENT } from '../../dom'; import { DOCUMENT } from '../../dom';

View File

@ -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 Observable, of, throwError } from 'rxjs';
import { AuthStateService } from '../../auth-state/auth-state.service'; import { AuthStateService } from '../../auth-state/auth-state.service';
import type { OpenIdConfiguration } from '../../config/openid-configuration'; import type { OpenIdConfiguration } from '../../config/openid-configuration';

View File

@ -1,5 +1,5 @@
import { HttpHeaders } from '@ngify/http'; 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 { type Observable, of, throwError, timer } from 'rxjs';
import { catchError, mergeMap, retryWhen, switchMap } from 'rxjs/operators'; import { catchError, mergeMap, retryWhen, switchMap } from 'rxjs/operators';
import { DataService } from '../../api/data.service'; import { DataService } from '../../api/data.service';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import type { Observable } from 'rxjs'; import type { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { AuthStateService } from '../../auth-state/auth-state.service'; import { AuthStateService } from '../../auth-state/auth-state.service';

View File

@ -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 Observable, of, throwError } from 'rxjs';
import { catchError, switchMap } from 'rxjs/operators'; import { catchError, switchMap } from 'rxjs/operators';
import { AuthStateService } from '../../auth-state/auth-state.service'; import { AuthStateService } from '../../auth-state/auth-state.service';

View File

@ -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 type { OpenIdConfiguration } from '../config/openid-configuration';
import { LoggerService } from '../logging/logger.service'; import { LoggerService } from '../logging/logger.service';
import { StoragePersistenceService } from '../storage/storage-persistence.service'; import { StoragePersistenceService } from '../storage/storage-persistence.service';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import type { Observable } from 'rxjs'; import type { Observable } from 'rxjs';
import { concatMap } from 'rxjs/operators'; import { concatMap } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -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 type { OpenIdConfiguration } from '../../config/openid-configuration';
import { LoggerService } from '../../logging/logger.service'; import { LoggerService } from '../../logging/logger.service';
import { CryptoService } from '../../utils/crypto/crypto.service'; import { CryptoService } from '../../utils/crypto/crypto.service';

View File

@ -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 { AuthStateService } from '../auth-state/auth-state.service';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';
import { LoggerService } from '../logging/logger.service'; import { LoggerService } from '../logging/logger.service';

View File

@ -1,5 +1,5 @@
import { HttpResponse } from '@ngify/http'; 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 { type Observable, throwError } from 'rxjs';
import { catchError, retry } from 'rxjs/operators'; import { catchError, retry } from 'rxjs/operators';
import { DataService } from '../api/data.service'; import { DataService } from '../api/data.service';

View File

@ -8,9 +8,13 @@ import {
withInterceptors, withInterceptors,
withLegacyInterceptors, withLegacyInterceptors,
} from '@ngify/http'; } 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'; 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'); export const HTTP_FEATURES = new InjectionToken<HttpFeature[]>('HTTP_FEATURES');

View File

@ -88,6 +88,7 @@ function paramParser(
// The `window.location.search` can be used while creating an instance of the `HttpParams` class // 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` // (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. // 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('&'); const params: string[] = rawParams.replace(/^\?/, '').split('&');
params.forEach((param: string) => { params.forEach((param: string) => {
const eqIdx = param.indexOf('='); const eqIdx = param.indexOf('=');
@ -304,7 +305,7 @@ export class HttpParams {
toNgify(): NgifyHttpParams { toNgify(): NgifyHttpParams {
this.init(); this.init();
return new NgifyHttpParams().appendAll( return new NgifyHttpParams().appendAll(
Object.fromEntries(this.map.entries()) Object.fromEntries(this.map!.entries())
); );
} }

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { BehaviorSubject, Observable, of } from 'rxjs'; import { BehaviorSubject, Observable, of } from 'rxjs';
import { take } from 'rxjs/operators'; import { take } from 'rxjs/operators';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -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 type { OpenIdConfiguration } from '../config/openid-configuration';
import { DOCUMENT } from '../dom'; import { DOCUMENT } from '../dom';
import { LoggerService } from '../logging/logger.service'; import { LoggerService } from '../logging/logger.service';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { import {
Observable, Observable,
ReplaySubject, ReplaySubject,
@ -82,14 +82,14 @@ export class RefreshSessionIframeService {
): void { ): void {
const instanceId = Math.random(); const instanceId = Math.random();
const oidcSilentRenewInit$ = fromEventPattern( const oidcSilentRenewInit$ = fromEventPattern<CustomEvent>(
(handler) => (handler) =>
this.document.defaultView.window.addEventListener( this.document.defaultView?.window?.addEventListener(
'oidc-silent-renew-init', 'oidc-silent-renew-init',
handler handler
), ),
(handler) => (handler) =>
this.document.defaultView.window.removeEventListener( this.document.defaultView?.window?.removeEventListener(
'oidc-silent-renew-init', 'oidc-silent-renew-init',
handler handler
) )
@ -104,12 +104,12 @@ export class RefreshSessionIframeService {
} }
this.silentRenewEventHandlerSubscription = fromEventPattern<CustomEvent>( this.silentRenewEventHandlerSubscription = fromEventPattern<CustomEvent>(
(handler) => (handler) =>
this.document.defaultView.window.addEventListener( this.document.defaultView?.window?.addEventListener(
'oidc-silent-renew-message', 'oidc-silent-renew-message',
handler handler
), ),
(handler) => (handler) =>
this.document.defaultView.window.removeEventListener( this.document.defaultView?.window?.removeEventListener(
'oidc-silent-renew-message', 'oidc-silent-renew-message',
handler handler
) )

View File

@ -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 { type Observable, Subject, of, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators'; import { catchError, map } from 'rxjs/operators';
import { AuthStateService } from '../auth-state/auth-state.service'; import { AuthStateService } from '../auth-state/auth-state.service';

View File

@ -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');

View File

@ -1,3 +1,2 @@
export type { Module } from './module'; export type { Module } from './module';
export { APP_INITIALIZER } from './convention';
export { injectAbstractType } from './inject'; export { injectAbstractType } from './inject';

View File

@ -1,4 +1,4 @@
import { inject } from 'injection-js'; import { inject } from '@outposts/injection-js';
// biome-ignore lint/complexity/noBannedTypes: <explanation> // biome-ignore lint/complexity/noBannedTypes: <explanation>
export interface AbstractType<T> extends Function { export interface AbstractType<T> extends Function {

View File

@ -1,3 +1,3 @@
import type { Injector } from 'injection-js'; import type { Injector } from '@outposts/injection-js';
export type Module = (parentInjector: Injector) => Injector; export type Module = (parentInjector: Injector) => Injector;

View File

@ -6,7 +6,7 @@ import type {
HttpInterceptorFn, HttpInterceptorFn,
HttpRequest, HttpRequest,
} from '@ngify/http'; } from '@ngify/http';
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import type { Observable } from 'rxjs'; import type { Observable } from 'rxjs';
import { AuthStateService } from '../auth-state/auth-state.service'; import { AuthStateService } from '../auth-state/auth-state.service';
import { ConfigurationService } from '../config/config.service'; import { ConfigurationService } from '../config/config.service';

View File

@ -1,4 +1,4 @@
import { Injectable } from 'injection-js'; import { Injectable } from '@outposts/injection-js';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';
@Injectable() @Injectable()

View File

@ -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. * Implement this class-interface to create a custom logger service.

View File

@ -1,4 +1,4 @@
import { Injectable } from 'injection-js'; import { Injectable } from '@outposts/injection-js';
import type { AbstractLoggerService } from './abstract-logger.service'; import type { AbstractLoggerService } from './abstract-logger.service';
@Injectable() @Injectable()

View File

@ -1,4 +1,4 @@
import { Injectable } from 'injection-js'; import { Injectable } from '@outposts/injection-js';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';
import { injectAbstractType } from '../injection/inject'; import { injectAbstractType } from '../injection/inject';
import { AbstractLoggerService } from './abstract-logger.service'; import { AbstractLoggerService } from './abstract-logger.service';

View File

@ -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 Observable, of, throwError } from 'rxjs';
import type { AuthOptions } from '../auth-options'; import type { AuthOptions } from '../auth-options';
import type { OpenIdConfiguration } from '../config/openid-configuration'; import type { OpenIdConfiguration } from '../config/openid-configuration';

View File

@ -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 Observable, of, throwError } from 'rxjs';
import { map, switchMap, take } from 'rxjs/operators'; import { map, switchMap, take } from 'rxjs/operators';
import type { AuthOptions } from '../../auth-options'; import type { AuthOptions } from '../../auth-options';

View File

@ -1,5 +1,5 @@
import { HttpHeaders } from '@ngify/http'; 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 { type Observable, throwError } from 'rxjs';
import { catchError, map, retry, switchMap } from 'rxjs/operators'; import { catchError, map, retry, switchMap } from 'rxjs/operators';
import { DataService } from '../../api/data.service'; import { DataService } from '../../api/data.service';
@ -74,7 +74,8 @@ export class ParService {
}; };
}), }),
catchError((error) => { 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); this.loggerService.logError(configuration, errorMessage, error);

View File

@ -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 Observable, of, throwError } from 'rxjs';
import { switchMap, take, tap } from 'rxjs/operators'; import { switchMap, take, tap } from 'rxjs/operators';
import type { AuthOptions } from '../../auth-options'; import type { AuthOptions } from '../../auth-options';

View File

@ -1,7 +1,7 @@
import { DOCUMENT } from '../../dom'; import { Injectable, inject } from '@outposts/injection-js';
import { inject, Injectable } from 'injection-js';
import { type Observable, Subject } from 'rxjs'; import { type Observable, Subject } from 'rxjs';
import type { OpenIdConfiguration } from '../../config/openid-configuration'; import type { OpenIdConfiguration } from '../../config/openid-configuration';
import { DOCUMENT } from '../../dom';
import { LoggerService } from '../../logging/logger.service'; import { LoggerService } from '../../logging/logger.service';
import { StoragePersistenceService } from '../../storage/storage-persistence.service'; import { StoragePersistenceService } from '../../storage/storage-persistence.service';
import type { PopupOptions } from './popup-options'; import type { PopupOptions } from './popup-options';

View File

@ -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 type { OpenIdConfiguration } from '../../config/openid-configuration';
import { LoggerService } from '../../logging/logger.service'; import { LoggerService } from '../../logging/logger.service';
import { FlowHelper } from '../../utils/flowHelper/flow-helper.service'; import { FlowHelper } from '../../utils/flowHelper/flow-helper.service';

View File

@ -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 Observable, map, of, switchMap } from 'rxjs';
import type { AuthOptions } from '../../auth-options'; import type { AuthOptions } from '../../auth-options';
import { AuthWellKnownService } from '../../config/auth-well-known/auth-well-known.service'; import { AuthWellKnownService } from '../../config/auth-well-known/auth-well-known.service';

View File

@ -1,5 +1,5 @@
import { HttpHeaders } from '@ngify/http'; 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 { type Observable, of, throwError } from 'rxjs';
import { catchError, concatMap, retry, switchMap } from 'rxjs/operators'; import { catchError, concatMap, retry, switchMap } from 'rxjs/operators';
import { DataService } from '../api/data.service'; import { DataService } from '../api/data.service';

View File

@ -1,4 +1,4 @@
import { Injectable, inject } from 'injection-js'; import { Injectable, inject } from '@outposts/injection-js';
import { BehaviorSubject, type Observable } from 'rxjs'; import { BehaviorSubject, type Observable } from 'rxjs';
import { concatMap, map, switchMap } from 'rxjs/operators'; import { concatMap, map, switchMap } from 'rxjs/operators';
import type { AuthOptions, LogoutAuthOptions } from './auth-options'; import type { AuthOptions, LogoutAuthOptions } from './auth-options';

View File

@ -1,8 +1,6 @@
import { TestBed } from '@/testing'; import { TestBed } from '@/testing';
import { mockClass, mockProvider } from '@/testing/mock'; import { mockProvider } from '@/testing/mock';
import { APP_INITIALIZER } from 'oidc-client-rx';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { vi } from 'vitest';
import { PASSED_CONFIG } from './auth-config'; import { PASSED_CONFIG } from './auth-config';
import { ConfigurationService } from './config/config.service'; import { ConfigurationService } from './config/config.service';
import { import {
@ -10,8 +8,7 @@ import {
StsConfigLoader, StsConfigLoader,
StsConfigStaticLoader, StsConfigStaticLoader,
} from './config/loader/config-loader'; } from './config/loader/config-loader';
import { OidcSecurityService } from './oidc.security.service'; import { provideAuth } from './provide-auth';
import { provideAuth, withAppInitializerAuthCheck } from './provide-auth';
describe('provideAuth', () => { describe('provideAuth', () => {
describe('APP_CONFIG', () => { describe('APP_CONFIG', () => {
@ -59,37 +56,37 @@ describe('provideAuth', () => {
}); });
}); });
describe('features', () => { // describe('features', () => {
let oidcSecurityServiceMock: OidcSecurityService; // let oidcSecurityServiceMock: OidcSecurityService;
let spy: any; // let spy: any;
beforeEach(async () => { // beforeEach(async () => {
//@ts-ignore // //@ts-ignore
oidcSecurityServiceMock = new (mockClass(OidcSecurityService))(); // oidcSecurityServiceMock = new (mockClass(OidcSecurityService))();
spy = vi.spyOn(oidcSecurityServiceMock, 'checkAuthMultiple'); // spy = vi.spyOn(oidcSecurityServiceMock, 'checkAuthMultiple');
await TestBed.configureTestingModule({ // await TestBed.configureTestingModule({
providers: [ // providers: [
provideAuth( // provideAuth(
{ config: { authority: 'something' } }, // { config: { authority: 'something' } },
withAppInitializerAuthCheck() // withAppInitializerAuthCheck()
), // ),
mockProvider(ConfigurationService), // mockProvider(ConfigurationService),
{ // {
provide: OidcSecurityService, // provide: OidcSecurityService,
useValue: oidcSecurityServiceMock, // useValue: oidcSecurityServiceMock,
}, // },
], // ],
}).compileComponents(); // }).compileComponents();
}); // });
it('should provide APP_INITIALIZER config', () => { // it('should provide APP_INITIALIZER config', () => {
const config = TestBed.inject(APP_INITIALIZER); // const config = TestBed.inject(APP_INITIALIZER);
expect( // expect(
config.length, // config.length,
'Expected an APP_INITIALIZER to be registered' // 'Expected an APP_INITIALIZER to be registered'
).toBe(1); // ).toBe(1);
expect(spy).toHaveBeenCalledTimes(1); // expect(spy).toHaveBeenCalledTimes(1);
}); // });
}); // });
}); });

View File

@ -1,15 +1,12 @@
import type { Provider } from 'injection-js'; import type { Provider } from '@outposts/injection-js';
import { firstValueFrom } from 'rxjs';
import { import {
PASSED_CONFIG, PASSED_CONFIG,
type PassedInitialConfig, type PassedInitialConfig,
createStaticLoader, createStaticLoader,
} from './auth-config'; } from './auth-config';
import { StsConfigLoader } from './config/loader/config-loader'; import { StsConfigLoader } from './config/loader/config-loader';
import { APP_INITIALIZER } from './injection';
import { AbstractLoggerService } from './logging/abstract-logger.service'; import { AbstractLoggerService } from './logging/abstract-logger.service';
import { ConsoleLoggerService } from './logging/console-logger.service'; import { ConsoleLoggerService } from './logging/console-logger.service';
import { OidcSecurityService } from './oidc.security.service';
import { AbstractSecurityStorage } from './storage/abstract-security-storage'; import { AbstractSecurityStorage } from './storage/abstract-security-storage';
import { DefaultSessionStorageService } from './storage/default-sessionstorage.service'; import { DefaultSessionStorageService } from './storage/default-sessionstorage.service';
@ -51,26 +48,3 @@ export function _provideAuth(passedConfig: PassedInitialConfig): Provider[] {
{ provide: AbstractLoggerService, useClass: ConsoleLoggerService }, { 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],
},
],
};
}

View File

@ -1,5 +0,0 @@
/*
* Public API Surface of oidc-client-rx
*/
export * from '.';

View File

@ -1,4 +1,4 @@
import { Injectable } from 'injection-js'; import { Injectable } from '@outposts/injection-js';
import { type Observable, ReplaySubject } from 'rxjs'; import { type Observable, ReplaySubject } from 'rxjs';
import type { EventTypes } from './event-types'; import type { EventTypes } from './event-types';
import type { OidcClientNotification } from './notification'; import type { OidcClientNotification } from './notification';

View File

@ -14,24 +14,15 @@ export interface UrlTree {
toString(): string; toString(): string;
} }
export interface NavigationExtras { export interface Navigation<URL extends UrlTree = UrlTree> {
[key: string]: any; extractedUrl: URL;
} }
export interface Navigation { export abstract class AbstractRouter<
id: number; URL extends UrlTree = UrlTree,
initialUrl: UrlTree; NAVIGATION extends Navigation<URL> = Navigation<URL>,
extractedUrl: UrlTree; > {
finalUrl?: UrlTree | undefined;
trigger: 'imperative' | 'popstate' | 'hashchange';
previousNavigation: Navigation | null;
extras?: NavigationExtras;
}
export abstract class AbstractRouter {
abstract navigateByUrl(url: string): void; abstract navigateByUrl(url: string): void;
abstract getCurrentNavigation(): Navigation; abstract getCurrentNavigation(): NAVIGATION;
abstract parseUrl(_url: string): any;
} }

View File

@ -1,4 +1,4 @@
import { Injectable } from 'injection-js'; import { Injectable } from '@outposts/injection-js';
/** /**
* Implement this class-interface to create a custom storage. * Implement this class-interface to create a custom storage.

View File

@ -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 type { OpenIdConfiguration } from '../config/openid-configuration';
import { injectAbstractType } from '../injection'; import { injectAbstractType } from '../injection';
import { LoggerService } from '../logging/logger.service'; import { LoggerService } from '../logging/logger.service';

View File

@ -1,4 +1,4 @@
import { Injectable } from 'injection-js'; import { Injectable } from '@outposts/injection-js';
import type { AbstractSecurityStorage } from './abstract-security-storage'; import type { AbstractSecurityStorage } from './abstract-security-storage';
@Injectable() @Injectable()

Some files were not shown because too many files have changed in this diff Show More