Skip to content

Commit 713ee55

Browse files
committed
remove unused ttl parameter from seal interface
1 parent 3b119a5 commit 713ee55

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

src/common/crypto/seal.spec.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ describe('seal', () => {
1111
expect(sealed).toContain('~2');
1212
expect(sealed.startsWith('Fe26.2*')).toBe(true);
1313
});
14-
15-
it('seals with TTL', async () => {
16-
const data = { foo: 'bar' };
17-
const sealed = await sealData(data, { password, ttl: 3600 });
18-
19-
expect(sealed).toContain('~2');
20-
});
2114
});
2215

2316
describe('unsealData', () => {
@@ -41,20 +34,6 @@ describe('seal', () => {
4134
expect(unsealed).toEqual(data);
4235
});
4336

44-
it('handles seals with TTL (expiration embedded in seal)', async () => {
45-
const data = { foo: 'bar' };
46-
// Seal with TTL - expiration timestamp is embedded in the seal
47-
const sealed = await sealData(data, { password, ttl: 3600 });
48-
49-
// Verify expiration field is present (5th component, non-empty)
50-
const parts = sealed.split('~')[0].split('*');
51-
expect(parts[5]).toMatch(/^\d+$/); // Non-empty expiration timestamp
52-
53-
// Should unseal successfully within TTL window
54-
const unsealed = await unsealData(sealed, { password });
55-
expect(unsealed).toEqual(data);
56-
});
57-
5837
it('returns empty object for bad password', async () => {
5938
const data = { foo: 'bar' };
6039
const sealed = await sealData(data, { password });

src/common/crypto/seal.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ const CURRENT_MAJOR_VERSION = 2;
99

1010
interface SealOptions {
1111
password: string;
12-
ttl?: number;
1312
}
1413

1514
interface UnsealOptions {
1615
password: string;
17-
ttl?: number;
1816
}
1917

2018
function parseSeal(seal: string): {
@@ -30,7 +28,7 @@ function parseSeal(seal: string): {
3028

3129
export async function sealData(
3230
data: unknown,
33-
{ password, ttl = 0 }: SealOptions,
31+
{ password }: SealOptions,
3432
): Promise<string> {
3533
const passwordObj = {
3634
id: '1',
@@ -39,7 +37,7 @@ export async function sealData(
3937

4038
const seal = await ironSeal(data, passwordObj, {
4139
...defaults,
42-
ttl: ttl * 1000,
40+
ttl: 0,
4341
encode: JSON.stringify,
4442
});
4543

@@ -48,7 +46,7 @@ export async function sealData(
4846

4947
export async function unsealData<T = unknown>(
5048
encryptedData: string,
51-
{ password, ttl = 0 }: UnsealOptions,
49+
{ password }: UnsealOptions,
5250
): Promise<T> {
5351
const { sealWithoutVersion, tokenVersion } = parseSeal(encryptedData);
5452

@@ -59,7 +57,7 @@ export async function unsealData<T = unknown>(
5957
data =
6058
(await ironUnseal(sealWithoutVersion, passwordMap, {
6159
...defaults,
62-
ttl: ttl * 1000,
60+
ttl: 0,
6361
})) ?? {};
6462
} catch (error) {
6563
if (

0 commit comments

Comments
 (0)