@hanzo/iam 0.4.0 → 0.4.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/betterauth.d.ts +14 -9
- package/dist/betterauth.d.ts.map +1 -1
- package/dist/betterauth.js +13 -10
- package/dist/betterauth.js.map +1 -1
- package/dist/nextauth.d.ts +12 -10
- package/dist/nextauth.d.ts.map +1 -1
- package/dist/nextauth.js +12 -11
- package/dist/nextauth.js.map +1 -1
- package/package.json +1 -1
- package/src/betterauth.ts +17 -12
- package/src/nextauth.ts +15 -13
package/dist/betterauth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BetterAuth SSO provider configuration for
|
|
2
|
+
* BetterAuth SSO provider configuration for IAM.
|
|
3
3
|
*
|
|
4
4
|
* Returns a provider config object compatible with BetterAuth's
|
|
5
5
|
* `socialProviders` or generic OAuth plugin.
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* import { betterAuth } from "better-auth";
|
|
10
|
-
* import {
|
|
10
|
+
* import { iamProvider } from "@hanzo/iam/betterauth";
|
|
11
11
|
*
|
|
12
12
|
* export const auth = betterAuth({
|
|
13
13
|
* socialProviders: [
|
|
14
|
-
*
|
|
14
|
+
* iamProvider({
|
|
15
15
|
* serverUrl: process.env.IAM_SERVER_URL!,
|
|
16
16
|
* clientId: process.env.IAM_CLIENT_ID!,
|
|
17
17
|
* clientSecret: process.env.IAM_CLIENT_SECRET!,
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @packageDocumentation
|
|
24
24
|
*/
|
|
25
25
|
import type { IamConfig } from "./types.js";
|
|
26
|
-
export interface
|
|
26
|
+
export interface IamSocialProvider {
|
|
27
27
|
id: string;
|
|
28
28
|
name: string;
|
|
29
29
|
type: "oidc";
|
|
@@ -50,13 +50,18 @@ export interface HanzoIamSocialProvider {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Create a BetterAuth-compatible social provider for
|
|
53
|
+
* Create a BetterAuth-compatible social provider for IAM.
|
|
54
54
|
*
|
|
55
55
|
* Works with BetterAuth's SSO plugin or generic OAuth integration.
|
|
56
|
-
* Uses
|
|
56
|
+
* Uses standard OIDC endpoints.
|
|
57
57
|
*/
|
|
58
|
-
export declare function
|
|
58
|
+
export declare function iamProvider(config: IamConfig & {
|
|
59
59
|
redirectUri?: string;
|
|
60
|
-
}):
|
|
61
|
-
|
|
60
|
+
}): IamSocialProvider;
|
|
61
|
+
/** @deprecated Use iamProvider instead */
|
|
62
|
+
export { iamProvider as hanzoIamProvider };
|
|
63
|
+
/** @deprecated Use iamProvider instead */
|
|
64
|
+
export { iamProvider as hanzoIamSocialProvider };
|
|
65
|
+
/** @deprecated Use IamSocialProvider instead */
|
|
66
|
+
export type { IamSocialProvider as HanzoIamSocialProvider };
|
|
62
67
|
//# sourceMappingURL=betterauth.d.ts.map
|
package/dist/betterauth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"betterauth.d.ts","sourceRoot":"","sources":["../src/betterauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"betterauth.d.ts","sourceRoot":"","sources":["../src/betterauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC1D,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;QAC7C,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,iBAAiB,CA6BnB;AAGD,0CAA0C;AAC1C,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,CAAC;AAC3C,0CAA0C;AAC1C,OAAO,EAAE,WAAW,IAAI,sBAAsB,EAAE,CAAC;AACjD,gDAAgD;AAChD,YAAY,EAAE,iBAAiB,IAAI,sBAAsB,EAAE,CAAC"}
|
package/dist/betterauth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BetterAuth SSO provider configuration for
|
|
2
|
+
* BetterAuth SSO provider configuration for IAM.
|
|
3
3
|
*
|
|
4
4
|
* Returns a provider config object compatible with BetterAuth's
|
|
5
5
|
* `socialProviders` or generic OAuth plugin.
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* import { betterAuth } from "better-auth";
|
|
10
|
-
* import {
|
|
10
|
+
* import { iamProvider } from "@hanzo/iam/betterauth";
|
|
11
11
|
*
|
|
12
12
|
* export const auth = betterAuth({
|
|
13
13
|
* socialProviders: [
|
|
14
|
-
*
|
|
14
|
+
* iamProvider({
|
|
15
15
|
* serverUrl: process.env.IAM_SERVER_URL!,
|
|
16
16
|
* clientId: process.env.IAM_CLIENT_ID!,
|
|
17
17
|
* clientSecret: process.env.IAM_CLIENT_SECRET!,
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
* @packageDocumentation
|
|
24
24
|
*/
|
|
25
25
|
/**
|
|
26
|
-
* Create a BetterAuth-compatible social provider for
|
|
26
|
+
* Create a BetterAuth-compatible social provider for IAM.
|
|
27
27
|
*
|
|
28
28
|
* Works with BetterAuth's SSO plugin or generic OAuth integration.
|
|
29
|
-
* Uses
|
|
29
|
+
* Uses standard OIDC endpoints.
|
|
30
30
|
*/
|
|
31
|
-
export function
|
|
31
|
+
export function iamProvider(config) {
|
|
32
32
|
const baseUrl = config.serverUrl.replace(/\/+$/, "");
|
|
33
33
|
return {
|
|
34
|
-
id: "
|
|
35
|
-
name: "
|
|
34
|
+
id: "iam",
|
|
35
|
+
name: "IAM",
|
|
36
36
|
type: "oidc",
|
|
37
37
|
issuer: baseUrl,
|
|
38
38
|
clientId: config.clientId,
|
|
@@ -56,6 +56,9 @@ export function hanzoIamProvider(config) {
|
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
// Backwards-compatible
|
|
60
|
-
|
|
59
|
+
// Backwards-compatible aliases
|
|
60
|
+
/** @deprecated Use iamProvider instead */
|
|
61
|
+
export { iamProvider as hanzoIamProvider };
|
|
62
|
+
/** @deprecated Use iamProvider instead */
|
|
63
|
+
export { iamProvider as hanzoIamSocialProvider };
|
|
61
64
|
//# sourceMappingURL=betterauth.js.map
|
package/dist/betterauth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"betterauth.js","sourceRoot":"","sources":["../src/betterauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAsBH;;;;;GAKG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"betterauth.js","sourceRoot":"","sources":["../src/betterauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAsBH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,MAA4C;IAE5C,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAErD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,OAAO;QACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,aAAa,EAAE;YACb,GAAG,EAAE,GAAG,OAAO,wBAAwB;YACvC,MAAM,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE;SAC1C;QACD,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,OAAO,+BAA+B,EAAE;QACzD,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,OAAO,eAAe,EAAE;QAC5C,OAAO,CAAC,OAAgC;YACtC,OAAO;gBACL,EAAE,EAAG,OAAO,CAAC,GAAc,IAAK,OAAO,CAAC,EAAa,IAAI,EAAE;gBAC3D,IAAI,EACD,OAAO,CAAC,WAAsB;oBAC9B,OAAO,CAAC,IAAe;oBACvB,OAAO,CAAC,kBAA6B;oBACtC,EAAE;gBACJ,KAAK,EAAG,OAAO,CAAC,KAAgB,IAAI,EAAE;gBACtC,KAAK,EAAG,OAAO,CAAC,MAAiB,IAAK,OAAO,CAAC,OAAkB,IAAI,IAAI;aACzE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,+BAA+B;AAC/B,0CAA0C;AAC1C,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,CAAC;AAC3C,0CAA0C;AAC1C,OAAO,EAAE,WAAW,IAAI,sBAAsB,EAAE,CAAC"}
|
package/dist/nextauth.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NextAuth.js provider for
|
|
2
|
+
* NextAuth.js / Auth.js provider for IAM (OIDC-based).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* so all Next.js apps can share one
|
|
4
|
+
* Provides a canonical NextAuth/Auth.js provider configuration
|
|
5
|
+
* so all Next.js apps can share one implementation.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* // next-auth config
|
|
10
|
-
* import {
|
|
10
|
+
* import { IamProvider } from "@hanzo/iam/nextauth";
|
|
11
11
|
*
|
|
12
12
|
* export default NextAuth({
|
|
13
13
|
* providers: [
|
|
14
|
-
*
|
|
14
|
+
* IamProvider({
|
|
15
15
|
* serverUrl: process.env.IAM_SERVER_URL!,
|
|
16
16
|
* clientId: process.env.IAM_CLIENT_ID!,
|
|
17
17
|
* clientSecret: process.env.IAM_CLIENT_SECRET!,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @packageDocumentation
|
|
24
24
|
*/
|
|
25
|
-
interface
|
|
25
|
+
export interface IamProfile extends Record<string, unknown> {
|
|
26
26
|
sub: string;
|
|
27
27
|
name: string;
|
|
28
28
|
email: string;
|
|
@@ -33,7 +33,7 @@ interface HanzoIamProfile extends Record<string, unknown> {
|
|
|
33
33
|
email_verified?: boolean;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* NextAuth.js / Auth.js compatible OAuth provider for
|
|
36
|
+
* NextAuth.js / Auth.js compatible OAuth provider for IAM.
|
|
37
37
|
*
|
|
38
38
|
* Uses standard OIDC well-known endpoint for automatic configuration.
|
|
39
39
|
* JWT id_token validation (issuer, audience, signature) is handled by
|
|
@@ -41,7 +41,7 @@ interface HanzoIamProfile extends Record<string, unknown> {
|
|
|
41
41
|
*
|
|
42
42
|
* Pass `checks: ["state", "pkce"]` in options for PKCE alignment.
|
|
43
43
|
*/
|
|
44
|
-
export declare function
|
|
44
|
+
export declare function IamProvider<P extends IamProfile>(options: {
|
|
45
45
|
serverUrl: string;
|
|
46
46
|
clientId: string;
|
|
47
47
|
clientSecret?: string;
|
|
@@ -51,6 +51,8 @@ export declare function HanzoIamProvider<P extends HanzoIamProfile>(options: {
|
|
|
51
51
|
checks?: ("state" | "pkce" | "nonce" | "none")[];
|
|
52
52
|
[key: string]: unknown;
|
|
53
53
|
}): Record<string, unknown>;
|
|
54
|
-
|
|
55
|
-
export
|
|
54
|
+
/** @deprecated Use IamProvider instead */
|
|
55
|
+
export { IamProvider as HanzoIamProvider };
|
|
56
|
+
/** @deprecated Use IamProfile instead */
|
|
57
|
+
export type { IamProfile as HanzoIamProfile };
|
|
56
58
|
//# sourceMappingURL=nextauth.d.ts.map
|
package/dist/nextauth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextauth.d.ts","sourceRoot":"","sources":["../src/nextauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,
|
|
1
|
+
{"version":3,"file":"nextauth.d.ts","sourceRoot":"","sources":["../src/nextauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAC9C,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,MAAM,CAAC,EAAE,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC;IACjD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,GACA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgCzB;AAGD,0CAA0C;AAC1C,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,CAAC;AAC3C,yCAAyC;AACzC,YAAY,EAAE,UAAU,IAAI,eAAe,EAAE,CAAC"}
|
package/dist/nextauth.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NextAuth.js provider for
|
|
2
|
+
* NextAuth.js / Auth.js provider for IAM (OIDC-based).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* so all Next.js apps can share one
|
|
4
|
+
* Provides a canonical NextAuth/Auth.js provider configuration
|
|
5
|
+
* so all Next.js apps can share one implementation.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* // next-auth config
|
|
10
|
-
* import {
|
|
10
|
+
* import { IamProvider } from "@hanzo/iam/nextauth";
|
|
11
11
|
*
|
|
12
12
|
* export default NextAuth({
|
|
13
13
|
* providers: [
|
|
14
|
-
*
|
|
14
|
+
* IamProvider({
|
|
15
15
|
* serverUrl: process.env.IAM_SERVER_URL!,
|
|
16
16
|
* clientId: process.env.IAM_CLIENT_ID!,
|
|
17
17
|
* clientSecret: process.env.IAM_CLIENT_SECRET!,
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @packageDocumentation
|
|
24
24
|
*/
|
|
25
25
|
/**
|
|
26
|
-
* NextAuth.js / Auth.js compatible OAuth provider for
|
|
26
|
+
* NextAuth.js / Auth.js compatible OAuth provider for IAM.
|
|
27
27
|
*
|
|
28
28
|
* Uses standard OIDC well-known endpoint for automatic configuration.
|
|
29
29
|
* JWT id_token validation (issuer, audience, signature) is handled by
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
*
|
|
32
32
|
* Pass `checks: ["state", "pkce"]` in options for PKCE alignment.
|
|
33
33
|
*/
|
|
34
|
-
export function
|
|
34
|
+
export function IamProvider(options) {
|
|
35
35
|
const issuer = options.serverUrl.replace(/\/$/, "");
|
|
36
36
|
const checks = options.checks ?? ["state"];
|
|
37
37
|
return {
|
|
38
|
-
id: "
|
|
39
|
-
name: "
|
|
38
|
+
id: "iam",
|
|
39
|
+
name: "IAM",
|
|
40
40
|
type: "oauth",
|
|
41
41
|
wellKnown: `${issuer}/.well-known/openid-configuration`,
|
|
42
42
|
idToken: true,
|
|
@@ -62,6 +62,7 @@ export function HanzoIamProvider(options) {
|
|
|
62
62
|
options,
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
//
|
|
66
|
-
|
|
65
|
+
// Backwards-compatible aliases
|
|
66
|
+
/** @deprecated Use IamProvider instead */
|
|
67
|
+
export { IamProvider as HanzoIamProvider };
|
|
67
68
|
//# sourceMappingURL=nextauth.js.map
|
package/dist/nextauth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextauth.js","sourceRoot":"","sources":["../src/nextauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAaH;;;;;;;;GAQG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"nextauth.js","sourceRoot":"","sources":["../src/nextauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAaH;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CACzB,OASC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;IAE3C,OAAO;QACL,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,OAAO;QACb,SAAS,EAAE,GAAG,MAAM,mCAAmC;QACvD,OAAO,EAAE,IAAI;QACb,MAAM;QACN,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,EAAE;QAC5D,OAAO,CAAC,OAAU;YAChB,OAAO;gBACL,EAAE,EAAE,OAAO,CAAC,GAAG;gBACf,IAAI,EACF,OAAO,CAAC,WAAW;oBACnB,OAAO,CAAC,IAAI;oBACZ,OAAO,CAAC,kBAAkB;oBAC1B,OAAO,CAAC,KAAK;oBACb,EAAE;gBACJ,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI;aACjD,CAAC;QACJ,CAAC;QACD,KAAK,EAAE;YACL,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,EAAE;SACT;QACD,OAAO;KACR,CAAC;AACJ,CAAC;AAED,+BAA+B;AAC/B,0CAA0C;AAC1C,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/betterauth.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BetterAuth SSO provider configuration for
|
|
2
|
+
* BetterAuth SSO provider configuration for IAM.
|
|
3
3
|
*
|
|
4
4
|
* Returns a provider config object compatible with BetterAuth's
|
|
5
5
|
* `socialProviders` or generic OAuth plugin.
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* import { betterAuth } from "better-auth";
|
|
10
|
-
* import {
|
|
10
|
+
* import { iamProvider } from "@hanzo/iam/betterauth";
|
|
11
11
|
*
|
|
12
12
|
* export const auth = betterAuth({
|
|
13
13
|
* socialProviders: [
|
|
14
|
-
*
|
|
14
|
+
* iamProvider({
|
|
15
15
|
* serverUrl: process.env.IAM_SERVER_URL!,
|
|
16
16
|
* clientId: process.env.IAM_CLIENT_ID!,
|
|
17
17
|
* clientSecret: process.env.IAM_CLIENT_SECRET!,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import type { IamConfig } from "./types.js";
|
|
27
27
|
|
|
28
|
-
export interface
|
|
28
|
+
export interface IamSocialProvider {
|
|
29
29
|
id: string;
|
|
30
30
|
name: string;
|
|
31
31
|
type: "oidc";
|
|
@@ -44,19 +44,19 @@ export interface HanzoIamSocialProvider {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Create a BetterAuth-compatible social provider for
|
|
47
|
+
* Create a BetterAuth-compatible social provider for IAM.
|
|
48
48
|
*
|
|
49
49
|
* Works with BetterAuth's SSO plugin or generic OAuth integration.
|
|
50
|
-
* Uses
|
|
50
|
+
* Uses standard OIDC endpoints.
|
|
51
51
|
*/
|
|
52
|
-
export function
|
|
52
|
+
export function iamProvider(
|
|
53
53
|
config: IamConfig & { redirectUri?: string },
|
|
54
|
-
):
|
|
54
|
+
): IamSocialProvider {
|
|
55
55
|
const baseUrl = config.serverUrl.replace(/\/+$/, "");
|
|
56
56
|
|
|
57
57
|
return {
|
|
58
|
-
id: "
|
|
59
|
-
name: "
|
|
58
|
+
id: "iam",
|
|
59
|
+
name: "IAM",
|
|
60
60
|
type: "oidc",
|
|
61
61
|
issuer: baseUrl,
|
|
62
62
|
clientId: config.clientId,
|
|
@@ -82,5 +82,10 @@ export function hanzoIamProvider(
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
// Backwards-compatible
|
|
86
|
-
|
|
85
|
+
// Backwards-compatible aliases
|
|
86
|
+
/** @deprecated Use iamProvider instead */
|
|
87
|
+
export { iamProvider as hanzoIamProvider };
|
|
88
|
+
/** @deprecated Use iamProvider instead */
|
|
89
|
+
export { iamProvider as hanzoIamSocialProvider };
|
|
90
|
+
/** @deprecated Use IamSocialProvider instead */
|
|
91
|
+
export type { IamSocialProvider as HanzoIamSocialProvider };
|
package/src/nextauth.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NextAuth.js provider for
|
|
2
|
+
* NextAuth.js / Auth.js provider for IAM (OIDC-based).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* so all Next.js apps can share one
|
|
4
|
+
* Provides a canonical NextAuth/Auth.js provider configuration
|
|
5
|
+
* so all Next.js apps can share one implementation.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* // next-auth config
|
|
10
|
-
* import {
|
|
10
|
+
* import { IamProvider } from "@hanzo/iam/nextauth";
|
|
11
11
|
*
|
|
12
12
|
* export default NextAuth({
|
|
13
13
|
* providers: [
|
|
14
|
-
*
|
|
14
|
+
* IamProvider({
|
|
15
15
|
* serverUrl: process.env.IAM_SERVER_URL!,
|
|
16
16
|
* clientId: process.env.IAM_CLIENT_ID!,
|
|
17
17
|
* clientSecret: process.env.IAM_CLIENT_SECRET!,
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @packageDocumentation
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
interface
|
|
26
|
+
export interface IamProfile extends Record<string, unknown> {
|
|
27
27
|
sub: string;
|
|
28
28
|
name: string;
|
|
29
29
|
email: string;
|
|
@@ -35,7 +35,7 @@ interface HanzoIamProfile extends Record<string, unknown> {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* NextAuth.js / Auth.js compatible OAuth provider for
|
|
38
|
+
* NextAuth.js / Auth.js compatible OAuth provider for IAM.
|
|
39
39
|
*
|
|
40
40
|
* Uses standard OIDC well-known endpoint for automatic configuration.
|
|
41
41
|
* JWT id_token validation (issuer, audience, signature) is handled by
|
|
@@ -43,7 +43,7 @@ interface HanzoIamProfile extends Record<string, unknown> {
|
|
|
43
43
|
*
|
|
44
44
|
* Pass `checks: ["state", "pkce"]` in options for PKCE alignment.
|
|
45
45
|
*/
|
|
46
|
-
export function
|
|
46
|
+
export function IamProvider<P extends IamProfile>(
|
|
47
47
|
options: {
|
|
48
48
|
serverUrl: string;
|
|
49
49
|
clientId: string;
|
|
@@ -59,8 +59,8 @@ export function HanzoIamProvider<P extends HanzoIamProfile>(
|
|
|
59
59
|
const checks = options.checks ?? ["state"];
|
|
60
60
|
|
|
61
61
|
return {
|
|
62
|
-
id: "
|
|
63
|
-
name: "
|
|
62
|
+
id: "iam",
|
|
63
|
+
name: "IAM",
|
|
64
64
|
type: "oauth",
|
|
65
65
|
wellKnown: `${issuer}/.well-known/openid-configuration`,
|
|
66
66
|
idToken: true,
|
|
@@ -88,6 +88,8 @@ export function HanzoIamProvider<P extends HanzoIamProfile>(
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
export
|
|
91
|
+
// Backwards-compatible aliases
|
|
92
|
+
/** @deprecated Use IamProvider instead */
|
|
93
|
+
export { IamProvider as HanzoIamProvider };
|
|
94
|
+
/** @deprecated Use IamProfile instead */
|
|
95
|
+
export type { IamProfile as HanzoIamProfile };
|