zeno.id 0.2.0 → 0.3.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.
@@ -400,6 +400,10 @@ type Relation = RelationTarget & {
400
400
  action?: string;
401
401
  at?: string;
402
402
  };
403
+ /** A relation as added: `linkWrite` says whether this call made a new link, the billed unit (a link added before isn't). */
404
+ type AddedRelation = Relation & {
405
+ linkWrite: boolean;
406
+ };
403
407
  /** A link to one user's Related view for your admin panel to frame, and when it stops working (ISO). */
404
408
  type Embed = {
405
409
  url: string;
@@ -453,6 +457,12 @@ type VerifyOptions = {
453
457
  * succeeded (the password matched, the account exists), with the user's ID, so a failed login attaches nothing.
454
458
  */
455
459
  externalId?: string;
460
+ /**
461
+ * Makes sending the same verify again safe: a repeat with this key within 5 minutes answers what the first did,
462
+ * instead of `already-used`. The SDK makes one per call and retries a lost answer with it itself; pass your own (8
463
+ * to 128 characters, such as your request's ID) when your code may send the same verify again.
464
+ */
465
+ idempotencyKey?: string;
456
466
  };
457
467
  /**
458
468
  * What `verify` says to do: `allow`, `challenge` or `block`, and why: its own check (`VerifyCheck`), else the event's
@@ -486,7 +496,8 @@ declare const createClient: (apiKey: ApiKey, options?: ClientOptions) => {
486
496
  * seconds (`too-old`, 5 minutes by default) or belongs to another user than `externalId`
487
497
  * (`external-id-mismatch`); otherwise it answers the event's verdict. Call it after the action succeeded (the
488
498
  * password matched, the account exists), with the user's ID: `externalId` is attached to an event without one.
489
- * It writes nothing else. Other api errors throw.
499
+ * It writes nothing else. A lost answer (a network error or a 5xx) is sent again twice with the same
500
+ * idempotency key, which answers the first result rather than `already-used`. Other api errors throw.
490
501
  */
491
502
  verify: (requestId: string | undefined | null, options?: VerifyOptions) => Promise<VerifyResult>;
492
503
  getEvent: (requestId: string) => Promise<Event>;
@@ -509,10 +520,11 @@ declare const createClient: (apiKey: ApiKey, options?: ClientOptions) => {
509
520
  * number, your own device id) or another of your users (a referral). Visitor ids only come from events with an
510
521
  * external id, so `identified` means the user was seen in a browser.
511
522
  *
512
- * Each call is billed like an identification, so once a spend limit you set is reached it throws a `402`
513
- * `spend_limit_reached` and adds nothing; only a `429` is sent again.
523
+ * A new link is billed like an identification (`linkWrite: true`); sending one again is free. Once a spend
524
+ * limit you set is reached it throws a `402` `spend_limit_reached` and adds nothing; only a `429` is sent
525
+ * again.
514
526
  */
515
- addRelation: ({ at, ...relation }: RelationInput) => Promise<Relation>;
527
+ addRelation: ({ at, ...relation }: RelationInput) => Promise<AddedRelation>;
516
528
  /**
517
529
  * Takes back a relation added with `addRelation`: a value, or a relation between two users (both sides go,
518
530
  * whichever side you name). What events related (a visitor id, an ip seen with an event) stays. Free.
@@ -603,4 +615,4 @@ type UnsealOptions = {
603
615
  */
604
616
  declare const unsealResult: (sealed: string | undefined | null, options: UnsealOptions) => Promise<VerifyResult>;
605
617
  //#endregion
606
- export { type ApiOptions, Bot, BrowserDetails, Client, ClientOptions, Confidence, Connection, Contradiction, Embed, Event, ForgedPayloadIndicator, IpInfo, Metadata, NetworkOwnerType, Page, type ProxyHandler, type ProxyOptions, Related, RelatedKind, RelatedType, RelatedUser, RelatedValue, RelatedValues, Relation, RelationInput, RelationRemoval, SIGNALS, SearchEvent, SearchFilters, SearchResult, SharedValue, Signal, SignalDetails, SignalReason, SignalResult, Signals, UnsealOptions, Velocity, Verdict, VerdictAction, VerdictReason, VerifyCheck, VerifyOptions, VerifyResult, VirtualMachineIndicator, Visitor, WebhookEvent, ZenoError, ZenoErrorCode, createClient, createProxy, unsealResult, verifyWebhook };
618
+ export { AddedRelation, type ApiOptions, Bot, BrowserDetails, Client, ClientOptions, Confidence, Connection, Contradiction, Embed, Event, ForgedPayloadIndicator, IpInfo, Metadata, NetworkOwnerType, Page, type ProxyHandler, type ProxyOptions, Related, RelatedKind, RelatedType, RelatedUser, RelatedValue, RelatedValues, Relation, RelationInput, RelationRemoval, SIGNALS, SearchEvent, SearchFilters, SearchResult, SharedValue, Signal, SignalDetails, SignalReason, SignalResult, Signals, UnsealOptions, Velocity, Verdict, VerdictAction, VerdictReason, VerifyCheck, VerifyOptions, VerifyResult, VirtualMachineIndicator, Visitor, WebhookEvent, ZenoError, ZenoErrorCode, createClient, createProxy, unsealResult, verifyWebhook };
@@ -400,6 +400,10 @@ type Relation = RelationTarget & {
400
400
  action?: string;
401
401
  at?: string;
402
402
  };
403
+ /** A relation as added: `linkWrite` says whether this call made a new link, the billed unit (a link added before isn't). */
404
+ type AddedRelation = Relation & {
405
+ linkWrite: boolean;
406
+ };
403
407
  /** A link to one user's Related view for your admin panel to frame, and when it stops working (ISO). */
404
408
  type Embed = {
405
409
  url: string;
@@ -453,6 +457,12 @@ type VerifyOptions = {
453
457
  * succeeded (the password matched, the account exists), with the user's ID, so a failed login attaches nothing.
454
458
  */
455
459
  externalId?: string;
460
+ /**
461
+ * Makes sending the same verify again safe: a repeat with this key within 5 minutes answers what the first did,
462
+ * instead of `already-used`. The SDK makes one per call and retries a lost answer with it itself; pass your own (8
463
+ * to 128 characters, such as your request's ID) when your code may send the same verify again.
464
+ */
465
+ idempotencyKey?: string;
456
466
  };
457
467
  /**
458
468
  * What `verify` says to do: `allow`, `challenge` or `block`, and why: its own check (`VerifyCheck`), else the event's
@@ -486,7 +496,8 @@ declare const createClient: (apiKey: ApiKey, options?: ClientOptions) => {
486
496
  * seconds (`too-old`, 5 minutes by default) or belongs to another user than `externalId`
487
497
  * (`external-id-mismatch`); otherwise it answers the event's verdict. Call it after the action succeeded (the
488
498
  * password matched, the account exists), with the user's ID: `externalId` is attached to an event without one.
489
- * It writes nothing else. Other api errors throw.
499
+ * It writes nothing else. A lost answer (a network error or a 5xx) is sent again twice with the same
500
+ * idempotency key, which answers the first result rather than `already-used`. Other api errors throw.
490
501
  */
491
502
  verify: (requestId: string | undefined | null, options?: VerifyOptions) => Promise<VerifyResult>;
492
503
  getEvent: (requestId: string) => Promise<Event>;
@@ -509,10 +520,11 @@ declare const createClient: (apiKey: ApiKey, options?: ClientOptions) => {
509
520
  * number, your own device id) or another of your users (a referral). Visitor ids only come from events with an
510
521
  * external id, so `identified` means the user was seen in a browser.
511
522
  *
512
- * Each call is billed like an identification, so once a spend limit you set is reached it throws a `402`
513
- * `spend_limit_reached` and adds nothing; only a `429` is sent again.
523
+ * A new link is billed like an identification (`linkWrite: true`); sending one again is free. Once a spend
524
+ * limit you set is reached it throws a `402` `spend_limit_reached` and adds nothing; only a `429` is sent
525
+ * again.
514
526
  */
515
- addRelation: ({ at, ...relation }: RelationInput) => Promise<Relation>;
527
+ addRelation: ({ at, ...relation }: RelationInput) => Promise<AddedRelation>;
516
528
  /**
517
529
  * Takes back a relation added with `addRelation`: a value, or a relation between two users (both sides go,
518
530
  * whichever side you name). What events related (a visitor id, an ip seen with an event) stays. Free.
@@ -603,4 +615,4 @@ type UnsealOptions = {
603
615
  */
604
616
  declare const unsealResult: (sealed: string | undefined | null, options: UnsealOptions) => Promise<VerifyResult>;
605
617
  //#endregion
606
- export { type ApiOptions, Bot, BrowserDetails, Client, ClientOptions, Confidence, Connection, Contradiction, Embed, Event, ForgedPayloadIndicator, IpInfo, Metadata, NetworkOwnerType, Page, type ProxyHandler, type ProxyOptions, Related, RelatedKind, RelatedType, RelatedUser, RelatedValue, RelatedValues, Relation, RelationInput, RelationRemoval, SIGNALS, SearchEvent, SearchFilters, SearchResult, SharedValue, Signal, SignalDetails, SignalReason, SignalResult, Signals, UnsealOptions, Velocity, Verdict, VerdictAction, VerdictReason, VerifyCheck, VerifyOptions, VerifyResult, VirtualMachineIndicator, Visitor, WebhookEvent, ZenoError, ZenoErrorCode, createClient, createProxy, unsealResult, verifyWebhook };
618
+ export { AddedRelation, type ApiOptions, Bot, BrowserDetails, Client, ClientOptions, Confidence, Connection, Contradiction, Embed, Event, ForgedPayloadIndicator, IpInfo, Metadata, NetworkOwnerType, Page, type ProxyHandler, type ProxyOptions, Related, RelatedKind, RelatedType, RelatedUser, RelatedValue, RelatedValues, Relation, RelationInput, RelationRemoval, SIGNALS, SearchEvent, SearchFilters, SearchResult, SharedValue, Signal, SignalDetails, SignalReason, SignalResult, Signals, UnsealOptions, Velocity, Verdict, VerdictAction, VerdictReason, VerifyCheck, VerifyOptions, VerifyResult, VirtualMachineIndicator, Visitor, WebhookEvent, ZenoError, ZenoErrorCode, createClient, createProxy, unsealResult, verifyWebhook };