@cartridge/controller 0.3.16 → 0.3.18

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.
@@ -1,16 +0,0 @@
1
- import { Request, Response } from "./types";
2
- export declare type Message<T = Request | Response> = {
3
- id?: string;
4
- type: "request" | "response";
5
- target: string;
6
- payload: T;
7
- };
8
- export declare class Messenger {
9
- private target;
10
- private origin;
11
- private pending;
12
- private defaultHandler;
13
- constructor(target: Window | null, origin?: string);
14
- onRequest(cb: (request: Request, reply: (response: Response) => void) => void): void;
15
- send<T = Response>(request: Request): Promise<T>;
16
- }
@@ -1,87 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import cuid from "cuid";
13
- var Messenger = /** @class */ (function () {
14
- function Messenger(target, origin) {
15
- if (origin === void 0) { origin = "https://cartridge.gg"; }
16
- var _this = this;
17
- this.pending = [];
18
- this.defaultHandler = function (e) {
19
- if (e.data.target === "cartridge" &&
20
- e.data.type === "request") {
21
- _this.pending.push(e);
22
- }
23
- };
24
- this.target = target;
25
- this.origin = origin;
26
- if (typeof document !== "undefined" &&
27
- document.body.getAttribute("cartridge") !== "true") {
28
- document.body.setAttribute("cartridge", "true");
29
- }
30
- window.addEventListener("message", this.defaultHandler);
31
- }
32
- Messenger.prototype.onRequest = function (cb) {
33
- window.removeEventListener("message", this.defaultHandler);
34
- var onResponse = function (_a) {
35
- var origin = _a.origin, source = _a.source, id = _a.data.id;
36
- return function (response) {
37
- if (!source) {
38
- return;
39
- }
40
- source.postMessage({
41
- id: id,
42
- target: "cartridge",
43
- type: "response",
44
- payload: __assign({ origin: window.origin }, response),
45
- }, { targetOrigin: origin });
46
- };
47
- };
48
- for (var i = 0; i < this.pending.length; i++) {
49
- var payload = this.pending[i].data.payload;
50
- cb(payload, onResponse(this.pending[i]));
51
- }
52
- window.addEventListener("message", function (e) {
53
- var _a = e.data, type = _a.type, target = _a.target, payload = _a.payload;
54
- if (target === "cartridge" &&
55
- type === "request") {
56
- cb(payload, onResponse(e));
57
- }
58
- });
59
- };
60
- Messenger.prototype.send = function (request) {
61
- var id = cuid();
62
- if (!this.target) {
63
- throw new Error("read only");
64
- }
65
- this.target.postMessage({
66
- id: id,
67
- target: "cartridge",
68
- type: "request",
69
- payload: __assign({ origin: window.origin }, request),
70
- }, this.origin);
71
- return new Promise(function (resolve, reject) {
72
- var handler = function (_a) {
73
- var data = _a.data;
74
- if (data.target === "cartridge" &&
75
- data.type === "response" &&
76
- id === data.id) {
77
- resolve(data.payload);
78
- window.removeEventListener("message", handler);
79
- }
80
- };
81
- window.addEventListener("message", handler);
82
- });
83
- };
84
- return Messenger;
85
- }());
86
- export { Messenger };
87
- //# sourceMappingURL=messenger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messenger.js","sourceRoot":"","sources":["../../src/messenger.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB;IAcE,mBAAY,MAAqB,EAAE,MAAuC;QAAvC,uBAAA,EAAA,+BAAuC;QAA1E,iBAYC;QAvBO,YAAO,GAAqC,EAAE,CAAA;QAE9C,mBAAc,GAAG,UAAC,CAAiC;YACzD,IACE,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW;gBAC7B,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EACzB;gBACA,KAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;aACrB;QACH,CAAC,CAAA;QAGC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IACE,OAAO,QAAQ,KAAK,WAAW;YAC/B,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SAAS,EAClB;gBACA,EAAE,CAAC,OAAkB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;aACvC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;IAED,wBAAI,GAAJ,UAAmB,OAAgB;QACjC,IAAM,EAAE,GAAG,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;SAC9B;QAED,IAAI,CAAC,MAAM,CAAC,WAAW,CACrB;YACE,EAAE,IAAA;YACF,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE,SAAS;YACf,OAAO,aACL,MAAM,EAAE,MAAM,CAAC,MAAM,IAClB,OAAO,CACX;SACF,EACD,IAAI,CAAC,MAAM,CACZ,CAAC;QAEF,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,IAAM,OAAO,GAAG,UAAC,EAAkC;oBAAhC,IAAI,UAAA;gBACrB,IACE,IAAI,CAAC,MAAM,KAAK,WAAW;oBAC3B,IAAI,CAAC,IAAI,KAAK,UAAU;oBACxB,EAAE,KAAK,IAAI,CAAC,EAAE,EACd;oBACA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACtB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;iBAChD;YACH,CAAC,CAAC;YACF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;IACH,gBAAC;AAAD,CAAC,AAhHD,IAgHC"}
@@ -1,38 +0,0 @@
1
- import { Abi, Invocation, InvocationsSignerDetails, SignerInterface, Signature, typedData } from "starknet";
2
- import { Messenger } from "./messenger";
3
- export declare class Signer implements SignerInterface {
4
- private messenger;
5
- private url;
6
- constructor(messenger: Messenger, options?: {
7
- url?: string;
8
- });
9
- /**
10
- * Method to get the public key of the signer
11
- *
12
- * @returns public key of signer as hex string with 0x prefix
13
- */
14
- getPubKey(): Promise<string>;
15
- /**
16
- * Sign an JSON object for off-chain usage with the starknet private key and return the signature
17
- * This adds a message prefix so it cant be interchanged with transactions
18
- *
19
- * @param typedData - JSON object to be signed
20
- * @param accountAddress - account
21
- * @returns the signature of the JSON object
22
- * @throws {Error} if the JSON object is not a valid JSON
23
- */
24
- signMessage(typedData: typedData.TypedData, account: string): Promise<Signature>;
25
- /**
26
- * Signs a transaction with the starknet private key and returns the signature
27
- *
28
- * @param invocation the invocation object containing:
29
- * - contractAddress - the address of the contract
30
- * - entrypoint - the entrypoint of the contract
31
- * - calldata - (defaults to []) the calldata
32
- * - signature - (defaults to []) the signature
33
- * @param abi (optional) the abi of the contract for better displaying
34
- *
35
- * @returns signature
36
- */
37
- signTransaction(transactions: Invocation[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
38
- }
package/lib/src/signer.js DELETED
@@ -1,141 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import qs from 'query-string';
38
- import cuid from "cuid";
39
- var Signer = /** @class */ (function () {
40
- function Signer(messenger, options) {
41
- this.url = "https://cartridge.gg";
42
- this.messenger = messenger;
43
- if (options === null || options === void 0 ? void 0 : options.url) {
44
- this.url = options.url;
45
- }
46
- }
47
- /**
48
- * Method to get the public key of the signer
49
- *
50
- * @returns public key of signer as hex string with 0x prefix
51
- */
52
- Signer.prototype.getPubKey = function () {
53
- return Promise.resolve("");
54
- };
55
- /**
56
- * Sign an JSON object for off-chain usage with the starknet private key and return the signature
57
- * This adds a message prefix so it cant be interchanged with transactions
58
- *
59
- * @param typedData - JSON object to be signed
60
- * @param accountAddress - account
61
- * @returns the signature of the JSON object
62
- * @throws {Error} if the JSON object is not a valid JSON
63
- */
64
- Signer.prototype.signMessage = function (typedData, account) {
65
- return __awaiter(this, void 0, void 0, function () {
66
- var id, response;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0:
70
- id = cuid();
71
- window.open("".concat(this.url, "/sign?").concat(qs.stringify({
72
- id: id,
73
- origin: window.origin,
74
- message: JSON.stringify(typedData.message),
75
- })), "_blank", "height=650,width=400");
76
- return [4 /*yield*/, this.messenger.send({
77
- method: "sign-message",
78
- params: {
79
- id: id,
80
- account: account,
81
- typedData: typedData,
82
- },
83
- })];
84
- case 1:
85
- response = _a.sent();
86
- if (response.error) {
87
- throw new Error(response.error);
88
- }
89
- return [2 /*return*/, response.result];
90
- }
91
- });
92
- });
93
- };
94
- /**
95
- * Signs a transaction with the starknet private key and returns the signature
96
- *
97
- * @param invocation the invocation object containing:
98
- * - contractAddress - the address of the contract
99
- * - entrypoint - the entrypoint of the contract
100
- * - calldata - (defaults to []) the calldata
101
- * - signature - (defaults to []) the signature
102
- * @param abi (optional) the abi of the contract for better displaying
103
- *
104
- * @returns signature
105
- */
106
- Signer.prototype.signTransaction = function (transactions, transactionsDetail, abis) {
107
- return __awaiter(this, void 0, void 0, function () {
108
- var id, calls, response;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- id = cuid();
113
- calls = Array.isArray(transactions) ? transactions : [transactions];
114
- window.open("".concat(this.url, "/sign?").concat(qs.stringify({
115
- id: id,
116
- origin: window.origin,
117
- calls: JSON.stringify(calls),
118
- })), "_blank", "height=650,width=400");
119
- return [4 /*yield*/, this.messenger.send({
120
- method: "sign-transaction",
121
- params: {
122
- id: id,
123
- transactions: transactions,
124
- abis: abis,
125
- transactionsDetail: transactionsDetail,
126
- },
127
- })];
128
- case 1:
129
- response = _a.sent();
130
- if (response.error) {
131
- throw new Error(response.error);
132
- }
133
- return [2 /*return*/, response.result];
134
- }
135
- });
136
- });
137
- };
138
- return Signer;
139
- }());
140
- export { Signer };
141
- //# sourceMappingURL=signer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer.ts"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;;;;;;;OAWG;IACU,gCAAe,GAA5B,UACI,YAA0B,EAC1B,kBAA4C,EAC5C,IAAY;;;;;;wBAEN,EAAE,GAAG,IAAI,EAAE,CAAA;wBACX,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;wBAE1E,MAAM,CAAC,IAAI,CACP,UAAG,IAAI,CAAC,GAAG,mBAAS,EAAE,CAAC,SAAS,CAAC;4BAC7B,EAAE,IAAA;4BACF,MAAM,EAAE,MAAM,CAAC,MAAM;4BACrB,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;yBAC/B,CAAC,CAAE,EACJ,QAAQ,EACR,sBAAsB,CACzB,CAAC;wBAEe,qBAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAA0B;gCAChE,MAAM,EAAE,kBAAkB;gCAC1B,MAAM,EAAE;oCACJ,EAAE,IAAA;oCACF,YAAY,cAAA;oCACZ,IAAI,MAAA;oCACJ,kBAAkB,oBAAA;iCACrB;6BACJ,CAAC,EAAA;;wBARI,QAAQ,GAAG,SAQf;wBAEF,IAAI,QAAQ,CAAC,KAAK,EAAE;4BAChB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAe,CAAC,CAAC;yBAC7C;wBAED,sBAAO,QAAQ,CAAC,MAAO,EAAC;;;;KAC3B;IACL,aAAC;AAAD,CAAC,AA3GD,IA2GC"}
@@ -1,162 +0,0 @@
1
- import { DeployContractPayload, DeployContractResponse as StarknetDeployContractResponse, Abi, Call, InvocationsDetails, typedData, InvokeFunctionResponse, Signature, Invocation } from "starknet";
2
- import { BigNumberish } from "starknet/dist/utils/number";
3
- import { EstimateFee } from "starknet/types/account";
4
- export declare type Approvals = {
5
- [origin: string]: {
6
- scopes: Scope[];
7
- maxFee: BigNumberish;
8
- };
9
- };
10
- export declare type Scope = {
11
- target: string;
12
- method?: string;
13
- };
14
- export interface ProbeRequest extends RawRequest {
15
- method: "probe";
16
- }
17
- export interface ProbeResponse extends RawResponse {
18
- method: "probe";
19
- result?: {
20
- address?: string;
21
- scopes?: Scope[];
22
- };
23
- }
24
- export interface ConnectRequest extends RawRequest {
25
- method: "connect";
26
- params: {
27
- id: string;
28
- scopes: Scope[];
29
- };
30
- }
31
- export interface ConnectResponse extends RawResponse {
32
- method: "connect";
33
- result?: {
34
- success: boolean;
35
- address?: string;
36
- scopes: Scope[];
37
- };
38
- }
39
- export interface DeployContractRequest extends RawRequest {
40
- method: "deploy-contract";
41
- params: {
42
- id: string;
43
- payload: DeployContractPayload;
44
- abi?: Abi;
45
- };
46
- }
47
- export interface DeployContractResponse extends RawResponse {
48
- method: "deploy-contract";
49
- result?: StarknetDeployContractResponse;
50
- }
51
- export interface EstimateFeeRequest extends RawRequest {
52
- method: "estimate-fee";
53
- params: {
54
- invocation: Invocation;
55
- };
56
- }
57
- export interface EstimateFeeResponse extends RawResponse {
58
- method: "estimate-fee";
59
- result?: EstimateFee;
60
- }
61
- export interface ExecuteRequest extends RawRequest {
62
- method: "execute";
63
- params: {
64
- id?: string;
65
- transactions: Call | Call[];
66
- abis?: Abi[];
67
- transactionsDetail?: InvocationsDetails;
68
- };
69
- }
70
- export interface ExecuteResponse extends RawResponse {
71
- method: "execute";
72
- result?: InvokeFunctionResponse;
73
- scopes?: Scope[];
74
- }
75
- export interface SignTransactionRequest extends RawRequest {
76
- method: "sign-transaction";
77
- params: {
78
- id: string;
79
- transactions: Call | Call[];
80
- abis?: Abi[];
81
- transactionsDetail?: InvocationsDetails;
82
- };
83
- }
84
- export interface SignTransactionResponse extends RawResponse {
85
- method: "sign-transaction";
86
- result?: Signature;
87
- }
88
- export interface SignMessageRequest extends RawRequest {
89
- method: "sign-message";
90
- params: {
91
- id: string;
92
- account?: string;
93
- typedData: typedData.TypedData;
94
- };
95
- }
96
- export interface SignMessageResponse extends RawResponse {
97
- method: "sign-message";
98
- result?: Signature;
99
- }
100
- export interface HashMessageRequest extends RawRequest {
101
- method: "hash-message";
102
- params: {
103
- typedData: typedData.TypedData;
104
- };
105
- }
106
- export interface HashMessageResponse extends RawResponse {
107
- method: "hash-message";
108
- result?: string;
109
- }
110
- export interface VerifyMessageRequest extends RawRequest {
111
- method: "verify-message";
112
- params: {
113
- typedData: typedData.TypedData;
114
- signature: Signature;
115
- };
116
- }
117
- export interface VerifyMessageResponse extends RawResponse {
118
- method: "verify-message";
119
- result?: boolean;
120
- }
121
- export interface VerifyMessageHashRequest extends RawRequest {
122
- method: "verify-message-hash";
123
- params: {
124
- hash: BigNumberish;
125
- signature: Signature;
126
- };
127
- }
128
- export interface VerifyMessageHashResponse extends RawResponse {
129
- method: "verify-message-hash";
130
- result?: boolean;
131
- }
132
- export interface GetNonceRequest extends RawRequest {
133
- method: "get-nonce";
134
- }
135
- export interface GetNonceResponse extends RawResponse {
136
- method: "get-nonce";
137
- result?: string;
138
- }
139
- export interface RegisterRequest extends RawRequest {
140
- method: "register";
141
- params: {
142
- username: string;
143
- address: string;
144
- };
145
- }
146
- export interface RegisterResponse extends RawResponse {
147
- method: "register";
148
- result: {
149
- publicKey: string;
150
- };
151
- }
152
- export declare type RawRequest = {
153
- origin?: string;
154
- method: string;
155
- params?: object | any[];
156
- };
157
- export declare type Request = RawRequest | ProbeRequest | ConnectRequest | DeployContractRequest | EstimateFeeRequest | ExecuteRequest | SignMessageRequest | HashMessageRequest | VerifyMessageHashRequest | VerifyMessageRequest | GetNonceRequest | RegisterRequest;
158
- export declare type RawResponse = {
159
- result?: any;
160
- error?: unknown;
161
- };
162
- export declare type Response = RawResponse | ProbeResponse | DeployContractResponse | EstimateFeeResponse | ConnectResponse | SignMessageResponse | HashMessageResponse | VerifyMessageHashResponse | VerifyMessageResponse | GetNonceResponse | RegisterResponse;
package/lib/src/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { Scope } from "./types";
2
- export declare function diff(a: Scope[], b: Scope[]): Scope[];
package/lib/src/utils.js DELETED
@@ -1,16 +0,0 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
- import equal from "fast-deep-equal";
11
- export function diff(a, b) {
12
- return a.reduce(function (prev, scope) {
13
- return b.some(function (approval) { return equal(approval, scope); }) ? prev : __spreadArray(__spreadArray([], prev, true), [scope], false);
14
- }, []);
15
- }
16
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAIpC,MAAM,UAAU,IAAI,CAAC,CAAU,EAAE,CAAU;IACvC,OAAO,CAAC,CAAC,MAAM,CACX,UAAC,IAAI,EAAE,KAAK;QACR,OAAA,CAAC,CAAC,IAAI,CAAC,UAAC,QAAQ,IAAK,OAAA,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAtB,CAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,iCAAK,IAAI,UAAE,KAAK,SAAC;IAAtE,CAAsE,EAC1E,EAAa,CAChB,CAAC;AACN,CAAC"}
@@ -1,16 +0,0 @@
1
- import { Abi, Invocation, InvocationsSignerDetails, Signature, SignerInterface, typedData } from "starknet";
2
- declare type Assertion = PublicKeyCredential & {
3
- response: AuthenticatorAssertionResponse;
4
- };
5
- export declare class WebauthnSigner implements SignerInterface {
6
- private credentialId;
7
- private publicKey;
8
- constructor(credentialId: string, publicKey: string);
9
- getPubKey(): Promise<string>;
10
- sign(hash: string): Promise<Assertion>;
11
- formatAssertion(assertion: Assertion): Signature;
12
- hashTransaction(transactions: Invocation[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): string;
13
- signTransaction(transactions: Invocation[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
14
- signMessage(td: typedData.TypedData, accountAddress: string): Promise<Signature>;
15
- }
16
- export {};