@astrox/agent 0.0.24 → 0.0.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. package/lib/cjs/actor.d.ts +126 -0
  2. package/lib/cjs/actor.js +207 -0
  3. package/lib/cjs/actor.js.map +1 -0
  4. package/lib/cjs/agent/api.d.ts +140 -0
  5. package/lib/cjs/agent/api.js +16 -0
  6. package/lib/cjs/agent/api.js.map +1 -0
  7. package/lib/cjs/agent/http/index.d.ts +49 -0
  8. package/lib/cjs/agent/http/index.js +355 -0
  9. package/lib/cjs/agent/http/index.js.map +1 -0
  10. package/lib/cjs/agent/http/transforms.d.ts +20 -0
  11. package/lib/cjs/agent/http/transforms.js +70 -0
  12. package/lib/cjs/agent/http/transforms.js.map +1 -0
  13. package/lib/cjs/agent/http/types.d.ts +77 -0
  14. package/lib/cjs/agent/http/types.js +24 -0
  15. package/lib/cjs/agent/http/types.js.map +1 -0
  16. package/lib/cjs/agent/index.d.ts +7 -0
  17. package/lib/cjs/agent/index.js +42 -0
  18. package/lib/cjs/agent/index.js.map +1 -0
  19. package/lib/cjs/agent/proxy.d.ts +85 -0
  20. package/lib/cjs/agent/proxy.js +159 -0
  21. package/lib/cjs/agent/proxy.js.map +1 -0
  22. package/lib/cjs/auth.d.ts +87 -0
  23. package/lib/cjs/auth.js +70 -0
  24. package/lib/cjs/auth.js.map +1 -0
  25. package/lib/cjs/canisters/asset.d.ts +10 -0
  26. package/lib/cjs/canisters/asset.js +18 -0
  27. package/lib/cjs/canisters/asset.js.map +1 -0
  28. package/lib/cjs/canisters/asset_idl.d.ts +7 -0
  29. package/lib/cjs/canisters/asset_idl.js +14 -0
  30. package/lib/cjs/canisters/asset_idl.js.map +1 -0
  31. package/lib/cjs/canisters/management.d.ts +33 -0
  32. package/lib/cjs/canisters/management.js +30 -0
  33. package/lib/cjs/canisters/management.js.map +1 -0
  34. package/lib/cjs/canisters/management_idl.d.ts +7 -0
  35. package/lib/cjs/canisters/management_idl.js +29 -0
  36. package/lib/cjs/canisters/management_idl.js.map +1 -0
  37. package/lib/cjs/cbor.d.ts +9 -0
  38. package/lib/cjs/cbor.js +138 -0
  39. package/lib/cjs/cbor.js.map +1 -0
  40. package/lib/cjs/certificate.d.ts +43 -0
  41. package/lib/cjs/certificate.js +227 -0
  42. package/lib/cjs/certificate.js.map +1 -0
  43. package/lib/cjs/errors.d.ts +8 -0
  44. package/lib/cjs/errors.js +13 -0
  45. package/lib/cjs/errors.js.map +1 -0
  46. package/lib/cjs/index.d.ts +52 -0
  47. package/lib/cjs/index.js +38 -0
  48. package/lib/cjs/index.js.map +1 -0
  49. package/lib/cjs/polling/index.d.ts +16 -0
  50. package/lib/cjs/polling/index.js +81 -0
  51. package/lib/cjs/polling/index.js.map +1 -0
  52. package/lib/cjs/polling/strategy.d.ts +47 -0
  53. package/lib/cjs/polling/strategy.js +106 -0
  54. package/lib/cjs/polling/strategy.js.map +1 -0
  55. package/lib/cjs/request_id.d.ts +15 -0
  56. package/lib/cjs/request_id.js +89 -0
  57. package/lib/cjs/request_id.js.map +1 -0
  58. package/lib/cjs/utils/bls.d.ts +9 -0
  59. package/lib/cjs/utils/bls.js +65 -0
  60. package/lib/cjs/utils/bls.js.map +1 -0
  61. package/lib/cjs/utils/buffer.d.ts +16 -0
  62. package/lib/cjs/utils/buffer.js +59 -0
  63. package/lib/cjs/utils/buffer.js.map +1 -0
  64. package/lib/cjs/vendor/bls/bls.d.ts +28 -0
  65. package/lib/cjs/vendor/bls/bls.js +894 -0
  66. package/lib/cjs/vendor/bls/bls.js.map +1 -0
  67. package/lib/esm/actor.d.ts +126 -0
  68. package/lib/esm/actor.js +200 -0
  69. package/lib/esm/actor.js.map +1 -0
  70. package/lib/esm/agent/api.d.ts +140 -0
  71. package/lib/esm/agent/api.js +13 -0
  72. package/lib/esm/agent/api.js.map +1 -0
  73. package/lib/esm/agent/http/index.d.ts +49 -0
  74. package/lib/esm/agent/http/index.js +328 -0
  75. package/lib/esm/agent/http/index.js.map +1 -0
  76. package/lib/esm/agent/http/transforms.d.ts +20 -0
  77. package/lib/esm/agent/http/transforms.js +45 -0
  78. package/lib/esm/agent/http/transforms.js.map +1 -0
  79. package/lib/esm/agent/http/types.d.ts +77 -0
  80. package/lib/esm/agent/http/types.js +20 -0
  81. package/lib/esm/agent/http/types.js.map +1 -0
  82. package/lib/esm/agent/index.d.ts +7 -0
  83. package/lib/esm/agent/index.js +27 -0
  84. package/lib/esm/agent/index.js.map +1 -0
  85. package/lib/esm/agent/proxy.d.ts +85 -0
  86. package/lib/esm/agent/proxy.js +154 -0
  87. package/lib/esm/agent/proxy.js.map +1 -0
  88. package/lib/esm/auth.d.ts +87 -0
  89. package/lib/esm/auth.js +64 -0
  90. package/lib/esm/auth.js.map +1 -0
  91. package/lib/esm/canisters/asset.d.ts +10 -0
  92. package/lib/esm/canisters/asset.js +11 -0
  93. package/lib/esm/canisters/asset.js.map +1 -0
  94. package/lib/esm/canisters/asset_idl.d.ts +7 -0
  95. package/lib/esm/canisters/asset_idl.js +12 -0
  96. package/lib/esm/canisters/asset_idl.js.map +1 -0
  97. package/lib/esm/canisters/management.d.ts +37 -0
  98. package/lib/esm/canisters/management.js +23 -0
  99. package/lib/esm/canisters/management.js.map +1 -0
  100. package/lib/esm/canisters/management_idl.d.ts +7 -0
  101. package/lib/esm/canisters/management_idl.js +27 -0
  102. package/lib/esm/canisters/management_idl.js.map +1 -0
  103. package/lib/esm/cbor.d.ts +9 -0
  104. package/lib/esm/cbor.js +111 -0
  105. package/lib/esm/cbor.js.map +1 -0
  106. package/lib/esm/certificate.d.ts +43 -0
  107. package/lib/esm/certificate.js +200 -0
  108. package/lib/esm/certificate.js.map +1 -0
  109. package/lib/esm/errors.d.ts +8 -0
  110. package/lib/esm/errors.js +9 -0
  111. package/lib/esm/errors.js.map +1 -0
  112. package/lib/esm/index.d.ts +52 -0
  113. package/lib/esm/index.js +14 -0
  114. package/lib/esm/index.js.map +1 -0
  115. package/lib/esm/polling/index.d.ts +16 -0
  116. package/lib/esm/polling/index.js +57 -0
  117. package/lib/esm/polling/index.js.map +1 -0
  118. package/lib/esm/polling/strategy.d.ts +47 -0
  119. package/lib/esm/polling/strategy.js +95 -0
  120. package/lib/esm/polling/strategy.js.map +1 -0
  121. package/lib/esm/request_id.d.ts +15 -0
  122. package/lib/esm/request_id.js +81 -0
  123. package/lib/esm/request_id.js.map +1 -0
  124. package/lib/esm/utils/bls.d.ts +9 -0
  125. package/lib/esm/utils/bls.js +43 -0
  126. package/lib/esm/utils/bls.js.map +1 -0
  127. package/lib/esm/utils/buffer.d.ts +16 -0
  128. package/lib/esm/utils/buffer.js +52 -0
  129. package/lib/esm/utils/buffer.js.map +1 -0
  130. package/lib/esm/vendor/bls/bls.d.ts +28 -0
  131. package/lib/esm/vendor/bls/bls.js +870 -0
  132. package/lib/esm/vendor/bls/bls.js.map +1 -0
  133. package/package.json +4 -4
@@ -0,0 +1,126 @@
1
+ import { Agent, QueryResponseRejected, SubmitResponse } from './agent';
2
+ import { AgentError } from './errors';
3
+ import { IDL } from '@astrox/candid';
4
+ import { PollStrategyFactory } from './polling';
5
+ import { Principal } from '@astrox/principal';
6
+ import { RequestId } from './request_id';
7
+ export declare class ActorCallError extends AgentError {
8
+ readonly canisterId: Principal;
9
+ readonly methodName: string;
10
+ readonly type: 'query' | 'update';
11
+ readonly props: Record<string, string>;
12
+ constructor(canisterId: Principal, methodName: string, type: 'query' | 'update', props: Record<string, string>);
13
+ }
14
+ export declare class QueryCallRejectedError extends ActorCallError {
15
+ readonly result: QueryResponseRejected;
16
+ constructor(canisterId: Principal, methodName: string, result: QueryResponseRejected);
17
+ }
18
+ export declare class UpdateCallRejectedError extends ActorCallError {
19
+ readonly requestId: RequestId;
20
+ readonly response: SubmitResponse['response'];
21
+ constructor(canisterId: Principal, methodName: string, requestId: RequestId, response: SubmitResponse['response']);
22
+ }
23
+ /**
24
+ * Configuration to make calls to the Replica.
25
+ */
26
+ export interface CallConfig {
27
+ /**
28
+ * An agent to use in this call, otherwise the actor or call will try to discover the
29
+ * agent to use.
30
+ */
31
+ agent?: Agent;
32
+ /**
33
+ * A polling strategy factory that dictates how much and often we should poll the
34
+ * read_state endpoint to get the result of an update call.
35
+ */
36
+ pollingStrategyFactory?: PollStrategyFactory;
37
+ /**
38
+ * The canister ID of this Actor.
39
+ */
40
+ canisterId?: string | Principal;
41
+ /**
42
+ * The effective canister ID. This should almost always be ignored.
43
+ */
44
+ effectiveCanisterId?: Principal;
45
+ }
46
+ /**
47
+ * Configuration that can be passed to customize the Actor behaviour.
48
+ */
49
+ export interface ActorConfig extends CallConfig {
50
+ /**
51
+ * The Canister ID of this Actor. This is required for an Actor.
52
+ */
53
+ canisterId: string | Principal;
54
+ /**
55
+ * An override function for update calls' CallConfig. This will be called on every calls.
56
+ */
57
+ callTransform?(methodName: string, args: unknown[], callConfig: CallConfig): Partial<CallConfig> | void;
58
+ /**
59
+ * An override function for query calls' CallConfig. This will be called on every query.
60
+ */
61
+ queryTransform?(methodName: string, args: unknown[], callConfig: CallConfig): Partial<CallConfig> | void;
62
+ }
63
+ /**
64
+ * A subclass of an actor. Actor class itself is meant to be a based class.
65
+ */
66
+ export declare type ActorSubclass<T = Record<string, ActorMethod>> = Actor & T;
67
+ /**
68
+ * An actor method type, defined for each methods of the actor service.
69
+ */
70
+ export interface ActorMethod<Args extends unknown[] = unknown[], Ret extends unknown = unknown> {
71
+ (...args: Args): Promise<Ret>;
72
+ withOptions(options: CallConfig): (...args: Args) => Promise<Ret>;
73
+ }
74
+ /**
75
+ * The mode used when installing a canister.
76
+ */
77
+ export declare enum CanisterInstallMode {
78
+ Install = "install",
79
+ Reinstall = "reinstall",
80
+ Upgrade = "upgrade"
81
+ }
82
+ /**
83
+ * Internal metadata for actors. It's an enhanced version of ActorConfig with
84
+ * some fields marked as required (as they are defaulted) and canisterId as
85
+ * a Principal type.
86
+ */
87
+ interface ActorMetadata {
88
+ service: IDL.ServiceClass;
89
+ agent?: Agent;
90
+ config: ActorConfig;
91
+ }
92
+ declare const metadataSymbol: unique symbol;
93
+ /**
94
+ * An actor base class. An actor is an object containing only functions that will
95
+ * return a promise. These functions are derived from the IDL definition.
96
+ */
97
+ export declare class Actor {
98
+ /**
99
+ * Get the Agent class this Actor would call, or undefined if the Actor would use
100
+ * the default agent (global.ic.agent).
101
+ * @param actor The actor to get the agent of.
102
+ */
103
+ static agentOf(actor: Actor): Agent | undefined;
104
+ /**
105
+ * Get the interface of an actor, in the form of an instance of a Service.
106
+ * @param actor The actor to get the interface of.
107
+ */
108
+ static interfaceOf(actor: Actor): IDL.ServiceClass;
109
+ static canisterIdOf(actor: Actor): Principal;
110
+ static install(fields: {
111
+ module: ArrayBuffer;
112
+ mode?: CanisterInstallMode;
113
+ arg?: ArrayBuffer;
114
+ }, config: ActorConfig): Promise<void>;
115
+ static createCanister(config?: CallConfig): Promise<Principal>;
116
+ static createAndInstallCanister(interfaceFactory: IDL.InterfaceFactory, fields: {
117
+ module: ArrayBuffer;
118
+ arg?: ArrayBuffer;
119
+ }, config?: CallConfig): Promise<ActorSubclass>;
120
+ static createActorClass(interfaceFactory: IDL.InterfaceFactory): ActorConstructor;
121
+ static createActor<T = Record<string, ActorMethod>>(interfaceFactory: IDL.InterfaceFactory, configuration: ActorConfig): ActorSubclass<T>;
122
+ private [metadataSymbol];
123
+ protected constructor(metadata: ActorMetadata);
124
+ }
125
+ export declare type ActorConstructor = new (config: ActorConfig) => ActorSubclass;
126
+ export {};
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Actor = exports.CanisterInstallMode = exports.UpdateCallRejectedError = exports.QueryCallRejectedError = exports.ActorCallError = void 0;
4
+ const buffer_1 = require("buffer/");
5
+ const agent_1 = require("./agent");
6
+ const management_1 = require("./canisters/management");
7
+ const errors_1 = require("./errors");
8
+ const candid_1 = require("@astrox/candid");
9
+ const polling_1 = require("./polling");
10
+ const principal_1 = require("@astrox/principal");
11
+ const buffer_2 = require("./utils/buffer");
12
+ class ActorCallError extends errors_1.AgentError {
13
+ constructor(canisterId, methodName, type, props) {
14
+ super([
15
+ `Call failed:`,
16
+ ` Canister: ${canisterId.toText()}`,
17
+ ` Method: ${methodName} (${type})`,
18
+ ...Object.getOwnPropertyNames(props).map(n => ` "${n}": ${JSON.stringify(props[n])}`),
19
+ ].join('\n'));
20
+ this.canisterId = canisterId;
21
+ this.methodName = methodName;
22
+ this.type = type;
23
+ this.props = props;
24
+ }
25
+ }
26
+ exports.ActorCallError = ActorCallError;
27
+ class QueryCallRejectedError extends ActorCallError {
28
+ constructor(canisterId, methodName, result) {
29
+ var _a;
30
+ super(canisterId, methodName, 'query', {
31
+ Status: result.status,
32
+ Code: (_a = agent_1.ReplicaRejectCode[result.reject_code]) !== null && _a !== void 0 ? _a : `Unknown Code "${result.reject_code}"`,
33
+ Message: result.reject_message,
34
+ });
35
+ this.result = result;
36
+ }
37
+ }
38
+ exports.QueryCallRejectedError = QueryCallRejectedError;
39
+ class UpdateCallRejectedError extends ActorCallError {
40
+ constructor(canisterId, methodName, requestId, response) {
41
+ super(canisterId, methodName, 'update', {
42
+ 'Request ID': buffer_2.toHex(requestId),
43
+ 'HTTP status code': response.status.toString(),
44
+ 'HTTP status text': response.statusText,
45
+ });
46
+ this.requestId = requestId;
47
+ this.response = response;
48
+ }
49
+ }
50
+ exports.UpdateCallRejectedError = UpdateCallRejectedError;
51
+ /**
52
+ * The mode used when installing a canister.
53
+ */
54
+ var CanisterInstallMode;
55
+ (function (CanisterInstallMode) {
56
+ CanisterInstallMode["Install"] = "install";
57
+ CanisterInstallMode["Reinstall"] = "reinstall";
58
+ CanisterInstallMode["Upgrade"] = "upgrade";
59
+ })(CanisterInstallMode = exports.CanisterInstallMode || (exports.CanisterInstallMode = {}));
60
+ const metadataSymbol = Symbol.for('ic-agent-metadata');
61
+ /**
62
+ * An actor base class. An actor is an object containing only functions that will
63
+ * return a promise. These functions are derived from the IDL definition.
64
+ */
65
+ class Actor {
66
+ constructor(metadata) {
67
+ this[metadataSymbol] = Object.freeze(metadata);
68
+ }
69
+ /**
70
+ * Get the Agent class this Actor would call, or undefined if the Actor would use
71
+ * the default agent (global.ic.agent).
72
+ * @param actor The actor to get the agent of.
73
+ */
74
+ static agentOf(actor) {
75
+ return actor[metadataSymbol].config.agent;
76
+ }
77
+ /**
78
+ * Get the interface of an actor, in the form of an instance of a Service.
79
+ * @param actor The actor to get the interface of.
80
+ */
81
+ static interfaceOf(actor) {
82
+ return actor[metadataSymbol].service;
83
+ }
84
+ static canisterIdOf(actor) {
85
+ return principal_1.Principal.from(actor[metadataSymbol].config.canisterId);
86
+ }
87
+ static async install(fields, config) {
88
+ const mode = fields.mode === undefined ? CanisterInstallMode.Install : fields.mode;
89
+ // Need to transform the arg into a number array.
90
+ const arg = fields.arg ? [...new Uint8Array(fields.arg)] : [];
91
+ // Same for module.
92
+ const wasmModule = [...new Uint8Array(fields.module)];
93
+ const canisterId = typeof config.canisterId === 'string'
94
+ ? principal_1.Principal.fromText(config.canisterId)
95
+ : config.canisterId;
96
+ await management_1.getManagementCanister(config).install_code({
97
+ mode: { [mode]: null },
98
+ arg,
99
+ wasm_module: wasmModule,
100
+ canister_id: canisterId,
101
+ });
102
+ }
103
+ static async createCanister(config) {
104
+ const { canister_id: canisterId } = await management_1.getManagementCanister(config || {}).provisional_create_canister_with_cycles({ amount: [], settings: [] });
105
+ return canisterId;
106
+ }
107
+ static async createAndInstallCanister(interfaceFactory, fields, config) {
108
+ const canisterId = await this.createCanister(config);
109
+ await this.install(Object.assign({}, fields), Object.assign(Object.assign({}, config), { canisterId }));
110
+ return this.createActor(interfaceFactory, Object.assign(Object.assign({}, config), { canisterId }));
111
+ }
112
+ static createActorClass(interfaceFactory) {
113
+ const service = interfaceFactory({ IDL: candid_1.IDL });
114
+ class CanisterActor extends Actor {
115
+ constructor(config) {
116
+ const canisterId = typeof config.canisterId === 'string'
117
+ ? principal_1.Principal.fromText(config.canisterId)
118
+ : config.canisterId;
119
+ super({
120
+ config: Object.assign(Object.assign(Object.assign({}, DEFAULT_ACTOR_CONFIG), config), { canisterId }),
121
+ service,
122
+ });
123
+ for (const [methodName, func] of service._fields) {
124
+ this[methodName] = _createActorMethod(this, methodName, func);
125
+ }
126
+ }
127
+ }
128
+ return CanisterActor;
129
+ }
130
+ static createActor(interfaceFactory, configuration) {
131
+ return new (this.createActorClass(interfaceFactory))(configuration);
132
+ }
133
+ }
134
+ exports.Actor = Actor;
135
+ // IDL functions can have multiple return values, so decoding always
136
+ // produces an array. Ensure that functions with single or zero return
137
+ // values behave as expected.
138
+ function decodeReturnValue(types, msg) {
139
+ const returnValues = candid_1.IDL.decode(types, buffer_1.Buffer.from(msg));
140
+ switch (returnValues.length) {
141
+ case 0:
142
+ return undefined;
143
+ case 1:
144
+ return returnValues[0];
145
+ default:
146
+ return returnValues;
147
+ }
148
+ }
149
+ const DEFAULT_ACTOR_CONFIG = {
150
+ pollingStrategyFactory: polling_1.strategy.defaultStrategy,
151
+ };
152
+ function _createActorMethod(actor, methodName, func) {
153
+ let caller;
154
+ if (func.annotations.includes('query')) {
155
+ caller = async (options, ...args) => {
156
+ var _a, _b;
157
+ // First, if there's a config transformation, call it.
158
+ options = Object.assign(Object.assign({}, options), (_b = (_a = actor[metadataSymbol].config).queryTransform) === null || _b === void 0 ? void 0 : _b.call(_a, methodName, args, Object.assign(Object.assign({}, actor[metadataSymbol].config), options)));
159
+ const agent = options.agent || actor[metadataSymbol].config.agent || agent_1.getDefaultAgent();
160
+ const cid = principal_1.Principal.from(options.canisterId || actor[metadataSymbol].config.canisterId);
161
+ const arg = candid_1.IDL.encode(func.argTypes, args);
162
+ const result = await agent.query(cid, { methodName, arg });
163
+ switch (result.status) {
164
+ case "rejected" /* Rejected */:
165
+ throw new QueryCallRejectedError(cid, methodName, result);
166
+ case "replied" /* Replied */:
167
+ return decodeReturnValue(func.retTypes, result.reply.arg);
168
+ }
169
+ };
170
+ }
171
+ else {
172
+ caller = async (options, ...args) => {
173
+ var _a, _b;
174
+ // First, if there's a config transformation, call it.
175
+ options = Object.assign(Object.assign({}, options), (_b = (_a = actor[metadataSymbol].config).callTransform) === null || _b === void 0 ? void 0 : _b.call(_a, methodName, args, Object.assign(Object.assign({}, actor[metadataSymbol].config), options)));
176
+ const agent = options.agent || actor[metadataSymbol].config.agent || agent_1.getDefaultAgent();
177
+ const { canisterId, effectiveCanisterId, pollingStrategyFactory } = Object.assign(Object.assign(Object.assign({}, DEFAULT_ACTOR_CONFIG), actor[metadataSymbol].config), options);
178
+ const cid = principal_1.Principal.from(canisterId);
179
+ const ecid = effectiveCanisterId !== undefined ? principal_1.Principal.from(effectiveCanisterId) : cid;
180
+ const arg = candid_1.IDL.encode(func.argTypes, args);
181
+ const { requestId, response } = await agent.call(cid, {
182
+ methodName,
183
+ arg,
184
+ effectiveCanisterId: ecid,
185
+ });
186
+ if (!response.ok) {
187
+ throw new UpdateCallRejectedError(cid, methodName, requestId, response);
188
+ }
189
+ const pollStrategy = pollingStrategyFactory();
190
+ const responseBytes = await polling_1.pollForResponse(agent, ecid, requestId, pollStrategy);
191
+ if (responseBytes !== undefined) {
192
+ return decodeReturnValue(func.retTypes, responseBytes);
193
+ }
194
+ else if (func.retTypes.length === 0) {
195
+ return undefined;
196
+ }
197
+ else {
198
+ throw new Error(`Call was returned undefined, but type [${func.retTypes.join(',')}].`);
199
+ }
200
+ };
201
+ }
202
+ const handler = (...args) => caller({}, ...args);
203
+ handler.withOptions =
204
+ (options) => (...args) => caller(options, ...args);
205
+ return handler;
206
+ }
207
+ //# sourceMappingURL=actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.js","sourceRoot":"","sources":["../../src/actor.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AACjC,mCAOiB;AACjB,uDAA+D;AAC/D,qCAAsC;AACtC,2CAAqC;AACrC,uCAA2E;AAC3E,iDAA8C;AAE9C,2CAAuC;AAEvC,MAAa,cAAe,SAAQ,mBAAU;IAC5C,YACkB,UAAqB,EACrB,UAAkB,EACl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AM,KAAK,CAAC,EAAE;gBACrC,OAAO,SAAS,CAAC;aAClB;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACxF;QACH,CAAC,CAAC;KACH;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5D,OAAO,CAAC,WAAW;QACjB,CAAC,OAAmB,EAAE,EAAE,CACxB,CAAC,GAAG,IAAe,EAAE,EAAE,CACrB,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7B,OAAO,OAAsB,CAAC;AAChC,CAAC"}
@@ -0,0 +1,140 @@
1
+ import { Principal } from '@astrox/principal';
2
+ import { RequestId } from '../request_id';
3
+ import { JsonObject } from '@astrox/candid';
4
+ /**
5
+ * Codes used by the replica for rejecting a message.
6
+ * See {@link https://sdk.dfinity.org/docs/interface-spec/#reject-codes | the interface spec}.
7
+ */
8
+ export declare enum ReplicaRejectCode {
9
+ SysFatal = 1,
10
+ SysTransient = 2,
11
+ DestinationInvalid = 3,
12
+ CanisterReject = 4,
13
+ CanisterError = 5
14
+ }
15
+ /**
16
+ * Options when doing a {@link Agent.readState} call.
17
+ */
18
+ export interface ReadStateOptions {
19
+ /**
20
+ * A list of paths to read the state of.
21
+ */
22
+ paths: ArrayBuffer[][];
23
+ }
24
+ /**
25
+ *
26
+ */
27
+ export declare type QueryResponse = QueryResponseReplied | QueryResponseRejected;
28
+ export declare const enum QueryResponseStatus {
29
+ Replied = "replied",
30
+ Rejected = "rejected"
31
+ }
32
+ export interface QueryResponseBase {
33
+ status: QueryResponseStatus;
34
+ }
35
+ export interface QueryResponseReplied extends QueryResponseBase {
36
+ status: QueryResponseStatus.Replied;
37
+ reply: {
38
+ arg: ArrayBuffer;
39
+ };
40
+ }
41
+ export interface QueryResponseRejected extends QueryResponseBase {
42
+ status: QueryResponseStatus.Rejected;
43
+ reject_code: ReplicaRejectCode;
44
+ reject_message: string;
45
+ }
46
+ /**
47
+ * Options when doing a {@link Agent.query} call.
48
+ */
49
+ export interface QueryFields {
50
+ /**
51
+ * The method name to call.
52
+ */
53
+ methodName: string;
54
+ /**
55
+ * A binary encoded argument. This is already encoded and will be sent as is.
56
+ */
57
+ arg: ArrayBuffer;
58
+ }
59
+ /**
60
+ * Options when doing a {@link Agent.call} call.
61
+ */
62
+ export interface CallOptions {
63
+ /**
64
+ * The method name to call.
65
+ */
66
+ methodName: string;
67
+ /**
68
+ * A binary encoded argument. This is already encoded and will be sent as is.
69
+ */
70
+ arg: ArrayBuffer;
71
+ /**
72
+ * An effective canister ID, used for routing. This should only be mentioned if
73
+ * it's different from the canister ID.
74
+ */
75
+ effectiveCanisterId: Principal | string;
76
+ }
77
+ export interface ReadStateResponse {
78
+ certificate: ArrayBuffer;
79
+ }
80
+ export interface SubmitResponse {
81
+ requestId: RequestId;
82
+ response: {
83
+ ok: boolean;
84
+ status: number;
85
+ statusText: string;
86
+ };
87
+ }
88
+ /**
89
+ * An Agent able to make calls and queries to a Replica.
90
+ */
91
+ export interface Agent {
92
+ readonly rootKey: ArrayBuffer | null;
93
+ /**
94
+ * Returns the principal ID associated with this agent (by default). It only shows
95
+ * the principal of the default identity in the agent, which is the principal used
96
+ * when calls don't specify it.
97
+ */
98
+ getPrincipal(): Promise<Principal>;
99
+ /**
100
+ * Send a read state query to the replica. This includes a list of paths to return,
101
+ * and will return a Certificate. This will only reject on communication errors,
102
+ * but the certificate might contain less information than requested.
103
+ * @param effectiveCanisterId A Canister ID related to this call.
104
+ * @param options The options for this call.
105
+ */
106
+ readState(effectiveCanisterId: Principal | string, options: ReadStateOptions): Promise<ReadStateResponse>;
107
+ call(canisterId: Principal | string, fields: CallOptions): Promise<SubmitResponse>;
108
+ /**
109
+ * Query the status endpoint of the replica. This normally has a few fields that
110
+ * corresponds to the version of the replica, its root public key, and any other
111
+ * information made public.
112
+ * @returns A JsonObject that is essentially a record of fields from the status
113
+ * endpoint.
114
+ */
115
+ status(): Promise<JsonObject>;
116
+ /**
117
+ * Send a query call to a canister. See
118
+ * {@link https://sdk.dfinity.org/docs/interface-spec/#http-query | the interface spec}.
119
+ * @param canisterId The Principal of the Canister to send the query to. Sending a query to
120
+ * the management canister is not supported (as it has no meaning from an agent).
121
+ * @param options Options to use to create and send the query.
122
+ * @returns The response from the replica. The Promise will only reject when the communication
123
+ * failed. If the query itself failed but no protocol errors happened, the response will
124
+ * be of type QueryResponseRejected.
125
+ */
126
+ query(canisterId: Principal | string, options: QueryFields): Promise<QueryResponse>;
127
+ /**
128
+ * By default, the agent is configured to talk to the main Internet Computer,
129
+ * and verifies responses using a hard-coded public key.
130
+ *
131
+ * This function will instruct the agent to ask the endpoint for its public
132
+ * key, and use that instead. This is required when talking to a local test
133
+ * instance, for example.
134
+ *
135
+ * Only use this when you are _not_ talking to the main Internet Computer,
136
+ * otherwise you are prone to man-in-the-middle attacks! Do not call this
137
+ * function by default.
138
+ */
139
+ fetchRootKey(): Promise<ArrayBuffer>;
140
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReplicaRejectCode = void 0;
4
+ /**
5
+ * Codes used by the replica for rejecting a message.
6
+ * See {@link https://sdk.dfinity.org/docs/interface-spec/#reject-codes | the interface spec}.
7
+ */
8
+ var ReplicaRejectCode;
9
+ (function (ReplicaRejectCode) {
10
+ ReplicaRejectCode[ReplicaRejectCode["SysFatal"] = 1] = "SysFatal";
11
+ ReplicaRejectCode[ReplicaRejectCode["SysTransient"] = 2] = "SysTransient";
12
+ ReplicaRejectCode[ReplicaRejectCode["DestinationInvalid"] = 3] = "DestinationInvalid";
13
+ ReplicaRejectCode[ReplicaRejectCode["CanisterReject"] = 4] = "CanisterReject";
14
+ ReplicaRejectCode[ReplicaRejectCode["CanisterError"] = 5] = "CanisterError";
15
+ })(ReplicaRejectCode = exports.ReplicaRejectCode || (exports.ReplicaRejectCode = {}));
16
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/agent/api.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,iEAAY,CAAA;IACZ,yEAAgB,CAAA;IAChB,qFAAsB,CAAA;IACtB,6EAAkB,CAAA;IAClB,2EAAiB,CAAA;AACnB,CAAC,EANW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAM5B"}
@@ -0,0 +1,49 @@
1
+ import { JsonObject } from '@astrox/candid';
2
+ import { Principal } from '@astrox/principal';
3
+ import { Identity } from '../../auth';
4
+ import { Agent, QueryFields, QueryResponse, ReadStateOptions, ReadStateResponse, SubmitResponse } from '../api';
5
+ import { HttpAgentRequest, HttpAgentRequestTransformFn } from './types';
6
+ export * from './transforms';
7
+ export { Nonce, makeNonce } from './types';
8
+ export declare enum RequestStatusResponseStatus {
9
+ Received = "received",
10
+ Processing = "processing",
11
+ Replied = "replied",
12
+ Rejected = "rejected",
13
+ Unknown = "unknown",
14
+ Done = "done"
15
+ }
16
+ export interface HttpAgentOptions {
17
+ source?: HttpAgent;
18
+ fetch?: typeof fetch;
19
+ fetchAgent?: typeof fetch;
20
+ host?: string;
21
+ identity?: Identity | Promise<Identity>;
22
+ credentials?: {
23
+ name: string;
24
+ password?: string;
25
+ };
26
+ }
27
+ export declare class HttpAgent implements Agent {
28
+ rootKey: ArrayBuffer;
29
+ private readonly _pipeline;
30
+ private readonly _identity;
31
+ private readonly _fetch;
32
+ private readonly _fetchAgent;
33
+ private readonly _host;
34
+ private readonly _credentials;
35
+ private _rootKeyFetched;
36
+ constructor(options?: HttpAgentOptions);
37
+ addTransform(fn: HttpAgentRequestTransformFn, priority?: number): void;
38
+ getPrincipal(): Promise<Principal>;
39
+ call(canisterId: Principal | string, options: {
40
+ methodName: string;
41
+ arg: ArrayBuffer;
42
+ effectiveCanisterId?: Principal | string;
43
+ }, identity?: Identity | Promise<Identity>): Promise<SubmitResponse>;
44
+ query(canisterId: Principal | string, fields: QueryFields, identity?: Identity | Promise<Identity>): Promise<QueryResponse>;
45
+ readState(canisterId: Principal | string, fields: ReadStateOptions, identity?: Identity | Promise<Identity>): Promise<ReadStateResponse>;
46
+ status(): Promise<JsonObject>;
47
+ fetchRootKey(): Promise<ArrayBuffer>;
48
+ protected _transform(request: HttpAgentRequest): Promise<HttpAgentRequest>;
49
+ }