@vritti/api-sdk 0.3.16 → 0.4.1

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/root.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/root/index.ts","../src/root/root.module.ts","../src/root/controllers/app.controller.ts","../src/auth/decorators/public.decorator.ts","../src/root/docs/app.docs.ts","../src/root/services/app.service.ts","../src/root/controllers/csrf.controller.ts","../src/root/docs/csrf.docs.ts"],"sourcesContent":["export { RootModule } from './root.module';\n","import { Module } from '@nestjs/common';\nimport { AppController } from './controllers/app.controller';\nimport { CsrfController } from './controllers/csrf.controller';\nimport { AppService } from './services/app.service';\n\n@Module({\n controllers: [AppController, CsrfController],\n providers: [AppService],\n})\nexport class RootModule {}\n","import { Controller, Get } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport { Public } from '../../auth/decorators/public.decorator';\nimport { ApiHealthCheck } from '../docs/app.docs';\nimport { AppService } from '../services/app.service';\n\n@ApiTags('Health')\n@Controller()\nexport class AppController {\n constructor(private readonly appService: AppService) {}\n\n // Returns a welcome message indicating the API is running\n @Get()\n @Public()\n @ApiHealthCheck()\n getHello(): string {\n return this.appService.getHello();\n }\n}\n","import { SetMetadata } from '@nestjs/common';\n\nexport const Public = () => SetMetadata('isPublic', true);\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiHealthCheck() {\n return applyDecorators(\n ApiOperation({ summary: 'Health check endpoint' }),\n ApiResponse({\n status: 200,\n description: 'Returns a welcome message indicating the API is running',\n type: String,\n }),\n );\n}\n","import { Injectable } from '@nestjs/common';\n\n@Injectable()\nexport class AppService {\n // Returns the API welcome message\n getHello(): string {\n return `Hello World!`;\n }\n}\n","import { Controller, Get, HttpCode, HttpStatus, Res } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport type { FastifyReply } from 'fastify';\nimport { Public } from '../../auth/decorators/public.decorator';\nimport { ApiGetCsrfToken } from '../docs/csrf.docs';\n\n// Type augmentation for @fastify/csrf-protection — added by the consuming server at runtime\ntype FastifyReplyWithCsrf = FastifyReply & { generateCsrf(): string };\n\n@ApiTags('CSRF')\n@Controller('csrf')\nexport class CsrfController {\n // Generates a CSRF token via Fastify's csrf-protection plugin\n @Get('token')\n @Public()\n @HttpCode(HttpStatus.OK)\n @ApiGetCsrfToken()\n getToken(@Res({ passthrough: true }) reply: FastifyReply): { csrfToken: string } {\n const csrfToken = (reply as FastifyReplyWithCsrf).generateCsrf();\n return { csrfToken };\n }\n}\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiGetCsrfToken() {\n return applyDecorators(\n ApiOperation({\n summary: 'Get CSRF token',\n description:\n 'Generates and returns a CSRF token that must be included in all state-changing requests (POST, PUT, PATCH, DELETE). The token should be sent in the X-CSRF-Token header.',\n }),\n ApiResponse({\n status: 200,\n description: 'CSRF token generated successfully',\n schema: {\n type: 'object',\n properties: {\n csrfToken: {\n type: 'string',\n description: 'The CSRF token to use in subsequent requests',\n example: 'abc123xyz789',\n },\n },\n required: ['csrfToken'],\n },\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,IAAAA,iBAAuB;;;ACAvB,IAAAC,iBAAgC;AAChC,IAAAC,kBAAwB;;;ACDxB,oBAA4B;AAErB,IAAMC,SAAS,iCAAMC,2BAAY,YAAY,IAAA,GAA9B;;;ACFtB,IAAAC,iBAAgC;AAChC,qBAA0C;AAEnC,SAASC,iBAAAA;AACd,aAAOC,oCACLC,6BAAa;IAAEC,SAAS;EAAwB,CAAA,OAChDC,4BAAY;IACVC,QAAQ;IACRC,aAAa;IACbC,MAAMC;EACR,CAAA,CAAA;AAEJ;AATgBR;;;ACHhB,IAAAS,iBAA2B;;;;;;;;AAGpB,IAAMC,aAAN,MAAMA;SAAAA;;;;EAEXC,WAAmB;AACjB,WAAO;EACT;AACF;;;;;;;;;;;;;;;;;AHAO,IAAMC,gBAAN,MAAMA;SAAAA;;;;EACX,YAA6BC,YAAwB;SAAxBA,aAAAA;EAAyB;;EAMtDC,WAAmB;AACjB,WAAO,KAAKD,WAAWC,SAAQ;EACjC;AACF;;;;;;;;;;;;;;;;;;;AIlBA,IAAAC,iBAA2D;AAC3D,IAAAC,kBAAwB;;;ACDxB,IAAAC,iBAAgC;AAChC,IAAAC,kBAA0C;AAEnC,SAASC,kBAAAA;AACd,aAAOC,oCACLC,8BAAa;IACXC,SAAS;IACTC,aACE;EACJ,CAAA,OACAC,6BAAY;IACVC,QAAQ;IACRF,aAAa;IACbG,QAAQ;MACNC,MAAM;MACNC,YAAY;QACVC,WAAW;UACTF,MAAM;UACNJ,aAAa;UACbO,SAAS;QACX;MACF;MACAC,UAAU;QAAC;;IACb;EACF,CAAA,CAAA;AAEJ;AAvBgBZ;;;;;;;;;;;;;;;;;;;;ADQT,IAAMa,iBAAN,MAAMA;SAAAA;;;;EAMXC,SAAqCC,OAA4C;AAC/E,UAAMC,YAAaD,MAA+BE,aAAY;AAC9D,WAAO;MAAED;IAAU;EACrB;AACF;;;;yDANuBE,EAAAA;;;IAELC,aAAa;;;;;;;;;;;;;;;;;;;;;ALRxB,IAAMC,aAAN,MAAMA;SAAAA;;;AAAY;;;IAHvBC,aAAa;MAACC;MAAeC;;IAC7BC,WAAW;MAACC;;;;","names":["import_common","import_common","import_swagger","Public","SetMetadata","import_common","ApiHealthCheck","applyDecorators","ApiOperation","summary","ApiResponse","status","description","type","String","import_common","AppService","getHello","AppController","appService","getHello","import_common","import_swagger","import_common","import_swagger","ApiGetCsrfToken","applyDecorators","ApiOperation","summary","description","ApiResponse","status","schema","type","properties","csrfToken","example","required","CsrfController","getToken","reply","csrfToken","generateCsrf","OK","passthrough","RootModule","controllers","AppController","CsrfController","providers","AppService"]}
1
+ {"version":3,"sources":["../src/root/index.ts","../src/root/root.module.ts","../src/root/controllers/app.controller.ts","../src/auth/decorators/require.decorator.ts","../src/root/docs/app.docs.ts","../src/root/services/app.service.ts","../src/root/controllers/csrf.controller.ts","../src/root/docs/csrf.docs.ts"],"sourcesContent":["export { RootModule } from './root.module';\n","import { Module } from '@nestjs/common';\nimport { AppController } from './controllers/app.controller';\nimport { CsrfController } from './controllers/csrf.controller';\nimport { AppService } from './services/app.service';\n\n@Module({\n controllers: [AppController, CsrfController],\n providers: [AppService],\n})\nexport class RootModule {}\n","import { Controller, Get } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport { AuthType, Require } from '../../auth/decorators/require.decorator';\nimport { ApiHealthCheck } from '../docs/app.docs';\nimport { AppService } from '../services/app.service';\n\n@ApiTags('Health')\n@Controller()\nexport class AppController {\n constructor(private readonly appService: AppService) {}\n\n // Returns a welcome message indicating the API is running\n @Get()\n @Require(AuthType.Public)\n @ApiHealthCheck()\n getHello(): string {\n return this.appService.getHello();\n }\n}\n","import { SetMetadata } from '@nestjs/common';\n\nexport const REQUIRE_AUTH_KEY = 'requireAuth';\n\nexport enum AuthType {\n Session = 'session',\n App = 'app',\n Cloud = 'cloud',\n Public = 'public',\n}\n\nexport interface AuthRequirement {\n type: AuthType;\n subtypes: string[];\n}\n\n// Declares how a route authenticates, and which subtypes of that caller may reach it.\n//\n// One decorator for every caller kind, so the branch the guard takes is stated at the call\n// site rather than inferred from which of three decorators happens to be present:\n//\n// @Require(AuthType.Session, SessionTypeValues.WEB) session types WEB\n// @Require(AuthType.App, AppTypeValues.GRAPHQL) app credentials of type GRAPHQL\n// @Require(AuthType.Cloud) signed control-plane calls\n// @Require(AuthType.Public) no authentication\n//\n// Subtypes are compared as strings — the enums belong to the consuming server's schema and\n// this only ever compares. Passing none means \"any subtype\", so the caller is still\n// authenticated but unrestricted.\nexport const Require = (type: AuthType, ...subtypes: string[]) =>\n SetMetadata<string, AuthRequirement>(REQUIRE_AUTH_KEY, { type, subtypes });\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiHealthCheck() {\n return applyDecorators(\n ApiOperation({ summary: 'Health check endpoint' }),\n ApiResponse({\n status: 200,\n description: 'Returns a welcome message indicating the API is running',\n type: String,\n }),\n );\n}\n","import { Injectable } from '@nestjs/common';\n\n@Injectable()\nexport class AppService {\n // Returns the API welcome message\n getHello(): string {\n return `Hello World!`;\n }\n}\n","import { Controller, Get, HttpCode, HttpStatus, Res } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport type { FastifyReply } from 'fastify';\nimport { AuthType, Require } from '../../auth/decorators/require.decorator';\nimport { ApiGetCsrfToken } from '../docs/csrf.docs';\n\n// Type augmentation for @fastify/csrf-protection — added by the consuming server at runtime\ntype FastifyReplyWithCsrf = FastifyReply & { generateCsrf(): string };\n\n@ApiTags('CSRF')\n@Controller('csrf')\nexport class CsrfController {\n // Generates a CSRF token via Fastify's csrf-protection plugin\n @Get('token')\n @Require(AuthType.Public)\n @HttpCode(HttpStatus.OK)\n @ApiGetCsrfToken()\n getToken(@Res({ passthrough: true }) reply: FastifyReply): { csrfToken: string } {\n const csrfToken = (reply as FastifyReplyWithCsrf).generateCsrf();\n return { csrfToken };\n }\n}\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiGetCsrfToken() {\n return applyDecorators(\n ApiOperation({\n summary: 'Get CSRF token',\n description:\n 'Generates and returns a CSRF token that must be included in all state-changing requests (POST, PUT, PATCH, DELETE). The token should be sent in the X-CSRF-Token header.',\n }),\n ApiResponse({\n status: 200,\n description: 'CSRF token generated successfully',\n schema: {\n type: 'object',\n properties: {\n csrfToken: {\n type: 'string',\n description: 'The CSRF token to use in subsequent requests',\n example: 'abc123xyz789',\n },\n },\n required: ['csrfToken'],\n },\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,IAAAA,iBAAuB;;;ACAvB,IAAAC,iBAAgC;AAChC,IAAAC,kBAAwB;;;ACDxB,oBAA4B;AAErB,IAAMC,mBAAmB;AAEzB,IAAKC,WAAAA,0BAAAA,WAAAA;;;;;SAAAA;;AAyBL,IAAMC,UAAU,wBAACC,SAAmBC,iBACzCC,2BAAqCL,kBAAkB;EAAEG;EAAMC;AAAS,CAAA,GADnD;;;AC7BvB,IAAAE,iBAAgC;AAChC,qBAA0C;AAEnC,SAASC,iBAAAA;AACd,aAAOC,oCACLC,6BAAa;IAAEC,SAAS;EAAwB,CAAA,OAChDC,4BAAY;IACVC,QAAQ;IACRC,aAAa;IACbC,MAAMC;EACR,CAAA,CAAA;AAEJ;AATgBR;;;ACHhB,IAAAS,iBAA2B;;;;;;;;AAGpB,IAAMC,aAAN,MAAMA;SAAAA;;;;EAEXC,WAAmB;AACjB,WAAO;EACT;AACF;;;;;;;;;;;;;;;;;AHAO,IAAMC,gBAAN,MAAMA;SAAAA;;;;EACX,YAA6BC,YAAwB;SAAxBA,aAAAA;EAAyB;;EAMtDC,WAAmB;AACjB,WAAO,KAAKD,WAAWC,SAAQ;EACjC;AACF;;;mBALoBC,MAAAA;;;;;;;;;;;;;;;;AIbpB,IAAAC,iBAA2D;AAC3D,IAAAC,kBAAwB;;;ACDxB,IAAAC,iBAAgC;AAChC,IAAAC,kBAA0C;AAEnC,SAASC,kBAAAA;AACd,aAAOC,oCACLC,8BAAa;IACXC,SAAS;IACTC,aACE;EACJ,CAAA,OACAC,6BAAY;IACVC,QAAQ;IACRF,aAAa;IACbG,QAAQ;MACNC,MAAM;MACNC,YAAY;QACVC,WAAW;UACTF,MAAM;UACNJ,aAAa;UACbO,SAAS;QACX;MACF;MACAC,UAAU;QAAC;;IACb;EACF,CAAA,CAAA;AAEJ;AAvBgBZ;;;;;;;;;;;;;;;;;;;;ADQT,IAAMa,iBAAN,MAAMA;SAAAA;;;;EAMXC,SAAqCC,OAA4C;AAC/E,UAAMC,YAAaD,MAA+BE,aAAY;AAC9D,WAAO;MAAED;IAAU;EACrB;AACF;;;mBAPoBE,MAAAA;yDACGC,EAAAA;;;IAELC,aAAa;;;;;;;;;;;;;;;;;;;;;ALRxB,IAAMC,aAAN,MAAMA;SAAAA;;;AAAY;;;IAHvBC,aAAa;MAACC;MAAeC;;IAC7BC,WAAW;MAACC;;;;","names":["import_common","import_common","import_swagger","REQUIRE_AUTH_KEY","AuthType","Require","type","subtypes","SetMetadata","import_common","ApiHealthCheck","applyDecorators","ApiOperation","summary","ApiResponse","status","description","type","String","import_common","AppService","getHello","AppController","appService","getHello","Public","import_common","import_swagger","import_common","import_swagger","ApiGetCsrfToken","applyDecorators","ApiOperation","summary","description","ApiResponse","status","schema","type","properties","csrfToken","example","required","CsrfController","getToken","reply","csrfToken","generateCsrf","Public","OK","passthrough","RootModule","controllers","AppController","CsrfController","providers","AppService"]}
package/dist/root.js CHANGED
@@ -8,9 +8,20 @@ import { Module } from "@nestjs/common";
8
8
  import { Controller, Get } from "@nestjs/common";
9
9
  import { ApiTags } from "@nestjs/swagger";
10
10
 
11
- // src/auth/decorators/public.decorator.ts
11
+ // src/auth/decorators/require.decorator.ts
12
12
  import { SetMetadata } from "@nestjs/common";
13
- var Public = /* @__PURE__ */ __name(() => SetMetadata("isPublic", true), "Public");
13
+ var REQUIRE_AUTH_KEY = "requireAuth";
14
+ var AuthType = /* @__PURE__ */ (function(AuthType2) {
15
+ AuthType2["Session"] = "session";
16
+ AuthType2["App"] = "app";
17
+ AuthType2["Cloud"] = "cloud";
18
+ AuthType2["Public"] = "public";
19
+ return AuthType2;
20
+ })({});
21
+ var Require = /* @__PURE__ */ __name((type, ...subtypes) => SetMetadata(REQUIRE_AUTH_KEY, {
22
+ type,
23
+ subtypes
24
+ }), "Require");
14
25
 
15
26
  // src/root/docs/app.docs.ts
16
27
  import { applyDecorators } from "@nestjs/common";
@@ -75,7 +86,7 @@ var AppController = class {
75
86
  };
76
87
  _ts_decorate2([
77
88
  Get(),
78
- Public(),
89
+ Require(AuthType.Public),
79
90
  ApiHealthCheck(),
80
91
  _ts_metadata("design:type", Function),
81
92
  _ts_metadata("design:paramtypes", []),
@@ -153,7 +164,7 @@ var CsrfController = class {
153
164
  };
154
165
  _ts_decorate3([
155
166
  Get2("token"),
156
- Public(),
167
+ Require(AuthType.Public),
157
168
  HttpCode(HttpStatus.OK),
158
169
  ApiGetCsrfToken(),
159
170
  _ts_param(0, Res({
package/dist/root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/root/root.module.ts","../src/root/controllers/app.controller.ts","../src/auth/decorators/public.decorator.ts","../src/root/docs/app.docs.ts","../src/root/services/app.service.ts","../src/root/controllers/csrf.controller.ts","../src/root/docs/csrf.docs.ts"],"sourcesContent":["import { Module } from '@nestjs/common';\nimport { AppController } from './controllers/app.controller';\nimport { CsrfController } from './controllers/csrf.controller';\nimport { AppService } from './services/app.service';\n\n@Module({\n controllers: [AppController, CsrfController],\n providers: [AppService],\n})\nexport class RootModule {}\n","import { Controller, Get } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport { Public } from '../../auth/decorators/public.decorator';\nimport { ApiHealthCheck } from '../docs/app.docs';\nimport { AppService } from '../services/app.service';\n\n@ApiTags('Health')\n@Controller()\nexport class AppController {\n constructor(private readonly appService: AppService) {}\n\n // Returns a welcome message indicating the API is running\n @Get()\n @Public()\n @ApiHealthCheck()\n getHello(): string {\n return this.appService.getHello();\n }\n}\n","import { SetMetadata } from '@nestjs/common';\n\nexport const Public = () => SetMetadata('isPublic', true);\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiHealthCheck() {\n return applyDecorators(\n ApiOperation({ summary: 'Health check endpoint' }),\n ApiResponse({\n status: 200,\n description: 'Returns a welcome message indicating the API is running',\n type: String,\n }),\n );\n}\n","import { Injectable } from '@nestjs/common';\n\n@Injectable()\nexport class AppService {\n // Returns the API welcome message\n getHello(): string {\n return `Hello World!`;\n }\n}\n","import { Controller, Get, HttpCode, HttpStatus, Res } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport type { FastifyReply } from 'fastify';\nimport { Public } from '../../auth/decorators/public.decorator';\nimport { ApiGetCsrfToken } from '../docs/csrf.docs';\n\n// Type augmentation for @fastify/csrf-protection — added by the consuming server at runtime\ntype FastifyReplyWithCsrf = FastifyReply & { generateCsrf(): string };\n\n@ApiTags('CSRF')\n@Controller('csrf')\nexport class CsrfController {\n // Generates a CSRF token via Fastify's csrf-protection plugin\n @Get('token')\n @Public()\n @HttpCode(HttpStatus.OK)\n @ApiGetCsrfToken()\n getToken(@Res({ passthrough: true }) reply: FastifyReply): { csrfToken: string } {\n const csrfToken = (reply as FastifyReplyWithCsrf).generateCsrf();\n return { csrfToken };\n }\n}\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiGetCsrfToken() {\n return applyDecorators(\n ApiOperation({\n summary: 'Get CSRF token',\n description:\n 'Generates and returns a CSRF token that must be included in all state-changing requests (POST, PUT, PATCH, DELETE). The token should be sent in the X-CSRF-Token header.',\n }),\n ApiResponse({\n status: 200,\n description: 'CSRF token generated successfully',\n schema: {\n type: 'object',\n properties: {\n csrfToken: {\n type: 'string',\n description: 'The CSRF token to use in subsequent requests',\n example: 'abc123xyz789',\n },\n },\n required: ['csrfToken'],\n },\n }),\n );\n}\n"],"mappings":";;;;AAAA,SAASA,cAAc;;;ACAvB,SAASC,YAAYC,WAAW;AAChC,SAASC,eAAe;;;ACDxB,SAASC,mBAAmB;AAErB,IAAMC,SAAS,6BAAMC,YAAY,YAAY,IAAA,GAA9B;;;ACFtB,SAASC,uBAAuB;AAChC,SAASC,cAAcC,mBAAmB;AAEnC,SAASC,iBAAAA;AACd,SAAOC,gBACLC,aAAa;IAAEC,SAAS;EAAwB,CAAA,GAChDC,YAAY;IACVC,QAAQ;IACRC,aAAa;IACbC,MAAMC;EACR,CAAA,CAAA;AAEJ;AATgBR;;;ACHhB,SAASS,kBAAkB;;;;;;;;AAGpB,IAAMC,aAAN,MAAMA;SAAAA;;;;EAEXC,WAAmB;AACjB,WAAO;EACT;AACF;;;;;;;;;;;;;;;;;AHAO,IAAMC,gBAAN,MAAMA;SAAAA;;;;EACX,YAA6BC,YAAwB;SAAxBA,aAAAA;EAAyB;;EAMtDC,WAAmB;AACjB,WAAO,KAAKD,WAAWC,SAAQ;EACjC;AACF;;;;;;;;;;;;;;;;;;;AIlBA,SAASC,cAAAA,aAAYC,OAAAA,MAAKC,UAAUC,YAAYC,WAAW;AAC3D,SAASC,WAAAA,gBAAe;;;ACDxB,SAASC,mBAAAA,wBAAuB;AAChC,SAASC,gBAAAA,eAAcC,eAAAA,oBAAmB;AAEnC,SAASC,kBAAAA;AACd,SAAOC,iBACLC,cAAa;IACXC,SAAS;IACTC,aACE;EACJ,CAAA,GACAC,aAAY;IACVC,QAAQ;IACRF,aAAa;IACbG,QAAQ;MACNC,MAAM;MACNC,YAAY;QACVC,WAAW;UACTF,MAAM;UACNJ,aAAa;UACbO,SAAS;QACX;MACF;MACAC,UAAU;QAAC;;IACb;EACF,CAAA,CAAA;AAEJ;AAvBgBZ;;;;;;;;;;;;;;;;;;;;ADQT,IAAMa,iBAAN,MAAMA;SAAAA;;;;EAMXC,SAAqCC,OAA4C;AAC/E,UAAMC,YAAaD,MAA+BE,aAAY;AAC9D,WAAO;MAAED;IAAU;EACrB;AACF;;;;sBANuBE,EAAAA;;;IAELC,aAAa;;;;;;;;;;;;;;;;;;;;;ALRxB,IAAMC,aAAN,MAAMA;SAAAA;;;AAAY;;;IAHvBC,aAAa;MAACC;MAAeC;;IAC7BC,WAAW;MAACC;;;;","names":["Module","Controller","Get","ApiTags","SetMetadata","Public","SetMetadata","applyDecorators","ApiOperation","ApiResponse","ApiHealthCheck","applyDecorators","ApiOperation","summary","ApiResponse","status","description","type","String","Injectable","AppService","getHello","AppController","appService","getHello","Controller","Get","HttpCode","HttpStatus","Res","ApiTags","applyDecorators","ApiOperation","ApiResponse","ApiGetCsrfToken","applyDecorators","ApiOperation","summary","description","ApiResponse","status","schema","type","properties","csrfToken","example","required","CsrfController","getToken","reply","csrfToken","generateCsrf","OK","passthrough","RootModule","controllers","AppController","CsrfController","providers","AppService"]}
1
+ {"version":3,"sources":["../src/root/root.module.ts","../src/root/controllers/app.controller.ts","../src/auth/decorators/require.decorator.ts","../src/root/docs/app.docs.ts","../src/root/services/app.service.ts","../src/root/controllers/csrf.controller.ts","../src/root/docs/csrf.docs.ts"],"sourcesContent":["import { Module } from '@nestjs/common';\nimport { AppController } from './controllers/app.controller';\nimport { CsrfController } from './controllers/csrf.controller';\nimport { AppService } from './services/app.service';\n\n@Module({\n controllers: [AppController, CsrfController],\n providers: [AppService],\n})\nexport class RootModule {}\n","import { Controller, Get } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport { AuthType, Require } from '../../auth/decorators/require.decorator';\nimport { ApiHealthCheck } from '../docs/app.docs';\nimport { AppService } from '../services/app.service';\n\n@ApiTags('Health')\n@Controller()\nexport class AppController {\n constructor(private readonly appService: AppService) {}\n\n // Returns a welcome message indicating the API is running\n @Get()\n @Require(AuthType.Public)\n @ApiHealthCheck()\n getHello(): string {\n return this.appService.getHello();\n }\n}\n","import { SetMetadata } from '@nestjs/common';\n\nexport const REQUIRE_AUTH_KEY = 'requireAuth';\n\nexport enum AuthType {\n Session = 'session',\n App = 'app',\n Cloud = 'cloud',\n Public = 'public',\n}\n\nexport interface AuthRequirement {\n type: AuthType;\n subtypes: string[];\n}\n\n// Declares how a route authenticates, and which subtypes of that caller may reach it.\n//\n// One decorator for every caller kind, so the branch the guard takes is stated at the call\n// site rather than inferred from which of three decorators happens to be present:\n//\n// @Require(AuthType.Session, SessionTypeValues.WEB) session types WEB\n// @Require(AuthType.App, AppTypeValues.GRAPHQL) app credentials of type GRAPHQL\n// @Require(AuthType.Cloud) signed control-plane calls\n// @Require(AuthType.Public) no authentication\n//\n// Subtypes are compared as strings — the enums belong to the consuming server's schema and\n// this only ever compares. Passing none means \"any subtype\", so the caller is still\n// authenticated but unrestricted.\nexport const Require = (type: AuthType, ...subtypes: string[]) =>\n SetMetadata<string, AuthRequirement>(REQUIRE_AUTH_KEY, { type, subtypes });\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiHealthCheck() {\n return applyDecorators(\n ApiOperation({ summary: 'Health check endpoint' }),\n ApiResponse({\n status: 200,\n description: 'Returns a welcome message indicating the API is running',\n type: String,\n }),\n );\n}\n","import { Injectable } from '@nestjs/common';\n\n@Injectable()\nexport class AppService {\n // Returns the API welcome message\n getHello(): string {\n return `Hello World!`;\n }\n}\n","import { Controller, Get, HttpCode, HttpStatus, Res } from '@nestjs/common';\nimport { ApiTags } from '@nestjs/swagger';\nimport type { FastifyReply } from 'fastify';\nimport { AuthType, Require } from '../../auth/decorators/require.decorator';\nimport { ApiGetCsrfToken } from '../docs/csrf.docs';\n\n// Type augmentation for @fastify/csrf-protection — added by the consuming server at runtime\ntype FastifyReplyWithCsrf = FastifyReply & { generateCsrf(): string };\n\n@ApiTags('CSRF')\n@Controller('csrf')\nexport class CsrfController {\n // Generates a CSRF token via Fastify's csrf-protection plugin\n @Get('token')\n @Require(AuthType.Public)\n @HttpCode(HttpStatus.OK)\n @ApiGetCsrfToken()\n getToken(@Res({ passthrough: true }) reply: FastifyReply): { csrfToken: string } {\n const csrfToken = (reply as FastifyReplyWithCsrf).generateCsrf();\n return { csrfToken };\n }\n}\n","import { applyDecorators } from '@nestjs/common';\nimport { ApiOperation, ApiResponse } from '@nestjs/swagger';\n\nexport function ApiGetCsrfToken() {\n return applyDecorators(\n ApiOperation({\n summary: 'Get CSRF token',\n description:\n 'Generates and returns a CSRF token that must be included in all state-changing requests (POST, PUT, PATCH, DELETE). The token should be sent in the X-CSRF-Token header.',\n }),\n ApiResponse({\n status: 200,\n description: 'CSRF token generated successfully',\n schema: {\n type: 'object',\n properties: {\n csrfToken: {\n type: 'string',\n description: 'The CSRF token to use in subsequent requests',\n example: 'abc123xyz789',\n },\n },\n required: ['csrfToken'],\n },\n }),\n );\n}\n"],"mappings":";;;;AAAA,SAASA,cAAc;;;ACAvB,SAASC,YAAYC,WAAW;AAChC,SAASC,eAAe;;;ACDxB,SAASC,mBAAmB;AAErB,IAAMC,mBAAmB;AAEzB,IAAKC,WAAAA,0BAAAA,WAAAA;;;;;SAAAA;;AAyBL,IAAMC,UAAU,wBAACC,SAAmBC,aACzCC,YAAqCL,kBAAkB;EAAEG;EAAMC;AAAS,CAAA,GADnD;;;AC7BvB,SAASE,uBAAuB;AAChC,SAASC,cAAcC,mBAAmB;AAEnC,SAASC,iBAAAA;AACd,SAAOC,gBACLC,aAAa;IAAEC,SAAS;EAAwB,CAAA,GAChDC,YAAY;IACVC,QAAQ;IACRC,aAAa;IACbC,MAAMC;EACR,CAAA,CAAA;AAEJ;AATgBR;;;ACHhB,SAASS,kBAAkB;;;;;;;;AAGpB,IAAMC,aAAN,MAAMA;SAAAA;;;;EAEXC,WAAmB;AACjB,WAAO;EACT;AACF;;;;;;;;;;;;;;;;;AHAO,IAAMC,gBAAN,MAAMA;SAAAA;;;;EACX,YAA6BC,YAAwB;SAAxBA,aAAAA;EAAyB;;EAMtDC,WAAmB;AACjB,WAAO,KAAKD,WAAWC,SAAQ;EACjC;AACF;;;mBALoBC,MAAAA;;;;;;;;;;;;;;;;AIbpB,SAASC,cAAAA,aAAYC,OAAAA,MAAKC,UAAUC,YAAYC,WAAW;AAC3D,SAASC,WAAAA,gBAAe;;;ACDxB,SAASC,mBAAAA,wBAAuB;AAChC,SAASC,gBAAAA,eAAcC,eAAAA,oBAAmB;AAEnC,SAASC,kBAAAA;AACd,SAAOC,iBACLC,cAAa;IACXC,SAAS;IACTC,aACE;EACJ,CAAA,GACAC,aAAY;IACVC,QAAQ;IACRF,aAAa;IACbG,QAAQ;MACNC,MAAM;MACNC,YAAY;QACVC,WAAW;UACTF,MAAM;UACNJ,aAAa;UACbO,SAAS;QACX;MACF;MACAC,UAAU;QAAC;;IACb;EACF,CAAA,CAAA;AAEJ;AAvBgBZ;;;;;;;;;;;;;;;;;;;;ADQT,IAAMa,iBAAN,MAAMA;SAAAA;;;;EAMXC,SAAqCC,OAA4C;AAC/E,UAAMC,YAAaD,MAA+BE,aAAY;AAC9D,WAAO;MAAED;IAAU;EACrB;AACF;;;mBAPoBE,MAAAA;sBACGC,EAAAA;;;IAELC,aAAa;;;;;;;;;;;;;;;;;;;;;ALRxB,IAAMC,aAAN,MAAMA;SAAAA;;;AAAY;;;IAHvBC,aAAa;MAACC;MAAeC;;IAC7BC,WAAW;MAACC;;;;","names":["Module","Controller","Get","ApiTags","SetMetadata","REQUIRE_AUTH_KEY","AuthType","Require","type","subtypes","SetMetadata","applyDecorators","ApiOperation","ApiResponse","ApiHealthCheck","applyDecorators","ApiOperation","summary","ApiResponse","status","description","type","String","Injectable","AppService","getHello","AppController","appService","getHello","Public","Controller","Get","HttpCode","HttpStatus","Res","ApiTags","applyDecorators","ApiOperation","ApiResponse","ApiGetCsrfToken","applyDecorators","ApiOperation","summary","description","ApiResponse","status","schema","type","properties","csrfToken","example","required","CsrfController","getToken","reply","csrfToken","generateCsrf","Public","OK","passthrough","RootModule","controllers","AppController","CsrfController","providers","AppService"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vritti/api-sdk",
3
3
  "type": "module",
4
- "version": "0.3.16",
4
+ "version": "0.4.1",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",