@aura-stack/auth 0.1.0 → 0.2.0-rc.1
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/dist/@types/index.d.ts +5 -5
- package/dist/@types/router.d.d.ts +5 -5
- package/dist/@types/utility.d.ts +1 -5
- package/dist/actions/callback/access-token.cjs +95 -74
- package/dist/actions/callback/access-token.d.ts +7 -7
- package/dist/actions/callback/access-token.js +5 -3
- package/dist/actions/callback/callback.cjs +171 -249
- package/dist/actions/callback/callback.d.ts +6 -6
- package/dist/actions/callback/callback.js +10 -10
- package/dist/actions/callback/userinfo.cjs +81 -57
- package/dist/actions/callback/userinfo.d.ts +5 -5
- package/dist/actions/callback/userinfo.js +7 -5
- package/dist/actions/csrfToken/csrfToken.cjs +36 -105
- package/dist/actions/csrfToken/csrfToken.js +6 -6
- package/dist/actions/index.cjs +309 -444
- package/dist/actions/index.d.ts +5 -5
- package/dist/actions/index.js +19 -19
- package/dist/actions/session/session.cjs +25 -109
- package/dist/actions/session/session.js +4 -5
- package/dist/actions/signIn/authorization.cjs +96 -87
- package/dist/actions/signIn/authorization.d.ts +5 -5
- package/dist/actions/signIn/authorization.js +5 -5
- package/dist/actions/signIn/signIn.cjs +133 -242
- package/dist/actions/signIn/signIn.d.ts +6 -6
- package/dist/actions/signIn/signIn.js +8 -9
- package/dist/actions/signOut/signOut.cjs +136 -282
- package/dist/actions/signOut/signOut.js +8 -9
- package/dist/assert.cjs +5 -0
- package/dist/assert.d.ts +10 -1
- package/dist/assert.js +3 -1
- package/dist/chunk-3EUWD5BB.js +63 -0
- package/dist/chunk-6R2YZ4AC.js +22 -0
- package/dist/chunk-A3N4PVAT.js +70 -0
- package/dist/chunk-B737EUJV.js +22 -0
- package/dist/{chunk-256KIVJL.js → chunk-CXLATHS5.js} +53 -9
- package/dist/{chunk-6SM22VVJ.js → chunk-EIL2FPSS.js} +5 -1
- package/dist/{chunk-VFTYH33W.js → chunk-EMKJA2GJ.js} +36 -8
- package/dist/{chunk-UJJ7R56J.js → chunk-GA2SMTJO.js} +16 -10
- package/dist/chunk-HP34YGGJ.js +22 -0
- package/dist/chunk-HT4YLL7N.js +35 -0
- package/dist/{chunk-EBPE35JT.js → chunk-IUYZQTJV.js} +0 -1
- package/dist/{chunk-RLT4RFKV.js → chunk-IVET23KF.js} +21 -8
- package/dist/{chunk-XXJKNKGQ.js → chunk-JVFTCTTE.js} +9 -13
- package/dist/chunk-KSWLO5ZU.js +102 -0
- package/dist/{chunk-GZU3RBTB.js → chunk-N2APGLXA.js} +19 -10
- package/dist/{chunk-CAKJT3KS.js → chunk-N4SX7TZT.js} +21 -17
- package/dist/chunk-RRLIF4PQ.js +55 -0
- package/dist/chunk-TLE4PXY3.js +39 -0
- package/dist/chunk-W6LG7BFW.js +197 -0
- package/dist/{chunk-HMRKN75I.js → chunk-YRCB5FLE.js} +14 -9
- package/dist/chunk-ZNCZVF6U.js +14 -0
- package/dist/cookie.cjs +140 -99
- package/dist/cookie.d.ts +35 -44
- package/dist/cookie.js +10 -17
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.ts +49 -0
- package/dist/errors.js +18 -0
- package/dist/{index-DpfbvTZ_.d.ts → index-DkaLJFn8.d.ts} +192 -61
- package/dist/index.cjs +543 -443
- package/dist/index.d.ts +6 -6
- package/dist/index.js +42 -28
- package/dist/jose.cjs +25 -14
- package/dist/jose.d.ts +4 -1
- package/dist/jose.js +5 -4
- package/dist/oauth/bitbucket.d.ts +5 -5
- package/dist/oauth/discord.cjs +0 -1
- package/dist/oauth/discord.d.ts +5 -5
- package/dist/oauth/discord.js +1 -1
- package/dist/oauth/figma.d.ts +5 -5
- package/dist/oauth/github.d.ts +5 -5
- package/dist/oauth/gitlab.d.ts +5 -5
- package/dist/oauth/index.cjs +176 -6
- package/dist/oauth/index.d.ts +5 -5
- package/dist/oauth/index.js +19 -4
- package/dist/oauth/mailchimp.cjs +46 -0
- package/dist/oauth/mailchimp.d.ts +7 -0
- package/dist/oauth/mailchimp.js +6 -0
- package/dist/oauth/pinterest.cjs +46 -0
- package/dist/oauth/pinterest.d.ts +7 -0
- package/dist/oauth/pinterest.js +6 -0
- package/dist/oauth/spotify.d.ts +5 -5
- package/dist/oauth/strava.cjs +46 -0
- package/dist/oauth/strava.d.ts +7 -0
- package/dist/oauth/strava.js +6 -0
- package/dist/oauth/x.d.ts +5 -5
- package/dist/{response.cjs → request.cjs} +14 -10
- package/dist/request.d.ts +13 -0
- package/dist/request.js +6 -0
- package/dist/schemas.cjs +43 -37
- package/dist/schemas.d.ts +67 -64
- package/dist/schemas.js +3 -1
- package/dist/secure.cjs +32 -24
- package/dist/secure.d.ts +5 -5
- package/dist/secure.js +4 -3
- package/dist/utils.cjs +90 -15
- package/dist/utils.d.ts +11 -2
- package/dist/utils.js +8 -4
- package/package.json +8 -7
- package/dist/chunk-FJUDBLCP.js +0 -59
- package/dist/chunk-HGJ4TXY4.js +0 -137
- package/dist/chunk-JAPMIE6S.js +0 -10
- package/dist/chunk-LLR722CL.js +0 -96
- package/dist/chunk-SJPDVKUS.js +0 -112
- package/dist/chunk-SMQO5WD7.js +0 -30
- package/dist/chunk-UTDLUEEG.js +0 -31
- package/dist/chunk-ZV4BH47P.js +0 -154
- package/dist/error.cjs +0 -88
- package/dist/error.d.ts +0 -62
- package/dist/error.js +0 -16
- package/dist/response.d.ts +0 -10
- package/dist/response.js +0 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as CookieConfig, E as ErrorType,
|
|
3
|
-
import 'zod
|
|
4
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
import { d as AuthConfig, e as AuthInstance } from './index-DkaLJFn8.js';
|
|
2
|
+
export { C as CookieConfig, E as ErrorType, f as JoseInstance, O as OAuthProvider, g as OAuthProviderConfig, h as OAuthProviderCredentials, S as Session, U as User } from './index-DkaLJFn8.js';
|
|
3
|
+
import 'zod';
|
|
5
4
|
import './schemas.js';
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
5
|
+
import '@aura-stack/router/cookie';
|
|
6
|
+
import '@aura-stack/jose';
|
|
7
|
+
import '@aura-stack/jose/jose';
|
|
8
8
|
import './@types/utility.js';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,62 +1,76 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createBuiltInOAuthProviders
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EMKJA2GJ.js";
|
|
4
|
+
import "./chunk-42XB3YCW.js";
|
|
4
5
|
import "./chunk-FKRDCWBF.js";
|
|
5
6
|
import "./chunk-IKHPGFCW.js";
|
|
6
7
|
import "./chunk-KRNOMBXQ.js";
|
|
8
|
+
import "./chunk-B737EUJV.js";
|
|
9
|
+
import "./chunk-HP34YGGJ.js";
|
|
7
10
|
import "./chunk-E3OXBRYF.js";
|
|
8
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-6R2YZ4AC.js";
|
|
9
12
|
import "./chunk-ITQ7352M.js";
|
|
13
|
+
import {
|
|
14
|
+
signOutAction
|
|
15
|
+
} from "./chunk-A3N4PVAT.js";
|
|
16
|
+
import {
|
|
17
|
+
callbackAction
|
|
18
|
+
} from "./chunk-KSWLO5ZU.js";
|
|
19
|
+
import "./chunk-GA2SMTJO.js";
|
|
20
|
+
import "./chunk-IVET23KF.js";
|
|
10
21
|
import {
|
|
11
22
|
csrfTokenAction
|
|
12
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-HT4YLL7N.js";
|
|
13
24
|
import {
|
|
14
25
|
sessionAction
|
|
15
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JVFTCTTE.js";
|
|
16
27
|
import {
|
|
17
28
|
signInAction
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import
|
|
20
|
-
signOutAction
|
|
21
|
-
} from "./chunk-SJPDVKUS.js";
|
|
22
|
-
import "./chunk-CAKJT3KS.js";
|
|
23
|
-
import {
|
|
24
|
-
callbackAction
|
|
25
|
-
} from "./chunk-HGJ4TXY4.js";
|
|
26
|
-
import "./chunk-RLT4RFKV.js";
|
|
27
|
-
import "./chunk-UJJ7R56J.js";
|
|
29
|
+
} from "./chunk-3EUWD5BB.js";
|
|
30
|
+
import "./chunk-N4SX7TZT.js";
|
|
28
31
|
import "./chunk-FIPU4MLT.js";
|
|
29
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-IUYZQTJV.js";
|
|
30
33
|
import {
|
|
31
|
-
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-6SM22VVJ.js";
|
|
34
|
+
createCookieStore
|
|
35
|
+
} from "./chunk-W6LG7BFW.js";
|
|
34
36
|
import "./chunk-STHEPPUZ.js";
|
|
35
37
|
import {
|
|
36
38
|
createJoseInstance
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
39
|
+
} from "./chunk-TLE4PXY3.js";
|
|
40
|
+
import "./chunk-N2APGLXA.js";
|
|
39
41
|
import {
|
|
40
|
-
onErrorHandler
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
import "./chunk-
|
|
44
|
-
import "./chunk-
|
|
42
|
+
onErrorHandler,
|
|
43
|
+
useSecureCookies
|
|
44
|
+
} from "./chunk-CXLATHS5.js";
|
|
45
|
+
import "./chunk-EIL2FPSS.js";
|
|
46
|
+
import "./chunk-RRLIF4PQ.js";
|
|
47
|
+
import "./chunk-ZNCZVF6U.js";
|
|
48
|
+
import "./chunk-YRCB5FLE.js";
|
|
45
49
|
|
|
46
50
|
// src/index.ts
|
|
47
51
|
import "dotenv/config";
|
|
48
52
|
import { createRouter } from "@aura-stack/router";
|
|
49
53
|
var createInternalConfig = (authConfig) => {
|
|
54
|
+
const useSecure = authConfig?.trustedProxyHeaders ?? false;
|
|
50
55
|
return {
|
|
51
56
|
basePath: authConfig?.basePath ?? "/auth",
|
|
52
57
|
onError: onErrorHandler,
|
|
53
58
|
context: {
|
|
54
59
|
oauth: createBuiltInOAuthProviders(authConfig?.oauth),
|
|
55
|
-
cookies: authConfig?.cookies ??
|
|
60
|
+
cookies: createCookieStore(useSecure, authConfig?.cookies?.prefix, authConfig?.cookies?.overrides ?? {}),
|
|
56
61
|
jose: createJoseInstance(authConfig?.secret),
|
|
62
|
+
secret: authConfig?.secret,
|
|
57
63
|
basePath: authConfig?.basePath ?? "/auth",
|
|
58
|
-
trustedProxyHeaders:
|
|
59
|
-
}
|
|
64
|
+
trustedProxyHeaders: useSecure
|
|
65
|
+
},
|
|
66
|
+
middlewares: [
|
|
67
|
+
(ctx) => {
|
|
68
|
+
const useSecure2 = useSecureCookies(ctx.request, ctx.context.trustedProxyHeaders);
|
|
69
|
+
const cookies = createCookieStore(useSecure2, authConfig?.cookies?.prefix, authConfig?.cookies?.overrides ?? {});
|
|
70
|
+
ctx.context.cookies = cookies;
|
|
71
|
+
return ctx;
|
|
72
|
+
}
|
|
73
|
+
]
|
|
60
74
|
};
|
|
61
75
|
};
|
|
62
76
|
var createAuth = (authConfig) => {
|
package/dist/jose.cjs
CHANGED
|
@@ -37,41 +37,52 @@ var import_config = require("dotenv/config");
|
|
|
37
37
|
var import_jose = require("@aura-stack/jose");
|
|
38
38
|
|
|
39
39
|
// src/secure.ts
|
|
40
|
-
var
|
|
40
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
41
41
|
|
|
42
42
|
// src/utils.ts
|
|
43
43
|
var import_router = require("@aura-stack/router");
|
|
44
44
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// src/errors.ts
|
|
46
|
+
var AuthInternalError = class extends Error {
|
|
47
|
+
type = "AUTH_INTERNAL_ERROR";
|
|
48
|
+
code;
|
|
49
|
+
constructor(code, message, options) {
|
|
50
|
+
super(message, options);
|
|
51
|
+
this.code = code;
|
|
52
|
+
this.name = new.target.name;
|
|
53
|
+
Error.captureStackTrace(this, new.target);
|
|
51
54
|
}
|
|
52
55
|
};
|
|
53
56
|
|
|
54
57
|
// src/secure.ts
|
|
55
58
|
var createDerivedSalt = (secret) => {
|
|
56
|
-
return
|
|
59
|
+
return import_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
// src/jose.ts
|
|
60
63
|
var createJoseInstance = (secret) => {
|
|
61
|
-
|
|
64
|
+
const env = process.env;
|
|
65
|
+
secret ??= env.AURA_AUTH_SECRET ?? env.AUTH_SECRET;
|
|
62
66
|
if (!secret) {
|
|
63
|
-
throw new
|
|
67
|
+
throw new AuthInternalError(
|
|
68
|
+
"JOSE_INITIALIZATION_FAILED",
|
|
69
|
+
"AURA_AUTH_SECRET environment variable is not set and no secret was provided."
|
|
70
|
+
);
|
|
64
71
|
}
|
|
65
|
-
const salt =
|
|
66
|
-
const { derivedKey:
|
|
72
|
+
const salt = env.AURA_AUTH_SALT ?? env.AUTH_SALT ?? createDerivedSalt(secret);
|
|
73
|
+
const { derivedKey: derivedSigningKey } = (0, import_jose.createDeriveKey)(secret, salt, "signing");
|
|
74
|
+
const { derivedKey: derivedEncryptionKey } = (0, import_jose.createDeriveKey)(secret, salt, "encryption");
|
|
67
75
|
const { derivedKey: derivedCsrfTokenKey } = (0, import_jose.createDeriveKey)(secret, salt, "csrfToken");
|
|
68
|
-
const { decodeJWT, encodeJWT } = (0, import_jose.createJWT)(
|
|
76
|
+
const { decodeJWT, encodeJWT } = (0, import_jose.createJWT)({ jws: derivedSigningKey, jwe: derivedEncryptionKey });
|
|
69
77
|
const { signJWS, verifyJWS } = (0, import_jose.createJWS)(derivedCsrfTokenKey);
|
|
78
|
+
const { encryptJWE, decryptJWE } = (0, import_jose.createJWE)(derivedEncryptionKey);
|
|
70
79
|
return {
|
|
71
80
|
decodeJWT,
|
|
72
81
|
encodeJWT,
|
|
73
82
|
signJWS,
|
|
74
|
-
verifyJWS
|
|
83
|
+
verifyJWS,
|
|
84
|
+
encryptJWE,
|
|
85
|
+
decryptJWE
|
|
75
86
|
};
|
|
76
87
|
};
|
|
77
88
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/jose.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _aura_stack_jose from '@aura-stack/jose';
|
|
1
2
|
import * as _aura_stack_jose_jose from '@aura-stack/jose/jose';
|
|
2
3
|
export { JWTPayload } from '@aura-stack/jose/jose';
|
|
3
4
|
|
|
@@ -14,7 +15,9 @@ declare const createJoseInstance: (secret?: string) => {
|
|
|
14
15
|
decodeJWT: (token: string) => Promise<_aura_stack_jose_jose.JWTPayload>;
|
|
15
16
|
encodeJWT: (payload: _aura_stack_jose_jose.JWTPayload) => Promise<string>;
|
|
16
17
|
signJWS: (payload: _aura_stack_jose_jose.JWTPayload) => Promise<string>;
|
|
17
|
-
verifyJWS: (payload: string) => Promise<_aura_stack_jose_jose.JWTPayload>;
|
|
18
|
+
verifyJWS: (payload: string, options?: _aura_stack_jose.JWTVerifyOptions) => Promise<_aura_stack_jose_jose.JWTPayload>;
|
|
19
|
+
encryptJWE: (payload: string, options?: _aura_stack_jose.EncryptOptions) => Promise<string>;
|
|
20
|
+
decryptJWE: (payload: string, options?: _aura_stack_jose.JWTDecryptOptions) => Promise<string>;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
export { createJoseInstance };
|
package/dist/jose.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createJoseInstance
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-TLE4PXY3.js";
|
|
4
|
+
import "./chunk-N2APGLXA.js";
|
|
5
|
+
import "./chunk-CXLATHS5.js";
|
|
6
|
+
import "./chunk-EIL2FPSS.js";
|
|
7
|
+
import "./chunk-RRLIF4PQ.js";
|
|
7
8
|
export {
|
|
8
9
|
createJoseInstance
|
|
9
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { B as BitbucketProfile,
|
|
1
|
+
export { B as BitbucketProfile, v as bitbucket } from '../index-DkaLJFn8.js';
|
|
2
2
|
import '../@types/utility.js';
|
|
3
|
-
import 'zod
|
|
4
|
-
import '@aura-stack/jose/jose';
|
|
3
|
+
import 'zod';
|
|
5
4
|
import '../schemas.js';
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
5
|
+
import '@aura-stack/router/cookie';
|
|
6
|
+
import '@aura-stack/jose';
|
|
7
|
+
import '@aura-stack/jose/jose';
|
package/dist/oauth/discord.cjs
CHANGED
package/dist/oauth/discord.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { D as DiscordProfile, N as Nameplate,
|
|
2
|
-
import 'zod
|
|
3
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
export { D as DiscordProfile, N as Nameplate, t as discord } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
4
3
|
import '../schemas.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
7
|
import '../@types/utility.js';
|
package/dist/oauth/discord.js
CHANGED
package/dist/oauth/figma.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { F as FigmaProfile,
|
|
2
|
-
import 'zod
|
|
3
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
export { F as FigmaProfile, u as figma } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
4
3
|
import '../schemas.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
7
|
import '../@types/utility.js';
|
package/dist/oauth/github.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import 'zod
|
|
3
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
export { w as GitHubProfile, y as github } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
4
3
|
import '../schemas.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
7
|
import '../@types/utility.js';
|
package/dist/oauth/gitlab.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { G as GitLabProfile,
|
|
2
|
-
import 'zod
|
|
3
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
export { G as GitLabProfile, r as gitlab } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
4
3
|
import '../schemas.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
7
|
import '../@types/utility.js';
|
package/dist/oauth/index.cjs
CHANGED
|
@@ -27,7 +27,10 @@ __export(oauth_exports, {
|
|
|
27
27
|
figma: () => figma,
|
|
28
28
|
github: () => github,
|
|
29
29
|
gitlab: () => gitlab,
|
|
30
|
+
mailchimp: () => mailchimp,
|
|
31
|
+
pinterest: () => pinterest,
|
|
30
32
|
spotify: () => spotify,
|
|
33
|
+
strava: () => strava,
|
|
31
34
|
x: () => x
|
|
32
35
|
});
|
|
33
36
|
module.exports = __toCommonJS(oauth_exports);
|
|
@@ -100,7 +103,6 @@ var discord = {
|
|
|
100
103
|
}
|
|
101
104
|
return {
|
|
102
105
|
sub: profile.id,
|
|
103
|
-
// https://discord.com/developers/docs/change-log#display-names
|
|
104
106
|
name: profile.global_name ?? profile.username,
|
|
105
107
|
email: profile.email ?? "",
|
|
106
108
|
image
|
|
@@ -165,6 +167,161 @@ var x = {
|
|
|
165
167
|
}
|
|
166
168
|
};
|
|
167
169
|
|
|
170
|
+
// src/oauth/strava.ts
|
|
171
|
+
var strava = {
|
|
172
|
+
id: "strava",
|
|
173
|
+
name: "Strava",
|
|
174
|
+
authorizeURL: "https://www.strava.com/oauth/authorize",
|
|
175
|
+
accessToken: "https://www.strava.com/oauth/token",
|
|
176
|
+
userInfo: "https://www.strava.com/api/v3/athlete",
|
|
177
|
+
scope: "read",
|
|
178
|
+
responseType: "code",
|
|
179
|
+
profile(profile) {
|
|
180
|
+
return {
|
|
181
|
+
sub: profile.id.toString(),
|
|
182
|
+
name: `${profile.firstname} ${profile.lastname}`,
|
|
183
|
+
image: profile.profile,
|
|
184
|
+
email: ""
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// src/oauth/mailchimp.ts
|
|
190
|
+
var mailchimp = {
|
|
191
|
+
id: "mailchimp",
|
|
192
|
+
name: "Mailchimp",
|
|
193
|
+
authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
|
|
194
|
+
accessToken: "https://login.mailchimp.com/oauth2/token",
|
|
195
|
+
userInfo: "https://login.mailchimp.com/oauth2/metadata",
|
|
196
|
+
scope: "",
|
|
197
|
+
responseType: "code",
|
|
198
|
+
profile(profile) {
|
|
199
|
+
return {
|
|
200
|
+
sub: profile.user_id,
|
|
201
|
+
name: profile.accountname,
|
|
202
|
+
email: profile.login.login_email,
|
|
203
|
+
image: null
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/oauth/pinterest.ts
|
|
209
|
+
var pinterest = {
|
|
210
|
+
id: "pinterest",
|
|
211
|
+
name: "Pinterest",
|
|
212
|
+
authorizeURL: "https://api.pinterest.com/oauth/",
|
|
213
|
+
accessToken: "https://api.pinterest.com/v5/oauth/token",
|
|
214
|
+
userInfo: "https://api.pinterest.com/v5/user_account",
|
|
215
|
+
scope: "user_accounts:read",
|
|
216
|
+
responseType: "code",
|
|
217
|
+
profile(profile) {
|
|
218
|
+
return {
|
|
219
|
+
sub: profile.id,
|
|
220
|
+
name: profile.username,
|
|
221
|
+
email: null,
|
|
222
|
+
image: profile.profile_image
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/schemas.ts
|
|
228
|
+
var import_zod = require("zod");
|
|
229
|
+
var OAuthProviderConfigSchema = (0, import_zod.object)({
|
|
230
|
+
authorizeURL: (0, import_zod.string)().url(),
|
|
231
|
+
accessToken: (0, import_zod.string)().url(),
|
|
232
|
+
scope: (0, import_zod.string)().optional(),
|
|
233
|
+
userInfo: (0, import_zod.string)().url(),
|
|
234
|
+
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
235
|
+
clientId: (0, import_zod.string)(),
|
|
236
|
+
clientSecret: (0, import_zod.string)()
|
|
237
|
+
});
|
|
238
|
+
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
239
|
+
redirectURI: (0, import_zod.string)(),
|
|
240
|
+
state: (0, import_zod.string)(),
|
|
241
|
+
codeChallenge: (0, import_zod.string)(),
|
|
242
|
+
codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
|
|
243
|
+
});
|
|
244
|
+
var OAuthAuthorizationResponse = (0, import_zod.object)({
|
|
245
|
+
state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
246
|
+
code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
247
|
+
});
|
|
248
|
+
var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
|
|
249
|
+
error: (0, import_zod.enum)([
|
|
250
|
+
"invalid_request",
|
|
251
|
+
"unauthorized_client",
|
|
252
|
+
"access_denied",
|
|
253
|
+
"unsupported_response_type",
|
|
254
|
+
"invalid_scope",
|
|
255
|
+
"server_error",
|
|
256
|
+
"temporarily_unavailable"
|
|
257
|
+
]),
|
|
258
|
+
error_description: (0, import_zod.string)().optional(),
|
|
259
|
+
error_uri: (0, import_zod.string)().optional(),
|
|
260
|
+
state: (0, import_zod.string)()
|
|
261
|
+
});
|
|
262
|
+
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
263
|
+
redirectURI: (0, import_zod.string)(),
|
|
264
|
+
code: (0, import_zod.string)(),
|
|
265
|
+
codeVerifier: (0, import_zod.string)().min(43).max(128)
|
|
266
|
+
});
|
|
267
|
+
var OAuthAccessTokenResponse = (0, import_zod.object)({
|
|
268
|
+
access_token: (0, import_zod.string)(),
|
|
269
|
+
token_type: (0, import_zod.string)().optional(),
|
|
270
|
+
expires_in: (0, import_zod.number)().optional(),
|
|
271
|
+
refresh_token: (0, import_zod.string)().optional(),
|
|
272
|
+
scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
|
|
273
|
+
});
|
|
274
|
+
var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
|
|
275
|
+
error: (0, import_zod.enum)([
|
|
276
|
+
"invalid_request",
|
|
277
|
+
"invalid_client",
|
|
278
|
+
"invalid_grant",
|
|
279
|
+
"unauthorized_client",
|
|
280
|
+
"unsupported_grant_type",
|
|
281
|
+
"invalid_scope"
|
|
282
|
+
]),
|
|
283
|
+
error_description: (0, import_zod.string)().optional(),
|
|
284
|
+
error_uri: (0, import_zod.string)().optional()
|
|
285
|
+
});
|
|
286
|
+
var OAuthErrorResponse = (0, import_zod.object)({
|
|
287
|
+
error: (0, import_zod.string)(),
|
|
288
|
+
error_description: (0, import_zod.string)().optional()
|
|
289
|
+
});
|
|
290
|
+
var OAuthEnvSchema = (0, import_zod.object)({
|
|
291
|
+
clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
292
|
+
clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// src/errors.ts
|
|
296
|
+
var AuthInternalError = class extends Error {
|
|
297
|
+
type = "AUTH_INTERNAL_ERROR";
|
|
298
|
+
code;
|
|
299
|
+
constructor(code, message, options2) {
|
|
300
|
+
super(message, options2);
|
|
301
|
+
this.code = code;
|
|
302
|
+
this.name = new.target.name;
|
|
303
|
+
Error.captureStackTrace(this, new.target);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// src/utils.ts
|
|
308
|
+
var import_router = require("@aura-stack/router");
|
|
309
|
+
var formatZodError = (error) => {
|
|
310
|
+
if (!error.issues || error.issues.length === 0) {
|
|
311
|
+
return {};
|
|
312
|
+
}
|
|
313
|
+
return error.issues.reduce((previous, issue) => {
|
|
314
|
+
const key = issue.path.join(".");
|
|
315
|
+
return {
|
|
316
|
+
...previous,
|
|
317
|
+
[key]: {
|
|
318
|
+
code: issue.code,
|
|
319
|
+
message: issue.message
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}, {});
|
|
323
|
+
};
|
|
324
|
+
|
|
168
325
|
// src/oauth/index.ts
|
|
169
326
|
var builtInOAuthProviders = {
|
|
170
327
|
github,
|
|
@@ -173,14 +330,24 @@ var builtInOAuthProviders = {
|
|
|
173
330
|
discord,
|
|
174
331
|
gitlab,
|
|
175
332
|
spotify,
|
|
176
|
-
x
|
|
333
|
+
x,
|
|
334
|
+
strava,
|
|
335
|
+
mailchimp,
|
|
336
|
+
pinterest
|
|
177
337
|
};
|
|
178
338
|
var defineOAuthEnvironment = (oauth) => {
|
|
179
339
|
const env = process.env;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
340
|
+
const clientIdSuffix = `${oauth.toUpperCase()}_CLIENT_ID`;
|
|
341
|
+
const clientSecretSuffix = `${oauth.toUpperCase()}_CLIENT_SECRET`;
|
|
342
|
+
const loadEnvs = OAuthEnvSchema.safeParse({
|
|
343
|
+
clientId: env[`AURA_AUTH_${clientIdSuffix}`] ?? env[`AUTH_${clientIdSuffix}`] ?? env[`${clientIdSuffix}`],
|
|
344
|
+
clientSecret: env[`AURA_AUTH_${clientSecretSuffix}`] ?? env[`AUTH_${clientSecretSuffix}`] ?? env[`${clientSecretSuffix}`]
|
|
345
|
+
});
|
|
346
|
+
if (!loadEnvs.success) {
|
|
347
|
+
const msg = JSON.stringify(formatZodError(loadEnvs.error), null, 2);
|
|
348
|
+
throw new AuthInternalError("INVALID_ENVIRONMENT_CONFIGURATION", msg);
|
|
349
|
+
}
|
|
350
|
+
return loadEnvs.data;
|
|
184
351
|
};
|
|
185
352
|
var defineOAuthProviderConfig = (config) => {
|
|
186
353
|
if (typeof config === "string") {
|
|
@@ -208,6 +375,9 @@ var createBuiltInOAuthProviders = (oauth = []) => {
|
|
|
208
375
|
figma,
|
|
209
376
|
github,
|
|
210
377
|
gitlab,
|
|
378
|
+
mailchimp,
|
|
379
|
+
pinterest,
|
|
211
380
|
spotify,
|
|
381
|
+
strava,
|
|
212
382
|
x
|
|
213
383
|
});
|
package/dist/oauth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { B as BitbucketProfile,
|
|
1
|
+
export { B as BitbucketProfile, K as BuiltInOAuthProvider, D as DiscordProfile, F as FigmaProfile, w as GitHubProfile, G as GitLabProfile, I as Image, L as Login, M as MailchimpProfile, N as Nameplate, P as PinterestProfile, o as SpotifyProfile, n as StravaProfile, k as SummaryClub, l as SummaryGear, X as XProfile, v as bitbucket, z as builtInOAuthProviders, H as createBuiltInOAuthProviders, t as discord, u as figma, y as github, r as gitlab, m as mailchimp, p as pinterest, q as spotify, s as strava, x } from '../index-DkaLJFn8.js';
|
|
2
2
|
import '../@types/utility.js';
|
|
3
|
-
import 'zod
|
|
4
|
-
import '@aura-stack/jose/jose';
|
|
3
|
+
import 'zod';
|
|
5
4
|
import '../schemas.js';
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
5
|
+
import '@aura-stack/router/cookie';
|
|
6
|
+
import '@aura-stack/jose';
|
|
7
|
+
import '@aura-stack/jose/jose';
|
package/dist/oauth/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
builtInOAuthProviders,
|
|
3
3
|
createBuiltInOAuthProviders
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-EMKJA2GJ.js";
|
|
5
|
+
import {
|
|
6
|
+
x
|
|
7
|
+
} from "../chunk-42XB3YCW.js";
|
|
5
8
|
import {
|
|
6
9
|
figma
|
|
7
10
|
} from "../chunk-FKRDCWBF.js";
|
|
@@ -11,18 +14,27 @@ import {
|
|
|
11
14
|
import {
|
|
12
15
|
gitlab
|
|
13
16
|
} from "../chunk-KRNOMBXQ.js";
|
|
17
|
+
import {
|
|
18
|
+
mailchimp
|
|
19
|
+
} from "../chunk-B737EUJV.js";
|
|
20
|
+
import {
|
|
21
|
+
pinterest
|
|
22
|
+
} from "../chunk-HP34YGGJ.js";
|
|
14
23
|
import {
|
|
15
24
|
spotify
|
|
16
25
|
} from "../chunk-E3OXBRYF.js";
|
|
17
26
|
import {
|
|
18
|
-
|
|
19
|
-
} from "../chunk-
|
|
27
|
+
strava
|
|
28
|
+
} from "../chunk-6R2YZ4AC.js";
|
|
20
29
|
import {
|
|
21
30
|
bitbucket
|
|
22
31
|
} from "../chunk-FIPU4MLT.js";
|
|
23
32
|
import {
|
|
24
33
|
discord
|
|
25
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-IUYZQTJV.js";
|
|
35
|
+
import "../chunk-CXLATHS5.js";
|
|
36
|
+
import "../chunk-RRLIF4PQ.js";
|
|
37
|
+
import "../chunk-YRCB5FLE.js";
|
|
26
38
|
export {
|
|
27
39
|
bitbucket,
|
|
28
40
|
builtInOAuthProviders,
|
|
@@ -31,6 +43,9 @@ export {
|
|
|
31
43
|
figma,
|
|
32
44
|
github,
|
|
33
45
|
gitlab,
|
|
46
|
+
mailchimp,
|
|
47
|
+
pinterest,
|
|
34
48
|
spotify,
|
|
49
|
+
strava,
|
|
35
50
|
x
|
|
36
51
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/oauth/mailchimp.ts
|
|
21
|
+
var mailchimp_exports = {};
|
|
22
|
+
__export(mailchimp_exports, {
|
|
23
|
+
mailchimp: () => mailchimp
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(mailchimp_exports);
|
|
26
|
+
var mailchimp = {
|
|
27
|
+
id: "mailchimp",
|
|
28
|
+
name: "Mailchimp",
|
|
29
|
+
authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
|
|
30
|
+
accessToken: "https://login.mailchimp.com/oauth2/token",
|
|
31
|
+
userInfo: "https://login.mailchimp.com/oauth2/metadata",
|
|
32
|
+
scope: "",
|
|
33
|
+
responseType: "code",
|
|
34
|
+
profile(profile) {
|
|
35
|
+
return {
|
|
36
|
+
sub: profile.user_id,
|
|
37
|
+
name: profile.accountname,
|
|
38
|
+
email: profile.login.login_email,
|
|
39
|
+
image: null
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
mailchimp
|
|
46
|
+
});
|