@cartridge/controller 0.5.0-alpha.4 → 0.5.0-alpha.6
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/.turbo/turbo-build$colon$deps.log +116 -4
- package/dist/account.d.ts +9 -6
- package/dist/account.js +84 -74
- package/dist/account.js.map +1 -1
- package/dist/constants.d.ts +4 -2
- package/dist/constants.js +7 -2
- package/dist/constants.js.map +1 -1
- package/dist/controller.d.ts +12 -5
- package/dist/controller.js +739 -182
- package/dist/controller.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +10 -6
- package/dist/errors.js.map +1 -1
- package/dist/icon.d.ts +3 -1
- package/dist/icon.js +5 -1
- package/dist/icon.js.map +1 -1
- package/dist/iframe/base.d.ts +5 -23
- package/dist/iframe/base.js +272 -98
- package/dist/iframe/base.js.map +1 -1
- package/dist/iframe/index.d.ts +5 -3
- package/dist/iframe/index.js +331 -3
- package/dist/iframe/index.js.map +1 -1
- package/dist/iframe/keychain.d.ts +5 -7
- package/dist/iframe/keychain.js +294 -13
- package/dist/iframe/keychain.js.map +1 -1
- package/dist/iframe/profile.d.ts +5 -11
- package/dist/iframe/profile.js +308 -16
- package/dist/iframe/profile.js.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.js +767 -4
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +9 -2
- package/dist/presets.js +159 -146
- package/dist/presets.js.map +1 -1
- package/dist/provider.d.ts +9 -4
- package/dist/provider.js +138 -124
- package/dist/provider.js.map +1 -1
- package/dist/session/account.d.ts +14 -8
- package/dist/session/account.js +235 -27
- package/dist/session/account.js.map +1 -1
- package/dist/session/backend.d.ts +4 -2
- package/dist/session/backend.js +38 -37
- package/dist/session/backend.js.map +1 -1
- package/dist/session/index.d.ts +9 -5
- package/dist/session/index.js +467 -5
- package/dist/session/index.js.map +1 -1
- package/dist/session/provider.d.ts +12 -8
- package/dist/session/provider.js +281 -81
- package/dist/session/provider.js.map +1 -1
- package/dist/telegram/backend.d.ts +5 -2
- package/dist/telegram/backend.js +38 -37
- package/dist/telegram/backend.js.map +1 -1
- package/dist/telegram/provider.d.ts +7 -4
- package/dist/telegram/provider.js +283 -70
- package/dist/telegram/provider.js.map +1 -1
- package/dist/types-DIeWpu0p.d.ts +196 -0
- package/dist/types.d.ts +5 -159
- package/dist/types.js +12 -8
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +7 -3
- package/dist/utils.js +12 -8
- package/dist/utils.js.map +1 -1
- package/package.json +17 -14
- package/src/controller.ts +13 -25
- package/src/iframe/base.ts +3 -0
- package/src/iframe/profile.ts +17 -9
- package/src/presets.ts +10 -1
- package/src/session/provider.ts +1 -2
- package/src/types.ts +3 -7
- package/tsconfig.json +4 -1
- package/tsconfig.tsbuildinfo +0 -1
package/dist/session/account.js
CHANGED
|
@@ -1,31 +1,239 @@
|
|
|
1
|
+
// src/session/account.ts
|
|
1
2
|
import { CartridgeSessionAccount } from "@cartridge/account-wasm/session";
|
|
2
3
|
import { WalletAccount } from "starknet";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
}
|
|
4
|
+
|
|
5
|
+
// src/utils.ts
|
|
6
|
+
import { addAddressPadding, CallData } from "starknet";
|
|
7
|
+
function normalizeCalls(calls) {
|
|
8
|
+
return (Array.isArray(calls) ? calls : [calls]).map((call) => {
|
|
9
|
+
return {
|
|
10
|
+
entrypoint: call.entrypoint,
|
|
11
|
+
contractAddress: addAddressPadding(call.contractAddress),
|
|
12
|
+
calldata: CallData.toHex(call.calldata)
|
|
13
|
+
};
|
|
14
|
+
});
|
|
30
15
|
}
|
|
16
|
+
|
|
17
|
+
// src/errors.ts
|
|
18
|
+
var NotReadyToConnect = class _NotReadyToConnect extends Error {
|
|
19
|
+
constructor() {
|
|
20
|
+
super("Not ready to connect");
|
|
21
|
+
Object.setPrototypeOf(this, _NotReadyToConnect.prototype);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/types.ts
|
|
26
|
+
var ResponseCodes = /* @__PURE__ */ ((ResponseCodes2) => {
|
|
27
|
+
ResponseCodes2["SUCCESS"] = "SUCCESS";
|
|
28
|
+
ResponseCodes2["NOT_CONNECTED"] = "NOT_CONNECTED";
|
|
29
|
+
ResponseCodes2["ERROR"] = "ERROR";
|
|
30
|
+
ResponseCodes2["CANCELED"] = "CANCELED";
|
|
31
|
+
ResponseCodes2["USER_INTERACTION_REQUIRED"] = "USER_INTERACTION_REQUIRED";
|
|
32
|
+
return ResponseCodes2;
|
|
33
|
+
})(ResponseCodes || {});
|
|
34
|
+
|
|
35
|
+
// src/presets.ts
|
|
36
|
+
var defaultPresets = {
|
|
37
|
+
cartridge: {
|
|
38
|
+
id: "cartridge",
|
|
39
|
+
name: "Cartridge",
|
|
40
|
+
icon: "/whitelabel/cartridge/icon.svg",
|
|
41
|
+
cover: {
|
|
42
|
+
light: "/whitelabel/cartridge/cover-light.png",
|
|
43
|
+
dark: "/whitelabel/cartridge/cover-dark.png"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"force-prime": {
|
|
47
|
+
id: "force-prime",
|
|
48
|
+
name: "Force Prime",
|
|
49
|
+
icon: "/whitelabel/force-prime/icon.png",
|
|
50
|
+
cover: "/whitelabel/force-prime/cover.png",
|
|
51
|
+
colors: {
|
|
52
|
+
primary: "#E1CC89"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
paved: {
|
|
56
|
+
id: "paved",
|
|
57
|
+
name: "Paved",
|
|
58
|
+
icon: "/whitelabel/paved/icon.svg",
|
|
59
|
+
cover: "/whitelabel/paved/cover.png",
|
|
60
|
+
colors: {
|
|
61
|
+
primary: "#B0CAF8"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
eternum: {
|
|
65
|
+
id: "eternum",
|
|
66
|
+
name: "Eternum",
|
|
67
|
+
icon: "/whitelabel/eternum/icon.gif",
|
|
68
|
+
cover: "/whitelabel/eternum/cover.png",
|
|
69
|
+
colors: {
|
|
70
|
+
primary: "#CE9822"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
pistols: {
|
|
74
|
+
id: "pistols",
|
|
75
|
+
name: "Pistols at Ten Blocks",
|
|
76
|
+
icon: "/whitelabel/pistols/icon.png",
|
|
77
|
+
cover: "/whitelabel/pistols/cover.png",
|
|
78
|
+
colors: {
|
|
79
|
+
primary: "#EF9758"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
pixelaw: {
|
|
83
|
+
id: "pixelaw",
|
|
84
|
+
name: "Pixelaw",
|
|
85
|
+
icon: "/whitelabel/pixelaw/icon.svg",
|
|
86
|
+
cover: "/whitelabel/pixelaw/cover.png",
|
|
87
|
+
colors: {
|
|
88
|
+
primary: "#7C00B1",
|
|
89
|
+
primaryForeground: "white"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"dope-wars": {
|
|
93
|
+
id: "dope-wars",
|
|
94
|
+
name: "Dope Wars",
|
|
95
|
+
icon: "/whitelabel/dope-wars/icon.png",
|
|
96
|
+
cover: "/whitelabel/dope-wars/cover.png",
|
|
97
|
+
colors: {
|
|
98
|
+
primary: "#11ED83"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
zkastle: {
|
|
102
|
+
id: "zkastle",
|
|
103
|
+
name: "zKastle",
|
|
104
|
+
icon: "/whitelabel/zkastle/icon.svg",
|
|
105
|
+
cover: "/whitelabel/zkastle/cover.png",
|
|
106
|
+
colors: {
|
|
107
|
+
primary: "#E50D2C"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"loot-survivor": {
|
|
111
|
+
id: "loot-survivor",
|
|
112
|
+
name: "Loot Survivor",
|
|
113
|
+
icon: "/whitelabel/loot-survivor/icon.png",
|
|
114
|
+
cover: "/whitelabel/loot-survivor/cover.png",
|
|
115
|
+
colors: {
|
|
116
|
+
primary: "#33FF33"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"tale-weaver": {
|
|
120
|
+
id: "tale-weaver",
|
|
121
|
+
name: "Tale Weaver",
|
|
122
|
+
icon: "/whitelabel/tale-weaver/icon.png",
|
|
123
|
+
cover: "/whitelabel/tale-weaver/cover.png",
|
|
124
|
+
colors: {
|
|
125
|
+
primary: "#fce377"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"realm-of-ra": {
|
|
129
|
+
id: "realm-of-ra",
|
|
130
|
+
name: "Realm of Ra",
|
|
131
|
+
icon: "/whitelabel/realm-of-ra/icon.png",
|
|
132
|
+
cover: "/whitelabel/realm-of-ra/cover.png",
|
|
133
|
+
colors: {
|
|
134
|
+
primary: "#de9534"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"jokers-of-neon": {
|
|
138
|
+
id: "jokers-of-neon",
|
|
139
|
+
name: "Jokers of Neon",
|
|
140
|
+
icon: "/whitelabel/jokers-of-neon/icon.png",
|
|
141
|
+
cover: "/whitelabel/jokers-of-neon/cover.png",
|
|
142
|
+
colors: {
|
|
143
|
+
primary: "#A144B2"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
flippyflop: {
|
|
147
|
+
id: "flippyflop",
|
|
148
|
+
name: "FlippyFlop",
|
|
149
|
+
icon: "/whitelabel/flippyflop/icon.png",
|
|
150
|
+
cover: "/whitelabel/flippyflop/cover.png",
|
|
151
|
+
colors: {
|
|
152
|
+
primary: "#F38332"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"savage-summit": {
|
|
156
|
+
id: "savage-summit",
|
|
157
|
+
name: "Savage Summit",
|
|
158
|
+
icon: "/whitelabel/savage-summit/icon.png",
|
|
159
|
+
cover: "/whitelabel/savage-summit/cover.png",
|
|
160
|
+
colors: {
|
|
161
|
+
primary: "#fbf7da"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"dark-shuffle": {
|
|
165
|
+
id: "dark-shuffle",
|
|
166
|
+
name: "Dark Shuffle",
|
|
167
|
+
icon: "/whitelabel/dark-shuffle/icon.svg",
|
|
168
|
+
cover: "/whitelabel/dark-shuffle/cover.png",
|
|
169
|
+
colors: {
|
|
170
|
+
primary: "#F59100"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"blob-arena": {
|
|
174
|
+
id: "blob-arena",
|
|
175
|
+
name: "Blob Arena",
|
|
176
|
+
icon: "/whitelabel/blob-arena/icon.png",
|
|
177
|
+
cover: "/whitelabel/blob-arena/cover.png",
|
|
178
|
+
colors: {
|
|
179
|
+
primary: "#980f06"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
zkube: {
|
|
183
|
+
id: "zkube",
|
|
184
|
+
name: "zKube",
|
|
185
|
+
icon: "/whitelabel/zkube/icon.png",
|
|
186
|
+
cover: "/whitelabel/zkube/cover.png",
|
|
187
|
+
colors: {
|
|
188
|
+
primary: "#5bc3e6"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/session/account.ts
|
|
194
|
+
var SessionAccount = class extends WalletAccount {
|
|
195
|
+
constructor(provider, {
|
|
196
|
+
rpcUrl,
|
|
197
|
+
privateKey,
|
|
198
|
+
address,
|
|
199
|
+
ownerGuid,
|
|
200
|
+
chainId,
|
|
201
|
+
expiresAt,
|
|
202
|
+
policies
|
|
203
|
+
}) {
|
|
204
|
+
super({ nodeUrl: rpcUrl }, provider);
|
|
205
|
+
this.controller = CartridgeSessionAccount.new_as_registered(
|
|
206
|
+
rpcUrl,
|
|
207
|
+
privateKey,
|
|
208
|
+
address,
|
|
209
|
+
ownerGuid,
|
|
210
|
+
chainId,
|
|
211
|
+
{
|
|
212
|
+
expiresAt,
|
|
213
|
+
policies
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Invoke execute function in account contract
|
|
219
|
+
*
|
|
220
|
+
* @param calls the invocation object or an array of them, containing:
|
|
221
|
+
* - contractAddress - the address of the contract
|
|
222
|
+
* - entrypoint - the entrypoint of the contract
|
|
223
|
+
* - calldata - (defaults to []) the calldata
|
|
224
|
+
* - signature - (defaults to []) the signature
|
|
225
|
+
* @param abis (optional) the abi of the contract for better displaying
|
|
226
|
+
*
|
|
227
|
+
* @returns response from addTransaction
|
|
228
|
+
*/
|
|
229
|
+
async execute(calls) {
|
|
230
|
+
return this.controller.execute(normalizeCalls(calls));
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
export {
|
|
234
|
+
NotReadyToConnect,
|
|
235
|
+
ResponseCodes,
|
|
236
|
+
SessionAccount as default,
|
|
237
|
+
defaultPresets
|
|
238
|
+
};
|
|
31
239
|
//# sourceMappingURL=account.js.map
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"sources":["../../src/session/account.ts","../../src/utils.ts","../../src/errors.ts","../../src/types.ts","../../src/presets.ts"],"sourcesContent":["import { Policy } from \"@cartridge/account-wasm\";\nimport { CartridgeSessionAccount } from \"@cartridge/account-wasm/session\";\nimport { Call, InvokeFunctionResponse, WalletAccount } from \"starknet\";\n\nimport { normalizeCalls } from \"../utils\";\nimport BaseProvider from \"../provider\";\n\nexport * from \"../errors\";\nexport * from \"../types\";\nexport { defaultPresets } from \"../presets\";\n\nexport default class SessionAccount extends WalletAccount {\n public controller: CartridgeSessionAccount;\n\n constructor(\n provider: BaseProvider,\n {\n rpcUrl,\n privateKey,\n address,\n ownerGuid,\n chainId,\n expiresAt,\n policies,\n }: {\n rpcUrl: string;\n privateKey: string;\n address: string;\n ownerGuid: string;\n chainId: string;\n expiresAt: number;\n policies: Policy[];\n },\n ) {\n super({ nodeUrl: rpcUrl }, provider);\n\n this.controller = CartridgeSessionAccount.new_as_registered(\n rpcUrl,\n privateKey,\n address,\n ownerGuid,\n chainId,\n {\n expiresAt,\n policies,\n },\n );\n }\n\n /**\n * Invoke execute function in account contract\n *\n * @param calls the invocation object or an array of them, containing:\n * - contractAddress - the address of the contract\n * - entrypoint - the entrypoint of the contract\n * - calldata - (defaults to []) the calldata\n * - signature - (defaults to []) the signature\n * @param abis (optional) the abi of the contract for better displaying\n *\n * @returns response from addTransaction\n */\n async execute(calls: Call | Call[]): Promise<InvokeFunctionResponse> {\n return this.controller.execute(normalizeCalls(calls));\n }\n}\n","import { addAddressPadding, Call, CallData } from \"starknet\";\n\nexport function normalizeCalls(calls: Call | Call[]) {\n return (Array.isArray(calls) ? calls : [calls]).map((call) => {\n return {\n entrypoint: call.entrypoint,\n contractAddress: addAddressPadding(call.contractAddress),\n calldata: CallData.toHex(call.calldata),\n };\n });\n}\n","export class NotReadyToConnect extends Error {\n constructor() {\n super(\"Not ready to connect\");\n\n Object.setPrototypeOf(this, NotReadyToConnect.prototype);\n }\n}\n","import {\n constants,\n BigNumberish,\n Call,\n Abi,\n InvocationsDetails,\n} from \"starknet\";\nimport {\n AddInvokeTransactionResult,\n Signature,\n TypedData,\n} from \"@starknet-io/types-js\";\nimport { KeychainIFrame, ProfileIFrame } from \"./iframe\";\nimport wasm from \"@cartridge/account-wasm/controller\";\n\nexport type Session = {\n chainId: constants.StarknetChainId;\n policies: Policy[];\n maxFee: BigNumberish;\n expiresAt: bigint;\n credentials: {\n authorization: string[];\n privateKey: string;\n };\n};\n\nexport type Policy = wasm.Policy & {\n description?: string;\n};\n\nexport enum ResponseCodes {\n SUCCESS = \"SUCCESS\",\n NOT_CONNECTED = \"NOT_CONNECTED\",\n ERROR = \"ERROR\",\n CANCELED = \"CANCELED\",\n USER_INTERACTION_REQUIRED = \"USER_INTERACTION_REQUIRED\",\n}\n\nexport type ConnectError = {\n code: ResponseCodes;\n message: string;\n error?: ControllerError;\n};\n\nexport type ControllerError = {\n code: Number;\n message: string;\n data?: any;\n};\n\nexport type ConnectReply = {\n code: ResponseCodes.SUCCESS;\n address: string;\n policies: Policy[];\n};\n\nexport type ExecuteReply =\n | (AddInvokeTransactionResult & {\n code: ResponseCodes.SUCCESS;\n })\n | {\n code: ResponseCodes.USER_INTERACTION_REQUIRED;\n };\n\nexport type ProbeReply = {\n code: ResponseCodes.SUCCESS;\n address: string;\n};\n\nexport type DeployReply = {\n code: ResponseCodes.SUCCESS;\n transaction_hash: string;\n};\n\nexport type IFrames = {\n keychain: KeychainIFrame;\n profile?: ProfileIFrame;\n};\n\ntype ContractAddress = string;\ntype CartridgeID = string;\nexport type ControllerAccounts = Record<ContractAddress, CartridgeID>;\n\nexport interface Keychain {\n probe(rpcUrl: string): Promise<ProbeReply | ConnectError>;\n connect(\n policies: Policy[],\n rpcUrl: string,\n ): Promise<ConnectReply | ConnectError>;\n disconnect(): void;\n\n reset(): void;\n revoke(origin: string): void;\n\n deploy(): Promise<DeployReply | ConnectError>;\n execute(\n calls: Call | Call[],\n abis?: Abi[],\n transactionsDetail?: InvocationsDetails,\n sync?: boolean,\n paymaster?: any,\n error?: ControllerError,\n ): Promise<ExecuteReply | ConnectError>;\n signMessage(\n typedData: TypedData,\n account: string,\n ): Promise<Signature | ConnectError>;\n logout(): Promise<void>;\n openSettings(): Promise<void | ConnectError>;\n session(): Promise<Session>;\n sessions(): Promise<{\n [key: string]: Session;\n }>;\n delegateAccount(): string;\n username(): string;\n fetchControllers(contractAddresses: string[]): Promise<ControllerAccounts>;\n openPurchaseCredits(): void;\n}\nexport interface Profile {\n navigate(path: string): void;\n}\n\nexport interface Modal {\n open: () => void;\n close: () => void;\n}\n\n/**\n * Options for configuring the controller\n */\nexport type ControllerOptions = ProviderOptions &\n KeychainOptions &\n ProfileOptions;\n\nexport type IFrameOptions = {\n /** The ID of the starter pack to use */\n starterPackId?: string;\n /** The theme to use */\n theme?: string;\n /** The color mode to use */\n colorMode?: ColorMode;\n /** Additional configuration options */\n config?: {\n /** Preset themes for the controller */\n presets?: ControllerThemePresets;\n };\n};\n\nexport type ProviderOptions = {\n /** The URL of the RPC */\n rpc: string;\n};\n\nexport type KeychainOptions = IFrameOptions & {\n policies?: Policy[];\n /** The URL of keychain */\n url?: string;\n /** The origin of keychain */\n origin?: string;\n /** Propagate transaction errors back to caller instead of showing modal */\n propagateSessionErrors?: boolean;\n};\n\nexport type ProfileOptions = IFrameOptions & {\n /** The URL of profile. Mainly for internal development purpose */\n profileUrl?: string;\n /** The project name of Slot instance. */\n slot?: string;\n /** The namespace to use to fetch trophies data from indexer. Will be mandatory once profile page is in production */\n namespace?: string;\n /** The tokens to be listed on Inventory modal */\n tokens?: Tokens;\n};\n\nexport type ProfileContextTypeVariant = \"inventory\" | \"trophies\";\n\nexport type ColorMode = \"light\" | \"dark\";\n\nexport type ControllerTheme = {\n id: string;\n name: string;\n icon: string;\n cover: ThemeValue<string>;\n colorMode: ColorMode;\n};\n\nexport type ControllerThemePresets = Record<string, ControllerThemePreset>;\n\nexport type ControllerThemePreset = Omit<ControllerTheme, \"colorMode\"> & {\n colors?: ControllerColors;\n};\n\nexport type ControllerColors = {\n primary?: ControllerColor;\n primaryForeground?: ControllerColor;\n};\n\nexport type ControllerColor = ThemeValue<string>;\n\nexport type ThemeValue<T> = T | { dark: T; light: T };\n\nexport type Prefund = { address: string; min: string };\n\nexport type Tokens = {\n erc20?: string[];\n};\n","import { ControllerThemePresets } from \"./types\";\n\nexport const defaultPresets: ControllerThemePresets = {\n cartridge: {\n id: \"cartridge\",\n name: \"Cartridge\",\n icon: \"/whitelabel/cartridge/icon.svg\",\n cover: {\n light: \"/whitelabel/cartridge/cover-light.png\",\n dark: \"/whitelabel/cartridge/cover-dark.png\",\n },\n },\n \"force-prime\": {\n id: \"force-prime\",\n name: \"Force Prime\",\n icon: \"/whitelabel/force-prime/icon.png\",\n cover: \"/whitelabel/force-prime/cover.png\",\n colors: {\n primary: \"#E1CC89\",\n },\n },\n paved: {\n id: \"paved\",\n name: \"Paved\",\n icon: \"/whitelabel/paved/icon.svg\",\n cover: \"/whitelabel/paved/cover.png\",\n colors: {\n primary: \"#B0CAF8\",\n },\n },\n eternum: {\n id: \"eternum\",\n name: \"Eternum\",\n icon: \"/whitelabel/eternum/icon.gif\",\n cover: \"/whitelabel/eternum/cover.png\",\n colors: {\n primary: \"#CE9822\",\n },\n },\n pistols: {\n id: \"pistols\",\n name: \"Pistols at Ten Blocks\",\n icon: \"/whitelabel/pistols/icon.png\",\n cover: \"/whitelabel/pistols/cover.png\",\n colors: {\n primary: \"#EF9758\",\n },\n },\n pixelaw: {\n id: \"pixelaw\",\n name: \"Pixelaw\",\n icon: \"/whitelabel/pixelaw/icon.svg\",\n cover: \"/whitelabel/pixelaw/cover.png\",\n colors: {\n primary: \"#7C00B1\",\n primaryForeground: \"white\",\n },\n },\n \"dope-wars\": {\n id: \"dope-wars\",\n name: \"Dope Wars\",\n icon: \"/whitelabel/dope-wars/icon.png\",\n cover: \"/whitelabel/dope-wars/cover.png\",\n colors: {\n primary: \"#11ED83\",\n },\n },\n zkastle: {\n id: \"zkastle\",\n name: \"zKastle\",\n icon: \"/whitelabel/zkastle/icon.svg\",\n cover: \"/whitelabel/zkastle/cover.png\",\n colors: {\n primary: \"#E50D2C\",\n },\n },\n \"loot-survivor\": {\n id: \"loot-survivor\",\n name: \"Loot Survivor\",\n icon: \"/whitelabel/loot-survivor/icon.png\",\n cover: \"/whitelabel/loot-survivor/cover.png\",\n colors: {\n primary: \"#33FF33\",\n },\n },\n \"tale-weaver\": {\n id: \"tale-weaver\",\n name: \"Tale Weaver\",\n icon: \"/whitelabel/tale-weaver/icon.png\",\n cover: \"/whitelabel/tale-weaver/cover.png\",\n colors: {\n primary: \"#fce377\",\n },\n },\n \"realm-of-ra\": {\n id: \"realm-of-ra\",\n name: \"Realm of Ra\",\n icon: \"/whitelabel/realm-of-ra/icon.png\",\n cover: \"/whitelabel/realm-of-ra/cover.png\",\n colors: {\n primary: \"#de9534\",\n },\n },\n \"jokers-of-neon\": {\n id: \"jokers-of-neon\",\n name: \"Jokers of Neon\",\n icon: \"/whitelabel/jokers-of-neon/icon.png\",\n cover: \"/whitelabel/jokers-of-neon/cover.png\",\n colors: {\n primary: \"#A144B2\",\n },\n },\n flippyflop: {\n id: \"flippyflop\",\n name: \"FlippyFlop\",\n icon: \"/whitelabel/flippyflop/icon.png\",\n cover: \"/whitelabel/flippyflop/cover.png\",\n colors: {\n primary: \"#F38332\",\n },\n },\n \"savage-summit\": {\n id: \"savage-summit\",\n name: \"Savage Summit\",\n icon: \"/whitelabel/savage-summit/icon.png\",\n cover: \"/whitelabel/savage-summit/cover.png\",\n colors: {\n primary: \"#fbf7da\",\n },\n },\n \"dark-shuffle\": {\n id: \"dark-shuffle\",\n name: \"Dark Shuffle\",\n icon: \"/whitelabel/dark-shuffle/icon.svg\",\n cover: \"/whitelabel/dark-shuffle/cover.png\",\n colors: {\n primary: \"#F59100\",\n },\n },\n \"blob-arena\": {\n id: \"blob-arena\",\n name: \"Blob Arena\",\n icon: \"/whitelabel/blob-arena/icon.png\",\n cover: \"/whitelabel/blob-arena/cover.png\",\n colors: {\n primary: \"#980f06\",\n },\n },\n zkube: {\n id: \"zkube\",\n name: \"zKube\",\n icon: \"/whitelabel/zkube/icon.png\",\n cover: \"/whitelabel/zkube/cover.png\",\n colors: {\n primary: \"#5bc3e6\",\n },\n },\n};\n"],"mappings":";AACA,SAAS,+BAA+B;AACxC,SAAuC,qBAAqB;;;ACF5D,SAAS,mBAAyB,gBAAgB;AAE3C,SAAS,eAAe,OAAsB;AACnD,UAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS;AAC5D,WAAO;AAAA,MACL,YAAY,KAAK;AAAA,MACjB,iBAAiB,kBAAkB,KAAK,eAAe;AAAA,MACvD,UAAU,SAAS,MAAM,KAAK,QAAQ;AAAA,IACxC;AAAA,EACF,CAAC;AACH;;;ACVO,IAAM,oBAAN,MAAM,2BAA0B,MAAM;AAAA,EAC3C,cAAc;AACZ,UAAM,sB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Z,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AACF;;;AJlJA,IAAqB,iBAArB,cAA4C,cAAc;AAAA,EAGxD,YACE,UACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GASA;AACA,UAAM,EAAE,SAAS,OAAO,GAAG,QAAQ;AAEnC,SAAK,aAAa,wBAAwB;AAAA,MACxC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,QAAQ,OAAuD;AACnE,WAAO,KAAK,WAAW,QAAQ,eAAe,KAAK,CAAC;AAAA,EACtD;AACF;","names":["ResponseCodes"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Represents a unified backend for storage operations and link handling.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
interface UnifiedBackend {
|
|
5
5
|
/**
|
|
6
6
|
* Retrieves the value associated with the specified key.
|
|
7
7
|
* @param key - The key to look up in the storage.
|
|
@@ -30,7 +30,7 @@ export interface UnifiedBackend {
|
|
|
30
30
|
/**
|
|
31
31
|
* Implements a local storage backend that conforms to the UnifiedBackend interface.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
declare class LocalStorageBackend {
|
|
34
34
|
/**
|
|
35
35
|
* Retrieves the value associated with the specified key from local storage.
|
|
36
36
|
* @param key - The key to look up in local storage.
|
|
@@ -56,3 +56,5 @@ export declare class LocalStorageBackend {
|
|
|
56
56
|
*/
|
|
57
57
|
openLink(url: string): void;
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
export { LocalStorageBackend, type UnifiedBackend };
|
package/dist/session/backend.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
// src/session/backend.ts
|
|
2
|
+
var LocalStorageBackend = class {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the value associated with the specified key from local storage.
|
|
5
|
+
* @param key - The key to look up in local storage.
|
|
6
|
+
* @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.
|
|
7
|
+
*/
|
|
8
|
+
async get(key) {
|
|
9
|
+
return localStorage.getItem(key);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Stores a key-value pair in local 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
|
+
async set(key, value) {
|
|
18
|
+
localStorage.setItem(key, value);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Removes the key-value pair associated with the specified key from local storage.
|
|
22
|
+
* @param key - The key of the item to be removed.
|
|
23
|
+
* @returns A promise that resolves when the item has been successfully removed.
|
|
24
|
+
*/
|
|
25
|
+
async delete(key) {
|
|
26
|
+
localStorage.removeItem(key);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Opens the specified URL in a new tab or window.
|
|
30
|
+
* @param url - The URL to open.
|
|
31
|
+
*/
|
|
32
|
+
openLink(url) {
|
|
33
|
+
window.open(url, "_blank");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
LocalStorageBackend
|
|
38
|
+
};
|
|
38
39
|
//# sourceMappingURL=backend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/session/backend.ts"],"sourcesContent":["/**\n * Represents a unified backend for storage operations and link handling.\n */\nexport interface UnifiedBackend {\n /**\n * Retrieves the value associated with the specified key.\n * @param key - The key to look up in the storage.\n * @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.\n */\n get: (key: string) => Promise<string | null>;\n\n /**\n * Stores a key-value pair in the storage.\n * @param key - The key under which to store the value.\n * @param value - The value to be stored.\n * @returns A promise that resolves when the value has been successfully stored.\n */\n set: (key: string, value: string) => Promise<void>;\n\n /**\n * Removes the key-value pair associated with the specified key from the storage.\n * @param key - The key of the item to be removed.\n * @returns A promise that resolves when the item has been successfully removed.\n */\n delete: (key: string) => Promise<void>;\n\n /**\n * Opens the specified URL.\n * @param url - The URL to open.\n */\n openLink: (url: string) => void;\n}\n\n/**\n * Implements a local storage backend that conforms to the UnifiedBackend interface.\n */\nexport class LocalStorageBackend {\n /**\n * Retrieves the value associated with the specified key from local storage.\n * @param key - The key to look up in local storage.\n * @returns A promise that resolves to the stored value as a string, or null if the key doesn't exist.\n */\n async get(key: string): Promise<string | null> {\n return localStorage.getItem(key);\n }\n\n /**\n * Stores a key-value pair in local storage.\n * @param key - The key under which to store the value.\n * @param value - The value to be stored.\n * @returns A promise that resolves when the value has been successfully stored.\n */\n async set(key: string, value: string): Promise<void> {\n localStorage.setItem(key, value);\n }\n\n /**\n * Removes the key-value pair associated with the specified key from local storage.\n * @param key - The key of the item to be removed.\n * @returns A promise that resolves when the item has been successfully removed.\n */\n async delete(key: string): Promise<void> {\n localStorage.removeItem(key);\n }\n\n /**\n * Opens the specified URL in a new tab or window.\n * @param url - The URL to open.\n */\n openLink(url: string): void {\n window.open(url, \"_blank\");\n }\n}\n"],"mappings":";AAoCO,IAAM,sBAAN,MAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,MAAM,IAAI,KAAqC;AAC7C,WAAO,aAAa,QAAQ,GAAG;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,KAAa,OAA8B;AACnD,iBAAa,QAAQ,KAAK,KAAK;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,OAAO,KAA4B;AACvC,iBAAa,WAAW,GAAG;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAS,KAAmB;AAC1B,WAAO,KAAK,KAAK,QAAQ;AAAA,EAC3B;AACF;","names":[]}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
1
|
+
export { SessionOptions, default } from './provider.js';
|
|
2
|
+
export { NotReadyToConnect } from '../errors.js';
|
|
3
|
+
export { l as ColorMode, C as ConnectError, b as ConnectReply, d as ControllerAccounts, q as ControllerColor, p as ControllerColors, a as ControllerError, f as ControllerOptions, m as ControllerTheme, o as ControllerThemePreset, n as ControllerThemePresets, D as DeployReply, E as ExecuteReply, g as IFrameOptions, I as IFrames, K as Keychain, i as KeychainOptions, M as Modal, P as Policy, r as Prefund, c as ProbeReply, e as Profile, k as ProfileContextTypeVariant, j as ProfileOptions, h as ProviderOptions, R as ResponseCodes, S as Session, T as ThemeValue, s as Tokens } from '../types-DIeWpu0p.js';
|
|
4
|
+
export { defaultPresets } from '../presets.js';
|
|
5
|
+
import 'starknet';
|
|
6
|
+
import '../provider.js';
|
|
7
|
+
import '@starknet-io/types-js';
|
|
8
|
+
import '@cartridge/penpal';
|
|
9
|
+
import '@cartridge/account-wasm/controller';
|