@cartridge/controller 0.4.0 → 0.5.0-alpha.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.
Files changed (80) hide show
  1. package/.turbo/turbo-build$colon$deps.log +1 -1
  2. package/dist/account.d.ts +35 -0
  3. package/dist/{device.js → account.js} +14 -33
  4. package/dist/account.js.map +1 -0
  5. package/dist/constants.d.ts +0 -2
  6. package/dist/constants.js +0 -2
  7. package/dist/constants.js.map +1 -1
  8. package/dist/controller.d.ts +7 -14
  9. package/dist/controller.js +41 -53
  10. package/dist/controller.js.map +1 -1
  11. package/dist/errors.d.ts +0 -3
  12. package/dist/errors.js +0 -6
  13. package/dist/errors.js.map +1 -1
  14. package/dist/icon.d.ts +1 -0
  15. package/dist/icon.js +2 -0
  16. package/dist/icon.js.map +1 -0
  17. package/dist/iframe/base.d.ts +0 -1
  18. package/dist/iframe/base.js +21 -11
  19. package/dist/iframe/base.js.map +1 -1
  20. package/dist/iframe/keychain.d.ts +1 -1
  21. package/dist/iframe/keychain.js +1 -4
  22. package/dist/iframe/keychain.js.map +1 -1
  23. package/dist/index.d.ts +4 -0
  24. package/dist/index.js +5 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/provider.d.ts +18 -0
  27. package/dist/provider.js +128 -0
  28. package/dist/provider.js.map +1 -0
  29. package/dist/session/account.d.ts +32 -0
  30. package/dist/session/account.js +31 -0
  31. package/dist/session/account.js.map +1 -0
  32. package/dist/session/backend.d.ts +58 -0
  33. package/dist/session/backend.js +38 -0
  34. package/dist/session/backend.js.map +1 -0
  35. package/dist/session/index.d.ts +5 -0
  36. package/dist/session/index.js +6 -0
  37. package/dist/session/index.js.map +1 -0
  38. package/dist/session/provider.d.ts +25 -0
  39. package/dist/session/provider.js +89 -0
  40. package/dist/session/provider.js.map +1 -0
  41. package/dist/telegram/backend.d.ts +30 -0
  42. package/dist/telegram/backend.js +39 -0
  43. package/dist/telegram/backend.js.map +1 -0
  44. package/dist/telegram/provider.d.ts +19 -0
  45. package/dist/telegram/provider.js +78 -0
  46. package/dist/telegram/provider.js.map +1 -0
  47. package/dist/types.d.ts +12 -31
  48. package/dist/types.js.map +1 -1
  49. package/dist/utils.d.ts +0 -2
  50. package/dist/utils.js +0 -4
  51. package/dist/utils.js.map +1 -1
  52. package/package.json +11 -9
  53. package/src/{device.ts → account.ts} +23 -66
  54. package/src/constants.ts +0 -2
  55. package/src/controller.ts +50 -79
  56. package/src/errors.ts +0 -8
  57. package/src/icon.ts +2 -0
  58. package/src/iframe/base.ts +27 -12
  59. package/src/iframe/keychain.ts +2 -12
  60. package/src/index.ts +5 -0
  61. package/src/provider.ts +181 -0
  62. package/src/session/account.ts +65 -0
  63. package/src/session/backend.ts +73 -0
  64. package/src/session/index.ts +6 -0
  65. package/src/session/provider.ts +141 -0
  66. package/src/telegram/backend.ts +43 -0
  67. package/src/telegram/provider.ts +131 -0
  68. package/src/types.ts +18 -66
  69. package/src/utils.ts +0 -10
  70. package/tsconfig.tsbuildinfo +1 -1
  71. package/dist/device.d.ts +0 -46
  72. package/dist/device.js.map +0 -1
  73. package/dist/session.d.ts +0 -40
  74. package/dist/session.js +0 -44
  75. package/dist/session.js.map +0 -1
  76. package/dist/signer.d.ts +0 -53
  77. package/dist/signer.js +0 -83
  78. package/dist/signer.js.map +0 -1
  79. package/src/session.ts +0 -92
  80. package/src/signer.ts +0 -144
@@ -0,0 +1,18 @@
1
+ import { WalletAccount } from "starknet";
2
+ import { RequestFn, StarknetWindowObject, WalletEventListener, WalletEvents } from "@starknet-io/types-js";
3
+ import { ProviderOptions } from "./types";
4
+ export default abstract class BaseProvider implements StarknetWindowObject {
5
+ id: string;
6
+ name: string;
7
+ version: string;
8
+ icon: string;
9
+ rpc: URL;
10
+ account?: WalletAccount;
11
+ subscriptions: WalletEvents[];
12
+ constructor(options: ProviderOptions);
13
+ request: RequestFn;
14
+ on: WalletEventListener;
15
+ off: WalletEventListener;
16
+ abstract probe(): Promise<WalletAccount | undefined>;
17
+ abstract connect(): Promise<WalletAccount | undefined>;
18
+ }
@@ -0,0 +1,128 @@
1
+ import { Permission, } from "@starknet-io/types-js";
2
+ import { icon } from "./icon";
3
+ export default class BaseProvider {
4
+ constructor(options) {
5
+ this.id = "controller";
6
+ this.name = "Controller";
7
+ this.version = "0.4.0";
8
+ this.icon = icon;
9
+ this.subscriptions = [];
10
+ this.request = async (call) => {
11
+ switch (call.type) {
12
+ case "wallet_getPermissions":
13
+ await this.probe();
14
+ if (this.account) {
15
+ return [Permission.ACCOUNTS];
16
+ }
17
+ return [];
18
+ case "wallet_requestAccounts": {
19
+ if (this.account) {
20
+ return [this.account.address];
21
+ }
22
+ const params = call.params;
23
+ if (params?.silent_mode) {
24
+ this.account = await this.probe();
25
+ }
26
+ else {
27
+ this.account = await this.connect();
28
+ }
29
+ if (this.account) {
30
+ return [this.account.address];
31
+ }
32
+ return [];
33
+ }
34
+ case "wallet_watchAsset":
35
+ throw {
36
+ code: 63,
37
+ message: "An unexpected error occurred",
38
+ data: "wallet_watchAsset not implemented",
39
+ };
40
+ case "wallet_addStarknetChain":
41
+ throw {
42
+ code: 63,
43
+ message: "An unexpected error occurred",
44
+ data: "wallet_addStarknetChain not implemented",
45
+ };
46
+ case "wallet_switchStarknetChain":
47
+ throw {
48
+ code: 63,
49
+ message: "An unexpected error occurred",
50
+ data: "wallet_switchStarknetChain not implemented",
51
+ };
52
+ case "wallet_requestChainId":
53
+ if (!this.account) {
54
+ throw {
55
+ code: 63,
56
+ message: "An unexpected error occurred",
57
+ data: "wallet_deploymentData not implemented",
58
+ };
59
+ }
60
+ return await this.account.getChainId();
61
+ case "wallet_deploymentData":
62
+ throw {
63
+ code: 63,
64
+ message: "An unexpected error occurred",
65
+ data: "wallet_deploymentData not implemented",
66
+ };
67
+ case "wallet_addInvokeTransaction":
68
+ if (!this.account) {
69
+ throw {
70
+ code: 63,
71
+ message: "An unexpected error occurred",
72
+ data: "wallet_deploymentData not implemented",
73
+ };
74
+ }
75
+ let params = call.params;
76
+ return await this.account.execute(params.calls.map((call) => ({
77
+ contractAddress: call.contract_address,
78
+ entrypoint: call.entry_point,
79
+ calldata: call.calldata,
80
+ })));
81
+ case "wallet_addDeclareTransaction":
82
+ throw {
83
+ code: 63,
84
+ message: "An unexpected error occurred",
85
+ data: "wallet_addDeclareTransaction not implemented",
86
+ };
87
+ case "wallet_signTypedData": {
88
+ if (!this.account) {
89
+ throw {
90
+ code: 63,
91
+ message: "An unexpected error occurred",
92
+ data: "Account not initialized",
93
+ };
94
+ }
95
+ return await this.account.signMessage(call.params);
96
+ }
97
+ case "wallet_supportedSpecs":
98
+ return [];
99
+ case "wallet_supportedWalletApi":
100
+ return [];
101
+ default:
102
+ throw {
103
+ code: 63,
104
+ message: "An unexpected error occurred",
105
+ data: `Unknown RPC call type: ${call.type}`,
106
+ };
107
+ }
108
+ };
109
+ this.on = (event, handler) => {
110
+ if (event !== "accountsChanged" && event !== "networkChanged") {
111
+ throw new Error(`Unknown event: ${event}`);
112
+ }
113
+ this.subscriptions.push({ type: event, handler });
114
+ };
115
+ this.off = (event, handler) => {
116
+ if (event !== "accountsChanged" && event !== "networkChanged") {
117
+ throw new Error(`Unknown event: ${event}`);
118
+ }
119
+ const idx = this.subscriptions.findIndex((sub) => sub.type === event && sub.handler === handler);
120
+ if (idx >= 0) {
121
+ this.subscriptions.splice(idx, 1);
122
+ }
123
+ };
124
+ const { rpc } = options;
125
+ this.rpc = new URL(rpc);
126
+ }
127
+ }
128
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,UAAU,GAQX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,MAAM,CAAC,OAAO,OAAgB,YAAY;IAUxC,YAAY,OAAwB;QAT7B,OAAE,GAAG,YAAY,CAAC;QAClB,SAAI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EAAE,CAAC;gBACb,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC;QApJA,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QAExB,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CAqJF"}
@@ -0,0 +1,32 @@
1
+ import { Policy } from "@cartridge/account-wasm";
2
+ import { CartridgeSessionAccount } from "@cartridge/account-wasm/session";
3
+ import { Call, InvokeFunctionResponse, WalletAccount } from "starknet";
4
+ import BaseProvider from "../provider";
5
+ export * from "../errors";
6
+ export * from "../types";
7
+ export { defaultPresets } from "../presets";
8
+ export default class SessionAccount extends WalletAccount {
9
+ controller: CartridgeSessionAccount;
10
+ constructor(provider: BaseProvider, { rpcUrl, privateKey, address, ownerGuid, chainId, expiresAt, policies, }: {
11
+ rpcUrl: string;
12
+ privateKey: string;
13
+ address: string;
14
+ ownerGuid: string;
15
+ chainId: string;
16
+ expiresAt: number;
17
+ policies: Policy[];
18
+ });
19
+ /**
20
+ * Invoke execute function in account contract
21
+ *
22
+ * @param calls the invocation object or an array of them, containing:
23
+ * - contractAddress - the address of the contract
24
+ * - entrypoint - the entrypoint of the contract
25
+ * - calldata - (defaults to []) the calldata
26
+ * - signature - (defaults to []) the signature
27
+ * @param abis (optional) the abi of the contract for better displaying
28
+ *
29
+ * @returns response from addTransaction
30
+ */
31
+ execute(calls: Call | Call[]): Promise<InvokeFunctionResponse>;
32
+ }
@@ -0,0 +1,31 @@
1
+ import { CartridgeSessionAccount } from "@cartridge/account-wasm/session";
2
+ import { WalletAccount } from "starknet";
3
+ import { normalizeCalls } from "../utils";
4
+ export * from "../errors";
5
+ export * from "../types";
6
+ export { defaultPresets } from "../presets";
7
+ export default class SessionAccount extends WalletAccount {
8
+ constructor(provider, { rpcUrl, privateKey, address, ownerGuid, chainId, expiresAt, policies, }) {
9
+ super({ nodeUrl: rpcUrl }, provider);
10
+ this.controller = CartridgeSessionAccount.new_as_registered(rpcUrl, privateKey, address, ownerGuid, chainId, {
11
+ expiresAt,
12
+ policies,
13
+ });
14
+ }
15
+ /**
16
+ * Invoke execute function in account contract
17
+ *
18
+ * @param calls the invocation object or an array of them, containing:
19
+ * - contractAddress - the address of the contract
20
+ * - entrypoint - the entrypoint of the contract
21
+ * - calldata - (defaults to []) the calldata
22
+ * - signature - (defaults to []) the signature
23
+ * @param abis (optional) the abi of the contract for better displaying
24
+ *
25
+ * @returns response from addTransaction
26
+ */
27
+ async execute(calls) {
28
+ return this.controller.execute(normalizeCalls(calls));
29
+ }
30
+ }
31
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/session/account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAgC,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,aAAa;IAGvD,YACE,QAAsB,EACtB,EACE,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,GAST;QAED,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;QAErC,IAAI,CAAC,UAAU,GAAG,uBAAuB,CAAC,iBAAiB,CACzD,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAAO,EACP;YACE,SAAS;YACT,QAAQ;SACT,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,OAAO,CAAC,KAAoB;QAChC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Represents a unified backend for storage operations and link handling.
3
+ */
4
+ export interface UnifiedBackend {
5
+ /**
6
+ * Retrieves the value associated with the specified key.
7
+ * @param key - The key to look up in the storage.
8
+ * @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.
9
+ */
10
+ get: (key: string) => Promise<string | null>;
11
+ /**
12
+ * Stores a key-value pair in the storage.
13
+ * @param key - The key under which to store the value.
14
+ * @param value - The value to be stored.
15
+ * @returns A promise that resolves when the value has been successfully stored.
16
+ */
17
+ set: (key: string, value: string) => Promise<void>;
18
+ /**
19
+ * Removes the key-value pair associated with the specified key from the storage.
20
+ * @param key - The key of the item to be removed.
21
+ * @returns A promise that resolves when the item has been successfully removed.
22
+ */
23
+ delete: (key: string) => Promise<void>;
24
+ /**
25
+ * Opens the specified URL.
26
+ * @param url - The URL to open.
27
+ */
28
+ openLink: (url: string) => void;
29
+ }
30
+ /**
31
+ * Implements a local storage backend that conforms to the UnifiedBackend interface.
32
+ */
33
+ export declare class LocalStorageBackend {
34
+ /**
35
+ * Retrieves the value associated with the specified key from local storage.
36
+ * @param key - The key to look up in local storage.
37
+ * @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.
38
+ */
39
+ get(key: string): Promise<string | null>;
40
+ /**
41
+ * Stores a key-value pair in local storage.
42
+ * @param key - The key under which to store the value.
43
+ * @param value - The value to be stored.
44
+ * @returns A promise that resolves when the value has been successfully stored.
45
+ */
46
+ set(key: string, value: string): Promise<void>;
47
+ /**
48
+ * Removes the key-value pair associated with the specified key from local storage.
49
+ * @param key - The key of the item to be removed.
50
+ * @returns A promise that resolves when the item has been successfully removed.
51
+ */
52
+ delete(key: string): Promise<void>;
53
+ /**
54
+ * Opens the specified URL in a new tab or window.
55
+ * @param url - The URL to open.
56
+ */
57
+ openLink(url: string): void;
58
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Implements a local storage backend that conforms to the UnifiedBackend interface.
3
+ */
4
+ export class LocalStorageBackend {
5
+ /**
6
+ * Retrieves the value associated with the specified key from local storage.
7
+ * @param key - The key to look up in local storage.
8
+ * @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.
9
+ */
10
+ async get(key) {
11
+ return localStorage.getItem(key);
12
+ }
13
+ /**
14
+ * Stores a key-value pair in local storage.
15
+ * @param key - The key under which to store the value.
16
+ * @param value - The value to be stored.
17
+ * @returns A promise that resolves when the value has been successfully stored.
18
+ */
19
+ async set(key, value) {
20
+ localStorage.setItem(key, value);
21
+ }
22
+ /**
23
+ * Removes the key-value pair associated with the specified key from local storage.
24
+ * @param key - The key of the item to be removed.
25
+ * @returns A promise that resolves when the item has been successfully removed.
26
+ */
27
+ async delete(key) {
28
+ localStorage.removeItem(key);
29
+ }
30
+ /**
31
+ * Opens the specified URL in a new tab or window.
32
+ * @param url - The URL to open.
33
+ */
34
+ openLink(url) {
35
+ window.open(url, "_blank");
36
+ }
37
+ }
38
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/session/backend.ts"],"names":[],"mappings":"AAiCA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC9B;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;QAClC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,GAAW;QAClB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export { default } from "./provider";
2
+ export * from "./provider";
3
+ export * from "../errors";
4
+ export * from "../types";
5
+ export { defaultPresets } from "../presets";
@@ -0,0 +1,6 @@
1
+ export { default } from "./provider";
2
+ export * from "./provider";
3
+ export * from "../errors";
4
+ export * from "../types";
5
+ export { defaultPresets } from "../presets";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Policy } from "@cartridge/controller";
2
+ import { WalletAccount } from "starknet";
3
+ import SessionAccount from "./account";
4
+ import BaseProvider from "../provider";
5
+ export type SessionOptions = {
6
+ rpc: string;
7
+ chainId: string;
8
+ policies: Policy[];
9
+ redirectUrl: string;
10
+ };
11
+ export default class SessionProvider extends BaseProvider {
12
+ id: string;
13
+ name: string;
14
+ protected _chainId: string;
15
+ protected _username?: string;
16
+ protected _redirectUrl: string;
17
+ protected _policies: Policy[];
18
+ account?: SessionAccount;
19
+ constructor({ rpc, chainId, policies, redirectUrl }: SessionOptions);
20
+ username(): Promise<string | undefined>;
21
+ probe(): Promise<WalletAccount | undefined>;
22
+ connect(): Promise<WalletAccount | undefined>;
23
+ disconnect(): Promise<void>;
24
+ tryRetrieveFromQueryOrStorage(): Promise<SessionAccount | undefined>;
25
+ }
@@ -0,0 +1,89 @@
1
+ import { ec, stark } from "starknet";
2
+ import SessionAccount from "./account";
3
+ import { KEYCHAIN_URL } from "../constants";
4
+ import BaseProvider from "../provider";
5
+ export default class SessionProvider extends BaseProvider {
6
+ constructor({ rpc, chainId, policies, redirectUrl }) {
7
+ super({ rpc });
8
+ this.id = "controller_session";
9
+ this.name = "Controller Session";
10
+ this._chainId = chainId;
11
+ this._redirectUrl = redirectUrl;
12
+ this._policies = policies;
13
+ if (typeof window !== "undefined") {
14
+ window.starknet_controller_session = this;
15
+ }
16
+ }
17
+ async username() {
18
+ await this.tryRetrieveFromQueryOrStorage();
19
+ return this._username;
20
+ }
21
+ async probe() {
22
+ await this.tryRetrieveFromQueryOrStorage();
23
+ return;
24
+ }
25
+ async connect() {
26
+ await this.tryRetrieveFromQueryOrStorage();
27
+ if (this.account) {
28
+ return;
29
+ }
30
+ // Generate a random local key pair
31
+ const pk = stark.randomAddress();
32
+ const publicKey = ec.starkCurve.getStarkKey(pk);
33
+ localStorage.setItem("sessionSigner", JSON.stringify({
34
+ privKey: pk,
35
+ pubKey: publicKey,
36
+ }));
37
+ const url = `${KEYCHAIN_URL}/session?public_key=${publicKey}&redirect_uri=${this._redirectUrl}&redirect_query_name=startapp&policies=${JSON.stringify(this._policies)}&rpc_url=${this.rpc}`;
38
+ localStorage.setItem("lastUsedConnector", this.id);
39
+ window.open(url, "_blank");
40
+ return;
41
+ }
42
+ disconnect() {
43
+ localStorage.removeItem("sessionSigner");
44
+ localStorage.removeItem("session");
45
+ this.account = undefined;
46
+ this._username = undefined;
47
+ return Promise.resolve();
48
+ }
49
+ async tryRetrieveFromQueryOrStorage() {
50
+ const signerString = localStorage.getItem("sessionSigner");
51
+ const signer = signerString ? JSON.parse(signerString) : null;
52
+ let sessionRegistration = null;
53
+ if (window.location.search.includes("startapp")) {
54
+ const params = new URLSearchParams(window.location.search);
55
+ const session = params.get("startapp");
56
+ if (session) {
57
+ sessionRegistration = JSON.parse(atob(session));
58
+ localStorage.setItem("session", JSON.stringify(sessionRegistration));
59
+ // Remove the session query parameter
60
+ params.delete("startapp");
61
+ const newUrl = window.location.pathname +
62
+ (params.toString() ? `?${params.toString()}` : "") +
63
+ window.location.hash;
64
+ window.history.replaceState({}, document.title, newUrl);
65
+ }
66
+ }
67
+ if (!sessionRegistration) {
68
+ const sessionString = localStorage.getItem("session");
69
+ if (sessionString) {
70
+ sessionRegistration = JSON.parse(sessionString);
71
+ }
72
+ }
73
+ if (!sessionRegistration || !signer) {
74
+ return;
75
+ }
76
+ this._username = sessionRegistration.username;
77
+ this.account = new SessionAccount(this, {
78
+ rpcUrl: this.rpc.toString(),
79
+ privateKey: signer.privKey,
80
+ address: sessionRegistration.address,
81
+ ownerGuid: sessionRegistration.ownerGuid,
82
+ chainId: this._chainId,
83
+ expiresAt: parseInt(sessionRegistration.expiresAt),
84
+ policies: this._policies,
85
+ });
86
+ return this.account;
87
+ }
88
+ }
89
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/session/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAiB,MAAM,UAAU,CAAC;AAEpD,OAAO,cAAc,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,YAAY,MAAM,aAAa,CAAC;AAiBvC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,YAAY;IAWvD,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAkB;QACjE,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAXV,OAAE,GAAG,oBAAoB,CAAC;QAC1B,SAAI,GAAG,oBAAoB,CAAC;QAYjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YACjC,MAAc,CAAC,2BAA2B,GAAG,IAAI,CAAC;QACrD,CAAC;IAC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,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QAED,IAAI,CAAC,mBAAmB,IAAI,CAAC,MAAM,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,IAAI,EAAE;YACtC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC3B,UAAU,EAAE,MAAM,CAAC,OAAO;YAC1B,OAAO,EAAE,mBAAmB,CAAC,OAAO;YACpC,SAAS,EAAE,mBAAmB,CAAC,SAAS;YACxC,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC;YAClD,QAAQ,EAAE,IAAI,CAAC,SAAS;SACzB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { UnifiedBackend } from "src/session/backend";
2
+ /**
3
+ * Implements the UnifiedBackend interface for Telegram storage operations.
4
+ */
5
+ export declare class TelegramBackend implements UnifiedBackend {
6
+ /**
7
+ * Retrieves the value associated with the specified key from Telegram cloud storage.
8
+ * @param key - The key to look up in the storage.
9
+ * @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.
10
+ */
11
+ get(key: string): Promise<string | null>;
12
+ /**
13
+ * Stores a key-value pair in Telegram cloud storage.
14
+ * @param key - The key under which to store the value.
15
+ * @param value - The value to be stored.
16
+ * @returns A promise that resolves when the value has been successfully stored.
17
+ */
18
+ set(key: string, value: string): Promise<void>;
19
+ /**
20
+ * Removes the key-value pair associated with the specified key from Telegram cloud storage.
21
+ * @param key - The key of the item to be removed.
22
+ * @returns A promise that resolves when the item has been successfully removed.
23
+ */
24
+ delete(key: string): Promise<void>;
25
+ /**
26
+ * Opens the specified URL using Telegram's openLink function.
27
+ * @param url - The URL to open.
28
+ */
29
+ openLink(url: string): void;
30
+ }
@@ -0,0 +1,39 @@
1
+ import { cloudStorage, openLink } from "@telegram-apps/sdk";
2
+ /**
3
+ * Implements the UnifiedBackend interface for Telegram storage operations.
4
+ */
5
+ export class TelegramBackend {
6
+ /**
7
+ * Retrieves the value associated with the specified key from Telegram cloud storage.
8
+ * @param key - The key to look up in the storage.
9
+ * @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.
10
+ */
11
+ async get(key) {
12
+ return await cloudStorage.getItem(key);
13
+ }
14
+ /**
15
+ * Stores a key-value pair in Telegram cloud storage.
16
+ * @param key - The key under which to store the value.
17
+ * @param value - The value to be stored.
18
+ * @returns A promise that resolves when the value has been successfully stored.
19
+ */
20
+ async set(key, value) {
21
+ await cloudStorage.setItem(key, value);
22
+ }
23
+ /**
24
+ * Removes the key-value pair associated with the specified key from Telegram cloud storage.
25
+ * @param key - The key of the item to be removed.
26
+ * @returns A promise that resolves when the item has been successfully removed.
27
+ */
28
+ async delete(key) {
29
+ await cloudStorage.deleteItem(key);
30
+ }
31
+ /**
32
+ * Opens the specified URL using Telegram's openLink function.
33
+ * @param url - The URL to open.
34
+ */
35
+ openLink(url) {
36
+ openLink(url);
37
+ }
38
+ }
39
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/telegram/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG5D;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;QAClC,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,GAAW;QAClB,QAAQ,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { WalletAccount } from "starknet";
2
+ import { Policy } from "src/types";
3
+ import BaseProvider from "src/provider";
4
+ export default class TelegramProvider extends BaseProvider {
5
+ private _tmaUrl;
6
+ protected _chainId: string;
7
+ protected _username?: string;
8
+ protected _policies: Policy[];
9
+ constructor({ rpc, chainId, policies, tmaUrl, }: {
10
+ rpc: string;
11
+ chainId: string;
12
+ policies: Policy[];
13
+ tmaUrl: string;
14
+ });
15
+ probe(): Promise<WalletAccount | undefined>;
16
+ connect(): Promise<WalletAccount | undefined>;
17
+ disconnect(): Promise<void>;
18
+ tryRetrieveFromQueryOrStorage(): Promise<WalletAccount | undefined>;
19
+ }
@@ -0,0 +1,78 @@
1
+ import { cloudStorage, miniApp, openLink, retrieveLaunchParams, } from "@telegram-apps/sdk";
2
+ import { ec, stark } from "starknet";
3
+ import { KEYCHAIN_URL } from "src/constants";
4
+ import SessionAccount from "src/session/account";
5
+ import BaseProvider from "src/provider";
6
+ export default class TelegramProvider extends BaseProvider {
7
+ constructor({ rpc, chainId, policies, tmaUrl, }) {
8
+ super({
9
+ rpc,
10
+ });
11
+ this._tmaUrl = tmaUrl;
12
+ this._chainId = chainId;
13
+ this._policies = policies;
14
+ if (typeof window !== "undefined") {
15
+ window.starknet_controller = this;
16
+ }
17
+ }
18
+ async probe() {
19
+ await this.tryRetrieveFromQueryOrStorage();
20
+ return;
21
+ }
22
+ async connect() {
23
+ await this.tryRetrieveFromQueryOrStorage();
24
+ if (this.account) {
25
+ return;
26
+ }
27
+ // Generate a random local key pair
28
+ const pk = stark.randomAddress();
29
+ const publicKey = ec.starkCurve.getStarkKey(pk);
30
+ cloudStorage.setItem("sessionSigner", JSON.stringify({
31
+ privKey: pk,
32
+ pubKey: publicKey,
33
+ }));
34
+ const url = `${KEYCHAIN_URL}/session?public_key=${publicKey}&redirect_uri=${this._tmaUrl}&redirect_query_name=startapp&policies=${JSON.stringify(this._policies)}&rpc_url=${this.rpc}`;
35
+ localStorage.setItem("lastUsedConnector", this.id);
36
+ openLink(url);
37
+ miniApp.close();
38
+ return;
39
+ }
40
+ disconnect() {
41
+ cloudStorage.deleteItem("sessionSigner");
42
+ cloudStorage.deleteItem("session");
43
+ this.account = undefined;
44
+ this._username = undefined;
45
+ return Promise.resolve();
46
+ }
47
+ async tryRetrieveFromQueryOrStorage() {
48
+ const signer = JSON.parse((await cloudStorage.getItem("sessionSigner")));
49
+ let sessionRegistration = null;
50
+ const launchParams = retrieveLaunchParams();
51
+ const session = launchParams.startParam;
52
+ if (session) {
53
+ sessionRegistration = JSON.parse(atob(session));
54
+ cloudStorage.setItem("session", JSON.stringify(sessionRegistration));
55
+ }
56
+ if (!sessionRegistration) {
57
+ const session = await cloudStorage.getItem("session");
58
+ if (session) {
59
+ sessionRegistration = JSON.parse(session);
60
+ }
61
+ }
62
+ if (!sessionRegistration) {
63
+ return;
64
+ }
65
+ this._username = sessionRegistration.username;
66
+ this.account = new SessionAccount(this, {
67
+ rpcUrl: this.rpc.toString(),
68
+ privateKey: signer.privKey,
69
+ address: sessionRegistration.address,
70
+ ownerGuid: sessionRegistration.ownerGuid,
71
+ chainId: this._chainId,
72
+ expiresAt: parseInt(sessionRegistration.expiresAt),
73
+ policies: this._policies,
74
+ });
75
+ return this.account;
76
+ }
77
+ }
78
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/telegram/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,oBAAoB,GACrB,MAAM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