@travetto/auth-web 6.0.0-rc.4 → 6.0.0-rc.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 +1 -0
- package/package.json +2 -2
- package/support/test/server.ts +9 -9
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ The only required method to be defined is the `authenticate` method. This takes
|
|
|
62
62
|
* Returning an [Principal](https://github.com/travetto/travetto/tree/main/module/auth/src/types/principal.ts#L7) if authentication was successful
|
|
63
63
|
* Throwing an error if it failed
|
|
64
64
|
* Returning undefined if the authentication is multi-staged and has not completed yet
|
|
65
|
+
|
|
65
66
|
A sample auth provider would look like:
|
|
66
67
|
|
|
67
68
|
**Code: Sample Identity Source**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/auth-web",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.6",
|
|
4
4
|
"description": "Web authentication integration support for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@travetto/auth": "^6.0.0-rc.2",
|
|
30
30
|
"@travetto/config": "^6.0.0-rc.2",
|
|
31
|
-
"@travetto/web": "^6.0.0-rc.
|
|
31
|
+
"@travetto/web": "^6.0.0-rc.4",
|
|
32
32
|
"njwt": "^2.0.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
package/support/test/server.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import timers from 'node:timers/promises';
|
|
2
2
|
import assert from 'node:assert';
|
|
3
3
|
|
|
4
|
-
import { Controller, Get, WebHeaders, WebResponse, Post } from '@travetto/web';
|
|
4
|
+
import { Controller, Get, WebHeaders, WebResponse, Post, Cookie, CookieJar } from '@travetto/web';
|
|
5
5
|
import { Suite, Test } from '@travetto/test';
|
|
6
6
|
import { DependencyRegistry, Inject, InjectableFactory } from '@travetto/di';
|
|
7
7
|
import { AuthenticationError, Authenticator, AuthContext, AuthConfig } from '@travetto/auth';
|
|
@@ -90,16 +90,16 @@ export abstract class AuthWebServerSuite extends BaseWebSuite {
|
|
|
90
90
|
@Inject()
|
|
91
91
|
config: WebAuthConfig;
|
|
92
92
|
|
|
93
|
-
getCookie(headers: WebHeaders):
|
|
94
|
-
return headers.getSetCookie()[0];
|
|
93
|
+
getCookie(headers: WebHeaders): Cookie | undefined {
|
|
94
|
+
return new CookieJar().importSetCookieHeader(headers.getSetCookie()).getAll()[0];
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
return
|
|
97
|
+
getCookieHeader(headers: WebHeaders): string | undefined {
|
|
98
|
+
return new CookieJar().importSetCookieHeader(headers.getSetCookie()).exportCookieHeader();
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
getCookieExpires(headers: WebHeaders): Date | undefined {
|
|
102
|
-
const v = this.getCookie(headers)?.
|
|
102
|
+
const v = this.getCookie(headers)?.expires;
|
|
103
103
|
return v ? new Date(v) : undefined;
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -152,7 +152,7 @@ export abstract class AuthWebServerSuite extends BaseWebSuite {
|
|
|
152
152
|
}
|
|
153
153
|
}, false);
|
|
154
154
|
assert(statusCode === 201);
|
|
155
|
-
const cookie = this.
|
|
155
|
+
const cookie = this.getCookieHeader(headers);
|
|
156
156
|
assert(cookie);
|
|
157
157
|
|
|
158
158
|
const { context: { httpStatusCode: lastStatus } } = await this.request({
|
|
@@ -225,7 +225,7 @@ export abstract class AuthWebServerSuite extends BaseWebSuite {
|
|
|
225
225
|
}
|
|
226
226
|
}, false);
|
|
227
227
|
assert(statusCode === 201);
|
|
228
|
-
const cookie = this.
|
|
228
|
+
const cookie = this.getCookieHeader(headers);
|
|
229
229
|
assert(cookie);
|
|
230
230
|
|
|
231
231
|
const { body, context: { httpStatusCode: lastStatus } } = await this.request({
|
|
@@ -253,7 +253,7 @@ export abstract class AuthWebServerSuite extends BaseWebSuite {
|
|
|
253
253
|
assert(statusCode === 201);
|
|
254
254
|
|
|
255
255
|
const start = Date.now();
|
|
256
|
-
const cookie = this.
|
|
256
|
+
const cookie = this.getCookieHeader(headers);
|
|
257
257
|
assert(cookie);
|
|
258
258
|
|
|
259
259
|
const expires = this.getCookieExpires(headers);
|