@@ -16,7 +16,7 @@ import type { CID } from 'multiformats/cid'
16
16
17
17
const log = logger ( 'ipns' )
18
18
const ID_MULTIHASH_CODE = identity . code
19
- const DEFAULT_TTL = BigInt ( 3.6e+12 ) // 1 Hour or 3600 Seconds
19
+ const DEFAULT_TTL_NS = BigInt ( 3.6e+12 ) // 1 Hour or 3600 Seconds
20
20
21
21
export const namespace = '/ipns/'
22
22
export const namespaceLength = namespace . length
@@ -129,7 +129,7 @@ export interface IDKeys {
129
129
}
130
130
131
131
export interface CreateOptions {
132
- lifetimeNs ?: bigint
132
+ ttlNs ?: bigint
133
133
v1Compatible ?: boolean
134
134
}
135
135
@@ -143,7 +143,7 @@ export interface CreateV2Options {
143
143
144
144
const defaultCreateOptions : CreateOptions = {
145
145
v1Compatible : true ,
146
- lifetimeNs : DEFAULT_TTL
146
+ ttlNs : DEFAULT_TTL_NS
147
147
}
148
148
149
149
/**
@@ -170,9 +170,9 @@ export async function create (peerId: PeerId, value: CID | PeerId | string, seq:
170
170
// Validity in ISOString with nanoseconds precision and validity type EOL
171
171
const expirationDate = new NanoDate ( Date . now ( ) + Number ( lifetime ) )
172
172
const validityType = IpnsEntry . ValidityType . EOL
173
- const lifetimeNs = typeof options . lifetimeNs === "bigint " ? options . lifetimeNs : DEFAULT_TTL
173
+ const ttlNs = typeof options . ttlNs !== "undefined " ? BigInt ( options . ttlNs ) : DEFAULT_TTL_NS
174
174
175
- return _create ( peerId , value , seq , validityType , expirationDate . toString ( ) , lifetimeNs , options )
175
+ return _create ( peerId , value , seq , validityType , expirationDate . toString ( ) , ttlNs , options )
176
176
}
177
177
178
178
/**
@@ -197,9 +197,9 @@ export async function createWithExpiration (peerId: PeerId, value: CID | PeerId
197
197
export async function createWithExpiration ( peerId : PeerId , value : CID | PeerId | string , seq : number | bigint , expiration : string , options : CreateOptions = defaultCreateOptions ) : Promise < IPNSRecord > {
198
198
const expirationDate = NanoDate . fromString ( expiration )
199
199
const validityType = IpnsEntry . ValidityType . EOL
200
- const lifetimeNs = typeof options . lifetimeNs === "bigint " ? options . lifetimeNs : DEFAULT_TTL
200
+ const ttlNs = typeof options . ttlNs !== "undefined " ? BigInt ( options . ttlNs ) : DEFAULT_TTL_NS
201
201
202
- return _create ( peerId , value , seq , validityType , expirationDate . toString ( ) , lifetimeNs , options )
202
+ return _create ( peerId , value , seq , validityType , expirationDate . toString ( ) , ttlNs , options )
203
203
}
204
204
205
205
const _create = async ( peerId : PeerId , value : CID | PeerId | string , seq : number | bigint , validityType : IpnsEntry . ValidityType , validity : string , ttl : bigint , options : CreateOptions = defaultCreateOptions ) : Promise < IPNSRecord > => {
0 commit comments