@polymorphism-tech/morph-spec 4.17.0 → 4.18.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 (40) hide show
  1. package/CLAUDE.md +36 -0
  2. package/README.md +2 -2
  3. package/claude-plugin.json +1 -1
  4. package/docs/CHEATSHEET.md +1 -1
  5. package/docs/QUICKSTART.md +1 -1
  6. package/framework/agents/backend/neon-expert.md +9 -27
  7. package/framework/agents/integrations/neon-auth.md +151 -0
  8. package/framework/agents.json +21 -13
  9. package/framework/rules/neon-auth-standards.md +13 -0
  10. package/framework/rules/neon-standards.md +1 -0
  11. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +3 -3
  12. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +1 -1
  13. package/framework/skills/level-0-meta/morph-init/SKILL.md +4 -4
  14. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +1 -1
  15. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +1 -1
  16. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +1 -1
  17. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
  18. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
  19. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +1 -1
  20. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  21. package/framework/standards/STANDARDS.json +13 -9
  22. package/framework/standards/backend/database/postgresql/database.md +5 -5
  23. package/framework/standards/backend/integrations/asaas/asaas-api.md +1 -1
  24. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +364 -0
  25. package/framework/standards/frontend/nextjs/nextjs-patterns.md +9 -9
  26. package/framework/templates/README.md +2 -2
  27. package/framework/templates/REGISTRY.json +5 -5
  28. package/framework/templates/code/sql/postgresql-migration.sql +10 -10
  29. package/framework/templates/code/sql/postgresql-migration.template.sql +12 -14
  30. package/framework/templates/code/sql/postgresql-rls-policy.sql +6 -9
  31. package/framework/templates/feature/decisions.md +8 -7
  32. package/framework/templates/integrations/neon-auth-config.cs +133 -0
  33. package/framework/workflows/docs/full-morph.md +1 -1
  34. package/package.json +1 -1
  35. package/src/lib/detectors/index.js +2 -2
  36. package/src/lib/generators/architecture-scanner.js +2 -3
  37. package/framework/agents/integrations/clerk-auth.md +0 -109
  38. package/framework/rules/clerk-standards.md +0 -13
  39. package/framework/standards/backend/integrations/clerk/clerk-auth.md +0 -292
  40. package/framework/templates/integrations/clerk-config.cs +0 -217
@@ -1,217 +0,0 @@
1
- // ==============================================================================
2
- // MORPH-SPEC - Clerk Authentication Configuration Template
3
- // Configuração de autenticação com Clerk para .NET
4
- // ==============================================================================
5
-
6
- using Microsoft.AspNetCore.Authentication;
7
- using System.Security.Claims;
8
-
9
- namespace {{Namespace}}.Infrastructure.Auth;
10
-
11
- // ==============================================================================
12
- // OPTIONS
13
- // ==============================================================================
14
-
15
- public class ClerkOptions
16
- {
17
- public const string SectionName = "Clerk";
18
-
19
- /// <summary>
20
- /// Clerk Secret Key (starts with sk_)
21
- /// </summary>
22
- public string SecretKey { get; set; } = string.Empty;
23
-
24
- /// <summary>
25
- /// Clerk Publishable Key (starts with pk_)
26
- /// </summary>
27
- public string PublishableKey { get; set; } = string.Empty;
28
-
29
- /// <summary>
30
- /// Clerk Frontend API URL
31
- /// </summary>
32
- public string FrontendApi { get; set; } = string.Empty;
33
- }
34
-
35
- // ==============================================================================
36
- // SERVICE EXTENSIONS
37
- // ==============================================================================
38
-
39
- public static class ClerkServiceExtensions
40
- {
41
- /// <summary>
42
- /// Adiciona autenticação Clerk ao projeto
43
- /// Requer: Clerk.Net.AspNetCore.Security
44
- /// </summary>
45
- public static IServiceCollection AddClerkAuthentication(
46
- this IServiceCollection services,
47
- IConfiguration configuration)
48
- {
49
- services.Configure<ClerkOptions>(configuration.GetSection(ClerkOptions.SectionName));
50
-
51
- // Opção 1: Usando Clerk.Net SDK oficial
52
- // services.AddClerk(configuration);
53
-
54
- // Opção 2: Configuração manual com JWT
55
- services.AddAuthentication("Clerk")
56
- .AddJwtBearer("Clerk", options =>
57
- {
58
- var clerkOptions = configuration.GetSection(ClerkOptions.SectionName).Get<ClerkOptions>()!;
59
-
60
- options.Authority = clerkOptions.FrontendApi;
61
- options.TokenValidationParameters = new()
62
- {
63
- ValidateIssuer = true,
64
- ValidateAudience = false,
65
- ValidateLifetime = true,
66
- ValidateIssuerSigningKey = true,
67
- NameClaimType = ClaimTypes.NameIdentifier
68
- };
69
- });
70
-
71
- services.AddAuthorization();
72
-
73
- return services;
74
- }
75
-
76
- }
77
-
78
- // ==============================================================================
79
- // CLERK USER SERVICE
80
- // ==============================================================================
81
-
82
- public interface IClerkUserService
83
- {
84
- Task<ClerkUser?> GetCurrentUserAsync(CancellationToken ct = default);
85
- Task<ClerkUser?> GetUserByIdAsync(string userId, CancellationToken ct = default);
86
- Task UpdateUserMetadataAsync(string userId, Dictionary<string, object> metadata, CancellationToken ct = default);
87
- }
88
-
89
- public class ClerkUserService : IClerkUserService
90
- {
91
- private readonly HttpClient _httpClient;
92
- private readonly IHttpContextAccessor _httpContextAccessor;
93
- private readonly ILogger<ClerkUserService> _logger;
94
-
95
- public ClerkUserService(
96
- HttpClient httpClient,
97
- IHttpContextAccessor httpContextAccessor,
98
- ILogger<ClerkUserService> logger)
99
- {
100
- _httpClient = httpClient;
101
- _httpContextAccessor = httpContextAccessor;
102
- _logger = logger;
103
- }
104
-
105
- public async Task<ClerkUser?> GetCurrentUserAsync(CancellationToken ct = default)
106
- {
107
- var userId = _httpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier);
108
- if (string.IsNullOrEmpty(userId)) return null;
109
-
110
- return await GetUserByIdAsync(userId, ct);
111
- }
112
-
113
- public async Task<ClerkUser?> GetUserByIdAsync(string userId, CancellationToken ct = default)
114
- {
115
- try
116
- {
117
- var response = await _httpClient.GetAsync($"users/{userId}", ct);
118
-
119
- if (!response.IsSuccessStatusCode)
120
- {
121
- _logger.LogWarning("Failed to get Clerk user {UserId}: {Status}", userId, response.StatusCode);
122
- return null;
123
- }
124
-
125
- return await response.Content.ReadFromJsonAsync<ClerkUser>(ct);
126
- }
127
- catch (Exception ex)
128
- {
129
- _logger.LogError(ex, "Error getting Clerk user {UserId}", userId);
130
- return null;
131
- }
132
- }
133
-
134
- public async Task UpdateUserMetadataAsync(string userId, Dictionary<string, object> metadata, CancellationToken ct = default)
135
- {
136
- var request = new { public_metadata = metadata };
137
- var response = await _httpClient.PatchAsJsonAsync($"users/{userId}", request, ct);
138
- response.EnsureSuccessStatusCode();
139
- }
140
- }
141
-
142
- // ==============================================================================
143
- // CLERK USER MODEL
144
- // ==============================================================================
145
-
146
- public record ClerkUser
147
- {
148
- public string Id { get; init; } = string.Empty;
149
- public string? FirstName { get; init; }
150
- public string? LastName { get; init; }
151
- public string? ImageUrl { get; init; }
152
- public List<ClerkEmailAddress>? EmailAddresses { get; init; }
153
- public string? PrimaryEmailAddressId { get; init; }
154
- public Dictionary<string, object>? PublicMetadata { get; init; }
155
- public long CreatedAt { get; init; }
156
- public long UpdatedAt { get; init; }
157
-
158
- public string? PrimaryEmail => EmailAddresses?
159
- .FirstOrDefault(e => e.Id == PrimaryEmailAddressId)?.EmailAddress;
160
-
161
- public string FullName => $"{FirstName} {LastName}".Trim();
162
- }
163
-
164
- public record ClerkEmailAddress
165
- {
166
- public string Id { get; init; } = string.Empty;
167
- public string EmailAddress { get; init; } = string.Empty;
168
- public bool Verified { get; init; }
169
- }
170
-
171
- // ==============================================================================
172
- // MIDDLEWARE PIPELINE
173
- // ==============================================================================
174
-
175
- public static class ClerkMiddlewareExtensions
176
- {
177
- public static IApplicationBuilder UseClerkAuthentication(this IApplicationBuilder app)
178
- {
179
- app.UseAuthentication();
180
- app.UseAuthorization();
181
- return app;
182
- }
183
- }
184
-
185
- // ==============================================================================
186
- // APPSETTINGS EXAMPLE
187
- // ==============================================================================
188
-
189
- /*
190
- {
191
- "Clerk": {
192
- "SecretKey": "sk_test_xxxxx",
193
- "PublishableKey": "pk_test_xxxxx",
194
- "FrontendApi": "https://your-app.clerk.accounts.dev"
195
- }
196
- }
197
- */
198
-
199
- // ==============================================================================
200
- // PROGRAM.CS EXAMPLE
201
- // ==============================================================================
202
-
203
- /*
204
- // Program.cs
205
- var builder = WebApplication.CreateBuilder(args);
206
-
207
- // Add Clerk authentication
208
- builder.Services.AddClerkAuthentication(builder.Configuration);
209
-
210
- var app = builder.Build();
211
-
212
- app.UseClerkAuthentication();
213
-
214
- app.MapControllers().RequireAuthorization();
215
-
216
- app.Run();
217
- */