alpic 1.142.1 → 1.142.3

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.
Files changed (49) hide show
  1. package/dist/__tests__/alpic-command.test.js +8 -4
  2. package/dist/__tests__/alpic-command.test.js.map +1 -1
  3. package/dist/__tests__/auth.e2e.test.js +3 -1
  4. package/dist/__tests__/auth.e2e.test.js.map +1 -1
  5. package/dist/api.d.ts +1 -1
  6. package/dist/api.js +2 -21
  7. package/dist/api.js.map +1 -1
  8. package/dist/commands/login.js +7 -5
  9. package/dist/commands/login.js.map +1 -1
  10. package/dist/commands/logout.js +1 -1
  11. package/dist/commands/logout.js.map +1 -1
  12. package/dist/commands/tunnel.js +27 -111
  13. package/dist/commands/tunnel.js.map +1 -1
  14. package/dist/commands/whoami.js +1 -1
  15. package/dist/commands/whoami.js.map +1 -1
  16. package/dist/lib/alpic-command.js +5 -3
  17. package/dist/lib/alpic-command.js.map +1 -1
  18. package/dist/lib/alpic-sdk.d.ts +2 -0
  19. package/dist/lib/alpic-sdk.js +9 -0
  20. package/dist/lib/alpic-sdk.js.map +1 -0
  21. package/dist/lib/telemetry.js +1 -1
  22. package/dist/lib/telemetry.js.map +1 -1
  23. package/dist/lib/{auth/whoami.js → whoami.js} +2 -2
  24. package/dist/lib/whoami.js.map +1 -0
  25. package/package.json +12 -15
  26. package/dist/lib/auth/auth.d.ts +0 -5
  27. package/dist/lib/auth/auth.js +0 -50
  28. package/dist/lib/auth/auth.js.map +0 -1
  29. package/dist/lib/auth/oauth/client.d.ts +0 -28
  30. package/dist/lib/auth/oauth/client.js +0 -116
  31. package/dist/lib/auth/oauth/client.js.map +0 -1
  32. package/dist/lib/auth/oauth/constants.d.ts +0 -2
  33. package/dist/lib/auth/oauth/constants.js +0 -3
  34. package/dist/lib/auth/oauth/constants.js.map +0 -1
  35. package/dist/lib/auth/oauth/server/assets/alpic-mountain.png +0 -0
  36. package/dist/lib/auth/oauth/server/assets/authorize.html +0 -234
  37. package/dist/lib/auth/oauth/server/assets/callback.html +0 -88
  38. package/dist/lib/auth/oauth/server/index.d.ts +0 -9
  39. package/dist/lib/auth/oauth/server/index.js +0 -128
  40. package/dist/lib/auth/oauth/server/index.js.map +0 -1
  41. package/dist/lib/auth/whoami.js.map +0 -1
  42. package/dist/lib/global-store.d.ts +0 -28
  43. package/dist/lib/global-store.js +0 -76
  44. package/dist/lib/global-store.js.map +0 -1
  45. package/dist/lib/vendor/pipenet.d.ts +0 -1
  46. package/dist/lib/vendor/pipenet.js +0 -16877
  47. package/dist/lib/vendor/pipenet.js.LEGAL.txt +0 -17
  48. package/dist/lib/vendor/pipenet.js.map +0 -7
  49. /package/dist/lib/{auth/whoami.d.ts → whoami.d.ts} +0 -0
@@ -1,50 +0,0 @@
1
- import * as p from "@clack/prompts";
2
- import chalk from "chalk";
3
- import open from "open";
4
- import { globalStore } from "../global-store.js";
5
- import { aliasMachineToUser } from "../telemetry.js";
6
- import { getOAuthClient } from "./oauth/client.js";
7
- import { getLoginPageUrl, listenToOAuthCallback } from "./oauth/server/index.js";
8
- export async function getApiToken() {
9
- const token = process.env.ALPIC_API_KEY ?? (await getOAuthClient().getValidAccessToken())?.access_token;
10
- return token;
11
- }
12
- export async function isAuthenticated() {
13
- const isAuthenticatedViaApiKey = hasApiKey();
14
- if (isAuthenticatedViaApiKey) {
15
- return true;
16
- }
17
- const isAuthenticatedViaOAuth = await hasValidAccessToken();
18
- if (isAuthenticatedViaOAuth) {
19
- return true;
20
- }
21
- return false;
22
- }
23
- function hasApiKey() {
24
- return process.env.ALPIC_API_KEY !== undefined;
25
- }
26
- async function hasValidAccessToken() {
27
- return (await getOAuthClient().getValidAccessToken()) !== null;
28
- }
29
- export async function oauthLogin(opts) {
30
- const { authorizeUrl, state, nonce, codeVerifier } = await getOAuthClient().prepareOAuthConfig();
31
- const loginUrl = getLoginPageUrl();
32
- if (opts?.isPlain) {
33
- console.log(`Opening browser to log in: ${loginUrl}`);
34
- }
35
- else {
36
- p.log.message(`Opening browser to log in…\n\nIf the browser does not open, copy this URL: ${chalk.cyan(loginUrl)}`);
37
- }
38
- if (!process.env.ALPIC_NO_OPEN) {
39
- await open(loginUrl);
40
- }
41
- const storedToken = await listenToOAuthCallback({
42
- state,
43
- nonce,
44
- codeVerifier,
45
- authorizeUrl: authorizeUrl.toString(),
46
- });
47
- globalStore.saveCredentials(storedToken);
48
- await aliasMachineToUser(storedToken.sub);
49
- }
50
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,MAAM,cAAc,EAAE,CAAC,mBAAmB,EAAE,CAAC,EAAE,YAAY,CAAC;IAExG,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,wBAAwB,GAAG,SAAS,EAAE,CAAC;IAC7C,IAAI,wBAAwB,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,uBAAuB,GAAG,MAAM,mBAAmB,EAAE,CAAC;IAC5D,IAAI,uBAAuB,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC;AACjD,CAAC;AAED,KAAK,UAAU,mBAAmB;IAChC,OAAO,CAAC,MAAM,cAAc,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,IAAI,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAA4B;IAC3D,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,cAAc,EAAE,CAAC,kBAAkB,EAAE,CAAC;IAEjG,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,8EAA8E,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACtH,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAC/B,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,qBAAqB,CAAC;QAC9C,KAAK;QACL,KAAK;QACL,YAAY;QACZ,YAAY,EAAE,YAAY,CAAC,QAAQ,EAAE;KACtC,CAAC,CAAC;IAEH,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAEzC,MAAM,kBAAkB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,28 +0,0 @@
1
- import * as openid from "openid-client";
2
- import { type Credentials } from "../../global-store.js";
3
- export declare class OAuthClient {
4
- private config;
5
- initialize: Promise<void>;
6
- constructor();
7
- getValidAccessToken(): Promise<Credentials | null>;
8
- fetchUserInfo(credentials: Credentials): Promise<openid.UserInfoResponse>;
9
- refreshAccessToken(credentials: Credentials): Promise<Credentials>;
10
- prepareOAuthConfig(): Promise<{
11
- authorizeUrl: URL;
12
- state: string;
13
- nonce: string;
14
- codeVerifier: string;
15
- }>;
16
- exchangeAuthorizationCode({ url, codeVerifier, state, nonce, }: {
17
- url: URL;
18
- codeVerifier: string;
19
- state: string;
20
- nonce: string;
21
- }): Promise<openid.TokenEndpointResponse & openid.TokenEndpointResponseHelpers>;
22
- getExpiresAt(expires_in: number): number;
23
- private loadConfig;
24
- private fetchOAuthProtectedResourceConfig;
25
- private getConfig;
26
- private isAccessTokenExpired;
27
- }
28
- export declare function getOAuthClient(): OAuthClient;
@@ -1,116 +0,0 @@
1
- import * as openid from "openid-client";
2
- import { env } from "../../../env.js";
3
- import { globalStore } from "../../global-store.js";
4
- import { LOOPBACK_HOST, LOOPBACK_PORT } from "./constants.js";
5
- const SCOPES = ["openid", "email", "profile"];
6
- export class OAuthClient {
7
- config = null;
8
- initialize;
9
- constructor() {
10
- this.initialize = this.loadConfig();
11
- }
12
- async getValidAccessToken() {
13
- await this.initialize;
14
- const stored = globalStore.getCredentials();
15
- if (!stored) {
16
- return null;
17
- }
18
- if (this.isAccessTokenExpired(stored)) {
19
- try {
20
- return await this.refreshAccessToken(stored);
21
- }
22
- catch {
23
- return null;
24
- }
25
- }
26
- return stored;
27
- }
28
- async fetchUserInfo(credentials) {
29
- return openid.fetchUserInfo(await this.getConfig(), credentials.access_token, credentials.sub);
30
- }
31
- async refreshAccessToken(credentials) {
32
- if (!credentials.refresh_token) {
33
- throw new Error("No refresh token available");
34
- }
35
- const response = await openid.refreshTokenGrant(await this.getConfig(), credentials.refresh_token);
36
- const refreshed = {
37
- access_token: response.access_token,
38
- refresh_token: response.refresh_token ?? credentials.refresh_token,
39
- expires_at: this.getExpiresAt(response.expires_in ?? 0),
40
- sub: credentials.sub,
41
- };
42
- globalStore.saveCredentials(refreshed);
43
- return refreshed;
44
- }
45
- async prepareOAuthConfig() {
46
- await this.initialize;
47
- if (!this.config) {
48
- throw new Error("Config not loaded");
49
- }
50
- const codeVerifier = openid.randomPKCECodeVerifier();
51
- const codeChallenge = await openid.calculatePKCECodeChallenge(codeVerifier);
52
- const state = openid.randomState();
53
- const nonce = openid.randomNonce();
54
- const callbackUrl = new URL(`http://${LOOPBACK_HOST}:${LOOPBACK_PORT}/callback`);
55
- const authorizeUrl = openid.buildAuthorizationUrl(this.config, {
56
- redirect_uri: callbackUrl.toString(),
57
- scope: SCOPES.join(" "),
58
- code_challenge: codeChallenge,
59
- code_challenge_method: "S256",
60
- state,
61
- nonce,
62
- });
63
- return { authorizeUrl, state, nonce, codeVerifier };
64
- }
65
- async exchangeAuthorizationCode({ url, codeVerifier, state, nonce, }) {
66
- return await openid.authorizationCodeGrant(await this.getConfig(), url, {
67
- pkceCodeVerifier: codeVerifier,
68
- expectedState: state,
69
- expectedNonce: nonce,
70
- });
71
- }
72
- getExpiresAt(expires_in) {
73
- return expires_in !== undefined ? Math.floor(Date.now() / 1000) + expires_in : Date.now() / 1000 + 3600;
74
- }
75
- async loadConfig() {
76
- const protectedResourceConfig = await this.fetchOAuthProtectedResourceConfig();
77
- const issuer = protectedResourceConfig.authorization_servers[0];
78
- if (!issuer) {
79
- throw new Error("No authorization server in OAuth protected resource config");
80
- }
81
- const issuerUrl = new URL(issuer);
82
- try {
83
- this.config = await openid.discovery(issuerUrl, env.ALPIC_COGNITO_CLIENT_ID);
84
- }
85
- catch {
86
- throw new Error("Failed to discover OAuth config");
87
- }
88
- }
89
- async fetchOAuthProtectedResourceConfig() {
90
- const baseUrl = env.ALPIC_API_BASE_URL;
91
- const response = await fetch(`${baseUrl}/.well-known/oauth-protected-resource`);
92
- if (!response.ok) {
93
- throw new Error(`Failed to load service config from ${baseUrl} (${response.status} ${response.statusText})`);
94
- }
95
- return (await response.json());
96
- }
97
- async getConfig() {
98
- await this.initialize;
99
- if (!this.config) {
100
- throw new Error("Config not loaded");
101
- }
102
- return this.config;
103
- }
104
- isAccessTokenExpired(credentials) {
105
- const EXPIRATION_WINDOW_IN_SECONDS = 300;
106
- return Date.now() / 1000 + EXPIRATION_WINDOW_IN_SECONDS >= credentials.expires_at;
107
- }
108
- }
109
- let _oAuthClient = null;
110
- export function getOAuthClient() {
111
- if (!_oAuthClient) {
112
- _oAuthClient = new OAuthClient();
113
- }
114
- return _oAuthClient;
115
- }
116
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/auth/oauth/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAU9C,MAAM,OAAO,WAAW;IACd,MAAM,GAAgC,IAAI,CAAC;IACnD,UAAU,CAAgB;IAE1B;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,MAAM,IAAI,CAAC,UAAU,CAAC;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,cAAc,EAAE,CAAC;QAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC/C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED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@
1
- export declare const LOOPBACK_HOST = "127.0.0.1";
2
- export declare const LOOPBACK_PORT = 38472;
@@ -1,3 +0,0 @@
1
- export const LOOPBACK_HOST = "127.0.0.1";
2
- export const LOOPBACK_PORT = 38472;
3
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/auth/oauth/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AACzC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC"}
@@ -1,234 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Sign in to Alpic</title>
7
- <link
8
- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Mozilla+Text:wght@200..700&display=swap"
9
- rel="stylesheet"
10
- />
11
- <style>
12
- *,
13
- *::before,
14
- *::after {
15
- margin: 0;
16
- padding: 0;
17
- box-sizing: border-box;
18
- }
19
-
20
- :root {
21
- --midnight: #051413;
22
- }
23
-
24
- body {
25
- font-family: "Inter", system-ui, sans-serif;
26
- background-color: var(--midnight);
27
- min-height: 100vh;
28
- display: flex;
29
- background-image: url("/assets/alpic-mountain.png");
30
- background-repeat: no-repeat;
31
- background-position: right bottom;
32
- background-size: auto;
33
- padding: 64px;
34
- }
35
-
36
- .card {
37
- background: #fff;
38
- border-radius: 2px;
39
- padding: 48px;
40
- width: 50%;
41
- min-height: calc(100vh - 128px);
42
- display: flex;
43
- flex-direction: column;
44
- align-items: center;
45
- justify-content: center;
46
- }
47
-
48
- h1 {
49
- font-family: "Mozilla Text", system-ui, sans-serif;
50
- font-weight: 400;
51
- font-size: 48px;
52
- color: var(--midnight);
53
- margin-bottom: 8px;
54
- }
55
-
56
- .subtitle {
57
- font-size: 20px;
58
- color: var(--midnight);
59
- margin-bottom: 32px;
60
- }
61
-
62
- .buttons {
63
- display: flex;
64
- flex-direction: column;
65
- gap: 12px;
66
- }
67
-
68
- .btn {
69
- display: flex;
70
- align-items: center;
71
- justify-content: center;
72
- gap: 8px;
73
- height: 48px;
74
- width: 256px;
75
- padding: 0 16px;
76
- border-radius: 2px;
77
- border: 1px solid var(--midnight);
78
- font-family: "Inter", system-ui, sans-serif;
79
- font-size: 16px;
80
- font-weight: 500;
81
- cursor: pointer;
82
- transition: background 0.15s;
83
- }
84
-
85
- .btn:focus-visible {
86
- outline: none;
87
- box-shadow: 0 0 0 2px var(--midnight);
88
- }
89
-
90
- .btn svg {
91
- width: 20px;
92
- height: 20px;
93
- flex-shrink: 0;
94
- }
95
-
96
- .btn-github {
97
- background: var(--midnight);
98
- color: #fff;
99
- }
100
- .btn-github svg {
101
- fill: #fff;
102
- }
103
- .btn-github:hover {
104
- background: rgba(5, 20, 19, 0.9);
105
- }
106
-
107
- .btn-google {
108
- background: #fff;
109
- color: var(--midnight);
110
- }
111
- .btn-google svg {
112
- fill: var(--midnight);
113
- }
114
- .btn-google:hover {
115
- background: rgba(5, 20, 19, 0.1);
116
- }
117
-
118
- .btn-sso {
119
- background: none;
120
- border: none;
121
- color: rgba(5, 20, 19, 0.6);
122
- font-size: 14px;
123
- font-weight: 500;
124
- height: 32px;
125
- width: auto;
126
- padding: 0 8px;
127
- gap: 4px;
128
- border-radius: 6px;
129
- }
130
- .btn-sso svg {
131
- width: 16px;
132
- height: 16px;
133
- stroke: rgba(5, 20, 19, 0.6);
134
- fill: none;
135
- }
136
- .btn-sso:hover {
137
- background: rgba(5, 20, 19, 0.06);
138
- color: var(--midnight);
139
- }
140
- .btn-sso:hover svg {
141
- stroke: var(--midnight);
142
- }
143
-
144
- .btn-loading {
145
- opacity: 0.7;
146
- pointer-events: none;
147
- cursor: default;
148
- transition: opacity 0.2s;
149
- }
150
- .spinner {
151
- width: 20px;
152
- height: 20px;
153
- animation: spin 0.8s linear infinite;
154
- }
155
- @keyframes spin {
156
- to {
157
- transform: rotate(360deg);
158
- }
159
- }
160
-
161
- @media (max-width: 768px) {
162
- body {
163
- padding: 16px;
164
- }
165
- .card {
166
- width: 100%;
167
- height: auto;
168
- padding: 24px;
169
- }
170
- h1 {
171
- font-size: 36px;
172
- }
173
- .subtitle {
174
- font-size: 18px;
175
- }
176
- }
177
- </style>
178
- </head>
179
- <body>
180
- <div class="card">
181
- <h1>Welcome to Alpic</h1>
182
- <p class="subtitle">Sign in to use Alpic CLI</p>
183
- <div class="buttons">
184
- <button class="btn btn-github" onclick="login('Github', this)" type="button">
185
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
186
- <title>GitHub</title>
187
- <path
188
- d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"
189
- />
190
- </svg>
191
- Sign in with GitHub
192
- </button>
193
- <button class="btn btn-google" onclick="login('google', this)" type="button">
194
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
195
- <title>Google</title>
196
- <path
197
- d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.8 4.133-1.147 1.147-2.933 2.4-6.04 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"
198
- />
199
- </svg>
200
- Sign in with Google
201
- </button>
202
- <button class="btn btn-sso" onclick="login('WorkOS', this)" type="button">
203
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
204
- <title>SSO</title>
205
- <path d="M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z" />
206
- <path d="M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2" />
207
- <path d="M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2" />
208
- <path d="M10 6h4" />
209
- <path d="M10 10h4" />
210
- <path d="M10 14h4" />
211
- <path d="M10 18h4" />
212
- </svg>
213
- Sign in with SSO
214
- </button>
215
- </div>
216
- </div>
217
- <script>
218
- var loaderSvg =
219
- '<svg class="spinner" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>';
220
- // biome-ignore lint/correctness/noUnusedVariables: The function is used within the buttons onclick handlers
221
- function login(provider, btn) {
222
- const icon = btn.querySelector("svg");
223
- const wrap = document.createElement("div");
224
- wrap.innerHTML = loaderSvg;
225
- icon.replaceWith(wrap.firstChild);
226
- btn.classList.add("btn-loading");
227
- btn.disabled = true;
228
- const url = new URL("%AUTH_BASE_URL%");
229
- url.searchParams.set("identity_provider", provider);
230
- window.location.href = url.toString();
231
- }
232
- </script>
233
- </body>
234
- </html>
@@ -1,88 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Sign in to Alpic</title>
7
- <link
8
- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Mozilla+Text:wght@200..700&display=swap"
9
- rel="stylesheet"
10
- />
11
- <style>
12
- *,
13
- *::before,
14
- *::after {
15
- margin: 0;
16
- padding: 0;
17
- box-sizing: border-box;
18
- }
19
-
20
- :root {
21
- --midnight: #051413;
22
- }
23
-
24
- body {
25
- font-family: "Inter", system-ui, sans-serif;
26
- background-color: var(--midnight);
27
- min-height: 100vh;
28
- display: flex;
29
- align-items: center;
30
- justify-content: center;
31
- padding: 64px;
32
- }
33
-
34
- .card {
35
- background: #fff;
36
- border-radius: 2px;
37
- padding: 48px;
38
- display: flex;
39
- flex-direction: column;
40
- align-items: center;
41
- justify-content: center;
42
- }
43
-
44
- .message {
45
- text-align: center;
46
- }
47
-
48
- .message-title {
49
- font-size: 28px;
50
- color: var(--midnight);
51
- display: block;
52
- }
53
-
54
- .message-sub {
55
- display: block;
56
- margin-top: 0.5em;
57
- color: #6b7280;
58
- }
59
-
60
- .message.error .message-title {
61
- color: #b91c1c;
62
- }
63
-
64
- .message.error .message-sub {
65
- display: none;
66
- }
67
-
68
- @media (max-width: 768px) {
69
- body {
70
- padding: 16px;
71
- }
72
- .card {
73
- width: 100%;
74
- height: auto;
75
- padding: 24px;
76
- }
77
- }
78
- </style>
79
- </head>
80
- <body>
81
- <div class="card">
82
- <p class="message __CALLBACK_STATUS__">
83
- <span class="message-title">__CALLBACK_TITLE__</span>
84
- <span class="message-sub">__CALLBACK_SUB__</span>
85
- </p>
86
- </div>
87
- </body>
88
- </html>
@@ -1,9 +0,0 @@
1
- import type { Credentials } from "../../../global-store.js";
2
- export declare const getLoginPageUrl: () => string;
3
- export declare const listenToOAuthCallback: ({ state, nonce, codeVerifier, authorizeUrl, isPlain, }: {
4
- state: string;
5
- nonce: string;
6
- codeVerifier: string;
7
- authorizeUrl?: string;
8
- isPlain?: boolean;
9
- }) => Promise<Credentials>;