@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,306 @@
|
|
|
1
|
+
import { Effect, Schema } from 'effect';
|
|
2
|
+
import { CurrentApp } from '../context/currentApp.ts';
|
|
3
|
+
import { InstantHttpAuthed } from './http.ts';
|
|
4
|
+
import { BadArgsError } from '../errors.ts';
|
|
5
|
+
export declare const AuthorizedOriginService: Schema.Literal<["generic", "vercel", "netlify", "custom-scheme"]>;
|
|
6
|
+
export declare const AuthorizedOrigin: Schema.Struct<{
|
|
7
|
+
id: typeof Schema.String;
|
|
8
|
+
service: Schema.Literal<["generic", "vercel", "netlify", "custom-scheme"]>;
|
|
9
|
+
params: Schema.mutable<Schema.Array$<typeof Schema.String>>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const OAuthServiceProvider: Schema.Struct<{
|
|
12
|
+
id: typeof Schema.String;
|
|
13
|
+
provider_name: typeof Schema.String;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const GoogleAppTypeSchema: Schema.Literal<["web", "ios", "android", "button-for-web"]>;
|
|
16
|
+
export declare const OAuthClient: Schema.Struct<{
|
|
17
|
+
id: typeof Schema.String;
|
|
18
|
+
client_name: typeof Schema.String;
|
|
19
|
+
client_id: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
20
|
+
provider_id: typeof Schema.String;
|
|
21
|
+
authorization_endpoint: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
22
|
+
token_endpoint: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
23
|
+
discovery_endpoint: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
24
|
+
redirect_to: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
25
|
+
meta: Schema.optional<Schema.Union<[Schema.extend<Schema.Struct<{
|
|
26
|
+
appType: Schema.optional<Schema.Literal<["web", "ios", "android", "button-for-web"]>>;
|
|
27
|
+
}>, Schema.Record$<typeof Schema.String, typeof Schema.Any>>, typeof Schema.Null]>>;
|
|
28
|
+
use_shared_credentials: Schema.optional<Schema.Union<[typeof Schema.Boolean, typeof Schema.Null]>>;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const AddOAuthProviderResponse: Schema.Struct<{
|
|
31
|
+
provider: Schema.Struct<{
|
|
32
|
+
id: typeof Schema.String;
|
|
33
|
+
provider_name: typeof Schema.String;
|
|
34
|
+
}>;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const AddOAuthClientResponse: Schema.Struct<{
|
|
37
|
+
client: Schema.Struct<{
|
|
38
|
+
id: typeof Schema.String;
|
|
39
|
+
client_name: typeof Schema.String;
|
|
40
|
+
client_id: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
41
|
+
provider_id: typeof Schema.String;
|
|
42
|
+
authorization_endpoint: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
43
|
+
token_endpoint: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
44
|
+
discovery_endpoint: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
45
|
+
redirect_to: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>;
|
|
46
|
+
meta: Schema.optional<Schema.Union<[Schema.extend<Schema.Struct<{
|
|
47
|
+
appType: Schema.optional<Schema.Literal<["web", "ios", "android", "button-for-web"]>>;
|
|
48
|
+
}>, Schema.Record$<typeof Schema.String, typeof Schema.Any>>, typeof Schema.Null]>>;
|
|
49
|
+
use_shared_credentials: Schema.optional<Schema.Union<[typeof Schema.Boolean, typeof Schema.Null]>>;
|
|
50
|
+
}>;
|
|
51
|
+
}>;
|
|
52
|
+
export declare const AuthorizedOriginResponse: Schema.Struct<{
|
|
53
|
+
origin: Schema.Struct<{
|
|
54
|
+
id: typeof Schema.String;
|
|
55
|
+
service: Schema.Literal<["generic", "vercel", "netlify", "custom-scheme"]>;
|
|
56
|
+
params: Schema.mutable<Schema.Array$<typeof Schema.String>>;
|
|
57
|
+
}>;
|
|
58
|
+
}>;
|
|
59
|
+
export declare const AppsAuthResponse: Schema.Struct<{
|
|
60
|
+
authorized_redirect_origins: Schema.optional<Schema.Union<[Schema.mutable<Schema.Array$<Schema.Schema<{
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
63
|
+
readonly params: string[];
|
|
64
|
+
}, {
|
|
65
|
+
readonly id: string;
|
|
66
|
+
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
67
|
+
readonly params: string[];
|
|
68
|
+
}, never>>>, typeof Schema.Null]>>;
|
|
69
|
+
oauth_service_providers: Schema.optional<Schema.Union<[Schema.mutable<Schema.Array$<Schema.Schema<{
|
|
70
|
+
readonly id: string;
|
|
71
|
+
readonly provider_name: string;
|
|
72
|
+
}, {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly provider_name: string;
|
|
75
|
+
}, never>>>, typeof Schema.Null]>>;
|
|
76
|
+
oauth_clients: Schema.optional<Schema.Union<[Schema.mutable<Schema.Array$<Schema.Schema<{
|
|
77
|
+
readonly id: string;
|
|
78
|
+
readonly client_name: string;
|
|
79
|
+
readonly client_id?: string | null | undefined;
|
|
80
|
+
readonly provider_id: string;
|
|
81
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
82
|
+
readonly token_endpoint?: string | null | undefined;
|
|
83
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
84
|
+
readonly redirect_to?: string | null | undefined;
|
|
85
|
+
readonly meta?: ({
|
|
86
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
87
|
+
} & {
|
|
88
|
+
readonly [x: string]: any;
|
|
89
|
+
}) | null | undefined;
|
|
90
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly client_name: string;
|
|
94
|
+
readonly provider_id: string;
|
|
95
|
+
readonly client_id?: string | null | undefined;
|
|
96
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
97
|
+
readonly token_endpoint?: string | null | undefined;
|
|
98
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
99
|
+
readonly redirect_to?: string | null | undefined;
|
|
100
|
+
readonly meta?: ({
|
|
101
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
102
|
+
} & {
|
|
103
|
+
readonly [x: string]: any;
|
|
104
|
+
}) | null | undefined;
|
|
105
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
106
|
+
}, never>>>, typeof Schema.Null]>>;
|
|
107
|
+
}>;
|
|
108
|
+
export declare const getAppsAuth: () => Effect.Effect<{
|
|
109
|
+
readonly authorized_redirect_origins?: {
|
|
110
|
+
readonly id: string;
|
|
111
|
+
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
112
|
+
readonly params: string[];
|
|
113
|
+
}[] | null | undefined;
|
|
114
|
+
readonly oauth_service_providers?: {
|
|
115
|
+
readonly id: string;
|
|
116
|
+
readonly provider_name: string;
|
|
117
|
+
}[] | null | undefined;
|
|
118
|
+
readonly oauth_clients?: {
|
|
119
|
+
readonly id: string;
|
|
120
|
+
readonly client_name: string;
|
|
121
|
+
readonly client_id?: string | null | undefined;
|
|
122
|
+
readonly provider_id: string;
|
|
123
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
124
|
+
readonly token_endpoint?: string | null | undefined;
|
|
125
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
126
|
+
readonly redirect_to?: string | null | undefined;
|
|
127
|
+
readonly meta?: ({
|
|
128
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
129
|
+
} & {
|
|
130
|
+
readonly [x: string]: any;
|
|
131
|
+
}) | null | undefined;
|
|
132
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
133
|
+
}[] | null | undefined;
|
|
134
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
135
|
+
export declare const addOAuthProvider: (params: {
|
|
136
|
+
appId?: string;
|
|
137
|
+
providerName: string;
|
|
138
|
+
}) => Effect.Effect<{
|
|
139
|
+
readonly provider: {
|
|
140
|
+
readonly id: string;
|
|
141
|
+
readonly provider_name: string;
|
|
142
|
+
};
|
|
143
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
144
|
+
export declare const addOAuthClient: (params: {
|
|
145
|
+
appId?: string;
|
|
146
|
+
providerId: string;
|
|
147
|
+
clientName: string;
|
|
148
|
+
clientId?: string;
|
|
149
|
+
clientSecret?: string;
|
|
150
|
+
authorizationEndpoint?: string;
|
|
151
|
+
tokenEndpoint?: string;
|
|
152
|
+
discoveryEndpoint?: string;
|
|
153
|
+
redirectTo?: string;
|
|
154
|
+
meta?: unknown;
|
|
155
|
+
useSharedCredentials?: boolean;
|
|
156
|
+
}) => Effect.Effect<{
|
|
157
|
+
readonly client: {
|
|
158
|
+
readonly id: string;
|
|
159
|
+
readonly client_name: string;
|
|
160
|
+
readonly client_id?: string | null | undefined;
|
|
161
|
+
readonly provider_id: string;
|
|
162
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
163
|
+
readonly token_endpoint?: string | null | undefined;
|
|
164
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
165
|
+
readonly redirect_to?: string | null | undefined;
|
|
166
|
+
readonly meta?: ({
|
|
167
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
168
|
+
} & {
|
|
169
|
+
readonly [x: string]: any;
|
|
170
|
+
}) | null | undefined;
|
|
171
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
172
|
+
};
|
|
173
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
174
|
+
export declare const updateOAuthClient: (params: {
|
|
175
|
+
oauthClientId: string;
|
|
176
|
+
clientId?: string | null;
|
|
177
|
+
clientSecret?: string | null;
|
|
178
|
+
discoveryEndpoint?: string | null;
|
|
179
|
+
redirectTo?: string | null;
|
|
180
|
+
meta?: unknown;
|
|
181
|
+
useSharedCredentials?: boolean | null;
|
|
182
|
+
}) => Effect.Effect<{
|
|
183
|
+
readonly client: {
|
|
184
|
+
readonly id: string;
|
|
185
|
+
readonly client_name: string;
|
|
186
|
+
readonly client_id?: string | null | undefined;
|
|
187
|
+
readonly provider_id: string;
|
|
188
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
189
|
+
readonly token_endpoint?: string | null | undefined;
|
|
190
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
191
|
+
readonly redirect_to?: string | null | undefined;
|
|
192
|
+
readonly meta?: ({
|
|
193
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
194
|
+
} & {
|
|
195
|
+
readonly [x: string]: any;
|
|
196
|
+
}) | null | undefined;
|
|
197
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
198
|
+
};
|
|
199
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
200
|
+
export declare const getOrCreateProvider: (type: "google" | "github" | "apple" | "linkedin" | "clerk" | "firebase") => Effect.Effect<{
|
|
201
|
+
auth: {
|
|
202
|
+
readonly authorized_redirect_origins?: {
|
|
203
|
+
readonly id: string;
|
|
204
|
+
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
205
|
+
readonly params: string[];
|
|
206
|
+
}[] | null | undefined;
|
|
207
|
+
readonly oauth_service_providers?: {
|
|
208
|
+
readonly id: string;
|
|
209
|
+
readonly provider_name: string;
|
|
210
|
+
}[] | null | undefined;
|
|
211
|
+
readonly oauth_clients?: {
|
|
212
|
+
readonly id: string;
|
|
213
|
+
readonly client_name: string;
|
|
214
|
+
readonly client_id?: string | null | undefined;
|
|
215
|
+
readonly provider_id: string;
|
|
216
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
217
|
+
readonly token_endpoint?: string | null | undefined;
|
|
218
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
219
|
+
readonly redirect_to?: string | null | undefined;
|
|
220
|
+
readonly meta?: ({
|
|
221
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
222
|
+
} & {
|
|
223
|
+
readonly [x: string]: any;
|
|
224
|
+
}) | null | undefined;
|
|
225
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
226
|
+
}[] | null | undefined;
|
|
227
|
+
};
|
|
228
|
+
provider: {
|
|
229
|
+
readonly id: string;
|
|
230
|
+
readonly provider_name: string;
|
|
231
|
+
};
|
|
232
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
233
|
+
export declare const findName: (prefix: string, used: Set<string>) => string;
|
|
234
|
+
export declare const getClientNameAndProvider: (providerType: "google" | "github" | "apple" | "linkedin" | "clerk" | "firebase", opts: Record<string, unknown>) => Effect.Effect<{
|
|
235
|
+
provider: {
|
|
236
|
+
readonly id: string;
|
|
237
|
+
readonly provider_name: string;
|
|
238
|
+
};
|
|
239
|
+
clientName: string;
|
|
240
|
+
}, BadArgsError | import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../context/globalOpts.ts").GlobalOpts | InstantHttpAuthed | CurrentApp>;
|
|
241
|
+
export declare const findClientByIdOrName: (params: {
|
|
242
|
+
id?: string;
|
|
243
|
+
name?: string;
|
|
244
|
+
}) => Effect.Effect<{
|
|
245
|
+
auth: {
|
|
246
|
+
readonly authorized_redirect_origins?: {
|
|
247
|
+
readonly id: string;
|
|
248
|
+
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
249
|
+
readonly params: string[];
|
|
250
|
+
}[] | null | undefined;
|
|
251
|
+
readonly oauth_service_providers?: {
|
|
252
|
+
readonly id: string;
|
|
253
|
+
readonly provider_name: string;
|
|
254
|
+
}[] | null | undefined;
|
|
255
|
+
readonly oauth_clients?: {
|
|
256
|
+
readonly id: string;
|
|
257
|
+
readonly client_name: string;
|
|
258
|
+
readonly client_id?: string | null | undefined;
|
|
259
|
+
readonly provider_id: string;
|
|
260
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
261
|
+
readonly token_endpoint?: string | null | undefined;
|
|
262
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
263
|
+
readonly redirect_to?: string | null | undefined;
|
|
264
|
+
readonly meta?: ({
|
|
265
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
266
|
+
} & {
|
|
267
|
+
readonly [x: string]: any;
|
|
268
|
+
}) | null | undefined;
|
|
269
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
270
|
+
}[] | null | undefined;
|
|
271
|
+
};
|
|
272
|
+
client: {
|
|
273
|
+
readonly id: string;
|
|
274
|
+
readonly client_name: string;
|
|
275
|
+
readonly client_id?: string | null | undefined;
|
|
276
|
+
readonly provider_id: string;
|
|
277
|
+
readonly authorization_endpoint?: string | null | undefined;
|
|
278
|
+
readonly token_endpoint?: string | null | undefined;
|
|
279
|
+
readonly discovery_endpoint?: string | null | undefined;
|
|
280
|
+
readonly redirect_to?: string | null | undefined;
|
|
281
|
+
readonly meta?: ({
|
|
282
|
+
readonly appType?: "android" | "web" | "ios" | "button-for-web" | undefined;
|
|
283
|
+
} & {
|
|
284
|
+
readonly [x: string]: any;
|
|
285
|
+
}) | null | undefined;
|
|
286
|
+
readonly use_shared_credentials?: boolean | null | undefined;
|
|
287
|
+
};
|
|
288
|
+
}, BadArgsError | import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
289
|
+
export declare const removeAuthorizedOrigin: (originId: string) => Effect.Effect<{
|
|
290
|
+
readonly origin: {
|
|
291
|
+
readonly id: string;
|
|
292
|
+
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
293
|
+
readonly params: string[];
|
|
294
|
+
};
|
|
295
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
296
|
+
export declare const addAuthorizedOrigin: (params: {
|
|
297
|
+
service: Schema.Schema.Type<typeof AuthorizedOriginService>;
|
|
298
|
+
params: string[];
|
|
299
|
+
}) => Effect.Effect<{
|
|
300
|
+
readonly origin: {
|
|
301
|
+
readonly id: string;
|
|
302
|
+
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
303
|
+
readonly params: string[];
|
|
304
|
+
};
|
|
305
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
|
|
306
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/lib/oauth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAe,MAAM,WAAW,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C,eAAO,MAAM,uBAAuB,mEAKnC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;EAI3B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;EAG/B,CAAC;AAEH,eAAO,MAAM,mBAAmB,6DAK/B,CAAC;AAmBF,eAAO,MAAM,WAAW;;;;;;;;;;;;;EAWtB,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;EAEnC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;EAEjC,CAAC;AAEH,eAAO,MAAM,wBAAwB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} from '@effect/platform';
|
|
2
|
+
import { Effect, Schema } from 'effect';
|
|
3
|
+
import { CurrentApp } from "../context/currentApp.js";
|
|
4
|
+
import { InstantHttpAuthed, withCommand } from "./http.js";
|
|
5
|
+
import { validateRequired } from "./ui.js";
|
|
6
|
+
import { UI } from "../ui/index.js";
|
|
7
|
+
import { BadArgsError } from "../errors.js";
|
|
8
|
+
import { Args } from "./args.js";
|
|
9
|
+
export const AuthorizedOriginService = Schema.Literal('generic', 'vercel', 'netlify', 'custom-scheme');
|
|
10
|
+
export const AuthorizedOrigin = Schema.Struct({
|
|
11
|
+
id: Schema.String,
|
|
12
|
+
service: AuthorizedOriginService,
|
|
13
|
+
params: Schema.Array(Schema.String).pipe(Schema.mutable),
|
|
14
|
+
});
|
|
15
|
+
export const OAuthServiceProvider = Schema.Struct({
|
|
16
|
+
id: Schema.String,
|
|
17
|
+
provider_name: Schema.String,
|
|
18
|
+
});
|
|
19
|
+
export const GoogleAppTypeSchema = Schema.Literal('web', 'ios', 'android', 'button-for-web');
|
|
20
|
+
const NullableString = Schema.Union(Schema.String, Schema.Null).pipe(Schema.optional);
|
|
21
|
+
const NullableBoolean = Schema.Union(Schema.Boolean, Schema.Null).pipe(Schema.optional);
|
|
22
|
+
const OAuthClientMeta = Schema.Struct({
|
|
23
|
+
// Currently the CLI only reads Google app type from meta. Other providers store
|
|
24
|
+
// different meta shapes, so keep the rest open until we have a clean
|
|
25
|
+
// top-level discriminator for a full provider-specific union.
|
|
26
|
+
appType: GoogleAppTypeSchema.pipe(Schema.optional),
|
|
27
|
+
}).pipe(Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Any })));
|
|
28
|
+
export const OAuthClient = Schema.Struct({
|
|
29
|
+
id: Schema.String,
|
|
30
|
+
client_name: Schema.String,
|
|
31
|
+
client_id: NullableString,
|
|
32
|
+
provider_id: Schema.String,
|
|
33
|
+
authorization_endpoint: NullableString,
|
|
34
|
+
token_endpoint: NullableString,
|
|
35
|
+
discovery_endpoint: NullableString,
|
|
36
|
+
redirect_to: NullableString,
|
|
37
|
+
meta: Schema.Union(OAuthClientMeta, Schema.Null).pipe(Schema.optional),
|
|
38
|
+
use_shared_credentials: NullableBoolean,
|
|
39
|
+
});
|
|
40
|
+
export const AddOAuthProviderResponse = Schema.Struct({
|
|
41
|
+
provider: OAuthServiceProvider,
|
|
42
|
+
});
|
|
43
|
+
export const AddOAuthClientResponse = Schema.Struct({
|
|
44
|
+
client: OAuthClient,
|
|
45
|
+
});
|
|
46
|
+
export const AuthorizedOriginResponse = Schema.Struct({
|
|
47
|
+
origin: AuthorizedOrigin,
|
|
48
|
+
});
|
|
49
|
+
const NullableArray = (schema) => Schema.Union(Schema.Array(schema).pipe(Schema.mutable), Schema.Null).pipe(Schema.optional);
|
|
50
|
+
export const AppsAuthResponse = Schema.Struct({
|
|
51
|
+
authorized_redirect_origins: NullableArray(AuthorizedOrigin),
|
|
52
|
+
oauth_service_providers: NullableArray(OAuthServiceProvider),
|
|
53
|
+
oauth_clients: NullableArray(OAuthClient),
|
|
54
|
+
});
|
|
55
|
+
export const getAppsAuth = Effect.fn(function* () {
|
|
56
|
+
const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
|
|
57
|
+
const targetAppId = (yield* CurrentApp).appId;
|
|
58
|
+
return yield* http
|
|
59
|
+
.get(`/dash/apps/${targetAppId}/auth`)
|
|
60
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AppsAuthResponse)));
|
|
61
|
+
});
|
|
62
|
+
export const addOAuthProvider = Effect.fn(function* (params) {
|
|
63
|
+
const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
|
|
64
|
+
const targetAppId = params.appId ?? (yield* CurrentApp).appId;
|
|
65
|
+
return yield* http
|
|
66
|
+
.post(`/dash/apps/${targetAppId}/oauth_service_providers`, {
|
|
67
|
+
body: HttpBody.unsafeJson({
|
|
68
|
+
provider_name: params.providerName,
|
|
69
|
+
}),
|
|
70
|
+
})
|
|
71
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthProviderResponse)));
|
|
72
|
+
});
|
|
73
|
+
export const addOAuthClient = Effect.fn(function* (params) {
|
|
74
|
+
const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
|
|
75
|
+
const targetAppId = params.appId ?? (yield* CurrentApp).appId;
|
|
76
|
+
return yield* http
|
|
77
|
+
.post(`/dash/apps/${targetAppId}/oauth_clients`, {
|
|
78
|
+
body: HttpBody.unsafeJson({
|
|
79
|
+
provider_id: params.providerId,
|
|
80
|
+
client_name: params.clientName,
|
|
81
|
+
client_id: params.clientId,
|
|
82
|
+
client_secret: params.clientSecret,
|
|
83
|
+
authorization_endpoint: params.authorizationEndpoint,
|
|
84
|
+
token_endpoint: params.tokenEndpoint,
|
|
85
|
+
discovery_endpoint: params.discoveryEndpoint,
|
|
86
|
+
redirect_to: params.redirectTo,
|
|
87
|
+
meta: params.meta,
|
|
88
|
+
use_shared_credentials: params.useSharedCredentials,
|
|
89
|
+
}),
|
|
90
|
+
})
|
|
91
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)));
|
|
92
|
+
});
|
|
93
|
+
export const updateOAuthClient = Effect.fn(function* (params) {
|
|
94
|
+
const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
|
|
95
|
+
const targetAppId = (yield* CurrentApp).appId;
|
|
96
|
+
return yield* http
|
|
97
|
+
.post(`/dash/apps/${targetAppId}/oauth_clients/${params.oauthClientId}`, {
|
|
98
|
+
body: HttpBody.unsafeJson({
|
|
99
|
+
client_id: params.clientId,
|
|
100
|
+
client_secret: params.clientSecret,
|
|
101
|
+
discovery_endpoint: params.discoveryEndpoint,
|
|
102
|
+
redirect_to: params.redirectTo,
|
|
103
|
+
meta: params.meta,
|
|
104
|
+
use_shared_credentials: params.useSharedCredentials,
|
|
105
|
+
}),
|
|
106
|
+
})
|
|
107
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)));
|
|
108
|
+
});
|
|
109
|
+
export const getOrCreateProvider = Effect.fn(function* (type) {
|
|
110
|
+
const auth = yield* getAppsAuth();
|
|
111
|
+
const provider = auth.oauth_service_providers?.find((entry) => entry.provider_name === type);
|
|
112
|
+
if (provider) {
|
|
113
|
+
return { auth, provider };
|
|
114
|
+
}
|
|
115
|
+
const created = yield* addOAuthProvider({ providerName: type });
|
|
116
|
+
return { auth, provider: created.provider };
|
|
117
|
+
});
|
|
118
|
+
// Returns prefix if unused; otherwise appends integers starting at 2.
|
|
119
|
+
// e.g. findName('google', new Set(['google', 'google2'])) returns 'google3'.
|
|
120
|
+
export const findName = (prefix, used) => {
|
|
121
|
+
if (!used.has(prefix)) {
|
|
122
|
+
return prefix;
|
|
123
|
+
}
|
|
124
|
+
for (let i = 2;; i++) {
|
|
125
|
+
const candidate = `${prefix}${i}`;
|
|
126
|
+
if (!used.has(candidate)) {
|
|
127
|
+
return candidate;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
export const getClientNameAndProvider = Effect.fn(function* (providerType, opts) {
|
|
132
|
+
const { auth, provider } = yield* getOrCreateProvider(providerType);
|
|
133
|
+
const usedClientNames = new Set((auth.oauth_clients ?? []).map((client) => client.client_name));
|
|
134
|
+
const suggestedClientName = findName(providerType, usedClientNames);
|
|
135
|
+
const clientName = yield* Args.text(opts, 'name').pipe(Args.prompt({
|
|
136
|
+
prompt: 'Client Name:',
|
|
137
|
+
defaultValue: suggestedClientName,
|
|
138
|
+
placeholder: suggestedClientName,
|
|
139
|
+
validate: validateRequired,
|
|
140
|
+
modifyOutput: UI.modifiers.piped([
|
|
141
|
+
UI.modifiers.topPadding,
|
|
142
|
+
UI.modifiers.dimOnComplete,
|
|
143
|
+
]),
|
|
144
|
+
}), Args.required());
|
|
145
|
+
if (usedClientNames.has(clientName)) {
|
|
146
|
+
return yield* BadArgsError.make({
|
|
147
|
+
message: `The unique name '${clientName}' is already in use.`,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return { provider, clientName };
|
|
151
|
+
});
|
|
152
|
+
export const findClientByIdOrName = Effect.fn(function* (params) {
|
|
153
|
+
if (params.id && params.name) {
|
|
154
|
+
return yield* BadArgsError.make({
|
|
155
|
+
message: 'Cannot specify both --id and --name',
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (!params.id && !params.name) {
|
|
159
|
+
return yield* BadArgsError.make({
|
|
160
|
+
message: 'Must specify --id or --name',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const auth = yield* getAppsAuth();
|
|
164
|
+
const clients = auth.oauth_clients ?? [];
|
|
165
|
+
const client = params.id
|
|
166
|
+
? clients.find((entry) => entry.id === params.id)
|
|
167
|
+
: clients.find((entry) => entry.client_name === params.name);
|
|
168
|
+
if (!client) {
|
|
169
|
+
const lookup = params.id ? `id ${params.id}` : `name ${params.name}`;
|
|
170
|
+
return yield* BadArgsError.make({
|
|
171
|
+
message: `OAuth client not found: ${lookup}`,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return { auth, client };
|
|
175
|
+
});
|
|
176
|
+
export const removeAuthorizedOrigin = Effect.fn(function* (originId) {
|
|
177
|
+
const http = (yield* InstantHttpAuthed).pipe(withCommand('auth origin delete'));
|
|
178
|
+
const { appId } = yield* CurrentApp;
|
|
179
|
+
return yield* http
|
|
180
|
+
.del(`/dash/apps/${appId}/authorized_redirect_origins/${originId}`)
|
|
181
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse)));
|
|
182
|
+
});
|
|
183
|
+
export const addAuthorizedOrigin = Effect.fn(function* (params) {
|
|
184
|
+
const http = (yield* InstantHttpAuthed).pipe(withCommand('auth origin add'));
|
|
185
|
+
const { appId } = yield* CurrentApp;
|
|
186
|
+
return yield* http
|
|
187
|
+
.post(`/dash/apps/${appId}/authorized_redirect_origins`, {
|
|
188
|
+
body: HttpBody.unsafeJson({
|
|
189
|
+
service: params.service,
|
|
190
|
+
params: params.params,
|
|
191
|
+
}),
|
|
192
|
+
})
|
|
193
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse)));
|
|
194
|
+
});
|
|
195
|
+
//# sourceMappingURL=oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/lib/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,CACnD,SAAS,EACT,QAAQ,EACR,SAAS,EACT,eAAe,CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,OAAO,EAAE,uBAAuB;IAChC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;CACzD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IAChD,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,aAAa,EAAE,MAAM,CAAC,MAAM;CAC7B,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AQ,EAAE,CAAC;SAClE,IAAI,CACH,MAAM,CAAC,OAAO,CACZ,kBAAkB,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAC5D,CACF,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAGvD;IACC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IAEpC,OAAO,KAAK,CAAC,CAAC,IAAI;SACf,IAAI,CAAC,cAAc,KAAK,8BAA8B,EAAE;QACvD,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC;KACH,CAAC;SACD,IAAI,CACH,MAAM,CAAC,OAAO,CACZ,kBAAkB,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAC5D,CACF,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["import { HttpBody, HttpClientResponse } from '@effect/platform';\nimport { Effect, Schema } from 'effect';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { InstantHttpAuthed, withCommand } from './http.ts';\nimport { validateRequired } from './ui.ts';\nimport { UI } from '../ui/index.ts';\nimport { BadArgsError } from '../errors.ts';\nimport type { ClientTypeSchema } from '../commands/auth/client/add.ts';\nimport { Args } from './args.ts';\n\nexport const AuthorizedOriginService = Schema.Literal(\n 'generic',\n 'vercel',\n 'netlify',\n 'custom-scheme',\n);\n\nexport const AuthorizedOrigin = Schema.Struct({\n id: Schema.String,\n service: AuthorizedOriginService,\n params: Schema.Array(Schema.String).pipe(Schema.mutable),\n});\n\nexport const OAuthServiceProvider = Schema.Struct({\n id: Schema.String,\n provider_name: Schema.String,\n});\n\nexport const GoogleAppTypeSchema = Schema.Literal(\n 'web',\n 'ios',\n 'android',\n 'button-for-web',\n);\n\nconst NullableString = Schema.Union(Schema.String, Schema.Null).pipe(\n Schema.optional,\n);\n\nconst NullableBoolean = Schema.Union(Schema.Boolean, Schema.Null).pipe(\n Schema.optional,\n);\n\nconst OAuthClientMeta = Schema.Struct({\n // Currently the CLI only reads Google app type from meta. Other providers store\n // different meta shapes, so keep the rest open until we have a clean\n // top-level discriminator for a full provider-specific union.\n appType: GoogleAppTypeSchema.pipe(Schema.optional),\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Any })),\n);\n\nexport const OAuthClient = Schema.Struct({\n id: Schema.String,\n client_name: Schema.String,\n client_id: NullableString,\n provider_id: Schema.String,\n authorization_endpoint: NullableString,\n token_endpoint: NullableString,\n discovery_endpoint: NullableString,\n redirect_to: NullableString,\n meta: Schema.Union(OAuthClientMeta, Schema.Null).pipe(Schema.optional),\n use_shared_credentials: NullableBoolean,\n});\n\nexport const AddOAuthProviderResponse = Schema.Struct({\n provider: OAuthServiceProvider,\n});\n\nexport const AddOAuthClientResponse = Schema.Struct({\n client: OAuthClient,\n});\n\nexport const AuthorizedOriginResponse = Schema.Struct({\n origin: AuthorizedOrigin,\n});\n\nconst NullableArray = <A, I, R>(schema: Schema.Schema<A, I, R>) =>\n Schema.Union(Schema.Array(schema).pipe(Schema.mutable), Schema.Null).pipe(\n Schema.optional,\n );\n\nexport const AppsAuthResponse = Schema.Struct({\n authorized_redirect_origins: NullableArray(AuthorizedOrigin),\n oauth_service_providers: NullableArray(OAuthServiceProvider),\n oauth_clients: NullableArray(OAuthClient),\n});\n\nexport const getAppsAuth = Effect.fn(function* () {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = (yield* CurrentApp).appId;\n\n return yield* http\n .get(`/dash/apps/${targetAppId}/auth`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AppsAuthResponse)));\n});\n\nexport const addOAuthProvider = Effect.fn(function* (params: {\n appId?: string;\n providerName: string;\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = params.appId ?? (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_service_providers`, {\n body: HttpBody.unsafeJson({\n provider_name: params.providerName,\n }),\n })\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AddOAuthProviderResponse),\n ),\n );\n});\n\nexport const addOAuthClient = Effect.fn(function* (params: {\n appId?: string;\n providerId: string;\n clientName: string;\n clientId?: string;\n clientSecret?: string;\n authorizationEndpoint?: string;\n tokenEndpoint?: string;\n discoveryEndpoint?: string;\n redirectTo?: string;\n meta?: unknown;\n useSharedCredentials?: boolean;\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = params.appId ?? (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_clients`, {\n body: HttpBody.unsafeJson({\n provider_id: params.providerId,\n client_name: params.clientName,\n client_id: params.clientId,\n client_secret: params.clientSecret,\n authorization_endpoint: params.authorizationEndpoint,\n token_endpoint: params.tokenEndpoint,\n discovery_endpoint: params.discoveryEndpoint,\n redirect_to: params.redirectTo,\n meta: params.meta,\n use_shared_credentials: params.useSharedCredentials,\n }),\n })\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)),\n );\n});\n\nexport const updateOAuthClient = Effect.fn(function* (params: {\n oauthClientId: string;\n clientId?: string | null;\n clientSecret?: string | null;\n discoveryEndpoint?: string | null;\n redirectTo?: string | null;\n meta?: unknown;\n useSharedCredentials?: boolean | null;\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_clients/${params.oauthClientId}`, {\n body: HttpBody.unsafeJson({\n client_id: params.clientId,\n client_secret: params.clientSecret,\n discovery_endpoint: params.discoveryEndpoint,\n redirect_to: params.redirectTo,\n meta: params.meta,\n use_shared_credentials: params.useSharedCredentials,\n }),\n })\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)),\n );\n});\n\nexport const getOrCreateProvider = Effect.fn(function* (\n type: typeof ClientTypeSchema.Type,\n) {\n const auth = yield* getAppsAuth();\n const provider = auth.oauth_service_providers?.find(\n (entry) => entry.provider_name === type,\n );\n\n if (provider) {\n return { auth, provider };\n }\n\n const created = yield* addOAuthProvider({ providerName: type });\n return { auth, provider: created.provider };\n});\n\n// Returns prefix if unused; otherwise appends integers starting at 2.\n// e.g. findName('google', new Set(['google', 'google2'])) returns 'google3'.\nexport const findName = (prefix: string, used: Set<string>) => {\n if (!used.has(prefix)) {\n return prefix;\n }\n\n for (let i = 2; ; i++) {\n const candidate = `${prefix}${i}`;\n if (!used.has(candidate)) {\n return candidate;\n }\n }\n};\n\nexport const getClientNameAndProvider = Effect.fn(function* (\n providerType: typeof ClientTypeSchema.Type,\n opts: Record<string, unknown>,\n) {\n const { auth, provider } = yield* getOrCreateProvider(providerType);\n const usedClientNames = new Set(\n (auth.oauth_clients ?? []).map((client) => client.client_name),\n );\n const suggestedClientName = findName(providerType, usedClientNames);\n\n const clientName = yield* Args.text(opts, 'name').pipe(\n Args.prompt({\n prompt: 'Client Name:',\n defaultValue: suggestedClientName,\n placeholder: suggestedClientName,\n validate: validateRequired,\n modifyOutput: UI.modifiers.piped([\n UI.modifiers.topPadding,\n UI.modifiers.dimOnComplete,\n ]),\n }),\n Args.required(),\n );\n\n if (usedClientNames.has(clientName)) {\n return yield* BadArgsError.make({\n message: `The unique name '${clientName}' is already in use.`,\n });\n }\n return { provider, clientName };\n});\n\nexport const findClientByIdOrName = Effect.fn(function* (params: {\n id?: string;\n name?: string;\n}) {\n if (params.id && params.name) {\n return yield* BadArgsError.make({\n message: 'Cannot specify both --id and --name',\n });\n }\n if (!params.id && !params.name) {\n return yield* BadArgsError.make({\n message: 'Must specify --id or --name',\n });\n }\n\n const auth = yield* getAppsAuth();\n const clients = auth.oauth_clients ?? [];\n const client = params.id\n ? clients.find((entry) => entry.id === params.id)\n : clients.find((entry) => entry.client_name === params.name);\n\n if (!client) {\n const lookup = params.id ? `id ${params.id}` : `name ${params.name}`;\n return yield* BadArgsError.make({\n message: `OAuth client not found: ${lookup}`,\n });\n }\n\n return { auth, client };\n});\n\nexport const removeAuthorizedOrigin = Effect.fn(function* (originId: string) {\n const http = (yield* InstantHttpAuthed).pipe(\n withCommand('auth origin delete'),\n );\n const { appId } = yield* CurrentApp;\n\n return yield* http\n .del(`/dash/apps/${appId}/authorized_redirect_origins/${originId}`)\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse),\n ),\n );\n});\n\nexport const addAuthorizedOrigin = Effect.fn(function* (params: {\n service: Schema.Schema.Type<typeof AuthorizedOriginService>;\n params: string[];\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth origin add'));\n const { appId } = yield* CurrentApp;\n\n return yield* http\n .post(`/dash/apps/${appId}/authorized_redirect_origins`, {\n body: HttpBody.unsafeJson({\n service: params.service,\n params: params.params,\n }),\n })\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse),\n ),\n );\n});\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { PlatformApi as InstantPlatformApi } from '@superlayer/platform';
|
|
3
|
+
import { AuthToken } from '../context/authToken.ts';
|
|
4
|
+
export declare const getAuthedPlatformApi: Effect.Effect<InstantPlatformApi, import("../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("effect/ConfigError").ConfigError, AuthToken>;
|
|
5
|
+
//# sourceMappingURL=platformApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformApi.d.ts","sourceRoot":"","sources":["../../src/lib/platformApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,eAAO,MAAM,oBAAoB,wKAK/B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { PlatformApi as InstantPlatformApi } from '@superlayer/platform';
|
|
3
|
+
import { AuthToken } from "../context/authToken.js";
|
|
4
|
+
import { getBaseUrl } from "./config.js";
|
|
5
|
+
export const getAuthedPlatformApi = Effect.gen(function* () {
|
|
6
|
+
const apiURI = yield* getBaseUrl;
|
|
7
|
+
const authToken = yield* AuthToken;
|
|
8
|
+
const token = yield* authToken.getAuthToken;
|
|
9
|
+
return new InstantPlatformApi({ apiURI, auth: { token } });
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=platformApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformApi.js","sourceRoot":"","sources":["../../src/lib/platformApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IACjC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC;IACnC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC;IAC5C,OAAO,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { PlatformApi as InstantPlatformApi } from '@superlayer/platform';\nimport { AuthToken } from '../context/authToken.ts';\nimport { getBaseUrl } from './config.ts';\n\nexport const getAuthedPlatformApi = Effect.gen(function* () {\n const apiURI = yield* getBaseUrl;\n const authToken = yield* AuthToken;\n const token = yield* authToken.getAuthToken;\n return new InstantPlatformApi({ apiURI, auth: { token } });\n});\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { CurrentApp } from '../context/currentApp.ts';
|
|
3
|
+
import { InstantHttpAuthed } from './http.ts';
|
|
4
|
+
import { ProjectInfo } from '../context/projectInfo.ts';
|
|
5
|
+
import { Path } from '@effect/platform';
|
|
6
|
+
export declare const pullPerms: Effect.Effect<void, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("./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 | ProjectInfo | InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | Path.Path | CurrentApp>;
|
|
7
|
+
//# sourceMappingURL=pullPerms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pullPerms.d.ts","sourceRoot":"","sources":["../../src/lib/pullPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAe,MAAM,WAAW,CAAC;AAQ3D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,eAAO,MAAM,SAAS,4fAoCpB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Effect, Option, Schema } from 'effect';
|
|
2
|
+
import { CurrentApp } from "../context/currentApp.js";
|
|
3
|
+
import { InstantHttpAuthed, withCommand } from "./http.js";
|
|
4
|
+
import { HttpClientResponse } from '@effect/platform';
|
|
5
|
+
import { readLocalPermsFile } from '../old.js';
|
|
6
|
+
import { getPermsPathToWrite } from "../util/findConfigCandidates.js";
|
|
7
|
+
import { promptOk } from "./ui.js";
|
|
8
|
+
import { UI } from "../ui/index.js";
|
|
9
|
+
import { writeTypescript } from "./pullSchema.js";
|
|
10
|
+
import { generatePermsTypescriptFile } from '@superlayer/platform';
|
|
11
|
+
import { ProjectInfo } from "../context/projectInfo.js";
|
|
12
|
+
import { Path } from '@effect/platform';
|
|
13
|
+
export const pullPerms = Effect.gen(function* () {
|
|
14
|
+
yield* Effect.log('\nPulling perms...');
|
|
15
|
+
const { appId } = yield* CurrentApp;
|
|
16
|
+
const http = yield* InstantHttpAuthed;
|
|
17
|
+
const permsResponse = yield* http
|
|
18
|
+
.pipe(withCommand('pull'))
|
|
19
|
+
.get(`/dash/apps/${appId}/perms/pull`)
|
|
20
|
+
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any))); // parse result body into "any"
|
|
21
|
+
const prevPermsFile = yield* Effect.tryPromise(readLocalPermsFile).pipe(Effect.map(Option.fromNullable));
|
|
22
|
+
const shortPermsPath = Option.match(prevPermsFile, {
|
|
23
|
+
onSome: (file) => file.path,
|
|
24
|
+
onNone: () => getPermsPathToWrite(),
|
|
25
|
+
});
|
|
26
|
+
if (Option.isSome(prevPermsFile)) {
|
|
27
|
+
const shouldContinue = yield* promptOk({
|
|
28
|
+
promptText: `This will overwrite your local ${shortPermsPath} file, OK to proceed?`,
|
|
29
|
+
modifyOutput: UI.modifiers.yPadding,
|
|
30
|
+
inline: true,
|
|
31
|
+
});
|
|
32
|
+
if (!shouldContinue)
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const { instantModuleName, pkgDir } = yield* ProjectInfo;
|
|
36
|
+
const fileContent = generatePermsTypescriptFile(permsResponse?.perms || {}, instantModuleName);
|
|
37
|
+
const path = yield* Path.Path;
|
|
38
|
+
yield* writeTypescript(path.join(pkgDir, shortPermsPath), fileContent);
|
|
39
|
+
yield* Effect.log('✅ Wrote permissions to ' + shortPermsPath);
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=pullPerms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pullPerms.js","sourceRoot":"","sources":["../../src/lib/pullPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC3C,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG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AClB,CAAC;IAEF,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAE9B,KAAK,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,WAAW,CAAC,CAAC;IACvE,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,GAAG,cAAc,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC","sourcesContent":["import { Effect, Option, Schema } from 'effect';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { InstantHttpAuthed, withCommand } from './http.ts';\nimport { HttpClientResponse } from '@effect/platform';\nimport { readLocalPermsFile } from '../old.js';\nimport { getPermsPathToWrite } from '../util/findConfigCandidates.ts';\nimport { promptOk } from './ui.ts';\nimport { UI } from '../ui/index.ts';\nimport { writeTypescript } from './pullSchema.ts';\nimport { generatePermsTypescriptFile } from '@superlayer/platform';\nimport { ProjectInfo } from '../context/projectInfo.ts';\nimport { Path } from '@effect/platform';\n\nexport const pullPerms = Effect.gen(function* () {\n yield* Effect.log('\\nPulling perms...');\n const { appId } = yield* CurrentApp;\n const http = yield* InstantHttpAuthed;\n const permsResponse = yield* http\n .pipe(withCommand('pull'))\n .get(`/dash/apps/${appId}/perms/pull`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any))); // parse result body into \"any\"\n\n const prevPermsFile = yield* Effect.tryPromise(readLocalPermsFile).pipe(\n Effect.map(Option.fromNullable),\n );\n\n const shortPermsPath = Option.match(prevPermsFile, {\n onSome: (file) => file.path,\n onNone: () => getPermsPathToWrite(),\n });\n\n if (Option.isSome(prevPermsFile)) {\n const shouldContinue = yield* promptOk({\n promptText: `This will overwrite your local ${shortPermsPath} file, OK to proceed?`,\n modifyOutput: UI.modifiers.yPadding,\n inline: true,\n });\n if (!shouldContinue) return;\n }\n const { instantModuleName, pkgDir } = yield* ProjectInfo;\n const fileContent = generatePermsTypescriptFile(\n permsResponse?.perms || {},\n instantModuleName,\n );\n\n const path = yield* Path.Path;\n\n yield* writeTypescript(path.join(pkgDir, shortPermsPath), fileContent);\n yield* Effect.log('✅ Wrote permissions to ' + shortPermsPath);\n});\n"]}
|