@atlasauth/js 0.1.3 → 0.1.4

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.
@@ -13,7 +13,22 @@
13
13
  * must not treat that as signed-in. Parsing this is pure and lives here so both
14
14
  * the React provider and any custom integration read the exact same contract.
15
15
  */
16
+ import type { FapiClient } from './fapi';
16
17
  export declare const REDIRECT_PARAMS: readonly ["__atlas_attempt", "__atlas_ticket", "__atlas_status"];
18
+ /**
19
+ * Start a redirect-based OAuth sign-in for a provider that has no in-page native
20
+ * flow (GitHub, Microsoft, Discord, …). Returns the provider authorization URL to
21
+ * navigate to; the provider redirects back to `redirectUrl` with the params
22
+ * {@link readRedirectResult} parses. A `native:true` provider (Google/Apple/FB
23
+ * Limited Login) should use the in-page id_token flow instead — no redirect, no
24
+ * stranded tab. Returns null if the start failed.
25
+ */
26
+ export declare function startOauthRedirect(client: FapiClient, input: {
27
+ provider: string;
28
+ redirectUrl: string;
29
+ }): Promise<{
30
+ authorizationUrl: string;
31
+ } | null>;
17
32
  export interface RedirectResult {
18
33
  attemptId: string;
19
34
  /** Present only when the sign-in completed — exchange it for cookies. */
package/dist/redirect.js CHANGED
@@ -16,9 +16,26 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.REDIRECT_PARAMS = void 0;
19
+ exports.startOauthRedirect = startOauthRedirect;
19
20
  exports.readRedirectResult = readRedirectResult;
20
21
  exports.stripRedirectParams = stripRedirectParams;
21
22
  exports.REDIRECT_PARAMS = ['__atlas_attempt', '__atlas_ticket', '__atlas_status'];
23
+ /**
24
+ * Start a redirect-based OAuth sign-in for a provider that has no in-page native
25
+ * flow (GitHub, Microsoft, Discord, …). Returns the provider authorization URL to
26
+ * navigate to; the provider redirects back to `redirectUrl` with the params
27
+ * {@link readRedirectResult} parses. A `native:true` provider (Google/Apple/FB
28
+ * Limited Login) should use the in-page id_token flow instead — no redirect, no
29
+ * stranded tab. Returns null if the start failed.
30
+ */
31
+ async function startOauthRedirect(client, input) {
32
+ const res = await client.post('/v1/client/sign_ins/oauth', {
33
+ provider: input.provider,
34
+ redirect_url: input.redirectUrl,
35
+ });
36
+ const url = res.ok ? res.data?.authorization_url : undefined;
37
+ return url ? { authorizationUrl: url } : null;
38
+ }
22
39
  /**
23
40
  * Read Atlas's redirect params from a query string (`window.location.search`).
24
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../src/redirect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAmBH,gDAcC;AAQD,kDAIC;AA3CY,QAAA,eAAe,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,CAAU,CAAC;AAUhG;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAChD,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5C,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEpC,OAAO;QACL,SAAS;QACT,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC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