@superlayer/cli 1.0.67
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.md +202 -0
- package/NOTICE +4 -0
- package/README.md +67 -0
- package/bin/index.js +3 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +103 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/commands/app/delete.d.ts +7 -0
- package/dist/commands/app/delete.d.ts.map +1 -0
- package/dist/commands/app/delete.js +57 -0
- package/dist/commands/app/delete.js.map +1 -0
- package/dist/commands/app/list.d.ts +6 -0
- package/dist/commands/app/list.d.ts.map +1 -0
- package/dist/commands/app/list.js +29 -0
- package/dist/commands/app/list.js.map +1 -0
- package/dist/commands/auth/client/add.d.ts +9 -0
- package/dist/commands/auth/client/add.d.ts.map +1 -0
- package/dist/commands/auth/client/add.js +409 -0
- package/dist/commands/auth/client/add.js.map +1 -0
- package/dist/commands/auth/client/delete.d.ts +11 -0
- package/dist/commands/auth/client/delete.d.ts.map +1 -0
- package/dist/commands/auth/client/delete.js +48 -0
- package/dist/commands/auth/client/delete.js.map +1 -0
- package/dist/commands/auth/client/list.d.ts +6 -0
- package/dist/commands/auth/client/list.d.ts.map +1 -0
- package/dist/commands/auth/client/list.js +38 -0
- package/dist/commands/auth/client/list.js.map +1 -0
- package/dist/commands/auth/client/shared.d.ts +70 -0
- package/dist/commands/auth/client/shared.d.ts.map +1 -0
- package/dist/commands/auth/client/shared.js +140 -0
- package/dist/commands/auth/client/shared.js.map +1 -0
- package/dist/commands/auth/client/update.d.ts +8 -0
- package/dist/commands/auth/client/update.d.ts.map +1 -0
- package/dist/commands/auth/client/update.js +445 -0
- package/dist/commands/auth/client/update.js.map +1 -0
- package/dist/commands/auth/email/pull.d.ts +24 -0
- package/dist/commands/auth/email/pull.d.ts.map +1 -0
- package/dist/commands/auth/email/pull.js +100 -0
- package/dist/commands/auth/email/pull.js.map +1 -0
- package/dist/commands/auth/email/push.d.ts +8 -0
- package/dist/commands/auth/email/push.d.ts.map +1 -0
- package/dist/commands/auth/email/push.js +58 -0
- package/dist/commands/auth/email/push.js.map +1 -0
- package/dist/commands/auth/email/resend.d.ts +3 -0
- package/dist/commands/auth/email/resend.d.ts.map +1 -0
- package/dist/commands/auth/email/resend.js +7 -0
- package/dist/commands/auth/email/resend.js.map +1 -0
- package/dist/commands/auth/email/reset.d.ts +5 -0
- package/dist/commands/auth/email/reset.d.ts.map +1 -0
- package/dist/commands/auth/email/reset.js +25 -0
- package/dist/commands/auth/email/reset.js.map +1 -0
- package/dist/commands/auth/email/status.d.ts +57 -0
- package/dist/commands/auth/email/status.d.ts.map +1 -0
- package/dist/commands/auth/email/status.js +96 -0
- package/dist/commands/auth/email/status.js.map +1 -0
- package/dist/commands/auth/email/verify.d.ts +5 -0
- package/dist/commands/auth/email/verify.d.ts.map +1 -0
- package/dist/commands/auth/email/verify.js +12 -0
- package/dist/commands/auth/email/verify.js.map +1 -0
- package/dist/commands/auth/origin/add.d.ts +12 -0
- package/dist/commands/auth/origin/add.d.ts.map +1 -0
- package/dist/commands/auth/origin/add.js +153 -0
- package/dist/commands/auth/origin/add.js.map +1 -0
- package/dist/commands/auth/origin/delete.d.ts +8 -0
- package/dist/commands/auth/origin/delete.d.ts.map +1 -0
- package/dist/commands/auth/origin/delete.js +38 -0
- package/dist/commands/auth/origin/delete.js.map +1 -0
- package/dist/commands/auth/origin/list.d.ts +9 -0
- package/dist/commands/auth/origin/list.d.ts.map +1 -0
- package/dist/commands/auth/origin/list.js +52 -0
- package/dist/commands/auth/origin/list.js.map +1 -0
- package/dist/commands/backup/download.d.ts +10 -0
- package/dist/commands/backup/download.d.ts.map +1 -0
- package/dist/commands/backup/download.js +174 -0
- package/dist/commands/backup/download.js.map +1 -0
- package/dist/commands/backup/list.d.ts +11 -0
- package/dist/commands/backup/list.d.ts.map +1 -0
- package/dist/commands/backup/list.js +74 -0
- package/dist/commands/backup/list.js.map +1 -0
- package/dist/commands/claim.d.ts +6 -0
- package/dist/commands/claim.d.ts.map +1 -0
- package/dist/commands/claim.js +22 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/explorer.d.ts +6 -0
- package/dist/commands/explorer.d.ts.map +1 -0
- package/dist/commands/explorer.js +13 -0
- package/dist/commands/explorer.js.map +1 -0
- package/dist/commands/info.d.ts +9 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +41 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +41 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/initWithoutFiles.d.ts +6 -0
- package/dist/commands/initWithoutFiles.d.ts.map +1 -0
- package/dist/commands/initWithoutFiles.js +64 -0
- package/dist/commands/initWithoutFiles.js.map +1 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +44 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +14 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/pull.d.ts +5 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +15 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +6 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +20 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/query.d.ts +7 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +52 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/webhooks/add.d.ts +9 -0
- package/dist/commands/webhooks/add.d.ts.map +1 -0
- package/dist/commands/webhooks/add.js +75 -0
- package/dist/commands/webhooks/add.js.map +1 -0
- package/dist/commands/webhooks/delete.d.ts +6 -0
- package/dist/commands/webhooks/delete.d.ts.map +1 -0
- package/dist/commands/webhooks/delete.js +17 -0
- package/dist/commands/webhooks/delete.js.map +1 -0
- package/dist/commands/webhooks/disable.d.ts +7 -0
- package/dist/commands/webhooks/disable.d.ts.map +1 -0
- package/dist/commands/webhooks/disable.js +18 -0
- package/dist/commands/webhooks/disable.js.map +1 -0
- package/dist/commands/webhooks/enable.d.ts +6 -0
- package/dist/commands/webhooks/enable.d.ts.map +1 -0
- package/dist/commands/webhooks/enable.js +18 -0
- package/dist/commands/webhooks/enable.js.map +1 -0
- package/dist/commands/webhooks/events/list.d.ts +7 -0
- package/dist/commands/webhooks/events/list.d.ts.map +1 -0
- package/dist/commands/webhooks/events/list.js +31 -0
- package/dist/commands/webhooks/events/list.js.map +1 -0
- package/dist/commands/webhooks/events/payload.d.ts +8 -0
- package/dist/commands/webhooks/events/payload.d.ts.map +1 -0
- package/dist/commands/webhooks/events/payload.js +39 -0
- package/dist/commands/webhooks/events/payload.js.map +1 -0
- package/dist/commands/webhooks/events/resend.d.ts +8 -0
- package/dist/commands/webhooks/events/resend.d.ts.map +1 -0
- package/dist/commands/webhooks/events/resend.js +43 -0
- package/dist/commands/webhooks/events/resend.js.map +1 -0
- package/dist/commands/webhooks/list.d.ts +8 -0
- package/dist/commands/webhooks/list.d.ts.map +1 -0
- package/dist/commands/webhooks/list.js +29 -0
- package/dist/commands/webhooks/list.js.map +1 -0
- package/dist/commands/webhooks/shared.d.ts +40 -0
- package/dist/commands/webhooks/shared.d.ts.map +1 -0
- package/dist/commands/webhooks/shared.js +248 -0
- package/dist/commands/webhooks/shared.js.map +1 -0
- package/dist/commands/webhooks/update.d.ts +10 -0
- package/dist/commands/webhooks/update.d.ts.map +1 -0
- package/dist/commands/webhooks/update.js +189 -0
- package/dist/commands/webhooks/update.js.map +1 -0
- package/dist/context/authToken.d.ts +29 -0
- package/dist/context/authToken.d.ts.map +1 -0
- package/dist/context/authToken.js +73 -0
- package/dist/context/authToken.js.map +1 -0
- package/dist/context/currentApp.d.ts +38 -0
- package/dist/context/currentApp.d.ts.map +1 -0
- package/dist/context/currentApp.js +222 -0
- package/dist/context/currentApp.js.map +1 -0
- package/dist/context/globalOpts.d.ts +11 -0
- package/dist/context/globalOpts.d.ts.map +1 -0
- package/dist/context/globalOpts.js +13 -0
- package/dist/context/globalOpts.js.map +1 -0
- package/dist/context/platformApi.d.ts +19 -0
- package/dist/context/platformApi.d.ts.map +1 -0
- package/dist/context/platformApi.js +24 -0
- package/dist/context/platformApi.js.map +1 -0
- package/dist/context/projectInfo.d.ts +30 -0
- package/dist/context/projectInfo.d.ts.map +1 -0
- package/dist/context/projectInfo.js +152 -0
- package/dist/context/projectInfo.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +714 -0
- package/dist/index.js.map +1 -0
- package/dist/layer.d.ts +25 -0
- package/dist/layer.d.ts.map +1 -0
- package/dist/layer.js +119 -0
- package/dist/layer.js.map +1 -0
- package/dist/lib/args.d.ts +212 -0
- package/dist/lib/args.d.ts.map +1 -0
- package/dist/lib/args.js +313 -0
- package/dist/lib/args.js.map +1 -0
- package/dist/lib/backupDownload.d.ts +21 -0
- package/dist/lib/backupDownload.d.ts.map +1 -0
- package/dist/lib/backupDownload.js +151 -0
- package/dist/lib/backupDownload.js.map +1 -0
- package/dist/lib/backups.d.ts +12 -0
- package/dist/lib/backups.d.ts.map +1 -0
- package/dist/lib/backups.js +26 -0
- package/dist/lib/backups.js.map +1 -0
- package/dist/lib/config.d.ts +6 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/createApp.d.ts +12 -0
- package/dist/lib/createApp.d.ts.map +1 -0
- package/dist/lib/createApp.js +15 -0
- package/dist/lib/createApp.js.map +1 -0
- package/dist/lib/email.d.ts +47 -0
- package/dist/lib/email.d.ts.map +1 -0
- package/dist/lib/email.js +71 -0
- package/dist/lib/email.js.map +1 -0
- package/dist/lib/handleEnv.d.ts +7 -0
- package/dist/lib/handleEnv.d.ts.map +1 -0
- package/dist/lib/handleEnv.js +99 -0
- package/dist/lib/handleEnv.js.map +1 -0
- package/dist/lib/http.d.ts +30 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +55 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/login.d.ts +12 -0
- package/dist/lib/login.d.ts.map +1 -0
- package/dist/lib/login.js +38 -0
- package/dist/lib/login.js.map +1 -0
- package/dist/lib/oauth.d.ts +306 -0
- package/dist/lib/oauth.d.ts.map +1 -0
- package/dist/lib/oauth.js +195 -0
- package/dist/lib/oauth.js.map +1 -0
- package/dist/lib/platformApi.d.ts +5 -0
- package/dist/lib/platformApi.d.ts.map +1 -0
- package/dist/lib/platformApi.js +11 -0
- package/dist/lib/platformApi.js.map +1 -0
- package/dist/lib/pullPerms.d.ts +7 -0
- package/dist/lib/pullPerms.d.ts.map +1 -0
- package/dist/lib/pullPerms.js +41 -0
- package/dist/lib/pullPerms.js.map +1 -0
- package/dist/lib/pullSchema.d.ts +12 -0
- package/dist/lib/pullSchema.d.ts.map +1 -0
- package/dist/lib/pullSchema.js +62 -0
- package/dist/lib/pullSchema.js.map +1 -0
- package/dist/lib/pushPerms.d.ts +13 -0
- package/dist/lib/pushPerms.d.ts.map +1 -0
- package/dist/lib/pushPerms.js +54 -0
- package/dist/lib/pushPerms.js.map +1 -0
- package/dist/lib/pushSchema.d.ts +53 -0
- package/dist/lib/pushSchema.d.ts.map +1 -0
- package/dist/lib/pushSchema.js +165 -0
- package/dist/lib/pushSchema.js.map +1 -0
- package/dist/lib/ui.d.ts +18 -0
- package/dist/lib/ui.d.ts.map +1 -0
- package/dist/lib/ui.js +32 -0
- package/dist/lib/ui.js.map +1 -0
- package/dist/lib/webhooks.d.ts +27 -0
- package/dist/lib/webhooks.d.ts.map +1 -0
- package/dist/lib/webhooks.js +95 -0
- package/dist/lib/webhooks.js.map +1 -0
- package/dist/logging.d.ts +5 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +25 -0
- package/dist/logging.js.map +1 -0
- package/dist/old.d.ts +17 -0
- package/dist/old.d.ts.map +1 -0
- package/dist/old.js +410 -0
- package/dist/old.js.map +1 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +3 -0
- package/dist/program.js.map +1 -0
- package/dist/renderSchemaPlan.d.ts +19 -0
- package/dist/renderSchemaPlan.d.ts.map +1 -0
- package/dist/renderSchemaPlan.js +220 -0
- package/dist/renderSchemaPlan.js.map +1 -0
- package/dist/ui/index.d.ts +292 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +1296 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/lib.d.ts +124 -0
- package/dist/ui/lib.d.ts.map +1 -0
- package/dist/ui/lib.js +333 -0
- package/dist/ui/lib.js.map +1 -0
- package/dist/util/findConfigCandidates.d.ts +13 -0
- package/dist/util/findConfigCandidates.d.ts.map +1 -0
- package/dist/util/findConfigCandidates.js +211 -0
- package/dist/util/findConfigCandidates.js.map +1 -0
- package/dist/util/fs.d.ts +4 -0
- package/dist/util/fs.d.ts.map +1 -0
- package/dist/util/fs.js +22 -0
- package/dist/util/fs.js.map +1 -0
- package/dist/util/getAppName.d.ts +5 -0
- package/dist/util/getAppName.d.ts.map +1 -0
- package/dist/util/getAppName.js +14 -0
- package/dist/util/getAppName.js.map +1 -0
- package/dist/util/instantConfig.d.ts +9 -0
- package/dist/util/instantConfig.d.ts.map +1 -0
- package/dist/util/instantConfig.js +13 -0
- package/dist/util/instantConfig.js.map +1 -0
- package/dist/util/isHeadlessEnvironment.d.ts +4 -0
- package/dist/util/isHeadlessEnvironment.d.ts.map +1 -0
- package/dist/util/isHeadlessEnvironment.js +11 -0
- package/dist/util/isHeadlessEnvironment.js.map +1 -0
- package/dist/util/loadConfig.d.ts +3 -0
- package/dist/util/loadConfig.d.ts.map +1 -0
- package/dist/util/loadConfig.js +72 -0
- package/dist/util/loadConfig.js.map +1 -0
- package/dist/util/loadEnv.d.ts +2 -0
- package/dist/util/loadEnv.d.ts.map +1 -0
- package/dist/util/loadEnv.js +10 -0
- package/dist/util/loadEnv.js.map +1 -0
- package/dist/util/mergeSchema.d.ts +10 -0
- package/dist/util/mergeSchema.d.ts.map +1 -0
- package/dist/util/mergeSchema.js +338 -0
- package/dist/util/mergeSchema.js.map +1 -0
- package/dist/util/projectDir.d.ts +7 -0
- package/dist/util/projectDir.d.ts.map +1 -0
- package/dist/util/projectDir.js +43 -0
- package/dist/util/projectDir.js.map +1 -0
- package/dist/util/renamePrompt.d.ts +15 -0
- package/dist/util/renamePrompt.d.ts.map +1 -0
- package/dist/util/renamePrompt.js +57 -0
- package/dist/util/renamePrompt.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { HttpClientResponse, Path } from '@effect/platform';
|
|
2
|
+
import { Effect, Schema } from 'effect';
|
|
3
|
+
import { ProjectInfo } from "../../../context/projectInfo.js";
|
|
4
|
+
import { BadArgsError } from "../../../errors.js";
|
|
5
|
+
import { readLocalEmailFile } from '../../../old.js';
|
|
6
|
+
import { UI } from "../../../ui/index.js";
|
|
7
|
+
import { getEmailPathToWrite } from "../../../util/findConfigCandidates.js";
|
|
8
|
+
import { writeTypescript } from "../../../lib/pullSchema.js";
|
|
9
|
+
import { promptOk } from "../../../lib/ui.js";
|
|
10
|
+
import { getEmailTemplateStatus } from "./status.js";
|
|
11
|
+
import { InstantHttp } from "../../../lib/http.js";
|
|
12
|
+
import { getAppName } from "../../../util/getAppName.js";
|
|
13
|
+
export const authEmailPullCmd = Effect.fn(function* (opts) {
|
|
14
|
+
yield* pullEmail(opts.file);
|
|
15
|
+
});
|
|
16
|
+
const pullEmail = (emailPath) => Effect.gen(function* () {
|
|
17
|
+
yield* Effect.log('Pulling email template...');
|
|
18
|
+
const info = yield* getEmailTemplateStatus;
|
|
19
|
+
const emailConfig = info
|
|
20
|
+
? infoToEmailConfig(info)
|
|
21
|
+
: yield* getDefaultEmailTemplate;
|
|
22
|
+
yield* writeEmailTemplate(emailConfig, { emailPath });
|
|
23
|
+
});
|
|
24
|
+
export const writeEmailTemplate = (emailConfig, { emailPath, confirmOverwrite = true } = {}) => Effect.gen(function* () {
|
|
25
|
+
const prevEmailFile = yield* Effect.tryPromise({
|
|
26
|
+
try: () => readLocalEmailFile(emailPath),
|
|
27
|
+
catch: (e) => BadArgsError.make({
|
|
28
|
+
message: `Error reading local email file: ${e}`,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
const shortEmailPath = prevEmailFile?.path ?? emailPath ?? getEmailPathToWrite();
|
|
32
|
+
if (prevEmailFile && confirmOverwrite) {
|
|
33
|
+
const shouldContinue = yield* promptOk({
|
|
34
|
+
promptText: `This will overwrite your local ${shortEmailPath} file, OK to proceed?`,
|
|
35
|
+
modifyOutput: UI.modifiers.yPadding,
|
|
36
|
+
inline: true,
|
|
37
|
+
});
|
|
38
|
+
if (!shouldContinue) {
|
|
39
|
+
yield* Effect.log('Cancelled email pull');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const path = yield* Path.Path;
|
|
44
|
+
const { pkgDir } = yield* ProjectInfo;
|
|
45
|
+
const fullEmailPath = shortEmailPath.startsWith('/')
|
|
46
|
+
? shortEmailPath
|
|
47
|
+
: path.join(pkgDir, shortEmailPath);
|
|
48
|
+
const typescriptFile = yield* generateEmailTypescriptFile(emailConfig);
|
|
49
|
+
yield* writeTypescript(fullEmailPath, typescriptFile);
|
|
50
|
+
yield* Effect.log('Wrote email template to ' + shortEmailPath);
|
|
51
|
+
});
|
|
52
|
+
const DefaultEmailTemplateSchema = Schema.Struct({
|
|
53
|
+
subject: Schema.String,
|
|
54
|
+
body: Schema.String,
|
|
55
|
+
'sender-email': Schema.String.pipe(Schema.optional),
|
|
56
|
+
});
|
|
57
|
+
export const getDefaultEmailTemplate = Effect.gen(function* () {
|
|
58
|
+
const http = yield* InstantHttp;
|
|
59
|
+
const template = yield* http
|
|
60
|
+
.get('/dash/default-email-template')
|
|
61
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(DefaultEmailTemplateSchema)));
|
|
62
|
+
const appName = yield* getAppName;
|
|
63
|
+
return {
|
|
64
|
+
subject: template.subject,
|
|
65
|
+
senderName: appName,
|
|
66
|
+
senderEmail: template['sender-email'],
|
|
67
|
+
body: template.body,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
const infoToEmailConfig = (info) => ({
|
|
71
|
+
subject: info.subject,
|
|
72
|
+
senderName: info.name,
|
|
73
|
+
senderEmail: info.email,
|
|
74
|
+
body: info.body,
|
|
75
|
+
});
|
|
76
|
+
const generateEmailTypescriptFile = Effect.fn(function* (emailConfig) {
|
|
77
|
+
const senderEmail = emailConfig.senderEmail
|
|
78
|
+
? JSON.stringify(emailConfig.senderEmail)
|
|
79
|
+
: 'undefined';
|
|
80
|
+
return `
|
|
81
|
+
// We provide a few dynamic variables for you to use in your email:
|
|
82
|
+
// {code}, the magic code e.g. 123456
|
|
83
|
+
// {app_title}, your app's title, i.e. test-fresh
|
|
84
|
+
// {user_email}, the user's email address, e.g. happyuser@gmail.com
|
|
85
|
+
// {expiration}, the magic code expiration, e.g. 10 minutes
|
|
86
|
+
// Note: {code} is required in both the subject and body.
|
|
87
|
+
const email = {
|
|
88
|
+
authEmail: {
|
|
89
|
+
subject: ${JSON.stringify(emailConfig.subject)},
|
|
90
|
+
senderName: ${JSON.stringify(emailConfig.senderName)},
|
|
91
|
+
senderEmail: ${senderEmail},
|
|
92
|
+
body: ${toTemplateLiteral(emailConfig.body)},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default email;
|
|
97
|
+
`;
|
|
98
|
+
});
|
|
99
|
+
const toTemplateLiteral = (value) => `\`${value.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${')}\``;
|
|
100
|
+
//# sourceMappingURL=pull.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../../src/commands/auth/email/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAA0B,MAAM,aAAa,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EACjD,IAA8C;IAE9C,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AASH,MAAM,SAAS,GAAG,CAAC,SAAkB,EAAE,EAAE,CACvC,MAAM,CAAC,GAAG,CAAC,QAA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E,QAAQ,CAAC,cAAc,CAAC;QACrC,IAAI,EAAE,QAAQ,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,IAAuB,EAAE,EAAE,CAAC,CAAC;IACtD,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,UAAU,EAAE,IAAI,CAAC,IAAI;IACrB,WAAW,EAAE,IAAI,CAAC,KAAK;IACvB,IAAI,EAAE,IAAI,CAAC,IAAI;CAChB,CAAC,CAAC;AAEH,MAAM,2BAA2B,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EACrD,WAAwB;IAExB,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW;QACzC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC;QACzC,CAAC,CAAC,WAAW,CAAC;IAEhB,OAAO;;;;;;;;;eASM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC;kBAChC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC;mBACrC,WAAW;YAClB,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;;;;;CAK9C,CAAC;AACF,CAAC,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,EAAE,CAC1C,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC","sourcesContent":["import { HttpClientResponse, Path } from '@effect/platform';\nimport { Effect, Schema } from 'effect';\nimport { ProjectInfo } from '../../../context/projectInfo.ts';\nimport { BadArgsError } from '../../../errors.ts';\nimport { readLocalEmailFile } from '../../../old.js';\nimport { UI } from '../../../ui/index.ts';\nimport { getEmailPathToWrite } from '../../../util/findConfigCandidates.ts';\nimport { writeTypescript } from '../../../lib/pullSchema.ts';\nimport { promptOk } from '../../../lib/ui.ts';\nimport { getEmailTemplateStatus, type EmailTemplateInfo } from './status.ts';\nimport type { authEmailPullDef, OptsFromCommand } from '../../../index.ts';\nimport { InstantHttp } from '../../../lib/http.ts';\nimport { getAppName } from '../../../util/getAppName.ts';\nimport type { EmailConfig } from '../../../lib/email.ts';\n\nexport const authEmailPullCmd = Effect.fn(function* (\n opts: OptsFromCommand<typeof authEmailPullDef>,\n) {\n yield* pullEmail(opts.file);\n});\n\nexport type EmailConfig = (typeof EmailConfig.Type)['authEmail'];\n\ntype WriteEmailTemplateOpts = {\n emailPath?: string;\n confirmOverwrite?: boolean;\n};\n\nconst pullEmail = (emailPath?: string) =>\n Effect.gen(function* () {\n yield* Effect.log('Pulling email template...');\n\n const info = yield* getEmailTemplateStatus;\n\n const emailConfig = info\n ? infoToEmailConfig(info)\n : yield* getDefaultEmailTemplate;\n\n yield* writeEmailTemplate(emailConfig, { emailPath });\n });\n\nexport const writeEmailTemplate = (\n emailConfig: EmailConfig,\n { emailPath, confirmOverwrite = true }: WriteEmailTemplateOpts = {},\n) =>\n Effect.gen(function* () {\n const prevEmailFile = yield* Effect.tryPromise({\n try: () => readLocalEmailFile(emailPath),\n catch: (e) =>\n BadArgsError.make({\n message: `Error reading local email file: ${e}`,\n }),\n });\n\n const shortEmailPath =\n prevEmailFile?.path ?? emailPath ?? getEmailPathToWrite();\n\n if (prevEmailFile && confirmOverwrite) {\n const shouldContinue = yield* promptOk({\n promptText: `This will overwrite your local ${shortEmailPath} file, OK to proceed?`,\n modifyOutput: UI.modifiers.yPadding,\n inline: true,\n });\n if (!shouldContinue) {\n yield* Effect.log('Cancelled email pull');\n return;\n }\n }\n\n const path = yield* Path.Path;\n const { pkgDir } = yield* ProjectInfo;\n const fullEmailPath = shortEmailPath.startsWith('/')\n ? shortEmailPath\n : path.join(pkgDir, shortEmailPath);\n\n const typescriptFile = yield* generateEmailTypescriptFile(emailConfig);\n\n yield* writeTypescript(fullEmailPath, typescriptFile);\n yield* Effect.log('Wrote email template to ' + shortEmailPath);\n });\n\nconst DefaultEmailTemplateSchema = Schema.Struct({\n subject: Schema.String,\n body: Schema.String,\n 'sender-email': Schema.String.pipe(Schema.optional),\n});\n\nexport const getDefaultEmailTemplate = Effect.gen(function* () {\n const http = yield* InstantHttp;\n const template = yield* http\n .get('/dash/default-email-template')\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(DefaultEmailTemplateSchema),\n ),\n );\n\n const appName = yield* getAppName;\n\n return {\n subject: template.subject,\n senderName: appName,\n senderEmail: template['sender-email'],\n body: template.body,\n };\n});\n\nconst infoToEmailConfig = (info: EmailTemplateInfo) => ({\n subject: info.subject,\n senderName: info.name,\n senderEmail: info.email,\n body: info.body,\n});\n\nconst generateEmailTypescriptFile = Effect.fn(function* (\n emailConfig: EmailConfig,\n) {\n const senderEmail = emailConfig.senderEmail\n ? JSON.stringify(emailConfig.senderEmail)\n : 'undefined';\n\n return `\n // We provide a few dynamic variables for you to use in your email:\n // {code}, the magic code e.g. 123456\n // {app_title}, your app's title, i.e. test-fresh\n // {user_email}, the user's email address, e.g. happyuser@gmail.com\n // {expiration}, the magic code expiration, e.g. 10 minutes\n // Note: {code} is required in both the subject and body.\n const email = {\n authEmail: {\n subject: ${JSON.stringify(emailConfig.subject)},\n senderName: ${JSON.stringify(emailConfig.senderName)},\n senderEmail: ${senderEmail},\n body: ${toTemplateLiteral(emailConfig.body)},\n },\n};\n\nexport default email;\n`;\n});\n\nconst toTemplateLiteral = (value: string) =>\n `\\`${value.replace(/\\\\/g, '\\\\\\\\').replace(/`/g, '\\\\`').replace(/\\$\\{/g, '\\\\${')}\\``;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { CurrentApp } from '../../../context/currentApp.ts';
|
|
3
|
+
import { InstantHttpAuthed } from '../../../lib/http.ts';
|
|
4
|
+
export declare const authEmailPushCmd: (opts: {
|
|
5
|
+
app?: string | undefined;
|
|
6
|
+
file?: string | undefined;
|
|
7
|
+
}) => Effect.Effect<void, import("../../../errors.ts").BadArgsError | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/HttpBody").HttpBodyError | import("../../../lib/email.ts").NoEmailFileFound, import("../../../lib/http.ts").InstantHttp | InstantHttpAuthed | CurrentApp>;
|
|
8
|
+
//# sourceMappingURL=push.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/email/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAOxC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAe,MAAM,sBAAsB,CAAC;AActE,eAAO,MAAM,gBAAgB;;;mfAuE3B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Effect, Schema } from 'effect';
|
|
2
|
+
import { getVerification, readEmailConfig, sendSenderVerification, } from "../../../lib/email.js";
|
|
3
|
+
import { CurrentApp } from "../../../context/currentApp.js";
|
|
4
|
+
import { InstantHttpAuthed, withCommand } from "../../../lib/http.js";
|
|
5
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse, } from '@effect/platform';
|
|
6
|
+
import boxen from 'boxen';
|
|
7
|
+
import { formatSenderVerificationDnsRecords, getEmailTemplateStatus, } from "./status.js";
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { getDefaultEmailTemplate } from "./pull.js";
|
|
10
|
+
export const authEmailPushCmd = Effect.fn(function* (opts) {
|
|
11
|
+
const emailConfig = yield* readEmailConfig(opts.file);
|
|
12
|
+
const { appId } = yield* CurrentApp;
|
|
13
|
+
const http = yield* InstantHttpAuthed;
|
|
14
|
+
const authEmail = emailConfig.authEmail;
|
|
15
|
+
const defTemplate = yield* getDefaultEmailTemplate;
|
|
16
|
+
const senderEmail =
|
|
17
|
+
// If the value in the code is the default instant-owned email, remove it from the request
|
|
18
|
+
authEmail.senderEmail === defTemplate.senderEmail
|
|
19
|
+
? undefined
|
|
20
|
+
: emailConfig.authEmail.senderEmail;
|
|
21
|
+
yield* http
|
|
22
|
+
.pipe(withCommand('auth email push'), HttpClient.mapRequestInputEffect(HttpClientRequest.bodyJson({
|
|
23
|
+
'email-type': 'magic-code',
|
|
24
|
+
subject: authEmail.subject,
|
|
25
|
+
body: authEmail.body,
|
|
26
|
+
'sender-email': senderEmail,
|
|
27
|
+
'sender-name': authEmail.senderName,
|
|
28
|
+
})))
|
|
29
|
+
.post(`/dash/apps/${appId}/email_templates`)
|
|
30
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
|
|
31
|
+
const info = yield* getEmailTemplateStatus;
|
|
32
|
+
yield* Effect.log([
|
|
33
|
+
chalk.green('Email template saved!'),
|
|
34
|
+
'',
|
|
35
|
+
chalk.bold('Pushed fields:'),
|
|
36
|
+
` Email type: ${chalk.cyan('magic-code')}`,
|
|
37
|
+
` Subject: ${chalk.cyan(authEmail.subject)}`,
|
|
38
|
+
` Sender name: ${chalk.cyan(authEmail.senderName)}`,
|
|
39
|
+
` Sender email: ${chalk.cyan(senderEmail || '(default)')}`,
|
|
40
|
+
` Body: ${chalk.cyan(`${authEmail.body.length} characters`)}`,
|
|
41
|
+
].join('\n'));
|
|
42
|
+
// Check if verification email needs to be sent
|
|
43
|
+
if (info?.verification_verified === false) {
|
|
44
|
+
yield* sendSenderVerification;
|
|
45
|
+
yield* Effect.log(boxen("We've sent a confirmation email containing a six digit code to verify the sender email address.\nUse superlayer auth email verify <code> to complete verification.", {
|
|
46
|
+
borderColor: 'yellow',
|
|
47
|
+
padding: { right: 1, left: 1 },
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
if (emailConfig.authEmail.senderEmail &&
|
|
51
|
+
emailConfig.authEmail.senderEmail !== defTemplate.senderEmail) {
|
|
52
|
+
const verification = yield* getVerification;
|
|
53
|
+
if (verification.verification) {
|
|
54
|
+
yield* Effect.log(formatSenderVerificationDnsRecords(verification.verification));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=push.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../../src/commands/auth/email/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EACL,eAAe,EACf,eAAe,EACf,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,kCAAkC,EAClC,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EACjD,IAA8C;IAE9C,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC;IACtC,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IACxC,MAAM,WA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KAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IAEF,+CAA+C;IAE/C,IAAI,IAAI,EAAE,qBAAqB,KAAK,KAAK,EAAE,CAAC;QAC1C,KAAK,CAAC,CAAC,sBAAsB,CAAC;QAC9B,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,KAAK,CACH,oKAAoK,EACpK;YACE,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;SAC/B,CACF,CACF,CAAC;IACJ,CAAC;IAED,IACE,WAAW,CAAC,SAAS,CAAC,WAAW;QACjC,WAAW,CAAC,SAAS,CAAC,WAAW,KAAK,WAAW,CAAC,WAAW,EAC7D,CAAC;QACD,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC;QAC5C,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;YAC9B,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,kCAAkC,CAAC,YAAY,CAAC,YAAY,CAAC,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { Effect, Schema } from 'effect';\nimport type { authEmailPushDef, OptsFromCommand } from '../../../index.ts';\nimport {\n getVerification,\n readEmailConfig,\n sendSenderVerification,\n} from '../../../lib/email.ts';\nimport { CurrentApp } from '../../../context/currentApp.ts';\nimport { InstantHttpAuthed, withCommand } from '../../../lib/http.ts';\nimport {\n HttpClient,\n HttpClientRequest,\n HttpClientResponse,\n} from '@effect/platform';\nimport boxen from 'boxen';\nimport {\n formatSenderVerificationDnsRecords,\n getEmailTemplateStatus,\n} from './status.ts';\nimport chalk from 'chalk';\nimport { getDefaultEmailTemplate } from './pull.ts';\n\nexport const authEmailPushCmd = Effect.fn(function* (\n opts: OptsFromCommand<typeof authEmailPushDef>,\n) {\n const emailConfig = yield* readEmailConfig(opts.file);\n const { appId } = yield* CurrentApp;\n const http = yield* InstantHttpAuthed;\n const authEmail = emailConfig.authEmail;\n const defTemplate = yield* getDefaultEmailTemplate;\n const senderEmail =\n // If the value in the code is the default instant-owned email, remove it from the request\n authEmail.senderEmail === defTemplate.senderEmail\n ? undefined\n : emailConfig.authEmail.senderEmail;\n\n yield* http\n .pipe(\n withCommand('auth email push'),\n HttpClient.mapRequestInputEffect(\n HttpClientRequest.bodyJson({\n 'email-type': 'magic-code',\n subject: authEmail.subject,\n body: authEmail.body,\n 'sender-email': senderEmail,\n 'sender-name': authEmail.senderName,\n }),\n ),\n )\n .post(`/dash/apps/${appId}/email_templates`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));\n\n const info = yield* getEmailTemplateStatus;\n\n yield* Effect.log(\n [\n chalk.green('Email template saved!'),\n '',\n chalk.bold('Pushed fields:'),\n ` Email type: ${chalk.cyan('magic-code')}`,\n ` Subject: ${chalk.cyan(authEmail.subject)}`,\n ` Sender name: ${chalk.cyan(authEmail.senderName)}`,\n ` Sender email: ${chalk.cyan(senderEmail || '(default)')}`,\n ` Body: ${chalk.cyan(`${authEmail.body.length} characters`)}`,\n ].join('\\n'),\n );\n\n // Check if verification email needs to be sent\n\n if (info?.verification_verified === false) {\n yield* sendSenderVerification;\n yield* Effect.log(\n boxen(\n \"We've sent a confirmation email containing a six digit code to verify the sender email address.\\nUse superlayer auth email verify <code> to complete verification.\",\n {\n borderColor: 'yellow',\n padding: { right: 1, left: 1 },\n },\n ),\n );\n }\n\n if (\n emailConfig.authEmail.senderEmail &&\n emailConfig.authEmail.senderEmail !== defTemplate.senderEmail\n ) {\n const verification = yield* getVerification;\n if (verification.verification) {\n yield* Effect.log(\n formatSenderVerificationDnsRecords(verification.verification),\n );\n }\n }\n});\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
export declare const resendEmailCmd: Effect.Effect<void, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
|
|
3
|
+
//# sourceMappingURL=resend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resend.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/email/resend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,eAAO,MAAM,cAAc,kRAIzB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { sendSenderVerification } from "../../../lib/email.js";
|
|
3
|
+
export const resendEmailCmd = Effect.gen(function* () {
|
|
4
|
+
yield* sendSenderVerification;
|
|
5
|
+
yield* Effect.log('Verification email re-sent!');
|
|
6
|
+
});
|
|
7
|
+
//# sourceMappingURL=resend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resend.js","sourceRoot":"","sources":["../../../../src/commands/auth/email/resend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAChD,KAAK,CAAC,CAAC,sBAAsB,CAAC;IAE9B,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { sendSenderVerification } from '../../../lib/email.ts';\n\nexport const resendEmailCmd = Effect.gen(function* () {\n yield* sendSenderVerification;\n\n yield* Effect.log('Verification email re-sent!');\n});\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { CurrentApp } from '../../../context/currentApp.ts';
|
|
3
|
+
import { InstantHttpAuthed } from '../../../lib/http.ts';
|
|
4
|
+
export declare const authEmailResetCmd: () => Effect.Effect<void, import("../../../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, import("../../../context/globalOpts.ts").GlobalOpts | import("../../../context/projectInfo.ts").ProjectInfo | import("../../../lib/http.ts").InstantHttp | InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | import("@effect/platform/Path").Path | CurrentApp>;
|
|
5
|
+
//# sourceMappingURL=reset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/email/reset.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAe,MAAM,sBAAsB,CAAC;AAItE,eAAO,MAAM,iBAAiB,irBA6B5B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HttpClientRequest, HttpClientResponse } from '@effect/platform';
|
|
2
|
+
import { Effect, Schema } from 'effect';
|
|
3
|
+
import { CurrentApp } from "../../../context/currentApp.js";
|
|
4
|
+
import { InstantHttpAuthed, withCommand } from "../../../lib/http.js";
|
|
5
|
+
import { getDefaultEmailTemplate, writeEmailTemplate } from "./pull.js";
|
|
6
|
+
import { getEmailTemplateStatus } from "./status.js";
|
|
7
|
+
export const authEmailResetCmd = Effect.fn(function* () {
|
|
8
|
+
const { appId } = yield* CurrentApp;
|
|
9
|
+
const http = (yield* InstantHttpAuthed).pipe(withCommand('auth email reset'));
|
|
10
|
+
const status = yield* getEmailTemplateStatus;
|
|
11
|
+
if (!status) {
|
|
12
|
+
yield* Effect.log('No email template configured. Resetting local email template.');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
yield* http
|
|
16
|
+
.execute(HttpClientRequest.del(`/dash/apps/${appId}/email_templates/${status.id}`))
|
|
17
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
|
|
18
|
+
}
|
|
19
|
+
const defaultConfig = yield* getDefaultEmailTemplate;
|
|
20
|
+
yield* writeEmailTemplate(defaultConfig, {
|
|
21
|
+
confirmOverwrite: false,
|
|
22
|
+
});
|
|
23
|
+
yield* Effect.log('instant.email.ts file reset to default. To apply this change, run superlayer auth email push');
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../../src/commands/auth/email/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC;IAClD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IACpC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAE9E,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,sBAAsB,CAAC;IAE7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,+DAA+D,CAChE,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,CAAC,IAAI;aACR,OAAO,CACN,iBAAiB,CAAC,GAAG,CACnB,cAAc,KAAK,oBAAoB,MAAM,CAAC,EAAE,EAAE,CACnD,CACF;aACA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,uBAAuB,CAAC;IAErD,KAAK,CAAC,CAAC,kBAAkB,CAAC,aAAa,EAAE;QACvC,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;IAEH,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,8FAA8F,CAC/F,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { HttpClientRequest, HttpClientResponse } from '@effect/platform';\nimport { Effect, Schema } from 'effect';\nimport { CurrentApp } from '../../../context/currentApp.ts';\nimport { InstantHttpAuthed, withCommand } from '../../../lib/http.ts';\nimport { getDefaultEmailTemplate, writeEmailTemplate } from './pull.ts';\nimport { getEmailTemplateStatus } from './status.ts';\n\nexport const authEmailResetCmd = Effect.fn(function* () {\n const { appId } = yield* CurrentApp;\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth email reset'));\n\n const status = yield* getEmailTemplateStatus;\n\n if (!status) {\n yield* Effect.log(\n 'No email template configured. Resetting local email template.',\n );\n } else {\n yield* http\n .execute(\n HttpClientRequest.del(\n `/dash/apps/${appId}/email_templates/${status.id}`,\n ),\n )\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));\n }\n\n const defaultConfig = yield* getDefaultEmailTemplate;\n\n yield* writeEmailTemplate(defaultConfig, {\n confirmOverwrite: false,\n });\n\n yield* Effect.log(\n 'instant.email.ts file reset to default. To apply this change, run superlayer auth email push',\n );\n});\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Effect, Schema } from 'effect';
|
|
2
|
+
import { CurrentApp } from '../../../context/currentApp.ts';
|
|
3
|
+
import { InstantHttpAuthed } from '../../../lib/http.ts';
|
|
4
|
+
export declare const formatSenderVerificationDnsRecords: (verification: {
|
|
5
|
+
Confirmed: boolean;
|
|
6
|
+
DKIMPendingHost: string;
|
|
7
|
+
DKIMPendingTextValue: string;
|
|
8
|
+
ReturnPathDomain: string;
|
|
9
|
+
ReturnPathDomainCNAMEValue: string;
|
|
10
|
+
}) => string;
|
|
11
|
+
export declare const EmailTemplateInfoSchema: Schema.Struct<{
|
|
12
|
+
id: typeof Schema.String;
|
|
13
|
+
email: Schema.NullishOr<typeof Schema.String>;
|
|
14
|
+
name: typeof Schema.String;
|
|
15
|
+
sender_id: Schema.NullishOr<typeof Schema.String>;
|
|
16
|
+
app_id: typeof Schema.String;
|
|
17
|
+
postmark_id: Schema.NullishOr<typeof Schema.Number>;
|
|
18
|
+
verification_verified: Schema.NullishOr<typeof Schema.Boolean>;
|
|
19
|
+
verification_id: Schema.NullishOr<typeof Schema.String>;
|
|
20
|
+
email_type: typeof Schema.String;
|
|
21
|
+
body: typeof Schema.String;
|
|
22
|
+
subject: typeof Schema.String;
|
|
23
|
+
}>;
|
|
24
|
+
export type EmailTemplateInfo = typeof EmailTemplateInfoSchema.Type;
|
|
25
|
+
export declare const EmailTemplateSchema: Schema.Union<[Schema.Struct<{
|
|
26
|
+
info: Schema.NullishOr<Schema.Struct<{
|
|
27
|
+
id: typeof Schema.String;
|
|
28
|
+
email: Schema.NullishOr<typeof Schema.String>;
|
|
29
|
+
name: typeof Schema.String;
|
|
30
|
+
sender_id: Schema.NullishOr<typeof Schema.String>;
|
|
31
|
+
app_id: typeof Schema.String;
|
|
32
|
+
postmark_id: Schema.NullishOr<typeof Schema.Number>;
|
|
33
|
+
verification_verified: Schema.NullishOr<typeof Schema.Boolean>;
|
|
34
|
+
verification_id: Schema.NullishOr<typeof Schema.String>;
|
|
35
|
+
email_type: typeof Schema.String;
|
|
36
|
+
body: typeof Schema.String;
|
|
37
|
+
subject: typeof Schema.String;
|
|
38
|
+
}>>;
|
|
39
|
+
}>, typeof Schema.Null]>;
|
|
40
|
+
export declare const getEmailTemplateStatus: Effect.Effect<{
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly body: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly email: string | null | undefined;
|
|
45
|
+
readonly subject: string;
|
|
46
|
+
readonly sender_id: string | null | undefined;
|
|
47
|
+
readonly app_id: string;
|
|
48
|
+
readonly postmark_id: number | null | undefined;
|
|
49
|
+
readonly verification_verified: boolean | null | undefined;
|
|
50
|
+
readonly verification_id: string | null | undefined;
|
|
51
|
+
readonly email_type: string;
|
|
52
|
+
} | null | undefined, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
53
|
+
export declare const emailStatusCmd: (opts: {
|
|
54
|
+
app?: string | undefined;
|
|
55
|
+
json?: true | undefined;
|
|
56
|
+
}) => Effect.Effect<void, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
57
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/email/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAoBzD,eAAO,MAAM,kCAAkC,GAAI,cAAc;IAC/D,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,0BAA0B,EAAE,MAAM,CAAC;CACpC,WAqBE,CAAC;AAEJ,eAAO,MAAM,uBAAuB;;;;;;;;;;;;EAYlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,OAAO,uBAAuB,CAAC,IAAI,CAAC;AAEpE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;wBAK/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;+SAUjC,CAAC;AAEH,eAAO,MAAM,cAAc;;;mTAgEzB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import boxen from 'boxen';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { Effect, Option, Schema } from 'effect';
|
|
4
|
+
import { CurrentApp } from "../../../context/currentApp.js";
|
|
5
|
+
import { InstantHttpAuthed } from "../../../lib/http.js";
|
|
6
|
+
import { HttpClientResponse } from '@effect/platform';
|
|
7
|
+
import { getVerification } from "../../../lib/email.js";
|
|
8
|
+
const formatValue = (value) => value ?? 'n/a';
|
|
9
|
+
const formatVerified = (value) => {
|
|
10
|
+
if (value === true) {
|
|
11
|
+
return chalk.green('verified');
|
|
12
|
+
}
|
|
13
|
+
if (value === false) {
|
|
14
|
+
return chalk.yellow('pending');
|
|
15
|
+
}
|
|
16
|
+
return 'n/a';
|
|
17
|
+
};
|
|
18
|
+
const formatDnsRecord = (type, name, value) => [chalk.bold(type), `Name: ${name}`, `Value: ${value}`].join('\n');
|
|
19
|
+
export const formatSenderVerificationDnsRecords = (verification) => boxen([
|
|
20
|
+
chalk.bold('Add these DNS records to verify your sender email:'),
|
|
21
|
+
'',
|
|
22
|
+
formatDnsRecord('TXT', verification.DKIMPendingHost, verification.DKIMPendingTextValue),
|
|
23
|
+
'',
|
|
24
|
+
formatDnsRecord('CNAME', verification.ReturnPathDomain, verification.ReturnPathDomainCNAMEValue),
|
|
25
|
+
].join('\n'), {
|
|
26
|
+
borderColor: verification.Confirmed ? 'green' : 'yellow',
|
|
27
|
+
padding: { right: 1, left: 1 },
|
|
28
|
+
});
|
|
29
|
+
export const EmailTemplateInfoSchema = Schema.Struct({
|
|
30
|
+
id: Schema.String,
|
|
31
|
+
email: Schema.String.pipe(Schema.NullishOr),
|
|
32
|
+
name: Schema.String,
|
|
33
|
+
sender_id: Schema.String.pipe(Schema.NullishOr),
|
|
34
|
+
app_id: Schema.String,
|
|
35
|
+
postmark_id: Schema.Number.pipe(Schema.NullishOr),
|
|
36
|
+
verification_verified: Schema.Boolean.pipe(Schema.NullishOr),
|
|
37
|
+
verification_id: Schema.String.pipe(Schema.NullishOr),
|
|
38
|
+
email_type: Schema.String,
|
|
39
|
+
body: Schema.String,
|
|
40
|
+
subject: Schema.String,
|
|
41
|
+
});
|
|
42
|
+
export const EmailTemplateSchema = Schema.Union(Schema.Struct({
|
|
43
|
+
info: EmailTemplateInfoSchema.pipe(Schema.NullishOr),
|
|
44
|
+
}), Schema.Null);
|
|
45
|
+
export const getEmailTemplateStatus = Effect.gen(function* () {
|
|
46
|
+
const { appId } = yield* CurrentApp;
|
|
47
|
+
const http = yield* InstantHttpAuthed;
|
|
48
|
+
const app = yield* http
|
|
49
|
+
.get(`/dash/apps/${appId}/email_status`)
|
|
50
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(EmailTemplateSchema)));
|
|
51
|
+
return app?.info;
|
|
52
|
+
});
|
|
53
|
+
export const emailStatusCmd = Effect.fn(function* (opts) {
|
|
54
|
+
const info = yield* getEmailTemplateStatus;
|
|
55
|
+
if (!info) {
|
|
56
|
+
yield* Effect.log("No custom magic code email associated with this app.\nTo add one, run 'superlayer auth email pull', edit the file, then run 'superlayer auth email push'");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const verification = yield* Option.match(Option.fromNullable(info.sender_id), {
|
|
60
|
+
onNone: () => Effect.succeed(null),
|
|
61
|
+
onSome: () => getVerification,
|
|
62
|
+
});
|
|
63
|
+
if (opts.json) {
|
|
64
|
+
const fullInfo = verification
|
|
65
|
+
? {
|
|
66
|
+
...info,
|
|
67
|
+
verification: verification,
|
|
68
|
+
}
|
|
69
|
+
: info;
|
|
70
|
+
yield* Effect.log(JSON.stringify(fullInfo, null, 2));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
yield* Effect.log(chalk.cyan('Custom Magic Code Email'));
|
|
74
|
+
yield* Effect.log(` Sender name: ${info.name}`);
|
|
75
|
+
yield* Effect.log(` Sender email: ${formatValue(info.email)}`);
|
|
76
|
+
yield* Effect.log(` Subject: ${info.subject}`);
|
|
77
|
+
yield* Effect.log(` Body: ${info.body}`);
|
|
78
|
+
if (verification) {
|
|
79
|
+
yield* Effect.log('\n' +
|
|
80
|
+
boxen([
|
|
81
|
+
`Instant verified: ${formatVerified(verification.instant['verified?'])}`,
|
|
82
|
+
`Postmark verified: ${formatVerified(verification.verification?.Confirmed)}`,
|
|
83
|
+
].join('\n'), {
|
|
84
|
+
title: 'Custom Sender Verification',
|
|
85
|
+
borderColor: verification.instant['verified?'] &&
|
|
86
|
+
verification.verification?.Confirmed
|
|
87
|
+
? 'green'
|
|
88
|
+
: 'yellow',
|
|
89
|
+
padding: { right: 1, left: 1 },
|
|
90
|
+
}));
|
|
91
|
+
if (verification.verification) {
|
|
92
|
+
yield* Effect.log('\n' + formatSenderVerificationDnsRecords(verification.verification));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../src/commands/auth/email/status.ts"],"names":[],"mappings":"AAAA,OAAO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Option, Schema } from 'effect';\nimport { CurrentApp } from '../../../context/currentApp.ts';\nimport type { authEmailStatusDef, OptsFromCommand } from '../../../index.ts';\nimport { InstantHttpAuthed } from '../../../lib/http.ts';\nimport { HttpClientResponse } from '@effect/platform';\nimport { getVerification } from '../../../lib/email.ts';\n\nconst formatValue = (value: string | number | null | undefined) =>\n value ?? 'n/a';\n\nconst formatVerified = (value: boolean | null | undefined) => {\n if (value === true) {\n return chalk.green('verified');\n }\n if (value === false) {\n return chalk.yellow('pending');\n }\n return 'n/a';\n};\n\nconst formatDnsRecord = (type: string, name: string, value: string) =>\n [chalk.bold(type), `Name: ${name}`, `Value: ${value}`].join('\\n');\n\nexport const formatSenderVerificationDnsRecords = (verification: {\n Confirmed: boolean;\n DKIMPendingHost: string;\n DKIMPendingTextValue: string;\n ReturnPathDomain: string;\n ReturnPathDomainCNAMEValue: string;\n}) =>\n boxen(\n [\n chalk.bold('Add these DNS records to verify your sender email:'),\n '',\n formatDnsRecord(\n 'TXT',\n verification.DKIMPendingHost,\n verification.DKIMPendingTextValue,\n ),\n '',\n formatDnsRecord(\n 'CNAME',\n verification.ReturnPathDomain,\n verification.ReturnPathDomainCNAMEValue,\n ),\n ].join('\\n'),\n {\n borderColor: verification.Confirmed ? 'green' : 'yellow',\n padding: { right: 1, left: 1 },\n },\n );\n\nexport const EmailTemplateInfoSchema = Schema.Struct({\n id: Schema.String,\n email: Schema.String.pipe(Schema.NullishOr),\n name: Schema.String,\n sender_id: Schema.String.pipe(Schema.NullishOr),\n app_id: Schema.String,\n postmark_id: Schema.Number.pipe(Schema.NullishOr),\n verification_verified: Schema.Boolean.pipe(Schema.NullishOr),\n verification_id: Schema.String.pipe(Schema.NullishOr),\n email_type: Schema.String,\n body: Schema.String,\n subject: Schema.String,\n});\n\nexport type EmailTemplateInfo = typeof EmailTemplateInfoSchema.Type;\n\nexport const EmailTemplateSchema = Schema.Union(\n Schema.Struct({\n info: EmailTemplateInfoSchema.pipe(Schema.NullishOr),\n }),\n Schema.Null,\n);\n\nexport const getEmailTemplateStatus = Effect.gen(function* () {\n const { appId } = yield* CurrentApp;\n const http = yield* InstantHttpAuthed;\n\n const app = yield* http\n .get(`/dash/apps/${appId}/email_status`)\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(EmailTemplateSchema)),\n );\n return app?.info;\n});\n\nexport const emailStatusCmd = Effect.fn(function* (\n opts: OptsFromCommand<typeof authEmailStatusDef>,\n) {\n const info = yield* getEmailTemplateStatus;\n\n if (!info) {\n yield* Effect.log(\n \"No custom magic code email associated with this app.\\nTo add one, run 'superlayer auth email pull', edit the file, then run 'superlayer auth email push'\",\n );\n return;\n }\n\n const verification = yield* Option.match(\n Option.fromNullable(info.sender_id),\n {\n onNone: () => Effect.succeed(null),\n onSome: () => getVerification,\n },\n );\n\n if (opts.json) {\n const fullInfo = verification\n ? {\n ...info,\n verification: verification,\n }\n : info;\n\n yield* Effect.log(JSON.stringify(fullInfo, null, 2));\n return;\n }\n\n yield* Effect.log(chalk.cyan('Custom Magic Code Email'));\n yield* Effect.log(` Sender name: ${info.name}`);\n yield* Effect.log(` Sender email: ${formatValue(info.email)}`);\n yield* Effect.log(` Subject: ${info.subject}`);\n yield* Effect.log(` Body: ${info.body}`);\n\n if (verification) {\n yield* Effect.log(\n '\\n' +\n boxen(\n [\n `Instant verified: ${formatVerified(verification.instant['verified?'])}`,\n `Postmark verified: ${formatVerified(verification.verification?.Confirmed)}`,\n ].join('\\n'),\n {\n title: 'Custom Sender Verification',\n borderColor:\n verification.instant['verified?'] &&\n verification.verification?.Confirmed\n ? 'green'\n : 'yellow',\n padding: { right: 1, left: 1 },\n },\n ),\n );\n\n if (verification.verification) {\n yield* Effect.log(\n '\\n' + formatSenderVerificationDnsRecords(verification.verification),\n );\n }\n }\n});\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
export declare const verifyCmd: (code: string, _opts: {
|
|
3
|
+
app?: string | undefined;
|
|
4
|
+
}) => Effect.Effect<void, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
|
|
5
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/email/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,eAAO,MAAM,SAAS;;2XAepB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { getVerification, submitVerification } from "../../../lib/email.js";
|
|
3
|
+
export const verifyCmd = Effect.fn(function* (code, _opts) {
|
|
4
|
+
yield* submitVerification(code);
|
|
5
|
+
// get verification status
|
|
6
|
+
const verificationInfo = yield* getVerification;
|
|
7
|
+
if (verificationInfo.instant['verified?'] &&
|
|
8
|
+
verificationInfo.verification?.Confirmed) {
|
|
9
|
+
yield* Effect.log('Verification successful for both Postmark and Instant!');
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../../src/commands/auth/email/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC1C,IAAY,EACZ,KAAiD;IAEjD,KAAK,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAEhC,0BAA0B;IAC1B,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC;IAEhD,IACE,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC;QACrC,gBAAgB,CAAC,YAAY,EAAE,SAAS,EACxC,CAAC;QACD,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport type { authEmailVerifyDef, OptsFromCommand } from '../../../index.ts';\nimport { getVerification, submitVerification } from '../../../lib/email.ts';\n\nexport const verifyCmd = Effect.fn(function* (\n code: string,\n _opts: OptsFromCommand<typeof authEmailVerifyDef>,\n) {\n yield* submitVerification(code);\n\n // get verification status\n const verificationInfo = yield* getVerification;\n\n if (\n verificationInfo.instant['verified?'] &&\n verificationInfo.verification?.Confirmed\n ) {\n yield* Effect.log('Verification successful for both Postmark and Instant!');\n }\n});\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Effect, Schema } from 'effect';
|
|
2
|
+
import { GlobalOpts } from '../../../context/globalOpts.ts';
|
|
3
|
+
export declare const OriginTypeSchema: Schema.Literal<["website", "vercel", "netlify", "custom-scheme"]>;
|
|
4
|
+
export declare const authOriginAddCmd: (opts: {
|
|
5
|
+
type?: string | undefined;
|
|
6
|
+
url?: string | undefined;
|
|
7
|
+
project?: string | undefined;
|
|
8
|
+
site?: string | undefined;
|
|
9
|
+
scheme?: string | undefined;
|
|
10
|
+
app?: string | undefined;
|
|
11
|
+
} & Record<string, unknown>) => Effect.Effect<void | undefined, import("../../../lib/ui.ts").UIError | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
|
|
12
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../src/commands/auth/origin/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAS5D,eAAO,MAAM,gBAAgB,mEAK5B,CAAC;AAuKF,eAAO,MAAM,gBAAgB;;;;;;;qdAoD5B,CAAC"}
|