Skip to content

Commit 9a56605

Browse files
committed
chore: rolled back changes for session tokens
1 parent b7b3bab commit 9a56605

File tree

5 files changed

+15
-68
lines changed

5 files changed

+15
-68
lines changed

src/client/handlers/AuthIdentityToken.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type {
22
ClientRPCRequestParams,
33
ClientRPCResponseResult,
4-
IdentityResponseData,
54
TokenIdentityResponse,
65
} from '../types.js';
6+
import type { AuthIdentityToken as AuthIdentityJWT } from '../../tokens/payloads/authIdentityToken.js';
77
import type KeyRing from '../../keys/KeyRing.js';
88
import { IdSortable } from '@matrixai/id';
99
import { UnaryHandler } from '@matrixai/rpc';
@@ -25,7 +25,7 @@ class AuthIdentityToken extends UnaryHandler<
2525
if (jti == null) {
2626
throw new clientErrors.ErrorClientAuthenticationInvalidJTI();
2727
}
28-
const outgoingToken = Token.fromPayload<IdentityResponseData>({
28+
const outgoingToken = Token.fromPayload<AuthIdentityJWT>({
2929
jti: jti.toMultibase('base64'),
3030
exp: Math.floor(Date.now() / 1000) + 60, // 60 seconds after issuing
3131
iss: nodesUtils.encodeNodeId(keyRing.getNodeId()),

src/client/types.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ type TokenMessage = {
108108
token: ProviderToken;
109109
};
110110

111-
type IdentityResponseData = TokenPayload & {
112-
jti: string;
113-
exp: number;
114-
iss: NodeIdEncoded;
115-
};
116-
117111
type TokenIdentityResponse = SignedTokenEncoded;
118112

119113
// Nodes messages
@@ -421,7 +415,6 @@ export type {
421415
ClaimIdMessage,
422416
ClaimNodeMessage,
423417
TokenMessage,
424-
IdentityResponseData,
425418
TokenIdentityResponse,
426419
NodeIdMessage,
427420
AddressMessage,
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,45 @@ import * as ids from '../../ids/index.js';
55
import * as validationErrors from '../../validation/errors.js';
66
import * as utils from '../../utils/index.js';
77

8-
interface AuthSignedIdentity extends TokenPayload {
9-
typ: 'AuthSignedIdentity';
8+
interface AuthIdentityToken extends TokenPayload {
109
iss: NodeIdEncoded;
1110
exp: number;
1211
jti: string;
1312
}
1413

1514
function assertAuthSignedIdentity(
16-
authSignedIdentity: unknown,
17-
): asserts authSignedIdentity is AuthSignedIdentity {
18-
if (!utils.isObject(authSignedIdentity)) {
15+
authIdentityToken: unknown,
16+
): asserts authIdentityToken is AuthIdentityToken {
17+
if (!utils.isObject(authIdentityToken)) {
1918
throw new validationErrors.ErrorParse('must be POJO');
2019
}
21-
if (authSignedIdentity['typ'] !== 'AuthSignedIdentity') {
22-
throw new validationErrors.ErrorParse(
23-
'`typ` property must be `AuthSignedToken`',
24-
);
25-
}
2620
if (
27-
authSignedIdentity['iss'] == null ||
28-
ids.decodeNodeId(authSignedIdentity['iss'] == null)
21+
authIdentityToken['iss'] == null ||
22+
ids.decodeNodeId(authIdentityToken['iss'] == null)
2923
) {
3024
throw new validationErrors.ErrorParse(
3125
'`iss` property must be an encoded node ID',
3226
);
3327
}
34-
if (typeof authSignedIdentity['exp'] !== 'number') {
28+
if (typeof authIdentityToken['exp'] !== 'number') {
3529
throw new validationErrors.ErrorParse('`exp` property must be a number');
3630
}
37-
if (typeof authSignedIdentity['jti'] !== 'string') {
31+
if (typeof authIdentityToken['jti'] !== 'string') {
3832
throw new validationErrors.ErrorParse('`jti` property must be a string');
3933
}
4034
}
4135

4236
function parseAuthSignedIdentity(
4337
authIdentityEncoded: unknown,
44-
): SignedToken<AuthSignedIdentity> {
38+
): SignedToken<AuthIdentityToken> {
4539
const encodedToken =
46-
tokensUtils.parseSignedToken<AuthSignedIdentity>(authIdentityEncoded);
40+
tokensUtils.parseSignedToken<AuthIdentityToken>(authIdentityEncoded);
4741
const authIdentity =
48-
tokensUtils.parseTokenPayload<AuthSignedIdentity>(encodedToken);
42+
tokensUtils.parseTokenPayload<AuthIdentityToken>(encodedToken);
4943
assertAuthSignedIdentity(authIdentity);
5044
return encodedToken;
5145
}
5246

5347
export { assertAuthSignedIdentity, parseAuthSignedIdentity };
5448

55-
export type { AuthSignedIdentity };
49+
export type { AuthIdentityToken };

src/tokens/payloads/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './authSignedIdentity.js';
1+
export * from './authIdentityToken.js';

src/tokens/payloads/sessionToken.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)