@carlonicora/nextjs-jsonapi 1.24.3 → 1.25.0

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 (76) hide show
  1. package/dist/{BlockNoteEditor-OFSTXGZX.js → BlockNoteEditor-CKMTHP7C.js} +13 -13
  2. package/dist/{BlockNoteEditor-OFSTXGZX.js.map → BlockNoteEditor-CKMTHP7C.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-TJNLCNIP.mjs → BlockNoteEditor-EJQLNOLB.mjs} +3 -3
  4. package/dist/billing/index.js +342 -342
  5. package/dist/billing/index.mjs +2 -2
  6. package/dist/{chunk-H5JZ5E7M.mjs → chunk-JNLXGGHE.mjs} +1247 -54
  7. package/dist/chunk-JNLXGGHE.mjs.map +1 -0
  8. package/dist/{chunk-5U4NJJOF.mjs → chunk-LNBT2YPZ.mjs} +289 -2
  9. package/dist/chunk-LNBT2YPZ.mjs.map +1 -0
  10. package/dist/{chunk-NQVPCNRS.js → chunk-O3LLMGP7.js} +290 -3
  11. package/dist/chunk-O3LLMGP7.js.map +1 -0
  12. package/dist/{chunk-EJALOG7L.js → chunk-YYZ2U4WU.js} +1598 -405
  13. package/dist/chunk-YYZ2U4WU.js.map +1 -0
  14. package/dist/client/index.d.mts +96 -1
  15. package/dist/client/index.d.ts +96 -1
  16. package/dist/client/index.js +9 -3
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/client/index.mjs +8 -2
  19. package/dist/components/index.d.mts +225 -1
  20. package/dist/components/index.d.ts +225 -1
  21. package/dist/components/index.js +25 -3
  22. package/dist/components/index.js.map +1 -1
  23. package/dist/components/index.mjs +24 -2
  24. package/dist/contexts/index.js +3 -3
  25. package/dist/contexts/index.mjs +2 -2
  26. package/dist/core/index.d.mts +108 -1
  27. package/dist/core/index.d.ts +108 -1
  28. package/dist/core/index.js +14 -2
  29. package/dist/core/index.js.map +1 -1
  30. package/dist/core/index.mjs +13 -1
  31. package/dist/index.d.mts +2 -1
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.js +14 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +13 -1
  36. package/dist/oauth.interface-DsZ5ecSX.d.mts +119 -0
  37. package/dist/oauth.interface-vL7za9Bz.d.ts +119 -0
  38. package/dist/server/index.js +3 -3
  39. package/dist/server/index.mjs +1 -1
  40. package/package.json +1 -1
  41. package/src/client/index.ts +1 -0
  42. package/src/components/index.ts +1 -0
  43. package/src/core/index.ts +3 -0
  44. package/src/core/registry/ModuleRegistry.ts +2 -0
  45. package/src/features/index.ts +1 -0
  46. package/src/features/oauth/atoms/index.ts +1 -0
  47. package/src/features/oauth/atoms/oauth.atoms.ts +131 -0
  48. package/src/features/oauth/components/OAuthClientCard.tsx +105 -0
  49. package/src/features/oauth/components/OAuthClientDetail.tsx +269 -0
  50. package/src/features/oauth/components/OAuthClientForm.tsx +212 -0
  51. package/src/features/oauth/components/OAuthClientList.tsx +127 -0
  52. package/src/features/oauth/components/OAuthClientSecretDisplay.tsx +127 -0
  53. package/src/features/oauth/components/OAuthRedirectUriInput.tsx +152 -0
  54. package/src/features/oauth/components/OAuthScopeSelector.tsx +123 -0
  55. package/src/features/oauth/components/consent/OAuthConsentActions.tsx +41 -0
  56. package/src/features/oauth/components/consent/OAuthConsentHeader.tsx +51 -0
  57. package/src/features/oauth/components/consent/OAuthConsentScreen.tsx +142 -0
  58. package/src/features/oauth/components/consent/OAuthScopeList.tsx +72 -0
  59. package/src/features/oauth/components/consent/index.ts +4 -0
  60. package/src/features/oauth/components/index.ts +8 -0
  61. package/src/features/oauth/data/index.ts +2 -0
  62. package/src/features/oauth/data/oauth.service.ts +191 -0
  63. package/src/features/oauth/data/oauth.ts +87 -0
  64. package/src/features/oauth/hooks/index.ts +3 -0
  65. package/src/features/oauth/hooks/useOAuthClient.ts +161 -0
  66. package/src/features/oauth/hooks/useOAuthClients.ts +111 -0
  67. package/src/features/oauth/hooks/useOAuthConsent.ts +125 -0
  68. package/src/features/oauth/index.ts +6 -0
  69. package/src/features/oauth/interfaces/index.ts +1 -0
  70. package/src/features/oauth/interfaces/oauth.interface.ts +175 -0
  71. package/src/features/oauth/oauth.module.ts +9 -0
  72. package/dist/chunk-5U4NJJOF.mjs.map +0 -1
  73. package/dist/chunk-EJALOG7L.js.map +0 -1
  74. package/dist/chunk-H5JZ5E7M.mjs.map +0 -1
  75. package/dist/chunk-NQVPCNRS.js.map +0 -1
  76. /package/dist/{BlockNoteEditor-TJNLCNIP.mjs.map → BlockNoteEditor-EJQLNOLB.mjs.map} +0 -0
@@ -4882,6 +4882,287 @@ var UserModule = /* @__PURE__ */ __name((factory) => factory({
4882
4882
  }
4883
4883
  }), "UserModule");
4884
4884
 
4885
+ // src/features/oauth/data/oauth.ts
4886
+ var OAuthClient = class extends AbstractApiData {
4887
+ static {
4888
+ __name(this, "OAuthClient");
4889
+ }
4890
+ _clientId;
4891
+ _name;
4892
+ _description;
4893
+ _redirectUris = [];
4894
+ _allowedScopes = [];
4895
+ _allowedGrantTypes = [];
4896
+ _isConfidential = true;
4897
+ _isActive = true;
4898
+ get clientId() {
4899
+ return this._clientId ?? this.id;
4900
+ }
4901
+ get name() {
4902
+ if (!this._name) throw new Error("Name is not defined");
4903
+ return this._name;
4904
+ }
4905
+ get description() {
4906
+ return this._description;
4907
+ }
4908
+ get redirectUris() {
4909
+ return this._redirectUris;
4910
+ }
4911
+ get allowedScopes() {
4912
+ return this._allowedScopes;
4913
+ }
4914
+ get allowedGrantTypes() {
4915
+ return this._allowedGrantTypes;
4916
+ }
4917
+ get isConfidential() {
4918
+ return this._isConfidential;
4919
+ }
4920
+ get isActive() {
4921
+ return this._isActive;
4922
+ }
4923
+ rehydrate(data) {
4924
+ super.rehydrate(data);
4925
+ const attrs = data.jsonApi.attributes || {};
4926
+ this._clientId = attrs.clientId ?? this._id;
4927
+ this._name = attrs.name;
4928
+ this._description = attrs.description;
4929
+ this._redirectUris = attrs.redirectUris ?? [];
4930
+ this._allowedScopes = attrs.allowedScopes ?? [];
4931
+ this._allowedGrantTypes = attrs.allowedGrantTypes ?? [];
4932
+ this._isConfidential = attrs.isConfidential ?? true;
4933
+ this._isActive = attrs.isActive ?? true;
4934
+ return this;
4935
+ }
4936
+ createJsonApi(data) {
4937
+ const response = {
4938
+ data: {
4939
+ type: "oauth-clients",
4940
+ attributes: {}
4941
+ }
4942
+ };
4943
+ if (data.id) response.data.id = data.id;
4944
+ if (data.name !== void 0) response.data.attributes.name = data.name;
4945
+ if (data.description !== void 0) response.data.attributes.description = data.description;
4946
+ if (data.redirectUris !== void 0) response.data.attributes.redirectUris = data.redirectUris;
4947
+ if (data.allowedScopes !== void 0) response.data.attributes.allowedScopes = data.allowedScopes;
4948
+ if (data.allowedGrantTypes !== void 0) response.data.attributes.allowedGrantTypes = data.allowedGrantTypes;
4949
+ if (data.isConfidential !== void 0) response.data.attributes.isConfidential = data.isConfidential;
4950
+ if (data.isActive !== void 0) response.data.attributes.isActive = data.isActive;
4951
+ return response;
4952
+ }
4953
+ };
4954
+
4955
+ // src/features/oauth/oauth.module.ts
4956
+ var OAuthModule = /* @__PURE__ */ __name((factory) => factory({
4957
+ pageUrl: "/oauth",
4958
+ name: "oauth-clients",
4959
+ model: OAuthClient
4960
+ }), "OAuthModule");
4961
+
4962
+ // src/features/oauth/data/oauth.service.ts
4963
+ var OAuthService = class extends AbstractService {
4964
+ static {
4965
+ __name(this, "OAuthService");
4966
+ }
4967
+ // ==========================================
4968
+ // CLIENT MANAGEMENT
4969
+ // ==========================================
4970
+ /**
4971
+ * List all OAuth clients for the current user
4972
+ */
4973
+ static async listClients(params) {
4974
+ return this.callApi({
4975
+ type: Modules.OAuth,
4976
+ method: "GET" /* GET */,
4977
+ endpoint: new EndpointCreator({ endpoint: "oauth/clients" }).generate(),
4978
+ next: params?.next
4979
+ });
4980
+ }
4981
+ /**
4982
+ * Get a single OAuth client by ID
4983
+ */
4984
+ static async getClient(params) {
4985
+ return this.callApi({
4986
+ type: Modules.OAuth,
4987
+ method: "GET" /* GET */,
4988
+ endpoint: new EndpointCreator({ endpoint: "oauth/clients", id: params.clientId }).generate()
4989
+ });
4990
+ }
4991
+ /**
4992
+ * Create a new OAuth client
4993
+ * @returns The created client AND the client secret (shown only once!)
4994
+ */
4995
+ static async createClient(data) {
4996
+ const result = await this.callApiWithMeta({
4997
+ type: Modules.OAuth,
4998
+ method: "POST" /* POST */,
4999
+ endpoint: new EndpointCreator({ endpoint: "oauth/clients" }).generate(),
5000
+ input: data
5001
+ });
5002
+ return {
5003
+ client: result.data,
5004
+ clientSecret: result.meta?.clientSecret
5005
+ };
5006
+ }
5007
+ /**
5008
+ * Update an existing OAuth client
5009
+ */
5010
+ static async updateClient(params) {
5011
+ return this.callApi({
5012
+ type: Modules.OAuth,
5013
+ method: "PATCH" /* PATCH */,
5014
+ endpoint: new EndpointCreator({ endpoint: "oauth/clients", id: params.clientId }).generate(),
5015
+ input: { id: params.clientId, ...params.data }
5016
+ });
5017
+ }
5018
+ /**
5019
+ * Delete an OAuth client
5020
+ */
5021
+ static async deleteClient(params) {
5022
+ await this.callApi({
5023
+ type: Modules.OAuth,
5024
+ method: "DELETE" /* DELETE */,
5025
+ endpoint: new EndpointCreator({ endpoint: "oauth/clients", id: params.clientId }).generate()
5026
+ });
5027
+ }
5028
+ /**
5029
+ * Regenerate the client secret
5030
+ * @returns The new client secret (shown only once!)
5031
+ */
5032
+ static async regenerateSecret(params) {
5033
+ const result = await this.callApiWithMeta({
5034
+ type: Modules.OAuth,
5035
+ method: "POST" /* POST */,
5036
+ endpoint: new EndpointCreator({
5037
+ endpoint: "oauth/clients",
5038
+ id: params.clientId,
5039
+ childEndpoint: "regenerate-secret"
5040
+ }).generate()
5041
+ });
5042
+ return {
5043
+ clientSecret: result.meta?.clientSecret
5044
+ };
5045
+ }
5046
+ // ==========================================
5047
+ // CONSENT FLOW
5048
+ // ==========================================
5049
+ /**
5050
+ * Get client information for the consent screen
5051
+ * Called when user is redirected to /oauth/authorize
5052
+ */
5053
+ static async getAuthorizationInfo(params) {
5054
+ const endpoint = new EndpointCreator({ endpoint: "oauth/authorize/info" });
5055
+ endpoint.addAdditionalParam("client_id", params.clientId);
5056
+ endpoint.addAdditionalParam("redirect_uri", params.redirectUri);
5057
+ endpoint.addAdditionalParam("scope", params.scope);
5058
+ if (params.state) endpoint.addAdditionalParam("state", params.state);
5059
+ if (params.codeChallenge) endpoint.addAdditionalParam("code_challenge", params.codeChallenge);
5060
+ if (params.codeChallengeMethod) endpoint.addAdditionalParam("code_challenge_method", params.codeChallengeMethod);
5061
+ return this.callApi({
5062
+ type: Modules.OAuth,
5063
+ method: "GET" /* GET */,
5064
+ endpoint: endpoint.generate()
5065
+ });
5066
+ }
5067
+ /**
5068
+ * Approve the authorization request
5069
+ * @returns Redirect URL with authorization code
5070
+ */
5071
+ static async approveAuthorization(params) {
5072
+ const result = await this.callApiWithMeta({
5073
+ type: Modules.OAuth,
5074
+ method: "POST" /* POST */,
5075
+ endpoint: new EndpointCreator({ endpoint: "oauth/authorize/approve" }).generate(),
5076
+ input: {
5077
+ client_id: params.clientId,
5078
+ redirect_uri: params.redirectUri,
5079
+ scope: params.scope,
5080
+ state: params.state,
5081
+ code_challenge: params.codeChallenge,
5082
+ code_challenge_method: params.codeChallengeMethod
5083
+ },
5084
+ overridesJsonApiCreation: true
5085
+ });
5086
+ return {
5087
+ redirectUrl: result.meta?.redirectUrl
5088
+ };
5089
+ }
5090
+ /**
5091
+ * Deny the authorization request
5092
+ * @returns Redirect URL with error=access_denied
5093
+ */
5094
+ static async denyAuthorization(params) {
5095
+ const result = await this.callApiWithMeta({
5096
+ type: Modules.OAuth,
5097
+ method: "POST" /* POST */,
5098
+ endpoint: new EndpointCreator({ endpoint: "oauth/authorize/deny" }).generate(),
5099
+ input: {
5100
+ client_id: params.clientId,
5101
+ redirect_uri: params.redirectUri,
5102
+ state: params.state
5103
+ },
5104
+ overridesJsonApiCreation: true
5105
+ });
5106
+ return {
5107
+ redirectUrl: result.meta?.redirectUrl
5108
+ };
5109
+ }
5110
+ };
5111
+
5112
+ // src/features/oauth/interfaces/oauth.interface.ts
5113
+ var OAUTH_SCOPE_DISPLAY = {
5114
+ read: {
5115
+ scope: "read",
5116
+ name: "Read Access",
5117
+ description: "Read access to your data",
5118
+ icon: "eye"
5119
+ },
5120
+ write: {
5121
+ scope: "write",
5122
+ name: "Write Access",
5123
+ description: "Write access to your data",
5124
+ icon: "pencil"
5125
+ },
5126
+ "photographs:read": {
5127
+ scope: "photographs:read",
5128
+ name: "View Photographs",
5129
+ description: "Access and download your photo library",
5130
+ icon: "image"
5131
+ },
5132
+ "photographs:write": {
5133
+ scope: "photographs:write",
5134
+ name: "Upload Photographs",
5135
+ description: "Add new photos to your rolls",
5136
+ icon: "upload"
5137
+ },
5138
+ "rolls:read": {
5139
+ scope: "rolls:read",
5140
+ name: "View Rolls",
5141
+ description: "See your film rolls and collections",
5142
+ icon: "film"
5143
+ },
5144
+ "rolls:write": {
5145
+ scope: "rolls:write",
5146
+ name: "Manage Rolls",
5147
+ description: "Create and modify film rolls",
5148
+ icon: "folder-plus"
5149
+ },
5150
+ profile: {
5151
+ scope: "profile",
5152
+ name: "View Profile",
5153
+ description: "Access your name and email",
5154
+ icon: "user"
5155
+ },
5156
+ admin: {
5157
+ scope: "admin",
5158
+ name: "Administrative Access",
5159
+ description: "Full administrative access to your account",
5160
+ icon: "shield"
5161
+ }
5162
+ };
5163
+ var AVAILABLE_OAUTH_SCOPES = Object.values(OAUTH_SCOPE_DISPLAY);
5164
+ var DEFAULT_GRANT_TYPES = ["authorization_code", "refresh_token"];
5165
+
4885
5166
  export {
4886
5167
  RehydrationFactory,
4887
5168
  AbstractApiData,
@@ -4994,6 +5275,12 @@ export {
4994
5275
  UserFields,
4995
5276
  UserService,
4996
5277
  AuthorModule,
4997
- UserModule
5278
+ UserModule,
5279
+ OAuthClient,
5280
+ OAuthModule,
5281
+ OAuthService,
5282
+ OAUTH_SCOPE_DISPLAY,
5283
+ AVAILABLE_OAUTH_SCOPES,
5284
+ DEFAULT_GRANT_TYPES
4998
5285
  };
4999
- //# sourceMappingURL=chunk-5U4NJJOF.mjs.map
5286
+ //# sourceMappingURL=chunk-LNBT2YPZ.mjs.map