@renown/sdk 6.0.0-dev.8 → 6.0.0-dev.81
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/src/common.d.ts +16 -8
- package/dist/src/common.d.ts.map +1 -1
- package/dist/src/common.js +78 -38
- package/dist/src/common.js.map +1 -1
- package/dist/src/crypto/browser-key-storage.d.ts +4 -2
- package/dist/src/crypto/browser-key-storage.d.ts.map +1 -1
- package/dist/src/crypto/browser-key-storage.js +54 -51
- package/dist/src/crypto/browser-key-storage.js.map +1 -1
- package/dist/src/crypto/common.d.ts +6 -0
- package/dist/src/crypto/common.d.ts.map +1 -0
- package/dist/src/crypto/common.js +8 -0
- package/dist/src/crypto/common.js.map +1 -0
- package/dist/src/crypto/index.d.ts +1 -34
- package/dist/src/crypto/index.d.ts.map +1 -1
- package/dist/src/crypto/index.js +1 -128
- package/dist/src/crypto/index.js.map +1 -1
- package/dist/src/crypto/memory-key-storage.d.ts +9 -0
- package/dist/src/crypto/memory-key-storage.d.ts.map +1 -0
- package/dist/src/crypto/memory-key-storage.js +18 -0
- package/dist/src/crypto/memory-key-storage.js.map +1 -0
- package/dist/src/crypto/node-key-storage.d.ts +16 -3
- package/dist/src/crypto/node-key-storage.d.ts.map +1 -1
- package/dist/src/crypto/node-key-storage.js +82 -42
- package/dist/src/crypto/node-key-storage.js.map +1 -1
- package/dist/src/crypto/node.d.ts +1 -0
- package/dist/src/crypto/node.d.ts.map +1 -1
- package/dist/src/crypto/node.js +1 -1
- package/dist/src/crypto/node.js.map +1 -1
- package/dist/src/crypto/renown-crypto-builder.d.ts +11 -0
- package/dist/src/crypto/renown-crypto-builder.d.ts.map +1 -0
- package/dist/src/crypto/renown-crypto-builder.js +34 -0
- package/dist/src/crypto/renown-crypto-builder.js.map +1 -0
- package/dist/src/crypto/renown-crypto.d.ts +26 -0
- package/dist/src/crypto/renown-crypto.d.ts.map +1 -0
- package/dist/src/crypto/renown-crypto.js +56 -0
- package/dist/src/crypto/renown-crypto.js.map +1 -0
- package/dist/src/crypto/signer.d.ts +61 -8
- package/dist/src/crypto/signer.d.ts.map +1 -1
- package/dist/src/crypto/signer.js +98 -28
- package/dist/src/crypto/signer.js.map +1 -1
- package/dist/src/crypto/types.d.ts +27 -0
- package/dist/src/crypto/types.d.ts.map +1 -0
- package/dist/src/crypto/types.js +2 -0
- package/dist/src/crypto/types.js.map +1 -0
- package/dist/src/crypto/utils.d.ts +13 -0
- package/dist/src/crypto/utils.d.ts.map +1 -0
- package/dist/src/crypto/utils.js +39 -0
- package/dist/src/crypto/utils.js.map +1 -0
- package/dist/src/event/event.browser.d.ts.map +1 -1
- package/dist/src/event/event.node.d.ts.map +1 -1
- package/dist/src/event/memory.d.ts +8 -0
- package/dist/src/event/memory.d.ts.map +1 -0
- package/dist/src/event/memory.js +16 -0
- package/dist/src/event/memory.js.map +1 -0
- package/dist/src/index.d.ts +4 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/init.browser.d.ts +51 -2
- package/dist/src/init.browser.d.ts.map +1 -1
- package/dist/src/init.browser.js +62 -3
- package/dist/src/init.browser.js.map +1 -1
- package/dist/src/init.node.d.ts +28 -2
- package/dist/src/init.node.d.ts.map +1 -1
- package/dist/src/init.node.js +26 -4
- package/dist/src/init.node.js.map +1 -1
- package/dist/src/node.d.ts +7 -3
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +7 -3
- package/dist/src/node.js.map +1 -1
- package/dist/src/profile.d.ts +3 -0
- package/dist/src/profile.d.ts.map +1 -0
- package/dist/src/profile.js +22 -0
- package/dist/src/profile.js.map +1 -0
- package/dist/src/renown-builder.d.ts +68 -0
- package/dist/src/renown-builder.d.ts.map +1 -0
- package/dist/src/renown-builder.js +130 -0
- package/dist/src/renown-builder.js.map +1 -0
- package/dist/src/storage/common.d.ts +14 -10
- package/dist/src/storage/common.d.ts.map +1 -1
- package/dist/src/storage/common.js +16 -3
- package/dist/src/storage/common.js.map +1 -1
- package/dist/src/storage/storage.browser.d.ts +1 -0
- package/dist/src/storage/storage.browser.d.ts.map +1 -1
- package/dist/src/storage/storage.browser.js +3 -1
- package/dist/src/storage/storage.browser.js.map +1 -1
- package/dist/src/storage/storage.node.d.ts +1 -1
- package/dist/src/storage/storage.node.d.ts.map +1 -1
- package/dist/src/storage/storage.node.js +7 -5
- package/dist/src/storage/storage.node.js.map +1 -1
- package/dist/src/types.d.ts +51 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +17 -10
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +14 -0
- package/dist/src/utils.js.map +1 -1
- package/dist/{tests → test}/auth.test.d.ts.map +1 -1
- package/dist/test/auth.test.js.map +1 -0
- package/dist/test/crypto/signer.test.d.ts +2 -0
- package/dist/test/crypto/signer.test.d.ts.map +1 -0
- package/dist/test/crypto/signer.test.js +184 -0
- package/dist/test/crypto/signer.test.js.map +1 -0
- package/dist/test/renown.test.d.ts +2 -0
- package/dist/test/renown.test.d.ts.map +1 -0
- package/dist/test/renown.test.js +287 -0
- package/dist/test/renown.test.js.map +1 -0
- package/dist/test/storage.node.test.d.ts +2 -0
- package/dist/test/storage.node.test.d.ts.map +1 -0
- package/dist/test/storage.node.test.js +66 -0
- package/dist/test/storage.node.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{e2e/fixtures/vite.config.d.ts → vitest.config.d.ts} +1 -1
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +7 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +4 -28
- package/dist/e2e/fixtures/main.d.ts +0 -2
- package/dist/e2e/fixtures/main.d.ts.map +0 -1
- package/dist/e2e/fixtures/main.js +0 -97
- package/dist/e2e/fixtures/main.js.map +0 -1
- package/dist/e2e/fixtures/vite.config.d.ts.map +0 -1
- package/dist/e2e/fixtures/vite.config.js +0 -10
- package/dist/e2e/fixtures/vite.config.js.map +0 -1
- package/dist/e2e/renown-components.spec.d.ts +0 -2
- package/dist/e2e/renown-components.spec.d.ts.map +0 -1
- package/dist/e2e/renown-components.spec.js +0 -155
- package/dist/e2e/renown-components.spec.js.map +0 -1
- package/dist/playwright.config.d.ts +0 -3
- package/dist/playwright.config.d.ts.map +0 -1
- package/dist/playwright.config.js +0 -25
- package/dist/playwright.config.js.map +0 -1
- package/dist/src/assets/assets.d.ts +0 -19
- package/dist/src/assets/renown-hover.svg +0 -17
- package/dist/src/assets/renown-light.svg +0 -15
- package/dist/src/assets/renown-short-hover.png +0 -0
- package/dist/src/assets/renown-short.png +0 -0
- package/dist/src/assets/renown.svg +0 -16
- package/dist/src/components/RenownAuthButton.d.ts +0 -62
- package/dist/src/components/RenownAuthButton.d.ts.map +0 -1
- package/dist/src/components/RenownAuthButton.js +0 -82
- package/dist/src/components/RenownAuthButton.js.map +0 -1
- package/dist/src/components/RenownLoginButton.d.ts +0 -48
- package/dist/src/components/RenownLoginButton.d.ts.map +0 -1
- package/dist/src/components/RenownLoginButton.js +0 -175
- package/dist/src/components/RenownLoginButton.js.map +0 -1
- package/dist/src/components/RenownUserButton.d.ts +0 -66
- package/dist/src/components/RenownUserButton.d.ts.map +0 -1
- package/dist/src/components/RenownUserButton.js +0 -216
- package/dist/src/components/RenownUserButton.js.map +0 -1
- package/dist/src/components/icons.d.ts +0 -25
- package/dist/src/components/icons.d.ts.map +0 -1
- package/dist/src/components/icons.js +0 -24
- package/dist/src/components/icons.js.map +0 -1
- package/dist/src/components/image-data.d.ts +0 -3
- package/dist/src/components/image-data.d.ts.map +0 -1
- package/dist/src/components/image-data.js +0 -4
- package/dist/src/components/image-data.js.map +0 -1
- package/dist/src/components/index.d.ts +0 -8
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/components/index.js +0 -5
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/hooks/index.d.ts +0 -2
- package/dist/src/hooks/index.d.ts.map +0 -1
- package/dist/src/hooks/index.js +0 -2
- package/dist/src/hooks/index.js.map +0 -1
- package/dist/src/hooks/use-user.d.ts +0 -21
- package/dist/src/hooks/use-user.d.ts.map +0 -1
- package/dist/src/hooks/use-user.js +0 -30
- package/dist/src/hooks/use-user.js.map +0 -1
- package/dist/src/index.browser.d.ts +0 -4
- package/dist/src/index.browser.d.ts.map +0 -1
- package/dist/src/index.browser.js +0 -4
- package/dist/src/index.browser.js.map +0 -1
- package/dist/src/index.node.d.ts +0 -4
- package/dist/src/index.node.d.ts.map +0 -1
- package/dist/src/index.node.js +0 -4
- package/dist/src/index.node.js.map +0 -1
- package/dist/src/lib/crypto/browser.d.ts +0 -8
- package/dist/src/lib/crypto/browser.d.ts.map +0 -1
- package/dist/src/lib/crypto/browser.js +0 -73
- package/dist/src/lib/crypto/browser.js.map +0 -1
- package/dist/src/lib/crypto/index.d.ts +0 -36
- package/dist/src/lib/crypto/index.d.ts.map +0 -1
- package/dist/src/lib/crypto/index.js +0 -150
- package/dist/src/lib/crypto/index.js.map +0 -1
- package/dist/src/lib/crypto/node.d.ts +0 -8
- package/dist/src/lib/crypto/node.d.ts.map +0 -1
- package/dist/src/lib/crypto/node.js +0 -67
- package/dist/src/lib/crypto/node.js.map +0 -1
- package/dist/src/lib/renown/constants.d.ts +0 -130
- package/dist/src/lib/renown/constants.d.ts.map +0 -1
- package/dist/src/lib/renown/constants.js +0 -40
- package/dist/src/lib/renown/constants.js.map +0 -1
- package/dist/src/lib/renown/did-parser.d.ts +0 -28
- package/dist/src/lib/renown/did-parser.d.ts.map +0 -1
- package/dist/src/lib/renown/did-parser.js +0 -57
- package/dist/src/lib/renown/did-parser.js.map +0 -1
- package/dist/src/lib/renown/index.d.ts +0 -4
- package/dist/src/lib/renown/index.d.ts.map +0 -1
- package/dist/src/lib/renown/index.js +0 -4
- package/dist/src/lib/renown/index.js.map +0 -1
- package/dist/src/lib/renown/utils.d.ts +0 -33
- package/dist/src/lib/renown/utils.d.ts.map +0 -1
- package/dist/src/lib/renown/utils.js +0 -207
- package/dist/src/lib/renown/utils.js.map +0 -1
- package/dist/src/lib/session-storage.d.ts +0 -40
- package/dist/src/lib/session-storage.d.ts.map +0 -1
- package/dist/src/lib/session-storage.js +0 -107
- package/dist/src/lib/session-storage.js.map +0 -1
- package/dist/src/providers/index.d.ts +0 -3
- package/dist/src/providers/index.d.ts.map +0 -1
- package/dist/src/providers/index.js +0 -2
- package/dist/src/providers/index.js.map +0 -1
- package/dist/src/providers/renown-user-provider.d.ts +0 -72
- package/dist/src/providers/renown-user-provider.d.ts.map +0 -1
- package/dist/src/providers/renown-user-provider.js +0 -171
- package/dist/src/providers/renown-user-provider.js.map +0 -1
- package/dist/tests/auth.test.js.map +0 -1
- /package/dist/{tests → test}/auth.test.d.ts +0 -0
- /package/dist/{tests → test}/auth.test.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.node.js","sourceRoot":"","sources":["../../src/init.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"init.node.js","sourceRoot":"","sources":["../../src/init.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,MAAM,OAAO,sBAAuB,SAAQ,gBAA8B;CAAG;AAC7E,MAAM,OAAO,iBAAkB,SAAQ,WAA6B;CAAG;AAEvE,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,CAAC;AAWhE;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAClD;;;OAGG;IACH,YAAY,OAAe,EAAE,UAAoC,EAAE;QACjE,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,MAAM,EACJ,WAAW,GAAG,2BAA2B,EACzC,OAAO,EACP,OAAO,GACR,GAAG,OAAO,CAAC;QAEZ,IAAI,CAAC,kBAAkB,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,WAAW,CAAC,IAAI,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,gBAAgB,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;QACpD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF"}
|
package/dist/src/node.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./crypto/node
|
|
3
|
-
export
|
|
1
|
+
export * from "./common.js";
|
|
2
|
+
export * from "./crypto/node.js";
|
|
3
|
+
export * from "./event/event.node.js";
|
|
4
|
+
export * from "./init.node.js";
|
|
5
|
+
export * from "./profile.js";
|
|
6
|
+
export * from "./renown-builder.js";
|
|
7
|
+
export * from "./storage/storage.node.js";
|
|
4
8
|
export * from "./types.js";
|
|
5
9
|
export * from "./utils.js";
|
|
6
10
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/src/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/src/node.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./crypto/node
|
|
3
|
-
export
|
|
1
|
+
export * from "./common.js";
|
|
2
|
+
export * from "./crypto/node.js";
|
|
3
|
+
export * from "./event/event.node.js";
|
|
4
|
+
export * from "./init.node.js";
|
|
5
|
+
export * from "./profile.js";
|
|
6
|
+
export * from "./renown-builder.js";
|
|
7
|
+
export * from "./storage/storage.node.js";
|
|
4
8
|
export * from "./types.js";
|
|
5
9
|
export * from "./utils.js";
|
|
6
10
|
//# sourceMappingURL=node.js.map
|
package/dist/src/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,kBAAkB,EAAE,cAwBhC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const fetchRenownProfile = async (user, baseUrl) => {
|
|
2
|
+
try {
|
|
3
|
+
const response = await fetch(`${baseUrl}/api/profile`, {
|
|
4
|
+
method: "POST",
|
|
5
|
+
headers: {
|
|
6
|
+
"Content-Type": "application/json",
|
|
7
|
+
},
|
|
8
|
+
body: JSON.stringify({
|
|
9
|
+
ethAddress: user.address,
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const result = (await response.json());
|
|
16
|
+
return result.profile ?? undefined;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/profile.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAmB,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,cAAc,EAAE;YACrD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,UAAU,EAAE,IAAI,CAAC,OAAO;aACzB,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAEpC,CAAC;QAEF,OAAO,MAAM,CAAC,OAAO,IAAI,SAAS,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Renown } from "./common.js";
|
|
2
|
+
import type { IRenownCrypto, JsonWebKeyPairStorage } from "./crypto/types.js";
|
|
3
|
+
import type { ProfileFetcher, RenownEventEmitter, RenownStorage } from "./types.js";
|
|
4
|
+
export interface RenownBuilderOptions {
|
|
5
|
+
appName: string;
|
|
6
|
+
storage?: RenownStorage;
|
|
7
|
+
eventEmitter?: RenownEventEmitter;
|
|
8
|
+
crypto?: IRenownCrypto;
|
|
9
|
+
keyPairStorage?: JsonWebKeyPairStorage;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
profileFetcher?: ProfileFetcher;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Base builder for creating Renown instances.
|
|
15
|
+
* Use platform-specific builders (RenownBuilder from init.browser.js or init.node.js)
|
|
16
|
+
* for pre-configured defaults.
|
|
17
|
+
*/
|
|
18
|
+
export declare class BaseRenownBuilder {
|
|
19
|
+
#private;
|
|
20
|
+
/**
|
|
21
|
+
* @param appName - Application name used for signing context
|
|
22
|
+
*/
|
|
23
|
+
constructor(appName: string);
|
|
24
|
+
/**
|
|
25
|
+
* Set custom storage for user data persistence.
|
|
26
|
+
* Defaults to in-memory storage if not set.
|
|
27
|
+
*/
|
|
28
|
+
withStorage(storage: RenownStorage): this;
|
|
29
|
+
/**
|
|
30
|
+
* Set custom event emitter for user state changes.
|
|
31
|
+
* Defaults to in-memory event emitter if not set.
|
|
32
|
+
*/
|
|
33
|
+
withEventEmitter(eventEmitter: RenownEventEmitter): this;
|
|
34
|
+
/**
|
|
35
|
+
* Set a pre-built crypto instance.
|
|
36
|
+
* Either crypto or keyPairStorage must be provided.
|
|
37
|
+
*/
|
|
38
|
+
withCrypto(crypto: IRenownCrypto): this;
|
|
39
|
+
/**
|
|
40
|
+
* Set key pair storage for cryptographic keys.
|
|
41
|
+
* A crypto instance will be built from this storage.
|
|
42
|
+
* Either crypto or keyPairStorage must be provided.
|
|
43
|
+
*/
|
|
44
|
+
withKeyPairStorage(keyPairStorage: JsonWebKeyPairStorage): this;
|
|
45
|
+
/**
|
|
46
|
+
* Set the Renown server URL for credential verification.
|
|
47
|
+
* Defaults to https://www.renown.id
|
|
48
|
+
*/
|
|
49
|
+
withBaseUrl(baseUrl: string): this;
|
|
50
|
+
/**
|
|
51
|
+
* Set a profile fetcher strategy for enriching user data after login.
|
|
52
|
+
* The fetcher receives the authenticated user and the base URL,
|
|
53
|
+
* and returns a RenownProfile. Called in the background after each login.
|
|
54
|
+
* Defaults to fetchRenownProfile which calls the Renown API.
|
|
55
|
+
*/
|
|
56
|
+
withProfileFetcher(profileFetcher: ProfileFetcher): this;
|
|
57
|
+
/**
|
|
58
|
+
* Build and initialize the Renown instance.
|
|
59
|
+
* If a user is stored, attempts to re-authenticate them.
|
|
60
|
+
* @throws Error if neither crypto nor keyPairStorage is provided
|
|
61
|
+
*/
|
|
62
|
+
build(): Promise<Renown>;
|
|
63
|
+
/**
|
|
64
|
+
* Create a BaseRenownBuilder from options object for a more concise API
|
|
65
|
+
*/
|
|
66
|
+
static from(options: RenownBuilderOptions): BaseRenownBuilder;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=renown-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renown-builder.d.ts","sourceRoot":"","sources":["../../src/renown-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG9E,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;;IAS5B;;OAEG;gBACS,OAAO,EAAE,MAAM;IAI3B;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAKzC;;;OAGG;IACH,gBAAgB,CAAC,YAAY,EAAE,kBAAkB,GAAG,IAAI;IAKxD;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAKvC;;;;OAIG;IACH,kBAAkB,CAAC,cAAc,EAAE,qBAAqB,GAAG,IAAI;IAK/D;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKlC;;;;;OAKG;IACH,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;IAKxD;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAsC9B;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,iBAAiB;CAwB9D"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Renown, RenownMemoryStorage } from "./common.js";
|
|
2
|
+
import { DEFAULT_RENOWN_URL } from "./constants.js";
|
|
3
|
+
import { RenownCryptoBuilder } from "./crypto/renown-crypto-builder.js";
|
|
4
|
+
import { MemoryEventEmitter } from "./event/memory.js";
|
|
5
|
+
import { fetchRenownProfile } from "./profile.js";
|
|
6
|
+
/**
|
|
7
|
+
* Base builder for creating Renown instances.
|
|
8
|
+
* Use platform-specific builders (RenownBuilder from init.browser.js or init.node.js)
|
|
9
|
+
* for pre-configured defaults.
|
|
10
|
+
*/
|
|
11
|
+
export class BaseRenownBuilder {
|
|
12
|
+
#appName;
|
|
13
|
+
#storage;
|
|
14
|
+
#eventEmitter;
|
|
15
|
+
#crypto;
|
|
16
|
+
#keyPairStorage;
|
|
17
|
+
#baseUrl;
|
|
18
|
+
#profileFetcher;
|
|
19
|
+
/**
|
|
20
|
+
* @param appName - Application name used for signing context
|
|
21
|
+
*/
|
|
22
|
+
constructor(appName) {
|
|
23
|
+
this.#appName = appName;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Set custom storage for user data persistence.
|
|
27
|
+
* Defaults to in-memory storage if not set.
|
|
28
|
+
*/
|
|
29
|
+
withStorage(storage) {
|
|
30
|
+
this.#storage = storage;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set custom event emitter for user state changes.
|
|
35
|
+
* Defaults to in-memory event emitter if not set.
|
|
36
|
+
*/
|
|
37
|
+
withEventEmitter(eventEmitter) {
|
|
38
|
+
this.#eventEmitter = eventEmitter;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set a pre-built crypto instance.
|
|
43
|
+
* Either crypto or keyPairStorage must be provided.
|
|
44
|
+
*/
|
|
45
|
+
withCrypto(crypto) {
|
|
46
|
+
this.#crypto = crypto;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Set key pair storage for cryptographic keys.
|
|
51
|
+
* A crypto instance will be built from this storage.
|
|
52
|
+
* Either crypto or keyPairStorage must be provided.
|
|
53
|
+
*/
|
|
54
|
+
withKeyPairStorage(keyPairStorage) {
|
|
55
|
+
this.#keyPairStorage = keyPairStorage;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Set the Renown server URL for credential verification.
|
|
60
|
+
* Defaults to https://www.renown.id
|
|
61
|
+
*/
|
|
62
|
+
withBaseUrl(baseUrl) {
|
|
63
|
+
this.#baseUrl = baseUrl;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Set a profile fetcher strategy for enriching user data after login.
|
|
68
|
+
* The fetcher receives the authenticated user and the base URL,
|
|
69
|
+
* and returns a RenownProfile. Called in the background after each login.
|
|
70
|
+
* Defaults to fetchRenownProfile which calls the Renown API.
|
|
71
|
+
*/
|
|
72
|
+
withProfileFetcher(profileFetcher) {
|
|
73
|
+
this.#profileFetcher = profileFetcher;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Build and initialize the Renown instance.
|
|
78
|
+
* If a user is stored, attempts to re-authenticate them.
|
|
79
|
+
* @throws Error if neither crypto nor keyPairStorage is provided
|
|
80
|
+
*/
|
|
81
|
+
async build() {
|
|
82
|
+
if (!this.#crypto && !this.#keyPairStorage) {
|
|
83
|
+
throw new Error("Either crypto or keyPairStorage is required. Use withCrypto() or withKeyPairStorage() to set one.");
|
|
84
|
+
}
|
|
85
|
+
const crypto = this.#crypto ??
|
|
86
|
+
(await new RenownCryptoBuilder()
|
|
87
|
+
.withKeyPairStorage(this.#keyPairStorage)
|
|
88
|
+
.build());
|
|
89
|
+
const storage = this.#storage ?? new RenownMemoryStorage();
|
|
90
|
+
const eventEmitter = this.#eventEmitter ?? new MemoryEventEmitter();
|
|
91
|
+
const baseUrl = this.#baseUrl ?? DEFAULT_RENOWN_URL;
|
|
92
|
+
const renown = new Renown(storage, eventEmitter, crypto, this.#appName, baseUrl, this.#profileFetcher ?? fetchRenownProfile);
|
|
93
|
+
// Re-authenticate stored user if present
|
|
94
|
+
if (renown.user) {
|
|
95
|
+
try {
|
|
96
|
+
await renown.login(renown.user.did);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error("Failed to re-authenticate user:", error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return renown;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a BaseRenownBuilder from options object for a more concise API
|
|
106
|
+
*/
|
|
107
|
+
static from(options) {
|
|
108
|
+
const builder = new BaseRenownBuilder(options.appName);
|
|
109
|
+
if (options.storage) {
|
|
110
|
+
builder.withStorage(options.storage);
|
|
111
|
+
}
|
|
112
|
+
if (options.eventEmitter) {
|
|
113
|
+
builder.withEventEmitter(options.eventEmitter);
|
|
114
|
+
}
|
|
115
|
+
if (options.crypto) {
|
|
116
|
+
builder.withCrypto(options.crypto);
|
|
117
|
+
}
|
|
118
|
+
if (options.keyPairStorage) {
|
|
119
|
+
builder.withKeyPairStorage(options.keyPairStorage);
|
|
120
|
+
}
|
|
121
|
+
if (options.baseUrl) {
|
|
122
|
+
builder.withBaseUrl(options.baseUrl);
|
|
123
|
+
}
|
|
124
|
+
if (options.profileFetcher) {
|
|
125
|
+
builder.withProfileFetcher(options.profileFetcher);
|
|
126
|
+
}
|
|
127
|
+
return builder;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=renown-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renown-builder.js","sourceRoot":"","sources":["../../src/renown-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAiBlD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAC5B,QAAQ,CAAS;IACjB,QAAQ,CAAiB;IACzB,aAAa,CAAsB;IACnC,OAAO,CAAiB;IACxB,eAAe,CAAyB;IACxC,QAAQ,CAAU;IAClB,eAAe,CAAkB;IAEjC;;OAEG;IACH,YAAY,OAAe;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,OAAsB;QAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,YAAgC;QAC/C,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAqB;QAC9B,IAAI,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AC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACtC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,OAA6B;QACvC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEvD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzB,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACrD,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
export interface IStorage<T extends Record<string, unknown> = Record<string, unknown
|
|
2
|
-
get
|
|
3
|
-
set
|
|
4
|
-
delete(key:
|
|
1
|
+
export interface IStorage<T extends Record<string, unknown> = Record<string, unknown>, Key extends keyof T = keyof T> {
|
|
2
|
+
get(key: Key): T[Key] | undefined;
|
|
3
|
+
set(key: Key, value?: T[Key]): void;
|
|
4
|
+
delete(key: Key): void;
|
|
5
5
|
}
|
|
6
|
-
export declare abstract class BaseStorage<T extends Record<string, unknown> = Record<string, unknown
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
abstract
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export declare abstract class BaseStorage<T extends Record<string, unknown> = Record<string, unknown>, Key extends keyof T = keyof T> implements IStorage<T> {
|
|
7
|
+
abstract get(key: Key): T[Key] | undefined;
|
|
8
|
+
abstract set(key: Key, value?: T[Key]): void;
|
|
9
|
+
abstract delete(key: Key): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class MemoryStorage<T extends Record<string, unknown> = Record<string, unknown>, Key extends keyof T = keyof T> extends BaseStorage<T> {
|
|
12
|
+
private readonly data;
|
|
13
|
+
get(key: Key): T[Key] | undefined;
|
|
14
|
+
set(key: Key, value?: T[Key]): void;
|
|
15
|
+
delete(key: Key): void;
|
|
12
16
|
}
|
|
13
17
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/storage/common.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/storage/common.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,GAAG,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC;IAE7B,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CA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Storage extends BaseStorage {
|
|
4
|
+
data = new Map();
|
|
5
|
+
get(key) {
|
|
6
|
+
return this.data.get(key);
|
|
7
|
+
}
|
|
8
|
+
set(key, value) {
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
this.data.delete(key);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
this.data.set(key, value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
delete(key) {
|
|
17
|
+
this.data.delete(key);
|
|
5
18
|
}
|
|
6
19
|
}
|
|
7
20
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/storage/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/storage/common.ts"],"names":[],"mappings":"AASA,MAAM,OAAgB,WAAW;CAOhC;AAED,MAAM,OAAO,aAGX,SAAQ,WAAc;IACL,IAAI,GAAG,IAAI,GAAG,EAAe,CAAC;IAE/C,GAAG,CAAC,GAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,GAAQ,EAAE,KAAc;QAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,MAAM,CAAC,GAAQ;QACb,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseStorage } from "./common.js";
|
|
2
2
|
export declare class BrowserStorage<T extends Record<string, unknown> = Record<string, unknown>> extends BaseStorage<T> {
|
|
3
3
|
#private;
|
|
4
|
+
private readonly namespace;
|
|
4
5
|
constructor(namespace: string, basename: string | undefined);
|
|
5
6
|
get<Key extends keyof T>(key: Key): T[Key] | undefined;
|
|
6
7
|
set<Key extends keyof T>(key: Key, value?: T[Key]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.browser.d.ts","sourceRoot":"","sources":["../../../src/storage/storage.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,cAAc,CACzB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D,SAAQ,WAAW,CAAC,CAAC,CAAC;;
|
|
1
|
+
{"version":3,"file":"storage.browser.d.ts","sourceRoot":"","sources":["../../../src/storage/storage.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,cAAc,CACzB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D,SAAQ,WAAW,CAAC,CAAC,CAAC;;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS;IAQ3D,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAQtD,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI;IAMxD,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI;CAG3B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseStorage } from "./common.js";
|
|
2
2
|
export class BrowserStorage extends BaseStorage {
|
|
3
|
+
namespace;
|
|
3
4
|
constructor(namespace, basename) {
|
|
4
|
-
super(
|
|
5
|
+
super();
|
|
6
|
+
this.namespace = `${basename}:${namespace}`;
|
|
5
7
|
}
|
|
6
8
|
#buildKey(key) {
|
|
7
9
|
return `${this.namespace}:${key.toString()}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.browser.js","sourceRoot":"","sources":["../../../src/storage/storage.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,cAEX,SAAQ,WAAc;
|
|
1
|
+
{"version":3,"file":"storage.browser.js","sourceRoot":"","sources":["../../../src/storage/storage.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,cAEX,SAAQ,WAAc;IACL,SAAS,CAAS;IAEnC,YAAY,SAAiB,EAAE,QAA4B;QACzD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC;IAC9C,CAAC;IAED,SAAS,CAAC,GAAY;QACpB,OAAO,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC/C,CAAC;IACD,GAAG,CAAsB,GAAQ;QAC/B,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAW,CAAC;QACrC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,GAAG,CAAsB,GAAQ,EAAE,KAAc;QAC/C,OAAO,KAAK;YACV,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAClE,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,GAAY;QACjB,OAAO,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseStorage } from "./common.js";
|
|
2
2
|
export declare class NodeStorage<T extends Record<string, unknown> = Record<string, unknown>> extends BaseStorage<T> {
|
|
3
3
|
private readonly filePath;
|
|
4
|
-
constructor(filePath: string
|
|
4
|
+
constructor(filePath: string);
|
|
5
5
|
private readData;
|
|
6
6
|
private writeData;
|
|
7
7
|
get<Key extends keyof T>(key: Key): T[Key] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.node.d.ts","sourceRoot":"","sources":["../../../src/storage/storage.node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,WAAW,CACtB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D,SAAQ,WAAW,CAAC,CAAC,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,QAAQ,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"storage.node.d.ts","sourceRoot":"","sources":["../../../src/storage/storage.node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,WAAW,CACtB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D,SAAQ,WAAW,CAAC,CAAC,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,QAAQ,EAAE,MAAM;IAY5B,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,SAAS;IAIjB,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAKtD,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI;IAUxD,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI;CAK3B"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
3
|
import { BaseStorage } from "./common.js";
|
|
4
4
|
export class NodeStorage extends BaseStorage {
|
|
5
5
|
filePath;
|
|
6
|
-
constructor(filePath
|
|
7
|
-
super(
|
|
6
|
+
constructor(filePath) {
|
|
7
|
+
super();
|
|
8
8
|
this.filePath = filePath;
|
|
9
|
+
const parentFolder = dirname(this.filePath);
|
|
10
|
+
mkdirSync(parentFolder, { recursive: true });
|
|
9
11
|
if (!existsSync(this.filePath)) {
|
|
10
12
|
writeFileSync(this.filePath, JSON.stringify({}));
|
|
11
13
|
}
|
|
@@ -15,7 +17,7 @@ export class NodeStorage extends BaseStorage {
|
|
|
15
17
|
return JSON.parse(data);
|
|
16
18
|
}
|
|
17
19
|
writeData(data) {
|
|
18
|
-
writeFileSync(
|
|
20
|
+
writeFileSync(this.filePath, JSON.stringify(data, null, 2));
|
|
19
21
|
}
|
|
20
22
|
get(key) {
|
|
21
23
|
const data = this.readData();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.node.js","sourceRoot":"","sources":["../../../src/storage/storage.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"storage.node.js","sourceRoot":"","sources":["../../../src/storage/storage.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,WAEX,SAAQ,WAAc;IACL,QAAQ,CAAS;IAElC,YAAY,QAAgB;QAC1B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAEO,QAAQ;QACd,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;IAEO,SAAS,CAAC,IAAO;QACvB,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,GAAG,CAAsB,GAAQ;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,GAAG,CAAsB,GAAQ,EAAE,KAAc;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC7B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,GAAY;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;CACF"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,25 +1,54 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Verifiable, VerifiedCredential } from "did-jwt-vc";
|
|
2
|
+
import type { User as EditorUser, ISigner } from "document-model";
|
|
2
3
|
import type { CREDENTIAL_TYPES } from "./constants.js";
|
|
4
|
+
import type { IRenownCrypto } from "./crypto/types.js";
|
|
3
5
|
import type { IEventEmitter } from "./event/types.js";
|
|
4
6
|
import type { IStorage } from "./storage/common.js";
|
|
7
|
+
export type { ISigner };
|
|
8
|
+
export type RenownProfile = {
|
|
9
|
+
documentId: string;
|
|
10
|
+
username: string | null;
|
|
11
|
+
ethAddress: string | null;
|
|
12
|
+
userImage: string | null;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
};
|
|
5
16
|
export type InternalUser = EditorUser & {
|
|
6
17
|
did: string;
|
|
7
18
|
credential: PowerhouseVerifiableCredential | undefined;
|
|
19
|
+
profile?: RenownProfile;
|
|
8
20
|
};
|
|
9
21
|
export type User = InternalUser;
|
|
22
|
+
/**
|
|
23
|
+
* Strategy function for fetching user profile data.
|
|
24
|
+
* Called after successful authentication to enrich the user object.
|
|
25
|
+
* Should return the user's Renown profile, or undefined if not available.
|
|
26
|
+
* Must not throw — return undefined on failure.
|
|
27
|
+
*/
|
|
28
|
+
export type ProfileFetcher = (user: User, baseUrl: string) => Promise<RenownProfile | undefined>;
|
|
10
29
|
export type Unsubscribe = () => void;
|
|
30
|
+
export type LoginStatus = "initial" | "checking" | "authorized" | "not-authorized";
|
|
11
31
|
export type RenownStorageMap = {
|
|
12
32
|
user: InternalUser | undefined;
|
|
13
33
|
};
|
|
14
34
|
export type RenownStorage = IStorage<RenownStorageMap>;
|
|
15
35
|
export type RenownEvents = {
|
|
16
36
|
user: User | undefined;
|
|
37
|
+
status: LoginStatus;
|
|
17
38
|
};
|
|
18
39
|
export type RenownEventEmitter = IEventEmitter<RenownEvents>;
|
|
19
40
|
export interface IRenown extends Pick<RenownEventEmitter, "on"> {
|
|
20
|
-
|
|
21
|
-
|
|
41
|
+
readonly baseUrl: string;
|
|
42
|
+
readonly user: User | undefined;
|
|
43
|
+
readonly status: LoginStatus;
|
|
44
|
+
login: (userDid: string) => Promise<User>;
|
|
22
45
|
logout: () => Promise<void>;
|
|
46
|
+
readonly crypto: IRenownCrypto;
|
|
47
|
+
readonly signer: ISigner;
|
|
48
|
+
readonly did: string;
|
|
49
|
+
readonly profileFetcher: ProfileFetcher | undefined;
|
|
50
|
+
verifyBearerToken: (token: string) => Promise<false | VerifiedCredential>;
|
|
51
|
+
getBearerToken: (options: CreateBearerTokenOptions, refresh?: boolean) => Promise<string>;
|
|
23
52
|
}
|
|
24
53
|
type IssuerType<T> = {
|
|
25
54
|
id: string;
|
|
@@ -46,7 +75,7 @@ interface IVerifiableCredentialPayload<Subject, Issuer> {
|
|
|
46
75
|
credentialStatus?: CredentialStatus;
|
|
47
76
|
credentialSchema: CredentialSchema;
|
|
48
77
|
}
|
|
49
|
-
interface IProof {
|
|
78
|
+
export interface IProof {
|
|
50
79
|
verificationMethod: string;
|
|
51
80
|
ethereumAddress: `0x${string}`;
|
|
52
81
|
created: string;
|
|
@@ -76,5 +105,22 @@ export interface IPowerhouseIssuerType {
|
|
|
76
105
|
ethereumAddress: `0x${string}`;
|
|
77
106
|
}
|
|
78
107
|
export type PowerhouseVerifiableCredential = IVerifiableCredential<IPowerhouseCredentialSubject, IPowerhouseIssuerType>;
|
|
79
|
-
export {
|
|
108
|
+
export interface IAuthCredentialSubject {
|
|
109
|
+
chainId: number;
|
|
110
|
+
networkId: string;
|
|
111
|
+
address: string;
|
|
112
|
+
}
|
|
113
|
+
export type AuthVerifiableCredential = IVerifiableCredential<IAuthCredentialSubject, {}>;
|
|
114
|
+
export type AuthVerifiedCredential = VerifiedCredential & {
|
|
115
|
+
verifiableCredential: Verifiable<AuthVerifiableCredential>;
|
|
116
|
+
};
|
|
117
|
+
export type PKHDid = {
|
|
118
|
+
networkId: string;
|
|
119
|
+
chainId: number;
|
|
120
|
+
address: `0x${string}`;
|
|
121
|
+
};
|
|
122
|
+
export interface CreateBearerTokenOptions {
|
|
123
|
+
expiresIn?: number;
|
|
124
|
+
aud?: string;
|
|
125
|
+
}
|
|
80
126
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MA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E,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,CAC1D,sBAAsB,EACtB,EAAE,CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG;IACxD,oBAAoB,EAAE,UAAU,CAAC,wBAAwB,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import type { Issuer } from "did-jwt-vc";
|
|
1
|
+
import type { Issuer, VerifiedCredential } from "did-jwt-vc";
|
|
2
2
|
import { Resolver } from "did-resolver";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type { AuthVerifiedCredential, CreateBearerTokenOptions, PKHDid } from "./types.js";
|
|
4
|
+
export type ILogger = {
|
|
5
|
+
level: "verbose" | "debug" | "info" | "warn" | "error";
|
|
6
|
+
verbose: (message: string, ...replacements: any[]) => void;
|
|
7
|
+
debug: (message: string, ...replacements: any[]) => void;
|
|
8
|
+
info: (message: string, ...replacements: any[]) => void;
|
|
9
|
+
warn: (message: string, ...replacements: any[]) => void;
|
|
10
|
+
error: (message: string, ...replacements: any[]) => void;
|
|
7
11
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Parse a DID:pkh string to extract network, chain ID, and address information
|
|
14
|
+
* @param did - The DID string in format "did:pkh:networkId:chainId:address"
|
|
15
|
+
* @returns Parsed DID information
|
|
16
|
+
* @throws Error if the DID format is invalid
|
|
17
|
+
*/
|
|
12
18
|
export declare function parsePkhDid(did: string): PKHDid;
|
|
13
|
-
export declare function verifyAuthBearerToken(jwt: string): Promise<false |
|
|
19
|
+
export declare function verifyAuthBearerToken(jwt: string): Promise<false | AuthVerifiedCredential>;
|
|
20
|
+
export declare function assertIsAuthCredential(credential: VerifiedCredential): asserts credential is AuthVerifiedCredential;
|
|
14
21
|
export declare function createAuthBearerToken(chainId: number, networkId: string, address: string, issuer: Issuer, options?: CreateBearerTokenOptions): Promise<string>;
|
|
15
22
|
export declare const getResolver: () => Resolver;
|
|
16
23
|
export declare function getIssuer(privateKey: Uint8Array): Promise<Issuer>;
|
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EAEN,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EAExB,MAAM,EACP,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAEvD,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAC3D,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACzD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,GAAG,EAAE,KAAK,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