@junobuild/core-peer 3.4.1 → 4.0.0

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.
@@ -0,0 +1,14 @@
1
+ import type { GitHubSignInRedirectOptions } from '../types/github';
2
+ export declare class GitHubProvider {
3
+ /**
4
+ * Initiates a GitHub sign-in flow.
5
+ *
6
+ * @param {Object} params - Parameters for the sign-in request.
7
+ * @param {GitHubSignInRedirectOptions} [params.options] - Optional configuration for the sign-in request.
8
+ *
9
+ * @returns {Promise<void>} Resolves once the sign-in flow has been initiated.
10
+ */
11
+ signIn({ options }: {
12
+ options?: GitHubSignInRedirectOptions;
13
+ }): Promise<void>;
14
+ }
@@ -1 +1,2 @@
1
- export declare const handleRedirectCallback: () => Promise<void>;
1
+ import type { HandleRedirectCallbackOptions } from '../types/auth';
2
+ export declare const handleRedirectCallback: (options: HandleRedirectCallbackOptions) => Promise<void>;
@@ -1,3 +1,4 @@
1
+ import type { GitHubHandleRedirectCallbackOptions, GitHubSignInRedirectOptions } from './github';
1
2
  import type { GoogleSignInRedirectOptions } from './google';
2
3
  import type { InternetIdentitySignInOptions } from './internet-identity';
3
4
  import type { WebAuthnSignInOptions, WebAuthnSignUpOptions } from './webauthn';
@@ -19,6 +20,7 @@ export interface SignInContext {
19
20
  * Defines which provider to use for signing in and its associated options.
20
21
  *
21
22
  * - `google` — Google sign-in
23
+ * - `github` — GitHub sign-in
22
24
  * - `internet_identity` — Internet Identity
23
25
  * - `webauthn` — WebAuthn/Passkeys
24
26
  */
@@ -26,6 +28,10 @@ export type SignInOptions = {
26
28
  google: {
27
29
  options?: GoogleSignInRedirectOptions;
28
30
  };
31
+ } | {
32
+ github: {
33
+ options?: GitHubSignInRedirectOptions;
34
+ };
29
35
  } | {
30
36
  internet_identity: {
31
37
  options?: InternetIdentitySignInOptions;
@@ -60,3 +66,16 @@ export interface SignOutOptions {
60
66
  */
61
67
  windowReload?: boolean;
62
68
  }
69
+ /**
70
+ * Defines which redirect should be handled.
71
+ *
72
+ * - `google`: Google sign-in
73
+ * - `github`: GitHub sign-in
74
+ */
75
+ export type HandleRedirectCallbackOptions = {
76
+ google: null;
77
+ } | {
78
+ github: {
79
+ options: GitHubHandleRedirectCallbackOptions;
80
+ } | null;
81
+ };
@@ -0,0 +1,56 @@
1
+ export type AuthScope = 'openid' | 'profile' | 'email';
2
+ /**
3
+ * Combination of OAuth scopes supported by GitHub.
4
+ *
5
+ * - `'read:user'` is always required.
6
+ * - `'user:email'` is optional.
7
+ *
8
+ * @see https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
9
+ */
10
+ export type GitHubAuthScopes = ['read:user', 'user:email'] | ['read:user'];
11
+ /**
12
+ * Sign-in options for the GitHub provider using a redirect flow.
13
+ * @interface GitHubSignInRedirectOptions
14
+ */
15
+ export interface GitHubSignInRedirectOptions {
16
+ /**
17
+ * Redirect configuration.
18
+ */
19
+ redirect?: GitHubRedirectOptions;
20
+ }
21
+ /**
22
+ * Redirect options for GitHub sign-in.
23
+ */
24
+ export interface GitHubRedirectOptions {
25
+ /**
26
+ * GitHub OAuth client ID.
27
+ * If omitted, the library attempts to read it from `juno.config`.
28
+ */
29
+ clientId?: string;
30
+ /**
31
+ * OAuth scopes to request.
32
+ * Must begin with `'openid'` and include `'profile'`, `'email'`, or both.
33
+ * @default ['openid', 'profile', 'email']
34
+ */
35
+ authScopes?: GitHubAuthScopes;
36
+ /**
37
+ * Redirect URL after authentication.
38
+ * @default window.location.origin
39
+ */
40
+ redirectUrl?: string;
41
+ /**
42
+ * Initialization URL. Useful for local development or to interact with a self-hosted API.
43
+ * @default https://api.juno.build/v1/auth/init/github
44
+ */
45
+ initUrl?: string;
46
+ }
47
+ /**
48
+ * Options for handling GitHub redirect callback.
49
+ */
50
+ export interface GitHubHandleRedirectCallbackOptions {
51
+ /**
52
+ * Finalization URL. Useful for local development or to interact with a self-hosted API.
53
+ * @default https://api.juno.build/v1/auth/finalize/github
54
+ */
55
+ finalizeUrl?: string;
56
+ }
@@ -1,4 +1,3 @@
1
- export type AuthScope = 'openid' | 'profile' | 'email';
2
1
  /**
3
2
  * Combination of OAuth scopes supported by Google.
4
3
  *
@@ -0,0 +1,3 @@
1
+ export declare const parseOptionalUrl: ({ url }: {
2
+ url: string;
3
+ }) => URL | null;
@@ -1,3 +1,5 @@
1
1
  export declare const envSatelliteId: () => string | undefined;
2
2
  export declare const envContainer: () => string | undefined;
3
3
  export declare const envGoogleClientId: () => string | undefined;
4
+ export declare const envGitHubClientId: () => string | undefined;
5
+ export declare const envApiUrl: () => string | undefined;
@@ -12,10 +12,13 @@ export { signUp } from './auth/services/sign-up.services';
12
12
  export type * from './auth/types/auth';
13
13
  export * from './auth/types/auth-client';
14
14
  export * from './auth/types/errors';
15
+ export type * from './auth/types/github';
16
+ export type * from './auth/types/google';
17
+ export type * from './auth/types/internet-identity';
15
18
  export type * from './auth/types/progress';
16
19
  export type * from './auth/types/provider';
17
20
  export type * from './auth/types/user';
18
- export * from './auth/types/webauthn';
21
+ export type * from './auth/types/webauthn';
19
22
  export * from './auth/utils/user.utils';
20
23
  export type * from './core/types/env';
21
24
  export { ListOrder, ListPaginate, ListParams, ListResults } from './core/types/list';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/core-peer",
3
- "version": "3.4.1",
3
+ "version": "4.0.0",
4
4
  "description": "JavaScript core client for Juno (deprecated, use @junobuild/core)",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  ],
55
55
  "homepage": "https://juno.build",
56
56
  "dependencies": {
57
- "@junobuild/auth": "^2.1",
57
+ "@junobuild/auth": "^3",
58
58
  "@junobuild/errors": "*",
59
59
  "@junobuild/ic-client": "^7.1",
60
60
  "@junobuild/storage": "^2.2",