@renown/sdk 6.0.0-dev.6 → 6.0.0-dev.61
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 +14 -8
- package/dist/src/common.d.ts.map +1 -1
- package/dist/src/common.js +35 -27
- 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/index.d.ts +5 -34
- package/dist/src/crypto/index.d.ts.map +1 -1
- package/dist/src/crypto/index.js +7 -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/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/hooks/use-user.d.ts +1 -1
- package/dist/src/hooks/use-user.js +1 -1
- package/dist/src/index.browser.d.ts +1 -1
- package/dist/src/index.browser.d.ts.map +1 -1
- package/dist/src/index.browser.js +1 -1
- package/dist/src/index.browser.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.node.d.ts +1 -1
- package/dist/src/index.node.d.ts.map +1 -1
- package/dist/src/index.node.js +1 -1
- package/dist/src/index.node.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/lib/renown/credential.d.ts +2 -0
- package/dist/src/lib/renown/credential.d.ts.map +1 -0
- package/dist/src/lib/renown/credential.js +68 -0
- package/dist/src/lib/renown/credential.js.map +1 -0
- package/dist/src/lib/renown/utils.d.ts +4 -4
- package/dist/src/lib/renown/utils.d.ts.map +1 -1
- package/dist/src/lib/renown/utils.js +24 -43
- package/dist/src/lib/renown/utils.js.map +1 -1
- package/dist/src/node.d.ts +5 -1
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +5 -1
- package/dist/src/node.js.map +1 -1
- package/dist/src/providers/renown-user-provider.d.ts +9 -5
- package/dist/src/providers/renown-user-provider.d.ts.map +1 -1
- package/dist/src/providers/renown-user-provider.js +25 -30
- package/dist/src/providers/renown-user-provider.js.map +1 -1
- package/dist/src/renown-builder.d.ts +60 -0
- package/dist/src/renown-builder.d.ts.map +1 -0
- package/dist/src/renown-builder.js +115 -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 +28 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +11 -10
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +8 -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/script.test.d.ts +2 -0
- package/dist/test/script.test.d.ts.map +1 -0
- package/dist/test/script.test.js +144 -0
- package/dist/test/script.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/vitest.config.d.ts +3 -0
- 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 +14 -14
- 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/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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Issuer } from "did-jwt-vc";
|
|
2
|
+
import type { CreateBearerTokenOptions } from "../types.js";
|
|
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
|
+
removeKeyPair(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export type DID = `did:${string}`;
|
|
13
|
+
export interface IRenownCrypto {
|
|
14
|
+
did: DID;
|
|
15
|
+
publicKey: CryptoKey;
|
|
16
|
+
removeDid(): Promise<void>;
|
|
17
|
+
sign: (data: Uint8Array) => Promise<Uint8Array>;
|
|
18
|
+
verify: (data: Uint8Array, signature: Uint8Array) => Promise<boolean>;
|
|
19
|
+
issuer: Issuer;
|
|
20
|
+
getBearerToken: (address: string | undefined, options?: CreateBearerTokenOptions) => Promise<string>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Use IRenownCrypto instead
|
|
24
|
+
*/
|
|
25
|
+
export interface IConnectCrypto extends IRenownCrypto {
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/crypto/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,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;IAChD,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,MAAM,MAAM,GAAG,GAAG,OAAO,MAAM,EAAE,CAAC;AAElC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,CACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,CAAC,EAAE,wBAAwB,KAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/crypto/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DID, JwkKeyPair } from "./types.js";
|
|
2
|
+
export declare const ECDSA_ALGORITHM: EcKeyAlgorithm;
|
|
3
|
+
export declare const ECDSA_SIGN_ALGORITHM: {
|
|
4
|
+
name: string;
|
|
5
|
+
namedCurve: string;
|
|
6
|
+
hash: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function ab2hex(ab: ArrayBuffer): string;
|
|
9
|
+
export declare function parseDid(keyPair: CryptoKeyPair, subtleCrypto: SubtleCrypto): Promise<DID>;
|
|
10
|
+
export declare function exportKeyPair(keyPair: CryptoKeyPair, subtleCrypto: SubtleCrypto): Promise<JwkKeyPair>;
|
|
11
|
+
export declare function importKeyPair(jwkKeyPair: JwkKeyPair, subtleCrypto: SubtleCrypto, algorithm?: EcKeyAlgorithm): Promise<CryptoKeyPair>;
|
|
12
|
+
export declare function generateKeyPair(subtleCrypto: SubtleCrypto, algorithm?: EcKeyAlgorithm): Promise<CryptoKeyPair>;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/crypto/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,cAG7B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC;AAEF,wBAAgB,MAAM,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAI9C;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,GAAG,CAAC,CAOd;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,UAAU,CAAC,CAKrB;AAED,wBAAsB,aAAa,CACjC,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,SAAS,GAAE,cAAgC,GAC1C,OAAO,CAAC,aAAa,CAAC,CAiBxB;AAED,wBAAsB,eAAe,CACnC,YAAY,EAAE,YAAY,EAC1B,SAAS,GAAE,cAAgC,GAC1C,OAAO,CAAC,aAAa,CAAC,CAExB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { compressedKeyInHexfromRaw, encodeDIDfromHexString, rawKeyInHexfromUncompressed, } from "did-key-creator";
|
|
2
|
+
export const ECDSA_ALGORITHM = {
|
|
3
|
+
name: "ECDSA",
|
|
4
|
+
namedCurve: "P-256",
|
|
5
|
+
};
|
|
6
|
+
export const ECDSA_SIGN_ALGORITHM = {
|
|
7
|
+
name: "ECDSA",
|
|
8
|
+
namedCurve: "P-256",
|
|
9
|
+
hash: "SHA-256",
|
|
10
|
+
};
|
|
11
|
+
export function ab2hex(ab) {
|
|
12
|
+
return Array.prototype.map
|
|
13
|
+
.call(new Uint8Array(ab), (x) => ("00" + x.toString(16)).slice(-2))
|
|
14
|
+
.join("");
|
|
15
|
+
}
|
|
16
|
+
export async function parseDid(keyPair, subtleCrypto) {
|
|
17
|
+
const publicKeyRaw = await subtleCrypto.exportKey("raw", keyPair.publicKey);
|
|
18
|
+
const multicodecName = "p256-pub";
|
|
19
|
+
const rawKey = rawKeyInHexfromUncompressed(ab2hex(publicKeyRaw));
|
|
20
|
+
const compressedKey = compressedKeyInHexfromRaw(rawKey);
|
|
21
|
+
const did = encodeDIDfromHexString(multicodecName, compressedKey);
|
|
22
|
+
return did;
|
|
23
|
+
}
|
|
24
|
+
export async function exportKeyPair(keyPair, subtleCrypto) {
|
|
25
|
+
return {
|
|
26
|
+
publicKey: await subtleCrypto.exportKey("jwk", keyPair.publicKey),
|
|
27
|
+
privateKey: await subtleCrypto.exportKey("jwk", keyPair.privateKey),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export async function importKeyPair(jwkKeyPair, subtleCrypto, algorithm = ECDSA_ALGORITHM) {
|
|
31
|
+
return {
|
|
32
|
+
publicKey: await subtleCrypto.importKey("jwk", jwkKeyPair.publicKey, algorithm, true, ["verify"]),
|
|
33
|
+
privateKey: await subtleCrypto.importKey("jwk", jwkKeyPair.privateKey, algorithm, true, ["sign"]),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export async function generateKeyPair(subtleCrypto, algorithm = ECDSA_ALGORITHM) {
|
|
37
|
+
return subtleCrypto.generateKey(algorithm, true, ["sign", "verify"]);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/crypto/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAGzB,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,IAAI,EAAE,OAAO;IACb,UAAU,EAAE,OAAO;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,OAAO;IACb,UAAU,EAAE,OAAO;IACnB,IAAI,EAAE,SAAS;CAChB,CAAC;AAEF,MAAM,UAAU,MAAM,CAAC,EAAe;IACpC,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;SACvB,IAAI,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1E,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAsB,EACtB,YAA0B;IAE1B,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5E,MAAM,cAAc,GAAG,UAAU,CAAC;IAClC,MAAM,MAAM,GAAG,2BAA2B,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,sBAAsB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IAClE,OAAO,GAAU,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAsB,EACtB,YAA0B;IAE1B,OAAO;QACL,SAAS,EAAE,MAAM,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC;QACjE,UAAU,EAAE,MAAM,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAsB,EACtB,YAA0B,EAC1B,YAA4B,eAAe;IAE3C,OAAO;QACL,SAAS,EAAE,MAAM,YAAY,CAAC,SAAS,CACrC,KAAK,EACL,UAAU,CAAC,SAAS,EACpB,SAAS,EACT,IAAI,EACJ,CAAC,QAAQ,CAAC,CACX;QACD,UAAU,EAAE,MAAM,YAAY,CAAC,SAAS,CACtC,KAAK,EACL,UAAU,CAAC,UAAU,EACrB,SAAS,EACT,IAAI,EACJ,CAAC,MAAM,CAAC,CACT;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,YAA0B,EAC1B,YAA4B,eAAe;IAE3C,OAAO,YAAY,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.browser.d.ts","sourceRoot":"","sources":["../../../src/event/event.browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;gBACzC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAGrC;AAED,qBAAa,mBAAmB,
|
|
1
|
+
{"version":3,"file":"event.browser.d.ts","sourceRoot":"","sources":["../../../src/event/event.browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;gBACzC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAGrC;AAED,qBAAa,mBAAmB,CAC9B,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACtC,YAAW,aAAa,CAAC,MAAM,CAAC;;IAGhC,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EACvB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GAClC,MAAM,IAAI;IAab,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;CAI9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.node.d.ts","sourceRoot":"","sources":["../../../src/event/event.node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qBAAa,gBAAgB,
|
|
1
|
+
{"version":3,"file":"event.node.d.ts","sourceRoot":"","sources":["../../../src/event/event.node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qBAAa,gBAAgB,CAC3B,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACtC,YAAW,aAAa,CAAC,MAAM,CAAC;;;IAOhC,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EACvB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GAClC,MAAM,IAAI;IAOb,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;CAG9D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RenownEvents } from "../types.js";
|
|
2
|
+
import type { IEventEmitter } from "./types.js";
|
|
3
|
+
export declare class MemoryEventEmitter implements IEventEmitter<RenownEvents> {
|
|
4
|
+
#private;
|
|
5
|
+
on<K extends keyof RenownEvents>(event: K, listener: (data: RenownEvents[K]) => void): () => void;
|
|
6
|
+
emit<K extends keyof RenownEvents>(event: K, data: RenownEvents[K]): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/event/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qBAAa,kBAAmB,YAAW,aAAa,CAAC,YAAY,CAAC;;IAGpE,EAAE,CAAC,CAAC,SAAS,MAAM,YAAY,EAC7B,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GACxC,MAAM,IAAI;IAUb,IAAI,CAAC,CAAC,SAAS,MAAM,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI;CAG1E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class MemoryEventEmitter {
|
|
2
|
+
#listeners = new Map();
|
|
3
|
+
on(event, listener) {
|
|
4
|
+
if (!this.#listeners.has(event)) {
|
|
5
|
+
this.#listeners.set(event, new Set());
|
|
6
|
+
}
|
|
7
|
+
this.#listeners.get(event).add(listener);
|
|
8
|
+
return () => {
|
|
9
|
+
this.#listeners.get(event)?.delete(listener);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
emit(event, data) {
|
|
13
|
+
this.#listeners.get(event)?.forEach((listener) => listener(data));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/event/memory.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,kBAAkB;IAC7B,UAAU,GAAG,IAAI,GAAG,EAAoD,CAAC;IAEzE,EAAE,CACA,KAAQ,EACR,QAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,QAAmC,CAAC,CAAC;QACrE,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,QAAmC,CAAC,CAAC;QAC1E,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAA+B,KAAQ,EAAE,IAAqB;QAChE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @example
|
|
10
10
|
* ```tsx
|
|
11
11
|
* function MyComponent() {
|
|
12
|
-
* const { user, loginStatus, isLoading, login, logout, openRenown,
|
|
12
|
+
* const { user, loginStatus, isLoading, login, logout, openRenown, renownCrypto, renown } = useUser()
|
|
13
13
|
*
|
|
14
14
|
* if (isLoading) return <div>Loading...</div>
|
|
15
15
|
* if (!user) return <button onClick={openRenown}>Login</button>
|
|
@@ -12,7 +12,7 @@ import { RenownUserContext } from "../providers/renown-user-provider.js";
|
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
14
|
* function MyComponent() {
|
|
15
|
-
* const { user, loginStatus, isLoading, login, logout, openRenown,
|
|
15
|
+
* const { user, loginStatus, isLoading, login, logout, openRenown, renownCrypto, renown } = useUser()
|
|
16
16
|
*
|
|
17
17
|
* if (isLoading) return <div>Loading...</div>
|
|
18
18
|
* if (!user) return <button onClick={openRenown}>Login</button>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
export * from "./common.js";
|
|
1
2
|
export * from "./components/index.js";
|
|
2
3
|
export * from "./crypto/index.js";
|
|
3
4
|
export * from "./hooks/index.js";
|
|
4
|
-
export
|
|
5
|
+
export * from "./init.browser.js";
|
|
5
6
|
export * from "./providers/index.js";
|
|
7
|
+
export * from "./renown-builder.js";
|
|
6
8
|
export * from "./types.js";
|
|
7
9
|
export * from "./utils.js";
|
|
8
10
|
export { RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, RENOWN_URL, } from "./lib/renown/constants.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,UAAU,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,UAAU,EACV,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
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
export * from "./common.js";
|
|
1
2
|
export * from "./components/index.js";
|
|
2
3
|
export * from "./crypto/index.js";
|
|
3
4
|
export * from "./hooks/index.js";
|
|
4
|
-
export
|
|
5
|
+
export * from "./init.browser.js";
|
|
5
6
|
export * from "./providers/index.js";
|
|
7
|
+
export * from "./renown-builder.js";
|
|
6
8
|
export * from "./types.js";
|
|
7
9
|
export * from "./utils.js";
|
|
8
10
|
// Export specific items from lib/renown to avoid conflicts
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,2DAA2D;AAC3D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,UAAU,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,UAAU,EACV,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/src/index.node.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../src/index.node.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../src/index.node.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/src/index.node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.js","sourceRoot":"","sources":["../../src/index.node.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.node.js","sourceRoot":"","sources":["../../src/index.node.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Renown } from "./common.js";
|
|
2
|
+
import { BrowserEventEmitter } from "./event/event.browser.js";
|
|
3
|
+
import { BaseRenownBuilder } from "./renown-builder.js";
|
|
4
|
+
import { BrowserStorage } from "./storage/storage.browser.js";
|
|
5
|
+
import type { RenownEvents, RenownStorageMap } from "./types.js";
|
|
6
|
+
export declare class BrowserRenownStorage extends BrowserStorage<RenownStorageMap> {
|
|
7
|
+
}
|
|
8
|
+
export declare class BrowserRenownEventEmitter extends BrowserEventEmitter<RenownEvents> {
|
|
9
|
+
}
|
|
10
|
+
export interface BrowserRenownBuilderOptions {
|
|
11
|
+
/** Base path for storage keys (e.g., "/app" for multi-tenant apps) */
|
|
12
|
+
basename?: string;
|
|
13
|
+
/** Renown server URL. Defaults to https://www.renown.id */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/** IndexedDB database name for key storage. Defaults to "renownKeyDB" */
|
|
16
|
+
keyDbName?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Browser-specific Renown builder with pre-configured defaults.
|
|
20
|
+
* Uses localStorage for user data and IndexedDB for key storage.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RenownBuilder extends BaseRenownBuilder {
|
|
23
|
+
#private;
|
|
24
|
+
/**
|
|
25
|
+
* @param appName - Application name used for signing context
|
|
26
|
+
* @param options - Browser-specific configuration options
|
|
27
|
+
*/
|
|
28
|
+
constructor(appName: string, options?: BrowserRenownBuilderOptions);
|
|
29
|
+
/**
|
|
30
|
+
* Set base path for storage keys (e.g., "/app" for multi-tenant apps).
|
|
31
|
+
*/
|
|
32
|
+
withBasename(basename: string): this;
|
|
33
|
+
/**
|
|
34
|
+
* Set IndexedDB database name for key storage.
|
|
35
|
+
* Defaults to "renownKeyDB".
|
|
36
|
+
*/
|
|
37
|
+
withKeyDbName(keyDbName: string): this;
|
|
38
|
+
/**
|
|
39
|
+
* Build and initialize the Renown instance.
|
|
40
|
+
* Initializes IndexedDB for key storage before building.
|
|
41
|
+
*/
|
|
42
|
+
build(): Promise<Renown>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use RenownBuilder directly instead.
|
|
46
|
+
* Initialize a browser-specific Renown instance.
|
|
47
|
+
* @param appName - Application name used for signing context
|
|
48
|
+
* @param options - Browser-specific configuration options
|
|
49
|
+
* @returns Initialized Renown instance
|
|
50
|
+
*/
|
|
51
|
+
export declare function initRenown(appName: string, options?: BrowserRenownBuilderOptions): Promise<Renown>;
|
|
3
52
|
//# sourceMappingURL=init.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.browser.d.ts","sourceRoot":"","sources":["../../src/init.browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.browser.d.ts","sourceRoot":"","sources":["../../src/init.browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,qBAAa,oBAAqB,SAAQ,cAAc,CAAC,gBAAgB,CAAC;CAAG;AAC7E,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,YAAY,CAAC;CAAG;AAEnF,MAAM,WAAW,2BAA2B;IAC1C,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;;IAIlD;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,2BAAgC;IAWtE;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMpC;;;OAGG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtC;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;CAK/B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,2BAAgC,mBAG1C"}
|
package/dist/src/init.browser.js
CHANGED
|
@@ -1,7 +1,66 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserKeyStorage } from "./crypto/browser-key-storage.js";
|
|
2
2
|
import { BrowserEventEmitter } from "./event/event.browser.js";
|
|
3
|
+
import { BaseRenownBuilder } from "./renown-builder.js";
|
|
3
4
|
import { BrowserStorage } from "./storage/storage.browser.js";
|
|
4
|
-
export
|
|
5
|
-
|
|
5
|
+
export class BrowserRenownStorage extends BrowserStorage {
|
|
6
|
+
}
|
|
7
|
+
export class BrowserRenownEventEmitter extends BrowserEventEmitter {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Browser-specific Renown builder with pre-configured defaults.
|
|
11
|
+
* Uses localStorage for user data and IndexedDB for key storage.
|
|
12
|
+
*/
|
|
13
|
+
export class RenownBuilder extends BaseRenownBuilder {
|
|
14
|
+
#basename;
|
|
15
|
+
#keyDbName;
|
|
16
|
+
/**
|
|
17
|
+
* @param appName - Application name used for signing context
|
|
18
|
+
* @param options - Browser-specific configuration options
|
|
19
|
+
*/
|
|
20
|
+
constructor(appName, options = {}) {
|
|
21
|
+
super(appName);
|
|
22
|
+
this.#basename = options.basename;
|
|
23
|
+
this.#keyDbName = options.keyDbName;
|
|
24
|
+
this.withStorage(new BrowserRenownStorage("renown", this.#basename));
|
|
25
|
+
this.withEventEmitter(new BrowserRenownEventEmitter());
|
|
26
|
+
if (options.baseUrl) {
|
|
27
|
+
this.withBaseUrl(options.baseUrl);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Set base path for storage keys (e.g., "/app" for multi-tenant apps).
|
|
32
|
+
*/
|
|
33
|
+
withBasename(basename) {
|
|
34
|
+
this.#basename = basename;
|
|
35
|
+
this.withStorage(new BrowserRenownStorage("renown", this.#basename));
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Set IndexedDB database name for key storage.
|
|
40
|
+
* Defaults to "renownKeyDB".
|
|
41
|
+
*/
|
|
42
|
+
withKeyDbName(keyDbName) {
|
|
43
|
+
this.#keyDbName = keyDbName;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build and initialize the Renown instance.
|
|
48
|
+
* Initializes IndexedDB for key storage before building.
|
|
49
|
+
*/
|
|
50
|
+
async build() {
|
|
51
|
+
const keyStorage = await BrowserKeyStorage.create(this.#keyDbName);
|
|
52
|
+
this.withKeyPairStorage(keyStorage);
|
|
53
|
+
return super.build();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use RenownBuilder directly instead.
|
|
58
|
+
* Initialize a browser-specific Renown instance.
|
|
59
|
+
* @param appName - Application name used for signing context
|
|
60
|
+
* @param options - Browser-specific configuration options
|
|
61
|
+
* @returns Initialized Renown instance
|
|
62
|
+
*/
|
|
63
|
+
export function initRenown(appName, options = {}) {
|
|
64
|
+
return new RenownBuilder(appName, options).build();
|
|
6
65
|
}
|
|
7
66
|
//# sourceMappingURL=init.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.browser.js","sourceRoot":"","sources":["../../src/init.browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.browser.js","sourceRoot":"","sources":["../../src/init.browser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,MAAM,OAAO,oBAAqB,SAAQ,cAAgC;CAAG;AAC7E,MAAM,OAAO,yBAA0B,SAAQ,mBAAiC;CAAG;AAWnF;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAClD,SAAS,CAAU;IACnB,UAAU,CAAU;IAEpB;;;OAGG;IACH,YAAY,OAAe,EAAE,UAAuC,EAAE;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,IAAI,CAAC,WAAW,CAAC,IAAI,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,gBAAgB,CAAC,IAAI,yBAAyB,EAAE,CAAC,CAAC;QACvD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,QAAgB;QAC3B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,WAAW,CAAC,IAAI,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,SAAiB;QAC7B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnE,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,OAAe,EACf,UAAuC,EAAE;IAEzC,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;AACrD,CAAC"}
|
package/dist/src/init.node.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { NodeEventEmitter } from "./event/event.node.js";
|
|
2
|
+
import { BaseRenownBuilder } from "./renown-builder.js";
|
|
3
|
+
import { NodeStorage } from "./storage/storage.node.js";
|
|
4
|
+
import type { RenownEvents, RenownStorageMap } from "./types.js";
|
|
5
|
+
export declare class NodeRenownEventEmitter extends NodeEventEmitter<RenownEvents> {
|
|
6
|
+
}
|
|
7
|
+
export declare class NodeRenownStorage extends NodeStorage<RenownStorageMap> {
|
|
8
|
+
}
|
|
9
|
+
export declare const DEFAULT_RENOWN_STORAGE_PATH = "./.ph/.renown.json";
|
|
10
|
+
export interface NodeRenownBuilderOptions {
|
|
11
|
+
/** File path for user storage. Defaults to ".ph/.renown.json" in cwd */
|
|
12
|
+
storagePath?: string;
|
|
13
|
+
/** File path for keypair storage. Defaults to ".ph/.keypair.json" in cwd */
|
|
14
|
+
keyPath?: string;
|
|
15
|
+
/** Renown server URL. Defaults to https://www.renown.id */
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Node.js-specific Renown builder with pre-configured defaults.
|
|
20
|
+
* Uses file-based storage for both user data and key storage.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RenownBuilder extends BaseRenownBuilder {
|
|
23
|
+
/**
|
|
24
|
+
* @param appName - Application name used for signing context
|
|
25
|
+
* @param options - Node.js-specific configuration options
|
|
26
|
+
*/
|
|
27
|
+
constructor(appName: string, options?: NodeRenownBuilderOptions);
|
|
28
|
+
}
|
|
3
29
|
//# sourceMappingURL=init.node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.node.d.ts","sourceRoot":"","sources":["../../src/init.node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.node.d.ts","sourceRoot":"","sources":["../../src/init.node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,qBAAa,sBAAuB,SAAQ,gBAAgB,CAAC,YAAY,CAAC;CAAG;AAC7E,qBAAa,iBAAkB,SAAQ,WAAW,CAAC,gBAAgB,CAAC;CAAG;AAEvE,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACvC,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;IAClD;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B;CAgBpE"}
|
package/dist/src/init.node.js
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodeKeyStorage } from "./crypto/node-key-storage.js";
|
|
2
2
|
import { NodeEventEmitter } from "./event/event.node.js";
|
|
3
|
+
import { BaseRenownBuilder } from "./renown-builder.js";
|
|
3
4
|
import { NodeStorage } from "./storage/storage.node.js";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export class NodeRenownEventEmitter extends NodeEventEmitter {
|
|
6
|
+
}
|
|
7
|
+
export class NodeRenownStorage extends NodeStorage {
|
|
8
|
+
}
|
|
9
|
+
export const DEFAULT_RENOWN_STORAGE_PATH = "./.ph/.renown.json";
|
|
10
|
+
/**
|
|
11
|
+
* Node.js-specific Renown builder with pre-configured defaults.
|
|
12
|
+
* Uses file-based storage for both user data and key storage.
|
|
13
|
+
*/
|
|
14
|
+
export class RenownBuilder extends BaseRenownBuilder {
|
|
15
|
+
/**
|
|
16
|
+
* @param appName - Application name used for signing context
|
|
17
|
+
* @param options - Node.js-specific configuration options
|
|
18
|
+
*/
|
|
19
|
+
constructor(appName, options = {}) {
|
|
20
|
+
super(appName);
|
|
21
|
+
const { storagePath = DEFAULT_RENOWN_STORAGE_PATH, keyPath, baseUrl, } = options;
|
|
22
|
+
this.withKeyPairStorage(new NodeKeyStorage(keyPath));
|
|
23
|
+
this.withStorage(new NodeRenownStorage(storagePath));
|
|
24
|
+
this.withEventEmitter(new NodeRenownEventEmitter());
|
|
25
|
+
if (baseUrl) {
|
|
26
|
+
this.withBaseUrl(baseUrl);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
7
29
|
}
|
|
8
30
|
//# sourceMappingURL=init.node.js.map
|
|
@@ -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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../../../src/lib/renown/credential.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
// import type { WalletClient } from "viem";
|
|
3
|
+
// import { CREDENTIAL_TYPES } from "./constants.js";
|
|
4
|
+
export {};
|
|
5
|
+
// export interface CreateEIP712CredentialParams {
|
|
6
|
+
// walletClient: WalletClient;
|
|
7
|
+
// chainId: number;
|
|
8
|
+
// app: string;
|
|
9
|
+
// connectId?: string;
|
|
10
|
+
// expiresInDays?: number;
|
|
11
|
+
// }
|
|
12
|
+
// /**
|
|
13
|
+
// * Create and sign an EIP-712 Verifiable Credential
|
|
14
|
+
// */
|
|
15
|
+
// export async function createEIP712Credential(
|
|
16
|
+
// params: CreateEIP712CredentialParams,
|
|
17
|
+
// ) {
|
|
18
|
+
// const { walletClient, chainId, app, connectId, expiresInDays = 7 } = params;
|
|
19
|
+
// if (!walletClient.account?.address) {
|
|
20
|
+
// throw new Error("Wallet not connected");
|
|
21
|
+
// }
|
|
22
|
+
// const address = walletClient.account.address;
|
|
23
|
+
// const issuerId = `did:pkh:eip155:${chainId}:${address.toLowerCase()}`;
|
|
24
|
+
// const credentialId = `urn:uuid:${uuidv4()}`;
|
|
25
|
+
// const now = new Date();
|
|
26
|
+
// const expirationDate = new Date(
|
|
27
|
+
// now.getTime() + expiresInDays * 24 * 60 * 60 * 1000,
|
|
28
|
+
// );
|
|
29
|
+
// // Build the credential
|
|
30
|
+
// const credential = {
|
|
31
|
+
// "@context": ["https://www.w3.org/2018/credentials/v1"],
|
|
32
|
+
// type: ["VerifiableCredential", "RenownCredential"],
|
|
33
|
+
// id: credentialId,
|
|
34
|
+
// issuer: {
|
|
35
|
+
// id: issuerId,
|
|
36
|
+
// ethereumAddress: address,
|
|
37
|
+
// },
|
|
38
|
+
// credentialSubject: {
|
|
39
|
+
// id: connectId || issuerId,
|
|
40
|
+
// app,
|
|
41
|
+
// },
|
|
42
|
+
// credentialSchema: {
|
|
43
|
+
// id: "https://renown.id/schemas/renown-credential/v1",
|
|
44
|
+
// type: "JsonSchemaValidator2018",
|
|
45
|
+
// },
|
|
46
|
+
// issuanceDate: now.toISOString(),
|
|
47
|
+
// expirationDate: expirationDate.toISOString(),
|
|
48
|
+
// };
|
|
49
|
+
// // EIP-712 domain
|
|
50
|
+
// const domain = {
|
|
51
|
+
// version: "1",
|
|
52
|
+
// chainId: BigInt(chainId),
|
|
53
|
+
// };
|
|
54
|
+
// // Sign with EIP-712
|
|
55
|
+
// const signature = await walletClient.signTypedData({
|
|
56
|
+
// account: walletClient.account,
|
|
57
|
+
// domain,
|
|
58
|
+
// types: CREDENTIAL_TYPES,
|
|
59
|
+
// primaryType: "VerifiableCredential",
|
|
60
|
+
// message: credential,
|
|
61
|
+
// });
|
|
62
|
+
// return {
|
|
63
|
+
// credential,
|
|
64
|
+
// signature,
|
|
65
|
+
// domain,
|
|
66
|
+
// };
|
|
67
|
+
// }
|
|
68
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../../../../src/lib/renown/credential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,4CAA4C;AAC5C,qDAAqD;;AAErD,kDAAkD;AAClD,gCAAgC;AAChC,qBAAqB;AACrB,iBAAiB;AACjB,wBAAwB;AACxB,4BAA4B;AAC5B,IAAI;AAEJ,MAAM;AACN,sDAAsD;AACtD,MAAM;AACN,gDAAgD;AAChD,0CAA0C;AAC1C,MAAM;AACN,iFAAiF;AAEjF,0CAA0C;AAC1C,+CAA+C;AAC/C,MAAM;AAEN,kDAAkD;AAClD,2EAA2E;AAC3E,iDAAiD;AACjD,4BAA4B;AAC5B,qCAAqC;AACrC,2DAA2D;AAC3D,OAAO;AAEP,4BAA4B;AAC5B,yBAAyB;AACzB,8DAA8D;AAC9D,0DAA0D;AAC1D,wBAAwB;AACxB,gBAAgB;AAChB,sBAAsB;AACtB,kCAAkC;AAClC,SAAS;AACT,2BAA2B;AAC3B,mCAAmC;AACnC,aAAa;AACb,SAAS;AACT,0BAA0B;AAC1B,8DAA8D;AAC9D,yCAAyC;AACzC,SAAS;AACT,uCAAuC;AACvC,oDAAoD;AACpD,OAAO;AAEP,sBAAsB;AACtB,qBAAqB;AACrB,oBAAoB;AACpB,gCAAgC;AAChC,OAAO;AAEP,yBAAyB;AACzB,yDAAyD;AACzD,qCAAqC;AACrC,cAAc;AACd,+BAA+B;AAC/B,2CAA2C;AAC3C,2BAA2B;AAC3B,QAAQ;AAER,aAAa;AACb,kBAAkB;AAClB,iBAAiB;AACjB,cAAc;AACd,OAAO;AACP,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IRenown } from "@renown/sdk";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IRenownCrypto } from "../../crypto/index.js";
|
|
3
3
|
export type LoginStatus = "initial" | "checking" | "authorized" | "not-authorized";
|
|
4
4
|
export interface User {
|
|
5
5
|
did: string;
|
|
@@ -18,12 +18,12 @@ declare global {
|
|
|
18
18
|
setGenerateJwtHandler: (handler: (driveUrl: string) => Promise<string>) => void;
|
|
19
19
|
removeJwtHandler: () => void;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
renownCrypto?: IRenownCrypto;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
export declare function openRenown(documentId?: string):
|
|
24
|
+
export declare function openRenown(documentId?: string): void;
|
|
25
25
|
export declare function handleRenownReturn(): Promise<void>;
|
|
26
|
-
export declare function login(userDid: string | undefined, renown: IRenown | undefined,
|
|
26
|
+
export declare function login(userDid: string | undefined, renown: IRenown | undefined, renownCrypto: IRenownCrypto | undefined): Promise<User | undefined>;
|
|
27
27
|
export declare function logout(): Promise<void>;
|
|
28
28
|
/**
|
|
29
29
|
* Re-authenticate using stored session data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/renown/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/renown/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAe3D,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,UAAU,GACV,YAAY,GACZ,gBAAgB,CAAC;AAErB,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAqDD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BvE;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE;YACR,qBAAqB,EAAE,CACrB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,KAC3C,IAAI,CAAC;YACV,gBAAgB,EAAE,MAAM,IAAI,CAAC;SAC9B,CAAC;QACF,YAAY,CAAC,EAAE,aAAa,CAAC;KAC9B;CACF;AAED,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,QA0B7C;AAGD,wBAAsB,kBAAkB,kBAkBvC;AAED,wBAAsB,KAAK,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,YAAY,EAAE,aAAa,GAAG,SAAS,6BA4DxC;AAED,wBAAsB,MAAM,kBAS3B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CA4BtE"}
|