Comparing version 3.6.1 to 3.7.0
@@ -12,2 +12,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "UserSearchOperator", { | ||
enumerable: true, | ||
get: function () { | ||
return _users.UserSearchOperator; | ||
} | ||
}); | ||
exports.envs = void 0; | ||
@@ -21,4 +27,6 @@ | ||
var _users = require("./users"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.Users = void 0; | ||
exports.Users = exports.UserSearchIterator = exports.UserSearchOperator = void 0; | ||
@@ -13,2 +13,54 @@ var _shared = require("./shared"); | ||
let UserSearchOperator; | ||
exports.UserSearchOperator = UserSearchOperator; | ||
(function (UserSearchOperator) { | ||
UserSearchOperator["OR"] = "OR"; | ||
UserSearchOperator["AND"] = "AND"; | ||
})(UserSearchOperator || (exports.UserSearchOperator = UserSearchOperator = {})); | ||
var mode; | ||
(function (mode) { | ||
mode[mode["pending"] = 0] = "pending"; | ||
mode[mode["inProgress"] = 1] = "inProgress"; | ||
mode[mode["complete"] = 2] = "complete"; | ||
})(mode || (mode = {})); | ||
class UserSearchIterator { | ||
constructor(client, data) { | ||
this.client = client; | ||
this.data = data; | ||
this.mode = mode.pending; | ||
} | ||
async next() { | ||
const res = await this.client.search(this.data); | ||
this.data = { ...this.data, | ||
cursor: res.results_metadata.next_cursor | ||
}; | ||
if (!this.data.cursor) { | ||
this.mode = mode.complete; | ||
} else { | ||
this.mode = mode.inProgress; | ||
} | ||
return res.results; | ||
} | ||
hasNext() { | ||
return this.mode !== mode.complete; | ||
} | ||
async *[Symbol.asyncIterator]() { | ||
while (this.hasNext()) { | ||
yield this.next(); | ||
} | ||
} | ||
} | ||
exports.UserSearchIterator = UserSearchIterator; | ||
class Users { | ||
@@ -37,5 +89,23 @@ constructor(client) { | ||
url: this.endpoint(userID) | ||
}).then(res => ({ ...res, | ||
...parseUser(res) | ||
})); | ||
} | ||
search(data) { | ||
return (0, _shared.request)(this.client, { | ||
method: "POST", | ||
url: this.endpoint("search"), | ||
data | ||
}).then(res => { | ||
return { ...res, | ||
results: res.results.map(parseUser) | ||
}; | ||
}); | ||
} | ||
searchAll(data) { | ||
return new UserSearchIterator(this, data); | ||
} | ||
update(userID, data) { | ||
@@ -87,2 +157,9 @@ return (0, _shared.request)(this.client, { | ||
exports.Users = Users; | ||
exports.Users = Users; | ||
function parseUser(user) { | ||
console.log(user); | ||
return { ...user, | ||
created_at: new Date(user.created_at) | ||
}; | ||
} |
{ | ||
"name": "stytch", | ||
"version": "3.6.1", | ||
"version": "3.7.0", | ||
"description": "A wrapper for the Stytch API", | ||
@@ -5,0 +5,0 @@ "types": "./types/lib/index.d.ts", |
@@ -28,2 +28,3 @@ # Stytch Node.js Library | ||
- [x] [WebAuthn (Beta)](https://stytch.com/docs/api/webauthn-overview) | ||
- [x] [User Management (Beta)](https://stytch.com/docs/api/users) | ||
@@ -30,0 +31,0 @@ ### Example usage |
export { Client } from "./client"; | ||
export * as envs from "./envs"; | ||
export { UserSearchOperator } from "./users"; |
@@ -27,2 +27,6 @@ import type { AxiosInstance, AxiosRequestConfig } from "axios"; | ||
} | ||
export interface OAuthProvider { | ||
provider_subject: string; | ||
provider_type: string; | ||
} | ||
export interface EmailFactor { | ||
@@ -29,0 +33,0 @@ delivery_method: "email" | "embedded"; |
@@ -0,1 +1,2 @@ | ||
import { OAuthProvider } from "./shared"; | ||
import type { AxiosInstance } from "axios"; | ||
@@ -25,10 +26,87 @@ import type { Attributes, BaseResponse, Email, Name, PhoneNumber, WebAuthnRegistration } from "./shared"; | ||
} | ||
export interface GetResponse extends BaseResponse { | ||
interface User { | ||
user_id: UserID; | ||
created_at: Date; | ||
status: string; | ||
name: Name; | ||
emails: Email[]; | ||
phone_numbers: PhoneNumber[]; | ||
providers: OAuthProvider[]; | ||
webauthn_registrations: WebAuthnRegistration[]; | ||
status: string; | ||
} | ||
export declare type GetResponse = BaseResponse & User; | ||
export declare enum UserSearchOperator { | ||
OR = "OR", | ||
AND = "AND" | ||
} | ||
export declare type UserSearchOperand = { | ||
filter_name: "created_at_greater_than"; | ||
filter_value: string; | ||
} | { | ||
filter_name: "created_at_less_than"; | ||
filter_value: string; | ||
} | { | ||
filter_name: "created_at_between"; | ||
filter_value: { | ||
greater_than: string; | ||
less_than: string; | ||
}; | ||
} | { | ||
filter_name: "status"; | ||
filter_value: "active" | "pending"; | ||
} | { | ||
filter_name: "oauth_provider"; | ||
filter_value: string[]; | ||
} | { | ||
filter_name: "user_id"; | ||
filter_value: string[]; | ||
} | { | ||
filter_name: "full_name_fuzzy"; | ||
filter_value: string; | ||
} | { | ||
filter_name: "phone_number"; | ||
filter_value: string[]; | ||
} | { | ||
filter_name: "phone_id"; | ||
filter_value: string[]; | ||
} | { | ||
filter_name: "phone_verified"; | ||
filter_value: boolean; | ||
} | { | ||
filter_name: "phone_number_fuzzy"; | ||
filter_value: string; | ||
} | { | ||
filter_name: "email_address"; | ||
filter_value: string[]; | ||
} | { | ||
filter_name: "email_id"; | ||
filter_value: string[]; | ||
} | { | ||
filter_name: "email_verified"; | ||
filter_value: boolean; | ||
} | { | ||
filter_name: "email_address_fuzzy"; | ||
filter_value: string; | ||
} | { | ||
filter_name: "webauthn_registration_verified"; | ||
filter_value: boolean; | ||
} | { | ||
filter_name: "webauthn_registration_id"; | ||
filter_value: string[]; | ||
}; | ||
export interface SearchRequest { | ||
limit?: number; | ||
query?: { | ||
operator: UserSearchOperator; | ||
operands: UserSearchOperand[]; | ||
}; | ||
cursor?: string | null; | ||
} | ||
export interface SearchResponse extends BaseResponse { | ||
results: User[]; | ||
results_metadata: { | ||
next_cursor: string | null; | ||
total: number; | ||
}; | ||
} | ||
export interface UpdateRequest { | ||
@@ -71,2 +149,11 @@ name?: Name; | ||
} | ||
export declare class UserSearchIterator { | ||
private client; | ||
private data; | ||
private mode; | ||
constructor(client: Users, data: SearchRequest); | ||
next(): Promise<User[]>; | ||
hasNext(): boolean; | ||
[Symbol.asyncIterator](): AsyncIterator<User[]>; | ||
} | ||
export declare class Users { | ||
@@ -79,2 +166,4 @@ base_path: string; | ||
get(userID: UserID): Promise<GetResponse>; | ||
search(data: SearchRequest): Promise<SearchResponse>; | ||
searchAll(data: SearchRequest): UserSearchIterator; | ||
update(userID: UserID, data: UpdateRequest): Promise<UpdateResponse>; | ||
@@ -87,1 +176,2 @@ delete(userID: UserID): Promise<DeleteResponse>; | ||
} | ||
export {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47502
1266
100
1