File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ describe("whoAmI", () => {
6
6
it ( "should fetch identity info" , async ( ) => {
7
7
const info = await whoAmI ( { credentials : { accessToken : TEST_ACCESS_TOKEN } , hubUrl : TEST_HUB_URL } ) ;
8
8
9
+ if ( info . auth . accessToken ?. createdAt instanceof Date ) {
10
+ info . auth . accessToken . createdAt = new Date ( 0 ) ;
11
+ }
12
+
9
13
assert . deepStrictEqual ( info , {
10
14
type : "user" ,
11
15
id : "62f264b9f3c90f4b6514a269" ,
@@ -21,6 +25,7 @@ describe("whoAmI", () => {
21
25
auth : {
22
26
type : "access_token" ,
23
27
accessToken : {
28
+ createdAt : new Date ( 0 ) ,
24
29
displayName : "ci-hub.js" ,
25
30
role : "write" ,
26
31
} ,
Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ export interface AuthInfo {
52
52
type : AuthType ;
53
53
accessToken ?: {
54
54
displayName : string ;
55
- expiration ?: Date ;
56
55
role : AccessTokenRole ;
56
+ createdAt : Date ;
57
57
} ;
58
58
expiresAt ?: Date ;
59
59
}
@@ -79,17 +79,11 @@ export async function whoAmI(params: {
79
79
}
80
80
81
81
const response : ApiWhoAmIReponse & {
82
- auth : Omit < AuthInfo , "accessToken" > & {
83
- accessToken ?: {
84
- displayName : string ;
85
- expiration ?: Date ; // actually string but we fix it below
86
- role : AccessTokenRole ;
87
- } ;
88
- } ;
82
+ auth : AuthInfo ;
89
83
} = await res . json ( ) ;
90
84
91
- if ( typeof response . auth . accessToken ?. expiration === "string" ) {
92
- response . auth . accessToken . expiration = new Date ( response . auth . accessToken . expiration ) ;
85
+ if ( typeof response . auth . accessToken ?. createdAt === "string" ) {
86
+ response . auth . accessToken . createdAt = new Date ( response . auth . accessToken . createdAt ) ;
93
87
}
94
88
95
89
return response ;
You can’t perform that action at this time.
0 commit comments