@webiny/api-core 6.5.2-beta.1 → 6.5.2-beta.2

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.
Files changed (79) hide show
  1. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +2 -0
  2. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  3. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +2 -2
  4. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js +7 -1
  5. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
  6. package/features/security/apiKeys/GetApiKey/abstractions.d.ts +3 -3
  7. package/features/security/apiKeys/GetApiKey/abstractions.js.map +1 -1
  8. package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.d.ts +2 -2
  9. package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js +4 -1
  10. package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js.map +1 -1
  11. package/features/security/apiKeys/ListApiKeys/abstractions.d.ts +3 -4
  12. package/features/security/apiKeys/ListApiKeys/abstractions.js.map +1 -1
  13. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +2 -0
  14. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  15. package/features/security/apiKeys/shared/hideToken.d.ts +8 -0
  16. package/features/security/apiKeys/shared/hideToken.js +11 -0
  17. package/features/security/apiKeys/shared/hideToken.js.map +1 -0
  18. package/features/security/apiKeys/shared/types.d.ts +7 -0
  19. package/features/security/roles/CreateRole/CreateRoleUseCase.js +6 -0
  20. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  21. package/features/security/roles/DeleteRole/DeleteRoleUseCase.js +2 -1
  22. package/features/security/roles/DeleteRole/DeleteRoleUseCase.js.map +1 -1
  23. package/features/security/roles/DeleteRole/abstractions.d.ts +2 -1
  24. package/features/security/roles/DeleteRole/abstractions.js.map +1 -1
  25. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +10 -1
  26. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  27. package/features/security/roles/UpdateRole/abstractions.d.ts +2 -1
  28. package/features/security/roles/UpdateRole/abstractions.js.map +1 -1
  29. package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.d.ts +5 -2
  30. package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.js +16 -3
  31. package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.js.map +1 -1
  32. package/features/security/roles/shared/errors.d.ts +8 -0
  33. package/features/security/roles/shared/errors.js +15 -1
  34. package/features/security/roles/shared/errors.js.map +1 -1
  35. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  36. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +17 -2
  37. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  38. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  39. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -2
  40. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  41. package/features/security/utils/canAssignRolesAndTeams.d.ts +16 -0
  42. package/features/security/utils/canAssignRolesAndTeams.js +31 -0
  43. package/features/security/utils/canAssignRolesAndTeams.js.map +1 -0
  44. package/features/security/utils/canGrantPermissions.d.ts +53 -0
  45. package/features/security/utils/canGrantPermissions.js +122 -0
  46. package/features/security/utils/canGrantPermissions.js.map +1 -0
  47. package/features/security/utils/verifyJwtUsingJwk.d.ts +16 -1
  48. package/features/security/utils/verifyJwtUsingJwk.js +22 -4
  49. package/features/security/utils/verifyJwtUsingJwk.js.map +1 -1
  50. package/features/system/InstallSystem/InstallSystemUseCase.d.ts +1 -1
  51. package/features/tenancy/CreateTenant/CreateTenantRepository.js +1 -0
  52. package/features/tenancy/CreateTenant/CreateTenantRepository.js.map +1 -1
  53. package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +5 -3
  54. package/features/tenancy/CreateTenant/CreateTenantUseCase.js +10 -3
  55. package/features/tenancy/CreateTenant/CreateTenantUseCase.js.map +1 -1
  56. package/features/tenancy/CreateTenant/abstractions.d.ts +2 -1
  57. package/features/tenancy/CreateTenant/abstractions.js.map +1 -1
  58. package/features/tenancy/CreateTenant/decorators/CreateTenantWithWcpIncrement.d.ts +1 -1
  59. package/features/tenancy/CreateTenant/errors.d.ts +6 -0
  60. package/features/tenancy/CreateTenant/errors.js +11 -1
  61. package/features/tenancy/CreateTenant/errors.js.map +1 -1
  62. package/features/tenancy/DeleteTenant/decorators/DeleteTenantWithWcpDecrement.js +1 -0
  63. package/features/tenancy/DeleteTenant/decorators/DeleteTenantWithWcpDecrement.js.map +1 -1
  64. package/features/tenancy/TenantContext/TenantContext.d.ts +2 -0
  65. package/features/tenancy/TenantContext/TenantContext.js +18 -21
  66. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  67. package/features/tenancy/TenantContext/abstractions.d.ts +5 -0
  68. package/features/tenancy/TenantContext/abstractions.js.map +1 -1
  69. package/features/users/CreateUser/CreateUserUseCase.d.ts +5 -1
  70. package/features/users/CreateUser/CreateUserUseCase.js +18 -2
  71. package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
  72. package/features/users/UpdateUser/UpdateUserUseCase.d.ts +5 -1
  73. package/features/users/UpdateUser/UpdateUserUseCase.js +24 -2
  74. package/features/users/UpdateUser/UpdateUserUseCase.js.map +1 -1
  75. package/graphql/security/apiKey.gql.js +1 -0
  76. package/graphql/security/apiKey.gql.js.map +1 -1
  77. package/idp/OidcJwtIdentityProvider.js +4 -1
  78. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  79. package/package.json +22 -22
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/security/apiKey.gql.js","sources":["../../../src/graphql/security/apiKey.gql.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { CreateApiKeyUseCase } from \"~/features/security/apiKeys/CreateApiKey/index.js\";\nimport { UpdateApiKeyUseCase } from \"~/features/security/apiKeys/UpdateApiKey/index.js\";\nimport { DeleteApiKeyUseCase } from \"~/features/security/apiKeys/DeleteApiKey/index.js\";\nimport { ListApiKeysUseCase } from \"~/features/security/apiKeys/ListApiKeys/index.js\";\nimport { GetApiKeyUseCase } from \"~/features/security/apiKeys/GetApiKey/index.js\";\n\nexport default new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type SecurityApiKey {\n id: ID\n name: String\n slug: String\n description: String\n token: String\n permissions: [JSON]\n createdOn: DateTime\n createdBy: SecurityCreatedBy\n }\n\n input SecurityApiKeyInput {\n id: ID\n name: String!\n slug: String\n description: String\n token: String\n permissions: [JSON]!\n }\n\n type SecurityApiKeyResponse {\n data: SecurityApiKey\n error: SecurityError\n }\n\n type SecurityApiKeyListResponse {\n data: [SecurityApiKey!]\n error: SecurityError\n }\n\n extend type SecurityQuery {\n listApiKeys: SecurityApiKeyListResponse\n getApiKey(id: ID!): SecurityApiKeyResponse\n }\n\n extend type SecurityMutation {\n createApiKey(data: SecurityApiKeyInput!): SecurityApiKeyResponse\n updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse\n deleteApiKey(id: ID!): SecurityBooleanResponse\n }\n `,\n resolvers: {\n SecurityQuery: {\n async listApiKeys(_, __, context) {\n const list = context.container.resolve(ListApiKeysUseCase);\n const result = await list.execute();\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async getApiKey(_, args: any, context) {\n const getById = context.container.resolve(GetApiKeyUseCase);\n const result = await getById.execute(args.id);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n },\n SecurityMutation: {\n async createApiKey(_, args: any, context) {\n const createApiKey = context.container.resolve(CreateApiKeyUseCase);\n const result = await createApiKey.execute(args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async updateApiKey(_, args: any, context) {\n const updateApiKey = context.container.resolve(UpdateApiKeyUseCase);\n const result = await updateApiKey.execute(args.id, args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async deleteApiKey(_, args: any, context) {\n const deleteApiKey = context.container.resolve(DeleteApiKeyUseCase);\n const result = await deleteApiKey.execute(args.id);\n\n if (result.isOk()) {\n return new Response(true);\n }\n return new ErrorResponse(result.error);\n }\n }\n }\n});\n"],"names":["GraphQLSchemaPlugin","_","__","context","list","ListApiKeysUseCase","result","Response","ErrorResponse","args","getById","GetApiKeyUseCase","createApiKey","CreateApiKeyUseCase","updateApiKey","UpdateApiKeyUseCase","deleteApiKey","DeleteApiKeyUseCase"],"mappings":";;;;;;;AASA,mBAAe,IAAIA,oBAAoC;IACnD,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyCzB,CAAC;IACD,WAAW;QACP,eAAe;YACX,MAAM,aAAYC,CAAC,EAAEC,EAAE,EAAEC,OAAO;gBAC5B,MAAMC,OAAOD,QAAQ,SAAS,CAAC,OAAO,CAACE;gBACvC,MAAMC,SAAS,MAAMF,KAAK,OAAO;gBAEjC,IAAIE,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,WAAUL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACjC,MAAMO,UAAUP,QAAQ,SAAS,CAAC,OAAO,CAACQ;gBAC1C,MAAML,SAAS,MAAMI,QAAQ,OAAO,CAACD,KAAK,EAAE;gBAE5C,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;QACJ;QACA,kBAAkB;YACd,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMS,eAAeT,QAAQ,SAAS,CAAC,OAAO,CAACU;gBAC/C,MAAMP,SAAS,MAAMM,aAAa,OAAO,CAACH,KAAK,IAAI;gBAEnD,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMW,eAAeX,QAAQ,SAAS,CAAC,OAAO,CAACY;gBAC/C,MAAMT,SAAS,MAAMQ,aAAa,OAAO,CAACL,KAAK,EAAE,EAAEA,KAAK,IAAI;gBAE5D,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMa,eAAeb,QAAQ,SAAS,CAAC,OAAO,CAACc;gBAC/C,MAAMX,SAAS,MAAMU,aAAa,OAAO,CAACP,KAAK,EAAE;gBAEjD,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAAS;gBAExB,OAAO,IAAIC,cAAcF,OAAO,KAAK;YACzC;QACJ;IACJ;AACJ"}
1
+ {"version":3,"file":"graphql/security/apiKey.gql.js","sources":["../../../src/graphql/security/apiKey.gql.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { CreateApiKeyUseCase } from \"~/features/security/apiKeys/CreateApiKey/index.js\";\nimport { UpdateApiKeyUseCase } from \"~/features/security/apiKeys/UpdateApiKey/index.js\";\nimport { DeleteApiKeyUseCase } from \"~/features/security/apiKeys/DeleteApiKey/index.js\";\nimport { ListApiKeysUseCase } from \"~/features/security/apiKeys/ListApiKeys/index.js\";\nimport { GetApiKeyUseCase } from \"~/features/security/apiKeys/GetApiKey/index.js\";\n\nexport default new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type SecurityApiKey {\n id: ID\n name: String\n slug: String\n description: String\n # Security: null when the caller doesn't have full access.\n token: String\n permissions: [JSON]\n createdOn: DateTime\n createdBy: SecurityCreatedBy\n }\n\n input SecurityApiKeyInput {\n id: ID\n name: String!\n slug: String\n description: String\n token: String\n permissions: [JSON]!\n }\n\n type SecurityApiKeyResponse {\n data: SecurityApiKey\n error: SecurityError\n }\n\n type SecurityApiKeyListResponse {\n data: [SecurityApiKey!]\n error: SecurityError\n }\n\n extend type SecurityQuery {\n listApiKeys: SecurityApiKeyListResponse\n getApiKey(id: ID!): SecurityApiKeyResponse\n }\n\n extend type SecurityMutation {\n createApiKey(data: SecurityApiKeyInput!): SecurityApiKeyResponse\n updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse\n deleteApiKey(id: ID!): SecurityBooleanResponse\n }\n `,\n resolvers: {\n SecurityQuery: {\n async listApiKeys(_, __, context) {\n const list = context.container.resolve(ListApiKeysUseCase);\n const result = await list.execute();\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async getApiKey(_, args: any, context) {\n const getById = context.container.resolve(GetApiKeyUseCase);\n const result = await getById.execute(args.id);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n },\n SecurityMutation: {\n async createApiKey(_, args: any, context) {\n const createApiKey = context.container.resolve(CreateApiKeyUseCase);\n const result = await createApiKey.execute(args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async updateApiKey(_, args: any, context) {\n const updateApiKey = context.container.resolve(UpdateApiKeyUseCase);\n const result = await updateApiKey.execute(args.id, args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async deleteApiKey(_, args: any, context) {\n const deleteApiKey = context.container.resolve(DeleteApiKeyUseCase);\n const result = await deleteApiKey.execute(args.id);\n\n if (result.isOk()) {\n return new Response(true);\n }\n return new ErrorResponse(result.error);\n }\n }\n }\n});\n"],"names":["GraphQLSchemaPlugin","_","__","context","list","ListApiKeysUseCase","result","Response","ErrorResponse","args","getById","GetApiKeyUseCase","createApiKey","CreateApiKeyUseCase","updateApiKey","UpdateApiKeyUseCase","deleteApiKey","DeleteApiKeyUseCase"],"mappings":";;;;;;;AASA,mBAAe,IAAIA,oBAAoC;IACnD,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0CzB,CAAC;IACD,WAAW;QACP,eAAe;YACX,MAAM,aAAYC,CAAC,EAAEC,EAAE,EAAEC,OAAO;gBAC5B,MAAMC,OAAOD,QAAQ,SAAS,CAAC,OAAO,CAACE;gBACvC,MAAMC,SAAS,MAAMF,KAAK,OAAO;gBAEjC,IAAIE,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,WAAUL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACjC,MAAMO,UAAUP,QAAQ,SAAS,CAAC,OAAO,CAACQ;gBAC1C,MAAML,SAAS,MAAMI,QAAQ,OAAO,CAACD,KAAK,EAAE;gBAE5C,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;QACJ;QACA,kBAAkB;YACd,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMS,eAAeT,QAAQ,SAAS,CAAC,OAAO,CAACU;gBAC/C,MAAMP,SAAS,MAAMM,aAAa,OAAO,CAACH,KAAK,IAAI;gBAEnD,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMW,eAAeX,QAAQ,SAAS,CAAC,OAAO,CAACY;gBAC/C,MAAMT,SAAS,MAAMQ,aAAa,OAAO,CAACL,KAAK,EAAE,EAAEA,KAAK,IAAI;gBAE5D,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMa,eAAeb,QAAQ,SAAS,CAAC,OAAO,CAACc;gBAC/C,MAAMX,SAAS,MAAMU,aAAa,OAAO,CAACP,KAAK,EAAE;gBAEjD,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAAS;gBAExB,OAAO,IAAIC,cAAcF,OAAO,KAAK;YACzC;QACJ;IACJ;AACJ"}
@@ -41,7 +41,10 @@ class OidcJwtIdentityProviderImpl {
41
41
  const jwks = await this.jwksCache.getKeys(provider.issuer);
42
42
  const jwk = jwks.find((key)=>key.kid === header.kid);
43
43
  if (!jwk) return null;
44
- if (!verifiedPayload) verifiedPayload = await verifyJwtUsingJwk(token, jwk);
44
+ if (!verifiedPayload) verifiedPayload = await verifyJwtUsingJwk(token, jwk, {
45
+ issuer: provider.issuer,
46
+ audience: provider.clientId
47
+ });
45
48
  if (provider.verifyTokenClaims) await provider.verifyTokenClaims(verifiedPayload);
46
49
  return verifiedPayload;
47
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"idp/OidcJwtIdentityProvider.js","sources":["../../src/idp/OidcJwtIdentityProvider.ts"],"sourcesContent":["import { verifyJwtUsingJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport { JwkCache, JwtIdentityProvider, OidcIdentityProvider } from \"./abstractions.js\";\n\nclass OidcJwtIdentityProviderImpl implements JwtIdentityProvider.Interface {\n constructor(\n private oidcIdentityProviders: OidcIdentityProvider.Interface[],\n private jwksCache: JwkCache.Interface\n ) {}\n\n isApplicable(token: JwtIdentityProvider.JwtPayload): boolean {\n return this.oidcIdentityProviders.some(provider => provider.isApplicable(token));\n }\n\n async getIdentity(token: string, jwt: JwtIdentityProvider.Jwt): Promise<IdentityData | null> {\n const { header, payload } = jwt;\n\n const provider = this.getApplicableProvider(payload);\n\n if (!provider) {\n return null;\n }\n\n const verifiedPayload = await this.verifyToken(provider, token, header);\n\n if (!verifiedPayload) {\n return null;\n }\n\n // Call config.getIdentity to get IdentityData\n const providerIdentity = await provider.getIdentity(verifiedPayload);\n\n const identity: IdentityData = {\n ...providerIdentity,\n type: providerIdentity.type ?? \"admin\"\n };\n\n // Handle default values\n const context = identity.context ?? { canAccessTenant: true, defaultTenantId: \"root\" };\n if (context.canAccessTenant === undefined) {\n context.canAccessTenant = true;\n }\n if (context.defaultTenantId === undefined) {\n context.defaultTenantId = \"root\";\n }\n\n identity.context = context;\n\n return identity;\n }\n\n private getApplicableProvider(\n payload: JwtIdentityProvider.JwtPayload\n ): OidcIdentityProvider.Interface | undefined {\n return this.oidcIdentityProviders.find(provider => provider.isApplicable(payload));\n }\n\n private async verifyToken(\n provider: OidcIdentityProvider.Interface,\n token: string,\n header: JwtIdentityProvider.JwtHeader\n ) {\n // If the implementation specifies a custom verification function, use it.\n let verifiedPayload: JwtIdentityProvider.JwtPayload | undefined;\n if (typeof provider.verifyToken === \"function\") {\n // Use custom verification\n const result = await provider.verifyToken(token);\n if (result) {\n return result;\n }\n return null;\n }\n\n // Otherwise, continue with OIDC best practices, using JWKs.\n\n // Fetch JWKs from cache\n const jwks = await this.jwksCache.getKeys(provider.issuer);\n\n // Find matching JWK using header.kid\n const jwk = jwks.find(key => key.kid === header.kid);\n if (!jwk) {\n return null;\n }\n\n if (!verifiedPayload) {\n // Default JWK verification\n verifiedPayload = await verifyJwtUsingJwk(token, jwk);\n }\n\n // Call verifyTokenClaims if provided\n if (provider.verifyTokenClaims) {\n await provider.verifyTokenClaims(verifiedPayload);\n }\n\n return verifiedPayload;\n }\n}\n\nexport const OidcJwtIdentityProvider = JwtIdentityProvider.createImplementation({\n implementation: OidcJwtIdentityProviderImpl,\n dependencies: [[OidcIdentityProvider, { multiple: true }], JwkCache]\n});\n"],"names":["OidcJwtIdentityProviderImpl","oidcIdentityProviders","jwksCache","token","provider","jwt","header","payload","verifiedPayload","providerIdentity","identity","context","undefined","result","jwks","jwk","key","verifyJwtUsingJwk","OidcJwtIdentityProvider","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";;AAIA,MAAMA;IACF,YACYC,qBAAuD,EACvDC,SAA6B,CACvC;aAFUD,qBAAqB,GAArBA;aACAC,SAAS,GAATA;IACT;IAEH,aAAaC,KAAqC,EAAW;QACzD,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACC,CAAAA,WAAYA,SAAS,YAAY,CAACD;IAC7E;IAEA,MAAM,YAAYA,KAAa,EAAEE,GAA4B,EAAgC;QACzF,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAE5B,MAAMD,WAAW,IAAI,CAAC,qBAAqB,CAACG;QAE5C,IAAI,CAACH,UACD,OAAO;QAGX,MAAMI,kBAAkB,MAAM,IAAI,CAAC,WAAW,CAACJ,UAAUD,OAAOG;QAEhE,IAAI,CAACE,iBACD,OAAO;QAIX,MAAMC,mBAAmB,MAAML,SAAS,WAAW,CAACI;QAEpD,MAAME,WAAyB;YAC3B,GAAGD,gBAAgB;YACnB,MAAMA,iBAAiB,IAAI,IAAI;QACnC;QAGA,MAAME,UAAUD,SAAS,OAAO,IAAI;YAAE,iBAAiB;YAAM,iBAAiB;QAAO;QACrF,IAAIC,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAE9B,IAAIA,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAG9BD,SAAS,OAAO,GAAGC;QAEnB,OAAOD;IACX;IAEQ,sBACJH,OAAuC,EACG;QAC1C,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACH,CAAAA,WAAYA,SAAS,YAAY,CAACG;IAC7E;IAEA,MAAc,YACVH,QAAwC,EACxCD,KAAa,EACbG,MAAqC,EACvC;QAEE,IAAIE;QACJ,IAAI,AAAgC,cAAhC,OAAOJ,SAAS,WAAW,EAAiB;YAE5C,MAAMS,SAAS,MAAMT,SAAS,WAAW,CAACD;YAC1C,IAAIU,QACA,OAAOA;YAEX,OAAO;QACX;QAKA,MAAMC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACV,SAAS,MAAM;QAGzD,MAAMW,MAAMD,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,GAAG,KAAKV,OAAO,GAAG;QACnD,IAAI,CAACS,KACD,OAAO;QAGX,IAAI,CAACP,iBAEDA,kBAAkB,MAAMS,kBAAkBd,OAAOY;QAIrD,IAAIX,SAAS,iBAAiB,EAC1B,MAAMA,SAAS,iBAAiB,CAACI;QAGrC,OAAOA;IACX;AACJ;AAEO,MAAMU,0BAA0BC,oBAAoB,oBAAoB,CAAC;IAC5E,gBAAgBnB;IAChB,cAAc;QAAC;YAACoB;YAAsB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAS;AACxE"}
1
+ {"version":3,"file":"idp/OidcJwtIdentityProvider.js","sources":["../../src/idp/OidcJwtIdentityProvider.ts"],"sourcesContent":["import { verifyJwtUsingJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport { JwkCache, JwtIdentityProvider, OidcIdentityProvider } from \"./abstractions.js\";\n\nclass OidcJwtIdentityProviderImpl implements JwtIdentityProvider.Interface {\n constructor(\n private oidcIdentityProviders: OidcIdentityProvider.Interface[],\n private jwksCache: JwkCache.Interface\n ) {}\n\n isApplicable(token: JwtIdentityProvider.JwtPayload): boolean {\n return this.oidcIdentityProviders.some(provider => provider.isApplicable(token));\n }\n\n async getIdentity(token: string, jwt: JwtIdentityProvider.Jwt): Promise<IdentityData | null> {\n const { header, payload } = jwt;\n\n const provider = this.getApplicableProvider(payload);\n\n if (!provider) {\n return null;\n }\n\n const verifiedPayload = await this.verifyToken(provider, token, header);\n\n if (!verifiedPayload) {\n return null;\n }\n\n // Call config.getIdentity to get IdentityData\n const providerIdentity = await provider.getIdentity(verifiedPayload);\n\n const identity: IdentityData = {\n ...providerIdentity,\n type: providerIdentity.type ?? \"admin\"\n };\n\n // Handle default values\n const context = identity.context ?? { canAccessTenant: true, defaultTenantId: \"root\" };\n if (context.canAccessTenant === undefined) {\n context.canAccessTenant = true;\n }\n if (context.defaultTenantId === undefined) {\n context.defaultTenantId = \"root\";\n }\n\n identity.context = context;\n\n return identity;\n }\n\n private getApplicableProvider(\n payload: JwtIdentityProvider.JwtPayload\n ): OidcIdentityProvider.Interface | undefined {\n return this.oidcIdentityProviders.find(provider => provider.isApplicable(payload));\n }\n\n private async verifyToken(\n provider: OidcIdentityProvider.Interface,\n token: string,\n header: JwtIdentityProvider.JwtHeader\n ) {\n // If the implementation specifies a custom verification function, use it.\n let verifiedPayload: JwtIdentityProvider.JwtPayload | undefined;\n if (typeof provider.verifyToken === \"function\") {\n // Use custom verification\n const result = await provider.verifyToken(token);\n if (result) {\n return result;\n }\n return null;\n }\n\n // Otherwise, continue with OIDC best practices, using JWKs.\n\n // Fetch JWKs from cache\n const jwks = await this.jwksCache.getKeys(provider.issuer);\n\n // Find matching JWK using header.kid\n const jwk = jwks.find(key => key.kid === header.kid);\n if (!jwk) {\n return null;\n }\n\n if (!verifiedPayload) {\n // Default JWK verification\n // Security: audience/issuer are enforced only when the provider has them configured.\n verifiedPayload = await verifyJwtUsingJwk(token, jwk, {\n issuer: provider.issuer,\n audience: provider.clientId\n });\n }\n\n // Call verifyTokenClaims if provided\n if (provider.verifyTokenClaims) {\n await provider.verifyTokenClaims(verifiedPayload);\n }\n\n return verifiedPayload;\n }\n}\n\nexport const OidcJwtIdentityProvider = JwtIdentityProvider.createImplementation({\n implementation: OidcJwtIdentityProviderImpl,\n dependencies: [[OidcIdentityProvider, { multiple: true }], JwkCache]\n});\n"],"names":["OidcJwtIdentityProviderImpl","oidcIdentityProviders","jwksCache","token","provider","jwt","header","payload","verifiedPayload","providerIdentity","identity","context","undefined","result","jwks","jwk","key","verifyJwtUsingJwk","OidcJwtIdentityProvider","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";;AAIA,MAAMA;IACF,YACYC,qBAAuD,EACvDC,SAA6B,CACvC;aAFUD,qBAAqB,GAArBA;aACAC,SAAS,GAATA;IACT;IAEH,aAAaC,KAAqC,EAAW;QACzD,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACC,CAAAA,WAAYA,SAAS,YAAY,CAACD;IAC7E;IAEA,MAAM,YAAYA,KAAa,EAAEE,GAA4B,EAAgC;QACzF,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAE5B,MAAMD,WAAW,IAAI,CAAC,qBAAqB,CAACG;QAE5C,IAAI,CAACH,UACD,OAAO;QAGX,MAAMI,kBAAkB,MAAM,IAAI,CAAC,WAAW,CAACJ,UAAUD,OAAOG;QAEhE,IAAI,CAACE,iBACD,OAAO;QAIX,MAAMC,mBAAmB,MAAML,SAAS,WAAW,CAACI;QAEpD,MAAME,WAAyB;YAC3B,GAAGD,gBAAgB;YACnB,MAAMA,iBAAiB,IAAI,IAAI;QACnC;QAGA,MAAME,UAAUD,SAAS,OAAO,IAAI;YAAE,iBAAiB;YAAM,iBAAiB;QAAO;QACrF,IAAIC,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAE9B,IAAIA,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAG9BD,SAAS,OAAO,GAAGC;QAEnB,OAAOD;IACX;IAEQ,sBACJH,OAAuC,EACG;QAC1C,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACH,CAAAA,WAAYA,SAAS,YAAY,CAACG;IAC7E;IAEA,MAAc,YACVH,QAAwC,EACxCD,KAAa,EACbG,MAAqC,EACvC;QAEE,IAAIE;QACJ,IAAI,AAAgC,cAAhC,OAAOJ,SAAS,WAAW,EAAiB;YAE5C,MAAMS,SAAS,MAAMT,SAAS,WAAW,CAACD;YAC1C,IAAIU,QACA,OAAOA;YAEX,OAAO;QACX;QAKA,MAAMC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACV,SAAS,MAAM;QAGzD,MAAMW,MAAMD,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,GAAG,KAAKV,OAAO,GAAG;QACnD,IAAI,CAACS,KACD,OAAO;QAGX,IAAI,CAACP,iBAGDA,kBAAkB,MAAMS,kBAAkBd,OAAOY,KAAK;YAClD,QAAQX,SAAS,MAAM;YACvB,UAAUA,SAAS,QAAQ;QAC/B;QAIJ,IAAIA,SAAS,iBAAiB,EAC1B,MAAMA,SAAS,iBAAiB,CAACI;QAGrC,OAAOA;IACX;AACJ;AAEO,MAAMU,0BAA0BC,oBAAoB,oBAAoB,CAAC;IAC5E,gBAAgBnB;IAChB,cAAc;QAAC;YAACoB;YAAsB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAS;AACxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-core",
3
- "version": "6.5.2-beta.1",
3
+ "version": "6.5.2-beta.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,39 +14,39 @@
14
14
  "./*": "./*"
15
15
  },
16
16
  "dependencies": {
17
- "@ai-sdk/anthropic": "4.0.94",
18
- "@ai-sdk/google": "4.0.109",
19
- "@ai-sdk/openai": "4.0.106",
17
+ "@ai-sdk/anthropic": "4.0.99",
18
+ "@ai-sdk/google": "4.0.114",
19
+ "@ai-sdk/openai": "4.0.111",
20
20
  "@openrouter/ai-sdk-provider": "3.1.0",
21
- "@webiny/api": "6.5.2-beta.1",
21
+ "@webiny/api": "6.5.2-beta.2",
22
22
  "@webiny/di": "1.1.0",
23
- "@webiny/error": "6.5.2-beta.1",
24
- "@webiny/feature": "6.5.2-beta.1",
25
- "@webiny/feature-flags": "6.5.2-beta.1",
26
- "@webiny/handler": "6.5.2-beta.1",
27
- "@webiny/handler-db": "6.5.2-beta.1",
28
- "@webiny/handler-graphql": "6.5.2-beta.1",
29
- "@webiny/plugins": "6.5.2-beta.1",
30
- "@webiny/utils": "6.5.2-beta.1",
31
- "@webiny/wcp": "6.5.2-beta.1",
32
- "ai": "7.0.159",
23
+ "@webiny/error": "6.5.2-beta.2",
24
+ "@webiny/feature": "6.5.2-beta.2",
25
+ "@webiny/feature-flags": "6.5.2-beta.2",
26
+ "@webiny/handler": "6.5.2-beta.2",
27
+ "@webiny/handler-db": "6.5.2-beta.2",
28
+ "@webiny/handler-graphql": "6.5.2-beta.2",
29
+ "@webiny/plugins": "6.5.2-beta.2",
30
+ "@webiny/utils": "6.5.2-beta.2",
31
+ "@webiny/wcp": "6.5.2-beta.2",
32
+ "ai": "7.0.166",
33
33
  "dataloader": "2.2.3",
34
- "jose": "6.2.15",
34
+ "jose": "6.2.16",
35
35
  "jsonwebtoken": "9.0.3",
36
36
  "lodash": "4.18.1",
37
- "minimatch": "11.0.4",
37
+ "minimatch": "11.0.5",
38
38
  "pino": "10.4.0",
39
39
  "pino-lambda": "4.4.1",
40
40
  "zod": "4.6.7"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/jsonwebtoken": "9.0.10",
44
- "@webiny/build-tools": "6.5.2-beta.1",
45
- "@webiny/handler-aws": "6.5.2-beta.1",
46
- "@webiny/project-utils": "6.5.2-beta.1",
47
- "rimraf": "6.1.3",
44
+ "@webiny/build-tools": "6.5.2-beta.2",
45
+ "@webiny/handler-aws": "6.5.2-beta.2",
46
+ "@webiny/project-utils": "6.5.2-beta.2",
47
+ "rimraf": "6.1.4",
48
48
  "typescript": "7.0.2",
49
- "vitest": "5.0.5"
49
+ "vitest": "5.1.0"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"