-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathlib.w
84 lines (69 loc) · 2 KB
/
lib.w
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
bring cloud;
bring util;
bring "./types.w" as types;
bring "./platform/sim.w" as sim;
bring "./platform/tfaws.w" as tfaws;
pub class Cognito impl types.ICognito {
inner: types.ICognito;
pub clientId: str;
pub userPoolId: str;
pub identityPoolId: str;
new(api: cloud.Api, props: types.CognitoProps?) {
let target = util.env("WING_TARGET");
if target == "sim" {
this.inner = new sim.Cognito_sim(api, props) as "sim";
this.clientId = "sim-client-id";
this.userPoolId = "sim-user-pool-id";
this.identityPoolId = "sim-identity-pool-id";
} else if target == "tf-aws" {
let auth = new tfaws.Cognito_tfaws(api, props) as "tf-aws";
this.clientId = auth.clientId;
this.userPoolId = auth.userPoolId;
this.identityPoolId = auth.identityPoolId;
this.inner = auth;
} else {
throw "Unsupported target {target}";
}
nodeof(this).icon = "lock-closed";
nodeof(this).color = "emerald";
}
pub get(path: str) {
this.inner.get(path);
}
pub post(path: str) {
this.inner.post(path);
}
pub put(path: str) {
this.inner.put(path);
}
pub patch(path: str) {
this.inner.patch(path);
}
pub delete(path: str) {
this.inner.delete(path);
}
pub head(path: str) {
this.inner.head(path);
}
pub options(path: str) {
this.inner.options(path);
}
pub connect(path: str) {
this.inner.connect(path);
}
pub inflight signUp(email: str, password: str): void {
this.inner.signUp(email, password);
}
pub inflight adminConfirmUser(email: str): void {
this.inner.adminConfirmUser(email);
}
pub inflight initiateAuth(email: str, password: str): str {
return this.inner.initiateAuth(email, password);
}
pub inflight getId(poolId: str, identityPoolId: str, token: str): str {
return this.inner.getId(poolId, identityPoolId, token);
}
pub inflight getCredentialsForIdentity(token: str, identityId: str): Json {
return this.inner.getCredentialsForIdentity(token, identityId);
}
}