@@ -39,7 +39,26 @@ const create = (privateKey, value, seq, lifetime, callback) => {
39
39
// Validity in ISOString with nanoseconds precision and validity type EOL
40
40
const isoValidity = nanoDateEol . toISOStringFull ( )
41
41
const validityType = ipnsEntryProto . ValidityType . EOL
42
+ _create ( privateKey , value , seq , isoValidity , validityType , callback )
43
+ }
44
+
45
+ /**
46
+ * Same as create(), but instead of generating a new Date, it receives the intended expiration time
47
+ * WARNING: nano precision is not standard, make sure the value in seconds is 9 orders of magnitude lesser than the one provided.
48
+ * @param {Object } privateKey private key for signing the record.
49
+ * @param {string } value value to be stored in the record.
50
+ * @param {number } seq number representing the current version of the record.
51
+ * @param {string } expiration expiration time of the record (in nanoseconds).
52
+ * @param {function(Error, entry) } [callback]
53
+ * @return {Void }
54
+ */
55
+ const createWithExpiration = ( privateKey , value , seq , expiration , callback ) => {
56
+ const bnExpiration = new NanoDate ( new Big ( expiration ) . toString ( ) ) . toISOStringFull ( )
57
+ const validityType = ipnsEntryProto . ValidityType . EOL
58
+ _create ( privateKey , value , seq , bnExpiration , validityType , callback )
59
+ }
42
60
61
+ const _create = ( privateKey , value , seq , isoValidity , validityType , callback ) => {
43
62
sign ( privateKey , value , validityType , isoValidity , ( error , signature ) => {
44
63
if ( error ) {
45
64
log . error ( 'record signature creation failed' )
@@ -294,6 +313,8 @@ const validator = {
294
313
module . exports = {
295
314
// create ipns entry record
296
315
create,
316
+ // create ipns entry record specifying the expiration time
317
+ createWithExpiration,
297
318
// validate ipns entry record
298
319
validate,
299
320
// embed public key in the record
0 commit comments