@openstax/ts-utils 1.34.0 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -62
- package/dist/cjs/assertions/index.d.ts +89 -0
- package/dist/cjs/assertions/index.js +157 -0
- package/dist/cjs/aws/ssmService.d.ts +5 -0
- package/dist/cjs/aws/ssmService.js +9 -0
- package/dist/cjs/config/awsParameterConfig.d.ts +10 -0
- package/dist/cjs/config/awsParameterConfig.js +26 -0
- package/dist/cjs/config/envConfig.d.ts +24 -0
- package/dist/cjs/config/envConfig.js +57 -0
- package/{packages/utils/src/config/index.ts → dist/cjs/config/index.d.ts} +13 -29
- package/dist/cjs/config/index.js +35 -0
- package/dist/cjs/config/lambdaParameterConfig.d.ts +12 -0
- package/dist/cjs/config/lambdaParameterConfig.js +45 -0
- package/dist/cjs/config/replaceConfig.d.ts +14 -0
- package/dist/cjs/config/replaceConfig.js +22 -0
- package/dist/cjs/config/resolveConfigValue.d.ts +5 -0
- package/dist/cjs/config/resolveConfigValue.js +12 -0
- package/dist/cjs/errors/index.d.ts +88 -0
- package/dist/cjs/errors/index.js +123 -0
- package/dist/cjs/fetch/fetchStatusRetry.d.ts +8 -0
- package/dist/cjs/fetch/fetchStatusRetry.js +27 -0
- package/dist/cjs/fetch/index.d.ts +64 -0
- package/dist/cjs/fetch/index.js +55 -0
- package/{packages/utils/src/guards/index.ts → dist/cjs/guards/index.d.ts} +7 -10
- package/dist/cjs/guards/index.js +44 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/middleware/apiErrorHandler.d.ts +24 -0
- package/dist/cjs/middleware/apiErrorHandler.js +42 -0
- package/dist/cjs/middleware/apiSlowResponseMiddleware.d.ts +23 -0
- package/dist/cjs/middleware/apiSlowResponseMiddleware.js +54 -0
- package/{packages/utils/src/middleware/index.ts → dist/cjs/middleware/index.d.ts} +5 -53
- package/dist/cjs/middleware/index.js +48 -0
- package/dist/cjs/middleware/lambdaCorsResponseMiddleware.d.ts +20 -0
- package/dist/cjs/middleware/lambdaCorsResponseMiddleware.js +44 -0
- package/dist/cjs/middleware/throwNotFoundMiddleware.d.ts +4 -0
- package/dist/cjs/middleware/throwNotFoundMiddleware.js +14 -0
- package/dist/cjs/misc/hashValue.d.ts +10 -0
- package/dist/cjs/misc/hashValue.js +17 -0
- package/dist/cjs/misc/helpers.d.ts +124 -0
- package/dist/cjs/misc/helpers.js +214 -0
- package/dist/cjs/misc/merge.d.ts +21 -0
- package/dist/cjs/misc/merge.js +45 -0
- package/dist/cjs/misc/partitionSequence.d.ts +35 -0
- package/dist/cjs/misc/partitionSequence.js +55 -0
- package/dist/cjs/pagination/index.d.ts +91 -0
- package/dist/cjs/pagination/index.js +83 -0
- package/dist/cjs/routing/helpers.d.ts +57 -0
- package/dist/cjs/routing/helpers.js +90 -0
- package/dist/cjs/routing/index.d.ts +290 -0
- package/dist/cjs/routing/index.js +295 -0
- package/dist/cjs/routing/validators/zod.d.ts +4 -0
- package/dist/cjs/routing/validators/zod.js +14 -0
- package/dist/cjs/services/accountsGateway/index.d.ts +92 -0
- package/dist/cjs/services/accountsGateway/index.js +138 -0
- package/dist/cjs/services/apiGateway/index.d.ts +68 -0
- package/dist/cjs/services/apiGateway/index.js +118 -0
- package/dist/cjs/services/authProvider/browser.d.ts +40 -0
- package/dist/cjs/services/authProvider/browser.js +155 -0
- package/dist/cjs/services/authProvider/decryption.d.ts +19 -0
- package/dist/cjs/services/authProvider/decryption.js +73 -0
- package/dist/cjs/services/authProvider/index.d.ts +63 -0
- package/dist/cjs/services/authProvider/index.js +34 -0
- package/dist/cjs/services/authProvider/subrequest.d.ts +13 -0
- package/dist/cjs/services/authProvider/subrequest.js +49 -0
- package/dist/cjs/services/authProvider/utils/decryptAndVerify.d.ts +28 -0
- package/dist/cjs/services/authProvider/utils/decryptAndVerify.js +91 -0
- package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.d.ts +26 -0
- package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.js +47 -0
- package/dist/cjs/services/authProvider/utils/userRoleValidator.d.ts +13 -0
- package/dist/cjs/services/authProvider/utils/userRoleValidator.js +37 -0
- package/dist/cjs/services/authProvider/utils/userSubrequest.d.ts +3 -0
- package/dist/cjs/services/authProvider/utils/userSubrequest.js +13 -0
- package/dist/cjs/services/documentStore/dynamoEncoding.d.ts +10 -0
- package/dist/cjs/services/documentStore/dynamoEncoding.js +52 -0
- package/dist/cjs/services/documentStore/fileSystemAssert.d.ts +1 -0
- package/dist/cjs/services/documentStore/fileSystemAssert.js +14 -0
- package/{packages/utils/src/services/documentStore/index.ts → dist/cjs/services/documentStore/index.d.ts} +8 -8
- package/dist/cjs/services/documentStore/index.js +2 -0
- package/dist/cjs/services/documentStore/unversioned/dynamodb.d.ts +31 -0
- package/dist/cjs/services/documentStore/unversioned/dynamodb.js +233 -0
- package/dist/cjs/services/documentStore/unversioned/file-system.d.ts +32 -0
- package/dist/cjs/services/documentStore/unversioned/file-system.js +214 -0
- package/{packages/utils/src/services/documentStore/unversioned/index.ts → dist/cjs/services/documentStore/unversioned/index.d.ts} +0 -2
- package/dist/cjs/services/documentStore/unversioned/index.js +2 -0
- package/dist/cjs/services/documentStore/versioned/dynamodb.d.ts +25 -0
- package/dist/cjs/services/documentStore/versioned/dynamodb.js +143 -0
- package/dist/cjs/services/documentStore/versioned/file-system.d.ts +25 -0
- package/dist/cjs/services/documentStore/versioned/file-system.js +73 -0
- package/dist/cjs/services/documentStore/versioned/index.d.ts +17 -0
- package/dist/cjs/services/documentStore/versioned/index.js +2 -0
- package/dist/cjs/services/exercisesGateway/index.d.ts +67 -0
- package/dist/cjs/services/exercisesGateway/index.js +107 -0
- package/dist/cjs/services/fileServer/index.d.ts +30 -0
- package/dist/cjs/services/fileServer/index.js +19 -0
- package/dist/cjs/services/fileServer/localFileServer.d.ts +13 -0
- package/dist/cjs/services/fileServer/localFileServer.js +132 -0
- package/dist/cjs/services/fileServer/s3FileServer.d.ts +14 -0
- package/dist/cjs/services/fileServer/s3FileServer.js +131 -0
- package/dist/cjs/services/launchParams/index.js +7 -0
- package/dist/cjs/services/launchParams/signer.d.ts +23 -0
- package/dist/cjs/services/launchParams/signer.js +58 -0
- package/dist/cjs/services/launchParams/verifier.d.ts +21 -0
- package/dist/cjs/services/launchParams/verifier.js +129 -0
- package/dist/cjs/services/logger/console.d.ts +4 -0
- package/dist/cjs/services/logger/console.js +12 -0
- package/{packages/utils/src/services/logger/index.ts → dist/cjs/services/logger/index.d.ts} +9 -23
- package/dist/cjs/services/logger/index.js +31 -0
- package/dist/cjs/services/lrsGateway/addStatementDefaultFields.d.ts +5 -0
- package/dist/cjs/services/lrsGateway/addStatementDefaultFields.js +21 -0
- package/dist/cjs/services/lrsGateway/attempt-utils.d.ts +72 -0
- package/dist/cjs/services/lrsGateway/attempt-utils.js +283 -0
- package/dist/cjs/services/lrsGateway/file-system.d.ts +15 -0
- package/dist/cjs/services/lrsGateway/file-system.js +150 -0
- package/dist/cjs/services/lrsGateway/index.d.ts +122 -0
- package/dist/cjs/services/lrsGateway/index.js +148 -0
- package/dist/cjs/services/lrsGateway/xapiUtils.d.ts +71 -0
- package/dist/cjs/services/lrsGateway/xapiUtils.js +145 -0
- package/dist/cjs/services/postgresConnection/index.d.ts +28 -0
- package/dist/cjs/services/postgresConnection/index.js +65 -0
- package/dist/cjs/services/searchProvider/index.d.ts +69 -0
- package/dist/cjs/services/searchProvider/index.js +2 -0
- package/dist/cjs/services/searchProvider/memorySearchTheBadWay.d.ts +20 -0
- package/dist/cjs/services/searchProvider/memorySearchTheBadWay.js +191 -0
- package/dist/cjs/services/searchProvider/openSearch.d.ts +28 -0
- package/dist/cjs/services/searchProvider/openSearch.js +162 -0
- package/dist/cjs/services/searchProvider/streamIndexer.d.ts +17 -0
- package/dist/cjs/services/searchProvider/streamIndexer.js +41 -0
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -0
- package/{packages/utils/src/types.ts → dist/cjs/types.d.ts} +6 -34
- package/dist/cjs/types.js +2 -0
- package/dist/esm/assertions/index.d.ts +89 -0
- package/{packages/utils/src/assertions/index.ts → dist/esm/assertions/index.js} +49 -64
- package/dist/esm/aws/ssmService.d.ts +5 -0
- package/dist/esm/aws/ssmService.js +6 -0
- package/dist/esm/config/awsParameterConfig.d.ts +10 -0
- package/dist/esm/config/awsParameterConfig.js +22 -0
- package/dist/esm/config/envConfig.d.ts +24 -0
- package/dist/esm/config/envConfig.js +53 -0
- package/dist/esm/config/index.d.ts +48 -0
- package/dist/esm/config/index.js +17 -0
- package/dist/esm/config/lambdaParameterConfig.d.ts +12 -0
- package/dist/esm/config/lambdaParameterConfig.js +38 -0
- package/dist/esm/config/replaceConfig.d.ts +14 -0
- package/{packages/utils/src/config/replaceConfig.ts → dist/esm/config/replaceConfig.js} +6 -16
- package/dist/esm/config/resolveConfigValue.d.ts +5 -0
- package/dist/esm/config/resolveConfigValue.js +8 -0
- package/dist/esm/errors/index.d.ts +88 -0
- package/{packages/utils/src/errors/index.ts → dist/esm/errors/index.js} +41 -57
- package/dist/esm/fetch/fetchStatusRetry.d.ts +8 -0
- package/dist/esm/fetch/fetchStatusRetry.js +23 -0
- package/dist/esm/fetch/index.d.ts +64 -0
- package/dist/esm/fetch/index.js +46 -0
- package/dist/esm/guards/index.d.ts +38 -0
- package/dist/esm/guards/index.js +36 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/middleware/apiErrorHandler.d.ts +24 -0
- package/dist/esm/middleware/apiErrorHandler.js +38 -0
- package/dist/esm/middleware/apiSlowResponseMiddleware.d.ts +23 -0
- package/dist/esm/middleware/apiSlowResponseMiddleware.js +50 -0
- package/dist/esm/middleware/index.d.ts +47 -0
- package/dist/esm/middleware/index.js +44 -0
- package/dist/esm/middleware/lambdaCorsResponseMiddleware.d.ts +20 -0
- package/dist/esm/middleware/lambdaCorsResponseMiddleware.js +40 -0
- package/dist/esm/middleware/throwNotFoundMiddleware.d.ts +4 -0
- package/dist/esm/middleware/throwNotFoundMiddleware.js +10 -0
- package/dist/esm/misc/hashValue.d.ts +10 -0
- package/dist/esm/misc/hashValue.js +13 -0
- package/dist/esm/misc/helpers.d.ts +124 -0
- package/dist/esm/misc/helpers.js +199 -0
- package/dist/esm/misc/merge.d.ts +21 -0
- package/dist/esm/misc/merge.js +40 -0
- package/dist/esm/misc/partitionSequence.d.ts +35 -0
- package/{packages/utils/src/misc/partitionSequence.ts → dist/esm/misc/partitionSequence.js} +15 -23
- package/dist/esm/pagination/index.d.ts +91 -0
- package/dist/esm/pagination/index.js +77 -0
- package/dist/esm/routing/helpers.d.ts +57 -0
- package/{packages/utils/src/routing/helpers.ts → dist/esm/routing/helpers.js} +30 -42
- package/dist/esm/routing/index.d.ts +290 -0
- package/dist/esm/routing/index.js +246 -0
- package/dist/esm/routing/validators/zod.d.ts +4 -0
- package/dist/esm/routing/validators/zod.js +10 -0
- package/dist/esm/services/accountsGateway/index.d.ts +92 -0
- package/dist/esm/services/accountsGateway/index.js +131 -0
- package/dist/esm/services/apiGateway/index.d.ts +68 -0
- package/dist/esm/services/apiGateway/index.js +77 -0
- package/dist/esm/services/authProvider/browser.d.ts +40 -0
- package/dist/esm/services/authProvider/browser.js +151 -0
- package/dist/esm/services/authProvider/decryption.d.ts +19 -0
- package/dist/esm/services/authProvider/decryption.js +69 -0
- package/dist/esm/services/authProvider/index.d.ts +63 -0
- package/dist/esm/services/authProvider/index.js +26 -0
- package/dist/esm/services/authProvider/subrequest.d.ts +13 -0
- package/dist/esm/services/authProvider/subrequest.js +45 -0
- package/dist/esm/services/authProvider/utils/decryptAndVerify.d.ts +28 -0
- package/dist/esm/services/authProvider/utils/decryptAndVerify.js +85 -0
- package/dist/esm/services/authProvider/utils/embeddedAuthProvider.d.ts +26 -0
- package/dist/esm/services/authProvider/utils/embeddedAuthProvider.js +40 -0
- package/dist/esm/services/authProvider/utils/userRoleValidator.d.ts +13 -0
- package/dist/esm/services/authProvider/utils/userRoleValidator.js +33 -0
- package/dist/esm/services/authProvider/utils/userSubrequest.d.ts +3 -0
- package/dist/esm/services/authProvider/utils/userSubrequest.js +6 -0
- package/dist/esm/services/documentStore/dynamoEncoding.d.ts +10 -0
- package/dist/esm/services/documentStore/dynamoEncoding.js +45 -0
- package/dist/esm/services/documentStore/fileSystemAssert.d.ts +1 -0
- package/dist/esm/services/documentStore/fileSystemAssert.js +10 -0
- package/dist/esm/services/documentStore/index.d.ts +14 -0
- package/dist/esm/services/documentStore/index.js +1 -0
- package/dist/esm/services/documentStore/unversioned/dynamodb.d.ts +31 -0
- package/dist/esm/services/documentStore/unversioned/dynamodb.js +226 -0
- package/dist/esm/services/documentStore/unversioned/file-system.d.ts +32 -0
- package/dist/esm/services/documentStore/unversioned/file-system.js +174 -0
- package/dist/esm/services/documentStore/unversioned/index.d.ts +2 -0
- package/dist/esm/services/documentStore/unversioned/index.js +1 -0
- package/dist/esm/services/documentStore/versioned/dynamodb.d.ts +25 -0
- package/dist/esm/services/documentStore/versioned/dynamodb.js +139 -0
- package/dist/esm/services/documentStore/versioned/file-system.d.ts +25 -0
- package/dist/esm/services/documentStore/versioned/file-system.js +69 -0
- package/dist/esm/services/documentStore/versioned/index.d.ts +17 -0
- package/dist/esm/services/documentStore/versioned/index.js +1 -0
- package/dist/esm/services/exercisesGateway/index.d.ts +67 -0
- package/dist/esm/services/exercisesGateway/index.js +70 -0
- package/dist/esm/services/fileServer/index.d.ts +30 -0
- package/dist/esm/services/fileServer/index.js +13 -0
- package/dist/esm/services/fileServer/localFileServer.d.ts +13 -0
- package/dist/esm/services/fileServer/localFileServer.js +125 -0
- package/dist/esm/services/fileServer/s3FileServer.d.ts +14 -0
- package/dist/esm/services/fileServer/s3FileServer.js +124 -0
- package/dist/esm/services/launchParams/index.d.ts +2 -0
- package/dist/esm/services/launchParams/index.js +2 -0
- package/dist/esm/services/launchParams/signer.d.ts +23 -0
- package/dist/esm/services/launchParams/signer.js +51 -0
- package/dist/esm/services/launchParams/verifier.d.ts +21 -0
- package/dist/esm/services/launchParams/verifier.js +92 -0
- package/dist/esm/services/logger/console.d.ts +4 -0
- package/{packages/utils/src/services/logger/console.ts → dist/esm/services/logger/console.js} +2 -5
- package/dist/esm/services/logger/index.d.ts +39 -0
- package/dist/esm/services/logger/index.js +27 -0
- package/dist/esm/services/lrsGateway/addStatementDefaultFields.d.ts +5 -0
- package/dist/esm/services/lrsGateway/addStatementDefaultFields.js +14 -0
- package/dist/esm/services/lrsGateway/attempt-utils.d.ts +72 -0
- package/dist/esm/services/lrsGateway/attempt-utils.js +261 -0
- package/dist/esm/services/lrsGateway/file-system.d.ts +15 -0
- package/dist/esm/services/lrsGateway/file-system.js +110 -0
- package/dist/esm/services/lrsGateway/index.d.ts +122 -0
- package/dist/esm/services/lrsGateway/index.js +111 -0
- package/dist/esm/services/lrsGateway/xapiUtils.d.ts +71 -0
- package/dist/esm/services/lrsGateway/xapiUtils.js +134 -0
- package/dist/esm/services/postgresConnection/index.d.ts +28 -0
- package/dist/esm/services/postgresConnection/index.js +58 -0
- package/dist/esm/services/searchProvider/index.d.ts +69 -0
- package/dist/esm/services/searchProvider/index.js +1 -0
- package/dist/esm/services/searchProvider/memorySearchTheBadWay.d.ts +20 -0
- package/dist/esm/services/searchProvider/memorySearchTheBadWay.js +187 -0
- package/dist/esm/services/searchProvider/openSearch.d.ts +28 -0
- package/dist/esm/services/searchProvider/openSearch.js +158 -0
- package/dist/esm/services/searchProvider/streamIndexer.d.ts +17 -0
- package/dist/esm/services/searchProvider/streamIndexer.js +37 -0
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +31 -0
- package/dist/esm/types.js +1 -0
- package/package.json +234 -12
- package/.cfnlintrc +0 -2
- package/.github/CODEOWNERS +0 -1
- package/.github/workflows/ci.yml +0 -36
- package/.github/workflows/lint.yml +0 -55
- package/.nvmrc +0 -1
- package/.syncignore +0 -4
- package/.syncpackrc +0 -18
- package/CONTRIBUTING.md +0 -96
- package/LICENSE +0 -661
- package/Procfile +0 -1
- package/app.json +0 -23
- package/cspell.json +0 -32
- package/deploy/constants.env +0 -21
- package/deploy/deploy.bash +0 -157
- package/deploy/deployment-alt-region.cfn.yml +0 -70
- package/deploy/deployment.cfn.yml +0 -650
- package/deploy/destroy-deployment.bash +0 -23
- package/deploy/shared.cfn.yml +0 -94
- package/docs/lambda-build.md +0 -35
- package/packages/frontend/README.md +0 -46
- package/packages/frontend/package.json +0 -101
- package/packages/frontend/public/favicon.ico +0 -0
- package/packages/frontend/public/index.html +0 -107
- package/packages/frontend/public/maintenance.html +0 -59
- package/packages/frontend/public/manifest.json +0 -15
- package/packages/frontend/public/robots.txt +0 -3
- package/packages/frontend/script/make-certificate.bash +0 -49
- package/packages/frontend/script/server/cli.js +0 -11
- package/packages/frontend/script/server/index.js +0 -47
- package/packages/frontend/script/start.bash +0 -22
- package/packages/frontend/script/trust-localhost.bash +0 -7
- package/packages/frontend/src/auth/authProvider.ts +0 -10
- package/packages/frontend/src/auth/useAuth.ts +0 -33
- package/packages/frontend/src/components/Pagination.tsx +0 -26
- package/packages/frontend/src/configProvider/index.ts +0 -53
- package/packages/frontend/src/configProvider/use.ts +0 -41
- package/packages/frontend/src/core/context/services.spec.tsx +0 -39
- package/packages/frontend/src/core/context/services.tsx +0 -16
- package/packages/frontend/src/core/index.spec.ts +0 -7
- package/packages/frontend/src/core/index.ts +0 -20
- package/packages/frontend/src/core/services.tsx +0 -14
- package/packages/frontend/src/core/types.ts +0 -3
- package/packages/frontend/src/example/api.ts +0 -28
- package/packages/frontend/src/example/components/Layout.tsx +0 -23
- package/packages/frontend/src/example/screens/Home.spec.tsx +0 -68
- package/packages/frontend/src/example/screens/Home.tsx +0 -78
- package/packages/frontend/src/example/screens/ThingList.spec.tsx +0 -60
- package/packages/frontend/src/example/screens/ThingList.tsx +0 -75
- package/packages/frontend/src/example/screens/ThingView.spec.tsx +0 -71
- package/packages/frontend/src/example/screens/ThingView.tsx +0 -47
- package/packages/frontend/src/example/screens/index.ts +0 -9
- package/packages/frontend/src/index.css +0 -159
- package/packages/frontend/src/index.tsx +0 -67
- package/packages/frontend/src/react-app-env.d.ts +0 -1
- package/packages/frontend/src/routing/components/RouteLink.spec.tsx +0 -55
- package/packages/frontend/src/routing/components/RouteLink.tsx +0 -35
- package/packages/frontend/src/routing/middleware.ts +0 -6
- package/packages/frontend/src/routing/useQuery.ts +0 -14
- package/packages/frontend/src/setupProxy.js +0 -19
- package/packages/frontend/src/setupTests.ts +0 -9
- package/packages/frontend/src/tests/testServices.tsx +0 -23
- package/packages/frontend/tsconfig.json +0 -27
- package/packages/lambda/.eslintrc.js +0 -64
- package/packages/lambda/jest-global-setup.js +0 -3
- package/packages/lambda/jest-setup-after-env.js +0 -1
- package/packages/lambda/jest.config.js +0 -31
- package/packages/lambda/jest.resolver.js +0 -17
- package/packages/lambda/package.json +0 -68
- package/packages/lambda/script/build.bash +0 -19
- package/packages/lambda/script/bundle-functions.bash +0 -10
- package/packages/lambda/script/lambdaLocalProxy.js +0 -16
- package/packages/lambda/script/lambdaLocalProxy.spec.ts +0 -147
- package/packages/lambda/script/utils/getRouteData.ts +0 -7
- package/packages/lambda/script/utils/routeDataLoader.js +0 -8
- package/packages/lambda/script/utils/routeDataLoader.spec.ts +0 -8
- package/packages/lambda/src/functions/serviceApi/core/index.ts +0 -7
- package/packages/lambda/src/functions/serviceApi/core/request.spec.ts +0 -38
- package/packages/lambda/src/functions/serviceApi/core/request.ts +0 -42
- package/packages/lambda/src/functions/serviceApi/core/routes.spec.ts +0 -7
- package/packages/lambda/src/functions/serviceApi/core/routes.ts +0 -10
- package/packages/lambda/src/functions/serviceApi/core/services.ts +0 -9
- package/packages/lambda/src/functions/serviceApi/core/types.ts +0 -13
- package/packages/lambda/src/functions/serviceApi/entry/lambda/https-xray.ts +0 -4
- package/packages/lambda/src/functions/serviceApi/entry/lambda/index.spec.ts +0 -48
- package/packages/lambda/src/functions/serviceApi/entry/lambda/index.ts +0 -58
- package/packages/lambda/src/functions/serviceApi/entry/lambda/services.ts +0 -36
- package/packages/lambda/src/functions/serviceApi/entry/local.ts +0 -71
- package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentSearchMiddleware.spec.ts +0 -16
- package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentSearchMiddleware.ts +0 -41
- package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentStoreMiddleware.spec.ts +0 -78
- package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentStoreMiddleware.ts +0 -70
- package/packages/lambda/src/functions/serviceApi/versions/v0/example/routes.spec.ts +0 -306
- package/packages/lambda/src/functions/serviceApi/versions/v0/example/routes.ts +0 -176
- package/packages/lambda/src/functions/serviceApi/versions/v0/index.spec.ts +0 -263
- package/packages/lambda/src/functions/serviceApi/versions/v0/index.ts +0 -134
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/authMiddleware.spec.ts +0 -23
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/authMiddleware.ts +0 -32
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/configMiddleware.spec.ts +0 -10
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/configMiddleware.ts +0 -7
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/frontendFileServerMiddleware.spec.ts +0 -13
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/frontendFileServerMiddleware.ts +0 -23
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/paginationMiddleware.spec.ts +0 -9
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/paginationMiddleware.ts +0 -9
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/searchMiddleware.spec.ts +0 -12
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/searchMiddleware.ts +0 -21
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/userRoleValidatorMiddleware.spec.ts +0 -21
- package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/userRoleValidatorMiddleware.ts +0 -18
- package/packages/lambda/tsconfig.json +0 -30
- package/packages/lambda/webpack.config.js +0 -97
- package/packages/utils/.eslintrc.js +0 -64
- package/packages/utils/README.md +0 -118
- package/packages/utils/jest-global-setup.js +0 -3
- package/packages/utils/jest.config.js +0 -25
- package/packages/utils/jest.resolver.js +0 -17
- package/packages/utils/package.json +0 -238
- package/packages/utils/src/assertions/index.spec.ts +0 -126
- package/packages/utils/src/aws/ssmService.ts +0 -7
- package/packages/utils/src/config/awsParameterConfig.ts +0 -24
- package/packages/utils/src/config/envConfig.ts +0 -58
- package/packages/utils/src/config/index.spec.ts +0 -165
- package/packages/utils/src/config/lambdaParameterConfig.ts +0 -49
- package/packages/utils/src/config/resolveConfigValue.ts +0 -10
- package/packages/utils/src/errors/index.spec.ts +0 -35
- package/packages/utils/src/fetch/fetchStatusRetry.spec.ts +0 -197
- package/packages/utils/src/fetch/fetchStatusRetry.ts +0 -33
- package/packages/utils/src/fetch/index.spec.ts +0 -34
- package/packages/utils/src/fetch/index.ts +0 -87
- package/packages/utils/src/guards/index.spec.ts +0 -58
- package/packages/utils/src/index.spec.ts +0 -471
- package/packages/utils/src/middleware/apiErrorHandler.spec.ts +0 -65
- package/packages/utils/src/middleware/apiErrorHandler.ts +0 -67
- package/packages/utils/src/middleware/apiSlowResponseMiddleware.spec.ts +0 -184
- package/packages/utils/src/middleware/apiSlowResponseMiddleware.ts +0 -71
- package/packages/utils/src/middleware/index.spec.ts +0 -99
- package/packages/utils/src/middleware/lambdaCorsResponseMiddleware.spec.ts +0 -103
- package/packages/utils/src/middleware/lambdaCorsResponseMiddleware.ts +0 -52
- package/packages/utils/src/middleware/throwNotFoundMiddleware.spec.ts +0 -20
- package/packages/utils/src/middleware/throwNotFoundMiddleware.ts +0 -11
- package/packages/utils/src/misc/hashValue.ts +0 -18
- package/packages/utils/src/misc/helpers.ts +0 -259
- package/packages/utils/src/misc/merge.ts +0 -48
- package/packages/utils/src/pagination/index.spec.ts +0 -150
- package/packages/utils/src/pagination/index.ts +0 -117
- package/packages/utils/src/routing/index.spec.ts +0 -553
- package/packages/utils/src/routing/index.ts +0 -424
- package/packages/utils/src/routing/validators/zod.spec.ts +0 -16
- package/packages/utils/src/routing/validators/zod.ts +0 -14
- package/packages/utils/src/services/accountsGateway/README.md +0 -3
- package/packages/utils/src/services/accountsGateway/index.spec.ts +0 -518
- package/packages/utils/src/services/accountsGateway/index.ts +0 -251
- package/packages/utils/src/services/apiGateway/README.md +0 -93
- package/packages/utils/src/services/apiGateway/index.spec.ts +0 -254
- package/packages/utils/src/services/apiGateway/index.ts +0 -189
- package/packages/utils/src/services/authProvider/README.md +0 -21
- package/packages/utils/src/services/authProvider/browser.spec.ts +0 -391
- package/packages/utils/src/services/authProvider/browser.ts +0 -209
- package/packages/utils/src/services/authProvider/decryption.spec.ts +0 -337
- package/packages/utils/src/services/authProvider/decryption.ts +0 -98
- package/packages/utils/src/services/authProvider/index.ts +0 -93
- package/packages/utils/src/services/authProvider/stub.spec.ts +0 -29
- package/packages/utils/src/services/authProvider/subrequest.spec.ts +0 -105
- package/packages/utils/src/services/authProvider/subrequest.ts +0 -68
- package/packages/utils/src/services/authProvider/utils/decryptAndVerify.spec.ts +0 -128
- package/packages/utils/src/services/authProvider/utils/decryptAndVerify.ts +0 -106
- package/packages/utils/src/services/authProvider/utils/embeddedAuthProvider.spec.ts +0 -26
- package/packages/utils/src/services/authProvider/utils/embeddedAuthProvider.ts +0 -57
- package/packages/utils/src/services/authProvider/utils/userRoleValidator.spec.ts +0 -135
- package/packages/utils/src/services/authProvider/utils/userRoleValidator.ts +0 -49
- package/packages/utils/src/services/authProvider/utils/userSubrequest.spec.ts +0 -26
- package/packages/utils/src/services/authProvider/utils/userSubrequest.ts +0 -10
- package/packages/utils/src/services/documentStore/dynamoEncoding.ts +0 -57
- package/packages/utils/src/services/documentStore/fileSystemAssert.spec.ts +0 -43
- package/packages/utils/src/services/documentStore/fileSystemAssert.ts +0 -10
- package/packages/utils/src/services/documentStore/unversioned/README.md +0 -13
- package/packages/utils/src/services/documentStore/unversioned/dynamodb.spec.ts +0 -859
- package/packages/utils/src/services/documentStore/unversioned/dynamodb.ts +0 -243
- package/packages/utils/src/services/documentStore/unversioned/file-system.spec.ts +0 -629
- package/packages/utils/src/services/documentStore/unversioned/file-system.ts +0 -194
- package/packages/utils/src/services/documentStore/versioned/README.md +0 -13
- package/packages/utils/src/services/documentStore/versioned/dynamodb.spec.ts +0 -376
- package/packages/utils/src/services/documentStore/versioned/dynamodb.ts +0 -167
- package/packages/utils/src/services/documentStore/versioned/file-system.spec.ts +0 -262
- package/packages/utils/src/services/documentStore/versioned/file-system.ts +0 -90
- package/packages/utils/src/services/documentStore/versioned/index.ts +0 -25
- package/packages/utils/src/services/exercisesGateway/README.md +0 -5
- package/packages/utils/src/services/exercisesGateway/index.spec.ts +0 -326
- package/packages/utils/src/services/exercisesGateway/index.ts +0 -163
- package/packages/utils/src/services/fileServer/index.spec.ts +0 -88
- package/packages/utils/src/services/fileServer/index.ts +0 -43
- package/packages/utils/src/services/fileServer/localFileServer.spec.ts +0 -182
- package/packages/utils/src/services/fileServer/localFileServer.ts +0 -159
- package/packages/utils/src/services/fileServer/s3FileServer.spec.ts +0 -266
- package/packages/utils/src/services/fileServer/s3FileServer.ts +0 -155
- package/packages/utils/src/services/launchParams/index.spec.ts +0 -366
- package/packages/utils/src/services/launchParams/signer.ts +0 -73
- package/packages/utils/src/services/launchParams/verifier.ts +0 -120
- package/packages/utils/src/services/logger/console.spec.ts +0 -29
- package/packages/utils/src/services/logger/index.spec.ts +0 -65
- package/packages/utils/src/services/lrsGateway/README.md +0 -5
- package/packages/utils/src/services/lrsGateway/addStatementDefaultFields.ts +0 -22
- package/packages/utils/src/services/lrsGateway/attempt-utils.spec.ts +0 -847
- package/packages/utils/src/services/lrsGateway/attempt-utils.ts +0 -358
- package/packages/utils/src/services/lrsGateway/file-system.spec.ts +0 -363
- package/packages/utils/src/services/lrsGateway/file-system.ts +0 -165
- package/packages/utils/src/services/lrsGateway/index.spec.ts +0 -194
- package/packages/utils/src/services/lrsGateway/index.ts +0 -257
- package/packages/utils/src/services/lrsGateway/xapiUtils.spec.ts +0 -887
- package/packages/utils/src/services/lrsGateway/xapiUtils.ts +0 -262
- package/packages/utils/src/services/postgresConnection/index.spec.ts +0 -170
- package/packages/utils/src/services/postgresConnection/index.ts +0 -84
- package/packages/utils/src/services/searchProvider/README.md +0 -3
- package/packages/utils/src/services/searchProvider/index.ts +0 -59
- package/packages/utils/src/services/searchProvider/memorySearchTheBadWay.spec.ts +0 -526
- package/packages/utils/src/services/searchProvider/memorySearchTheBadWay.ts +0 -223
- package/packages/utils/src/services/searchProvider/openSearch.spec.ts +0 -926
- package/packages/utils/src/services/searchProvider/openSearch.ts +0 -195
- package/packages/utils/tsconfig.json +0 -31
- package/packages/utils/tsconfig.without-specs.cjs.json +0 -7
- package/packages/utils/tsconfig.without-specs.esm.json +0 -7
- package/packages/utils/tsconfig.without-specs.json +0 -6
- package/scripts/build.bash +0 -24
- package/scripts/ci.bash +0 -10
- package/scripts/start.bash +0 -29
- /package/{packages/utils/src/index.ts → dist/cjs/index.d.ts} +0 -0
- /package/{packages/utils/src/services/launchParams/index.ts → dist/cjs/services/launchParams/index.d.ts} +0 -0
- /package/{packages/utils/script → script}/bin/copy-from-template.bash +0 -0
- /package/{packages/utils/script → script}/bin/delete-stack.bash +0 -0
- /package/{packages/utils/script → script}/bin/deploy.bash +0 -0
- /package/{packages/utils/script → script}/bin/destroy-deployment.bash +0 -0
- /package/{packages/utils/script → script}/bin/empty-bucket.bash +0 -0
- /package/{packages/utils/script → script}/bin/get-arg.bash +0 -0
- /package/{packages/utils/script → script}/bin/get-deployed-environments.bash +0 -0
- /package/{packages/utils/script → script}/bin/get-env-param.bash +0 -0
- /package/{packages/utils/script → script}/bin/get-kwarg.bash +0 -0
- /package/{packages/utils/script → script}/bin/get-stack-param.bash +0 -0
- /package/{packages/utils/script → script}/bin/has-flag.bash +0 -0
- /package/{packages/utils/script → script}/bin/init-constants-script.bash +0 -0
- /package/{packages/utils/script → script}/bin/init-params-script.bash +0 -0
- /package/{packages/utils/script → script}/bin/stack-exists.bash +0 -0
- /package/{packages/utils/script → script}/bin/update-utils.bash +0 -0
- /package/{packages/utils/script → script}/bin/upload-pager-duty-endpoints.bash +0 -0
- /package/{packages/utils/script → script}/bin/upload-params.bash +0 -0
- /package/{packages/utils/script → script}/bin/which.bash +0 -0
- /package/{packages/utils/script → script}/bin-entry.bash +0 -0
- /package/{packages/utils/script → script}/build.bash +0 -0
package/deploy/shared.cfn.yml
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
Parameters:
|
|
2
|
-
BucketPrefix:
|
|
3
|
-
Description: A prefix to prevent collisions between buckets in different accounts, e.g. sandbox-
|
|
4
|
-
Type: String
|
|
5
|
-
|
|
6
|
-
PagerDutyAnytimeEndpoint:
|
|
7
|
-
Description: PagerDuty endpoint for Anytime notifications
|
|
8
|
-
Type: String
|
|
9
|
-
|
|
10
|
-
PagerDutyWorkdayEndpoint:
|
|
11
|
-
Description: PagerDuty endpoint for Workday notifications
|
|
12
|
-
Type: String
|
|
13
|
-
|
|
14
|
-
Conditions:
|
|
15
|
-
HasPagerDutyAnytimeEndpoint: !Not [!Equals [!Ref PagerDutyAnytimeEndpoint, ""]]
|
|
16
|
-
HasPagerDutyWorkdayEndpoint: !Not [!Equals [!Ref PagerDutyWorkdayEndpoint, ""]]
|
|
17
|
-
|
|
18
|
-
Resources:
|
|
19
|
-
Bucket:
|
|
20
|
-
Type: AWS::S3::Bucket
|
|
21
|
-
DeletionPolicy: Delete
|
|
22
|
-
Properties:
|
|
23
|
-
BucketName: !Sub ${BucketPrefix}${AWS::StackName}-lambda-code
|
|
24
|
-
VersioningConfiguration:
|
|
25
|
-
Status: Enabled
|
|
26
|
-
LifecycleConfiguration:
|
|
27
|
-
Rules:
|
|
28
|
-
- Id: auto-delete
|
|
29
|
-
Status: Enabled
|
|
30
|
-
ExpirationInDays: 30
|
|
31
|
-
OwnershipControls:
|
|
32
|
-
Rules:
|
|
33
|
-
- ObjectOwnership: BucketOwnerEnforced
|
|
34
|
-
|
|
35
|
-
AnytimeTopic:
|
|
36
|
-
Type: AWS::SNS::Topic
|
|
37
|
-
Properties:
|
|
38
|
-
TopicName: !Sub ${AWS::StackName}-anytime-topic
|
|
39
|
-
|
|
40
|
-
AnytimeSubscription:
|
|
41
|
-
Type: AWS::SNS::Subscription
|
|
42
|
-
Condition: HasPagerDutyAnytimeEndpoint
|
|
43
|
-
Properties:
|
|
44
|
-
Endpoint: !Ref PagerDutyAnytimeEndpoint
|
|
45
|
-
Protocol: https
|
|
46
|
-
TopicArn: !Ref AnytimeTopic
|
|
47
|
-
|
|
48
|
-
WorkdayTopic:
|
|
49
|
-
Type: AWS::SNS::Topic
|
|
50
|
-
Properties:
|
|
51
|
-
TopicName: !Sub ${AWS::StackName}-workday-topic
|
|
52
|
-
|
|
53
|
-
WorkdaySubscription:
|
|
54
|
-
Type: AWS::SNS::Subscription
|
|
55
|
-
Condition: HasPagerDutyWorkdayEndpoint
|
|
56
|
-
Properties:
|
|
57
|
-
Endpoint: !Ref PagerDutyWorkdayEndpoint
|
|
58
|
-
Protocol: https
|
|
59
|
-
TopicArn: !Ref WorkdayTopic
|
|
60
|
-
|
|
61
|
-
TopicPolicy:
|
|
62
|
-
Type: AWS::SNS::TopicPolicy
|
|
63
|
-
Properties:
|
|
64
|
-
PolicyDocument:
|
|
65
|
-
Version: '2012-10-17'
|
|
66
|
-
Statement:
|
|
67
|
-
- Effect: Allow
|
|
68
|
-
Principal:
|
|
69
|
-
Service: cloudwatch.amazonaws.com
|
|
70
|
-
Condition:
|
|
71
|
-
ArnLike:
|
|
72
|
-
AWS:SourceArn: !Sub arn:aws:cloudwatch:${AWS::Region}:${AWS::AccountId}:alarm:*
|
|
73
|
-
Action: sns:Publish
|
|
74
|
-
Resource: '*'
|
|
75
|
-
Topics:
|
|
76
|
-
- !Ref AnytimeTopic
|
|
77
|
-
- !Ref WorkdayTopic
|
|
78
|
-
|
|
79
|
-
Outputs:
|
|
80
|
-
BucketName:
|
|
81
|
-
Description: Bucket name
|
|
82
|
-
Value: !Ref Bucket
|
|
83
|
-
|
|
84
|
-
AnytimeTopicArn:
|
|
85
|
-
Description: ARN of the anytime SNS topic
|
|
86
|
-
Value: !Ref AnytimeTopic
|
|
87
|
-
Export:
|
|
88
|
-
Name: !Sub ${AWS::StackName}-sns-anytime-topic-arn
|
|
89
|
-
|
|
90
|
-
WorkdayTopicArn:
|
|
91
|
-
Description: ARN of the workday SNS topic
|
|
92
|
-
Value: !Ref WorkdayTopic
|
|
93
|
-
Export:
|
|
94
|
-
Name: !Sub ${AWS::StackName}-sns-workday-topic-arn
|
package/docs/lambda-build.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Building Typescript for Lambda
|
|
2
|
-
|
|
3
|
-
In our lambda build we use TSC to transpile the typescript, then webpack to bundle the code, and then a zip archive to upload the code to lambda.
|
|
4
|
-
|
|
5
|
-
the lambda `yarn build` command runs the following steps:
|
|
6
|
-
- `/build` directory is populated by TSC in [this script](../packages/lambda/script/build.bash), this can be done with `--watch` for development, which is the default in the main [start command](../scripts/start.bash)
|
|
7
|
-
- `/dist` directory is populated by webpack, which bundles each function in the `/build` directory into a separate bundle.
|
|
8
|
-
- `/dist` directory functions are zipped by [this script](../packages/lambda/script/bundle-functions.bash), the zips are placed next to the bundle files in `/dist`
|
|
9
|
-
|
|
10
|
-
There are a bunch of ways that building typescript for lambda _could_ be done, in this document we'll outline some of the reasons for using this method.
|
|
11
|
-
|
|
12
|
-
## lambda code upload
|
|
13
|
-
|
|
14
|
-
There are 3 main ways to upload the lambda code:
|
|
15
|
-
- [inline](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#aws-properties-lambda-function-code-properties) in a cloudformation template (4MB code size limit)
|
|
16
|
-
- using a [zip file uploaded to s3](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#aws-properties-lambda-function-code-properties). can use multiple zip files to define layers. ([code limit 250MB total, 50MB zipped per zip archive](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#function-configuration-deployment-and-execution))
|
|
17
|
-
- a [container image uploaded to ECR](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#aws-properties-lambda-function-code-properties). ([image size limit 10GB](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#function-configuration-deployment-and-execution))
|
|
18
|
-
|
|
19
|
-
there are other ways to hack around this, like downloading additional code at runtime to the tmp directory, which can get you [another 10GB of code](https://aws.amazon.com/blogs/aws/aws-lambda-now-supports-up-to-10-gb-ephemeral-storage/), but there is performance cost to needing to download it while users wait.
|
|
20
|
-
|
|
21
|
-
*We chose to do zip file uploads, and hedge against size constraints using webpack*. The rest of this section describes the rationale for this decision.
|
|
22
|
-
|
|
23
|
-
with typescript, when choosing one of these methods, the main problem is the size of the `node_modules`. This template repo, with only the example code, has a production `node_modules` directory of 164MB, which zips down to 28MB. So we _could_ just include that in a zip archive. We could either put our whole project in one archive or do two layers, one for the node modules and one for the application code (that might optimize deployments so the lambda runtime doesn't have to download the modules if they haven't changed). The problem is that as real application code is added to this template the size of the `node_modules` is going to grow really fast, the approach being used will stop working, and the build will have to be re-configured to use the container image upload or... do something else.
|
|
24
|
-
|
|
25
|
-
There are a few projects like [this one](https://github.com/tj/node-prune) that try to reduce the size of the `node_modules` by removing unnecessary files based on file-name glob patterns. If you're already in a place where you're uploading your `node_modules` as an archive and need a way to keep its size down to avoid breaking your build, maybe plugging in something like this is an easy solution. In our case we're expecting this to become a problem and there seems to be a better solution for only including the files that are actually used in our deployment code, to bundle the code with a code bundler like webpack. By including a bundler, worst case scenario our deployment will include only the files that have been `import`ed directly, this could still be a lot but is already better than using a file-name based pruning script. Best case scenario the bundler [tree shaking](https://webpack.js.org/guides/tree-shaking/) plugins will be able to also remove any unused parts of the `import`ed code.
|
|
26
|
-
|
|
27
|
-
## TSC
|
|
28
|
-
|
|
29
|
-
Webpack can bundle typescript code directly using [ts-loader](https://www.npmjs.com/package/ts-loader), so there isn't usually a reason to _also_ use the default typescript compiler. In this project template there are two complicating factors, the sibling packages trying to import from our lambda module as a library, and our build config provider.
|
|
30
|
-
|
|
31
|
-
*because of the following concerns we chose to pre-build the ts using tsc and run webpack on the resulting javascript, instead of using ts-loader*
|
|
32
|
-
|
|
33
|
-
In our project workspace, when another package tries to import from a typescript module, it could theoretically import the `.ts` files directly, but this would require the two packages share a typescript config. With different packages, especially if there is a frontend that needs special config like `jsx`, or some packages want the `dom` lib and some want the node types, its not practical for all the packages to share the same typescript configuration. this means that if you want to import between them, they need to be built into javascript with definitions exported. Now we could have two totally separate builds, one for deploying and one for being available to the other packages, but there is already a little incentive here to try to align the way the code is processed to reduce variables and dependencies.
|
|
34
|
-
|
|
35
|
-
The other problem is that our [config system](../packages/utils/src/config.ts) has a flag to indicate if a configuration needs to be provided at build time. To find these configs the build `require`s the code (which is all inert unless you actually invoke the handler) and receives the keys associated with any calls to `envConfig` that don't indicate the `runtime` build option. The build script then dynamically provides these values to webpack's [define plugin](https://webpack.js.org/plugins/define-plugin/). Getting at the real problem, its _super annoying_ to actually invoke typescript directly. it can be done using tools like [ts-node](https://www.npmjs.com/package/ts-node) or [@babel/register](https://babeljs.io/docs/en/babel-register/), but these (especially babel) involve a lot of extra tooling and dependencies, and there is the added discomfort of introducing another runtime that might have its own issues. So the approach that we go with for this is to use TSC to transpile to js, invoke that to get the required env configs, and then bundle the JS that we just invoked. This way we're always sure we're using the same runtime and logic when executing the code, and we're using the same toolkit we already have in the project.
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Getting Started with Create React App
|
|
2
|
-
|
|
3
|
-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
4
|
-
|
|
5
|
-
## Available Scripts
|
|
6
|
-
|
|
7
|
-
In the project directory, you can run:
|
|
8
|
-
|
|
9
|
-
### `yarn start`
|
|
10
|
-
|
|
11
|
-
Runs the app in the development mode.\
|
|
12
|
-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
13
|
-
|
|
14
|
-
The page will reload if you make edits.\
|
|
15
|
-
You will also see any lint errors in the console.
|
|
16
|
-
|
|
17
|
-
### `yarn test`
|
|
18
|
-
|
|
19
|
-
Launches the test runner in the interactive watch mode.\
|
|
20
|
-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
21
|
-
|
|
22
|
-
### `yarn build`
|
|
23
|
-
|
|
24
|
-
Builds the app for production to the `build` folder.\
|
|
25
|
-
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
26
|
-
|
|
27
|
-
The build is minified and the filenames include the hashes.\
|
|
28
|
-
Your app is ready to be deployed!
|
|
29
|
-
|
|
30
|
-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
|
-
|
|
32
|
-
### `yarn eject`
|
|
33
|
-
|
|
34
|
-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
|
35
|
-
|
|
36
|
-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
37
|
-
|
|
38
|
-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
|
39
|
-
|
|
40
|
-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
|
41
|
-
|
|
42
|
-
## Learn More
|
|
43
|
-
|
|
44
|
-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
45
|
-
|
|
46
|
-
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@project/frontend",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"browserslist": {
|
|
5
|
-
"production": [
|
|
6
|
-
">0.2%",
|
|
7
|
-
"not dead",
|
|
8
|
-
"not op_mini all"
|
|
9
|
-
],
|
|
10
|
-
"development": [
|
|
11
|
-
"last 1 chrome version",
|
|
12
|
-
"last 1 firefox version",
|
|
13
|
-
"last 1 safari version"
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@openstax/ts-utils": "1.33.0",
|
|
18
|
-
"@openstax/ui-components": "https://github.com/openstax/ui-components#1.18.3",
|
|
19
|
-
"@testing-library/jest-dom": "^5.14.1",
|
|
20
|
-
"@testing-library/react": "^12.0.0",
|
|
21
|
-
"@testing-library/user-event": "^13.2.1",
|
|
22
|
-
"@types/jest": "^29.5.14",
|
|
23
|
-
"@types/node": "^24.2.0",
|
|
24
|
-
"@types/react": "^17.0.20",
|
|
25
|
-
"@types/react-dom": "^17.0.9",
|
|
26
|
-
"@types/styled-components": "^5.1.25",
|
|
27
|
-
"crypto": "npm:crypto-browserify@^3.12.0",
|
|
28
|
-
"history": "^5.3.0",
|
|
29
|
-
"react": "^17.0.2",
|
|
30
|
-
"react-dom": "^17.0.2",
|
|
31
|
-
"react-scripts": "5.0.0",
|
|
32
|
-
"stream": "npm:stream-browserify@^3.0.0",
|
|
33
|
-
"styled-components": "^5.3.5",
|
|
34
|
-
"typescript": "5.9.2",
|
|
35
|
-
"web-vitals": "^2.1.0"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@babel/plugin-proposal-private-property-in-object": "^7.16.7",
|
|
39
|
-
"@project/lambdas": "1.0.0",
|
|
40
|
-
"cspell": "^5.18.5",
|
|
41
|
-
"http-proxy-middleware": "0.19.0",
|
|
42
|
-
"npm-run-all": "^4.1.5",
|
|
43
|
-
"val-loader": "^4.0.0"
|
|
44
|
-
},
|
|
45
|
-
"eslintConfig": {
|
|
46
|
-
"extends": [
|
|
47
|
-
"react-app",
|
|
48
|
-
"react-app/jest"
|
|
49
|
-
],
|
|
50
|
-
"ignorePatterns": [
|
|
51
|
-
"node_modules",
|
|
52
|
-
"build",
|
|
53
|
-
"coverage"
|
|
54
|
-
],
|
|
55
|
-
"rules": {
|
|
56
|
-
"semi": "off",
|
|
57
|
-
"@typescript-eslint/semi": [
|
|
58
|
-
"warn"
|
|
59
|
-
],
|
|
60
|
-
"@typescript-eslint/member-delimiter-style": [
|
|
61
|
-
"warn"
|
|
62
|
-
],
|
|
63
|
-
"max-len": [
|
|
64
|
-
"warn",
|
|
65
|
-
{
|
|
66
|
-
"code": 120,
|
|
67
|
-
"tabWidth": 4
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"jest": {
|
|
73
|
-
"coverageReporters": [
|
|
74
|
-
"text-summary",
|
|
75
|
-
"html",
|
|
76
|
-
"lcovonly"
|
|
77
|
-
],
|
|
78
|
-
"collectCoverageFrom": [
|
|
79
|
-
"src/*/**/*.{js,ts,tsx}"
|
|
80
|
-
],
|
|
81
|
-
"moduleNameMapper": {
|
|
82
|
-
"//comment//": "remove this when CRA upgrades jest above 28",
|
|
83
|
-
"(.*)@openstax/ts-utils(.*)": "$1@openstax/ts-utils/dist/cjs$2"
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
"private": true,
|
|
87
|
-
"scripts": {
|
|
88
|
-
"build": "react-scripts build",
|
|
89
|
-
"build:clean": "yarn clean && yarn build",
|
|
90
|
-
"ci": "CI=true npm-run-all ci:*",
|
|
91
|
-
"ci:lint": "eslint --max-warnings=0 .",
|
|
92
|
-
"ci:spelling": "git ls-files | yarn cspell -c ../../cspell.json --file-list stdin",
|
|
93
|
-
"ci:test": "CI=true yarn test . --coverage",
|
|
94
|
-
"ci:typecheck": "tsc --noEmit",
|
|
95
|
-
"clean": "rm -rf build",
|
|
96
|
-
"coverage-report": "open coverage/index.html",
|
|
97
|
-
"eject": "react-scripts eject",
|
|
98
|
-
"start": "./script/start.bash",
|
|
99
|
-
"test": "react-scripts test"
|
|
100
|
-
}
|
|
101
|
-
}
|
|
Binary file
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<!-- spell-checker: ignore TFCS -->
|
|
5
|
-
<meta charset="utf-8" />
|
|
6
|
-
<title>OpenStax</title>
|
|
7
|
-
<meta name="robots" content="noindex" />
|
|
8
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
9
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
10
|
-
<meta name="theme-color" content="#000000" />
|
|
11
|
-
<meta
|
|
12
|
-
name="description"
|
|
13
|
-
content="OpenStax"
|
|
14
|
-
/>
|
|
15
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
16
|
-
<!--
|
|
17
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
18
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
19
|
-
-->
|
|
20
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
21
|
-
|
|
22
|
-
<script>
|
|
23
|
-
window.dataLayer = window.dataLayer || [];
|
|
24
|
-
function gtag() {
|
|
25
|
-
dataLayer.push(arguments);
|
|
26
|
-
}
|
|
27
|
-
gtag("consent", "default", {
|
|
28
|
-
ad_storage: "denied",
|
|
29
|
-
ad_user_data: "denied",
|
|
30
|
-
ad_personalization: "denied",
|
|
31
|
-
analytics_storage: "denied",
|
|
32
|
-
functionality_storage: "denied",
|
|
33
|
-
personalization_storage: "denied",
|
|
34
|
-
security_storage: "granted",
|
|
35
|
-
wait_for_update: 2000,
|
|
36
|
-
});
|
|
37
|
-
gtag("set", "ads_data_redaction", true);
|
|
38
|
-
gtag("set", "url_passthrough", false);
|
|
39
|
-
|
|
40
|
-
dataLayer.push({
|
|
41
|
-
'os.release_id':'%REACT_APP_CODE_VERSION%',
|
|
42
|
-
'os.app':'%REACT_APP_NAME%',
|
|
43
|
-
'os.user':window._OX_USER_DATA,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
document.addEventListener('cookieyes_banner_load', (eventData) => {
|
|
47
|
-
const consentPreferences = window._OX_USER_DATA?.consentPreferences;
|
|
48
|
-
if (consentPreferences) {
|
|
49
|
-
// Accounts remembers some state
|
|
50
|
-
// We always defer to Accounts in this case
|
|
51
|
-
|
|
52
|
-
// Only call the CookieYes API if it doesn't match what's in Accounts
|
|
53
|
-
let doUpdate = !eventData.detail.isUserActionCompleted;
|
|
54
|
-
|
|
55
|
-
consentPreferences.accepted?.forEach((accepted) => {
|
|
56
|
-
// There is no "necessary" switch
|
|
57
|
-
if (accepted !== 'necessary') {
|
|
58
|
-
const switchElem = document.getElementById(`ckySwitch${accepted}`);
|
|
59
|
-
if (switchElem) {
|
|
60
|
-
switchElem.checked = true;
|
|
61
|
-
if (!eventData.detail.categories[accepted]) { doUpdate = true; }
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
consentPreferences.rejected?.forEach((rejected) => {
|
|
66
|
-
const switchElem = document.getElementById(`ckySwitch${rejected}`);
|
|
67
|
-
if (switchElem) {
|
|
68
|
-
switchElem.checked = false;
|
|
69
|
-
if (eventData.detail.categories[rejected]) { doUpdate = true; }
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
if (doUpdate) { performBannerAction('accept_partial'); }
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
</script>
|
|
76
|
-
|
|
77
|
-
<!-- Google Tag Manager -->
|
|
78
|
-
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
|
79
|
-
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
|
80
|
-
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
81
|
-
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
82
|
-
})(window,document,'script','dataLayer','GTM-W6N7PB');</script>
|
|
83
|
-
<!-- End Google Tag Manager -->
|
|
84
|
-
<!-- Start cookieyes banner -->
|
|
85
|
-
<script id="cookieyes" type="text/javascript" src="https://cdn-cookieyes.com/client_data/7c03144a7ef8b7f646f1ce01/script.js"></script>
|
|
86
|
-
<!-- End cookieyes banner -->
|
|
87
|
-
<!-- Any new scripts must be placed after this point -->
|
|
88
|
-
</head>
|
|
89
|
-
<body>
|
|
90
|
-
<!-- Google Tag Manager (noscript) -->
|
|
91
|
-
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TFCS56G"
|
|
92
|
-
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
|
93
|
-
<!-- End Google Tag Manager (noscript) -->
|
|
94
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
95
|
-
<main id="root"></main>
|
|
96
|
-
<!--
|
|
97
|
-
This HTML file is a template.
|
|
98
|
-
If you open it directly in the browser, you will see an empty page.
|
|
99
|
-
|
|
100
|
-
You can add web-fonts, meta tags, or analytics to this file.
|
|
101
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
102
|
-
|
|
103
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
104
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
105
|
-
-->
|
|
106
|
-
</body>
|
|
107
|
-
</html>
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<!-- spell-checker: ignore TFCS -->
|
|
5
|
-
<meta charset="utf-8" />
|
|
6
|
-
<title>OpenStax</title>
|
|
7
|
-
<meta name="robots" content="noindex" />
|
|
8
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
9
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
10
|
-
<meta name="theme-color" content="#000000" />
|
|
11
|
-
<meta
|
|
12
|
-
name="description"
|
|
13
|
-
content="OpenStax"
|
|
14
|
-
/>
|
|
15
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
16
|
-
<!--
|
|
17
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
18
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
19
|
-
-->
|
|
20
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
21
|
-
|
|
22
|
-
<script>
|
|
23
|
-
window.dataLayer = window.dataLayer || [];
|
|
24
|
-
window.dataLayer.push({
|
|
25
|
-
'os.release_id':'%REACT_APP_CODE_VERSION%',
|
|
26
|
-
'os.app':'%REACT_APP_NAME%',
|
|
27
|
-
'os.user':window._OX_USER_DATA,
|
|
28
|
-
});
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<style>
|
|
32
|
-
html {
|
|
33
|
-
font-family: Helvetica, Arial, sans-serif;
|
|
34
|
-
font-size: 62.5%;
|
|
35
|
-
text-size-adjust: 100%;
|
|
36
|
-
}
|
|
37
|
-
body {
|
|
38
|
-
padding: 3rem;
|
|
39
|
-
font-size: 1.6rem;
|
|
40
|
-
-webkit-font-smoothing: antialiased;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
h3 {
|
|
44
|
-
font-weight: 400;
|
|
45
|
-
font-size: 2.2rem;
|
|
46
|
-
margin-top: 0;
|
|
47
|
-
}
|
|
48
|
-
</style>
|
|
49
|
-
|
|
50
|
-
<!-- Google Tag Manager -->
|
|
51
|
-
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
|
52
|
-
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
|
53
|
-
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
54
|
-
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
55
|
-
})(window,document,'script','dataLayer','GTM-W6N7PB');</script>
|
|
56
|
-
<!-- End Google Tag Manager -->
|
|
57
|
-
</head>
|
|
58
|
-
<body></body>
|
|
59
|
-
</html>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"short_name": "OpenStax",
|
|
3
|
-
"name": "OpenStax",
|
|
4
|
-
"icons": [
|
|
5
|
-
{
|
|
6
|
-
"src": "favicon.ico",
|
|
7
|
-
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
-
"type": "image/x-icon"
|
|
9
|
-
}
|
|
10
|
-
],
|
|
11
|
-
"start_url": ".",
|
|
12
|
-
"display": "standalone",
|
|
13
|
-
"theme_color": "#000000",
|
|
14
|
-
"background_color": "#ffffff"
|
|
15
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# spell-checker: ignore pipefail newkey outform keyout extfile
|
|
3
|
-
set -euo pipefail; if [ -n "${DEBUG-}" ]; then set -x; fi
|
|
4
|
-
|
|
5
|
-
project_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )"
|
|
6
|
-
shared_certificate_dir=~/.openstax/certs
|
|
7
|
-
|
|
8
|
-
mkdir -p "$project_dir/data"
|
|
9
|
-
mkdir -p "$shared_certificate_dir"
|
|
10
|
-
cd "$project_dir/data"
|
|
11
|
-
|
|
12
|
-
host=${HOST:-localhost}
|
|
13
|
-
|
|
14
|
-
# links about this logic
|
|
15
|
-
# - https://stackoverflow.com/questions/43929436/subject-alternative-name-missing-err-ssl-version-or-cipher-mismatch
|
|
16
|
-
# - https://stackoverflow.com/questions/64597721/neterr-cert-validity-too-long-the-server-certificate-has-a-validity-period-t
|
|
17
|
-
# - https://devopscube.com/create-self-signed-certificates-openssl/
|
|
18
|
-
|
|
19
|
-
if [ ! -f "$shared_certificate_dir/CA.cer" ] || [ ! -f "$shared_certificate_dir/CA.pvk" ]; then
|
|
20
|
-
echo "creating self signed authority"
|
|
21
|
-
cat << EOF > "$shared_certificate_dir/cert.cfn"
|
|
22
|
-
[ req ]
|
|
23
|
-
distinguished_name = req_distinguished_name
|
|
24
|
-
x509_extensions = root_ca
|
|
25
|
-
|
|
26
|
-
[ req_distinguished_name ]
|
|
27
|
-
commonName = openstax.local
|
|
28
|
-
|
|
29
|
-
[ root_ca ]
|
|
30
|
-
basicConstraints = critical, CA:true
|
|
31
|
-
EOF
|
|
32
|
-
openssl req -x509 -sha256 -days 356 -nodes -newkey rsa:2048 -config "$shared_certificate_dir/cert.cfn" -subj "/CN=Openstax.local" \
|
|
33
|
-
-keyout "$shared_certificate_dir/CA.pvk" \
|
|
34
|
-
-out "$shared_certificate_dir/CA.cer"
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
if [ ! -f "$host.pvk" ] || [ ! -f "$host.cer" ]; then
|
|
38
|
-
cat << EOF > "$project_dir/data/$host.ext"
|
|
39
|
-
subjectAltName = @alt_names
|
|
40
|
-
extendedKeyUsage = serverAuth
|
|
41
|
-
|
|
42
|
-
[alt_names]
|
|
43
|
-
DNS.1 = $host
|
|
44
|
-
EOF
|
|
45
|
-
openssl req -newkey rsa:2048 -keyout "$host.pvk" -out "$host.req" -subj /CN="$host" -sha256 -nodes
|
|
46
|
-
openssl x509 -req \
|
|
47
|
-
-CA "$shared_certificate_dir/CA.cer" -CAkey "$shared_certificate_dir/CA.pvk" \
|
|
48
|
-
-in "$host.req" -out "$host.cer" -days 397 -extfile "$host.ext" -sha256
|
|
49
|
-
fi
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
const { argv } = require('yargs');
|
|
3
|
-
const { startServer } = require('.');
|
|
4
|
-
|
|
5
|
-
startServer(argv)
|
|
6
|
-
.then(({port}) => console.log(`WEBSERVER: running on port: ${port}`))
|
|
7
|
-
.catch((e) => {
|
|
8
|
-
console.error(e.message);
|
|
9
|
-
process.exit(1);
|
|
10
|
-
})
|
|
11
|
-
;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const express = require('express');
|
|
2
|
-
const http = require('http');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const serveStatic = require('serve-static');
|
|
5
|
-
const setupProxy = require('../../src/setupProxy');
|
|
6
|
-
|
|
7
|
-
const makeFallback = (serve) => (req, res, next) => {
|
|
8
|
-
req.url = '/index.html';
|
|
9
|
-
serve(req, res, next);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const makeServe = (baseDir) => {
|
|
13
|
-
return serveStatic(baseDir, {redirect: false});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const makeOptions = (options) => ({
|
|
17
|
-
port: process.env.PORT,
|
|
18
|
-
...options,
|
|
19
|
-
baseDir: path.join(__dirname, '../../build'),
|
|
20
|
-
onlyProxy: !!options.onlyProxy,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const makeMiddleware = (options) => {
|
|
24
|
-
const app = express();
|
|
25
|
-
|
|
26
|
-
setupProxy(app);
|
|
27
|
-
|
|
28
|
-
if (!options.onlyProxy) {
|
|
29
|
-
const serve = makeServe(options.baseDir);
|
|
30
|
-
app.use(serve);
|
|
31
|
-
app.use(makeFallback(serve));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return app;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const startServer = (options) => new Promise((resolve) => {
|
|
38
|
-
const serverConfig = makeOptions(options);
|
|
39
|
-
const app = makeMiddleware(serverConfig);
|
|
40
|
-
const server = http.createServer(app);
|
|
41
|
-
|
|
42
|
-
server.listen(serverConfig.port, () => resolve({server, port: serverConfig.port}));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
module.exports = {
|
|
46
|
-
startServer
|
|
47
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# spell-checker: ignore pipefail
|
|
3
|
-
set -euo pipefail; if [ -n "${DEBUG-}" ]; then set -x; fi
|
|
4
|
-
|
|
5
|
-
project_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )"
|
|
6
|
-
shared_certificate_dir=~/.openstax/certs
|
|
7
|
-
|
|
8
|
-
mkdir -p "$project_dir/data"
|
|
9
|
-
|
|
10
|
-
./script/make-certificate.bash
|
|
11
|
-
|
|
12
|
-
cd "$project_dir"
|
|
13
|
-
|
|
14
|
-
# nodejs does not use system certs by default
|
|
15
|
-
# - https://github.com/nodejs/node/issues/39657
|
|
16
|
-
export NODE_EXTRA_CA_CERTS="$shared_certificate_dir/CA.cer"
|
|
17
|
-
export SSL_CRT_FILE="$project_dir/data/${HOST:-localhost}.cer"
|
|
18
|
-
export SSL_KEY_FILE="$project_dir/data/${HOST:-localhost}.pvk";
|
|
19
|
-
export HTTPS=true
|
|
20
|
-
export BROWSER=none
|
|
21
|
-
|
|
22
|
-
yarn react-scripts start
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# spell-checker: ignore pipefail Keychains keychain
|
|
3
|
-
set -euo pipefail; if [ -n "${DEBUG-}" ]; then set -x; fi
|
|
4
|
-
|
|
5
|
-
shared_certificate_dir=~/.openstax/certs
|
|
6
|
-
|
|
7
|
-
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "$shared_certificate_dir"/CA.cer
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { browserAuthProvider } from '@openstax/ts-utils/services/authProvider/browser';
|
|
2
|
-
import { FrontendConfigProvider } from '../configProvider';
|
|
3
|
-
|
|
4
|
-
export const createAuthProvider = (
|
|
5
|
-
...args: Parameters<typeof browserAuthProvider>
|
|
6
|
-
) => (configProvider: FrontendConfigProvider) => browserAuthProvider(...args)({
|
|
7
|
-
auth: {
|
|
8
|
-
accountsBase: () => configProvider.getValue('accountsBase'),
|
|
9
|
-
}
|
|
10
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { User } from "@openstax/ts-utils/services/authProvider";
|
|
3
|
-
import { useServices } from "../core/context/services";
|
|
4
|
-
import { useSetAppError } from '@openstax/ui-components';
|
|
5
|
-
import { FetchState, fetchSuccess, fetchLoading } from "@openstax/ts-utils/fetch";
|
|
6
|
-
import { useFrontendConfigValue } from '../configProvider/use';
|
|
7
|
-
|
|
8
|
-
export const useAuth = () => {
|
|
9
|
-
const authProvider = useServices().authProvider;
|
|
10
|
-
const setAppError = useSetAppError();
|
|
11
|
-
const [state, setUser] = React.useState<FetchState<User | undefined, string>>(fetchLoading());
|
|
12
|
-
|
|
13
|
-
React.useEffect(() => {
|
|
14
|
-
authProvider.getUser()
|
|
15
|
-
.then(user => setUser(fetchSuccess(user)))
|
|
16
|
-
.catch(setAppError);
|
|
17
|
-
}, [authProvider, setAppError]);
|
|
18
|
-
|
|
19
|
-
return state;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const useUserRoles = () => {
|
|
23
|
-
const roleValidator = useServices().roleValidator;
|
|
24
|
-
const [state, setRoles] = React.useState<FetchState<string[], string>>(fetchLoading());
|
|
25
|
-
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
roleValidator.getUserRoles().then(roles => setRoles(fetchSuccess(roles)));
|
|
28
|
-
}, [roleValidator]);
|
|
29
|
-
|
|
30
|
-
return state;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const useAccountsBase = () => useFrontendConfigValue('accountsBase');
|