@kalutskii/foundation 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -165,10 +165,10 @@ type JWTSignOptions = {
165
165
  };
166
166
 
167
167
  declare class ZodJWTService<TSchema extends z$1.ZodObject<z$1.ZodRawShape>> {
168
- readonly payloadSchema: TSchema;
168
+ readonly payloadSchema: TSchema | undefined;
169
169
  protected readonly algorithm: SymmetricAlgorithm;
170
170
  protected readonly defaultExpirationSeconds: number;
171
- constructor(payloadSchema: TSchema, options?: JWTServiceOptions);
171
+ constructor(payloadSchema?: TSchema, options?: JWTServiceOptions);
172
172
  /**
173
173
  * Signs a JWT token with the provided payload and secret, using the configured algorithm and expiration settings.
174
174
  * Example usage: `const accessToken = await JWTServiceInstance.sign({ userId: 123 }, 'my-secret', { expiresInSeconds: 300 });`
package/dist/index.js CHANGED
@@ -186,6 +186,8 @@ var ZodJWTService = class {
186
186
  */
187
187
  async decode(token) {
188
188
  const { payload } = decodeJWT(token);
189
+ if (!this.payloadSchema)
190
+ return payload;
189
191
  const { success: success2, data } = await this.payloadSchema.safeParseAsync(payload);
190
192
  return success2 ? data : null;
191
193
  }
@@ -195,6 +197,8 @@ var ZodJWTService = class {
195
197
  */
196
198
  async verifyOrThrow(token, secret) {
197
199
  const payload = await verifyJWT(token, secret, this.algorithm);
200
+ if (!this.payloadSchema)
201
+ return payload;
198
202
  return this.payloadSchema.parseAsync(payload);
199
203
  }
200
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "type": "module",
6
6
  "repository": {