@geekmidas/constructs 10.0.0-alpha.12 → 10.0.0-alpha.121
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-B7AXn0xH.d.mts +230 -0
- package/dist/Construct-B7AXn0xH.d.mts.map +1 -0
- package/dist/Construct-CFW0zjdD.d.cts +230 -0
- package/dist/Construct-CFW0zjdD.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/{Cron-DmQ8vQ4b.d.cts → Cron-bdGRSROY.d.cts} +15 -9
- package/dist/Cron-bdGRSROY.d.cts.map +1 -0
- package/dist/{Cron-dh4rUgib.d.mts → Cron-i4Uetezh.d.mts} +15 -9
- package/dist/Cron-i4Uetezh.d.mts.map +1 -0
- package/dist/CronBuilder-9H4BnD6W.d.mts +47 -0
- package/dist/CronBuilder-9H4BnD6W.d.mts.map +1 -0
- package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BXTG10u5.cjs} +47 -31
- package/dist/CronBuilder-BXTG10u5.cjs.map +1 -0
- package/dist/CronBuilder-B_24LZpn.d.cts +47 -0
- package/dist/CronBuilder-B_24LZpn.d.cts.map +1 -0
- package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-D3sF9tS_.mjs} +37 -21
- package/dist/CronBuilder-D3sF9tS_.mjs.map +1 -0
- package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-CeFkSwh5.d.mts} +129 -99
- package/dist/Endpoint-CeFkSwh5.d.mts.map +1 -0
- package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-DgrpG15P.d.cts} +127 -97
- package/dist/Endpoint-DgrpG15P.d.cts.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/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-CSrAyazj.cjs} +361 -112
- package/dist/EndpointFactory-CSrAyazj.cjs.map +1 -0
- package/dist/{index-lAO9egTb.d.mts → EndpointFactory-Cc863XJS.d.cts} +190 -136
- package/dist/EndpointFactory-Cc863XJS.d.cts.map +1 -0
- package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-Dbw9ugkX.d.mts} +189 -135
- package/dist/EndpointFactory-Dbw9ugkX.d.mts.map +1 -0
- package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-c2ZugGig.mjs} +283 -76
- package/dist/EndpointFactory-c2ZugGig.mjs.map +1 -0
- package/dist/Function-B0uZhZnU.d.cts +76 -0
- package/dist/Function-B0uZhZnU.d.cts.map +1 -0
- package/dist/Function-B_9R7Zy1.d.mts +76 -0
- package/dist/Function-B_9R7Zy1.d.mts.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-D7ZuwBhy.d.cts → Queue-B-dDXyjF.d.mts} +48 -48
- package/dist/Queue-B-dDXyjF.d.mts.map +1 -0
- package/dist/Queue-BhuofM3k.cjs +109 -0
- package/dist/Queue-BhuofM3k.cjs.map +1 -0
- package/dist/{Queue-gVGfi2Yk.d.mts → Queue-JbIjVtTf.d.cts} +49 -49
- package/dist/Queue-JbIjVtTf.d.cts.map +1 -0
- package/dist/Queue-cmhqEBOB.mjs +104 -0
- package/dist/Queue-cmhqEBOB.mjs.map +1 -0
- package/dist/QueueBuilder-48W-q8In.d.mts +75 -0
- package/dist/QueueBuilder-48W-q8In.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-MfpkJ3R9.d.cts +75 -0
- package/dist/QueueBuilder-MfpkJ3R9.d.cts.map +1 -0
- package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-CEt7kHkc.d.cts} +29 -20
- package/dist/Subscriber-CEt7kHkc.d.cts.map +1 -0
- package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-dsxc5LKa.d.mts} +29 -20
- package/dist/Subscriber-dsxc5LKa.d.mts.map +1 -0
- package/dist/SubscriberBuilder-BRa_nrmH.d.cts +67 -0
- package/dist/SubscriberBuilder-BRa_nrmH.d.cts.map +1 -0
- package/dist/SubscriberBuilder-D9bkrYzH.d.mts +67 -0
- package/dist/SubscriberBuilder-D9bkrYzH.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/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/cipher-DSDxPRIp.d.cts +106 -0
- package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
- package/dist/cipher-DSDxPRIp.d.mts +106 -0
- package/dist/cipher-DSDxPRIp.d.mts.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/kms.cjs +95 -0
- package/dist/encryption/kms.cjs.map +1 -0
- package/dist/encryption/kms.d.cts +7 -0
- package/dist/encryption/kms.d.cts.map +1 -0
- package/dist/encryption/kms.d.mts +7 -0
- package/dist/encryption/kms.d.mts.map +1 -0
- package/dist/encryption/kms.mjs +93 -0
- package/dist/encryption/kms.mjs.map +1 -0
- package/dist/encryption.cjs +116 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +37 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +37 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +101 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +27 -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/expire-C586zznE.d.cts +38 -0
- package/dist/expire-C586zznE.d.cts.map +1 -0
- package/dist/expire-C586zznE.d.mts +38 -0
- package/dist/expire-C586zznE.d.mts.map +1 -0
- package/dist/expire-CieftS01.cjs +67 -0
- package/dist/expire-CieftS01.cjs.map +1 -0
- package/dist/expire-CpzUAfr9.mjs +50 -0
- package/dist/expire-CpzUAfr9.mjs.map +1 -0
- 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-B7rvi4Qp.d.cts +201 -0
- package/dist/fake-B7rvi4Qp.d.cts.map +1 -0
- package/dist/fake-JXbkdao8.d.mts +201 -0
- package/dist/fake-JXbkdao8.d.mts.map +1 -0
- package/dist/file-server.cjs +66 -11
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +25 -10
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +25 -10
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +58 -4
- 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-Cd2w-DRL.d.cts +115 -0
- package/dist/index-Cd2w-DRL.d.cts.map +1 -0
- package/dist/index-DdRjYhiJ.d.cts +119 -0
- package/dist/index-DdRjYhiJ.d.cts.map +1 -0
- package/dist/index-DdRjYhiJ.d.mts +119 -0
- package/dist/index-DdRjYhiJ.d.mts.map +1 -0
- package/dist/index-aBIcAiH5.d.mts +115 -0
- package/dist/index-aBIcAiH5.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/kysely-BHYV-WC-.d.cts +216 -0
- package/dist/kysely-BHYV-WC-.d.cts.map +1 -0
- package/dist/kysely-CAW3QSqp.d.mts +216 -0
- package/dist/kysely-CAW3QSqp.d.mts.map +1 -0
- package/dist/kysely-Cs4uPO8k.mjs +371 -0
- package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
- package/dist/kysely-CukArHJ0.cjs +384 -0
- package/dist/kysely-CukArHJ0.cjs.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 +26 -11
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +12 -7
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +12 -7
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +18 -5
- 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 -45
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +54 -29
- package/dist/worker.mjs.map +1 -1
- package/package.json +115 -41
- 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,95 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_cipher = require("../cipher-CVxfwLjk.cjs");
|
|
3
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
4
|
+
let _aws_sdk_client_kms = require("@aws-sdk/client-kms");
|
|
5
|
+
//#region src/encryption/kms.ts
|
|
6
|
+
/**
|
|
7
|
+
* The `kms://` cipher: envelope encryption under an AWS KMS key.
|
|
8
|
+
*
|
|
9
|
+
* Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it
|
|
10
|
+
* locally, and stores the data key *as KMS encrypted it* beside the data. The
|
|
11
|
+
* plaintext data key is used once and dropped, and the master key never leaves
|
|
12
|
+
* KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.
|
|
13
|
+
*
|
|
14
|
+
* Rotation is KMS's: it keeps every backing version of the key, and the
|
|
15
|
+
* encrypted data key names the one that wrapped it, so nothing here tracks a
|
|
16
|
+
* version and `reencrypt` has nothing to move. The ciphertext's key field is
|
|
17
|
+
* `kms` for that reason.
|
|
18
|
+
*
|
|
19
|
+
* The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the
|
|
20
|
+
* key is as unextractable as the encryption key.
|
|
21
|
+
*
|
|
22
|
+
* In its own entry, `@geekmidas/constructs/encryption/kms`, which only an
|
|
23
|
+
* AWS build's generated entry imports — to register {@link kmsCipherDriver}
|
|
24
|
+
* — so a project that never deploys to AWS never needs
|
|
25
|
+
* `@aws-sdk/client-kms` installed, and its bundle never mentions it.
|
|
26
|
+
*/
|
|
27
|
+
/** The ciphertext's key field: the version lives inside KMS's own blob. */
|
|
28
|
+
const KMS_KEY_ID = "kms";
|
|
29
|
+
function kmsCipher(construct, url) {
|
|
30
|
+
const parsed = new URL(url);
|
|
31
|
+
const region = parsed.hostname;
|
|
32
|
+
const keyId = parsed.searchParams.get("key");
|
|
33
|
+
const indexKeyId = parsed.searchParams.get("index");
|
|
34
|
+
if (!region || !keyId || !indexKeyId) throw new require_cipher.EncryptionUrlInvalid(construct, "a kms:// URL names a region, a key and an index key");
|
|
35
|
+
const endpoint = parsed.searchParams.get("endpoint");
|
|
36
|
+
const kms = new _aws_sdk_client_kms.KMSClient({
|
|
37
|
+
region,
|
|
38
|
+
...endpoint ? { endpoint } : {}
|
|
39
|
+
});
|
|
40
|
+
const context = { construct };
|
|
41
|
+
const aad = require_cipher.associatedData(construct, KMS_KEY_ID);
|
|
42
|
+
return {
|
|
43
|
+
async encrypt(plaintext) {
|
|
44
|
+
const dataKey = await kms.send(new _aws_sdk_client_kms.GenerateDataKeyCommand({
|
|
45
|
+
KeyId: keyId,
|
|
46
|
+
KeySpec: "AES_256",
|
|
47
|
+
EncryptionContext: context
|
|
48
|
+
}));
|
|
49
|
+
const wrapped = Buffer.from(dataKey.CiphertextBlob);
|
|
50
|
+
const sealed = require_cipher.seal(Buffer.from(dataKey.Plaintext), Buffer.from(plaintext, "utf8"), aad);
|
|
51
|
+
const length = Buffer.alloc(2);
|
|
52
|
+
length.writeUInt16BE(wrapped.length);
|
|
53
|
+
return require_cipher.formatCiphertext(KMS_KEY_ID, Buffer.concat([
|
|
54
|
+
length,
|
|
55
|
+
wrapped,
|
|
56
|
+
sealed
|
|
57
|
+
]));
|
|
58
|
+
},
|
|
59
|
+
async decrypt(ciphertext) {
|
|
60
|
+
const { payload } = require_cipher.parseCiphertext(construct, ciphertext);
|
|
61
|
+
const length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;
|
|
62
|
+
const wrapped = payload.subarray(2, 2 + length);
|
|
63
|
+
if (!length || wrapped.length !== length) throw new require_cipher.CiphertextNotAuthentic(construct);
|
|
64
|
+
const dataKey = await kms.send(new _aws_sdk_client_kms.DecryptCommand({
|
|
65
|
+
CiphertextBlob: wrapped,
|
|
66
|
+
EncryptionContext: context
|
|
67
|
+
}));
|
|
68
|
+
const plaintext = require_cipher.open(Buffer.from(dataKey.Plaintext), payload.subarray(2 + length), aad);
|
|
69
|
+
if (!plaintext) throw new require_cipher.CiphertextNotAuthentic(construct);
|
|
70
|
+
return plaintext.toString("utf8");
|
|
71
|
+
},
|
|
72
|
+
async index(value) {
|
|
73
|
+
const { Mac } = await kms.send(new _aws_sdk_client_kms.GenerateMacCommand({
|
|
74
|
+
KeyId: indexKeyId,
|
|
75
|
+
MacAlgorithm: "HMAC_SHA_256",
|
|
76
|
+
Message: Buffer.from(value, "utf8")
|
|
77
|
+
}));
|
|
78
|
+
return Buffer.from(Mac).toString("base64url");
|
|
79
|
+
},
|
|
80
|
+
async reencrypt(ciphertext) {
|
|
81
|
+
require_cipher.parseCiphertext(construct, ciphertext);
|
|
82
|
+
return ciphertext;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** The `kms:` cipher, as an AWS build's entry registers it. */
|
|
87
|
+
const kmsCipherDriver = {
|
|
88
|
+
scheme: _geekmidas_manifest.KMS_SCHEME,
|
|
89
|
+
open: kmsCipher
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
exports.kmsCipher = kmsCipher;
|
|
93
|
+
exports.kmsCipherDriver = kmsCipherDriver;
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=kms.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms.cjs","names":["EncryptionUrlInvalid","KMSClient","associatedData","GenerateDataKeyCommand","seal","formatCiphertext","parseCiphertext","CiphertextNotAuthentic","DecryptCommand","open","GenerateMacCommand","KMS_SCHEME"],"sources":["../../src/encryption/kms.ts"],"sourcesContent":["/**\n * The `kms://` cipher: envelope encryption under an AWS KMS key.\n *\n * Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it\n * locally, and stores the data key *as KMS encrypted it* beside the data. The\n * plaintext data key is used once and dropped, and the master key never leaves\n * KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.\n *\n * Rotation is KMS's: it keeps every backing version of the key, and the\n * encrypted data key names the one that wrapped it, so nothing here tracks a\n * version and `reencrypt` has nothing to move. The ciphertext's key field is\n * `kms` for that reason.\n *\n * The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the\n * key is as unextractable as the encryption key.\n *\n * In its own entry, `@geekmidas/constructs/encryption/kms`, which only an\n * AWS build's generated entry imports — to register {@link kmsCipherDriver}\n * — so a project that never deploys to AWS never needs\n * `@aws-sdk/client-kms` installed, and its bundle never mentions it.\n */\n\nimport {\n\tDecryptCommand,\n\tGenerateDataKeyCommand,\n\tGenerateMacCommand,\n\tKMSClient,\n} from '@aws-sdk/client-kms';\nimport { KMS_SCHEME } from '@geekmidas/manifest';\nimport {\n\tassociatedData,\n\ttype Cipher,\n\ttype CipherDriver,\n\tCiphertextNotAuthentic,\n\tEncryptionUrlInvalid,\n\tformatCiphertext,\n\topen,\n\tparseCiphertext,\n\tseal,\n} from './cipher';\n\n/** The ciphertext's key field: the version lives inside KMS's own blob. */\nconst KMS_KEY_ID = 'kms';\n\nexport function kmsCipher(construct: string, url: string): Cipher {\n\tconst parsed = new URL(url);\n\tconst region = parsed.hostname;\n\tconst keyId = parsed.searchParams.get('key');\n\tconst indexKeyId = parsed.searchParams.get('index');\n\tif (!region || !keyId || !indexKeyId) {\n\t\tthrow new EncryptionUrlInvalid(\n\t\t\tconstruct,\n\t\t\t'a kms:// URL names a region, a key and an index key',\n\t\t);\n\t}\n\n\tconst endpoint = parsed.searchParams.get('endpoint');\n\t// Credentials are not part of the address: the default chain — a Lambda's\n\t// role deployed, the environment against an emulator.\n\tconst kms = new KMSClient({ region, ...(endpoint ? { endpoint } : {}) });\n\t// What KMS checks on every decrypt, and what CloudTrail shows each call was\n\t// for — a data key minted for one construct will not open for another.\n\tconst context = { construct };\n\tconst aad = associatedData(construct, KMS_KEY_ID);\n\n\treturn {\n\t\tasync encrypt(plaintext) {\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew GenerateDataKeyCommand({\n\t\t\t\t\tKeyId: keyId,\n\t\t\t\t\tKeySpec: 'AES_256',\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst wrapped = Buffer.from(dataKey.CiphertextBlob!);\n\t\t\tconst sealed = seal(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tBuffer.from(plaintext, 'utf8'),\n\t\t\t\taad,\n\t\t\t);\n\n\t\t\tconst length = Buffer.alloc(2);\n\t\t\tlength.writeUInt16BE(wrapped.length);\n\t\t\treturn formatCiphertext(\n\t\t\t\tKMS_KEY_ID,\n\t\t\t\tBuffer.concat([length, wrapped, sealed]),\n\t\t\t);\n\t\t},\n\n\t\tasync decrypt(ciphertext) {\n\t\t\tconst { payload } = parseCiphertext(construct, ciphertext);\n\t\t\tconst length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;\n\t\t\tconst wrapped = payload.subarray(2, 2 + length);\n\t\t\tif (!length || wrapped.length !== length) {\n\t\t\t\tthrow new CiphertextNotAuthentic(construct);\n\t\t\t}\n\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew DecryptCommand({\n\t\t\t\t\tCiphertextBlob: wrapped,\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst plaintext = open(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tpayload.subarray(2 + length),\n\t\t\t\taad,\n\t\t\t);\n\t\t\tif (!plaintext) throw new CiphertextNotAuthentic(construct);\n\n\t\t\treturn plaintext.toString('utf8');\n\t\t},\n\n\t\tasync index(value) {\n\t\t\tconst { Mac } = await kms.send(\n\t\t\t\tnew GenerateMacCommand({\n\t\t\t\t\tKeyId: indexKeyId,\n\t\t\t\t\tMacAlgorithm: 'HMAC_SHA_256',\n\t\t\t\t\tMessage: Buffer.from(value, 'utf8'),\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn Buffer.from(Mac!).toString('base64url');\n\t\t},\n\n\t\t// KMS keeps every version it rotated through, so a value is never under\n\t\t// a key that could be retired from under it.\n\t\tasync reencrypt(ciphertext) {\n\t\t\tparseCiphertext(construct, ciphertext);\n\t\t\treturn ciphertext;\n\t\t},\n\t};\n}\n\n/** The `kms:` cipher, as an AWS build's entry registers it. */\nexport const kmsCipherDriver: CipherDriver = {\n\tscheme: KMS_SCHEME,\n\topen: kmsCipher,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,aAAa;AAEnB,SAAgB,UAAU,WAAmB,KAAqB;CACjE,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,SAAS,OAAO;CACtB,MAAM,QAAQ,OAAO,aAAa,IAAI,KAAK;CAC3C,MAAM,aAAa,OAAO,aAAa,IAAI,OAAO;CAClD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YACzB,MAAM,IAAIA,eAAAA,qBACT,WACA,qDACD;CAGD,MAAM,WAAW,OAAO,aAAa,IAAI,UAAU;CAGnD,MAAM,MAAM,IAAIC,oBAAAA,UAAU;EAAE;EAAQ,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAAG,CAAC;CAGvE,MAAM,UAAU,EAAE,UAAU;CAC5B,MAAM,MAAMC,eAAAA,eAAe,WAAW,UAAU;CAEhD,OAAO;EACN,MAAM,QAAQ,WAAW;GACxB,MAAM,UAAU,MAAM,IAAI,KACzB,IAAIC,oBAAAA,uBAAuB;IAC1B,OAAO;IACP,SAAS;IACT,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,UAAU,OAAO,KAAK,QAAQ,cAAe;GACnD,MAAM,SAASC,eAAAA,KACd,OAAO,KAAK,QAAQ,SAAU,GAC9B,OAAO,KAAK,WAAW,MAAM,GAC7B,GACD;GAEA,MAAM,SAAS,OAAO,MAAM,CAAC;GAC7B,OAAO,cAAc,QAAQ,MAAM;GACnC,OAAOC,eAAAA,iBACN,YACA,OAAO,OAAO;IAAC;IAAQ;IAAS;GAAM,CAAC,CACxC;EACD;EAEA,MAAM,QAAQ,YAAY;GACzB,MAAM,EAAE,YAAYC,eAAAA,gBAAgB,WAAW,UAAU;GACzD,MAAM,SAAS,QAAQ,UAAU,IAAI,QAAQ,aAAa,CAAC,IAAI;GAC/D,MAAM,UAAU,QAAQ,SAAS,GAAG,IAAI,MAAM;GAC9C,IAAI,CAAC,UAAU,QAAQ,WAAW,QACjC,MAAM,IAAIC,eAAAA,uBAAuB,SAAS;GAG3C,MAAM,UAAU,MAAM,IAAI,KACzB,IAAIC,oBAAAA,eAAe;IAClB,gBAAgB;IAChB,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,YAAYC,eAAAA,KACjB,OAAO,KAAK,QAAQ,SAAU,GAC9B,QAAQ,SAAS,IAAI,MAAM,GAC3B,GACD;GACA,IAAI,CAAC,WAAW,MAAM,IAAIF,eAAAA,uBAAuB,SAAS;GAE1D,OAAO,UAAU,SAAS,MAAM;EACjC;EAEA,MAAM,MAAM,OAAO;GAClB,MAAM,EAAE,QAAQ,MAAM,IAAI,KACzB,IAAIG,oBAAAA,mBAAmB;IACtB,OAAO;IACP,cAAc;IACd,SAAS,OAAO,KAAK,OAAO,MAAM;GACnC,CAAC,CACF;GACA,OAAO,OAAO,KAAK,GAAI,CAAC,CAAC,SAAS,WAAW;EAC9C;EAIA,MAAM,UAAU,YAAY;GAC3B,eAAA,gBAAgB,WAAW,UAAU;GACrC,OAAO;EACR;CACD;AACD;;AAGA,MAAa,kBAAgC;CAC5C,QAAQC,oBAAAA;CACR,MAAM;AACP"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { n as CipherDriver, t as Cipher } from "../cipher-DSDxPRIp.cjs";
|
|
2
|
+
//#region src/encryption/kms.d.ts
|
|
3
|
+
export declare function kmsCipher(construct: string, url: string): Cipher;
|
|
4
|
+
/** The `kms:` cipher, as an AWS build's entry registers it. */
|
|
5
|
+
export declare const kmsCipherDriver: CipherDriver;
|
|
6
|
+
//#endregion
|
|
7
|
+
//# sourceMappingURL=kms.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms.d.cts","names":[],"sources":["../../src/encryption/kms.ts"],"mappings":";;wBA4CgB,UAAU,mBAAmB,cAAc;;qBA0F9C,iBAAiB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { n as CipherDriver, t as Cipher } from "../cipher-DSDxPRIp.mjs";
|
|
2
|
+
//#region src/encryption/kms.d.ts
|
|
3
|
+
export declare function kmsCipher(construct: string, url: string): Cipher;
|
|
4
|
+
/** The `kms:` cipher, as an AWS build's entry registers it. */
|
|
5
|
+
export declare const kmsCipherDriver: CipherDriver;
|
|
6
|
+
//#endregion
|
|
7
|
+
//# sourceMappingURL=kms.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms.d.mts","names":[],"sources":["../../src/encryption/kms.ts"],"mappings":";;wBA4CgB,UAAU,mBAAmB,cAAc;;qBA0F9C,iBAAiB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { a as EncryptionUrlInvalid, c as associatedData, l as formatCiphertext, m as parseCiphertext, n as CiphertextNotAuthentic, p as open, v as seal } from "../cipher-C1lEFX63.mjs";
|
|
2
|
+
import { KMS_SCHEME } from "@geekmidas/manifest";
|
|
3
|
+
import { DecryptCommand, GenerateDataKeyCommand, GenerateMacCommand, KMSClient } from "@aws-sdk/client-kms";
|
|
4
|
+
//#region src/encryption/kms.ts
|
|
5
|
+
/**
|
|
6
|
+
* The `kms://` cipher: envelope encryption under an AWS KMS key.
|
|
7
|
+
*
|
|
8
|
+
* Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it
|
|
9
|
+
* locally, and stores the data key *as KMS encrypted it* beside the data. The
|
|
10
|
+
* plaintext data key is used once and dropped, and the master key never leaves
|
|
11
|
+
* KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.
|
|
12
|
+
*
|
|
13
|
+
* Rotation is KMS's: it keeps every backing version of the key, and the
|
|
14
|
+
* encrypted data key names the one that wrapped it, so nothing here tracks a
|
|
15
|
+
* version and `reencrypt` has nothing to move. The ciphertext's key field is
|
|
16
|
+
* `kms` for that reason.
|
|
17
|
+
*
|
|
18
|
+
* The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the
|
|
19
|
+
* key is as unextractable as the encryption key.
|
|
20
|
+
*
|
|
21
|
+
* In its own entry, `@geekmidas/constructs/encryption/kms`, which only an
|
|
22
|
+
* AWS build's generated entry imports — to register {@link kmsCipherDriver}
|
|
23
|
+
* — so a project that never deploys to AWS never needs
|
|
24
|
+
* `@aws-sdk/client-kms` installed, and its bundle never mentions it.
|
|
25
|
+
*/
|
|
26
|
+
/** The ciphertext's key field: the version lives inside KMS's own blob. */
|
|
27
|
+
const KMS_KEY_ID = "kms";
|
|
28
|
+
function kmsCipher(construct, url) {
|
|
29
|
+
const parsed = new URL(url);
|
|
30
|
+
const region = parsed.hostname;
|
|
31
|
+
const keyId = parsed.searchParams.get("key");
|
|
32
|
+
const indexKeyId = parsed.searchParams.get("index");
|
|
33
|
+
if (!region || !keyId || !indexKeyId) throw new EncryptionUrlInvalid(construct, "a kms:// URL names a region, a key and an index key");
|
|
34
|
+
const endpoint = parsed.searchParams.get("endpoint");
|
|
35
|
+
const kms = new KMSClient({
|
|
36
|
+
region,
|
|
37
|
+
...endpoint ? { endpoint } : {}
|
|
38
|
+
});
|
|
39
|
+
const context = { construct };
|
|
40
|
+
const aad = associatedData(construct, KMS_KEY_ID);
|
|
41
|
+
return {
|
|
42
|
+
async encrypt(plaintext) {
|
|
43
|
+
const dataKey = await kms.send(new GenerateDataKeyCommand({
|
|
44
|
+
KeyId: keyId,
|
|
45
|
+
KeySpec: "AES_256",
|
|
46
|
+
EncryptionContext: context
|
|
47
|
+
}));
|
|
48
|
+
const wrapped = Buffer.from(dataKey.CiphertextBlob);
|
|
49
|
+
const sealed = seal(Buffer.from(dataKey.Plaintext), Buffer.from(plaintext, "utf8"), aad);
|
|
50
|
+
const length = Buffer.alloc(2);
|
|
51
|
+
length.writeUInt16BE(wrapped.length);
|
|
52
|
+
return formatCiphertext(KMS_KEY_ID, Buffer.concat([
|
|
53
|
+
length,
|
|
54
|
+
wrapped,
|
|
55
|
+
sealed
|
|
56
|
+
]));
|
|
57
|
+
},
|
|
58
|
+
async decrypt(ciphertext) {
|
|
59
|
+
const { payload } = parseCiphertext(construct, ciphertext);
|
|
60
|
+
const length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;
|
|
61
|
+
const wrapped = payload.subarray(2, 2 + length);
|
|
62
|
+
if (!length || wrapped.length !== length) throw new CiphertextNotAuthentic(construct);
|
|
63
|
+
const dataKey = await kms.send(new DecryptCommand({
|
|
64
|
+
CiphertextBlob: wrapped,
|
|
65
|
+
EncryptionContext: context
|
|
66
|
+
}));
|
|
67
|
+
const plaintext = open(Buffer.from(dataKey.Plaintext), payload.subarray(2 + length), aad);
|
|
68
|
+
if (!plaintext) throw new CiphertextNotAuthentic(construct);
|
|
69
|
+
return plaintext.toString("utf8");
|
|
70
|
+
},
|
|
71
|
+
async index(value) {
|
|
72
|
+
const { Mac } = await kms.send(new GenerateMacCommand({
|
|
73
|
+
KeyId: indexKeyId,
|
|
74
|
+
MacAlgorithm: "HMAC_SHA_256",
|
|
75
|
+
Message: Buffer.from(value, "utf8")
|
|
76
|
+
}));
|
|
77
|
+
return Buffer.from(Mac).toString("base64url");
|
|
78
|
+
},
|
|
79
|
+
async reencrypt(ciphertext) {
|
|
80
|
+
parseCiphertext(construct, ciphertext);
|
|
81
|
+
return ciphertext;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** The `kms:` cipher, as an AWS build's entry registers it. */
|
|
86
|
+
const kmsCipherDriver = {
|
|
87
|
+
scheme: KMS_SCHEME,
|
|
88
|
+
open: kmsCipher
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { kmsCipher, kmsCipherDriver };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=kms.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms.mjs","names":[],"sources":["../../src/encryption/kms.ts"],"sourcesContent":["/**\n * The `kms://` cipher: envelope encryption under an AWS KMS key.\n *\n * Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it\n * locally, and stores the data key *as KMS encrypted it* beside the data. The\n * plaintext data key is used once and dropped, and the master key never leaves\n * KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.\n *\n * Rotation is KMS's: it keeps every backing version of the key, and the\n * encrypted data key names the one that wrapped it, so nothing here tracks a\n * version and `reencrypt` has nothing to move. The ciphertext's key field is\n * `kms` for that reason.\n *\n * The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the\n * key is as unextractable as the encryption key.\n *\n * In its own entry, `@geekmidas/constructs/encryption/kms`, which only an\n * AWS build's generated entry imports — to register {@link kmsCipherDriver}\n * — so a project that never deploys to AWS never needs\n * `@aws-sdk/client-kms` installed, and its bundle never mentions it.\n */\n\nimport {\n\tDecryptCommand,\n\tGenerateDataKeyCommand,\n\tGenerateMacCommand,\n\tKMSClient,\n} from '@aws-sdk/client-kms';\nimport { KMS_SCHEME } from '@geekmidas/manifest';\nimport {\n\tassociatedData,\n\ttype Cipher,\n\ttype CipherDriver,\n\tCiphertextNotAuthentic,\n\tEncryptionUrlInvalid,\n\tformatCiphertext,\n\topen,\n\tparseCiphertext,\n\tseal,\n} from './cipher';\n\n/** The ciphertext's key field: the version lives inside KMS's own blob. */\nconst KMS_KEY_ID = 'kms';\n\nexport function kmsCipher(construct: string, url: string): Cipher {\n\tconst parsed = new URL(url);\n\tconst region = parsed.hostname;\n\tconst keyId = parsed.searchParams.get('key');\n\tconst indexKeyId = parsed.searchParams.get('index');\n\tif (!region || !keyId || !indexKeyId) {\n\t\tthrow new EncryptionUrlInvalid(\n\t\t\tconstruct,\n\t\t\t'a kms:// URL names a region, a key and an index key',\n\t\t);\n\t}\n\n\tconst endpoint = parsed.searchParams.get('endpoint');\n\t// Credentials are not part of the address: the default chain — a Lambda's\n\t// role deployed, the environment against an emulator.\n\tconst kms = new KMSClient({ region, ...(endpoint ? { endpoint } : {}) });\n\t// What KMS checks on every decrypt, and what CloudTrail shows each call was\n\t// for — a data key minted for one construct will not open for another.\n\tconst context = { construct };\n\tconst aad = associatedData(construct, KMS_KEY_ID);\n\n\treturn {\n\t\tasync encrypt(plaintext) {\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew GenerateDataKeyCommand({\n\t\t\t\t\tKeyId: keyId,\n\t\t\t\t\tKeySpec: 'AES_256',\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst wrapped = Buffer.from(dataKey.CiphertextBlob!);\n\t\t\tconst sealed = seal(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tBuffer.from(plaintext, 'utf8'),\n\t\t\t\taad,\n\t\t\t);\n\n\t\t\tconst length = Buffer.alloc(2);\n\t\t\tlength.writeUInt16BE(wrapped.length);\n\t\t\treturn formatCiphertext(\n\t\t\t\tKMS_KEY_ID,\n\t\t\t\tBuffer.concat([length, wrapped, sealed]),\n\t\t\t);\n\t\t},\n\n\t\tasync decrypt(ciphertext) {\n\t\t\tconst { payload } = parseCiphertext(construct, ciphertext);\n\t\t\tconst length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;\n\t\t\tconst wrapped = payload.subarray(2, 2 + length);\n\t\t\tif (!length || wrapped.length !== length) {\n\t\t\t\tthrow new CiphertextNotAuthentic(construct);\n\t\t\t}\n\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew DecryptCommand({\n\t\t\t\t\tCiphertextBlob: wrapped,\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst plaintext = open(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tpayload.subarray(2 + length),\n\t\t\t\taad,\n\t\t\t);\n\t\t\tif (!plaintext) throw new CiphertextNotAuthentic(construct);\n\n\t\t\treturn plaintext.toString('utf8');\n\t\t},\n\n\t\tasync index(value) {\n\t\t\tconst { Mac } = await kms.send(\n\t\t\t\tnew GenerateMacCommand({\n\t\t\t\t\tKeyId: indexKeyId,\n\t\t\t\t\tMacAlgorithm: 'HMAC_SHA_256',\n\t\t\t\t\tMessage: Buffer.from(value, 'utf8'),\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn Buffer.from(Mac!).toString('base64url');\n\t\t},\n\n\t\t// KMS keeps every version it rotated through, so a value is never under\n\t\t// a key that could be retired from under it.\n\t\tasync reencrypt(ciphertext) {\n\t\t\tparseCiphertext(construct, ciphertext);\n\t\t\treturn ciphertext;\n\t\t},\n\t};\n}\n\n/** The `kms:` cipher, as an AWS build's entry registers it. */\nexport const kmsCipherDriver: CipherDriver = {\n\tscheme: KMS_SCHEME,\n\topen: kmsCipher,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,aAAa;AAEnB,SAAgB,UAAU,WAAmB,KAAqB;CACjE,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,SAAS,OAAO;CACtB,MAAM,QAAQ,OAAO,aAAa,IAAI,KAAK;CAC3C,MAAM,aAAa,OAAO,aAAa,IAAI,OAAO;CAClD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YACzB,MAAM,IAAI,qBACT,WACA,qDACD;CAGD,MAAM,WAAW,OAAO,aAAa,IAAI,UAAU;CAGnD,MAAM,MAAM,IAAI,UAAU;EAAE;EAAQ,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAAG,CAAC;CAGvE,MAAM,UAAU,EAAE,UAAU;CAC5B,MAAM,MAAM,eAAe,WAAW,UAAU;CAEhD,OAAO;EACN,MAAM,QAAQ,WAAW;GACxB,MAAM,UAAU,MAAM,IAAI,KACzB,IAAI,uBAAuB;IAC1B,OAAO;IACP,SAAS;IACT,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,UAAU,OAAO,KAAK,QAAQ,cAAe;GACnD,MAAM,SAAS,KACd,OAAO,KAAK,QAAQ,SAAU,GAC9B,OAAO,KAAK,WAAW,MAAM,GAC7B,GACD;GAEA,MAAM,SAAS,OAAO,MAAM,CAAC;GAC7B,OAAO,cAAc,QAAQ,MAAM;GACnC,OAAO,iBACN,YACA,OAAO,OAAO;IAAC;IAAQ;IAAS;GAAM,CAAC,CACxC;EACD;EAEA,MAAM,QAAQ,YAAY;GACzB,MAAM,EAAE,YAAY,gBAAgB,WAAW,UAAU;GACzD,MAAM,SAAS,QAAQ,UAAU,IAAI,QAAQ,aAAa,CAAC,IAAI;GAC/D,MAAM,UAAU,QAAQ,SAAS,GAAG,IAAI,MAAM;GAC9C,IAAI,CAAC,UAAU,QAAQ,WAAW,QACjC,MAAM,IAAI,uBAAuB,SAAS;GAG3C,MAAM,UAAU,MAAM,IAAI,KACzB,IAAI,eAAe;IAClB,gBAAgB;IAChB,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,YAAY,KACjB,OAAO,KAAK,QAAQ,SAAU,GAC9B,QAAQ,SAAS,IAAI,MAAM,GAC3B,GACD;GACA,IAAI,CAAC,WAAW,MAAM,IAAI,uBAAuB,SAAS;GAE1D,OAAO,UAAU,SAAS,MAAM;EACjC;EAEA,MAAM,MAAM,OAAO;GAClB,MAAM,EAAE,QAAQ,MAAM,IAAI,KACzB,IAAI,mBAAmB;IACtB,OAAO;IACP,cAAc;IACd,SAAS,OAAO,KAAK,OAAO,MAAM;GACnC,CAAC,CACF;GACA,OAAO,OAAO,KAAK,GAAI,CAAC,CAAC,SAAS,WAAW;EAC9C;EAIA,MAAM,UAAU,YAAY;GAC3B,gBAAgB,WAAW,UAAU;GACrC,OAAO;EACR;CACD;AACD;;AAGA,MAAa,kBAAgC;CAC5C,QAAQ;CACR,MAAM;AACP"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_cipher = require("./cipher-CVxfwLjk.cjs");
|
|
3
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
4
|
+
//#region src/encryption.ts
|
|
5
|
+
/**
|
|
6
|
+
* `Encryption` — a key that encrypts what the application stores.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* export const pii = new Encryption('Pii');
|
|
10
|
+
*
|
|
11
|
+
* // an endpoint that `.dependsOn([pii])`
|
|
12
|
+
* const email = await services.pii.encrypt(body.email);
|
|
13
|
+
* const emailIndex = await services.pii.index(body.email);
|
|
14
|
+
* await db.insertInto('users').values({ email, emailIndex }).execute();
|
|
15
|
+
*
|
|
16
|
+
* // and to find them again, without decrypting a column
|
|
17
|
+
* db.selectFrom('users').where('emailIndex', '=', await services.pii.index(q));
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* The app names no cipher and holds no key. The construct provides one URL,
|
|
21
|
+
* `<ID>_URL`, and its scheme picks the backend the way a queue's connection
|
|
22
|
+
* string picks its broker:
|
|
23
|
+
*
|
|
24
|
+
* - **AWS** — `kms://`: envelope encryption under a KMS key that rotates
|
|
25
|
+
* yearly, and a KMS HMAC key for the index. Only a function that depends on
|
|
26
|
+
* the construct is granted either key.
|
|
27
|
+
* - **Server, local, tests** — `aes256gcm://`: a keyring the process holds.
|
|
28
|
+
* Derived locally, so `gkm dev` and `gkm test` need nothing set; generated
|
|
29
|
+
* into a server stage's secrets on its first deploy, and rotated there with
|
|
30
|
+
* `gkm encryption:rotate`.
|
|
31
|
+
*
|
|
32
|
+
* Every ciphertext names the key that wrote it, so a rotated key still opens
|
|
33
|
+
* what it wrote. Retiring one is explicit — `reencrypt` the column, then
|
|
34
|
+
* `gkm encryption:retire` — and a value still under an old key says so when it
|
|
35
|
+
* is decrypted, once per key per process.
|
|
36
|
+
*/
|
|
37
|
+
const drivers = /* @__PURE__ */ new Map();
|
|
38
|
+
/** Make a cipher available for its scheme. Idempotent. */
|
|
39
|
+
function registerCipherDriver(driver) {
|
|
40
|
+
drivers.set(driver.scheme, driver);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A key whose URL names a cipher this process registered no driver for —
|
|
44
|
+
* `kms:` in an entry built for a target whose keys are local.
|
|
45
|
+
*/
|
|
46
|
+
var UnregisteredEncryptionScheme = class extends Error {
|
|
47
|
+
construct;
|
|
48
|
+
scheme;
|
|
49
|
+
constructor(construct, scheme) {
|
|
50
|
+
super(`${construct}'s key is a '${scheme}' URL, and this build registered no cipher for it. ` + (scheme === _geekmidas_manifest.KMS_SCHEME ? "A KMS key is an AWS target's: build for it (gkm build --provider aws), which registers the KMS cipher and needs @aws-sdk/client-kms installed." : "Register its driver with registerCipherDriver before the first request."));
|
|
51
|
+
this.construct = construct;
|
|
52
|
+
this.scheme = scheme;
|
|
53
|
+
this.name = "UnregisteredEncryptionScheme";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var Encryption = class {
|
|
57
|
+
id;
|
|
58
|
+
service;
|
|
59
|
+
/**
|
|
60
|
+
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
61
|
+
* target publishes and the key the client reads cannot drift.
|
|
62
|
+
*/
|
|
63
|
+
key;
|
|
64
|
+
/**
|
|
65
|
+
* One cipher per process, held as the promise: a keyring is parsed once and
|
|
66
|
+
* a KMS client is built once, however many handlers register it at once.
|
|
67
|
+
*/
|
|
68
|
+
cipher;
|
|
69
|
+
constructor(id) {
|
|
70
|
+
const canonical = (0, _geekmidas_manifest.canonicalId)(id);
|
|
71
|
+
this.id = canonical;
|
|
72
|
+
this.key = (0, _geekmidas_manifest.provideKey)(canonical, "url");
|
|
73
|
+
this.service = {
|
|
74
|
+
serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
|
|
75
|
+
register: (options) => this.connect(options)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare() {
|
|
79
|
+
return [{
|
|
80
|
+
kind: "encryption",
|
|
81
|
+
id: this.id,
|
|
82
|
+
provides: [this.key]
|
|
83
|
+
}];
|
|
84
|
+
}
|
|
85
|
+
connect(options) {
|
|
86
|
+
this.cipher ??= this.open(options);
|
|
87
|
+
return this.cipher;
|
|
88
|
+
}
|
|
89
|
+
async open(options) {
|
|
90
|
+
const { url } = options.envParser.create((get) => ({ url: get(this.key).string() })).parse();
|
|
91
|
+
const scheme = url.slice(0, url.indexOf(":") + 1);
|
|
92
|
+
if (scheme === "aes256gcm:") return require_cipher.keyringCipher(this.id, url, (stale, current) => console.warn(`${this.id} decrypted a value still under '${stale}' (current: '${current}'). reencrypt it, and retire '${stale}' once nothing is left under it.`));
|
|
93
|
+
const driver = drivers.get(scheme);
|
|
94
|
+
if (driver) return driver.open(this.id, url);
|
|
95
|
+
if (scheme === _geekmidas_manifest.KMS_SCHEME) throw new UnregisteredEncryptionScheme(this.id, scheme);
|
|
96
|
+
throw new require_cipher.UnknownEncryptionScheme(this.id, scheme);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
exports.CiphertextMalformed = require_cipher.CiphertextMalformed;
|
|
101
|
+
exports.CiphertextNotAuthentic = require_cipher.CiphertextNotAuthentic;
|
|
102
|
+
exports.CurrentKeyCannotRetire = require_cipher.CurrentKeyCannotRetire;
|
|
103
|
+
exports.Encryption = Encryption;
|
|
104
|
+
exports.EncryptionKeyRetired = require_cipher.EncryptionKeyRetired;
|
|
105
|
+
exports.EncryptionUrlInvalid = require_cipher.EncryptionUrlInvalid;
|
|
106
|
+
exports.UnknownEncryptionScheme = require_cipher.UnknownEncryptionScheme;
|
|
107
|
+
exports.UnregisteredEncryptionScheme = UnregisteredEncryptionScheme;
|
|
108
|
+
exports.formatKeyring = require_cipher.formatKeyring;
|
|
109
|
+
exports.generateKeyring = require_cipher.generateKeyring;
|
|
110
|
+
exports.keyringCipher = require_cipher.keyringCipher;
|
|
111
|
+
exports.parseKeyring = require_cipher.parseKeyring;
|
|
112
|
+
exports.registerCipherDriver = registerCipherDriver;
|
|
113
|
+
exports.retireKey = require_cipher.retireKey;
|
|
114
|
+
exports.rotateKeyring = require_cipher.rotateKeyring;
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=encryption.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.cjs","names":["KMS_SCHEME","canonicalId","provideKey","serviceKey","keyringCipher","UnknownEncryptionScheme"],"sources":["../src/encryption.ts"],"sourcesContent":["/**\n * `Encryption` — a key that encrypts what the application stores.\n *\n * ```ts\n * export const pii = new Encryption('Pii');\n *\n * // an endpoint that `.dependsOn([pii])`\n * const email = await services.pii.encrypt(body.email);\n * const emailIndex = await services.pii.index(body.email);\n * await db.insertInto('users').values({ email, emailIndex }).execute();\n *\n * // and to find them again, without decrypting a column\n * db.selectFrom('users').where('emailIndex', '=', await services.pii.index(q));\n * ```\n *\n * The app names no cipher and holds no key. The construct provides one URL,\n * `<ID>_URL`, and its scheme picks the backend the way a queue's connection\n * string picks its broker:\n *\n * - **AWS** — `kms://`: envelope encryption under a KMS key that rotates\n * yearly, and a KMS HMAC key for the index. Only a function that depends on\n * the construct is granted either key.\n * - **Server, local, tests** — `aes256gcm://`: a keyring the process holds.\n * Derived locally, so `gkm dev` and `gkm test` need nothing set; generated\n * into a server stage's secrets on its first deploy, and rotated there with\n * `gkm encryption:rotate`.\n *\n * Every ciphertext names the key that wrote it, so a rotated key still opens\n * what it wrote. Retiring one is explicit — `reencrypt` the column, then\n * `gkm encryption:retire` — and a value still under an old key says so when it\n * is decrypted, once per key per process.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tKMS_SCHEME,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\nimport {\n\ttype Cipher,\n\ttype CipherDriver,\n\tkeyringCipher,\n\tLOCAL_SCHEME,\n\tUnknownEncryptionScheme,\n} from './encryption/cipher';\n\nexport type { Cipher, CipherDriver } from './encryption/cipher';\nexport {\n\tCiphertextMalformed,\n\tCiphertextNotAuthentic,\n\tCurrentKeyCannotRetire,\n\tEncryptionKeyRetired,\n\tEncryptionUrlInvalid,\n\tformatKeyring,\n\tgenerateKeyring,\n\ttype Keyring,\n\tkeyringCipher,\n\tparseKeyring,\n\tretireKey,\n\trotateKeyring,\n\tUnknownEncryptionScheme,\n} from './encryption/cipher';\n\nconst drivers = new Map<string, CipherDriver>();\n\n/** Make a cipher available for its scheme. Idempotent. */\nexport function registerCipherDriver(driver: CipherDriver): void {\n\tdrivers.set(driver.scheme, driver);\n}\n\n/**\n * A key whose URL names a cipher this process registered no driver for —\n * `kms:` in an entry built for a target whose keys are local.\n */\nexport class UnregisteredEncryptionScheme extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly scheme: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}'s key is a '${scheme}' URL, and this build registered no cipher for it. ` +\n\t\t\t\t(scheme === KMS_SCHEME\n\t\t\t\t\t? \"A KMS key is an AWS target's: build for it (gkm build --provider aws), which registers the KMS cipher and needs @aws-sdk/client-kms installed.\"\n\t\t\t\t\t: 'Register its driver with registerCipherDriver before the first request.'),\n\t\t);\n\t\tthis.name = 'UnregisteredEncryptionScheme';\n\t}\n}\n\nexport class Encryption<TName extends string = string>\n\timplements Construct<TName, Cipher>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Cipher>;\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 key: string;\n\n\t/**\n\t * One cipher per process, held as the promise: a keyring is parsed once and\n\t * a KMS client is built once, however many handlers register it at once.\n\t */\n\tprivate cipher?: Promise<Cipher>;\n\n\tconstructor(id: ConstructName<TName>) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = provideKey(canonical, 'url');\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: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [{ kind: 'encryption', id: this.id, provides: [this.key] }];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Cipher> {\n\t\tthis.cipher ??= this.open(options);\n\t\treturn this.cipher;\n\t}\n\n\tprivate async open(options: ServiceRegisterOptions): Promise<Cipher> {\n\t\tconst { url } = options.envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\t\tconst scheme = url.slice(0, url.indexOf(':') + 1);\n\n\t\tif (scheme === LOCAL_SCHEME) {\n\t\t\treturn keyringCipher(this.id, url, (stale, current) =>\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${this.id} decrypted a value still under '${stale}' (current: '${current}'). reencrypt it, and retire '${stale}' once nothing is left under it.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\t// Registered by the entry a build generates, only for a target whose\n\t\t// keys live there — so no other process imports that cipher's SDK.\n\t\tconst driver = drivers.get(scheme);\n\t\tif (driver) return driver.open(this.id, url);\n\t\tif (scheme === KMS_SCHEME) {\n\t\t\tthrow new UnregisteredEncryptionScheme(this.id, scheme);\n\t\t}\n\n\t\tthrow new UnknownEncryptionScheme(this.id, scheme);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,0BAAU,IAAI,IAA0B;;AAG9C,SAAgB,qBAAqB,QAA4B;CAChE,QAAQ,IAAI,OAAO,QAAQ,MAAM;AAClC;;;;;AAMA,IAAa,+BAAb,cAAkD,MAAM;CAE7C;CACA;CAFV,YACC,WACA,QACC;EACD,MACC,GAAG,UAAU,eAAe,OAAO,wDACjC,WAAWA,oBAAAA,aACT,mJACA,0EACL;EARS,KAAA,YAAA;EACA,KAAA,SAAA;EAQT,KAAK,OAAO;CACb;AACD;AAEA,IAAa,aAAb,MAEA;CACC;CACA;;;;;CAMA;;;;;CAMA;CAEA,YAAY,IAA0B;EACrC,MAAM,aAAA,GAAYC,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAA,GAAMC,oBAAAA,WAAAA,CAAW,WAAW,KAAK;EAGtC,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CAAC;GAAE,MAAM;GAAc,IAAI,KAAK;GAAI,UAAU,CAAC,KAAK,GAAG;EAAE,CAAC;CAClE;CAEA,QAAgB,SAAkD;EACjE,KAAK,WAAW,KAAK,KAAK,OAAO;EACjC,OAAO,KAAK;CACb;CAEA,MAAc,KAAK,SAAkD;EACpE,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EACR,MAAM,SAAS,IAAI,MAAM,GAAG,IAAI,QAAQ,GAAG,IAAI,CAAC;EAEhD,IAAI,WAAA,cACH,OAAOC,eAAAA,cAAc,KAAK,IAAI,MAAM,OAAO,YAC1C,QAAQ,KACP,GAAG,KAAK,GAAG,kCAAkC,MAAM,eAAe,QAAQ,gCAAgC,MAAM,iCACjH,CACD;EAKD,MAAM,SAAS,QAAQ,IAAI,MAAM;EACjC,IAAI,QAAQ,OAAO,OAAO,KAAK,KAAK,IAAI,GAAG;EAC3C,IAAI,WAAWJ,oBAAAA,YACd,MAAM,IAAI,6BAA6B,KAAK,IAAI,MAAM;EAGvD,MAAM,IAAIK,eAAAA,wBAAwB,KAAK,IAAI,MAAM;CAClD;AACD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { n as Construct } from "./construct-interface-B1AfqRl4.cjs";
|
|
2
|
+
import { a as CurrentKeyCannotRetire, c as Keyring, d as generateKeyring, f as keyringCipher, h as rotateKeyring, i as CiphertextNotAuthentic, l as UnknownEncryptionScheme, m as retireKey, n as CipherDriver, o as EncryptionKeyRetired, p as parseKeyring, r as CiphertextMalformed, s as EncryptionUrlInvalid, t as Cipher, u as formatKeyring } from "./cipher-DSDxPRIp.cjs";
|
|
3
|
+
import { Service } from "@geekmidas/services";
|
|
4
|
+
import { ConstructName, Declaration } from "@geekmidas/manifest";
|
|
5
|
+
//#region src/encryption.d.ts
|
|
6
|
+
/** Make a cipher available for its scheme. Idempotent. */
|
|
7
|
+
export declare function registerCipherDriver(driver: CipherDriver): void;
|
|
8
|
+
/**
|
|
9
|
+
* A key whose URL names a cipher this process registered no driver for —
|
|
10
|
+
* `kms:` in an entry built for a target whose keys are local.
|
|
11
|
+
*/
|
|
12
|
+
export declare class UnregisteredEncryptionScheme extends Error {
|
|
13
|
+
readonly construct: string;
|
|
14
|
+
readonly scheme: string;
|
|
15
|
+
constructor(construct: string, scheme: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class Encryption<TName extends string = string> implements Construct<TName, Cipher> {
|
|
18
|
+
readonly id: TName;
|
|
19
|
+
readonly service: Service<Uncapitalize<TName>, Cipher>;
|
|
20
|
+
/**
|
|
21
|
+
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
22
|
+
* target publishes and the key the client reads cannot drift.
|
|
23
|
+
*/
|
|
24
|
+
private readonly key;
|
|
25
|
+
/**
|
|
26
|
+
* One cipher per process, held as the promise: a keyring is parsed once and
|
|
27
|
+
* a KMS client is built once, however many handlers register it at once.
|
|
28
|
+
*/
|
|
29
|
+
private cipher?;
|
|
30
|
+
constructor(id: ConstructName<TName>);
|
|
31
|
+
declare(): Declaration[];
|
|
32
|
+
private connect;
|
|
33
|
+
private open;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { type Cipher, type CipherDriver, CiphertextMalformed, CiphertextNotAuthentic, CurrentKeyCannotRetire, EncryptionKeyRetired, EncryptionUrlInvalid, type Keyring, UnknownEncryptionScheme, formatKeyring, generateKeyring, keyringCipher, parseKeyring, retireKey, rotateKeyring };
|
|
37
|
+
//# sourceMappingURL=encryption.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.cts","names":[],"sources":["../src/encryption.ts"],"mappings":";;;;;;wBAuEgB,qBAAqB,QAAQ;;;;;qBAQhC,qCAAqC;WAEvC;WACA;EAFV,YACU,mBACA;;qBAYE,WAAW,0CACZ,UAAU,OAAO;WAEnB,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;;;;;mBAM9B;;;;;UAMT;EAER,YAAY,IAAI,cAAc;EAa9B,WAAW;UAIH;UAKM"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { n as Construct } from "./construct-interface-ZvYQbivO.mjs";
|
|
2
|
+
import { a as CurrentKeyCannotRetire, c as Keyring, d as generateKeyring, f as keyringCipher, h as rotateKeyring, i as CiphertextNotAuthentic, l as UnknownEncryptionScheme, m as retireKey, n as CipherDriver, o as EncryptionKeyRetired, p as parseKeyring, r as CiphertextMalformed, s as EncryptionUrlInvalid, t as Cipher, u as formatKeyring } from "./cipher-DSDxPRIp.mjs";
|
|
3
|
+
import { ConstructName, Declaration } from "@geekmidas/manifest";
|
|
4
|
+
import { Service } from "@geekmidas/services";
|
|
5
|
+
//#region src/encryption.d.ts
|
|
6
|
+
/** Make a cipher available for its scheme. Idempotent. */
|
|
7
|
+
export declare function registerCipherDriver(driver: CipherDriver): void;
|
|
8
|
+
/**
|
|
9
|
+
* A key whose URL names a cipher this process registered no driver for —
|
|
10
|
+
* `kms:` in an entry built for a target whose keys are local.
|
|
11
|
+
*/
|
|
12
|
+
export declare class UnregisteredEncryptionScheme extends Error {
|
|
13
|
+
readonly construct: string;
|
|
14
|
+
readonly scheme: string;
|
|
15
|
+
constructor(construct: string, scheme: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class Encryption<TName extends string = string> implements Construct<TName, Cipher> {
|
|
18
|
+
readonly id: TName;
|
|
19
|
+
readonly service: Service<Uncapitalize<TName>, Cipher>;
|
|
20
|
+
/**
|
|
21
|
+
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
22
|
+
* target publishes and the key the client reads cannot drift.
|
|
23
|
+
*/
|
|
24
|
+
private readonly key;
|
|
25
|
+
/**
|
|
26
|
+
* One cipher per process, held as the promise: a keyring is parsed once and
|
|
27
|
+
* a KMS client is built once, however many handlers register it at once.
|
|
28
|
+
*/
|
|
29
|
+
private cipher?;
|
|
30
|
+
constructor(id: ConstructName<TName>);
|
|
31
|
+
declare(): Declaration[];
|
|
32
|
+
private connect;
|
|
33
|
+
private open;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { type Cipher, type CipherDriver, CiphertextMalformed, CiphertextNotAuthentic, CurrentKeyCannotRetire, EncryptionKeyRetired, EncryptionUrlInvalid, type Keyring, UnknownEncryptionScheme, formatKeyring, generateKeyring, keyringCipher, parseKeyring, retireKey, rotateKeyring };
|
|
37
|
+
//# sourceMappingURL=encryption.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.mts","names":[],"sources":["../src/encryption.ts"],"mappings":";;;;;;wBAuEgB,qBAAqB,QAAQ;;;;;qBAQhC,qCAAqC;WAEvC;WACA;EAFV,YACU,mBACA;;qBAYE,WAAW,0CACZ,UAAU,OAAO;WAEnB,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;;;;;mBAM9B;;;;;UAMT;EAER,YAAY,IAAI,cAAc;EAa9B,WAAW;UAIH;UAKM"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { _ as rotateKeyring, a as EncryptionUrlInvalid, d as generateKeyring, f as keyringCipher, g as retireKey, h as parseKeyring, i as EncryptionKeyRetired, n as CiphertextNotAuthentic, r as CurrentKeyCannotRetire, s as UnknownEncryptionScheme, t as CiphertextMalformed, u as formatKeyring } from "./cipher-C1lEFX63.mjs";
|
|
2
|
+
import { KMS_SCHEME, canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
3
|
+
//#region src/encryption.ts
|
|
4
|
+
/**
|
|
5
|
+
* `Encryption` — a key that encrypts what the application stores.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* export const pii = new Encryption('Pii');
|
|
9
|
+
*
|
|
10
|
+
* // an endpoint that `.dependsOn([pii])`
|
|
11
|
+
* const email = await services.pii.encrypt(body.email);
|
|
12
|
+
* const emailIndex = await services.pii.index(body.email);
|
|
13
|
+
* await db.insertInto('users').values({ email, emailIndex }).execute();
|
|
14
|
+
*
|
|
15
|
+
* // and to find them again, without decrypting a column
|
|
16
|
+
* db.selectFrom('users').where('emailIndex', '=', await services.pii.index(q));
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The app names no cipher and holds no key. The construct provides one URL,
|
|
20
|
+
* `<ID>_URL`, and its scheme picks the backend the way a queue's connection
|
|
21
|
+
* string picks its broker:
|
|
22
|
+
*
|
|
23
|
+
* - **AWS** — `kms://`: envelope encryption under a KMS key that rotates
|
|
24
|
+
* yearly, and a KMS HMAC key for the index. Only a function that depends on
|
|
25
|
+
* the construct is granted either key.
|
|
26
|
+
* - **Server, local, tests** — `aes256gcm://`: a keyring the process holds.
|
|
27
|
+
* Derived locally, so `gkm dev` and `gkm test` need nothing set; generated
|
|
28
|
+
* into a server stage's secrets on its first deploy, and rotated there with
|
|
29
|
+
* `gkm encryption:rotate`.
|
|
30
|
+
*
|
|
31
|
+
* Every ciphertext names the key that wrote it, so a rotated key still opens
|
|
32
|
+
* what it wrote. Retiring one is explicit — `reencrypt` the column, then
|
|
33
|
+
* `gkm encryption:retire` — and a value still under an old key says so when it
|
|
34
|
+
* is decrypted, once per key per process.
|
|
35
|
+
*/
|
|
36
|
+
const drivers = /* @__PURE__ */ new Map();
|
|
37
|
+
/** Make a cipher available for its scheme. Idempotent. */
|
|
38
|
+
function registerCipherDriver(driver) {
|
|
39
|
+
drivers.set(driver.scheme, driver);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A key whose URL names a cipher this process registered no driver for —
|
|
43
|
+
* `kms:` in an entry built for a target whose keys are local.
|
|
44
|
+
*/
|
|
45
|
+
var UnregisteredEncryptionScheme = class extends Error {
|
|
46
|
+
construct;
|
|
47
|
+
scheme;
|
|
48
|
+
constructor(construct, scheme) {
|
|
49
|
+
super(`${construct}'s key is a '${scheme}' URL, and this build registered no cipher for it. ` + (scheme === KMS_SCHEME ? "A KMS key is an AWS target's: build for it (gkm build --provider aws), which registers the KMS cipher and needs @aws-sdk/client-kms installed." : "Register its driver with registerCipherDriver before the first request."));
|
|
50
|
+
this.construct = construct;
|
|
51
|
+
this.scheme = scheme;
|
|
52
|
+
this.name = "UnregisteredEncryptionScheme";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var Encryption = class {
|
|
56
|
+
id;
|
|
57
|
+
service;
|
|
58
|
+
/**
|
|
59
|
+
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
60
|
+
* target publishes and the key the client reads cannot drift.
|
|
61
|
+
*/
|
|
62
|
+
key;
|
|
63
|
+
/**
|
|
64
|
+
* One cipher per process, held as the promise: a keyring is parsed once and
|
|
65
|
+
* a KMS client is built once, however many handlers register it at once.
|
|
66
|
+
*/
|
|
67
|
+
cipher;
|
|
68
|
+
constructor(id) {
|
|
69
|
+
const canonical = canonicalId(id);
|
|
70
|
+
this.id = canonical;
|
|
71
|
+
this.key = provideKey(canonical, "url");
|
|
72
|
+
this.service = {
|
|
73
|
+
serviceName: serviceKey(canonical),
|
|
74
|
+
register: (options) => this.connect(options)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
declare() {
|
|
78
|
+
return [{
|
|
79
|
+
kind: "encryption",
|
|
80
|
+
id: this.id,
|
|
81
|
+
provides: [this.key]
|
|
82
|
+
}];
|
|
83
|
+
}
|
|
84
|
+
connect(options) {
|
|
85
|
+
this.cipher ??= this.open(options);
|
|
86
|
+
return this.cipher;
|
|
87
|
+
}
|
|
88
|
+
async open(options) {
|
|
89
|
+
const { url } = options.envParser.create((get) => ({ url: get(this.key).string() })).parse();
|
|
90
|
+
const scheme = url.slice(0, url.indexOf(":") + 1);
|
|
91
|
+
if (scheme === "aes256gcm:") return keyringCipher(this.id, url, (stale, current) => console.warn(`${this.id} decrypted a value still under '${stale}' (current: '${current}'). reencrypt it, and retire '${stale}' once nothing is left under it.`));
|
|
92
|
+
const driver = drivers.get(scheme);
|
|
93
|
+
if (driver) return driver.open(this.id, url);
|
|
94
|
+
if (scheme === KMS_SCHEME) throw new UnregisteredEncryptionScheme(this.id, scheme);
|
|
95
|
+
throw new UnknownEncryptionScheme(this.id, scheme);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { CiphertextMalformed, CiphertextNotAuthentic, CurrentKeyCannotRetire, Encryption, EncryptionKeyRetired, EncryptionUrlInvalid, UnknownEncryptionScheme, UnregisteredEncryptionScheme, formatKeyring, generateKeyring, keyringCipher, parseKeyring, registerCipherDriver, retireKey, rotateKeyring };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=encryption.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.mjs","names":[],"sources":["../src/encryption.ts"],"sourcesContent":["/**\n * `Encryption` — a key that encrypts what the application stores.\n *\n * ```ts\n * export const pii = new Encryption('Pii');\n *\n * // an endpoint that `.dependsOn([pii])`\n * const email = await services.pii.encrypt(body.email);\n * const emailIndex = await services.pii.index(body.email);\n * await db.insertInto('users').values({ email, emailIndex }).execute();\n *\n * // and to find them again, without decrypting a column\n * db.selectFrom('users').where('emailIndex', '=', await services.pii.index(q));\n * ```\n *\n * The app names no cipher and holds no key. The construct provides one URL,\n * `<ID>_URL`, and its scheme picks the backend the way a queue's connection\n * string picks its broker:\n *\n * - **AWS** — `kms://`: envelope encryption under a KMS key that rotates\n * yearly, and a KMS HMAC key for the index. Only a function that depends on\n * the construct is granted either key.\n * - **Server, local, tests** — `aes256gcm://`: a keyring the process holds.\n * Derived locally, so `gkm dev` and `gkm test` need nothing set; generated\n * into a server stage's secrets on its first deploy, and rotated there with\n * `gkm encryption:rotate`.\n *\n * Every ciphertext names the key that wrote it, so a rotated key still opens\n * what it wrote. Retiring one is explicit — `reencrypt` the column, then\n * `gkm encryption:retire` — and a value still under an old key says so when it\n * is decrypted, once per key per process.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tKMS_SCHEME,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\nimport {\n\ttype Cipher,\n\ttype CipherDriver,\n\tkeyringCipher,\n\tLOCAL_SCHEME,\n\tUnknownEncryptionScheme,\n} from './encryption/cipher';\n\nexport type { Cipher, CipherDriver } from './encryption/cipher';\nexport {\n\tCiphertextMalformed,\n\tCiphertextNotAuthentic,\n\tCurrentKeyCannotRetire,\n\tEncryptionKeyRetired,\n\tEncryptionUrlInvalid,\n\tformatKeyring,\n\tgenerateKeyring,\n\ttype Keyring,\n\tkeyringCipher,\n\tparseKeyring,\n\tretireKey,\n\trotateKeyring,\n\tUnknownEncryptionScheme,\n} from './encryption/cipher';\n\nconst drivers = new Map<string, CipherDriver>();\n\n/** Make a cipher available for its scheme. Idempotent. */\nexport function registerCipherDriver(driver: CipherDriver): void {\n\tdrivers.set(driver.scheme, driver);\n}\n\n/**\n * A key whose URL names a cipher this process registered no driver for —\n * `kms:` in an entry built for a target whose keys are local.\n */\nexport class UnregisteredEncryptionScheme extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly scheme: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}'s key is a '${scheme}' URL, and this build registered no cipher for it. ` +\n\t\t\t\t(scheme === KMS_SCHEME\n\t\t\t\t\t? \"A KMS key is an AWS target's: build for it (gkm build --provider aws), which registers the KMS cipher and needs @aws-sdk/client-kms installed.\"\n\t\t\t\t\t: 'Register its driver with registerCipherDriver before the first request.'),\n\t\t);\n\t\tthis.name = 'UnregisteredEncryptionScheme';\n\t}\n}\n\nexport class Encryption<TName extends string = string>\n\timplements Construct<TName, Cipher>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Cipher>;\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 key: string;\n\n\t/**\n\t * One cipher per process, held as the promise: a keyring is parsed once and\n\t * a KMS client is built once, however many handlers register it at once.\n\t */\n\tprivate cipher?: Promise<Cipher>;\n\n\tconstructor(id: ConstructName<TName>) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.key = provideKey(canonical, 'url');\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: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [{ kind: 'encryption', id: this.id, provides: [this.key] }];\n\t}\n\n\tprivate connect(options: ServiceRegisterOptions): Promise<Cipher> {\n\t\tthis.cipher ??= this.open(options);\n\t\treturn this.cipher;\n\t}\n\n\tprivate async open(options: ServiceRegisterOptions): Promise<Cipher> {\n\t\tconst { url } = options.envParser\n\t\t\t.create((get) => ({ url: get(this.key).string() }))\n\t\t\t.parse();\n\t\tconst scheme = url.slice(0, url.indexOf(':') + 1);\n\n\t\tif (scheme === LOCAL_SCHEME) {\n\t\t\treturn keyringCipher(this.id, url, (stale, current) =>\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${this.id} decrypted a value still under '${stale}' (current: '${current}'). reencrypt it, and retire '${stale}' once nothing is left under it.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\t// Registered by the entry a build generates, only for a target whose\n\t\t// keys live there — so no other process imports that cipher's SDK.\n\t\tconst driver = drivers.get(scheme);\n\t\tif (driver) return driver.open(this.id, url);\n\t\tif (scheme === KMS_SCHEME) {\n\t\t\tthrow new UnregisteredEncryptionScheme(this.id, scheme);\n\t\t}\n\n\t\tthrow new UnknownEncryptionScheme(this.id, scheme);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,0BAAU,IAAI,IAA0B;;AAG9C,SAAgB,qBAAqB,QAA4B;CAChE,QAAQ,IAAI,OAAO,QAAQ,MAAM;AAClC;;;;;AAMA,IAAa,+BAAb,cAAkD,MAAM;CAE7C;CACA;CAFV,YACC,WACA,QACC;EACD,MACC,GAAG,UAAU,eAAe,OAAO,wDACjC,WAAW,aACT,mJACA,0EACL;EARS,KAAA,YAAA;EACA,KAAA,SAAA;EAQT,KAAK,OAAO;CACb;AACD;AAEA,IAAa,aAAb,MAEA;CACC;CACA;;;;;CAMA;;;;;CAMA;CAEA,YAAY,IAA0B;EACrC,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,MAAM,WAAW,WAAW,KAAK;EAGtC,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CAAC;GAAE,MAAM;GAAc,IAAI,KAAK;GAAI,UAAU,CAAC,KAAK,GAAG;EAAE,CAAC;CAClE;CAEA,QAAgB,SAAkD;EACjE,KAAK,WAAW,KAAK,KAAK,OAAO;EACjC,OAAO,KAAK;CACb;CAEA,MAAc,KAAK,SAAkD;EACpE,MAAM,EAAE,QAAQ,QAAQ,UACtB,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAClD,MAAM;EACR,MAAM,SAAS,IAAI,MAAM,GAAG,IAAI,QAAQ,GAAG,IAAI,CAAC;EAEhD,IAAI,WAAA,cACH,OAAO,cAAc,KAAK,IAAI,MAAM,OAAO,YAC1C,QAAQ,KACP,GAAG,KAAK,GAAG,kCAAkC,MAAM,eAAe,QAAQ,gCAAgC,MAAM,iCACjH,CACD;EAKD,MAAM,SAAS,QAAQ,IAAI,MAAM;EACjC,IAAI,QAAQ,OAAO,OAAO,KAAK,KAAK,IAAI,GAAG;EAC3C,IAAI,WAAW,YACd,MAAM,IAAI,6BAA6B,KAAK,IAAI,MAAM;EAGvD,MAAM,IAAI,wBAAwB,KAAK,IAAI,MAAM;CAClD;AACD"}
|
package/dist/endpoints/index.cjs
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
require(
|
|
4
|
-
const
|
|
5
|
-
require(
|
|
6
|
-
const
|
|
7
|
-
const require_surfaceEnv = require('../surfaceEnv-BFXEms2f.cjs');
|
|
8
|
-
const require_lazyAccessors = require('../lazyAccessors-e3j2oE2m.cjs');
|
|
9
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_EndpointFactory = require("../EndpointFactory-CSrAyazj.cjs");
|
|
3
|
+
const require_functions = require("../functions-D7O5SGVc.cjs");
|
|
4
|
+
const require_Endpoint = require("../Endpoint-yhR2T2Wt.cjs");
|
|
5
|
+
const require_surfaceEnv = require("../surfaceEnv-CNimK76p.cjs");
|
|
6
|
+
const require_readRequestBody = require("../readRequestBody-Dej_L3c4.cjs");
|
|
10
7
|
exports.BUILT_IN_SECURITY_SCHEMES = require_EndpointFactory.BUILT_IN_SECURITY_SCHEMES;
|
|
11
8
|
exports.Endpoint = require_Endpoint.Endpoint;
|
|
12
9
|
exports.EndpointBuilder = require_EndpointFactory.EndpointBuilder;
|
|
13
10
|
exports.EndpointFactory = require_EndpointFactory.EndpointFactory;
|
|
11
|
+
exports.MalformedRequestBody = require_readRequestBody.MalformedRequestBody;
|
|
12
|
+
exports.NoAuthenticator = require_Endpoint.NoAuthenticator;
|
|
14
13
|
exports.RLS_BYPASS = require_EndpointFactory.RLS_BYPASS;
|
|
14
|
+
exports.RedirectStatus = require_Endpoint.RedirectStatus;
|
|
15
15
|
exports.ResponseBuilder = require_Endpoint.ResponseBuilder;
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
16
|
+
exports.SUPPORTED_BODY_TYPES = require_readRequestBody.SUPPORTED_BODY_TYPES;
|
|
17
|
+
exports.SuccessStatus = require_Endpoint.SuccessStatus;
|
|
18
|
+
exports.UPLOAD_POST_SCHEMA = require_EndpointFactory.UPLOAD_POST_SCHEMA;
|
|
19
|
+
exports.UnsupportedRequestContentType = require_readRequestBody.UnsupportedRequestContentType;
|
|
20
|
+
exports.UploadAcceptInvalid = require_EndpointFactory.UploadAcceptInvalid;
|
|
21
|
+
exports.UploadContentTypeRefused = require_EndpointFactory.UploadContentTypeRefused;
|
|
22
|
+
exports.UploadContentTypeUnresolved = require_EndpointFactory.UploadContentTypeUnresolved;
|
|
23
|
+
exports.UploadEndpointBuilder = require_EndpointFactory.UploadEndpointBuilder;
|
|
24
|
+
exports.UploadExpiryInvalid = require_EndpointFactory.UploadExpiryInvalid;
|
|
25
|
+
exports.UploadMaxSizeInvalid = require_EndpointFactory.UploadMaxSizeInvalid;
|
|
26
|
+
exports.createApiGatewayCookies = require_readRequestBody.createApiGatewayCookies;
|
|
27
|
+
exports.createApiGatewayHeaders = require_readRequestBody.createApiGatewayHeaders;
|
|
18
28
|
exports.createAuthorizer = require_EndpointFactory.createAuthorizer;
|
|
19
|
-
exports.createHonoCookies =
|
|
20
|
-
exports.createHonoHeaders =
|
|
21
|
-
exports.createNoopCookies =
|
|
22
|
-
exports.createNoopHeaders =
|
|
29
|
+
exports.createHonoCookies = require_readRequestBody.createHonoCookies;
|
|
30
|
+
exports.createHonoHeaders = require_readRequestBody.createHonoHeaders;
|
|
31
|
+
exports.createNoopCookies = require_readRequestBody.createNoopCookies;
|
|
32
|
+
exports.createNoopHeaders = require_readRequestBody.createNoopHeaders;
|
|
23
33
|
exports.defaultEnvParser = require_surfaceEnv.defaultEnvParser;
|
|
24
34
|
exports.envParserFor = require_surfaceEnv.envParserFor;
|
|
25
35
|
exports.getSecurityScheme = require_EndpointFactory.getSecurityScheme;
|
|
26
36
|
exports.isBuiltInSecurityScheme = require_EndpointFactory.isBuiltInSecurityScheme;
|
|
27
|
-
exports.publishConstructEvents =
|
|
37
|
+
exports.publishConstructEvents = require_functions.publishConstructEvents;
|
|
38
|
+
exports.readRequestBody = require_readRequestBody.readRequestBody;
|