@renown/sdk 5.1.0-dev.2 → 5.1.0-dev.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.
Files changed (79) hide show
  1. package/README.md +487 -1
  2. package/dist/src/common.d.ts +1 -1
  3. package/dist/src/common.d.ts.map +1 -1
  4. package/dist/src/components/RenownAuthButton.d.ts +92 -0
  5. package/dist/src/components/RenownAuthButton.d.ts.map +1 -0
  6. package/dist/src/components/RenownAuthButton.js +122 -0
  7. package/dist/src/components/RenownAuthButton.js.map +1 -0
  8. package/dist/src/components/index.d.ts +2 -3
  9. package/dist/src/components/index.d.ts.map +1 -1
  10. package/dist/src/components/index.js +1 -1
  11. package/dist/src/components/index.js.map +1 -1
  12. package/dist/src/constants.d.ts +1 -1
  13. package/dist/src/constants.d.ts.map +1 -1
  14. package/dist/src/constants.js +1 -1
  15. package/dist/src/constants.js.map +1 -1
  16. package/dist/src/hooks/index.d.ts +2 -0
  17. package/dist/src/hooks/index.d.ts.map +1 -0
  18. package/dist/src/hooks/index.js +2 -0
  19. package/dist/src/hooks/index.js.map +1 -0
  20. package/dist/src/hooks/use-user.d.ts +21 -0
  21. package/dist/src/hooks/use-user.d.ts.map +1 -0
  22. package/dist/src/hooks/use-user.js +30 -0
  23. package/dist/src/hooks/use-user.js.map +1 -0
  24. package/dist/src/index.d.ts +7 -0
  25. package/dist/src/index.d.ts.map +1 -1
  26. package/dist/src/index.js +7 -0
  27. package/dist/src/index.js.map +1 -1
  28. package/dist/src/lib/crypto/browser.d.ts +8 -0
  29. package/dist/src/lib/crypto/browser.d.ts.map +1 -0
  30. package/dist/src/lib/crypto/browser.js +73 -0
  31. package/dist/src/lib/crypto/browser.js.map +1 -0
  32. package/dist/src/lib/crypto/index.d.ts +36 -0
  33. package/dist/src/lib/crypto/index.d.ts.map +1 -0
  34. package/dist/src/lib/crypto/index.js +150 -0
  35. package/dist/src/lib/crypto/index.js.map +1 -0
  36. package/dist/src/lib/crypto/node.d.ts +8 -0
  37. package/dist/src/lib/crypto/node.d.ts.map +1 -0
  38. package/dist/src/lib/crypto/node.js +67 -0
  39. package/dist/src/lib/crypto/node.js.map +1 -0
  40. package/dist/src/lib/renown/constants.d.ts +130 -0
  41. package/dist/src/lib/renown/constants.d.ts.map +1 -0
  42. package/dist/src/lib/renown/constants.js +40 -0
  43. package/dist/src/lib/renown/constants.js.map +1 -0
  44. package/dist/src/lib/renown/did-parser.d.ts +28 -0
  45. package/dist/src/lib/renown/did-parser.d.ts.map +1 -0
  46. package/dist/src/lib/renown/did-parser.js +57 -0
  47. package/dist/src/lib/renown/did-parser.js.map +1 -0
  48. package/dist/src/lib/renown/index.d.ts +4 -0
  49. package/dist/src/lib/renown/index.d.ts.map +1 -0
  50. package/dist/src/lib/renown/index.js +4 -0
  51. package/dist/src/lib/renown/index.js.map +1 -0
  52. package/dist/src/lib/renown/utils.d.ts +32 -0
  53. package/dist/src/lib/renown/utils.d.ts.map +1 -0
  54. package/dist/src/lib/renown/utils.js +199 -0
  55. package/dist/src/lib/renown/utils.js.map +1 -0
  56. package/dist/src/lib/session-storage.d.ts +40 -0
  57. package/dist/src/lib/session-storage.d.ts.map +1 -0
  58. package/dist/src/lib/session-storage.js +107 -0
  59. package/dist/src/lib/session-storage.js.map +1 -0
  60. package/dist/src/providers/index.d.ts +3 -0
  61. package/dist/src/providers/index.d.ts.map +1 -0
  62. package/dist/src/providers/index.js +2 -0
  63. package/dist/src/providers/index.js.map +1 -0
  64. package/dist/src/providers/user-provider.d.ts +66 -0
  65. package/dist/src/providers/user-provider.d.ts.map +1 -0
  66. package/dist/src/providers/user-provider.js +159 -0
  67. package/dist/src/providers/user-provider.js.map +1 -0
  68. package/dist/src/types.d.ts +3 -2
  69. package/dist/src/types.d.ts.map +1 -1
  70. package/dist/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +13 -5
  72. package/dist/src/components/RenownLoginAvatar.d.ts +0 -44
  73. package/dist/src/components/RenownLoginAvatar.d.ts.map +0 -1
  74. package/dist/src/components/RenownLoginAvatar.js +0 -50
  75. package/dist/src/components/RenownLoginAvatar.js.map +0 -1
  76. package/dist/src/components/types.d.ts +0 -12
  77. package/dist/src/components/types.d.ts.map +0 -1
  78. package/dist/src/components/types.js +0 -2
  79. package/dist/src/components/types.js.map +0 -1
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React from "react";
4
+ import { useUser } from "../hooks/use-user.js";
5
+ /**
6
+ * Smart authentication button that adapts based on auth state
7
+ * Shows login button when not authenticated, and user info when authenticated
8
+ *
9
+ * @example
10
+ * Basic usage:
11
+ * ```tsx
12
+ * import { RenownAuthButton } from '@renown/sdk'
13
+ *
14
+ * function Header() {
15
+ * return <RenownAuthButton />
16
+ * }
17
+ * ```
18
+ *
19
+ * @example
20
+ * Custom rendering:
21
+ * ```tsx
22
+ * <RenownAuthButton
23
+ * renderAuthenticated={({ user, logout }) => (
24
+ * <div>
25
+ * <span>{user.name}</span>
26
+ * <button onClick={logout}>Sign out</button>
27
+ * </div>
28
+ * )}
29
+ * renderUnauthenticated={({ openRenown }) => (
30
+ * <button onClick={openRenown}>Sign In</button>
31
+ * )}
32
+ * />
33
+ * ```
34
+ *
35
+ * @example
36
+ * With logout button:
37
+ * ```tsx
38
+ * <RenownAuthButton
39
+ * showLogoutButton
40
+ * logoutButtonText="Sign Out"
41
+ * profileBaseUrl="https://myapp.com/profile"
42
+ * />
43
+ * ```
44
+ */
45
+ export function RenownAuthButton({ className = "", profileBaseUrl = "https://www.renown.id/profile", renderAuthenticated, renderUnauthenticated, renderLoading, showUsername = true, showLogoutButton = false, logoutButtonText = "Logout", }) {
46
+ const { user, loginStatus, isLoading, openRenown, logout } = useUser();
47
+ const openProfile = () => {
48
+ if (!user)
49
+ return;
50
+ const identifier = user.ethAddress || user.address || user.name;
51
+ if (identifier) {
52
+ window.open(`${profileBaseUrl}/${identifier}`, "_blank");
53
+ }
54
+ };
55
+ // Loading state
56
+ if (isLoading && loginStatus === "initial") {
57
+ if (renderLoading) {
58
+ return _jsx("div", { className: className, children: renderLoading() });
59
+ }
60
+ return (_jsxs("div", { className: className, style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [_jsx("div", { style: {
61
+ width: "1rem",
62
+ height: "1rem",
63
+ border: "2px solid #e5e7eb",
64
+ borderTopColor: "#6366f1",
65
+ borderRadius: "50%",
66
+ animation: "spin 1s linear infinite",
67
+ } }), _jsx("span", { style: { fontSize: "0.875rem" }, children: "Loading..." })] }));
68
+ }
69
+ // Authenticated state
70
+ if (loginStatus === "authorized" && user) {
71
+ if (renderAuthenticated) {
72
+ return (_jsx("div", { className: className, children: renderAuthenticated({ user, logout, openProfile }) }));
73
+ }
74
+ // Default authenticated rendering
75
+ return (_jsxs("div", { className: className, style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [_jsxs("div", { onClick: openProfile, style: {
76
+ display: "flex",
77
+ alignItems: "center",
78
+ gap: "0.5rem",
79
+ cursor: "pointer",
80
+ }, children: [user.avatar ? (_jsx("img", { src: user.avatar, alt: user.name || "User", style: {
81
+ width: "2rem",
82
+ height: "2rem",
83
+ borderRadius: "50%",
84
+ objectFit: "cover",
85
+ } })) : (_jsx("div", { style: {
86
+ width: "2rem",
87
+ height: "2rem",
88
+ borderRadius: "50%",
89
+ backgroundColor: "#6366f1",
90
+ color: "white",
91
+ display: "flex",
92
+ alignItems: "center",
93
+ justifyContent: "center",
94
+ fontWeight: "bold",
95
+ fontSize: "0.75rem",
96
+ }, children: (user.name || user.did).substring(0, 2).toUpperCase() })), showUsername && (_jsx("span", { style: { fontSize: "0.875rem", fontWeight: "500" }, children: user.name || user.did.slice(0, 15) + "..." }))] }), showLogoutButton && (_jsx("button", { onClick: logout, style: {
97
+ padding: "0.25rem 0.75rem",
98
+ border: "1px solid #d1d5db",
99
+ borderRadius: "0.375rem",
100
+ backgroundColor: "white",
101
+ cursor: "pointer",
102
+ fontSize: "0.75rem",
103
+ fontWeight: "500",
104
+ }, children: logoutButtonText }))] }));
105
+ }
106
+ // Unauthenticated state
107
+ if (renderUnauthenticated) {
108
+ return (_jsx("div", { className: className, children: renderUnauthenticated({ openRenown, isLoading }) }));
109
+ }
110
+ // Default unauthenticated rendering
111
+ return (_jsx("button", { onClick: openRenown, disabled: isLoading, className: className, style: {
112
+ padding: "0.5rem 1rem",
113
+ border: "1px solid #d1d5db",
114
+ borderRadius: "0.375rem",
115
+ backgroundColor: "white",
116
+ cursor: isLoading ? "not-allowed" : "pointer",
117
+ fontSize: "0.875rem",
118
+ fontWeight: "500",
119
+ opacity: isLoading ? 0.6 : 1,
120
+ }, children: isLoading ? "Loading..." : "Login with Renown" }));
121
+ }
122
+ //# sourceMappingURL=RenownAuthButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenownAuthButton.js","sourceRoot":"","sources":["../../../src/components/RenownAuthButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAqD/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,SAAS,GAAG,EAAE,EACd,cAAc,GAAG,+BAA+B,EAChD,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,YAAY,GAAG,IAAI,EACnB,gBAAgB,GAAG,KAAK,EACxB,gBAAgB,GAAG,QAAQ,GACL;IACtB,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;IAEvE,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CA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AgB,GACV,CACV,IACG,CACP,CAAC;IACJ,CAAC;IAED,wBAAwB;IACxB,IAAI,qBAAqB,EAAE,CAAC;QAC1B,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,YACtB,qBAAqB,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,GAC7C,CACP,CAAC;IACJ,CAAC;IAED,oCAAoC;IACpC,OAAO,CACL,iBACE,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE;YACL,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,mBAAmB;YAC3B,YAAY,EAAE,UAAU;YACxB,eAAe,EAAE,OAAO;YACxB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YAC7C,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC7B,YAEA,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,mBAAmB,GACxC,CACV,CAAC;AACJ,CAAC"}
@@ -1,4 +1,3 @@
1
- export { RenownLoginAvatar } from "./RenownLoginAvatar.js";
2
- export type { RenownLoginAvatarProps } from "./RenownLoginAvatar.js";
3
- export type { RenownUser, LoginAvatarProps } from "./types.js";
1
+ export { RenownAuthButton } from "./RenownAuthButton.js";
2
+ export type { RenownAuthButtonProps, RenownAuthButtonRenderProps, } from "./RenownAuthButton.js";
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EACV,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC"}
@@ -1,2 +1,2 @@
1
- export { RenownLoginAvatar } from "./RenownLoginAvatar.js";
1
+ export { RenownAuthButton } from "./RenownAuthButton.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare const DEFAULT_RENOWN_URL = "https://auth.renown.id";
1
+ export declare const DEFAULT_RENOWN_URL = "https://www.renown.id";
2
2
  export declare const DEFAULT_RENOWN_NETWORK_ID = "eip155";
3
3
  export declare const DEFAULT_RENOWN_CHAIN_ID = "1";
4
4
  export declare const DOMAIN_TYPE: readonly [{
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAC3D,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,WAAW;;;;;;;;;;;;EAKd,CAAC;AAEX,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;EASpC,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;;;;EAGhC,CAAC;AAEX,eAAO,MAAM,uBAAuB;;;;;;;;;EAI1B,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;EAGd,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMnB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAC1D,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,WAAW;;;;;;;;;;;;EAKd,CAAC;AAEX,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;EASpC,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;;;;EAGhC,CAAC;AAEX,eAAO,MAAM,uBAAuB;;;;;;;;;EAI1B,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;EAGd,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMnB,CAAC"}
@@ -1,4 +1,4 @@
1
- export const DEFAULT_RENOWN_URL = "https://auth.renown.id";
1
+ export const DEFAULT_RENOWN_URL = "https://www.renown.id";
2
2
  export const DEFAULT_RENOWN_NETWORK_ID = "eip155";
3
3
  export const DEFAULT_RENOWN_CHAIN_ID = "1";
4
4
  export const DOMAIN_TYPE = [
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,QAAQ,CAAC;AAClD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,E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AkB,EAAE;IACtD,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE;CAClC,CAAC;AAEX,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;CACxB,CAAC;AAEX,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;CACxB,CAAC;AAEX,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE;CACnC,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY,EAAE,WAAW;IACzB,oBAAoB,EAAE,iCAAiC;IACvD,gBAAgB,EAAE,6BAA6B;IAC/C,iBAAiB,EAAE,uBAAuB;IAC1C,MAAM,EAAE,WAAW;CACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useUser } from "./use-user.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useUser } from "./use-user.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * useUser Hook - Access user context
3
+ *
4
+ * Provides access to the current user and authentication methods.
5
+ * Must be used within a UserProvider.
6
+ *
7
+ * @throws Error if used outside of UserProvider
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * function MyComponent() {
12
+ * const { user, loginStatus, isLoading, login, logout, openRenown } = useUser()
13
+ *
14
+ * if (isLoading) return <div>Loading...</div>
15
+ * if (!user) return <button onClick={openRenown}>Login</button>
16
+ * return <div>Welcome {user.name || user.did}</div>
17
+ * }
18
+ * ```
19
+ */
20
+ export declare function useUser(): import("../providers/user-provider.js").UserContextValue;
21
+ //# sourceMappingURL=use-user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-user.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-user.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,6DAQtB"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { useContext } from "react";
3
+ import { UserContext } from "../providers/user-provider.js";
4
+ /**
5
+ * useUser Hook - Access user context
6
+ *
7
+ * Provides access to the current user and authentication methods.
8
+ * Must be used within a UserProvider.
9
+ *
10
+ * @throws Error if used outside of UserProvider
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * function MyComponent() {
15
+ * const { user, loginStatus, isLoading, login, logout, openRenown } = useUser()
16
+ *
17
+ * if (isLoading) return <div>Loading...</div>
18
+ * if (!user) return <button onClick={openRenown}>Login</button>
19
+ * return <div>Welcome {user.name || user.did}</div>
20
+ * }
21
+ * ```
22
+ */
23
+ export function useUser() {
24
+ const context = useContext(UserContext);
25
+ if (!context) {
26
+ throw new Error("useUser must be used within a UserProvider");
27
+ }
28
+ return context;
29
+ }
30
+ //# sourceMappingURL=use-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-user.js","sourceRoot":"","sources":["../../../src/hooks/use-user.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAExC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -3,4 +3,11 @@ export { initRenown } from "./init.browser.js";
3
3
  export * from "./types.js";
4
4
  export * from "./utils.js";
5
5
  export * from "./components/index.js";
6
+ export * from "./providers/index.js";
7
+ export * from "./hooks/index.js";
8
+ export { RENOWN_URL, RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, } from "./lib/renown/constants.js";
9
+ export { extractEthAddressFromDid } from "./lib/renown/did-parser.js";
10
+ export { login, logout, openRenown, handleRenownReturn, fetchProfileDataForUser, reauthenticateFromSession, } from "./lib/renown/utils.js";
11
+ export type { LoginStatus, User as SimpleUser } from "./lib/renown/utils.js";
12
+ export { SessionStorageManager } from "./lib/session-storage.js";
6
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,eAAe,EACf,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,KAAK,EACL,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,WAAW,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/src/index.js CHANGED
@@ -3,4 +3,11 @@ export { initRenown } from "./init.browser.js";
3
3
  export * from "./types.js";
4
4
  export * from "./utils.js";
5
5
  export * from "./components/index.js";
6
+ export * from "./providers/index.js";
7
+ export * from "./hooks/index.js";
8
+ // Export specific items from lib/renown to avoid conflicts
9
+ export { RENOWN_URL, RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, } from "./lib/renown/constants.js";
10
+ export { extractEthAddressFromDid } from "./lib/renown/did-parser.js";
11
+ export { login, logout, openRenown, handleRenownReturn, fetchProfileDataForUser, reauthenticateFromSession, } from "./lib/renown/utils.js";
12
+ export { SessionStorageManager } from "./lib/session-storage.js";
6
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,2DAA2D;AAC3D,OAAO,EACL,UAAU,EACV,eAAe,EACf,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,KAAK,EACL,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { JsonWebKeyPairStorage, JwkKeyPair } from "./index.js";
2
+ export declare class BrowserKeyStorage implements JsonWebKeyPairStorage {
3
+ #private;
4
+ constructor();
5
+ saveKeyPair(keyPair: JwkKeyPair): Promise<void>;
6
+ loadKeyPair(): Promise<JwkKeyPair | undefined>;
7
+ }
8
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../src/lib/crypto/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpE,qBAAa,iBAAkB,YAAW,qBAAqB;;;IAgEvD,WAAW,CAAC,OAAO,EAAE,UAAU;IAa/B,WAAW,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;CAcrD"}
@@ -0,0 +1,73 @@
1
+ export class BrowserKeyStorage {
2
+ static #DB_NAME = "browserKeyDB";
3
+ static #STORE_NAME = "keyPairs";
4
+ static #KEY = "keyPair";
5
+ #db;
6
+ constructor() {
7
+ this.#db = this.#initializeDatabase();
8
+ }
9
+ #initializeDatabase() {
10
+ return new Promise((resolve, reject) => {
11
+ // Open without version to get current version or create new database
12
+ const req = indexedDB.open(BrowserKeyStorage.#DB_NAME);
13
+ req.onupgradeneeded = this.#handleDatabaseUpgrade;
14
+ req.onsuccess = () => this.#handleDatabaseSuccess(req.result, resolve, reject);
15
+ req.onerror = () => reject(req.error);
16
+ });
17
+ }
18
+ #handleDatabaseUpgrade = (event) => {
19
+ const db = event.target.result;
20
+ this.#ensureObjectStoreExists(db);
21
+ };
22
+ #handleDatabaseSuccess = (db, resolve, reject) => {
23
+ if (!db.objectStoreNames.contains(BrowserKeyStorage.#STORE_NAME)) {
24
+ // Close and reopen with a higher version to create the missing object store
25
+ const currentVersion = db.version;
26
+ db.close();
27
+ const upgradeReq = indexedDB.open(BrowserKeyStorage.#DB_NAME, currentVersion + 1);
28
+ upgradeReq.onupgradeneeded = this.#handleDatabaseUpgrade;
29
+ upgradeReq.onsuccess = () => resolve(upgradeReq.result);
30
+ upgradeReq.onerror = () => reject(upgradeReq.error);
31
+ }
32
+ else {
33
+ resolve(db);
34
+ }
35
+ };
36
+ #ensureObjectStoreExists(db) {
37
+ if (!db.objectStoreNames.contains(BrowserKeyStorage.#STORE_NAME)) {
38
+ db.createObjectStore(BrowserKeyStorage.#STORE_NAME);
39
+ }
40
+ }
41
+ async #useStore(mode = "readwrite") {
42
+ const database = await this.#db;
43
+ const transaction = database.transaction(BrowserKeyStorage.#STORE_NAME, mode);
44
+ const store = transaction.objectStore(BrowserKeyStorage.#STORE_NAME);
45
+ return store;
46
+ }
47
+ async saveKeyPair(keyPair) {
48
+ const store = await this.#useStore();
49
+ const request = store.put(keyPair, BrowserKeyStorage.#KEY);
50
+ return new Promise((resolve, reject) => {
51
+ request.onsuccess = () => {
52
+ resolve();
53
+ };
54
+ request.onerror = () => {
55
+ reject(new Error("Failed to save key pair"));
56
+ };
57
+ });
58
+ }
59
+ async loadKeyPair() {
60
+ const store = await this.#useStore("readonly");
61
+ const request = store.get(BrowserKeyStorage.#KEY);
62
+ return new Promise((resolve, reject) => {
63
+ request.onsuccess = () => {
64
+ const keyPair = request.result;
65
+ resolve(keyPair);
66
+ };
67
+ request.onerror = () => {
68
+ reject(new Error("Failed to load key pair"));
69
+ };
70
+ });
71
+ }
72
+ }
73
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../../src/lib/crypto/browser.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC;IACjC,MAAM,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,MAAM,CAAC,IAAI,GAAG,SAAS,CAAC;IAExB,GAAG,CAAuB;IAE1B;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACxC,CAAC;IAED,mBAAmB;QACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,qEAAqE;YACrE,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YACvD,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC;YAClD,GAAG,CAAC,SAAS,GAAG,GAAG,EAAE,CACnB,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAC3D,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAc,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,sBAAsB,GAAG,CAAC,KAA4B,EAAQ,EAAE;QAC9D,MAAM,EAAE,GAAI,KAAK,CAAC,MAA2B,CAAC,MAAM,CAAC;QACrD,IAAI,CAAC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E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAmB;QACnC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC3D,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE;gBACvB,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;YACF,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE;gBACrB,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;YAC/C,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAElD,OAAO,IAAI,OAAO,CAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC7D,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE;gBACvB,MAAM,OAAO,GAAG,OAAO,CAAC,MAAgC,CAAC;gBACzD,OAAO,CAAC,OAAO,CAAC,CAAC;YACnB,CAAC,CAAC;YACF,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE;gBACrB,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;YAC/C,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { CreateBearerTokenOptions } from "@renown/sdk";
2
+ import type { Issuer } from "did-jwt-vc";
3
+ export type JwkKeyPair = {
4
+ publicKey: JsonWebKey;
5
+ privateKey: JsonWebKey;
6
+ };
7
+ export interface JsonWebKeyPairStorage {
8
+ loadKeyPair(): Promise<JwkKeyPair | undefined>;
9
+ saveKeyPair(keyPair: JwkKeyPair): Promise<void>;
10
+ }
11
+ export interface IConnectCrypto {
12
+ did: () => Promise<DID>;
13
+ regenerateDid(): Promise<void>;
14
+ sign: (data: Uint8Array) => Promise<Uint8Array>;
15
+ getIssuer: () => Promise<Issuer>;
16
+ getBearerToken: (driveUrl: string, address: string | undefined, refresh?: boolean, options?: CreateBearerTokenOptions) => Promise<string>;
17
+ }
18
+ export type DID = `did:key:${string}`;
19
+ export declare class ConnectCrypto implements IConnectCrypto {
20
+ #private;
21
+ static algorithm: EcKeyAlgorithm;
22
+ static signAlgorithm: {
23
+ name: string;
24
+ namedCurve: string;
25
+ hash: string;
26
+ };
27
+ constructor(keyPairStorage: JsonWebKeyPairStorage);
28
+ getBearerToken(driveUrl: string, address: string | undefined, refresh?: boolean, options?: CreateBearerTokenOptions): Promise<string>;
29
+ did(): Promise<`did:key:${string}`>;
30
+ regenerateDid(): Promise<void>;
31
+ sign(data: Uint8Array | string): Promise<Uint8Array>;
32
+ getIssuer(): Promise<Issuer>;
33
+ }
34
+ export * from "./browser.js";
35
+ export * from "./node.js";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/crypto/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAWzC,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,UAAU,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,WAAW,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAC/C,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAQD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAChD,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,cAAc,EAAE,CACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,CAAC,EAAE,OAAO,EACjB,OAAO,CAAC,EAAE,wBAAwB,KAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED,MAAM,MAAM,GAAG,GAAG,WAAW,MAAM,EAAE,CAAC;AAEtC,qBAAa,aAAc,YAAW,cAAc;;IAQlD,MAAM,CAAC,SAAS,EAAE,cAAc,CAG9B;IAEF,MAAM,CAAC,aAAa;;;;MAIlB;gBAEU,cAAc,EAAE,qBAAqB;IAwC3C,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,UAAQ,EACf,OAAO,CAAC,EAAE,wBAAwB;IAgBpC,GAAG;IAIG,aAAa;IAiFb,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAmBpD,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;CAgBnC;AACD,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,150 @@
1
+ /* eslint-disable no-unused-private-class-members */
2
+ import { createAuthBearerToken } from "@renown/sdk";
3
+ import { bytesToBase64url } from "did-jwt";
4
+ import { compressedKeyInHexfromRaw, encodeDIDfromHexString, rawKeyInHexfromUncompressed, } from "did-key-creator";
5
+ import { fromString } from "uint8arrays";
6
+ const RENOWN_NETWORK_ID = "eip155";
7
+ const RENOWN_CHAIN_ID = 1;
8
+ function ab2hex(ab) {
9
+ return Array.prototype.map
10
+ .call(new Uint8Array(ab), (x) => ("00" + x.toString(16)).slice(-2))
11
+ .join("");
12
+ }
13
+ export class ConnectCrypto {
14
+ #subtleCrypto;
15
+ #keyPair;
16
+ #keyPairStorage;
17
+ #did;
18
+ #bearerToken;
19
+ static algorithm = {
20
+ name: "ECDSA",
21
+ namedCurve: "P-256",
22
+ };
23
+ static signAlgorithm = {
24
+ name: "ECDSA",
25
+ namedCurve: "P-256",
26
+ hash: "SHA-256",
27
+ };
28
+ constructor(keyPairStorage) {
29
+ this.#keyPairStorage = keyPairStorage;
30
+ // Initializes the subtleCrypto module according to the host environment
31
+ this.#subtleCrypto = this.#initCrypto();
32
+ this.#did = this.#initialize();
33
+ }
34
+ #initCrypto() {
35
+ return new Promise((resolve, reject) => {
36
+ if (typeof window === "undefined") {
37
+ import("node:crypto")
38
+ .then((module) => {
39
+ resolve(module.webcrypto.subtle);
40
+ })
41
+ .catch(reject);
42
+ }
43
+ else {
44
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
45
+ if (!window.crypto?.subtle) {
46
+ reject(new Error("Crypto module not available"));
47
+ }
48
+ resolve(window.crypto.subtle);
49
+ }
50
+ });
51
+ }
52
+ // loads the key pair from storage or generates a new one if none is stored
53
+ async #initialize() {
54
+ const loadedKeyPair = await this.#keyPairStorage.loadKeyPair();
55
+ if (loadedKeyPair) {
56
+ this.#keyPair = await this.#importKeyPair(loadedKeyPair);
57
+ }
58
+ else {
59
+ this.#keyPair = await this.#generateECDSAKeyPair();
60
+ await this.#keyPairStorage.saveKeyPair(await this.#exportKeyPair());
61
+ }
62
+ const did = await this.#parseDid();
63
+ return did;
64
+ }
65
+ async getBearerToken(driveUrl, address, refresh = false, options) {
66
+ const issuer = await this.getIssuer();
67
+ if (refresh || !this.#bearerToken) {
68
+ this.#bearerToken = await createAuthBearerToken(Number(RENOWN_CHAIN_ID), RENOWN_NETWORK_ID, address || (await this.#did), issuer, options);
69
+ }
70
+ return this.#bearerToken;
71
+ }
72
+ did() {
73
+ return this.#did;
74
+ }
75
+ async regenerateDid() {
76
+ this.#keyPair = await this.#generateECDSAKeyPair();
77
+ await this.#keyPairStorage.saveKeyPair(await this.#exportKeyPair());
78
+ }
79
+ async #parseDid() {
80
+ if (!this.#keyPair) {
81
+ throw new Error("No key pair available");
82
+ }
83
+ const subtleCrypto = await this.#subtleCrypto;
84
+ const publicKeyRaw = await subtleCrypto.exportKey("raw", this.#keyPair.publicKey);
85
+ const multicodecName = "p256-pub";
86
+ const rawKey = rawKeyInHexfromUncompressed(ab2hex(publicKeyRaw));
87
+ const compressedKey = compressedKeyInHexfromRaw(rawKey);
88
+ const did = encodeDIDfromHexString(multicodecName, compressedKey);
89
+ return did;
90
+ }
91
+ async #generateECDSAKeyPair() {
92
+ const subtleCrypto = await this.#subtleCrypto;
93
+ const keyPair = await subtleCrypto.generateKey(ConnectCrypto.algorithm, true, ["sign", "verify"]);
94
+ return keyPair;
95
+ }
96
+ async #exportKeyPair() {
97
+ if (!this.#keyPair) {
98
+ throw new Error("No key pair available");
99
+ }
100
+ const subtleCrypto = await this.#subtleCrypto;
101
+ const jwkKeyPair = {
102
+ publicKey: await subtleCrypto.exportKey("jwk", this.#keyPair.publicKey),
103
+ privateKey: await subtleCrypto.exportKey("jwk", this.#keyPair.privateKey),
104
+ };
105
+ return jwkKeyPair;
106
+ }
107
+ async #importKeyPair(jwkKeyPair) {
108
+ const subtleCrypto = await this.#subtleCrypto;
109
+ return {
110
+ publicKey: await subtleCrypto.importKey("jwk", jwkKeyPair.publicKey, ConnectCrypto.algorithm, true, ["verify"]),
111
+ privateKey: await subtleCrypto.importKey("jwk", jwkKeyPair.privateKey, ConnectCrypto.algorithm, true, ["sign"]),
112
+ };
113
+ }
114
+ #sign = async (...args) => {
115
+ return (await this.#subtleCrypto).sign(...args);
116
+ };
117
+ #verify = async (...args) => {
118
+ return (await this.#subtleCrypto).verify(...args);
119
+ };
120
+ #stringToBytes(s) {
121
+ return fromString(s, "utf-8");
122
+ }
123
+ async sign(data) {
124
+ if (this.#keyPair?.privateKey) {
125
+ const dataBytes = typeof data === "string" ? this.#stringToBytes(data) : data;
126
+ const subtleCrypto = await this.#subtleCrypto;
127
+ const arrayBuffer = await subtleCrypto.sign(ConnectCrypto.signAlgorithm, this.#keyPair.privateKey, dataBytes.buffer);
128
+ return new Uint8Array(arrayBuffer);
129
+ }
130
+ else {
131
+ throw new Error("No private key available");
132
+ }
133
+ }
134
+ async getIssuer() {
135
+ if (!this.#keyPair?.privateKey) {
136
+ throw new Error("No private key available");
137
+ }
138
+ return {
139
+ did: await this.#did,
140
+ signer: async (data) => {
141
+ const signature = await this.sign(typeof data === "string" ? new TextEncoder().encode(data) : data);
142
+ return bytesToBase64url(signature);
143
+ },
144
+ alg: "ES256",
145
+ };
146
+ }
147
+ }
148
+ export * from "./browser.js";
149
+ export * from "./node.js";
150
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/crypto/index.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAGpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,eAAe,GAAG,CAAC,CAAC;AAY1B,SAAS,MAAM,CAAC,EAAe;IAC7B,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;SACvB,IAAI,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC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a,EAC3B,IAAI,CAAC,QAAQ,CAAC,UAAU,EACxB,SAAS,CAAC,MAAqB,CAChC,CAAC;YAEF,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO;YACL,GAAG,EAAE,MAAM,IAAI,CAAC,IAAI;YACpB,MAAM,EAAE,KAAK,EAAE,IAAyB,EAAE,EAAE;gBAC1C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,IAAI,CAC/B,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CACjE,CAAC;gBACF,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;YACrC,CAAC;YACD,GAAG,EAAE,OAAO;SACb,CAAC;IACJ,CAAC;;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { JsonWebKeyPairStorage, JwkKeyPair } from "./index.js";
2
+ export declare class NodeKeyStorage implements JsonWebKeyPairStorage {
3
+ #private;
4
+ constructor(filePath?: string);
5
+ saveKeyPair(keyPair: JwkKeyPair): Promise<void>;
6
+ loadKeyPair(): Promise<JwkKeyPair | undefined>;
7
+ }
8
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/lib/crypto/node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpE,qBAAa,cAAe,YAAW,qBAAqB;;gBAO9C,QAAQ,CAAC,EAAE,MAAM;IAuCvB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/C,WAAW,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;CASrD"}