@awsless/awsless 0.0.79 → 0.0.81
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/dist/bin.js +113 -83
- package/dist/index.d.ts +2938 -71
- package/dist/index.js +23 -19
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -2139,10 +2139,7 @@ var tablePlugin = definePlugin({
|
|
|
2139
2139
|
* }
|
|
2140
2140
|
* }
|
|
2141
2141
|
*/
|
|
2142
|
-
fields: z9.record(
|
|
2143
|
-
z9.string(),
|
|
2144
|
-
z9.enum(["string", "number", "binary"])
|
|
2145
|
-
).optional(),
|
|
2142
|
+
fields: z9.record(z9.string(), z9.enum(["string", "number", "binary"])).optional(),
|
|
2146
2143
|
/** The table class of the table.
|
|
2147
2144
|
* @default 'standard'
|
|
2148
2145
|
*/
|
|
@@ -2179,18 +2176,21 @@ var tablePlugin = definePlugin({
|
|
|
2179
2176
|
* }
|
|
2180
2177
|
* }
|
|
2181
2178
|
*/
|
|
2182
|
-
indexes: z9.record(
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2179
|
+
indexes: z9.record(
|
|
2180
|
+
z9.string(),
|
|
2181
|
+
z9.object({
|
|
2182
|
+
/** Specifies the name of the partition / hash key that makes up the primary key for the global secondary index. */
|
|
2183
|
+
hash: KeySchema,
|
|
2184
|
+
/** Specifies the name of the range / sort key that makes up the primary key for the global secondary index. */
|
|
2185
|
+
sort: KeySchema.optional(),
|
|
2186
|
+
/** The set of attributes that are projected into the index:
|
|
2187
|
+
* - all - All of the table attributes are projected into the index.
|
|
2188
|
+
* - keys-only - Only the index and primary keys are projected into the index.
|
|
2189
|
+
* @default 'all'
|
|
2190
|
+
*/
|
|
2191
|
+
projection: z9.enum(["all", "keys-only"]).default("all")
|
|
2192
|
+
})
|
|
2193
|
+
).optional()
|
|
2194
2194
|
})
|
|
2195
2195
|
).optional()
|
|
2196
2196
|
}).array()
|
|
@@ -2201,7 +2201,7 @@ var tablePlugin = definePlugin({
|
|
|
2201
2201
|
const list3 = new TypeObject();
|
|
2202
2202
|
for (const name of Object.keys(stack.tables || {})) {
|
|
2203
2203
|
const tableName = formatName(`${config.name}-${stack.name}-${name}`);
|
|
2204
|
-
list3.addType(name,
|
|
2204
|
+
list3.addType(name, tableName);
|
|
2205
2205
|
}
|
|
2206
2206
|
types2.addType(stack.name, list3.toString());
|
|
2207
2207
|
}
|
|
@@ -2433,7 +2433,7 @@ import { PublishOptions } from '@awsless/sns'
|
|
|
2433
2433
|
|
|
2434
2434
|
type Publish<Name extends string> = {
|
|
2435
2435
|
readonly name: Name
|
|
2436
|
-
|
|
2436
|
+
(payload: unknown, options?: Omit<PublishOptions, 'topic' | 'payload'>): Promise<void>
|
|
2437
2437
|
}`;
|
|
2438
2438
|
var topicPlugin = definePlugin({
|
|
2439
2439
|
name: "topic",
|
|
@@ -5316,11 +5316,13 @@ var sitePlugin = definePlugin({
|
|
|
5316
5316
|
}).dependsOn(lambda);
|
|
5317
5317
|
const url = lambda.addUrl();
|
|
5318
5318
|
stack.add(url, lambda, permissions);
|
|
5319
|
-
origins.push(
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5319
|
+
origins.push(
|
|
5320
|
+
new Origin({
|
|
5321
|
+
id: "lambda",
|
|
5322
|
+
domainName: select(2, split("/", url.url)),
|
|
5323
|
+
protocol: "https-only"
|
|
5324
|
+
})
|
|
5325
|
+
);
|
|
5324
5326
|
deps.push(lambda, url, permissions);
|
|
5325
5327
|
}
|
|
5326
5328
|
if (props.static) {
|
|
@@ -5355,20 +5357,24 @@ var sitePlugin = definePlugin({
|
|
|
5355
5357
|
}
|
|
5356
5358
|
}).dependsOn(bucket);
|
|
5357
5359
|
stack.add(bucket, files, uploadBucketAsset, deleteBucket, accessControl);
|
|
5358
|
-
origins.push(
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5360
|
+
origins.push(
|
|
5361
|
+
new Origin({
|
|
5362
|
+
id: "bucket",
|
|
5363
|
+
// domainName: select(2, split('/', bucket.url)),
|
|
5364
|
+
domainName: bucket.domainName,
|
|
5365
|
+
originAccessControlId: accessControl.id
|
|
5366
|
+
})
|
|
5367
|
+
);
|
|
5364
5368
|
deps.push(bucket, accessControl);
|
|
5365
5369
|
}
|
|
5366
5370
|
if (props.ssr && props.static) {
|
|
5367
|
-
originGroups.push(
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5371
|
+
originGroups.push(
|
|
5372
|
+
new OriginGroup({
|
|
5373
|
+
id: "group",
|
|
5374
|
+
members: ["lambda", "bucket"],
|
|
5375
|
+
statusCodes: [403, 404]
|
|
5376
|
+
})
|
|
5377
|
+
);
|
|
5372
5378
|
}
|
|
5373
5379
|
const cache = new CachePolicy(id, {
|
|
5374
5380
|
name: `site-${config.name}-${stack.name}-${id}`,
|
|
@@ -5455,14 +5461,7 @@ var sitePlugin = definePlugin({
|
|
|
5455
5461
|
hostedZoneId: "Z2FDTNDATAQYW2"
|
|
5456
5462
|
}
|
|
5457
5463
|
}).dependsOn(distribution);
|
|
5458
|
-
stack.add(
|
|
5459
|
-
distribution,
|
|
5460
|
-
invalidateCache,
|
|
5461
|
-
responseHeaders,
|
|
5462
|
-
originRequest,
|
|
5463
|
-
cache,
|
|
5464
|
-
record
|
|
5465
|
-
);
|
|
5464
|
+
stack.add(distribution, invalidateCache, responseHeaders, originRequest, cache, record);
|
|
5466
5465
|
}
|
|
5467
5466
|
}
|
|
5468
5467
|
});
|
|
@@ -5710,22 +5709,42 @@ var UserPool = class extends Resource {
|
|
|
5710
5709
|
}
|
|
5711
5710
|
},
|
|
5712
5711
|
LambdaConfig: {
|
|
5713
|
-
...this.attr("PreAuthentication", this.props.
|
|
5714
|
-
...this.attr("PostAuthentication", this.props.
|
|
5715
|
-
...this.attr("PostConfirmation", this.props.
|
|
5716
|
-
...this.attr("PreSignUp", this.props.
|
|
5717
|
-
...this.attr("PreTokenGeneration", this.props.
|
|
5718
|
-
...this.attr("CustomMessage", this.props.
|
|
5719
|
-
...this.attr("UserMigration", this.props.
|
|
5720
|
-
...this.attr("DefineAuthChallenge", this.props.
|
|
5721
|
-
...this.attr("CreateAuthChallenge", this.props.
|
|
5722
|
-
...this.attr("VerifyAuthChallengeResponse", this.props.
|
|
5712
|
+
...this.attr("PreAuthentication", this.props.triggers?.beforeLogin),
|
|
5713
|
+
...this.attr("PostAuthentication", this.props.triggers?.afterLogin),
|
|
5714
|
+
...this.attr("PostConfirmation", this.props.triggers?.afterRegister),
|
|
5715
|
+
...this.attr("PreSignUp", this.props.triggers?.beforeRegister),
|
|
5716
|
+
...this.attr("PreTokenGeneration", this.props.triggers?.beforeToken),
|
|
5717
|
+
...this.attr("CustomMessage", this.props.triggers?.customMessage),
|
|
5718
|
+
...this.attr("UserMigration", this.props.triggers?.userMigration),
|
|
5719
|
+
...this.attr("DefineAuthChallenge", this.props.triggers?.defineChallange),
|
|
5720
|
+
...this.attr("CreateAuthChallenge", this.props.triggers?.createChallange),
|
|
5721
|
+
...this.attr("VerifyAuthChallengeResponse", this.props.triggers?.verifyChallange)
|
|
5723
5722
|
}
|
|
5724
5723
|
};
|
|
5725
5724
|
}
|
|
5726
5725
|
};
|
|
5727
5726
|
|
|
5728
5727
|
// src/plugins/auth.ts
|
|
5728
|
+
var TriggersSchema = z25.object({
|
|
5729
|
+
/** A pre jwt token generation AWS Lambda trigger. */
|
|
5730
|
+
beforeToken: FunctionSchema.optional(),
|
|
5731
|
+
/** A pre user login AWS Lambda trigger. */
|
|
5732
|
+
beforeLogin: FunctionSchema.optional(),
|
|
5733
|
+
/** A post user login AWS Lambda trigger. */
|
|
5734
|
+
afterLogin: FunctionSchema.optional(),
|
|
5735
|
+
/** A pre user register AWS Lambda trigger. */
|
|
5736
|
+
beforeRegister: FunctionSchema.optional(),
|
|
5737
|
+
/** A post user register AWS Lambda trigger. */
|
|
5738
|
+
afterRegister: FunctionSchema.optional(),
|
|
5739
|
+
/** A custom message AWS Lambda trigger. */
|
|
5740
|
+
customMessage: FunctionSchema.optional(),
|
|
5741
|
+
/** Defines the authentication challenge. */
|
|
5742
|
+
defineChallenge: FunctionSchema.optional(),
|
|
5743
|
+
/** Creates an authentication challenge. */
|
|
5744
|
+
createChallenge: FunctionSchema.optional(),
|
|
5745
|
+
/** Verifies the authentication challenge response. */
|
|
5746
|
+
verifyChallenge: FunctionSchema.optional()
|
|
5747
|
+
});
|
|
5729
5748
|
var authPlugin = definePlugin({
|
|
5730
5749
|
name: "auth",
|
|
5731
5750
|
schema: z25.object({
|
|
@@ -5812,29 +5831,31 @@ var authPlugin = definePlugin({
|
|
|
5812
5831
|
refreshToken: DurationSchema.default("365 days")
|
|
5813
5832
|
}).default({}),
|
|
5814
5833
|
/** Specifies the configuration for AWS Lambda triggers. */
|
|
5815
|
-
|
|
5816
|
-
/** A pre jwt token generation AWS Lambda trigger. */
|
|
5817
|
-
preToken: FunctionSchema.optional(),
|
|
5818
|
-
/** A pre user login AWS Lambda trigger. */
|
|
5819
|
-
preLogin: FunctionSchema.optional(),
|
|
5820
|
-
/** A post user login AWS Lambda trigger. */
|
|
5821
|
-
postLogin: FunctionSchema.optional(),
|
|
5822
|
-
/** A pre user register AWS Lambda trigger. */
|
|
5823
|
-
preRegister: FunctionSchema.optional(),
|
|
5824
|
-
/** A post user register AWS Lambda trigger. */
|
|
5825
|
-
postRegister: FunctionSchema.optional(),
|
|
5826
|
-
/** A custom message AWS Lambda trigger. */
|
|
5827
|
-
customMessage: FunctionSchema.optional(),
|
|
5828
|
-
/** Defines the authentication challenge. */
|
|
5829
|
-
defineChallenge: FunctionSchema.optional(),
|
|
5830
|
-
/** Creates an authentication challenge. */
|
|
5831
|
-
createChallenge: FunctionSchema.optional(),
|
|
5832
|
-
/** Verifies the authentication challenge response. */
|
|
5833
|
-
verifyChallenge: FunctionSchema.optional()
|
|
5834
|
-
}).optional()
|
|
5834
|
+
triggers: TriggersSchema.optional()
|
|
5835
5835
|
})
|
|
5836
5836
|
).default({})
|
|
5837
|
-
}).default({})
|
|
5837
|
+
}).default({}),
|
|
5838
|
+
stacks: z25.object({
|
|
5839
|
+
/** Define the auth triggers in your stack.
|
|
5840
|
+
* @example
|
|
5841
|
+
* {
|
|
5842
|
+
* auth: {
|
|
5843
|
+
* AUTH_NAME: {
|
|
5844
|
+
* triggers: {
|
|
5845
|
+
* beforeLogin: 'function.ts',
|
|
5846
|
+
* }
|
|
5847
|
+
* }
|
|
5848
|
+
* }
|
|
5849
|
+
* }
|
|
5850
|
+
*/
|
|
5851
|
+
auth: z25.record(
|
|
5852
|
+
ResourceIdSchema,
|
|
5853
|
+
z25.object({
|
|
5854
|
+
/** Specifies the configuration for AWS Lambda triggers. */
|
|
5855
|
+
triggers: TriggersSchema.optional()
|
|
5856
|
+
})
|
|
5857
|
+
).optional()
|
|
5858
|
+
}).array()
|
|
5838
5859
|
}),
|
|
5839
5860
|
onTypeGen({ config }) {
|
|
5840
5861
|
const gen = new TypeGen("@awsless/awsless", "AuthResources");
|
|
@@ -5847,18 +5868,30 @@ var authPlugin = definePlugin({
|
|
|
5847
5868
|
const { config, bootstrap: bootstrap2, bind } = ctx;
|
|
5848
5869
|
for (const [id, props] of Object.entries(config.defaults.auth)) {
|
|
5849
5870
|
const functions = /* @__PURE__ */ new Map();
|
|
5850
|
-
const
|
|
5851
|
-
for (const [
|
|
5852
|
-
const lambda = toLambdaFunction(ctx, `auth-${id}-${
|
|
5853
|
-
functions.set(
|
|
5854
|
-
|
|
5871
|
+
const triggers = {};
|
|
5872
|
+
for (const [trigger, fnProps] of Object.entries(props.triggers ?? {})) {
|
|
5873
|
+
const lambda = toLambdaFunction(ctx, `auth-${id}-${trigger}`, fnProps);
|
|
5874
|
+
functions.set(trigger, lambda);
|
|
5875
|
+
triggers[trigger] = lambda.arn;
|
|
5876
|
+
}
|
|
5877
|
+
for (const stack of config.stacks) {
|
|
5878
|
+
for (const [trigger, fnProps] of Object.entries(stack.auth?.[id]?.triggers ?? {})) {
|
|
5879
|
+
const lambda = toLambdaFunction(ctx, `auth-${id}-${trigger}`, fnProps);
|
|
5880
|
+
if (functions.has(trigger)) {
|
|
5881
|
+
throw new TypeError(
|
|
5882
|
+
`Only one "${trigger}" trigger can be defined for each auth instance: ${id}`
|
|
5883
|
+
);
|
|
5884
|
+
}
|
|
5885
|
+
functions.set(trigger, lambda);
|
|
5886
|
+
triggers[trigger] = lambda.arn;
|
|
5887
|
+
}
|
|
5855
5888
|
}
|
|
5856
5889
|
const userPool = new UserPool(id, {
|
|
5857
5890
|
name: `${config.name}-${id}`,
|
|
5858
5891
|
allowUserRegistration: props.allowUserRegistration,
|
|
5859
5892
|
username: props.username,
|
|
5860
5893
|
password: props.password,
|
|
5861
|
-
|
|
5894
|
+
triggers
|
|
5862
5895
|
});
|
|
5863
5896
|
const client = userPool.addClient({
|
|
5864
5897
|
name: `${config.name}-${id}`,
|
|
@@ -5880,10 +5913,7 @@ var authPlugin = definePlugin({
|
|
|
5880
5913
|
functionArn: lambda.arn,
|
|
5881
5914
|
sourceArn: userPool.arn
|
|
5882
5915
|
}).dependsOn(lambda);
|
|
5883
|
-
bootstrap2.add(
|
|
5884
|
-
lambda,
|
|
5885
|
-
permission
|
|
5886
|
-
);
|
|
5916
|
+
bootstrap2.add(lambda, permission);
|
|
5887
5917
|
}
|
|
5888
5918
|
}
|
|
5889
5919
|
bind((lambda) => {
|