@happyvertical/auth 0.74.8

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 (45) hide show
  1. package/AGENT.md +33 -0
  2. package/LICENSE +7 -0
  3. package/README.md +73 -0
  4. package/dist/chunks/cognito-dmypylFX.js +128 -0
  5. package/dist/chunks/cognito-dmypylFX.js.map +1 -0
  6. package/dist/chunks/decode_jwt-D2OK1b8a.js +1395 -0
  7. package/dist/chunks/decode_jwt-D2OK1b8a.js.map +1 -0
  8. package/dist/chunks/github-NSZp5tVm.js +413 -0
  9. package/dist/chunks/github-NSZp5tVm.js.map +1 -0
  10. package/dist/chunks/google-HXk2ctYR.js +483 -0
  11. package/dist/chunks/google-HXk2ctYR.js.map +1 -0
  12. package/dist/chunks/index-BpsMhFXS.js +151 -0
  13. package/dist/chunks/index-BpsMhFXS.js.map +1 -0
  14. package/dist/chunks/kanidm-hkw-YPVF.js +747 -0
  15. package/dist/chunks/kanidm-hkw-YPVF.js.map +1 -0
  16. package/dist/chunks/keycloak-t6JEUeOz.js +871 -0
  17. package/dist/chunks/keycloak-t6JEUeOz.js.map +1 -0
  18. package/dist/cli/claude-context.d.ts +3 -0
  19. package/dist/cli/claude-context.d.ts.map +1 -0
  20. package/dist/cli/claude-context.js +21 -0
  21. package/dist/cli/claude-context.js.map +1 -0
  22. package/dist/index.d.ts +65 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +499 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/shared/errors.d.ts +227 -0
  27. package/dist/shared/errors.d.ts.map +1 -0
  28. package/dist/shared/factory.d.ts +85 -0
  29. package/dist/shared/factory.d.ts.map +1 -0
  30. package/dist/shared/providers/cognito.d.ts +38 -0
  31. package/dist/shared/providers/cognito.d.ts.map +1 -0
  32. package/dist/shared/providers/github.d.ts +65 -0
  33. package/dist/shared/providers/github.d.ts.map +1 -0
  34. package/dist/shared/providers/google.d.ts +58 -0
  35. package/dist/shared/providers/google.d.ts.map +1 -0
  36. package/dist/shared/providers/kanidm.d.ts +78 -0
  37. package/dist/shared/providers/kanidm.d.ts.map +1 -0
  38. package/dist/shared/providers/keycloak.d.ts +67 -0
  39. package/dist/shared/providers/keycloak.d.ts.map +1 -0
  40. package/dist/shared/providers/nostr/index.d.ts +47 -0
  41. package/dist/shared/providers/nostr/index.d.ts.map +1 -0
  42. package/dist/shared/types.d.ts +812 -0
  43. package/dist/shared/types.d.ts.map +1 -0
  44. package/metadata.json +32 -0
  45. package/package.json +60 -0
@@ -0,0 +1,151 @@
1
+ import { NotImplementedError } from "../index.js";
2
+ class NostrProvider {
3
+ options;
4
+ constructor(options) {
5
+ this.options = {
6
+ challengeExpiration: 300,
7
+ // 5 minutes
8
+ relayTimeout: 1e4,
9
+ // 10 seconds
10
+ ...options,
11
+ // Ensure relays has a default if not provided
12
+ relays: options.relays?.length ? options.relays : ["wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"]
13
+ };
14
+ }
15
+ // ---------------------------------------------------------------------------
16
+ // AUTHENTICATION FLOWS
17
+ // ---------------------------------------------------------------------------
18
+ async getAuthorizationUrl(_options) {
19
+ throw new NotImplementedError("getAuthorizationUrl", "nostr");
20
+ }
21
+ async exchangeCode(_params) {
22
+ throw new NotImplementedError("exchangeCode", "nostr");
23
+ }
24
+ async authenticate(_credentials) {
25
+ throw new NotImplementedError("authenticate", "nostr");
26
+ }
27
+ async refresh(_refreshToken) {
28
+ throw new NotImplementedError("refresh", "nostr", {
29
+ reason: "NIP-98 tokens are ephemeral. Generate a new token for each request."
30
+ });
31
+ }
32
+ async logout(_options) {
33
+ throw new NotImplementedError("logout", "nostr");
34
+ }
35
+ // ---------------------------------------------------------------------------
36
+ // TOKEN OPERATIONS
37
+ // ---------------------------------------------------------------------------
38
+ async validateToken(_token, _options) {
39
+ throw new NotImplementedError("validateToken", "nostr");
40
+ }
41
+ decodeToken(_token) {
42
+ throw new NotImplementedError("decodeToken", "nostr");
43
+ }
44
+ async introspectToken(_token) {
45
+ throw new NotImplementedError("introspectToken", "nostr");
46
+ }
47
+ // ---------------------------------------------------------------------------
48
+ // USER OPERATIONS
49
+ // ---------------------------------------------------------------------------
50
+ async getProfile(_tokenOrSession) {
51
+ throw new NotImplementedError("getProfile", "nostr");
52
+ }
53
+ async updateProfile(_tokenOrSession, _profile) {
54
+ throw new NotImplementedError("updateProfile", "nostr");
55
+ }
56
+ async getUser(_userId, _adminToken) {
57
+ throw new NotImplementedError("getUser", "nostr");
58
+ }
59
+ async createUser(_user, _adminToken) {
60
+ throw new NotImplementedError("createUser", "nostr", {
61
+ reason: 'Nostr users self-create by generating a keypair. Use authenticate({ method: "generate" }).'
62
+ });
63
+ }
64
+ async updateUser(_userId, _updates, _adminToken) {
65
+ throw new NotImplementedError("updateUser", "nostr", {
66
+ reason: "Nostr is decentralized. Users can only update their own profile."
67
+ });
68
+ }
69
+ async deleteUser(_userId, _adminToken) {
70
+ throw new NotImplementedError("deleteUser", "nostr", {
71
+ reason: "Nostr identities cannot be deleted. The keypair remains valid forever. To abandon an identity, stop using the keypair."
72
+ });
73
+ }
74
+ async listUsers(_query, _adminToken) {
75
+ throw new NotImplementedError("listUsers", "nostr");
76
+ }
77
+ async requestPasswordReset(_email) {
78
+ throw new NotImplementedError("requestPasswordReset", "nostr", {
79
+ reason: "Nostr uses keypairs, not passwords. There is no password to reset."
80
+ });
81
+ }
82
+ async resetPassword(_token, _newPassword) {
83
+ throw new NotImplementedError("resetPassword", "nostr", {
84
+ reason: "Nostr uses keypairs, not passwords. There is no password to reset."
85
+ });
86
+ }
87
+ // ---------------------------------------------------------------------------
88
+ // SESSION OPERATIONS
89
+ // ---------------------------------------------------------------------------
90
+ async listSessions(_userId, _adminToken) {
91
+ throw new NotImplementedError("listSessions", "nostr");
92
+ }
93
+ async revokeSession(_sessionId, _adminToken) {
94
+ throw new NotImplementedError("revokeSession", "nostr");
95
+ }
96
+ async revokeAllSessions(_userId, _adminToken) {
97
+ throw new NotImplementedError("revokeAllSessions", "nostr");
98
+ }
99
+ // ---------------------------------------------------------------------------
100
+ // AUTHORIZATION
101
+ // ---------------------------------------------------------------------------
102
+ async hasRole(_tokenOrUserId, _role) {
103
+ throw new NotImplementedError("hasRole", "nostr");
104
+ }
105
+ async hasPermission(_tokenOrUserId, _permission, _resource) {
106
+ throw new NotImplementedError("hasPermission", "nostr");
107
+ }
108
+ async getRoles(_tokenOrUserId, _adminToken) {
109
+ throw new NotImplementedError("getRoles", "nostr");
110
+ }
111
+ async assignRole(_userId, _role, _adminToken) {
112
+ throw new NotImplementedError("assignRole", "nostr");
113
+ }
114
+ async removeRole(_userId, _role, _adminToken) {
115
+ throw new NotImplementedError("removeRole", "nostr");
116
+ }
117
+ // ---------------------------------------------------------------------------
118
+ // PROVIDER INFORMATION
119
+ // ---------------------------------------------------------------------------
120
+ async getCapabilities() {
121
+ return {
122
+ authorizationCode: false,
123
+ // Uses challenge-response instead
124
+ passwordGrant: false,
125
+ // Uses keypair instead
126
+ clientCredentials: false,
127
+ tokenRefresh: false,
128
+ // NIP-98 tokens are ephemeral
129
+ oidc: false,
130
+ userManagement: false,
131
+ // Decentralized - users self-manage
132
+ sessionManagement: false,
133
+ // Client-side only
134
+ rbac: !!this.options.roleStore,
135
+ // Only if roleStore configured
136
+ passwordReset: false,
137
+ // No passwords
138
+ mfa: false,
139
+ socialLogin: false,
140
+ federation: false,
141
+ decentralized: true
142
+ };
143
+ }
144
+ async getDiscoveryDocument() {
145
+ return null;
146
+ }
147
+ }
148
+ export {
149
+ NostrProvider
150
+ };
151
+ //# sourceMappingURL=index-BpsMhFXS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BpsMhFXS.js","sources":["../../src/shared/providers/nostr/index.ts"],"sourcesContent":["/**\n * Nostr Provider - Public Key Identity Authentication\n *\n * This is a stub implementation. The full implementation will be added in Phase 4.\n *\n * Nostr authentication uses public key cryptography:\n * - Identity = public key (npub)\n * - Authentication = proving private key ownership via signatures\n * - Tokens = NIP-98 signed events\n * - Profiles = kind:0 events from relays\n */\n\nimport { NotImplementedError } from '../../errors.js';\nimport type {\n AuthCapabilities,\n AuthCredentials,\n AuthInterface,\n AuthorizationOptions,\n AuthorizationResult,\n AuthResult,\n CodeExchangeParams,\n CreateUserRequest,\n LogoutOptions,\n NostrOptions,\n OIDCDiscoveryDocument,\n Session,\n TokenClaims,\n TokenIntrospection,\n TokenPayload,\n TokenValidationOptions,\n UserListResult,\n UserProfile,\n UserQuery,\n} from '../../types.js';\n\n/**\n * Nostr authentication provider.\n *\n * Implements public key identity authentication using the Nostr protocol.\n * Maps Nostr concepts to OAuth-like interface:\n *\n * | Concept | OAuth/OIDC | Nostr |\n * |---------------|----------------------|--------------------------------|\n * | Identity | Server user ID | Public key (npub) |\n * | Authentication| Password | Signature (private key proof) |\n * | Tokens | JWT | NIP-98 signed events |\n * | Profiles | Userinfo endpoint | kind:0 events from relays |\n * | Sessions | Server-side | Client-side keypair reference |\n */\nexport class NostrProvider implements AuthInterface {\n private options: NostrOptions;\n\n constructor(options: NostrOptions) {\n this.options = {\n challengeExpiration: 300, // 5 minutes\n relayTimeout: 10000, // 10 seconds\n ...options,\n // Ensure relays has a default if not provided\n relays: options.relays?.length\n ? options.relays\n : ['wss://relay.damus.io', 'wss://nos.lol', 'wss://relay.nostr.band'],\n };\n }\n\n // ---------------------------------------------------------------------------\n // AUTHENTICATION FLOWS\n // ---------------------------------------------------------------------------\n\n async getAuthorizationUrl(\n _options?: AuthorizationOptions,\n ): Promise<AuthorizationResult> {\n throw new NotImplementedError('getAuthorizationUrl', 'nostr');\n }\n\n async exchangeCode(_params: CodeExchangeParams): Promise<AuthResult> {\n throw new NotImplementedError('exchangeCode', 'nostr');\n }\n\n async authenticate(_credentials: AuthCredentials): Promise<AuthResult> {\n throw new NotImplementedError('authenticate', 'nostr');\n }\n\n async refresh(_refreshToken: string): Promise<AuthResult> {\n // Nostr tokens (NIP-98 events) are ephemeral and cannot be refreshed\n throw new NotImplementedError('refresh', 'nostr', {\n reason:\n 'NIP-98 tokens are ephemeral. Generate a new token for each request.',\n });\n }\n\n async logout(_options?: LogoutOptions): Promise<void> {\n throw new NotImplementedError('logout', 'nostr');\n }\n\n // ---------------------------------------------------------------------------\n // TOKEN OPERATIONS\n // ---------------------------------------------------------------------------\n\n async validateToken(\n _token: string,\n _options?: TokenValidationOptions,\n ): Promise<TokenClaims | null> {\n throw new NotImplementedError('validateToken', 'nostr');\n }\n\n decodeToken(_token: string): TokenPayload {\n throw new NotImplementedError('decodeToken', 'nostr');\n }\n\n async introspectToken(_token: string): Promise<TokenIntrospection> {\n throw new NotImplementedError('introspectToken', 'nostr');\n }\n\n // ---------------------------------------------------------------------------\n // USER OPERATIONS\n // ---------------------------------------------------------------------------\n\n async getProfile(_tokenOrSession: string): Promise<UserProfile> {\n throw new NotImplementedError('getProfile', 'nostr');\n }\n\n async updateProfile(\n _tokenOrSession: string,\n _profile: Partial<UserProfile>,\n ): Promise<UserProfile> {\n throw new NotImplementedError('updateProfile', 'nostr');\n }\n\n async getUser(_userId: string, _adminToken?: string): Promise<UserProfile> {\n throw new NotImplementedError('getUser', 'nostr');\n }\n\n async createUser(\n _user: CreateUserRequest,\n _adminToken: string,\n ): Promise<UserProfile> {\n // Nostr users create their own identity by generating a keypair\n throw new NotImplementedError('createUser', 'nostr', {\n reason:\n 'Nostr users self-create by generating a keypair. Use authenticate({ method: \"generate\" }).',\n });\n }\n\n async updateUser(\n _userId: string,\n _updates: Partial<CreateUserRequest>,\n _adminToken: string,\n ): Promise<UserProfile> {\n // Can only update own profile via updateProfile\n throw new NotImplementedError('updateUser', 'nostr', {\n reason:\n 'Nostr is decentralized. Users can only update their own profile.',\n });\n }\n\n async deleteUser(_userId: string, _adminToken: string): Promise<void> {\n // Nostr identities cannot be deleted - they are cryptographic keys\n throw new NotImplementedError('deleteUser', 'nostr', {\n reason:\n 'Nostr identities cannot be deleted. The keypair remains valid forever. ' +\n 'To abandon an identity, stop using the keypair.',\n });\n }\n\n async listUsers(\n _query: UserQuery,\n _adminToken?: string,\n ): Promise<UserListResult> {\n throw new NotImplementedError('listUsers', 'nostr');\n }\n\n async requestPasswordReset(_email: string): Promise<void> {\n // Nostr has no passwords - identity is based on keypairs\n throw new NotImplementedError('requestPasswordReset', 'nostr', {\n reason:\n 'Nostr uses keypairs, not passwords. There is no password to reset.',\n });\n }\n\n async resetPassword(_token: string, _newPassword: string): Promise<void> {\n throw new NotImplementedError('resetPassword', 'nostr', {\n reason:\n 'Nostr uses keypairs, not passwords. There is no password to reset.',\n });\n }\n\n // ---------------------------------------------------------------------------\n // SESSION OPERATIONS\n // ---------------------------------------------------------------------------\n\n async listSessions(\n _userId: string,\n _adminToken?: string,\n ): Promise<Session[]> {\n throw new NotImplementedError('listSessions', 'nostr');\n }\n\n async revokeSession(_sessionId: string, _adminToken?: string): Promise<void> {\n throw new NotImplementedError('revokeSession', 'nostr');\n }\n\n async revokeAllSessions(\n _userId: string,\n _adminToken?: string,\n ): Promise<void> {\n throw new NotImplementedError('revokeAllSessions', 'nostr');\n }\n\n // ---------------------------------------------------------------------------\n // AUTHORIZATION\n // ---------------------------------------------------------------------------\n\n async hasRole(_tokenOrUserId: string, _role: string): Promise<boolean> {\n throw new NotImplementedError('hasRole', 'nostr');\n }\n\n async hasPermission(\n _tokenOrUserId: string,\n _permission: string,\n _resource?: string,\n ): Promise<boolean> {\n throw new NotImplementedError('hasPermission', 'nostr');\n }\n\n async getRoles(\n _tokenOrUserId: string,\n _adminToken?: string,\n ): Promise<string[]> {\n throw new NotImplementedError('getRoles', 'nostr');\n }\n\n async assignRole(\n _userId: string,\n _role: string,\n _adminToken: string,\n ): Promise<void> {\n throw new NotImplementedError('assignRole', 'nostr');\n }\n\n async removeRole(\n _userId: string,\n _role: string,\n _adminToken: string,\n ): Promise<void> {\n throw new NotImplementedError('removeRole', 'nostr');\n }\n\n // ---------------------------------------------------------------------------\n // PROVIDER INFORMATION\n // ---------------------------------------------------------------------------\n\n async getCapabilities(): Promise<AuthCapabilities> {\n return {\n authorizationCode: false, // Uses challenge-response instead\n passwordGrant: false, // Uses keypair instead\n clientCredentials: false,\n tokenRefresh: false, // NIP-98 tokens are ephemeral\n oidc: false,\n userManagement: false, // Decentralized - users self-manage\n sessionManagement: false, // Client-side only\n rbac: !!this.options.roleStore, // Only if roleStore configured\n passwordReset: false, // No passwords\n mfa: false,\n socialLogin: false,\n federation: false,\n decentralized: true,\n };\n }\n\n async getDiscoveryDocument(): Promise<OIDCDiscoveryDocument | null> {\n // Nostr is not OIDC-based\n return null;\n }\n}\n"],"names":[],"mappings":";AAiDO,MAAM,cAAuC;AAAA,EAC1C;AAAA,EAER,YAAY,SAAuB;AACjC,SAAK,UAAU;AAAA,MACb,qBAAqB;AAAA;AAAA,MACrB,cAAc;AAAA;AAAA,MACd,GAAG;AAAA;AAAA,MAEH,QAAQ,QAAQ,QAAQ,SACpB,QAAQ,SACR,CAAC,wBAAwB,iBAAiB,wBAAwB;AAAA,IAAA;AAAA,EAE1E;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,oBACJ,UAC8B;AAC9B,UAAM,IAAI,oBAAoB,uBAAuB,OAAO;AAAA,EAC9D;AAAA,EAEA,MAAM,aAAa,SAAkD;AACnE,UAAM,IAAI,oBAAoB,gBAAgB,OAAO;AAAA,EACvD;AAAA,EAEA,MAAM,aAAa,cAAoD;AACrE,UAAM,IAAI,oBAAoB,gBAAgB,OAAO;AAAA,EACvD;AAAA,EAEA,MAAM,QAAQ,eAA4C;AAExD,UAAM,IAAI,oBAAoB,WAAW,SAAS;AAAA,MAChD,QACE;AAAA,IAAA,CACH;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,UAAyC;AACpD,UAAM,IAAI,oBAAoB,UAAU,OAAO;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,cACJ,QACA,UAC6B;AAC7B,UAAM,IAAI,oBAAoB,iBAAiB,OAAO;AAAA,EACxD;AAAA,EAEA,YAAY,QA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