@awsless/awsless 0.0.446 → 0.0.448
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/app.json +1 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +9 -2
- package/dist/build-json-schema.js +3 -2
- package/dist/client.d.ts +75 -0
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/server.d.ts +169 -0
- package/dist/server.js +2 -2
- package/dist/stack.json +1 -1
- package/package.json +12 -12
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
|
|
2
|
+
import { Mock } from 'vitest';
|
|
3
|
+
import { Duration, DurationFormat } from '@awsless/duration';
|
|
4
|
+
import { QoS } from '@awsless/iot';
|
|
5
|
+
export { QoS } from '@awsless/iot';
|
|
6
|
+
import { IoTCustomAuthorizerResult } from 'aws-lambda';
|
|
7
|
+
|
|
8
|
+
declare const regions: readonly ["us-east-2", "us-east-1", "us-west-1", "us-west-2", "af-south-1", "ap-east-1", "ap-south-2", "ap-southeast-3", "ap-southeast-4", "ap-south-1", "ap-northeast-3", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-south-1", "eu-west-3", "eu-south-2", "eu-north-1", "eu-central-2", "me-south-1", "me-central-1", "sa-east-1"];
|
|
9
|
+
type Region = (typeof regions)[number];
|
|
10
|
+
|
|
11
|
+
type Credentials = AwsCredentialIdentityProvider;
|
|
12
|
+
|
|
13
|
+
type CommandContext = {
|
|
14
|
+
region: Region;
|
|
15
|
+
credentials: Credentials;
|
|
16
|
+
accountId: string;
|
|
17
|
+
update: (msg: string) => void;
|
|
18
|
+
};
|
|
19
|
+
type CommandHandler = (options: CommandOptions, context: CommandContext) => Promise<string | undefined | void>;
|
|
20
|
+
declare class CommandOptions {
|
|
21
|
+
private opts;
|
|
22
|
+
constructor(args: string[]);
|
|
23
|
+
get(name: string): any;
|
|
24
|
+
private getAssertType;
|
|
25
|
+
number(name: string): number;
|
|
26
|
+
string(name: string): string;
|
|
27
|
+
boolean(name: string): boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface AlertMock {
|
|
31
|
+
}
|
|
32
|
+
interface AlertMockResponse {
|
|
33
|
+
}
|
|
34
|
+
declare const mockAlert: (cb: (mock: AlertMock) => void) => AlertMockResponse;
|
|
35
|
+
|
|
36
|
+
interface FunctionMock {
|
|
37
|
+
}
|
|
38
|
+
interface FunctionMockResponse {
|
|
39
|
+
}
|
|
40
|
+
declare const mockFunction: (cb: (mock: FunctionMock) => void) => FunctionMockResponse;
|
|
41
|
+
|
|
42
|
+
declare const mockPubSub: () => Mock;
|
|
43
|
+
|
|
44
|
+
interface QueueMock {
|
|
45
|
+
}
|
|
46
|
+
interface QueueMockResponse {
|
|
47
|
+
}
|
|
48
|
+
declare const mockQueue: (cb: (mock: QueueMock) => void) => QueueMockResponse;
|
|
49
|
+
|
|
50
|
+
interface TaskMock {
|
|
51
|
+
}
|
|
52
|
+
interface TaskMockResponse {
|
|
53
|
+
}
|
|
54
|
+
declare const mockTask: (cb: (mock: TaskMock) => void) => TaskMockResponse;
|
|
55
|
+
|
|
56
|
+
interface TopicMock {
|
|
57
|
+
}
|
|
58
|
+
interface TopicMockResponse {
|
|
59
|
+
}
|
|
60
|
+
declare const mockTopic: (cb: (mock: TopicMock) => void) => TopicMockResponse;
|
|
61
|
+
|
|
62
|
+
declare const getAlertName: <N extends string>(resourceName: N) => `app--alert--${N}`;
|
|
63
|
+
interface AlertResources {
|
|
64
|
+
}
|
|
65
|
+
declare const Alert: AlertResources;
|
|
66
|
+
|
|
67
|
+
declare const getAuthProps: (name: string) => {
|
|
68
|
+
readonly userPoolId: string | undefined;
|
|
69
|
+
readonly clientId: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
interface AuthResources {
|
|
72
|
+
}
|
|
73
|
+
declare const Auth: AuthResources;
|
|
74
|
+
|
|
75
|
+
declare const getCacheProps: (name: string, stack?: string) => {
|
|
76
|
+
readonly host: string;
|
|
77
|
+
readonly port: number;
|
|
78
|
+
};
|
|
79
|
+
interface CacheResources {
|
|
80
|
+
}
|
|
81
|
+
declare const Cache: CacheResources;
|
|
82
|
+
|
|
83
|
+
declare const getConfigName: (name: string) => string;
|
|
84
|
+
declare const getConfigValue: (name: string) => string;
|
|
85
|
+
declare const setConfigValue: (name: string, value: string) => void;
|
|
86
|
+
interface ConfigResources {
|
|
87
|
+
}
|
|
88
|
+
declare const Config: ConfigResources;
|
|
89
|
+
|
|
90
|
+
declare const getFunctionName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--function--${N}`;
|
|
91
|
+
interface FunctionResources {
|
|
92
|
+
}
|
|
93
|
+
declare const Function: FunctionResources;
|
|
94
|
+
declare const Fn: FunctionResources;
|
|
95
|
+
|
|
96
|
+
declare const getPubSubTopic: <N extends string>(name: N) => `app/pubsub/${N}`;
|
|
97
|
+
|
|
98
|
+
type PublishOptions = {
|
|
99
|
+
qos?: QoS;
|
|
100
|
+
};
|
|
101
|
+
declare const PubSub: {
|
|
102
|
+
publish(topic: string, event: string, payload: unknown, opts?: PublishOptions): Promise<void>;
|
|
103
|
+
};
|
|
104
|
+
type PubsubAuthorizerResponse = {
|
|
105
|
+
authorized: boolean;
|
|
106
|
+
principalId?: string;
|
|
107
|
+
publish?: string[];
|
|
108
|
+
subscribe?: string[];
|
|
109
|
+
disconnectAfter?: Duration;
|
|
110
|
+
refreshAfter?: Duration;
|
|
111
|
+
};
|
|
112
|
+
type PubsubAuthorizerEvent = {
|
|
113
|
+
protocolData: {
|
|
114
|
+
mqtt?: {
|
|
115
|
+
password?: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
declare const pubsubAuthorizerHandle: (cb: (token: string) => PubsubAuthorizerResponse | Promise<PubsubAuthorizerResponse>) => Promise<(event: PubsubAuthorizerEvent) => Promise<IoTCustomAuthorizerResult>>;
|
|
120
|
+
declare const pubsubAuthorizerResponse: (props: PubsubAuthorizerResponse) => IoTCustomAuthorizerResult;
|
|
121
|
+
|
|
122
|
+
declare const getQueueName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--queue--${N}`;
|
|
123
|
+
declare const getQueueUrl: (name: string, stack?: string) => string | undefined;
|
|
124
|
+
interface QueueResources {
|
|
125
|
+
}
|
|
126
|
+
declare const Queue: QueueResources;
|
|
127
|
+
|
|
128
|
+
type RpcAuthorizerResponse = {
|
|
129
|
+
authorized: false;
|
|
130
|
+
} | {
|
|
131
|
+
authorized: true;
|
|
132
|
+
context?: unknown;
|
|
133
|
+
ttl: DurationFormat;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
declare const getSearchName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--search--${N}`;
|
|
137
|
+
declare const getSearchProps: (name: string, stack?: string) => {
|
|
138
|
+
readonly domain: string | undefined;
|
|
139
|
+
};
|
|
140
|
+
interface SearchResources {
|
|
141
|
+
}
|
|
142
|
+
declare const Search: SearchResources;
|
|
143
|
+
|
|
144
|
+
declare const getSiteBucketName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--site--${N}--${string}`;
|
|
145
|
+
|
|
146
|
+
declare const getStoreName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--store--${N}--${string}`;
|
|
147
|
+
interface StoreResources {
|
|
148
|
+
}
|
|
149
|
+
declare const Store: StoreResources;
|
|
150
|
+
|
|
151
|
+
declare const getTableName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--table--${N}`;
|
|
152
|
+
interface TableResources {
|
|
153
|
+
}
|
|
154
|
+
declare const Table: TableResources;
|
|
155
|
+
|
|
156
|
+
declare const getTaskName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--task--${N}`;
|
|
157
|
+
interface TaskResources {
|
|
158
|
+
}
|
|
159
|
+
declare const Task: TaskResources;
|
|
160
|
+
|
|
161
|
+
declare const getTopicName: <N extends string>(resourceName: N) => `app--topic--${N}`;
|
|
162
|
+
interface TopicResources {
|
|
163
|
+
}
|
|
164
|
+
declare const Topic: TopicResources;
|
|
165
|
+
|
|
166
|
+
declare const APP: "app";
|
|
167
|
+
declare const STACK: "stack";
|
|
168
|
+
|
|
169
|
+
export { APP, Alert, type AlertMock, type AlertMockResponse, type AlertResources, Auth, type AuthResources, Cache, type CacheResources, type CommandContext, type CommandHandler, CommandOptions, Config, type ConfigResources, Fn, Function, type FunctionMock, type FunctionMockResponse, type FunctionResources, PubSub, type PublishOptions, Queue, type QueueMock, type QueueMockResponse, type QueueResources, type RpcAuthorizerResponse, STACK, Search, type SearchResources, Store, type StoreResources, Table, type TableResources, Task, type TaskMock, type TaskMockResponse, type TaskResources, Topic, type TopicMock, type TopicMockResponse, type TopicResources, getAlertName, getAuthProps, getCacheProps, getConfigName, getConfigValue, getFunctionName, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockAlert, mockFunction, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
|
package/dist/server.js
CHANGED
|
@@ -483,8 +483,8 @@ var pubsubAuthorizerResponse = (props) => {
|
|
|
483
483
|
return {
|
|
484
484
|
isAuthenticated: props.authorized,
|
|
485
485
|
principalId: props.principalId ?? Date.now().toString(),
|
|
486
|
-
disconnectAfterInSeconds:
|
|
487
|
-
refreshAfterInSeconds:
|
|
486
|
+
disconnectAfterInSeconds: toSeconds(props.disconnectAfter ?? hours(1)),
|
|
487
|
+
refreshAfterInSeconds: toSeconds(props.disconnectAfter ?? hours(1)),
|
|
488
488
|
policyDocuments
|
|
489
489
|
};
|
|
490
490
|
};
|