nomoss 0.0.1

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 (81) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +45 -0
  3. package/bin/nomoss +13 -0
  4. package/docs/code-documentation.md +36 -0
  5. package/docs/effect-native-development.md +55 -0
  6. package/docs/engine-design.md +93 -0
  7. package/docs/linting.md +88 -0
  8. package/docs/releasing.md +13 -0
  9. package/docs/resource-command-policy-stage.md +71 -0
  10. package/docs/resource-graph-mvp.md +31 -0
  11. package/docs/resource-graph-testing-approach.md +11 -0
  12. package/docs/resource-lifecycle-tracker.md +93 -0
  13. package/docs/testing.md +86 -0
  14. package/examples/upload-events/README.md +41 -0
  15. package/media/nomoss.gif +0 -0
  16. package/package.json +64 -0
  17. package/src/cli.ts +18 -0
  18. package/src/cliCommand.ts +186 -0
  19. package/src/cliRuntimeLayer.ts +49 -0
  20. package/src/core/index.ts +17 -0
  21. package/src/core/lifecycle.ts +127 -0
  22. package/src/core/model.ts +229 -0
  23. package/src/core/physicalNameStore.ts +226 -0
  24. package/src/core/planner.ts +645 -0
  25. package/src/core/resourceCommandPolicy.ts +79 -0
  26. package/src/core/resourceGraphBuilder.ts +167 -0
  27. package/src/core/resourceGraphStore.ts +288 -0
  28. package/src/core/resourceOutputResolver.ts +185 -0
  29. package/src/core/resourcePolicy.ts +77 -0
  30. package/src/core/resourceStackDefinition.ts +17 -0
  31. package/src/core/resourceStackLifecycle.ts +456 -0
  32. package/src/core/resourceStackOperations.ts +129 -0
  33. package/src/core/runtimeLayer.ts +73 -0
  34. package/src/core/stackWorkflowRenderer.ts +239 -0
  35. package/src/core/stateSecretService.ts +553 -0
  36. package/src/core/stateStore.ts +652 -0
  37. package/src/core/tracing.ts +26 -0
  38. package/src/index.ts +2 -0
  39. package/src/providers/aws/awsApply.ts +132 -0
  40. package/src/providers/aws/awsBucket.ts +329 -0
  41. package/src/providers/aws/awsBucketNotification.ts +351 -0
  42. package/src/providers/aws/awsBucketNotificationResourcePolicy.ts +251 -0
  43. package/src/providers/aws/awsBucketResourcePolicy.ts +198 -0
  44. package/src/providers/aws/awsProviderLayer.ts +274 -0
  45. package/src/providers/aws/awsQueue.ts +346 -0
  46. package/src/providers/aws/awsQueuePolicy.ts +419 -0
  47. package/src/providers/aws/awsQueuePolicyResourcePolicy.ts +215 -0
  48. package/src/providers/aws/awsQueueResourcePolicy.ts +270 -0
  49. package/src/providers/aws/awsReconciliation.ts +92 -0
  50. package/src/providers/aws/awsRefresh.ts +50 -0
  51. package/src/providers/aws/awsResourceLifecycle.ts +118 -0
  52. package/src/providers/aws/awsResourcePolicy.ts +83 -0
  53. package/src/providers/aws/awsResources.ts +274 -0
  54. package/src/providers/aws/awsRuntimeLayer.ts +21 -0
  55. package/src/providers/aws/awsSqsTransport.ts +33 -0
  56. package/src/providers/aws/awsStackLifecycle.ts +272 -0
  57. package/src/providers/aws/awsTagging.ts +186 -0
  58. package/src/providers/aws/constants.ts +3 -0
  59. package/src/providers/aws/index.ts +22 -0
  60. package/src/providers/aws/sampleStack.ts +65 -0
  61. package/src/providers/aws/stackWorkflow.ts +443 -0
  62. package/src/providers/index.ts +5 -0
  63. package/src/providers/provider.ts +5 -0
  64. package/src/providers/providerRuntimeLayer.ts +121 -0
  65. package/src/providers/resourceCommandPolicyLayer.ts +240 -0
  66. package/src/providers/stripe/index.ts +15 -0
  67. package/src/providers/stripe/stripeAccount.ts +139 -0
  68. package/src/providers/stripe/stripeBillingConfigurationExport.ts +180 -0
  69. package/src/providers/stripe/stripeBillingConfigurationExportResourcePolicy.ts +178 -0
  70. package/src/providers/stripe/stripeBillingPortalConfiguration.ts +153 -0
  71. package/src/providers/stripe/stripeBillingPortalConfigurationResourcePolicy.ts +177 -0
  72. package/src/providers/stripe/stripeCustomer.ts +148 -0
  73. package/src/providers/stripe/stripeCustomerResourcePolicy.ts +160 -0
  74. package/src/providers/stripe/stripePrice.ts +218 -0
  75. package/src/providers/stripe/stripePriceResourcePolicy.ts +151 -0
  76. package/src/providers/stripe/stripeProduct.ts +171 -0
  77. package/src/providers/stripe/stripeProductResourcePolicy.ts +161 -0
  78. package/src/providers/stripe/stripeResources.ts +454 -0
  79. package/src/providers/stripe/stripeRuntimeLayer.ts +131 -0
  80. package/src/providers/stripe/stripeWebhookEndpoint.ts +293 -0
  81. package/src/providers/stripe/stripeWebhookEndpointResourcePolicy.ts +198 -0
@@ -0,0 +1,553 @@
1
+ import {
2
+ Array as Arr,
3
+ Config,
4
+ Context,
5
+ Data,
6
+ Effect,
7
+ Layer,
8
+ Match,
9
+ Option,
10
+ Record,
11
+ Schema,
12
+ Stream,
13
+ } from "effect";
14
+
15
+ import { ChildProcess } from "effect/unstable/process";
16
+ import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
17
+
18
+ import { type ResourceNode, ResourceNodeSchema } from "./model.js";
19
+ import { type ResourceState, ResourceStateSchema } from "./stateStore.js";
20
+
21
+ /**
22
+ * The local resource-state file stores this reference after a provider has
23
+ * emitted a value that later provider updates require but must not retain in
24
+ * JSON. `StateSecretService` resolves it before lifecycle code receives the
25
+ * corresponding `ResourceNode`.
26
+ */
27
+ export const StateSecretReferenceSchema = Schema.TaggedStruct(
28
+ "NomossStateSecretRef",
29
+ {
30
+ key: Schema.NonEmptyString,
31
+ store: Schema.Literal("macos-keychain"),
32
+ },
33
+ );
34
+
35
+ export type StateSecretReference = Schema.Schema.Type<
36
+ typeof StateSecretReferenceSchema
37
+ >;
38
+
39
+ const ResourceOutputRecordSchema = Schema.Record(Schema.String, Schema.Json);
40
+
41
+ type ResourceOutputRecord = Schema.Schema.Type<
42
+ typeof ResourceOutputRecordSchema
43
+ >;
44
+
45
+ type StateSecretOutputUpdate = {
46
+ readonly output: Schema.Json;
47
+ readonly outputKey: string;
48
+ };
49
+
50
+ enum MacOSKeychainServiceName {
51
+ NomossState = "com.nomoss.state",
52
+ }
53
+
54
+ /**
55
+ * `ResourceStateStore` invokes this service while loading and saving each
56
+ * lifecycle record. Stripe webhook endpoint updates need the original signing
57
+ * secret even though Stripe does not return it again, so the selected macOS
58
+ * implementation restores it in memory and persists only its Keychain record.
59
+ */
60
+ export class StateSecretService extends Context.Service<StateSecretService>()(
61
+ "nomoss/core/stateSecretService",
62
+ {
63
+ make: Effect.gen(function* () {
64
+ const childProcessSpawner = yield* ChildProcessSpawner;
65
+
66
+ return {
67
+ persistStateSecrets: Effect.fn(
68
+ "StateSecretService.persistStateSecrets",
69
+ )(function* (
70
+ stack: string,
71
+ resourceStates: ReadonlyArray<ResourceState>,
72
+ ) {
73
+ const persistedResourceStates: ReadonlyArray<ResourceState> =
74
+ yield* Effect.forEach(resourceStates, (resourceState) =>
75
+ persistResourceStateSecrets(stack, resourceState).pipe(
76
+ Effect.provideService(ChildProcessSpawner, childProcessSpawner),
77
+ ),
78
+ );
79
+
80
+ return persistedResourceStates;
81
+ }),
82
+ restoreStateSecrets: Effect.fn(
83
+ "StateSecretService.restoreStateSecrets",
84
+ )(function* (resourceStates: ReadonlyArray<ResourceState>) {
85
+ const hydratedResourceStates: ReadonlyArray<ResourceState> =
86
+ yield* Effect.forEach(resourceStates, (resourceState) =>
87
+ restoreResourceStateSecrets(resourceState).pipe(
88
+ Effect.provideService(ChildProcessSpawner, childProcessSpawner),
89
+ ),
90
+ );
91
+
92
+ return hydratedResourceStates;
93
+ }),
94
+ };
95
+ }),
96
+ },
97
+ ) {}
98
+
99
+ /**
100
+ * A Keychain read or write failed for a state value that Stripe cannot recover
101
+ * from its endpoint API. Failing state handling preserves the signing secret
102
+ * instead of letting a later endpoint update silently drop it.
103
+ */
104
+ export class StateSecretServiceError extends Data.TaggedError(
105
+ "StateSecretServiceError",
106
+ )<{
107
+ readonly key: string;
108
+ readonly operation: "persist" | "restore" | "read" | "write";
109
+ readonly cause: unknown;
110
+ }> {}
111
+
112
+ const stateSecretReferenceFor = (
113
+ stack: string,
114
+ node: ResourceNode,
115
+ outputKey: string,
116
+ ): StateSecretReference =>
117
+ StateSecretReferenceSchema.make({
118
+ _tag: "NomossStateSecretRef",
119
+ key: `${stack}/${node.key.logicalId}/${outputKey}`,
120
+ store: "macos-keychain",
121
+ });
122
+
123
+ const resourceNodeWithOutputs = (
124
+ node: ResourceNode,
125
+ outputs: ResourceOutputRecord,
126
+ ) =>
127
+ ResourceNodeSchema.make({
128
+ key: node.key,
129
+ props: node.props,
130
+ schema: node.schema,
131
+ outputs,
132
+ });
133
+
134
+ const executeSecurity = Effect.fn("StateSecretService.executeSecurity")(
135
+ function* (
136
+ args: ReadonlyArray<string>,
137
+ key: string,
138
+ operation: "read" | "write",
139
+ ) {
140
+ const process = yield* ChildProcess.make("security", args).pipe(
141
+ Effect.mapError(
142
+ (cause) =>
143
+ new StateSecretServiceError({
144
+ key,
145
+ operation,
146
+ cause,
147
+ }),
148
+ ),
149
+ );
150
+ const [exitCode, stdout] = yield* Effect.all(
151
+ [
152
+ process.exitCode.pipe(
153
+ Effect.mapError(
154
+ (cause) =>
155
+ new StateSecretServiceError({
156
+ key,
157
+ operation,
158
+ cause,
159
+ }),
160
+ ),
161
+ ),
162
+ process.stdout.pipe(
163
+ Stream.decodeText(),
164
+ Stream.runFold(
165
+ () => "",
166
+ (output, chunk) => `${output}${chunk}`,
167
+ ),
168
+ Effect.mapError(
169
+ (cause) =>
170
+ new StateSecretServiceError({
171
+ key,
172
+ operation,
173
+ cause,
174
+ }),
175
+ ),
176
+ ),
177
+ ],
178
+ { concurrency: 2 },
179
+ );
180
+
181
+ return yield* Effect.succeed(stdout).pipe(
182
+ Effect.filterOrFail(
183
+ () => exitCode === 0,
184
+ () =>
185
+ new StateSecretServiceError({
186
+ key,
187
+ operation,
188
+ cause: { exitCode },
189
+ }),
190
+ ),
191
+ );
192
+ },
193
+ );
194
+
195
+ const writeMacOSKeychainSecret = (
196
+ reference: StateSecretReference,
197
+ value: string,
198
+ ) =>
199
+ executeSecurity(
200
+ [
201
+ "add-generic-password",
202
+ "-U",
203
+ "-a",
204
+ reference.key,
205
+ "-s",
206
+ MacOSKeychainServiceName.NomossState,
207
+ "-w",
208
+ value,
209
+ ],
210
+ reference.key,
211
+ "write",
212
+ ).pipe(Effect.scoped, Effect.asVoid);
213
+
214
+ const readMacOSKeychainSecret = Effect.fn(
215
+ "StateSecretService.readMacOSKeychainSecret",
216
+ )(function* (reference: StateSecretReference) {
217
+ const secret = yield* executeSecurity(
218
+ [
219
+ "find-generic-password",
220
+ "-a",
221
+ reference.key,
222
+ "-s",
223
+ MacOSKeychainServiceName.NomossState,
224
+ "-w",
225
+ ],
226
+ reference.key,
227
+ "read",
228
+ ).pipe(Effect.scoped);
229
+
230
+ return secret.replace(/\n$/, "");
231
+ });
232
+
233
+ const persistStateSecretOutput = Effect.fn(
234
+ "StateSecretService.persistStateSecretOutput",
235
+ )(function* (
236
+ stack: string,
237
+ node: ResourceNode,
238
+ outputKey: string,
239
+ output: Schema.Json,
240
+ ) {
241
+ const reference = Schema.decodeUnknownOption(StateSecretReferenceSchema)(
242
+ output,
243
+ );
244
+
245
+ return yield* Option.match(reference, {
246
+ onNone: () =>
247
+ Effect.gen(function* () {
248
+ const secret = yield* Schema.decodeUnknownEffect(Schema.String)(
249
+ output,
250
+ ).pipe(
251
+ Effect.mapError(
252
+ (cause) =>
253
+ new StateSecretServiceError({
254
+ key: `${node.key.logicalId}/${outputKey}`,
255
+ operation: "persist",
256
+ cause,
257
+ }),
258
+ ),
259
+ );
260
+ const persistedReference = stateSecretReferenceFor(
261
+ stack,
262
+ node,
263
+ outputKey,
264
+ );
265
+
266
+ yield* writeMacOSKeychainSecret(persistedReference, secret);
267
+
268
+ return Option.some<StateSecretOutputUpdate>({
269
+ output: persistedReference,
270
+ outputKey,
271
+ });
272
+ }),
273
+ onSome: () =>
274
+ Effect.succeed(
275
+ Option.some<StateSecretOutputUpdate>({ output, outputKey }),
276
+ ),
277
+ });
278
+ });
279
+
280
+ const restoreStateSecretOutput = Effect.fn(
281
+ "StateSecretService.restoreStateSecretOutput",
282
+ )(function* (node: ResourceNode, outputKey: string, output: Schema.Json) {
283
+ const reference = Schema.decodeUnknownOption(StateSecretReferenceSchema)(
284
+ output,
285
+ );
286
+
287
+ return yield* Option.match(reference, {
288
+ onNone: () =>
289
+ Schema.decodeUnknownEffect(Schema.String)(output).pipe(
290
+ Effect.mapError(
291
+ (cause) =>
292
+ new StateSecretServiceError({
293
+ key: `${node.key.logicalId}/${outputKey}`,
294
+ operation: "restore",
295
+ cause,
296
+ }),
297
+ ),
298
+ Effect.map(() =>
299
+ Option.some<StateSecretOutputUpdate>({ output, outputKey }),
300
+ ),
301
+ ),
302
+ onSome: (reference) =>
303
+ Effect.map(readMacOSKeychainSecret(reference), (secret) =>
304
+ Option.some<StateSecretOutputUpdate>({ output: secret, outputKey }),
305
+ ),
306
+ });
307
+ });
308
+
309
+ const persistResourceNodeSecrets = Effect.fn(
310
+ "StateSecretService.persistResourceNodeSecrets",
311
+ )(function* (stack: string, node: ResourceNode) {
312
+ const outputs = yield* Schema.decodeUnknownEffect(ResourceOutputRecordSchema)(
313
+ node.outputs,
314
+ ).pipe(
315
+ Effect.mapError(
316
+ (cause) =>
317
+ new StateSecretServiceError({
318
+ key: node.key.logicalId,
319
+ operation: "persist",
320
+ cause,
321
+ }),
322
+ ),
323
+ );
324
+ const persistedResourceNode: ResourceNode = yield* Effect.forEach(
325
+ node.schema.stateSecretOutputKeys,
326
+ (outputKey) =>
327
+ Option.fromUndefinedOr(outputs[outputKey]).pipe(
328
+ Option.match({
329
+ onNone: () => Effect.succeed(Option.none<StateSecretOutputUpdate>()),
330
+ onSome: (output) =>
331
+ persistStateSecretOutput(stack, node, outputKey, output),
332
+ }),
333
+ ),
334
+ ).pipe(
335
+ Effect.map((outputUpdates) =>
336
+ resourceNodeWithOutputs(
337
+ node,
338
+ Arr.reduce(outputUpdates, outputs, (currentOutputs, outputUpdate) =>
339
+ Option.match(outputUpdate, {
340
+ onNone: () => currentOutputs,
341
+ onSome: ({ output, outputKey }) =>
342
+ Record.set(currentOutputs, outputKey, output),
343
+ }),
344
+ ),
345
+ ),
346
+ ),
347
+ );
348
+
349
+ return persistedResourceNode;
350
+ });
351
+
352
+ const restoreResourceNodeSecrets = Effect.fn(
353
+ "StateSecretService.restoreResourceNodeSecrets",
354
+ )(function* (node: ResourceNode) {
355
+ const outputs = yield* Schema.decodeUnknownEffect(ResourceOutputRecordSchema)(
356
+ node.outputs,
357
+ ).pipe(
358
+ Effect.mapError(
359
+ (cause) =>
360
+ new StateSecretServiceError({
361
+ key: node.key.logicalId,
362
+ operation: "restore",
363
+ cause,
364
+ }),
365
+ ),
366
+ );
367
+ const restoredResourceNode: ResourceNode = yield* Effect.forEach(
368
+ node.schema.stateSecretOutputKeys,
369
+ (outputKey) =>
370
+ Option.fromUndefinedOr(outputs[outputKey]).pipe(
371
+ Option.match({
372
+ onNone: () => Effect.succeed(Option.none<StateSecretOutputUpdate>()),
373
+ onSome: (output) => restoreStateSecretOutput(node, outputKey, output),
374
+ }),
375
+ ),
376
+ ).pipe(
377
+ Effect.map((outputUpdates) =>
378
+ resourceNodeWithOutputs(
379
+ node,
380
+ Arr.reduce(outputUpdates, outputs, (currentOutputs, outputUpdate) =>
381
+ Option.match(outputUpdate, {
382
+ onNone: () => currentOutputs,
383
+ onSome: ({ output, outputKey }) =>
384
+ Record.set(currentOutputs, outputKey, output),
385
+ }),
386
+ ),
387
+ ),
388
+ ),
389
+ );
390
+
391
+ return restoredResourceNode;
392
+ });
393
+
394
+ const persistResourceStateSecrets = (
395
+ stack: string,
396
+ resourceState: ResourceState,
397
+ ) =>
398
+ Match.value(resourceState).pipe(
399
+ Match.when({ _tag: "Updating" }, (updating) =>
400
+ Effect.zipWith(
401
+ persistResourceNodeSecrets(stack, updating.node),
402
+ persistResourceNodeSecrets(stack, updating.previous),
403
+ (node, previous) =>
404
+ ResourceStateSchema.make({
405
+ _tag: "Updating",
406
+ startedAt: updating.startedAt,
407
+ lastFailure: updating.lastFailure,
408
+ node,
409
+ previous,
410
+ }),
411
+ ),
412
+ ),
413
+ Match.when({ _tag: "Creating" }, (creating) =>
414
+ Effect.map(persistResourceNodeSecrets(stack, creating.node), (node) =>
415
+ ResourceStateSchema.make({
416
+ _tag: "Creating",
417
+ startedAt: creating.startedAt,
418
+ lastFailure: creating.lastFailure,
419
+ node,
420
+ }),
421
+ ),
422
+ ),
423
+ Match.when({ _tag: "Created" }, (created) =>
424
+ Effect.map(persistResourceNodeSecrets(stack, created.node), (node) =>
425
+ ResourceStateSchema.make({
426
+ _tag: "Created",
427
+ completedAt: created.completedAt,
428
+ node,
429
+ }),
430
+ ),
431
+ ),
432
+ Match.when({ _tag: "Updated" }, (updated) =>
433
+ Effect.map(persistResourceNodeSecrets(stack, updated.node), (node) =>
434
+ ResourceStateSchema.make({
435
+ _tag: "Updated",
436
+ completedAt: updated.completedAt,
437
+ node,
438
+ }),
439
+ ),
440
+ ),
441
+ Match.when({ _tag: "Deleting" }, (deleting) =>
442
+ Effect.map(persistResourceNodeSecrets(stack, deleting.node), (node) =>
443
+ ResourceStateSchema.make({
444
+ _tag: "Deleting",
445
+ startedAt: deleting.startedAt,
446
+ lastFailure: deleting.lastFailure,
447
+ node,
448
+ }),
449
+ ),
450
+ ),
451
+ Match.exhaustive,
452
+ );
453
+
454
+ const restoreResourceStateSecrets = (resourceState: ResourceState) =>
455
+ Match.value(resourceState).pipe(
456
+ Match.when({ _tag: "Updating" }, (updating) =>
457
+ Effect.zipWith(
458
+ restoreResourceNodeSecrets(updating.node),
459
+ restoreResourceNodeSecrets(updating.previous),
460
+ (node, previous) =>
461
+ ResourceStateSchema.make({
462
+ _tag: "Updating",
463
+ startedAt: updating.startedAt,
464
+ lastFailure: updating.lastFailure,
465
+ node,
466
+ previous,
467
+ }),
468
+ ),
469
+ ),
470
+ Match.when({ _tag: "Creating" }, (creating) =>
471
+ Effect.map(restoreResourceNodeSecrets(creating.node), (node) =>
472
+ ResourceStateSchema.make({
473
+ _tag: "Creating",
474
+ startedAt: creating.startedAt,
475
+ lastFailure: creating.lastFailure,
476
+ node,
477
+ }),
478
+ ),
479
+ ),
480
+ Match.when({ _tag: "Created" }, (created) =>
481
+ Effect.map(restoreResourceNodeSecrets(created.node), (node) =>
482
+ ResourceStateSchema.make({
483
+ _tag: "Created",
484
+ completedAt: created.completedAt,
485
+ node,
486
+ }),
487
+ ),
488
+ ),
489
+ Match.when({ _tag: "Updated" }, (updated) =>
490
+ Effect.map(restoreResourceNodeSecrets(updated.node), (node) =>
491
+ ResourceStateSchema.make({
492
+ _tag: "Updated",
493
+ completedAt: updated.completedAt,
494
+ node,
495
+ }),
496
+ ),
497
+ ),
498
+ Match.when({ _tag: "Deleting" }, (deleting) =>
499
+ Effect.map(restoreResourceNodeSecrets(deleting.node), (node) =>
500
+ ResourceStateSchema.make({
501
+ _tag: "Deleting",
502
+ startedAt: deleting.startedAt,
503
+ lastFailure: deleting.lastFailure,
504
+ node,
505
+ }),
506
+ ),
507
+ ),
508
+ Match.exhaustive,
509
+ );
510
+
511
+ /**
512
+ * General Nomoss runtime composition has no selected external secret store.
513
+ * This service keeps ordinary state files unchanged until a CLI or provider
514
+ * runtime explicitly chooses the macOS Keychain implementation.
515
+ */
516
+ export const StateSecretServiceDefaultLayer = Layer.succeed(
517
+ StateSecretService,
518
+ {
519
+ persistStateSecrets: (_stack, resourceStates) =>
520
+ Effect.succeed(resourceStates),
521
+ restoreStateSecrets: (resourceStates) => Effect.succeed(resourceStates),
522
+ },
523
+ );
524
+
525
+ /**
526
+ * CLI and provider runtime composition reads `NOMOSS_STATE_SECRET_STORE` so
527
+ * local Stripe lifecycle runs can use Keychain records without changing the
528
+ * regular file-state contract for other executions.
529
+ */
530
+ export const ConfiguredStateSecretServiceLayer = Layer.unwrap(
531
+ Effect.gen(function* () {
532
+ const store = yield* Config.literals(
533
+ ["none", "macos-keychain"],
534
+ "NOMOSS_STATE_SECRET_STORE",
535
+ ).pipe(Config.withDefault("none"));
536
+
537
+ return Match.value(store).pipe(
538
+ Match.when("macos-keychain", () => MacOSKeychainStateSecretServiceLayer),
539
+ Match.when("none", () => StateSecretServiceDefaultLayer),
540
+ Match.exhaustive,
541
+ );
542
+ }),
543
+ );
544
+
545
+ /**
546
+ * Local Stripe lifecycle runs receive the Keychain implementation only when
547
+ * `NOMOSS_STATE_SECRET_STORE` selects it. The login Keychain retains the
548
+ * signing secret while the resource-state file retains its stable reference.
549
+ */
550
+ export const MacOSKeychainStateSecretServiceLayer = Layer.effect(
551
+ StateSecretService,
552
+ StateSecretService.make,
553
+ );