@geekmidas/constructs 10.0.0-alpha.11 → 10.0.0-alpha.111
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 +222 -158
- package/dist/Construct-BQALFCh2.d.cts +230 -0
- package/dist/Construct-BQALFCh2.d.cts.map +1 -0
- package/dist/{Construct-BD5neF7w.mjs → Construct-CKUA-CTA.mjs} +35 -35
- package/dist/Construct-CKUA-CTA.mjs.map +1 -0
- package/dist/{Construct-CyS3RpTL.cjs → Construct-DEOVauyA.cjs} +55 -49
- package/dist/Construct-DEOVauyA.cjs.map +1 -0
- package/dist/Construct-QXnl3VqT.d.mts +230 -0
- package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
- package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-CQJqqkhY.d.mts} +17 -11
- package/dist/Cron-CQJqqkhY.d.mts.map +1 -0
- package/dist/{Cron-dh4rUgib.d.mts → Cron-DI3nKoic.d.cts} +17 -11
- package/dist/Cron-DI3nKoic.d.cts.map +1 -0
- package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BXTG10u5.cjs} +47 -31
- package/dist/CronBuilder-BXTG10u5.cjs.map +1 -0
- package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-D3sF9tS_.mjs} +37 -21
- package/dist/CronBuilder-D3sF9tS_.mjs.map +1 -0
- package/dist/CronBuilder-Xx_zakuc.d.mts +47 -0
- package/dist/CronBuilder-Xx_zakuc.d.mts.map +1 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
- package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
- package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-BWyKCa2x.d.cts} +130 -100
- package/dist/Endpoint-BWyKCa2x.d.cts.map +1 -0
- package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-CrE9Ppdk.d.mts} +130 -100
- package/dist/Endpoint-CrE9Ppdk.d.mts.map +1 -0
- package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-gPXhHKhJ.mjs} +208 -100
- package/dist/Endpoint-gPXhHKhJ.mjs.map +1 -0
- package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-yhR2T2Wt.cjs} +248 -122
- package/dist/Endpoint-yhR2T2Wt.cjs.map +1 -0
- package/dist/{index-lAO9egTb.d.mts → EndpointFactory-BV-nfnaP.d.mts} +85 -136
- package/dist/EndpointFactory-BV-nfnaP.d.mts.map +1 -0
- package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-BVv6EIDu.cjs} +98 -112
- package/dist/EndpointFactory-BVv6EIDu.cjs.map +1 -0
- package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-C1-IBwm4.d.cts} +84 -135
- package/dist/EndpointFactory-C1-IBwm4.d.cts.map +1 -0
- package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-Cs8IHvwF.mjs} +62 -76
- package/dist/EndpointFactory-Cs8IHvwF.mjs.map +1 -0
- package/dist/Function-DuqGcbOI.d.mts +76 -0
- package/dist/Function-DuqGcbOI.d.mts.map +1 -0
- package/dist/Function-Pu-1kKZz.d.cts +76 -0
- package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-CN1jjUBJ.cjs} +115 -71
- package/dist/HonoEndpointAdaptor-CN1jjUBJ.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-euH1oSdY.mjs} +105 -64
- package/dist/HonoEndpointAdaptor-euH1oSdY.mjs.map +1 -0
- package/dist/Queue-BhuofM3k.cjs +109 -0
- package/dist/Queue-BhuofM3k.cjs.map +1 -0
- package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
- package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
- package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
- package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
- package/dist/Queue-cmhqEBOB.mjs +104 -0
- package/dist/Queue-cmhqEBOB.mjs.map +1 -0
- package/dist/QueueBuilder-Cx9lKC5d.d.mts +75 -0
- package/dist/QueueBuilder-Cx9lKC5d.d.mts.map +1 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs +118 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs.map +1 -0
- package/dist/QueueBuilder-DdU2klPu.cjs +135 -0
- package/dist/QueueBuilder-DdU2klPu.cjs.map +1 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
- package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
- package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
- package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
- package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
- package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
- package/dist/SubscriberBuilder-4DWe9feX.d.mts +67 -0
- package/dist/SubscriberBuilder-4DWe9feX.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DRXfxWn_.mjs} +50 -24
- package/dist/SubscriberBuilder-DRXfxWn_.mjs.map +1 -0
- package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-M2EAgQhC.cjs} +61 -36
- package/dist/SubscriberBuilder-M2EAgQhC.cjs.map +1 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
- package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
- package/dist/Topic-D2R0r24C.mjs +99 -0
- package/dist/Topic-D2R0r24C.mjs.map +1 -0
- package/dist/Topic-DwS3QO0m.cjs +104 -0
- package/dist/Topic-DwS3QO0m.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +200 -246
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +58 -62
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +59 -63
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +171 -219
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +3 -10
- package/dist/adaptors/hono.d.cts +7 -16
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +9 -18
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +2 -10
- package/dist/adaptors/testing.cjs +765 -99
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +351 -54
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +351 -54
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +726 -78
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BMCJN30Y.d.cts +268 -0
- package/dist/auth-BMCJN30Y.d.cts.map +1 -0
- package/dist/auth-D_0788uW.d.mts +268 -0
- package/dist/auth-D_0788uW.d.mts.map +1 -0
- package/dist/auth.cjs +301 -33
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -108
- package/dist/auth.d.mts +2 -108
- package/dist/auth.mjs +289 -27
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-BrRz3fEB.d.mts → cache-5QZzh5Er.d.mts} +3 -6
- package/dist/cache-5QZzh5Er.d.mts.map +1 -0
- package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
- package/dist/cache-DnGDGly3.d.cts.map +1 -0
- package/dist/cache.cjs +68 -2
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.cts +1 -2
- package/dist/cache.d.mts +1 -2
- package/dist/cache.mjs +67 -2
- package/dist/cache.mjs.map +1 -0
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
- package/dist/clone-EKNovYHu.mjs.map +1 -0
- package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
- package/dist/clone-UGJpvQnL.cjs.map +1 -0
- package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
- package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
- package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-ZvYQbivO.d.mts} +42 -11
- package/dist/construct-interface-ZvYQbivO.d.mts.map +1 -0
- package/dist/construct-interface.cjs +113 -7
- package/dist/construct-interface.cjs.map +1 -0
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +106 -2
- package/dist/construct-interface.mjs.map +1 -0
- package/dist/credential-DYymbp_7.cjs +257 -0
- package/dist/credential-DYymbp_7.cjs.map +1 -0
- package/dist/credential-DfSAOOdY.mjs +222 -0
- package/dist/credential-DfSAOOdY.mjs.map +1 -0
- package/dist/credential.cjs +8 -96
- package/dist/credential.d.cts +2 -61
- package/dist/credential.d.mts +2 -61
- package/dist/credential.mjs +2 -94
- package/dist/crons/index.cjs +129 -7
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +45 -11
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +45 -11
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +127 -8
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +4 -181
- package/dist/database/kysely.d.cts +2 -152
- package/dist/database/kysely.d.mts +2 -152
- package/dist/database/kysely.mjs +2 -180
- package/dist/email.cjs +25 -12
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +3 -7
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +4 -8
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +16 -3
- package/dist/email.mjs.map +1 -1
- package/dist/encryption.cjs +96 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +117 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +117 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +83 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +20 -16
- package/dist/endpoints/index.d.cts +105 -7
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +105 -7
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -10
- package/dist/external-api.cjs +106 -0
- package/dist/external-api.cjs.map +1 -0
- package/dist/external-api.d.cts +2 -0
- package/dist/external-api.d.mts +2 -0
- package/dist/external-api.mjs +103 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/fake-DqKo8INJ.d.mts +201 -0
- package/dist/fake-DqKo8INJ.d.mts.map +1 -0
- package/dist/fake-Dvion_Fh.d.cts +201 -0
- package/dist/fake-Dvion_Fh.d.cts.map +1 -0
- package/dist/file-server.cjs +42 -10
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +6 -10
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +6 -10
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +34 -2
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +3 -6
- package/dist/functions/index.d.cts +3 -4
- package/dist/functions/index.d.mts +3 -4
- package/dist/functions/index.mjs +2 -6
- package/dist/{functions-14lpEFL4.mjs → functions-CTI-hDem.mjs} +376 -238
- package/dist/{functions-14lpEFL4.mjs.map → functions-CTI-hDem.mjs.map} +1 -1
- package/dist/{functions-i_la-N5r.cjs → functions-D7O5SGVc.cjs} +414 -264
- package/dist/functions-D7O5SGVc.cjs.map +1 -0
- package/dist/index-B13kQB_U.d.mts +115 -0
- package/dist/index-B13kQB_U.d.mts.map +1 -0
- package/dist/index-BuzRvKOQ.d.cts +115 -0
- package/dist/index-BuzRvKOQ.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.cts +79 -0
- package/dist/index-CeEtxDmK.d.cts.map +1 -0
- package/dist/index-CeEtxDmK.d.mts +79 -0
- package/dist/index-CeEtxDmK.d.mts.map +1 -0
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +27 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +27 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/kms-B-Hm3d5r.cjs +85 -0
- package/dist/kms-B-Hm3d5r.cjs.map +1 -0
- package/dist/kms-BdUlMJEZ.mjs +85 -0
- package/dist/kms-BdUlMJEZ.mjs.map +1 -0
- package/dist/kysely-B3zfg9ti.cjs +383 -0
- package/dist/kysely-B3zfg9ti.cjs.map +1 -0
- package/dist/kysely-B_0BAr0T.mjs +370 -0
- package/dist/kysely-B_0BAr0T.mjs.map +1 -0
- package/dist/kysely-D0bpzgPs.d.cts +175 -0
- package/dist/kysely-D0bpzgPs.d.cts.map +1 -0
- package/dist/kysely-DKwnl0nf.d.mts +175 -0
- package/dist/kysely-DKwnl0nf.d.mts.map +1 -0
- package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +74 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +73 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +73 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +73 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +18 -10
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +3 -7
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +3 -7
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +11 -3
- package/dist/object-storage.mjs.map +1 -1
- package/dist/queue/index.cjs +6 -189
- package/dist/queue/index.d.cts +3 -60
- package/dist/queue/index.d.mts +3 -60
- package/dist/queue/index.mjs +3 -186
- package/dist/random-password.cjs +86 -0
- package/dist/random-password.cjs.map +1 -0
- package/dist/random-password.d.cts +30 -0
- package/dist/random-password.d.cts.map +1 -0
- package/dist/random-password.d.mts +30 -0
- package/dist/random-password.d.mts.map +1 -0
- package/dist/random-password.mjs +84 -0
- package/dist/random-password.mjs.map +1 -0
- package/dist/{lazyAccessors-BoJN3SMd.mjs → readRequestBody-BTIl3k-D.mjs} +117 -60
- package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
- package/dist/readRequestBody-Dej_L3c4.cjs +342 -0
- package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
- package/dist/requestLogger-BZcXwdBs.cjs +207 -0
- package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
- package/dist/requestLogger-pA4gi3E1.mjs +178 -0
- package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
- package/dist/rest-api.cjs +90 -59
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +70 -42
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +70 -42
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +82 -51
- package/dist/rest-api.mjs.map +1 -1
- package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
- package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
- package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
- package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
- package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
- package/dist/shutdown-BMJmAhSt.cjs +38 -0
- package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
- package/dist/shutdown-C7xa8x9S.mjs +27 -0
- package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
- package/dist/site.cjs +33 -7
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +17 -7
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +17 -7
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +29 -3
- package/dist/site.mjs.map +1 -1
- package/dist/stages-BSCF19o2.d.cts +56 -0
- package/dist/stages-BSCF19o2.d.cts.map +1 -0
- package/dist/stages-BSCF19o2.d.mts +56 -0
- package/dist/stages-BSCF19o2.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +118 -6
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +51 -6
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +51 -6
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +115 -5
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/surfaceEnv-CNimK76p.cjs +56 -0
- package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
- package/dist/telemetry-B48RLjyk.d.cts +40 -0
- package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
- package/dist/telemetry-BEoBn6GO.d.mts +40 -0
- package/dist/telemetry-BEoBn6GO.d.mts.map +1 -0
- package/dist/telemetry.cjs +56 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +55 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/topic/index.cjs +3 -137
- package/dist/topic/index.d.cts +2 -4
- package/dist/topic/index.d.mts +2 -4
- package/dist/topic/index.mjs +2 -134
- package/dist/tracing-Bbj1uoFJ.mjs +127 -0
- package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
- package/dist/tracing-C0ooU0V2.cjs +150 -0
- package/dist/tracing-C0ooU0V2.cjs.map +1 -0
- package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
- package/dist/types-DMuSQeLL.d.cts.map +1 -0
- package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
- package/dist/types-DMuSQeLL.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -0
- package/dist/worker.cjs +59 -34
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +70 -45
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +71 -46
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +54 -29
- package/dist/worker.mjs.map +1 -1
- package/package.json +106 -42
- package/dist/Construct-BD5neF7w.mjs.map +0 -1
- package/dist/Construct-C0ijr2qp.d.cts +0 -117
- package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
- package/dist/Construct-Ct8nalEi.d.mts +0 -117
- package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
- package/dist/Construct-CyS3RpTL.cjs.map +0 -1
- package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
- package/dist/Cron-dh4rUgib.d.mts.map +0 -1
- package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
- package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
- package/dist/CronBuilder-CGgY2080.d.mts +0 -44
- package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
- package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
- package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
- package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
- package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
- package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
- package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
- package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
- package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
- package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
- package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
- package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
- package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
- package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
- package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
- package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
- package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
- package/dist/Topic-19QeHBIR.d.cts +0 -91
- package/dist/Topic-19QeHBIR.d.cts.map +0 -1
- package/dist/Topic-DuFeqkBh.d.mts +0 -91
- package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache-0ANvRQnD.mjs +0 -51
- package/dist/cache-0ANvRQnD.mjs.map +0 -1
- package/dist/cache-3WSvAulx.cjs +0 -57
- package/dist/cache-3WSvAulx.cjs.map +0 -1
- package/dist/cache-BrRz3fEB.d.mts.map +0 -1
- package/dist/cache-BtZY_tHe.d.cts.map +0 -1
- package/dist/clone-DblgEZZa.mjs.map +0 -1
- package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
- package/dist/construct-interface-BfjcOD_E.cjs +0 -117
- package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
- package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
- package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
- package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
- package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-i_la-N5r.cjs.map +0 -1
- package/dist/index-Bd5FqCoe.d.cts.map +0 -1
- package/dist/index-BknhM6Ux.d.mts +0 -31
- package/dist/index-BknhM6Ux.d.mts.map +0 -1
- package/dist/index-CBSfrowv.d.cts +0 -31
- package/dist/index-CBSfrowv.d.cts.map +0 -1
- package/dist/index-D24Xm79M.d.cts +0 -171
- package/dist/index-D24Xm79M.d.cts.map +0 -1
- package/dist/index-_ajboYxK.d.mts +0 -171
- package/dist/index-_ajboYxK.d.mts.map +0 -1
- package/dist/index-lAO9egTb.d.mts.map +0 -1
- package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
- package/dist/lazyAccessors-e3j2oE2m.cjs +0 -274
- package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
- package/dist/processAudits-CGqttuXm.cjs +0 -92
- package/dist/processAudits-CGqttuXm.cjs.map +0 -1
- package/dist/processAudits-Dmts9H_b.mjs +0 -80
- package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
- package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
- package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
- package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
- package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
- package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
- package/dist/types-BlAkSuGI.d.cts.map +0 -1
- package/dist/types-aKksMEWL.d.mts.map +0 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
2
|
+
import { parseSchema } from "@geekmidas/schema/parser";
|
|
3
|
+
//#region src/fake.ts
|
|
4
|
+
/**
|
|
5
|
+
* Marks a fake. A registered symbol, so a fake built by a second copy of this
|
|
6
|
+
* package — a linked workspace, two versions in a lockfile — is still one.
|
|
7
|
+
*/
|
|
8
|
+
const FAKE = Symbol.for("@geekmidas/constructs/fake");
|
|
9
|
+
/**
|
|
10
|
+
* Build the fake `test/fakes/<id>.ts` default-exports.
|
|
11
|
+
*
|
|
12
|
+
* Pass the construct's type to have the value checked against its schema —
|
|
13
|
+
* `fake.app<typeof polar>(…)`, `fake.credential<typeof stripe>(…)`.
|
|
14
|
+
*/
|
|
15
|
+
const fake = {
|
|
16
|
+
/** A working implementation of an external API, kept beside the tests that use it. */
|
|
17
|
+
app(handler, options) {
|
|
18
|
+
return {
|
|
19
|
+
[FAKE]: true,
|
|
20
|
+
kind: "app",
|
|
21
|
+
handler,
|
|
22
|
+
credentials: options.credentials
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
/** A local server an external API's provider publishes — `stripe/stripe-mock`. */
|
|
26
|
+
image(image, options) {
|
|
27
|
+
return {
|
|
28
|
+
[FAKE]: true,
|
|
29
|
+
kind: "image",
|
|
30
|
+
image,
|
|
31
|
+
port: options.port,
|
|
32
|
+
credentials: options.credentials
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* A `Credential`'s value on the test stage and under `gkm dev --fake`, as
|
|
37
|
+
* its schema takes it — a string, or the object a JSON credential holds.
|
|
38
|
+
* It is validated where it is read, like the real one.
|
|
39
|
+
*/
|
|
40
|
+
credential(credentials) {
|
|
41
|
+
return {
|
|
42
|
+
[FAKE]: true,
|
|
43
|
+
kind: "credential",
|
|
44
|
+
credentials
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */
|
|
49
|
+
function isFake(value) {
|
|
50
|
+
return typeof value === "object" && value !== null && value[FAKE] === true;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/credential.ts
|
|
54
|
+
/**
|
|
55
|
+
* `Credential` — a third-party credential with a shape.
|
|
56
|
+
*
|
|
57
|
+
* The answer to the design's first open question, "where does `Secret` sit?".
|
|
58
|
+
* It sits beside a secret rather than replacing it, because the two differ by
|
|
59
|
+
* *lifecycle* and that is the only difference worth two kinds for: a secret is
|
|
60
|
+
* generated and rotated by the platform and is one opaque string, while a
|
|
61
|
+
* credential is issued by someone else, arrives with several fields, and is
|
|
62
|
+
* worth validating on the way in.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* export const stripe = new Credential('Stripe', {
|
|
66
|
+
* schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // in a handler — no await, already parsed and validated
|
|
70
|
+
* services.stripe.secretKey
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* **Nothing about it is async at the call site**, which is the part that looks
|
|
74
|
+
* like it should be hard and is not. `Service.register()` may return a promise
|
|
75
|
+
* and `ServiceDiscovery` awaits every one before a handler runs, so fetching a
|
|
76
|
+
* value and validating it — including when a StandardSchema's `~standard.validate`
|
|
77
|
+
* returns a promise of its own — both happen inside that existing seam.
|
|
78
|
+
*
|
|
79
|
+
* **One key holding JSON, not one key per field.** That is the shape a secret
|
|
80
|
+
* manager stores, and it is the only shape that works with an arbitrary
|
|
81
|
+
* StandardSchema: the spec has no introspection API, so enumerating a schema's
|
|
82
|
+
* fields means reaching into one library's internals (`.shape`) and being wrong
|
|
83
|
+
* for every other.
|
|
84
|
+
*
|
|
85
|
+
* **A test stage is handed a fake.** Nobody issues a credential to a test
|
|
86
|
+
* stage set up fresh — CI's auto-setup stores no third party's values — so a
|
|
87
|
+
* credential a test reaches has a fake at `test/fakes/<id>.ts`, the folder an
|
|
88
|
+
* `ExternalApi`'s fake lives in:
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* // test/fakes/stripe.ts
|
|
92
|
+
* import { fake } from '@geekmidas/constructs/credential';
|
|
93
|
+
* import type { stripe } from '../../constructs/stripe';
|
|
94
|
+
*
|
|
95
|
+
* export default fake.credential<typeof stripe>({
|
|
96
|
+
* secretKey: 'sk_test_fake',
|
|
97
|
+
* webhookSecret: 'whsec_fake',
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* gkm reads it for `gkm test` and `gkm dev --fake` only, and the construct
|
|
102
|
+
* never names it, so it is in no deployed bundle and a deploy still refuses a
|
|
103
|
+
* stage without the real value.
|
|
104
|
+
*/
|
|
105
|
+
var Credential = class {
|
|
106
|
+
options;
|
|
107
|
+
id;
|
|
108
|
+
service;
|
|
109
|
+
/**
|
|
110
|
+
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
111
|
+
* target publishes and the key the client reads cannot drift.
|
|
112
|
+
*/
|
|
113
|
+
keys;
|
|
114
|
+
/**
|
|
115
|
+
* The resolved value, held as the *promise* rather than the value.
|
|
116
|
+
*
|
|
117
|
+
* Caching the promise is what makes two concurrent registrations share one
|
|
118
|
+
* resolution: caching the value would let both start before either finished,
|
|
119
|
+
* which is a duplicated fetch every cold start rather than never.
|
|
120
|
+
*/
|
|
121
|
+
resolved;
|
|
122
|
+
constructor(id, options) {
|
|
123
|
+
this.options = options;
|
|
124
|
+
const canonical = canonicalId(id);
|
|
125
|
+
this.id = canonical;
|
|
126
|
+
this.keys = { credentials: provideKey(canonical, "credentials") };
|
|
127
|
+
this.service = {
|
|
128
|
+
serviceName: serviceKey(canonical),
|
|
129
|
+
register: (registerOptions) => this.connect(registerOptions)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* What the stage's `<ID>_CREDENTIALS` must look like — the schema the value
|
|
134
|
+
* is validated against where it is read. Public so a tool setting the value
|
|
135
|
+
* (`gkm secrets:add`) can check it, and describe its fields, before it is
|
|
136
|
+
* stored rather than at the first request.
|
|
137
|
+
*/
|
|
138
|
+
get credentialsSchema() {
|
|
139
|
+
return this.options.schema;
|
|
140
|
+
}
|
|
141
|
+
declare() {
|
|
142
|
+
return [{
|
|
143
|
+
kind: "credential",
|
|
144
|
+
id: this.id,
|
|
145
|
+
provides: [this.keys.credentials]
|
|
146
|
+
}];
|
|
147
|
+
}
|
|
148
|
+
connect(options) {
|
|
149
|
+
if (this.options.refresh) return this.resolve(options);
|
|
150
|
+
this.resolved ??= this.resolve(options);
|
|
151
|
+
return this.resolved;
|
|
152
|
+
}
|
|
153
|
+
resolve(options) {
|
|
154
|
+
return readCredentials(this.id, this.keys.credentials, this.options.schema, options.envParser);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* A credentials key, read and validated against its schema.
|
|
159
|
+
*
|
|
160
|
+
* Shared with every construct that holds a third party's credentials — an
|
|
161
|
+
* `ExternalApi` reads its own the same way — so the shape a stage stores and
|
|
162
|
+
* the error a bad value raises are the same everywhere.
|
|
163
|
+
*
|
|
164
|
+
* @throws {MalformedCredential} when the value is not what the schema says.
|
|
165
|
+
*/
|
|
166
|
+
async function readCredentials(id, key, schema, envParser) {
|
|
167
|
+
const { raw } = envParser.create((get) => ({ raw: get(key).string() })).parse();
|
|
168
|
+
try {
|
|
169
|
+
return await parseSchema(schema, decodeCredentials(raw));
|
|
170
|
+
} catch (issues) {
|
|
171
|
+
throw new MalformedCredential(id, key, issues);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The raw environment value as the thing the schema should see.
|
|
176
|
+
*
|
|
177
|
+
* JSON when it is JSON, and the string itself when it is not — a credential
|
|
178
|
+
* with a single opaque field is ordinary, and requiring `"…"` around it would
|
|
179
|
+
* be ceremony that every operator setting one by hand would get wrong once.
|
|
180
|
+
*
|
|
181
|
+
* Exported so a tool checking a value before it is stored reads it exactly as
|
|
182
|
+
* the process that uses it will.
|
|
183
|
+
*/
|
|
184
|
+
function decodeCredentials(raw) {
|
|
185
|
+
const value = raw.startsWith(JSON_SCHEME) ? raw.slice(JSON_SCHEME.length) : raw;
|
|
186
|
+
try {
|
|
187
|
+
return JSON.parse(value);
|
|
188
|
+
} catch {
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The explicit form, for the case a credential legitimately *is* a JSON string
|
|
194
|
+
* and must not be parsed into an object. Rare, and cheaper to support than to
|
|
195
|
+
* explain.
|
|
196
|
+
*/
|
|
197
|
+
const JSON_SCHEME = "json:";
|
|
198
|
+
/** A credential was set, and is not what its schema says it should be. */
|
|
199
|
+
var MalformedCredential = class extends Error {
|
|
200
|
+
id;
|
|
201
|
+
key;
|
|
202
|
+
issues;
|
|
203
|
+
constructor(id, key, issues) {
|
|
204
|
+
super(`${key} is not a valid ${id} credential. It is validated where it is read, so this is the value that is set rather than the code that uses it: ${describe(issues)}`);
|
|
205
|
+
this.id = id;
|
|
206
|
+
this.key = key;
|
|
207
|
+
this.issues = issues;
|
|
208
|
+
this.name = "MalformedCredential";
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
/** StandardSchema issues as one line. */
|
|
212
|
+
function describe(issues) {
|
|
213
|
+
if (!Array.isArray(issues)) return String(issues);
|
|
214
|
+
return issues.map((issue) => {
|
|
215
|
+
const path = issue.path?.map((segment) => typeof segment === "object" ? String(segment.key) : String(segment)).join(".");
|
|
216
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
217
|
+
}).join("; ");
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
export { fake as a, readCredentials as i, MalformedCredential as n, isFake as o, decodeCredentials as r, Credential as t };
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=credential-DfSAOOdY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-DfSAOOdY.mjs","names":[],"sources":["../src/fake.ts","../src/credential.ts"],"sourcesContent":["/**\n * Fakes: what a test stage — and `gkm dev --fake` — is handed in place of a\n * third party.\n *\n * An `ExternalApi`'s fake answers its requests and says which credentials it\n * accepts; a `Credential`'s fake is the value the test stage is handed in\n * place of the one a third party issued. Both live at `test/fakes/<id>.ts`,\n * found by convention and default-exported:\n *\n * ```ts\n * // test/fakes/polar.ts\n * export default fake.app<typeof polar>(new Hono()…, {\n * credentials: { clientId: 'fake', clientSecret: 'fake' },\n * });\n *\n * // test/fakes/reviewer-password.ts\n * export default fake.credential<typeof reviewerPassword>(\n * 'a-reviewer-password-for-tests',\n * );\n * ```\n *\n * **The construct never names its fake**, so a fake cannot end up in a\n * deployed bundle however the bundler follows imports. gkm reads the folder\n * for `gkm test` (and the suite it starts) and for `gkm dev --fake`, and for\n * nothing that acts on a deployed stage: a deploy still refuses a stage that\n * lacks the real value.\n */\n\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Credential } from './credential';\nimport type { ExternalApi } from './external-api';\n\n/**\n * Marks a fake. A registered symbol, so a fake built by a second copy of this\n * package — a linked workspace, two versions in a lockfile — is still one.\n */\nconst FAKE = Symbol.for('@geekmidas/constructs/fake');\n\n/** Anything that answers a request — a Hono app, or a bare `{ fetch }`. */\nexport interface FetchHandler {\n\tfetch(request: Request): Response | Promise<Response>;\n}\n\n/**\n * What a construct's credentials look like going in, for a fake to supply —\n * an external API's `credentials` schema, or a credential's `schema`.\n */\ntype CredentialsOf<TConstruct> =\n\tTConstruct extends ExternalApi<string, infer TSchema, unknown>\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: TConstruct extends Credential<string, infer TSchema>\n\t\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t\t: unknown;\n\n/**\n * A third party's stand-in, as `test/fakes/<id>.ts` default-exports it.\n *\n * `credentials` are what a local or test stage is handed as `<ID>_CREDENTIALS`\n * in place of the stage's own: what an external API's fake accepts, or a\n * credential's test value.\n */\nexport type Fake = {\n\treadonly [FAKE]: true;\n\treadonly credentials: unknown;\n} & (\n\t| {\n\t\t\treadonly kind: 'app';\n\t\t\t/** Served by gkm: in-process in a test, on its own port in `gkm dev`. */\n\t\t\treadonly handler: FetchHandler;\n\t }\n\t| {\n\t\t\treadonly kind: 'image';\n\t\t\t/** The provider's own local server, run as a container. */\n\t\t\treadonly image: string;\n\t\t\t/** The port it listens on inside the container. */\n\t\t\treadonly port: number;\n\t }\n\t| {\n\t\t\t/** A `Credential`'s test value — nothing to serve. */\n\t\t\treadonly kind: 'credential';\n\t }\n);\n\n/**\n * Build the fake `test/fakes/<id>.ts` default-exports.\n *\n * Pass the construct's type to have the value checked against its schema —\n * `fake.app<typeof polar>(…)`, `fake.credential<typeof stripe>(…)`.\n */\nexport const fake = {\n\t/** A working implementation of an external API, kept beside the tests that use it. */\n\tapp<TApi = unknown>(\n\t\thandler: FetchHandler,\n\t\toptions: { credentials: CredentialsOf<TApi> },\n\t): Fake {\n\t\treturn {\n\t\t\t[FAKE]: true,\n\t\t\tkind: 'app',\n\t\t\thandler,\n\t\t\tcredentials: options.credentials,\n\t\t};\n\t},\n\n\t/** A local server an external API's provider publishes — `stripe/stripe-mock`. */\n\timage<TApi = unknown>(\n\t\timage: string,\n\t\toptions: { port: number; credentials: CredentialsOf<TApi> },\n\t): Fake {\n\t\treturn {\n\t\t\t[FAKE]: true,\n\t\t\tkind: 'image',\n\t\t\timage,\n\t\t\tport: options.port,\n\t\t\tcredentials: options.credentials,\n\t\t};\n\t},\n\n\t/**\n\t * A `Credential`'s value on the test stage and under `gkm dev --fake`, as\n\t * its schema takes it — a string, or the object a JSON credential holds.\n\t * It is validated where it is read, like the real one.\n\t */\n\tcredential<TCredential = unknown>(\n\t\tcredentials: CredentialsOf<TCredential>,\n\t): Fake {\n\t\treturn { [FAKE]: true, kind: 'credential', credentials };\n\t},\n};\n\n/** Whether a value is a fake — what gkm asks of a `test/fakes` default export. */\nexport function isFake(value: unknown): value is Fake {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as { [FAKE]?: unknown })[FAKE] === true\n\t);\n}\n","/**\n * `Credential` — a third-party credential with a shape.\n *\n * The answer to the design's first open question, \"where does `Secret` sit?\".\n * It sits beside a secret rather than replacing it, because the two differ by\n * *lifecycle* and that is the only difference worth two kinds for: a secret is\n * generated and rotated by the platform and is one opaque string, while a\n * credential is issued by someone else, arrives with several fields, and is\n * worth validating on the way in.\n *\n * ```ts\n * export const stripe = new Credential('Stripe', {\n * schema: z.object({ secretKey: z.string(), webhookSecret: z.string() }),\n * });\n *\n * // in a handler — no await, already parsed and validated\n * services.stripe.secretKey\n * ```\n *\n * **Nothing about it is async at the call site**, which is the part that looks\n * like it should be hard and is not. `Service.register()` may return a promise\n * and `ServiceDiscovery` awaits every one before a handler runs, so fetching a\n * value and validating it — including when a StandardSchema's `~standard.validate`\n * returns a promise of its own — both happen inside that existing seam.\n *\n * **One key holding JSON, not one key per field.** That is the shape a secret\n * manager stores, and it is the only shape that works with an arbitrary\n * StandardSchema: the spec has no introspection API, so enumerating a schema's\n * fields means reaching into one library's internals (`.shape`) and being wrong\n * for every other.\n *\n * **A test stage is handed a fake.** Nobody issues a credential to a test\n * stage set up fresh — CI's auto-setup stores no third party's values — so a\n * credential a test reaches has a fake at `test/fakes/<id>.ts`, the folder an\n * `ExternalApi`'s fake lives in:\n *\n * ```ts\n * // test/fakes/stripe.ts\n * import { fake } from '@geekmidas/constructs/credential';\n * import type { stripe } from '../../constructs/stripe';\n *\n * export default fake.credential<typeof stripe>({\n * secretKey: 'sk_test_fake',\n * webhookSecret: 'whsec_fake',\n * });\n * ```\n *\n * gkm reads it for `gkm test` and `gkm dev --fake` only, and the construct\n * never names it, so it is in no deployed bundle and a deploy still refuses a\n * stage without the real value.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport { parseSchema } from '@geekmidas/schema/parser';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Consumable } from './construct-interface';\n\n/** What a credential's schema yields. */\ntype Value<TSchema extends StandardSchemaV1> =\n\tStandardSchemaV1.InferOutput<TSchema>;\n\nexport interface CredentialOptions<TSchema extends StandardSchemaV1> {\n\t/**\n\t * What the credential must look like.\n\t *\n\t * Validated at registration, so a malformed or half-set credential fails\n\t * when the process starts rather than on the first request that needs the\n\t * one field somebody forgot.\n\t */\n\tschema: TSchema;\n\t/**\n\t * Re-resolve on every registration instead of once per process.\n\t *\n\t * Off by default: a credential is resolved once and reused, because the\n\t * alternative is a fetch on every request. The cost of that default is that\n\t * a rotated credential needs a restart, which is the right trade for a value\n\t * that changes a few times a year — and this is the escape hatch for when it\n\t * is not.\n\t */\n\trefresh?: boolean;\n}\n\nexport class Credential<\n\tTName extends string = string,\n\tTSchema extends StandardSchemaV1 = StandardSchemaV1,\n> implements Consumable<TName, Value<TSchema>>\n{\n\t// `Consumable` rather than `Construct`, and not by preference: `Construct`\n\t// types its service as `[TClient] extends [never] ? never : Service<…>` so\n\t// that a `Cron` cannot be depended on, and TypeScript cannot evaluate that\n\t// conditional while `TClient` is still a type parameter. Every construct\n\t// with a concrete client satisfies `Construct`; the first one whose client\n\t// is generic cannot. `Consumable` is the face `.dependsOn()` requires and\n\t// carries no conditional, so it is the honest annotation here.\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Value<TSchema>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * target publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { credentials: string };\n\n\t/**\n\t * The resolved value, held as the *promise* rather than the value.\n\t *\n\t * Caching the promise is what makes two concurrent registrations share one\n\t * resolution: caching the value would let both start before either finished,\n\t * which is a duplicated fetch every cold start rather than never.\n\t */\n\tprivate resolved?: Promise<Value<TSchema>>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: CredentialOptions<TSchema>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { credentials: provideKey(canonical, 'credentials') };\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\t/**\n\t * What the stage's `<ID>_CREDENTIALS` must look like — the schema the value\n\t * is validated against where it is read. Public so a tool setting the value\n\t * (`gkm secrets:add`) can check it, and describe its fields, before it is\n\t * stored rather than at the first request.\n\t */\n\tget credentialsSchema(): TSchema {\n\t\treturn this.options.schema;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'credential',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.credentials],\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\tif (this.options.refresh) return this.resolve(options);\n\n\t\tthis.resolved ??= this.resolve(options);\n\n\t\treturn this.resolved;\n\t}\n\n\tprivate resolve(options: ServiceRegisterOptions): Promise<Value<TSchema>> {\n\t\treturn readCredentials(\n\t\t\tthis.id,\n\t\t\tthis.keys.credentials,\n\t\t\tthis.options.schema,\n\t\t\toptions.envParser,\n\t\t);\n\t}\n}\n\n/**\n * A credentials key, read and validated against its schema.\n *\n * Shared with every construct that holds a third party's credentials — an\n * `ExternalApi` reads its own the same way — so the shape a stage stores and\n * the error a bad value raises are the same everywhere.\n *\n * @throws {MalformedCredential} when the value is not what the schema says.\n */\nexport async function readCredentials<TSchema extends StandardSchemaV1>(\n\tid: string,\n\tkey: string,\n\tschema: TSchema,\n\tenvParser: ServiceRegisterOptions['envParser'],\n): Promise<Value<TSchema>> {\n\tconst { raw } = envParser\n\t\t.create((get) => ({ raw: get(key).string() }))\n\t\t.parse();\n\n\ttry {\n\t\treturn await parseSchema(schema, decodeCredentials(raw));\n\t} catch (issues) {\n\t\tthrow new MalformedCredential(id, key, issues);\n\t}\n}\n\n/**\n * The raw environment value as the thing the schema should see.\n *\n * JSON when it is JSON, and the string itself when it is not — a credential\n * with a single opaque field is ordinary, and requiring `\"…\"` around it would\n * be ceremony that every operator setting one by hand would get wrong once.\n *\n * Exported so a tool checking a value before it is stored reads it exactly as\n * the process that uses it will.\n */\nexport function decodeCredentials(raw: string): unknown {\n\tconst value = raw.startsWith(JSON_SCHEME)\n\t\t? raw.slice(JSON_SCHEME.length)\n\t\t: raw;\n\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\n/**\n * The explicit form, for the case a credential legitimately *is* a JSON string\n * and must not be parsed into an object. Rare, and cheaper to support than to\n * explain.\n */\nconst JSON_SCHEME = 'json:';\n\n/** A credential was set, and is not what its schema says it should be. */\nexport class MalformedCredential extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly key: string,\n\t\treadonly issues: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${key} is not a valid ${id} credential. ` +\n\t\t\t\t`It is validated where it is read, so this is the value that is set ` +\n\t\t\t\t`rather than the code that uses it: ${describe(issues)}`,\n\t\t);\n\t\tthis.name = 'MalformedCredential';\n\t}\n}\n\n/** StandardSchema issues as one line. */\nfunction describe(issues: unknown): string {\n\tif (!Array.isArray(issues)) return String(issues);\n\n\treturn issues\n\t\t.map((issue: StandardSchemaV1.Issue) => {\n\t\t\tconst path = issue.path\n\t\t\t\t?.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\n\t\t\treturn path ? `${path}: ${issue.message}` : issue.message;\n\t\t})\n\t\t.join('; ');\n}\n\nexport { type Fake, fake, isFake } from './fake';\n"],"mappings":";;;;;;;AAoCA,MAAM,OAAO,OAAO,IAAI,4BAA4B;;;;;;;AAqDpD,MAAa,OAAO;;CAEnB,IACC,SACA,SACO;EACP,OAAO;IACL,OAAO;GACR,MAAM;GACN;GACA,aAAa,QAAQ;EACtB;CACD;;CAGA,MACC,OACA,SACO;EACP,OAAO;IACL,OAAO;GACR,MAAM;GACN;GACA,MAAM,QAAQ;GACd,aAAa,QAAQ;EACtB;CACD;;;;;;CAOA,WACC,aACO;EACP,OAAO;IAAG,OAAO;GAAM,MAAM;GAAc;EAAY;CACxD;AACD;;AAGA,SAAgB,OAAO,OAA+B;CACrD,OACC,OAAO,UAAU,YACjB,UAAU,QACT,MAA+B,UAAU;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/CA,IAAa,aAAb,MAIA;CA4BmB;CApBlB;CACA;;;;;CAMA;;;;;;;;CASA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO,EAAE,aAAa,WAAW,WAAW,aAAa,EAAE;EAGhE,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,oBAAoB,KAAK,QAAQ,eAAe;EAC5D;CACD;;;;;;;CAQA,IAAI,oBAA6B;EAChC,OAAO,KAAK,QAAQ;CACrB;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,WAAW;EACjC,CACD;CACD;CAEA,QAAgB,SAA0D;EACzE,IAAI,KAAK,QAAQ,SAAS,OAAO,KAAK,QAAQ,OAAO;EAErD,KAAK,aAAa,KAAK,QAAQ,OAAO;EAEtC,OAAO,KAAK;CACb;CAEA,QAAgB,SAA0D;EACzE,OAAO,gBACN,KAAK,IACL,KAAK,KAAK,aACV,KAAK,QAAQ,QACb,QAAQ,SACT;CACD;AACD;;;;;;;;;;AAWA,eAAsB,gBACrB,IACA,KACA,QACA,WAC0B;CAC1B,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7C,MAAM;CAER,IAAI;EACH,OAAO,MAAM,YAAY,QAAQ,kBAAkB,GAAG,CAAC;CACxD,SAAS,QAAQ;EAChB,MAAM,IAAI,oBAAoB,IAAI,KAAK,MAAM;CAC9C;AACD;;;;;;;;;;;AAYA,SAAgB,kBAAkB,KAAsB;CACvD,MAAM,QAAQ,IAAI,WAAW,WAAW,IACrC,IAAI,MAAM,YAAY,MAAM,IAC5B;CAEH,IAAI;EACH,OAAO,KAAK,MAAM,KAAK;CACxB,QAAQ;EACP,OAAO;CACR;AACD;;;;;;AAOA,MAAM,cAAc;;AAGpB,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CACA;CAHV,YACC,IACA,KACA,QACC;EACD,MACC,GAAG,IAAI,kBAAkB,GAAG,qHAEW,SAAS,MAAM,GACvD;EARS,KAAA,KAAA;EACA,KAAA,MAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,SAAS,QAAyB;CAC1C,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,OAAO,MAAM;CAEhD,OAAO,OACL,KAAK,UAAkC;EACvC,MAAM,OAAO,MAAM,MAChB,KAAK,YACN,OAAO,YAAY,WAAW,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,CACnE,CAAC,CACA,KAAK,GAAG;EAEV,OAAO,OAAO,GAAG,KAAK,IAAI,MAAM,YAAY,MAAM;CACnD,CAAC,CAAC,CACD,KAAK,IAAI;AACZ"}
|
package/dist/credential.cjs
CHANGED
|
@@ -1,96 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
11
|
-
* target publishes and the key the client reads cannot drift.
|
|
12
|
-
*/
|
|
13
|
-
keys;
|
|
14
|
-
/**
|
|
15
|
-
* The resolved value, held as the *promise* rather than the value.
|
|
16
|
-
*
|
|
17
|
-
* Caching the promise is what makes two concurrent registrations share one
|
|
18
|
-
* resolution: caching the value would let both start before either finished,
|
|
19
|
-
* which is a duplicated fetch every cold start rather than never.
|
|
20
|
-
*/
|
|
21
|
-
resolved;
|
|
22
|
-
constructor(id, options) {
|
|
23
|
-
this.options = options;
|
|
24
|
-
const canonical = (0, __geekmidas_manifest.canonicalId)(id);
|
|
25
|
-
this.id = canonical;
|
|
26
|
-
this.keys = { credential: (0, __geekmidas_manifest.provideKey)(canonical, "credential") };
|
|
27
|
-
this.service = {
|
|
28
|
-
serviceName: (0, __geekmidas_manifest.serviceKey)(canonical),
|
|
29
|
-
register: (registerOptions) => this.connect(registerOptions)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
declare() {
|
|
33
|
-
return [{
|
|
34
|
-
kind: "credential",
|
|
35
|
-
id: this.id,
|
|
36
|
-
provides: [this.keys.credential]
|
|
37
|
-
}];
|
|
38
|
-
}
|
|
39
|
-
connect(options) {
|
|
40
|
-
if (this.options.refresh) return this.resolve(options);
|
|
41
|
-
this.resolved ??= this.resolve(options);
|
|
42
|
-
return this.resolved;
|
|
43
|
-
}
|
|
44
|
-
async resolve(options) {
|
|
45
|
-
const { raw } = options.envParser.create((get) => ({ raw: get(this.keys.credential).string() })).parse();
|
|
46
|
-
try {
|
|
47
|
-
return await (0, __geekmidas_schema_parser.parseSchema)(this.options.schema, decode(raw));
|
|
48
|
-
} catch (issues) {
|
|
49
|
-
throw new MalformedCredential(this.id, this.keys.credential, issues);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* The raw environment value as the thing the schema should see.
|
|
55
|
-
*
|
|
56
|
-
* JSON when it is JSON, and the string itself when it is not — a credential
|
|
57
|
-
* with a single opaque field is ordinary, and requiring `"…"` around it would
|
|
58
|
-
* be ceremony that every operator setting one by hand would get wrong once.
|
|
59
|
-
*/
|
|
60
|
-
function decode(raw) {
|
|
61
|
-
const value = raw.startsWith(JSON_SCHEME) ? raw.slice(JSON_SCHEME.length) : raw;
|
|
62
|
-
try {
|
|
63
|
-
return JSON.parse(value);
|
|
64
|
-
} catch {
|
|
65
|
-
return value;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The explicit form, for the case a credential legitimately *is* a JSON string
|
|
70
|
-
* and must not be parsed into an object. Rare, and cheaper to support than to
|
|
71
|
-
* explain.
|
|
72
|
-
*/
|
|
73
|
-
const JSON_SCHEME = "json:";
|
|
74
|
-
/** A credential was set, and is not what its schema says it should be. */
|
|
75
|
-
var MalformedCredential = class extends Error {
|
|
76
|
-
constructor(id, key, issues) {
|
|
77
|
-
super(`${key} is not a valid ${id} credential. It is validated where it is read, so this is the value that is set rather than the code that uses it: ${describe(issues)}`);
|
|
78
|
-
this.id = id;
|
|
79
|
-
this.key = key;
|
|
80
|
-
this.issues = issues;
|
|
81
|
-
this.name = "MalformedCredential";
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
/** StandardSchema issues as one line. */
|
|
85
|
-
function describe(issues) {
|
|
86
|
-
if (!Array.isArray(issues)) return String(issues);
|
|
87
|
-
return issues.map((issue) => {
|
|
88
|
-
const path = issue.path?.map((segment) => typeof segment === "object" ? String(segment.key) : String(segment)).join(".");
|
|
89
|
-
return path ? `${path}: ${issue.message}` : issue.message;
|
|
90
|
-
}).join("; ");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
exports.Credential = Credential;
|
|
95
|
-
exports.MalformedCredential = MalformedCredential;
|
|
96
|
-
//# sourceMappingURL=credential.cjs.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_credential = require("./credential-DYymbp_7.cjs");
|
|
3
|
+
exports.Credential = require_credential.Credential;
|
|
4
|
+
exports.MalformedCredential = require_credential.MalformedCredential;
|
|
5
|
+
exports.decodeCredentials = require_credential.decodeCredentials;
|
|
6
|
+
exports.fake = require_credential.fake;
|
|
7
|
+
exports.isFake = require_credential.isFake;
|
|
8
|
+
exports.readCredentials = require_credential.readCredentials;
|
package/dist/credential.d.cts
CHANGED
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
import { ConstructName, Declaration } from "@geekmidas/manifest";
|
|
5
|
-
|
|
6
|
-
//#region src/credential.d.ts
|
|
7
|
-
|
|
8
|
-
/** What a credential's schema yields. */
|
|
9
|
-
type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
|
|
10
|
-
interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
11
|
-
/**
|
|
12
|
-
* What the credential must look like.
|
|
13
|
-
*
|
|
14
|
-
* Validated at registration, so a malformed or half-set credential fails
|
|
15
|
-
* when the process starts rather than on the first request that needs the
|
|
16
|
-
* one field somebody forgot.
|
|
17
|
-
*/
|
|
18
|
-
schema: TSchema;
|
|
19
|
-
/**
|
|
20
|
-
* Re-resolve on every registration instead of once per process.
|
|
21
|
-
*
|
|
22
|
-
* Off by default: a credential is resolved once and reused, because the
|
|
23
|
-
* alternative is a fetch on every request. The cost of that default is that
|
|
24
|
-
* a rotated credential needs a restart, which is the right trade for a value
|
|
25
|
-
* that changes a few times a year — and this is the escape hatch for when it
|
|
26
|
-
* is not.
|
|
27
|
-
*/
|
|
28
|
-
refresh?: boolean;
|
|
29
|
-
}
|
|
30
|
-
declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
|
|
31
|
-
private readonly options;
|
|
32
|
-
readonly id: TName;
|
|
33
|
-
readonly service: Service<Uncapitalize<TName>, Value<TSchema>>;
|
|
34
|
-
/**
|
|
35
|
-
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
36
|
-
* target publishes and the key the client reads cannot drift.
|
|
37
|
-
*/
|
|
38
|
-
private readonly keys;
|
|
39
|
-
/**
|
|
40
|
-
* The resolved value, held as the *promise* rather than the value.
|
|
41
|
-
*
|
|
42
|
-
* Caching the promise is what makes two concurrent registrations share one
|
|
43
|
-
* resolution: caching the value would let both start before either finished,
|
|
44
|
-
* which is a duplicated fetch every cold start rather than never.
|
|
45
|
-
*/
|
|
46
|
-
private resolved?;
|
|
47
|
-
constructor(id: ConstructName<TName>, options: CredentialOptions<TSchema>);
|
|
48
|
-
declare(): Declaration[];
|
|
49
|
-
private connect;
|
|
50
|
-
private resolve;
|
|
51
|
-
}
|
|
52
|
-
/** A credential was set, and is not what its schema says it should be. */
|
|
53
|
-
declare class MalformedCredential extends Error {
|
|
54
|
-
readonly id: string;
|
|
55
|
-
readonly key: string;
|
|
56
|
-
readonly issues: unknown;
|
|
57
|
-
constructor(id: string, key: string, issues: unknown);
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
export { Credential, CredentialOptions, MalformedCredential };
|
|
61
|
-
//# sourceMappingURL=credential.d.cts.map
|
|
1
|
+
import { c as Credential, d as decodeCredentials, f as readCredentials, i as isFake, l as CredentialOptions, r as fake, t as Fake, u as MalformedCredential } from "./fake-Dvion_Fh.cjs";
|
|
2
|
+
export { Credential, CredentialOptions, type Fake, MalformedCredential, decodeCredentials, fake, isFake, readCredentials };
|
package/dist/credential.d.mts
CHANGED
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Service } from "@geekmidas/services";
|
|
4
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
-
|
|
6
|
-
//#region src/credential.d.ts
|
|
7
|
-
|
|
8
|
-
/** What a credential's schema yields. */
|
|
9
|
-
type Value<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema>;
|
|
10
|
-
interface CredentialOptions<TSchema extends StandardSchemaV1> {
|
|
11
|
-
/**
|
|
12
|
-
* What the credential must look like.
|
|
13
|
-
*
|
|
14
|
-
* Validated at registration, so a malformed or half-set credential fails
|
|
15
|
-
* when the process starts rather than on the first request that needs the
|
|
16
|
-
* one field somebody forgot.
|
|
17
|
-
*/
|
|
18
|
-
schema: TSchema;
|
|
19
|
-
/**
|
|
20
|
-
* Re-resolve on every registration instead of once per process.
|
|
21
|
-
*
|
|
22
|
-
* Off by default: a credential is resolved once and reused, because the
|
|
23
|
-
* alternative is a fetch on every request. The cost of that default is that
|
|
24
|
-
* a rotated credential needs a restart, which is the right trade for a value
|
|
25
|
-
* that changes a few times a year — and this is the escape hatch for when it
|
|
26
|
-
* is not.
|
|
27
|
-
*/
|
|
28
|
-
refresh?: boolean;
|
|
29
|
-
}
|
|
30
|
-
declare class Credential<TName extends string = string, TSchema extends StandardSchemaV1 = StandardSchemaV1> implements Consumable<TName, Value<TSchema>> {
|
|
31
|
-
private readonly options;
|
|
32
|
-
readonly id: TName;
|
|
33
|
-
readonly service: Service<Uncapitalize<TName>, Value<TSchema>>;
|
|
34
|
-
/**
|
|
35
|
-
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
36
|
-
* target publishes and the key the client reads cannot drift.
|
|
37
|
-
*/
|
|
38
|
-
private readonly keys;
|
|
39
|
-
/**
|
|
40
|
-
* The resolved value, held as the *promise* rather than the value.
|
|
41
|
-
*
|
|
42
|
-
* Caching the promise is what makes two concurrent registrations share one
|
|
43
|
-
* resolution: caching the value would let both start before either finished,
|
|
44
|
-
* which is a duplicated fetch every cold start rather than never.
|
|
45
|
-
*/
|
|
46
|
-
private resolved?;
|
|
47
|
-
constructor(id: ConstructName<TName>, options: CredentialOptions<TSchema>);
|
|
48
|
-
declare(): Declaration[];
|
|
49
|
-
private connect;
|
|
50
|
-
private resolve;
|
|
51
|
-
}
|
|
52
|
-
/** A credential was set, and is not what its schema says it should be. */
|
|
53
|
-
declare class MalformedCredential extends Error {
|
|
54
|
-
readonly id: string;
|
|
55
|
-
readonly key: string;
|
|
56
|
-
readonly issues: unknown;
|
|
57
|
-
constructor(id: string, key: string, issues: unknown);
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
export { Credential, CredentialOptions, MalformedCredential };
|
|
61
|
-
//# sourceMappingURL=credential.d.mts.map
|
|
1
|
+
import { c as Credential, d as decodeCredentials, f as readCredentials, i as isFake, l as CredentialOptions, r as fake, t as Fake, u as MalformedCredential } from "./fake-DqKo8INJ.mjs";
|
|
2
|
+
export { Credential, CredentialOptions, type Fake, MalformedCredential, decodeCredentials, fake, isFake, readCredentials };
|
package/dist/credential.mjs
CHANGED
|
@@ -1,94 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/credential.ts
|
|
5
|
-
var Credential = class {
|
|
6
|
-
id;
|
|
7
|
-
service;
|
|
8
|
-
/**
|
|
9
|
-
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
10
|
-
* target publishes and the key the client reads cannot drift.
|
|
11
|
-
*/
|
|
12
|
-
keys;
|
|
13
|
-
/**
|
|
14
|
-
* The resolved value, held as the *promise* rather than the value.
|
|
15
|
-
*
|
|
16
|
-
* Caching the promise is what makes two concurrent registrations share one
|
|
17
|
-
* resolution: caching the value would let both start before either finished,
|
|
18
|
-
* which is a duplicated fetch every cold start rather than never.
|
|
19
|
-
*/
|
|
20
|
-
resolved;
|
|
21
|
-
constructor(id, options) {
|
|
22
|
-
this.options = options;
|
|
23
|
-
const canonical = canonicalId(id);
|
|
24
|
-
this.id = canonical;
|
|
25
|
-
this.keys = { credential: provideKey(canonical, "credential") };
|
|
26
|
-
this.service = {
|
|
27
|
-
serviceName: serviceKey(canonical),
|
|
28
|
-
register: (registerOptions) => this.connect(registerOptions)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
declare() {
|
|
32
|
-
return [{
|
|
33
|
-
kind: "credential",
|
|
34
|
-
id: this.id,
|
|
35
|
-
provides: [this.keys.credential]
|
|
36
|
-
}];
|
|
37
|
-
}
|
|
38
|
-
connect(options) {
|
|
39
|
-
if (this.options.refresh) return this.resolve(options);
|
|
40
|
-
this.resolved ??= this.resolve(options);
|
|
41
|
-
return this.resolved;
|
|
42
|
-
}
|
|
43
|
-
async resolve(options) {
|
|
44
|
-
const { raw } = options.envParser.create((get) => ({ raw: get(this.keys.credential).string() })).parse();
|
|
45
|
-
try {
|
|
46
|
-
return await parseSchema(this.options.schema, decode(raw));
|
|
47
|
-
} catch (issues) {
|
|
48
|
-
throw new MalformedCredential(this.id, this.keys.credential, issues);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* The raw environment value as the thing the schema should see.
|
|
54
|
-
*
|
|
55
|
-
* JSON when it is JSON, and the string itself when it is not — a credential
|
|
56
|
-
* with a single opaque field is ordinary, and requiring `"…"` around it would
|
|
57
|
-
* be ceremony that every operator setting one by hand would get wrong once.
|
|
58
|
-
*/
|
|
59
|
-
function decode(raw) {
|
|
60
|
-
const value = raw.startsWith(JSON_SCHEME) ? raw.slice(JSON_SCHEME.length) : raw;
|
|
61
|
-
try {
|
|
62
|
-
return JSON.parse(value);
|
|
63
|
-
} catch {
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The explicit form, for the case a credential legitimately *is* a JSON string
|
|
69
|
-
* and must not be parsed into an object. Rare, and cheaper to support than to
|
|
70
|
-
* explain.
|
|
71
|
-
*/
|
|
72
|
-
const JSON_SCHEME = "json:";
|
|
73
|
-
/** A credential was set, and is not what its schema says it should be. */
|
|
74
|
-
var MalformedCredential = class extends Error {
|
|
75
|
-
constructor(id, key, issues) {
|
|
76
|
-
super(`${key} is not a valid ${id} credential. It is validated where it is read, so this is the value that is set rather than the code that uses it: ${describe(issues)}`);
|
|
77
|
-
this.id = id;
|
|
78
|
-
this.key = key;
|
|
79
|
-
this.issues = issues;
|
|
80
|
-
this.name = "MalformedCredential";
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
/** StandardSchema issues as one line. */
|
|
84
|
-
function describe(issues) {
|
|
85
|
-
if (!Array.isArray(issues)) return String(issues);
|
|
86
|
-
return issues.map((issue) => {
|
|
87
|
-
const path = issue.path?.map((segment) => typeof segment === "object" ? String(segment.key) : String(segment)).join(".");
|
|
88
|
-
return path ? `${path}: ${issue.message}` : issue.message;
|
|
89
|
-
}).join("; ");
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
export { Credential, MalformedCredential };
|
|
94
|
-
//# sourceMappingURL=credential.mjs.map
|
|
1
|
+
import { a as fake, i as readCredentials, n as MalformedCredential, o as isFake, r as decodeCredentials, t as Credential } from "./credential-DfSAOOdY.mjs";
|
|
2
|
+
export { Credential, MalformedCredential, decodeCredentials, fake, isFake, readCredentials };
|