anhedral 0.15.0 → 0.17.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.
- package/README.md +82 -34
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/UPSTREAM.json +0 -11
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -66
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +39 -322
- package/dist/dependencies.d.ts +29 -9
- package/dist/dependencies.js +57 -64
- package/dist/index.d.ts +1 -42
- package/dist/index.js +1 -27
- package/dist/platforms/web.d.ts +1 -1
- package/dist/platforms/web.js +27 -75
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -82
- package/dist/registry/options.js +1 -5
- package/dist/registry/resolve.d.ts +1 -1
- package/dist/registry/resolve.js +4 -10
- package/dist/registry/usage.js +3 -9
- package/dist/scaffold/backend.js +0 -3
- package/dist/scaffold/database.js +2 -1
- package/dist/scaffold/documentation.js +56 -25
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/workspace.js +21 -22
- package/dist/stack-registry.d.ts +2 -10
- package/dist/stack-registry.js +12 -98
- package/dist/standard.js +1 -11
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +12 -23
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +47 -0
- package/docs/software-factory.md +35 -50
- package/docs/stack-standard.md +19 -70
- package/docs/ui.md +33 -0
- package/docs/verification.md +6 -876
- package/package.json +21 -16
- package/assets/ui/native/button.tsx +0 -85
- package/assets/ui/native/card.tsx +0 -33
- package/assets/ui/native/dialog.tsx +0 -75
- package/assets/ui/native/input.tsx +0 -27
- package/assets/ui/native/label.tsx +0 -4
- package/assets/ui/native/layout.tsx +0 -26
- package/assets/ui/native/text.tsx +0 -20
- package/assets/ui/native/theme-switcher.tsx +0 -22
- package/assets/ui/theme-storage.ts +0 -25
- package/assets/ui/theme.tsx +0 -66
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -129
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -112
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -157
- package/dist/delivery.d.ts +0 -82
- package/dist/delivery.js +0 -489
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -12
- package/dist/integration-service-readers.js +0 -92
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -370
- package/dist/platforms/mobile.d.ts +0 -2
- package/dist/platforms/mobile.js +0 -156
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -671
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -47
- package/dist/project-state.js +0 -480
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -180
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -85
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -103
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -136
- package/dist/providers/definitions.d.ts +0 -115
- package/dist/providers/definitions.js +0 -42
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -56
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -52
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -234
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -283
- package/dist/provision.d.ts +0 -47
- package/dist/provision.js +0 -208
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -117
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -210
- package/dist/registry/bootstrap.d.ts +0 -3
- package/dist/registry/bootstrap.js +0 -5
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -83
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -2
- package/dist/scaffold/auth.js +0 -76
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -208
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -203
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -257
- package/dist/scaffold/expo-runtime.d.ts +0 -3
- package/dist/scaffold/expo-runtime.js +0 -43
- package/dist/scaffold/integrations.d.ts +0 -2
- package/dist/scaffold/integrations.js +0 -11
- package/dist/scaffold/managed-email.d.ts +0 -3
- package/dist/scaffold/managed-email.js +0 -47
- package/dist/scaffold/native-ui.d.ts +0 -2
- package/dist/scaffold/native-ui.js +0 -69
- package/dist/scaffold/password-reset.d.ts +0 -1
- package/dist/scaffold/password-reset.js +0 -99
- package/dist/scaffold/private-files.d.ts +0 -2
- package/dist/scaffold/private-files.js +0 -78
- package/dist/scaffold/web-billing.d.ts +0 -2
- package/dist/scaffold/web-billing.js +0 -48
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -71
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -48
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -216
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -96
- package/dist/ship.d.ts +0 -35
- package/dist/ship.js +0 -107
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from 'hono';
|
|
2
|
+
import { createAuth, authConfiguration } from './auth';
|
|
3
|
+
import type { AppEnv } from './environment';
|
|
4
|
+
const bearer = (headers: Headers) => (headers.get('authorization') ?? '').startsWith('Bearer ');
|
|
5
|
+
function sessionHeaders(request: Request) {
|
|
6
|
+
const headers = new Headers(request.headers);
|
|
7
|
+
if (bearer(headers)) headers.delete('cookie');
|
|
8
|
+
return headers;
|
|
9
|
+
}
|
|
10
|
+
function nativeOrigin(request: Request, env: AppEnv['Bindings']) {
|
|
11
|
+
const origins = (env.AUTH_TRUSTED_ORIGINS ?? '').split(',').map((value) => value.trim());
|
|
12
|
+
const claimed = request.headers.get('expo-origin') ?? '';
|
|
13
|
+
return claimed.length > 0 && origins.includes(claimed);
|
|
14
|
+
}
|
|
15
|
+
function trustedMutation(request: Request, env: AppEnv['Bindings']) {
|
|
16
|
+
if (['GET', 'HEAD', 'OPTIONS'].includes(request.method)) return true;
|
|
17
|
+
if (bearer(request.headers)) return true;
|
|
18
|
+
const origin = request.headers.get('origin');
|
|
19
|
+
if (origin !== null) return origin === new URL(env.PUBLIC_APP_URL!).origin;
|
|
20
|
+
// A browser-supplied Origin is never bypassed by an expo-origin header.
|
|
21
|
+
return nativeOrigin(request, env);
|
|
22
|
+
}
|
|
23
|
+
export const requireSession: MiddlewareHandler<AppEnv> = async (c, next) => {
|
|
24
|
+
if (!authConfiguration.safeParse(c.env).success)
|
|
25
|
+
return c.json({ error: 'Authentication needs configuration' }, 503);
|
|
26
|
+
const session = await createAuth(c.env).api.getSession({ headers: sessionHeaders(c.req.raw) });
|
|
27
|
+
if (!session) return c.json({ error: 'Unauthorized' }, 401);
|
|
28
|
+
if (!trustedMutation(c.req.raw, c.env)) return c.json({ error: 'Origin rejected' }, 403);
|
|
29
|
+
c.set('userId', session.user.id);
|
|
30
|
+
await next();
|
|
31
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { requireSession } from '../security';
|
|
3
|
+
import type { AppEnv } from '../environment';
|
|
4
|
+
export const storageRoutes = new Hono<AppEnv>();
|
|
5
|
+
storageRoutes.use('/files/*', requireSession);
|
|
6
|
+
storageRoutes.use('/files/:name', async (c, next) => {
|
|
7
|
+
const name = c.req.param('name');
|
|
8
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(name))
|
|
9
|
+
return c.json({ error: 'Invalid filename' }, 400);
|
|
10
|
+
c.set('fileKey', encodeURIComponent(c.get('userId')) + '/' + name);
|
|
11
|
+
await next();
|
|
12
|
+
});
|
|
13
|
+
storageRoutes.get('/files/:name', async (c) => {
|
|
14
|
+
const object = await c.env.FILES.get(c.get('fileKey'));
|
|
15
|
+
if (!object) return c.json({ error: 'Not found' }, 404);
|
|
16
|
+
return new Response(object.body, {
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/octet-stream',
|
|
19
|
+
'Content-Disposition': 'attachment; filename="' + c.req.param('name') + '"',
|
|
20
|
+
'X-Content-Type-Options': 'nosniff',
|
|
21
|
+
'Cache-Control': 'private, no-store',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
storageRoutes.put('/files/:name', async (c) => {
|
|
26
|
+
const bytes = await c.req.arrayBuffer();
|
|
27
|
+
if (bytes.byteLength > 1024 * 1024) return c.json({ error: 'File too large' }, 413);
|
|
28
|
+
await c.env.FILES.put(c.get('fileKey'), bytes, {
|
|
29
|
+
httpMetadata: { contentType: 'application/octet-stream' },
|
|
30
|
+
});
|
|
31
|
+
return c.json({ stored: true }, 201);
|
|
32
|
+
});
|
|
33
|
+
storageRoutes.delete('/files/:name', async (c) => {
|
|
34
|
+
await c.env.FILES.delete(c.get('fileKey'));
|
|
35
|
+
return c.body(null, 204);
|
|
36
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import Stripe from 'stripe';
|
|
4
|
+
import { requireSession } from '../security';
|
|
5
|
+
import { billingEnvironment } from '../billing-mode';
|
|
6
|
+
import type { AppEnv } from '../environment';
|
|
7
|
+
export const stripeRoutes = new Hono<AppEnv>();
|
|
8
|
+
const client = (key: string) =>
|
|
9
|
+
new Stripe(key, {
|
|
10
|
+
httpClient: Stripe.createFetchHttpClient(),
|
|
11
|
+
timeout: 5000,
|
|
12
|
+
maxNetworkRetries: 0,
|
|
13
|
+
});
|
|
14
|
+
const settings = z.object({
|
|
15
|
+
STRIPE_SECRET_KEY: z.string().min(1),
|
|
16
|
+
STRIPE_PRICE_ID: z.string().startsWith('price_'),
|
|
17
|
+
PUBLIC_APP_URL: z.url(),
|
|
18
|
+
});
|
|
19
|
+
const webhookSettings = z.object({
|
|
20
|
+
STRIPE_SECRET_KEY: z.string().min(1),
|
|
21
|
+
STRIPE_WEBHOOK_SECRET: z.string().min(1),
|
|
22
|
+
});
|
|
23
|
+
const idempotencyKey = z.string().regex(/^[a-zA-Z0-9_-]{8,100}$/);
|
|
24
|
+
stripeRoutes.post('/billing/checkout', requireSession, async (c) => {
|
|
25
|
+
const config = settings.safeParse(c.env);
|
|
26
|
+
if (!config.success) return c.json({ error: 'Configure Stripe test mode first' }, 503);
|
|
27
|
+
const key = idempotencyKey.safeParse(c.req.header('idempotency-key'));
|
|
28
|
+
if (!key.success) return c.json({ error: 'Provide an idempotency-key' }, 400);
|
|
29
|
+
const env = config.data;
|
|
30
|
+
requireMatchingKey(c.env, env.STRIPE_SECRET_KEY);
|
|
31
|
+
const userId = c.get('userId');
|
|
32
|
+
const result = await client(env.STRIPE_SECRET_KEY).checkout.sessions.create(
|
|
33
|
+
{
|
|
34
|
+
mode: 'subscription',
|
|
35
|
+
client_reference_id: userId,
|
|
36
|
+
line_items: [{ price: env.STRIPE_PRICE_ID, quantity: 1 }],
|
|
37
|
+
subscription_data: { metadata: { userId } },
|
|
38
|
+
success_url: new URL('/?checkout=success', env.PUBLIC_APP_URL).href,
|
|
39
|
+
cancel_url: new URL('/?checkout=cancelled', env.PUBLIC_APP_URL).href,
|
|
40
|
+
},
|
|
41
|
+
{ idempotencyKey: 'checkout:' + userId + ':' + key.data },
|
|
42
|
+
);
|
|
43
|
+
return c.json({ url: result.url });
|
|
44
|
+
});
|
|
45
|
+
async function verifiedEvent(
|
|
46
|
+
key: string,
|
|
47
|
+
secret: string,
|
|
48
|
+
signature: string | undefined,
|
|
49
|
+
body: string,
|
|
50
|
+
live: boolean,
|
|
51
|
+
) {
|
|
52
|
+
if (!signature) return null;
|
|
53
|
+
try {
|
|
54
|
+
const event = await client(key).webhooks.constructEventAsync(
|
|
55
|
+
body,
|
|
56
|
+
signature,
|
|
57
|
+
secret,
|
|
58
|
+
undefined,
|
|
59
|
+
Stripe.createSubtleCryptoProvider(),
|
|
60
|
+
);
|
|
61
|
+
return event.livemode === live ? event : null;
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
stripeRoutes.post('/webhooks/stripe', async (c) => {
|
|
67
|
+
const config = webhookSettings.safeParse(c.env);
|
|
68
|
+
if (!config.success) return c.json({ error: 'Webhook needs configuration' }, 503);
|
|
69
|
+
requireMatchingKey(c.env, config.data.STRIPE_SECRET_KEY);
|
|
70
|
+
const event = await verifiedEvent(
|
|
71
|
+
config.data.STRIPE_SECRET_KEY,
|
|
72
|
+
config.data.STRIPE_WEBHOOK_SECRET,
|
|
73
|
+
c.req.header('stripe-signature'),
|
|
74
|
+
await c.req.text(),
|
|
75
|
+
billingEnvironment(c.env) === 'live',
|
|
76
|
+
);
|
|
77
|
+
if (!event) return c.json({ error: 'Invalid signature or billing environment' }, 400);
|
|
78
|
+
// Receipts deduplicate delivery, but never grant an entitlement by event order.
|
|
79
|
+
await c.env.DB.prepare(
|
|
80
|
+
'INSERT OR IGNORE INTO billing_receipt(provider,event_id,received_at) VALUES (?,?,?)',
|
|
81
|
+
)
|
|
82
|
+
.bind('stripe', event.id, Date.now())
|
|
83
|
+
.run();
|
|
84
|
+
return c.json({ received: true });
|
|
85
|
+
});
|
|
86
|
+
function activePrice(subscription: Stripe.Subscription, price: string) {
|
|
87
|
+
if (!['active', 'trialing'].includes(subscription.status)) return false;
|
|
88
|
+
return subscription.items.data.some(
|
|
89
|
+
(item) => item.price.id === price && item.current_period_end * 1000 > Date.now(),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
function requireMatchingKey(env: AppEnv['Bindings'], key: string) {
|
|
93
|
+
const prefix = { sandbox: 'sk_test_', live: 'sk_live_' }[billingEnvironment(env)];
|
|
94
|
+
if (!key.startsWith(prefix))
|
|
95
|
+
throw Error('Stripe key does not match the configured billing environment');
|
|
96
|
+
}
|
|
97
|
+
export async function stripeEntitled(env: AppEnv['Bindings'], userId: string) {
|
|
98
|
+
const config = settings.parse(env);
|
|
99
|
+
requireMatchingKey(env, config.STRIPE_SECRET_KEY);
|
|
100
|
+
const stripe = client(config.STRIPE_SECRET_KEY);
|
|
101
|
+
const subject = userId.replaceAll('\\', '\\\\').replaceAll("'", "\\'");
|
|
102
|
+
const found = await stripe.subscriptions.search({
|
|
103
|
+
query: "metadata['userId']:'" + subject + "'",
|
|
104
|
+
limit: 100,
|
|
105
|
+
});
|
|
106
|
+
const canonical = await Promise.all(
|
|
107
|
+
found.data.map((value) => stripe.subscriptions.retrieve(value.id)),
|
|
108
|
+
);
|
|
109
|
+
return canonical.some(
|
|
110
|
+
(value) =>
|
|
111
|
+
value.metadata.userId === userId &&
|
|
112
|
+
value.livemode === (billingEnvironment(env) === 'live') &&
|
|
113
|
+
activePrice(value, config.STRIPE_PRICE_ID),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
stripeRoutes.get('/billing/status', requireSession, async (c) => {
|
|
117
|
+
try {
|
|
118
|
+
return c.json({
|
|
119
|
+
entitled: await stripeEntitled(c.env, c.get('userId')),
|
|
120
|
+
provider: 'stripe',
|
|
121
|
+
environment: billingEnvironment(c.env),
|
|
122
|
+
});
|
|
123
|
+
} catch {
|
|
124
|
+
return c.json({ error: 'Billing needs configuration or is temporarily unavailable' }, 503);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { authClient } from '@/lib/auth-client';
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import { Input } from '@/components/ui/input';
|
|
6
|
+
import { Label } from '@/components/ui/label';
|
|
7
|
+
export default function SignIn() {
|
|
8
|
+
const [email, setEmail] = useState('');
|
|
9
|
+
const [password, setPassword] = useState('');
|
|
10
|
+
const [message, setMessage] = useState('');
|
|
11
|
+
const [busy, setBusy] = useState(false);
|
|
12
|
+
async function submit(event: React.FormEvent<HTMLFormElement>) {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
setBusy(true);
|
|
15
|
+
try {
|
|
16
|
+
const result = await authClient.signIn.email({ email, password });
|
|
17
|
+
setMessage(result.error?.message ?? 'Signed in');
|
|
18
|
+
} catch {
|
|
19
|
+
setMessage('Unable to sign in');
|
|
20
|
+
} finally {
|
|
21
|
+
setBusy(false);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return (
|
|
25
|
+
<form onSubmit={submit} className="stack">
|
|
26
|
+
<h1>Sign in</h1>
|
|
27
|
+
<Label htmlFor="email">Email</Label>
|
|
28
|
+
<Input
|
|
29
|
+
id="email"
|
|
30
|
+
type="email"
|
|
31
|
+
autoComplete="email"
|
|
32
|
+
required
|
|
33
|
+
value={email}
|
|
34
|
+
onChange={(event) => setEmail(event.target.value)}
|
|
35
|
+
/>
|
|
36
|
+
<Label htmlFor="password">Password</Label>
|
|
37
|
+
<Input
|
|
38
|
+
id="password"
|
|
39
|
+
type="password"
|
|
40
|
+
autoComplete="current-password"
|
|
41
|
+
required
|
|
42
|
+
value={password}
|
|
43
|
+
onChange={(event) => setPassword(event.target.value)}
|
|
44
|
+
/>
|
|
45
|
+
<Button type="submit" disabled={busy}>
|
|
46
|
+
Sign in
|
|
47
|
+
</Button>
|
|
48
|
+
<p role="status">{message}</p>
|
|
49
|
+
</form>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Founded Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/assets/ui/UPSTREAM.json
CHANGED
|
@@ -10,24 +10,13 @@
|
|
|
10
10
|
"source": "https://ui.shadcn.com/r/styles/base-nova/input.json",
|
|
11
11
|
"sha256": "b4d1fa668ce203a2d78af7eb23e3769de303d46c983e3e40bed7018423efccb2"
|
|
12
12
|
},
|
|
13
|
-
"card": {
|
|
14
|
-
"source": "https://ui.shadcn.com/r/styles/base-nova/card.json",
|
|
15
|
-
"sha256": "a3b2cb98311bb9ce9475b6cf07d28b9a8eaac282ea6ff51ea77d1d3516947e54"
|
|
16
|
-
},
|
|
17
13
|
"label": {
|
|
18
14
|
"source": "https://ui.shadcn.com/r/styles/base-nova/label.json",
|
|
19
15
|
"sha256": "ef2ca2ddbd0eb67f3a0f59ee5d970c213172a8edc7bb2b28c9d69020bc6ba950"
|
|
20
|
-
},
|
|
21
|
-
"dialog": {
|
|
22
|
-
"source": "https://ui.shadcn.com/r/styles/base-nova/dialog.json",
|
|
23
|
-
"sha256": "ace3d5ba732f66e14bd1062306f9022a32040f7c168a697ebb483b4e80cbd7fd"
|
|
24
16
|
}
|
|
25
17
|
},
|
|
26
18
|
"adaptations": [
|
|
27
19
|
"The Base Nova web Button uses the local cn utility, an explicit React client boundary and a public variant export.",
|
|
28
|
-
"Native components are Anhedral-maintained React Native ports, isolated from DOM components and without React Native Reusables.",
|
|
29
|
-
"Native themes derive their colors from the generated shared semantic tokens; no separate native palette is installed.",
|
|
30
|
-
"Native Dialog restores focus to its actionable trigger on both iOS dismissal and Android close transitions.",
|
|
31
20
|
"Recovered Input and Label use the local cn utility; Input delegates keyboard focus styling to the existing shared global focus rule."
|
|
32
21
|
]
|
|
33
22
|
}
|