b23-lib 1.2.2 → 1.2.4

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.mts CHANGED
@@ -247,11 +247,14 @@ type AuthUtilityConfig = {
247
247
  adminPrivateKeys?: StringifiedJSONArray;
248
248
  adminPublicKeys?: StringifiedJSONArray;
249
249
  };
250
+ declare const DefaultAuthUtilityConfig: AuthUtilityConfig;
251
+ type AuthTokenType = 'Anon' | 'User' | 'System' | 'Admin';
250
252
  type AuthMiddlewareConfig = {
251
- allowAnonymous: boolean;
252
- allowSystem: boolean;
253
- allowUser: boolean;
253
+ allowAnonymous?: boolean;
254
+ allowSystem?: boolean;
255
+ allowUser?: boolean;
254
256
  };
257
+ declare const DefaultAuthMiddlewareConfig: AuthMiddlewareConfig;
255
258
  declare class AuthUtility {
256
259
  private maxTokenAge;
257
260
  private userPrivateKeys;
@@ -276,6 +279,15 @@ declare class AuthUtility {
276
279
  AuthMiddleware({ allowAnonymous, allowSystem, allowUser }?: AuthMiddlewareConfig): (req: any, res: any, next: any) => Promise<void>;
277
280
  }
278
281
 
282
+ type index_AuthMiddlewareConfig = AuthMiddlewareConfig;
283
+ type index_AuthTokenType = AuthTokenType;
284
+ type index_AuthUtilityConfig = AuthUtilityConfig;
285
+ declare const index_DefaultAuthMiddlewareConfig: typeof DefaultAuthMiddlewareConfig;
286
+ declare const index_DefaultAuthUtilityConfig: typeof DefaultAuthUtilityConfig;
287
+ declare namespace index {
288
+ export { type index_AuthMiddlewareConfig as AuthMiddlewareConfig, type index_AuthTokenType as AuthTokenType, type index_AuthUtilityConfig as AuthUtilityConfig, index_DefaultAuthMiddlewareConfig as DefaultAuthMiddlewareConfig, index_DefaultAuthUtilityConfig as DefaultAuthUtilityConfig, AuthUtility as default };
289
+ }
290
+
279
291
  declare const _default: {
280
292
  isUUID: (value: string) => boolean;
281
293
  generateUUID: (value?: string, namespace?: string) => string;
@@ -316,4 +328,4 @@ declare const Logger: {
316
328
  logInvalidPayload: (functionName: string, errorMessage: string) => void;
317
329
  };
318
330
 
319
- export { AuthUtility as Auth, DynamoDBUtility as DynamoDB, Fetch, Logger, ResponseUtility, Schema, _default as Utils };
331
+ export { index as Auth, DynamoDBUtility as DynamoDB, Fetch, Logger, ResponseUtility, Schema, _default as Utils };
package/dist/index.d.ts CHANGED
@@ -247,11 +247,14 @@ type AuthUtilityConfig = {
247
247
  adminPrivateKeys?: StringifiedJSONArray;
248
248
  adminPublicKeys?: StringifiedJSONArray;
249
249
  };
250
+ declare const DefaultAuthUtilityConfig: AuthUtilityConfig;
251
+ type AuthTokenType = 'Anon' | 'User' | 'System' | 'Admin';
250
252
  type AuthMiddlewareConfig = {
251
- allowAnonymous: boolean;
252
- allowSystem: boolean;
253
- allowUser: boolean;
253
+ allowAnonymous?: boolean;
254
+ allowSystem?: boolean;
255
+ allowUser?: boolean;
254
256
  };
257
+ declare const DefaultAuthMiddlewareConfig: AuthMiddlewareConfig;
255
258
  declare class AuthUtility {
256
259
  private maxTokenAge;
257
260
  private userPrivateKeys;
@@ -276,6 +279,15 @@ declare class AuthUtility {
276
279
  AuthMiddleware({ allowAnonymous, allowSystem, allowUser }?: AuthMiddlewareConfig): (req: any, res: any, next: any) => Promise<void>;
277
280
  }
278
281
 
282
+ type index_AuthMiddlewareConfig = AuthMiddlewareConfig;
283
+ type index_AuthTokenType = AuthTokenType;
284
+ type index_AuthUtilityConfig = AuthUtilityConfig;
285
+ declare const index_DefaultAuthMiddlewareConfig: typeof DefaultAuthMiddlewareConfig;
286
+ declare const index_DefaultAuthUtilityConfig: typeof DefaultAuthUtilityConfig;
287
+ declare namespace index {
288
+ export { type index_AuthMiddlewareConfig as AuthMiddlewareConfig, type index_AuthTokenType as AuthTokenType, type index_AuthUtilityConfig as AuthUtilityConfig, index_DefaultAuthMiddlewareConfig as DefaultAuthMiddlewareConfig, index_DefaultAuthUtilityConfig as DefaultAuthUtilityConfig, AuthUtility as default };
289
+ }
290
+
279
291
  declare const _default: {
280
292
  isUUID: (value: string) => boolean;
281
293
  generateUUID: (value?: string, namespace?: string) => string;
@@ -316,4 +328,4 @@ declare const Logger: {
316
328
  logInvalidPayload: (functionName: string, errorMessage: string) => void;
317
329
  };
318
330
 
319
- export { AuthUtility as Auth, DynamoDBUtility as DynamoDB, Fetch, Logger, ResponseUtility, Schema, _default as Utils };
331
+ export { index as Auth, DynamoDBUtility as DynamoDB, Fetch, Logger, ResponseUtility, Schema, _default as Utils };
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- Auth: () => Auth_default,
33
+ Auth: () => Auth_exports,
34
34
  DynamoDB: () => Dynamodb_default,
35
35
  Fetch: () => fetch_default,
36
36
  Logger: () => Logger_default,
@@ -410,6 +410,12 @@ var Schema = {
410
410
  var Schema_default = Schema;
411
411
 
412
412
  // src/Auth/index.ts
413
+ var Auth_exports = {};
414
+ __export(Auth_exports, {
415
+ DefaultAuthMiddlewareConfig: () => DefaultAuthMiddlewareConfig,
416
+ DefaultAuthUtilityConfig: () => DefaultAuthUtilityConfig,
417
+ default: () => Auth_default
418
+ });
413
419
  var import_jose = require("jose");
414
420
  var import_util2 = __toESM(require("util"));
415
421
 
@@ -667,7 +673,7 @@ var AuthUtility = class {
667
673
  (0, import_assert.default)(payload.type === "Admin", ErrorTypes_default.INVALID_AUTH_TYPE);
668
674
  return payload;
669
675
  }
670
- AuthMiddleware({ allowAnonymous, allowSystem, allowUser } = DefaultAuthMiddlewareConfig) {
676
+ AuthMiddleware({ allowAnonymous = false, allowSystem = true, allowUser = true } = DefaultAuthMiddlewareConfig) {
671
677
  return async (req, res, next) => {
672
678
  try {
673
679
  const [authType, token] = req.get("Authorization")?.split(" ");
package/dist/index.mjs CHANGED
@@ -1,3 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/Dynamodb/index.ts
2
8
  import {
3
9
  BatchGetItemCommand,
@@ -383,6 +389,12 @@ var Schema = {
383
389
  var Schema_default = Schema;
384
390
 
385
391
  // src/Auth/index.ts
392
+ var Auth_exports = {};
393
+ __export(Auth_exports, {
394
+ DefaultAuthMiddlewareConfig: () => DefaultAuthMiddlewareConfig,
395
+ DefaultAuthUtilityConfig: () => DefaultAuthUtilityConfig,
396
+ default: () => Auth_default
397
+ });
386
398
  import { importPKCS8, importSPKI, jwtVerify, SignJWT } from "jose";
387
399
  import util2 from "util";
388
400
 
@@ -640,7 +652,7 @@ var AuthUtility = class {
640
652
  assert(payload.type === "Admin", ErrorTypes_default.INVALID_AUTH_TYPE);
641
653
  return payload;
642
654
  }
643
- AuthMiddleware({ allowAnonymous, allowSystem, allowUser } = DefaultAuthMiddlewareConfig) {
655
+ AuthMiddleware({ allowAnonymous = false, allowSystem = true, allowUser = true } = DefaultAuthMiddlewareConfig) {
644
656
  return async (req, res, next) => {
645
657
  try {
646
658
  const [authType, token] = req.get("Authorization")?.split(" ");
@@ -734,7 +746,7 @@ var Fetch = async (baseURL, endpoint, method = "GET", headers = {}, payload) =>
734
746
  };
735
747
  var fetch_default = Fetch;
736
748
  export {
737
- Auth_default as Auth,
749
+ Auth_exports as Auth,
738
750
  Dynamodb_default as DynamoDB,
739
751
  fetch_default as Fetch,
740
752
  Logger_default as Logger,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b23-lib",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "This repo hold common classes, type and util functiona",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",