@@ -11,7 +11,12 @@ import {
1111 NucToken ,
1212 NucTokenDataSchema ,
1313} from "#/token" ;
14- import { base64UrlEncode , type Hex , randomBytes } from "#/utils" ;
14+ import {
15+ base64UrlEncode ,
16+ type Hex ,
17+ parseEpochSeconds ,
18+ randomBytes ,
19+ } from "#/utils" ;
1520
1621const DEFAULT_NONCE_LENGTH = 16 ;
1722
@@ -102,9 +107,11 @@ export class NucTokenBuilder {
102107 /**
103108 * Set the token's `not before` instant.
104109 *
105- * @param notBeforeInSeconds The Unix timestamp (in seconds) at which the token becomes valid.
110+ * @param epoch The Unix timestamp (in seconds) at which the token becomes valid.
111+ * @throws Error if the value is not a valid epoch timestamp.
106112 */
107- notBefore ( notBeforeInSeconds : number ) : NucTokenBuilder {
113+ notBefore ( epoch : number ) : NucTokenBuilder {
114+ const notBeforeInSeconds = parseEpochSeconds ( epoch ) ;
108115 this . _notBefore = Temporal . Instant . fromEpochMilliseconds (
109116 notBeforeInSeconds * 1000 ,
110117 ) ;
@@ -114,9 +121,11 @@ export class NucTokenBuilder {
114121 /**
115122 * Set the token's `expires at` instant.
116123 *
117- * @param expiresAtInSeconds The Unix timestamp (in seconds) at which the token expires.
124+ * @param epoch The Unix timestamp (in seconds) at which the token expires.
125+ * @throws Error if the value is not a valid epoch timestamp.
118126 */
119- expiresAt ( expiresAtInSeconds : number ) : NucTokenBuilder {
127+ expiresAt ( epoch : number ) : NucTokenBuilder {
128+ const expiresAtInSeconds = parseEpochSeconds ( epoch ) ;
120129 this . _expiresAt = Temporal . Instant . fromEpochMilliseconds (
121130 expiresAtInSeconds * 1000 ,
122131 ) ;
0 commit comments