@authup/server-core 1.0.0-beta.39 → 1.0.0-beta.40

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.
@@ -19,8 +19,8 @@ export declare class RealmController {
19
19
  add(data: any, req: any, res: any): Promise<any>;
20
20
  get(id: string, req: any, res: any): Promise<any>;
21
21
  getOpenIdConfiguration(id: string): Promise<OpenIDProviderMetadata>;
22
- getCerts(id: string, req: any, res: any): Promise<OAuth2JsonWebKey[]>;
23
- getCert(id: string, keyId: string, req: any, res: any): Promise<OAuth2JsonWebKey>;
22
+ getCerts(id: string, res: any): Promise<OAuth2JsonWebKey[]>;
23
+ getCert(id: string, keyId: string, res: any): Promise<OAuth2JsonWebKey>;
24
24
  edit(id: string, data: any, req: any, res: any): Promise<any>;
25
25
  put(id: string, data: any, req: any, res: any): Promise<any>;
26
26
  drop(id: string, req: any, res: any): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../../src/adapters/http/controllers/entities/realm/module.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAI9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAKvE,MAAM,MAAM,sBAAsB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAA;CAClB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,OAAO,EAAE,sBAAsB,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;CACxC,CAAC;AAEF,qBAEa,eAAe;IACxB,SAAS,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAE1C,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC;IAEjC,SAAS,CAAC,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;gBAEnC,GAAG,EAAE,sBAAsB;IAOjC,OAAO,CACG,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACtB,OAAO,CAAC,GAAG,CAAC;IAaT,GAAG,CACI,IAAI,EAAE,GAAG,EACN,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACrB,OAAO,CAAC,GAAG,CAAC;IAQV,GAAG,CACQ,EAAE,EAAE,MAAM,EACX,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACtB,OAAO,CAAC,GAAG,CAAC;IAST,sBAAsB,CACX,EAAE,EAAE,MAAM,GACxB,OAAO,CAAC,sBAAsB,CAAC;IA6C5B,QAAQ,CACG,EAAE,EAAE,MAAM,EACX,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACtB,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAKxB,OAAO,CACI,EAAE,EAAE,MAAM,EACP,KAAK,EAAE,MAAM,EACjB,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACtB,OAAO,CAAC,gBAAgB,CAAC;IAKtB,IAAI,CACO,EAAE,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACN,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACrB,OAAO,CAAC,GAAG,CAAC;IAYV,GAAG,CACQ,EAAE,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACN,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACrB,OAAO,CAAC,GAAG,CAAC;IAmBV,IAAI,CACO,EAAE,EAAE,MAAM,EACX,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACrB,OAAO,CAAC,GAAG,CAAC;CAMnB"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../../src/adapters/http/controllers/entities/realm/module.ts"],"names":[],"m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GAAG,GACtB,OAAO,CAAC,gBAAgB,CAAC;IAMtB,IAAI,CACO,EAAE,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACN,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACrB,OAAO,CAAC,GAAG,CAAC;IAYV,GAAG,CACQ,EAAE,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACN,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACrB,OAAO,CAAC,GAAG,CAAC;IAmBV,IAAI,CACO,EAAE,EAAE,MAAM,EACX,GAAG,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,GACrB,OAAO,CAAC,GAAG,CAAC;CAMnB"}
@@ -49,9 +49,9 @@ var RealmController = class {
49
49
  async getOpenIdConfiguration(id) {
50
50
  const entity = await this.service.getOne(id);
51
51
  return {
52
- issuer: this.options.baseURL,
52
+ issuer: `${this.options.baseURL.replace(/\/+$/, "")}/realms/${entity.name}`,
53
53
  authorization_endpoint: new URL("authorize", this.options.baseURL).href,
54
- jwks_uri: new URL(`realms/${entity.id}/jwks`, this.options.baseURL).href,
54
+ jwks_uri: new URL(`realms/${entity.name}/jwks`, this.options.baseURL).href,
55
55
  response_types_supported: [
56
56
  OAuth2AuthorizationResponseType.CODE,
57
57
  OAuth2AuthorizationResponseType.TOKEN,
@@ -74,11 +74,13 @@ var RealmController = class {
74
74
  userinfo_endpoint: new URL("users/@me", this.options.baseURL).href
75
75
  };
76
76
  }
77
- async getCerts(id, req, res) {
78
- return getJwksRouteHandler(req, res, this.keyRepository, "id");
77
+ async getCerts(id, res) {
78
+ const entity = await this.service.getOne(id);
79
+ return getJwksRouteHandler(res, this.keyRepository, entity.id);
79
80
  }
80
- async getCert(id, keyId, req, res) {
81
- return getJwkRouteHandler(req, res, this.keyRepository, "keyId");
81
+ async getCert(id, keyId, res) {
82
+ const entity = await this.service.getOne(id);
83
+ return getJwkRouteHandler(res, this.keyRepository, keyId, entity.id);
82
84
  }
83
85
  async edit(id, data, req, res) {
84
86
  const actor = buildActorContext(req);
@@ -139,27 +141,20 @@ _ts_decorate([
139
141
  _ts_decorate([
140
142
  DGet("/:id/jwks", []),
141
143
  _ts_param(0, DPath("id")),
142
- _ts_param(1, DRequest()),
143
- _ts_param(2, DResponse()),
144
+ _ts_param(1, DResponse()),
144
145
  _ts_metadata("design:type", Function),
145
- _ts_metadata("design:paramtypes", [
146
- String,
147
- Object,
148
- Object
149
- ]),
146
+ _ts_metadata("design:paramtypes", [String, Object]),
150
147
  _ts_metadata("design:returntype", Promise)
151
148
  ], RealmController.prototype, "getCerts", null);
152
149
  _ts_decorate([
153
150
  DGet("/:id/jwks/:keyId", []),
154
151
  _ts_param(0, DPath("id")),
155
152
  _ts_param(1, DPath("keyId")),
156
- _ts_param(2, DRequest()),
157
- _ts_param(3, DResponse()),
153
+ _ts_param(2, DResponse()),
158
154
  _ts_metadata("design:type", Function),
159
155
  _ts_metadata("design:paramtypes", [
160
156
  String,
161
157
  String,
162
- Object,
163
158
  Object
164
159
  ]),
165
160
  _ts_metadata("design:returntype", Promise)
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["DBody","DController","DDelete","DGet","DPath","DPost","DPut","DRequest","DResponse","DTags","OAuth2AuthorizationResponseType","send","sendAccepted","sendCreated","useRequestQuery","getJwkRouteHandler","getJwksRouteHandler","ForceLoggedInMiddleware","buildActorContext","RealmController","options","service","keyRepository","ctx","getMany","req","res","data","meta","add","actor","entity","create","get","id","getOne","getOpenIdConfiguration","issuer","baseURL","authorization_endpoint","URL","href","jwks_uri","response_types_supported","CODE","TOKEN","NONE","subject_types_supported","id_token_signing_alg_values_supported","token_endpoint","introspection_endpoint","revocation_endpoint","service_documentation","userinfo_endpoint","getCerts","getCert","keyId","edit","update","put","created","save","undefined","drop","delete"],"sources":["../../../../../../src/adapters/http/controllers/entities/realm/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n DBody, \n DController, \n DDelete, \n DGet, \n DPath, \n DPost, \n DPut, \n DRequest, \n DResponse, \n DTags,\n} from '@routup/decorators';\nimport type { OAuth2JsonWebKey, OpenIDProviderMetadata } from '@authup/specs';\nimport { OAuth2AuthorizationResponseType } from '@authup/specs';\nimport { send, sendAccepted, sendCreated } from 'routup';\nimport { useRequestQuery } from '@routup/basic/query';\nimport type { Repository } from 'typeorm';\nimport type { IRealmService } from '../../../../../core/index.ts';\nimport type { KeyEntity } from '../../../../database/domains/index.ts';\nimport { getJwkRouteHandler, getJwksRouteHandler } from '../../workflows/index.ts';\nimport { ForceLoggedInMiddleware } from '../../../middleware/index.ts';\nimport { buildActorContext } from '../../../request/index.ts';\n\nexport type RealmControllerOptions = {\n baseURL: string\n};\n\nexport type RealmControllerContext = {\n options: RealmControllerOptions,\n service: IRealmService,\n keyRepository: Repository<KeyEntity>,\n};\n\n@DTags('realm')\n@DController('/realms')\nexport class RealmController {\n protected options: RealmControllerOptions;\n\n protected service: IRealmService;\n\n protected keyRepository: Repository<KeyEntity>;\n\n constructor(ctx: RealmControllerContext) {\n this.options = ctx.options;\n this.service = ctx.service;\n this.keyRepository = ctx.keyRepository;\n }\n\n @DGet('', [])\n async getMany(\n @DRequest() req: any,\n @DResponse() res: any,\n ): Promise<any> {\n const {\n data, \n meta, \n } = await this.service.getMany(useRequestQuery(req));\n\n return send(res, {\n data,\n meta, \n });\n }\n\n @DPost('', [ForceLoggedInMiddleware])\n async add(\n @DBody() data: any,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const entity = await this.service.create(data, actor);\n\n return sendCreated(res, entity);\n }\n\n @DGet('/:id', [])\n async get(\n @DPath('id') id: string,\n @DRequest() req: any,\n @DResponse() res: any,\n ): Promise<any> {\n const entity = await this.service.getOne(\n id,\n );\n\n return send(res, entity);\n }\n\n @DGet('/:id/.well-known/openid-configuration', [])\n async getOpenIdConfiguration(\n @DPath('id') id: string,\n ): Promise<OpenIDProviderMetadata> {\n const entity = await this.service.getOne(id);\n\n return {\n issuer: this.options.baseURL,\n\n authorization_endpoint: new URL('authorize', this.options.baseURL).href,\n\n jwks_uri: new URL(`realms/${entity.id}/jwks`, this.options.baseURL).href,\n\n response_types_supported: [\n OAuth2AuthorizationResponseType.CODE,\n OAuth2AuthorizationResponseType.TOKEN,\n OAuth2AuthorizationResponseType.NONE,\n ],\n\n subject_types_supported: [\n 'public',\n ],\n\n id_token_signing_alg_values_supported: [\n 'HS256', \n 'HS384', \n 'HS512', \n 'RS256', \n 'RS384', \n 'RS512', \n 'none',\n ],\n\n token_endpoint: new URL('token', this.options.baseURL).href,\n\n introspection_endpoint: new URL('token/introspect', this.options.baseURL).href,\n\n revocation_endpoint: new URL('token', this.options.baseURL).href,\n\n // -----------------------------------------------------------\n\n service_documentation: 'https://authup.org/',\n\n userinfo_endpoint: new URL('users/@me', this.options.baseURL).href,\n };\n }\n\n @DGet('/:id/jwks', [])\n async getCerts(\n @DPath('id') id: string,\n @DRequest() req: any,\n @DResponse() res: any,\n ): Promise<OAuth2JsonWebKey[]> {\n return getJwksRouteHandler(req, res, this.keyRepository, 'id');\n }\n\n @DGet('/:id/jwks/:keyId', [])\n async getCert(\n @DPath('id') id: string,\n @DPath('keyId') keyId: string,\n @DRequest() req: any,\n @DResponse() res: any,\n ): Promise<OAuth2JsonWebKey> {\n return getJwkRouteHandler(req, res, this.keyRepository, 'keyId');\n }\n\n @DPost('/:id', [ForceLoggedInMiddleware])\n async edit(\n @DPath('id') id: string,\n @DBody() data: any,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const entity = await this.service.update(\n id,\n data,\n actor,\n );\n\n return sendAccepted(res, entity);\n }\n\n @DPut('/:id', [ForceLoggedInMiddleware])\n async put(\n @DPath('id') id: string,\n @DBody() data: any,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const {\n entity, \n created, \n } = await this.service.save(\n id || undefined,\n data,\n actor,\n );\n\n if (created) {\n return sendCreated(res, entity);\n }\n\n return sendAccepted(res, entity);\n }\n\n @DDelete('/:id', [ForceLoggedInMiddleware])\n async drop(\n @DPath('id') id: string,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const entity = await this.service.delete(id, actor);\n\n return sendAccepted(res, entity);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAamB,kBAAb,MAAaA;CACCC;CAEAC;CAEAC;CAEV,YAAYC,KAA6B;AACrC,OAAKH,UAAUG,IAAIH;AACnB,OAAKC,UAAUE,IAAIF;AACnB,OAAKC,gBAAgBC,IAAID;;CAG7B,MACME,QACF,KACA,KACY;EACZ,MAAM,EACFG,MACAC,SACA,MAAM,KAAKP,QAAQG,QAAQV,gBAAgBW,IAAAA,CAAAA;AAE/C,SAAOd,KAAKe,KAAK;GACbC;GACAC;GACJ,CAAA;;CAGJ,MACMC,IACF,MACA,KACA,KACa;EACb,MAAMC,QAAQZ,kBAAkBO,IAAAA;AAGhC,SAAOZ,YAAYa,KAAKK,MAFH,KAAKV,QAAQW,OAAOL,MAAMG,MAAAA,CAEvBC;;CAG5B,MACME,IACF,IACA,KACA,KACY;AAKZ,SAAOtB,KAAKe,KAAKK,MAJI,KAAKV,QAAQc,OAC9BD,GAAAA,CAGaH;;CAGrB,MACMK,uBACF,IAC+B;EAC/B,MAAML,SAAS,MAAM,KAAKV,QAAQc,OAAOD,GAAAA;AAEzC,SAAO;GACHG,QAAQ,KAAKjB,QAAQkB;GAErBC,wBAAwB,IAAIC,IAAI,aAAa,KAAKpB,QAAQkB,QAAO,CAAEG;GAEnEC,UAAU,IAAIF,IAAI,UAAUT,OAAOG,GAAG,QAAQ,KAAKd,QAAQkB,QAAO,CAAEG;GAEpEE,0BAA0B;IACtBjC,gCAAgCkC;IAChClC,gCAAgCmC;IA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2FIA,wBAAAA,CAAAA;;;;;;;;;;;;;;;eAiBDA,wBAAAA,CAAAA;;;;;;;;;;;;;;;kBAwBGA,wBAAAA,CAAAA"}
1
+ {"version":3,"file":"module.mjs","names":["DBody","DController","DDelete","DGet","DPath","DPost","DPut","DRequest","DResponse","DTags","OAuth2AuthorizationResponseType","send","sendAccepted","sendCreated","useRequestQuery","getJwkRouteHandler","getJwksRouteHandler","ForceLoggedInMiddleware","buildActorContext","RealmController","options","service","keyRepository","ctx","getMany","req","res","data","meta","add","actor","entity","create","get","id","getOne","getOpenIdConfiguration","baseURL","replace","issuer","name","authorization_endpoint","URL","href","jwks_uri","response_types_supported","CODE","TOKEN","NONE","subject_types_supported","id_token_signing_alg_values_supported","token_endpoint","introspection_endpoint","revocation_endpoint","service_documentation","userinfo_endpoint","getCerts","getCert","keyId","edit","update","put","created","save","undefined","drop","delete"],"sources":["../../../../../../src/adapters/http/controllers/entities/realm/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n DBody, \n DController, \n DDelete, \n DGet, \n DPath, \n DPost, \n DPut, \n DRequest, \n DResponse, \n DTags,\n} from '@routup/decorators';\nimport type { OAuth2JsonWebKey, OpenIDProviderMetadata } from '@authup/specs';\nimport { OAuth2AuthorizationResponseType } from '@authup/specs';\nimport { send, sendAccepted, sendCreated } from 'routup';\nimport { useRequestQuery } from '@routup/basic/query';\nimport type { Repository } from 'typeorm';\nimport type { IRealmService } from '../../../../../core/index.ts';\nimport type { KeyEntity } from '../../../../database/domains/index.ts';\nimport { getJwkRouteHandler, getJwksRouteHandler } from '../../workflows/index.ts';\nimport { ForceLoggedInMiddleware } from '../../../middleware/index.ts';\nimport { buildActorContext } from '../../../request/index.ts';\n\nexport type RealmControllerOptions = {\n baseURL: string\n};\n\nexport type RealmControllerContext = {\n options: RealmControllerOptions,\n service: IRealmService,\n keyRepository: Repository<KeyEntity>,\n};\n\n@DTags('realm')\n@DController('/realms')\nexport class RealmController {\n protected options: RealmControllerOptions;\n\n protected service: IRealmService;\n\n protected keyRepository: Repository<KeyEntity>;\n\n constructor(ctx: RealmControllerContext) {\n this.options = ctx.options;\n this.service = ctx.service;\n this.keyRepository = ctx.keyRepository;\n }\n\n @DGet('', [])\n async getMany(\n @DRequest() req: any,\n @DResponse() res: any,\n ): Promise<any> {\n const {\n data, \n meta, \n } = await this.service.getMany(useRequestQuery(req));\n\n return send(res, {\n data,\n meta, \n });\n }\n\n @DPost('', [ForceLoggedInMiddleware])\n async add(\n @DBody() data: any,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const entity = await this.service.create(data, actor);\n\n return sendCreated(res, entity);\n }\n\n @DGet('/:id', [])\n async get(\n @DPath('id') id: string,\n @DRequest() req: any,\n @DResponse() res: any,\n ): Promise<any> {\n const entity = await this.service.getOne(\n id,\n );\n\n return send(res, entity);\n }\n\n @DGet('/:id/.well-known/openid-configuration', [])\n async getOpenIdConfiguration(\n @DPath('id') id: string,\n ): Promise<OpenIDProviderMetadata> {\n const entity = await this.service.getOne(id);\n\n const baseURL = this.options.baseURL.replace(/\\/+$/, '');\n\n return {\n issuer: `${baseURL}/realms/${entity.name}`,\n\n authorization_endpoint: new URL('authorize', this.options.baseURL).href,\n\n jwks_uri: new URL(`realms/${entity.name}/jwks`, this.options.baseURL).href,\n\n response_types_supported: [\n OAuth2AuthorizationResponseType.CODE,\n OAuth2AuthorizationResponseType.TOKEN,\n OAuth2AuthorizationResponseType.NONE,\n ],\n\n subject_types_supported: [\n 'public',\n ],\n\n id_token_signing_alg_values_supported: [\n 'HS256', \n 'HS384', \n 'HS512', \n 'RS256', \n 'RS384', \n 'RS512', \n 'none',\n ],\n\n token_endpoint: new URL('token', this.options.baseURL).href,\n\n introspection_endpoint: new URL('token/introspect', this.options.baseURL).href,\n\n revocation_endpoint: new URL('token', this.options.baseURL).href,\n\n // -----------------------------------------------------------\n\n service_documentation: 'https://authup.org/',\n\n userinfo_endpoint: new URL('users/@me', this.options.baseURL).href,\n };\n }\n\n @DGet('/:id/jwks', [])\n async getCerts(\n @DPath('id') id: string,\n @DResponse() res: any,\n ): Promise<OAuth2JsonWebKey[]> {\n const entity = await this.service.getOne(id);\n return getJwksRouteHandler(res, this.keyRepository, entity.id);\n }\n\n @DGet('/:id/jwks/:keyId', [])\n async getCert(\n @DPath('id') id: string,\n @DPath('keyId') keyId: string,\n @DResponse() res: any,\n ): Promise<OAuth2JsonWebKey> {\n const entity = await this.service.getOne(id);\n return getJwkRouteHandler(res, this.keyRepository, keyId, entity.id);\n }\n\n @DPost('/:id', [ForceLoggedInMiddleware])\n async edit(\n @DPath('id') id: string,\n @DBody() data: any,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const entity = await this.service.update(\n id,\n data,\n actor,\n );\n\n return sendAccepted(res, entity);\n }\n\n @DPut('/:id', [ForceLoggedInMiddleware])\n async put(\n @DPath('id') id: string,\n @DBody() data: any,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const {\n entity, \n created, \n } = await this.service.save(\n id || undefined,\n data,\n actor,\n );\n\n if (created) {\n return sendCreated(res, entity);\n }\n\n return sendAccepted(res, entity);\n }\n\n @DDelete('/:id', [ForceLoggedInMiddleware])\n async drop(\n @DPath('id') id: string,\n @DRequest() req: any,\n @DResponse() res: any,\n ) : Promise<any> {\n const actor = buildActorContext(req);\n const entity = await this.service.delete(id, actor);\n\n return sendAccepted(res, entity);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAamB,kBAAb,MAAaA;CACCC;CAEAC;CAEAC;CAEV,YAAYC,KAA6B;AACrC,OAAKH,UAAUG,IAAIH;AACnB,OAAKC,UAAUE,IA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AClE;;CAGJ,MACMa,SACF,IACA,KAC2B;EAC3B,MAAMzB,SAAS,MAAM,KAAKV,QAAQc,OAAOD,GAAAA;AACzC,SAAOlB,oBAAoBU,KAAK,KAAKJ,eAAeS,OAAOG,GAAE;;CAGjE,MACMuB,QACF,IACA,OACA,KACyB;EACzB,MAAM1B,SAAS,MAAM,KAAKV,QAAQc,OAAOD,GAAAA;AACzC,SAAOnB,mBAAmBW,KAAK,KAAKJ,eAAeoC,OAAO3B,OAAOG,GAAE;;CAGvE,MACMyB,KACF,IACA,MACA,KACA,KACa;EACb,MAAM7B,QAAQZ,kBAAkBO,IAAAA;AAOhC,SAAOb,aAAac,KAAKK,MANJ,KAAKV,QAAQuC,OAC9B1B,IACAP,MACAG,MAAAA,CAGqBC;;CAG7B,MACM8B,IACF,IACA,MACA,KACA,KACa;EACb,MAAM/B,QAAQZ,kBAAkBO,IAAAA;EAChC,MAAM,EACFM,QACA+B,YACA,MAAM,KAAKzC,QAAQ0C,KACnB7B,MAAM8B,KAAAA,GACNrC,MACAG,MAAAA;AAGJ,MAAIgC,QACA,QAAOjD,YAAYa,KAAKK,OAAAA;AAG5B,SAAOnB,aAAac,KAAKK,OAAAA;;CAG7B,MACMkC,KACF,IACA,KACA,KACa;EACb,MAAMnC,QAAQZ,kBAAkBO,IAAAA;AAGhC,SAAOb,aAAac,KAAKK,MAFJ,KAAKV,QAAQ6C,OAAOhC,IAAIJ,MAAAA,CAEpBC;;;;;;;;;;;;YA/IjBd,wBAAAA,CAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA6FIA,wBAAAA,CAAAA;;;;;;;;;;;;;;;eAiBDA,wBAAAA,CAAAA;;;;;;;;;;;;;;;kBAwBGA,wBAAAA,CAAAA"}
@@ -1,6 +1,6 @@
1
- import type { Request, Response } from 'routup';
1
+ import type { Response } from 'routup';
2
2
  import type { Repository } from 'typeorm';
3
3
  import type { KeyEntity } from '../../../../../database/domains/index.ts';
4
- export declare function getJwksRouteHandler(req: Request, res: Response, repository: Repository<KeyEntity>, realmIdParamKey?: string): Promise<any>;
5
- export declare function getJwkRouteHandler(req: Request, res: Response, repository: Repository<KeyEntity>, idParamKey?: string): Promise<any>;
4
+ export declare function getJwksRouteHandler(res: Response, repository: Repository<KeyEntity>, realmId?: string): Promise<any>;
5
+ export declare function getJwkRouteHandler(res: Response, repository: Repository<KeyEntity>, keyId: string, realmId?: string): Promise<any>;
6
6
  //# sourceMappingURL=read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../../../../../src/adapters/http/controllers/workflows/jwks/handlers/read.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAG1E,wBAAsB,mBAAmB,CACrC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACjC,eAAe,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,GAAG,CAAC,CA+Bf;AAED,wBAAsB,kBAAkB,CACpC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACjC,UAAU,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,GAAG,CAAC,CAgCf"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../../../../../src/adapters/http/controllers/workflows/jwks/handlers/read.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAE1E,wBAAsB,mBAAmB,CACrC,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACjC,OAAO,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CA6Bf;AAED,wBAAsB,kBAAkB,CACpC,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACjC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,CA+Bf"}
@@ -1,13 +1,10 @@
1
- import { getRequestStringParam, getRequestStringParamOrFail } from "../../../../request/helpers/param-id.mjs";
2
- import "../../../../request/index.mjs";
3
1
  import { In } from "typeorm";
4
2
  import { AsymmetricKey } from "@authup/server-kit";
5
3
  import { JWKType } from "@authup/specs";
6
4
  import { BadRequestError, NotFoundError } from "@ebec/http";
7
5
  import { send } from "routup";
8
6
  //#region src/adapters/http/controllers/workflows/jwks/handlers/read.ts
9
- async function getJwksRouteHandler(req, res, repository, realmIdParamKey) {
10
- const realmId = getRequestStringParam(req, realmIdParamKey || "realmId");
7
+ async function getJwksRouteHandler(res, repository, realmId) {
11
8
  const promises = (await repository.find({
12
9
  where: {
13
10
  type: In([JWKType.RSA, JWKType.EC]),
@@ -25,11 +22,11 @@ async function getJwksRouteHandler(req, res, repository, realmIdParamKey) {
25
22
  })));
26
23
  return send(res, { keys: await Promise.all(promises) });
27
24
  }
28
- async function getJwkRouteHandler(req, res, repository, idParamKey) {
29
- const id = getRequestStringParamOrFail(req, idParamKey || "id");
25
+ async function getJwkRouteHandler(res, repository, keyId, realmId) {
30
26
  const entity = await repository.findOne({ where: {
31
27
  type: In([JWKType.RSA, JWKType.EC]),
32
- id
28
+ id: keyId,
29
+ ...realmId ? { realm_id: realmId } : {}
33
30
  } });
34
31
  if (!entity) throw new NotFoundError();
35
32
  if (!entity.encryption_key) throw new BadRequestError("The encryption key does not exist");
@@ -1 +1 @@
1
- {"version":3,"file":"read.mjs","names":["AsymmetricKey","JWKType","send","In","BadRequestError","NotFoundError","getRequestStringParam","getRequestStringParamOrFail","getJwksRouteHandler","req","res","repository","realmIdParamKey","realmId","entities","find","where","type","RSA","EC","realm_id","order","priority","promises","filter","entity","encryption_key","map","fromBase64","format","key","options","buildImportOptionsForJWTAlgorithm","signature_algorithm","then","container","toJWK","kid","id","alg","keys","Promise","all","getJwkRouteHandler","idParamKey","findOne","jsonWebKey"],"sources":["../../../../../../../src/adapters/http/controllers/workflows/jwks/handlers/read.ts"],"sourcesContent":["/*\n * Copyright (c) 2022-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { AsymmetricKey } from '@authup/server-kit';\nimport { JWKType } from '@authup/specs';\nimport type { Request, Response } from 'routup';\nimport { send } from 'routup';\nimport type { Repository } from 'typeorm';\nimport { In } from 'typeorm';\nimport { BadRequestError, NotFoundError } from '@ebec/http';\nimport type { KeyEntity } from '../../../../../database/domains/index.ts';\nimport { getRequestStringParam, getRequestStringParamOrFail } from '../../../../request/index.ts';\n\nexport async function getJwksRouteHandler(\n req: Request,\n res: Response,\n repository: Repository<KeyEntity>,\n realmIdParamKey?: string,\n) : Promise<any> {\n const realmId = getRequestStringParam(req, realmIdParamKey || 'realmId');\n\n const entities = await repository.find({\n where: {\n type: In([JWKType.RSA, JWKType.EC]),\n ...(realmId ? { realm_id: realmId } : {}),\n },\n order: { priority: 'DESC' },\n });\n\n const promises = entities\n .filter((entity) => !!entity.encryption_key)\n .map(\n (entity) => AsymmetricKey\n .fromBase64({\n format: 'spki',\n key: entity.encryption_key!,\n options: AsymmetricKey.buildImportOptionsForJWTAlgorithm(entity.signature_algorithm),\n })\n .then((container) => container.toJWK())\n .then((key) => ({\n ...key,\n kid: entity.id,\n alg: entity.signature_algorithm,\n })),\n );\n\n const keys = await Promise.all(promises);\n\n return send(res, { keys });\n}\n\nexport async function getJwkRouteHandler(\n req: Request,\n res: Response,\n repository: Repository<KeyEntity>,\n idParamKey?: string,\n) : Promise<any> {\n const id = getRequestStringParamOrFail(req, idParamKey || 'id');\n\n const entity = await repository.findOne({\n where: {\n type: In([JWKType.RSA, JWKType.EC]),\n id,\n },\n });\n\n if (!entity) {\n throw new NotFoundError();\n }\n\n if (!entity.encryption_key) {\n throw new BadRequestError('The encryption key does not exist');\n }\n\n const container = await AsymmetricKey\n .fromBase64({\n format: 'spki',\n key: entity.encryption_key!,\n options: AsymmetricKey.buildImportOptionsForJWTAlgorithm(entity.signature_algorithm),\n });\n\n const jsonWebKey = await container.toJWK();\n jsonWebKey.alg = entity.signature_algorithm;\n\n return send(res, {\n ...jsonWebKey,\n kid: entity.id,\n });\n}\n"],"mappings":";;;;;;;;AAiBA,eAAsBQ,oBAClBC,KACAC,KACAC,YACAC,iBAAwB;CAExB,MAAMC,UAAUP,sBAAsBG,KAAKG,mBAAmB,UAAA;CAU9D,MAAMW,YAAWT,MARMH,WAAWI,KAAK;EACnCC,OAAO;GACHC,MAAMd,GAAG,CAACF,QAAQiB,KAAKjB,QAAQkB,GAAG,CAAA;GAClC,GAAIN,UAAU,EAAEO,UAAUP,SAAQ,GAAI,EAAE;GAC5C;EACAQ,OAAO,EAAEC,UAAU,QAAO;EAC9B,CAAA,EAGKE,QAAQC,WAAW,CAAC,CAACA,OAAOC,eAAc,CAC1CC,KACIF,WAAWzB,cACP4B,WAAW;EACRC,QAAQ;EACRC,KAAKL,OAAOC;EACZK,SAAS/B,cAAcgC,kCAAkCP,OAAOQ,oBAAmB;EACvF,CAAA,CACCC,MAAMC,cAAcA,UAAUC,OAAK,CAAA,CACnCF,MAAMJ,SAAS;EACZ,GAAGA;EACHO,KAAKZ,OAAOa;EACZC,KAAKd,OAAOQ;EAChB,EAAA,CAAA;AAKZ,QAAO/B,KAAKQ,KAAK,EAAE8B,MAAAA,MAFAC,QAAQC,IAAInB,SAAAA,EAEP,CAAA;;AAG5B,eAAsBoB,mBAClBlC,KACAC,KACAC,YACAiC,YAAmB;CAEnB,MAAMN,KAAK/B,4BAA4BE,KAAKmC,cAAc,KAAA;CAE1D,MAAMnB,SAAS,MAAMd,WAAWkC,QAAQ,EACpC7B,OAAO;EACHC,MAAMd,GAAG,CAACF,QAAQiB,KAAKjB,QAAQkB,GAAG,CAAA;EAClCmB;EACJ,EACJ,CAAA;AAEA,KAAI,CAACb,OACD,OAAM,IAAIpB,eAAAA;AAGd,KAAI,CAACoB,OAAOC,eACR,OAAM,IAAItB,gBAAgB,oCAAA;CAU9B,MAAM0C,aAAa,OAAMX,MAPDnC,cACnB4B,WAAW;EACRC,QAAQ;EACRC,KAAKL,OAAOC;EACZK,SAAS/B,cAAcgC,kCAAkCP,OAAOQ,oBAAmB;EACvF,CAAA,EAE+BG,OAAK;AACxCU,YAAWP,MAAMd,OAAOQ;AAExB,QAAO/B,KAAKQ,KAAK;EACb,GAAGoC;EACHT,KAAKZ,OAAOa;EAChB,CAAA"}
1
+ {"version":3,"file":"read.mjs","names":["AsymmetricKey","JWKType","send","In","BadRequestError","NotFoundError","getJwksRouteHandler","res","repository","realmId","entities","find","where","type","RSA","EC","realm_id","order","priority","promises","filter","entity","encryption_key","map","fromBase64","format","key","options","buildImportOptionsForJWTAlgorithm","signature_algorithm","then","container","toJWK","kid","id","alg","keys","Promise","all","getJwkRouteHandler","keyId","findOne","jsonWebKey"],"sources":["../../../../../../../src/adapters/http/controllers/workflows/jwks/handlers/read.ts"],"sourcesContent":["/*\n * Copyright (c) 2022-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { AsymmetricKey } from '@authup/server-kit';\nimport { JWKType } from '@authup/specs';\nimport type { Response } from 'routup';\nimport { send } from 'routup';\nimport type { Repository } from 'typeorm';\nimport { In } from 'typeorm';\nimport { BadRequestError, NotFoundError } from '@ebec/http';\nimport type { KeyEntity } from '../../../../../database/domains/index.ts';\n\nexport async function getJwksRouteHandler(\n res: Response,\n repository: Repository<KeyEntity>,\n realmId?: string,\n) : Promise<any> {\n const entities = await repository.find({\n where: {\n type: In([JWKType.RSA, JWKType.EC]),\n ...(realmId ? { realm_id: realmId } : {}),\n },\n order: { priority: 'DESC' },\n });\n\n const promises = entities\n .filter((entity) => !!entity.encryption_key)\n .map(\n (entity) => AsymmetricKey\n .fromBase64({\n format: 'spki',\n key: entity.encryption_key!,\n options: AsymmetricKey.buildImportOptionsForJWTAlgorithm(entity.signature_algorithm),\n })\n .then((container) => container.toJWK())\n .then((key) => ({\n ...key,\n kid: entity.id,\n alg: entity.signature_algorithm,\n })),\n );\n\n const keys = await Promise.all(promises);\n\n return send(res, { keys });\n}\n\nexport async function getJwkRouteHandler(\n res: Response,\n repository: Repository<KeyEntity>,\n keyId: string,\n realmId?: string,\n) : Promise<any> {\n const entity = await repository.findOne({\n where: {\n type: In([JWKType.RSA, JWKType.EC]),\n id: keyId,\n ...(realmId ? { realm_id: realmId } : {}),\n },\n });\n\n if (!entity) {\n throw new NotFoundError();\n }\n\n if (!entity.encryption_key) {\n throw new BadRequestError('The encryption key does not exist');\n }\n\n const container = await AsymmetricKey\n .fromBase64({\n format: 'spki',\n key: entity.encryption_key!,\n options: AsymmetricKey.buildImportOptionsForJWTAlgorithm(entity.signature_algorithm),\n });\n\n const jsonWebKey = await container.toJWK();\n jsonWebKey.alg = entity.signature_algorithm;\n\n return send(res, {\n ...jsonWebKey,\n kid: entity.id,\n });\n}\n"],"mappings":";;;;;;AAgBA,eAAsBM,oBAClBC,KACAC,YACAC,SAAgB;CAUhB,MAAMU,YAAWT,MARMF,WAAWG,KAAK;EACnCC,OAAO;GACHC,MAAMV,GAAG,CAACF,QAAQa,KAAKb,QAAQc,GAAG,CAAA;GAClC,GAAIN,UAAU,EAAEO,UAAUP,SAAQ,GAAI,EAAE;GAC5C;EACAQ,OAAO,EAAEC,UAAU,QAAO;EAC9B,CAAA,EAGKE,QAAQC,WAAW,CAAC,CAACA,OAAOC,eAAc,CAC1CC,KACIF,WAAWrB,cACPwB,WAAW;EACRC,QAAQ;EACRC,KAAKL,OAAOC;EACZK,SAAS3B,cAAc4B,kCAAkCP,OAAOQ,oBAAmB;EACvF,CAAA,CACCC,MAAMC,cAAcA,UAAUC,OAAK,CAAA,CACnCF,MAAMJ,SAAS;EACZ,GAAGA;EACHO,KAAKZ,OAAOa;EACZC,KAAKd,OAAOQ;EAChB,EAAA,CAAA;AAKZ,QAAO3B,KAAKK,KAAK,EAAE6B,MAAAA,MAFAC,QAAQC,IAAInB,SAAAA,EAEP,CAAA;;AAG5B,eAAsBoB,mBAClBhC,KACAC,YACAgC,OACA/B,SAAgB;CAEhB,MAAMY,SAAS,MAAMb,WAAWiC,QAAQ,EACpC7B,OAAO;EACHC,MAAMV,GAAG,CAACF,QAAQa,KAAKb,QAAQc,GAAG,CAAA;EAClCmB,IAAIM;EACJ,GAAI/B,UAAU,EAAEO,UAAUP,SAAQ,GAAI,EAAE;EAC5C,EACJ,CAAA;AAEA,KAAI,CAACY,OACD,OAAM,IAAIhB,eAAAA;AAGd,KAAI,CAACgB,OAAOC,eACR,OAAM,IAAIlB,gBAAgB,oCAAA;CAU9B,MAAMsC,aAAa,OAAMX,MAPD/B,cACnBwB,WAAW;EACRC,QAAQ;EACRC,KAAKL,OAAOC;EACZK,SAAS3B,cAAc4B,kCAAkCP,OAAOQ,oBAAmB;EACvF,CAAA,EAE+BG,OAAK;AACxCU,YAAWP,MAAMd,OAAOQ;AAExB,QAAO3B,KAAKK,KAAK;EACb,GAAGmC;EACHT,KAAKZ,OAAOa;EAChB,CAAA"}
@@ -20,7 +20,7 @@ var ClientCredentialsGrant = class extends OAuth2BaseGrant {
20
20
  sub: input.id,
21
21
  sub_kind: OAuth2SubKind.CLIENT,
22
22
  realm_id: input.realm.id,
23
- realm_name: input.realm.id,
23
+ realm_name: input.realm.name,
24
24
  client_id: input.id
25
25
  });
26
26
  return buildOAuth2BearerTokenResponse({
@@ -1 +1 @@
1
- {"version":3,"file":"client-credentials.mjs","names":["OAuth2SubKind","IdentityType","ScopeName","OAuth2BaseGrant","buildOAuth2BearerTokenResponse","ClientCredentialsGrant","runWith","input","options","session","sessionManager","create","user_agent","userAgent","ip_address","ipAddress","realm_id","sub","id","sub_kind","CLIENT","accessToken","accessTokenPayload","accessTokenIssuer","issue","remote_address","session_id","scope","GLOBAL","realm","realm_name","client_id"],"sources":["../../../../src/core/oauth2/grant-types/client-credentials.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse } from '@authup/specs';\nimport { OAuth2SubKind } from '@authup/specs';\nimport type { Client } from '@authup/core-kit';\nimport {\n IdentityType,\n ScopeName,\n} from '@authup/core-kit';\nimport { OAuth2BaseGrant } from './base.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { OAuth2GrantRunWIthOptions } from './types.ts';\n\nexport class ClientCredentialsGrant extends OAuth2BaseGrant<Client> {\n async runWith(input: Client, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: input.realm_id,\n sub: input.id,\n sub_kind: IdentityType.CLIENT,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n session_id: session.id,\n scope: ScopeName.GLOBAL,\n sub: input.id,\n sub_kind: OAuth2SubKind.CLIENT,\n realm_id: input.realm.id,\n realm_name: input.realm.id,\n client_id: input.id,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;AAkBA,IAAaK,yBAAb,cAA4CF,gBAAAA;CACxC,MAAMG,QAAQC,OAAeC,UAAqC,EAAE,EAAsC;EACtG,MAAMC,UAAU,MAAM,KAAKC,eAAeC,OAAO;GAC7CC,YAAYJ,QAAQK;GACpBC,YAAYN,QAAQO;GACpBC,UAAUT,MAAMS;GAChBC,KAAKV,MAAMW;GACXC,UAAUlB,aAAamB;GAC3B,CAAA;EAEA,MAAM,CAACC,aAAaC,sBAAsB,MAAM,KAAKC,kBAAkBC,MAAM;GACzEZ,YAAYH,QAAQG;GACpBa,gBAAgBhB,QAAQK;GACxBY,YAAYjB,QAAQS;GACpBS,OAAOzB,UAAU0B;GACjBX,KAAKV,MAAMW;GACXC,UAAUnB,cAAcoB;GACxBJ,UAAUT,MAAMsB,MAAMX;GACtBY,YAAYvB,MAAMsB,MAAMX;GACxBa,WAAWxB,MAAMW;GACrB,CAAA;AAEA,SAAOd,+BAA+B;GAClCiB;GACAC;GACJ,CAAA"}
1
+ {"version":3,"file":"client-credentials.mjs","names":["OAuth2SubKind","IdentityType","ScopeName","OAuth2BaseGrant","buildOAuth2BearerTokenResponse","ClientCredentialsGrant","runWith","input","options","session","sessionManager","create","user_agent","userAgent","ip_address","ipAddress","realm_id","sub","id","sub_kind","CLIENT","accessToken","accessTokenPayload","accessTokenIssuer","issue","remote_address","session_id","scope","GLOBAL","realm","realm_name","name","client_id"],"sources":["../../../../src/core/oauth2/grant-types/client-credentials.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse } from '@authup/specs';\nimport { OAuth2SubKind } from '@authup/specs';\nimport type { Client } from '@authup/core-kit';\nimport {\n IdentityType,\n ScopeName,\n} from '@authup/core-kit';\nimport { OAuth2BaseGrant } from './base.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { OAuth2GrantRunWIthOptions } from './types.ts';\n\nexport class ClientCredentialsGrant extends OAuth2BaseGrant<Client> {\n async runWith(input: Client, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: input.realm_id,\n sub: input.id,\n sub_kind: IdentityType.CLIENT,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n session_id: session.id,\n scope: ScopeName.GLOBAL,\n sub: input.id,\n sub_kind: OAuth2SubKind.CLIENT,\n realm_id: input.realm.id,\n realm_name: input.realm.name,\n client_id: input.id,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;AAkBA,IAAaK,yBAAb,cAA4CF,gBAAAA;CACxC,MAAMG,QAAQC,OAAeC,UAAqC,EAAE,EAAsC;EACtG,MAAMC,UAAU,MAAM,KAAKC,eAAeC,OAAO;GAC7CC,YAAYJ,QAAQK;GACpBC,YAAYN,QAAQO;GACpBC,UAAUT,MAAMS;GAChBC,KAAKV,MAAMW;GACXC,UAAUlB,aAAamB;GAC3B,CAAA;EAEA,MAAM,CAACC,aAAaC,sBAAsB,MAAM,KAAKC,kBAAkBC,MAAM;GACzEZ,YAAYH,QAAQG;GACpBa,gBAAgBhB,QAAQK;GACxBY,YAAYjB,QAAQS;GACpBS,OAAOzB,UAAU0B;GACjBX,KAAKV,MAAMW;GACXC,UAAUnB,cAAcoB;GACxBJ,UAAUT,MAAMsB,MAAMX;GACtBY,YAAYvB,MAAMsB,MAAME;GACxBC,WAAWzB,MAAMW;GACrB,CAAA;AAEA,SAAOd,+BAA+B;GAClCiB;GACAC;GACJ,CAAA"}
@@ -20,7 +20,7 @@ var RobotCredentialsGrant = class extends OAuth2BaseGrant {
20
20
  sub: input.id,
21
21
  sub_kind: OAuth2SubKind.ROBOT,
22
22
  realm_id: input.realm.id,
23
- realm_name: input.realm?.id,
23
+ realm_name: input.realm.name,
24
24
  client_id: input.client_id || void 0
25
25
  });
26
26
  return buildOAuth2BearerTokenResponse({
@@ -1 +1 @@
1
- {"version":3,"file":"robot-credentials.mjs","names":["OAuth2SubKind","IdentityType","ScopeName","OAuth2BaseGrant","buildOAuth2BearerTokenResponse","RobotCredentialsGrant","runWith","input","options","session","sessionManager","create","user_agent","userAgent","ip_address","ipAddress","realm_id","sub","id","sub_kind","ROBOT","accessToken","accessTokenPayload","accessTokenIssuer","issue","session_id","remote_address","scope","GLOBAL","realm","realm_name","client_id","undefined"],"sources":["../../../../src/core/oauth2/grant-types/robot-credentials.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse } from '@authup/specs';\nimport { OAuth2SubKind } from '@authup/specs';\nimport type { Robot } from '@authup/core-kit';\nimport {\n IdentityType,\n ScopeName,\n} from '@authup/core-kit';\nimport { OAuth2BaseGrant } from './base.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { OAuth2GrantRunWIthOptions } from './types.ts';\n\nexport class RobotCredentialsGrant extends OAuth2BaseGrant<Robot> {\n async runWith(input: Robot, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: input.realm_id,\n sub: input.id,\n sub_kind: IdentityType.ROBOT,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n scope: ScopeName.GLOBAL,\n sub: input.id,\n sub_kind: OAuth2SubKind.ROBOT,\n realm_id: input.realm.id,\n realm_name: input.realm?.id,\n client_id: input.client_id || undefined,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;AAkBA,IAAaK,wBAAb,cAA2CF,gBAAAA;CACvC,MAAMG,QAAQC,OAAcC,UAAqC,EAAE,EAAsC;EACrG,MAAMC,UAAU,MAAM,KAAKC,eAAeC,OAAO;GAC7CC,YAAYJ,QAAQK;GACpBC,YAAYN,QAAQO;GACpBC,UAAUT,MAAMS;GAChBC,KAAKV,MAAMW;GACXC,UAAUlB,aAAamB;GAC3B,CAAA;EAEA,MAAM,CAACC,aAAaC,sBAAsB,MAAM,KAAKC,kBAAkBC,MAAM;GACzEC,YAAYhB,QAAQS;GACpBN,YAAYH,QAAQG;GACpBc,gBAAgBjB,QAAQK;GACxBa,OAAOzB,UAAU0B;GACjBX,KAAKV,MAAMW;GACXC,UAAUnB,cAAcoB;GACxBJ,UAAUT,MAAMsB,MAAMX;GACtBY,YAAYvB,MAAMsB,OAAOX;GACzBa,WAAWxB,MAAMwB,aAAaC,KAAAA;GAClC,CAAA;AAEA,SAAO5B,+BAA+B;GAClCiB;GACAC;GACJ,CAAA"}
1
+ {"version":3,"file":"robot-credentials.mjs","names":["OAuth2SubKind","IdentityType","ScopeName","OAuth2BaseGrant","buildOAuth2BearerTokenResponse","RobotCredentialsGrant","runWith","input","options","session","sessionManager","create","user_agent","userAgent","ip_address","ipAddress","realm_id","sub","id","sub_kind","ROBOT","accessToken","accessTokenPayload","accessTokenIssuer","issue","session_id","remote_address","scope","GLOBAL","realm","realm_name","name","client_id","undefined"],"sources":["../../../../src/core/oauth2/grant-types/robot-credentials.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse } from '@authup/specs';\nimport { OAuth2SubKind } from '@authup/specs';\nimport type { Robot } from '@authup/core-kit';\nimport {\n IdentityType,\n ScopeName,\n} from '@authup/core-kit';\nimport { OAuth2BaseGrant } from './base.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { OAuth2GrantRunWIthOptions } from './types.ts';\n\nexport class RobotCredentialsGrant extends OAuth2BaseGrant<Robot> {\n async runWith(input: Robot, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: input.realm_id,\n sub: input.id,\n sub_kind: IdentityType.ROBOT,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n scope: ScopeName.GLOBAL,\n sub: input.id,\n sub_kind: OAuth2SubKind.ROBOT,\n realm_id: input.realm.id,\n realm_name: input.realm.name,\n client_id: input.client_id || undefined,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;AAkBA,IAAaK,wBAAb,cAA2CF,gBAAAA;CACvC,MAAMG,QAAQC,OAAcC,UAAqC,EAAE,EAAsC;EACrG,MAAMC,UAAU,MAAM,KAAKC,eAAeC,OAAO;GAC7CC,YAAYJ,QAAQK;GACpBC,YAAYN,QAAQO;GACpBC,UAAUT,MAAMS;GAChBC,KAAKV,MAAMW;GACXC,UAAUlB,aAAamB;GAC3B,CAAA;EAEA,MAAM,CAACC,aAAaC,sBAAsB,MAAM,KAAKC,kBAAkBC,MAAM;GACzEC,YAAYhB,QAAQS;GACpBN,YAAYH,QAAQG;GACpBc,gBAAgBjB,QAAQK;GACxBa,OAAOzB,UAAU0B;GACjBX,KAAKV,MAAMW;GACXC,UAAUnB,cAAcoB;GACxBJ,UAAUT,MAAMsB,MAAMX;GACtBY,YAAYvB,MAAMsB,MAAME;GACxBC,WAAWzB,MAAMyB,aAAaC,KAAAA;GAClC,CAAA;AAEA,SAAO7B,+BAA+B;GAClCiB;GACAC;GACJ,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@authup/server-core",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.39",
4
+ "version": "1.0.0-beta.40",
5
5
  "description": "This is a standalone application.",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/index.mjs",
@@ -67,13 +67,13 @@
67
67
  },
68
68
  "homepage": "https://github.com/authup/authup#readme",
69
69
  "dependencies": {
70
- "@authup/access": "^1.0.0-beta.39",
71
- "@authup/core-http-kit": "^1.0.0-beta.39",
72
- "@authup/core-kit": "^1.0.0-beta.39",
73
- "@authup/errors": "^1.0.0-beta.39",
74
- "@authup/kit": "^1.0.0-beta.39",
75
- "@authup/server-kit": "^1.0.0-beta.39",
76
- "@authup/specs": "^1.0.0-beta.39",
70
+ "@authup/access": "^1.0.0-beta.40",
71
+ "@authup/core-http-kit": "^1.0.0-beta.40",
72
+ "@authup/core-kit": "^1.0.0-beta.40",
73
+ "@authup/errors": "^1.0.0-beta.40",
74
+ "@authup/kit": "^1.0.0-beta.40",
75
+ "@authup/server-kit": "^1.0.0-beta.40",
76
+ "@authup/specs": "^1.0.0-beta.40",
77
77
  "@ebec/http": "^2.3.0",
78
78
  "@hapic/oauth2": "^3.2.0",
79
79
  "@routup/assets": "^3.4.2",
@@ -115,7 +115,7 @@
115
115
  "zod": "^4.3.6"
116
116
  },
117
117
  "devDependencies": {
118
- "@authup/client-web-kit": "^1.0.0-beta.39",
118
+ "@authup/client-web-kit": "^1.0.0-beta.40",
119
119
  "@faker-js/faker": "^10.4.0",
120
120
  "@fortawesome/fontawesome-free": "^7.2.0",
121
121
  "@types/cors": "^2.8.19",