const uuidPlugin = function (schema, options) { options = options || {}; var pk = schema.add({ _id: { type: String, default: () => uuidv4(), trim: true, lowercase: true } }); schema.path("_id").validate(function (v) { console.log("validating: " + JSON.stringify(v)); return validator.isUUID(v); }, "ID is not a valid GUID: {VALUE}"); }
/** * View Action * @param id * @param options * @returns {Promise<*>} */ async view(id, options) { // Check if this is a valid UUID if (!validate.isUUID(id)) { this.error(i18n.__(`This is not a valid UUID: ${id}`)); } // Get the record let url = `${this.URL_BASE}/${id}.json?api-version=v1&`; if (typeof options !== 'undefined') { url += options; } const request = { url, jar: this.cookieJar }; try { const response = await this.get(request); return this._parseResponse(response); } catch (error) { this.error(error); } }
return new Error(i18n.__(`Passbolt does not support GPGAuth token nonce longer than 36 characters: ${sections[2]}`)); if (!validator.isUUID(sections[2])) { return new Error(i18n.__('Passbolt does not support GPGAuth token nonce that are not UUIDs'));