@renown/sdk 0.16.2 → 2.5.0-test.0
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 -0
- package/dist/src/common.d.ts.map +1 -0
- package/dist/src/common.js +105 -0
- package/dist/src/common.js.map +1 -0
- package/dist/src/constants.d.ts +130 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +40 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/event/event.browser.d.ts +10 -0
- package/dist/src/event/event.browser.d.ts.map +1 -0
- package/dist/src/event/event.browser.js +24 -0
- package/dist/src/event/event.browser.js.map +1 -0
- package/dist/src/event/event.node.d.ts +8 -0
- package/dist/src/event/event.node.d.ts.map +1 -0
- package/dist/src/event/event.node.js +17 -0
- package/dist/src/event/event.node.js.map +1 -0
- package/dist/src/event/types.d.ts +16 -0
- package/dist/src/event/types.d.ts.map +1 -0
- package/dist/src/event/types.js +2 -0
- package/dist/src/event/types.js.map +1 -0
- package/dist/src/index.browser.d.ts +4 -0
- package/dist/src/index.browser.d.ts.map +1 -0
- package/{src/index.browser.ts → dist/src/index.browser.js} +2 -0
- package/dist/src/index.browser.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.node.d.ts +4 -0
- package/dist/src/index.node.d.ts.map +1 -0
- package/{src/index.node.ts → dist/src/index.node.js} +2 -0
- package/dist/src/index.node.js.map +1 -0
- package/dist/src/init.browser.d.ts +3 -0
- package/dist/src/init.browser.d.ts.map +1 -0
- package/dist/src/init.browser.js +7 -0
- package/dist/src/init.browser.js.map +1 -0
- package/dist/src/init.node.d.ts +3 -0
- package/dist/src/init.node.d.ts.map +1 -0
- package/dist/src/init.node.js +8 -0
- package/dist/src/init.node.js.map +1 -0
- package/dist/src/storage/common.d.ts +13 -0
- package/dist/src/storage/common.d.ts.map +1 -0
- package/dist/src/storage/common.js +7 -0
- package/dist/src/storage/common.js.map +1 -0
- package/dist/src/storage/storage.browser.d.ts +9 -0
- package/dist/src/storage/storage.browser.d.ts.map +1 -0
- package/dist/src/storage/storage.browser.js +25 -0
- package/dist/src/storage/storage.browser.js.map +1 -0
- package/dist/src/storage/storage.node.d.ts +11 -0
- package/dist/src/storage/storage.node.d.ts.map +1 -0
- package/dist/src/storage/storage.node.js +42 -0
- package/dist/src/storage/storage.node.js.map +1 -0
- package/dist/src/types.d.ts +79 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +13 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +67 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.browser.tsbuildinfo +1 -0
- package/dist/tsconfig.common.tsbuildinfo +1 -0
- package/dist/tsconfig.node.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +24 -16
- package/src/common.ts +0 -136
- package/src/constants.ts +0 -45
- package/src/event/event.browser.ts +0 -34
- package/src/event/event.node.ts +0 -26
- package/src/event/types.ts +0 -19
- package/src/init.browser.ts +0 -17
- package/src/init.node.ts +0 -19
- package/src/storage/common.ts +0 -18
- package/src/storage/storage.browser.ts +0 -30
- package/src/storage/storage.node.ts +0 -53
- package/src/types.ts +0 -96
- package/src/utils.ts +0 -28
- package/tsconfig.base.json +0 -10
- package/tsconfig.browser.json +0 -9
- package/tsconfig.node.json +0 -9
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Issuer } from "did-jwt-vc";
|
|
2
|
+
import { type IRenown, type RenownEventEmitter, type RenownEvents, type RenownStorage, type User } from "./types.js";
|
|
3
|
+
export declare class Renown implements IRenown {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(store: RenownStorage, eventEmitter: RenownEventEmitter, connectId: string, baseUrl?: string);
|
|
6
|
+
get user(): User | undefined;
|
|
7
|
+
set connectId(connectId: string);
|
|
8
|
+
login(did: string): Promise<User>;
|
|
9
|
+
logout(): Promise<void>;
|
|
10
|
+
on<K extends keyof RenownEvents>(event: K, listener: (data: RenownEvents[K]) => void): () => void;
|
|
11
|
+
verifyBearerToken(token: string): Promise<false | import("did-jwt-vc").VerifiedCredential>;
|
|
12
|
+
createBearerToken(address: string, chainId: number, issuer: Issuer): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAOpB,qBAAa,MAAO,YAAW,OAAO;;gBAOlC,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,kBAAkB,EAChC,SAAS,EAAE,MAAM,EACjB,OAAO,SAAqB;IAY9B,IAAI,IAAI,qBAEP;IAWD,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,EAY9B;IAEK,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuCvC,MAAM;IAKN,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;IA6BP,iBAAiB,CAAC,KAAK,EAAE,MAAM;IAI/B,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAMzE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { DEFAULT_RENOWN_URL } from "./constants.js";
|
|
2
|
+
import { createAuthBearerToken, parsePkhDid, verifyAuthBearerToken, } from "./utils.js";
|
|
3
|
+
export class Renown {
|
|
4
|
+
#baseUrl;
|
|
5
|
+
#store;
|
|
6
|
+
#connectId;
|
|
7
|
+
#eventEmitter;
|
|
8
|
+
constructor(store, eventEmitter, connectId, baseUrl = DEFAULT_RENOWN_URL) {
|
|
9
|
+
this.#store = store;
|
|
10
|
+
this.#eventEmitter = eventEmitter;
|
|
11
|
+
this.#connectId = connectId;
|
|
12
|
+
this.#baseUrl = baseUrl;
|
|
13
|
+
if (this.user) {
|
|
14
|
+
this.login(this.user.did).catch(() => void 0);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
get user() {
|
|
18
|
+
return this.#store.get("user");
|
|
19
|
+
}
|
|
20
|
+
#updateUser(user) {
|
|
21
|
+
if (user) {
|
|
22
|
+
this.#store.set("user", user);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.#store.delete("user");
|
|
26
|
+
}
|
|
27
|
+
this.#eventEmitter.emit("user", user);
|
|
28
|
+
}
|
|
29
|
+
set connectId(connectId) {
|
|
30
|
+
this.#connectId = connectId;
|
|
31
|
+
const user = this.user;
|
|
32
|
+
this.#updateUser(undefined);
|
|
33
|
+
// tries to login with new connectId
|
|
34
|
+
if (user) {
|
|
35
|
+
this.login(user.did).catch((e) => {
|
|
36
|
+
console.log("User no longer authenticated:", e);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async login(did) {
|
|
41
|
+
try {
|
|
42
|
+
const result = parsePkhDid(did);
|
|
43
|
+
const credential = await this.#getCredential(result.address, result.chainId, this.#connectId);
|
|
44
|
+
if (!credential) {
|
|
45
|
+
this.#updateUser(undefined);
|
|
46
|
+
throw new Error("Credential not found");
|
|
47
|
+
}
|
|
48
|
+
const user = {
|
|
49
|
+
...result,
|
|
50
|
+
did,
|
|
51
|
+
credential,
|
|
52
|
+
};
|
|
53
|
+
// TODO
|
|
54
|
+
// getEnsInfo(user.address, user.chainId)
|
|
55
|
+
// .then((ens) => {
|
|
56
|
+
// if (
|
|
57
|
+
// this.user?.address === user.address &&
|
|
58
|
+
// this.user.chainId === user.chainId
|
|
59
|
+
// ) {
|
|
60
|
+
// this.#updateUser({ ...this.user, ens });
|
|
61
|
+
// }
|
|
62
|
+
// })
|
|
63
|
+
// .catch(logger.error);
|
|
64
|
+
this.#updateUser(user);
|
|
65
|
+
return user;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.#updateUser(undefined);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
logout() {
|
|
73
|
+
this.#updateUser(undefined);
|
|
74
|
+
return Promise.resolve();
|
|
75
|
+
}
|
|
76
|
+
on(event, listener) {
|
|
77
|
+
return this.#eventEmitter.on(event, listener);
|
|
78
|
+
}
|
|
79
|
+
async #getCredential(address, chainId, connectId) {
|
|
80
|
+
if (!this.#baseUrl) {
|
|
81
|
+
throw new Error("RENOWN_URL is not set");
|
|
82
|
+
}
|
|
83
|
+
const url = new URL(`/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(connectId)}`, this.#baseUrl);
|
|
84
|
+
const response = await fetch(url, {
|
|
85
|
+
method: "GET",
|
|
86
|
+
});
|
|
87
|
+
if (response.ok) {
|
|
88
|
+
const result = (await response.json());
|
|
89
|
+
return result.credential;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new Error("Failed to get credential");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async verifyBearerToken(token) {
|
|
96
|
+
return verifyAuthBearerToken(token);
|
|
97
|
+
}
|
|
98
|
+
async createBearerToken(address, chainId, issuer) {
|
|
99
|
+
if (!this.user) {
|
|
100
|
+
throw new Error("User not found");
|
|
101
|
+
}
|
|
102
|
+
return createAuthBearerToken(chainId, this.#connectId, address, issuer);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export declare const DEFAULT_RENOWN_URL = "https://auth.renown.id";
|
|
2
|
+
export declare const DEFAULT_RENOWN_NETWORK_ID = "eip155";
|
|
3
|
+
export declare const DEFAULT_RENOWN_CHAIN_ID = "1";
|
|
4
|
+
export declare const DOMAIN_TYPE: readonly [{
|
|
5
|
+
readonly name: "name";
|
|
6
|
+
readonly type: "string";
|
|
7
|
+
}, {
|
|
8
|
+
readonly name: "version";
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "chainId";
|
|
12
|
+
readonly type: "uint256";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "verifyingContract";
|
|
15
|
+
readonly type: "address";
|
|
16
|
+
}];
|
|
17
|
+
export declare const VERIFIABLE_CREDENTIAL_EIP712_TYPE: readonly [{
|
|
18
|
+
readonly name: "@context";
|
|
19
|
+
readonly type: "string[]";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "type";
|
|
22
|
+
readonly type: "string[]";
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "id";
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "issuer";
|
|
28
|
+
readonly type: "Issuer";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "credentialSubject";
|
|
31
|
+
readonly type: "CredentialSubject";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "credentialSchema";
|
|
34
|
+
readonly type: "CredentialSchema";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "issuanceDate";
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "expirationDate";
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
}];
|
|
42
|
+
export declare const CREDENTIAL_SCHEMA_EIP712_TYPE: readonly [{
|
|
43
|
+
readonly name: "id";
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "type";
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
}];
|
|
49
|
+
export declare const CREDENTIAL_SUBJECT_TYPE: readonly [{
|
|
50
|
+
readonly name: "app";
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "id";
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "name";
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
}];
|
|
59
|
+
export declare const ISSUER_TYPE: readonly [{
|
|
60
|
+
readonly name: "id";
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
}, {
|
|
63
|
+
readonly name: "ethereumAddress";
|
|
64
|
+
readonly type: "string";
|
|
65
|
+
}];
|
|
66
|
+
export declare const CREDENTIAL_TYPES: {
|
|
67
|
+
readonly EIP712Domain: readonly [{
|
|
68
|
+
readonly name: "name";
|
|
69
|
+
readonly type: "string";
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "version";
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "chainId";
|
|
75
|
+
readonly type: "uint256";
|
|
76
|
+
}, {
|
|
77
|
+
readonly name: "verifyingContract";
|
|
78
|
+
readonly type: "address";
|
|
79
|
+
}];
|
|
80
|
+
readonly VerifiableCredential: readonly [{
|
|
81
|
+
readonly name: "@context";
|
|
82
|
+
readonly type: "string[]";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "type";
|
|
85
|
+
readonly type: "string[]";
|
|
86
|
+
}, {
|
|
87
|
+
readonly name: "id";
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "issuer";
|
|
91
|
+
readonly type: "Issuer";
|
|
92
|
+
}, {
|
|
93
|
+
readonly name: "credentialSubject";
|
|
94
|
+
readonly type: "CredentialSubject";
|
|
95
|
+
}, {
|
|
96
|
+
readonly name: "credentialSchema";
|
|
97
|
+
readonly type: "CredentialSchema";
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "issuanceDate";
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "expirationDate";
|
|
103
|
+
readonly type: "string";
|
|
104
|
+
}];
|
|
105
|
+
readonly CredentialSchema: readonly [{
|
|
106
|
+
readonly name: "id";
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "type";
|
|
110
|
+
readonly type: "string";
|
|
111
|
+
}];
|
|
112
|
+
readonly CredentialSubject: readonly [{
|
|
113
|
+
readonly name: "app";
|
|
114
|
+
readonly type: "string";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "id";
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
}, {
|
|
119
|
+
readonly name: "name";
|
|
120
|
+
readonly type: "string";
|
|
121
|
+
}];
|
|
122
|
+
readonly Issuer: readonly [{
|
|
123
|
+
readonly name: "id";
|
|
124
|
+
readonly type: "string";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "ethereumAddress";
|
|
127
|
+
readonly type: "string";
|
|
128
|
+
}];
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const DEFAULT_RENOWN_URL = "https://auth.renown.id";
|
|
2
|
+
export const DEFAULT_RENOWN_NETWORK_ID = "eip155";
|
|
3
|
+
export const DEFAULT_RENOWN_CHAIN_ID = "1";
|
|
4
|
+
export const DOMAIN_TYPE = [
|
|
5
|
+
{ name: "name", type: "string" },
|
|
6
|
+
{ name: "version", type: "string" },
|
|
7
|
+
{ name: "chainId", type: "uint256" },
|
|
8
|
+
{ name: "verifyingContract", type: "address" },
|
|
9
|
+
];
|
|
10
|
+
export const VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
|
|
11
|
+
{ name: "@context", type: "string[]" },
|
|
12
|
+
{ name: "type", type: "string[]" },
|
|
13
|
+
{ name: "id", type: "string" },
|
|
14
|
+
{ name: "issuer", type: "Issuer" },
|
|
15
|
+
{ name: "credentialSubject", type: "CredentialSubject" },
|
|
16
|
+
{ name: "credentialSchema", type: "CredentialSchema" },
|
|
17
|
+
{ name: "issuanceDate", type: "string" },
|
|
18
|
+
{ name: "expirationDate", type: "string" },
|
|
19
|
+
];
|
|
20
|
+
export const CREDENTIAL_SCHEMA_EIP712_TYPE = [
|
|
21
|
+
{ name: "id", type: "string" },
|
|
22
|
+
{ name: "type", type: "string" },
|
|
23
|
+
];
|
|
24
|
+
export const CREDENTIAL_SUBJECT_TYPE = [
|
|
25
|
+
{ name: "app", type: "string" },
|
|
26
|
+
{ name: "id", type: "string" },
|
|
27
|
+
{ name: "name", type: "string" },
|
|
28
|
+
];
|
|
29
|
+
export const ISSUER_TYPE = [
|
|
30
|
+
{ name: "id", type: "string" },
|
|
31
|
+
{ name: "ethereumAddress", type: "string" },
|
|
32
|
+
];
|
|
33
|
+
export const CREDENTIAL_TYPES = {
|
|
34
|
+
EIP712Domain: DOMAIN_TYPE,
|
|
35
|
+
VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
|
|
36
|
+
CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
|
|
37
|
+
CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
|
|
38
|
+
Issuer: ISSUER_TYPE,
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +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,EAAE,QAAQ,EAAE;IAChC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;CACtC,CAAC;AAEX,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IACtC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE;IAClC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IAClC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,mBAAmB,EAAE;IACxD,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,kBAAkB,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,10 @@
|
|
|
1
|
+
import type { IEventEmitter } from "./types.js";
|
|
2
|
+
export declare class TypedCustomEvent<T> extends CustomEvent<T> {
|
|
3
|
+
constructor(type: string, detail?: T);
|
|
4
|
+
}
|
|
5
|
+
export declare class BrowserEventEmitter<Events extends Record<string, unknown>> implements IEventEmitter<Events> {
|
|
6
|
+
#private;
|
|
7
|
+
on<K extends keyof Events>(event: K, listener: (data: Events[K]) => void): () => void;
|
|
8
|
+
emit<K extends keyof Events>(event: K, data: Events[K]): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=event.browser.d.ts.map
|
|
@@ -0,0 +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,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACrE,YAAW,aAAa,CAAC,MAAM,CAAC;;IAIhC,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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class TypedCustomEvent extends CustomEvent {
|
|
2
|
+
constructor(type, detail) {
|
|
3
|
+
super(type, { detail });
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export class BrowserEventEmitter {
|
|
7
|
+
#eventTarget = new EventTarget();
|
|
8
|
+
on(event, listener) {
|
|
9
|
+
const wrappedListener = (e) => {
|
|
10
|
+
if (e instanceof TypedCustomEvent) {
|
|
11
|
+
listener(e.detail);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
this.#eventTarget.addEventListener(event.toString(), wrappedListener);
|
|
15
|
+
return () => {
|
|
16
|
+
this.#eventTarget.removeEventListener(event.toString(), wrappedListener);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
emit(event, data) {
|
|
20
|
+
const customEvent = new TypedCustomEvent(event.toString(), data);
|
|
21
|
+
this.#eventTarget.dispatchEvent(customEvent);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=event.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.browser.js","sourceRoot":"","sources":["../../../src/event/event.browser.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAoB,SAAQ,WAAc;IACrD,YAAY,IAAY,EAAE,MAAU;QAClC,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,OAAO,mBAAmB;IAG9B,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC;IAEjC,EAAE,CACA,KAAQ,EACR,QAAmC;QAEnC,MAAM,eAAe,GAAG,CAAC,CAAQ,EAAE,EAAE;YACnC,IAAI,CAAC,YAAY,gBAAgB,EAAE,CAAC;gBAClC,QAAQ,CAAC,CAAC,CAAC,MAAmB,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,eAAe,CAAC,CAAC;QACtE,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,eAAe,CAAC,CAAC;QAC3E,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAyB,KAAQ,EAAE,IAAe;QACpD,MAAM,WAAW,GAAG,IAAI,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IEventEmitter } from "./types.js";
|
|
2
|
+
export declare class NodeEventEmitter<Events extends Record<string, unknown>> implements IEventEmitter<Events> {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
on<K extends keyof Events>(event: K, listener: (data: Events[K]) => void): () => void;
|
|
6
|
+
emit<K extends keyof Events>(event: K, data: Events[K]): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=event.node.d.ts.map
|
|
@@ -0,0 +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,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAClE,YAAW,aAAa,CAAC,MAAM,CAAC;;;IAQhC,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,17 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
export class NodeEventEmitter {
|
|
3
|
+
#emitter = new EventEmitter();
|
|
4
|
+
constructor() {
|
|
5
|
+
this.#emitter.setMaxListeners(0);
|
|
6
|
+
}
|
|
7
|
+
on(event, listener) {
|
|
8
|
+
this.#emitter.on(event, listener);
|
|
9
|
+
return () => {
|
|
10
|
+
this.#emitter.removeListener(event.toString(), listener);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
emit(event, data) {
|
|
14
|
+
this.#emitter.emit(event.toString(), data);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=event.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.node.js","sourceRoot":"","sources":["../../../src/event/event.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,OAAO,gBAAgB;IAG3B,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IAE9B;QACE,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,EAAE,CACA,KAAQ,EACR,QAAmC;QAEnC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAe,EAAE,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAyB,KAAQ,EAAE,IAAe;QACpD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface IEventEmitter<Events extends Record<string, unknown>> {
|
|
2
|
+
/**
|
|
3
|
+
* Registers a listener for the specified event.
|
|
4
|
+
* @param event - The event name.
|
|
5
|
+
* @param listener - The listener function for the event.
|
|
6
|
+
* @returns A function to remove the listener.
|
|
7
|
+
*/
|
|
8
|
+
on<K extends keyof Events>(event: K, listener: (data: Events[K]) => void): () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Emits an event with the specified data.
|
|
11
|
+
* @param event - The event name.
|
|
12
|
+
* @param data - The data to pass to listeners.
|
|
13
|
+
*/
|
|
14
|
+
emit<K extends keyof Events>(event: K, data: Events[K]): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/event/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnE;;;;;OAKG;IACH,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,CAAC;IAEd;;;;OAIG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/event/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../src/index.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.js","sourceRoot":"","sources":["../../src/index.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.browser.d.ts","sourceRoot":"","sources":["../../src/init.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,CAAC,EAAE,MAAM,UAQjB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Renown } from "./common.js";
|
|
2
|
+
import { BrowserEventEmitter } from "./event/event.browser.js";
|
|
3
|
+
import { BrowserStorage } from "./storage/storage.browser.js";
|
|
4
|
+
export function initRenown(connectId, basename, baseUrl) {
|
|
5
|
+
return new Renown(new BrowserStorage("renown", basename), new BrowserEventEmitter(), connectId, baseUrl);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=init.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.browser.js","sourceRoot":"","sources":["../../src/init.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,MAAM,UAAU,UAAU,CACxB,SAAiB,EACjB,QAA4B,EAC5B,OAAgB;IAEhB,OAAO,IAAI,MAAM,CACf,IAAI,cAAc,CAAmB,QAAQ,EAAE,QAAQ,CAAC,EACxD,IAAI,mBAAmB,EAAgB,EACvC,SAAS,EACT,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.node.d.ts","sourceRoot":"","sources":["../../src/init.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,UASjB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Renown } from "./common.js";
|
|
2
|
+
import { NodeEventEmitter } from "./event/event.node.js";
|
|
3
|
+
import { NodeStorage } from "./storage/storage.node.js";
|
|
4
|
+
export function initRenown(connectId, filePath, namespace, baseUrl) {
|
|
5
|
+
const storage = new NodeStorage(filePath, namespace);
|
|
6
|
+
return new Renown(storage, new NodeEventEmitter(), connectId, baseUrl);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=init.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.node.js","sourceRoot":"","sources":["../../src/init.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,MAAM,UAAU,UAAU,CACxB,SAAiB,EACjB,QAAgB,EAChB,SAAiB,EACjB,OAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,WAAW,CAAmB,QAAQ,EAAE,SAAS,CAAC,CAAC;IACvE,OAAO,IAAI,MAAM,CACf,OAAO,EACP,IAAI,gBAAgB,EAAgB,EACpC,SAAS,EACT,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IStorage<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
2
|
+
get<Key extends keyof T>(key: Key): T[Key] | undefined;
|
|
3
|
+
set<Key extends keyof T>(key: Key, value?: T[Key]): void;
|
|
4
|
+
delete(key: keyof T): void;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class BaseStorage<T extends Record<string, unknown> = Record<string, unknown>> implements IStorage<T> {
|
|
7
|
+
protected namespace: string;
|
|
8
|
+
protected constructor(namespace: string);
|
|
9
|
+
abstract get<Key extends keyof T>(key: Key): T[Key] | undefined;
|
|
10
|
+
abstract set<Key extends keyof T>(key: Key, value?: T[Key]): void;
|
|
11
|
+
abstract delete(key: keyof T): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +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;IAE3D,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACvD,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACzD,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC5B;AAED,8BAAsB,WAAW,CAC/B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D,YAAW,QAAQ,CAAC,CAAC,CAAC;IAEA,SAAS,CAAC,SAAS,EAAE,MAAM;IAAjD,SAAS,aAAuB,SAAS,EAAE,MAAM;IAEjD,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAC/D,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI;IACjE,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/storage/common.ts"],"names":[],"mappings":"AAQA,MAAM,OAAgB,WAAW;IAIC;IAAhC,YAAgC,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;CAKtD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseStorage } from "./common.js";
|
|
2
|
+
export declare class BrowserStorage<T extends Record<string, unknown> = Record<string, unknown>> extends BaseStorage<T> {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(namespace: string, basename: string | undefined);
|
|
5
|
+
get<Key extends keyof T>(key: Key): T[Key] | undefined;
|
|
6
|
+
set<Key extends keyof T>(key: Key, value?: T[Key] | undefined): void;
|
|
7
|
+
delete(key: keyof T): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=storage.browser.d.ts.map
|
|
@@ -0,0 +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;;gBACV,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS;IAO3D,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,SAAS,GAAG,IAAI;IAMpE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI;CAG3B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseStorage } from "./common.js";
|
|
2
|
+
export class BrowserStorage extends BaseStorage {
|
|
3
|
+
constructor(namespace, basename) {
|
|
4
|
+
super(`${basename}:${namespace}`);
|
|
5
|
+
}
|
|
6
|
+
#buildKey(key) {
|
|
7
|
+
return `${this.namespace}:${key.toString()}`;
|
|
8
|
+
}
|
|
9
|
+
get(key) {
|
|
10
|
+
const value = localStorage.getItem(this.#buildKey(key));
|
|
11
|
+
if (value) {
|
|
12
|
+
return JSON.parse(value);
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
set(key, value) {
|
|
17
|
+
return value
|
|
18
|
+
? localStorage.setItem(this.#buildKey(key), JSON.stringify(value))
|
|
19
|
+
: localStorage.removeItem(this.#buildKey(key));
|
|
20
|
+
}
|
|
21
|
+
delete(key) {
|
|
22
|
+
return localStorage.removeItem(this.#buildKey(key));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=storage.browser.js.map
|
|
@@ -0,0 +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;IACtB,YAAY,SAAiB,EAAE,QAA4B;QACzD,KAAK,CAAC,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC,CAAC;IACpC,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,KAA0B;QAC3D,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseStorage } from "./common.js";
|
|
2
|
+
export declare class NodeStorage<T extends Record<string, unknown> = Record<string, unknown>> extends BaseStorage<T> {
|
|
3
|
+
private readonly filePath;
|
|
4
|
+
constructor(filePath: string, namespace: string);
|
|
5
|
+
private readData;
|
|
6
|
+
private writeData;
|
|
7
|
+
get<Key extends keyof T>(key: Key): T[Key] | undefined;
|
|
8
|
+
set<Key extends keyof T>(key: Key, value?: T[Key]): void;
|
|
9
|
+
delete(key: keyof T): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=storage.node.d.ts.map
|
|
@@ -0,0 +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,EAAE,SAAS,EAAE,MAAM;IAS/C,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,SAAS;IAOjB,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;IAWxD,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI;CAM3B"}
|