@webiny/api-core 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.5387e5f7c8

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 (234) hide show
  1. package/ApiCoreFeature.js +8 -0
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/tasks.d.ts +1 -0
  4. package/exports/api/tasks.js +1 -1
  5. package/exports/api.d.ts +1 -1
  6. package/exports/api.js +1 -1
  7. package/features/ai/Ai.d.ts +3 -1
  8. package/features/ai/Ai.js +36 -28
  9. package/features/ai/Ai.js.map +1 -1
  10. package/features/ai/AiModelRegistry.d.ts +14 -0
  11. package/features/ai/AiModelRegistry.js +39 -0
  12. package/features/ai/AiModelRegistry.js.map +1 -0
  13. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  14. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  15. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  16. package/features/ai/AiSdkTools.d.ts +4 -3
  17. package/features/ai/AiSdkTools.js +11 -9
  18. package/features/ai/AiSdkTools.js.map +1 -1
  19. package/features/ai/AnthropicSdkFactory.js +12 -4
  20. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  21. package/features/ai/DEVELOPERS.md +183 -0
  22. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  23. package/features/ai/GoogleSdkFactory.js +65 -0
  24. package/features/ai/GoogleSdkFactory.js.map +1 -0
  25. package/features/ai/OpenAiSdkFactory.js +51 -11
  26. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  27. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  28. package/features/ai/OpenRouterSdkFactory.js +112 -0
  29. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  30. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  31. package/features/ai/RemoteAiModelCatalog.js +74 -0
  32. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  33. package/features/ai/abstractions.d.ts +102 -7
  34. package/features/ai/abstractions.js +6 -2
  35. package/features/ai/abstractions.js.map +1 -1
  36. package/features/ai/feature.js +10 -0
  37. package/features/ai/feature.js.map +1 -1
  38. package/features/ai/index.d.ts +2 -4
  39. package/features/ai/index.js +1 -1
  40. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  41. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  42. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  43. package/features/dateFormatter/abstractions.d.ts +13 -0
  44. package/features/dateFormatter/abstractions.js +5 -0
  45. package/features/dateFormatter/abstractions.js.map +1 -0
  46. package/features/dateFormatter/feature.d.ts +4 -0
  47. package/features/dateFormatter/feature.js +11 -0
  48. package/features/dateFormatter/feature.js.map +1 -0
  49. package/features/dateFormatter/index.d.ts +3 -0
  50. package/features/dateFormatter/index.js +2 -0
  51. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  52. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  53. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  54. package/features/encryption/EncryptionService.d.ts +2 -1
  55. package/features/encryption/EncryptionService.js +11 -4
  56. package/features/encryption/EncryptionService.js.map +1 -1
  57. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  58. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  59. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  60. package/features/encryption/abstractions.d.ts +11 -0
  61. package/features/encryption/abstractions.js +2 -1
  62. package/features/encryption/abstractions.js.map +1 -1
  63. package/features/encryption/index.d.ts +1 -0
  64. package/features/encryption/index.js +1 -0
  65. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  66. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +61 -0
  67. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  68. package/features/httpClient/HttpClient.d.ts +7 -0
  69. package/features/httpClient/HttpClient.js +72 -0
  70. package/features/httpClient/HttpClient.js.map +1 -0
  71. package/features/httpClient/HttpRequestError.d.ts +10 -0
  72. package/features/httpClient/HttpRequestError.js +13 -0
  73. package/features/httpClient/HttpRequestError.js.map +1 -0
  74. package/features/httpClient/HttpStatusError.d.ts +12 -0
  75. package/features/httpClient/HttpStatusError.js +12 -0
  76. package/features/httpClient/HttpStatusError.js.map +1 -0
  77. package/features/httpClient/abstractions.d.ts +32 -0
  78. package/features/httpClient/abstractions.js +5 -0
  79. package/features/httpClient/abstractions.js.map +1 -0
  80. package/features/httpClient/feature.d.ts +4 -0
  81. package/features/httpClient/feature.js +11 -0
  82. package/features/httpClient/feature.js.map +1 -0
  83. package/features/httpClient/index.d.ts +3 -0
  84. package/features/httpClient/index.js +3 -0
  85. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  86. package/features/requestContext/RawAssumePermissions.js +19 -0
  87. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  88. package/features/requestContext/abstractions.d.ts +22 -0
  89. package/features/requestContext/abstractions.js +2 -1
  90. package/features/requestContext/abstractions.js.map +1 -1
  91. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  92. package/features/requestContext/extractAssumePermissions.js +32 -0
  93. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  94. package/features/requestContext/feature.d.ts +2 -1
  95. package/features/requestContext/feature.js +2 -0
  96. package/features/requestContext/feature.js.map +1 -1
  97. package/features/requestContext/index.d.ts +3 -1
  98. package/features/requestContext/index.js +2 -1
  99. package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
  100. package/features/security/IdentityContext/IdentityContext.js +6 -6
  101. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  102. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  103. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  104. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  105. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  106. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  107. package/features/security/apiKeys/shared/schemas.js +2 -2
  108. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  109. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  110. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  111. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  112. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  113. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  114. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  115. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  116. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  117. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  118. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  119. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  120. package/features/security/roles/CreateRole/schema.js +1 -1
  121. package/features/security/roles/CreateRole/schema.js.map +1 -1
  122. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  123. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  124. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  125. package/features/security/roles/UpdateRole/schema.js +1 -1
  126. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  127. package/features/security/shared/description.d.ts +4 -0
  128. package/features/security/shared/description.js +7 -0
  129. package/features/security/shared/description.js.map +1 -0
  130. package/features/security/shared/index.d.ts +1 -0
  131. package/features/security/shared/index.js +1 -0
  132. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  133. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  134. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  135. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  136. package/features/security/teams/CreateTeam/schema.js +1 -1
  137. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  138. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  139. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  140. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  141. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  142. package/features/security/teams/UpdateTeam/schema.js +1 -1
  143. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  144. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  145. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  146. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  147. package/features/slugify/DefaultSlugify.d.ts +8 -0
  148. package/features/slugify/DefaultSlugify.js +20 -0
  149. package/features/slugify/DefaultSlugify.js.map +1 -0
  150. package/features/slugify/abstractions.d.ts +12 -0
  151. package/features/slugify/abstractions.js +5 -0
  152. package/features/slugify/abstractions.js.map +1 -0
  153. package/features/slugify/feature.d.ts +4 -0
  154. package/features/slugify/feature.js +11 -0
  155. package/features/slugify/feature.js.map +1 -0
  156. package/features/slugify/index.d.ts +3 -0
  157. package/features/slugify/index.js +2 -0
  158. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  159. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  160. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  161. package/features/stringFormatter/abstractions.d.ts +11 -0
  162. package/features/stringFormatter/abstractions.js +5 -0
  163. package/features/stringFormatter/abstractions.js.map +1 -0
  164. package/features/stringFormatter/feature.d.ts +4 -0
  165. package/features/stringFormatter/feature.js +13 -0
  166. package/features/stringFormatter/feature.js.map +1 -0
  167. package/features/stringFormatter/index.d.ts +3 -0
  168. package/features/stringFormatter/index.js +2 -0
  169. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  170. package/features/task/TaskDefinition/abstractions.js +2 -1
  171. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  172. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  173. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  174. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  175. package/features/wcp/WcpContext/WcpContext.d.ts +6 -0
  176. package/features/wcp/WcpContext/WcpContext.js +18 -0
  177. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  178. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +9 -69
  179. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +63 -35
  180. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  181. package/features/wcp/WcpFeature.js +2 -0
  182. package/features/wcp/WcpFeature.js.map +1 -1
  183. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  184. package/features/wcp/WcpLicenseLoader.js +58 -0
  185. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  186. package/features/wcp/WcpLicenseProvider.d.ts +6 -14
  187. package/features/wcp/WcpLicenseProvider.js +3 -7
  188. package/features/wcp/WcpLicenseProvider.js.map +1 -1
  189. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  190. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  191. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  192. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  193. package/graphql/ApiCoreSchemaFactory.js +7 -1
  194. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  195. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  196. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  197. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  198. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  199. package/graphql/security/SecuritySchemaFactory.js +4 -0
  200. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  201. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  202. package/graphql/system/SystemSchemaFactory.js +4 -0
  203. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  204. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  205. package/graphql/users/UsersSchemaFactory.js +4 -0
  206. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  207. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  208. package/graphql/wcp/WcpSchemaFactory.js +5 -0
  209. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  210. package/idp/JwksCache.d.ts +14 -3
  211. package/idp/JwksCache.js +97 -17
  212. package/idp/JwksCache.js.map +1 -1
  213. package/idp/JwksStoreFeature.d.ts +8 -0
  214. package/idp/JwksStoreFeature.js +11 -0
  215. package/idp/JwksStoreFeature.js.map +1 -0
  216. package/idp/MemoryJwksStore.d.ts +14 -0
  217. package/idp/MemoryJwksStore.js +21 -0
  218. package/idp/MemoryJwksStore.js.map +1 -0
  219. package/idp/OidcJwtIdentityProvider.js +5 -1
  220. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  221. package/idp/abstractions.d.ts +24 -0
  222. package/idp/abstractions.js +2 -1
  223. package/idp/abstractions.js.map +1 -1
  224. package/idp/feature.js +1 -2
  225. package/idp/feature.js.map +1 -1
  226. package/idp/index.d.ts +1 -0
  227. package/idp/index.js +1 -0
  228. package/package.json +20 -18
  229. package/testing/environment.d.ts +14 -0
  230. package/testing/environment.js +18 -0
  231. package/testing/environment.js.map +1 -0
  232. package/features/wcp/loadWcpLicense.d.ts +0 -2
  233. package/features/wcp/loadWcpLicense.js +0 -51
  234. package/features/wcp/loadWcpLicense.js.map +0 -1
@@ -56,6 +56,12 @@ export declare namespace OidcIdentityProvider {
56
56
  }
57
57
  interface IJwkCache {
58
58
  getKeys(issuer: string): Promise<IJwk[]>;
59
+ /**
60
+ * Fetches the issuer's keys again, for a token signed with a key the cached set doesn't have
61
+ * (the issuer rotated its keys). Returns null when a fetch started less than a minute ago, or
62
+ * when the fetch fails, so tokens with made-up key ids can't make every request call the issuer.
63
+ */
64
+ refreshKeys(issuer: string): Promise<IJwk[] | null>;
59
65
  }
60
66
  /** Cache for JSON Web Keys used in JWT verification. */
61
67
  export declare const JwkCache: import("@webiny/di").Abstraction<IJwkCache>;
@@ -63,4 +69,22 @@ export declare namespace JwkCache {
63
69
  type Interface = IJwkCache;
64
70
  type Jwk = IJwk;
65
71
  }
72
+ export interface IJwksIssuerState {
73
+ keys?: IJwk[];
74
+ fetchedAt?: number;
75
+ lastAttemptAt?: number;
76
+ pending?: Promise<IJwk[]>;
77
+ }
78
+ export interface IJwksStore {
79
+ get(issuer: string): IJwksIssuerState;
80
+ }
81
+ /**
82
+ * Keeps each issuer's JSON Web Keys across requests. Register it in the ROOT container: JwkCache is
83
+ * registered per request, so keys kept there would be fetched again on every request.
84
+ */
85
+ export declare const JwksStore: import("@webiny/di").Abstraction<IJwksStore>;
86
+ export declare namespace JwksStore {
87
+ type Interface = IJwksStore;
88
+ type IssuerState = IJwksIssuerState;
89
+ }
66
90
  export {};
@@ -3,6 +3,7 @@ const IdentityProvider = createAbstraction("IdentityProvider");
3
3
  const JwtIdentityProvider = createAbstraction("JwtIdentityProvider");
4
4
  const OidcIdentityProvider = createAbstraction("OidcIdentityProvider");
5
5
  const JwkCache = createAbstraction("JwkCache");
6
- export { IdentityProvider, JwkCache, JwtIdentityProvider, OidcIdentityProvider };
6
+ const JwksStore = createAbstraction("JwksStore");
7
+ export { IdentityProvider, JwkCache, JwksStore, JwtIdentityProvider, OidcIdentityProvider };
7
8
 
8
9
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"idp/abstractions.js","sources":["../../src/idp/abstractions.ts"],"sourcesContent":["import type { JwtPayload as IJwtPayload, JwtHeader as IJwtHeader } from \"jsonwebtoken\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IdentityData as IIdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport type { Jwk as IJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\n\nexport type IJwt = {\n header: IJwtHeader;\n payload: IJwtPayload;\n};\n\nexport type OptionalExternal<T> = Omit<T, \"external\"> & { external?: boolean };\n\nexport type IProviderIdentityData = Omit<IIdentityData, \"type\" | \"profile\"> & {\n /**\n * Defaults to `admin` it omitted.\n */\n type?: string;\n profile?: OptionalExternal<NonNullable<IIdentityData[\"profile\"]>>;\n};\n\n// Generic Idp Provider\nexport interface IIdentityProvider {\n isApplicable(token: string): boolean;\n getIdentity(token: string): Promise<IProviderIdentityData | null>;\n}\n\n/** Generic identity provider for token-based authentication. */\nexport const IdentityProvider = createAbstraction<IIdentityProvider>(\"IdentityProvider\");\n\nexport namespace IdentityProvider {\n export type Interface = IIdentityProvider;\n export type IdentityData = IProviderIdentityData;\n export type JwtPayload = IJwtPayload;\n}\n\nexport interface IJwtIdentityProvider {\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(token: string, jwt: IJwt): Promise<IProviderIdentityData | null>;\n}\n\n/** JWT-specific identity provider for token validation. */\nexport const JwtIdentityProvider = createAbstraction<IJwtIdentityProvider>(\"JwtIdentityProvider\");\n\nexport namespace JwtIdentityProvider {\n export type Interface = IJwtIdentityProvider;\n export type Jwt = IJwt;\n export type JwtPayload = IJwtPayload;\n export type JwtHeader = IJwtHeader;\n export type IdentityData = IProviderIdentityData;\n}\n\n// OIDC Provider\nexport interface IOidcIdentityProvider {\n issuer: string;\n clientId: string;\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(jwt: IJwtPayload): Promise<IProviderIdentityData>;\n verifyToken?(token: string): Promise<IJwtPayload | undefined>;\n verifyTokenClaims?(token: IJwtPayload): Promise<void>;\n}\n\n/** OIDC-compliant identity provider with issuer validation. */\nexport const OidcIdentityProvider =\n createAbstraction<IOidcIdentityProvider>(\"OidcIdentityProvider\");\n\nexport namespace OidcIdentityProvider {\n export type Interface = IOidcIdentityProvider;\n export type JwtPayload = IJwtPayload;\n export type IdentityData = IProviderIdentityData;\n}\n\ninterface IJwkCache {\n getKeys(issuer: string): Promise<IJwk[]>;\n}\n\n/** Cache for JSON Web Keys used in JWT verification. */\nexport const JwkCache = createAbstraction<IJwkCache>(\"JwkCache\");\nexport namespace JwkCache {\n export type Interface = IJwkCache;\n export type Jwk = IJwk;\n}\n"],"names":["IdentityProvider","createAbstraction","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";AA2BO,MAAMA,mBAAmBC,kBAAqC;AAc9D,MAAMC,sBAAsBD,kBAAwC;AAqBpE,MAAME,uBACTF,kBAAyC;AAatC,MAAMG,WAAWH,kBAA6B"}
1
+ {"version":3,"file":"idp/abstractions.js","sources":["../../src/idp/abstractions.ts"],"sourcesContent":["import type { JwtPayload as IJwtPayload, JwtHeader as IJwtHeader } from \"jsonwebtoken\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IdentityData as IIdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport type { Jwk as IJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\n\nexport type IJwt = {\n header: IJwtHeader;\n payload: IJwtPayload;\n};\n\nexport type OptionalExternal<T> = Omit<T, \"external\"> & { external?: boolean };\n\nexport type IProviderIdentityData = Omit<IIdentityData, \"type\" | \"profile\"> & {\n /**\n * Defaults to `admin` it omitted.\n */\n type?: string;\n profile?: OptionalExternal<NonNullable<IIdentityData[\"profile\"]>>;\n};\n\n// Generic Idp Provider\nexport interface IIdentityProvider {\n isApplicable(token: string): boolean;\n getIdentity(token: string): Promise<IProviderIdentityData | null>;\n}\n\n/** Generic identity provider for token-based authentication. */\nexport const IdentityProvider = createAbstraction<IIdentityProvider>(\"IdentityProvider\");\n\nexport namespace IdentityProvider {\n export type Interface = IIdentityProvider;\n export type IdentityData = IProviderIdentityData;\n export type JwtPayload = IJwtPayload;\n}\n\nexport interface IJwtIdentityProvider {\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(token: string, jwt: IJwt): Promise<IProviderIdentityData | null>;\n}\n\n/** JWT-specific identity provider for token validation. */\nexport const JwtIdentityProvider = createAbstraction<IJwtIdentityProvider>(\"JwtIdentityProvider\");\n\nexport namespace JwtIdentityProvider {\n export type Interface = IJwtIdentityProvider;\n export type Jwt = IJwt;\n export type JwtPayload = IJwtPayload;\n export type JwtHeader = IJwtHeader;\n export type IdentityData = IProviderIdentityData;\n}\n\n// OIDC Provider\nexport interface IOidcIdentityProvider {\n issuer: string;\n clientId: string;\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(jwt: IJwtPayload): Promise<IProviderIdentityData>;\n verifyToken?(token: string): Promise<IJwtPayload | undefined>;\n verifyTokenClaims?(token: IJwtPayload): Promise<void>;\n}\n\n/** OIDC-compliant identity provider with issuer validation. */\nexport const OidcIdentityProvider =\n createAbstraction<IOidcIdentityProvider>(\"OidcIdentityProvider\");\n\nexport namespace OidcIdentityProvider {\n export type Interface = IOidcIdentityProvider;\n export type JwtPayload = IJwtPayload;\n export type IdentityData = IProviderIdentityData;\n}\n\ninterface IJwkCache {\n getKeys(issuer: string): Promise<IJwk[]>;\n /**\n * Fetches the issuer's keys again, for a token signed with a key the cached set doesn't have\n * (the issuer rotated its keys). Returns null when a fetch started less than a minute ago, or\n * when the fetch fails, so tokens with made-up key ids can't make every request call the issuer.\n */\n refreshKeys(issuer: string): Promise<IJwk[] | null>;\n}\n\n/** Cache for JSON Web Keys used in JWT verification. */\nexport const JwkCache = createAbstraction<IJwkCache>(\"JwkCache\");\nexport namespace JwkCache {\n export type Interface = IJwkCache;\n export type Jwk = IJwk;\n}\n\nexport interface IJwksIssuerState {\n keys?: IJwk[];\n // When the keys were last fetched successfully.\n fetchedAt?: number;\n // When a fetch last started, successful or not. Limits how often an unknown key id can refetch.\n lastAttemptAt?: number;\n // The fetch in progress, shared by every request that needs it.\n pending?: Promise<IJwk[]>;\n}\n\nexport interface IJwksStore {\n // Returns the issuer's state, creating it on first use. Callers update it in place.\n get(issuer: string): IJwksIssuerState;\n}\n\n/**\n * Keeps each issuer's JSON Web Keys across requests. Register it in the ROOT container: JwkCache is\n * registered per request, so keys kept there would be fetched again on every request.\n */\nexport const JwksStore = createAbstraction<IJwksStore>(\"JwksStore\");\nexport namespace JwksStore {\n export type Interface = IJwksStore;\n export type IssuerState = IJwksIssuerState;\n}\n"],"names":["IdentityProvider","createAbstraction","JwtIdentityProvider","OidcIdentityProvider","JwkCache","JwksStore"],"mappings":";AA2BO,MAAMA,mBAAmBC,kBAAqC;AAc9D,MAAMC,sBAAsBD,kBAAwC;AAqBpE,MAAME,uBACTF,kBAAyC;AAmBtC,MAAMG,WAAWH,kBAA6B;AAyB9C,MAAMI,YAAYJ,kBAA8B"}
package/idp/feature.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { JwtAuthenticator } from "./JwtAuthenticator.js";
3
- import { JwkCache } from "./abstractions.js";
4
3
  import { JwksCache } from "./JwksCache.js";
5
4
  import { OidcJwtIdentityProvider } from "./OidcJwtIdentityProvider.js";
6
5
  const IdpAuthenticatorFeature = createFeature({
@@ -8,7 +7,7 @@ const IdpAuthenticatorFeature = createFeature({
8
7
  register (container) {
9
8
  container.register(JwtAuthenticator);
10
9
  container.register(OidcJwtIdentityProvider);
11
- container.registerInstance(JwkCache, new JwksCache());
10
+ container.register(JwksCache).inSingletonScope();
12
11
  }
13
12
  });
14
13
  export { IdpAuthenticatorFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"idp/feature.js","sources":["../../src/idp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { JwtAuthenticator } from \"./JwtAuthenticator.js\";\nimport { JwkCache } from \"./abstractions.js\";\nimport { JwksCache } from \"./JwksCache.js\";\nimport { OidcJwtIdentityProvider } from \"~/idp/OidcJwtIdentityProvider.js\";\n\nexport const IdpAuthenticatorFeature = createFeature({\n name: \"IdpAuthenticator\",\n register(container) {\n container.register(JwtAuthenticator);\n container.register(OidcJwtIdentityProvider);\n container.registerInstance(JwkCache, new JwksCache());\n }\n});\n"],"names":["IdpAuthenticatorFeature","createFeature","container","JwtAuthenticator","OidcJwtIdentityProvider","JwkCache","JwksCache"],"mappings":";;;;;AAMO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,gBAAgB,CAACG,UAAU,IAAIC;IAC7C;AACJ"}
1
+ {"version":3,"file":"idp/feature.js","sources":["../../src/idp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { JwtAuthenticator } from \"./JwtAuthenticator.js\";\nimport { JwksCache } from \"./JwksCache.js\";\nimport { OidcJwtIdentityProvider } from \"~/idp/OidcJwtIdentityProvider.js\";\n\nexport const IdpAuthenticatorFeature = createFeature({\n name: \"IdpAuthenticator\",\n register(container) {\n container.register(JwtAuthenticator);\n container.register(OidcJwtIdentityProvider);\n /*\n * Per request. The keys outlive it through JwksStore, which belongs in the root container\n * (JwksStoreFeature).\n */\n container.register(JwksCache).inSingletonScope();\n }\n});\n"],"names":["IdpAuthenticatorFeature","createFeature","container","JwtAuthenticator","OidcJwtIdentityProvider","JwksCache"],"mappings":";;;;AAKO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QAKnBF,UAAU,QAAQ,CAACG,WAAW,gBAAgB;IAClD;AACJ"}
package/idp/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { IdentityProvider, OidcIdentityProvider, JwtIdentityProvider } from "./abstractions.js";
2
2
  export type { IdentityData } from "./types.js";
3
+ export { JwksStoreFeature } from "./JwksStoreFeature.js";
package/idp/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { IdentityProvider, JwtIdentityProvider, OidcIdentityProvider } from "./abstractions.js";
2
+ export { JwksStoreFeature } from "./JwksStoreFeature.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-core",
3
- "version": "0.0.0-unstable.0d717d18dd",
3
+ "version": "0.0.0-unstable.5387e5f7c8",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,36 +14,38 @@
14
14
  "./*": "./*"
15
15
  },
16
16
  "dependencies": {
17
- "@ai-sdk/anthropic": "4.0.27",
18
- "@ai-sdk/openai": "4.0.27",
19
- "@webiny/api": "0.0.0-unstable.0d717d18dd",
20
- "@webiny/api-graphql": "0.0.0-unstable.0d717d18dd",
21
- "@webiny/di": "1.0.2",
22
- "@webiny/error": "0.0.0-unstable.0d717d18dd",
23
- "@webiny/feature": "0.0.0-unstable.0d717d18dd",
24
- "@webiny/feature-flags": "0.0.0-unstable.0d717d18dd",
25
- "@webiny/handler": "0.0.0-unstable.0d717d18dd",
26
- "@webiny/utils": "0.0.0-unstable.0d717d18dd",
27
- "@webiny/wcp": "0.0.0-unstable.0d717d18dd",
28
- "ai": "7.0.47",
17
+ "@ai-sdk/anthropic": "4.0.40",
18
+ "@ai-sdk/google": "4.0.49",
19
+ "@ai-sdk/openai": "4.0.45",
20
+ "@openrouter/ai-sdk-provider": "3.1.0",
21
+ "@webiny/api": "0.0.0-unstable.5387e5f7c8",
22
+ "@webiny/api-graphql": "0.0.0-unstable.5387e5f7c8",
23
+ "@webiny/di": "2.0.0",
24
+ "@webiny/error": "0.0.0-unstable.5387e5f7c8",
25
+ "@webiny/event-handler-core": "0.0.0-unstable.5387e5f7c8",
26
+ "@webiny/feature": "0.0.0-unstable.5387e5f7c8",
27
+ "@webiny/feature-flags": "0.0.0-unstable.5387e5f7c8",
28
+ "@webiny/handler": "0.0.0-unstable.5387e5f7c8",
29
+ "@webiny/utils": "0.0.0-unstable.5387e5f7c8",
30
+ "@webiny/wcp": "0.0.0-unstable.5387e5f7c8",
31
+ "ai": "7.0.73",
29
32
  "dataloader": "2.2.3",
30
33
  "graphql": "16.14.2",
31
- "jose": "6.2.6",
34
+ "jose": "6.2.9",
32
35
  "jsonwebtoken": "9.0.3",
33
36
  "lodash": "4.18.1",
34
37
  "minimatch": "10.2.6",
35
38
  "pino": "10.3.1",
36
39
  "pino-lambda": "4.4.1",
40
+ "slugify": "1.6.9",
37
41
  "zod": "4.4.3"
38
42
  },
39
43
  "devDependencies": {
40
44
  "@types/jsonwebtoken": "9.0.10",
41
- "@webiny/build-tools": "0.0.0-unstable.0d717d18dd",
42
- "@webiny/event-handler-core": "0.0.0-unstable.0d717d18dd",
43
- "@webiny/project-utils": "0.0.0-unstable.0d717d18dd",
45
+ "@webiny/build-tools": "0.0.0-unstable.5387e5f7c8",
44
46
  "rimraf": "6.1.3",
45
47
  "typescript": "7.0.2",
46
- "vitest": "4.1.10"
48
+ "vitest": "4.1.11"
47
49
  },
48
50
  "publishConfig": {
49
51
  "access": "public"
@@ -0,0 +1,14 @@
1
+ export type Plugin<T = Record<string, any>> = {
2
+ type: string;
3
+ name?: string;
4
+ init?: () => void;
5
+ [key: string]: any;
6
+ } & T;
7
+ export type PluginCollection = (Plugin | PluginCollection)[];
8
+ export interface StorageOperations<T = any> {
9
+ storageOperations: T;
10
+ plugins: PluginCollection;
11
+ }
12
+ export declare const getStorageOps: <T = any>(app: string) => StorageOperations<T>;
13
+ export declare const setStorageOps: (app: string, factory: () => StorageOperations) => void;
14
+ export declare const clearStorageOps: () => void;
@@ -0,0 +1,18 @@
1
+ const getStorageOps = (app)=>{
2
+ const storageOps = globalThis["__storageOps"];
3
+ if (void 0 === storageOps) throw new Error("Storage ops are not configured!");
4
+ const appStorageOps = storageOps[app];
5
+ if (void 0 === appStorageOps) throw new Error(`Storage ops for "${app}" are not configured! Have you configured "jest.setup.js" correctly?`);
6
+ return appStorageOps();
7
+ };
8
+ const setStorageOps = (app, factory)=>{
9
+ const storageOps = globalThis["__storageOps"] || {};
10
+ storageOps[app] = factory;
11
+ globalThis["__storageOps"] = storageOps;
12
+ };
13
+ const clearStorageOps = ()=>{
14
+ delete globalThis["__storageOps"];
15
+ };
16
+ export { clearStorageOps, getStorageOps, setStorageOps };
17
+
18
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing/environment.js","sources":["../../src/testing/environment.ts"],"sourcesContent":["export type Plugin<T = Record<string, any>> = {\n type: string;\n name?: string;\n init?: () => void;\n [key: string]: any;\n} & T;\n\nexport type PluginCollection = (Plugin | PluginCollection)[];\n\nexport interface StorageOperations<T = any> {\n storageOperations: T;\n plugins: PluginCollection;\n}\n\nexport const getStorageOps = <T = any>(app: string): StorageOperations<T> => {\n const storageOps = (globalThis as Record<string, any>)[\"__storageOps\"];\n\n if (typeof storageOps === \"undefined\") {\n throw new Error(`Storage ops are not configured!`);\n }\n\n const appStorageOps = storageOps[app];\n if (typeof appStorageOps === \"undefined\") {\n throw new Error(\n `Storage ops for \"${app}\" are not configured! Have you configured \"jest.setup.js\" correctly?`\n );\n }\n\n return appStorageOps();\n};\n\nexport const setStorageOps = (app: string, factory: () => StorageOperations): void => {\n const storageOps = (globalThis as Record<string, any>)[\"__storageOps\"] || {};\n storageOps[app] = factory;\n (globalThis as Record<string, any>)[\"__storageOps\"] = storageOps;\n};\n\nexport const clearStorageOps = (): void => {\n delete (globalThis as Record<string, any>)[\"__storageOps\"];\n};\n"],"names":["getStorageOps","app","storageOps","globalThis","Error","appStorageOps","setStorageOps","factory","clearStorageOps"],"mappings":"AAcO,MAAMA,gBAAgB,CAAUC;IACnC,MAAMC,aAAcC,UAAkC,CAAC,eAAe;IAEtE,IAAI,AAAsB,WAAfD,YACP,MAAM,IAAIE,MAAM;IAGpB,MAAMC,gBAAgBH,UAAU,CAACD,IAAI;IACrC,IAAI,AAAyB,WAAlBI,eACP,MAAM,IAAID,MACN,CAAC,iBAAiB,EAAEH,IAAI,oEAAoE,CAAC;IAIrG,OAAOI;AACX;AAEO,MAAMC,gBAAgB,CAACL,KAAaM;IACvC,MAAML,aAAcC,UAAkC,CAAC,eAAe,IAAI,CAAC;IAC3ED,UAAU,CAACD,IAAI,GAAGM;IACjBJ,UAAkC,CAAC,eAAe,GAAGD;AAC1D;AAEO,MAAMM,kBAAkB;IAC3B,OAAQL,UAAkC,CAAC,eAAe;AAC9D"}
@@ -1,2 +0,0 @@
1
- import type { DecryptedWcpProjectLicense, ILicense } from "@webiny/wcp/types.js";
2
- export declare function loadWcpLicense(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense>;
@@ -1,51 +0,0 @@
1
- import { License, NullLicense, getWcpProjectEnvironment, getWcpProjectLicense } from "@webiny/wcp";
2
- import { getWcpProjectLicenseCacheKey } from "./WcpContext/utils.js";
3
- function resolveWcpProjectEnvironment() {
4
- const fromBlob = getWcpProjectEnvironment();
5
- if (fromBlob) return fromBlob;
6
- const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;
7
- const apiKey = process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;
8
- if (!projectId || !apiKey) return null;
9
- const [orgId, project] = projectId.split("/");
10
- if (!orgId || !project) return null;
11
- return {
12
- id: "",
13
- apiKey,
14
- org: {
15
- id: orgId
16
- },
17
- project: {
18
- id: project
19
- }
20
- };
21
- }
22
- const wcpProjectEnvironment = resolveWcpProjectEnvironment();
23
- const cachedLicense = {
24
- cacheKey: null,
25
- project: null,
26
- license: new NullLicense()
27
- };
28
- async function loadWcpLicense(testProjectLicense) {
29
- if (testProjectLicense) cachedLicense.license = License.fromLicenseDto(testProjectLicense);
30
- else if (wcpProjectEnvironment) {
31
- const currentCacheKey = getWcpProjectLicenseCacheKey();
32
- if (cachedLicense.cacheKey !== currentCacheKey) {
33
- cachedLicense.cacheKey = currentCacheKey;
34
- const decryptedLicenseDto = await getWcpProjectLicense({
35
- orgId: wcpProjectEnvironment.org.id,
36
- projectId: wcpProjectEnvironment.project.id,
37
- projectEnvironmentApiKey: wcpProjectEnvironment.apiKey
38
- });
39
- if (decryptedLicenseDto) cachedLicense.project = {
40
- orgId: decryptedLicenseDto.orgId,
41
- projectId: decryptedLicenseDto.projectId,
42
- package: decryptedLicenseDto.package
43
- };
44
- cachedLicense.license = License.fromLicenseDto(decryptedLicenseDto);
45
- }
46
- }
47
- return cachedLicense.license;
48
- }
49
- export { loadWcpLicense };
50
-
51
- //# sourceMappingURL=loadWcpLicense.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/wcp/loadWcpLicense.js","sources":["../../../src/features/wcp/loadWcpLicense.ts"],"sourcesContent":["import { getWcpProjectLicense, getWcpProjectEnvironment, NullLicense } from \"@webiny/wcp\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment\n} from \"@webiny/wcp/types.js\";\nimport { License } from \"@webiny/wcp\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\n\n/**\n * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed\n * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).\n * When it's absent — a CLI-less self-hosted deploy that boots the built handler directly (e.g.\n * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a\n * fresh license can still be fetched.\n */\nfunction resolveWcpProjectEnvironment(): WcpProjectEnvironment | null {\n const fromBlob = getWcpProjectEnvironment();\n if (fromBlob) {\n return fromBlob;\n }\n\n const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n if (!projectId || !apiKey) {\n return null;\n }\n\n // WEBINY_PROJECT_ID has an \"orgId/projectId\" shape.\n const [orgId, project] = projectId.split(\"/\");\n if (!orgId || !project) {\n return null;\n }\n\n // `id` is intentionally empty. The WCP backend identifies the specific project environment\n // from the api key (sent as the request's authorization header); the license fetch only uses\n // org/project (URL path) + apiKey (auth), never the environment id. So there's nothing to fill.\n return { id: \"\", apiKey, org: { id: orgId }, project: { id: project } };\n}\n\nconst wcpProjectEnvironment = resolveWcpProjectEnvironment();\n\nconst cachedLicense: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n};\n\nexport async function loadWcpLicense(\n testProjectLicense?: DecryptedWcpProjectLicense\n): Promise<ILicense> {\n if (testProjectLicense) {\n cachedLicense.license = License.fromLicenseDto(testProjectLicense);\n } else if (wcpProjectEnvironment) {\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cachedLicense.cacheKey !== currentCacheKey) {\n cachedLicense.cacheKey = currentCacheKey;\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: wcpProjectEnvironment.org.id,\n projectId: wcpProjectEnvironment.project.id,\n projectEnvironmentApiKey: wcpProjectEnvironment.apiKey\n });\n\n if (decryptedLicenseDto) {\n cachedLicense.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cachedLicense.license = License.fromLicenseDto(decryptedLicenseDto);\n }\n }\n\n return cachedLicense.license;\n}\n"],"names":["resolveWcpProjectEnvironment","fromBlob","getWcpProjectEnvironment","projectId","process","apiKey","orgId","project","wcpProjectEnvironment","cachedLicense","NullLicense","loadWcpLicense","testProjectLicense","License","currentCacheKey","getWcpProjectLicenseCacheKey","decryptedLicenseDto","getWcpProjectLicense"],"mappings":";;AAiBA,SAASA;IACL,MAAMC,WAAWC;IACjB,IAAID,UACA,OAAOA;IAGX,MAAME,YAAYC,QAAQ,GAAG,CAAC,iBAAiB,IAAIA,QAAQ,GAAG,CAAC,cAAc;IAC7E,MAAMC,SACFD,QAAQ,GAAG,CAAC,sBAAsB,IAAIA,QAAQ,GAAG,CAAC,+BAA+B;IACrF,IAAI,CAACD,aAAa,CAACE,QACf,OAAO;IAIX,MAAM,CAACC,OAAOC,QAAQ,GAAGJ,UAAU,KAAK,CAAC;IACzC,IAAI,CAACG,SAAS,CAACC,SACX,OAAO;IAMX,OAAO;QAAE,IAAI;QAAIF;QAAQ,KAAK;YAAE,IAAIC;QAAM;QAAG,SAAS;YAAE,IAAIC;QAAQ;IAAE;AAC1E;AAEA,MAAMC,wBAAwBR;AAE9B,MAAMS,gBAAyC;IAC3C,UAAU;IACV,SAAS;IACT,SAAS,IAAIC;AACjB;AAEO,eAAeC,eAClBC,kBAA+C;IAE/C,IAAIA,oBACAH,cAAc,OAAO,GAAGI,QAAQ,cAAc,CAACD;SAC5C,IAAIJ,uBAAuB;QAC9B,MAAMM,kBAAkBC;QACxB,IAAIN,cAAc,QAAQ,KAAKK,iBAAiB;YAC5CL,cAAc,QAAQ,GAAGK;YAEzB,MAAME,sBAAsB,MAAMC,qBAAqB;gBACnD,OAAOT,sBAAsB,GAAG,CAAC,EAAE;gBACnC,WAAWA,sBAAsB,OAAO,CAAC,EAAE;gBAC3C,0BAA0BA,sBAAsB,MAAM;YAC1D;YAEA,IAAIQ,qBACAP,cAAc,OAAO,GAAG;gBACpB,OAAOO,oBAAoB,KAAK;gBAChC,WAAWA,oBAAoB,SAAS;gBACxC,SAASA,oBAAoB,OAAO;YACxC;YAGJP,cAAc,OAAO,GAAGI,QAAQ,cAAc,CAACG;QACnD;IACJ;IAEA,OAAOP,cAAc,OAAO;AAChC"}