@dfns/sdk 0.4.2-alpha.1 → 0.4.3-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ export type CreateWebhookBody = {
3
3
  /** Webhook status */
4
4
  status?: ("Enabled" | "Disabled") | undefined;
5
5
  description?: string | undefined;
6
- events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested") | "*")[];
6
+ events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified") | "*")[];
7
7
  };
8
8
  export type CreateWebhookResponse = {
9
9
  /** Webhook ID */
@@ -11,7 +11,7 @@ export type CreateWebhookResponse = {
11
11
  /** Webhook url */
12
12
  url: string;
13
13
  /** All events this webhook is subscribed to. */
14
- events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested") | "*")[];
14
+ events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified") | "*")[];
15
15
  /** Webhook status */
16
16
  status: "Enabled" | "Disabled";
17
17
  /** Short description this webhook's purpose */
@@ -42,7 +42,7 @@ export type GetWebhookResponse = {
42
42
  /** Webhook url */
43
43
  url: string;
44
44
  /** All events this webhook is subscribed to. */
45
- events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested") | "*")[];
45
+ events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified") | "*")[];
46
46
  /** Webhook status */
47
47
  status: "Enabled" | "Disabled";
48
48
  /** Short description this webhook's purpose */
@@ -63,7 +63,7 @@ export type GetWebhookEventResponse = {
63
63
  /** ISO date string when event was raised */
64
64
  date: string;
65
65
  /** Webhook event */
66
- kind: "policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested";
66
+ kind: "policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified";
67
67
  data: {
68
68
  [x: string]: any;
69
69
  };
@@ -79,7 +79,7 @@ export type ListWebhookEventsParams = {
79
79
  webhookId: string;
80
80
  };
81
81
  export type ListWebhookEventsQuery = {
82
- kind?: ("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested") | undefined;
82
+ kind?: ("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified") | undefined;
83
83
  deliveryFailed?: ("true" | "false") | undefined;
84
84
  limit?: number | undefined;
85
85
  paginationToken?: string | undefined;
@@ -91,7 +91,7 @@ export type ListWebhookEventsResponse = {
91
91
  /** ISO date string when event was raised */
92
92
  date: string;
93
93
  /** Webhook event */
94
- kind: "policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested";
94
+ kind: "policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified";
95
95
  data: {
96
96
  [x: string]: any;
97
97
  };
@@ -118,7 +118,7 @@ export type ListWebhooksResponse = {
118
118
  /** Webhook url */
119
119
  url: string;
120
120
  /** All events this webhook is subscribed to. */
121
- events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested") | "*")[];
121
+ events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified") | "*")[];
122
122
  /** Webhook status */
123
123
  status: "Enabled" | "Disabled";
124
124
  /** Short description this webhook's purpose */
@@ -144,7 +144,7 @@ export type PingWebhookRequest = PingWebhookParams;
144
144
  export type UpdateWebhookBody = {
145
145
  url?: string | undefined;
146
146
  description?: (string | undefined) | undefined;
147
- events?: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested") | "*")[] | undefined;
147
+ events?: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified") | "*")[] | undefined;
148
148
  /** Webhook status */
149
149
  status?: (("Enabled" | "Disabled") | undefined) | undefined;
150
150
  };
@@ -157,7 +157,7 @@ export type UpdateWebhookResponse = {
157
157
  /** Webhook url */
158
158
  url: string;
159
159
  /** All events this webhook is subscribed to. */
160
- events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested") | "*")[];
160
+ events: (("policy.approval.pending" | "policy.approval.resolved" | "wallet.blockchainevent.detected" | "wallet.created" | "wallet.delegated" | "wallet.exported" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.requested" | "wallet.signature.signed" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.requested" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.requested" | "wallet.tags.modified") | "*")[];
161
161
  /** Webhook status */
162
162
  status: "Enabled" | "Disabled";
163
163
  /** Short description this webhook's purpose */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfns/sdk",
3
- "version": "0.4.2-alpha.1",
3
+ "version": "0.4.3-alpha.1",
4
4
  "dependencies": {
5
5
  "buffer": "6.0.3",
6
6
  "cross-fetch": "3.1.6",
package/signer.d.ts CHANGED
@@ -5,7 +5,6 @@ export type UserVerificationRequirement = 'required' | 'preferred' | 'discourage
5
5
  export type AllowCredential = {
6
6
  type: 'public-key';
7
7
  id: string;
8
- transports: CredentialTransport[];
9
8
  };
10
9
  export type SupportedCredential = {
11
10
  kind: CredentialKind;
@@ -43,7 +42,7 @@ export type Fido2Assertion = {
43
42
  clientData: string;
44
43
  authenticatorData: string;
45
44
  signature: string;
46
- userHandle: string;
45
+ userHandle?: string;
47
46
  };
48
47
  };
49
48
  export type PasswordAssertion = {
@@ -69,6 +68,3 @@ export type CredentialAssertion = KeyAssertion | Fido2Assertion | PasswordAssert
69
68
  export interface CredentialSigner<T extends CredentialAssertion = FirstFactorAssertion> {
70
69
  sign(challenge: UserActionChallenge): Promise<T>;
71
70
  }
72
- export declare class EmptySigner implements CredentialSigner {
73
- sign(): Promise<never>;
74
- }
package/signer.js CHANGED
@@ -1,10 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmptySigner = void 0;
4
- const dfnsError_1 = require("./dfnsError");
5
- class EmptySigner {
6
- async sign() {
7
- throw new dfnsError_1.DfnsError(-1, 'A signature is required, but an EmptySigner cannot fulfill it.');
8
- }
9
- }
10
- exports.EmptySigner = EmptySigner;
@@ -0,0 +1 @@
1
+ export * from '../generated/auth';
package/types/auth.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../generated/auth"), exports);
package/utils/fetch.js CHANGED
@@ -5,9 +5,10 @@ const cross_fetch_1 = require("cross-fetch");
5
5
  const dfnsError_1 = require("../dfnsError");
6
6
  const baseAuthApi_1 = require("../baseAuthApi");
7
7
  const nonce_1 = require("./nonce");
8
+ const DEFAULT_DFNS_BASE_URL = 'https://api.dfns.io';
8
9
  const fullUrl = (fetch) => {
9
10
  return async (resource, options) => {
10
- const { baseUrl } = options.apiOptions;
11
+ const baseUrl = options.apiOptions.baseUrl || DEFAULT_DFNS_BASE_URL;
11
12
  resource = new URL(resource, baseUrl);
12
13
  return fetch(resource, options);
13
14
  };
@@ -83,6 +84,13 @@ const userAction = (fetch) => {
83
84
  ...options.apiOptions,
84
85
  baseUrl: options.apiOptions.baseAuthUrl || options.apiOptions.baseUrl,
85
86
  };
87
+ if (!apiOptions.signer) {
88
+ throw new dfnsError_1.DfnsError(-1, 'A "signer" needs to be passed to Dfns client.', {
89
+ detail: `Most non-readonly endpoints require "User Action Signing" flow.` +
90
+ ` During that flow, the credential "signer" that you passed will handle signing` +
91
+ ` the user action challenge, using your credential.`,
92
+ });
93
+ }
86
94
  const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
87
95
  userActionPayload: options.body ?? '',
88
96
  userActionHttpMethod: options.method,