@travetto/auth-web 7.0.4 → 7.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/package.json +5 -5
- package/src/codec.ts +4 -4
- package/src/decorator.ts +1 -1
- package/src/interceptors/context.ts +4 -4
- package/src/interceptors/login.ts +2 -2
- package/src/interceptors/logout.ts +2 -2
- package/src/interceptors/verify.ts +2 -2
- package/src/internal/principal-schema.ts +2 -2
- package/src/types.ts +2 -2
- package/support/test/server.ts +3 -3
package/README.md
CHANGED
|
@@ -26,8 +26,8 @@ Every external framework integration relies upon the [Authenticator](https://git
|
|
|
26
26
|
|
|
27
27
|
**Code: Structure for the Identity Source**
|
|
28
28
|
```typescript
|
|
29
|
-
import { AnyMap } from '@travetto/runtime';
|
|
30
|
-
import { Principal } from './principal.ts';
|
|
29
|
+
import type { AnyMap } from '@travetto/runtime';
|
|
30
|
+
import type { Principal } from './principal.ts';
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Represents the general shape of additional login context, usually across multiple calls
|
|
@@ -67,7 +67,7 @@ A sample auth provider would look like:
|
|
|
67
67
|
|
|
68
68
|
**Code: Sample Identity Source**
|
|
69
69
|
```typescript
|
|
70
|
-
import { AuthenticationError, Authenticator } from '@travetto/auth';
|
|
70
|
+
import { AuthenticationError, type Authenticator } from '@travetto/auth';
|
|
71
71
|
|
|
72
72
|
type User = { username: string, password: string };
|
|
73
73
|
|
|
@@ -120,13 +120,13 @@ The [PrincipalCodec](https://github.com/travetto/travetto/tree/main/module/auth-
|
|
|
120
120
|
```typescript
|
|
121
121
|
import type { Jwt, Verifier, SupportedAlgorithms } from 'njwt';
|
|
122
122
|
|
|
123
|
-
import { AuthContext, AuthenticationError, AuthToken, Principal } from '@travetto/auth';
|
|
123
|
+
import { type AuthContext, AuthenticationError, type AuthToken, type Principal } from '@travetto/auth';
|
|
124
124
|
import { Injectable, Inject } from '@travetto/di';
|
|
125
|
-
import { WebResponse, WebRequest, WebAsyncContext, CookieJar } from '@travetto/web';
|
|
125
|
+
import { type WebResponse, type WebRequest, type WebAsyncContext, CookieJar } from '@travetto/web';
|
|
126
126
|
import { AppError, castTo, TimeUtil } from '@travetto/runtime';
|
|
127
127
|
|
|
128
|
-
import { CommonPrincipalCodecSymbol, PrincipalCodec } from './types.ts';
|
|
129
|
-
import { WebAuthConfig } from './config.ts';
|
|
128
|
+
import { CommonPrincipalCodecSymbol, type PrincipalCodec } from './types.ts';
|
|
129
|
+
import type { WebAuthConfig } from './config.ts';
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* JWT Principal codec
|
|
@@ -222,11 +222,11 @@ A trivial/sample custom [PrincipalCodec](https://github.com/travetto/travetto/tr
|
|
|
222
222
|
|
|
223
223
|
**Code: Custom Principal Codec**
|
|
224
224
|
```typescript
|
|
225
|
-
import { Principal } from '@travetto/auth';
|
|
226
|
-
import { PrincipalCodec } from '@travetto/auth-web';
|
|
225
|
+
import type { Principal } from '@travetto/auth';
|
|
226
|
+
import type { PrincipalCodec } from '@travetto/auth-web';
|
|
227
227
|
import { Injectable } from '@travetto/di';
|
|
228
228
|
import { BinaryUtil } from '@travetto/runtime';
|
|
229
|
-
import { WebResponse, WebRequest } from '@travetto/web';
|
|
229
|
+
import type { WebResponse, WebRequest } from '@travetto/web';
|
|
230
230
|
|
|
231
231
|
@Injectable()
|
|
232
232
|
export class CustomCodec implements PrincipalCodec {
|
|
@@ -261,7 +261,7 @@ This implementation is not suitable for production, but shows the general patter
|
|
|
261
261
|
```typescript
|
|
262
262
|
import { Controller, Get, ContextParam, WebResponse } from '@travetto/web';
|
|
263
263
|
import { Login, Authenticated, Logout } from '@travetto/auth-web';
|
|
264
|
-
import { Principal } from '@travetto/auth';
|
|
264
|
+
import type { Principal } from '@travetto/auth';
|
|
265
265
|
|
|
266
266
|
import { FbAuthSymbol } from './facebook.ts';
|
|
267
267
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/auth-web",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Web authentication integration support for the Travetto framework",
|
|
6
6
|
"keywords": [
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"directory": "module/auth-web"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/auth": "^7.0.
|
|
31
|
-
"@travetto/config": "^7.0.
|
|
32
|
-
"@travetto/web": "^7.0.
|
|
30
|
+
"@travetto/auth": "^7.0.6",
|
|
31
|
+
"@travetto/config": "^7.0.6",
|
|
32
|
+
"@travetto/web": "^7.0.6",
|
|
33
33
|
"njwt": "^2.0.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/test": "^7.0.
|
|
36
|
+
"@travetto/test": "^7.0.6"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/test": {
|
package/src/codec.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Jwt, Verifier, SupportedAlgorithms } from 'njwt';
|
|
2
2
|
|
|
3
|
-
import { AuthContext, AuthenticationError, AuthToken, Principal } from '@travetto/auth';
|
|
3
|
+
import { type AuthContext, AuthenticationError, type AuthToken, type Principal } from '@travetto/auth';
|
|
4
4
|
import { Injectable, Inject } from '@travetto/di';
|
|
5
|
-
import { WebResponse, WebRequest, WebAsyncContext, CookieJar } from '@travetto/web';
|
|
5
|
+
import { type WebResponse, type WebRequest, type WebAsyncContext, CookieJar } from '@travetto/web';
|
|
6
6
|
import { AppError, castTo, TimeUtil } from '@travetto/runtime';
|
|
7
7
|
|
|
8
|
-
import { CommonPrincipalCodecSymbol, PrincipalCodec } from './types.ts';
|
|
9
|
-
import { WebAuthConfig } from './config.ts';
|
|
8
|
+
import { CommonPrincipalCodecSymbol, type PrincipalCodec } from './types.ts';
|
|
9
|
+
import type { WebAuthConfig } from './config.ts';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* JWT Principal codec
|
package/src/decorator.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ControllerRegistryIndex, EndpointDecorator } from '@travetto/web';
|
|
1
|
+
import { ControllerRegistryIndex, type EndpointDecorator } from '@travetto/web';
|
|
2
2
|
|
|
3
3
|
import { AuthVerifyInterceptor } from './interceptors/verify.ts';
|
|
4
4
|
import { AuthLoginInterceptor } from './interceptors/login.ts';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { toConcrete } from '@travetto/runtime';
|
|
2
|
-
import { WebInterceptor, WebAsyncContext, WebInterceptorCategory, WebChainedContext, WebResponse } from '@travetto/web';
|
|
2
|
+
import type { WebInterceptor, WebAsyncContext, WebInterceptorCategory, WebChainedContext, WebResponse } from '@travetto/web';
|
|
3
3
|
import { Injectable, Inject, DependencyRegistryIndex } from '@travetto/di';
|
|
4
|
-
import { AuthContext, AuthService, AuthToken, Principal } from '@travetto/auth';
|
|
4
|
+
import type { AuthContext, AuthService, AuthToken, Principal } from '@travetto/auth';
|
|
5
5
|
import { Required } from '@travetto/schema';
|
|
6
6
|
|
|
7
|
-
import { CommonPrincipalCodecSymbol, PrincipalCodec } from '../types.ts';
|
|
8
|
-
import { WebAuthConfig } from '../config.ts';
|
|
7
|
+
import { CommonPrincipalCodecSymbol, type PrincipalCodec } from '../types.ts';
|
|
8
|
+
import type { WebAuthConfig } from '../config.ts';
|
|
9
9
|
|
|
10
10
|
const toDate = (value: string | Date | undefined): Date | undefined => (typeof value === 'string') ? new Date(value) : value;
|
|
11
11
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { WebInterceptor, WebInterceptorCategory, WebChainedContext, WebResponse, WebInterceptorContext } from '@travetto/web';
|
|
1
|
+
import type { WebInterceptor, WebInterceptorCategory, WebChainedContext, WebResponse, WebInterceptorContext } from '@travetto/web';
|
|
2
2
|
import { Injectable, Inject } from '@travetto/di';
|
|
3
3
|
import { Config } from '@travetto/config';
|
|
4
4
|
import { Ignore } from '@travetto/schema';
|
|
5
|
-
import { AuthService } from '@travetto/auth';
|
|
5
|
+
import type { AuthService } from '@travetto/auth';
|
|
6
6
|
|
|
7
7
|
import { AuthContextInterceptor } from './context.ts';
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WebInterceptor, WebInterceptorCategory, WebChainedContext, WebResponse, WebInterceptorContext } from '@travetto/web';
|
|
1
|
+
import type { WebInterceptor, WebInterceptorCategory, WebChainedContext, WebResponse, WebInterceptorContext } from '@travetto/web';
|
|
2
2
|
import { Injectable, Inject } from '@travetto/di';
|
|
3
3
|
import { Config } from '@travetto/config';
|
|
4
|
-
import { AuthContext, AuthenticationError } from '@travetto/auth';
|
|
4
|
+
import { type AuthContext, AuthenticationError } from '@travetto/auth';
|
|
5
5
|
|
|
6
6
|
import { AuthContextInterceptor } from './context.ts';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AppError, Util } from '@travetto/runtime';
|
|
2
|
-
import { WebInterceptor, WebInterceptorCategory, WebChainedContext, WebResponse, WebInterceptorContext } from '@travetto/web';
|
|
2
|
+
import type { WebInterceptor, WebInterceptorCategory, WebChainedContext, WebResponse, WebInterceptorContext } from '@travetto/web';
|
|
3
3
|
import { Injectable, Inject } from '@travetto/di';
|
|
4
4
|
import { Config } from '@travetto/config';
|
|
5
5
|
import { Ignore } from '@travetto/schema';
|
|
6
|
-
import { AuthenticationError, AuthContext } from '@travetto/auth';
|
|
6
|
+
import { AuthenticationError, type AuthContext } from '@travetto/auth';
|
|
7
7
|
|
|
8
8
|
import { AuthContextInterceptor } from './context.ts';
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema, SchemaRegistryIndex } from '@travetto/schema';
|
|
2
|
-
import { toConcrete, AnyMap } from '@travetto/runtime';
|
|
3
|
-
import { Principal } from '@travetto/auth';
|
|
2
|
+
import { toConcrete, type AnyMap } from '@travetto/runtime';
|
|
3
|
+
import type { Principal } from '@travetto/auth';
|
|
4
4
|
|
|
5
5
|
@Schema()
|
|
6
6
|
export class PrincipalSchema implements Principal {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthToken, Principal } from '@travetto/auth';
|
|
2
|
-
import { WebRequest, WebResponse } from '@travetto/web';
|
|
1
|
+
import type { AuthToken, Principal } from '@travetto/auth';
|
|
2
|
+
import type { WebRequest, WebResponse } from '@travetto/web';
|
|
3
3
|
|
|
4
4
|
export const CommonPrincipalCodecSymbol = Symbol.for('@travetto/auth-web:common-codec');
|
|
5
5
|
|
package/support/test/server.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import timers from 'node:timers/promises';
|
|
2
2
|
import assert from 'node:assert';
|
|
3
3
|
|
|
4
|
-
import { Controller, Get, WebHeaders, WebResponse, Post, Cookie, CookieJar } from '@travetto/web';
|
|
4
|
+
import { Controller, Get, type WebHeaders, WebResponse, Post, type Cookie, CookieJar } from '@travetto/web';
|
|
5
5
|
import { Suite, Test } from '@travetto/test';
|
|
6
6
|
import { DependencyRegistryIndex, Inject, InjectableFactory } from '@travetto/di';
|
|
7
|
-
import { AuthenticationError, Authenticator, AuthContext, AuthConfig } from '@travetto/auth';
|
|
7
|
+
import { AuthenticationError, type Authenticator, type AuthContext, type AuthConfig } from '@travetto/auth';
|
|
8
8
|
|
|
9
9
|
import { InjectableSuite } from '@travetto/di/support/test/suite.ts';
|
|
10
10
|
import { BaseWebSuite } from '@travetto/web/support/test/suite/base.ts';
|
|
11
11
|
|
|
12
12
|
import { Login, Authenticated, Logout } from '../../src/decorator.ts';
|
|
13
|
-
import { WebAuthConfig } from '../../src/config.ts';
|
|
13
|
+
import type { WebAuthConfig } from '../../src/config.ts';
|
|
14
14
|
import { CommonPrincipalCodecSymbol } from '../../src/types.ts';
|
|
15
15
|
import { JWTPrincipalCodec } from '../../src/codec.ts';
|
|
16
16
|
|