@crowi/plugin-aws 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Sotaro KARASAWA <sotaro.k@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # @crowi/plugin-aws
2
+
3
+ Shared AWS credentials base plugin. Holds `region` / `accessKeyId` /
4
+ `secretAccessKey` once, so any number of AWS-using plugins
5
+ (`@crowi/plugin-storage-aws-s3`, future `@crowi/plugin-mail-aws-ses`, etc)
6
+ can read the same configuration without operators duplicating it.
7
+
8
+ This plugin **does not register any driver** on its own — it's a
9
+ config-holder. It auto-loads when any AWS plugin lists it under
10
+ `requires`, so operators do not need to add it to
11
+ `crowi.config.json:plugins` themselves.
12
+
13
+ ## Configure
14
+
15
+ Open `/admin/plugins`, select `@crowi/plugin-aws`, and fill in:
16
+
17
+ | Field | Required? | Notes |
18
+ |---|---|---|
19
+ | `region` | Recommended | e.g. `ap-northeast-1`, `us-east-1`. Validated against the `<area>-<sub>-<num>` shape. Empty string falls back to the SDK default region resolution. |
20
+ | `accessKeyId` | Optional | Long-lived IAM access key. Leave blank to use the SDK's default credential chain (see below). |
21
+ | `secretAccessKey` | Optional | Pairs with `accessKeyId`. Encrypted at rest with `CROWI_ENCRYPTION_KEY`. |
22
+
23
+ ### When to leave the keys blank
24
+
25
+ Both `accessKeyId` and `secretAccessKey` empty → the AWS SDK falls back
26
+ to its [default credential provider chain](https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html#credentialProviderChain),
27
+ in this order:
28
+
29
+ 1. Environment variables (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` /
30
+ `AWS_SESSION_TOKEN`)
31
+ 2. Shared credentials file (`~/.aws/credentials`)
32
+ 3. EC2 / ECS / EKS instance / task / pod identity
33
+ 4. Other SDK-managed sources (SSO, web identity, etc.)
34
+
35
+ For production on AWS, **leave the keys blank and use an IAM role**.
36
+ You get short-lived credentials rotated by AWS without operators ever
37
+ holding a long-lived secret.
38
+
39
+ ## What this plugin does NOT do
40
+
41
+ - **Does not register a storage / search / auth / notifier driver.** Its
42
+ only job is to publish a typed config to dependent plugins via
43
+ `ctx.dependencyConfig<AwsConfig>('@crowi/plugin-aws')`.
44
+ - **Does not pre-validate credentials.** A bad key shows up at the first
45
+ AWS API call from the dependent plugin (e.g. an S3 `PutObject`),
46
+ not at boot.
47
+ - **Does not configure per-service knobs** (S3 bucket, SES verified
48
+ identity, etc). Those live in the consuming plugin's own config.
49
+
50
+ ## See also
51
+
52
+ - [`@crowi/plugin-storage-aws-s3`](../plugin-storage-aws-s3) — S3 storage
53
+ driver. Required IAM permissions are documented there.
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod/v3';
2
+ import { CrowiPlugin } from '@crowi/plugin-api';
3
+
4
+ /**
5
+ * Shared AWS configuration. Storage / mail / etc. plugins list this in
6
+ * `requires` and read it via `ctx.dependencyConfig('@crowi/plugin-aws')`,
7
+ * so operators don't have to add it to `crowi.config.json:plugins`
8
+ * themselves and the admin form section is rendered once regardless of
9
+ * how many AWS-using plugins are installed.
10
+ */
11
+ declare const AwsConfigSchema: z.ZodObject<{
12
+ region: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
13
+ /**
14
+ * Leave both accessKeyId and secretAccessKey empty to fall back to
15
+ * the Node SDK's default credential chain (IAM role / env vars /
16
+ * shared credentials file).
17
+ */
18
+ accessKeyId: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
19
+ secretAccessKey: z.ZodDefault<z.ZodString>;
20
+ }, "strict", z.ZodTypeAny, {
21
+ region: string;
22
+ accessKeyId: string;
23
+ secretAccessKey: string;
24
+ }, {
25
+ region?: string | undefined;
26
+ accessKeyId?: string | undefined;
27
+ secretAccessKey?: string | undefined;
28
+ }>;
29
+ type AwsConfig = z.infer<typeof AwsConfigSchema>;
30
+ declare const plugin: CrowiPlugin;
31
+
32
+ export { type AwsConfig, AwsConfigSchema, plugin as default };
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod/v3';
2
+ import { CrowiPlugin } from '@crowi/plugin-api';
3
+
4
+ /**
5
+ * Shared AWS configuration. Storage / mail / etc. plugins list this in
6
+ * `requires` and read it via `ctx.dependencyConfig('@crowi/plugin-aws')`,
7
+ * so operators don't have to add it to `crowi.config.json:plugins`
8
+ * themselves and the admin form section is rendered once regardless of
9
+ * how many AWS-using plugins are installed.
10
+ */
11
+ declare const AwsConfigSchema: z.ZodObject<{
12
+ region: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
13
+ /**
14
+ * Leave both accessKeyId and secretAccessKey empty to fall back to
15
+ * the Node SDK's default credential chain (IAM role / env vars /
16
+ * shared credentials file).
17
+ */
18
+ accessKeyId: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
19
+ secretAccessKey: z.ZodDefault<z.ZodString>;
20
+ }, "strict", z.ZodTypeAny, {
21
+ region: string;
22
+ accessKeyId: string;
23
+ secretAccessKey: string;
24
+ }, {
25
+ region?: string | undefined;
26
+ accessKeyId?: string | undefined;
27
+ secretAccessKey?: string | undefined;
28
+ }>;
29
+ type AwsConfig = z.infer<typeof AwsConfigSchema>;
30
+ declare const plugin: CrowiPlugin;
31
+
32
+ export { type AwsConfig, AwsConfigSchema, plugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AwsConfigSchema: () => AwsConfigSchema,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_v3 = require("zod/v3");
28
+ var AwsConfigSchema = import_v3.z.object({
29
+ region: import_v3.z.string().trim().refine((v) => v === "" || /^[a-z]+(-[a-z]+)?-[a-z]+-\d+$/.test(v), {
30
+ message: "Must be a valid AWS region name (e.g. ap-northeast-1)"
31
+ }).default(""),
32
+ /**
33
+ * Leave both accessKeyId and secretAccessKey empty to fall back to
34
+ * the Node SDK's default credential chain (IAM role / env vars /
35
+ * shared credentials file).
36
+ */
37
+ accessKeyId: import_v3.z.string().trim().refine((v) => v === "" || /^[\dA-Za-z]+$/.test(v), {
38
+ message: "Access Key ID must be alphanumeric"
39
+ }).default(""),
40
+ secretAccessKey: import_v3.z.string().describe("@sensitive AWS secret access key").default("")
41
+ }).strict();
42
+ var plugin = {
43
+ name: "@crowi/plugin-aws",
44
+ version: "0.1.0-dev",
45
+ configSchema: AwsConfigSchema,
46
+ adminPlacement: {
47
+ section: "shared",
48
+ label: "AWS",
49
+ icon: "cloud"
50
+ }
51
+ };
52
+ var index_default = plugin;
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ AwsConfigSchema
56
+ });
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { z } from 'zod/v3';\nimport type { CrowiPlugin } from '@crowi/plugin-api';\n\n/**\n * Shared AWS configuration. Storage / mail / etc. plugins list this in\n * `requires` and read it via `ctx.dependencyConfig('@crowi/plugin-aws')`,\n * so operators don't have to add it to `crowi.config.json:plugins`\n * themselves and the admin form section is rendered once regardless of\n * how many AWS-using plugins are installed.\n */\nexport const AwsConfigSchema = z\n .object({\n region: z\n .string()\n .trim()\n .refine((v) => v === '' || /^[a-z]+(-[a-z]+)?-[a-z]+-\\d+$/.test(v), {\n message: 'Must be a valid AWS region name (e.g. ap-northeast-1)',\n })\n .default(''),\n /**\n * Leave both accessKeyId and secretAccessKey empty to fall back to\n * the Node SDK's default credential chain (IAM role / env vars /\n * shared credentials file).\n */\n accessKeyId: z\n .string()\n .trim()\n .refine((v) => v === '' || /^[\\dA-Za-z]+$/.test(v), {\n message: 'Access Key ID must be alphanumeric',\n })\n .default(''),\n secretAccessKey: z.string().describe('@sensitive AWS secret access key').default(''),\n })\n .strict();\n\nexport type AwsConfig = z.infer<typeof AwsConfigSchema>;\n\nconst plugin: CrowiPlugin = {\n name: '@crowi/plugin-aws',\n version: '0.1.0-dev',\n configSchema: AwsConfigSchema,\n adminPlacement: {\n section: 'shared',\n label: 'AWS',\n icon: 'cloud',\n },\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAkB;AAUX,IAAM,kBAAkB,YAC5B,OAAO;AAAA,EACN,QAAQ,YACL,OAAO,EACP,KAAK,EACL,OAAO,CAAC,MAAM,MAAM,MAAM,gCAAgC,KAAK,CAAC,GAAG;AAAA,IAClE,SAAS;AAAA,EACX,CAAC,EACA,QAAQ,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMb,aAAa,YACV,OAAO,EACP,KAAK,EACL,OAAO,CAAC,MAAM,MAAM,MAAM,gBAAgB,KAAK,CAAC,GAAG;AAAA,IAClD,SAAS;AAAA,EACX,CAAC,EACA,QAAQ,EAAE;AAAA,EACb,iBAAiB,YAAE,OAAO,EAAE,SAAS,kCAAkC,EAAE,QAAQ,EAAE;AACrF,CAAC,EACA,OAAO;AAIV,IAAM,SAAsB;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,cAAc;AAAA,EACd,gBAAgB;AAAA,IACd,SAAS;AAAA,IACT,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,32 @@
1
+ // src/index.ts
2
+ import { z } from "zod/v3";
3
+ var AwsConfigSchema = z.object({
4
+ region: z.string().trim().refine((v) => v === "" || /^[a-z]+(-[a-z]+)?-[a-z]+-\d+$/.test(v), {
5
+ message: "Must be a valid AWS region name (e.g. ap-northeast-1)"
6
+ }).default(""),
7
+ /**
8
+ * Leave both accessKeyId and secretAccessKey empty to fall back to
9
+ * the Node SDK's default credential chain (IAM role / env vars /
10
+ * shared credentials file).
11
+ */
12
+ accessKeyId: z.string().trim().refine((v) => v === "" || /^[\dA-Za-z]+$/.test(v), {
13
+ message: "Access Key ID must be alphanumeric"
14
+ }).default(""),
15
+ secretAccessKey: z.string().describe("@sensitive AWS secret access key").default("")
16
+ }).strict();
17
+ var plugin = {
18
+ name: "@crowi/plugin-aws",
19
+ version: "0.1.0-dev",
20
+ configSchema: AwsConfigSchema,
21
+ adminPlacement: {
22
+ section: "shared",
23
+ label: "AWS",
24
+ icon: "cloud"
25
+ }
26
+ };
27
+ var index_default = plugin;
28
+ export {
29
+ AwsConfigSchema,
30
+ index_default as default
31
+ };
32
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { z } from 'zod/v3';\nimport type { CrowiPlugin } from '@crowi/plugin-api';\n\n/**\n * Shared AWS configuration. Storage / mail / etc. plugins list this in\n * `requires` and read it via `ctx.dependencyConfig('@crowi/plugin-aws')`,\n * so operators don't have to add it to `crowi.config.json:plugins`\n * themselves and the admin form section is rendered once regardless of\n * how many AWS-using plugins are installed.\n */\nexport const AwsConfigSchema = z\n .object({\n region: z\n .string()\n .trim()\n .refine((v) => v === '' || /^[a-z]+(-[a-z]+)?-[a-z]+-\\d+$/.test(v), {\n message: 'Must be a valid AWS region name (e.g. ap-northeast-1)',\n })\n .default(''),\n /**\n * Leave both accessKeyId and secretAccessKey empty to fall back to\n * the Node SDK's default credential chain (IAM role / env vars /\n * shared credentials file).\n */\n accessKeyId: z\n .string()\n .trim()\n .refine((v) => v === '' || /^[\\dA-Za-z]+$/.test(v), {\n message: 'Access Key ID must be alphanumeric',\n })\n .default(''),\n secretAccessKey: z.string().describe('@sensitive AWS secret access key').default(''),\n })\n .strict();\n\nexport type AwsConfig = z.infer<typeof AwsConfigSchema>;\n\nconst plugin: CrowiPlugin = {\n name: '@crowi/plugin-aws',\n version: '0.1.0-dev',\n configSchema: AwsConfigSchema,\n adminPlacement: {\n section: 'shared',\n label: 'AWS',\n icon: 'cloud',\n },\n};\n\nexport default plugin;\n"],"mappings":";AAAA,SAAS,SAAS;AAUX,IAAM,kBAAkB,EAC5B,OAAO;AAAA,EACN,QAAQ,EACL,OAAO,EACP,KAAK,EACL,OAAO,CAAC,MAAM,MAAM,MAAM,gCAAgC,KAAK,CAAC,GAAG;AAAA,IAClE,SAAS;AAAA,EACX,CAAC,EACA,QAAQ,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMb,aAAa,EACV,OAAO,EACP,KAAK,EACL,OAAO,CAAC,MAAM,MAAM,MAAM,gBAAgB,KAAK,CAAC,GAAG;AAAA,IAClD,SAAS;AAAA,EACX,CAAC,EACA,QAAQ,EAAE;AAAA,EACb,iBAAiB,EAAE,OAAO,EAAE,SAAS,kCAAkC,EAAE,QAAQ,EAAE;AACrF,CAAC,EACA,OAAO;AAIV,IAAM,SAAsB;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,cAAc;AAAA,EACd,gBAAgB;AAAA,IACd,SAAS;AAAA,IACT,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@crowi/plugin-aws",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "AWS base configuration for Crowi 2.0 — shared region / accessKeyId / secretAccessKey for downstream AWS service plugins (S3, SES, ...).",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "peerDependencies": {
23
+ "zod": "^4.4.3"
24
+ },
25
+ "devDependencies": {
26
+ "tsup": "^8.3.5",
27
+ "typescript": "^5.8.3",
28
+ "zod": "^4.4.3",
29
+ "@crowi/tsconfig": "0.1.0-alpha.0",
30
+ "@crowi/plugin-api": "0.1.0-alpha.0"
31
+ },
32
+ "dependencies": {
33
+ "@crowi/plugin-api": "^0.1.0-alpha.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "dev": "tsup --watch --no-clean",
38
+ "type-check": "tsc --noEmit"
39
+ }
40
+ }