@ownables/platform-browser 0.1.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +42 -0
  2. package/dist/core/src/index.d.ts +21 -0
  3. package/dist/core/src/index.d.ts.map +1 -0
  4. package/dist/core/src/index.js +20 -0
  5. package/dist/core/src/index.js.map +1 -0
  6. package/dist/core/src/interfaces/core.d.ts +53 -0
  7. package/dist/core/src/interfaces/core.d.ts.map +1 -0
  8. package/dist/core/src/interfaces/core.js +2 -0
  9. package/dist/core/src/interfaces/core.js.map +1 -0
  10. package/dist/core/src/logger.d.ts +3 -0
  11. package/dist/core/src/logger.d.ts.map +1 -0
  12. package/dist/core/src/logger.js +2 -0
  13. package/dist/core/src/logger.js.map +1 -0
  14. package/dist/core/src/ownableErrorMessage.d.ts +2 -0
  15. package/dist/core/src/ownableErrorMessage.d.ts.map +1 -0
  16. package/dist/core/src/ownableErrorMessage.js +20 -0
  17. package/dist/core/src/ownableErrorMessage.js.map +1 -0
  18. package/dist/core/src/progress.d.ts +3 -0
  19. package/dist/core/src/progress.d.ts.map +1 -0
  20. package/dist/core/src/progress.js +8 -0
  21. package/dist/core/src/progress.js.map +1 -0
  22. package/dist/core/src/services/EventChain.service.d.ts +47 -0
  23. package/dist/core/src/services/EventChain.service.d.ts.map +1 -0
  24. package/dist/core/src/services/EventChain.service.js +113 -0
  25. package/dist/core/src/services/EventChain.service.js.map +1 -0
  26. package/dist/core/src/services/Ownable.service.d.ts +60 -0
  27. package/dist/core/src/services/Ownable.service.d.ts.map +1 -0
  28. package/dist/core/src/services/Ownable.service.js +421 -0
  29. package/dist/core/src/services/Ownable.service.js.map +1 -0
  30. package/dist/core/src/services/Polling.service.d.ts +31 -0
  31. package/dist/core/src/services/Polling.service.d.ts.map +1 -0
  32. package/dist/core/src/services/Polling.service.js +109 -0
  33. package/dist/core/src/services/Polling.service.js.map +1 -0
  34. package/dist/core/src/services/SIWE.service.d.ts +16 -0
  35. package/dist/core/src/services/SIWE.service.d.ts.map +1 -0
  36. package/dist/core/src/services/SIWE.service.js +123 -0
  37. package/dist/core/src/services/SIWE.service.js.map +1 -0
  38. package/dist/core/src/services/StateStoreRecordStore.service.d.ts +13 -0
  39. package/dist/core/src/services/StateStoreRecordStore.service.d.ts.map +1 -0
  40. package/dist/core/src/services/StateStoreRecordStore.service.js +76 -0
  41. package/dist/core/src/services/StateStoreRecordStore.service.js.map +1 -0
  42. package/dist/core/src/services/WorkerRPC.service.d.ts +37 -0
  43. package/dist/core/src/services/WorkerRPC.service.d.ts.map +1 -0
  44. package/dist/core/src/services/WorkerRPC.service.js +219 -0
  45. package/dist/core/src/services/WorkerRPC.service.js.map +1 -0
  46. package/dist/core/src/services/workerSource.d.ts +2 -0
  47. package/dist/core/src/services/workerSource.d.ts.map +1 -0
  48. package/dist/core/src/services/workerSource.js +72 -0
  49. package/dist/core/src/services/workerSource.js.map +1 -0
  50. package/dist/core/src/types/Authority.d.ts +40 -0
  51. package/dist/core/src/types/Authority.d.ts.map +1 -0
  52. package/dist/core/src/types/Authority.js +2 -0
  53. package/dist/core/src/types/Authority.js.map +1 -0
  54. package/dist/core/src/types/EventChainStore.d.ts +12 -0
  55. package/dist/core/src/types/EventChainStore.d.ts.map +1 -0
  56. package/dist/core/src/types/EventChainStore.js +2 -0
  57. package/dist/core/src/types/EventChainStore.js.map +1 -0
  58. package/dist/core/src/types/MessageInfo.d.ts +19 -0
  59. package/dist/core/src/types/MessageInfo.d.ts.map +1 -0
  60. package/dist/core/src/types/MessageInfo.js +2 -0
  61. package/dist/core/src/types/MessageInfo.js.map +1 -0
  62. package/dist/core/src/types/OwnableRuntime.d.ts +40 -0
  63. package/dist/core/src/types/OwnableRuntime.d.ts.map +1 -0
  64. package/dist/core/src/types/OwnableRuntime.js +2 -0
  65. package/dist/core/src/types/OwnableRuntime.js.map +1 -0
  66. package/dist/core/src/types/Polling.d.ts +14 -0
  67. package/dist/core/src/types/Polling.d.ts.map +1 -0
  68. package/dist/core/src/types/Polling.js +2 -0
  69. package/dist/core/src/types/Polling.js.map +1 -0
  70. package/dist/core/src/types/SIWE.d.ts +30 -0
  71. package/dist/core/src/types/SIWE.d.ts.map +1 -0
  72. package/dist/core/src/types/SIWE.js +2 -0
  73. package/dist/core/src/types/SIWE.js.map +1 -0
  74. package/dist/core/src/types/TypedCosmWasmMsg.d.ts +12 -0
  75. package/dist/core/src/types/TypedCosmWasmMsg.d.ts.map +1 -0
  76. package/dist/core/src/types/TypedCosmWasmMsg.js +2 -0
  77. package/dist/core/src/types/TypedCosmWasmMsg.js.map +1 -0
  78. package/dist/core/src/types/TypedDict.d.ts +4 -0
  79. package/dist/core/src/types/TypedDict.d.ts.map +1 -0
  80. package/dist/core/src/types/TypedDict.js +2 -0
  81. package/dist/core/src/types/TypedDict.js.map +1 -0
  82. package/dist/core/src/types/TypedOwnableInfo.d.ts +34 -0
  83. package/dist/core/src/types/TypedOwnableInfo.d.ts.map +1 -0
  84. package/dist/core/src/types/TypedOwnableInfo.js +2 -0
  85. package/dist/core/src/types/TypedOwnableInfo.js.map +1 -0
  86. package/dist/core/src/types/TypedPackage.d.ts +35 -0
  87. package/dist/core/src/types/TypedPackage.d.ts.map +1 -0
  88. package/dist/core/src/types/TypedPackage.js +2 -0
  89. package/dist/core/src/types/TypedPackage.js.map +1 -0
  90. package/dist/platform-browser/src/index.d.ts +11 -0
  91. package/dist/platform-browser/src/index.d.ts.map +1 -0
  92. package/dist/platform-browser/src/index.js +11 -0
  93. package/dist/platform-browser/src/index.js.map +1 -0
  94. package/dist/platform-browser/src/services/IDB.service.d.ts +29 -0
  95. package/dist/platform-browser/src/services/IDB.service.d.ts.map +1 -0
  96. package/dist/platform-browser/src/services/IDB.service.js +192 -0
  97. package/dist/platform-browser/src/services/IDB.service.js.map +1 -0
  98. package/dist/platform-browser/src/services/LocalStorage.service.d.ts +14 -0
  99. package/dist/platform-browser/src/services/LocalStorage.service.d.ts.map +1 -0
  100. package/dist/platform-browser/src/services/LocalStorage.service.js +57 -0
  101. package/dist/platform-browser/src/services/LocalStorage.service.js.map +1 -0
  102. package/dist/platform-browser/src/services/Package.service.d.ts +49 -0
  103. package/dist/platform-browser/src/services/Package.service.d.ts.map +1 -0
  104. package/dist/platform-browser/src/services/Package.service.js +466 -0
  105. package/dist/platform-browser/src/services/Package.service.js.map +1 -0
  106. package/dist/platform-browser/src/services/Relay.service.d.ts +59 -0
  107. package/dist/platform-browser/src/services/Relay.service.d.ts.map +1 -0
  108. package/dist/platform-browser/src/services/Relay.service.js +299 -0
  109. package/dist/platform-browser/src/services/Relay.service.js.map +1 -0
  110. package/dist/platform-browser/src/services/SessionStorage.service.d.ts +7 -0
  111. package/dist/platform-browser/src/services/SessionStorage.service.d.ts.map +1 -0
  112. package/dist/platform-browser/src/services/SessionStorage.service.js +16 -0
  113. package/dist/platform-browser/src/services/SessionStorage.service.js.map +1 -0
  114. package/dist/platform-browser/src/utils/calculateCid.d.ts +2 -0
  115. package/dist/platform-browser/src/utils/calculateCid.d.ts.map +1 -0
  116. package/dist/platform-browser/src/utils/calculateCid.js +18 -0
  117. package/dist/platform-browser/src/utils/calculateCid.js.map +1 -0
  118. package/package.json +7 -2
@@ -0,0 +1,123 @@
1
+ export class SIWEClient {
2
+ domain;
3
+ version = "1";
4
+ fetchFn;
5
+ now;
6
+ nonceGenerator;
7
+ constructor(domain, deps = {}) {
8
+ this.domain = domain || "localhost:8000";
9
+ this.fetchFn = deps.fetchFn ?? ((input, init) => fetch(input, init));
10
+ this.now = deps.now ?? (() => new Date());
11
+ this.nonceGenerator = deps.nonceGenerator;
12
+ }
13
+ generateNonce() {
14
+ if (this.nonceGenerator)
15
+ return this.nonceGenerator();
16
+ return (Math.random().toString(36).substring(2, 15) +
17
+ Math.random().toString(36).substring(2, 15));
18
+ }
19
+ createMessage(address, uri, chainId = 84532) {
20
+ return {
21
+ domain: this.domain,
22
+ address,
23
+ statement: "Sign in with Ethereum to the EQTY Relay",
24
+ uri,
25
+ version: this.version,
26
+ chainId,
27
+ nonce: this.generateNonce(),
28
+ issuedAt: this.now().toISOString(),
29
+ };
30
+ }
31
+ async signMessage(message, signer) {
32
+ const domain = {
33
+ name: "Sign-In with Ethereum",
34
+ version: this.version,
35
+ chainId: message.chainId,
36
+ };
37
+ const types = {
38
+ Message: [
39
+ { name: "domain", type: "string" },
40
+ { name: "address", type: "address" },
41
+ { name: "statement", type: "string" },
42
+ { name: "uri", type: "string" },
43
+ { name: "version", type: "string" },
44
+ { name: "chainId", type: "uint256" },
45
+ { name: "nonce", type: "string" },
46
+ { name: "issuedAt", type: "string" },
47
+ { name: "expirationTime", type: "string" },
48
+ { name: "notBefore", type: "string" },
49
+ { name: "requestId", type: "string" },
50
+ { name: "resources", type: "string[]" },
51
+ ],
52
+ };
53
+ const value = {
54
+ domain: message.domain,
55
+ address: message.address,
56
+ statement: message.statement || "",
57
+ uri: message.uri,
58
+ version: message.version,
59
+ chainId: message.chainId,
60
+ nonce: message.nonce,
61
+ issuedAt: message.issuedAt,
62
+ expirationTime: message.expirationTime || "",
63
+ notBefore: message.notBefore || "",
64
+ requestId: message.requestId || "",
65
+ resources: message.resources || [],
66
+ };
67
+ return await signer.signTypedData(domain, types, value);
68
+ }
69
+ async authenticate(signer, relayUrl, chainId = 84532) {
70
+ try {
71
+ const address = await signer.getAddress();
72
+ const uri = `${relayUrl}/auth/verify`;
73
+ const message = this.createMessage(address, uri, chainId);
74
+ const signature = await this.signMessage(message, signer);
75
+ const response = await this.fetchFn(`${relayUrl}/auth/verify`, {
76
+ method: "POST",
77
+ headers: {
78
+ "Content-Type": "application/json",
79
+ },
80
+ body: JSON.stringify({
81
+ message,
82
+ signature,
83
+ }),
84
+ });
85
+ if (!response.ok) {
86
+ const error = await response.json();
87
+ return {
88
+ success: false,
89
+ error: error.error || "Authentication failed",
90
+ };
91
+ }
92
+ const result = await response.json();
93
+ return {
94
+ success: true,
95
+ address: result.address,
96
+ token: result.token,
97
+ expiresIn: result.expiresIn,
98
+ };
99
+ }
100
+ catch (error) {
101
+ return {
102
+ success: false,
103
+ error: `Authentication failed: ${error instanceof Error ? error.message : String(error)}`,
104
+ };
105
+ }
106
+ }
107
+ async getNonce(relayUrl) {
108
+ try {
109
+ const response = await this.fetchFn(`${relayUrl}/auth/nonce`, {
110
+ method: "POST",
111
+ });
112
+ if (!response.ok) {
113
+ throw new Error("Failed to get nonce");
114
+ }
115
+ const result = await response.json();
116
+ return result.nonce;
117
+ }
118
+ catch (error) {
119
+ throw new Error(`Failed to get nonce: ${error instanceof Error ? error.message : String(error)}`);
120
+ }
121
+ }
122
+ }
123
+ //# sourceMappingURL=SIWE.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SIWE.service.js","sourceRoot":"","sources":["../../../../../core/src/services/SIWE.service.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,UAAU;IACJ,MAAM,CAAS;IACf,OAAO,GAAW,GAAG,CAAC;IACtB,OAAO,CAAwF;IAC/F,GAAG,CAAa;IAChB,cAAc,CAA6B;IAE5D,YAAY,MAAe,EAAE,OAAuB,EAAE;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,gBAAgB,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAC5C,CAAC;IAED,aAAa;QACX,IAAI,IAAI,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;QACtD,OAAO,CACL,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CA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C,qBAAqB,CAAC,CAAC;YACzC,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACrC,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,wBACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import type { RecordStore, BridgedOwnableRecord, NftRef } from '../types/Authority';
2
+ import type { StateStore } from '../interfaces/core';
3
+ export default class StateStoreRecordStore implements RecordStore {
4
+ private readonly state;
5
+ constructor(state: StateStore);
6
+ put(record: BridgedOwnableRecord): Promise<void>;
7
+ getByCid(cid: string): Promise<BridgedOwnableRecord | undefined>;
8
+ hasCid(cid: string): Promise<boolean>;
9
+ getCidByNft(nft: NftRef): Promise<string | undefined>;
10
+ getByNft(nft: NftRef): Promise<BridgedOwnableRecord | undefined>;
11
+ listByPrevOwner(prevOwner: string): Promise<BridgedOwnableRecord[]>;
12
+ }
13
+ //# sourceMappingURL=StateStoreRecordStore.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateStoreRecordStore.service.d.ts","sourceRoot":"","sources":["../../../../../core/src/services/StateStoreRecordStore.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA4BrD,MAAM,CAAC,OAAO,OAAO,qBAAsB,YAAW,WAAW;IACnD,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,UAAU;IAExC,GAAG,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkChD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAKhE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKrC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKrD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAMhE,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;CAQ1E"}
@@ -0,0 +1,76 @@
1
+ const STORE_BY_CID = 'records:by-cid';
2
+ const STORE_BY_NFT = 'records:index:nft';
3
+ const STORE_BY_OWNER = 'records:index:owner';
4
+ function normalizeAddress(address) {
5
+ return address.toLowerCase();
6
+ }
7
+ function ownerKey(owner) {
8
+ return normalizeAddress(owner);
9
+ }
10
+ function nftKey(nft) {
11
+ return `${nft.network.toLowerCase()}|${normalizeAddress(nft.address)}|${nft.id}`;
12
+ }
13
+ async function ensureStores(state) {
14
+ const stores = [STORE_BY_CID, STORE_BY_NFT, STORE_BY_OWNER];
15
+ const missing = await Promise.all(stores.map((store) => state.hasStore(store)));
16
+ const toCreate = stores.filter((_store, idx) => !missing[idx]);
17
+ if (toCreate.length > 0) {
18
+ await state.createStore(...toCreate);
19
+ }
20
+ }
21
+ export default class StateStoreRecordStore {
22
+ state;
23
+ constructor(state) {
24
+ this.state = state;
25
+ }
26
+ async put(record) {
27
+ await ensureStores(this.state);
28
+ const existing = await this.getByCid(record.cid);
29
+ const owner = ownerKey(record.prevOwner);
30
+ const nft = nftKey(record.nft);
31
+ await this.state.set(STORE_BY_CID, record.cid, record);
32
+ await this.state.set(STORE_BY_NFT, nft, record.cid);
33
+ const ownerCids = (await this.state.get(STORE_BY_OWNER, owner)) ?? [];
34
+ if (!ownerCids.includes(record.cid)) {
35
+ await this.state.set(STORE_BY_OWNER, owner, [...ownerCids, record.cid]);
36
+ }
37
+ if (!existing) {
38
+ return;
39
+ }
40
+ const oldOwner = ownerKey(existing.prevOwner);
41
+ const oldNft = nftKey(existing.nft);
42
+ if (oldNft !== nft) {
43
+ await this.state.delete(STORE_BY_NFT, oldNft);
44
+ }
45
+ if (oldOwner !== owner) {
46
+ const oldOwnerCids = (await this.state.get(STORE_BY_OWNER, oldOwner)) ?? [];
47
+ const next = oldOwnerCids.filter((cid) => cid !== record.cid);
48
+ await this.state.set(STORE_BY_OWNER, oldOwner, next);
49
+ }
50
+ }
51
+ async getByCid(cid) {
52
+ await ensureStores(this.state);
53
+ return (await this.state.get(STORE_BY_CID, cid));
54
+ }
55
+ async hasCid(cid) {
56
+ const record = await this.getByCid(cid);
57
+ return Boolean(record);
58
+ }
59
+ async getCidByNft(nft) {
60
+ await ensureStores(this.state);
61
+ return (await this.state.get(STORE_BY_NFT, nftKey(nft)));
62
+ }
63
+ async getByNft(nft) {
64
+ const cid = await this.getCidByNft(nft);
65
+ if (!cid)
66
+ return undefined;
67
+ return this.getByCid(cid);
68
+ }
69
+ async listByPrevOwner(prevOwner) {
70
+ await ensureStores(this.state);
71
+ const cids = (await this.state.get(STORE_BY_OWNER, ownerKey(prevOwner))) ?? [];
72
+ const records = await Promise.all(cids.map((cid) => this.getByCid(cid)));
73
+ return records.filter((record) => Boolean(record));
74
+ }
75
+ }
76
+ //# sourceMappingURL=StateStoreRecordStore.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateStoreRecordStore.service.js","sourceRoot":"","sources":["../../../../../core/src/services/StateStoreRecordStore.service.ts"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,gBAAgB,CAAC;AACtC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/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,GAAG,CAAC,CAAC,CAAC,CAAC;QACzE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAkC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ import type TypedDict from '../types/TypedDict';
2
+ import type { CosmWasmEvent, CosmWasmMessageInfo, OwnableRPC, StateDump } from '../types/OwnableRuntime';
3
+ export default class WorkerRPC implements OwnableRPC {
4
+ private worker;
5
+ private readonly ownableId;
6
+ private widgetWindow;
7
+ private _queue;
8
+ constructor(id: string);
9
+ private wrapWorkerError;
10
+ initialize(js: string, wasm: Uint8Array): Promise<void>;
11
+ setWidgetWindow(win: unknown | null): void;
12
+ terminate(): void;
13
+ private attributesToDict;
14
+ private decodeEnvelope;
15
+ private workerCall;
16
+ instantiate(msg: TypedDict, info: CosmWasmMessageInfo): Promise<{
17
+ attributes: TypedDict<string>;
18
+ state: StateDump;
19
+ }>;
20
+ execute(msg: TypedDict, info: CosmWasmMessageInfo, state: StateDump): Promise<{
21
+ attributes: TypedDict<string>;
22
+ events: Array<CosmWasmEvent>;
23
+ data: string;
24
+ state: StateDump;
25
+ }>;
26
+ externalEvent(msg: TypedDict, info: TypedDict, state: StateDump): Promise<{
27
+ attributes: TypedDict<string>;
28
+ events: Array<CosmWasmEvent>;
29
+ data: string;
30
+ state: StateDump;
31
+ }>;
32
+ private toExecuteResult;
33
+ private queryRaw;
34
+ query(msg: TypedDict, state: StateDump): Promise<any>;
35
+ refresh(state: StateDump): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=WorkerRPC.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerRPC.service.d.ts","sourceRoot":"","sources":["../../../../../core/src/services/WorkerRPC.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,SA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cF,OAAO,CAAC,eAAe;YAoBT,QAAQ;IAIhB,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAKrD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAK/C"}
@@ -0,0 +1,219 @@
1
+ import { decode, encode } from 'cbor-x';
2
+ export default class WorkerRPC {
3
+ worker;
4
+ ownableId;
5
+ widgetWindow = null;
6
+ _queue = Promise.resolve();
7
+ constructor(id) {
8
+ this.ownableId = id;
9
+ }
10
+ wrapWorkerError(context, err) {
11
+ if (err instanceof Error)
12
+ return err;
13
+ if (typeof ErrorEvent !== 'undefined' && err instanceof ErrorEvent) {
14
+ const parts = [
15
+ context,
16
+ err.message || 'worker script error',
17
+ err.filename ? `at ${err.filename}:${err.lineno}:${err.colno}` : '',
18
+ ].filter(Boolean);
19
+ const wrapped = new Error(parts.join(' '));
20
+ wrapped.cause = err;
21
+ return wrapped;
22
+ }
23
+ if (typeof MessageEvent !== 'undefined' && err instanceof MessageEvent) {
24
+ const wrapped = new Error(`${context}: worker message deserialization error`);
25
+ wrapped.cause = err;
26
+ return wrapped;
27
+ }
28
+ if (err instanceof Event) {
29
+ const eventLike = err;
30
+ const details = [
31
+ eventLike?.message,
32
+ eventLike?.filename
33
+ ? `at ${eventLike.filename}:${eventLike.lineno ?? '?'}:${eventLike.colno ?? '?'}`
34
+ : '',
35
+ ]
36
+ .filter((v) => typeof v === 'string' && v.trim() !== '')
37
+ .join(' ');
38
+ const wrapped = new Error(`${context}: worker emitted ${err.type} event${details ? ` (${details})` : ''}`);
39
+ wrapped.cause = err;
40
+ return wrapped;
41
+ }
42
+ const wrapped = new Error(`${context}: ${String(err)}`);
43
+ wrapped.cause = err;
44
+ return wrapped;
45
+ }
46
+ async initialize(js, wasm) {
47
+ return await new Promise((resolve, reject) => {
48
+ const blob = new Blob([js], { type: 'application/javascript' });
49
+ const blobURL = URL.createObjectURL(blob);
50
+ this.worker = new Worker(blobURL, { type: 'module' });
51
+ let settled = false;
52
+ const onMessage = (event) => {
53
+ if (settled)
54
+ return;
55
+ settled = true;
56
+ cleanup();
57
+ if (event.data?.err) {
58
+ const raw = event.data.err;
59
+ if (raw.includes('__wbindgen_placeholder__')) {
60
+ reject(new Error('Ownable package is incompatible with this runtime (wasm-bindgen imports detected). Rebuild and re-import the package with Host ABI v1.'));
61
+ return;
62
+ }
63
+ reject(new Error(`Ownable worker init failed: ${raw}`));
64
+ return;
65
+ }
66
+ if (event.data?.success) {
67
+ resolve();
68
+ return;
69
+ }
70
+ reject(new Error('Ownable worker init failed: invalid init response'));
71
+ };
72
+ const onError = (event) => {
73
+ if (settled)
74
+ return;
75
+ settled = true;
76
+ cleanup();
77
+ reject(this.wrapWorkerError('Ownable worker init failed', event));
78
+ };
79
+ const onMessageError = (event) => {
80
+ if (settled)
81
+ return;
82
+ settled = true;
83
+ cleanup();
84
+ reject(this.wrapWorkerError('Ownable worker init failed', event));
85
+ };
86
+ const cleanup = () => {
87
+ URL.revokeObjectURL(blobURL);
88
+ this.worker.removeEventListener('message', onMessage);
89
+ this.worker.removeEventListener('error', onError);
90
+ this.worker.removeEventListener('messageerror', onMessageError);
91
+ };
92
+ this.worker.addEventListener('message', onMessage);
93
+ this.worker.addEventListener('error', onError);
94
+ this.worker.addEventListener('messageerror', onMessageError);
95
+ this.worker.postMessage({ type: 'init', wasm });
96
+ });
97
+ }
98
+ setWidgetWindow(win) {
99
+ this.widgetWindow = win ?? null;
100
+ }
101
+ terminate() {
102
+ this.worker?.terminate();
103
+ }
104
+ attributesToDict(attributes) {
105
+ return Object.fromEntries(attributes.map((a) => [a.key, a.value]));
106
+ }
107
+ decodeEnvelope(output) {
108
+ const envelope = decode(output instanceof Uint8Array ? output : new Uint8Array(output));
109
+ if (!envelope.success) {
110
+ throw new Error(`Ownable ABI call failed: ${envelope.error_code || 'UNKNOWN'} ${envelope.error_message || ''}`.trim());
111
+ }
112
+ const payload = envelope.payload ?? new Uint8Array();
113
+ return decode(payload);
114
+ }
115
+ workerCall(type, request, state) {
116
+ const call = () => new Promise((resolve, reject) => {
117
+ if (!this.worker) {
118
+ reject(new Error(`Unable to ${type}: not initialized`));
119
+ return;
120
+ }
121
+ let settled = false;
122
+ const onMessage = (event) => {
123
+ if (settled)
124
+ return;
125
+ settled = true;
126
+ cleanup();
127
+ if (event.data?.err) {
128
+ reject(new Error(`Ownable ${type} failed: ${event.data.err}`));
129
+ return;
130
+ }
131
+ if (!event.data?.output) {
132
+ reject(new Error(`Ownable ${type} failed: empty worker output`));
133
+ return;
134
+ }
135
+ try {
136
+ const decoded = this.decodeEnvelope(event.data.output);
137
+ const nextState = decoded.mem?.state_dump ?? state;
138
+ resolve({ response: decoded.result, state: nextState || [] });
139
+ }
140
+ catch (error) {
141
+ reject(error instanceof Error ? error : new Error(String(error)));
142
+ }
143
+ };
144
+ const onError = (event) => {
145
+ if (settled)
146
+ return;
147
+ settled = true;
148
+ cleanup();
149
+ reject(this.wrapWorkerError(`Ownable ${type} failed`, event));
150
+ };
151
+ const onMessageError = (event) => {
152
+ if (settled)
153
+ return;
154
+ settled = true;
155
+ cleanup();
156
+ reject(this.wrapWorkerError(`Ownable ${type} failed`, event));
157
+ };
158
+ const cleanup = () => {
159
+ this.worker.removeEventListener('message', onMessage);
160
+ this.worker.removeEventListener('error', onError);
161
+ this.worker.removeEventListener('messageerror', onMessageError);
162
+ };
163
+ this.worker.addEventListener('message', onMessage);
164
+ this.worker.addEventListener('error', onError);
165
+ this.worker.addEventListener('messageerror', onMessageError);
166
+ const input = encode(request);
167
+ this.worker.postMessage({ type, input });
168
+ });
169
+ const next = this._queue.then(call, call);
170
+ this._queue = next.catch(() => { });
171
+ return next;
172
+ }
173
+ async instantiate(msg, info) {
174
+ const { response, state } = await this.workerCall('instantiate', { msg, info });
175
+ const parsed = decode(response);
176
+ return {
177
+ attributes: this.attributesToDict(parsed.attributes),
178
+ state,
179
+ };
180
+ }
181
+ async execute(msg, info, state) {
182
+ const { response, state: newState } = await this.workerCall('execute', { msg, info, mem: { state_dump: state } }, state);
183
+ return this.toExecuteResult(decode(response), newState);
184
+ }
185
+ async externalEvent(msg, info, state) {
186
+ const { response, state: newState } = await this.workerCall('external_event', {
187
+ msg: msg.msg,
188
+ info,
189
+ ownable_id: this.ownableId,
190
+ mem: { state_dump: state },
191
+ }, state);
192
+ return this.toExecuteResult(decode(response), newState);
193
+ }
194
+ toExecuteResult(response, state) {
195
+ return {
196
+ attributes: this.attributesToDict(response.attributes),
197
+ events: (response.events || []).map((e) => ({
198
+ type: e.type,
199
+ attributes: this.attributesToDict(e.attributes),
200
+ })),
201
+ data: response.data ?? '',
202
+ state,
203
+ };
204
+ }
205
+ async queryRaw(msg, state) {
206
+ return (await this.workerCall('query', { msg, mem: { state_dump: state } }, state)).response;
207
+ }
208
+ async query(msg, state) {
209
+ const bytes = await this.queryRaw(msg, state);
210
+ return JSON.parse(new TextDecoder().decode(bytes));
211
+ }
212
+ async refresh(state) {
213
+ if (!this.widgetWindow)
214
+ return;
215
+ const widgetState = await this.query({ get_widget_state: {} }, state);
216
+ this.widgetWindow.postMessage({ ownable_id: this.ownableId, state: widgetState }, '*');
217
+ }
218
+ }
219
+ //# sourceMappingURL=WorkerRPC.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerRPC.service.js","sourceRoot":"","sources":["../../../../../core/src/services/WorkerRPC.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAoBxC,MAAM,CAAC,OAAO,OAAO,SAAS;IACpB,MAAM,CAAU;IACP,SAAS,CAAS;IAC3B,YAAY,GAAkB,IAAI,CAAC;IACnC,MAAM,GAAiB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEjD,YAAY,EAAU;QACpB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAEO,eAAe,CAAC,OAAe,E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W,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,CAAC;IACzF,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_WORKER_SOURCE = "let wasm;\nlet exportsRef;\nlet memory;\n\nfunction toU8Array(value) {\n if (value instanceof Uint8Array) return value;\n if (value instanceof ArrayBuffer) return new Uint8Array(value);\n if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n throw new Error(\"invalid wasm payload: expected ArrayBuffer or TypedArray\");\n}\n\nfunction unpackPtrLen(packed) {\n const value = typeof packed === \"bigint\" ? packed : BigInt(packed);\n const ptr = Number(value & 0xffffffffn);\n const len = Number((value >> 32n) & 0xffffffffn);\n return { ptr, len };\n}\n\nfunction invoke(type, inputBytes) {\n if (!exportsRef || !memory) throw new Error(\"WASM not initialized\");\n\n const len = inputBytes.length >>> 0;\n const inPtr = exportsRef.ownable_alloc(len);\n if (len > 0) new Uint8Array(memory.buffer, inPtr, len).set(inputBytes);\n\n let packed;\n try {\n switch (type) {\n case \"instantiate\": packed = exportsRef.ownable_instantiate(inPtr, len); break;\n case \"execute\": packed = exportsRef.ownable_execute(inPtr, len); break;\n case \"query\": packed = exportsRef.ownable_query(inPtr, len); break;\n case \"external_event\": packed = exportsRef.ownable_external_event(inPtr, len); break;\n default: throw new Error(`unknown message type ${type}`);\n }\n } finally {\n exportsRef.ownable_free(inPtr, len);\n }\n\n const { ptr: outPtr, len: outLen } = unpackPtrLen(packed);\n const output = outLen > 0\n ? new Uint8Array(new Uint8Array(memory.buffer, outPtr, outLen))\n : new Uint8Array();\n if (outLen > 0) exportsRef.ownable_free(outPtr, outLen);\n return output;\n}\n\naddEventListener(\"message\", async (e) => {\n try {\n const { type: messageType } = e.data || {};\n\n if (messageType === \"init\") {\n const wasmBytes = toU8Array(e.data.wasm);\n const { instance } = await WebAssembly.instantiate(wasmBytes, {});\n wasm = instance;\n exportsRef = wasm.exports;\n memory = exportsRef.memory;\n self.postMessage({ success: true, msg: \"WASM instantiated successfully\" });\n return;\n }\n\n if (!wasm) throw new Error(\"WASM not initialized\");\n\n const { type, input } = e.data;\n const inBytes = new Uint8Array(input || new ArrayBuffer(0));\n const output = invoke(type, inBytes);\n self.postMessage({ output }, [output.buffer]);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n self.postMessage({ err: message });\n }\n});";
2
+ //# sourceMappingURL=workerSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerSource.d.ts","sourceRoot":"","sources":["../../../../../core/src/services/workerSource.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,2/EAsE9B,CAAC"}
@@ -0,0 +1,72 @@
1
+ export const DEFAULT_WORKER_SOURCE = `let wasm;
2
+ let exportsRef;
3
+ let memory;
4
+
5
+ function toU8Array(value) {
6
+ if (value instanceof Uint8Array) return value;
7
+ if (value instanceof ArrayBuffer) return new Uint8Array(value);
8
+ if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
9
+ throw new Error("invalid wasm payload: expected ArrayBuffer or TypedArray");
10
+ }
11
+
12
+ function unpackPtrLen(packed) {
13
+ const value = typeof packed === "bigint" ? packed : BigInt(packed);
14
+ const ptr = Number(value & 0xffffffffn);
15
+ const len = Number((value >> 32n) & 0xffffffffn);
16
+ return { ptr, len };
17
+ }
18
+
19
+ function invoke(type, inputBytes) {
20
+ if (!exportsRef || !memory) throw new Error("WASM not initialized");
21
+
22
+ const len = inputBytes.length >>> 0;
23
+ const inPtr = exportsRef.ownable_alloc(len);
24
+ if (len > 0) new Uint8Array(memory.buffer, inPtr, len).set(inputBytes);
25
+
26
+ let packed;
27
+ try {
28
+ switch (type) {
29
+ case "instantiate": packed = exportsRef.ownable_instantiate(inPtr, len); break;
30
+ case "execute": packed = exportsRef.ownable_execute(inPtr, len); break;
31
+ case "query": packed = exportsRef.ownable_query(inPtr, len); break;
32
+ case "external_event": packed = exportsRef.ownable_external_event(inPtr, len); break;
33
+ default: throw new Error(\`unknown message type \${type}\`);
34
+ }
35
+ } finally {
36
+ exportsRef.ownable_free(inPtr, len);
37
+ }
38
+
39
+ const { ptr: outPtr, len: outLen } = unpackPtrLen(packed);
40
+ const output = outLen > 0
41
+ ? new Uint8Array(new Uint8Array(memory.buffer, outPtr, outLen))
42
+ : new Uint8Array();
43
+ if (outLen > 0) exportsRef.ownable_free(outPtr, outLen);
44
+ return output;
45
+ }
46
+
47
+ addEventListener("message", async (e) => {
48
+ try {
49
+ const { type: messageType } = e.data || {};
50
+
51
+ if (messageType === "init") {
52
+ const wasmBytes = toU8Array(e.data.wasm);
53
+ const { instance } = await WebAssembly.instantiate(wasmBytes, {});
54
+ wasm = instance;
55
+ exportsRef = wasm.exports;
56
+ memory = exportsRef.memory;
57
+ self.postMessage({ success: true, msg: "WASM instantiated successfully" });
58
+ return;
59
+ }
60
+
61
+ if (!wasm) throw new Error("WASM not initialized");
62
+
63
+ const { type, input } = e.data;
64
+ const inBytes = new Uint8Array(input || new ArrayBuffer(0));
65
+ const output = invoke(type, inBytes);
66
+ self.postMessage({ output }, [output.buffer]);
67
+ } catch (err) {
68
+ const message = err instanceof Error ? err.message : String(err);
69
+ self.postMessage({ err: message });
70
+ }
71
+ });`;
72
+ //# sourceMappingURL=workerSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerSource.js","sourceRoot":"","sources":["../../../../../core/src/services/workerSource.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsEjC,CAAC"}
@@ -0,0 +1,40 @@
1
+ export interface NftRef {
2
+ network: string;
3
+ address: string;
4
+ id: string;
5
+ }
6
+ export interface BridgedOwnableRecord {
7
+ cid: string;
8
+ prevOwner: string;
9
+ nft: NftRef;
10
+ createdAt: string;
11
+ }
12
+ export interface ImportedArchive {
13
+ cid: string;
14
+ chainJson: Record<string, unknown>;
15
+ chainFileName: 'eventChain.json' | 'chain.json';
16
+ packageFiles: string[];
17
+ }
18
+ export interface RecordStore {
19
+ put(record: BridgedOwnableRecord): Promise<void>;
20
+ getByCid(cid: string): Promise<BridgedOwnableRecord | undefined>;
21
+ hasCid(cid: string): Promise<boolean>;
22
+ getCidByNft(nft: NftRef): Promise<string | undefined>;
23
+ getByNft(nft: NftRef): Promise<BridgedOwnableRecord | undefined>;
24
+ listByPrevOwner(prevOwner: string): Promise<BridgedOwnableRecord[]>;
25
+ }
26
+ export interface ArchiveService {
27
+ importArchive(data: Uint8Array): Promise<ImportedArchive>;
28
+ hasPackage(cid: string): Promise<boolean>;
29
+ hasChain(cid: string): Promise<boolean>;
30
+ readChain(cid: string): Promise<Record<string, unknown>>;
31
+ readPackageZip(cid: string): Promise<Uint8Array>;
32
+ }
33
+ export interface LockableGateway {
34
+ getOwner(contractAddress: string, tokenId: string): Promise<string>;
35
+ isLocked(contractAddress: string, tokenId: string): Promise<boolean>;
36
+ getUnlockChallenge(contractAddress: string, tokenId: string): Promise<string>;
37
+ signUnlockChallenge(challenge: string): Promise<string>;
38
+ isUnlockProofValid(contractAddress: string, tokenId: string, proof: string): Promise<boolean>;
39
+ }
40
+ //# sourceMappingURL=Authority.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Authority.d.ts","sourceRoot":"","sources":["../../../../../core/src/types/Authority.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,M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