From 594f97fca0b451cd103cbea4b7320cae22069a2b Mon Sep 17 00:00:00 2001 From: cipchk Date: Tue, 20 Aug 2024 23:23:45 +0800 Subject: [PATCH] docs(auth): typo - close https://github.com/ng-alain/ng-alain/issues/2516 --- packages/auth/docs/getting-started.en-US.md | 3 ++- packages/auth/docs/getting-started.zh-CN.md | 3 ++- packages/auth/docs/send.en-US.md | 12 ++++++------ packages/auth/docs/send.zh-CN.md | 13 +++++++------ packages/auth/docs/set.en-US.md | 3 ++- packages/auth/docs/set.zh-CN.md | 3 ++- packages/auth/src/store/cookie-storage.service.ts | 3 ++- packages/auth/src/store/local-storage.service.ts | 3 ++- packages/auth/src/store/session-storage.service.ts | 3 ++- 9 files changed, 27 insertions(+), 19 deletions(-) diff --git a/packages/auth/docs/getting-started.en-US.md b/packages/auth/docs/getting-started.en-US.md index e7abe0b84..d142fdc67 100644 --- a/packages/auth/docs/getting-started.en-US.md +++ b/packages/auth/docs/getting-started.en-US.md @@ -49,7 +49,8 @@ Configure the `provideAuth` environment in `app.config.ts`: ```typescript providers: [ // Indicates using JWT style and using `localStorage` to store Token - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/docs/getting-started.zh-CN.md b/packages/auth/docs/getting-started.zh-CN.md index 112fd24ed..012e141b1 100644 --- a/packages/auth/docs/getting-started.zh-CN.md +++ b/packages/auth/docs/getting-started.zh-CN.md @@ -49,7 +49,8 @@ npm i -S @delon/auth ```typescript providers: [ // 表示使用JWT风格并用 `localStorage` 存储 Token - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/docs/send.en-US.md b/packages/auth/docs/send.en-US.md index 49f7c49ec..5161ce005 100644 --- a/packages/auth/docs/send.en-US.md +++ b/packages/auth/docs/send.en-US.md @@ -10,7 +10,7 @@ type: Documents It is better to add the corresponding authentication information to each request through the HTTP interceptor. `@delonn/auth` implements two separate HTTP interceptors based on two different authentication styles. -### withSimple +### authSimpleInterceptor The parameter name and its sending location can be specified via `DelonAuthConfig`, for example: @@ -22,15 +22,15 @@ token_send_place = 'header'; Indicates the `{ token: 'Bearer token_string' }` data in the `header` of each request. -### withJWT +### authJWTInterceptor It is a standard JWT sending rule that automatically adds `{ Authorization: 'Bearer token_string' }` to `header`. ### How to choose? -`withSimple` is a very liberal style, you can put `token` in the request body, request header, etc. +`authSimpleInterceptor` is a very liberal style, you can put `token` in the request body, request header, etc. -`withJWT` is a JWT standard, which needs to ensure that the backend also uses such standards. +`authJWTInterceptor` is a JWT standard, which needs to ensure that the backend also uses such standards. ## How to load @@ -38,9 +38,9 @@ In `app.config.ts` file: ```ts providers: [ - provideAuth(withSimple()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])), // Or JWT - provideAuth(withJWT()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), ] ``` diff --git a/packages/auth/docs/send.zh-CN.md b/packages/auth/docs/send.zh-CN.md index 46b857dfc..d32634341 100644 --- a/packages/auth/docs/send.zh-CN.md +++ b/packages/auth/docs/send.zh-CN.md @@ -8,7 +8,7 @@ type: Documents 通过HTTP拦截器在每一个请求中加入相应的认证信息,这是再好不过。`@delonn/auth` 根据两种不同认证风格,实现两种各自的HTTP拦截器。 -### withSimple +### authSimpleInterceptor 透过 `DelonAuthConfig` 可以指定参数名以及其发送位置,例如: @@ -20,15 +20,15 @@ token_send_place = 'header'; 表示在每一个请求的 `header` 加上 `{ token: 'Bearer token_string' }` 数据。 -### withJWT +### authJWTInterceptor 它是一个标准JWT的发送规则,即在 `header` 自动加上 `{ Authorization: 'Bearer token_string' }`。 ### 如何选择? -`withSimple` 是一种自由度非常高的风格,你可以将 `token` 放在请求体、请求头等当中。 +`authSimpleInterceptor` 是一种自由度非常高的风格,你可以将 `token` 放在请求体、请求头等当中。 -`withJWT` 是一个 JWT 标准,这需要确保后端也采用这类标准。 +`authJWTInterceptor` 是一个 JWT 标准,这需要确保后端也采用这类标准。 ## 如何加载 @@ -36,9 +36,10 @@ token_send_place = 'header'; ```ts providers: [ - provideAuth(withSimple()), + // 表示使用JWT风格并用 `localStorage` 存储 Token + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])), // Or JWT - provideAuth(withJWT()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), ] ``` diff --git a/packages/auth/docs/set.en-US.md b/packages/auth/docs/set.en-US.md index 6fcc342a0..8eb5f4373 100644 --- a/packages/auth/docs/set.en-US.md +++ b/packages/auth/docs/set.en-US.md @@ -32,7 +32,8 @@ The default is to use `withLocalStorage` persistent storage. You can change othe ```ts providers: [ - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/docs/set.zh-CN.md b/packages/auth/docs/set.zh-CN.md index 47306d95d..3326f2c86 100644 --- a/packages/auth/docs/set.zh-CN.md +++ b/packages/auth/docs/set.zh-CN.md @@ -30,7 +30,8 @@ constructor(@Inject(DA_SERVICE_TOKEN) service: ITokenService) { ```ts providers: [ - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/src/store/cookie-storage.service.ts b/packages/auth/src/store/cookie-storage.service.ts index 79b3d70f8..ac5374745 100644 --- a/packages/auth/src/store/cookie-storage.service.ts +++ b/packages/auth/src/store/cookie-storage.service.ts @@ -9,7 +9,8 @@ import { IStore } from './interface'; * `cookie` storage * * ```ts - * provideAuth(withJWT(), withCookie()) + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withCookie()), * ``` */ export class CookieStorageStore implements IStore { diff --git a/packages/auth/src/store/local-storage.service.ts b/packages/auth/src/store/local-storage.service.ts index 271fb6bfe..96fe3c115 100644 --- a/packages/auth/src/store/local-storage.service.ts +++ b/packages/auth/src/store/local-storage.service.ts @@ -9,7 +9,8 @@ export function DA_STORE_TOKEN_LOCAL_FACTORY(): IStore { * `localStorage` storage, **not lost after closing the browser**. * * ```ts - * provideAuth(withJWT(), withLocalStorage()) + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), * ``` */ export class LocalStorageStore implements IStore { diff --git a/packages/auth/src/store/session-storage.service.ts b/packages/auth/src/store/session-storage.service.ts index 8922173d7..78bf9ecd5 100644 --- a/packages/auth/src/store/session-storage.service.ts +++ b/packages/auth/src/store/session-storage.service.ts @@ -5,7 +5,8 @@ import { IStore } from './interface'; * `sessionStorage` storage, **lost after closing the browser**. * * ```ts - * provideAuth(withJWT(), withSessionStorage()) + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withSessionStorage()), * ``` */ export class SessionStorageStore implements IStore {