1- import type { IdentityResponseData } from '#src/client/types.js' ;
21import type { TLSConfig } from '#network/types.js' ;
32import fs from 'node:fs' ;
43import path from 'node:path' ;
@@ -7,17 +6,17 @@ import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger';
76import { RPCClient } from '@matrixai/rpc' ;
87import { WebSocketClient } from '@matrixai/ws' ;
98import * as testsUtils from '../../utils/index.js' ;
10- import { AuthSignToken } from '#client/handlers/index.js' ;
11- import { authSignToken } from '#client/callers/index.js' ;
9+ import { AuthIdentityToken } from '#client/handlers/index.js' ;
10+ import { authIdentityToken } from '#client/callers/index.js' ;
1211import KeyRing from '#keys/KeyRing.js' ;
1312import Token from '#tokens/Token.js' ;
1413import ClientService from '#client/ClientService.js' ;
1514import * as keysUtils from '#keys/utils/index.js' ;
1615import * as networkUtils from '#network/utils.js' ;
1716import * as nodesUtils from '#nodes/utils.js' ;
1817
19- describe ( 'authSignToken ' , ( ) => {
20- const logger = new Logger ( 'authSignToken test' , LogLevel . WARN , [
18+ describe ( 'authIdentityToken ' , ( ) => {
19+ const logger = new Logger ( 'authIdentityToken test' , LogLevel . WARN , [
2120 new StreamHandler (
2221 formatting . format `${ formatting . level } :${ formatting . keys } :${ formatting . msg } ` ,
2322 ) ,
@@ -30,7 +29,7 @@ describe('authSignToken', () => {
3029 let clientService : ClientService ;
3130 let webSocketClient : WebSocketClient ;
3231 let rpcClient : RPCClient < {
33- authSignToken : typeof authSignToken ;
32+ authIdentityToken : typeof authIdentityToken ;
3433 } > ;
3534
3635 beforeEach ( async ( ) => {
@@ -53,7 +52,7 @@ describe('authSignToken', () => {
5352 } ) ;
5453 await clientService . start ( {
5554 manifest : {
56- authSignToken : new AuthSignToken ( {
55+ authIdentityToken : new AuthIdentityToken ( {
5756 keyRing,
5857 } ) ,
5958 } ,
@@ -69,7 +68,7 @@ describe('authSignToken', () => {
6968 } ) ;
7069 rpcClient = new RPCClient ( {
7170 manifest : {
72- authSignToken ,
71+ authIdentityToken ,
7372 } ,
7473 streamFactory : ( ) => webSocketClient . connection . newStream ( ) ,
7574 toError : networkUtils . toError ,
@@ -89,11 +88,13 @@ describe('authSignToken', () => {
8988 } ) ;
9089
9190 test ( 'should return a signed token' , async ( ) => {
92- const identityToken = await rpcClient . methods . authSignToken ( { } ) ;
93- const decodedToken = Token . fromEncoded < IdentityResponseData > ( identityToken ) ;
91+ const identityToken = await rpcClient . methods . authIdentityToken ( { } ) ;
92+ const decodedToken = Token . fromEncoded ( identityToken ) ;
9493 const decodedPublicKey = keysUtils . publicKeyFromNodeId ( keyRing . getNodeId ( ) ) ;
9594 expect ( decodedToken . verifyWithPublicKey ( decodedPublicKey ) ) . toBeTrue ( ) ;
9695 const encodedNodeId = nodesUtils . encodeNodeId ( keyRing . getNodeId ( ) ) ;
97- expect ( decodedToken . payload . nodeId ) . toBe ( encodedNodeId ) ;
96+ expect ( decodedToken . payload . iss ) . toBe ( encodedNodeId ) ;
97+ expect ( decodedToken . payload . exp ) . toBeDefined ( ) ;
98+ expect ( decodedToken . payload . jti ) . toBeDefined ( ) ;
9899 } ) ;
99100} ) ;
0 commit comments