From f128e06ea608f07f279baa5c3e934b020fa57682 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Mon, 18 Nov 2019 21:03:25 +0100 Subject: [PATCH 01/17] fix: add search to reserved usernames (#9063) * fix: add search to reserved usernames * Update integrations/user_test.go Co-Authored-By: 6543 <24977596+6543@users.noreply.github.com> --- integrations/user_test.go | 1 + models/user.go | 1 + 2 files changed, 2 insertions(+) diff --git a/integrations/user_test.go b/integrations/user_test.go index 0a6fdd19d5a09..452ea2ddf0d94 100644 --- a/integrations/user_test.go +++ b/integrations/user_test.go @@ -90,6 +90,7 @@ func TestRenameReservedUsername(t *testing.T) { "repo", "template", "user", + "search", } session := loginUser(t, "user2") diff --git a/models/user.go b/models/user.go index ce78e5bfcee90..2cef2e5deccce 100644 --- a/models/user.go +++ b/models/user.go @@ -822,6 +822,7 @@ var ( ".", "..", ".well-known", + "search", } reservedUserPatterns = []string{"*.keys", "*.gpg"} ) From 2c2b9718e6f13dfa14b0ff8aafb15cfa1d85bc0e Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Mon, 18 Nov 2019 20:43:03 -0300 Subject: [PATCH 02/17] Avoid re-issuing redundant cross-references. (#8734) * Avoid re-issuing redundant cross-references. * Remove unused func; fix lint * Simplify code as suggested by @laftriks * Update test --- models/issue.go | 19 ++++--------- models/issue_comment.go | 7 ++--- models/issue_xref.go | 57 ++++++++++++++++++++++++++++++++------- models/issue_xref_test.go | 4 +-- 4 files changed, 56 insertions(+), 31 deletions(-) diff --git a/models/issue.go b/models/issue.go index 0113f0a4046bf..e28e7c01c3025 100644 --- a/models/issue.go +++ b/models/issue.go @@ -722,11 +722,7 @@ func (issue *Issue) ChangeTitle(doer *User, oldTitle string) (err error) { return fmt.Errorf("createComment: %v", err) } - if err = issue.neuterCrossReferences(sess); err != nil { - return err - } - - if err = issue.addCrossReferences(sess, doer); err != nil { + if err = issue.addCrossReferences(sess, doer, true); err != nil { return err } @@ -790,10 +786,8 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) { if err = updateIssueCols(sess, issue, "content"); err != nil { return fmt.Errorf("UpdateIssueCols: %v", err) } - if err = issue.neuterCrossReferences(sess); err != nil { - return err - } - if err = issue.addCrossReferences(sess, doer); err != nil { + + if err = issue.addCrossReferences(sess, doer, true); err != nil { return err } @@ -944,7 +938,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) { if err = opts.Issue.loadAttributes(e); err != nil { return err } - return opts.Issue.addCrossReferences(e, doer) + return opts.Issue.addCrossReferences(e, doer, false) } // NewIssue creates new issue with labels for repository. @@ -1578,13 +1572,10 @@ func UpdateIssue(issue *Issue) error { if err := updateIssue(sess, issue); err != nil { return err } - if err := issue.neuterCrossReferences(sess); err != nil { - return err - } if err := issue.loadPoster(sess); err != nil { return err } - if err := issue.addCrossReferences(sess, issue.Poster); err != nil { + if err := issue.addCrossReferences(sess, issue.Poster, true); err != nil { return err } return sess.Commit() diff --git a/models/issue_comment.go b/models/issue_comment.go index 7ac8c4df4383a..73fd9c8c83eeb 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -545,7 +545,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err } } - if err = comment.addCrossReferences(e, opts.Doer); err != nil { + if err = comment.addCrossReferences(e, opts.Doer, false); err != nil { return nil, err } @@ -882,10 +882,7 @@ func UpdateComment(c *Comment, doer *User) error { if err := c.loadIssue(sess); err != nil { return err } - if err := c.neuterCrossReferences(sess); err != nil { - return err - } - if err := c.addCrossReferences(sess, doer); err != nil { + if err := c.addCrossReferences(sess, doer, true); err != nil { return err } if err := sess.Commit(); err != nil { diff --git a/models/issue_xref.go b/models/issue_xref.go index f41c154753068..9f30aba259178 100644 --- a/models/issue_xref.go +++ b/models/issue_xref.go @@ -25,20 +25,30 @@ type crossReferencesContext struct { Doer *User OrigIssue *Issue OrigComment *Comment + RemoveOld bool } -func neuterCrossReferences(e Engine, issueID int64, commentID int64) error { +func findOldCrossReferences(e Engine, issueID int64, commentID int64) ([]*Comment, error) { active := make([]*Comment, 0, 10) - sess := e.Where("`ref_action` IN (?, ?, ?)", references.XRefActionNone, references.XRefActionCloses, references.XRefActionReopens). + return active, e.Where("`ref_action` IN (?, ?, ?)", references.XRefActionNone, references.XRefActionCloses, references.XRefActionReopens). And("`ref_issue_id` = ?", issueID). - And("`ref_comment_id` = ?", commentID) - if err := sess.Find(&active); err != nil || len(active) == 0 { + And("`ref_comment_id` = ?", commentID). + Find(&active) +} + +func neuterCrossReferences(e Engine, issueID int64, commentID int64) error { + active, err := findOldCrossReferences(e, issueID, commentID) + if err != nil { return err } ids := make([]int64, len(active)) for i, c := range active { ids[i] = c.ID } + return neuterCrossReferencesIds(e, ids) +} + +func neuterCrossReferencesIds(e Engine, ids []int64) error { _, err := e.In("id", ids).Cols("`ref_action`").Update(&Comment{RefAction: references.XRefActionNeutered}) return err } @@ -51,7 +61,7 @@ func neuterCrossReferences(e Engine, issueID int64, commentID int64) error { // \/ \/ \/ // -func (issue *Issue) addCrossReferences(e *xorm.Session, doer *User) error { +func (issue *Issue) addCrossReferences(e *xorm.Session, doer *User, removeOld bool) error { var commentType CommentType if issue.IsPull { commentType = CommentTypePullRef @@ -62,6 +72,7 @@ func (issue *Issue) addCrossReferences(e *xorm.Session, doer *User) error { Type: commentType, Doer: doer, OrigIssue: issue, + RemoveOld: removeOld, } return issue.createCrossReferences(e, ctx, issue.Title, issue.Content) } @@ -71,6 +82,35 @@ func (issue *Issue) createCrossReferences(e *xorm.Session, ctx *crossReferencesC if err != nil { return err } + if ctx.RemoveOld { + var commentID int64 + if ctx.OrigComment != nil { + commentID = ctx.OrigComment.ID + } + active, err := findOldCrossReferences(e, ctx.OrigIssue.ID, commentID) + if err != nil { + return err + } + ids := make([]int64, 0, len(active)) + for _, c := range active { + found := false + for i, x := range xreflist { + if x.Issue.ID == c.IssueID && x.Action == c.RefAction { + found = true + xreflist = append(xreflist[:i], xreflist[i+1:]...) + break + } + } + if !found { + ids = append(ids, c.ID) + } + } + if len(ids) > 0 { + if err = neuterCrossReferencesIds(e, ids); err != nil { + return err + } + } + } for _, xref := range xreflist { var refCommentID int64 if ctx.OrigComment != nil { @@ -193,10 +233,6 @@ func (issue *Issue) verifyReferencedIssue(e Engine, ctx *crossReferencesContext, return refIssue, refAction, nil } -func (issue *Issue) neuterCrossReferences(e Engine) error { - return neuterCrossReferences(e, issue.ID, 0) -} - // _________ __ // \_ ___ \ ____ _____ _____ ____ _____/ |_ // / \ \/ / _ \ / \ / \_/ __ \ / \ __\ @@ -205,7 +241,7 @@ func (issue *Issue) neuterCrossReferences(e Engine) error { // \/ \/ \/ \/ \/ // -func (comment *Comment) addCrossReferences(e *xorm.Session, doer *User) error { +func (comment *Comment) addCrossReferences(e *xorm.Session, doer *User, removeOld bool) error { if comment.Type != CommentTypeCode && comment.Type != CommentTypeComment { return nil } @@ -217,6 +253,7 @@ func (comment *Comment) addCrossReferences(e *xorm.Session, doer *User) error { Doer: doer, OrigIssue: comment.Issue, OrigComment: comment, + RemoveOld: removeOld, } return comment.Issue.createCrossReferences(e, ctx, "", comment.Content) } diff --git a/models/issue_xref_test.go b/models/issue_xref_test.go index 4fc6011d788a9..c13577e905aeb 100644 --- a/models/issue_xref_test.go +++ b/models/issue_xref_test.go @@ -133,7 +133,7 @@ func testCreateIssue(t *testing.T, repo, doer int64, title, content string, ispu assert.NoError(t, err) i, err = getIssueByID(sess, i.ID) assert.NoError(t, err) - assert.NoError(t, i.addCrossReferences(sess, d)) + assert.NoError(t, i.addCrossReferences(sess, d, false)) assert.NoError(t, sess.Commit()) return i } @@ -158,7 +158,7 @@ func testCreateComment(t *testing.T, repo, doer, issue int64, content string) *C assert.NoError(t, sess.Begin()) _, err := sess.Insert(c) assert.NoError(t, err) - assert.NoError(t, c.addCrossReferences(sess, d)) + assert.NoError(t, c.addCrossReferences(sess, d, false)) assert.NoError(t, sess.Commit()) return c } From 9ccb50f162bf58faeb5099755b6fdf21d807bdd4 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Tue, 19 Nov 2019 00:06:09 +0000 Subject: [PATCH 03/17] [skip ci] Updated translations via Crowdin --- options/locale/locale_de-DE.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index 0603c7b496791..d1c36f0b6dc40 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -581,6 +581,8 @@ email_notifications.submit=E-Mail-Einstellungen festlegegen owner=Besitzer repo_name=Repository-Name repo_name_helper=Ein guter Repository-Name besteht normalerweise aus kurzen, unvergesslichen und einzigartigen Schlagwörtern. +repo_size=Repository Größe +template=Template template_select=Vorlage auswählen visibility=Sichtbarkeit visibility_description=Nur der Besitzer oder Organisationsmitglieder mit entsprechender Berechtigung, werden in der Lage sein, es zu sehen. @@ -618,6 +620,7 @@ forks=Forks pick_reaction=Wähle eine Reaktion reactions_more=und %d weitere +template.topics=Themen archive.title=Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen. archive.issue.nocomment=Dieses Repo ist archiviert. Du kannst Issues nicht kommentieren. @@ -862,6 +865,7 @@ issues.create_comment=Kommentieren issues.closed_at=`hat %[2]s geschlossen` issues.reopened_at=`hat %[2]s wieder geöffnet` issues.commit_ref_at=`hat dieses Issue %[2]s aus einem Commit referenziert` +issues.ref_from=`von %[1]s` issues.poster=Ersteller issues.collaborator=Mitarbeiter issues.owner=Besitzer @@ -1691,6 +1695,7 @@ users.auth_login_name=Anmeldename zur Authentifizierung users.password_helper=Passwort leer lassen, um es nicht zu verändern. users.update_profile_success=Das Benutzerkonto wurde aktualisiert. users.edit_account=Benutzerkonto bearbeiten +users.max_repo_creation=Maximale Anzahl an Repositories users.max_repo_creation_desc=(Gib -1 ein, um das globale Standardlimit zu verwenden.) users.is_activated=Account ist aktiviert users.prohibit_login=Anmelden deaktivieren From 5a3af7992cefe2bc17fff61de059a2e8b62f2065 Mon Sep 17 00:00:00 2001 From: Iwasa Kazmi Date: Tue, 19 Nov 2019 16:35:37 +0900 Subject: [PATCH 04/17] fix placeholders in the error message (#9060) --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 4d22aa2fd909b..4b3edc9057bc4 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1045,7 +1045,7 @@ pulls.rebase_merge_commit_pull_request = Rebase and Merge (--no-ff) pulls.squash_merge_pull_request = Squash and Merge pulls.invalid_merge_option = You cannot use this merge option for this pull request. pulls.merge_conflict = Merge Failed: There was a conflict whilst merging: %[1]s
%[2]s
Hint: Try a different strategy -pulls.rebase_conflict = Merge Failed: There was a conflict whilst rebasing commit: %s[1]
%[1]s
%[2]s
Hint:Try a different strategy +pulls.rebase_conflict = Merge Failed: There was a conflict whilst rebasing commit: %[1]s
%[2]s
%[3]s
Hint:Try a different strategy pulls.unrelated_histories = Merge Failed: The merge head and base do not share a common history. Hint: Try a different strategy pulls.merge_out_of_date = Merge Failed: Whilst generating the merge, the base was updated. Hint: Try again. pulls.open_unmerged_pull_exists = `You cannot perform a reopen operation because there is a pending pull request (#%d) with identical properties.` From af7f08bca87852d453848be93e2044e697820b87 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Tue, 19 Nov 2019 07:37:59 +0000 Subject: [PATCH 05/17] [skip ci] Updated translations via Crowdin --- options/locale/locale_es-ES.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini index 4dc844fbea660..d1da6b2d0c904 100644 --- a/options/locale/locale_es-ES.ini +++ b/options/locale/locale_es-ES.ini @@ -874,6 +874,7 @@ issues.create_comment=Comentar issues.closed_at=`cerró %[2]s` issues.reopened_at=`reabrió %[2]s` issues.commit_ref_at=`mencionada esta incidencia en un commit %[2]s` +issues.ref_from=`de %[1]s` issues.poster=Autor issues.collaborator=Colaborador issues.owner=Propietario From eb0359cad4b725553c8bca3e95ada9c789c5da0b Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Tue, 19 Nov 2019 12:33:42 -0600 Subject: [PATCH 06/17] Context menus for comments (#9043) * Add quote replies Signed-off-by: jolheiser --- options/locale/locale_en-US.ini | 4 + public/css/index.css | 1 + public/js/index.js | 2 +- public/js/index.js.map | 2 +- templates/repo/diff/comments.tmpl | 9 +-- templates/repo/issue/view_content.tmpl | 8 +- .../repo/issue/view_content/comments.tmpl | 81 +++++++++---------- .../repo/issue/view_content/context_menu.tmpl | 22 +++++ web_src/js/index.js | 40 +++++++-- web_src/less/_repository.less | 4 + 10 files changed, 110 insertions(+), 63 deletions(-) create mode 100644 templates/repo/issue/view_content/context_menu.tmpl diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 4b3edc9057bc4..be644c6ea9a83 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -867,6 +867,10 @@ issues.closed_title = Closed issues.num_comments = %d comments issues.commented_at = `commented %s` issues.delete_comment_confirm = Are you sure you want to delete this comment? +issues.context.copy_link = Copy Link +issues.context.quote_reply = Quote Reply +issues.context.edit = Edit +issues.context.delete = Delete issues.no_content = There is no content yet. issues.close_issue = Close issues.close_comment_issue = Comment and Close diff --git a/public/css/index.css b/public/css/index.css index 21141d78ff2a9..33d1f8046a3f3 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -573,6 +573,7 @@ i.icon.centerlock{top:1.5em} .repository.view.issue .comment-list .comment .tag{color:#767676;margin-top:3px;padding:2px 5px;font-size:12px;border:1px solid rgba(0,0,0,.1);border-radius:3px} .repository.view.issue .comment-list .comment .tag.pending{color:#000;background-color:#fffbb2;margin-left:5px} .repository.view.issue .comment-list .comment .actions .item{float:left} +.repository.view.issue .comment-list .comment .actions .item.context{float:none} .repository.view.issue .comment-list .comment .actions .item.tag{margin-right:5px} .repository.view.issue .comment-list .comment .actions .item.action{margin-top:6px;margin-left:10px} .repository.view.issue .comment-list .comment .content{margin-left:4em} diff --git a/public/js/index.js b/public/js/index.js index eb5fddf5716b7..21a3d0be21dfc 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,2 +1,2 @@ -!function(e){function t(t){for(var n,i,o=t[0],r=t[1],c=0,l=[];c=0;--o){var r=this.tryEntries[o],c=r.completion;if("root"===r.tryLoc)return i("end");if(r.tryLoc<=this.prev){var s=a.call(r,"catchLoc"),l=a.call(r,"finallyLoc");if(s&&l){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var i=a.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,a){return this.delegate={iterator:T(e),resultName:n,nextLoc:a},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=a}catch(e){Function("r","regeneratorRuntime = r")(a)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],a=!0,i=!1,o=void 0;try{for(var r,c=e[Symbol.iterator]();!(a=(r=c.next()).done)&&(n.push(r.value),!t||n.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{a||null==c.return||c.return()}finally{if(i)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t,n){"use strict";n.r(t);n(3);var a,i,o,r,c,s=n(0),l=n.n(s),d=n(1),u=n.n(d);function h(e){return jQuery("
").text(e).html()}function f(e){var t=e.find(".tabular.menu");t.find(".item").tab(),t.find('.item[data-tab="'.concat(t.data("preview"),'"]')).click((function(){var n=$(this);$.post(n.data("url"),{_csrf:a,mode:"gfm",context:n.data("context"),text:e.find('.tab.segment[data-tab="'.concat(t.data("write"),'"] textarea')).val()},(function(n){var a=e.find('.tab.segment[data-tab="'.concat(t.data("preview"),'"]'));a.html(n),emojify.run(a[0]),$("pre code",a[0]).each((function(){hljs.highlightBlock(this)}))}))})),x()}function p(){var e,t;0!==$(".edit.form").length&&(!function(e){var t=e.find(".tabular.menu");t.find(".item").tab();var n=t.find('.item[data-tab="'.concat(t.data("preview"),'"]'));n.length&&(o=n.data("preview-file-modes").split(","),n.click((function(){var n=$(this);$.post(n.data("url"),{_csrf:a,mode:"gfm",context:n.data("context"),text:e.find('.tab.segment[data-tab="'.concat(t.data("write"),'"] textarea')).val()},(function(n){var a=e.find('.tab.segment[data-tab="'.concat(t.data("preview"),'"]'));a.html(n),emojify.run(a[0]),$("pre code",a[0]).each((function(){hljs.highlightBlock(this)}))}))})))}($(".edit.form")),e=$(".edit.form"),(t=e.find(".tabular.menu")).find(".item").tab(),t.find('.item[data-tab="'.concat(t.data("diff"),'"]')).click((function(){var n=$(this);$.post(n.data("url"),{_csrf:a,context:n.data("context"),content:e.find('.tab.segment[data-tab="'.concat(t.data("write"),'"] textarea')).val()},(function(n){var a=e.find('.tab.segment[data-tab="'.concat(t.data("diff"),'"]'));a.html(n),emojify.run(a[0])}))})))}function m(e,t,n,i){return new Promise((function(o){$.ajax({type:"POST",url:e,data:{_csrf:a,action:t,issue_ids:n,id:i},success:o})}))}function v(){window.location.reload()}function g(e){e.each((function(){var e=this;e.addEventListener("paste",(function(t){!function(e,t){if(e.clipboardData){var n=e.clipboardData.items;if(void 0!==n)for(var a=0;a')).val(a.uuid);$(".files").append(o)}))}))}),!1)}))}function b(){var e;0!==$(".comment.form").length&&((e=$(".ui.select-branch")).find(".reference-list-menu").find(".item:not(.no-select)").click((function(){var t=$(this).data("id");$($(this).data("id-selector")).val(t),e.find(".ui .branch-name").text(t)})),e.find(".reference.column").click((function(){return e.find(".scrolling.reference-list-menu").css("display","none"),e.find(".reference .text").removeClass("black"),$($(this).data("target")).css("display","block"),$(this).find(".text").addClass("black"),!1})),f($(".comment.form")),g($(".comment.form textarea")),t("select-label","labels"),t("select-assignees","assignees"),t("select-assignees-modify","assignees"),n(".select-milestone","#milestone_id"),n(".select-assignee","#assignee_id"));function t(e,t){var n=$(".ui.".concat(t,".list")),a=n.find(".no-select"),i=$(".".concat(e," .menu")),o="update"===i.data("action"),r={};$(".".concat(e)).dropdown("setting","onHide",(function(){if(o="update"===i.data("action")){var e=[];Object.keys(r).forEach((function(t){var n=r[t],a=m(n["update-url"],n.action,n["issue-id"],t);e.push(a)})),Promise.all(e).then(v)}})),i.find(".item:not(.no-select)").click((function(){if("select-assignees-modify"===e)return $(this).hasClass("checked")?($(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check")):($(this).addClass("checked"),$(this).find(".octicon").addClass("octicon-check")),m(i.data("update-url"),"",i.data("issue-id"),$(this).data("id")),i.data("action","update"),!1;$(this).hasClass("checked")?($(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check"),o&&($(this).data("id")in r?delete r[$(this).data("id")]:r[$(this).data("id")]={"update-url":i.data("update-url"),action:"detach","issue-id":i.data("issue-id")})):($(this).addClass("checked"),$(this).find(".octicon").addClass("octicon-check"),o&&($(this).data("id")in r?delete r[$(this).data("id")]:r[$(this).data("id")]={"update-url":i.data("update-url"),action:"attach","issue-id":i.data("issue-id")}));var t=[];return $(this).parent().find(".item").each((function(){$(this).hasClass("checked")?(t.push($(this).data("id")),$($(this).data("id-selector")).removeClass("hide")):$($(this).data("id-selector")).addClass("hide")})),0===t.length?a.removeClass("hide"):a.addClass("hide"),$($(this).parent().data("id")).val(t.join(",")),!1})),i.find(".no-select.item").click((function(){(o||"select-assignees-modify"===e)&&m(i.data("update-url"),"clear",i.data("issue-id"),"").then(v),$(this).parent().find(".item").each((function(){$(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check")})),n.find(".item").each((function(){$(this).addClass("hide")})),a.removeClass("hide"),$($(this).parent().data("id")).val("")}))}function n(e,t){var n=$("".concat(e," .menu")),a=$(".ui".concat(e,".list")),i="update"===n.data("action");n.find(".item:not(.no-select)").click((function(){switch($(this).parent().find(".item").each((function(){$(this).removeClass("selected active")})),$(this).addClass("selected active"),i&&m(n.data("update-url"),"",n.data("issue-id"),$(this).data("id")).then(v),t){case"#milestone_id":a.find(".selected").html('')).val(t.uuid);c.append(n)})),this.on("removedfile",(function(e){e.name in s&&($("#".concat(s[e.name].uuid)).remove(),r.data("remove-url")&&r.data("csrf")&&!s[e.name].submitted&&$.post(r.data("remove-url"),{file:s[e.name].uuid,_csrf:r.data("csrf")}))})),this.on("submit",(function(){$.each(s,(function(e){s[e].submitted=!0}))})),this.on("reload",(function(){$.getJSON(n.data("attachment-url"),(function(e){var t=r.get(0).dropzone;t.removeAllFiles(!0),c.empty(),$.each(e,(function(){var e="".concat(r.data("upload-url"),"/").concat(this.uuid);t.emit("addedfile",this),t.emit("thumbnail",this,e),t.emit("complete",this),t.files.push(this),s[this.name]={submitted:!0,uuid:this.uuid},r.find("img[src='".concat(e,"']")).css("max-width","100%");var n=$('')).val(this.uuid);c.append(n)}))}))}))}}),r.get(0).dropzone.emit("reload")}var l=n.find(".ui.comment.form"),d=l.find(".tabular.menu");d.attr("data-write",n.data("write")),d.attr("data-preview",n.data("preview")),d.find(".write.item").attr("data-tab",n.data("write")),d.find(".preview.item").attr("data-tab",n.data("preview")),l.find(".write.segment").attr("data-tab",n.data("write")),l.find(".preview.segment").attr("data-tab",n.data("preview")),f(l),n.find(".cancel.button").click((function(){i.show(),n.hide(),r.get(0).dropzone.emit("reload")})),n.find(".save.button").click((function(){i.show(),n.hide();var o=c.find("[name=files]").map((function(){return $(this).val()})).get();$.post(n.data("update-url"),{_csrf:a,content:e.val(),context:n.data("context"),files:o},(function(e){0===e.length?i.html($("#no-content").html()):(i.html(e.content),emojify.run(i[0]),$("pre code",i[0]).each((function(){hljs.highlightBlock(this)})));var n=t.parent();n.find(".ui.small.images").length?""===e.attachments?n.find(".ui.small.images").parent().remove():n.find(".ui.small.images").html(e.attachments):""!==e.attachments&&(n.append('
'),n.find(".ui.small.images").html(e.attachments)),r.get(0).dropzone.emit("submit"),r.get(0).dropzone.emit("reload")}))}))}else e=t.find("textarea");return n.show(),i.hide(),0===e.val().length&&e.val(o.text()),e.focus(),!1})),$(".delete-comment").click((function(){var e=$(this);return window.confirm(e.data("locale"))&&$.post(e.data("url"),{_csrf:a}).success((function(){$("#".concat(e.data("comment-id"))).remove()})),!1}));var r=$("#status-button");$("#comment-form .edit_area").keyup((function(){0===$(this).val().length?r.text(r.data("status")):r.text(r.data("status-and-comment"))})),r.click((function(){$("#status").val(r.data("status-val")),$("#comment-form").submit()}));var c=$(".merge-button > button");c.on("click",(function(e){e.preventDefault(),$(".".concat($(this).data("do"),"-fields")).show(),$(this).parent().hide()})),$(".merge-button > .dropdown").dropdown({onChange:function(e,t,n){n.data("do")&&(c.find(".button-text").text(n.text()),c.data("do",n.data("do")))}}),$(".merge-cancel").on("click",(function(e){e.preventDefault(),$(this).closest(".form").hide(),c.parent().show()})),function e(t){var n="";t||(t=$(document),n=".reactions > "),t.find("".concat(n,"a.label")).popup({position:"bottom left",metadata:{content:"title",title:"none"}}),t.find(".select-reaction > .menu > .item, ".concat(n,"a.label")).on("click",(function(t){var n=this;if(t.preventDefault(),!$(this).hasClass("disabled")){var i=$(this).hasClass("item")?$(this).closest(".select-reaction").data("action-url"):$(this).data("action-url"),o="".concat(i,"/").concat($(this).hasClass("blue")?"unreact":"react");$.ajax({type:"POST",url:o,data:{_csrf:a,content:$(this).data("content")}}).done((function(t){if(t&&(t.html||t.empty)){var a=$(n).closest(".content"),i=a.find(".segment.reactions");if(!t.empty&&i.length>0&&i.remove(),!t.empty){i=$('
');var o=a.find(".segment.bottom:first");o.length>0?i.insertBefore(o):i.appendTo(a),i.html(t.html);for(var r=i.find(".has-emoji"),c=0;c0&&$(".diff-counter").each((function(){var e=$(this),t=e.find("span[data-line].add").data("line"),n=e.find("span[data-line].del").data("line"),a=parseFloat(t)/(parseFloat(t)+parseFloat(n))*100;e.find(".bar .add").css("width","".concat(a,"%"))})),$("#repo-clone-ssh").click((function(){$(".clone-url").text($(this).data("link")),$("#repo-clone-url").val($(this).data("link")),$(this).addClass("blue"),$("#repo-clone-https").removeClass("blue"),localStorage.setItem("repo-clone-protocol","ssh")})),$("#repo-clone-https").click((function(){$(".clone-url").text($(this).data("link")),$("#repo-clone-url").val($(this).data("link")),$(this).addClass("blue"),$("#repo-clone-ssh").removeClass("blue"),localStorage.setItem("repo-clone-protocol","https")})),$("#repo-clone-url").click((function(){$(this).select()}));var s=$(".repository.compare.pull");s.length>0&&(l(".choose.branch .dropdown"),s.find("button.show-form").on("click",(function(e){e.preventDefault(),s.find(".pullrequest-form").show(),$(this).parent().hide()}))),$(".repository.settings.branches").length>0&&(l(".protected-branches .dropdown"),$(".enable-protection, .enable-whitelist").change((function(){this.checked?$($(this).data("target")).removeClass("disabled"):$($(this).data("target")).addClass("disabled")})))}function l(e){var t=$(e);t.dropdown({fullTextSearch:!0,selectOnKeydown:!1,onChange:function(e,t,n){n.data("url")&&(window.location.href=n.data("url"))},message:{noResults:t.data("no-results")}})}}function y(e){var t=Math.floor(Math.random()*Math.floor(1e6));return e.attr("data-write",e.attr("data-write")+t),e.attr("data-preview",e.attr("data-preview")+t),e.find(".item").each((function(){var e=$(this).attr("data-tab")+t;$(this).attr("data-tab",e)})),e.parent().find("*[data-tab='write']").attr("data-tab","write".concat(t)),e.parent().find("*[data-tab='preview']").attr("data-tab","preview".concat(t)),f(e.parent(".form")),t}function k(){$(".access-mode.menu .item").click((function(){var e=$(this).parent();$.post(e.data("url"),{_csrf:a,uid:e.data("uid"),mode:$(this).data("value")})}))}function _(){$(".js-quick-pull-choice-option").change((function(){"commit-to-new-branch"===$(this).val()?($(".quick-pull-branch-name").show(),$(".quick-pull-branch-name input").prop("required",!0)):($(".quick-pull-branch-name").hide(),$(".quick-pull-branch-name input").prop("required",!1)),$("#commit-button").text($(this).attr("button_text"))}));var e=$("#file-name");e.keyup((function(e){var t,n,a=$(".breadcrumb span.section"),i=$(".breadcrumb div.divider");if(8===e.keyCode&&0===$(this).getCursorPosition()&&a.length>0&&(t=a.last().find("a").text(),$(this).val(t+$(this).val()),$(this)[0].setSelectionRange(t.length,t.length),a.last().remove(),i.last().remove()),191===e.keyCode){n=$(this).val().split("/");for(var o=0;o
'.concat(t,"")).insertBefore($(this)),$('
/
').insertBefore($(this))):$(this).val(t),$(this)[0].setSelectionRange(0,0)}n=[],$(".breadcrumb span.section").each((function(){var e=$(this);e.find("a").length?n.push(e.find("a").text()):n.push(e.text())})),$(this).val()&&n.push($(this).val()),$("#tree_path").val(n.join("/"))})).trigger("keyup");var t=$(".repository.editor textarea#edit_area");if(t.length){var n=t.data("markdown-file-exts").split(","),i=t.data("line-wrap-extensions").split(",");e.on("keyup",(function(){var s,l,d,u,h,f,p=e.val();d=u="";var m=/.+\.([^.]+)$/.exec(p);m&&(d=m[1],u=".".concat(d));var v=CodeMirror.findModeByExtension(d),g=$("a[data-tab=preview]");if(v?(s=v.mode,l=v.mime,f=s):f=d,g.length&&f&&o&&o.length&&o.indexOf(f)>=0?(h=g.data("url"),g.data("url",h.replace(/(.*)\/.*/i,"$1/".concat(s))),g.show()):g.hide(),!(n.indexOf(u)>=0&&function(e){return c&&(c.toTextArea(),c=null),!!r||(r=new SimpleMDE({autoDownloadFontAwesome:!1,element:e[0],forceSync:!0,renderingConfig:{singleLineBreaks:!1},indentWithTabs:!1,tabSize:4,spellChecker:!1,previewRender:function(t,n){return setTimeout((function(){$.post(e.data("url"),{_csrf:a,mode:"gfm",context:e.data("context"),text:t},(function(e){n.innerHTML='
'.concat(e,"
"),emojify.run($(".editor-preview")[0])}))}),0),"Loading..."},toolbar:["bold","italic","strikethrough","|","heading-1","heading-2","heading-3","heading-bigger","heading-smaller","|","code","quote","|","unordered-list","ordered-list","|","link","image","table","horizontal-rule","|","clean-block","preview","fullscreen","side-by-side"]}),!0)}(t))&&(c||function(e){return r&&(r.toTextArea(),r=null),!!c||((c=CodeMirror.fromTextArea(e[0],{lineNumbers:!0})).on("change",(function(t,n){e.val(t.getValue())})),!0)}(t))){s&&(c.setOption("mode",l),CodeMirror.autoLoadMode(c,s)),i.indexOf(u)>=0?c.setOption("lineWrapping",!0):c.setOption("lineWrapping",!1);var b=e.val();0!==b.length&&(b=(b=b.split("/"))[b.length-1],$.getJSON(e.data("ec-url-prefix")+b,(function(e){"tab"===e.indent_style?(c.setOption("indentWithTabs",!0),c.setOption("extraKeys",{})):(c.setOption("indentWithTabs",!1),c.setOption("extraKeys",{Tab:function(e){var t=Array(parseInt(e.getOption("indentUnit"))+1).join(" ");e.replaceSelection(t)}})),c.setOption("indentUnit",e.indent_size||4),c.setOption("tabSize",e.tab_width||4)})))}})).trigger("keyup");var s=$("#commit-button"),l=$(".ui.edit.form");s.prop("disabled",!0),l.areYouSure({silent:!0,dirtyClass:"dirty-file",fieldSelector:":input:not(.commit-form-wrapper :input)",change:function(){var e=$(this).hasClass("dirty-file");s.prop("disabled",!e)}}),s.click((function(e){0===t.val().length&&($("#edit-empty-content-modal").modal({onApprove:function(){$(".edit.form").submit()}}).modal("show"),e.preventDefault())}))}}function C(){$(".user.settings.profile").length>0&&$("#username").keyup((function(){var e=$("#name-change-prompt");$(this).val().toString().toLowerCase()!==$(this).data("name").toString().toLowerCase()?e.show():e.hide()}))}function x(){$(".ui.button").keypress((function(e){13!==e.keyCode&&32!==e.keyCode||$(this).click()}))}function S(){$(".code-view .linenums").length>0&&($(document).on("click",".lines-num span",(function(e){var t=$(this),n=t.parent().siblings(".lines-code").find("ol.linenums > li");A(n,n.filter("[rel=".concat(t.attr("id"),"]")),e.shiftKey?n.filter(".active").eq(0):null),window.getSelection?window.getSelection().removeAllRanges():document.selection.empty()})),$(window).on("hashchange",(function(){var e,t=window.location.hash.match(/^#(L\d+)-(L\d+)$/),n=$(".code-view ol.linenums > li");if(t)return e=n.filter(".".concat(t[1])),A(n,e,n.filter(".".concat(t[2]))),void $("html, body").scrollTop(e.offset().top-200);(t=window.location.hash.match(/^#(L|n)(\d+)$/))&&(e=n.filter(".L".concat(t[2])),A(n,e),$("html, body").scrollTop(e.offset().top-200))})).trigger("hashchange")),$(".ui.fold-code").on("click",(function(e){var t=$(e.target);t.hasClass("fa-chevron-down")?$(e.target).parent().next().slideUp("fast",(function(){t.removeClass("fa-chevron-down").addClass("fa-chevron-right")})):$(e.target).parent().next().slideDown("fast",(function(){t.removeClass("fa-chevron-right").addClass("fa-chevron-down")}))})),$(".ui.blob-excerpt").on("click",(function(e){!function e(t){var n=$(t.target),a=n.parent().parent();$.get("".concat(n.data("url"),"?").concat(n.data("query"),"&anchor=").concat(n.data("anchor")),(function(t){a.replaceWith(t),$('[data-anchor="'.concat(n.data("anchor"),'"]')).on("click",(function(t){e(t)}))}))}(e)}))}function q(e){$.ajax({url:"".concat(i,"/user/u2f/sign"),type:"POST",headers:{"X-Csrf-Token":a},data:JSON.stringify(e),contentType:"application/json; charset=utf-8"}).done((function(e){window.location.replace(e)})).fail((function(){L(1)}))}function T(e){(function(e){if(!("errorCode"in e))return!1;if(0===e.errorCode)return!1;return L(e.errorCode),!0})(e)||$.ajax({url:"".concat(i,"/user/settings/security/u2f/register"),type:"POST",headers:{"X-Csrf-Token":a},data:JSON.stringify(e),contentType:"application/json; charset=utf-8",success:function(){v()},fail:function(){L(1)}})}function L(e){var t={browser:$("#unsupported-browser"),1:$("#u2f-error-1"),2:$("#u2f-error-2"),3:$("#u2f-error-3"),4:$("#u2f-error-4"),5:$(".u2f-error-5")};t[e].removeClass("hide"),Object.keys(t).forEach((function(n){n!==e&&t[n].addClass("hide")})),$("#u2f-error").modal("show")}function O(){$.post("".concat(i,"/user/settings/security/u2f/request_register"),{_csrf:a,name:$("#nickname").val()}).success((function(e){$("#nickname").closest("div.field").removeClass("error"),$("#register-device").modal("show"),null===e.registeredKeys&&(e.registeredKeys=[]),u2fApi.register(e.appId,e.registerRequests,e.registeredKeys,30).then(T).catch((function(e){L(void 0!==e?e.metaData.code:1)}))})).fail((function(e){409===e.status&&$("#nickname").closest("div.field").addClass("error")}))}function j(e){window.history.pushState?window.history.pushState(null,null,e):window.location.hash=e}function A(e,t,n){if(e.removeClass("active"),n){var a,i=parseInt(t.attr("rel").substr(1)),o=parseInt(n.attr("rel").substr(1));if(i!==o){i>o&&(a=i,i=o,o=a);for(var r=[],c=i;c<=o;c++)r.push(".L".concat(c));return e.filter(r.join(",")).addClass("active"),void j("#L".concat(i,"-L").concat(o))}}t.addClass("active"),j("#".concat(t.attr("rel")))}function D(){var e=$(this),t="";e.attr("id")&&(t+="#".concat(e.attr("id")));var n=$(".delete.modal".concat(t));return n.find(".name").text(e.data("name")),n.modal({closable:!1,onApprove:function(){"form"!==e.data("type")?$.post(e.data("url"),{_csrf:a,id:e.data("id")}).done((function(e){window.location.href=e.redirect})):$(e.data("form")).submit()}}).modal("show"),!1}function F(){var e=$(this),t="";e.attr("id")&&(t+="#".concat(e.attr("id")));var n=$(".addall.modal".concat(t));return n.find(".name").text(e.data("name")),n.modal({closable:!1,onApprove:function(){"form"!==e.data("type")?$.post(e.data("url"),{_csrf:a,id:e.data("id")}).done((function(e){window.location.href=e.redirect})):$(e.data("form")).submit()}}).modal("show"),!1}$((function(){var e,t,a,i,o;return l.a.async((function(r){for(;;)switch(r.prev=r.next){case 0:if(e=document.getElementById("graph-canvas")){r.next=3;break}return r.abrupt("return");case 3:return r.next=5,l.a.awrap(Promise.all([n.e(0).then(n.bind(null,12)),n.e(0).then(n.t.bind(null,13,7))]));case 5:t=r.sent,a=u()(t,1),i=a[0].default,o=[],$("#graph-raw-list li span.node-relation").each((function(){o.push($(this).text())})),i(e,o);case 11:case"end":return r.stop()}}))})),"undefined"!=typeof Dropzone&&(Dropzone.autoDiscover=!1),$.fn.getCursorPosition=function(){var e=$(this).get(0),t=0;if("selectionStart"in e)t=e.selectionStart;else if("selection"in document){e.focus();var n=document.selection.createRange(),a=document.selection.createRange().text.length;n.moveStart("character",-e.value.length),t=n.text.length-a}return t},$(document).ready((function(){if(a=$("meta[name=_csrf]").attr("content"),i=$("meta[name=_suburl]").attr("content"),$(".time-since").each((function(){$(this).addClass("poping up").attr("data-content",$(this).attr("title")).attr("data-variation","inverted tiny").attr("title","")})),$(".dropdown:not(.custom)").dropdown(),$(".jump.dropdown").dropdown({action:"hide",onShow:function(){$(".poping.up").popup("hide")}}),$(".slide.up.dropdown").dropdown({transition:"slide up"}),$(".upward.dropdown").dropdown({direction:"upward"}),$(".ui.accordion").accordion(),$(".ui.checkbox").checkbox(),$(".ui.progress").progress({showActivity:!1}),$(".poping.up").popup(),$(".top.menu .poping.up").popup({onShow:function(){if($(".top.menu .menu.transition").hasClass("visible"))return!1}}),$(".tabular.menu .item").tab(),$(".tabable.menu .item").tab(),$(".toggle.button").click((function(){$($(this).data("target")).slideToggle(100)})),$("tr[data-href]").click((function(){window.location=$(this).data("href")})),"undefined"!=typeof hljs)for(var e=[].slice.call(document.querySelectorAll("pre code")||[]),t=0;t0){var o={};new Dropzone("#dropzone",{url:n.data("upload-url"),headers:{"X-Csrf-Token":a},maxFiles:n.data("max-file"),maxFilesize:n.data("max-size"),acceptedFiles:"*/*"===n.data("accepts")?null:n.data("accepts"),addRemoveLinks:!0,dictDefaultMessage:n.data("default-message"),dictInvalidFileType:n.data("invalid-input-type"),dictFileTooBig:n.data("file-too-big"),dictRemoveFile:n.data("remove-file"),init:function(){this.on("success",(function(e,t){o[e.name]=t.uuid;var n=$('')).val(t.uuid);$(".files").append(n)})),this.on("removedfile",(function(e){e.name in o&&$("#".concat(o[e.name])).remove(),n.data("remove-url")&&n.data("csrf")&&$.post(n.data("remove-url"),{file:o[e.name],_csrf:n.data("csrf")})}))}})}emojify.setConfig({img_dir:"".concat(i,"/vendor/plugins/emojify/images"),ignore_emoticons:!0});for(var r=document.getElementsByClassName("has-emoji"),c=0;c0&&(a="".concat(n,"-").concat(e[n])),void 0===e[n]?e[n]=1:e[n]+=1,(t=t.wrap('
'))).append(''))}))})),$(".issue-checkbox").click((function(){$(".issue-checkbox").children("input:checked").length>0?($("#issue-filters").addClass("hide"),$("#issue-actions").removeClass("hide")):($("#issue-filters").removeClass("hide"),$("#issue-actions").addClass("hide"))})),$(".issue-action").click((function(){var e=this.dataset.action,t=this.dataset.elementId,n=$(".issue-checkbox").children("input:checked").map((function(){return this.dataset.issueId})).get().join(),a=this.dataset.url;"0"===t&&"/assignee"===a.substr(-9)&&(t="",e="clear"),m(a,e,n,t).then((function(){"close"!==e&&"open"!==e||$('.issue-checkbox input[type="checkbox"]').each((function(e,t){t.checked=!1})),v()}))})),$('.issue-checkbox input[type="checkbox"]:checked').first().each((function(e,t){t.checked=!1,$(t).click()})),x(),$("#search-user-box").search({minCharacters:2,apiSettings:{url:"".concat(i,"/api/v1/users/search?q={query}"),onResponse:function(e){var t=[];return $.each(e.data,(function(e,n){var a=n.login;n.full_name&&n.full_name.length>0&&(a+=" (".concat(h(n.full_name),")")),t.push({title:a,image:n.avatar_url})})),{results:t}}},searchFields:["login","full_name"],showNoResults:!1}),(l=$("#search-team-box")).search({minCharacters:2,apiSettings:{url:"".concat(i,"/api/v1/orgs/").concat(l.data("org"),"/teams/search?q={query}"),headers:{"X-Csrf-Token":a},onResponse:function(e){var t=[];return $.each(e.data,(function(e,n){var a="".concat(n.name," (").concat(n.permission," access)");t.push({title:a})})),{results:t}}},searchFields:["name","description"],showNoResults:!1}),(d=$("#search-repo-box")).search({minCharacters:2,apiSettings:{url:"".concat(i,"/api/v1/repos/search?q={query}&uid=").concat(d.data("uid")),onResponse:function(e){var t=[];return $.each(e.data,(function(e,n){t.push({title:n.full_name.split("/")[1],description:n.full_name})})),{results:t}}},searchFields:["full_name"],showNoResults:!1}),b(),0!==$(".install").length&&(""===$("#db_host").val()&&($("#db_host").val("127.0.0.1:3306"),$("#db_user").val("gitea"),$("#db_name").val("gitea")),$("#db_type").change((function(){var e=$(this).val();if("SQLite3"===e)return $("#sql_settings").hide(),$("#pgsql_settings").hide(),$("#mysql_settings").hide(),$("#sqlite_settings").show(),void("SQLite3"===e&&"data/gitea_tidb"===$("#db_path").val()&&$("#db_path").val("data/gitea.db"));var t={MySQL:"127.0.0.1:3306",PostgreSQL:"127.0.0.1:5432",MSSQL:"127.0.0.1:1433"};$("#sqlite_settings").hide(),$("#sql_settings").show(),$("#pgsql_settings").toggle("PostgreSQL"===e),$("#mysql_settings").toggle("MySQL"===e),$.each(t,(function(n,a){if($("#db_host").val()===a)return $("#db_host").val(t[e]),!1}))})),$("#offline-mode input").change((function(){$(this).is(":checked")&&($("#disable-gravatar").checkbox("check"),$("#federated-avatar-lookup").checkbox("uncheck"))})),$("#disable-gravatar input").change((function(){$(this).is(":checked")?$("#federated-avatar-lookup").checkbox("uncheck"):$("#offline-mode").checkbox("uncheck")})),$("#federated-avatar-lookup input").change((function(){$(this).is(":checked")&&($("#disable-gravatar").checkbox("uncheck"),$("#offline-mode").checkbox("uncheck"))})),$("#enable-openid-signin input").change((function(){$(this).is(":checked")?$("#disable-registration input").is(":checked")||$("#enable-openid-signup").checkbox("check"):$("#enable-openid-signup").checkbox("uncheck")})),$("#disable-registration input").change((function(){$(this).is(":checked")?($("#enable-captcha").checkbox("uncheck"),$("#enable-openid-signup").checkbox("uncheck")):$("#enable-openid-signup").checkbox("check")})),$("#enable-captcha input").change((function(){$(this).is(":checked")&&$("#disable-registration").checkbox("uncheck")}))),w(),(u=function(){var e=$("#auth_username").val(),t=$("#clone_addr").val();!$("#mirror").is(":checked")&&e&&e.length>0&&void 0!==t&&(t.startsWith("https://github.com")||t.startsWith("http://github.com"))?$("#migrate_items").show():$("#migrate_items").hide()})(),$("#clone_addr").on("input",u),$("#auth_username").on("input",u),$("#mirror").on("change",u),function(){var e=$(".repository.wiki textarea#edit_area"),t=0,n=null;if(e.length>0){var i=new SimpleMDE({autoDownloadFontAwesome:!1,element:e[0],forceSync:!0,previewRender:function(o,r){return setTimeout((function(){var c=function(){t=0,null!=n&&(clearTimeout(n),n=null),$.post(e.data("url"),{_csrf:a,mode:"gfm",context:e.data("context"),text:o},(function(e){r.innerHTML='
'.concat(e,"
"),emojify.run($(".editor-preview")[0]),$(r).find("pre code").each((function(e,t){hljs.highlightBlock(t)}))}))};i.isSideBySideActive()?(++t>10&&c(),null!=n&&(clearTimeout(n),n=null),n=setTimeout(c,600)):c()}),0),i.isSideBySideActive()?r.innerHTML:"Loading..."},renderingConfig:{singleLineBreaks:!1},indentWithTabs:!1,tabSize:4,spellChecker:!1,toolbar:["bold","italic","strikethrough","|","heading-1","heading-2","heading-3","heading-bigger","heading-smaller","|",{name:"code-inline",action:function(e){var t=e.codemirror,n=t.getSelection();if(t.replaceSelection("`".concat(n,"`")),!n){var a=t.getCursor();t.setCursor(a.line,a.ch-1)}t.focus()},className:"fa fa-angle-right",title:"Add Inline Code"},"code","quote","|",{name:"checkbox-empty",action:function(e){var t=e.codemirror;t.replaceSelection("\n- [ ] ".concat(t.getSelection())),t.focus()},className:"fa fa-square-o",title:"Add Checkbox (empty)"},{name:"checkbox-checked",action:function(e){var t=e.codemirror;t.replaceSelection("\n- [x] ".concat(t.getSelection())),t.focus()},className:"fa fa-check-square-o",title:"Add Checkbox (checked)"},"|","unordered-list","ordered-list","|","link","image","table","horizontal-rule","|","clean-block","preview","fullscreen","side-by-side"]});$(i.codemirror.getInputField()).addClass("js-quick-submit"),setTimeout((function(){var e=$('.repository.wiki.new .previewtabs a[data-tab="write"]'),n=$('.repository.wiki.new .previewtabs a[data-tab="preview"]'),a=$(".editor-toolbar"),i=$(".editor-toolbar a.fa-eye"),o=$(".editor-toolbar a.fa-columns");e.on("click",(function(){a.hasClass("disabled-for-preview")&&i.click()})),n.on("click",(function(){a.hasClass("disabled-for-preview")||i.click()})),i.on("click",(function(){setTimeout((function(){a.hasClass("disabled-for-preview")?(e.hasClass("active")&&e.removeClass("active"),n.hasClass("active")||n.addClass("active")):(e.hasClass("active")||e.addClass("active"),n.hasClass("active")&&n.removeClass("active"))}),0)})),o.on("click",(function(){t=10}))}),0)}}(),p(),_(),0!==$(".organization").length&&$(".organization.settings.options").length>0&&$("#org_name").keyup((function(){var e=$("#org-name-change-prompt");$(this).val().toString().toLowerCase()!==$(this).data("org-name").toString().toLowerCase()?e.show():e.hide()})),0!==$(".edit.githook").length&&CodeMirror.autoLoadMode(CodeMirror.fromTextArea($("#content")[0],{lineNumbers:!0,mode:"shell"}),"shell"),function(){if(0!==$(".new.webhook").length){$(".events.checkbox input").change((function(){$(this).is(":checked")&&$(".events.fields").show()})),$(".non-events.checkbox input").change((function(){$(this).is(":checked")&&$(".events.fields").hide()}));var e=function(){var e="POST"===$("#http_method").val();$("#content_type").parent().parent()[e?"show":"hide"]()};e(),$("#http_method").change((function(){e()})),$("#test-delivery").click((function(){var e=$(this);e.addClass("loading disabled"),$.post(e.data("link"),{_csrf:a}).done(setTimeout((function(){window.location.href=e.data("redirect")}),5e3))}))}}(),function(){if(0!==$(".admin").length){if(($(".admin.new.user").length>0||$(".admin.edit.user").length>0)&&$("#login_type").change((function(){"0"===$(this).val().substring(0,1)?($("#login_name").removeAttr("required"),$(".non-local").hide(),$(".local").show(),$("#user_name").focus(),"required"===$(this).data("password")&&$("#password").attr("required","required")):($("#login_name").attr("required","required"),$(".non-local").show(),$(".local").hide(),$("#login_name").focus(),$("#password").removeAttr("required"))})),$(".admin.new.authentication").length>0&&($("#auth_type").change((function(){$(".ldap, .dldap, .smtp, .pam, .oauth2, .has-tls .search-page-size").hide(),$(".ldap input[required], .binddnrequired input[required], .dldap input[required], .smtp input[required], .pam input[required], .oauth2 input[required], .has-tls input[required]").removeAttr("required"),$(".binddnrequired").removeClass("required");var e=$(this).val();switch(e){case"2":$(".ldap").show(),$(".binddnrequired input, .ldap div.required:not(.dldap) input").attr("required","required"),$(".binddnrequired").addClass("required");break;case"3":$(".smtp").show(),$(".has-tls").show(),$(".smtp div.required input, .has-tls").attr("required","required");break;case"4":$(".pam").show(),$(".pam input").attr("required","required");break;case"5":$(".dldap").show(),$(".dldap div.required:not(.ldap) input").attr("required","required");break;case"6":$(".oauth2").show(),$(".oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input").attr("required","required"),r()}"2"!==e&&"5"!==e||i(),"2"===e&&o()})),$("#auth_type").change(),$("#security_protocol").change(i),$("#use_paged_search").change(o),$("#oauth2_provider").change(r),$("#oauth2_use_custom_url").change(c)),$(".admin.edit.authentication").length>0){var e=$("#auth_type").val();"2"===e||"5"===e?($("#security_protocol").change(i),"2"===e&&$("#use_paged_search").change(o)):"6"===e&&($("#oauth2_provider").change(r),$("#oauth2_use_custom_url").change(c),r())}if($(".admin.notice")){var t=$("#detail-modal");$(".view-detail").click((function(){return t.find(".content p").text($(this).data("content")),t.modal("show"),!1}));var n=$(".select.table .ui.checkbox");$(".select.action").click((function(){switch($(this).data("action")){case"select-all":n.checkbox("check");break;case"deselect-all":n.checkbox("uncheck");break;case"inverse":n.checkbox("toggle")}})),$("#delete-selection").click((function(){var e=$(this);e.addClass("loading disabled");var t=[];n.each((function(){$(this).checkbox("is checked")&&t.push($(this).data("id"))})),$.post(e.data("link"),{_csrf:a,ids:t}).done((function(){window.location.href=e.data("redirect")}))}))}}function i(){$("#security_protocol").val()>0?$(".has-tls").show():$(".has-tls").hide()}function o(){$("#use_paged_search").prop("checked")?$(".search-page-size").show().find("input").attr("required","required"):$(".search-page-size").hide().find("input").removeAttr("required")}function r(){switch($(".open_id_connect_auto_discovery_url, .oauth2_use_custom_url").hide(),$(".open_id_connect_auto_discovery_url input[required]").removeAttr("required"),$("#oauth2_provider").val()){case"github":case"gitlab":case"gitea":$(".oauth2_use_custom_url").show();break;case"openidConnect":$(".open_id_connect_auto_discovery_url input").attr("required","required"),$(".open_id_connect_auto_discovery_url").show()}c()}function c(){var e=$("#oauth2_provider").val();if($(".oauth2_use_custom_url_field").hide(),$(".oauth2_use_custom_url_field input[required]").removeAttr("required"),$("#oauth2_use_custom_url").is(":checked"))switch($("#oauth2_token_url").val()||$("#oauth2_token_url").val($("#".concat(e,"_token_url")).val()),$("#oauth2_auth_url").val()||$("#oauth2_auth_url").val($("#".concat(e,"_auth_url")).val()),$("#oauth2_profile_url").val()||$("#oauth2_profile_url").val($("#".concat(e,"_profile_url")).val()),$("#oauth2_email_url").val()||$("#oauth2_email_url").val($("#".concat(e,"_email_url")).val()),e){case"github":$(".oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input, .oauth2_email_url input").attr("required","required"),$(".oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url, .oauth2_email_url").show();break;case"gitea":case"gitlab":$(".oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input").attr("required","required"),$(".oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url").show(),$("#oauth2_email_url").val("")}}}(),S(),function(){var e=document.getElementById("app");if(!e)return;Vue.component("repo-search",{delimiters:["${","}"],props:{searchLimit:{type:Number,default:10},suburl:{type:String,required:!0},uid:{type:Number,required:!0},organizations:{type:Array,default:[]},isOrganization:{type:Boolean,default:!0},canCreateOrganization:{type:Boolean,default:!1},organizationsTotalCount:{type:Number,default:0},moreReposLink:{type:String,default:""}},data:function(){return{tab:"repos",repos:[],reposTotalCount:0,reposFilter:"all",searchQuery:"",isLoading:!1,repoTypes:{all:{count:0,searchMode:""},forks:{count:0,searchMode:"fork"},mirrors:{count:0,searchMode:"mirror"},sources:{count:0,searchMode:"source"},collaborative:{count:0,searchMode:"collaborative"}}}},computed:{showMoreReposLink:function(){return this.repos.length>0&&this.repos.length'.concat(i[r],"
")).insertBefore(o);A.css("display","none"),N.show()}})).fail((function(t){if(422===t.status)if(t.responseJSON.invalidTopics.length>0){z.formatPrompt=t.responseJSON.message;var n=t.responseJSON.invalidTopics,a=E.children("a.ui.label");e.split(",").forEach((function(e,t){for(var i=0;i]*>?/gm,""),a=!1,i=[];if(E.find("div.label.visible.topic,a.label.visible").each((function(e,t){i.push(t.dataset.value)})),e.topics){for(var o=!1,r=0;r0&&!a?(t.success=!0,t.results.unshift({description:n,"data-value":n})):n.length>0&&a&&t.results.sort((function(e,t){return e.description.toLowerCase()===n.toLowerCase()?-1:t.description.toLowerCase()===n.toLowerCase()?1:e.description>t.description?-1:e.description').concat(h(a.repository.full_name),""),value:a.id})})),t},cache:!1},fullTextSearch:!0}),$(".menu a.label-filter-item").each((function(){$(this).click((function(e){if(e.altKey){e.preventDefault();var t=$(this).attr("href"),n=$(this).data("label-id"),a="labels=(-?[0-9]+%2c)*(".concat(n,")(%2c-?[0-9]+)*&");window.location=t.replace(new RegExp(a),"labels=$1-$2$3&")}}))})),$(".menu .ui.dropdown.label-filter").keydown((function(e){if(e.altKey&&13===e.keyCode){var t=$(".menu .ui.dropdown.label-filter .menu .item.selected");if(t.length>0){var n=$(t[0]),a=n.attr("href"),i=n.data("label-id"),o="labels=(-?[0-9]+%2c)*(".concat(i,")(%2c-?[0-9]+)*&");window.location=a.replace(new RegExp(o),"labels=$1-$2$3&")}}}))}(),$(".title_wip_desc > a").click((function(e){e.preventDefault();var t=$("#issue_title");t.focus();var n=t.val().trim().toUpperCase();for(var a in wipPrefixes)if(n.startsWith(wipPrefixes[a].toUpperCase()))return;t.val("".concat(wipPrefixes[0]," ").concat(t.val()))})),$(".show-outdated").on("click",(function(e){e.preventDefault();var t=$(this).data("comment");$(this).addClass("hide"),$("#code-comments-".concat(t)).removeClass("hide"),$("#code-preview-".concat(t)).removeClass("hide"),$("#hide-outdated-".concat(t)).removeClass("hide")})),$(".hide-outdated").on("click",(function(e){e.preventDefault();var t=$(this).data("comment");$(this).addClass("hide"),$("#code-comments-".concat(t)).addClass("hide"),$("#code-preview-".concat(t)).addClass("hide"),$("#show-outdated-".concat(t)).removeClass("hide")})),$("button.comment-form-reply").on("click",(function(e){e.preventDefault(),$(this).hide();var t=$(this).parent().find(".comment-form");t.removeClass("hide"),y(t.find(".menu"))})),0!==$(".repository.pull.diff").length&&($(".diff-detail-box.ui.sticky").sticky(),$(".btn-review").on("click",(function(e){e.preventDefault(),$(this).closest(".dropdown").find(".menu").toggle("visible")})).closest(".dropdown").find(".link.close").on("click",(function(e){e.preventDefault(),$(this).closest(".menu").toggle("visible")})),$(".code-view .lines-code,.code-view .lines-num").on("mouseenter",(function(){var e=$(this).closest("td");$(this).closest("tr").addClass(e.hasClass("lines-num-old")||e.hasClass("lines-code-old")?"focus-lines-old":"focus-lines-new")})).on("mouseleave",(function(){$(this).closest("tr").removeClass("focus-lines-new focus-lines-old")})),$(".add-code-comment").on("click",(function(e){if(!$(e.target).hasClass("btn-add-single")){e.preventDefault();var t=$(this).closest(".code-diff").hasClass("code-diff-split"),n=$(this).data("side"),a=$(this).data("idx"),i=$(this).data("path"),o=$("#pull_review_add_comment").html(),r=$(this).closest("tr"),c=r.next();c.hasClass("add-comment")||(c=$(''.concat(t?'':'',"")),r.after(c));var s=c.find(".add-comment-".concat(n)),l=s.find(".comment-code-cloud");0===l.length&&(s.html(o),y((l=s.find(".comment-code-cloud")).find(".menu")),s.find("input[name='line']").val(a),s.find("input[name='side']").val("left"===n?"previous":"proposed"),s.find("input[name='path']").val(i)),l.find("textarea").focus()}}))),function e(){var t=$("#repo_migrating");if($("#repo_migrating_failed").hide(),t){var n=t.attr("repo");if(void 0===n)return;$.ajax({type:"GET",url:"".concat(i,"/").concat(n,"/status"),data:{_csrf:a},complete:function(t){if(200===t.status&&t.responseJSON)return 0===t.responseJSON.status?void window.location.reload():void setTimeout((function(){e()}),2e3);$("#repo_migrating_progress").hide(),$("#repo_migrating_failed").show()}})}}(),function(){var e=$("#repo_template"),t=function(){var t=$("#template_units"),n=$("#non_template");""!==e.val()?(t.show(),n.hide()):(t.hide(),n.show())};e.change(t),t();var n=function(){$("#repo_template_search").dropdown({apiSettings:{url:"".concat(i,"/api/v1/repos/search?q={query}&template=true&priority_owner_id=").concat($("#uid").val()),onResponse:function(e){var t={success:!0,results:[]};return t.results.push({name:"",value:""}),$.each(e.data,(function(e,n){t.results.push({name:h(n.full_name),value:n.id})})),t},cache:!1},fullTextSearch:!0})};$("#uid").change(n),n()}(),$("#repo-clone-url").length>0)switch(localStorage.getItem("repo-clone-protocol")){case"ssh":0===$("#repo-clone-ssh").click().length&&$("#repo-clone-https").click();break;default:$("#repo-clone-https").click()}var J,H={"div.user.settings":C,"div.repository.settings.collaboration":k};for(J in H)if($(J).length>0){H[J]();break}var V=$("#clone_addr");V.change((function(){var e=$("#repo_name");V.val().length>0&&0===e.val().length&&e.val(V.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3])}))})),$((function(){0===$(".user.signin").length&&$("form:not(.ignore-dirty)").areYouSure(),$("#ssh-key-content").on("change paste keyup",(function(){var e=$(this).val().split(" "),t=$("#ssh-key-title");""===t.val()&&3===e.length&&""!==e[2]&&t.val(e[2])}))})),window.timeAddManual=function(){$(".mini.modal").modal({duration:200,onApprove:function(){$("#add_time_manual_form").submit()}}).modal("show")},window.toggleStopwatch=function(){$("#toggle_stopwatch_form").submit()},window.cancelStopwatch=function(){$("#cancel_stopwatch_form").submit()},window.initHeatmap=function(e,t,n){var a=document.getElementById(e);if(a){(n=n||{}).contributions=n.contributions||"contributions",n.no_contributions=n.no_contributions||"No contributions";var i=["${","}"];Vue.component("activity-heatmap",{delimiters:i,props:{user:{type:String,required:!0},suburl:{type:String,required:!0},locale:{type:Object,required:!0}},data:function(){return{isLoading:!0,colorRange:[],endDate:null,values:[],totalContributions:0}},mounted:function(){this.colorRange=[this.getColor(0),this.getColor(1),this.getColor(2),this.getColor(3),this.getColor(4),this.getColor(5)],this.endDate=new Date,this.loadHeatmap(this.user)},methods:{loadHeatmap:function(e){var t=this;$.get("".concat(this.suburl,"/api/v1/users/").concat(e,"/heatmap"),(function(e){for(var n=[],a=0;a

total contributions in the last 12 months

'}),new Vue({delimiters:i,el:a,data:{suburl:document.querySelector("meta[name=_suburl]").content,heatmapUser:t,locale:n}})}},$(".commit-button").click((function(e){e.preventDefault(),$(this).parent().find(".commit-body").toggle()})),window.toggleDeadlineForm=function(){$("#deadlineForm").fadeToggle(150)},window.setDeadline=function(){var e=$("#deadlineDate").val();window.updateDeadline(e)},window.updateDeadline=function(e){$("#deadline-err-invalid-date").hide(),$("#deadline-loader").addClass("loading");var t=null;if(""!==e){var n=Date.parse(e);if(Number.isNaN(n))return $("#deadline-loader").removeClass("loading"),$("#deadline-err-invalid-date").show(),!1;t=new Date(n)}$.ajax("".concat($("#update-issue-deadline-form").attr("action"),"/deadline"),{data:JSON.stringify({due_date:t}),headers:{"X-Csrf-Token":a,"X-Remote":!0},contentType:"application/json",type:"POST",success:function(){v()},error:function(){$("#deadline-loader").removeClass("loading"),$("#deadline-err-invalid-date").show()}})},window.deleteDependencyModal=function(e,t){$(".remove-dependency").modal({closable:!1,duration:200,onApprove:function(){$("#removeDependencyID").val(e),$("#dependencyType").val(t),$("#removeDependencyForm").submit()}}).modal("show")},window.cancelCodeComment=function(e){var t=$(e).closest("form");t.length>0&&t.hasClass("comment-form")?(t.addClass("hide"),t.parent().find("button.comment-form-reply").show()):t.closest(".comment-code-cloud").remove()},window.onOAuthLoginClick=function(){var e=$("#oauth2-login-loader"),t=$("#oauth2-login-navigator");t.hide(),e.removeClass("disabled"),setTimeout((function(){e.addClass("disabled"),t.show()}),5e3)}}]); +!function(e){function t(t){for(var n,i,o=t[0],r=t[1],c=0,l=[];c=0;--o){var r=this.tryEntries[o],c=r.completion;if("root"===r.tryLoc)return i("end");if(r.tryLoc<=this.prev){var s=a.call(r,"catchLoc"),l=a.call(r,"finallyLoc");if(s&&l){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var i=a.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,a){return this.delegate={iterator:T(e),resultName:n,nextLoc:a},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=a}catch(e){Function("r","regeneratorRuntime = r")(a)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],a=!0,i=!1,o=void 0;try{for(var r,c=e[Symbol.iterator]();!(a=(r=c.next()).done)&&(n.push(r.value),!t||n.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{a||null==c.return||c.return()}finally{if(i)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t,n){"use strict";n.r(t);n(3);var a,i,o,r,c,s=n(0),l=n.n(s),d=n(1),u=n.n(d);function h(e){return jQuery("
").text(e).html()}function f(e){var t=e.find(".tabular.menu");t.find(".item").tab(),t.find('.item[data-tab="'.concat(t.data("preview"),'"]')).click((function(){var n=$(this);$.post(n.data("url"),{_csrf:a,mode:"gfm",context:n.data("context"),text:e.find('.tab.segment[data-tab="'.concat(t.data("write"),'"] textarea')).val()},(function(n){var a=e.find('.tab.segment[data-tab="'.concat(t.data("preview"),'"]'));a.html(n),emojify.run(a[0]),$("pre code",a[0]).each((function(){hljs.highlightBlock(this)}))}))})),x()}function p(){var e,t;0!==$(".edit.form").length&&(!function(e){var t=e.find(".tabular.menu");t.find(".item").tab();var n=t.find('.item[data-tab="'.concat(t.data("preview"),'"]'));n.length&&(o=n.data("preview-file-modes").split(","),n.click((function(){var n=$(this);$.post(n.data("url"),{_csrf:a,mode:"gfm",context:n.data("context"),text:e.find('.tab.segment[data-tab="'.concat(t.data("write"),'"] textarea')).val()},(function(n){var a=e.find('.tab.segment[data-tab="'.concat(t.data("preview"),'"]'));a.html(n),emojify.run(a[0]),$("pre code",a[0]).each((function(){hljs.highlightBlock(this)}))}))})))}($(".edit.form")),e=$(".edit.form"),(t=e.find(".tabular.menu")).find(".item").tab(),t.find('.item[data-tab="'.concat(t.data("diff"),'"]')).click((function(){var n=$(this);$.post(n.data("url"),{_csrf:a,context:n.data("context"),content:e.find('.tab.segment[data-tab="'.concat(t.data("write"),'"] textarea')).val()},(function(n){var a=e.find('.tab.segment[data-tab="'.concat(t.data("diff"),'"]'));a.html(n),emojify.run(a[0])}))})))}function m(e,t,n,i){return new Promise((function(o){$.ajax({type:"POST",url:e,data:{_csrf:a,action:t,issue_ids:n,id:i},success:o})}))}function v(){window.location.reload()}function g(e){e.each((function(){var e=this;e.addEventListener("paste",(function(t){!function(e,t){if(e.clipboardData){var n=e.clipboardData.items;if(void 0!==n)for(var a=0;a')).val(a.uuid);$(".files").append(o)}))}))}),!1)}))}function b(){var e;0!==$(".comment.form").length&&((e=$(".ui.select-branch")).find(".reference-list-menu").find(".item:not(.no-select)").click((function(){var t=$(this).data("id");$($(this).data("id-selector")).val(t),e.find(".ui .branch-name").text(t)})),e.find(".reference.column").click((function(){return e.find(".scrolling.reference-list-menu").css("display","none"),e.find(".reference .text").removeClass("black"),$($(this).data("target")).css("display","block"),$(this).find(".text").addClass("black"),!1})),f($(".comment.form")),g($(".comment.form textarea")),t("select-label","labels"),t("select-assignees","assignees"),t("select-assignees-modify","assignees"),n(".select-milestone","#milestone_id"),n(".select-assignee","#assignee_id"));function t(e,t){var n=$(".ui.".concat(t,".list")),a=n.find(".no-select"),i=$(".".concat(e," .menu")),o="update"===i.data("action"),r={};$(".".concat(e)).dropdown("setting","onHide",(function(){if(o="update"===i.data("action")){var e=[];Object.keys(r).forEach((function(t){var n=r[t],a=m(n["update-url"],n.action,n["issue-id"],t);e.push(a)})),Promise.all(e).then(v)}})),i.find(".item:not(.no-select)").click((function(){if("select-assignees-modify"===e)return $(this).hasClass("checked")?($(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check")):($(this).addClass("checked"),$(this).find(".octicon").addClass("octicon-check")),m(i.data("update-url"),"",i.data("issue-id"),$(this).data("id")),i.data("action","update"),!1;$(this).hasClass("checked")?($(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check"),o&&($(this).data("id")in r?delete r[$(this).data("id")]:r[$(this).data("id")]={"update-url":i.data("update-url"),action:"detach","issue-id":i.data("issue-id")})):($(this).addClass("checked"),$(this).find(".octicon").addClass("octicon-check"),o&&($(this).data("id")in r?delete r[$(this).data("id")]:r[$(this).data("id")]={"update-url":i.data("update-url"),action:"attach","issue-id":i.data("issue-id")}));var t=[];return $(this).parent().find(".item").each((function(){$(this).hasClass("checked")?(t.push($(this).data("id")),$($(this).data("id-selector")).removeClass("hide")):$($(this).data("id-selector")).addClass("hide")})),0===t.length?a.removeClass("hide"):a.addClass("hide"),$($(this).parent().data("id")).val(t.join(",")),!1})),i.find(".no-select.item").click((function(){(o||"select-assignees-modify"===e)&&m(i.data("update-url"),"clear",i.data("issue-id"),"").then(v),$(this).parent().find(".item").each((function(){$(this).removeClass("checked"),$(this).find(".octicon").removeClass("octicon-check")})),n.find(".item").each((function(){$(this).addClass("hide")})),a.removeClass("hide"),$($(this).parent().data("id")).val("")}))}function n(e,t){var n=$("".concat(e," .menu")),a=$(".ui".concat(e,".list")),i="update"===n.data("action");n.find(".item:not(.no-select)").click((function(){switch($(this).parent().find(".item").each((function(){$(this).removeClass("selected active")})),$(this).addClass("selected active"),i&&m(n.data("update-url"),"",n.data("issue-id"),$(this).data("id")).then(v),t){case"#milestone_id":a.find(".selected").html(' "),o="> ".concat(i,"\n\n");""!==t.val()?t.val("".concat(t.val(),"\n\n").concat(o)):t.val("".concat(o)),t.focus(),e.preventDefault()})),$(".edit-content").click((function(e){$(this).closest(".dropdown").find(".menu").toggle("visible");var t,n=$(this).closest(".header").next(),i=n.find(".edit-content-zone"),o=n.find(".render-content"),r=n.find(".raw-content");if(0===i.html().length){i.html($("#edit-content-form").html()),t=i.find("textarea"),issuesTribute.attach(t.get()),emojiTribute.attach(t.get());var c=i.find(".dropzone");c.data("saved",!1);var s=i.find(".comment-files");if(c.length>0){var l={};c.dropzone({url:c.data("upload-url"),headers:{"X-Csrf-Token":a},maxFiles:c.data("max-file"),maxFilesize:c.data("max-size"),acceptedFiles:"*/*"===c.data("accepts")?null:c.data("accepts"),addRemoveLinks:!0,dictDefaultMessage:c.data("default-message"),dictInvalidFileType:c.data("invalid-input-type"),dictFileTooBig:c.data("file-too-big"),dictRemoveFile:c.data("remove-file"),init:function(){this.on("success",(function(e,t){l[e.name]={uuid:t.uuid,submitted:!1};var n=$('')).val(t.uuid);s.append(n)})),this.on("removedfile",(function(e){e.name in l&&($("#".concat(l[e.name].uuid)).remove(),c.data("remove-url")&&c.data("csrf")&&!l[e.name].submitted&&$.post(c.data("remove-url"),{file:l[e.name].uuid,_csrf:c.data("csrf")}))})),this.on("submit",(function(){$.each(l,(function(e){l[e].submitted=!0}))})),this.on("reload",(function(){$.getJSON(i.data("attachment-url"),(function(e){var t=c.get(0).dropzone;t.removeAllFiles(!0),s.empty(),$.each(e,(function(){var e="".concat(c.data("upload-url"),"/").concat(this.uuid);t.emit("addedfile",this),t.emit("thumbnail",this,e),t.emit("complete",this),t.files.push(this),l[this.name]={submitted:!0,uuid:this.uuid},c.find("img[src='".concat(e,"']")).css("max-width","100%");var n=$('')).val(this.uuid);s.append(n)}))}))}))}}),c.get(0).dropzone.emit("reload")}var d=i.find(".ui.comment.form"),u=d.find(".tabular.menu");u.attr("data-write",i.data("write")),u.attr("data-preview",i.data("preview")),u.find(".write.item").attr("data-tab",i.data("write")),u.find(".preview.item").attr("data-tab",i.data("preview")),d.find(".write.segment").attr("data-tab",i.data("write")),d.find(".preview.segment").attr("data-tab",i.data("preview")),f(d),i.find(".cancel.button").click((function(){o.show(),i.hide(),c.get(0).dropzone.emit("reload")})),i.find(".save.button").click((function(){o.show(),i.hide();var e=s.find("[name=files]").map((function(){return $(this).val()})).get();$.post(i.data("update-url"),{_csrf:a,content:t.val(),context:i.data("context"),files:e},(function(e){0===e.length?o.html($("#no-content").html()):(o.html(e.content),emojify.run(o[0]),$("pre code",o[0]).each((function(){hljs.highlightBlock(this)})));var t=n.parent();t.find(".ui.small.images").length?""===e.attachments?t.find(".ui.small.images").parent().remove():t.find(".ui.small.images").html(e.attachments):""!==e.attachments&&(t.append('
'),t.find(".ui.small.images").html(e.attachments)),c.get(0).dropzone.emit("submit"),c.get(0).dropzone.emit("reload")}))}))}else t=n.find("textarea");i.show(),o.hide(),0===t.val().length&&t.val(r.text()),t.focus(),e.preventDefault()})),$(".delete-comment").click((function(){var e=$(this);return window.confirm(e.data("locale"))&&$.post(e.data("url"),{_csrf:a}).success((function(){$("#".concat(e.data("comment-id"))).remove()})),!1}));var r=$("#status-button");$("#comment-form .edit_area").keyup((function(){0===$(this).val().length?r.text(r.data("status")):r.text(r.data("status-and-comment"))})),r.click((function(){$("#status").val(r.data("status-val")),$("#comment-form").submit()}));var c=$(".merge-button > button");c.on("click",(function(e){e.preventDefault(),$(".".concat($(this).data("do"),"-fields")).show(),$(this).parent().hide()})),$(".merge-button > .dropdown").dropdown({onChange:function(e,t,n){n.data("do")&&(c.find(".button-text").text(n.text()),c.data("do",n.data("do")))}}),$(".merge-cancel").on("click",(function(e){e.preventDefault(),$(this).closest(".form").hide(),c.parent().show()})),function e(t){var n="";t||(t=$(document),n=".reactions > "),t.find("".concat(n,"a.label")).popup({position:"bottom left",metadata:{content:"title",title:"none"}}),t.find(".select-reaction > .menu > .item, ".concat(n,"a.label")).on("click",(function(t){var n=this;if(t.preventDefault(),!$(this).hasClass("disabled")){var i=$(this).hasClass("item")?$(this).closest(".select-reaction").data("action-url"):$(this).data("action-url"),o="".concat(i,"/").concat($(this).hasClass("blue")?"unreact":"react");$.ajax({type:"POST",url:o,data:{_csrf:a,content:$(this).data("content")}}).done((function(t){if(t&&(t.html||t.empty)){var a=$(n).closest(".content"),i=a.find(".segment.reactions");if(!t.empty&&i.length>0&&i.remove(),!t.empty){i=$('
');var o=a.find(".segment.bottom:first");o.length>0?i.insertBefore(o):i.appendTo(a),i.html(t.html);for(var r=i.find(".has-emoji"),c=0;c0&&$(".diff-counter").each((function(){var e=$(this),t=e.find("span[data-line].add").data("line"),n=e.find("span[data-line].del").data("line"),a=parseFloat(t)/(parseFloat(t)+parseFloat(n))*100;e.find(".bar .add").css("width","".concat(a,"%"))})),$("#repo-clone-ssh").click((function(){$(".clone-url").text($(this).data("link")),$("#repo-clone-url").val($(this).data("link")),$(this).addClass("blue"),$("#repo-clone-https").removeClass("blue"),localStorage.setItem("repo-clone-protocol","ssh")})),$("#repo-clone-https").click((function(){$(".clone-url").text($(this).data("link")),$("#repo-clone-url").val($(this).data("link")),$(this).addClass("blue"),$("#repo-clone-ssh").removeClass("blue"),localStorage.setItem("repo-clone-protocol","https")})),$("#repo-clone-url").click((function(){$(this).select()}));var s=$(".repository.compare.pull");s.length>0&&(l(".choose.branch .dropdown"),s.find("button.show-form").on("click",(function(e){e.preventDefault(),s.find(".pullrequest-form").show(),$(this).parent().hide()}))),$(".repository.settings.branches").length>0&&(l(".protected-branches .dropdown"),$(".enable-protection, .enable-whitelist").change((function(){this.checked?$($(this).data("target")).removeClass("disabled"):$($(this).data("target")).addClass("disabled")})))}function l(e){var t=$(e);t.dropdown({fullTextSearch:!0,selectOnKeydown:!1,onChange:function(e,t,n){n.data("url")&&(window.location.href=n.data("url"))},message:{noResults:t.data("no-results")}})}}function y(e){var t=Math.floor(Math.random()*Math.floor(1e6));return e.attr("data-write",e.attr("data-write")+t),e.attr("data-preview",e.attr("data-preview")+t),e.find(".item").each((function(){var e=$(this).attr("data-tab")+t;$(this).attr("data-tab",e)})),e.parent().find("*[data-tab='write']").attr("data-tab","write".concat(t)),e.parent().find("*[data-tab='preview']").attr("data-tab","preview".concat(t)),f(e.parent(".form")),t}function k(){$(".access-mode.menu .item").click((function(){var e=$(this).parent();$.post(e.data("url"),{_csrf:a,uid:e.data("uid"),mode:$(this).data("value")})}))}function _(){$(".js-quick-pull-choice-option").change((function(){"commit-to-new-branch"===$(this).val()?($(".quick-pull-branch-name").show(),$(".quick-pull-branch-name input").prop("required",!0)):($(".quick-pull-branch-name").hide(),$(".quick-pull-branch-name input").prop("required",!1)),$("#commit-button").text($(this).attr("button_text"))}));var e=$("#file-name");e.keyup((function(e){var t,n,a=$(".breadcrumb span.section"),i=$(".breadcrumb div.divider");if(8===e.keyCode&&0===$(this).getCursorPosition()&&a.length>0&&(t=a.last().find("a").text(),$(this).val(t+$(this).val()),$(this)[0].setSelectionRange(t.length,t.length),a.last().remove(),i.last().remove()),191===e.keyCode){n=$(this).val().split("/");for(var o=0;o
'.concat(t,"")).insertBefore($(this)),$('
/
').insertBefore($(this))):$(this).val(t),$(this)[0].setSelectionRange(0,0)}n=[],$(".breadcrumb span.section").each((function(){var e=$(this);e.find("a").length?n.push(e.find("a").text()):n.push(e.text())})),$(this).val()&&n.push($(this).val()),$("#tree_path").val(n.join("/"))})).trigger("keyup");var t=$(".repository.editor textarea#edit_area");if(t.length){var n=t.data("markdown-file-exts").split(","),i=t.data("line-wrap-extensions").split(",");e.on("keyup",(function(){var s,l,d,u,h,f,p=e.val();d=u="";var m=/.+\.([^.]+)$/.exec(p);m&&(d=m[1],u=".".concat(d));var v=CodeMirror.findModeByExtension(d),g=$("a[data-tab=preview]");if(v?(s=v.mode,l=v.mime,f=s):f=d,g.length&&f&&o&&o.length&&o.indexOf(f)>=0?(h=g.data("url"),g.data("url",h.replace(/(.*)\/.*/i,"$1/".concat(s))),g.show()):g.hide(),!(n.indexOf(u)>=0&&function(e){return c&&(c.toTextArea(),c=null),!!r||(r=new SimpleMDE({autoDownloadFontAwesome:!1,element:e[0],forceSync:!0,renderingConfig:{singleLineBreaks:!1},indentWithTabs:!1,tabSize:4,spellChecker:!1,previewRender:function(t,n){return setTimeout((function(){$.post(e.data("url"),{_csrf:a,mode:"gfm",context:e.data("context"),text:t},(function(e){n.innerHTML='
'.concat(e,"
"),emojify.run($(".editor-preview")[0])}))}),0),"Loading..."},toolbar:["bold","italic","strikethrough","|","heading-1","heading-2","heading-3","heading-bigger","heading-smaller","|","code","quote","|","unordered-list","ordered-list","|","link","image","table","horizontal-rule","|","clean-block","preview","fullscreen","side-by-side"]}),!0)}(t))&&(c||function(e){return r&&(r.toTextArea(),r=null),!!c||((c=CodeMirror.fromTextArea(e[0],{lineNumbers:!0})).on("change",(function(t,n){e.val(t.getValue())})),!0)}(t))){s&&(c.setOption("mode",l),CodeMirror.autoLoadMode(c,s)),i.indexOf(u)>=0?c.setOption("lineWrapping",!0):c.setOption("lineWrapping",!1);var b=e.val();0!==b.length&&(b=(b=b.split("/"))[b.length-1],$.getJSON(e.data("ec-url-prefix")+b,(function(e){"tab"===e.indent_style?(c.setOption("indentWithTabs",!0),c.setOption("extraKeys",{})):(c.setOption("indentWithTabs",!1),c.setOption("extraKeys",{Tab:function(e){var t=Array(parseInt(e.getOption("indentUnit"))+1).join(" ");e.replaceSelection(t)}})),c.setOption("indentUnit",e.indent_size||4),c.setOption("tabSize",e.tab_width||4)})))}})).trigger("keyup");var s=$("#commit-button"),l=$(".ui.edit.form");s.prop("disabled",!0),l.areYouSure({silent:!0,dirtyClass:"dirty-file",fieldSelector:":input:not(.commit-form-wrapper :input)",change:function(){var e=$(this).hasClass("dirty-file");s.prop("disabled",!e)}}),s.click((function(e){0===t.val().length&&($("#edit-empty-content-modal").modal({onApprove:function(){$(".edit.form").submit()}}).modal("show"),e.preventDefault())}))}}function C(){$(".user.settings.profile").length>0&&$("#username").keyup((function(){var e=$("#name-change-prompt");$(this).val().toString().toLowerCase()!==$(this).data("name").toString().toLowerCase()?e.show():e.hide()}))}function x(){$(".ui.button").keypress((function(e){13!==e.keyCode&&32!==e.keyCode||$(this).click()}))}function S(){$(".code-view .linenums").length>0&&($(document).on("click",".lines-num span",(function(e){var t=$(this),n=t.parent().siblings(".lines-code").find("ol.linenums > li");A(n,n.filter("[rel=".concat(t.attr("id"),"]")),e.shiftKey?n.filter(".active").eq(0):null),window.getSelection?window.getSelection().removeAllRanges():document.selection.empty()})),$(window).on("hashchange",(function(){var e,t=window.location.hash.match(/^#(L\d+)-(L\d+)$/),n=$(".code-view ol.linenums > li");if(t)return e=n.filter(".".concat(t[1])),A(n,e,n.filter(".".concat(t[2]))),void $("html, body").scrollTop(e.offset().top-200);(t=window.location.hash.match(/^#(L|n)(\d+)$/))&&(e=n.filter(".L".concat(t[2])),A(n,e),$("html, body").scrollTop(e.offset().top-200))})).trigger("hashchange")),$(".ui.fold-code").on("click",(function(e){var t=$(e.target);t.hasClass("fa-chevron-down")?$(e.target).parent().next().slideUp("fast",(function(){t.removeClass("fa-chevron-down").addClass("fa-chevron-right")})):$(e.target).parent().next().slideDown("fast",(function(){t.removeClass("fa-chevron-right").addClass("fa-chevron-down")}))})),$(".ui.blob-excerpt").on("click",(function(e){!function e(t){var n=$(t.target),a=n.parent().parent();$.get("".concat(n.data("url"),"?").concat(n.data("query"),"&anchor=").concat(n.data("anchor")),(function(t){a.replaceWith(t),$('[data-anchor="'.concat(n.data("anchor"),'"]')).on("click",(function(t){e(t)}))}))}(e)}))}function q(e){$.ajax({url:"".concat(i,"/user/u2f/sign"),type:"POST",headers:{"X-Csrf-Token":a},data:JSON.stringify(e),contentType:"application/json; charset=utf-8"}).done((function(e){window.location.replace(e)})).fail((function(){L(1)}))}function T(e){(function(e){if(!("errorCode"in e))return!1;if(0===e.errorCode)return!1;return L(e.errorCode),!0})(e)||$.ajax({url:"".concat(i,"/user/settings/security/u2f/register"),type:"POST",headers:{"X-Csrf-Token":a},data:JSON.stringify(e),contentType:"application/json; charset=utf-8",success:function(){v()},fail:function(){L(1)}})}function L(e){var t={browser:$("#unsupported-browser"),1:$("#u2f-error-1"),2:$("#u2f-error-2"),3:$("#u2f-error-3"),4:$("#u2f-error-4"),5:$(".u2f-error-5")};t[e].removeClass("hide"),Object.keys(t).forEach((function(n){n!==e&&t[n].addClass("hide")})),$("#u2f-error").modal("show")}function O(){$.post("".concat(i,"/user/settings/security/u2f/request_register"),{_csrf:a,name:$("#nickname").val()}).success((function(e){$("#nickname").closest("div.field").removeClass("error"),$("#register-device").modal("show"),null===e.registeredKeys&&(e.registeredKeys=[]),u2fApi.register(e.appId,e.registerRequests,e.registeredKeys,30).then(T).catch((function(e){L(void 0!==e?e.metaData.code:1)}))})).fail((function(e){409===e.status&&$("#nickname").closest("div.field").addClass("error")}))}function j(e){window.history.pushState?window.history.pushState(null,null,e):window.location.hash=e}function A(e,t,n){if(e.removeClass("active"),n){var a,i=parseInt(t.attr("rel").substr(1)),o=parseInt(n.attr("rel").substr(1));if(i!==o){i>o&&(a=i,i=o,o=a);for(var r=[],c=i;c<=o;c++)r.push(".L".concat(c));return e.filter(r.join(",")).addClass("active"),void j("#L".concat(i,"-L").concat(o))}}t.addClass("active"),j("#".concat(t.attr("rel")))}function D(){var e=$(this),t="";e.attr("id")&&(t+="#".concat(e.attr("id")));var n=$(".delete.modal".concat(t));return n.find(".name").text(e.data("name")),n.modal({closable:!1,onApprove:function(){"form"!==e.data("type")?$.post(e.data("url"),{_csrf:a,id:e.data("id")}).done((function(e){window.location.href=e.redirect})):$(e.data("form")).submit()}}).modal("show"),!1}function F(){var e=$(this),t="";e.attr("id")&&(t+="#".concat(e.attr("id")));var n=$(".addall.modal".concat(t));return n.find(".name").text(e.data("name")),n.modal({closable:!1,onApprove:function(){"form"!==e.data("type")?$.post(e.data("url"),{_csrf:a,id:e.data("id")}).done((function(e){window.location.href=e.redirect})):$(e.data("form")).submit()}}).modal("show"),!1}$((function(){var e,t,a,i,o;return l.a.async((function(r){for(;;)switch(r.prev=r.next){case 0:if(e=document.getElementById("graph-canvas")){r.next=3;break}return r.abrupt("return");case 3:return r.next=5,l.a.awrap(Promise.all([n.e(0).then(n.bind(null,12)),n.e(0).then(n.t.bind(null,13,7))]));case 5:t=r.sent,a=u()(t,1),i=a[0].default,o=[],$("#graph-raw-list li span.node-relation").each((function(){o.push($(this).text())})),i(e,o);case 11:case"end":return r.stop()}}))})),"undefined"!=typeof Dropzone&&(Dropzone.autoDiscover=!1),$.fn.getCursorPosition=function(){var e=$(this).get(0),t=0;if("selectionStart"in e)t=e.selectionStart;else if("selection"in document){e.focus();var n=document.selection.createRange(),a=document.selection.createRange().text.length;n.moveStart("character",-e.value.length),t=n.text.length-a}return t},$(document).ready((function(){if(a=$("meta[name=_csrf]").attr("content"),i=$("meta[name=_suburl]").attr("content"),$(".time-since").each((function(){$(this).addClass("poping up").attr("data-content",$(this).attr("title")).attr("data-variation","inverted tiny").attr("title","")})),$(".dropdown:not(.custom)").dropdown(),$(".jump.dropdown").dropdown({action:"hide",onShow:function(){$(".poping.up").popup("hide")}}),$(".slide.up.dropdown").dropdown({transition:"slide up"}),$(".upward.dropdown").dropdown({direction:"upward"}),$(".ui.accordion").accordion(),$(".ui.checkbox").checkbox(),$(".ui.progress").progress({showActivity:!1}),$(".poping.up").popup(),$(".top.menu .poping.up").popup({onShow:function(){if($(".top.menu .menu.transition").hasClass("visible"))return!1}}),$(".tabular.menu .item").tab(),$(".tabable.menu .item").tab(),$(".toggle.button").click((function(){$($(this).data("target")).slideToggle(100)})),$("tr[data-href]").click((function(){window.location=$(this).data("href")})),"undefined"!=typeof hljs)for(var e=[].slice.call(document.querySelectorAll("pre code")||[]),t=0;t0){var o={};new Dropzone("#dropzone",{url:n.data("upload-url"),headers:{"X-Csrf-Token":a},maxFiles:n.data("max-file"),maxFilesize:n.data("max-size"),acceptedFiles:"*/*"===n.data("accepts")?null:n.data("accepts"),addRemoveLinks:!0,dictDefaultMessage:n.data("default-message"),dictInvalidFileType:n.data("invalid-input-type"),dictFileTooBig:n.data("file-too-big"),dictRemoveFile:n.data("remove-file"),init:function(){this.on("success",(function(e,t){o[e.name]=t.uuid;var n=$('')).val(t.uuid);$(".files").append(n)})),this.on("removedfile",(function(e){e.name in o&&$("#".concat(o[e.name])).remove(),n.data("remove-url")&&n.data("csrf")&&$.post(n.data("remove-url"),{file:o[e.name],_csrf:n.data("csrf")})}))}})}emojify.setConfig({img_dir:"".concat(i,"/vendor/plugins/emojify/images"),ignore_emoticons:!0});for(var r=document.getElementsByClassName("has-emoji"),c=0;c0&&(a="".concat(n,"-").concat(e[n])),void 0===e[n]?e[n]=1:e[n]+=1,(t=t.wrap('
'))).append(''))}))})),$(".issue-checkbox").click((function(){$(".issue-checkbox").children("input:checked").length>0?($("#issue-filters").addClass("hide"),$("#issue-actions").removeClass("hide")):($("#issue-filters").removeClass("hide"),$("#issue-actions").addClass("hide"))})),$(".issue-action").click((function(){var e=this.dataset.action,t=this.dataset.elementId,n=$(".issue-checkbox").children("input:checked").map((function(){return this.dataset.issueId})).get().join(),a=this.dataset.url;"0"===t&&"/assignee"===a.substr(-9)&&(t="",e="clear"),m(a,e,n,t).then((function(){"close"!==e&&"open"!==e||$('.issue-checkbox input[type="checkbox"]').each((function(e,t){t.checked=!1})),v()}))})),$('.issue-checkbox input[type="checkbox"]:checked').first().each((function(e,t){t.checked=!1,$(t).click()})),x(),$("#search-user-box").search({minCharacters:2,apiSettings:{url:"".concat(i,"/api/v1/users/search?q={query}"),onResponse:function(e){var t=[];return $.each(e.data,(function(e,n){var a=n.login;n.full_name&&n.full_name.length>0&&(a+=" (".concat(h(n.full_name),")")),t.push({title:a,image:n.avatar_url})})),{results:t}}},searchFields:["login","full_name"],showNoResults:!1}),(l=$("#search-team-box")).search({minCharacters:2,apiSettings:{url:"".concat(i,"/api/v1/orgs/").concat(l.data("org"),"/teams/search?q={query}"),headers:{"X-Csrf-Token":a},onResponse:function(e){var t=[];return $.each(e.data,(function(e,n){var a="".concat(n.name," (").concat(n.permission," access)");t.push({title:a})})),{results:t}}},searchFields:["name","description"],showNoResults:!1}),(d=$("#search-repo-box")).search({minCharacters:2,apiSettings:{url:"".concat(i,"/api/v1/repos/search?q={query}&uid=").concat(d.data("uid")),onResponse:function(e){var t=[];return $.each(e.data,(function(e,n){t.push({title:n.full_name.split("/")[1],description:n.full_name})})),{results:t}}},searchFields:["full_name"],showNoResults:!1}),b(),0!==$(".install").length&&(""===$("#db_host").val()&&($("#db_host").val("127.0.0.1:3306"),$("#db_user").val("gitea"),$("#db_name").val("gitea")),$("#db_type").change((function(){var e=$(this).val();if("SQLite3"===e)return $("#sql_settings").hide(),$("#pgsql_settings").hide(),$("#mysql_settings").hide(),$("#sqlite_settings").show(),void("SQLite3"===e&&"data/gitea_tidb"===$("#db_path").val()&&$("#db_path").val("data/gitea.db"));var t={MySQL:"127.0.0.1:3306",PostgreSQL:"127.0.0.1:5432",MSSQL:"127.0.0.1:1433"};$("#sqlite_settings").hide(),$("#sql_settings").show(),$("#pgsql_settings").toggle("PostgreSQL"===e),$("#mysql_settings").toggle("MySQL"===e),$.each(t,(function(n,a){if($("#db_host").val()===a)return $("#db_host").val(t[e]),!1}))})),$("#offline-mode input").change((function(){$(this).is(":checked")&&($("#disable-gravatar").checkbox("check"),$("#federated-avatar-lookup").checkbox("uncheck"))})),$("#disable-gravatar input").change((function(){$(this).is(":checked")?$("#federated-avatar-lookup").checkbox("uncheck"):$("#offline-mode").checkbox("uncheck")})),$("#federated-avatar-lookup input").change((function(){$(this).is(":checked")&&($("#disable-gravatar").checkbox("uncheck"),$("#offline-mode").checkbox("uncheck"))})),$("#enable-openid-signin input").change((function(){$(this).is(":checked")?$("#disable-registration input").is(":checked")||$("#enable-openid-signup").checkbox("check"):$("#enable-openid-signup").checkbox("uncheck")})),$("#disable-registration input").change((function(){$(this).is(":checked")?($("#enable-captcha").checkbox("uncheck"),$("#enable-openid-signup").checkbox("uncheck")):$("#enable-openid-signup").checkbox("check")})),$("#enable-captcha input").change((function(){$(this).is(":checked")&&$("#disable-registration").checkbox("uncheck")}))),w(),(u=function(){var e=$("#auth_username").val(),t=$("#clone_addr").val();!$("#mirror").is(":checked")&&e&&e.length>0&&void 0!==t&&(t.startsWith("https://github.com")||t.startsWith("http://github.com"))?$("#migrate_items").show():$("#migrate_items").hide()})(),$("#clone_addr").on("input",u),$("#auth_username").on("input",u),$("#mirror").on("change",u),function(){var e=$(".repository.wiki textarea#edit_area"),t=0,n=null;if(e.length>0){var i=new SimpleMDE({autoDownloadFontAwesome:!1,element:e[0],forceSync:!0,previewRender:function(o,r){return setTimeout((function(){var c=function(){t=0,null!=n&&(clearTimeout(n),n=null),$.post(e.data("url"),{_csrf:a,mode:"gfm",context:e.data("context"),text:o},(function(e){r.innerHTML='
'.concat(e,"
"),emojify.run($(".editor-preview")[0]),$(r).find("pre code").each((function(e,t){hljs.highlightBlock(t)}))}))};i.isSideBySideActive()?(++t>10&&c(),null!=n&&(clearTimeout(n),n=null),n=setTimeout(c,600)):c()}),0),i.isSideBySideActive()?r.innerHTML:"Loading..."},renderingConfig:{singleLineBreaks:!1},indentWithTabs:!1,tabSize:4,spellChecker:!1,toolbar:["bold","italic","strikethrough","|","heading-1","heading-2","heading-3","heading-bigger","heading-smaller","|",{name:"code-inline",action:function(e){var t=e.codemirror,n=t.getSelection();if(t.replaceSelection("`".concat(n,"`")),!n){var a=t.getCursor();t.setCursor(a.line,a.ch-1)}t.focus()},className:"fa fa-angle-right",title:"Add Inline Code"},"code","quote","|",{name:"checkbox-empty",action:function(e){var t=e.codemirror;t.replaceSelection("\n- [ ] ".concat(t.getSelection())),t.focus()},className:"fa fa-square-o",title:"Add Checkbox (empty)"},{name:"checkbox-checked",action:function(e){var t=e.codemirror;t.replaceSelection("\n- [x] ".concat(t.getSelection())),t.focus()},className:"fa fa-check-square-o",title:"Add Checkbox (checked)"},"|","unordered-list","ordered-list","|","link","image","table","horizontal-rule","|","clean-block","preview","fullscreen","side-by-side"]});$(i.codemirror.getInputField()).addClass("js-quick-submit"),setTimeout((function(){var e=$('.repository.wiki.new .previewtabs a[data-tab="write"]'),n=$('.repository.wiki.new .previewtabs a[data-tab="preview"]'),a=$(".editor-toolbar"),i=$(".editor-toolbar a.fa-eye"),o=$(".editor-toolbar a.fa-columns");e.on("click",(function(){a.hasClass("disabled-for-preview")&&i.click()})),n.on("click",(function(){a.hasClass("disabled-for-preview")||i.click()})),i.on("click",(function(){setTimeout((function(){a.hasClass("disabled-for-preview")?(e.hasClass("active")&&e.removeClass("active"),n.hasClass("active")||n.addClass("active")):(e.hasClass("active")||e.addClass("active"),n.hasClass("active")&&n.removeClass("active"))}),0)})),o.on("click",(function(){t=10}))}),0)}}(),p(),_(),0!==$(".organization").length&&$(".organization.settings.options").length>0&&$("#org_name").keyup((function(){var e=$("#org-name-change-prompt");$(this).val().toString().toLowerCase()!==$(this).data("org-name").toString().toLowerCase()?e.show():e.hide()})),0!==$(".edit.githook").length&&CodeMirror.autoLoadMode(CodeMirror.fromTextArea($("#content")[0],{lineNumbers:!0,mode:"shell"}),"shell"),function(){if(0!==$(".new.webhook").length){$(".events.checkbox input").change((function(){$(this).is(":checked")&&$(".events.fields").show()})),$(".non-events.checkbox input").change((function(){$(this).is(":checked")&&$(".events.fields").hide()}));var e=function(){var e="POST"===$("#http_method").val();$("#content_type").parent().parent()[e?"show":"hide"]()};e(),$("#http_method").change((function(){e()})),$("#test-delivery").click((function(){var e=$(this);e.addClass("loading disabled"),$.post(e.data("link"),{_csrf:a}).done(setTimeout((function(){window.location.href=e.data("redirect")}),5e3))}))}}(),function(){if(0!==$(".admin").length){if(($(".admin.new.user").length>0||$(".admin.edit.user").length>0)&&$("#login_type").change((function(){"0"===$(this).val().substring(0,1)?($("#login_name").removeAttr("required"),$(".non-local").hide(),$(".local").show(),$("#user_name").focus(),"required"===$(this).data("password")&&$("#password").attr("required","required")):($("#login_name").attr("required","required"),$(".non-local").show(),$(".local").hide(),$("#login_name").focus(),$("#password").removeAttr("required"))})),$(".admin.new.authentication").length>0&&($("#auth_type").change((function(){$(".ldap, .dldap, .smtp, .pam, .oauth2, .has-tls .search-page-size").hide(),$(".ldap input[required], .binddnrequired input[required], .dldap input[required], .smtp input[required], .pam input[required], .oauth2 input[required], .has-tls input[required]").removeAttr("required"),$(".binddnrequired").removeClass("required");var e=$(this).val();switch(e){case"2":$(".ldap").show(),$(".binddnrequired input, .ldap div.required:not(.dldap) input").attr("required","required"),$(".binddnrequired").addClass("required");break;case"3":$(".smtp").show(),$(".has-tls").show(),$(".smtp div.required input, .has-tls").attr("required","required");break;case"4":$(".pam").show(),$(".pam input").attr("required","required");break;case"5":$(".dldap").show(),$(".dldap div.required:not(.ldap) input").attr("required","required");break;case"6":$(".oauth2").show(),$(".oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input").attr("required","required"),r()}"2"!==e&&"5"!==e||i(),"2"===e&&o()})),$("#auth_type").change(),$("#security_protocol").change(i),$("#use_paged_search").change(o),$("#oauth2_provider").change(r),$("#oauth2_use_custom_url").change(c)),$(".admin.edit.authentication").length>0){var e=$("#auth_type").val();"2"===e||"5"===e?($("#security_protocol").change(i),"2"===e&&$("#use_paged_search").change(o)):"6"===e&&($("#oauth2_provider").change(r),$("#oauth2_use_custom_url").change(c),r())}if($(".admin.notice")){var t=$("#detail-modal");$(".view-detail").click((function(){return t.find(".content p").text($(this).data("content")),t.modal("show"),!1}));var n=$(".select.table .ui.checkbox");$(".select.action").click((function(){switch($(this).data("action")){case"select-all":n.checkbox("check");break;case"deselect-all":n.checkbox("uncheck");break;case"inverse":n.checkbox("toggle")}})),$("#delete-selection").click((function(){var e=$(this);e.addClass("loading disabled");var t=[];n.each((function(){$(this).checkbox("is checked")&&t.push($(this).data("id"))})),$.post(e.data("link"),{_csrf:a,ids:t}).done((function(){window.location.href=e.data("redirect")}))}))}}function i(){$("#security_protocol").val()>0?$(".has-tls").show():$(".has-tls").hide()}function o(){$("#use_paged_search").prop("checked")?$(".search-page-size").show().find("input").attr("required","required"):$(".search-page-size").hide().find("input").removeAttr("required")}function r(){switch($(".open_id_connect_auto_discovery_url, .oauth2_use_custom_url").hide(),$(".open_id_connect_auto_discovery_url input[required]").removeAttr("required"),$("#oauth2_provider").val()){case"github":case"gitlab":case"gitea":$(".oauth2_use_custom_url").show();break;case"openidConnect":$(".open_id_connect_auto_discovery_url input").attr("required","required"),$(".open_id_connect_auto_discovery_url").show()}c()}function c(){var e=$("#oauth2_provider").val();if($(".oauth2_use_custom_url_field").hide(),$(".oauth2_use_custom_url_field input[required]").removeAttr("required"),$("#oauth2_use_custom_url").is(":checked"))switch($("#oauth2_token_url").val()||$("#oauth2_token_url").val($("#".concat(e,"_token_url")).val()),$("#oauth2_auth_url").val()||$("#oauth2_auth_url").val($("#".concat(e,"_auth_url")).val()),$("#oauth2_profile_url").val()||$("#oauth2_profile_url").val($("#".concat(e,"_profile_url")).val()),$("#oauth2_email_url").val()||$("#oauth2_email_url").val($("#".concat(e,"_email_url")).val()),e){case"github":$(".oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input, .oauth2_email_url input").attr("required","required"),$(".oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url, .oauth2_email_url").show();break;case"gitea":case"gitlab":$(".oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input").attr("required","required"),$(".oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url").show(),$("#oauth2_email_url").val("")}}}(),S(),function(){var e=document.getElementById("app");if(!e)return;Vue.component("repo-search",{delimiters:["${","}"],props:{searchLimit:{type:Number,default:10},suburl:{type:String,required:!0},uid:{type:Number,required:!0},organizations:{type:Array,default:[]},isOrganization:{type:Boolean,default:!0},canCreateOrganization:{type:Boolean,default:!1},organizationsTotalCount:{type:Number,default:0},moreReposLink:{type:String,default:""}},data:function(){return{tab:"repos",repos:[],reposTotalCount:0,reposFilter:"all",searchQuery:"",isLoading:!1,repoTypes:{all:{count:0,searchMode:""},forks:{count:0,searchMode:"fork"},mirrors:{count:0,searchMode:"mirror"},sources:{count:0,searchMode:"source"},collaborative:{count:0,searchMode:"collaborative"}}}},computed:{showMoreReposLink:function(){return this.repos.length>0&&this.repos.length'.concat(i[r],"
")).insertBefore(o);A.css("display","none"),N.show()}})).fail((function(t){if(422===t.status)if(t.responseJSON.invalidTopics.length>0){z.formatPrompt=t.responseJSON.message;var n=t.responseJSON.invalidTopics,a=E.children("a.ui.label");e.split(",").forEach((function(e,t){for(var i=0;i]*>?/gm,""),a=!1,i=[];if(E.find("div.label.visible.topic,a.label.visible").each((function(e,t){i.push(t.dataset.value)})),e.topics){for(var o=!1,r=0;r0&&!a?(t.success=!0,t.results.unshift({description:n,"data-value":n})):n.length>0&&a&&t.results.sort((function(e,t){return e.description.toLowerCase()===n.toLowerCase()?-1:t.description.toLowerCase()===n.toLowerCase()?1:e.description>t.description?-1:e.description').concat(h(a.repository.full_name),""),value:a.id})})),t},cache:!1},fullTextSearch:!0}),$(".menu a.label-filter-item").each((function(){$(this).click((function(e){if(e.altKey){e.preventDefault();var t=$(this).attr("href"),n=$(this).data("label-id"),a="labels=(-?[0-9]+%2c)*(".concat(n,")(%2c-?[0-9]+)*&");window.location=t.replace(new RegExp(a),"labels=$1-$2$3&")}}))})),$(".menu .ui.dropdown.label-filter").keydown((function(e){if(e.altKey&&13===e.keyCode){var t=$(".menu .ui.dropdown.label-filter .menu .item.selected");if(t.length>0){var n=$(t[0]),a=n.attr("href"),i=n.data("label-id"),o="labels=(-?[0-9]+%2c)*(".concat(i,")(%2c-?[0-9]+)*&");window.location=a.replace(new RegExp(o),"labels=$1-$2$3&")}}}))}(),$(".title_wip_desc > a").click((function(e){e.preventDefault();var t=$("#issue_title");t.focus();var n=t.val().trim().toUpperCase();for(var a in wipPrefixes)if(n.startsWith(wipPrefixes[a].toUpperCase()))return;t.val("".concat(wipPrefixes[0]," ").concat(t.val()))})),$(".show-outdated").on("click",(function(e){e.preventDefault();var t=$(this).data("comment");$(this).addClass("hide"),$("#code-comments-".concat(t)).removeClass("hide"),$("#code-preview-".concat(t)).removeClass("hide"),$("#hide-outdated-".concat(t)).removeClass("hide")})),$(".hide-outdated").on("click",(function(e){e.preventDefault();var t=$(this).data("comment");$(this).addClass("hide"),$("#code-comments-".concat(t)).addClass("hide"),$("#code-preview-".concat(t)).addClass("hide"),$("#show-outdated-".concat(t)).removeClass("hide")})),$("button.comment-form-reply").on("click",(function(e){e.preventDefault(),$(this).hide();var t=$(this).parent().find(".comment-form");t.removeClass("hide"),y(t.find(".menu"))})),0!==$(".repository.pull.diff").length&&($(".diff-detail-box.ui.sticky").sticky(),$(".btn-review").on("click",(function(e){e.preventDefault(),$(this).closest(".dropdown").find(".menu").toggle("visible")})).closest(".dropdown").find(".link.close").on("click",(function(e){e.preventDefault(),$(this).closest(".menu").toggle("visible")})),$(".code-view .lines-code,.code-view .lines-num").on("mouseenter",(function(){var e=$(this).closest("td");$(this).closest("tr").addClass(e.hasClass("lines-num-old")||e.hasClass("lines-code-old")?"focus-lines-old":"focus-lines-new")})).on("mouseleave",(function(){$(this).closest("tr").removeClass("focus-lines-new focus-lines-old")})),$(".add-code-comment").on("click",(function(e){if(!$(e.target).hasClass("btn-add-single")){e.preventDefault();var t=$(this).closest(".code-diff").hasClass("code-diff-split"),n=$(this).data("side"),a=$(this).data("idx"),i=$(this).data("path"),o=$("#pull_review_add_comment").html(),r=$(this).closest("tr"),c=r.next();c.hasClass("add-comment")||(c=$(''.concat(t?'':'',"")),r.after(c));var s=c.find(".add-comment-".concat(n)),l=s.find(".comment-code-cloud");0===l.length&&(s.html(o),y((l=s.find(".comment-code-cloud")).find(".menu")),s.find("input[name='line']").val(a),s.find("input[name='side']").val("left"===n?"previous":"proposed"),s.find("input[name='path']").val(i)),l.find("textarea").focus()}}))),function e(){var t=$("#repo_migrating");if($("#repo_migrating_failed").hide(),t){var n=t.attr("repo");if(void 0===n)return;$.ajax({type:"GET",url:"".concat(i,"/").concat(n,"/status"),data:{_csrf:a},complete:function(t){if(200===t.status&&t.responseJSON)return 0===t.responseJSON.status?void window.location.reload():void setTimeout((function(){e()}),2e3);$("#repo_migrating_progress").hide(),$("#repo_migrating_failed").show()}})}}(),function(){var e=$("#repo_template"),t=function(){var t=$("#template_units"),n=$("#non_template");""!==e.val()?(t.show(),n.hide()):(t.hide(),n.show())};e.change(t),t();var n=function(){$("#repo_template_search").dropdown({apiSettings:{url:"".concat(i,"/api/v1/repos/search?q={query}&template=true&priority_owner_id=").concat($("#uid").val()),onResponse:function(e){var t={success:!0,results:[]};return t.results.push({name:"",value:""}),$.each(e.data,(function(e,n){t.results.push({name:h(n.full_name),value:n.id})})),t},cache:!1},fullTextSearch:!0})};$("#uid").change(n),n()}(),$("#repo-clone-url").length>0)switch(localStorage.getItem("repo-clone-protocol")){case"ssh":0===$("#repo-clone-ssh").click().length&&$("#repo-clone-https").click();break;default:$("#repo-clone-https").click()}var J,H={"div.user.settings":C,"div.repository.settings.collaboration":k};for(J in H)if($(J).length>0){H[J]();break}var V=$("#clone_addr");V.change((function(){var e=$("#repo_name");V.val().length>0&&0===e.val().length&&e.val(V.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3])}))})),$((function(){0===$(".user.signin").length&&$("form:not(.ignore-dirty)").areYouSure(),$("#ssh-key-content").on("change paste keyup",(function(){var e=$(this).val().split(" "),t=$("#ssh-key-title");""===t.val()&&3===e.length&&""!==e[2]&&t.val(e[2])}))})),window.timeAddManual=function(){$(".mini.modal").modal({duration:200,onApprove:function(){$("#add_time_manual_form").submit()}}).modal("show")},window.toggleStopwatch=function(){$("#toggle_stopwatch_form").submit()},window.cancelStopwatch=function(){$("#cancel_stopwatch_form").submit()},window.initHeatmap=function(e,t,n){var a=document.getElementById(e);if(a){(n=n||{}).contributions=n.contributions||"contributions",n.no_contributions=n.no_contributions||"No contributions";var i=["${","}"];Vue.component("activity-heatmap",{delimiters:i,props:{user:{type:String,required:!0},suburl:{type:String,required:!0},locale:{type:Object,required:!0}},data:function(){return{isLoading:!0,colorRange:[],endDate:null,values:[],totalContributions:0}},mounted:function(){this.colorRange=[this.getColor(0),this.getColor(1),this.getColor(2),this.getColor(3),this.getColor(4),this.getColor(5)],this.endDate=new Date,this.loadHeatmap(this.user)},methods:{loadHeatmap:function(e){var t=this;$.get("".concat(this.suburl,"/api/v1/users/").concat(e,"/heatmap"),(function(e){for(var n=[],a=0;a

total contributions in the last 12 months

'}),new Vue({delimiters:i,el:a,data:{suburl:document.querySelector("meta[name=_suburl]").content,heatmapUser:t,locale:n}})}},$(".commit-button").click((function(e){e.preventDefault(),$(this).parent().find(".commit-body").toggle()})),window.toggleDeadlineForm=function(){$("#deadlineForm").fadeToggle(150)},window.setDeadline=function(){var e=$("#deadlineDate").val();window.updateDeadline(e)},window.updateDeadline=function(e){$("#deadline-err-invalid-date").hide(),$("#deadline-loader").addClass("loading");var t=null;if(""!==e){var n=Date.parse(e);if(Number.isNaN(n))return $("#deadline-loader").removeClass("loading"),$("#deadline-err-invalid-date").show(),!1;t=new Date(n)}$.ajax("".concat($("#update-issue-deadline-form").attr("action"),"/deadline"),{data:JSON.stringify({due_date:t}),headers:{"X-Csrf-Token":a,"X-Remote":!0},contentType:"application/json",type:"POST",success:function(){v()},error:function(){$("#deadline-loader").removeClass("loading"),$("#deadline-err-invalid-date").show()}})},window.deleteDependencyModal=function(e,t){$(".remove-dependency").modal({closable:!1,duration:200,onApprove:function(){$("#removeDependencyID").val(e),$("#dependencyType").val(t),$("#removeDependencyForm").submit()}}).modal("show")},window.cancelCodeComment=function(e){var t=$(e).closest("form");t.length>0&&t.hasClass("comment-form")?(t.addClass("hide"),t.parent().find("button.comment-form-reply").show()):t.closest(".comment-code-cloud").remove()},window.onOAuthLoginClick=function(){var e=$("#oauth2-login-loader"),t=$("#oauth2-login-navigator");t.hide(),e.removeClass("disabled"),setTimeout((function(){e.addClass("disabled"),t.show()}),5e3)}}]); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/public/js/index.js.map b/public/js/index.js.map index b0f2ca699cfd9..34d4418612aff 100644 --- a/public/js/index.js.map +++ b/public/js/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/regenerator/index.js","webpack:///./node_modules/@babel/runtime/helpers/slicedToArray.js","webpack:///./web_src/js/publicPath.js","webpack:///./node_modules/regenerator-runtime/runtime.js","webpack:///./node_modules/@babel/runtime/helpers/arrayWithHoles.js","webpack:///./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","webpack:///./node_modules/@babel/runtime/helpers/nonIterableRest.js","webpack:///./web_src/js/index.js","webpack:///./web_src/js/gitGraph.js"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","installedModules","1","__webpack_require__","exports","module","l","e","promises","installedChunkData","promise","Promise","resolve","reject","onScriptComplete","script","document","createElement","charset","timeout","nc","setAttribute","src","p","jsonpScriptSrc","error","Error","event","onerror","onload","clearTimeout","chunk","errorType","type","realSrc","target","message","name","request","undefined","setTimeout","head","appendChild","all","m","c","d","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","oe","err","console","jsonpArray","window","oldJsonpFunction","slice","s","arrayWithHoles","iterableToArrayLimit","nonIterableRest","arr","currentScript","url","URL","__webpack_public_path__","pathname","replace","querySelector","getAttribute","runtime","Op","hasOwn","$Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","wrap","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","context","Context","_invoke","state","GenStateSuspendedStart","method","arg","GenStateExecuting","GenStateCompleted","doneResult","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","done","GenStateSuspendedYield","makeInvokeMethod","fn","obj","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","this","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","previousPromise","callInvokeWithMethodAndArg","invoke","result","__await","then","unwrapped","TypeError","info","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","constructor","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","async","iter","toString","keys","reverse","pop","skipTempReset","prev","charAt","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","thrown","delegateYield","regeneratorRuntime","accidentalStrictMode","Function","Array","isArray","_arr","_n","_d","_e","_s","_i","csrf","suburl","previewFileModes","simpleMDEditor","codeMirrorEditor","htmlEncode","text","jQuery","html","initCommentPreviewTab","$form","$tabMenu","find","tab","click","$this","$","post","_csrf","val","$previewPanel","emojify","run","each","hljs","highlightBlock","buttonsClickOnEnter","initEditForm","$previewTab","split","initEditPreviewTab","content","$diffPreviewPanel","updateIssuesMeta","action","issueIds","elementId","ajax","issue_ids","id","success","reload","location","initImagePaste","field","addEventListener","pasteEvent","callback","clipboardData","items","indexOf","blob","getAsFile","preventDefault","stopPropagation","retrieveImageFromClipboardAsBlob","img","substr","lastIndexOf","selectionStart","startPos","endPos","selectionEnd","substring","insertAtCursor","file","xhr","XMLHttpRequest","status","responseText","open","setRequestHeader","formData","FormData","append","send","uploadFile","res","JSON","parse","oldval","newval","replaceAndKeepCursor","uuid","input","initCommentForm","$selectBranch","selectedValue","css","removeClass","addClass","initListSubmits","selectItem","selector","outerSelector","$list","$noSelect","$listMenu","hasLabelUpdateAction","labels","dropdown","label","hasClass","listIds","parent","join","select_id","input_id","$menu","hasUpdateAction","initRepository","$data","searchTerm","noResults","canCreateBranch","menuVisible","active","branch","tag","selected","remove","Vue","delimiters","el","beforeMount","vm","$el","body","contains","set","watch","visible","focusSearchField","computed","filteredItems","filter","item","toLowerCase","showCreateNewBranch","showNoResults","methods","getSelected","href","createNewBranch","$refs","newBranchForm","submit","nextTick","searchField","focus","j","getSelectedIndexInFiltered","scrollToActive","cont","scrollContainer","offsetTop","scrollTop","clientHeight","keydown","keyCode","initFilterSearchDropdown","keyup","$prompt","show","hide","change","checked","$newLabelPanel","minicolors","color_hex","modal","onApprove","$datepicker","datetimepicker","lang","inline","timepicker","startDate","formatDate","onSelectDate","ct","dateFormat","$issueTitle","$editInput","editTitleToggle","toggle","title","$textarea","$segment","$editContentZone","$renderContent","$rawContent","issuesTribute","attach","emojiTribute","$dropzone","$files","filenameDict","dropzone","headers","maxFiles","maxFilesize","acceptedFiles","addRemoveLinks","dictDefaultMessage","dictInvalidFileType","dictFileTooBig","dictRemoveFile","init","on","submitted","getJSON","drop","removeAllFiles","empty","imgSrc","emit","files","$editContentForm","attr","$attachments","map","$content","attachments","confirm","$statusButton","$mergeButton","onChange","_text","_value","$choice","closest","initReactionSelector","reactions","popup","position","metadata","actionURL","resp","react","insertBefore","appendTo","hasEmoji","$item","addLine","delLine","addPercent","parseFloat","localStorage","setItem","select","$repoComparePull","$dropdown","fullTextSearch","selectOnKeydown","assingMenuAttributes","menu","Math","floor","random","initRepositoryCollaboration","uid","initEditor","prop","$editFilename","parts","$section","$divider","getCursorPosition","last","setSelectionRange","element","trigger","$editArea","markdownFileExts","lineWrapExtensions","spec","extension","extWithDot","dataUrl","apiCall","exec","CodeMirror","findModeByExtension","previewLink","mime","toTextArea","SimpleMDE","autoDownloadFontAwesome","forceSync","renderingConfig","singleLineBreaks","indentWithTabs","tabSize","spellChecker","previewRender","plainText","preview","innerHTML","toolbar","setSimpleMDE","fromTextArea","lineNumbers","cm","_change","getValue","setCodeMirror","setOption","autoLoadMode","editorconfig","indent_style","Tab","spaces","parseInt","getOption","replaceSelection","indent_size","tab_width","$commitButton","$editForm","areYouSure","silent","dirtyClass","fieldSelector","dirty","initUserSettings","keypress","initCodeView","$select","siblings","selectRange","shiftKey","eq","getSelection","removeAllRanges","selection","$first","hash","match","offset","top","$foldButton","slideUp","slideDown","insertBlobExcerpt","$blob","$row","replaceWith","u2fSigned","stringify","contentType","fail","u2fError","u2fRegistered","errorCode","checkError","u2fErrors","browser","2","3","4","5","u2fRegisterRequest","req","registeredKeys","u2fApi","register","appId","registerRequests","catch","reason","metaData","code","changeHash","history","pushState","$from","a","b","classes","showDeletePopup","dialog","closable","redirect","showAddAllPopup","graphCanvas","getElementById","gitGraph","default","graphList","Dropzone","autoDiscover","pos","Sel","createRange","SelLength","moveStart","ready","onShow","transition","direction","accordion","checkbox","progress","showActivity","slideToggle","nodes","querySelectorAll","setConfig","img_dir","ignore_emoticons","getElementsByClassName","childNodes","nodeName","$searchTeamBox","$searchRepoBox","toggleMigrations","isExpanded","mgrBtn","editDiv","viewDiv","saveBtn","topicDropdown","topicForm","topicPrompts","hidePrompt","prompts","clipboard","Clipboard","clearSelection","node","encodeURIComponent","children","dataset","issueIDs","issueId","_","first","search","minCharacters","apiSettings","onResponse","response","login","full_name","image","avatar_url","results","searchFields","permission","description","dbType","dbDefaults","MySQL","PostgreSQL","MSSQL","_type","defaultHost","is","authUserName","cloneAddr","startsWith","sideBySideChanges","sideBySideTimeout","simplemde","render","isSideBySideActive","codemirror","cursorPos","getCursor","setCursor","line","ch","className","getInputField","$bEdit","$bPrev","$toolbar","$bPreview","$bSideBySide","initWikiForm","updateContentType","initWebhook","removeAttr","authType","onOAuth2Change","onSecurityProtocolChange","onUsePagedSearchChange","onOAuth2UseCustomURLChange","$detailModal","$checkboxes","ids","provider","initAdmin","component","props","searchLimit","Number","String","required","organizations","isOrganization","Boolean","canCreateOrganization","organizationsTotalCount","moreReposLink","repos","reposTotalCount","reposFilter","searchQuery","isLoading","repoTypes","count","searchMode","forks","mirrors","sources","collaborative","showMoreReposLink","searchURL","repoTypeCount","mounted","searchRepos","changeTab","changeReposFilter","showRepo","repo","owner","mirror","fork","searchedMode","searchedURL","searchedQuery","_textStatus","getResponseHeader","always","repoClass","private","initVueApp","ctrlKey","altKey","metaKey","countPrompt","formatPrompt","topics","_data","responseJSON","topicArray","invalidTopics","topicLables","index","form","allowAdditions","forceSelection","fields","saveRemoteData","duration","variation","blue","basic","throttle","cache","formattedResponse","query","urlData","trim","found_query","current_topics","found","topic_name","unshift","sort","onLabelCreate","contents","onAdd","addedValue","_addedText","$addedChoice","settings","rules","validateTopic","_values","regExp","identifier","prompt","ensureSupport","sign","challenge","allowMultiple","repolink","repoId","crossRepoSearch","issueSearchUrl","filteredResponse","currIssueId","issue","number","repository","regStr","RegExp","selectedItems","initIssueList","toUpperCase","wipPrefixes","sticky","isSplit","side","idx","path","tr","ntr","after","td","commentCloud","initRepoStatusChecker","migrating","repo_name","$repoTemplate","checkTemplate","$templateUnits","$nonTemplate","changeOwner","_r","initTemplateSearch","getItem","routes","$cloneAddr","$repoName","arrays","$title","timeAddManual","toggleStopwatch","cancelStopwatch","initHeatmap","appElementId","heatmapUser","locale","contributions","no_contributions","vueDelimeters","user","colorRange","endDate","totalContributions","getColor","Date","loadHeatmap","userName","chartRawData","chartData","date","timestamp","color","getComputedStyle","backgroundColor","removeChild","template","toggleDeadlineForm","fadeToggle","setDeadline","deadline","updateDeadline","deadlineString","realDeadline","newDate","due_date","deleteDependencyModal","cancelCodeComment","btn","onOAuthLoginClick","oauthLoader","oauthNav"],"mappings":"aACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GAKAK,EAAI,EAAGC,EAAW,GACpCD,EAAIF,EAASI,OAAQF,IACzBH,EAAUC,EAASE,GAChBG,OAAOC,UAAUC,eAAeC,KAAKC,EAAiBV,IAAYU,EAAgBV,IACpFI,EAASO,KAAKD,EAAgBV,GAAS,IAExCU,EAAgBV,GAAW,EAE5B,IAAID,KAAYG,EACZI,OAAOC,UAAUC,eAAeC,KAAKP,EAAaH,KACpDa,EAAQb,GAAYG,EAAYH,IAKlC,IAFGc,GAAqBA,EAAoBf,GAEtCM,EAASC,QACdD,EAASU,OAATV,GAOF,IAAIW,EAAmB,GAKnBL,EAAkB,CACrBM,EAAG,GAWJ,SAASC,EAAoBlB,GAG5B,GAAGgB,EAAiBhB,GACnB,OAAOgB,EAAiBhB,GAAUmB,QAGnC,IAAIC,EAASJ,EAAiBhB,GAAY,CACzCI,EAAGJ,EACHqB,GAAG,EACHF,QAAS,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E,oBAAoByE,YAAY,WAClCzE,EAAE,8BAA8BmJ,WAKtC9S,OAAOqyB,sBAAwB,SAAUnnB,EAAIvN,GAC3CgM,EAAE,sBACC0J,MAAM,CACLoN,UAAU,EACV8K,SAAU,IACVjY,UAHK,WAIH3J,EAAE,uBAAuBG,IAAIoB,GAC7BvB,EAAE,mBAAmBG,IAAInM,GACzBgM,EAAE,yBAAyBkI,YAE5BwB,MAAM,SAwEbrT,OAAOsyB,kBAAoB,SAAUC,GACnC,IAAMrH,EAAOvhB,EAAE4oB,GAAKrb,QAAQ,QACxBgU,EAAKjwB,OAAS,GAAKiwB,EAAKjc,SAAS,iBACnCic,EAAK7c,SAAS,QACd6c,EAAK/b,SAAS5F,KAAK,6BAA6BuJ,QAEhDoY,EAAKhU,QAAQ,uBAAuB/G,UAGxCnQ,OAAOwyB,kBAAoB,WACzB,IAAMC,EAAc9oB,EAAE,wBAChB+oB,EAAW/oB,EAAE,2BAEnB+oB,EAAS3f,OACT0f,EAAYrkB,YAAY,YAExBlQ,YAAW,WAGTu0B,EAAYpkB,SAAS,YACrBqkB,EAAS5f,SACR","file":"index.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t};\n\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t1: 0\n \t};\n\n\n\n \t// script path function\n \tfunction jsonpScriptSrc(chunkId) {\n \t\treturn __webpack_require__.p + \"\" + ({\"0\":\"gitgraph\"}[chunkId]||chunkId) + \".js\"\n \t}\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tvar promises = [];\n\n\n \t\t// JSONP chunk loading for javascript\n\n \t\tvar installedChunkData = installedChunks[chunkId];\n \t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n \t\t\t// a Promise means \"currently loading\".\n \t\t\tif(installedChunkData) {\n \t\t\t\tpromises.push(installedChunkData[2]);\n \t\t\t} else {\n \t\t\t\t// setup Promise in chunk cache\n \t\t\t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\t\t\tinstalledChunkData = installedChunks[chunkId] = [resolve, reject];\n \t\t\t\t});\n \t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n \t\t\t\t// start chunk loading\n \t\t\t\tvar script = document.createElement('script');\n \t\t\t\tvar onScriptComplete;\n\n \t\t\t\tscript.charset = 'utf-8';\n \t\t\t\tscript.timeout = 120;\n \t\t\t\tif (__webpack_require__.nc) {\n \t\t\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t\t\t}\n \t\t\t\tscript.src = jsonpScriptSrc(chunkId);\n\n \t\t\t\t// create error before stack unwound to get useful stacktrace later\n \t\t\t\tvar error = new Error();\n \t\t\t\tonScriptComplete = function (event) {\n \t\t\t\t\t// avoid mem leaks in IE.\n \t\t\t\t\tscript.onerror = script.onload = null;\n \t\t\t\t\tclearTimeout(timeout);\n \t\t\t\t\tvar chunk = installedChunks[chunkId];\n \t\t\t\t\tif(chunk !== 0) {\n \t\t\t\t\t\tif(chunk) {\n \t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n \t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n \t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n \t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n \t\t\t\t\t\t\terror.type = errorType;\n \t\t\t\t\t\t\terror.request = realSrc;\n \t\t\t\t\t\t\tchunk[1](error);\n \t\t\t\t\t\t}\n \t\t\t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t\t\t}\n \t\t\t\t};\n \t\t\t\tvar timeout = setTimeout(function(){\n \t\t\t\t\tonScriptComplete({ type: 'timeout', target: script });\n \t\t\t\t}, 120000);\n \t\t\t\tscript.onerror = script.onload = onScriptComplete;\n \t\t\t\tdocument.head.appendChild(script);\n \t\t\t}\n \t\t}\n \t\treturn Promise.all(promises);\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","module.exports = require(\"regenerator-runtime\");\n","var arrayWithHoles = require(\"./arrayWithHoles\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit\");\n\nvar nonIterableRest = require(\"./nonIterableRest\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray;","/* This sets up webpack's chunk loading to load resources from the same\n directory where it loaded index.js from. This file must be imported\n before any lazy-loading is being attempted. */\n\nif (document.currentScript && document.currentScript.src) {\n const url = new URL(document.currentScript.src);\n __webpack_public_path__ = `${url.pathname.replace(/\\/[^/]*$/, '')}/`;\n} else {\n // compat: IE11\n const script = document.querySelector('script[src*=\"/index.js\"]');\n __webpack_public_path__ = `${script.getAttribute('src').replace(/\\/[^/]*$/, '')}/`;\n}\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles;","function _iterableToArrayLimit(arr, i) {\n if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) {\n return;\n }\n\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n}\n\nmodule.exports = _nonIterableRest;","/* globals wipPrefixes, issuesTribute, emojiTribute */\n/* exported timeAddManual, toggleStopwatch, cancelStopwatch, initHeatmap */\n/* exported toggleDeadlineForm, setDeadline, updateDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */\n\nimport './publicPath';\nimport './gitGraph';\n\nfunction htmlEncode(text) {\n return jQuery('
').text(text).html();\n}\n\nlet csrf;\nlet suburl;\nlet previewFileModes;\nlet simpleMDEditor;\nlet codeMirrorEditor;\n\n// Disable Dropzone auto-discover because it's manually initialized\nif (typeof (Dropzone) !== 'undefined') {\n Dropzone.autoDiscover = false;\n}\n\nfunction initCommentPreviewTab($form) {\n const $tabMenu = $form.find('.tabular.menu');\n $tabMenu.find('.item').tab();\n $tabMenu.find(`.item[data-tab=\"${$tabMenu.data('preview')}\"]`).click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $this.data('context'),\n text: $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('write')}\"] textarea`).val()\n }, (data) => {\n const $previewPanel = $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('preview')}\"]`);\n $previewPanel.html(data);\n emojify.run($previewPanel[0]);\n $('pre code', $previewPanel[0]).each(function () {\n hljs.highlightBlock(this);\n });\n });\n });\n\n buttonsClickOnEnter();\n}\n\nfunction initEditPreviewTab($form) {\n const $tabMenu = $form.find('.tabular.menu');\n $tabMenu.find('.item').tab();\n const $previewTab = $tabMenu.find(`.item[data-tab=\"${$tabMenu.data('preview')}\"]`);\n if ($previewTab.length) {\n previewFileModes = $previewTab.data('preview-file-modes').split(',');\n $previewTab.click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $this.data('context'),\n text: $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('write')}\"] textarea`).val()\n }, (data) => {\n const $previewPanel = $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('preview')}\"]`);\n $previewPanel.html(data);\n emojify.run($previewPanel[0]);\n $('pre code', $previewPanel[0]).each(function () {\n hljs.highlightBlock(this);\n });\n });\n });\n }\n}\n\nfunction initEditDiffTab($form) {\n const $tabMenu = $form.find('.tabular.menu');\n $tabMenu.find('.item').tab();\n $tabMenu.find(`.item[data-tab=\"${$tabMenu.data('diff')}\"]`).click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n context: $this.data('context'),\n content: $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('write')}\"] textarea`).val()\n }, (data) => {\n const $diffPreviewPanel = $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('diff')}\"]`);\n $diffPreviewPanel.html(data);\n emojify.run($diffPreviewPanel[0]);\n });\n });\n}\n\n\nfunction initEditForm() {\n if ($('.edit.form').length === 0) {\n return;\n }\n\n initEditPreviewTab($('.edit.form'));\n initEditDiffTab($('.edit.form'));\n}\n\nfunction initBranchSelector() {\n const $selectBranch = $('.ui.select-branch');\n const $branchMenu = $selectBranch.find('.reference-list-menu');\n $branchMenu.find('.item:not(.no-select)').click(function () {\n const selectedValue = $(this).data('id');\n $($(this).data('id-selector')).val(selectedValue);\n $selectBranch.find('.ui .branch-name').text(selectedValue);\n });\n $selectBranch.find('.reference.column').click(function () {\n $selectBranch.find('.scrolling.reference-list-menu').css('display', 'none');\n $selectBranch.find('.reference .text').removeClass('black');\n $($(this).data('target')).css('display', 'block');\n $(this).find('.text').addClass('black');\n return false;\n });\n}\n\nfunction updateIssuesMeta(url, action, issueIds, elementId) {\n return new Promise(((resolve) => {\n $.ajax({\n type: 'POST',\n url,\n data: {\n _csrf: csrf,\n action,\n issue_ids: issueIds,\n id: elementId\n },\n success: resolve\n });\n }));\n}\n\nfunction initRepoStatusChecker() {\n const migrating = $('#repo_migrating');\n $('#repo_migrating_failed').hide();\n if (migrating) {\n const repo_name = migrating.attr('repo');\n if (typeof repo_name === 'undefined') {\n return;\n }\n $.ajax({\n type: 'GET',\n url: `${suburl}/${repo_name}/status`,\n data: {\n _csrf: csrf,\n },\n complete(xhr) {\n if (xhr.status === 200) {\n if (xhr.responseJSON) {\n if (xhr.responseJSON.status === 0) {\n window.location.reload();\n return;\n }\n\n setTimeout(() => {\n initRepoStatusChecker();\n }, 2000);\n return;\n }\n }\n $('#repo_migrating_progress').hide();\n $('#repo_migrating_failed').show();\n }\n });\n }\n}\n\nfunction initReactionSelector(parent) {\n let reactions = '';\n if (!parent) {\n parent = $(document);\n reactions = '.reactions > ';\n }\n\n parent.find(`${reactions}a.label`).popup({ position: 'bottom left', metadata: { content: 'title', title: 'none' } });\n\n parent.find(`.select-reaction > .menu > .item, ${reactions}a.label`).on('click', function (e) {\n const vm = this;\n e.preventDefault();\n\n if ($(this).hasClass('disabled')) return;\n\n const actionURL = $(this).hasClass('item')\n ? $(this).closest('.select-reaction').data('action-url')\n : $(this).data('action-url');\n const url = `${actionURL}/${$(this).hasClass('blue') ? 'unreact' : 'react'}`;\n $.ajax({\n type: 'POST',\n url,\n data: {\n _csrf: csrf,\n content: $(this).data('content')\n }\n }).done((resp) => {\n if (resp && (resp.html || resp.empty)) {\n const content = $(vm).closest('.content');\n let react = content.find('.segment.reactions');\n if (!resp.empty && react.length > 0) {\n react.remove();\n }\n if (!resp.empty) {\n react = $('
');\n const attachments = content.find('.segment.bottom:first');\n if (attachments.length > 0) {\n react.insertBefore(attachments);\n } else {\n react.appendTo(content);\n }\n react.html(resp.html);\n const hasEmoji = react.find('.has-emoji');\n for (let i = 0; i < hasEmoji.length; i++) {\n emojify.run(hasEmoji.get(i));\n }\n react.find('.dropdown').dropdown();\n initReactionSelector(react);\n }\n }\n });\n });\n}\n\nfunction insertAtCursor(field, value) {\n if (field.selectionStart || field.selectionStart === 0) {\n const startPos = field.selectionStart;\n const endPos = field.selectionEnd;\n field.value = field.value.substring(0, startPos)\n + value\n + field.value.substring(endPos, field.value.length);\n field.selectionStart = startPos + value.length;\n field.selectionEnd = startPos + value.length;\n } else {\n field.value += value;\n }\n}\n\nfunction replaceAndKeepCursor(field, oldval, newval) {\n if (field.selectionStart || field.selectionStart === 0) {\n const startPos = field.selectionStart;\n const endPos = field.selectionEnd;\n field.value = field.value.replace(oldval, newval);\n field.selectionStart = startPos + newval.length - oldval.length;\n field.selectionEnd = endPos + newval.length - oldval.length;\n } else {\n field.value = field.value.replace(oldval, newval);\n }\n}\n\nfunction retrieveImageFromClipboardAsBlob(pasteEvent, callback) {\n if (!pasteEvent.clipboardData) {\n return;\n }\n\n const { items } = pasteEvent.clipboardData;\n if (typeof items === 'undefined') {\n return;\n }\n\n for (let i = 0; i < items.length; i++) {\n if (items[i].type.indexOf('image') === -1) continue;\n const blob = items[i].getAsFile();\n\n if (typeof (callback) === 'function') {\n pasteEvent.preventDefault();\n pasteEvent.stopPropagation();\n callback(blob);\n }\n }\n}\n\nfunction uploadFile(file, callback) {\n const xhr = new XMLHttpRequest();\n\n xhr.onload = function () {\n if (xhr.status === 200) {\n callback(xhr.responseText);\n }\n };\n\n xhr.open('post', `${suburl}/attachments`, true);\n xhr.setRequestHeader('X-Csrf-Token', csrf);\n const formData = new FormData();\n formData.append('file', file, file.name);\n xhr.send(formData);\n}\n\nfunction reload() {\n window.location.reload();\n}\n\nfunction initImagePaste(target) {\n target.each(function () {\n const field = this;\n field.addEventListener('paste', (event) => {\n retrieveImageFromClipboardAsBlob(event, (img) => {\n const name = img.name.substr(0, img.name.lastIndexOf('.'));\n insertAtCursor(field, `![${name}]()`);\n uploadFile(img, (res) => {\n const data = JSON.parse(res);\n replaceAndKeepCursor(field, `![${name}]()`, `![${name}](${suburl}/attachments/${data.uuid})`);\n const input = $(``).val(data.uuid);\n $('.files').append(input);\n });\n });\n }, false);\n });\n}\n\nfunction initCommentForm() {\n if ($('.comment.form').length === 0) {\n return;\n }\n\n initBranchSelector();\n initCommentPreviewTab($('.comment.form'));\n initImagePaste($('.comment.form textarea'));\n\n // Listsubmit\n function initListSubmits(selector, outerSelector) {\n const $list = $(`.ui.${outerSelector}.list`);\n const $noSelect = $list.find('.no-select');\n const $listMenu = $(`.${selector} .menu`);\n let hasLabelUpdateAction = $listMenu.data('action') === 'update';\n const labels = {};\n\n $(`.${selector}`).dropdown('setting', 'onHide', () => {\n hasLabelUpdateAction = $listMenu.data('action') === 'update'; // Update the var\n if (hasLabelUpdateAction) {\n const promises = [];\n Object.keys(labels).forEach((elementId) => {\n const label = labels[elementId];\n const promise = updateIssuesMeta(\n label['update-url'],\n label.action,\n label['issue-id'],\n elementId\n );\n promises.push(promise);\n });\n Promise.all(promises).then(reload);\n }\n });\n\n $listMenu.find('.item:not(.no-select)').click(function () {\n // we don't need the action attribute when updating assignees\n if (selector === 'select-assignees-modify') {\n // UI magic. We need to do this here, otherwise it would destroy the functionality of\n // adding/removing labels\n if ($(this).hasClass('checked')) {\n $(this).removeClass('checked');\n $(this).find('.octicon').removeClass('octicon-check');\n } else {\n $(this).addClass('checked');\n $(this).find('.octicon').addClass('octicon-check');\n }\n\n updateIssuesMeta(\n $listMenu.data('update-url'),\n '',\n $listMenu.data('issue-id'),\n $(this).data('id')\n );\n $listMenu.data('action', 'update'); // Update to reload the page when we updated items\n return false;\n }\n\n if ($(this).hasClass('checked')) {\n $(this).removeClass('checked');\n $(this).find('.octicon').removeClass('octicon-check');\n if (hasLabelUpdateAction) {\n if (!($(this).data('id') in labels)) {\n labels[$(this).data('id')] = {\n 'update-url': $listMenu.data('update-url'),\n action: 'detach',\n 'issue-id': $listMenu.data('issue-id'),\n };\n } else {\n delete labels[$(this).data('id')];\n }\n }\n } else {\n $(this).addClass('checked');\n $(this).find('.octicon').addClass('octicon-check');\n if (hasLabelUpdateAction) {\n if (!($(this).data('id') in labels)) {\n labels[$(this).data('id')] = {\n 'update-url': $listMenu.data('update-url'),\n action: 'attach',\n 'issue-id': $listMenu.data('issue-id'),\n };\n } else {\n delete labels[$(this).data('id')];\n }\n }\n }\n\n const listIds = [];\n $(this).parent().find('.item').each(function () {\n if ($(this).hasClass('checked')) {\n listIds.push($(this).data('id'));\n $($(this).data('id-selector')).removeClass('hide');\n } else {\n $($(this).data('id-selector')).addClass('hide');\n }\n });\n if (listIds.length === 0) {\n $noSelect.removeClass('hide');\n } else {\n $noSelect.addClass('hide');\n }\n $($(this).parent().data('id')).val(listIds.join(','));\n return false;\n });\n $listMenu.find('.no-select.item').click(function () {\n if (hasLabelUpdateAction || selector === 'select-assignees-modify') {\n updateIssuesMeta(\n $listMenu.data('update-url'),\n 'clear',\n $listMenu.data('issue-id'),\n ''\n ).then(reload);\n }\n\n $(this).parent().find('.item').each(function () {\n $(this).removeClass('checked');\n $(this).find('.octicon').removeClass('octicon-check');\n });\n\n $list.find('.item').each(function () {\n $(this).addClass('hide');\n });\n $noSelect.removeClass('hide');\n $($(this).parent().data('id')).val('');\n });\n }\n\n // Init labels and assignees\n initListSubmits('select-label', 'labels');\n initListSubmits('select-assignees', 'assignees');\n initListSubmits('select-assignees-modify', 'assignees');\n\n function selectItem(select_id, input_id) {\n const $menu = $(`${select_id} .menu`);\n const $list = $(`.ui${select_id}.list`);\n const hasUpdateAction = $menu.data('action') === 'update';\n\n $menu.find('.item:not(.no-select)').click(function () {\n $(this).parent().find('.item').each(function () {\n $(this).removeClass('selected active');\n });\n\n $(this).addClass('selected active');\n if (hasUpdateAction) {\n updateIssuesMeta(\n $menu.data('update-url'),\n '',\n $menu.data('issue-id'),\n $(this).data('id')\n ).then(reload);\n }\n switch (input_id) {\n case '#milestone_id':\n $list.find('.selected').html(`${\n htmlEncode($(this).text())}`);\n break;\n case '#assignee_id':\n $list.find('.selected').html(``\n + `${\n htmlEncode($(this).text())}`);\n }\n $(`.ui${select_id}.list .no-select`).addClass('hide');\n $(input_id).val($(this).data('id'));\n });\n $menu.find('.no-select.item').click(function () {\n $(this).parent().find('.item:not(.no-select)').each(function () {\n $(this).removeClass('selected active');\n });\n\n if (hasUpdateAction) {\n updateIssuesMeta(\n $menu.data('update-url'),\n '',\n $menu.data('issue-id'),\n $(this).data('id')\n ).then(reload);\n }\n\n $list.find('.selected').html('');\n $list.find('.no-select').removeClass('hide');\n $(input_id).val('');\n });\n }\n\n // Milestone and assignee\n selectItem('.select-milestone', '#milestone_id');\n selectItem('.select-assignee', '#assignee_id');\n}\n\nfunction initInstall() {\n if ($('.install').length === 0) {\n return;\n }\n\n if ($('#db_host').val() === '') {\n $('#db_host').val('127.0.0.1:3306');\n $('#db_user').val('gitea');\n $('#db_name').val('gitea');\n }\n\n // Database type change detection.\n $('#db_type').change(function () {\n const sqliteDefault = 'data/gitea.db';\n const tidbDefault = 'data/gitea_tidb';\n\n const dbType = $(this).val();\n if (dbType === 'SQLite3') {\n $('#sql_settings').hide();\n $('#pgsql_settings').hide();\n $('#mysql_settings').hide();\n $('#sqlite_settings').show();\n\n if (dbType === 'SQLite3' && $('#db_path').val() === tidbDefault) {\n $('#db_path').val(sqliteDefault);\n }\n return;\n }\n\n const dbDefaults = {\n MySQL: '127.0.0.1:3306',\n PostgreSQL: '127.0.0.1:5432',\n MSSQL: '127.0.0.1:1433'\n };\n\n $('#sqlite_settings').hide();\n $('#sql_settings').show();\n\n $('#pgsql_settings').toggle(dbType === 'PostgreSQL');\n $('#mysql_settings').toggle(dbType === 'MySQL');\n $.each(dbDefaults, (_type, defaultHost) => {\n if ($('#db_host').val() === defaultHost) {\n $('#db_host').val(dbDefaults[dbType]);\n return false;\n }\n });\n });\n\n // TODO: better handling of exclusive relations.\n $('#offline-mode input').change(function () {\n if ($(this).is(':checked')) {\n $('#disable-gravatar').checkbox('check');\n $('#federated-avatar-lookup').checkbox('uncheck');\n }\n });\n $('#disable-gravatar input').change(function () {\n if ($(this).is(':checked')) {\n $('#federated-avatar-lookup').checkbox('uncheck');\n } else {\n $('#offline-mode').checkbox('uncheck');\n }\n });\n $('#federated-avatar-lookup input').change(function () {\n if ($(this).is(':checked')) {\n $('#disable-gravatar').checkbox('uncheck');\n $('#offline-mode').checkbox('uncheck');\n }\n });\n $('#enable-openid-signin input').change(function () {\n if ($(this).is(':checked')) {\n if (!$('#disable-registration input').is(':checked')) {\n $('#enable-openid-signup').checkbox('check');\n }\n } else {\n $('#enable-openid-signup').checkbox('uncheck');\n }\n });\n $('#disable-registration input').change(function () {\n if ($(this).is(':checked')) {\n $('#enable-captcha').checkbox('uncheck');\n $('#enable-openid-signup').checkbox('uncheck');\n } else {\n $('#enable-openid-signup').checkbox('check');\n }\n });\n $('#enable-captcha input').change(function () {\n if ($(this).is(':checked')) {\n $('#disable-registration').checkbox('uncheck');\n }\n });\n}\n\nfunction initRepository() {\n if ($('.repository').length === 0) {\n return;\n }\n\n function initFilterSearchDropdown(selector) {\n const $dropdown = $(selector);\n $dropdown.dropdown({\n fullTextSearch: true,\n selectOnKeydown: false,\n onChange(_text, _value, $choice) {\n if ($choice.data('url')) {\n window.location.href = $choice.data('url');\n }\n },\n message: { noResults: $dropdown.data('no-results') }\n });\n }\n\n // File list and commits\n if ($('.repository.file.list').length > 0 || ('.repository.commits').length > 0) {\n initFilterBranchTagDropdown('.choose.reference .dropdown');\n }\n\n // Wiki\n if ($('.repository.wiki.view').length > 0) {\n initFilterSearchDropdown('.choose.page .dropdown');\n }\n\n // Options\n if ($('.repository.settings.options').length > 0) {\n $('#repo_name').keyup(function () {\n const $prompt = $('#repo-name-change-prompt');\n if ($(this).val().toString().toLowerCase() !== $(this).data('name').toString().toLowerCase()) {\n $prompt.show();\n } else {\n $prompt.hide();\n }\n });\n\n // Enable or select internal/external wiki system and issue tracker.\n $('.enable-system').change(function () {\n if (this.checked) {\n $($(this).data('target')).removeClass('disabled');\n if (!$(this).data('context')) $($(this).data('context')).addClass('disabled');\n } else {\n $($(this).data('target')).addClass('disabled');\n if (!$(this).data('context')) $($(this).data('context')).removeClass('disabled');\n }\n });\n $('.enable-system-radio').change(function () {\n if (this.value === 'false') {\n $($(this).data('target')).addClass('disabled');\n if (typeof $(this).data('context') !== 'undefined') $($(this).data('context')).removeClass('disabled');\n } else if (this.value === 'true') {\n $($(this).data('target')).removeClass('disabled');\n if (typeof $(this).data('context') !== 'undefined') $($(this).data('context')).addClass('disabled');\n }\n });\n }\n\n // Labels\n if ($('.repository.labels').length > 0) {\n // Create label\n const $newLabelPanel = $('.new-label.segment');\n $('.new-label.button').click(() => {\n $newLabelPanel.show();\n });\n $('.new-label.segment .cancel').click(() => {\n $newLabelPanel.hide();\n });\n\n $('.color-picker').each(function () {\n $(this).minicolors();\n });\n $('.precolors .color').click(function () {\n const color_hex = $(this).data('color-hex');\n $('.color-picker').val(color_hex);\n $('.minicolors-swatch-color').css('background-color', color_hex);\n });\n $('.edit-label-button').click(function () {\n $('#label-modal-id').val($(this).data('id'));\n $('.edit-label .new-label-input').val($(this).data('title'));\n $('.edit-label .new-label-desc-input').val($(this).data('description'));\n $('.edit-label .color-picker').val($(this).data('color'));\n $('.minicolors-swatch-color').css('background-color', $(this).data('color'));\n $('.edit-label.modal').modal({\n onApprove() {\n $('.edit-label.form').submit();\n }\n }).modal('show');\n return false;\n });\n }\n\n // Milestones\n if ($('.repository.new.milestone').length > 0) {\n const $datepicker = $('.milestone.datepicker');\n $datepicker.datetimepicker({\n lang: $datepicker.data('lang'),\n inline: true,\n timepicker: false,\n startDate: $datepicker.data('start-date'),\n formatDate: 'Y-m-d',\n onSelectDate(ct) {\n $('#deadline').val(ct.dateFormat('Y-m-d'));\n }\n });\n $('#clear-date').click(() => {\n $('#deadline').val('');\n return false;\n });\n }\n\n // Issues\n if ($('.repository.view.issue').length > 0) {\n // Edit issue title\n const $issueTitle = $('#issue-title');\n const $editInput = $('#edit-title-input input');\n const editTitleToggle = function () {\n $issueTitle.toggle();\n $('.not-in-edit').toggle();\n $('#edit-title-input').toggle();\n $('.in-edit').toggle();\n $editInput.focus();\n return false;\n };\n $('#edit-title').click(editTitleToggle);\n $('#cancel-edit-title').click(editTitleToggle);\n $('#save-edit-title').click(editTitleToggle).click(function () {\n if ($editInput.val().length === 0 || $editInput.val() === $issueTitle.text()) {\n $editInput.val($issueTitle.text());\n return false;\n }\n\n $.post($(this).data('update-url'), {\n _csrf: csrf,\n title: $editInput.val()\n },\n (data) => {\n $editInput.val(data.title);\n $issueTitle.text(data.title);\n reload();\n });\n return false;\n });\n\n // Edit issue or comment content\n $('.edit-content').click(function () {\n const $segment = $(this).parent().parent().parent()\n .next();\n const $editContentZone = $segment.find('.edit-content-zone');\n const $renderContent = $segment.find('.render-content');\n const $rawContent = $segment.find('.raw-content');\n let $textarea;\n\n // Setup new form\n if ($editContentZone.html().length === 0) {\n $editContentZone.html($('#edit-content-form').html());\n $textarea = $editContentZone.find('textarea');\n issuesTribute.attach($textarea.get());\n emojiTribute.attach($textarea.get());\n\n const $dropzone = $editContentZone.find('.dropzone');\n $dropzone.data('saved', false);\n const $files = $editContentZone.find('.comment-files');\n if ($dropzone.length > 0) {\n const filenameDict = {};\n $dropzone.dropzone({\n url: $dropzone.data('upload-url'),\n headers: { 'X-Csrf-Token': csrf },\n maxFiles: $dropzone.data('max-file'),\n maxFilesize: $dropzone.data('max-size'),\n acceptedFiles: ($dropzone.data('accepts') === '*/*') ? null : $dropzone.data('accepts'),\n addRemoveLinks: true,\n dictDefaultMessage: $dropzone.data('default-message'),\n dictInvalidFileType: $dropzone.data('invalid-input-type'),\n dictFileTooBig: $dropzone.data('file-too-big'),\n dictRemoveFile: $dropzone.data('remove-file'),\n init() {\n this.on('success', (file, data) => {\n filenameDict[file.name] = {\n uuid: data.uuid,\n submitted: false\n };\n const input = $(``).val(data.uuid);\n $files.append(input);\n });\n this.on('removedfile', (file) => {\n if (!(file.name in filenameDict)) {\n return;\n }\n $(`#${filenameDict[file.name].uuid}`).remove();\n if ($dropzone.data('remove-url') && $dropzone.data('csrf') && !filenameDict[file.name].submitted) {\n $.post($dropzone.data('remove-url'), {\n file: filenameDict[file.name].uuid,\n _csrf: $dropzone.data('csrf')\n });\n }\n });\n this.on('submit', () => {\n $.each(filenameDict, (name) => {\n filenameDict[name].submitted = true;\n });\n });\n this.on('reload', () => {\n $.getJSON($editContentZone.data('attachment-url'), (data) => {\n const drop = $dropzone.get(0).dropzone;\n drop.removeAllFiles(true);\n $files.empty();\n $.each(data, function () {\n const imgSrc = `${$dropzone.data('upload-url')}/${this.uuid}`;\n drop.emit('addedfile', this);\n drop.emit('thumbnail', this, imgSrc);\n drop.emit('complete', this);\n drop.files.push(this);\n filenameDict[this.name] = {\n submitted: true,\n uuid: this.uuid\n };\n $dropzone.find(`img[src='${imgSrc}']`).css('max-width', '100%');\n const input = $(``).val(this.uuid);\n $files.append(input);\n });\n });\n });\n }\n });\n $dropzone.get(0).dropzone.emit('reload');\n }\n // Give new write/preview data-tab name to distinguish from others\n const $editContentForm = $editContentZone.find('.ui.comment.form');\n const $tabMenu = $editContentForm.find('.tabular.menu');\n $tabMenu.attr('data-write', $editContentZone.data('write'));\n $tabMenu.attr('data-preview', $editContentZone.data('preview'));\n $tabMenu.find('.write.item').attr('data-tab', $editContentZone.data('write'));\n $tabMenu.find('.preview.item').attr('data-tab', $editContentZone.data('preview'));\n $editContentForm.find('.write.segment').attr('data-tab', $editContentZone.data('write'));\n $editContentForm.find('.preview.segment').attr('data-tab', $editContentZone.data('preview'));\n\n initCommentPreviewTab($editContentForm);\n\n $editContentZone.find('.cancel.button').click(() => {\n $renderContent.show();\n $editContentZone.hide();\n $dropzone.get(0).dropzone.emit('reload');\n });\n $editContentZone.find('.save.button').click(() => {\n $renderContent.show();\n $editContentZone.hide();\n const $attachments = $files.find('[name=files]').map(function () {\n return $(this).val();\n }).get();\n $.post($editContentZone.data('update-url'), {\n _csrf: csrf,\n content: $textarea.val(),\n context: $editContentZone.data('context'),\n files: $attachments\n }, (data) => {\n if (data.length === 0) {\n $renderContent.html($('#no-content').html());\n } else {\n $renderContent.html(data.content);\n emojify.run($renderContent[0]);\n $('pre code', $renderContent[0]).each(function () {\n hljs.highlightBlock(this);\n });\n }\n const $content = $segment.parent();\n if (!$content.find('.ui.small.images').length) {\n if (data.attachments !== '') {\n $content.append(\n '
'\n );\n $content.find('.ui.small.images').html(data.attachments);\n }\n } else if (data.attachments === '') {\n $content.find('.ui.small.images').parent().remove();\n } else {\n $content.find('.ui.small.images').html(data.attachments);\n }\n $dropzone.get(0).dropzone.emit('submit');\n $dropzone.get(0).dropzone.emit('reload');\n });\n });\n } else {\n $textarea = $segment.find('textarea');\n }\n\n // Show write/preview tab and copy raw content as needed\n $editContentZone.show();\n $renderContent.hide();\n if ($textarea.val().length === 0) {\n $textarea.val($rawContent.text());\n }\n $textarea.focus();\n return false;\n });\n\n // Delete comment\n $('.delete-comment').click(function () {\n const $this = $(this);\n if (window.confirm($this.data('locale'))) {\n $.post($this.data('url'), {\n _csrf: csrf\n }).success(() => {\n $(`#${$this.data('comment-id')}`).remove();\n });\n }\n return false;\n });\n\n // Change status\n const $statusButton = $('#status-button');\n $('#comment-form .edit_area').keyup(function () {\n if ($(this).val().length === 0) {\n $statusButton.text($statusButton.data('status'));\n } else {\n $statusButton.text($statusButton.data('status-and-comment'));\n }\n });\n $statusButton.click(() => {\n $('#status').val($statusButton.data('status-val'));\n $('#comment-form').submit();\n });\n\n // Pull Request merge button\n const $mergeButton = $('.merge-button > button');\n $mergeButton.on('click', function (e) {\n e.preventDefault();\n $(`.${$(this).data('do')}-fields`).show();\n $(this).parent().hide();\n });\n $('.merge-button > .dropdown').dropdown({\n onChange(_text, _value, $choice) {\n if ($choice.data('do')) {\n $mergeButton.find('.button-text').text($choice.text());\n $mergeButton.data('do', $choice.data('do'));\n }\n }\n });\n $('.merge-cancel').on('click', function (e) {\n e.preventDefault();\n $(this).closest('.form').hide();\n $mergeButton.parent().show();\n });\n\n initReactionSelector();\n }\n\n // Diff\n if ($('.repository.diff').length > 0) {\n $('.diff-counter').each(function () {\n const $item = $(this);\n const addLine = $item.find('span[data-line].add').data('line');\n const delLine = $item.find('span[data-line].del').data('line');\n const addPercent = parseFloat(addLine) / (parseFloat(addLine) + parseFloat(delLine)) * 100;\n $item.find('.bar .add').css('width', `${addPercent}%`);\n });\n }\n\n // Quick start and repository home\n $('#repo-clone-ssh').click(function () {\n $('.clone-url').text($(this).data('link'));\n $('#repo-clone-url').val($(this).data('link'));\n $(this).addClass('blue');\n $('#repo-clone-https').removeClass('blue');\n localStorage.setItem('repo-clone-protocol', 'ssh');\n });\n $('#repo-clone-https').click(function () {\n $('.clone-url').text($(this).data('link'));\n $('#repo-clone-url').val($(this).data('link'));\n $(this).addClass('blue');\n $('#repo-clone-ssh').removeClass('blue');\n localStorage.setItem('repo-clone-protocol', 'https');\n });\n $('#repo-clone-url').click(function () {\n $(this).select();\n });\n\n // Pull request\n const $repoComparePull = $('.repository.compare.pull');\n if ($repoComparePull.length > 0) {\n initFilterSearchDropdown('.choose.branch .dropdown');\n // show pull request form\n $repoComparePull.find('button.show-form').on('click', function (e) {\n e.preventDefault();\n $repoComparePull.find('.pullrequest-form').show();\n $(this).parent().hide();\n });\n }\n\n // Branches\n if ($('.repository.settings.branches').length > 0) {\n initFilterSearchDropdown('.protected-branches .dropdown');\n $('.enable-protection, .enable-whitelist').change(function () {\n if (this.checked) {\n $($(this).data('target')).removeClass('disabled');\n } else {\n $($(this).data('target')).addClass('disabled');\n }\n });\n }\n}\n\nfunction initMigration() {\n const toggleMigrations = function () {\n const authUserName = $('#auth_username').val();\n const cloneAddr = $('#clone_addr').val();\n if (!$('#mirror').is(':checked') && (authUserName && authUserName.length > 0)\n && (cloneAddr !== undefined && (cloneAddr.startsWith('https://github.com') || cloneAddr.startsWith('http://github.com')))) {\n $('#migrate_items').show();\n } else {\n $('#migrate_items').hide();\n }\n };\n\n toggleMigrations();\n\n $('#clone_addr').on('input', toggleMigrations);\n $('#auth_username').on('input', toggleMigrations);\n $('#mirror').on('change', toggleMigrations);\n}\n\nfunction initPullRequestReview() {\n $('.show-outdated').on('click', function (e) {\n e.preventDefault();\n const id = $(this).data('comment');\n $(this).addClass('hide');\n $(`#code-comments-${id}`).removeClass('hide');\n $(`#code-preview-${id}`).removeClass('hide');\n $(`#hide-outdated-${id}`).removeClass('hide');\n });\n\n $('.hide-outdated').on('click', function (e) {\n e.preventDefault();\n const id = $(this).data('comment');\n $(this).addClass('hide');\n $(`#code-comments-${id}`).addClass('hide');\n $(`#code-preview-${id}`).addClass('hide');\n $(`#show-outdated-${id}`).removeClass('hide');\n });\n\n $('button.comment-form-reply').on('click', function (e) {\n e.preventDefault();\n $(this).hide();\n const form = $(this).parent().find('.comment-form');\n form.removeClass('hide');\n assingMenuAttributes(form.find('.menu'));\n });\n // The following part is only for diff views\n if ($('.repository.pull.diff').length === 0) {\n return;\n }\n\n $('.diff-detail-box.ui.sticky').sticky();\n\n $('.btn-review').on('click', function (e) {\n e.preventDefault();\n $(this).closest('.dropdown').find('.menu').toggle('visible');\n }).closest('.dropdown').find('.link.close')\n .on('click', function (e) {\n e.preventDefault();\n $(this).closest('.menu').toggle('visible');\n });\n\n $('.code-view .lines-code,.code-view .lines-num')\n .on('mouseenter', function () {\n const parent = $(this).closest('td');\n $(this).closest('tr').addClass(\n parent.hasClass('lines-num-old') || parent.hasClass('lines-code-old')\n ? 'focus-lines-old' : 'focus-lines-new'\n );\n })\n .on('mouseleave', function () {\n $(this).closest('tr').removeClass('focus-lines-new focus-lines-old');\n });\n $('.add-code-comment').on('click', function (e) {\n // https://github.com/go-gitea/gitea/issues/4745\n if ($(e.target).hasClass('btn-add-single')) {\n return;\n }\n e.preventDefault();\n const isSplit = $(this).closest('.code-diff').hasClass('code-diff-split');\n const side = $(this).data('side');\n const idx = $(this).data('idx');\n const path = $(this).data('path');\n const form = $('#pull_review_add_comment').html();\n const tr = $(this).closest('tr');\n let ntr = tr.next();\n if (!ntr.hasClass('add-comment')) {\n ntr = $(`${\n isSplit ? ''\n : ''\n }`);\n tr.after(ntr);\n }\n const td = ntr.find(`.add-comment-${side}`);\n let commentCloud = td.find('.comment-code-cloud');\n if (commentCloud.length === 0) {\n td.html(form);\n commentCloud = td.find('.comment-code-cloud');\n assingMenuAttributes(commentCloud.find('.menu'));\n\n td.find(\"input[name='line']\").val(idx);\n td.find(\"input[name='side']\").val(side === 'left' ? 'previous' : 'proposed');\n td.find(\"input[name='path']\").val(path);\n }\n commentCloud.find('textarea').focus();\n });\n}\n\nfunction assingMenuAttributes(menu) {\n const id = Math.floor(Math.random() * Math.floor(1000000));\n menu.attr('data-write', menu.attr('data-write') + id);\n menu.attr('data-preview', menu.attr('data-preview') + id);\n menu.find('.item').each(function () {\n const tab = $(this).attr('data-tab') + id;\n $(this).attr('data-tab', tab);\n });\n menu.parent().find(\"*[data-tab='write']\").attr('data-tab', `write${id}`);\n menu.parent().find(\"*[data-tab='preview']\").attr('data-tab', `preview${id}`);\n initCommentPreviewTab(menu.parent('.form'));\n return id;\n}\n\nfunction initRepositoryCollaboration() {\n // Change collaborator access mode\n $('.access-mode.menu .item').click(function () {\n const $menu = $(this).parent();\n $.post($menu.data('url'), {\n _csrf: csrf,\n uid: $menu.data('uid'),\n mode: $(this).data('value')\n });\n });\n}\n\nfunction initTeamSettings() {\n // Change team access mode\n $('.organization.new.team input[name=permission]').change(() => {\n const val = $('input[name=permission]:checked', '.organization.new.team').val();\n if (val === 'admin') {\n $('.organization.new.team .team-units').hide();\n } else {\n $('.organization.new.team .team-units').show();\n }\n });\n}\n\nfunction initWikiForm() {\n const $editArea = $('.repository.wiki textarea#edit_area');\n let sideBySideChanges = 0;\n let sideBySideTimeout = null;\n if ($editArea.length > 0) {\n const simplemde = new SimpleMDE({\n autoDownloadFontAwesome: false,\n element: $editArea[0],\n forceSync: true,\n previewRender(plainText, preview) { // Async method\n setTimeout(() => {\n // FIXME: still send render request when return back to edit mode\n const render = function () {\n sideBySideChanges = 0;\n if (sideBySideTimeout != null) {\n clearTimeout(sideBySideTimeout);\n sideBySideTimeout = null;\n }\n $.post($editArea.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $editArea.data('context'),\n text: plainText\n },\n (data) => {\n preview.innerHTML = `
${data}
`;\n emojify.run($('.editor-preview')[0]);\n $(preview).find('pre code').each((_, e) => {\n hljs.highlightBlock(e);\n });\n });\n };\n if (!simplemde.isSideBySideActive()) {\n render();\n } else {\n // delay preview by keystroke counting\n sideBySideChanges++;\n if (sideBySideChanges > 10) {\n render();\n }\n // or delay preview by timeout\n if (sideBySideTimeout != null) {\n clearTimeout(sideBySideTimeout);\n sideBySideTimeout = null;\n }\n sideBySideTimeout = setTimeout(render, 600);\n }\n }, 0);\n if (!simplemde.isSideBySideActive()) {\n return 'Loading...';\n }\n return preview.innerHTML;\n },\n renderingConfig: {\n singleLineBreaks: false\n },\n indentWithTabs: false,\n tabSize: 4,\n spellChecker: false,\n toolbar: ['bold', 'italic', 'strikethrough', '|',\n 'heading-1', 'heading-2', 'heading-3', 'heading-bigger', 'heading-smaller', '|',\n {\n name: 'code-inline',\n action(e) {\n const cm = e.codemirror;\n const selection = cm.getSelection();\n cm.replaceSelection(`\\`${selection}\\``);\n if (!selection) {\n const cursorPos = cm.getCursor();\n cm.setCursor(cursorPos.line, cursorPos.ch - 1);\n }\n cm.focus();\n },\n className: 'fa fa-angle-right',\n title: 'Add Inline Code',\n }, 'code', 'quote', '|', {\n name: 'checkbox-empty',\n action(e) {\n const cm = e.codemirror;\n cm.replaceSelection(`\\n- [ ] ${cm.getSelection()}`);\n cm.focus();\n },\n className: 'fa fa-square-o',\n title: 'Add Checkbox (empty)',\n },\n {\n name: 'checkbox-checked',\n action(e) {\n const cm = e.codemirror;\n cm.replaceSelection(`\\n- [x] ${cm.getSelection()}`);\n cm.focus();\n },\n className: 'fa fa-check-square-o',\n title: 'Add Checkbox (checked)',\n }, '|',\n 'unordered-list', 'ordered-list', '|',\n 'link', 'image', 'table', 'horizontal-rule', '|',\n 'clean-block', 'preview', 'fullscreen', 'side-by-side']\n });\n $(simplemde.codemirror.getInputField()).addClass('js-quick-submit');\n\n setTimeout(() => {\n const $bEdit = $('.repository.wiki.new .previewtabs a[data-tab=\"write\"]');\n const $bPrev = $('.repository.wiki.new .previewtabs a[data-tab=\"preview\"]');\n const $toolbar = $('.editor-toolbar');\n const $bPreview = $('.editor-toolbar a.fa-eye');\n const $bSideBySide = $('.editor-toolbar a.fa-columns');\n $bEdit.on('click', () => {\n if ($toolbar.hasClass('disabled-for-preview')) {\n $bPreview.click();\n }\n });\n $bPrev.on('click', () => {\n if (!$toolbar.hasClass('disabled-for-preview')) {\n $bPreview.click();\n }\n });\n $bPreview.on('click', () => {\n setTimeout(() => {\n if ($toolbar.hasClass('disabled-for-preview')) {\n if ($bEdit.hasClass('active')) {\n $bEdit.removeClass('active');\n }\n if (!$bPrev.hasClass('active')) {\n $bPrev.addClass('active');\n }\n } else {\n if (!$bEdit.hasClass('active')) {\n $bEdit.addClass('active');\n }\n if ($bPrev.hasClass('active')) {\n $bPrev.removeClass('active');\n }\n }\n }, 0);\n });\n $bSideBySide.on('click', () => {\n sideBySideChanges = 10;\n });\n }, 0);\n }\n}\n\n// Adding function to get the cursor position in a text field to jQuery object.\n$.fn.getCursorPosition = function () {\n const el = $(this).get(0);\n let pos = 0;\n if ('selectionStart' in el) {\n pos = el.selectionStart;\n } else if ('selection' in document) {\n el.focus();\n const Sel = document.selection.createRange();\n const SelLength = document.selection.createRange().text.length;\n Sel.moveStart('character', -el.value.length);\n pos = Sel.text.length - SelLength;\n }\n return pos;\n};\n\nfunction setSimpleMDE($editArea) {\n if (codeMirrorEditor) {\n codeMirrorEditor.toTextArea();\n codeMirrorEditor = null;\n }\n\n if (simpleMDEditor) {\n return true;\n }\n\n simpleMDEditor = new SimpleMDE({\n autoDownloadFontAwesome: false,\n element: $editArea[0],\n forceSync: true,\n renderingConfig: {\n singleLineBreaks: false\n },\n indentWithTabs: false,\n tabSize: 4,\n spellChecker: false,\n previewRender(plainText, preview) { // Async method\n setTimeout(() => {\n // FIXME: still send render request when return back to edit mode\n $.post($editArea.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $editArea.data('context'),\n text: plainText\n },\n (data) => {\n preview.innerHTML = `
${data}
`;\n emojify.run($('.editor-preview')[0]);\n });\n }, 0);\n\n return 'Loading...';\n },\n toolbar: ['bold', 'italic', 'strikethrough', '|',\n 'heading-1', 'heading-2', 'heading-3', 'heading-bigger', 'heading-smaller', '|',\n 'code', 'quote', '|',\n 'unordered-list', 'ordered-list', '|',\n 'link', 'image', 'table', 'horizontal-rule', '|',\n 'clean-block', 'preview', 'fullscreen', 'side-by-side']\n });\n\n return true;\n}\n\nfunction setCodeMirror($editArea) {\n if (simpleMDEditor) {\n simpleMDEditor.toTextArea();\n simpleMDEditor = null;\n }\n\n if (codeMirrorEditor) {\n return true;\n }\n\n codeMirrorEditor = CodeMirror.fromTextArea($editArea[0], {\n lineNumbers: true\n });\n codeMirrorEditor.on('change', (cm, _change) => {\n $editArea.val(cm.getValue());\n });\n\n return true;\n}\n\nfunction initEditor() {\n $('.js-quick-pull-choice-option').change(function () {\n if ($(this).val() === 'commit-to-new-branch') {\n $('.quick-pull-branch-name').show();\n $('.quick-pull-branch-name input').prop('required', true);\n } else {\n $('.quick-pull-branch-name').hide();\n $('.quick-pull-branch-name input').prop('required', false);\n }\n $('#commit-button').text($(this).attr('button_text'));\n });\n\n const $editFilename = $('#file-name');\n $editFilename.keyup(function (e) {\n const $section = $('.breadcrumb span.section');\n const $divider = $('.breadcrumb div.divider');\n let value;\n let parts;\n\n if (e.keyCode === 8) {\n if ($(this).getCursorPosition() === 0) {\n if ($section.length > 0) {\n value = $section.last().find('a').text();\n $(this).val(value + $(this).val());\n $(this)[0].setSelectionRange(value.length, value.length);\n $section.last().remove();\n $divider.last().remove();\n }\n }\n }\n if (e.keyCode === 191) {\n parts = $(this).val().split('/');\n for (let i = 0; i < parts.length; ++i) {\n value = parts[i];\n if (i < parts.length - 1) {\n if (value.length) {\n $(`${value}`).insertBefore($(this));\n $('
/
').insertBefore($(this));\n }\n } else {\n $(this).val(value);\n }\n $(this)[0].setSelectionRange(0, 0);\n }\n }\n parts = [];\n $('.breadcrumb span.section').each(function () {\n const element = $(this);\n if (element.find('a').length) {\n parts.push(element.find('a').text());\n } else {\n parts.push(element.text());\n }\n });\n if ($(this).val()) parts.push($(this).val());\n $('#tree_path').val(parts.join('/'));\n }).trigger('keyup');\n\n const $editArea = $('.repository.editor textarea#edit_area');\n if (!$editArea.length) return;\n\n const markdownFileExts = $editArea.data('markdown-file-exts').split(',');\n const lineWrapExtensions = $editArea.data('line-wrap-extensions').split(',');\n\n $editFilename.on('keyup', () => {\n const val = $editFilename.val();\n let mode, spec, extension, extWithDot, dataUrl, apiCall;\n\n extension = extWithDot = '';\n const m = /.+\\.([^.]+)$/.exec(val);\n if (m) {\n extension = m[1];\n extWithDot = `.${extension}`;\n }\n\n const info = CodeMirror.findModeByExtension(extension);\n const previewLink = $('a[data-tab=preview]');\n if (info) {\n mode = info.mode;\n spec = info.mime;\n apiCall = mode;\n } else {\n apiCall = extension;\n }\n\n if (previewLink.length && apiCall && previewFileModes && previewFileModes.length && previewFileModes.indexOf(apiCall) >= 0) {\n dataUrl = previewLink.data('url');\n previewLink.data('url', dataUrl.replace(/(.*)\\/.*/i, `$1/${mode}`));\n previewLink.show();\n } else {\n previewLink.hide();\n }\n\n // If this file is a Markdown extensions, we will load that editor and return\n if (markdownFileExts.indexOf(extWithDot) >= 0) {\n if (setSimpleMDE($editArea)) {\n return;\n }\n }\n\n // Else we are going to use CodeMirror\n if (!codeMirrorEditor && !setCodeMirror($editArea)) {\n return;\n }\n\n if (mode) {\n codeMirrorEditor.setOption('mode', spec);\n CodeMirror.autoLoadMode(codeMirrorEditor, mode);\n }\n\n if (lineWrapExtensions.indexOf(extWithDot) >= 0) {\n codeMirrorEditor.setOption('lineWrapping', true);\n } else {\n codeMirrorEditor.setOption('lineWrapping', false);\n }\n\n // get the filename without any folder\n let value = $editFilename.val();\n if (value.length === 0) {\n return;\n }\n value = value.split('/');\n value = value[value.length - 1];\n\n $.getJSON($editFilename.data('ec-url-prefix') + value, (editorconfig) => {\n if (editorconfig.indent_style === 'tab') {\n codeMirrorEditor.setOption('indentWithTabs', true);\n codeMirrorEditor.setOption('extraKeys', {});\n } else {\n codeMirrorEditor.setOption('indentWithTabs', false);\n // required because CodeMirror doesn't seems to use spaces correctly for {\"indentWithTabs\": false}:\n // - https://github.com/codemirror/CodeMirror/issues/988\n // - https://codemirror.net/doc/manual.html#keymaps\n codeMirrorEditor.setOption('extraKeys', {\n Tab(cm) {\n const spaces = Array(parseInt(cm.getOption('indentUnit')) + 1).join(' ');\n cm.replaceSelection(spaces);\n }\n });\n }\n codeMirrorEditor.setOption('indentUnit', editorconfig.indent_size || 4);\n codeMirrorEditor.setOption('tabSize', editorconfig.tab_width || 4);\n });\n }).trigger('keyup');\n\n // Using events from https://github.com/codedance/jquery.AreYouSure#advanced-usage\n // to enable or disable the commit button\n const $commitButton = $('#commit-button');\n const $editForm = $('.ui.edit.form');\n const dirtyFileClass = 'dirty-file';\n\n // Disabling the button at the start\n $commitButton.prop('disabled', true);\n\n // Registering a custom listener for the file path and the file content\n $editForm.areYouSure({\n silent: true,\n dirtyClass: dirtyFileClass,\n fieldSelector: ':input:not(.commit-form-wrapper :input)',\n change() {\n const dirty = $(this).hasClass(dirtyFileClass);\n $commitButton.prop('disabled', !dirty);\n }\n });\n\n $commitButton.click((event) => {\n // A modal which asks if an empty file should be committed\n if ($editArea.val().length === 0) {\n $('#edit-empty-content-modal').modal({\n onApprove() {\n $('.edit.form').submit();\n }\n }).modal('show');\n event.preventDefault();\n }\n });\n}\n\nfunction initOrganization() {\n if ($('.organization').length === 0) {\n return;\n }\n\n // Options\n if ($('.organization.settings.options').length > 0) {\n $('#org_name').keyup(function () {\n const $prompt = $('#org-name-change-prompt');\n if ($(this).val().toString().toLowerCase() !== $(this).data('org-name').toString().toLowerCase()) {\n $prompt.show();\n } else {\n $prompt.hide();\n }\n });\n }\n}\n\nfunction initUserSettings() {\n // Options\n if ($('.user.settings.profile').length > 0) {\n $('#username').keyup(function () {\n const $prompt = $('#name-change-prompt');\n if ($(this).val().toString().toLowerCase() !== $(this).data('name').toString().toLowerCase()) {\n $prompt.show();\n } else {\n $prompt.hide();\n }\n });\n }\n}\n\nfunction initGithook() {\n if ($('.edit.githook').length === 0) {\n return;\n }\n\n CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], {\n lineNumbers: true,\n mode: 'shell'\n }), 'shell');\n}\n\nfunction initWebhook() {\n if ($('.new.webhook').length === 0) {\n return;\n }\n\n $('.events.checkbox input').change(function () {\n if ($(this).is(':checked')) {\n $('.events.fields').show();\n }\n });\n $('.non-events.checkbox input').change(function () {\n if ($(this).is(':checked')) {\n $('.events.fields').hide();\n }\n });\n\n const updateContentType = function () {\n const visible = $('#http_method').val() === 'POST';\n $('#content_type').parent().parent()[visible ? 'show' : 'hide']();\n };\n updateContentType();\n $('#http_method').change(() => {\n updateContentType();\n });\n\n // Test delivery\n $('#test-delivery').click(function () {\n const $this = $(this);\n $this.addClass('loading disabled');\n $.post($this.data('link'), {\n _csrf: csrf\n }).done(\n setTimeout(() => {\n window.location.href = $this.data('redirect');\n }, 5000)\n );\n });\n}\n\nfunction initAdmin() {\n if ($('.admin').length === 0) {\n return;\n }\n\n // New user\n if ($('.admin.new.user').length > 0 || $('.admin.edit.user').length > 0) {\n $('#login_type').change(function () {\n if ($(this).val().substring(0, 1) === '0') {\n $('#login_name').removeAttr('required');\n $('.non-local').hide();\n $('.local').show();\n $('#user_name').focus();\n\n if ($(this).data('password') === 'required') {\n $('#password').attr('required', 'required');\n }\n } else {\n $('#login_name').attr('required', 'required');\n $('.non-local').show();\n $('.local').hide();\n $('#login_name').focus();\n\n $('#password').removeAttr('required');\n }\n });\n }\n\n function onSecurityProtocolChange() {\n if ($('#security_protocol').val() > 0) {\n $('.has-tls').show();\n } else {\n $('.has-tls').hide();\n }\n }\n\n function onUsePagedSearchChange() {\n if ($('#use_paged_search').prop('checked')) {\n $('.search-page-size').show()\n .find('input').attr('required', 'required');\n } else {\n $('.search-page-size').hide()\n .find('input').removeAttr('required');\n }\n }\n\n function onOAuth2Change() {\n $('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url').hide();\n $('.open_id_connect_auto_discovery_url input[required]').removeAttr('required');\n\n const provider = $('#oauth2_provider').val();\n switch (provider) {\n case 'github':\n case 'gitlab':\n case 'gitea':\n $('.oauth2_use_custom_url').show();\n break;\n case 'openidConnect':\n $('.open_id_connect_auto_discovery_url input').attr('required', 'required');\n $('.open_id_connect_auto_discovery_url').show();\n break;\n }\n onOAuth2UseCustomURLChange();\n }\n\n function onOAuth2UseCustomURLChange() {\n const provider = $('#oauth2_provider').val();\n $('.oauth2_use_custom_url_field').hide();\n $('.oauth2_use_custom_url_field input[required]').removeAttr('required');\n\n if ($('#oauth2_use_custom_url').is(':checked')) {\n if (!$('#oauth2_token_url').val()) {\n $('#oauth2_token_url').val($(`#${provider}_token_url`).val());\n }\n if (!$('#oauth2_auth_url').val()) {\n $('#oauth2_auth_url').val($(`#${provider}_auth_url`).val());\n }\n if (!$('#oauth2_profile_url').val()) {\n $('#oauth2_profile_url').val($(`#${provider}_profile_url`).val());\n }\n if (!$('#oauth2_email_url').val()) {\n $('#oauth2_email_url').val($(`#${provider}_email_url`).val());\n }\n switch (provider) {\n case 'github':\n $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input, .oauth2_email_url input').attr('required', 'required');\n $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url, .oauth2_email_url').show();\n break;\n case 'gitea':\n case 'gitlab':\n $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input').attr('required', 'required');\n $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url').show();\n $('#oauth2_email_url').val('');\n break;\n }\n }\n }\n\n // New authentication\n if ($('.admin.new.authentication').length > 0) {\n $('#auth_type').change(function () {\n $('.ldap, .dldap, .smtp, .pam, .oauth2, .has-tls .search-page-size').hide();\n\n $('.ldap input[required], .binddnrequired input[required], .dldap input[required], .smtp input[required], .pam input[required], .oauth2 input[required], .has-tls input[required]').removeAttr('required');\n $('.binddnrequired').removeClass('required');\n\n const authType = $(this).val();\n switch (authType) {\n case '2': // LDAP\n $('.ldap').show();\n $('.binddnrequired input, .ldap div.required:not(.dldap) input').attr('required', 'required');\n $('.binddnrequired').addClass('required');\n break;\n case '3': // SMTP\n $('.smtp').show();\n $('.has-tls').show();\n $('.smtp div.required input, .has-tls').attr('required', 'required');\n break;\n case '4': // PAM\n $('.pam').show();\n $('.pam input').attr('required', 'required');\n break;\n case '5': // LDAP\n $('.dldap').show();\n $('.dldap div.required:not(.ldap) input').attr('required', 'required');\n break;\n case '6': // OAuth2\n $('.oauth2').show();\n $('.oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input').attr('required', 'required');\n onOAuth2Change();\n break;\n }\n if (authType === '2' || authType === '5') {\n onSecurityProtocolChange();\n }\n if (authType === '2') {\n onUsePagedSearchChange();\n }\n });\n $('#auth_type').change();\n $('#security_protocol').change(onSecurityProtocolChange);\n $('#use_paged_search').change(onUsePagedSearchChange);\n $('#oauth2_provider').change(onOAuth2Change);\n $('#oauth2_use_custom_url').change(onOAuth2UseCustomURLChange);\n }\n // Edit authentication\n if ($('.admin.edit.authentication').length > 0) {\n const authType = $('#auth_type').val();\n if (authType === '2' || authType === '5') {\n $('#security_protocol').change(onSecurityProtocolChange);\n if (authType === '2') {\n $('#use_paged_search').change(onUsePagedSearchChange);\n }\n } else if (authType === '6') {\n $('#oauth2_provider').change(onOAuth2Change);\n $('#oauth2_use_custom_url').change(onOAuth2UseCustomURLChange);\n onOAuth2Change();\n }\n }\n\n // Notice\n if ($('.admin.notice')) {\n const $detailModal = $('#detail-modal');\n\n // Attach view detail modals\n $('.view-detail').click(function () {\n $detailModal.find('.content p').text($(this).data('content'));\n $detailModal.modal('show');\n return false;\n });\n\n // Select actions\n const $checkboxes = $('.select.table .ui.checkbox');\n $('.select.action').click(function () {\n switch ($(this).data('action')) {\n case 'select-all':\n $checkboxes.checkbox('check');\n break;\n case 'deselect-all':\n $checkboxes.checkbox('uncheck');\n break;\n case 'inverse':\n $checkboxes.checkbox('toggle');\n break;\n }\n });\n $('#delete-selection').click(function () {\n const $this = $(this);\n $this.addClass('loading disabled');\n const ids = [];\n $checkboxes.each(function () {\n if ($(this).checkbox('is checked')) {\n ids.push($(this).data('id'));\n }\n });\n $.post($this.data('link'), {\n _csrf: csrf,\n ids\n }).done(() => {\n window.location.href = $this.data('redirect');\n });\n });\n }\n}\n\nfunction buttonsClickOnEnter() {\n $('.ui.button').keypress(function (e) {\n if (e.keyCode === 13 || e.keyCode === 32) { // enter key or space bar\n $(this).click();\n }\n });\n}\n\nfunction searchUsers() {\n const $searchUserBox = $('#search-user-box');\n $searchUserBox.search({\n minCharacters: 2,\n apiSettings: {\n url: `${suburl}/api/v1/users/search?q={query}`,\n onResponse(response) {\n const items = [];\n $.each(response.data, (_i, item) => {\n let title = item.login;\n if (item.full_name && item.full_name.length > 0) {\n title += ` (${htmlEncode(item.full_name)})`;\n }\n items.push({\n title,\n image: item.avatar_url\n });\n });\n\n return { results: items };\n }\n },\n searchFields: ['login', 'full_name'],\n showNoResults: false\n });\n}\n\nfunction searchTeams() {\n const $searchTeamBox = $('#search-team-box');\n $searchTeamBox.search({\n minCharacters: 2,\n apiSettings: {\n url: `${suburl}/api/v1/orgs/${$searchTeamBox.data('org')}/teams/search?q={query}`,\n headers: { 'X-Csrf-Token': csrf },\n onResponse(response) {\n const items = [];\n $.each(response.data, (_i, item) => {\n const title = `${item.name} (${item.permission} access)`;\n items.push({\n title,\n });\n });\n\n return { results: items };\n }\n },\n searchFields: ['name', 'description'],\n showNoResults: false\n });\n}\n\nfunction searchRepositories() {\n const $searchRepoBox = $('#search-repo-box');\n $searchRepoBox.search({\n minCharacters: 2,\n apiSettings: {\n url: `${suburl}/api/v1/repos/search?q={query}&uid=${$searchRepoBox.data('uid')}`,\n onResponse(response) {\n const items = [];\n $.each(response.data, (_i, item) => {\n items.push({\n title: item.full_name.split('/')[1],\n description: item.full_name\n });\n });\n\n return { results: items };\n }\n },\n searchFields: ['full_name'],\n showNoResults: false\n });\n}\n\nfunction initCodeView() {\n if ($('.code-view .linenums').length > 0) {\n $(document).on('click', '.lines-num span', function (e) {\n const $select = $(this);\n const $list = $select.parent().siblings('.lines-code').find('ol.linenums > li');\n selectRange($list, $list.filter(`[rel=${$select.attr('id')}]`), (e.shiftKey ? $list.filter('.active').eq(0) : null));\n deSelect();\n });\n\n $(window).on('hashchange', () => {\n let m = window.location.hash.match(/^#(L\\d+)-(L\\d+)$/);\n const $list = $('.code-view ol.linenums > li');\n let $first;\n if (m) {\n $first = $list.filter(`.${m[1]}`);\n selectRange($list, $first, $list.filter(`.${m[2]}`));\n $('html, body').scrollTop($first.offset().top - 200);\n return;\n }\n m = window.location.hash.match(/^#(L|n)(\\d+)$/);\n if (m) {\n $first = $list.filter(`.L${m[2]}`);\n selectRange($list, $first);\n $('html, body').scrollTop($first.offset().top - 200);\n }\n }).trigger('hashchange');\n }\n $('.ui.fold-code').on('click', (e) => {\n const $foldButton = $(e.target);\n if ($foldButton.hasClass('fa-chevron-down')) {\n $(e.target).parent().next().slideUp('fast', () => {\n $foldButton.removeClass('fa-chevron-down').addClass('fa-chevron-right');\n });\n } else {\n $(e.target).parent().next().slideDown('fast', () => {\n $foldButton.removeClass('fa-chevron-right').addClass('fa-chevron-down');\n });\n }\n });\n function insertBlobExcerpt(e) {\n const $blob = $(e.target);\n const $row = $blob.parent().parent();\n $.get(`${$blob.data('url')}?${$blob.data('query')}&anchor=${$blob.data('anchor')}`, (blob) => {\n $row.replaceWith(blob);\n $(`[data-anchor=\"${$blob.data('anchor')}\"]`).on('click', (e) => { insertBlobExcerpt(e); });\n });\n }\n $('.ui.blob-excerpt').on('click', (e) => { insertBlobExcerpt(e); });\n}\n\nfunction initU2FAuth() {\n if ($('#wait-for-key').length === 0) {\n return;\n }\n u2fApi.ensureSupport()\n .then(() => {\n $.getJSON(`${suburl}/user/u2f/challenge`).success((req) => {\n u2fApi.sign(req.appId, req.challenge, req.registeredKeys, 30)\n .then(u2fSigned)\n .catch((err) => {\n if (err === undefined) {\n u2fError(1);\n return;\n }\n u2fError(err.metaData.code);\n });\n });\n }).catch(() => {\n // Fallback in case browser do not support U2F\n window.location.href = `${suburl}/user/two_factor`;\n });\n}\nfunction u2fSigned(resp) {\n $.ajax({\n url: `${suburl}/user/u2f/sign`,\n type: 'POST',\n headers: { 'X-Csrf-Token': csrf },\n data: JSON.stringify(resp),\n contentType: 'application/json; charset=utf-8',\n }).done((res) => {\n window.location.replace(res);\n }).fail(() => {\n u2fError(1);\n });\n}\n\nfunction u2fRegistered(resp) {\n if (checkError(resp)) {\n return;\n }\n $.ajax({\n url: `${suburl}/user/settings/security/u2f/register`,\n type: 'POST',\n headers: { 'X-Csrf-Token': csrf },\n data: JSON.stringify(resp),\n contentType: 'application/json; charset=utf-8',\n success() {\n reload();\n },\n fail() {\n u2fError(1);\n }\n });\n}\n\nfunction checkError(resp) {\n if (!('errorCode' in resp)) {\n return false;\n }\n if (resp.errorCode === 0) {\n return false;\n }\n u2fError(resp.errorCode);\n return true;\n}\n\n\nfunction u2fError(errorType) {\n const u2fErrors = {\n browser: $('#unsupported-browser'),\n 1: $('#u2f-error-1'),\n 2: $('#u2f-error-2'),\n 3: $('#u2f-error-3'),\n 4: $('#u2f-error-4'),\n 5: $('.u2f-error-5')\n };\n u2fErrors[errorType].removeClass('hide');\n\n Object.keys(u2fErrors).forEach((type) => {\n if (type !== errorType) {\n u2fErrors[type].addClass('hide');\n }\n });\n $('#u2f-error').modal('show');\n}\n\nfunction initU2FRegister() {\n $('#register-device').modal({ allowMultiple: false });\n $('#u2f-error').modal({ allowMultiple: false });\n $('#register-security-key').on('click', (e) => {\n e.preventDefault();\n u2fApi.ensureSupport()\n .then(u2fRegisterRequest)\n .catch(() => {\n u2fError('browser');\n });\n });\n}\n\nfunction u2fRegisterRequest() {\n $.post(`${suburl}/user/settings/security/u2f/request_register`, {\n _csrf: csrf,\n name: $('#nickname').val()\n }).success((req) => {\n $('#nickname').closest('div.field').removeClass('error');\n $('#register-device').modal('show');\n if (req.registeredKeys === null) {\n req.registeredKeys = [];\n }\n u2fApi.register(req.appId, req.registerRequests, req.registeredKeys, 30)\n .then(u2fRegistered)\n .catch((reason) => {\n if (reason === undefined) {\n u2fError(1);\n return;\n }\n u2fError(reason.metaData.code);\n });\n }).fail((xhr) => {\n if (xhr.status === 409) {\n $('#nickname').closest('div.field').addClass('error');\n }\n });\n}\n\nfunction initWipTitle() {\n $('.title_wip_desc > a').click((e) => {\n e.preventDefault();\n\n const $issueTitle = $('#issue_title');\n $issueTitle.focus();\n const value = $issueTitle.val().trim().toUpperCase();\n\n for (const i in wipPrefixes) {\n if (value.startsWith(wipPrefixes[i].toUpperCase())) {\n return;\n }\n }\n\n $issueTitle.val(`${wipPrefixes[0]} ${$issueTitle.val()}`);\n });\n}\n\nfunction initTemplateSearch() {\n const $repoTemplate = $('#repo_template');\n const checkTemplate = function () {\n const $templateUnits = $('#template_units');\n const $nonTemplate = $('#non_template');\n if ($repoTemplate.val() !== '') {\n $templateUnits.show();\n $nonTemplate.hide();\n } else {\n $templateUnits.hide();\n $nonTemplate.show();\n }\n };\n $repoTemplate.change(checkTemplate);\n checkTemplate();\n\n const changeOwner = function () {\n $('#repo_template_search')\n .dropdown({\n apiSettings: {\n url: `${suburl}/api/v1/repos/search?q={query}&template=true&priority_owner_id=${$('#uid').val()}`,\n onResponse(response) {\n const filteredResponse = { success: true, results: [] };\n filteredResponse.results.push({\n name: '',\n value: ''\n });\n // Parse the response from the api to work with our dropdown\n $.each(response.data, (_r, repo) => {\n filteredResponse.results.push({\n name: htmlEncode(repo.full_name),\n value: repo.id\n });\n });\n return filteredResponse;\n },\n cache: false,\n },\n\n fullTextSearch: true\n });\n };\n $('#uid').change(changeOwner);\n changeOwner();\n}\n\n$(document).ready(() => {\n csrf = $('meta[name=_csrf]').attr('content');\n suburl = $('meta[name=_suburl]').attr('content');\n\n // Show exact time\n $('.time-since').each(function () {\n $(this)\n .addClass('poping up')\n .attr('data-content', $(this).attr('title'))\n .attr('data-variation', 'inverted tiny')\n .attr('title', '');\n });\n\n // Semantic UI modules.\n $('.dropdown:not(.custom)').dropdown();\n $('.jump.dropdown').dropdown({\n action: 'hide',\n onShow() {\n $('.poping.up').popup('hide');\n }\n });\n $('.slide.up.dropdown').dropdown({\n transition: 'slide up'\n });\n $('.upward.dropdown').dropdown({\n direction: 'upward'\n });\n $('.ui.accordion').accordion();\n $('.ui.checkbox').checkbox();\n $('.ui.progress').progress({\n showActivity: false\n });\n $('.poping.up').popup();\n $('.top.menu .poping.up').popup({\n onShow() {\n if ($('.top.menu .menu.transition').hasClass('visible')) {\n return false;\n }\n }\n });\n $('.tabular.menu .item').tab();\n $('.tabable.menu .item').tab();\n\n $('.toggle.button').click(function () {\n $($(this).data('target')).slideToggle(100);\n });\n\n // make table element clickable like a link\n $('tr[data-href]').click(function () {\n window.location = $(this).data('href');\n });\n\n // Highlight JS\n if (typeof hljs !== 'undefined') {\n const nodes = [].slice.call(document.querySelectorAll('pre code') || []);\n for (let i = 0; i < nodes.length; i++) {\n hljs.highlightBlock(nodes[i]);\n }\n }\n\n // Dropzone\n const $dropzone = $('#dropzone');\n if ($dropzone.length > 0) {\n const filenameDict = {};\n\n new Dropzone('#dropzone', {\n url: $dropzone.data('upload-url'),\n headers: { 'X-Csrf-Token': csrf },\n maxFiles: $dropzone.data('max-file'),\n maxFilesize: $dropzone.data('max-size'),\n acceptedFiles: ($dropzone.data('accepts') === '*/*') ? null : $dropzone.data('accepts'),\n addRemoveLinks: true,\n dictDefaultMessage: $dropzone.data('default-message'),\n dictInvalidFileType: $dropzone.data('invalid-input-type'),\n dictFileTooBig: $dropzone.data('file-too-big'),\n dictRemoveFile: $dropzone.data('remove-file'),\n init() {\n this.on('success', (file, data) => {\n filenameDict[file.name] = data.uuid;\n const input = $(``).val(data.uuid);\n $('.files').append(input);\n });\n this.on('removedfile', (file) => {\n if (file.name in filenameDict) {\n $(`#${filenameDict[file.name]}`).remove();\n }\n if ($dropzone.data('remove-url') && $dropzone.data('csrf')) {\n $.post($dropzone.data('remove-url'), {\n file: filenameDict[file.name],\n _csrf: $dropzone.data('csrf')\n });\n }\n });\n },\n });\n }\n\n // Emojify\n emojify.setConfig({\n img_dir: `${suburl}/vendor/plugins/emojify/images`,\n ignore_emoticons: true\n });\n const hasEmoji = document.getElementsByClassName('has-emoji');\n for (let i = 0; i < hasEmoji.length; i++) {\n emojify.run(hasEmoji[i]);\n for (let j = 0; j < hasEmoji[i].childNodes.length; j++) {\n if (hasEmoji[i].childNodes[j].nodeName === 'A') {\n emojify.run(hasEmoji[i].childNodes[j]);\n }\n }\n }\n\n // Clipboard JS\n const clipboard = new Clipboard('.clipboard');\n clipboard.on('success', (e) => {\n e.clearSelection();\n\n $(`#${e.trigger.getAttribute('id')}`).popup('destroy');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success'));\n $(`#${e.trigger.getAttribute('id')}`).popup('show');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original'));\n });\n\n clipboard.on('error', (e) => {\n $(`#${e.trigger.getAttribute('id')}`).popup('destroy');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-error'));\n $(`#${e.trigger.getAttribute('id')}`).popup('show');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original'));\n });\n\n // Helpers.\n $('.delete-button').click(showDeletePopup);\n $('.add-all-button').click(showAddAllPopup);\n\n $('.delete-branch-button').click(showDeletePopup);\n\n $('.undo-button').click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n id: $this.data('id')\n }).done((data) => {\n window.location.href = data.redirect;\n });\n });\n $('.show-panel.button').click(function () {\n $($(this).data('panel')).show();\n });\n $('.show-modal.button').click(function () {\n $($(this).data('modal')).modal('show');\n });\n $('.delete-post.button').click(function () {\n const $this = $(this);\n $.post($this.data('request-url'), {\n _csrf: csrf\n }).done(() => {\n window.location.href = $this.data('done-url');\n });\n });\n\n // Set anchor.\n $('.markdown').each(function () {\n const headers = {};\n $(this).find('h1, h2, h3, h4, h5, h6').each(function () {\n let node = $(this);\n const val = encodeURIComponent(node.text().toLowerCase().replace(/[^\\u00C0-\\u1FFF\\u2C00-\\uD7FF\\w\\- ]/g, '').replace(/[ ]/g, '-'));\n let name = val;\n if (headers[val] > 0) {\n name = `${val}-${headers[val]}`;\n }\n if (headers[val] === undefined) {\n headers[val] = 1;\n } else {\n headers[val] += 1;\n }\n node = node.wrap(`
`);\n node.append(``);\n });\n });\n\n $('.issue-checkbox').click(() => {\n const numChecked = $('.issue-checkbox').children('input:checked').length;\n if (numChecked > 0) {\n $('#issue-filters').addClass('hide');\n $('#issue-actions').removeClass('hide');\n } else {\n $('#issue-filters').removeClass('hide');\n $('#issue-actions').addClass('hide');\n }\n });\n\n $('.issue-action').click(function () {\n let { action } = this.dataset;\n let { elementId } = this.dataset;\n const issueIDs = $('.issue-checkbox').children('input:checked').map(function () {\n return this.dataset.issueId;\n }).get().join();\n const { url } = this.dataset;\n if (elementId === '0' && url.substr(-9) === '/assignee') {\n elementId = '';\n action = 'clear';\n }\n updateIssuesMeta(url, action, issueIDs, elementId).then(() => {\n // NOTICE: This reset of checkbox state targets Firefox caching behaviour, as the checkboxes stay checked after reload\n if (action === 'close' || action === 'open') {\n // uncheck all checkboxes\n $('.issue-checkbox input[type=\"checkbox\"]').each((_, e) => { e.checked = false; });\n }\n reload();\n });\n });\n\n // NOTICE: This event trigger targets Firefox caching behaviour, as the checkboxes stay checked after reload\n // trigger ckecked event, if checkboxes are checked on load\n $('.issue-checkbox input[type=\"checkbox\"]:checked').first().each((_, e) => {\n e.checked = false;\n $(e).click();\n });\n\n buttonsClickOnEnter();\n searchUsers();\n searchTeams();\n searchRepositories();\n\n initCommentForm();\n initInstall();\n initRepository();\n initMigration();\n initWikiForm();\n initEditForm();\n initEditor();\n initOrganization();\n initGithook();\n initWebhook();\n initAdmin();\n initCodeView();\n initVueApp();\n initTeamSettings();\n initCtrlEnterSubmit();\n initNavbarContentToggle();\n initTopicbar();\n initU2FAuth();\n initU2FRegister();\n initIssueList();\n initWipTitle();\n initPullRequestReview();\n initRepoStatusChecker();\n initTemplateSearch();\n\n // Repo clone url.\n if ($('#repo-clone-url').length > 0) {\n switch (localStorage.getItem('repo-clone-protocol')) {\n case 'ssh':\n if ($('#repo-clone-ssh').click().length === 0) {\n $('#repo-clone-https').click();\n }\n break;\n default:\n $('#repo-clone-https').click();\n break;\n }\n }\n\n const routes = {\n 'div.user.settings': initUserSettings,\n 'div.repository.settings.collaboration': initRepositoryCollaboration\n };\n\n let selector;\n for (selector in routes) {\n if ($(selector).length > 0) {\n routes[selector]();\n break;\n }\n }\n\n const $cloneAddr = $('#clone_addr');\n $cloneAddr.change(() => {\n const $repoName = $('#repo_name');\n if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { // Only modify if repo_name input is blank\n $repoName.val($cloneAddr.val().match(/^(.*\\/)?((.+?)(\\.git)?)$/)[3]);\n }\n });\n});\n\nfunction changeHash(hash) {\n if (window.history.pushState) {\n window.history.pushState(null, null, hash);\n } else {\n window.location.hash = hash;\n }\n}\n\nfunction deSelect() {\n if (window.getSelection) {\n window.getSelection().removeAllRanges();\n } else {\n document.selection.empty();\n }\n}\n\nfunction selectRange($list, $select, $from) {\n $list.removeClass('active');\n if ($from) {\n let a = parseInt($select.attr('rel').substr(1));\n let b = parseInt($from.attr('rel').substr(1));\n let c;\n if (a !== b) {\n if (a > b) {\n c = a;\n a = b;\n b = c;\n }\n const classes = [];\n for (let i = a; i <= b; i++) {\n classes.push(`.L${i}`);\n }\n $list.filter(classes.join(',')).addClass('active');\n changeHash(`#L${a}-L${b}`);\n return;\n }\n }\n $select.addClass('active');\n changeHash(`#${$select.attr('rel')}`);\n}\n\n$(() => {\n // Warn users that try to leave a page after entering data into a form.\n // Except on sign-in pages, and for forms marked as 'ignore-dirty'.\n if ($('.user.signin').length === 0) {\n $('form:not(.ignore-dirty)').areYouSure();\n }\n\n // Parse SSH Key\n $('#ssh-key-content').on('change paste keyup', function () {\n const arrays = $(this).val().split(' ');\n const $title = $('#ssh-key-title');\n if ($title.val() === '' && arrays.length === 3 && arrays[2] !== '') {\n $title.val(arrays[2]);\n }\n });\n});\n\nfunction showDeletePopup() {\n const $this = $(this);\n let filter = '';\n if ($this.attr('id')) {\n filter += `#${$this.attr('id')}`;\n }\n\n const dialog = $(`.delete.modal${filter}`);\n dialog.find('.name').text($this.data('name'));\n\n dialog.modal({\n closable: false,\n onApprove() {\n if ($this.data('type') === 'form') {\n $($this.data('form')).submit();\n return;\n }\n\n $.post($this.data('url'), {\n _csrf: csrf,\n id: $this.data('id')\n }).done((data) => {\n window.location.href = data.redirect;\n });\n }\n }).modal('show');\n return false;\n}\n\nfunction showAddAllPopup() {\n const $this = $(this);\n let filter = '';\n if ($this.attr('id')) {\n filter += `#${$this.attr('id')}`;\n }\n\n const dialog = $(`.addall.modal${filter}`);\n dialog.find('.name').text($this.data('name'));\n\n dialog.modal({\n closable: false,\n onApprove() {\n if ($this.data('type') === 'form') {\n $($this.data('form')).submit();\n return;\n }\n\n $.post($this.data('url'), {\n _csrf: csrf,\n id: $this.data('id')\n }).done((data) => {\n window.location.href = data.redirect;\n });\n }\n }).modal('show');\n return false;\n}\n\nfunction initVueComponents() {\n const vueDelimeters = ['${', '}'];\n\n Vue.component('repo-search', {\n delimiters: vueDelimeters,\n\n props: {\n searchLimit: {\n type: Number,\n default: 10\n },\n suburl: {\n type: String,\n required: true\n },\n uid: {\n type: Number,\n required: true\n },\n organizations: {\n type: Array,\n default: []\n },\n isOrganization: {\n type: Boolean,\n default: true\n },\n canCreateOrganization: {\n type: Boolean,\n default: false\n },\n organizationsTotalCount: {\n type: Number,\n default: 0\n },\n moreReposLink: {\n type: String,\n default: ''\n }\n },\n\n data() {\n return {\n tab: 'repos',\n repos: [],\n reposTotalCount: 0,\n reposFilter: 'all',\n searchQuery: '',\n isLoading: false,\n repoTypes: {\n all: {\n count: 0,\n searchMode: '',\n },\n forks: {\n count: 0,\n searchMode: 'fork',\n },\n mirrors: {\n count: 0,\n searchMode: 'mirror',\n },\n sources: {\n count: 0,\n searchMode: 'source',\n },\n collaborative: {\n count: 0,\n searchMode: 'collaborative',\n },\n }\n };\n },\n\n computed: {\n showMoreReposLink() {\n return this.repos.length > 0 && this.repos.length < this.repoTypes[this.reposFilter].count;\n },\n searchURL() {\n return `${this.suburl}/api/v1/repos/search?sort=updated&order=desc&uid=${this.uid}&q=${this.searchQuery\n }&limit=${this.searchLimit}&mode=${this.repoTypes[this.reposFilter].searchMode\n }${this.reposFilter !== 'all' ? '&exclusive=1' : ''}`;\n },\n repoTypeCount() {\n return this.repoTypes[this.reposFilter].count;\n }\n },\n\n mounted() {\n this.searchRepos(this.reposFilter);\n\n const self = this;\n Vue.nextTick(() => {\n self.$refs.search.focus();\n });\n },\n\n methods: {\n changeTab(t) {\n this.tab = t;\n },\n\n changeReposFilter(filter) {\n this.reposFilter = filter;\n this.repos = [];\n this.repoTypes[filter].count = 0;\n this.searchRepos(filter);\n },\n\n showRepo(repo, filter) {\n switch (filter) {\n case 'sources':\n return repo.owner.id === this.uid && !repo.mirror && !repo.fork;\n case 'forks':\n return repo.owner.id === this.uid && !repo.mirror && repo.fork;\n case 'mirrors':\n return repo.mirror;\n case 'collaborative':\n return repo.owner.id !== this.uid && !repo.mirror;\n default:\n return true;\n }\n },\n\n searchRepos(reposFilter) {\n const self = this;\n\n this.isLoading = true;\n\n const searchedMode = this.repoTypes[reposFilter].searchMode;\n const searchedURL = this.searchURL;\n const searchedQuery = this.searchQuery;\n\n $.getJSON(searchedURL, (result, _textStatus, request) => {\n if (searchedURL === self.searchURL) {\n self.repos = result.data;\n const count = request.getResponseHeader('X-Total-Count');\n if (searchedQuery === '' && searchedMode === '') {\n self.reposTotalCount = count;\n }\n self.repoTypes[reposFilter].count = count;\n }\n }).always(() => {\n if (searchedURL === self.searchURL) {\n self.isLoading = false;\n }\n });\n },\n\n repoClass(repo) {\n if (repo.fork) {\n return 'octicon octicon-repo-forked';\n } if (repo.mirror) {\n return 'octicon octicon-repo-clone';\n } if (repo.private) {\n return 'octicon octicon-lock';\n }\n return 'octicon octicon-repo';\n }\n }\n });\n}\n\nfunction initCtrlEnterSubmit() {\n $('.js-quick-submit').keydown(function (e) {\n if (((e.ctrlKey && !e.altKey) || e.metaKey) && (e.keyCode === 13 || e.keyCode === 10)) {\n $(this).closest('form').submit();\n }\n });\n}\n\nfunction initVueApp() {\n const el = document.getElementById('app');\n if (!el) {\n return;\n }\n\n initVueComponents();\n\n new Vue({\n delimiters: ['${', '}'],\n el,\n data: {\n searchLimit: document.querySelector('meta[name=_search_limit]').content,\n suburl: document.querySelector('meta[name=_suburl]').content,\n uid: document.querySelector('meta[name=_context_uid]').content,\n },\n });\n}\n\nwindow.timeAddManual = function () {\n $('.mini.modal')\n .modal({\n duration: 200,\n onApprove() {\n $('#add_time_manual_form').submit();\n }\n }).modal('show');\n};\n\nwindow.toggleStopwatch = function () {\n $('#toggle_stopwatch_form').submit();\n};\nwindow.cancelStopwatch = function () {\n $('#cancel_stopwatch_form').submit();\n};\n\nwindow.initHeatmap = function (appElementId, heatmapUser, locale) {\n const el = document.getElementById(appElementId);\n if (!el) {\n return;\n }\n\n locale = locale || {};\n\n locale.contributions = locale.contributions || 'contributions';\n locale.no_contributions = locale.no_contributions || 'No contributions';\n\n const vueDelimeters = ['${', '}'];\n\n Vue.component('activity-heatmap', {\n delimiters: vueDelimeters,\n\n props: {\n user: {\n type: String,\n required: true\n },\n suburl: {\n type: String,\n required: true\n },\n locale: {\n type: Object,\n required: true\n }\n },\n\n data() {\n return {\n isLoading: true,\n colorRange: [],\n endDate: null,\n values: [],\n totalContributions: 0,\n };\n },\n\n mounted() {\n this.colorRange = [\n this.getColor(0),\n this.getColor(1),\n this.getColor(2),\n this.getColor(3),\n this.getColor(4),\n this.getColor(5)\n ];\n this.endDate = new Date();\n this.loadHeatmap(this.user);\n },\n\n methods: {\n loadHeatmap(userName) {\n const self = this;\n $.get(`${this.suburl}/api/v1/users/${userName}/heatmap`, (chartRawData) => {\n const chartData = [];\n for (let i = 0; i < chartRawData.length; i++) {\n self.totalContributions += chartRawData[i].contributions;\n chartData[i] = { date: new Date(chartRawData[i].timestamp * 1000), count: chartRawData[i].contributions };\n }\n self.values = chartData;\n self.isLoading = false;\n });\n },\n\n getColor(idx) {\n const el = document.createElement('div');\n el.className = `heatmap-color-${idx}`;\n document.body.appendChild(el);\n\n const color = getComputedStyle(el).backgroundColor;\n\n document.body.removeChild(el);\n\n return color;\n }\n },\n\n template: '

total contributions in the last 12 months

'\n });\n\n new Vue({\n delimiters: vueDelimeters,\n el,\n\n data: {\n suburl: document.querySelector('meta[name=_suburl]').content,\n heatmapUser,\n locale\n },\n });\n};\n\nfunction initFilterBranchTagDropdown(selector) {\n $(selector).each(function () {\n const $dropdown = $(this);\n const $data = $dropdown.find('.data');\n const data = {\n items: [],\n mode: $data.data('mode'),\n searchTerm: '',\n noResults: '',\n canCreateBranch: false,\n menuVisible: false,\n active: 0\n };\n $data.find('.item').each(function () {\n data.items.push({\n name: $(this).text(),\n url: $(this).data('url'),\n branch: $(this).hasClass('branch'),\n tag: $(this).hasClass('tag'),\n selected: $(this).hasClass('selected')\n });\n });\n $data.remove();\n new Vue({\n delimiters: ['${', '}'],\n el: this,\n data,\n\n beforeMount() {\n const vm = this;\n\n this.noResults = vm.$el.getAttribute('data-no-results');\n this.canCreateBranch = vm.$el.getAttribute('data-can-create-branch') === 'true';\n\n document.body.addEventListener('click', (event) => {\n if (vm.$el.contains(event.target)) {\n return;\n }\n if (vm.menuVisible) {\n Vue.set(vm, 'menuVisible', false);\n }\n });\n },\n\n watch: {\n menuVisible(visible) {\n if (visible) {\n this.focusSearchField();\n }\n }\n },\n\n computed: {\n filteredItems() {\n const vm = this;\n\n const items = vm.items.filter((item) => {\n return ((vm.mode === 'branches' && item.branch) || (vm.mode === 'tags' && item.tag))\n && (!vm.searchTerm || item.name.toLowerCase().indexOf(vm.searchTerm.toLowerCase()) >= 0);\n });\n\n vm.active = (items.length === 0 && vm.showCreateNewBranch ? 0 : -1);\n\n return items;\n },\n showNoResults() {\n return this.filteredItems.length === 0 && !this.showCreateNewBranch;\n },\n showCreateNewBranch() {\n const vm = this;\n if (!this.canCreateBranch || !vm.searchTerm || vm.mode === 'tags') {\n return false;\n }\n\n return vm.items.filter((item) => item.name.toLowerCase() === vm.searchTerm.toLowerCase()).length === 0;\n }\n },\n\n methods: {\n selectItem(item) {\n const prev = this.getSelected();\n if (prev !== null) {\n prev.selected = false;\n }\n item.selected = true;\n window.location.href = item.url;\n },\n createNewBranch() {\n if (!this.showCreateNewBranch) {\n return;\n }\n this.$refs.newBranchForm.submit();\n },\n focusSearchField() {\n const vm = this;\n Vue.nextTick(() => {\n vm.$refs.searchField.focus();\n });\n },\n getSelected() {\n for (let i = 0, j = this.items.length; i < j; ++i) {\n if (this.items[i].selected) return this.items[i];\n }\n return null;\n },\n getSelectedIndexInFiltered() {\n for (let i = 0, j = this.filteredItems.length; i < j; ++i) {\n if (this.filteredItems[i].selected) return i;\n }\n return -1;\n },\n scrollToActive() {\n let el = this.$refs[`listItem${this.active}`];\n if (!el || el.length === 0) {\n return;\n }\n if (Array.isArray(el)) {\n el = el[0];\n }\n\n const cont = this.$refs.scrollContainer;\n\n if (el.offsetTop < cont.scrollTop) {\n cont.scrollTop = el.offsetTop;\n } else if (el.offsetTop + el.clientHeight > cont.scrollTop + cont.clientHeight) {\n cont.scrollTop = el.offsetTop + el.clientHeight - cont.clientHeight;\n }\n },\n keydown(event) {\n const vm = this;\n if (event.keyCode === 40) {\n // arrow down\n event.preventDefault();\n\n if (vm.active === -1) {\n vm.active = vm.getSelectedIndexInFiltered();\n }\n\n if (vm.active + (vm.showCreateNewBranch ? 0 : 1) >= vm.filteredItems.length) {\n return;\n }\n vm.active++;\n vm.scrollToActive();\n }\n if (event.keyCode === 38) {\n // arrow up\n event.preventDefault();\n\n if (vm.active === -1) {\n vm.active = vm.getSelectedIndexInFiltered();\n }\n\n if (vm.active <= 0) {\n return;\n }\n vm.active--;\n vm.scrollToActive();\n }\n if (event.keyCode === 13) {\n // enter\n event.preventDefault();\n\n if (vm.active >= vm.filteredItems.length) {\n vm.createNewBranch();\n } else if (vm.active >= 0) {\n vm.selectItem(vm.filteredItems[vm.active]);\n }\n }\n if (event.keyCode === 27) {\n // escape\n event.preventDefault();\n vm.menuVisible = false;\n }\n }\n }\n });\n });\n}\n\n$('.commit-button').click(function (e) {\n e.preventDefault();\n $(this).parent().find('.commit-body').toggle();\n});\n\nfunction initNavbarContentToggle() {\n const content = $('#navbar');\n const toggle = $('#navbar-expand-toggle');\n let isExpanded = false;\n toggle.click(() => {\n isExpanded = !isExpanded;\n if (isExpanded) {\n content.addClass('shown');\n toggle.addClass('active');\n } else {\n content.removeClass('shown');\n toggle.removeClass('active');\n }\n });\n}\n\nfunction initTopicbar() {\n const mgrBtn = $('#manage_topic');\n const editDiv = $('#topic_edit');\n const viewDiv = $('#repo-topics');\n const saveBtn = $('#save_topic');\n const topicDropdown = $('#topic_edit .dropdown');\n const topicForm = $('#topic_edit.ui.form');\n const topicPrompts = getPrompts();\n\n mgrBtn.click(() => {\n viewDiv.hide();\n editDiv.css('display', ''); // show Semantic UI Grid\n });\n\n function getPrompts() {\n const hidePrompt = $('div.hide#validate_prompt');\n const prompts = {\n countPrompt: hidePrompt.children('#count_prompt').text(),\n formatPrompt: hidePrompt.children('#format_prompt').text()\n };\n hidePrompt.remove();\n return prompts;\n }\n\n saveBtn.click(() => {\n const topics = $('input[name=topics]').val();\n\n $.post(saveBtn.data('link'), {\n _csrf: csrf,\n topics\n }, (_data, _textStatus, xhr) => {\n if (xhr.responseJSON.status === 'ok') {\n viewDiv.children('.topic').remove();\n if (topics.length) {\n const topicArray = topics.split(',');\n\n const last = viewDiv.children('a').last();\n for (let i = 0; i < topicArray.length; i++) {\n $(`
${topicArray[i]}
`).insertBefore(last);\n }\n }\n editDiv.css('display', 'none');\n viewDiv.show();\n }\n }).fail((xhr) => {\n if (xhr.status === 422) {\n if (xhr.responseJSON.invalidTopics.length > 0) {\n topicPrompts.formatPrompt = xhr.responseJSON.message;\n\n const { invalidTopics } = xhr.responseJSON;\n const topicLables = topicDropdown.children('a.ui.label');\n\n topics.split(',').forEach((value, index) => {\n for (let i = 0; i < invalidTopics.length; i++) {\n if (invalidTopics[i] === value) {\n topicLables.eq(index).removeClass('green').addClass('red');\n }\n }\n });\n } else {\n topicPrompts.countPrompt = xhr.responseJSON.message;\n }\n }\n }).always(() => {\n topicForm.form('validate form');\n });\n });\n\n topicDropdown.dropdown({\n allowAdditions: true,\n forceSelection: false,\n fields: { name: 'description', value: 'data-value' },\n saveRemoteData: false,\n label: {\n transition: 'horizontal flip',\n duration: 200,\n variation: false,\n blue: true,\n basic: true,\n },\n className: {\n label: 'ui small label'\n },\n apiSettings: {\n url: `${suburl}/api/v1/topics/search?q={query}`,\n throttle: 500,\n cache: false,\n onResponse(res) {\n const formattedResponse = {\n success: false,\n results: [],\n };\n const stripTags = function (text) {\n return text.replace(/<[^>]*>?/gm, '');\n };\n\n const query = stripTags(this.urlData.query.trim());\n let found_query = false;\n const current_topics = [];\n topicDropdown.find('div.label.visible.topic,a.label.visible').each((_, e) => { current_topics.push(e.dataset.value); });\n\n if (res.topics) {\n let found = false;\n for (let i = 0; i < res.topics.length; i++) {\n // skip currently added tags\n if (current_topics.indexOf(res.topics[i].topic_name) !== -1) {\n continue;\n }\n\n if (res.topics[i].topic_name.toLowerCase() === query.toLowerCase()) {\n found_query = true;\n }\n formattedResponse.results.push({ description: res.topics[i].topic_name, 'data-value': res.topics[i].topic_name });\n found = true;\n }\n formattedResponse.success = found;\n }\n\n if (query.length > 0 && !found_query) {\n formattedResponse.success = true;\n formattedResponse.results.unshift({ description: query, 'data-value': query });\n } else if (query.length > 0 && found_query) {\n formattedResponse.results.sort((a, b) => {\n if (a.description.toLowerCase() === query.toLowerCase()) return -1;\n if (b.description.toLowerCase() === query.toLowerCase()) return 1;\n if (a.description > b.description) return -1;\n if (a.description < b.description) return 1;\n return 0;\n });\n }\n\n\n return formattedResponse;\n },\n },\n onLabelCreate(value) {\n value = value.toLowerCase().trim();\n this.attr('data-value', value).contents().first().replaceWith(value);\n return $(this);\n },\n onAdd(addedValue, _addedText, $addedChoice) {\n addedValue = addedValue.toLowerCase().trim();\n $($addedChoice).attr('data-value', addedValue);\n $($addedChoice).attr('data-text', addedValue);\n }\n });\n\n $.fn.form.settings.rules.validateTopic = function (_values, regExp) {\n const topics = topicDropdown.children('a.ui.label');\n const status = topics.length === 0 || topics.last().attr('data-value').match(regExp);\n if (!status) {\n topics.last().removeClass('green').addClass('red');\n }\n return status && topicDropdown.children('a.ui.label.red').length === 0;\n };\n\n topicForm.form({\n on: 'change',\n inline: true,\n fields: {\n topics: {\n identifier: 'topics',\n rules: [\n {\n type: 'validateTopic',\n value: /^[a-z0-9][a-z0-9-]{1,35}$/,\n prompt: topicPrompts.formatPrompt\n },\n {\n type: 'maxCount[25]',\n prompt: topicPrompts.countPrompt\n }\n ]\n },\n }\n });\n}\n\nwindow.toggleDeadlineForm = function () {\n $('#deadlineForm').fadeToggle(150);\n};\n\nwindow.setDeadline = function () {\n const deadline = $('#deadlineDate').val();\n window.updateDeadline(deadline);\n};\n\nwindow.updateDeadline = function (deadlineString) {\n $('#deadline-err-invalid-date').hide();\n $('#deadline-loader').addClass('loading');\n\n let realDeadline = null;\n if (deadlineString !== '') {\n const newDate = Date.parse(deadlineString);\n\n if (Number.isNaN(newDate)) {\n $('#deadline-loader').removeClass('loading');\n $('#deadline-err-invalid-date').show();\n return false;\n }\n realDeadline = new Date(newDate);\n }\n\n $.ajax(`${$('#update-issue-deadline-form').attr('action')}/deadline`, {\n data: JSON.stringify({\n due_date: realDeadline,\n }),\n headers: {\n 'X-Csrf-Token': csrf,\n 'X-Remote': true,\n },\n contentType: 'application/json',\n type: 'POST',\n success() {\n reload();\n },\n error() {\n $('#deadline-loader').removeClass('loading');\n $('#deadline-err-invalid-date').show();\n }\n });\n};\n\nwindow.deleteDependencyModal = function (id, type) {\n $('.remove-dependency')\n .modal({\n closable: false,\n duration: 200,\n onApprove() {\n $('#removeDependencyID').val(id);\n $('#dependencyType').val(type);\n $('#removeDependencyForm').submit();\n }\n }).modal('show');\n};\n\nfunction initIssueList() {\n const repolink = $('#repolink').val();\n const repoId = $('#repoId').val();\n const crossRepoSearch = $('#crossRepoSearch').val();\n let issueSearchUrl = `${suburl}/api/v1/repos/${repolink}/issues?q={query}`;\n if (crossRepoSearch === 'true') {\n issueSearchUrl = `${suburl}/api/v1/repos/issues/search?q={query}&priority_repo_id=${repoId}`;\n }\n $('#new-dependency-drop-list')\n .dropdown({\n apiSettings: {\n url: issueSearchUrl,\n onResponse(response) {\n const filteredResponse = { success: true, results: [] };\n const currIssueId = $('#new-dependency-drop-list').data('issue-id');\n // Parse the response from the api to work with our dropdown\n $.each(response, (_i, issue) => {\n // Don't list current issue in the dependency list.\n if (issue.id === currIssueId) {\n return;\n }\n filteredResponse.results.push({\n name: `#${issue.number} ${htmlEncode(issue.title)\n }
${htmlEncode(issue.repository.full_name)}
`,\n value: issue.id\n });\n });\n return filteredResponse;\n },\n cache: false,\n },\n\n fullTextSearch: true\n });\n\n $('.menu a.label-filter-item').each(function () {\n $(this).click(function (e) {\n if (e.altKey) {\n e.preventDefault();\n\n const href = $(this).attr('href');\n const id = $(this).data('label-id');\n\n const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;\n const newStr = 'labels=$1-$2$3&';\n\n window.location = href.replace(new RegExp(regStr), newStr);\n }\n });\n });\n\n $('.menu .ui.dropdown.label-filter').keydown((e) => {\n if (e.altKey && e.keyCode === 13) {\n const selectedItems = $('.menu .ui.dropdown.label-filter .menu .item.selected');\n\n if (selectedItems.length > 0) {\n const item = $(selectedItems[0]);\n\n const href = item.attr('href');\n const id = item.data('label-id');\n\n const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;\n const newStr = 'labels=$1-$2$3&';\n\n window.location = href.replace(new RegExp(regStr), newStr);\n }\n }\n });\n}\nwindow.cancelCodeComment = function (btn) {\n const form = $(btn).closest('form');\n if (form.length > 0 && form.hasClass('comment-form')) {\n form.addClass('hide');\n form.parent().find('button.comment-form-reply').show();\n } else {\n form.closest('.comment-code-cloud').remove();\n }\n};\nwindow.onOAuthLoginClick = function () {\n const oauthLoader = $('#oauth2-login-loader');\n const oauthNav = $('#oauth2-login-navigator');\n\n oauthNav.hide();\n oauthLoader.removeClass('disabled');\n\n setTimeout(() => {\n // recover previous content to let user try again\n // usually redirection will be performed before this action\n oauthLoader.addClass('disabled');\n oauthNav.show();\n }, 5000);\n};\n","$(async () => {\n const graphCanvas = document.getElementById('graph-canvas');\n if (!graphCanvas) return;\n\n const [{ default: gitGraph }] = await Promise.all([\n import(/* webpackChunkName: \"gitgraph\" */'../vendor/gitgraph.js/gitgraph.custom.js'),\n import(/* webpackChunkName: \"gitgraph\" */'../vendor/gitgraph.js/gitgraph.custom.css'),\n ]);\n\n const graphList = [];\n $('#graph-raw-list li span.node-relation').each(function () {\n graphList.push($(this).text());\n });\n\n gitGraph(graphCanvas, graphList);\n});\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/regenerator/index.js","webpack:///./node_modules/@babel/runtime/helpers/slicedToArray.js","webpack:///./web_src/js/publicPath.js","webpack:///./node_modules/regenerator-runtime/runtime.js","webpack:///./node_modules/@babel/runtime/helpers/arrayWithHoles.js","webpack:///./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","webpack:///./node_modules/@babel/runtime/helpers/nonIterableRest.js","webpack:///./web_src/js/index.js","webpack:///./web_src/js/gitGraph.js"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","installedModules","1","__webpack_require__","exports","module","l","e","promises","installedChunkData","promise","Promise","resolve","reject","onScriptComplete","script","document","createElement","charset","timeout","nc","setAttribute","src","p","jsonpScriptSrc","error","Error","event","onerror","onload","clearTimeout","chunk","errorType","type","realSrc","target","message","name","request","undefined","setTimeout","head","appendChild","all","m","c","d","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","oe","err","console","jsonpArray","window","oldJsonpFunction","slice","s","arrayWithHoles","iterableToArrayLimit","nonIterableRest","arr","currentScript","url","URL","__webpack_public_path__","pathname","replace","querySelector","getAttribute","runtime","Op","hasOwn","$Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","wrap","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","context","Context","_invoke","state","GenStateSuspendedStart","method","arg","GenStateExecuting","GenStateCompleted","doneResult","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","done","GenStateSuspendedYield","makeInvokeMethod","fn","obj","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","this","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","previousPromise","callInvokeWithMethodAndArg","invoke","result","__await","then","unwrapped","TypeError","info","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","constructor","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","async","iter","toString","keys","reverse","pop","skipTempReset","prev","charAt","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","thrown","delegateYield","regeneratorRuntime","accidentalStrictMode","Function","Array","isArray","_arr","_n","_d","_e","_s","_i","csrf","suburl","previewFileModes","simpleMDEditor","codeMirrorEditor","htmlEncode","text","jQuery","html","initCommentPreviewTab","$form","$tabMenu","find","tab","click","$this","$","post","_csrf","val","$previewPanel","emojify","run","each","hljs","highlightBlock","buttonsClickOnEnter","initEditForm","$previewTab","split","initEditPreviewTab","content","$diffPreviewPanel","updateIssuesMeta","action","issueIds","elementId","ajax","issue_ids","id","success","reload","location","initImagePaste","field","addEventListener","pasteEvent","callback","clipboardData","items","indexOf","blob","getAsFile","preventDefault","stopPropagation","retrieveImageFromClipboardAsBlob","img","substr","lastIndexOf","selectionStart","startPos","endPos","selectionEnd","substring","insertAtCursor","file","xhr","XMLHttpRequest","status","responseText","open","setRequestHeader","formData","FormData","append","send","uploadFile","res","JSON","parse","oldval","newval","replaceAndKeepCursor","uuid","input","initCommentForm","$selectBranch","selectedValue","css","removeClass","addClass","initListSubmits","selectItem","selector","outerSelector","$list","$noSelect","$listMenu","hasLabelUpdateAction","labels","dropdown","label","hasClass","listIds","parent","join","select_id","input_id","$menu","hasUpdateAction","initRepository","$data","searchTerm","noResults","canCreateBranch","menuVisible","active","branch","tag","selected","remove","Vue","delimiters","el","beforeMount","vm","$el","body","contains","set","watch","visible","focusSearchField","computed","filteredItems","filter","item","toLowerCase","showCreateNewBranch","showNoResults","methods","getSelected","href","createNewBranch","$refs","newBranchForm","submit","nextTick","searchField","focus","j","getSelectedIndexInFiltered","scrollToActive","cont","scrollContainer","offsetTop","scrollTop","clientHeight","keydown","keyCode","initFilterSearchDropdown","keyup","$prompt","show","hide","change","checked","$newLabelPanel","minicolors","color_hex","modal","onApprove","$datepicker","datetimepicker","lang","inline","timepicker","startDate","formatDate","onSelectDate","ct","dateFormat","$issueTitle","$editInput","editTitleToggle","toggle","title","closest","$content","$parent","quote","$textarea","$segment","$editContentZone","$renderContent","$rawContent","issuesTribute","attach","emojiTribute","$dropzone","$files","filenameDict","dropzone","headers","maxFiles","maxFilesize","acceptedFiles","addRemoveLinks","dictDefaultMessage","dictInvalidFileType","dictFileTooBig","dictRemoveFile","init","on","submitted","getJSON","drop","removeAllFiles","empty","imgSrc","emit","files","$editContentForm","attr","$attachments","map","attachments","confirm","$statusButton","$mergeButton","onChange","_text","_value","$choice","initReactionSelector","reactions","popup","position","metadata","actionURL","resp","react","insertBefore","appendTo","hasEmoji","$item","addLine","delLine","addPercent","parseFloat","localStorage","setItem","select","$repoComparePull","$dropdown","fullTextSearch","selectOnKeydown","assingMenuAttributes","menu","Math","floor","random","initRepositoryCollaboration","uid","initEditor","prop","$editFilename","parts","$section","$divider","getCursorPosition","last","setSelectionRange","element","trigger","$editArea","markdownFileExts","lineWrapExtensions","spec","extension","extWithDot","dataUrl","apiCall","exec","CodeMirror","findModeByExtension","previewLink","mime","toTextArea","SimpleMDE","autoDownloadFontAwesome","forceSync","renderingConfig","singleLineBreaks","indentWithTabs","tabSize","spellChecker","previewRender","plainText","preview","innerHTML","toolbar","setSimpleMDE","fromTextArea","lineNumbers","cm","_change","getValue","setCodeMirror","setOption","autoLoadMode","editorconfig","indent_style","Tab","spaces","parseInt","getOption","replaceSelection","indent_size","tab_width","$commitButton","$editForm","areYouSure","silent","dirtyClass","fieldSelector","dirty","initUserSettings","keypress","initCodeView","$select","siblings","selectRange","shiftKey","eq","getSelection","removeAllRanges","selection","$first","hash","match","offset","top","$foldButton","slideUp","slideDown","insertBlobExcerpt","$blob","$row","replaceWith","u2fSigned","stringify","contentType","fail","u2fError","u2fRegistered","errorCode","checkError","u2fErrors","browser","2","3","4","5","u2fRegisterRequest","req","registeredKeys","u2fApi","register","appId","registerRequests","catch","reason","metaData","code","changeHash","history","pushState","$from","a","b","classes","showDeletePopup","dialog","closable","redirect","showAddAllPopup","graphCanvas","getElementById","gitGraph","default","graphList","Dropzone","autoDiscover","pos","Sel","createRange","SelLength","moveStart","ready","onShow","transition","direction","accordion","checkbox","progress","showActivity","slideToggle","nodes","querySelectorAll","setConfig","img_dir","ignore_emoticons","getElementsByClassName","childNodes","nodeName","$searchTeamBox","$searchRepoBox","toggleMigrations","isExpanded","mgrBtn","editDiv","viewDiv","saveBtn","topicDropdown","topicForm","topicPrompts","hidePrompt","prompts","clipboard","Clipboard","clearSelection","node","encodeURIComponent","children","dataset","issueIDs","issueId","_","first","search","minCharacters","apiSettings","onResponse","response","login","full_name","image","avatar_url","results","searchFields","permission","description","dbType","dbDefaults","MySQL","PostgreSQL","MSSQL","_type","defaultHost","is","authUserName","cloneAddr","startsWith","sideBySideChanges","sideBySideTimeout","simplemde","render","isSideBySideActive","codemirror","cursorPos","getCursor","setCursor","line","ch","className","getInputField","$bEdit","$bPrev","$toolbar","$bPreview","$bSideBySide","initWikiForm","updateContentType","initWebhook","removeAttr","authType","onOAuth2Change","onSecurityProtocolChange","onUsePagedSearchChange","onOAuth2UseCustomURLChange","$detailModal","$checkboxes","ids","provider","initAdmin","component","props","searchLimit","Number","String","required","organizations","isOrganization","Boolean","canCreateOrganization","organizationsTotalCount","moreReposLink","repos","reposTotalCount","reposFilter","searchQuery","isLoading","repoTypes","count","searchMode","forks","mirrors","sources","collaborative","showMoreReposLink","searchURL","repoTypeCount","mounted","searchRepos","changeTab","changeReposFilter","showRepo","repo","owner","mirror","fork","searchedMode","searchedURL","searchedQuery","_textStatus","getResponseHeader","always","repoClass","private","initVueApp","ctrlKey","altKey","metaKey","countPrompt","formatPrompt","topics","_data","responseJSON","topicArray","invalidTopics","topicLables","index","form","allowAdditions","forceSelection","fields","saveRemoteData","duration","variation","blue","basic","throttle","cache","formattedResponse","query","urlData","trim","found_query","current_topics","found","topic_name","unshift","sort","onLabelCreate","contents","onAdd","addedValue","_addedText","$addedChoice","settings","rules","validateTopic","_values","regExp","identifier","prompt","ensureSupport","sign","challenge","allowMultiple","repolink","repoId","crossRepoSearch","issueSearchUrl","filteredResponse","currIssueId","issue","number","repository","regStr","RegExp","selectedItems","initIssueList","toUpperCase","wipPrefixes","sticky","isSplit","side","idx","path","tr","ntr","after","td","commentCloud","initRepoStatusChecker","migrating","repo_name","$repoTemplate","checkTemplate","$templateUnits","$nonTemplate","changeOwner","_r","initTemplateSearch","getItem","routes","$cloneAddr","$repoName","arrays","$title","timeAddManual","toggleStopwatch","cancelStopwatch","initHeatmap","appElementId","heatmapUser","locale","contributions","no_contributions","vueDelimeters","user","colorRange","endDate","totalContributions","getColor","Date","loadHeatmap","userName","chartRawData","chartData","date","timestamp","color","getComputedStyle","backgroundColor","removeChild","template","toggleDeadlineForm","fadeToggle","setDeadline","deadline","updateDeadline","deadlineString","realDeadline","newDate","due_date","deleteDependencyModal","cancelCodeComment","btn","onOAuthLoginClick","oauthLoader","oauthNav"],"mappings":"aACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GAKAK,EAAI,EAAGC,EAAW,GACpCD,EAAIF,EAASI,OAAQF,IACzBH,EAAUC,EAASE,GAChBG,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AA8BmJ,WAKtC9S,OAAOuyB,sBAAwB,SAAUrnB,EAAIvN,GAC3CgM,EAAE,sBACC0J,MAAM,CACLsN,UAAU,EACV8K,SAAU,IACVnY,UAHK,WAIH3J,EAAE,uBAAuBG,IAAIoB,GAC7BvB,EAAE,mBAAmBG,IAAInM,GACzBgM,EAAE,yBAAyBkI,YAE5BwB,MAAM,SAwEbrT,OAAOwyB,kBAAoB,SAAUC,GACnC,IAAMrH,EAAOzhB,EAAE8oB,GAAKne,QAAQ,QACxB8W,EAAKnwB,OAAS,GAAKmwB,EAAKnc,SAAS,iBACnCmc,EAAK/c,SAAS,QACd+c,EAAKjc,SAAS5F,KAAK,6BAA6BuJ,QAEhDsY,EAAK9W,QAAQ,uBAAuBnE,UAGxCnQ,OAAO0yB,kBAAoB,WACzB,IAAMC,EAAchpB,EAAE,wBAChBipB,EAAWjpB,EAAE,2BAEnBipB,EAAS7f,OACT4f,EAAYvkB,YAAY,YAExBlQ,YAAW,WAGTy0B,EAAYtkB,SAAS,YACrBukB,EAAS9f,SACR","file":"index.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t};\n\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t1: 0\n \t};\n\n\n\n \t// script path function\n \tfunction jsonpScriptSrc(chunkId) {\n \t\treturn __webpack_require__.p + \"\" + ({\"0\":\"gitgraph\"}[chunkId]||chunkId) + \".js\"\n \t}\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tvar promises = [];\n\n\n \t\t// JSONP chunk loading for javascript\n\n \t\tvar installedChunkData = installedChunks[chunkId];\n \t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n \t\t\t// a Promise means \"currently loading\".\n \t\t\tif(installedChunkData) {\n \t\t\t\tpromises.push(installedChunkData[2]);\n \t\t\t} else {\n \t\t\t\t// setup Promise in chunk cache\n \t\t\t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\t\t\tinstalledChunkData = installedChunks[chunkId] = [resolve, reject];\n \t\t\t\t});\n \t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n \t\t\t\t// start chunk loading\n \t\t\t\tvar script = document.createElement('script');\n \t\t\t\tvar onScriptComplete;\n\n \t\t\t\tscript.charset = 'utf-8';\n \t\t\t\tscript.timeout = 120;\n \t\t\t\tif (__webpack_require__.nc) {\n \t\t\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t\t\t}\n \t\t\t\tscript.src = jsonpScriptSrc(chunkId);\n\n \t\t\t\t// create error before stack unwound to get useful stacktrace later\n \t\t\t\tvar error = new Error();\n \t\t\t\tonScriptComplete = function (event) {\n \t\t\t\t\t// avoid mem leaks in IE.\n \t\t\t\t\tscript.onerror = script.onload = null;\n \t\t\t\t\tclearTimeout(timeout);\n \t\t\t\t\tvar chunk = installedChunks[chunkId];\n \t\t\t\t\tif(chunk !== 0) {\n \t\t\t\t\t\tif(chunk) {\n \t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n \t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n \t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n \t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n \t\t\t\t\t\t\terror.type = errorType;\n \t\t\t\t\t\t\terror.request = realSrc;\n \t\t\t\t\t\t\tchunk[1](error);\n \t\t\t\t\t\t}\n \t\t\t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t\t\t}\n \t\t\t\t};\n \t\t\t\tvar timeout = setTimeout(function(){\n \t\t\t\t\tonScriptComplete({ type: 'timeout', target: script });\n \t\t\t\t}, 120000);\n \t\t\t\tscript.onerror = script.onload = onScriptComplete;\n \t\t\t\tdocument.head.appendChild(script);\n \t\t\t}\n \t\t}\n \t\treturn Promise.all(promises);\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","module.exports = require(\"regenerator-runtime\");\n","var arrayWithHoles = require(\"./arrayWithHoles\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit\");\n\nvar nonIterableRest = require(\"./nonIterableRest\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray;","/* This sets up webpack's chunk loading to load resources from the same\n directory where it loaded index.js from. This file must be imported\n before any lazy-loading is being attempted. */\n\nif (document.currentScript && document.currentScript.src) {\n const url = new URL(document.currentScript.src);\n __webpack_public_path__ = `${url.pathname.replace(/\\/[^/]*$/, '')}/`;\n} else {\n // compat: IE11\n const script = document.querySelector('script[src*=\"/index.js\"]');\n __webpack_public_path__ = `${script.getAttribute('src').replace(/\\/[^/]*$/, '')}/`;\n}\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles;","function _iterableToArrayLimit(arr, i) {\n if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) {\n return;\n }\n\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n}\n\nmodule.exports = _nonIterableRest;","/* globals wipPrefixes, issuesTribute, emojiTribute */\n/* exported timeAddManual, toggleStopwatch, cancelStopwatch, initHeatmap */\n/* exported toggleDeadlineForm, setDeadline, updateDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */\n\nimport './publicPath';\nimport './gitGraph';\n\nfunction htmlEncode(text) {\n return jQuery('
').text(text).html();\n}\n\nlet csrf;\nlet suburl;\nlet previewFileModes;\nlet simpleMDEditor;\nlet codeMirrorEditor;\n\n// Disable Dropzone auto-discover because it's manually initialized\nif (typeof (Dropzone) !== 'undefined') {\n Dropzone.autoDiscover = false;\n}\n\nfunction initCommentPreviewTab($form) {\n const $tabMenu = $form.find('.tabular.menu');\n $tabMenu.find('.item').tab();\n $tabMenu.find(`.item[data-tab=\"${$tabMenu.data('preview')}\"]`).click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $this.data('context'),\n text: $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('write')}\"] textarea`).val()\n }, (data) => {\n const $previewPanel = $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('preview')}\"]`);\n $previewPanel.html(data);\n emojify.run($previewPanel[0]);\n $('pre code', $previewPanel[0]).each(function () {\n hljs.highlightBlock(this);\n });\n });\n });\n\n buttonsClickOnEnter();\n}\n\nfunction initEditPreviewTab($form) {\n const $tabMenu = $form.find('.tabular.menu');\n $tabMenu.find('.item').tab();\n const $previewTab = $tabMenu.find(`.item[data-tab=\"${$tabMenu.data('preview')}\"]`);\n if ($previewTab.length) {\n previewFileModes = $previewTab.data('preview-file-modes').split(',');\n $previewTab.click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $this.data('context'),\n text: $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('write')}\"] textarea`).val()\n }, (data) => {\n const $previewPanel = $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('preview')}\"]`);\n $previewPanel.html(data);\n emojify.run($previewPanel[0]);\n $('pre code', $previewPanel[0]).each(function () {\n hljs.highlightBlock(this);\n });\n });\n });\n }\n}\n\nfunction initEditDiffTab($form) {\n const $tabMenu = $form.find('.tabular.menu');\n $tabMenu.find('.item').tab();\n $tabMenu.find(`.item[data-tab=\"${$tabMenu.data('diff')}\"]`).click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n context: $this.data('context'),\n content: $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('write')}\"] textarea`).val()\n }, (data) => {\n const $diffPreviewPanel = $form.find(`.tab.segment[data-tab=\"${$tabMenu.data('diff')}\"]`);\n $diffPreviewPanel.html(data);\n emojify.run($diffPreviewPanel[0]);\n });\n });\n}\n\n\nfunction initEditForm() {\n if ($('.edit.form').length === 0) {\n return;\n }\n\n initEditPreviewTab($('.edit.form'));\n initEditDiffTab($('.edit.form'));\n}\n\nfunction initBranchSelector() {\n const $selectBranch = $('.ui.select-branch');\n const $branchMenu = $selectBranch.find('.reference-list-menu');\n $branchMenu.find('.item:not(.no-select)').click(function () {\n const selectedValue = $(this).data('id');\n $($(this).data('id-selector')).val(selectedValue);\n $selectBranch.find('.ui .branch-name').text(selectedValue);\n });\n $selectBranch.find('.reference.column').click(function () {\n $selectBranch.find('.scrolling.reference-list-menu').css('display', 'none');\n $selectBranch.find('.reference .text').removeClass('black');\n $($(this).data('target')).css('display', 'block');\n $(this).find('.text').addClass('black');\n return false;\n });\n}\n\nfunction updateIssuesMeta(url, action, issueIds, elementId) {\n return new Promise(((resolve) => {\n $.ajax({\n type: 'POST',\n url,\n data: {\n _csrf: csrf,\n action,\n issue_ids: issueIds,\n id: elementId\n },\n success: resolve\n });\n }));\n}\n\nfunction initRepoStatusChecker() {\n const migrating = $('#repo_migrating');\n $('#repo_migrating_failed').hide();\n if (migrating) {\n const repo_name = migrating.attr('repo');\n if (typeof repo_name === 'undefined') {\n return;\n }\n $.ajax({\n type: 'GET',\n url: `${suburl}/${repo_name}/status`,\n data: {\n _csrf: csrf,\n },\n complete(xhr) {\n if (xhr.status === 200) {\n if (xhr.responseJSON) {\n if (xhr.responseJSON.status === 0) {\n window.location.reload();\n return;\n }\n\n setTimeout(() => {\n initRepoStatusChecker();\n }, 2000);\n return;\n }\n }\n $('#repo_migrating_progress').hide();\n $('#repo_migrating_failed').show();\n }\n });\n }\n}\n\nfunction initReactionSelector(parent) {\n let reactions = '';\n if (!parent) {\n parent = $(document);\n reactions = '.reactions > ';\n }\n\n parent.find(`${reactions}a.label`).popup({ position: 'bottom left', metadata: { content: 'title', title: 'none' } });\n\n parent.find(`.select-reaction > .menu > .item, ${reactions}a.label`).on('click', function (e) {\n const vm = this;\n e.preventDefault();\n\n if ($(this).hasClass('disabled')) return;\n\n const actionURL = $(this).hasClass('item')\n ? $(this).closest('.select-reaction').data('action-url')\n : $(this).data('action-url');\n const url = `${actionURL}/${$(this).hasClass('blue') ? 'unreact' : 'react'}`;\n $.ajax({\n type: 'POST',\n url,\n data: {\n _csrf: csrf,\n content: $(this).data('content')\n }\n }).done((resp) => {\n if (resp && (resp.html || resp.empty)) {\n const content = $(vm).closest('.content');\n let react = content.find('.segment.reactions');\n if (!resp.empty && react.length > 0) {\n react.remove();\n }\n if (!resp.empty) {\n react = $('
');\n const attachments = content.find('.segment.bottom:first');\n if (attachments.length > 0) {\n react.insertBefore(attachments);\n } else {\n react.appendTo(content);\n }\n react.html(resp.html);\n const hasEmoji = react.find('.has-emoji');\n for (let i = 0; i < hasEmoji.length; i++) {\n emojify.run(hasEmoji.get(i));\n }\n react.find('.dropdown').dropdown();\n initReactionSelector(react);\n }\n }\n });\n });\n}\n\nfunction insertAtCursor(field, value) {\n if (field.selectionStart || field.selectionStart === 0) {\n const startPos = field.selectionStart;\n const endPos = field.selectionEnd;\n field.value = field.value.substring(0, startPos)\n + value\n + field.value.substring(endPos, field.value.length);\n field.selectionStart = startPos + value.length;\n field.selectionEnd = startPos + value.length;\n } else {\n field.value += value;\n }\n}\n\nfunction replaceAndKeepCursor(field, oldval, newval) {\n if (field.selectionStart || field.selectionStart === 0) {\n const startPos = field.selectionStart;\n const endPos = field.selectionEnd;\n field.value = field.value.replace(oldval, newval);\n field.selectionStart = startPos + newval.length - oldval.length;\n field.selectionEnd = endPos + newval.length - oldval.length;\n } else {\n field.value = field.value.replace(oldval, newval);\n }\n}\n\nfunction retrieveImageFromClipboardAsBlob(pasteEvent, callback) {\n if (!pasteEvent.clipboardData) {\n return;\n }\n\n const { items } = pasteEvent.clipboardData;\n if (typeof items === 'undefined') {\n return;\n }\n\n for (let i = 0; i < items.length; i++) {\n if (items[i].type.indexOf('image') === -1) continue;\n const blob = items[i].getAsFile();\n\n if (typeof (callback) === 'function') {\n pasteEvent.preventDefault();\n pasteEvent.stopPropagation();\n callback(blob);\n }\n }\n}\n\nfunction uploadFile(file, callback) {\n const xhr = new XMLHttpRequest();\n\n xhr.onload = function () {\n if (xhr.status === 200) {\n callback(xhr.responseText);\n }\n };\n\n xhr.open('post', `${suburl}/attachments`, true);\n xhr.setRequestHeader('X-Csrf-Token', csrf);\n const formData = new FormData();\n formData.append('file', file, file.name);\n xhr.send(formData);\n}\n\nfunction reload() {\n window.location.reload();\n}\n\nfunction initImagePaste(target) {\n target.each(function () {\n const field = this;\n field.addEventListener('paste', (event) => {\n retrieveImageFromClipboardAsBlob(event, (img) => {\n const name = img.name.substr(0, img.name.lastIndexOf('.'));\n insertAtCursor(field, `![${name}]()`);\n uploadFile(img, (res) => {\n const data = JSON.parse(res);\n replaceAndKeepCursor(field, `![${name}]()`, `![${name}](${suburl}/attachments/${data.uuid})`);\n const input = $(``).val(data.uuid);\n $('.files').append(input);\n });\n });\n }, false);\n });\n}\n\nfunction initCommentForm() {\n if ($('.comment.form').length === 0) {\n return;\n }\n\n initBranchSelector();\n initCommentPreviewTab($('.comment.form'));\n initImagePaste($('.comment.form textarea'));\n\n // Listsubmit\n function initListSubmits(selector, outerSelector) {\n const $list = $(`.ui.${outerSelector}.list`);\n const $noSelect = $list.find('.no-select');\n const $listMenu = $(`.${selector} .menu`);\n let hasLabelUpdateAction = $listMenu.data('action') === 'update';\n const labels = {};\n\n $(`.${selector}`).dropdown('setting', 'onHide', () => {\n hasLabelUpdateAction = $listMenu.data('action') === 'update'; // Update the var\n if (hasLabelUpdateAction) {\n const promises = [];\n Object.keys(labels).forEach((elementId) => {\n const label = labels[elementId];\n const promise = updateIssuesMeta(\n label['update-url'],\n label.action,\n label['issue-id'],\n elementId\n );\n promises.push(promise);\n });\n Promise.all(promises).then(reload);\n }\n });\n\n $listMenu.find('.item:not(.no-select)').click(function () {\n // we don't need the action attribute when updating assignees\n if (selector === 'select-assignees-modify') {\n // UI magic. We need to do this here, otherwise it would destroy the functionality of\n // adding/removing labels\n if ($(this).hasClass('checked')) {\n $(this).removeClass('checked');\n $(this).find('.octicon').removeClass('octicon-check');\n } else {\n $(this).addClass('checked');\n $(this).find('.octicon').addClass('octicon-check');\n }\n\n updateIssuesMeta(\n $listMenu.data('update-url'),\n '',\n $listMenu.data('issue-id'),\n $(this).data('id')\n );\n $listMenu.data('action', 'update'); // Update to reload the page when we updated items\n return false;\n }\n\n if ($(this).hasClass('checked')) {\n $(this).removeClass('checked');\n $(this).find('.octicon').removeClass('octicon-check');\n if (hasLabelUpdateAction) {\n if (!($(this).data('id') in labels)) {\n labels[$(this).data('id')] = {\n 'update-url': $listMenu.data('update-url'),\n action: 'detach',\n 'issue-id': $listMenu.data('issue-id'),\n };\n } else {\n delete labels[$(this).data('id')];\n }\n }\n } else {\n $(this).addClass('checked');\n $(this).find('.octicon').addClass('octicon-check');\n if (hasLabelUpdateAction) {\n if (!($(this).data('id') in labels)) {\n labels[$(this).data('id')] = {\n 'update-url': $listMenu.data('update-url'),\n action: 'attach',\n 'issue-id': $listMenu.data('issue-id'),\n };\n } else {\n delete labels[$(this).data('id')];\n }\n }\n }\n\n const listIds = [];\n $(this).parent().find('.item').each(function () {\n if ($(this).hasClass('checked')) {\n listIds.push($(this).data('id'));\n $($(this).data('id-selector')).removeClass('hide');\n } else {\n $($(this).data('id-selector')).addClass('hide');\n }\n });\n if (listIds.length === 0) {\n $noSelect.removeClass('hide');\n } else {\n $noSelect.addClass('hide');\n }\n $($(this).parent().data('id')).val(listIds.join(','));\n return false;\n });\n $listMenu.find('.no-select.item').click(function () {\n if (hasLabelUpdateAction || selector === 'select-assignees-modify') {\n updateIssuesMeta(\n $listMenu.data('update-url'),\n 'clear',\n $listMenu.data('issue-id'),\n ''\n ).then(reload);\n }\n\n $(this).parent().find('.item').each(function () {\n $(this).removeClass('checked');\n $(this).find('.octicon').removeClass('octicon-check');\n });\n\n $list.find('.item').each(function () {\n $(this).addClass('hide');\n });\n $noSelect.removeClass('hide');\n $($(this).parent().data('id')).val('');\n });\n }\n\n // Init labels and assignees\n initListSubmits('select-label', 'labels');\n initListSubmits('select-assignees', 'assignees');\n initListSubmits('select-assignees-modify', 'assignees');\n\n function selectItem(select_id, input_id) {\n const $menu = $(`${select_id} .menu`);\n const $list = $(`.ui${select_id}.list`);\n const hasUpdateAction = $menu.data('action') === 'update';\n\n $menu.find('.item:not(.no-select)').click(function () {\n $(this).parent().find('.item').each(function () {\n $(this).removeClass('selected active');\n });\n\n $(this).addClass('selected active');\n if (hasUpdateAction) {\n updateIssuesMeta(\n $menu.data('update-url'),\n '',\n $menu.data('issue-id'),\n $(this).data('id')\n ).then(reload);\n }\n switch (input_id) {\n case '#milestone_id':\n $list.find('.selected').html(`${\n htmlEncode($(this).text())}`);\n break;\n case '#assignee_id':\n $list.find('.selected').html(``\n + `${\n htmlEncode($(this).text())}`);\n }\n $(`.ui${select_id}.list .no-select`).addClass('hide');\n $(input_id).val($(this).data('id'));\n });\n $menu.find('.no-select.item').click(function () {\n $(this).parent().find('.item:not(.no-select)').each(function () {\n $(this).removeClass('selected active');\n });\n\n if (hasUpdateAction) {\n updateIssuesMeta(\n $menu.data('update-url'),\n '',\n $menu.data('issue-id'),\n $(this).data('id')\n ).then(reload);\n }\n\n $list.find('.selected').html('');\n $list.find('.no-select').removeClass('hide');\n $(input_id).val('');\n });\n }\n\n // Milestone and assignee\n selectItem('.select-milestone', '#milestone_id');\n selectItem('.select-assignee', '#assignee_id');\n}\n\nfunction initInstall() {\n if ($('.install').length === 0) {\n return;\n }\n\n if ($('#db_host').val() === '') {\n $('#db_host').val('127.0.0.1:3306');\n $('#db_user').val('gitea');\n $('#db_name').val('gitea');\n }\n\n // Database type change detection.\n $('#db_type').change(function () {\n const sqliteDefault = 'data/gitea.db';\n const tidbDefault = 'data/gitea_tidb';\n\n const dbType = $(this).val();\n if (dbType === 'SQLite3') {\n $('#sql_settings').hide();\n $('#pgsql_settings').hide();\n $('#mysql_settings').hide();\n $('#sqlite_settings').show();\n\n if (dbType === 'SQLite3' && $('#db_path').val() === tidbDefault) {\n $('#db_path').val(sqliteDefault);\n }\n return;\n }\n\n const dbDefaults = {\n MySQL: '127.0.0.1:3306',\n PostgreSQL: '127.0.0.1:5432',\n MSSQL: '127.0.0.1:1433'\n };\n\n $('#sqlite_settings').hide();\n $('#sql_settings').show();\n\n $('#pgsql_settings').toggle(dbType === 'PostgreSQL');\n $('#mysql_settings').toggle(dbType === 'MySQL');\n $.each(dbDefaults, (_type, defaultHost) => {\n if ($('#db_host').val() === defaultHost) {\n $('#db_host').val(dbDefaults[dbType]);\n return false;\n }\n });\n });\n\n // TODO: better handling of exclusive relations.\n $('#offline-mode input').change(function () {\n if ($(this).is(':checked')) {\n $('#disable-gravatar').checkbox('check');\n $('#federated-avatar-lookup').checkbox('uncheck');\n }\n });\n $('#disable-gravatar input').change(function () {\n if ($(this).is(':checked')) {\n $('#federated-avatar-lookup').checkbox('uncheck');\n } else {\n $('#offline-mode').checkbox('uncheck');\n }\n });\n $('#federated-avatar-lookup input').change(function () {\n if ($(this).is(':checked')) {\n $('#disable-gravatar').checkbox('uncheck');\n $('#offline-mode').checkbox('uncheck');\n }\n });\n $('#enable-openid-signin input').change(function () {\n if ($(this).is(':checked')) {\n if (!$('#disable-registration input').is(':checked')) {\n $('#enable-openid-signup').checkbox('check');\n }\n } else {\n $('#enable-openid-signup').checkbox('uncheck');\n }\n });\n $('#disable-registration input').change(function () {\n if ($(this).is(':checked')) {\n $('#enable-captcha').checkbox('uncheck');\n $('#enable-openid-signup').checkbox('uncheck');\n } else {\n $('#enable-openid-signup').checkbox('check');\n }\n });\n $('#enable-captcha input').change(function () {\n if ($(this).is(':checked')) {\n $('#disable-registration').checkbox('uncheck');\n }\n });\n}\n\nfunction initRepository() {\n if ($('.repository').length === 0) {\n return;\n }\n\n function initFilterSearchDropdown(selector) {\n const $dropdown = $(selector);\n $dropdown.dropdown({\n fullTextSearch: true,\n selectOnKeydown: false,\n onChange(_text, _value, $choice) {\n if ($choice.data('url')) {\n window.location.href = $choice.data('url');\n }\n },\n message: { noResults: $dropdown.data('no-results') }\n });\n }\n\n // File list and commits\n if ($('.repository.file.list').length > 0 || ('.repository.commits').length > 0) {\n initFilterBranchTagDropdown('.choose.reference .dropdown');\n }\n\n // Wiki\n if ($('.repository.wiki.view').length > 0) {\n initFilterSearchDropdown('.choose.page .dropdown');\n }\n\n // Options\n if ($('.repository.settings.options').length > 0) {\n $('#repo_name').keyup(function () {\n const $prompt = $('#repo-name-change-prompt');\n if ($(this).val().toString().toLowerCase() !== $(this).data('name').toString().toLowerCase()) {\n $prompt.show();\n } else {\n $prompt.hide();\n }\n });\n\n // Enable or select internal/external wiki system and issue tracker.\n $('.enable-system').change(function () {\n if (this.checked) {\n $($(this).data('target')).removeClass('disabled');\n if (!$(this).data('context')) $($(this).data('context')).addClass('disabled');\n } else {\n $($(this).data('target')).addClass('disabled');\n if (!$(this).data('context')) $($(this).data('context')).removeClass('disabled');\n }\n });\n $('.enable-system-radio').change(function () {\n if (this.value === 'false') {\n $($(this).data('target')).addClass('disabled');\n if (typeof $(this).data('context') !== 'undefined') $($(this).data('context')).removeClass('disabled');\n } else if (this.value === 'true') {\n $($(this).data('target')).removeClass('disabled');\n if (typeof $(this).data('context') !== 'undefined') $($(this).data('context')).addClass('disabled');\n }\n });\n }\n\n // Labels\n if ($('.repository.labels').length > 0) {\n // Create label\n const $newLabelPanel = $('.new-label.segment');\n $('.new-label.button').click(() => {\n $newLabelPanel.show();\n });\n $('.new-label.segment .cancel').click(() => {\n $newLabelPanel.hide();\n });\n\n $('.color-picker').each(function () {\n $(this).minicolors();\n });\n $('.precolors .color').click(function () {\n const color_hex = $(this).data('color-hex');\n $('.color-picker').val(color_hex);\n $('.minicolors-swatch-color').css('background-color', color_hex);\n });\n $('.edit-label-button').click(function () {\n $('#label-modal-id').val($(this).data('id'));\n $('.edit-label .new-label-input').val($(this).data('title'));\n $('.edit-label .new-label-desc-input').val($(this).data('description'));\n $('.edit-label .color-picker').val($(this).data('color'));\n $('.minicolors-swatch-color').css('background-color', $(this).data('color'));\n $('.edit-label.modal').modal({\n onApprove() {\n $('.edit-label.form').submit();\n }\n }).modal('show');\n return false;\n });\n }\n\n // Milestones\n if ($('.repository.new.milestone').length > 0) {\n const $datepicker = $('.milestone.datepicker');\n $datepicker.datetimepicker({\n lang: $datepicker.data('lang'),\n inline: true,\n timepicker: false,\n startDate: $datepicker.data('start-date'),\n formatDate: 'Y-m-d',\n onSelectDate(ct) {\n $('#deadline').val(ct.dateFormat('Y-m-d'));\n }\n });\n $('#clear-date').click(() => {\n $('#deadline').val('');\n return false;\n });\n }\n\n // Issues\n if ($('.repository.view.issue').length > 0) {\n // Edit issue title\n const $issueTitle = $('#issue-title');\n const $editInput = $('#edit-title-input input');\n const editTitleToggle = function () {\n $issueTitle.toggle();\n $('.not-in-edit').toggle();\n $('#edit-title-input').toggle();\n $('.in-edit').toggle();\n $editInput.focus();\n return false;\n };\n $('#edit-title').click(editTitleToggle);\n $('#cancel-edit-title').click(editTitleToggle);\n $('#save-edit-title').click(editTitleToggle).click(function () {\n if ($editInput.val().length === 0 || $editInput.val() === $issueTitle.text()) {\n $editInput.val($issueTitle.text());\n return false;\n }\n\n $.post($(this).data('update-url'), {\n _csrf: csrf,\n title: $editInput.val()\n },\n (data) => {\n $editInput.val(data.title);\n $issueTitle.text(data.title);\n reload();\n });\n return false;\n });\n\n // Issue/PR Context Menus\n $('.context-dropdown').dropdown({\n action: 'hide'\n });\n\n // Quote reply\n $('.quote-reply').click(function (event) {\n $(this).closest('.dropdown').find('.menu').toggle('visible');\n const target = $(this).data('target');\n\n let $content;\n if ($(this).hasClass('quote-reply-diff')) {\n const $parent = $(this).closest('.comment-code-cloud');\n $parent.find('button.comment-form-reply').click();\n $content = $parent.find('[name=\"content\"]');\n } else {\n $content = $('#content');\n }\n\n const quote = $(`#comment-${target}`).text().replace(/\\n/g, '\\n> ');\n const content = `> ${quote}\\n\\n`;\n\n if ($content.val() !== '') {\n $content.val(`${$content.val()}\\n\\n${content}`);\n } else {\n $content.val(`${content}`);\n }\n $content.focus();\n event.preventDefault();\n });\n\n // Edit issue or comment content\n $('.edit-content').click(function (event) {\n $(this).closest('.dropdown').find('.menu').toggle('visible');\n const $segment = $(this).closest('.header').next();\n const $editContentZone = $segment.find('.edit-content-zone');\n const $renderContent = $segment.find('.render-content');\n const $rawContent = $segment.find('.raw-content');\n let $textarea;\n\n // Setup new form\n if ($editContentZone.html().length === 0) {\n $editContentZone.html($('#edit-content-form').html());\n $textarea = $editContentZone.find('textarea');\n issuesTribute.attach($textarea.get());\n emojiTribute.attach($textarea.get());\n\n const $dropzone = $editContentZone.find('.dropzone');\n $dropzone.data('saved', false);\n const $files = $editContentZone.find('.comment-files');\n if ($dropzone.length > 0) {\n const filenameDict = {};\n $dropzone.dropzone({\n url: $dropzone.data('upload-url'),\n headers: { 'X-Csrf-Token': csrf },\n maxFiles: $dropzone.data('max-file'),\n maxFilesize: $dropzone.data('max-size'),\n acceptedFiles: ($dropzone.data('accepts') === '*/*') ? null : $dropzone.data('accepts'),\n addRemoveLinks: true,\n dictDefaultMessage: $dropzone.data('default-message'),\n dictInvalidFileType: $dropzone.data('invalid-input-type'),\n dictFileTooBig: $dropzone.data('file-too-big'),\n dictRemoveFile: $dropzone.data('remove-file'),\n init() {\n this.on('success', (file, data) => {\n filenameDict[file.name] = {\n uuid: data.uuid,\n submitted: false\n };\n const input = $(``).val(data.uuid);\n $files.append(input);\n });\n this.on('removedfile', (file) => {\n if (!(file.name in filenameDict)) {\n return;\n }\n $(`#${filenameDict[file.name].uuid}`).remove();\n if ($dropzone.data('remove-url') && $dropzone.data('csrf') && !filenameDict[file.name].submitted) {\n $.post($dropzone.data('remove-url'), {\n file: filenameDict[file.name].uuid,\n _csrf: $dropzone.data('csrf')\n });\n }\n });\n this.on('submit', () => {\n $.each(filenameDict, (name) => {\n filenameDict[name].submitted = true;\n });\n });\n this.on('reload', () => {\n $.getJSON($editContentZone.data('attachment-url'), (data) => {\n const drop = $dropzone.get(0).dropzone;\n drop.removeAllFiles(true);\n $files.empty();\n $.each(data, function () {\n const imgSrc = `${$dropzone.data('upload-url')}/${this.uuid}`;\n drop.emit('addedfile', this);\n drop.emit('thumbnail', this, imgSrc);\n drop.emit('complete', this);\n drop.files.push(this);\n filenameDict[this.name] = {\n submitted: true,\n uuid: this.uuid\n };\n $dropzone.find(`img[src='${imgSrc}']`).css('max-width', '100%');\n const input = $(``).val(this.uuid);\n $files.append(input);\n });\n });\n });\n }\n });\n $dropzone.get(0).dropzone.emit('reload');\n }\n // Give new write/preview data-tab name to distinguish from others\n const $editContentForm = $editContentZone.find('.ui.comment.form');\n const $tabMenu = $editContentForm.find('.tabular.menu');\n $tabMenu.attr('data-write', $editContentZone.data('write'));\n $tabMenu.attr('data-preview', $editContentZone.data('preview'));\n $tabMenu.find('.write.item').attr('data-tab', $editContentZone.data('write'));\n $tabMenu.find('.preview.item').attr('data-tab', $editContentZone.data('preview'));\n $editContentForm.find('.write.segment').attr('data-tab', $editContentZone.data('write'));\n $editContentForm.find('.preview.segment').attr('data-tab', $editContentZone.data('preview'));\n\n initCommentPreviewTab($editContentForm);\n\n $editContentZone.find('.cancel.button').click(() => {\n $renderContent.show();\n $editContentZone.hide();\n $dropzone.get(0).dropzone.emit('reload');\n });\n $editContentZone.find('.save.button').click(() => {\n $renderContent.show();\n $editContentZone.hide();\n const $attachments = $files.find('[name=files]').map(function () {\n return $(this).val();\n }).get();\n $.post($editContentZone.data('update-url'), {\n _csrf: csrf,\n content: $textarea.val(),\n context: $editContentZone.data('context'),\n files: $attachments\n }, (data) => {\n if (data.length === 0) {\n $renderContent.html($('#no-content').html());\n } else {\n $renderContent.html(data.content);\n emojify.run($renderContent[0]);\n $('pre code', $renderContent[0]).each(function () {\n hljs.highlightBlock(this);\n });\n }\n const $content = $segment.parent();\n if (!$content.find('.ui.small.images').length) {\n if (data.attachments !== '') {\n $content.append(\n '
'\n );\n $content.find('.ui.small.images').html(data.attachments);\n }\n } else if (data.attachments === '') {\n $content.find('.ui.small.images').parent().remove();\n } else {\n $content.find('.ui.small.images').html(data.attachments);\n }\n $dropzone.get(0).dropzone.emit('submit');\n $dropzone.get(0).dropzone.emit('reload');\n });\n });\n } else {\n $textarea = $segment.find('textarea');\n }\n\n // Show write/preview tab and copy raw content as needed\n $editContentZone.show();\n $renderContent.hide();\n if ($textarea.val().length === 0) {\n $textarea.val($rawContent.text());\n }\n $textarea.focus();\n event.preventDefault();\n });\n\n // Delete comment\n $('.delete-comment').click(function () {\n const $this = $(this);\n if (window.confirm($this.data('locale'))) {\n $.post($this.data('url'), {\n _csrf: csrf\n }).success(() => {\n $(`#${$this.data('comment-id')}`).remove();\n });\n }\n return false;\n });\n\n // Change status\n const $statusButton = $('#status-button');\n $('#comment-form .edit_area').keyup(function () {\n if ($(this).val().length === 0) {\n $statusButton.text($statusButton.data('status'));\n } else {\n $statusButton.text($statusButton.data('status-and-comment'));\n }\n });\n $statusButton.click(() => {\n $('#status').val($statusButton.data('status-val'));\n $('#comment-form').submit();\n });\n\n // Pull Request merge button\n const $mergeButton = $('.merge-button > button');\n $mergeButton.on('click', function (e) {\n e.preventDefault();\n $(`.${$(this).data('do')}-fields`).show();\n $(this).parent().hide();\n });\n $('.merge-button > .dropdown').dropdown({\n onChange(_text, _value, $choice) {\n if ($choice.data('do')) {\n $mergeButton.find('.button-text').text($choice.text());\n $mergeButton.data('do', $choice.data('do'));\n }\n }\n });\n $('.merge-cancel').on('click', function (e) {\n e.preventDefault();\n $(this).closest('.form').hide();\n $mergeButton.parent().show();\n });\n initReactionSelector();\n }\n\n // Diff\n if ($('.repository.diff').length > 0) {\n $('.diff-counter').each(function () {\n const $item = $(this);\n const addLine = $item.find('span[data-line].add').data('line');\n const delLine = $item.find('span[data-line].del').data('line');\n const addPercent = parseFloat(addLine) / (parseFloat(addLine) + parseFloat(delLine)) * 100;\n $item.find('.bar .add').css('width', `${addPercent}%`);\n });\n }\n\n // Quick start and repository home\n $('#repo-clone-ssh').click(function () {\n $('.clone-url').text($(this).data('link'));\n $('#repo-clone-url').val($(this).data('link'));\n $(this).addClass('blue');\n $('#repo-clone-https').removeClass('blue');\n localStorage.setItem('repo-clone-protocol', 'ssh');\n });\n $('#repo-clone-https').click(function () {\n $('.clone-url').text($(this).data('link'));\n $('#repo-clone-url').val($(this).data('link'));\n $(this).addClass('blue');\n $('#repo-clone-ssh').removeClass('blue');\n localStorage.setItem('repo-clone-protocol', 'https');\n });\n $('#repo-clone-url').click(function () {\n $(this).select();\n });\n\n // Pull request\n const $repoComparePull = $('.repository.compare.pull');\n if ($repoComparePull.length > 0) {\n initFilterSearchDropdown('.choose.branch .dropdown');\n // show pull request form\n $repoComparePull.find('button.show-form').on('click', function (e) {\n e.preventDefault();\n $repoComparePull.find('.pullrequest-form').show();\n $(this).parent().hide();\n });\n }\n\n // Branches\n if ($('.repository.settings.branches').length > 0) {\n initFilterSearchDropdown('.protected-branches .dropdown');\n $('.enable-protection, .enable-whitelist').change(function () {\n if (this.checked) {\n $($(this).data('target')).removeClass('disabled');\n } else {\n $($(this).data('target')).addClass('disabled');\n }\n });\n }\n}\n\nfunction initMigration() {\n const toggleMigrations = function () {\n const authUserName = $('#auth_username').val();\n const cloneAddr = $('#clone_addr').val();\n if (!$('#mirror').is(':checked') && (authUserName && authUserName.length > 0)\n && (cloneAddr !== undefined && (cloneAddr.startsWith('https://github.com') || cloneAddr.startsWith('http://github.com')))) {\n $('#migrate_items').show();\n } else {\n $('#migrate_items').hide();\n }\n };\n\n toggleMigrations();\n\n $('#clone_addr').on('input', toggleMigrations);\n $('#auth_username').on('input', toggleMigrations);\n $('#mirror').on('change', toggleMigrations);\n}\n\nfunction initPullRequestReview() {\n $('.show-outdated').on('click', function (e) {\n e.preventDefault();\n const id = $(this).data('comment');\n $(this).addClass('hide');\n $(`#code-comments-${id}`).removeClass('hide');\n $(`#code-preview-${id}`).removeClass('hide');\n $(`#hide-outdated-${id}`).removeClass('hide');\n });\n\n $('.hide-outdated').on('click', function (e) {\n e.preventDefault();\n const id = $(this).data('comment');\n $(this).addClass('hide');\n $(`#code-comments-${id}`).addClass('hide');\n $(`#code-preview-${id}`).addClass('hide');\n $(`#show-outdated-${id}`).removeClass('hide');\n });\n\n $('button.comment-form-reply').on('click', function (e) {\n e.preventDefault();\n $(this).hide();\n const form = $(this).parent().find('.comment-form');\n form.removeClass('hide');\n assingMenuAttributes(form.find('.menu'));\n });\n // The following part is only for diff views\n if ($('.repository.pull.diff').length === 0) {\n return;\n }\n\n $('.diff-detail-box.ui.sticky').sticky();\n\n $('.btn-review').on('click', function (e) {\n e.preventDefault();\n $(this).closest('.dropdown').find('.menu').toggle('visible');\n }).closest('.dropdown').find('.link.close')\n .on('click', function (e) {\n e.preventDefault();\n $(this).closest('.menu').toggle('visible');\n });\n\n $('.code-view .lines-code,.code-view .lines-num')\n .on('mouseenter', function () {\n const parent = $(this).closest('td');\n $(this).closest('tr').addClass(\n parent.hasClass('lines-num-old') || parent.hasClass('lines-code-old')\n ? 'focus-lines-old' : 'focus-lines-new'\n );\n })\n .on('mouseleave', function () {\n $(this).closest('tr').removeClass('focus-lines-new focus-lines-old');\n });\n $('.add-code-comment').on('click', function (e) {\n // https://github.com/go-gitea/gitea/issues/4745\n if ($(e.target).hasClass('btn-add-single')) {\n return;\n }\n e.preventDefault();\n const isSplit = $(this).closest('.code-diff').hasClass('code-diff-split');\n const side = $(this).data('side');\n const idx = $(this).data('idx');\n const path = $(this).data('path');\n const form = $('#pull_review_add_comment').html();\n const tr = $(this).closest('tr');\n let ntr = tr.next();\n if (!ntr.hasClass('add-comment')) {\n ntr = $(`${\n isSplit ? ''\n : ''\n }`);\n tr.after(ntr);\n }\n const td = ntr.find(`.add-comment-${side}`);\n let commentCloud = td.find('.comment-code-cloud');\n if (commentCloud.length === 0) {\n td.html(form);\n commentCloud = td.find('.comment-code-cloud');\n assingMenuAttributes(commentCloud.find('.menu'));\n\n td.find(\"input[name='line']\").val(idx);\n td.find(\"input[name='side']\").val(side === 'left' ? 'previous' : 'proposed');\n td.find(\"input[name='path']\").val(path);\n }\n commentCloud.find('textarea').focus();\n });\n}\n\nfunction assingMenuAttributes(menu) {\n const id = Math.floor(Math.random() * Math.floor(1000000));\n menu.attr('data-write', menu.attr('data-write') + id);\n menu.attr('data-preview', menu.attr('data-preview') + id);\n menu.find('.item').each(function () {\n const tab = $(this).attr('data-tab') + id;\n $(this).attr('data-tab', tab);\n });\n menu.parent().find(\"*[data-tab='write']\").attr('data-tab', `write${id}`);\n menu.parent().find(\"*[data-tab='preview']\").attr('data-tab', `preview${id}`);\n initCommentPreviewTab(menu.parent('.form'));\n return id;\n}\n\nfunction initRepositoryCollaboration() {\n // Change collaborator access mode\n $('.access-mode.menu .item').click(function () {\n const $menu = $(this).parent();\n $.post($menu.data('url'), {\n _csrf: csrf,\n uid: $menu.data('uid'),\n mode: $(this).data('value')\n });\n });\n}\n\nfunction initTeamSettings() {\n // Change team access mode\n $('.organization.new.team input[name=permission]').change(() => {\n const val = $('input[name=permission]:checked', '.organization.new.team').val();\n if (val === 'admin') {\n $('.organization.new.team .team-units').hide();\n } else {\n $('.organization.new.team .team-units').show();\n }\n });\n}\n\nfunction initWikiForm() {\n const $editArea = $('.repository.wiki textarea#edit_area');\n let sideBySideChanges = 0;\n let sideBySideTimeout = null;\n if ($editArea.length > 0) {\n const simplemde = new SimpleMDE({\n autoDownloadFontAwesome: false,\n element: $editArea[0],\n forceSync: true,\n previewRender(plainText, preview) { // Async method\n setTimeout(() => {\n // FIXME: still send render request when return back to edit mode\n const render = function () {\n sideBySideChanges = 0;\n if (sideBySideTimeout != null) {\n clearTimeout(sideBySideTimeout);\n sideBySideTimeout = null;\n }\n $.post($editArea.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $editArea.data('context'),\n text: plainText\n },\n (data) => {\n preview.innerHTML = `
${data}
`;\n emojify.run($('.editor-preview')[0]);\n $(preview).find('pre code').each((_, e) => {\n hljs.highlightBlock(e);\n });\n });\n };\n if (!simplemde.isSideBySideActive()) {\n render();\n } else {\n // delay preview by keystroke counting\n sideBySideChanges++;\n if (sideBySideChanges > 10) {\n render();\n }\n // or delay preview by timeout\n if (sideBySideTimeout != null) {\n clearTimeout(sideBySideTimeout);\n sideBySideTimeout = null;\n }\n sideBySideTimeout = setTimeout(render, 600);\n }\n }, 0);\n if (!simplemde.isSideBySideActive()) {\n return 'Loading...';\n }\n return preview.innerHTML;\n },\n renderingConfig: {\n singleLineBreaks: false\n },\n indentWithTabs: false,\n tabSize: 4,\n spellChecker: false,\n toolbar: ['bold', 'italic', 'strikethrough', '|',\n 'heading-1', 'heading-2', 'heading-3', 'heading-bigger', 'heading-smaller', '|',\n {\n name: 'code-inline',\n action(e) {\n const cm = e.codemirror;\n const selection = cm.getSelection();\n cm.replaceSelection(`\\`${selection}\\``);\n if (!selection) {\n const cursorPos = cm.getCursor();\n cm.setCursor(cursorPos.line, cursorPos.ch - 1);\n }\n cm.focus();\n },\n className: 'fa fa-angle-right',\n title: 'Add Inline Code',\n }, 'code', 'quote', '|', {\n name: 'checkbox-empty',\n action(e) {\n const cm = e.codemirror;\n cm.replaceSelection(`\\n- [ ] ${cm.getSelection()}`);\n cm.focus();\n },\n className: 'fa fa-square-o',\n title: 'Add Checkbox (empty)',\n },\n {\n name: 'checkbox-checked',\n action(e) {\n const cm = e.codemirror;\n cm.replaceSelection(`\\n- [x] ${cm.getSelection()}`);\n cm.focus();\n },\n className: 'fa fa-check-square-o',\n title: 'Add Checkbox (checked)',\n }, '|',\n 'unordered-list', 'ordered-list', '|',\n 'link', 'image', 'table', 'horizontal-rule', '|',\n 'clean-block', 'preview', 'fullscreen', 'side-by-side']\n });\n $(simplemde.codemirror.getInputField()).addClass('js-quick-submit');\n\n setTimeout(() => {\n const $bEdit = $('.repository.wiki.new .previewtabs a[data-tab=\"write\"]');\n const $bPrev = $('.repository.wiki.new .previewtabs a[data-tab=\"preview\"]');\n const $toolbar = $('.editor-toolbar');\n const $bPreview = $('.editor-toolbar a.fa-eye');\n const $bSideBySide = $('.editor-toolbar a.fa-columns');\n $bEdit.on('click', () => {\n if ($toolbar.hasClass('disabled-for-preview')) {\n $bPreview.click();\n }\n });\n $bPrev.on('click', () => {\n if (!$toolbar.hasClass('disabled-for-preview')) {\n $bPreview.click();\n }\n });\n $bPreview.on('click', () => {\n setTimeout(() => {\n if ($toolbar.hasClass('disabled-for-preview')) {\n if ($bEdit.hasClass('active')) {\n $bEdit.removeClass('active');\n }\n if (!$bPrev.hasClass('active')) {\n $bPrev.addClass('active');\n }\n } else {\n if (!$bEdit.hasClass('active')) {\n $bEdit.addClass('active');\n }\n if ($bPrev.hasClass('active')) {\n $bPrev.removeClass('active');\n }\n }\n }, 0);\n });\n $bSideBySide.on('click', () => {\n sideBySideChanges = 10;\n });\n }, 0);\n }\n}\n\n// Adding function to get the cursor position in a text field to jQuery object.\n$.fn.getCursorPosition = function () {\n const el = $(this).get(0);\n let pos = 0;\n if ('selectionStart' in el) {\n pos = el.selectionStart;\n } else if ('selection' in document) {\n el.focus();\n const Sel = document.selection.createRange();\n const SelLength = document.selection.createRange().text.length;\n Sel.moveStart('character', -el.value.length);\n pos = Sel.text.length - SelLength;\n }\n return pos;\n};\n\nfunction setSimpleMDE($editArea) {\n if (codeMirrorEditor) {\n codeMirrorEditor.toTextArea();\n codeMirrorEditor = null;\n }\n\n if (simpleMDEditor) {\n return true;\n }\n\n simpleMDEditor = new SimpleMDE({\n autoDownloadFontAwesome: false,\n element: $editArea[0],\n forceSync: true,\n renderingConfig: {\n singleLineBreaks: false\n },\n indentWithTabs: false,\n tabSize: 4,\n spellChecker: false,\n previewRender(plainText, preview) { // Async method\n setTimeout(() => {\n // FIXME: still send render request when return back to edit mode\n $.post($editArea.data('url'), {\n _csrf: csrf,\n mode: 'gfm',\n context: $editArea.data('context'),\n text: plainText\n },\n (data) => {\n preview.innerHTML = `
${data}
`;\n emojify.run($('.editor-preview')[0]);\n });\n }, 0);\n\n return 'Loading...';\n },\n toolbar: ['bold', 'italic', 'strikethrough', '|',\n 'heading-1', 'heading-2', 'heading-3', 'heading-bigger', 'heading-smaller', '|',\n 'code', 'quote', '|',\n 'unordered-list', 'ordered-list', '|',\n 'link', 'image', 'table', 'horizontal-rule', '|',\n 'clean-block', 'preview', 'fullscreen', 'side-by-side']\n });\n\n return true;\n}\n\nfunction setCodeMirror($editArea) {\n if (simpleMDEditor) {\n simpleMDEditor.toTextArea();\n simpleMDEditor = null;\n }\n\n if (codeMirrorEditor) {\n return true;\n }\n\n codeMirrorEditor = CodeMirror.fromTextArea($editArea[0], {\n lineNumbers: true\n });\n codeMirrorEditor.on('change', (cm, _change) => {\n $editArea.val(cm.getValue());\n });\n\n return true;\n}\n\nfunction initEditor() {\n $('.js-quick-pull-choice-option').change(function () {\n if ($(this).val() === 'commit-to-new-branch') {\n $('.quick-pull-branch-name').show();\n $('.quick-pull-branch-name input').prop('required', true);\n } else {\n $('.quick-pull-branch-name').hide();\n $('.quick-pull-branch-name input').prop('required', false);\n }\n $('#commit-button').text($(this).attr('button_text'));\n });\n\n const $editFilename = $('#file-name');\n $editFilename.keyup(function (e) {\n const $section = $('.breadcrumb span.section');\n const $divider = $('.breadcrumb div.divider');\n let value;\n let parts;\n\n if (e.keyCode === 8) {\n if ($(this).getCursorPosition() === 0) {\n if ($section.length > 0) {\n value = $section.last().find('a').text();\n $(this).val(value + $(this).val());\n $(this)[0].setSelectionRange(value.length, value.length);\n $section.last().remove();\n $divider.last().remove();\n }\n }\n }\n if (e.keyCode === 191) {\n parts = $(this).val().split('/');\n for (let i = 0; i < parts.length; ++i) {\n value = parts[i];\n if (i < parts.length - 1) {\n if (value.length) {\n $(`${value}`).insertBefore($(this));\n $('
/
').insertBefore($(this));\n }\n } else {\n $(this).val(value);\n }\n $(this)[0].setSelectionRange(0, 0);\n }\n }\n parts = [];\n $('.breadcrumb span.section').each(function () {\n const element = $(this);\n if (element.find('a').length) {\n parts.push(element.find('a').text());\n } else {\n parts.push(element.text());\n }\n });\n if ($(this).val()) parts.push($(this).val());\n $('#tree_path').val(parts.join('/'));\n }).trigger('keyup');\n\n const $editArea = $('.repository.editor textarea#edit_area');\n if (!$editArea.length) return;\n\n const markdownFileExts = $editArea.data('markdown-file-exts').split(',');\n const lineWrapExtensions = $editArea.data('line-wrap-extensions').split(',');\n\n $editFilename.on('keyup', () => {\n const val = $editFilename.val();\n let mode, spec, extension, extWithDot, dataUrl, apiCall;\n\n extension = extWithDot = '';\n const m = /.+\\.([^.]+)$/.exec(val);\n if (m) {\n extension = m[1];\n extWithDot = `.${extension}`;\n }\n\n const info = CodeMirror.findModeByExtension(extension);\n const previewLink = $('a[data-tab=preview]');\n if (info) {\n mode = info.mode;\n spec = info.mime;\n apiCall = mode;\n } else {\n apiCall = extension;\n }\n\n if (previewLink.length && apiCall && previewFileModes && previewFileModes.length && previewFileModes.indexOf(apiCall) >= 0) {\n dataUrl = previewLink.data('url');\n previewLink.data('url', dataUrl.replace(/(.*)\\/.*/i, `$1/${mode}`));\n previewLink.show();\n } else {\n previewLink.hide();\n }\n\n // If this file is a Markdown extensions, we will load that editor and return\n if (markdownFileExts.indexOf(extWithDot) >= 0) {\n if (setSimpleMDE($editArea)) {\n return;\n }\n }\n\n // Else we are going to use CodeMirror\n if (!codeMirrorEditor && !setCodeMirror($editArea)) {\n return;\n }\n\n if (mode) {\n codeMirrorEditor.setOption('mode', spec);\n CodeMirror.autoLoadMode(codeMirrorEditor, mode);\n }\n\n if (lineWrapExtensions.indexOf(extWithDot) >= 0) {\n codeMirrorEditor.setOption('lineWrapping', true);\n } else {\n codeMirrorEditor.setOption('lineWrapping', false);\n }\n\n // get the filename without any folder\n let value = $editFilename.val();\n if (value.length === 0) {\n return;\n }\n value = value.split('/');\n value = value[value.length - 1];\n\n $.getJSON($editFilename.data('ec-url-prefix') + value, (editorconfig) => {\n if (editorconfig.indent_style === 'tab') {\n codeMirrorEditor.setOption('indentWithTabs', true);\n codeMirrorEditor.setOption('extraKeys', {});\n } else {\n codeMirrorEditor.setOption('indentWithTabs', false);\n // required because CodeMirror doesn't seems to use spaces correctly for {\"indentWithTabs\": false}:\n // - https://github.com/codemirror/CodeMirror/issues/988\n // - https://codemirror.net/doc/manual.html#keymaps\n codeMirrorEditor.setOption('extraKeys', {\n Tab(cm) {\n const spaces = Array(parseInt(cm.getOption('indentUnit')) + 1).join(' ');\n cm.replaceSelection(spaces);\n }\n });\n }\n codeMirrorEditor.setOption('indentUnit', editorconfig.indent_size || 4);\n codeMirrorEditor.setOption('tabSize', editorconfig.tab_width || 4);\n });\n }).trigger('keyup');\n\n // Using events from https://github.com/codedance/jquery.AreYouSure#advanced-usage\n // to enable or disable the commit button\n const $commitButton = $('#commit-button');\n const $editForm = $('.ui.edit.form');\n const dirtyFileClass = 'dirty-file';\n\n // Disabling the button at the start\n $commitButton.prop('disabled', true);\n\n // Registering a custom listener for the file path and the file content\n $editForm.areYouSure({\n silent: true,\n dirtyClass: dirtyFileClass,\n fieldSelector: ':input:not(.commit-form-wrapper :input)',\n change() {\n const dirty = $(this).hasClass(dirtyFileClass);\n $commitButton.prop('disabled', !dirty);\n }\n });\n\n $commitButton.click((event) => {\n // A modal which asks if an empty file should be committed\n if ($editArea.val().length === 0) {\n $('#edit-empty-content-modal').modal({\n onApprove() {\n $('.edit.form').submit();\n }\n }).modal('show');\n event.preventDefault();\n }\n });\n}\n\nfunction initOrganization() {\n if ($('.organization').length === 0) {\n return;\n }\n\n // Options\n if ($('.organization.settings.options').length > 0) {\n $('#org_name').keyup(function () {\n const $prompt = $('#org-name-change-prompt');\n if ($(this).val().toString().toLowerCase() !== $(this).data('org-name').toString().toLowerCase()) {\n $prompt.show();\n } else {\n $prompt.hide();\n }\n });\n }\n}\n\nfunction initUserSettings() {\n // Options\n if ($('.user.settings.profile').length > 0) {\n $('#username').keyup(function () {\n const $prompt = $('#name-change-prompt');\n if ($(this).val().toString().toLowerCase() !== $(this).data('name').toString().toLowerCase()) {\n $prompt.show();\n } else {\n $prompt.hide();\n }\n });\n }\n}\n\nfunction initGithook() {\n if ($('.edit.githook').length === 0) {\n return;\n }\n\n CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], {\n lineNumbers: true,\n mode: 'shell'\n }), 'shell');\n}\n\nfunction initWebhook() {\n if ($('.new.webhook').length === 0) {\n return;\n }\n\n $('.events.checkbox input').change(function () {\n if ($(this).is(':checked')) {\n $('.events.fields').show();\n }\n });\n $('.non-events.checkbox input').change(function () {\n if ($(this).is(':checked')) {\n $('.events.fields').hide();\n }\n });\n\n const updateContentType = function () {\n const visible = $('#http_method').val() === 'POST';\n $('#content_type').parent().parent()[visible ? 'show' : 'hide']();\n };\n updateContentType();\n $('#http_method').change(() => {\n updateContentType();\n });\n\n // Test delivery\n $('#test-delivery').click(function () {\n const $this = $(this);\n $this.addClass('loading disabled');\n $.post($this.data('link'), {\n _csrf: csrf\n }).done(\n setTimeout(() => {\n window.location.href = $this.data('redirect');\n }, 5000)\n );\n });\n}\n\nfunction initAdmin() {\n if ($('.admin').length === 0) {\n return;\n }\n\n // New user\n if ($('.admin.new.user').length > 0 || $('.admin.edit.user').length > 0) {\n $('#login_type').change(function () {\n if ($(this).val().substring(0, 1) === '0') {\n $('#login_name').removeAttr('required');\n $('.non-local').hide();\n $('.local').show();\n $('#user_name').focus();\n\n if ($(this).data('password') === 'required') {\n $('#password').attr('required', 'required');\n }\n } else {\n $('#login_name').attr('required', 'required');\n $('.non-local').show();\n $('.local').hide();\n $('#login_name').focus();\n\n $('#password').removeAttr('required');\n }\n });\n }\n\n function onSecurityProtocolChange() {\n if ($('#security_protocol').val() > 0) {\n $('.has-tls').show();\n } else {\n $('.has-tls').hide();\n }\n }\n\n function onUsePagedSearchChange() {\n if ($('#use_paged_search').prop('checked')) {\n $('.search-page-size').show()\n .find('input').attr('required', 'required');\n } else {\n $('.search-page-size').hide()\n .find('input').removeAttr('required');\n }\n }\n\n function onOAuth2Change() {\n $('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url').hide();\n $('.open_id_connect_auto_discovery_url input[required]').removeAttr('required');\n\n const provider = $('#oauth2_provider').val();\n switch (provider) {\n case 'github':\n case 'gitlab':\n case 'gitea':\n $('.oauth2_use_custom_url').show();\n break;\n case 'openidConnect':\n $('.open_id_connect_auto_discovery_url input').attr('required', 'required');\n $('.open_id_connect_auto_discovery_url').show();\n break;\n }\n onOAuth2UseCustomURLChange();\n }\n\n function onOAuth2UseCustomURLChange() {\n const provider = $('#oauth2_provider').val();\n $('.oauth2_use_custom_url_field').hide();\n $('.oauth2_use_custom_url_field input[required]').removeAttr('required');\n\n if ($('#oauth2_use_custom_url').is(':checked')) {\n if (!$('#oauth2_token_url').val()) {\n $('#oauth2_token_url').val($(`#${provider}_token_url`).val());\n }\n if (!$('#oauth2_auth_url').val()) {\n $('#oauth2_auth_url').val($(`#${provider}_auth_url`).val());\n }\n if (!$('#oauth2_profile_url').val()) {\n $('#oauth2_profile_url').val($(`#${provider}_profile_url`).val());\n }\n if (!$('#oauth2_email_url').val()) {\n $('#oauth2_email_url').val($(`#${provider}_email_url`).val());\n }\n switch (provider) {\n case 'github':\n $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input, .oauth2_email_url input').attr('required', 'required');\n $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url, .oauth2_email_url').show();\n break;\n case 'gitea':\n case 'gitlab':\n $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input').attr('required', 'required');\n $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url').show();\n $('#oauth2_email_url').val('');\n break;\n }\n }\n }\n\n // New authentication\n if ($('.admin.new.authentication').length > 0) {\n $('#auth_type').change(function () {\n $('.ldap, .dldap, .smtp, .pam, .oauth2, .has-tls .search-page-size').hide();\n\n $('.ldap input[required], .binddnrequired input[required], .dldap input[required], .smtp input[required], .pam input[required], .oauth2 input[required], .has-tls input[required]').removeAttr('required');\n $('.binddnrequired').removeClass('required');\n\n const authType = $(this).val();\n switch (authType) {\n case '2': // LDAP\n $('.ldap').show();\n $('.binddnrequired input, .ldap div.required:not(.dldap) input').attr('required', 'required');\n $('.binddnrequired').addClass('required');\n break;\n case '3': // SMTP\n $('.smtp').show();\n $('.has-tls').show();\n $('.smtp div.required input, .has-tls').attr('required', 'required');\n break;\n case '4': // PAM\n $('.pam').show();\n $('.pam input').attr('required', 'required');\n break;\n case '5': // LDAP\n $('.dldap').show();\n $('.dldap div.required:not(.ldap) input').attr('required', 'required');\n break;\n case '6': // OAuth2\n $('.oauth2').show();\n $('.oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input').attr('required', 'required');\n onOAuth2Change();\n break;\n }\n if (authType === '2' || authType === '5') {\n onSecurityProtocolChange();\n }\n if (authType === '2') {\n onUsePagedSearchChange();\n }\n });\n $('#auth_type').change();\n $('#security_protocol').change(onSecurityProtocolChange);\n $('#use_paged_search').change(onUsePagedSearchChange);\n $('#oauth2_provider').change(onOAuth2Change);\n $('#oauth2_use_custom_url').change(onOAuth2UseCustomURLChange);\n }\n // Edit authentication\n if ($('.admin.edit.authentication').length > 0) {\n const authType = $('#auth_type').val();\n if (authType === '2' || authType === '5') {\n $('#security_protocol').change(onSecurityProtocolChange);\n if (authType === '2') {\n $('#use_paged_search').change(onUsePagedSearchChange);\n }\n } else if (authType === '6') {\n $('#oauth2_provider').change(onOAuth2Change);\n $('#oauth2_use_custom_url').change(onOAuth2UseCustomURLChange);\n onOAuth2Change();\n }\n }\n\n // Notice\n if ($('.admin.notice')) {\n const $detailModal = $('#detail-modal');\n\n // Attach view detail modals\n $('.view-detail').click(function () {\n $detailModal.find('.content p').text($(this).data('content'));\n $detailModal.modal('show');\n return false;\n });\n\n // Select actions\n const $checkboxes = $('.select.table .ui.checkbox');\n $('.select.action').click(function () {\n switch ($(this).data('action')) {\n case 'select-all':\n $checkboxes.checkbox('check');\n break;\n case 'deselect-all':\n $checkboxes.checkbox('uncheck');\n break;\n case 'inverse':\n $checkboxes.checkbox('toggle');\n break;\n }\n });\n $('#delete-selection').click(function () {\n const $this = $(this);\n $this.addClass('loading disabled');\n const ids = [];\n $checkboxes.each(function () {\n if ($(this).checkbox('is checked')) {\n ids.push($(this).data('id'));\n }\n });\n $.post($this.data('link'), {\n _csrf: csrf,\n ids\n }).done(() => {\n window.location.href = $this.data('redirect');\n });\n });\n }\n}\n\nfunction buttonsClickOnEnter() {\n $('.ui.button').keypress(function (e) {\n if (e.keyCode === 13 || e.keyCode === 32) { // enter key or space bar\n $(this).click();\n }\n });\n}\n\nfunction searchUsers() {\n const $searchUserBox = $('#search-user-box');\n $searchUserBox.search({\n minCharacters: 2,\n apiSettings: {\n url: `${suburl}/api/v1/users/search?q={query}`,\n onResponse(response) {\n const items = [];\n $.each(response.data, (_i, item) => {\n let title = item.login;\n if (item.full_name && item.full_name.length > 0) {\n title += ` (${htmlEncode(item.full_name)})`;\n }\n items.push({\n title,\n image: item.avatar_url\n });\n });\n\n return { results: items };\n }\n },\n searchFields: ['login', 'full_name'],\n showNoResults: false\n });\n}\n\nfunction searchTeams() {\n const $searchTeamBox = $('#search-team-box');\n $searchTeamBox.search({\n minCharacters: 2,\n apiSettings: {\n url: `${suburl}/api/v1/orgs/${$searchTeamBox.data('org')}/teams/search?q={query}`,\n headers: { 'X-Csrf-Token': csrf },\n onResponse(response) {\n const items = [];\n $.each(response.data, (_i, item) => {\n const title = `${item.name} (${item.permission} access)`;\n items.push({\n title,\n });\n });\n\n return { results: items };\n }\n },\n searchFields: ['name', 'description'],\n showNoResults: false\n });\n}\n\nfunction searchRepositories() {\n const $searchRepoBox = $('#search-repo-box');\n $searchRepoBox.search({\n minCharacters: 2,\n apiSettings: {\n url: `${suburl}/api/v1/repos/search?q={query}&uid=${$searchRepoBox.data('uid')}`,\n onResponse(response) {\n const items = [];\n $.each(response.data, (_i, item) => {\n items.push({\n title: item.full_name.split('/')[1],\n description: item.full_name\n });\n });\n\n return { results: items };\n }\n },\n searchFields: ['full_name'],\n showNoResults: false\n });\n}\n\nfunction initCodeView() {\n if ($('.code-view .linenums').length > 0) {\n $(document).on('click', '.lines-num span', function (e) {\n const $select = $(this);\n const $list = $select.parent().siblings('.lines-code').find('ol.linenums > li');\n selectRange($list, $list.filter(`[rel=${$select.attr('id')}]`), (e.shiftKey ? $list.filter('.active').eq(0) : null));\n deSelect();\n });\n\n $(window).on('hashchange', () => {\n let m = window.location.hash.match(/^#(L\\d+)-(L\\d+)$/);\n const $list = $('.code-view ol.linenums > li');\n let $first;\n if (m) {\n $first = $list.filter(`.${m[1]}`);\n selectRange($list, $first, $list.filter(`.${m[2]}`));\n $('html, body').scrollTop($first.offset().top - 200);\n return;\n }\n m = window.location.hash.match(/^#(L|n)(\\d+)$/);\n if (m) {\n $first = $list.filter(`.L${m[2]}`);\n selectRange($list, $first);\n $('html, body').scrollTop($first.offset().top - 200);\n }\n }).trigger('hashchange');\n }\n $('.ui.fold-code').on('click', (e) => {\n const $foldButton = $(e.target);\n if ($foldButton.hasClass('fa-chevron-down')) {\n $(e.target).parent().next().slideUp('fast', () => {\n $foldButton.removeClass('fa-chevron-down').addClass('fa-chevron-right');\n });\n } else {\n $(e.target).parent().next().slideDown('fast', () => {\n $foldButton.removeClass('fa-chevron-right').addClass('fa-chevron-down');\n });\n }\n });\n function insertBlobExcerpt(e) {\n const $blob = $(e.target);\n const $row = $blob.parent().parent();\n $.get(`${$blob.data('url')}?${$blob.data('query')}&anchor=${$blob.data('anchor')}`, (blob) => {\n $row.replaceWith(blob);\n $(`[data-anchor=\"${$blob.data('anchor')}\"]`).on('click', (e) => { insertBlobExcerpt(e); });\n });\n }\n $('.ui.blob-excerpt').on('click', (e) => { insertBlobExcerpt(e); });\n}\n\nfunction initU2FAuth() {\n if ($('#wait-for-key').length === 0) {\n return;\n }\n u2fApi.ensureSupport()\n .then(() => {\n $.getJSON(`${suburl}/user/u2f/challenge`).success((req) => {\n u2fApi.sign(req.appId, req.challenge, req.registeredKeys, 30)\n .then(u2fSigned)\n .catch((err) => {\n if (err === undefined) {\n u2fError(1);\n return;\n }\n u2fError(err.metaData.code);\n });\n });\n }).catch(() => {\n // Fallback in case browser do not support U2F\n window.location.href = `${suburl}/user/two_factor`;\n });\n}\nfunction u2fSigned(resp) {\n $.ajax({\n url: `${suburl}/user/u2f/sign`,\n type: 'POST',\n headers: { 'X-Csrf-Token': csrf },\n data: JSON.stringify(resp),\n contentType: 'application/json; charset=utf-8',\n }).done((res) => {\n window.location.replace(res);\n }).fail(() => {\n u2fError(1);\n });\n}\n\nfunction u2fRegistered(resp) {\n if (checkError(resp)) {\n return;\n }\n $.ajax({\n url: `${suburl}/user/settings/security/u2f/register`,\n type: 'POST',\n headers: { 'X-Csrf-Token': csrf },\n data: JSON.stringify(resp),\n contentType: 'application/json; charset=utf-8',\n success() {\n reload();\n },\n fail() {\n u2fError(1);\n }\n });\n}\n\nfunction checkError(resp) {\n if (!('errorCode' in resp)) {\n return false;\n }\n if (resp.errorCode === 0) {\n return false;\n }\n u2fError(resp.errorCode);\n return true;\n}\n\n\nfunction u2fError(errorType) {\n const u2fErrors = {\n browser: $('#unsupported-browser'),\n 1: $('#u2f-error-1'),\n 2: $('#u2f-error-2'),\n 3: $('#u2f-error-3'),\n 4: $('#u2f-error-4'),\n 5: $('.u2f-error-5')\n };\n u2fErrors[errorType].removeClass('hide');\n\n Object.keys(u2fErrors).forEach((type) => {\n if (type !== errorType) {\n u2fErrors[type].addClass('hide');\n }\n });\n $('#u2f-error').modal('show');\n}\n\nfunction initU2FRegister() {\n $('#register-device').modal({ allowMultiple: false });\n $('#u2f-error').modal({ allowMultiple: false });\n $('#register-security-key').on('click', (e) => {\n e.preventDefault();\n u2fApi.ensureSupport()\n .then(u2fRegisterRequest)\n .catch(() => {\n u2fError('browser');\n });\n });\n}\n\nfunction u2fRegisterRequest() {\n $.post(`${suburl}/user/settings/security/u2f/request_register`, {\n _csrf: csrf,\n name: $('#nickname').val()\n }).success((req) => {\n $('#nickname').closest('div.field').removeClass('error');\n $('#register-device').modal('show');\n if (req.registeredKeys === null) {\n req.registeredKeys = [];\n }\n u2fApi.register(req.appId, req.registerRequests, req.registeredKeys, 30)\n .then(u2fRegistered)\n .catch((reason) => {\n if (reason === undefined) {\n u2fError(1);\n return;\n }\n u2fError(reason.metaData.code);\n });\n }).fail((xhr) => {\n if (xhr.status === 409) {\n $('#nickname').closest('div.field').addClass('error');\n }\n });\n}\n\nfunction initWipTitle() {\n $('.title_wip_desc > a').click((e) => {\n e.preventDefault();\n\n const $issueTitle = $('#issue_title');\n $issueTitle.focus();\n const value = $issueTitle.val().trim().toUpperCase();\n\n for (const i in wipPrefixes) {\n if (value.startsWith(wipPrefixes[i].toUpperCase())) {\n return;\n }\n }\n\n $issueTitle.val(`${wipPrefixes[0]} ${$issueTitle.val()}`);\n });\n}\n\nfunction initTemplateSearch() {\n const $repoTemplate = $('#repo_template');\n const checkTemplate = function () {\n const $templateUnits = $('#template_units');\n const $nonTemplate = $('#non_template');\n if ($repoTemplate.val() !== '') {\n $templateUnits.show();\n $nonTemplate.hide();\n } else {\n $templateUnits.hide();\n $nonTemplate.show();\n }\n };\n $repoTemplate.change(checkTemplate);\n checkTemplate();\n\n const changeOwner = function () {\n $('#repo_template_search')\n .dropdown({\n apiSettings: {\n url: `${suburl}/api/v1/repos/search?q={query}&template=true&priority_owner_id=${$('#uid').val()}`,\n onResponse(response) {\n const filteredResponse = { success: true, results: [] };\n filteredResponse.results.push({\n name: '',\n value: ''\n });\n // Parse the response from the api to work with our dropdown\n $.each(response.data, (_r, repo) => {\n filteredResponse.results.push({\n name: htmlEncode(repo.full_name),\n value: repo.id\n });\n });\n return filteredResponse;\n },\n cache: false,\n },\n\n fullTextSearch: true\n });\n };\n $('#uid').change(changeOwner);\n changeOwner();\n}\n\n$(document).ready(() => {\n csrf = $('meta[name=_csrf]').attr('content');\n suburl = $('meta[name=_suburl]').attr('content');\n\n // Show exact time\n $('.time-since').each(function () {\n $(this)\n .addClass('poping up')\n .attr('data-content', $(this).attr('title'))\n .attr('data-variation', 'inverted tiny')\n .attr('title', '');\n });\n\n // Semantic UI modules.\n $('.dropdown:not(.custom)').dropdown();\n $('.jump.dropdown').dropdown({\n action: 'hide',\n onShow() {\n $('.poping.up').popup('hide');\n }\n });\n $('.slide.up.dropdown').dropdown({\n transition: 'slide up'\n });\n $('.upward.dropdown').dropdown({\n direction: 'upward'\n });\n $('.ui.accordion').accordion();\n $('.ui.checkbox').checkbox();\n $('.ui.progress').progress({\n showActivity: false\n });\n $('.poping.up').popup();\n $('.top.menu .poping.up').popup({\n onShow() {\n if ($('.top.menu .menu.transition').hasClass('visible')) {\n return false;\n }\n }\n });\n $('.tabular.menu .item').tab();\n $('.tabable.menu .item').tab();\n\n $('.toggle.button').click(function () {\n $($(this).data('target')).slideToggle(100);\n });\n\n // make table element clickable like a link\n $('tr[data-href]').click(function () {\n window.location = $(this).data('href');\n });\n\n // Highlight JS\n if (typeof hljs !== 'undefined') {\n const nodes = [].slice.call(document.querySelectorAll('pre code') || []);\n for (let i = 0; i < nodes.length; i++) {\n hljs.highlightBlock(nodes[i]);\n }\n }\n\n // Dropzone\n const $dropzone = $('#dropzone');\n if ($dropzone.length > 0) {\n const filenameDict = {};\n\n new Dropzone('#dropzone', {\n url: $dropzone.data('upload-url'),\n headers: { 'X-Csrf-Token': csrf },\n maxFiles: $dropzone.data('max-file'),\n maxFilesize: $dropzone.data('max-size'),\n acceptedFiles: ($dropzone.data('accepts') === '*/*') ? null : $dropzone.data('accepts'),\n addRemoveLinks: true,\n dictDefaultMessage: $dropzone.data('default-message'),\n dictInvalidFileType: $dropzone.data('invalid-input-type'),\n dictFileTooBig: $dropzone.data('file-too-big'),\n dictRemoveFile: $dropzone.data('remove-file'),\n init() {\n this.on('success', (file, data) => {\n filenameDict[file.name] = data.uuid;\n const input = $(``).val(data.uuid);\n $('.files').append(input);\n });\n this.on('removedfile', (file) => {\n if (file.name in filenameDict) {\n $(`#${filenameDict[file.name]}`).remove();\n }\n if ($dropzone.data('remove-url') && $dropzone.data('csrf')) {\n $.post($dropzone.data('remove-url'), {\n file: filenameDict[file.name],\n _csrf: $dropzone.data('csrf')\n });\n }\n });\n },\n });\n }\n\n // Emojify\n emojify.setConfig({\n img_dir: `${suburl}/vendor/plugins/emojify/images`,\n ignore_emoticons: true\n });\n const hasEmoji = document.getElementsByClassName('has-emoji');\n for (let i = 0; i < hasEmoji.length; i++) {\n emojify.run(hasEmoji[i]);\n for (let j = 0; j < hasEmoji[i].childNodes.length; j++) {\n if (hasEmoji[i].childNodes[j].nodeName === 'A') {\n emojify.run(hasEmoji[i].childNodes[j]);\n }\n }\n }\n\n // Clipboard JS\n const clipboard = new Clipboard('.clipboard');\n clipboard.on('success', (e) => {\n e.clearSelection();\n\n $(`#${e.trigger.getAttribute('id')}`).popup('destroy');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success'));\n $(`#${e.trigger.getAttribute('id')}`).popup('show');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original'));\n });\n\n clipboard.on('error', (e) => {\n $(`#${e.trigger.getAttribute('id')}`).popup('destroy');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-error'));\n $(`#${e.trigger.getAttribute('id')}`).popup('show');\n e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original'));\n });\n\n // Helpers.\n $('.delete-button').click(showDeletePopup);\n $('.add-all-button').click(showAddAllPopup);\n\n $('.delete-branch-button').click(showDeletePopup);\n\n $('.undo-button').click(function () {\n const $this = $(this);\n $.post($this.data('url'), {\n _csrf: csrf,\n id: $this.data('id')\n }).done((data) => {\n window.location.href = data.redirect;\n });\n });\n $('.show-panel.button').click(function () {\n $($(this).data('panel')).show();\n });\n $('.show-modal.button').click(function () {\n $($(this).data('modal')).modal('show');\n });\n $('.delete-post.button').click(function () {\n const $this = $(this);\n $.post($this.data('request-url'), {\n _csrf: csrf\n }).done(() => {\n window.location.href = $this.data('done-url');\n });\n });\n\n // Set anchor.\n $('.markdown').each(function () {\n const headers = {};\n $(this).find('h1, h2, h3, h4, h5, h6').each(function () {\n let node = $(this);\n const val = encodeURIComponent(node.text().toLowerCase().replace(/[^\\u00C0-\\u1FFF\\u2C00-\\uD7FF\\w\\- ]/g, '').replace(/[ ]/g, '-'));\n let name = val;\n if (headers[val] > 0) {\n name = `${val}-${headers[val]}`;\n }\n if (headers[val] === undefined) {\n headers[val] = 1;\n } else {\n headers[val] += 1;\n }\n node = node.wrap(`
`);\n node.append(``);\n });\n });\n\n $('.issue-checkbox').click(() => {\n const numChecked = $('.issue-checkbox').children('input:checked').length;\n if (numChecked > 0) {\n $('#issue-filters').addClass('hide');\n $('#issue-actions').removeClass('hide');\n } else {\n $('#issue-filters').removeClass('hide');\n $('#issue-actions').addClass('hide');\n }\n });\n\n $('.issue-action').click(function () {\n let { action } = this.dataset;\n let { elementId } = this.dataset;\n const issueIDs = $('.issue-checkbox').children('input:checked').map(function () {\n return this.dataset.issueId;\n }).get().join();\n const { url } = this.dataset;\n if (elementId === '0' && url.substr(-9) === '/assignee') {\n elementId = '';\n action = 'clear';\n }\n updateIssuesMeta(url, action, issueIDs, elementId).then(() => {\n // NOTICE: This reset of checkbox state targets Firefox caching behaviour, as the checkboxes stay checked after reload\n if (action === 'close' || action === 'open') {\n // uncheck all checkboxes\n $('.issue-checkbox input[type=\"checkbox\"]').each((_, e) => { e.checked = false; });\n }\n reload();\n });\n });\n\n // NOTICE: This event trigger targets Firefox caching behaviour, as the checkboxes stay checked after reload\n // trigger ckecked event, if checkboxes are checked on load\n $('.issue-checkbox input[type=\"checkbox\"]:checked').first().each((_, e) => {\n e.checked = false;\n $(e).click();\n });\n\n buttonsClickOnEnter();\n searchUsers();\n searchTeams();\n searchRepositories();\n\n initCommentForm();\n initInstall();\n initRepository();\n initMigration();\n initWikiForm();\n initEditForm();\n initEditor();\n initOrganization();\n initGithook();\n initWebhook();\n initAdmin();\n initCodeView();\n initVueApp();\n initTeamSettings();\n initCtrlEnterSubmit();\n initNavbarContentToggle();\n initTopicbar();\n initU2FAuth();\n initU2FRegister();\n initIssueList();\n initWipTitle();\n initPullRequestReview();\n initRepoStatusChecker();\n initTemplateSearch();\n\n // Repo clone url.\n if ($('#repo-clone-url').length > 0) {\n switch (localStorage.getItem('repo-clone-protocol')) {\n case 'ssh':\n if ($('#repo-clone-ssh').click().length === 0) {\n $('#repo-clone-https').click();\n }\n break;\n default:\n $('#repo-clone-https').click();\n break;\n }\n }\n\n const routes = {\n 'div.user.settings': initUserSettings,\n 'div.repository.settings.collaboration': initRepositoryCollaboration\n };\n\n let selector;\n for (selector in routes) {\n if ($(selector).length > 0) {\n routes[selector]();\n break;\n }\n }\n\n const $cloneAddr = $('#clone_addr');\n $cloneAddr.change(() => {\n const $repoName = $('#repo_name');\n if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { // Only modify if repo_name input is blank\n $repoName.val($cloneAddr.val().match(/^(.*\\/)?((.+?)(\\.git)?)$/)[3]);\n }\n });\n});\n\nfunction changeHash(hash) {\n if (window.history.pushState) {\n window.history.pushState(null, null, hash);\n } else {\n window.location.hash = hash;\n }\n}\n\nfunction deSelect() {\n if (window.getSelection) {\n window.getSelection().removeAllRanges();\n } else {\n document.selection.empty();\n }\n}\n\nfunction selectRange($list, $select, $from) {\n $list.removeClass('active');\n if ($from) {\n let a = parseInt($select.attr('rel').substr(1));\n let b = parseInt($from.attr('rel').substr(1));\n let c;\n if (a !== b) {\n if (a > b) {\n c = a;\n a = b;\n b = c;\n }\n const classes = [];\n for (let i = a; i <= b; i++) {\n classes.push(`.L${i}`);\n }\n $list.filter(classes.join(',')).addClass('active');\n changeHash(`#L${a}-L${b}`);\n return;\n }\n }\n $select.addClass('active');\n changeHash(`#${$select.attr('rel')}`);\n}\n\n$(() => {\n // Warn users that try to leave a page after entering data into a form.\n // Except on sign-in pages, and for forms marked as 'ignore-dirty'.\n if ($('.user.signin').length === 0) {\n $('form:not(.ignore-dirty)').areYouSure();\n }\n\n // Parse SSH Key\n $('#ssh-key-content').on('change paste keyup', function () {\n const arrays = $(this).val().split(' ');\n const $title = $('#ssh-key-title');\n if ($title.val() === '' && arrays.length === 3 && arrays[2] !== '') {\n $title.val(arrays[2]);\n }\n });\n});\n\nfunction showDeletePopup() {\n const $this = $(this);\n let filter = '';\n if ($this.attr('id')) {\n filter += `#${$this.attr('id')}`;\n }\n\n const dialog = $(`.delete.modal${filter}`);\n dialog.find('.name').text($this.data('name'));\n\n dialog.modal({\n closable: false,\n onApprove() {\n if ($this.data('type') === 'form') {\n $($this.data('form')).submit();\n return;\n }\n\n $.post($this.data('url'), {\n _csrf: csrf,\n id: $this.data('id')\n }).done((data) => {\n window.location.href = data.redirect;\n });\n }\n }).modal('show');\n return false;\n}\n\nfunction showAddAllPopup() {\n const $this = $(this);\n let filter = '';\n if ($this.attr('id')) {\n filter += `#${$this.attr('id')}`;\n }\n\n const dialog = $(`.addall.modal${filter}`);\n dialog.find('.name').text($this.data('name'));\n\n dialog.modal({\n closable: false,\n onApprove() {\n if ($this.data('type') === 'form') {\n $($this.data('form')).submit();\n return;\n }\n\n $.post($this.data('url'), {\n _csrf: csrf,\n id: $this.data('id')\n }).done((data) => {\n window.location.href = data.redirect;\n });\n }\n }).modal('show');\n return false;\n}\n\nfunction initVueComponents() {\n const vueDelimeters = ['${', '}'];\n\n Vue.component('repo-search', {\n delimiters: vueDelimeters,\n\n props: {\n searchLimit: {\n type: Number,\n default: 10\n },\n suburl: {\n type: String,\n required: true\n },\n uid: {\n type: Number,\n required: true\n },\n organizations: {\n type: Array,\n default: []\n },\n isOrganization: {\n type: Boolean,\n default: true\n },\n canCreateOrganization: {\n type: Boolean,\n default: false\n },\n organizationsTotalCount: {\n type: Number,\n default: 0\n },\n moreReposLink: {\n type: String,\n default: ''\n }\n },\n\n data() {\n return {\n tab: 'repos',\n repos: [],\n reposTotalCount: 0,\n reposFilter: 'all',\n searchQuery: '',\n isLoading: false,\n repoTypes: {\n all: {\n count: 0,\n searchMode: '',\n },\n forks: {\n count: 0,\n searchMode: 'fork',\n },\n mirrors: {\n count: 0,\n searchMode: 'mirror',\n },\n sources: {\n count: 0,\n searchMode: 'source',\n },\n collaborative: {\n count: 0,\n searchMode: 'collaborative',\n },\n }\n };\n },\n\n computed: {\n showMoreReposLink() {\n return this.repos.length > 0 && this.repos.length < this.repoTypes[this.reposFilter].count;\n },\n searchURL() {\n return `${this.suburl}/api/v1/repos/search?sort=updated&order=desc&uid=${this.uid}&q=${this.searchQuery\n }&limit=${this.searchLimit}&mode=${this.repoTypes[this.reposFilter].searchMode\n }${this.reposFilter !== 'all' ? '&exclusive=1' : ''}`;\n },\n repoTypeCount() {\n return this.repoTypes[this.reposFilter].count;\n }\n },\n\n mounted() {\n this.searchRepos(this.reposFilter);\n\n const self = this;\n Vue.nextTick(() => {\n self.$refs.search.focus();\n });\n },\n\n methods: {\n changeTab(t) {\n this.tab = t;\n },\n\n changeReposFilter(filter) {\n this.reposFilter = filter;\n this.repos = [];\n this.repoTypes[filter].count = 0;\n this.searchRepos(filter);\n },\n\n showRepo(repo, filter) {\n switch (filter) {\n case 'sources':\n return repo.owner.id === this.uid && !repo.mirror && !repo.fork;\n case 'forks':\n return repo.owner.id === this.uid && !repo.mirror && repo.fork;\n case 'mirrors':\n return repo.mirror;\n case 'collaborative':\n return repo.owner.id !== this.uid && !repo.mirror;\n default:\n return true;\n }\n },\n\n searchRepos(reposFilter) {\n const self = this;\n\n this.isLoading = true;\n\n const searchedMode = this.repoTypes[reposFilter].searchMode;\n const searchedURL = this.searchURL;\n const searchedQuery = this.searchQuery;\n\n $.getJSON(searchedURL, (result, _textStatus, request) => {\n if (searchedURL === self.searchURL) {\n self.repos = result.data;\n const count = request.getResponseHeader('X-Total-Count');\n if (searchedQuery === '' && searchedMode === '') {\n self.reposTotalCount = count;\n }\n self.repoTypes[reposFilter].count = count;\n }\n }).always(() => {\n if (searchedURL === self.searchURL) {\n self.isLoading = false;\n }\n });\n },\n\n repoClass(repo) {\n if (repo.fork) {\n return 'octicon octicon-repo-forked';\n } if (repo.mirror) {\n return 'octicon octicon-repo-clone';\n } if (repo.private) {\n return 'octicon octicon-lock';\n }\n return 'octicon octicon-repo';\n }\n }\n });\n}\n\nfunction initCtrlEnterSubmit() {\n $('.js-quick-submit').keydown(function (e) {\n if (((e.ctrlKey && !e.altKey) || e.metaKey) && (e.keyCode === 13 || e.keyCode === 10)) {\n $(this).closest('form').submit();\n }\n });\n}\n\nfunction initVueApp() {\n const el = document.getElementById('app');\n if (!el) {\n return;\n }\n\n initVueComponents();\n\n new Vue({\n delimiters: ['${', '}'],\n el,\n data: {\n searchLimit: document.querySelector('meta[name=_search_limit]').content,\n suburl: document.querySelector('meta[name=_suburl]').content,\n uid: document.querySelector('meta[name=_context_uid]').content,\n },\n });\n}\n\nwindow.timeAddManual = function () {\n $('.mini.modal')\n .modal({\n duration: 200,\n onApprove() {\n $('#add_time_manual_form').submit();\n }\n }).modal('show');\n};\n\nwindow.toggleStopwatch = function () {\n $('#toggle_stopwatch_form').submit();\n};\nwindow.cancelStopwatch = function () {\n $('#cancel_stopwatch_form').submit();\n};\n\nwindow.initHeatmap = function (appElementId, heatmapUser, locale) {\n const el = document.getElementById(appElementId);\n if (!el) {\n return;\n }\n\n locale = locale || {};\n\n locale.contributions = locale.contributions || 'contributions';\n locale.no_contributions = locale.no_contributions || 'No contributions';\n\n const vueDelimeters = ['${', '}'];\n\n Vue.component('activity-heatmap', {\n delimiters: vueDelimeters,\n\n props: {\n user: {\n type: String,\n required: true\n },\n suburl: {\n type: String,\n required: true\n },\n locale: {\n type: Object,\n required: true\n }\n },\n\n data() {\n return {\n isLoading: true,\n colorRange: [],\n endDate: null,\n values: [],\n totalContributions: 0,\n };\n },\n\n mounted() {\n this.colorRange = [\n this.getColor(0),\n this.getColor(1),\n this.getColor(2),\n this.getColor(3),\n this.getColor(4),\n this.getColor(5)\n ];\n this.endDate = new Date();\n this.loadHeatmap(this.user);\n },\n\n methods: {\n loadHeatmap(userName) {\n const self = this;\n $.get(`${this.suburl}/api/v1/users/${userName}/heatmap`, (chartRawData) => {\n const chartData = [];\n for (let i = 0; i < chartRawData.length; i++) {\n self.totalContributions += chartRawData[i].contributions;\n chartData[i] = { date: new Date(chartRawData[i].timestamp * 1000), count: chartRawData[i].contributions };\n }\n self.values = chartData;\n self.isLoading = false;\n });\n },\n\n getColor(idx) {\n const el = document.createElement('div');\n el.className = `heatmap-color-${idx}`;\n document.body.appendChild(el);\n\n const color = getComputedStyle(el).backgroundColor;\n\n document.body.removeChild(el);\n\n return color;\n }\n },\n\n template: '

total contributions in the last 12 months

'\n });\n\n new Vue({\n delimiters: vueDelimeters,\n el,\n\n data: {\n suburl: document.querySelector('meta[name=_suburl]').content,\n heatmapUser,\n locale\n },\n });\n};\n\nfunction initFilterBranchTagDropdown(selector) {\n $(selector).each(function () {\n const $dropdown = $(this);\n const $data = $dropdown.find('.data');\n const data = {\n items: [],\n mode: $data.data('mode'),\n searchTerm: '',\n noResults: '',\n canCreateBranch: false,\n menuVisible: false,\n active: 0\n };\n $data.find('.item').each(function () {\n data.items.push({\n name: $(this).text(),\n url: $(this).data('url'),\n branch: $(this).hasClass('branch'),\n tag: $(this).hasClass('tag'),\n selected: $(this).hasClass('selected')\n });\n });\n $data.remove();\n new Vue({\n delimiters: ['${', '}'],\n el: this,\n data,\n\n beforeMount() {\n const vm = this;\n\n this.noResults = vm.$el.getAttribute('data-no-results');\n this.canCreateBranch = vm.$el.getAttribute('data-can-create-branch') === 'true';\n\n document.body.addEventListener('click', (event) => {\n if (vm.$el.contains(event.target)) {\n return;\n }\n if (vm.menuVisible) {\n Vue.set(vm, 'menuVisible', false);\n }\n });\n },\n\n watch: {\n menuVisible(visible) {\n if (visible) {\n this.focusSearchField();\n }\n }\n },\n\n computed: {\n filteredItems() {\n const vm = this;\n\n const items = vm.items.filter((item) => {\n return ((vm.mode === 'branches' && item.branch) || (vm.mode === 'tags' && item.tag))\n && (!vm.searchTerm || item.name.toLowerCase().indexOf(vm.searchTerm.toLowerCase()) >= 0);\n });\n\n vm.active = (items.length === 0 && vm.showCreateNewBranch ? 0 : -1);\n\n return items;\n },\n showNoResults() {\n return this.filteredItems.length === 0 && !this.showCreateNewBranch;\n },\n showCreateNewBranch() {\n const vm = this;\n if (!this.canCreateBranch || !vm.searchTerm || vm.mode === 'tags') {\n return false;\n }\n\n return vm.items.filter((item) => item.name.toLowerCase() === vm.searchTerm.toLowerCase()).length === 0;\n }\n },\n\n methods: {\n selectItem(item) {\n const prev = this.getSelected();\n if (prev !== null) {\n prev.selected = false;\n }\n item.selected = true;\n window.location.href = item.url;\n },\n createNewBranch() {\n if (!this.showCreateNewBranch) {\n return;\n }\n this.$refs.newBranchForm.submit();\n },\n focusSearchField() {\n const vm = this;\n Vue.nextTick(() => {\n vm.$refs.searchField.focus();\n });\n },\n getSelected() {\n for (let i = 0, j = this.items.length; i < j; ++i) {\n if (this.items[i].selected) return this.items[i];\n }\n return null;\n },\n getSelectedIndexInFiltered() {\n for (let i = 0, j = this.filteredItems.length; i < j; ++i) {\n if (this.filteredItems[i].selected) return i;\n }\n return -1;\n },\n scrollToActive() {\n let el = this.$refs[`listItem${this.active}`];\n if (!el || el.length === 0) {\n return;\n }\n if (Array.isArray(el)) {\n el = el[0];\n }\n\n const cont = this.$refs.scrollContainer;\n\n if (el.offsetTop < cont.scrollTop) {\n cont.scrollTop = el.offsetTop;\n } else if (el.offsetTop + el.clientHeight > cont.scrollTop + cont.clientHeight) {\n cont.scrollTop = el.offsetTop + el.clientHeight - cont.clientHeight;\n }\n },\n keydown(event) {\n const vm = this;\n if (event.keyCode === 40) {\n // arrow down\n event.preventDefault();\n\n if (vm.active === -1) {\n vm.active = vm.getSelectedIndexInFiltered();\n }\n\n if (vm.active + (vm.showCreateNewBranch ? 0 : 1) >= vm.filteredItems.length) {\n return;\n }\n vm.active++;\n vm.scrollToActive();\n }\n if (event.keyCode === 38) {\n // arrow up\n event.preventDefault();\n\n if (vm.active === -1) {\n vm.active = vm.getSelectedIndexInFiltered();\n }\n\n if (vm.active <= 0) {\n return;\n }\n vm.active--;\n vm.scrollToActive();\n }\n if (event.keyCode === 13) {\n // enter\n event.preventDefault();\n\n if (vm.active >= vm.filteredItems.length) {\n vm.createNewBranch();\n } else if (vm.active >= 0) {\n vm.selectItem(vm.filteredItems[vm.active]);\n }\n }\n if (event.keyCode === 27) {\n // escape\n event.preventDefault();\n vm.menuVisible = false;\n }\n }\n }\n });\n });\n}\n\n$('.commit-button').click(function (e) {\n e.preventDefault();\n $(this).parent().find('.commit-body').toggle();\n});\n\nfunction initNavbarContentToggle() {\n const content = $('#navbar');\n const toggle = $('#navbar-expand-toggle');\n let isExpanded = false;\n toggle.click(() => {\n isExpanded = !isExpanded;\n if (isExpanded) {\n content.addClass('shown');\n toggle.addClass('active');\n } else {\n content.removeClass('shown');\n toggle.removeClass('active');\n }\n });\n}\n\nfunction initTopicbar() {\n const mgrBtn = $('#manage_topic');\n const editDiv = $('#topic_edit');\n const viewDiv = $('#repo-topics');\n const saveBtn = $('#save_topic');\n const topicDropdown = $('#topic_edit .dropdown');\n const topicForm = $('#topic_edit.ui.form');\n const topicPrompts = getPrompts();\n\n mgrBtn.click(() => {\n viewDiv.hide();\n editDiv.css('display', ''); // show Semantic UI Grid\n });\n\n function getPrompts() {\n const hidePrompt = $('div.hide#validate_prompt');\n const prompts = {\n countPrompt: hidePrompt.children('#count_prompt').text(),\n formatPrompt: hidePrompt.children('#format_prompt').text()\n };\n hidePrompt.remove();\n return prompts;\n }\n\n saveBtn.click(() => {\n const topics = $('input[name=topics]').val();\n\n $.post(saveBtn.data('link'), {\n _csrf: csrf,\n topics\n }, (_data, _textStatus, xhr) => {\n if (xhr.responseJSON.status === 'ok') {\n viewDiv.children('.topic').remove();\n if (topics.length) {\n const topicArray = topics.split(',');\n\n const last = viewDiv.children('a').last();\n for (let i = 0; i < topicArray.length; i++) {\n $(`
${topicArray[i]}
`).insertBefore(last);\n }\n }\n editDiv.css('display', 'none');\n viewDiv.show();\n }\n }).fail((xhr) => {\n if (xhr.status === 422) {\n if (xhr.responseJSON.invalidTopics.length > 0) {\n topicPrompts.formatPrompt = xhr.responseJSON.message;\n\n const { invalidTopics } = xhr.responseJSON;\n const topicLables = topicDropdown.children('a.ui.label');\n\n topics.split(',').forEach((value, index) => {\n for (let i = 0; i < invalidTopics.length; i++) {\n if (invalidTopics[i] === value) {\n topicLables.eq(index).removeClass('green').addClass('red');\n }\n }\n });\n } else {\n topicPrompts.countPrompt = xhr.responseJSON.message;\n }\n }\n }).always(() => {\n topicForm.form('validate form');\n });\n });\n\n topicDropdown.dropdown({\n allowAdditions: true,\n forceSelection: false,\n fields: { name: 'description', value: 'data-value' },\n saveRemoteData: false,\n label: {\n transition: 'horizontal flip',\n duration: 200,\n variation: false,\n blue: true,\n basic: true,\n },\n className: {\n label: 'ui small label'\n },\n apiSettings: {\n url: `${suburl}/api/v1/topics/search?q={query}`,\n throttle: 500,\n cache: false,\n onResponse(res) {\n const formattedResponse = {\n success: false,\n results: [],\n };\n const stripTags = function (text) {\n return text.replace(/<[^>]*>?/gm, '');\n };\n\n const query = stripTags(this.urlData.query.trim());\n let found_query = false;\n const current_topics = [];\n topicDropdown.find('div.label.visible.topic,a.label.visible').each((_, e) => { current_topics.push(e.dataset.value); });\n\n if (res.topics) {\n let found = false;\n for (let i = 0; i < res.topics.length; i++) {\n // skip currently added tags\n if (current_topics.indexOf(res.topics[i].topic_name) !== -1) {\n continue;\n }\n\n if (res.topics[i].topic_name.toLowerCase() === query.toLowerCase()) {\n found_query = true;\n }\n formattedResponse.results.push({ description: res.topics[i].topic_name, 'data-value': res.topics[i].topic_name });\n found = true;\n }\n formattedResponse.success = found;\n }\n\n if (query.length > 0 && !found_query) {\n formattedResponse.success = true;\n formattedResponse.results.unshift({ description: query, 'data-value': query });\n } else if (query.length > 0 && found_query) {\n formattedResponse.results.sort((a, b) => {\n if (a.description.toLowerCase() === query.toLowerCase()) return -1;\n if (b.description.toLowerCase() === query.toLowerCase()) return 1;\n if (a.description > b.description) return -1;\n if (a.description < b.description) return 1;\n return 0;\n });\n }\n\n\n return formattedResponse;\n },\n },\n onLabelCreate(value) {\n value = value.toLowerCase().trim();\n this.attr('data-value', value).contents().first().replaceWith(value);\n return $(this);\n },\n onAdd(addedValue, _addedText, $addedChoice) {\n addedValue = addedValue.toLowerCase().trim();\n $($addedChoice).attr('data-value', addedValue);\n $($addedChoice).attr('data-text', addedValue);\n }\n });\n\n $.fn.form.settings.rules.validateTopic = function (_values, regExp) {\n const topics = topicDropdown.children('a.ui.label');\n const status = topics.length === 0 || topics.last().attr('data-value').match(regExp);\n if (!status) {\n topics.last().removeClass('green').addClass('red');\n }\n return status && topicDropdown.children('a.ui.label.red').length === 0;\n };\n\n topicForm.form({\n on: 'change',\n inline: true,\n fields: {\n topics: {\n identifier: 'topics',\n rules: [\n {\n type: 'validateTopic',\n value: /^[a-z0-9][a-z0-9-]{1,35}$/,\n prompt: topicPrompts.formatPrompt\n },\n {\n type: 'maxCount[25]',\n prompt: topicPrompts.countPrompt\n }\n ]\n },\n }\n });\n}\n\nwindow.toggleDeadlineForm = function () {\n $('#deadlineForm').fadeToggle(150);\n};\n\nwindow.setDeadline = function () {\n const deadline = $('#deadlineDate').val();\n window.updateDeadline(deadline);\n};\n\nwindow.updateDeadline = function (deadlineString) {\n $('#deadline-err-invalid-date').hide();\n $('#deadline-loader').addClass('loading');\n\n let realDeadline = null;\n if (deadlineString !== '') {\n const newDate = Date.parse(deadlineString);\n\n if (Number.isNaN(newDate)) {\n $('#deadline-loader').removeClass('loading');\n $('#deadline-err-invalid-date').show();\n return false;\n }\n realDeadline = new Date(newDate);\n }\n\n $.ajax(`${$('#update-issue-deadline-form').attr('action')}/deadline`, {\n data: JSON.stringify({\n due_date: realDeadline,\n }),\n headers: {\n 'X-Csrf-Token': csrf,\n 'X-Remote': true,\n },\n contentType: 'application/json',\n type: 'POST',\n success() {\n reload();\n },\n error() {\n $('#deadline-loader').removeClass('loading');\n $('#deadline-err-invalid-date').show();\n }\n });\n};\n\nwindow.deleteDependencyModal = function (id, type) {\n $('.remove-dependency')\n .modal({\n closable: false,\n duration: 200,\n onApprove() {\n $('#removeDependencyID').val(id);\n $('#dependencyType').val(type);\n $('#removeDependencyForm').submit();\n }\n }).modal('show');\n};\n\nfunction initIssueList() {\n const repolink = $('#repolink').val();\n const repoId = $('#repoId').val();\n const crossRepoSearch = $('#crossRepoSearch').val();\n let issueSearchUrl = `${suburl}/api/v1/repos/${repolink}/issues?q={query}`;\n if (crossRepoSearch === 'true') {\n issueSearchUrl = `${suburl}/api/v1/repos/issues/search?q={query}&priority_repo_id=${repoId}`;\n }\n $('#new-dependency-drop-list')\n .dropdown({\n apiSettings: {\n url: issueSearchUrl,\n onResponse(response) {\n const filteredResponse = { success: true, results: [] };\n const currIssueId = $('#new-dependency-drop-list').data('issue-id');\n // Parse the response from the api to work with our dropdown\n $.each(response, (_i, issue) => {\n // Don't list current issue in the dependency list.\n if (issue.id === currIssueId) {\n return;\n }\n filteredResponse.results.push({\n name: `#${issue.number} ${htmlEncode(issue.title)\n }
${htmlEncode(issue.repository.full_name)}
`,\n value: issue.id\n });\n });\n return filteredResponse;\n },\n cache: false,\n },\n\n fullTextSearch: true\n });\n\n $('.menu a.label-filter-item').each(function () {\n $(this).click(function (e) {\n if (e.altKey) {\n e.preventDefault();\n\n const href = $(this).attr('href');\n const id = $(this).data('label-id');\n\n const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;\n const newStr = 'labels=$1-$2$3&';\n\n window.location = href.replace(new RegExp(regStr), newStr);\n }\n });\n });\n\n $('.menu .ui.dropdown.label-filter').keydown((e) => {\n if (e.altKey && e.keyCode === 13) {\n const selectedItems = $('.menu .ui.dropdown.label-filter .menu .item.selected');\n\n if (selectedItems.length > 0) {\n const item = $(selectedItems[0]);\n\n const href = item.attr('href');\n const id = item.data('label-id');\n\n const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;\n const newStr = 'labels=$1-$2$3&';\n\n window.location = href.replace(new RegExp(regStr), newStr);\n }\n }\n });\n}\nwindow.cancelCodeComment = function (btn) {\n const form = $(btn).closest('form');\n if (form.length > 0 && form.hasClass('comment-form')) {\n form.addClass('hide');\n form.parent().find('button.comment-form-reply').show();\n } else {\n form.closest('.comment-code-cloud').remove();\n }\n};\nwindow.onOAuthLoginClick = function () {\n const oauthLoader = $('#oauth2-login-loader');\n const oauthNav = $('#oauth2-login-navigator');\n\n oauthNav.hide();\n oauthLoader.removeClass('disabled');\n\n setTimeout(() => {\n // recover previous content to let user try again\n // usually redirection will be performed before this action\n oauthLoader.addClass('disabled');\n oauthNav.show();\n }, 5000);\n};\n","$(async () => {\n const graphCanvas = document.getElementById('graph-canvas');\n if (!graphCanvas) return;\n\n const [{ default: gitGraph }] = await Promise.all([\n import(/* webpackChunkName: \"gitgraph\" */'../vendor/gitgraph.js/gitgraph.custom.js'),\n import(/* webpackChunkName: \"gitgraph\" */'../vendor/gitgraph.js/gitgraph.custom.css'),\n ]);\n\n const graphList = [];\n $('#graph-raw-list li span.node-relation').each(function () {\n graphList.push($(this).text());\n });\n\n gitGraph(graphCanvas, graphList);\n});\n"],"sourceRoot":""} \ No newline at end of file diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 85c84c6bac4a2..cc62f19a327b9 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -21,12 +21,7 @@ {{end}} {{end}} {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) }} - {{if or $.root.Permission.IsAdmin (eq .Poster.ID $.root.SignedUserID)}} -
- - -
- {{end}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "diff" true }}
@@ -37,7 +32,7 @@ {{$.root.i18n.Tr "repo.issues.no_content"}} {{end}}
-
{{.Content}}
+
{{.Content}}
{{$reactions := .Reactions.GroupByType}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 2379d21e9ccb1..5b5d7c45d75dc 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -29,11 +29,7 @@ {{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) }} - {{if or .IsIssueWriter .IsIssuePoster}} -
- -
- {{end}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false }}
{{end}}
@@ -45,7 +41,7 @@ {{.i18n.Tr "repo.issues.no_content"}} {{end}} -
{{.Issue.Content}}
+
{{.Issue.Content}}
{{$reactions := .Issue.Reactions.GroupByType}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 86860fe8f44b6..1ea626ab84963 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -23,28 +23,23 @@ {{else}} {{.Poster.GetDisplayName}} {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}} {{end}} - {{if not $.Repository.IsArchived}} -
- {{if gt .ShowTag 0}} -
- {{if eq .ShowTag 1}} - {{$.i18n.Tr "repo.issues.poster"}} - {{else if eq .ShowTag 2}} - {{$.i18n.Tr "repo.issues.collaborator"}} - {{else if eq .ShowTag 3}} - {{$.i18n.Tr "repo.issues.owner"}} - {{end}} -
- {{end}} - {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }} - {{if or $.Permission.IsAdmin (eq .Poster.ID $.SignedUserID)}} -
- - -
- {{end}} -
- {{end}} + {{if not $.Repository.IsArchived}} +
+ {{if gt .ShowTag 0}} +
+ {{if eq .ShowTag 1}} + {{$.i18n.Tr "repo.issues.poster"}} + {{else if eq .ShowTag 2}} + {{$.i18n.Tr "repo.issues.collaborator"}} + {{else if eq .ShowTag 3}} + {{$.i18n.Tr "repo.issues.owner"}} + {{end}} +
+ {{end}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false }} +
+ {{end}}
@@ -54,7 +49,7 @@ {{$.i18n.Tr "repo.issues.no_content"}} {{end}}
-
{{.Content}}
+
{{.Content}}
{{$reactions := .Reactions.GroupByType}} @@ -277,29 +272,29 @@ - - - {{$.i18n.Tr "repo.issues.dependency.added_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}} - -
+ + + {{$.i18n.Tr "repo.issues.dependency.added_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}} + + -
+ #{{.DependentIssue.Index}} {{.DependentIssue.Title}} + + {{else if eq .Type 20}}
- - - - - - {{$.i18n.Tr "repo.issues.dependency.removed_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}} - - -
+ + + + + + {{$.i18n.Tr "repo.issues.dependency.removed_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}} + + + {{else if eq .Type 22}}
diff --git a/templates/repo/issue/view_content/context_menu.tmpl b/templates/repo/issue/view_content/context_menu.tmpl new file mode 100644 index 0000000000000..468e004c91da7 --- /dev/null +++ b/templates/repo/issue/view_content/context_menu.tmpl @@ -0,0 +1,22 @@ +{{if .ctx.IsSigned}} + +{{end}} diff --git a/web_src/js/index.js b/web_src/js/index.js index 671c66f689b95..7ef036885b315 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -732,10 +732,41 @@ function initRepository() { return false; }); + // Issue/PR Context Menus + $('.context-dropdown').dropdown({ + action: 'hide' + }); + + // Quote reply + $('.quote-reply').click(function (event) { + $(this).closest('.dropdown').find('.menu').toggle('visible'); + const target = $(this).data('target'); + + let $content; + if ($(this).hasClass('quote-reply-diff')) { + const $parent = $(this).closest('.comment-code-cloud'); + $parent.find('button.comment-form-reply').click(); + $content = $parent.find('[name="content"]'); + } else { + $content = $('#content'); + } + + const quote = $(`#comment-${target}`).text().replace(/\n/g, '\n> '); + const content = `> ${quote}\n\n`; + + if ($content.val() !== '') { + $content.val(`${$content.val()}\n\n${content}`); + } else { + $content.val(`${content}`); + } + $content.focus(); + event.preventDefault(); + }); + // Edit issue or comment content - $('.edit-content').click(function () { - const $segment = $(this).parent().parent().parent() - .next(); + $('.edit-content').click(function (event) { + $(this).closest('.dropdown').find('.menu').toggle('visible'); + const $segment = $(this).closest('.header').next(); const $editContentZone = $segment.find('.edit-content-zone'); const $renderContent = $segment.find('.render-content'); const $rawContent = $segment.find('.raw-content'); @@ -881,7 +912,7 @@ function initRepository() { $textarea.val($rawContent.text()); } $textarea.focus(); - return false; + event.preventDefault(); }); // Delete comment @@ -931,7 +962,6 @@ function initRepository() { $(this).closest('.form').hide(); $mergeButton.parent().show(); }); - initReactionSelector(); } diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less index 86661af428114..e0537245efff3 100644 --- a/web_src/less/_repository.less +++ b/web_src/less/_repository.less @@ -748,6 +748,10 @@ .item { float: left; + &.context { + float: none; + } + &.tag { margin-right: 5px; } From c57edb6c7b5066da2b0f526e6ab9f7842fd785fb Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Tue, 19 Nov 2019 19:44:58 -0300 Subject: [PATCH 07/17] Add password requirement info on error (#9074) * Add password requirement info on error * Move BuildComplexityError to the password pkg * Unexport complexity type * Fix extra line * Update modules/password/password.go Co-Authored-By: Lauris BH --- modules/password/password.go | 66 +++++++++++++++++++++------- modules/password/password_test.go | 4 +- options/locale/locale_en-US.ini | 6 ++- public/css/index.css | 1 + routers/admin/users.go | 4 +- routers/user/auth.go | 4 +- routers/user/setting/account.go | 2 +- routers/user/setting/account_test.go | 2 +- web_src/less/_base.less | 7 +++ 9 files changed, 72 insertions(+), 24 deletions(-) diff --git a/modules/password/password.go b/modules/password/password.go index 92986977ec6dd..1c4b9c514a459 100644 --- a/modules/password/password.go +++ b/modules/password/password.go @@ -5,24 +5,44 @@ package password import ( + "bytes" "crypto/rand" "math/big" "strings" "sync" + "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" ) +// complexity contains information about a particular kind of password complexity +type complexity struct { + ValidChars string + TrNameOne string +} + var ( matchComplexityOnce sync.Once validChars string - requiredChars []string + requiredList []complexity - charComplexities = map[string]string{ - "lower": `abcdefghijklmnopqrstuvwxyz`, - "upper": `ABCDEFGHIJKLMNOPQRSTUVWXYZ`, - "digit": `0123456789`, - "spec": ` !"#$%&'()*+,-./:;<=>?@[\]^_{|}~` + "`", + charComplexities = map[string]complexity{ + "lower": { + `abcdefghijklmnopqrstuvwxyz`, + "form.password_lowercase_one", + }, + "upper": { + `ABCDEFGHIJKLMNOPQRSTUVWXYZ`, + "form.password_uppercase_one", + }, + "digit": { + `0123456789`, + "form.password_digit_one", + }, + "spec": { + ` !"#$%&'()*+,-./:;<=>?@[\]^_{|}~` + "`", + "form.password_special_one", + }, } ) @@ -36,22 +56,22 @@ func NewComplexity() { func setupComplexity(values []string) { if len(values) != 1 || values[0] != "off" { for _, val := range values { - if chars, ok := charComplexities[val]; ok { - validChars += chars - requiredChars = append(requiredChars, chars) + if complex, ok := charComplexities[val]; ok { + validChars += complex.ValidChars + requiredList = append(requiredList, complex) } } - if len(requiredChars) == 0 { + if len(requiredList) == 0 { // No valid character classes found; use all classes as default - for _, chars := range charComplexities { - validChars += chars - requiredChars = append(requiredChars, chars) + for _, complex := range charComplexities { + validChars += complex.ValidChars + requiredList = append(requiredList, complex) } } } if validChars == "" { // No complexities to check; provide a sensible default for password generation - validChars = charComplexities["lower"] + charComplexities["upper"] + charComplexities["digit"] + validChars = charComplexities["lower"].ValidChars + charComplexities["upper"].ValidChars + charComplexities["digit"].ValidChars } } @@ -59,8 +79,8 @@ func setupComplexity(values []string) { func IsComplexEnough(pwd string) bool { NewComplexity() if len(validChars) > 0 { - for _, req := range requiredChars { - if !strings.ContainsAny(req, pwd) { + for _, req := range requiredList { + if !strings.ContainsAny(req.ValidChars, pwd) { return false } } @@ -86,3 +106,17 @@ func Generate(n int) (string, error) { } } } + +// BuildComplexityError builds the error message when password complexity checks fail +func BuildComplexityError(ctx *context.Context) string { + var buffer bytes.Buffer + buffer.WriteString(ctx.Tr("form.password_complexity")) + buffer.WriteString("
    ") + for _, c := range requiredList { + buffer.WriteString("
  • ") + buffer.WriteString(ctx.Tr(c.TrNameOne)) + buffer.WriteString("
  • ") + } + buffer.WriteString("
") + return buffer.String() +} diff --git a/modules/password/password_test.go b/modules/password/password_test.go index d46a6d1571e9e..4325086b50b80 100644 --- a/modules/password/password_test.go +++ b/modules/password/password_test.go @@ -18,6 +18,7 @@ func TestComplexity_IsComplexEnough(t *testing.T) { truevalues []string falsevalues []string }{ + {[]string{"off"}, []string{"1", "-", "a", "A", "ñ", "日本語"}, []string{}}, {[]string{"lower"}, []string{"abc", "abc!"}, []string{"ABC", "123", "=!$", ""}}, {[]string{"upper"}, []string{"ABC"}, []string{"abc", "123", "=!$", "abc!", ""}}, {[]string{"digit"}, []string{"123"}, []string{"abc", "ABC", "=!$", "abc!", ""}}, @@ -25,6 +26,7 @@ func TestComplexity_IsComplexEnough(t *testing.T) { {[]string{"off"}, []string{"abc", "ABC", "123", "=!$", "abc!", ""}, nil}, {[]string{"lower", "spec"}, []string{"abc!"}, []string{"abc", "ABC", "123", "=!$", "abcABC123", ""}}, {[]string{"lower", "upper", "digit"}, []string{"abcABC123"}, []string{"abc", "ABC", "123", "=!$", "abc!", ""}}, + {[]string{""}, []string{"abC=1", "abc!9D"}, []string{"ABC", "123", "=!$", ""}}, } for _, test := range testlist { @@ -70,6 +72,6 @@ func TestComplexity_Generate(t *testing.T) { func testComplextity(values []string) { // Cleanup previous values validChars = "" - requiredChars = make([]string, 0, len(values)) + requiredList = make([]complexity, 0, len(values)) setupComplexity(values) } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index be644c6ea9a83..99304c470d39d 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -328,7 +328,11 @@ team_no_units_error = Allow access to at least one repository section. email_been_used = The email address is already used. openid_been_used = The OpenID address '%s' is already used. username_password_incorrect = Username or password is incorrect. -password_complexity = Password does not pass complexity requirements. +password_complexity = Password does not pass complexity requirements: +password_lowercase_one = At least one lowercase character +password_uppercase_one = At least one uppercase character +password_digit_one = At least one digit +password_special_one = At least one special character (punctuation, brackets, quotes, etc.) enterred_invalid_repo_name = The repository name you entered is incorrect. enterred_invalid_owner_name = The new owner name is not valid. enterred_invalid_password = The password you entered is incorrect. diff --git a/public/css/index.css b/public/css/index.css index 33d1f8046a3f3..1265fffad0bb8 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -113,6 +113,7 @@ a{cursor:pointer} .ui .text.nopadding{padding:0} .ui .text.nomargin{margin:0} .ui .message{text-align:center} +.ui .message>ul{margin-left:auto;margin-right:auto;display:table;text-align:left} .ui.bottom.attached.message{font-weight:700;text-align:left;color:#000} .ui.bottom.attached.message .pull-right{color:#000} .ui.bottom.attached.message .pull-right>span,.ui.bottom.attached.message>span{color:#21ba45} diff --git a/routers/admin/users.go b/routers/admin/users.go index 2284f21838c6a..7626fbc0d0919 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -96,7 +96,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) { } if u.LoginType == models.LoginPlain { if !password.IsComplexEnough(form.Password) { - ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form) + ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserNew, &form) return } u.MustChangePassword = form.MustChangePassword @@ -208,7 +208,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) { return } if !password.IsComplexEnough(form.Password) { - ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserEdit, &form) + ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserEdit, &form) return } u.HashPassword(form.Password) diff --git a/routers/user/auth.go b/routers/user/auth.go index cb5611e0459ba..d0ad4afffd21b 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -1072,7 +1072,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo } if !password.IsComplexEnough(form.Password) { ctx.Data["Err_Password"] = true - ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplSignUp, &form) + ctx.RenderWithErr(password.BuildComplexityError(ctx), tplSignUp, &form) return } @@ -1343,7 +1343,7 @@ func ResetPasswdPost(ctx *context.Context) { } else if !password.IsComplexEnough(passwd) { ctx.Data["IsResetForm"] = true ctx.Data["Err_Password"] = true - ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplResetPassword, nil) + ctx.RenderWithErr(password.BuildComplexityError(ctx), tplResetPassword, nil) return } diff --git a/routers/user/setting/account.go b/routers/user/setting/account.go index 73799c8bd72e9..a9064b0e15749 100644 --- a/routers/user/setting/account.go +++ b/routers/user/setting/account.go @@ -53,7 +53,7 @@ func AccountPost(ctx *context.Context, form auth.ChangePasswordForm) { } else if form.Password != form.Retype { ctx.Flash.Error(ctx.Tr("form.password_not_match")) } else if !password.IsComplexEnough(form.Password) { - ctx.Flash.Error(ctx.Tr("form.password_complexity")) + ctx.Flash.Error(password.BuildComplexityError(ctx)) } else { var err error if ctx.User.Salt, err = models.GetUserSalt(); err != nil { diff --git a/routers/user/setting/account_test.go b/routers/user/setting/account_test.go index 41783e19d736a..841ecb8ac25c5 100644 --- a/routers/user/setting/account_test.go +++ b/routers/user/setting/account_test.go @@ -91,7 +91,7 @@ func TestChangePassword(t *testing.T) { Retype: req.Retype, }) - assert.EqualValues(t, req.Message, ctx.Flash.ErrorMsg) + assert.Contains(t, ctx.Flash.ErrorMsg, req.Message) assert.EqualValues(t, http.StatusFound, ctx.Resp.Status()) } } diff --git a/web_src/less/_base.less b/web_src/less/_base.less index 8bf49b1ef904e..a39977065d8ec 100644 --- a/web_src/less/_base.less +++ b/web_src/less/_base.less @@ -471,6 +471,13 @@ code, text-align: center; } + .message > ul { + margin-left: auto; + margin-right: auto; + display: table; + text-align: left; + } + &.bottom.attached.message { font-weight: bold; text-align: left; From 4a357f4188ee037d5279d198356af71a8ca102bc Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Tue, 19 Nov 2019 23:06:30 +0000 Subject: [PATCH 08/17] [skip ci] Updated translations via Crowdin --- options/locale/locale_es-ES.ini | 3 ++- options/locale/locale_pt-BR.ini | 1 - options/locale/locale_zh-CN.ini | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini index d1da6b2d0c904..1ef4ea1fed7f4 100644 --- a/options/locale/locale_es-ES.ini +++ b/options/locale/locale_es-ES.ini @@ -1037,7 +1037,6 @@ pulls.rebase_merge_commit_pull_request=Hacer Rebase y Fusionar (--no-ff) pulls.squash_merge_pull_request=Hacer Squash y Fusionar pulls.invalid_merge_option=No puede utilizar esta opción de combinación para esta solicitud de extracción. pulls.merge_conflict=Fusión fallida: Hubo un conflicto mientras se fusionaba: %[1]s
%[2]s
Pista: Pruebe una estrategia diferente -pulls.rebase_conflict=Fusión fallida: Hubo un conflicto mientras se rebasaba el commit: %s[1]
%[1]s
s[2]s
Sugerencia:Prueba una estrategia diferente pulls.open_unmerged_pull_exists=`No puede realizar la reapertura porque hay un pull request pendiente (#%d) con propiedades idénticas.` pulls.status_checking=Algunas comprobaciones están pendientes pulls.status_checks_success=Todas las comprobaciones han sido exitosas @@ -1981,6 +1980,8 @@ compare_commits_general=Comparar commits mirror_sync_push=sincronizó cambios a %[3]s en %[4]s desde réplica mirror_sync_create=sincronizada nueva referencia %[2]s a %[3]s desde réplica mirror_sync_delete=sincronizada y eliminada referencia %[2]s en %[3]s desde réplica +approve_pull_request=`aprobado %s#%[2]s` +reject_pull_request=`sugerido cambios para %s#%[2]s` [tool] ago=hace %s diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index 3c1822a00c7d3..bf668a00bb9c0 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -1044,7 +1044,6 @@ pulls.rebase_merge_commit_pull_request=Aplicar Rebase e Merge (--no-ff) pulls.squash_merge_pull_request=Aplicar Squash e Merge pulls.invalid_merge_option=Você não pode usar esta opção de merge neste pull request. pulls.merge_conflict=Merge falhou: Houve um conflito durante o merge: %[1]s
%[2]s
Dica: Tente uma estratégia diferente -pulls.rebase_conflict=Merge Falhou: Houve um conflito durante o rebase do commit: %s[1]
%[1]s
%[2]s
Dica: Tente uma estratégia diferente pulls.unrelated_histories=Merge falhou: O merge do principal e da base não compartilham uma história comum. Dica: Tente uma estratégia diferente pulls.merge_out_of_date=Merge falhou: durante a geração do merge, a base não foi atualizada. Dica: Tente novamente. pulls.open_unmerged_pull_exists=`Não é possível executar uma operação de reabertura pois há um pull request pendente (#%d) com propriedades idênticas.` diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 633e38bc7fa7d..1ed8667d027db 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1037,7 +1037,6 @@ pulls.rebase_merge_commit_pull_request=变基合并 (--no-ff) pulls.squash_merge_pull_request=压缩提交并合并 pulls.invalid_merge_option=你可以在此合并请求中使用合并选项。 pulls.merge_conflict=合并失败:合并时发生冲突:%[1]s
[2]
提示:尝试不同的合并策略 -pulls.rebase_conflict=合并失败:Rebase合并时发生冲突:%[1]s
[2]
提示:尝试不同的合并策略 pulls.unrelated_histories=合并失败:两个分支没有共同历史。提示:尝试不同的策略 pulls.merge_out_of_date=合并失败:在生成合并时,主分支已更新。提示:再试一次。 pulls.open_unmerged_pull_exists=`您不能执行重新打开操作, 因为已经存在相同的合并请求 (#%d)。` From e4ec32de2eee4ae320ef8e2f9a68a39ad607f548 Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Tue, 19 Nov 2019 21:07:51 -0300 Subject: [PATCH 09/17] Fix password checks on admin create/edit user (#9076) * Fix password checks on admin create/edit user * Remove incorrect trimspace --- routers/admin/users.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/routers/admin/users.go b/routers/admin/users.go index 7626fbc0d0919..b5c7dbd38346b 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -94,8 +94,14 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) { u.LoginName = form.LoginName } } - if u.LoginType == models.LoginPlain { + if u.LoginType == models.LoginNoType || u.LoginType == models.LoginPlain { + if len(form.Password) < setting.MinPasswordLength { + ctx.Data["Err_Password"] = true + ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplUserNew, &form) + return + } if !password.IsComplexEnough(form.Password) { + ctx.Data["Err_Password"] = true ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserNew, &form) return } @@ -203,14 +209,19 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) { if len(form.Password) > 0 { var err error - if u.Salt, err = models.GetUserSalt(); err != nil { - ctx.ServerError("UpdateUser", err) + if len(form.Password) < setting.MinPasswordLength { + ctx.Data["Err_Password"] = true + ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplUserEdit, &form) return } if !password.IsComplexEnough(form.Password) { ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserEdit, &form) return } + if u.Salt, err = models.GetUserSalt(); err != nil { + ctx.ServerError("UpdateUser", err) + return + } u.HashPassword(form.Password) } From 108bed202349532d22f55c51a794ad48ae662e17 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Wed, 20 Nov 2019 00:16:19 +0000 Subject: [PATCH 10/17] [skip ci] Updated translations via Crowdin --- options/locale/locale_de-DE.ini | 1 - options/locale/locale_es-ES.ini | 1 - options/locale/locale_fa-IR.ini | 1 - options/locale/locale_fr-FR.ini | 1 - options/locale/locale_ja-JP.ini | 1 - options/locale/locale_pt-BR.ini | 1 - options/locale/locale_tr-TR.ini | 1 - options/locale/locale_zh-CN.ini | 1 - 8 files changed, 8 deletions(-) diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index d1c36f0b6dc40..9cc0fb18bf7dd 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -327,7 +327,6 @@ team_no_units_error=Das Team muss auf mindestens einen Bereich Zugriff haben. email_been_used=Die E-Mail-Adresse wird bereits verwendet. openid_been_used=Die OpenID-Adresse „%s“ wird bereits verwendet. username_password_incorrect=Benutzername oder Passwort ist falsch. -password_complexity=Das Passwort erfüllt nicht die Komplexitätsanforderungen. enterred_invalid_repo_name=Der eingegebenen Repository-Name ist falsch. enterred_invalid_owner_name=Der Name des neuen Besitzers ist ungültig. enterred_invalid_password=Das eingegebene Passwort ist falsch. diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini index 1ef4ea1fed7f4..ddabc5cedfe56 100644 --- a/options/locale/locale_es-ES.ini +++ b/options/locale/locale_es-ES.ini @@ -327,7 +327,6 @@ team_no_units_error=Permitir el acceso a por lo menos una sección del repositor email_been_used=La dirección de correo electrónico ya está usada. openid_been_used=La dirección OpenID '%s' ya está usada. username_password_incorrect=El nombre de usuario o la contraseña son incorrectos. -password_complexity=La contraseña no pasa por los requisitos de complejidad. enterred_invalid_repo_name=El nombre de repositorio que ha entrado es incorrecto. enterred_invalid_owner_name=El nuevo nombre de usuario no es válido. enterred_invalid_password=La contraseña que ha introducido es incorrecta. diff --git a/options/locale/locale_fa-IR.ini b/options/locale/locale_fa-IR.ini index 1ca16fe167377..edcd7e95ce56c 100644 --- a/options/locale/locale_fa-IR.ini +++ b/options/locale/locale_fa-IR.ini @@ -323,7 +323,6 @@ team_no_units_error=اجازه دسترسی به حداقل یک بخش مخزن email_been_used=این ایمیل قبلا ثبت شده. openid_been_used=آدرس OpenID %s قبلا ثبت شده است. username_password_incorrect=نام کاربری یا گذرواژه صحیح نیست. -password_complexity=پسورد ضرورت به پیچیدگی نداشته باشد. enterred_invalid_repo_name=نام مخزنی که وارد کرده اید صحیح نمی باشد. enterred_invalid_owner_name=نام مالک جدید معتبر نیست. enterred_invalid_password=گذرواژه وارد شده صحیح نیست. diff --git a/options/locale/locale_fr-FR.ini b/options/locale/locale_fr-FR.ini index a2739e0e6bf23..9bc071104bba0 100644 --- a/options/locale/locale_fr-FR.ini +++ b/options/locale/locale_fr-FR.ini @@ -320,7 +320,6 @@ team_no_units_error=Autoriser l’accès à au moins une section du dépôt. email_been_used=Cette adresse e-mail est déjà utilisée. openid_been_used=Adresse OpenID '%s' déjà utilisée. username_password_incorrect=Identifiant ou mot de passe invalide. -password_complexity=Le mot de passe ne respecte pas les exigences de complexité. enterred_invalid_repo_name=Le nom de dépôt saisi est incorrect. enterred_invalid_owner_name=Le nom du nouveau propriétaire est invalide. enterred_invalid_password=Le mot de passe saisi est incorrect. diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index ea4e7718d182a..35213cdd60465 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -327,7 +327,6 @@ team_no_units_error=少なくともひとつのリポジトリセクションへ email_been_used=メールアドレスが既に使用されています。 openid_been_used=OpenIDのアドレス '%s' は既に使用されています。 username_password_incorrect=ユーザー名またはパスワードが間違っています。 -password_complexity=パスワードが複雑性の要件を満たしていません。 enterred_invalid_repo_name=入力したリポジトリ名が間違っています。 enterred_invalid_owner_name=新しいオーナーの名前が正しくありません。 enterred_invalid_password=入力されたパスワードが間違っています。 diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index bf668a00bb9c0..8c6dd5d70d1e2 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -327,7 +327,6 @@ team_no_units_error=Permitir acesso a pelo menos uma seção de repositório. email_been_used=Este endereço de e-mail já está sendo usado. openid_been_used=O endereço OpenID '%s' já está sendo usado. username_password_incorrect=Nome de usuário ou senha incorretos. -password_complexity=A senha não passa nos requisitos de complexidade. enterred_invalid_repo_name=O nome do repositório que você digitou está incorreto. enterred_invalid_owner_name=O nome do novo proprietário não é válido. enterred_invalid_password=A senha que você digitou está incorreta. diff --git a/options/locale/locale_tr-TR.ini b/options/locale/locale_tr-TR.ini index b6e6c6784abe9..fb2e37fefbee6 100644 --- a/options/locale/locale_tr-TR.ini +++ b/options/locale/locale_tr-TR.ini @@ -315,7 +315,6 @@ team_no_units_error=En az bir depo bölümüne erişimine izin ver. email_been_used=E-posta adresi zaten kullanılıyor. openid_been_used=OpenID adresi '%s' zaten kullanılıyor. username_password_incorrect=Kullanıcı adı veya parola hatalı. -password_complexity=Parola, karmaşıklık gereksinimlerini karşılamıyor. enterred_invalid_repo_name=Girdiğiniz depo adı hatalı. enterred_invalid_owner_name=Yeni sahip ismi hatalı. enterred_invalid_password=Girdiğiniz parola hatalı. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 1ed8667d027db..8c4f57cf00d4a 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -327,7 +327,6 @@ team_no_units_error=至少选择一项仓库单元。 email_been_used=该电子邮件地址已在使用中。 openid_been_used=OpenID 地址 '%s' 已被使用。 username_password_incorrect=用户名或密码不正确。 -password_complexity=密码未达到复杂程度要求 enterred_invalid_repo_name=输入的仓库名称不正确 enterred_invalid_owner_name=新的所有者名称无效。 enterred_invalid_password=输入的密码不正确 From 05f6eccf27824549d711f30578eff2a39252c7a0 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 20 Nov 2019 00:30:46 -0500 Subject: [PATCH 11/17] update golang.org/x/crypto vendor to use acme v2 (#9056) --- go.mod | 2 +- go.sum | 2 + vendor/golang.org/x/crypto/acme/acme.go | 168 ++-- .../x/crypto/acme/autocert/autocert.go | 266 ++++-- vendor/golang.org/x/crypto/acme/http.go | 10 +- vendor/golang.org/x/crypto/acme/jws.go | 17 +- vendor/golang.org/x/crypto/acme/rfc8555.go | 280 +++++- vendor/golang.org/x/crypto/acme/types.go | 240 ++++- .../x/crypto/chacha20/chacha_arm64.go | 17 + .../asm_arm64.s => chacha20/chacha_arm64.s} | 0 .../x/crypto/chacha20/chacha_generic.go | 364 ++++++++ .../x/crypto/chacha20/chacha_noasm.go | 13 + .../x/crypto/chacha20/chacha_ppc64le.go | 16 + .../x/crypto/chacha20/chacha_ppc64le.s | 449 +++++++++ .../x/crypto/chacha20/chacha_s390x.go | 26 + .../{internal => }/chacha20/chacha_s390x.s | 40 +- .../x/crypto/{internal => }/chacha20/xor.go | 4 +- .../x/crypto/curve25519/const_amd64.h | 8 - .../x/crypto/curve25519/const_amd64.s | 20 - .../x/crypto/curve25519/cswap_amd64.s | 65 -- .../x/crypto/curve25519/curve25519.go | 881 ++---------------- ...mont25519_amd64.go => curve25519_amd64.go} | 2 +- ...{ladderstep_amd64.s => curve25519_amd64.s} | 420 ++++++++- .../x/crypto/curve25519/curve25519_generic.go | 828 ++++++++++++++++ .../x/crypto/curve25519/curve25519_noasm.go | 11 + vendor/golang.org/x/crypto/curve25519/doc.go | 23 - .../x/crypto/curve25519/freeze_amd64.s | 73 -- .../x/crypto/curve25519/mul_amd64.s | 169 ---- .../x/crypto/curve25519/square_amd64.s | 132 --- .../x/crypto/internal/chacha20/asm_ppc64le.s | 668 ------------- .../crypto/internal/chacha20/chacha_arm64.go | 31 - .../internal/chacha20/chacha_generic.go | 264 ------ .../crypto/internal/chacha20/chacha_noasm.go | 16 - .../internal/chacha20/chacha_ppc64le.go | 52 -- .../crypto/internal/chacha20/chacha_s390x.go | 29 - .../x/crypto/openpgp/elgamal/elgamal.go | 4 +- .../x/crypto/openpgp/packet/encrypted_key.go | 6 +- .../x/crypto/openpgp/packet/private_key.go | 2 +- .../x/crypto/poly1305/bits_compat.go | 39 + .../x/crypto/poly1305/bits_go1.13.go | 21 + .../golang.org/x/crypto/poly1305/poly1305.go | 10 +- .../golang.org/x/crypto/poly1305/sum_amd64.go | 56 +- .../golang.org/x/crypto/poly1305/sum_amd64.s | 40 - .../golang.org/x/crypto/poly1305/sum_arm.go | 7 +- .../x/crypto/poly1305/sum_generic.go | 391 +++++--- .../golang.org/x/crypto/poly1305/sum_noasm.go | 5 +- .../x/crypto/poly1305/sum_ppc64le.go | 56 +- .../x/crypto/poly1305/sum_ppc64le.s | 66 -- .../golang.org/x/crypto/poly1305/sum_s390x.go | 5 +- vendor/golang.org/x/crypto/ssh/cipher.go | 51 +- vendor/golang.org/x/crypto/ssh/kex.go | 2 +- vendor/modules.txt | 4 +- 52 files changed, 3429 insertions(+), 2942 deletions(-) create mode 100644 vendor/golang.org/x/crypto/chacha20/chacha_arm64.go rename vendor/golang.org/x/crypto/{internal/chacha20/asm_arm64.s => chacha20/chacha_arm64.s} (100%) create mode 100644 vendor/golang.org/x/crypto/chacha20/chacha_generic.go create mode 100644 vendor/golang.org/x/crypto/chacha20/chacha_noasm.go create mode 100644 vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go create mode 100644 vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s create mode 100644 vendor/golang.org/x/crypto/chacha20/chacha_s390x.go rename vendor/golang.org/x/crypto/{internal => }/chacha20/chacha_s390x.s (87%) rename vendor/golang.org/x/crypto/{internal => }/chacha20/xor.go (98%) delete mode 100644 vendor/golang.org/x/crypto/curve25519/const_amd64.h delete mode 100644 vendor/golang.org/x/crypto/curve25519/const_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/cswap_amd64.s rename vendor/golang.org/x/crypto/curve25519/{mont25519_amd64.go => curve25519_amd64.go} (99%) rename vendor/golang.org/x/crypto/curve25519/{ladderstep_amd64.s => curve25519_amd64.s} (76%) create mode 100644 vendor/golang.org/x/crypto/curve25519/curve25519_generic.go create mode 100644 vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go delete mode 100644 vendor/golang.org/x/crypto/curve25519/doc.go delete mode 100644 vendor/golang.org/x/crypto/curve25519/freeze_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/mul_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/square_amd64.s delete mode 100644 vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s delete mode 100644 vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go delete mode 100644 vendor/golang.org/x/crypto/internal/chacha20/chacha_generic.go delete mode 100644 vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go delete mode 100644 vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go delete mode 100644 vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.go create mode 100644 vendor/golang.org/x/crypto/poly1305/bits_compat.go create mode 100644 vendor/golang.org/x/crypto/poly1305/bits_go1.13.go diff --git a/go.mod b/go.mod index 64cc079b3570d..3c99c64e93f4f 100644 --- a/go.mod +++ b/go.mod @@ -98,7 +98,7 @@ require ( github.com/urfave/cli v1.20.0 github.com/willf/bitset v0.0.0-20180426185212-8ce1146b8621 // indirect github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53 - golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad + golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b diff --git a/go.sum b/go.sum index 24b7f6f92ec4a..3443711687890 100644 --- a/go.sum +++ b/go.sum @@ -583,6 +583,8 @@ golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad h1:5E5raQxcv+6CZ11RrBYQe5WRbUIWpScjh0kvHZkZIrQ= golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f h1:kz4KIr+xcPUsI3VMoqWfPMvtnJ6MGfiVwsWSVzphMO4= +golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= diff --git a/vendor/golang.org/x/crypto/acme/acme.go b/vendor/golang.org/x/crypto/acme/acme.go index 31d07e30f7d4c..02fde12db59f1 100644 --- a/vendor/golang.org/x/crypto/acme/acme.go +++ b/vendor/golang.org/x/crypto/acme/acme.go @@ -5,7 +5,7 @@ // Package acme provides an implementation of the // Automatic Certificate Management Environment (ACME) spec. // The intial implementation was based on ACME draft-02 and -// is now being extended to comply with RFC8555. +// is now being extended to comply with RFC 8555. // See https://tools.ietf.org/html/draft-ietf-acme-acme-02 // and https://tools.ietf.org/html/rfc8555 for details. // @@ -44,7 +44,7 @@ import ( const ( // LetsEncryptURL is the Directory endpoint of Let's Encrypt CA. - LetsEncryptURL = "https://acme-v01.api.letsencrypt.org/directory" + LetsEncryptURL = "https://acme-v02.api.letsencrypt.org/directory" // ALPNProto is the ALPN protocol name used by a CA server when validating // tls-alpn-01 challenges. @@ -60,7 +60,10 @@ var idPeACMEIdentifierV1 = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 30, 1} const ( maxChainLen = 5 // max depth and breadth of a certificate chain - maxCertSize = 1 << 20 // max size of a certificate, in bytes + maxCertSize = 1 << 20 // max size of a certificate, in DER bytes + // Used for decoding certs from application/pem-certificate-chain response, + // the default when in RFC mode. + maxCertChainSize = maxCertSize * maxChainLen // Max number of collected nonces kept in memory. // Expect usual peak of 1 or 2. @@ -139,8 +142,7 @@ type Client struct { func (c *Client) accountKID(ctx context.Context) keyID { c.cacheMu.Lock() defer c.cacheMu.Unlock() - if c.dir.OrderURL == "" { - // Assume legacy CA. + if !c.dir.rfcCompliant() { return noKeyID } if c.kid != noKeyID { @@ -233,6 +235,9 @@ func (c *Client) directoryURL() string { } // CreateCert requests a new certificate using the Certificate Signing Request csr encoded in DER format. +// It is incompatible with RFC 8555. Callers should use CreateOrderCert when interfacing +// with an RFC-compliant CA. +// // The exp argument indicates the desired certificate validity duration. CA may issue a certificate // with a different duration. // If the bundle argument is true, the returned value will also contain the CA (issuer) certificate chain. @@ -284,12 +289,22 @@ func (c *Client) CreateCert(ctx context.Context, csr []byte, exp time.Duration, // It retries the request until the certificate is successfully retrieved, // context is cancelled by the caller or an error response is received. // -// The returned value will also contain the CA (issuer) certificate if the bundle argument is true. +// If the bundle argument is true, the returned value also contains the CA (issuer) +// certificate chain. // // FetchCert returns an error if the CA's response or chain was unreasonably large. // Callers are encouraged to parse the returned value to ensure the certificate is valid // and has expected features. func (c *Client) FetchCert(ctx context.Context, url string, bundle bool) ([][]byte, error) { + dir, err := c.Discover(ctx) + if err != nil { + return nil, err + } + if dir.rfcCompliant() { + return c.fetchCertRFC(ctx, url, bundle) + } + + // Legacy non-authenticated GET request. res, err := c.get(ctx, url, wantStatus(http.StatusOK)) if err != nil { return nil, err @@ -304,10 +319,15 @@ func (c *Client) FetchCert(ctx context.Context, url string, bundle bool) ([][]by // For instance, the key pair of the certificate may be authorized. // If the key is nil, c.Key is used instead. func (c *Client) RevokeCert(ctx context.Context, key crypto.Signer, cert []byte, reason CRLReasonCode) error { - if _, err := c.Discover(ctx); err != nil { + dir, err := c.Discover(ctx) + if err != nil { return err } + if dir.rfcCompliant() { + return c.revokeCertRFC(ctx, key, cert, reason) + } + // Legacy CA. body := &struct { Resource string `json:"resource"` Cert string `json:"certificate"` @@ -317,7 +337,7 @@ func (c *Client) RevokeCert(ctx context.Context, key crypto.Signer, cert []byte, Cert: base64.RawURLEncoding.EncodeToString(cert), Reason: int(reason), } - res, err := c.post(ctx, key, c.dir.RevokeURL, body, wantStatus(http.StatusOK)) + res, err := c.post(ctx, key, dir.RevokeURL, body, wantStatus(http.StatusOK)) if err != nil { return err } @@ -337,7 +357,7 @@ func AcceptTOS(tosURL string) bool { return true } // Register calls prompt with a TOS URL provided by the CA. Prompt should report // whether the caller agrees to the terms. To always accept the terms, the caller can use AcceptTOS. // -// When interfacing with RFC compliant CA, non-RFC8555 compliant fields of acct are ignored +// When interfacing with an RFC-compliant CA, non-RFC 8555 fields of acct are ignored // and prompt is called if Directory's Terms field is non-zero. // Also see Error's Instance field for when a CA requires already registered accounts to agree // to an updated Terms of Service. @@ -346,9 +366,7 @@ func (c *Client) Register(ctx context.Context, acct *Account, prompt func(tosURL if err != nil { return nil, err } - - // RFC8555 compliant account registration. - if dir.OrderURL != "" { + if dir.rfcCompliant() { return c.registerRFC(ctx, acct, prompt) } @@ -370,16 +388,14 @@ func (c *Client) Register(ctx context.Context, acct *Account, prompt func(tosURL // GetReg retrieves an existing account associated with c.Key. // -// The url argument is an Account URI used with pre-RFC8555 CAs. -// It is ignored when interfacing with an RFC compliant CA. +// The url argument is an Account URI used with pre-RFC 8555 CAs. +// It is ignored when interfacing with an RFC-compliant CA. func (c *Client) GetReg(ctx context.Context, url string) (*Account, error) { dir, err := c.Discover(ctx) if err != nil { return nil, err } - - // Assume RFC8555 compliant CA. - if dir.OrderURL != "" { + if dir.rfcCompliant() { return c.getRegRFC(ctx) } @@ -395,16 +411,14 @@ func (c *Client) GetReg(ctx context.Context, url string) (*Account, error) { // UpdateReg updates an existing registration. // It returns an updated account copy. The provided account is not modified. // -// When interfacing with RFC compliant CAs, a.URI is ignored and the account URL +// When interfacing with RFC-compliant CAs, a.URI is ignored and the account URL // associated with c.Key is used instead. func (c *Client) UpdateReg(ctx context.Context, acct *Account) (*Account, error) { dir, err := c.Discover(ctx) if err != nil { return nil, err } - - // Assume RFC8555 compliant CA. - if dir.OrderURL != "" { + if dir.rfcCompliant() { return c.updateRegRFC(ctx, acct) } @@ -418,13 +432,21 @@ func (c *Client) UpdateReg(ctx context.Context, acct *Account) (*Account, error) return a, nil } -// Authorize performs the initial step in an authorization flow. +// Authorize performs the initial step in the pre-authorization flow, +// as opposed to order-based flow. // The caller will then need to choose from and perform a set of returned // challenges using c.Accept in order to successfully complete authorization. // +// Once complete, the caller can use AuthorizeOrder which the CA +// should provision with the already satisfied authorization. +// For pre-RFC CAs, the caller can proceed directly to requesting a certificate +// using CreateCert method. +// // If an authorization has been previously granted, the CA may return -// a valid authorization (Authorization.Status is StatusValid). If so, the caller -// need not fulfill any challenge and can proceed to requesting a certificate. +// a valid authorization which has its Status field set to StatusValid. +// +// More about pre-authorization can be found at +// https://tools.ietf.org/html/rfc8555#section-7.4.1. func (c *Client) Authorize(ctx context.Context, domain string) (*Authorization, error) { return c.authorize(ctx, "dns", domain) } @@ -476,7 +498,17 @@ func (c *Client) authorize(ctx context.Context, typ, val string) (*Authorization // If a caller needs to poll an authorization until its status is final, // see the WaitAuthorization method. func (c *Client) GetAuthorization(ctx context.Context, url string) (*Authorization, error) { - res, err := c.get(ctx, url, wantStatus(http.StatusOK, http.StatusAccepted)) + dir, err := c.Discover(ctx) + if err != nil { + return nil, err + } + + var res *http.Response + if dir.rfcCompliant() { + res, err = c.postAsGet(ctx, url, wantStatus(http.StatusOK)) + } else { + res, err = c.get(ctx, url, wantStatus(http.StatusOK, http.StatusAccepted)) + } if err != nil { return nil, err } @@ -493,8 +525,8 @@ func (c *Client) GetAuthorization(ctx context.Context, url string) (*Authorizati // The url argument is an Authorization.URI value. // // If successful, the caller will be required to obtain a new authorization -// using the Authorize method before being able to request a new certificate -// for the domain associated with the authorization. +// using the Authorize or AuthorizeOrder methods before being able to request +// a new certificate for the domain associated with the authorization. // // It does not revoke existing certificates. func (c *Client) RevokeAuthorization(ctx context.Context, url string) error { @@ -528,8 +560,18 @@ func (c *Client) RevokeAuthorization(ctx context.Context, url string) error { // In all other cases WaitAuthorization returns an error. // If the Status is StatusInvalid, the returned error is of type *AuthorizationError. func (c *Client) WaitAuthorization(ctx context.Context, url string) (*Authorization, error) { + // Required for c.accountKID() when in RFC mode. + dir, err := c.Discover(ctx) + if err != nil { + return nil, err + } + getfn := c.postAsGet + if !dir.rfcCompliant() { + getfn = c.get + } + for { - res, err := c.get(ctx, url, wantStatus(http.StatusOK, http.StatusAccepted)) + res, err := getfn(ctx, url, wantStatus(http.StatusOK, http.StatusAccepted)) if err != nil { return nil, err } @@ -572,10 +614,21 @@ func (c *Client) WaitAuthorization(ctx context.Context, url string) (*Authorizat // // A client typically polls a challenge status using this method. func (c *Client) GetChallenge(ctx context.Context, url string) (*Challenge, error) { - res, err := c.get(ctx, url, wantStatus(http.StatusOK, http.StatusAccepted)) + // Required for c.accountKID() when in RFC mode. + dir, err := c.Discover(ctx) + if err != nil { + return nil, err + } + + getfn := c.postAsGet + if !dir.rfcCompliant() { + getfn = c.get + } + res, err := getfn(ctx, url, wantStatus(http.StatusOK, http.StatusAccepted)) if err != nil { return nil, err } + defer res.Body.Close() v := wireChallenge{URI: url} if err := json.NewDecoder(res.Body).Decode(&v); err != nil { @@ -590,23 +643,26 @@ func (c *Client) GetChallenge(ctx context.Context, url string) (*Challenge, erro // The server will then perform the validation asynchronously. func (c *Client) Accept(ctx context.Context, chal *Challenge) (*Challenge, error) { // Required for c.accountKID() when in RFC mode. - if _, err := c.Discover(ctx); err != nil { - return nil, err - } - - auth, err := keyAuth(c.Key.Public(), chal.Token) + dir, err := c.Discover(ctx) if err != nil { return nil, err } - req := struct { - Resource string `json:"resource"` - Type string `json:"type"` - Auth string `json:"keyAuthorization"` - }{ - Resource: "challenge", - Type: chal.Type, - Auth: auth, + var req interface{} = json.RawMessage("{}") // RFC-compliant CA + if !dir.rfcCompliant() { + auth, err := keyAuth(c.Key.Public(), chal.Token) + if err != nil { + return nil, err + } + req = struct { + Resource string `json:"resource"` + Type string `json:"type"` + Auth string `json:"keyAuthorization"` + }{ + Resource: "challenge", + Type: chal.Type, + Auth: auth, + } } res, err := c.post(ctx, nil, chal.URI, req, wantStatus( http.StatusOK, // according to the spec @@ -658,21 +714,8 @@ func (c *Client) HTTP01ChallengePath(token string) string { } // TLSSNI01ChallengeCert creates a certificate for TLS-SNI-01 challenge response. -// Servers can present the certificate to validate the challenge and prove control -// over a domain name. -// -// The implementation is incomplete in that the returned value is a single certificate, -// computed only for Z0 of the key authorization. ACME CAs are expected to update -// their implementations to use the newer version, TLS-SNI-02. -// For more details on TLS-SNI-01 see https://tools.ietf.org/html/draft-ietf-acme-acme-01#section-7.3. -// -// The token argument is a Challenge.Token value. -// If a WithKey option is provided, its private part signs the returned cert, -// and the public part is used to specify the signee. -// If no WithKey option is provided, a new ECDSA key is generated using P-256 curve. // -// The returned certificate is valid for the next 24 hours and must be presented only when -// the server name of the TLS ClientHello matches exactly the returned name value. +// Deprecated: This challenge type is unused in both draft-02 and RFC versions of ACME spec. func (c *Client) TLSSNI01ChallengeCert(token string, opt ...CertOption) (cert tls.Certificate, name string, err error) { ka, err := keyAuth(c.Key.Public(), token) if err != nil { @@ -689,17 +732,8 @@ func (c *Client) TLSSNI01ChallengeCert(token string, opt ...CertOption) (cert tl } // TLSSNI02ChallengeCert creates a certificate for TLS-SNI-02 challenge response. -// Servers can present the certificate to validate the challenge and prove control -// over a domain name. For more details on TLS-SNI-02 see -// https://tools.ietf.org/html/draft-ietf-acme-acme-03#section-7.3. -// -// The token argument is a Challenge.Token value. -// If a WithKey option is provided, its private part signs the returned cert, -// and the public part is used to specify the signee. -// If no WithKey option is provided, a new ECDSA key is generated using P-256 curve. // -// The returned certificate is valid for the next 24 hours and must be presented only when -// the server name in the TLS ClientHello matches exactly the returned name value. +// Deprecated: This challenge type is unused in both draft-02 and RFC versions of ACME spec. func (c *Client) TLSSNI02ChallengeCert(token string, opt ...CertOption) (cert tls.Certificate, name string, err error) { b := sha256.Sum256([]byte(token)) h := hex.EncodeToString(b[:]) @@ -766,7 +800,7 @@ func (c *Client) TLSALPN01ChallengeCert(token, domain string, opt ...CertOption) return tlsChallengeCert([]string{domain}, newOpt) } -// doReg sends all types of registration requests. +// doReg sends all types of registration requests the old way (pre-RFC world). // The type of request is identified by typ argument, which is a "resource" // in the ACME spec terms. // diff --git a/vendor/golang.org/x/crypto/acme/autocert/autocert.go b/vendor/golang.org/x/crypto/acme/autocert/autocert.go index 5256bc3105ca9..2ea9e23174748 100644 --- a/vendor/golang.org/x/crypto/acme/autocert/autocert.go +++ b/vendor/golang.org/x/crypto/acme/autocert/autocert.go @@ -35,6 +35,9 @@ import ( "golang.org/x/net/idna" ) +// DefaultACMEDirectory is the default ACME Directory URL used when the Manager's Client is nil. +const DefaultACMEDirectory = "https://acme-v02.api.letsencrypt.org/directory" + // createCertRetryAfter is how much time to wait before removing a failed state // entry due to an unsuccessful createCert call. // This is a variable instead of a const for testing. @@ -135,9 +138,10 @@ type Manager struct { // Client is used to perform low-level operations, such as account registration // and requesting new certificates. // - // If Client is nil, a zero-value acme.Client is used with acme.LetsEncryptURL - // as directory endpoint. If the Client.Key is nil, a new ECDSA P-256 key is - // generated and, if Cache is not nil, stored in cache. + // If Client is nil, a zero-value acme.Client is used with DefaultACMEDirectory + // as the directory endpoint. + // If the Client.Key is nil, a new ECDSA P-256 key is generated and, + // if Cache is not nil, stored in cache. // // Mutating the field after the first call of GetCertificate method will have no effect. Client *acme.Client @@ -174,8 +178,8 @@ type Manager struct { renewalMu sync.Mutex renewal map[certKey]*domainRenewal - // tokensMu guards the rest of the fields: tryHTTP01, certTokens and httpTokens. - tokensMu sync.RWMutex + // challengeMu guards tryHTTP01, certTokens and httpTokens. + challengeMu sync.RWMutex // tryHTTP01 indicates whether the Manager should try "http-01" challenge type // during the authorization flow. tryHTTP01 bool @@ -188,6 +192,7 @@ type Manager struct { // and is keyed by the domain name which matches the ClientHello server name. // The entries are stored for the duration of the authorization flow. certTokens map[string]*tls.Certificate + // nowFunc, if not nil, returns the current time. This may be set for // testing purposes. nowFunc func() time.Time @@ -267,8 +272,8 @@ func (m *Manager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, // Check whether this is a token cert requested for TLS-ALPN challenge. if wantsTokenCert(hello) { - m.tokensMu.RLock() - defer m.tokensMu.RUnlock() + m.challengeMu.RLock() + defer m.challengeMu.RUnlock() if cert := m.certTokens[name]; cert != nil { return cert, nil } @@ -376,8 +381,8 @@ func supportsECDSA(hello *tls.ClientHelloInfo) bool { // If HTTPHandler is never called, the Manager will only use the "tls-alpn-01" // challenge for domain verification. func (m *Manager) HTTPHandler(fallback http.Handler) http.Handler { - m.tokensMu.Lock() - defer m.tokensMu.Unlock() + m.challengeMu.Lock() + defer m.challengeMu.Unlock() m.tryHTTP01 = true if fallback == nil { @@ -640,71 +645,64 @@ func (m *Manager) certState(ck certKey) (*certState, error) { // authorizedCert starts the domain ownership verification process and requests a new cert upon success. // The key argument is the certificate private key. func (m *Manager) authorizedCert(ctx context.Context, key crypto.Signer, ck certKey) (der [][]byte, leaf *x509.Certificate, err error) { - client, err := m.acmeClient(ctx) - if err != nil { - return nil, nil, err - } - - if err := m.verify(ctx, client, ck.domain); err != nil { - return nil, nil, err - } csr, err := certRequest(key, ck.domain, m.ExtraExtensions) if err != nil { return nil, nil, err } - der, _, err = client.CreateCert(ctx, csr, 0, true) + + client, err := m.acmeClient(ctx) if err != nil { return nil, nil, err } - leaf, err = validCert(ck, der, key, m.now()) + dir, err := client.Discover(ctx) if err != nil { return nil, nil, err } - return der, leaf, nil -} -// revokePendingAuthz revokes all authorizations idenfied by the elements of uri slice. -// It ignores revocation errors. -func (m *Manager) revokePendingAuthz(ctx context.Context, uri []string) { - client, err := m.acmeClient(ctx) - if err != nil { - return + var chain [][]byte + switch { + // Pre-RFC legacy CA. + case dir.OrderURL == "": + if err := m.verify(ctx, client, ck.domain); err != nil { + return nil, nil, err + } + der, _, err := client.CreateCert(ctx, csr, 0, true) + if err != nil { + return nil, nil, err + } + chain = der + // RFC 8555 compliant CA. + default: + o, err := m.verifyRFC(ctx, client, ck.domain) + if err != nil { + return nil, nil, err + } + der, _, err := client.CreateOrderCert(ctx, o.FinalizeURL, csr, true) + if err != nil { + return nil, nil, err + } + chain = der } - for _, u := range uri { - client.RevokeAuthorization(ctx, u) + leaf, err = validCert(ck, chain, key, m.now()) + if err != nil { + return nil, nil, err } + return chain, leaf, nil } -// verify runs the identifier (domain) authorization flow +// verify runs the identifier (domain) pre-authorization flow for legacy CAs // using each applicable ACME challenge type. func (m *Manager) verify(ctx context.Context, client *acme.Client, domain string) error { - // The list of challenge types we'll try to fulfill - // in this specific order. - challengeTypes := []string{"tls-alpn-01"} - m.tokensMu.RLock() - if m.tryHTTP01 { - challengeTypes = append(challengeTypes, "http-01") - } - m.tokensMu.RUnlock() - - // Keep track of pending authzs and revoke the ones that did not validate. - pendingAuthzs := make(map[string]bool) + // Remove all hanging authorizations to reduce rate limit quotas + // after we're done. + var authzURLs []string defer func() { - var uri []string - for k, pending := range pendingAuthzs { - if pending { - uri = append(uri, k) - } - } - if len(uri) > 0 { - // Use "detached" background context. - // The revocations need not happen in the current verification flow. - go m.revokePendingAuthz(context.Background(), uri) - } + go m.deactivatePendingAuthz(authzURLs) }() // errs accumulates challenge failure errors, printed if all fail errs := make(map[*acme.Challenge]error) + challengeTypes := m.supportedChallengeTypes() var nextTyp int // challengeType index of the next challenge type to try for { // Start domain authorization and get the challenge. @@ -712,6 +710,7 @@ func (m *Manager) verify(ctx context.Context, client *acme.Client, domain string if err != nil { return err } + authzURLs = append(authzURLs, authz.URI) // No point in accepting challenges if the authorization status // is in a final state. switch authz.Status { @@ -721,8 +720,6 @@ func (m *Manager) verify(ctx context.Context, client *acme.Client, domain string return fmt.Errorf("acme/autocert: invalid authorization %q", authz.URI) } - pendingAuthzs[authz.URI] = true - // Pick the next preferred challenge. var chal *acme.Challenge for chal == nil && nextTyp < len(challengeTypes) { @@ -752,11 +749,126 @@ func (m *Manager) verify(ctx context.Context, client *acme.Client, domain string errs[chal] = err continue } - delete(pendingAuthzs, authz.URI) return nil } } +// verifyRFC runs the identifier (domain) order-based authorization flow for RFC compliant CAs +// using each applicable ACME challenge type. +func (m *Manager) verifyRFC(ctx context.Context, client *acme.Client, domain string) (*acme.Order, error) { + // Try each supported challenge type starting with a new order each time. + // The nextTyp index of the next challenge type to try is shared across + // all order authorizations: if we've tried a challenge type once and it didn't work, + // it will most likely not work on another order's authorization either. + challengeTypes := m.supportedChallengeTypes() + nextTyp := 0 // challengeTypes index +AuthorizeOrderLoop: + for { + o, err := client.AuthorizeOrder(ctx, acme.DomainIDs(domain)) + if err != nil { + return nil, err + } + // Remove all hanging authorizations to reduce rate limit quotas + // after we're done. + defer func(urls []string) { + go m.deactivatePendingAuthz(urls) + }(o.AuthzURLs) + + // Check if there's actually anything we need to do. + switch o.Status { + case acme.StatusReady: + // Already authorized. + return o, nil + case acme.StatusPending: + // Continue normal Order-based flow. + default: + return nil, fmt.Errorf("acme/autocert: invalid new order status %q; order URL: %q", o.Status, o.URI) + } + + // Satisfy all pending authorizations. + for _, zurl := range o.AuthzURLs { + z, err := client.GetAuthorization(ctx, zurl) + if err != nil { + return nil, err + } + if z.Status != acme.StatusPending { + // We are interested only in pending authorizations. + continue + } + // Pick the next preferred challenge. + var chal *acme.Challenge + for chal == nil && nextTyp < len(challengeTypes) { + chal = pickChallenge(challengeTypes[nextTyp], z.Challenges) + nextTyp++ + } + if chal == nil { + return nil, fmt.Errorf("acme/autocert: unable to satisfy %q for domain %q: no viable challenge type found", z.URI, domain) + } + // Respond to the challenge and wait for validation result. + cleanup, err := m.fulfill(ctx, client, chal, domain) + if err != nil { + continue AuthorizeOrderLoop + } + defer cleanup() + if _, err := client.Accept(ctx, chal); err != nil { + continue AuthorizeOrderLoop + } + if _, err := client.WaitAuthorization(ctx, z.URI); err != nil { + continue AuthorizeOrderLoop + } + } + + // All authorizations are satisfied. + // Wait for the CA to update the order status. + o, err = client.WaitOrder(ctx, o.URI) + if err != nil { + continue AuthorizeOrderLoop + } + return o, nil + } +} + +func pickChallenge(typ string, chal []*acme.Challenge) *acme.Challenge { + for _, c := range chal { + if c.Type == typ { + return c + } + } + return nil +} + +func (m *Manager) supportedChallengeTypes() []string { + m.challengeMu.RLock() + defer m.challengeMu.RUnlock() + typ := []string{"tls-alpn-01"} + if m.tryHTTP01 { + typ = append(typ, "http-01") + } + return typ +} + +// deactivatePendingAuthz relinquishes all authorizations identified by the elements +// of the provided uri slice which are in "pending" state. +// It ignores revocation errors. +// +// deactivatePendingAuthz takes no context argument and instead runs with its own +// "detached" context because deactivations are done in a goroutine separate from +// that of the main issuance or renewal flow. +func (m *Manager) deactivatePendingAuthz(uri []string) { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + client, err := m.acmeClient(ctx) + if err != nil { + return + } + for _, u := range uri { + z, err := client.GetAuthorization(ctx, u) + if err == nil && z.Status == acme.StatusPending { + client.RevokeAuthorization(ctx, u) + } + } +} + // fulfill provisions a response to the challenge chal. // The cleanup is non-nil only if provisioning succeeded. func (m *Manager) fulfill(ctx context.Context, client *acme.Client, chal *acme.Challenge, domain string) (cleanup func(), err error) { @@ -780,20 +892,11 @@ func (m *Manager) fulfill(ctx context.Context, client *acme.Client, chal *acme.C return nil, fmt.Errorf("acme/autocert: unknown challenge type %q", chal.Type) } -func pickChallenge(typ string, chal []*acme.Challenge) *acme.Challenge { - for _, c := range chal { - if c.Type == typ { - return c - } - } - return nil -} - // putCertToken stores the token certificate with the specified name // in both m.certTokens map and m.Cache. func (m *Manager) putCertToken(ctx context.Context, name string, cert *tls.Certificate) { - m.tokensMu.Lock() - defer m.tokensMu.Unlock() + m.challengeMu.Lock() + defer m.challengeMu.Unlock() if m.certTokens == nil { m.certTokens = make(map[string]*tls.Certificate) } @@ -804,8 +907,8 @@ func (m *Manager) putCertToken(ctx context.Context, name string, cert *tls.Certi // deleteCertToken removes the token certificate with the specified name // from both m.certTokens map and m.Cache. func (m *Manager) deleteCertToken(name string) { - m.tokensMu.Lock() - defer m.tokensMu.Unlock() + m.challengeMu.Lock() + defer m.challengeMu.Unlock() delete(m.certTokens, name) if m.Cache != nil { ck := certKey{domain: name, isToken: true} @@ -816,8 +919,8 @@ func (m *Manager) deleteCertToken(name string) { // httpToken retrieves an existing http-01 token value from an in-memory map // or the optional cache. func (m *Manager) httpToken(ctx context.Context, tokenPath string) ([]byte, error) { - m.tokensMu.RLock() - defer m.tokensMu.RUnlock() + m.challengeMu.RLock() + defer m.challengeMu.RUnlock() if v, ok := m.httpTokens[tokenPath]; ok { return v, nil } @@ -832,8 +935,8 @@ func (m *Manager) httpToken(ctx context.Context, tokenPath string) ([]byte, erro // // It ignores any error returned from Cache.Put. func (m *Manager) putHTTPToken(ctx context.Context, tokenPath, val string) { - m.tokensMu.Lock() - defer m.tokensMu.Unlock() + m.challengeMu.Lock() + defer m.challengeMu.Unlock() if m.httpTokens == nil { m.httpTokens = make(map[string][]byte) } @@ -849,8 +952,8 @@ func (m *Manager) putHTTPToken(ctx context.Context, tokenPath, val string) { // // If m.Cache is non-nil, it blocks until Cache.Delete returns without a timeout. func (m *Manager) deleteHTTPToken(tokenPath string) { - m.tokensMu.Lock() - defer m.tokensMu.Unlock() + m.challengeMu.Lock() + defer m.challengeMu.Unlock() delete(m.httpTokens, tokenPath) if m.Cache != nil { m.Cache.Delete(context.Background(), httpTokenCacheKey(tokenPath)) @@ -949,7 +1052,7 @@ func (m *Manager) acmeClient(ctx context.Context) (*acme.Client, error) { client := m.Client if client == nil { - client = &acme.Client{DirectoryURL: acme.LetsEncryptURL} + client = &acme.Client{DirectoryURL: DefaultACMEDirectory} } if client.Key == nil { var err error @@ -967,14 +1070,23 @@ func (m *Manager) acmeClient(ctx context.Context) (*acme.Client, error) { } a := &acme.Account{Contact: contact} _, err := client.Register(ctx, a, m.Prompt) - if ae, ok := err.(*acme.Error); err == nil || ok && ae.StatusCode == http.StatusConflict { - // conflict indicates the key is already registered + if err == nil || isAccountAlreadyExist(err) { m.client = client err = nil } return m.client, err } +// isAccountAlreadyExist reports whether the err, as returned from acme.Client.Register, +// indicates the account has already been registered. +func isAccountAlreadyExist(err error) bool { + if err == acme.ErrAccountAlreadyExists { + return true + } + ae, ok := err.(*acme.Error) + return ok && ae.StatusCode == http.StatusConflict +} + func (m *Manager) hostPolicy() HostPolicy { if m.HostPolicy != nil { return m.HostPolicy diff --git a/vendor/golang.org/x/crypto/acme/http.go b/vendor/golang.org/x/crypto/acme/http.go index b145292f9e968..c51943e71a420 100644 --- a/vendor/golang.org/x/crypto/acme/http.go +++ b/vendor/golang.org/x/crypto/acme/http.go @@ -155,6 +155,14 @@ func (c *Client) get(ctx context.Context, url string, ok resOkay) (*http.Respons } } +// postAsGet is POST-as-GET, a replacement for GET in RFC8555 +// as described in https://tools.ietf.org/html/rfc8555#section-6.3. +// It makes a POST request in KID form with zero JWS payload. +// See nopayload doc comments in jws.go. +func (c *Client) postAsGet(ctx context.Context, url string, ok resOkay) (*http.Response, error) { + return c.post(ctx, nil, url, noPayload, ok) +} + // post issues a signed POST request in JWS format using the provided key // to the specified URL. If key is nil, c.Key is used instead. // It returns a non-error value only when ok reports true. @@ -200,7 +208,7 @@ func (c *Client) post(ctx context.Context, key crypto.Signer, url string, body i // If key argument is nil and c.accountKID returns a non-zero keyID, // the request is sent in KID form. Otherwise, JWK form is used. // -// In practice, when interfacing with RFC compliant CAs most requests are sent in KID form +// In practice, when interfacing with RFC-compliant CAs most requests are sent in KID form // and JWK is used only when KID is unavailable: new account endpoint and certificate // revocation requests authenticated by a cert key. // See jwsEncodeJSON for other details. diff --git a/vendor/golang.org/x/crypto/acme/jws.go b/vendor/golang.org/x/crypto/acme/jws.go index f8bc2c467981c..cac8b6786e388 100644 --- a/vendor/golang.org/x/crypto/acme/jws.go +++ b/vendor/golang.org/x/crypto/acme/jws.go @@ -24,6 +24,12 @@ type keyID string // See jwsEncodeJSON for details. const noKeyID = keyID("") +// noPayload indicates jwsEncodeJSON will encode zero-length octet string +// in a JWS request. This is called POST-as-GET in RFC 8555 and is used to make +// authenticated GET requests via POSTing with an empty payload. +// See https://tools.ietf.org/html/rfc8555#section-6.3 for more details. +const noPayload = "" + // jwsEncodeJSON signs claimset using provided key and a nonce. // The result is serialized in JSON format containing either kid or jwk // fields based on the provided keyID value. @@ -50,11 +56,14 @@ func jwsEncodeJSON(claimset interface{}, key crypto.Signer, kid keyID, nonce, ur phead = fmt.Sprintf(`{"alg":%q,"kid":%q,"nonce":%q,"url":%q}`, alg, kid, nonce, url) } phead = base64.RawURLEncoding.EncodeToString([]byte(phead)) - cs, err := json.Marshal(claimset) - if err != nil { - return nil, err + var payload string + if claimset != noPayload { + cs, err := json.Marshal(claimset) + if err != nil { + return nil, err + } + payload = base64.RawURLEncoding.EncodeToString(cs) } - payload := base64.RawURLEncoding.EncodeToString(cs) hash := sha.New() hash.Write([]byte(phead + "." + payload)) sig, err := jwsSign(key, sha, hash.Sum(nil)) diff --git a/vendor/golang.org/x/crypto/acme/rfc8555.go b/vendor/golang.org/x/crypto/acme/rfc8555.go index 51839a0723c7a..dfb57a66fd4be 100644 --- a/vendor/golang.org/x/crypto/acme/rfc8555.go +++ b/vendor/golang.org/x/crypto/acme/rfc8555.go @@ -6,16 +6,23 @@ package acme import ( "context" + "crypto" + "encoding/base64" "encoding/json" + "encoding/pem" + "errors" "fmt" + "io" + "io/ioutil" "net/http" + "time" ) // DeactivateReg permanently disables an existing account associated with c.Key. // A deactivated account can no longer request certificate issuance or access // resources related to the account, such as orders or authorizations. // -// It works only with RFC8555 compliant CAs. +// It only works with CAs implementing RFC 8555. func (c *Client) DeactivateReg(ctx context.Context) error { url := string(c.accountKID(ctx)) if url == "" { @@ -30,7 +37,7 @@ func (c *Client) DeactivateReg(ctx context.Context) error { return nil } -// registerRFC is quivalent to c.Register but for RFC-compliant CAs. +// registerRFC is quivalent to c.Register but for CAs implementing RFC 8555. // It expects c.Discover to have already been called. // TODO: Implement externalAccountBinding. func (c *Client) registerRFC(ctx context.Context, acct *Account, prompt func(tosURL string) bool) (*Account, error) { @@ -68,7 +75,7 @@ func (c *Client) registerRFC(ctx context.Context, acct *Account, prompt func(tos return a, nil } -// updateGegRFC is equivalent to c.UpdateReg but for RFC-compliant CAs. +// updateGegRFC is equivalent to c.UpdateReg but for CAs implementing RFC 8555. // It expects c.Discover to have already been called. func (c *Client) updateRegRFC(ctx context.Context, a *Account) (*Account, error) { url := string(c.accountKID(ctx)) @@ -88,7 +95,7 @@ func (c *Client) updateRegRFC(ctx context.Context, a *Account) (*Account, error) return responseAccount(res) } -// getGegRFC is equivalent to c.GetReg but for RFC-compliant CAs. +// getGegRFC is equivalent to c.GetReg but for CAs implementing RFC 8555. // It expects c.Discover to have already been called. func (c *Client) getRegRFC(ctx context.Context) (*Account, error) { req := json.RawMessage(`{"onlyReturnExisting": true}`) @@ -111,7 +118,7 @@ func responseAccount(res *http.Response) (*Account, error) { Orders string } if err := json.NewDecoder(res.Body).Decode(&v); err != nil { - return nil, fmt.Errorf("acme: invalid response: %v", err) + return nil, fmt.Errorf("acme: invalid account response: %v", err) } return &Account{ URI: res.Header.Get("Location"), @@ -120,3 +127,266 @@ func responseAccount(res *http.Response) (*Account, error) { OrdersURL: v.Orders, }, nil } + +// AuthorizeOrder initiates the order-based application for certificate issuance, +// as opposed to pre-authorization in Authorize. +// It is only supported by CAs implementing RFC 8555. +// +// The caller then needs to fetch each authorization with GetAuthorization, +// identify those with StatusPending status and fulfill a challenge using Accept. +// Once all authorizations are satisfied, the caller will typically want to poll +// order status using WaitOrder until it's in StatusReady state. +// To finalize the order and obtain a certificate, the caller submits a CSR with CreateOrderCert. +func (c *Client) AuthorizeOrder(ctx context.Context, id []AuthzID, opt ...OrderOption) (*Order, error) { + dir, err := c.Discover(ctx) + if err != nil { + return nil, err + } + + req := struct { + Identifiers []wireAuthzID `json:"identifiers"` + NotBefore string `json:"notBefore,omitempty"` + NotAfter string `json:"notAfter,omitempty"` + }{} + for _, v := range id { + req.Identifiers = append(req.Identifiers, wireAuthzID{ + Type: v.Type, + Value: v.Value, + }) + } + for _, o := range opt { + switch o := o.(type) { + case orderNotBeforeOpt: + req.NotBefore = time.Time(o).Format(time.RFC3339) + case orderNotAfterOpt: + req.NotAfter = time.Time(o).Format(time.RFC3339) + default: + // Package's fault if we let this happen. + panic(fmt.Sprintf("unsupported order option type %T", o)) + } + } + + res, err := c.post(ctx, nil, dir.OrderURL, req, wantStatus(http.StatusCreated)) + if err != nil { + return nil, err + } + defer res.Body.Close() + return responseOrder(res) +} + +// GetOrder retrives an order identified by the given URL. +// For orders created with AuthorizeOrder, the url value is Order.URI. +// +// If a caller needs to poll an order until its status is final, +// see the WaitOrder method. +func (c *Client) GetOrder(ctx context.Context, url string) (*Order, error) { + if _, err := c.Discover(ctx); err != nil { + return nil, err + } + + res, err := c.postAsGet(ctx, url, wantStatus(http.StatusOK)) + if err != nil { + return nil, err + } + defer res.Body.Close() + return responseOrder(res) +} + +// WaitOrder polls an order from the given URL until it is in one of the final states, +// StatusReady, StatusValid or StatusInvalid, the CA responded with a non-retryable error +// or the context is done. +// +// It returns a non-nil Order only if its Status is StatusReady or StatusValid. +// In all other cases WaitOrder returns an error. +// If the Status is StatusInvalid, the returned error is of type *OrderError. +func (c *Client) WaitOrder(ctx context.Context, url string) (*Order, error) { + if _, err := c.Discover(ctx); err != nil { + return nil, err + } + for { + res, err := c.postAsGet(ctx, url, wantStatus(http.StatusOK)) + if err != nil { + return nil, err + } + o, err := responseOrder(res) + res.Body.Close() + switch { + case err != nil: + // Skip and retry. + case o.Status == StatusInvalid: + return nil, &OrderError{OrderURL: o.URI, Status: o.Status} + case o.Status == StatusReady || o.Status == StatusValid: + return o, nil + } + + d := retryAfter(res.Header.Get("Retry-After")) + if d == 0 { + // Default retry-after. + // Same reasoning as in WaitAuthorization. + d = time.Second + } + t := time.NewTimer(d) + select { + case <-ctx.Done(): + t.Stop() + return nil, ctx.Err() + case <-t.C: + // Retry. + } + } +} + +func responseOrder(res *http.Response) (*Order, error) { + var v struct { + Status string + Expires time.Time + Identifiers []wireAuthzID + NotBefore time.Time + NotAfter time.Time + Error *wireError + Authorizations []string + Finalize string + Certificate string + } + if err := json.NewDecoder(res.Body).Decode(&v); err != nil { + return nil, fmt.Errorf("acme: error reading order: %v", err) + } + o := &Order{ + URI: res.Header.Get("Location"), + Status: v.Status, + Expires: v.Expires, + NotBefore: v.NotBefore, + NotAfter: v.NotAfter, + AuthzURLs: v.Authorizations, + FinalizeURL: v.Finalize, + CertURL: v.Certificate, + } + for _, id := range v.Identifiers { + o.Identifiers = append(o.Identifiers, AuthzID{Type: id.Type, Value: id.Value}) + } + if v.Error != nil { + o.Error = v.Error.error(nil /* headers */) + } + return o, nil +} + +// CreateOrderCert submits the CSR (Certificate Signing Request) to a CA at the specified URL. +// The URL is the FinalizeURL field of an Order created with AuthorizeOrder. +// +// If the bundle argument is true, the returned value also contain the CA (issuer) +// certificate chain. Otherwise, only a leaf certificate is returned. +// The returned URL can be used to re-fetch the certificate using FetchCert. +// +// This method is only supported by CAs implementing RFC 8555. See CreateCert for pre-RFC CAs. +// +// CreateOrderCert returns an error if the CA's response is unreasonably large. +// Callers are encouraged to parse the returned value to ensure the certificate is valid and has the expected features. +func (c *Client) CreateOrderCert(ctx context.Context, url string, csr []byte, bundle bool) (der [][]byte, certURL string, err error) { + if _, err := c.Discover(ctx); err != nil { // required by c.accountKID + return nil, "", err + } + + // RFC describes this as "finalize order" request. + req := struct { + CSR string `json:"csr"` + }{ + CSR: base64.RawURLEncoding.EncodeToString(csr), + } + res, err := c.post(ctx, nil, url, req, wantStatus(http.StatusOK)) + if err != nil { + return nil, "", err + } + defer res.Body.Close() + o, err := responseOrder(res) + if err != nil { + return nil, "", err + } + + // Wait for CA to issue the cert if they haven't. + if o.Status != StatusValid { + o, err = c.WaitOrder(ctx, o.URI) + } + if err != nil { + return nil, "", err + } + // The only acceptable status post finalize and WaitOrder is "valid". + if o.Status != StatusValid { + return nil, "", &OrderError{OrderURL: o.URI, Status: o.Status} + } + crt, err := c.fetchCertRFC(ctx, o.CertURL, bundle) + return crt, o.CertURL, err +} + +// fetchCertRFC downloads issued certificate from the given URL. +// It expects the CA to respond with PEM-encoded certificate chain. +// +// The URL argument is the CertURL field of Order. +func (c *Client) fetchCertRFC(ctx context.Context, url string, bundle bool) ([][]byte, error) { + res, err := c.postAsGet(ctx, url, wantStatus(http.StatusOK)) + if err != nil { + return nil, err + } + defer res.Body.Close() + + // Get all the bytes up to a sane maximum. + // Account very roughly for base64 overhead. + const max = maxCertChainSize + maxCertChainSize/33 + b, err := ioutil.ReadAll(io.LimitReader(res.Body, max+1)) + if err != nil { + return nil, fmt.Errorf("acme: fetch cert response stream: %v", err) + } + if len(b) > max { + return nil, errors.New("acme: certificate chain is too big") + } + + // Decode PEM chain. + var chain [][]byte + for { + var p *pem.Block + p, b = pem.Decode(b) + if p == nil { + break + } + if p.Type != "CERTIFICATE" { + return nil, fmt.Errorf("acme: invalid PEM cert type %q", p.Type) + } + + chain = append(chain, p.Bytes) + if !bundle { + return chain, nil + } + if len(chain) > maxChainLen { + return nil, errors.New("acme: certificate chain is too long") + } + } + if len(chain) == 0 { + return nil, errors.New("acme: certificate chain is empty") + } + return chain, nil +} + +// sends a cert revocation request in either JWK form when key is non-nil or KID form otherwise. +func (c *Client) revokeCertRFC(ctx context.Context, key crypto.Signer, cert []byte, reason CRLReasonCode) error { + req := &struct { + Cert string `json:"certificate"` + Reason int `json:"reason"` + }{ + Cert: base64.RawURLEncoding.EncodeToString(cert), + Reason: int(reason), + } + res, err := c.post(ctx, key, c.dir.RevokeURL, req, wantStatus(http.StatusOK)) + if err != nil { + if isAlreadyRevoked(err) { + // Assume it is not an error to revoke an already revoked cert. + return nil + } + return err + } + defer res.Body.Close() + return nil +} + +func isAlreadyRevoked(err error) bool { + e, ok := err.(*Error) + return ok && e.ProblemType == "urn:ietf:params:acme:error:alreadyRevoked" +} diff --git a/vendor/golang.org/x/crypto/acme/types.go b/vendor/golang.org/x/crypto/acme/types.go index 4432afbc21a4b..9c59097a05103 100644 --- a/vendor/golang.org/x/crypto/acme/types.go +++ b/vendor/golang.org/x/crypto/acme/types.go @@ -14,12 +14,15 @@ import ( "time" ) -// ACME server response statuses used to describe Authorization and Challenge states. +// ACME status values of Account, Order, Authorization and Challenge objects. +// See https://tools.ietf.org/html/rfc8555#section-7.1.6 for details. const ( StatusDeactivated = "deactivated" + StatusExpired = "expired" StatusInvalid = "invalid" StatusPending = "pending" StatusProcessing = "processing" + StatusReady = "ready" StatusRevoked = "revoked" StatusUnknown = "unknown" StatusValid = "valid" @@ -102,6 +105,21 @@ func (a *AuthorizationError) Error() string { return fmt.Sprintf("acme: authorization error for %s: %s", a.Identifier, strings.Join(e, "; ")) } +// OrderError is returned from Client's order related methods. +// It indicates the order is unusable and the clients should start over with +// AuthorizeOrder. +// +// The clients can still fetch the order object from CA using GetOrder +// to inspect its state. +type OrderError struct { + OrderURL string + Status string +} + +func (oe *OrderError) Error() string { + return fmt.Sprintf("acme: order %s status: %s", oe.OrderURL, oe.Status) +} + // RateLimit reports whether err represents a rate limit error and // any Retry-After duration returned by the server. // @@ -124,11 +142,11 @@ func RateLimit(err error) (time.Duration, bool) { } // Account is a user account. It is associated with a private key. -// Non-RFC8555 fields are empty when interfacing with a compliant CA. +// Non-RFC 8555 fields are empty when interfacing with a compliant CA. type Account struct { // URI is the account unique ID, which is also a URL used to retrieve // account data from the CA. - // When interfacing with RFC8555-compliant CAs, URI is the "kid" field + // When interfacing with RFC 8555-compliant CAs, URI is the "kid" field // value in JWS signed requests. URI string @@ -138,7 +156,7 @@ type Account struct { Contact []string // Status indicates current account status as returned by the CA. - // Possible values are "valid", "deactivated", and "revoked". + // Possible values are StatusValid, StatusDeactivated, and StatusRevoked. Status string // OrdersURL is a URL from which a list of orders submitted by this account @@ -149,32 +167,32 @@ type Account struct { // A value not matching CurrentTerms indicates that the user hasn't agreed // to the actual Terms of Service of the CA. // - // It is non-RFC8555 compliant. Package users can store the ToS they agree to + // It is non-RFC 8555 compliant. Package users can store the ToS they agree to // during Client's Register call in the prompt callback function. AgreedTerms string // Actual terms of a CA. // - // It is non-RFC8555 compliant. Use Directory's Terms field. + // It is non-RFC 8555 compliant. Use Directory's Terms field. // When a CA updates their terms and requires an account agreement, // a URL at which instructions to do so is available in Error's Instance field. CurrentTerms string // Authz is the authorization URL used to initiate a new authz flow. // - // It is non-RFC8555 compliant. Use Directory's AuthzURL or OrderURL. + // It is non-RFC 8555 compliant. Use Directory's AuthzURL or OrderURL. Authz string // Authorizations is a URI from which a list of authorizations // granted to this account can be fetched via a GET request. // - // It is non-RFC8555 compliant and is obsoleted by OrdersURL. + // It is non-RFC 8555 compliant and is obsoleted by OrdersURL. Authorizations string // Certificates is a URI from which a list of certificates // issued for this account can be fetched via a GET request. // - // It is non-RFC8555 compliant and is obsoleted by OrdersURL. + // It is non-RFC 8555 compliant and is obsoleted by OrdersURL. Certificates string } @@ -185,11 +203,11 @@ type Directory struct { NonceURL string // RegURL is an account endpoint URL, allowing for creating new accounts. - // Pre-RFC8555 CAs also allow modifying existing accounts at this URL. + // Pre-RFC 8555 CAs also allow modifying existing accounts at this URL. RegURL string // OrderURL is used to initiate the certificate issuance flow - // as described in RFC8555. + // as described in RFC 8555. OrderURL string // AuthzURL is used to initiate identifier pre-authorization flow. @@ -197,7 +215,7 @@ type Directory struct { AuthzURL string // CertURL is a new certificate issuance endpoint URL. - // It is non-RFC8555 compliant and is obsoleted by OrderURL. + // It is non-RFC 8555 compliant and is obsoleted by OrderURL. CertURL string // RevokeURL is used to initiate a certificate revocation flow. @@ -223,42 +241,120 @@ type Directory struct { ExternalAccountRequired bool } -// Challenge encodes a returned CA challenge. -// Its Error field may be non-nil if the challenge is part of an Authorization -// with StatusInvalid. -type Challenge struct { - // Type is the challenge type, e.g. "http-01", "tls-sni-02", "dns-01". - Type string +// rfcCompliant reports whether the ACME server implements RFC 8555. +// Note that some servers may have incomplete RFC implementation +// even if the returned value is true. +// If rfcCompliant reports false, the server most likely implements draft-02. +func (d *Directory) rfcCompliant() bool { + return d.OrderURL != "" +} - // URI is where a challenge response can be posted to. +// Order represents a client's request for a certificate. +// It tracks the request flow progress through to issuance. +type Order struct { + // URI uniquely identifies an order. URI string - // Token is a random value that uniquely identifies the challenge. - Token string - - // Status identifies the status of this challenge. + // Status represents the current status of the order. + // It indicates which action the client should take. + // + // Possible values are StatusPending, StatusReady, StatusProcessing, StatusValid and StatusInvalid. + // Pending means the CA does not believe that the client has fulfilled the requirements. + // Ready indicates that the client has fulfilled all the requirements and can submit a CSR + // to obtain a certificate. This is done with Client's CreateOrderCert. + // Processing means the certificate is being issued. + // Valid indicates the CA has issued the certificate. It can be downloaded + // from the Order's CertURL. This is done with Client's FetchCert. + // Invalid means the certificate will not be issued. Users should consider this order + // abandoned. Status string - // Error indicates the reason for an authorization failure - // when this challenge was used. - // The type of a non-nil value is *Error. - Error error + // Expires is the timestamp after which CA considers this order invalid. + Expires time.Time + + // Identifiers contains all identifier objects which the order pertains to. + Identifiers []AuthzID + + // NotBefore is the requested value of the notBefore field in the certificate. + NotBefore time.Time + + // NotAfter is the requested value of the notAfter field in the certificate. + NotAfter time.Time + + // AuthzURLs represents authorizations to complete before a certificate + // for identifiers specified in the order can be issued. + // It also contains unexpired authorizations that the client has completed + // in the past. + // + // Authorization objects can be fetched using Client's GetAuthorization method. + // + // The required authorizations are dictated by CA policies. + // There may not be a 1:1 relationship between the identifiers and required authorizations. + // Required authorizations can be identified by their StatusPending status. + // + // For orders in the StatusValid or StatusInvalid state these are the authorizations + // which were completed. + AuthzURLs []string + + // FinalizeURL is the endpoint at which a CSR is submitted to obtain a certificate + // once all the authorizations are satisfied. + FinalizeURL string + + // CertURL points to the certificate that has been issued in response to this order. + CertURL string + + // The error that occurred while processing the order as received from a CA, if any. + Error *Error +} + +// OrderOption allows customizing Client.AuthorizeOrder call. +type OrderOption interface { + privateOrderOpt() +} + +// WithOrderNotBefore sets order's NotBefore field. +func WithOrderNotBefore(t time.Time) OrderOption { + return orderNotBeforeOpt(t) } +// WithOrderNotAfter sets order's NotAfter field. +func WithOrderNotAfter(t time.Time) OrderOption { + return orderNotAfterOpt(t) +} + +type orderNotBeforeOpt time.Time + +func (orderNotBeforeOpt) privateOrderOpt() {} + +type orderNotAfterOpt time.Time + +func (orderNotAfterOpt) privateOrderOpt() {} + // Authorization encodes an authorization response. type Authorization struct { // URI uniquely identifies a authorization. URI string - // Status identifies the status of an authorization. + // Status is the current status of an authorization. + // Possible values are StatusPending, StatusValid, StatusInvalid, StatusDeactivated, + // StatusExpired and StatusRevoked. Status string // Identifier is what the account is authorized to represent. Identifier AuthzID + // The timestamp after which the CA considers the authorization invalid. + Expires time.Time + + // Wildcard is true for authorizations of a wildcard domain name. + Wildcard bool + // Challenges that the client needs to fulfill in order to prove possession // of the identifier (for pending authorizations). - // For final authorizations, the challenges that were used. + // For valid authorizations, the challenge that was validated. + // For invalid authorizations, the challenge that was attempted and failed. + // + // RFC 8555 compatible CAs require users to fuflfill only one of the challenges. Challenges []*Challenge // A collection of sets of challenges, each of which would be sufficient @@ -266,24 +362,51 @@ type Authorization struct { // Clients must complete a set of challenges that covers at least one set. // Challenges are identified by their indices in the challenges array. // If this field is empty, the client needs to complete all challenges. + // + // This field is unused in RFC 8555. Combinations [][]int } // AuthzID is an identifier that an account is authorized to represent. type AuthzID struct { - Type string // The type of identifier, e.g. "dns". + Type string // The type of identifier, "dns" or "ip". Value string // The identifier itself, e.g. "example.org". } +// DomainIDs creates a slice of AuthzID with "dns" identifier type. +func DomainIDs(names ...string) []AuthzID { + a := make([]AuthzID, len(names)) + for i, v := range names { + a[i] = AuthzID{Type: "dns", Value: v} + } + return a +} + +// IPIDs creates a slice of AuthzID with "ip" identifier type. +// Each element of addr is textual form of an address as defined +// in RFC1123 Section 2.1 for IPv4 and in RFC5952 Section 4 for IPv6. +func IPIDs(addr ...string) []AuthzID { + a := make([]AuthzID, len(addr)) + for i, v := range addr { + a[i] = AuthzID{Type: "ip", Value: v} + } + return a +} + +// wireAuthzID is ACME JSON representation of authorization identifier objects. +type wireAuthzID struct { + Type string `json:"type"` + Value string `json:"value"` +} + // wireAuthz is ACME JSON representation of Authorization objects. type wireAuthz struct { + Identifier wireAuthzID Status string + Expires time.Time + Wildcard bool Challenges []wireChallenge Combinations [][]int - Identifier struct { - Type string - Value string - } } func (z *wireAuthz) authorization(uri string) *Authorization { @@ -291,8 +414,10 @@ func (z *wireAuthz) authorization(uri string) *Authorization { URI: uri, Status: z.Status, Identifier: AuthzID{Type: z.Identifier.Type, Value: z.Identifier.Value}, - Combinations: z.Combinations, // shallow copy + Expires: z.Expires, + Wildcard: z.Wildcard, Challenges: make([]*Challenge, len(z.Challenges)), + Combinations: z.Combinations, // shallow copy } for i, v := range z.Challenges { a.Challenges[i] = v.challenge() @@ -313,22 +438,55 @@ func (z *wireAuthz) error(uri string) *AuthorizationError { return err } +// Challenge encodes a returned CA challenge. +// Its Error field may be non-nil if the challenge is part of an Authorization +// with StatusInvalid. +type Challenge struct { + // Type is the challenge type, e.g. "http-01", "tls-alpn-01", "dns-01". + Type string + + // URI is where a challenge response can be posted to. + URI string + + // Token is a random value that uniquely identifies the challenge. + Token string + + // Status identifies the status of this challenge. + // In RFC 8555, possible values are StatusPending, StatusProcessing, StatusValid, + // and StatusInvalid. + Status string + + // Validated is the time at which the CA validated this challenge. + // Always zero value in pre-RFC 8555. + Validated time.Time + + // Error indicates the reason for an authorization failure + // when this challenge was used. + // The type of a non-nil value is *Error. + Error error +} + // wireChallenge is ACME JSON challenge representation. type wireChallenge struct { - URI string `json:"uri"` - Type string - Token string - Status string - Error *wireError + URL string `json:"url"` // RFC + URI string `json:"uri"` // pre-RFC + Type string + Token string + Status string + Validated time.Time + Error *wireError } func (c *wireChallenge) challenge() *Challenge { v := &Challenge{ - URI: c.URI, + URI: c.URL, Type: c.Type, Token: c.Token, Status: c.Status, } + if v.URI == "" { + v.URI = c.URI // c.URL was empty; use legacy + } if v.Status == "" { v.Status = StatusPending } diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go new file mode 100644 index 0000000000000..87f1e369cc27a --- /dev/null +++ b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go @@ -0,0 +1,17 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.11 +// +build !gccgo,!appengine + +package chacha20 + +const bufSize = 256 + +//go:noescape +func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32) + +func (c *Cipher) xorKeyStreamBlocks(dst, src []byte) { + xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter) +} diff --git a/vendor/golang.org/x/crypto/internal/chacha20/asm_arm64.s b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.s similarity index 100% rename from vendor/golang.org/x/crypto/internal/chacha20/asm_arm64.s rename to vendor/golang.org/x/crypto/chacha20/chacha_arm64.s diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_generic.go b/vendor/golang.org/x/crypto/chacha20/chacha_generic.go new file mode 100644 index 0000000000000..098ec9f6be06c --- /dev/null +++ b/vendor/golang.org/x/crypto/chacha20/chacha_generic.go @@ -0,0 +1,364 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package chacha20 implements the ChaCha20 and XChaCha20 encryption algorithms +// as specified in RFC 8439 and draft-irtf-cfrg-xchacha-01. +package chacha20 + +import ( + "crypto/cipher" + "encoding/binary" + "errors" + "math/bits" + + "golang.org/x/crypto/internal/subtle" +) + +const ( + // KeySize is the size of the key used by this cipher, in bytes. + KeySize = 32 + + // NonceSize is the size of the nonce used with the standard variant of this + // cipher, in bytes. + // + // Note that this is too short to be safely generated at random if the same + // key is reused more than 2³² times. + NonceSize = 12 + + // NonceSizeX is the size of the nonce used with the XChaCha20 variant of + // this cipher, in bytes. + NonceSizeX = 24 +) + +// Cipher is a stateful instance of ChaCha20 or XChaCha20 using a particular key +// and nonce. A *Cipher implements the cipher.Stream interface. +type Cipher struct { + // The ChaCha20 state is 16 words: 4 constant, 8 of key, 1 of counter + // (incremented after each block), and 3 of nonce. + key [8]uint32 + counter uint32 + nonce [3]uint32 + + // The last len bytes of buf are leftover key stream bytes from the previous + // XORKeyStream invocation. The size of buf depends on how many blocks are + // computed at a time. + buf [bufSize]byte + len int + + // The counter-independent results of the first round are cached after they + // are computed the first time. + precompDone bool + p1, p5, p9, p13 uint32 + p2, p6, p10, p14 uint32 + p3, p7, p11, p15 uint32 +} + +var _ cipher.Stream = (*Cipher)(nil) + +// NewUnauthenticatedCipher creates a new ChaCha20 stream cipher with the given +// 32 bytes key and a 12 or 24 bytes nonce. If a nonce of 24 bytes is provided, +// the XChaCha20 construction will be used. It returns an error if key or nonce +// have any other length. +// +// Note that ChaCha20, like all stream ciphers, is not authenticated and allows +// attackers to silently tamper with the plaintext. For this reason, it is more +// appropriate as a building block than as a standalone encryption mechanism. +// Instead, consider using package golang.org/x/crypto/chacha20poly1305. +func NewUnauthenticatedCipher(key, nonce []byte) (*Cipher, error) { + // This function is split into a wrapper so that the Cipher allocation will + // be inlined, and depending on how the caller uses the return value, won't + // escape to the heap. + c := &Cipher{} + return newUnauthenticatedCipher(c, key, nonce) +} + +func newUnauthenticatedCipher(c *Cipher, key, nonce []byte) (*Cipher, error) { + if len(key) != KeySize { + return nil, errors.New("chacha20: wrong key size") + } + if len(nonce) == NonceSizeX { + // XChaCha20 uses the ChaCha20 core to mix 16 bytes of the nonce into a + // derived key, allowing it to operate on a nonce of 24 bytes. See + // draft-irtf-cfrg-xchacha-01, Section 2.3. + key, _ = HChaCha20(key, nonce[0:16]) + cNonce := make([]byte, NonceSize) + copy(cNonce[4:12], nonce[16:24]) + nonce = cNonce + } else if len(nonce) != NonceSize { + return nil, errors.New("chacha20: wrong nonce size") + } + + c.key = [8]uint32{ + binary.LittleEndian.Uint32(key[0:4]), + binary.LittleEndian.Uint32(key[4:8]), + binary.LittleEndian.Uint32(key[8:12]), + binary.LittleEndian.Uint32(key[12:16]), + binary.LittleEndian.Uint32(key[16:20]), + binary.LittleEndian.Uint32(key[20:24]), + binary.LittleEndian.Uint32(key[24:28]), + binary.LittleEndian.Uint32(key[28:32]), + } + c.nonce = [3]uint32{ + binary.LittleEndian.Uint32(nonce[0:4]), + binary.LittleEndian.Uint32(nonce[4:8]), + binary.LittleEndian.Uint32(nonce[8:12]), + } + return c, nil +} + +// The constant first 4 words of the ChaCha20 state. +const ( + j0 uint32 = 0x61707865 // expa + j1 uint32 = 0x3320646e // nd 3 + j2 uint32 = 0x79622d32 // 2-by + j3 uint32 = 0x6b206574 // te k +) + +const blockSize = 64 + +// quarterRound is the core of ChaCha20. It shuffles the bits of 4 state words. +// It's executed 4 times for each of the 20 ChaCha20 rounds, operating on all 16 +// words each round, in columnar or diagonal groups of 4 at a time. +func quarterRound(a, b, c, d uint32) (uint32, uint32, uint32, uint32) { + a += b + d ^= a + d = bits.RotateLeft32(d, 16) + c += d + b ^= c + b = bits.RotateLeft32(b, 12) + a += b + d ^= a + d = bits.RotateLeft32(d, 8) + c += d + b ^= c + b = bits.RotateLeft32(b, 7) + return a, b, c, d +} + +// XORKeyStream XORs each byte in the given slice with a byte from the +// cipher's key stream. Dst and src must overlap entirely or not at all. +// +// If len(dst) < len(src), XORKeyStream will panic. It is acceptable +// to pass a dst bigger than src, and in that case, XORKeyStream will +// only update dst[:len(src)] and will not touch the rest of dst. +// +// Multiple calls to XORKeyStream behave as if the concatenation of +// the src buffers was passed in a single run. That is, Cipher +// maintains state and does not reset at each XORKeyStream call. +func (s *Cipher) XORKeyStream(dst, src []byte) { + if len(src) == 0 { + return + } + if len(dst) < len(src) { + panic("chacha20: output smaller than input") + } + dst = dst[:len(src)] + if subtle.InexactOverlap(dst, src) { + panic("chacha20: invalid buffer overlap") + } + + // First, drain any remaining key stream from a previous XORKeyStream. + if s.len != 0 { + keyStream := s.buf[bufSize-s.len:] + if len(src) < len(keyStream) { + keyStream = keyStream[:len(src)] + } + _ = src[len(keyStream)-1] // bounds check elimination hint + for i, b := range keyStream { + dst[i] = src[i] ^ b + } + s.len -= len(keyStream) + src = src[len(keyStream):] + dst = dst[len(keyStream):] + } + + const blocksPerBuf = bufSize / blockSize + numBufs := (uint64(len(src)) + bufSize - 1) / bufSize + if uint64(s.counter)+numBufs*blocksPerBuf >= 1<<32 { + panic("chacha20: counter overflow") + } + + // xorKeyStreamBlocks implementations expect input lengths that are a + // multiple of bufSize. Platform-specific ones process multiple blocks at a + // time, so have bufSizes that are a multiple of blockSize. + + rem := len(src) % bufSize + full := len(src) - rem + + if full > 0 { + s.xorKeyStreamBlocks(dst[:full], src[:full]) + } + + // If we have a partial (multi-)block, pad it for xorKeyStreamBlocks, and + // keep the leftover keystream for the next XORKeyStream invocation. + if rem > 0 { + s.buf = [bufSize]byte{} + copy(s.buf[:], src[full:]) + s.xorKeyStreamBlocks(s.buf[:], s.buf[:]) + s.len = bufSize - copy(dst[full:], s.buf[:]) + } +} + +func (s *Cipher) xorKeyStreamBlocksGeneric(dst, src []byte) { + if len(dst) != len(src) || len(dst)%blockSize != 0 { + panic("chacha20: internal error: wrong dst and/or src length") + } + + // To generate each block of key stream, the initial cipher state + // (represented below) is passed through 20 rounds of shuffling, + // alternatively applying quarterRounds by columns (like 1, 5, 9, 13) + // or by diagonals (like 1, 6, 11, 12). + // + // 0:cccccccc 1:cccccccc 2:cccccccc 3:cccccccc + // 4:kkkkkkkk 5:kkkkkkkk 6:kkkkkkkk 7:kkkkkkkk + // 8:kkkkkkkk 9:kkkkkkkk 10:kkkkkkkk 11:kkkkkkkk + // 12:bbbbbbbb 13:nnnnnnnn 14:nnnnnnnn 15:nnnnnnnn + // + // c=constant k=key b=blockcount n=nonce + var ( + c0, c1, c2, c3 = j0, j1, j2, j3 + c4, c5, c6, c7 = s.key[0], s.key[1], s.key[2], s.key[3] + c8, c9, c10, c11 = s.key[4], s.key[5], s.key[6], s.key[7] + _, c13, c14, c15 = s.counter, s.nonce[0], s.nonce[1], s.nonce[2] + ) + + // Three quarters of the first round don't depend on the counter, so we can + // calculate them here, and reuse them for multiple blocks in the loop, and + // for future XORKeyStream invocations. + if !s.precompDone { + s.p1, s.p5, s.p9, s.p13 = quarterRound(c1, c5, c9, c13) + s.p2, s.p6, s.p10, s.p14 = quarterRound(c2, c6, c10, c14) + s.p3, s.p7, s.p11, s.p15 = quarterRound(c3, c7, c11, c15) + s.precompDone = true + } + + for i := 0; i < len(src); i += blockSize { + // The remainder of the first column round. + fcr0, fcr4, fcr8, fcr12 := quarterRound(c0, c4, c8, s.counter) + + // The second diagonal round. + x0, x5, x10, x15 := quarterRound(fcr0, s.p5, s.p10, s.p15) + x1, x6, x11, x12 := quarterRound(s.p1, s.p6, s.p11, fcr12) + x2, x7, x8, x13 := quarterRound(s.p2, s.p7, fcr8, s.p13) + x3, x4, x9, x14 := quarterRound(s.p3, fcr4, s.p9, s.p14) + + // The remaining 18 rounds. + for i := 0; i < 9; i++ { + // Column round. + x0, x4, x8, x12 = quarterRound(x0, x4, x8, x12) + x1, x5, x9, x13 = quarterRound(x1, x5, x9, x13) + x2, x6, x10, x14 = quarterRound(x2, x6, x10, x14) + x3, x7, x11, x15 = quarterRound(x3, x7, x11, x15) + + // Diagonal round. + x0, x5, x10, x15 = quarterRound(x0, x5, x10, x15) + x1, x6, x11, x12 = quarterRound(x1, x6, x11, x12) + x2, x7, x8, x13 = quarterRound(x2, x7, x8, x13) + x3, x4, x9, x14 = quarterRound(x3, x4, x9, x14) + } + + // Finally, add back the initial state to generate the key stream. + x0 += c0 + x1 += c1 + x2 += c2 + x3 += c3 + x4 += c4 + x5 += c5 + x6 += c6 + x7 += c7 + x8 += c8 + x9 += c9 + x10 += c10 + x11 += c11 + x12 += s.counter + x13 += c13 + x14 += c14 + x15 += c15 + + s.counter += 1 + if s.counter == 0 { + panic("chacha20: internal error: counter overflow") + } + + in, out := src[i:], dst[i:] + in, out = in[:blockSize], out[:blockSize] // bounds check elimination hint + + // XOR the key stream with the source and write out the result. + xor(out[0:], in[0:], x0) + xor(out[4:], in[4:], x1) + xor(out[8:], in[8:], x2) + xor(out[12:], in[12:], x3) + xor(out[16:], in[16:], x4) + xor(out[20:], in[20:], x5) + xor(out[24:], in[24:], x6) + xor(out[28:], in[28:], x7) + xor(out[32:], in[32:], x8) + xor(out[36:], in[36:], x9) + xor(out[40:], in[40:], x10) + xor(out[44:], in[44:], x11) + xor(out[48:], in[48:], x12) + xor(out[52:], in[52:], x13) + xor(out[56:], in[56:], x14) + xor(out[60:], in[60:], x15) + } +} + +// HChaCha20 uses the ChaCha20 core to generate a derived key from a 32 bytes +// key and a 16 bytes nonce. It returns an error if key or nonce have any other +// length. It is used as part of the XChaCha20 construction. +func HChaCha20(key, nonce []byte) ([]byte, error) { + // This function is split into a wrapper so that the slice allocation will + // be inlined, and depending on how the caller uses the return value, won't + // escape to the heap. + out := make([]byte, 32) + return hChaCha20(out, key, nonce) +} + +func hChaCha20(out, key, nonce []byte) ([]byte, error) { + if len(key) != KeySize { + return nil, errors.New("chacha20: wrong HChaCha20 key size") + } + if len(nonce) != 16 { + return nil, errors.New("chacha20: wrong HChaCha20 nonce size") + } + + x0, x1, x2, x3 := j0, j1, j2, j3 + x4 := binary.LittleEndian.Uint32(key[0:4]) + x5 := binary.LittleEndian.Uint32(key[4:8]) + x6 := binary.LittleEndian.Uint32(key[8:12]) + x7 := binary.LittleEndian.Uint32(key[12:16]) + x8 := binary.LittleEndian.Uint32(key[16:20]) + x9 := binary.LittleEndian.Uint32(key[20:24]) + x10 := binary.LittleEndian.Uint32(key[24:28]) + x11 := binary.LittleEndian.Uint32(key[28:32]) + x12 := binary.LittleEndian.Uint32(nonce[0:4]) + x13 := binary.LittleEndian.Uint32(nonce[4:8]) + x14 := binary.LittleEndian.Uint32(nonce[8:12]) + x15 := binary.LittleEndian.Uint32(nonce[12:16]) + + for i := 0; i < 10; i++ { + // Diagonal round. + x0, x4, x8, x12 = quarterRound(x0, x4, x8, x12) + x1, x5, x9, x13 = quarterRound(x1, x5, x9, x13) + x2, x6, x10, x14 = quarterRound(x2, x6, x10, x14) + x3, x7, x11, x15 = quarterRound(x3, x7, x11, x15) + + // Column round. + x0, x5, x10, x15 = quarterRound(x0, x5, x10, x15) + x1, x6, x11, x12 = quarterRound(x1, x6, x11, x12) + x2, x7, x8, x13 = quarterRound(x2, x7, x8, x13) + x3, x4, x9, x14 = quarterRound(x3, x4, x9, x14) + } + + _ = out[31] // bounds check elimination hint + binary.LittleEndian.PutUint32(out[0:4], x0) + binary.LittleEndian.PutUint32(out[4:8], x1) + binary.LittleEndian.PutUint32(out[8:12], x2) + binary.LittleEndian.PutUint32(out[12:16], x3) + binary.LittleEndian.PutUint32(out[16:20], x12) + binary.LittleEndian.PutUint32(out[20:24], x13) + binary.LittleEndian.PutUint32(out[24:28], x14) + binary.LittleEndian.PutUint32(out[28:32], x15) + return out, nil +} diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go b/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go new file mode 100644 index 0000000000000..ec609ed868b85 --- /dev/null +++ b/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go @@ -0,0 +1,13 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !arm64,!s390x,!ppc64le arm64,!go1.11 gccgo appengine + +package chacha20 + +const bufSize = blockSize + +func (s *Cipher) xorKeyStreamBlocks(dst, src []byte) { + s.xorKeyStreamBlocksGeneric(dst, src) +} diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go new file mode 100644 index 0000000000000..d0ec61f08d918 --- /dev/null +++ b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go @@ -0,0 +1,16 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !gccgo,!appengine + +package chacha20 + +const bufSize = 256 + +//go:noescape +func chaCha20_ctr32_vsx(out, inp *byte, len int, key *[8]uint32, counter *uint32) + +func (c *Cipher) xorKeyStreamBlocks(dst, src []byte) { + chaCha20_ctr32_vsx(&dst[0], &src[0], len(src), &c.key, &c.counter) +} diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s new file mode 100644 index 0000000000000..533014ea3e8d4 --- /dev/null +++ b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s @@ -0,0 +1,449 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Based on CRYPTOGAMS code with the following comment: +// # ==================================================================== +// # Written by Andy Polyakov for the OpenSSL +// # project. The module is, however, dual licensed under OpenSSL and +// # CRYPTOGAMS licenses depending on where you obtain it. For further +// # details see http://www.openssl.org/~appro/cryptogams/. +// # ==================================================================== + +// Code for the perl script that generates the ppc64 assembler +// can be found in the cryptogams repository at the link below. It is based on +// the original from openssl. + +// https://github.com/dot-asm/cryptogams/commit/a60f5b50ed908e91 + +// The differences in this and the original implementation are +// due to the calling conventions and initialization of constants. + +// +build !gccgo,!appengine + +#include "textflag.h" + +#define OUT R3 +#define INP R4 +#define LEN R5 +#define KEY R6 +#define CNT R7 +#define TMP R15 + +#define CONSTBASE R16 +#define BLOCKS R17 + +DATA consts<>+0x00(SB)/8, $0x3320646e61707865 +DATA consts<>+0x08(SB)/8, $0x6b20657479622d32 +DATA consts<>+0x10(SB)/8, $0x0000000000000001 +DATA consts<>+0x18(SB)/8, $0x0000000000000000 +DATA consts<>+0x20(SB)/8, $0x0000000000000004 +DATA consts<>+0x28(SB)/8, $0x0000000000000000 +DATA consts<>+0x30(SB)/8, $0x0a0b08090e0f0c0d +DATA consts<>+0x38(SB)/8, $0x0203000106070405 +DATA consts<>+0x40(SB)/8, $0x090a0b080d0e0f0c +DATA consts<>+0x48(SB)/8, $0x0102030005060704 +DATA consts<>+0x50(SB)/8, $0x6170786561707865 +DATA consts<>+0x58(SB)/8, $0x6170786561707865 +DATA consts<>+0x60(SB)/8, $0x3320646e3320646e +DATA consts<>+0x68(SB)/8, $0x3320646e3320646e +DATA consts<>+0x70(SB)/8, $0x79622d3279622d32 +DATA consts<>+0x78(SB)/8, $0x79622d3279622d32 +DATA consts<>+0x80(SB)/8, $0x6b2065746b206574 +DATA consts<>+0x88(SB)/8, $0x6b2065746b206574 +DATA consts<>+0x90(SB)/8, $0x0000000100000000 +DATA consts<>+0x98(SB)/8, $0x0000000300000002 +GLOBL consts<>(SB), RODATA, $0xa0 + +//func chaCha20_ctr32_vsx(out, inp *byte, len int, key *[8]uint32, counter *uint32) +TEXT ·chaCha20_ctr32_vsx(SB),NOSPLIT,$64-40 + MOVD out+0(FP), OUT + MOVD inp+8(FP), INP + MOVD len+16(FP), LEN + MOVD key+24(FP), KEY + MOVD counter+32(FP), CNT + + // Addressing for constants + MOVD $consts<>+0x00(SB), CONSTBASE + MOVD $16, R8 + MOVD $32, R9 + MOVD $48, R10 + MOVD $64, R11 + SRD $6, LEN, BLOCKS + // V16 + LXVW4X (CONSTBASE)(R0), VS48 + ADD $80,CONSTBASE + + // Load key into V17,V18 + LXVW4X (KEY)(R0), VS49 + LXVW4X (KEY)(R8), VS50 + + // Load CNT, NONCE into V19 + LXVW4X (CNT)(R0), VS51 + + // Clear V27 + VXOR V27, V27, V27 + + // V28 + LXVW4X (CONSTBASE)(R11), VS60 + + // splat slot from V19 -> V26 + VSPLTW $0, V19, V26 + + VSLDOI $4, V19, V27, V19 + VSLDOI $12, V27, V19, V19 + + VADDUWM V26, V28, V26 + + MOVD $10, R14 + MOVD R14, CTR + +loop_outer_vsx: + // V0, V1, V2, V3 + LXVW4X (R0)(CONSTBASE), VS32 + LXVW4X (R8)(CONSTBASE), VS33 + LXVW4X (R9)(CONSTBASE), VS34 + LXVW4X (R10)(CONSTBASE), VS35 + + // splat values from V17, V18 into V4-V11 + VSPLTW $0, V17, V4 + VSPLTW $1, V17, V5 + VSPLTW $2, V17, V6 + VSPLTW $3, V17, V7 + VSPLTW $0, V18, V8 + VSPLTW $1, V18, V9 + VSPLTW $2, V18, V10 + VSPLTW $3, V18, V11 + + // VOR + VOR V26, V26, V12 + + // splat values from V19 -> V13, V14, V15 + VSPLTW $1, V19, V13 + VSPLTW $2, V19, V14 + VSPLTW $3, V19, V15 + + // splat const values + VSPLTISW $-16, V27 + VSPLTISW $12, V28 + VSPLTISW $8, V29 + VSPLTISW $7, V30 + +loop_vsx: + VADDUWM V0, V4, V0 + VADDUWM V1, V5, V1 + VADDUWM V2, V6, V2 + VADDUWM V3, V7, V3 + + VXOR V12, V0, V12 + VXOR V13, V1, V13 + VXOR V14, V2, V14 + VXOR V15, V3, V15 + + VRLW V12, V27, V12 + VRLW V13, V27, V13 + VRLW V14, V27, V14 + VRLW V15, V27, V15 + + VADDUWM V8, V12, V8 + VADDUWM V9, V13, V9 + VADDUWM V10, V14, V10 + VADDUWM V11, V15, V11 + + VXOR V4, V8, V4 + VXOR V5, V9, V5 + VXOR V6, V10, V6 + VXOR V7, V11, V7 + + VRLW V4, V28, V4 + VRLW V5, V28, V5 + VRLW V6, V28, V6 + VRLW V7, V28, V7 + + VADDUWM V0, V4, V0 + VADDUWM V1, V5, V1 + VADDUWM V2, V6, V2 + VADDUWM V3, V7, V3 + + VXOR V12, V0, V12 + VXOR V13, V1, V13 + VXOR V14, V2, V14 + VXOR V15, V3, V15 + + VRLW V12, V29, V12 + VRLW V13, V29, V13 + VRLW V14, V29, V14 + VRLW V15, V29, V15 + + VADDUWM V8, V12, V8 + VADDUWM V9, V13, V9 + VADDUWM V10, V14, V10 + VADDUWM V11, V15, V11 + + VXOR V4, V8, V4 + VXOR V5, V9, V5 + VXOR V6, V10, V6 + VXOR V7, V11, V7 + + VRLW V4, V30, V4 + VRLW V5, V30, V5 + VRLW V6, V30, V6 + VRLW V7, V30, V7 + + VADDUWM V0, V5, V0 + VADDUWM V1, V6, V1 + VADDUWM V2, V7, V2 + VADDUWM V3, V4, V3 + + VXOR V15, V0, V15 + VXOR V12, V1, V12 + VXOR V13, V2, V13 + VXOR V14, V3, V14 + + VRLW V15, V27, V15 + VRLW V12, V27, V12 + VRLW V13, V27, V13 + VRLW V14, V27, V14 + + VADDUWM V10, V15, V10 + VADDUWM V11, V12, V11 + VADDUWM V8, V13, V8 + VADDUWM V9, V14, V9 + + VXOR V5, V10, V5 + VXOR V6, V11, V6 + VXOR V7, V8, V7 + VXOR V4, V9, V4 + + VRLW V5, V28, V5 + VRLW V6, V28, V6 + VRLW V7, V28, V7 + VRLW V4, V28, V4 + + VADDUWM V0, V5, V0 + VADDUWM V1, V6, V1 + VADDUWM V2, V7, V2 + VADDUWM V3, V4, V3 + + VXOR V15, V0, V15 + VXOR V12, V1, V12 + VXOR V13, V2, V13 + VXOR V14, V3, V14 + + VRLW V15, V29, V15 + VRLW V12, V29, V12 + VRLW V13, V29, V13 + VRLW V14, V29, V14 + + VADDUWM V10, V15, V10 + VADDUWM V11, V12, V11 + VADDUWM V8, V13, V8 + VADDUWM V9, V14, V9 + + VXOR V5, V10, V5 + VXOR V6, V11, V6 + VXOR V7, V8, V7 + VXOR V4, V9, V4 + + VRLW V5, V30, V5 + VRLW V6, V30, V6 + VRLW V7, V30, V7 + VRLW V4, V30, V4 + BC 16, LT, loop_vsx + + VADDUWM V12, V26, V12 + + WORD $0x13600F8C // VMRGEW V0, V1, V27 + WORD $0x13821F8C // VMRGEW V2, V3, V28 + + WORD $0x10000E8C // VMRGOW V0, V1, V0 + WORD $0x10421E8C // VMRGOW V2, V3, V2 + + WORD $0x13A42F8C // VMRGEW V4, V5, V29 + WORD $0x13C63F8C // VMRGEW V6, V7, V30 + + XXPERMDI VS32, VS34, $0, VS33 + XXPERMDI VS32, VS34, $3, VS35 + XXPERMDI VS59, VS60, $0, VS32 + XXPERMDI VS59, VS60, $3, VS34 + + WORD $0x10842E8C // VMRGOW V4, V5, V4 + WORD $0x10C63E8C // VMRGOW V6, V7, V6 + + WORD $0x13684F8C // VMRGEW V8, V9, V27 + WORD $0x138A5F8C // VMRGEW V10, V11, V28 + + XXPERMDI VS36, VS38, $0, VS37 + XXPERMDI VS36, VS38, $3, VS39 + XXPERMDI VS61, VS62, $0, VS36 + XXPERMDI VS61, VS62, $3, VS38 + + WORD $0x11084E8C // VMRGOW V8, V9, V8 + WORD $0x114A5E8C // VMRGOW V10, V11, V10 + + WORD $0x13AC6F8C // VMRGEW V12, V13, V29 + WORD $0x13CE7F8C // VMRGEW V14, V15, V30 + + XXPERMDI VS40, VS42, $0, VS41 + XXPERMDI VS40, VS42, $3, VS43 + XXPERMDI VS59, VS60, $0, VS40 + XXPERMDI VS59, VS60, $3, VS42 + + WORD $0x118C6E8C // VMRGOW V12, V13, V12 + WORD $0x11CE7E8C // VMRGOW V14, V15, V14 + + VSPLTISW $4, V27 + VADDUWM V26, V27, V26 + + XXPERMDI VS44, VS46, $0, VS45 + XXPERMDI VS44, VS46, $3, VS47 + XXPERMDI VS61, VS62, $0, VS44 + XXPERMDI VS61, VS62, $3, VS46 + + VADDUWM V0, V16, V0 + VADDUWM V4, V17, V4 + VADDUWM V8, V18, V8 + VADDUWM V12, V19, V12 + + CMPU LEN, $64 + BLT tail_vsx + + // Bottom of loop + LXVW4X (INP)(R0), VS59 + LXVW4X (INP)(R8), VS60 + LXVW4X (INP)(R9), VS61 + LXVW4X (INP)(R10), VS62 + + VXOR V27, V0, V27 + VXOR V28, V4, V28 + VXOR V29, V8, V29 + VXOR V30, V12, V30 + + STXVW4X VS59, (OUT)(R0) + STXVW4X VS60, (OUT)(R8) + ADD $64, INP + STXVW4X VS61, (OUT)(R9) + ADD $-64, LEN + STXVW4X VS62, (OUT)(R10) + ADD $64, OUT + BEQ done_vsx + + VADDUWM V1, V16, V0 + VADDUWM V5, V17, V4 + VADDUWM V9, V18, V8 + VADDUWM V13, V19, V12 + + CMPU LEN, $64 + BLT tail_vsx + + LXVW4X (INP)(R0), VS59 + LXVW4X (INP)(R8), VS60 + LXVW4X (INP)(R9), VS61 + LXVW4X (INP)(R10), VS62 + VXOR V27, V0, V27 + + VXOR V28, V4, V28 + VXOR V29, V8, V29 + VXOR V30, V12, V30 + + STXVW4X VS59, (OUT)(R0) + STXVW4X VS60, (OUT)(R8) + ADD $64, INP + STXVW4X VS61, (OUT)(R9) + ADD $-64, LEN + STXVW4X VS62, (OUT)(V10) + ADD $64, OUT + BEQ done_vsx + + VADDUWM V2, V16, V0 + VADDUWM V6, V17, V4 + VADDUWM V10, V18, V8 + VADDUWM V14, V19, V12 + + CMPU LEN, $64 + BLT tail_vsx + + LXVW4X (INP)(R0), VS59 + LXVW4X (INP)(R8), VS60 + LXVW4X (INP)(R9), VS61 + LXVW4X (INP)(R10), VS62 + + VXOR V27, V0, V27 + VXOR V28, V4, V28 + VXOR V29, V8, V29 + VXOR V30, V12, V30 + + STXVW4X VS59, (OUT)(R0) + STXVW4X VS60, (OUT)(R8) + ADD $64, INP + STXVW4X VS61, (OUT)(R9) + ADD $-64, LEN + STXVW4X VS62, (OUT)(R10) + ADD $64, OUT + BEQ done_vsx + + VADDUWM V3, V16, V0 + VADDUWM V7, V17, V4 + VADDUWM V11, V18, V8 + VADDUWM V15, V19, V12 + + CMPU LEN, $64 + BLT tail_vsx + + LXVW4X (INP)(R0), VS59 + LXVW4X (INP)(R8), VS60 + LXVW4X (INP)(R9), VS61 + LXVW4X (INP)(R10), VS62 + + VXOR V27, V0, V27 + VXOR V28, V4, V28 + VXOR V29, V8, V29 + VXOR V30, V12, V30 + + STXVW4X VS59, (OUT)(R0) + STXVW4X VS60, (OUT)(R8) + ADD $64, INP + STXVW4X VS61, (OUT)(R9) + ADD $-64, LEN + STXVW4X VS62, (OUT)(R10) + ADD $64, OUT + + MOVD $10, R14 + MOVD R14, CTR + BNE loop_outer_vsx + +done_vsx: + // Increment counter by number of 64 byte blocks + MOVD (CNT), R14 + ADD BLOCKS, R14 + MOVD R14, (CNT) + RET + +tail_vsx: + ADD $32, R1, R11 + MOVD LEN, CTR + + // Save values on stack to copy from + STXVW4X VS32, (R11)(R0) + STXVW4X VS36, (R11)(R8) + STXVW4X VS40, (R11)(R9) + STXVW4X VS44, (R11)(R10) + ADD $-1, R11, R12 + ADD $-1, INP + ADD $-1, OUT + +looptail_vsx: + // Copying the result to OUT + // in bytes. + MOVBZU 1(R12), KEY + MOVBZU 1(INP), TMP + XOR KEY, TMP, KEY + MOVBU KEY, 1(OUT) + BC 16, LT, looptail_vsx + + // Clear the stack values + STXVW4X VS48, (R11)(R0) + STXVW4X VS48, (R11)(R8) + STXVW4X VS48, (R11)(R9) + STXVW4X VS48, (R11)(R10) + BR done_vsx diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go new file mode 100644 index 0000000000000..cd55f45a3337d --- /dev/null +++ b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go @@ -0,0 +1,26 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !gccgo,!appengine + +package chacha20 + +import "golang.org/x/sys/cpu" + +var haveAsm = cpu.S390X.HasVX + +const bufSize = 256 + +// xorKeyStreamVX is an assembly implementation of XORKeyStream. It must only +// be called when the vector facility is available. Implementation in asm_s390x.s. +//go:noescape +func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32) + +func (c *Cipher) xorKeyStreamBlocks(dst, src []byte) { + if cpu.S390X.HasVX { + xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter) + } else { + c.xorKeyStreamBlocksGeneric(dst, src) + } +} diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.s b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.s similarity index 87% rename from vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.s rename to vendor/golang.org/x/crypto/chacha20/chacha_s390x.s index 57df404465c22..de52a2ea8d1b3 100644 --- a/vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.s +++ b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.s @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build s390x,!gccgo,!appengine +// +build !gccgo,!appengine #include "go_asm.h" #include "textflag.h" @@ -24,15 +24,6 @@ DATA ·constants<>+0x14(SB)/4, $0x3320646e DATA ·constants<>+0x18(SB)/4, $0x79622d32 DATA ·constants<>+0x1c(SB)/4, $0x6b206574 -// EXRL targets: -TEXT ·mvcSrcToBuf(SB), NOFRAME|NOSPLIT, $0 - MVC $1, (R1), (R8) - RET - -TEXT ·mvcBufToDst(SB), NOFRAME|NOSPLIT, $0 - MVC $1, (R8), (R9) - RET - #define BSWAP V5 #define J0 V6 #define KEY0 V7 @@ -144,7 +135,7 @@ TEXT ·mvcBufToDst(SB), NOFRAME|NOSPLIT, $0 VMRHF v, w, c \ // c = {a[2], b[2], c[2], d[2]} VMRLF v, w, d // d = {a[3], b[3], c[3], d[3]} -// func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32, buf *[256]byte, len *int) +// func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32) TEXT ·xorKeyStreamVX(SB), NOSPLIT, $0 MOVD $·constants<>(SB), R1 MOVD dst+0(FP), R2 // R2=&dst[0] @@ -152,25 +143,10 @@ TEXT ·xorKeyStreamVX(SB), NOSPLIT, $0 MOVD key+48(FP), R5 // R5=key MOVD nonce+56(FP), R6 // R6=nonce MOVD counter+64(FP), R7 // R7=counter - MOVD buf+72(FP), R8 // R8=buf - MOVD len+80(FP), R9 // R9=len // load BSWAP and J0 VLM (R1), BSWAP, J0 - // set up tail buffer - ADD $-1, R4, R12 - MOVBZ R12, R12 - CMPUBEQ R12, $255, aligned - MOVD R4, R1 - AND $~255, R1 - MOVD $(R3)(R1*1), R1 - EXRL $·mvcSrcToBuf(SB), R12 - MOVD $255, R0 - SUB R12, R0 - MOVD R0, (R9) // update len - -aligned: // setup MOVD $95, R0 VLM (R5), KEY0, KEY1 @@ -217,9 +193,7 @@ loop: // decrement length ADD $-256, R4 - BLT tail -continue: // rearrange vectors SHUFFLE(X0, X1, X2, X3, M0, M1, M2, M3) ADDV(J0, X0, X1, X2, X3) @@ -245,16 +219,6 @@ continue: MOVD $256(R3), R3 CMPBNE R4, $0, chacha - CMPUBEQ R12, $255, return - EXRL $·mvcBufToDst(SB), R12 // len was updated during setup -return: VSTEF $0, CTR, (R7) RET - -tail: - MOVD R2, R9 - MOVD R8, R2 - MOVD R8, R3 - MOVD $0, R4 - JMP continue diff --git a/vendor/golang.org/x/crypto/internal/chacha20/xor.go b/vendor/golang.org/x/crypto/chacha20/xor.go similarity index 98% rename from vendor/golang.org/x/crypto/internal/chacha20/xor.go rename to vendor/golang.org/x/crypto/chacha20/xor.go index 9c5ba0b33ae3a..0110c9865af71 100644 --- a/vendor/golang.org/x/crypto/internal/chacha20/xor.go +++ b/vendor/golang.org/x/crypto/chacha20/xor.go @@ -4,9 +4,7 @@ package chacha20 -import ( - "runtime" -) +import "runtime" // Platforms that have fast unaligned 32-bit little endian accesses. const unaligned = runtime.GOARCH == "386" || diff --git a/vendor/golang.org/x/crypto/curve25519/const_amd64.h b/vendor/golang.org/x/crypto/curve25519/const_amd64.h deleted file mode 100644 index b3f74162f6092..0000000000000 --- a/vendor/golang.org/x/crypto/curve25519/const_amd64.h +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -#define REDMASK51 0x0007FFFFFFFFFFFF diff --git a/vendor/golang.org/x/crypto/curve25519/const_amd64.s b/vendor/golang.org/x/crypto/curve25519/const_amd64.s deleted file mode 100644 index ee7b4bd5f8e33..0000000000000 --- a/vendor/golang.org/x/crypto/curve25519/const_amd64.s +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -// These constants cannot be encoded in non-MOVQ immediates. -// We access them directly from memory instead. - -DATA ·_121666_213(SB)/8, $996687872 -GLOBL ·_121666_213(SB), 8, $8 - -DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA -GLOBL ·_2P0(SB), 8, $8 - -DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE -GLOBL ·_2P1234(SB), 8, $8 diff --git a/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s b/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s deleted file mode 100644 index cd793a5b5f2eb..0000000000000 --- a/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64,!gccgo,!appengine - -// func cswap(inout *[4][5]uint64, v uint64) -TEXT ·cswap(SB),7,$0 - MOVQ inout+0(FP),DI - MOVQ v+8(FP),SI - - SUBQ $1, SI - NOTQ SI - MOVQ SI, X15 - PSHUFD $0x44, X15, X15 - - MOVOU 0(DI), X0 - MOVOU 16(DI), X2 - MOVOU 32(DI), X4 - MOVOU 48(DI), X6 - MOVOU 64(DI), X8 - MOVOU 80(DI), X1 - MOVOU 96(DI), X3 - MOVOU 112(DI), X5 - MOVOU 128(DI), X7 - MOVOU 144(DI), X9 - - MOVO X1, X10 - MOVO X3, X11 - MOVO X5, X12 - MOVO X7, X13 - MOVO X9, X14 - - PXOR X0, X10 - PXOR X2, X11 - PXOR X4, X12 - PXOR X6, X13 - PXOR X8, X14 - PAND X15, X10 - PAND X15, X11 - PAND X15, X12 - PAND X15, X13 - PAND X15, X14 - PXOR X10, X0 - PXOR X10, X1 - PXOR X11, X2 - PXOR X11, X3 - PXOR X12, X4 - PXOR X12, X5 - PXOR X13, X6 - PXOR X13, X7 - PXOR X14, X8 - PXOR X14, X9 - - MOVOU X0, 0(DI) - MOVOU X2, 16(DI) - MOVOU X4, 32(DI) - MOVOU X6, 48(DI) - MOVOU X8, 64(DI) - MOVOU X1, 80(DI) - MOVOU X3, 96(DI) - MOVOU X5, 112(DI) - MOVOU X7, 128(DI) - MOVOU X9, 144(DI) - RET diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519.go b/vendor/golang.org/x/crypto/curve25519/curve25519.go index 75f24babb694b..4b9a655d1b562 100644 --- a/vendor/golang.org/x/crypto/curve25519/curve25519.go +++ b/vendor/golang.org/x/crypto/curve25519/curve25519.go @@ -1,834 +1,95 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// Copyright 2019 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// We have an implementation in amd64 assembly so this code is only run on -// non-amd64 platforms. The amd64 assembly does not support gccgo. -// +build !amd64 gccgo appengine - -package curve25519 +// Package curve25519 provides an implementation of the X25519 function, which +// performs scalar multiplication on the elliptic curve known as Curve25519. +// See RFC 7748. +package curve25519 // import "golang.org/x/crypto/curve25519" import ( - "encoding/binary" + "crypto/subtle" + "fmt" ) -// This code is a port of the public domain, "ref10" implementation of -// curve25519 from SUPERCOP 20130419 by D. J. Bernstein. - -// fieldElement represents an element of the field GF(2^255 - 19). An element -// t, entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77 -// t[3]+2^102 t[4]+...+2^230 t[9]. Bounds on each t[i] vary depending on -// context. -type fieldElement [10]int32 - -func feZero(fe *fieldElement) { - for i := range fe { - fe[i] = 0 - } -} - -func feOne(fe *fieldElement) { - feZero(fe) - fe[0] = 1 -} - -func feAdd(dst, a, b *fieldElement) { - for i := range dst { - dst[i] = a[i] + b[i] - } -} - -func feSub(dst, a, b *fieldElement) { - for i := range dst { - dst[i] = a[i] - b[i] - } -} - -func feCopy(dst, src *fieldElement) { - for i := range dst { - dst[i] = src[i] - } -} - -// feCSwap replaces (f,g) with (g,f) if b == 1; replaces (f,g) with (f,g) if b == 0. -// -// Preconditions: b in {0,1}. -func feCSwap(f, g *fieldElement, b int32) { - b = -b - for i := range f { - t := b & (f[i] ^ g[i]) - f[i] ^= t - g[i] ^= t - } -} - -// load3 reads a 24-bit, little-endian value from in. -func load3(in []byte) int64 { - var r int64 - r = int64(in[0]) - r |= int64(in[1]) << 8 - r |= int64(in[2]) << 16 - return r -} - -// load4 reads a 32-bit, little-endian value from in. -func load4(in []byte) int64 { - return int64(binary.LittleEndian.Uint32(in)) -} - -func feFromBytes(dst *fieldElement, src *[32]byte) { - h0 := load4(src[:]) - h1 := load3(src[4:]) << 6 - h2 := load3(src[7:]) << 5 - h3 := load3(src[10:]) << 3 - h4 := load3(src[13:]) << 2 - h5 := load4(src[16:]) - h6 := load3(src[20:]) << 7 - h7 := load3(src[23:]) << 5 - h8 := load3(src[26:]) << 4 - h9 := (load3(src[29:]) & 0x7fffff) << 2 - - var carry [10]int64 - carry[9] = (h9 + 1<<24) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 - carry[1] = (h1 + 1<<24) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[3] = (h3 + 1<<24) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[5] = (h5 + 1<<24) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - carry[7] = (h7 + 1<<24) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 - - carry[0] = (h0 + 1<<25) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[2] = (h2 + 1<<25) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[4] = (h4 + 1<<25) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[6] = (h6 + 1<<25) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - carry[8] = (h8 + 1<<25) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 - - dst[0] = int32(h0) - dst[1] = int32(h1) - dst[2] = int32(h2) - dst[3] = int32(h3) - dst[4] = int32(h4) - dst[5] = int32(h5) - dst[6] = int32(h6) - dst[7] = int32(h7) - dst[8] = int32(h8) - dst[9] = int32(h9) -} - -// feToBytes marshals h to s. -// Preconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -// -// Write p=2^255-19; q=floor(h/p). -// Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))). -// -// Proof: -// Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4. -// Also have |h-2^230 h9|<2^230 so |19 2^(-255)(h-2^230 h9)|<1/4. -// -// Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9). -// Then 0> 25 - q = (h[0] + q) >> 26 - q = (h[1] + q) >> 25 - q = (h[2] + q) >> 26 - q = (h[3] + q) >> 25 - q = (h[4] + q) >> 26 - q = (h[5] + q) >> 25 - q = (h[6] + q) >> 26 - q = (h[7] + q) >> 25 - q = (h[8] + q) >> 26 - q = (h[9] + q) >> 25 - - // Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. - h[0] += 19 * q - // Goal: Output h-2^255 q, which is between 0 and 2^255-20. - - carry[0] = h[0] >> 26 - h[1] += carry[0] - h[0] -= carry[0] << 26 - carry[1] = h[1] >> 25 - h[2] += carry[1] - h[1] -= carry[1] << 25 - carry[2] = h[2] >> 26 - h[3] += carry[2] - h[2] -= carry[2] << 26 - carry[3] = h[3] >> 25 - h[4] += carry[3] - h[3] -= carry[3] << 25 - carry[4] = h[4] >> 26 - h[5] += carry[4] - h[4] -= carry[4] << 26 - carry[5] = h[5] >> 25 - h[6] += carry[5] - h[5] -= carry[5] << 25 - carry[6] = h[6] >> 26 - h[7] += carry[6] - h[6] -= carry[6] << 26 - carry[7] = h[7] >> 25 - h[8] += carry[7] - h[7] -= carry[7] << 25 - carry[8] = h[8] >> 26 - h[9] += carry[8] - h[8] -= carry[8] << 26 - carry[9] = h[9] >> 25 - h[9] -= carry[9] << 25 - // h10 = carry9 - - // Goal: Output h[0]+...+2^255 h10-2^255 q, which is between 0 and 2^255-20. - // Have h[0]+...+2^230 h[9] between 0 and 2^255-1; - // evidently 2^255 h10-2^255 q = 0. - // Goal: Output h[0]+...+2^230 h[9]. - - s[0] = byte(h[0] >> 0) - s[1] = byte(h[0] >> 8) - s[2] = byte(h[0] >> 16) - s[3] = byte((h[0] >> 24) | (h[1] << 2)) - s[4] = byte(h[1] >> 6) - s[5] = byte(h[1] >> 14) - s[6] = byte((h[1] >> 22) | (h[2] << 3)) - s[7] = byte(h[2] >> 5) - s[8] = byte(h[2] >> 13) - s[9] = byte((h[2] >> 21) | (h[3] << 5)) - s[10] = byte(h[3] >> 3) - s[11] = byte(h[3] >> 11) - s[12] = byte((h[3] >> 19) | (h[4] << 6)) - s[13] = byte(h[4] >> 2) - s[14] = byte(h[4] >> 10) - s[15] = byte(h[4] >> 18) - s[16] = byte(h[5] >> 0) - s[17] = byte(h[5] >> 8) - s[18] = byte(h[5] >> 16) - s[19] = byte((h[5] >> 24) | (h[6] << 1)) - s[20] = byte(h[6] >> 7) - s[21] = byte(h[6] >> 15) - s[22] = byte((h[6] >> 23) | (h[7] << 3)) - s[23] = byte(h[7] >> 5) - s[24] = byte(h[7] >> 13) - s[25] = byte((h[7] >> 21) | (h[8] << 4)) - s[26] = byte(h[8] >> 4) - s[27] = byte(h[8] >> 12) - s[28] = byte((h[8] >> 20) | (h[9] << 6)) - s[29] = byte(h[9] >> 2) - s[30] = byte(h[9] >> 10) - s[31] = byte(h[9] >> 18) +// Deprecated: when provided a low-order point, ScalarMult will set dst to all +// zeroes, irrespective of the scalar. Instead, use the X25519 function, which +// will return an error. +func ScalarMult(dst, scalar, point *[32]byte) { + scalarMult(dst, scalar, point) } -// feMul calculates h = f * g -// Can overlap h with f or g. -// -// Preconditions: -// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -// |g| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -// -// Postconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -// -// Notes on implementation strategy: -// -// Using schoolbook multiplication. -// Karatsuba would save a little in some cost models. +// ScalarBaseMult sets dst to the product scalar * base where base is the +// standard generator. // -// Most multiplications by 2 and 19 are 32-bit precomputations; -// cheaper than 64-bit postcomputations. -// -// There is one remaining multiplication by 19 in the carry chain; -// one *19 precomputation can be merged into this, -// but the resulting data flow is considerably less clean. -// -// There are 12 carries below. -// 10 of them are 2-way parallelizable and vectorizable. -// Can get away with 11 carries, but then data flow is much deeper. -// -// With tighter constraints on inputs can squeeze carries into int32. -func feMul(h, f, g *fieldElement) { - f0 := f[0] - f1 := f[1] - f2 := f[2] - f3 := f[3] - f4 := f[4] - f5 := f[5] - f6 := f[6] - f7 := f[7] - f8 := f[8] - f9 := f[9] - g0 := g[0] - g1 := g[1] - g2 := g[2] - g3 := g[3] - g4 := g[4] - g5 := g[5] - g6 := g[6] - g7 := g[7] - g8 := g[8] - g9 := g[9] - g1_19 := 19 * g1 // 1.4*2^29 - g2_19 := 19 * g2 // 1.4*2^30; still ok - g3_19 := 19 * g3 - g4_19 := 19 * g4 - g5_19 := 19 * g5 - g6_19 := 19 * g6 - g7_19 := 19 * g7 - g8_19 := 19 * g8 - g9_19 := 19 * g9 - f1_2 := 2 * f1 - f3_2 := 2 * f3 - f5_2 := 2 * f5 - f7_2 := 2 * f7 - f9_2 := 2 * f9 - f0g0 := int64(f0) * int64(g0) - f0g1 := int64(f0) * int64(g1) - f0g2 := int64(f0) * int64(g2) - f0g3 := int64(f0) * int64(g3) - f0g4 := int64(f0) * int64(g4) - f0g5 := int64(f0) * int64(g5) - f0g6 := int64(f0) * int64(g6) - f0g7 := int64(f0) * int64(g7) - f0g8 := int64(f0) * int64(g8) - f0g9 := int64(f0) * int64(g9) - f1g0 := int64(f1) * int64(g0) - f1g1_2 := int64(f1_2) * int64(g1) - f1g2 := int64(f1) * int64(g2) - f1g3_2 := int64(f1_2) * int64(g3) - f1g4 := int64(f1) * int64(g4) - f1g5_2 := int64(f1_2) * int64(g5) - f1g6 := int64(f1) * int64(g6) - f1g7_2 := int64(f1_2) * int64(g7) - f1g8 := int64(f1) * int64(g8) - f1g9_38 := int64(f1_2) * int64(g9_19) - f2g0 := int64(f2) * int64(g0) - f2g1 := int64(f2) * int64(g1) - f2g2 := int64(f2) * int64(g2) - f2g3 := int64(f2) * int64(g3) - f2g4 := int64(f2) * int64(g4) - f2g5 := int64(f2) * int64(g5) - f2g6 := int64(f2) * int64(g6) - f2g7 := int64(f2) * int64(g7) - f2g8_19 := int64(f2) * int64(g8_19) - f2g9_19 := int64(f2) * int64(g9_19) - f3g0 := int64(f3) * int64(g0) - f3g1_2 := int64(f3_2) * int64(g1) - f3g2 := int64(f3) * int64(g2) - f3g3_2 := int64(f3_2) * int64(g3) - f3g4 := int64(f3) * int64(g4) - f3g5_2 := int64(f3_2) * int64(g5) - f3g6 := int64(f3) * int64(g6) - f3g7_38 := int64(f3_2) * int64(g7_19) - f3g8_19 := int64(f3) * int64(g8_19) - f3g9_38 := int64(f3_2) * int64(g9_19) - f4g0 := int64(f4) * int64(g0) - f4g1 := int64(f4) * int64(g1) - f4g2 := int64(f4) * int64(g2) - f4g3 := int64(f4) * int64(g3) - f4g4 := int64(f4) * int64(g4) - f4g5 := int64(f4) * int64(g5) - f4g6_19 := int64(f4) * int64(g6_19) - f4g7_19 := int64(f4) * int64(g7_19) - f4g8_19 := int64(f4) * int64(g8_19) - f4g9_19 := int64(f4) * int64(g9_19) - f5g0 := int64(f5) * int64(g0) - f5g1_2 := int64(f5_2) * int64(g1) - f5g2 := int64(f5) * int64(g2) - f5g3_2 := int64(f5_2) * int64(g3) - f5g4 := int64(f5) * int64(g4) - f5g5_38 := int64(f5_2) * int64(g5_19) - f5g6_19 := int64(f5) * int64(g6_19) - f5g7_38 := int64(f5_2) * int64(g7_19) - f5g8_19 := int64(f5) * int64(g8_19) - f5g9_38 := int64(f5_2) * int64(g9_19) - f6g0 := int64(f6) * int64(g0) - f6g1 := int64(f6) * int64(g1) - f6g2 := int64(f6) * int64(g2) - f6g3 := int64(f6) * int64(g3) - f6g4_19 := int64(f6) * int64(g4_19) - f6g5_19 := int64(f6) * int64(g5_19) - f6g6_19 := int64(f6) * int64(g6_19) - f6g7_19 := int64(f6) * int64(g7_19) - f6g8_19 := int64(f6) * int64(g8_19) - f6g9_19 := int64(f6) * int64(g9_19) - f7g0 := int64(f7) * int64(g0) - f7g1_2 := int64(f7_2) * int64(g1) - f7g2 := int64(f7) * int64(g2) - f7g3_38 := int64(f7_2) * int64(g3_19) - f7g4_19 := int64(f7) * int64(g4_19) - f7g5_38 := int64(f7_2) * int64(g5_19) - f7g6_19 := int64(f7) * int64(g6_19) - f7g7_38 := int64(f7_2) * int64(g7_19) - f7g8_19 := int64(f7) * int64(g8_19) - f7g9_38 := int64(f7_2) * int64(g9_19) - f8g0 := int64(f8) * int64(g0) - f8g1 := int64(f8) * int64(g1) - f8g2_19 := int64(f8) * int64(g2_19) - f8g3_19 := int64(f8) * int64(g3_19) - f8g4_19 := int64(f8) * int64(g4_19) - f8g5_19 := int64(f8) * int64(g5_19) - f8g6_19 := int64(f8) * int64(g6_19) - f8g7_19 := int64(f8) * int64(g7_19) - f8g8_19 := int64(f8) * int64(g8_19) - f8g9_19 := int64(f8) * int64(g9_19) - f9g0 := int64(f9) * int64(g0) - f9g1_38 := int64(f9_2) * int64(g1_19) - f9g2_19 := int64(f9) * int64(g2_19) - f9g3_38 := int64(f9_2) * int64(g3_19) - f9g4_19 := int64(f9) * int64(g4_19) - f9g5_38 := int64(f9_2) * int64(g5_19) - f9g6_19 := int64(f9) * int64(g6_19) - f9g7_38 := int64(f9_2) * int64(g7_19) - f9g8_19 := int64(f9) * int64(g8_19) - f9g9_38 := int64(f9_2) * int64(g9_19) - h0 := f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38 - h1 := f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19 - h2 := f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38 - h3 := f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19 - h4 := f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38 - h5 := f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19 - h6 := f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38 - h7 := f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19 - h8 := f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38 - h9 := f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0 - var carry [10]int64 - - // |h0| <= (1.1*1.1*2^52*(1+19+19+19+19)+1.1*1.1*2^50*(38+38+38+38+38)) - // i.e. |h0| <= 1.2*2^59; narrower ranges for h2, h4, h6, h8 - // |h1| <= (1.1*1.1*2^51*(1+1+19+19+19+19+19+19+19+19)) - // i.e. |h1| <= 1.5*2^58; narrower ranges for h3, h5, h7, h9 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - // |h0| <= 2^25 - // |h4| <= 2^25 - // |h1| <= 1.51*2^58 - // |h5| <= 1.51*2^58 - - carry[1] = (h1 + (1 << 24)) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[5] = (h5 + (1 << 24)) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - // |h1| <= 2^24; from now on fits into int32 - // |h5| <= 2^24; from now on fits into int32 - // |h2| <= 1.21*2^59 - // |h6| <= 1.21*2^59 - - carry[2] = (h2 + (1 << 25)) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[6] = (h6 + (1 << 25)) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - // |h2| <= 2^25; from now on fits into int32 unchanged - // |h6| <= 2^25; from now on fits into int32 unchanged - // |h3| <= 1.51*2^58 - // |h7| <= 1.51*2^58 - - carry[3] = (h3 + (1 << 24)) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[7] = (h7 + (1 << 24)) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 - // |h3| <= 2^24; from now on fits into int32 unchanged - // |h7| <= 2^24; from now on fits into int32 unchanged - // |h4| <= 1.52*2^33 - // |h8| <= 1.52*2^33 - - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[8] = (h8 + (1 << 25)) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 - // |h4| <= 2^25; from now on fits into int32 unchanged - // |h8| <= 2^25; from now on fits into int32 unchanged - // |h5| <= 1.01*2^24 - // |h9| <= 1.51*2^58 - - carry[9] = (h9 + (1 << 24)) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 - // |h9| <= 2^24; from now on fits into int32 unchanged - // |h0| <= 1.8*2^37 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - // |h0| <= 2^25; from now on fits into int32 unchanged - // |h1| <= 1.01*2^24 - - h[0] = int32(h0) - h[1] = int32(h1) - h[2] = int32(h2) - h[3] = int32(h3) - h[4] = int32(h4) - h[5] = int32(h5) - h[6] = int32(h6) - h[7] = int32(h7) - h[8] = int32(h8) - h[9] = int32(h9) +// It is recommended to use the X25519 function with Basepoint instead, as +// copying into fixed size arrays can lead to unexpected bugs. +func ScalarBaseMult(dst, scalar *[32]byte) { + ScalarMult(dst, scalar, &basePoint) } -// feSquare calculates h = f*f. Can overlap h with f. -// -// Preconditions: -// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -// -// Postconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -func feSquare(h, f *fieldElement) { - f0 := f[0] - f1 := f[1] - f2 := f[2] - f3 := f[3] - f4 := f[4] - f5 := f[5] - f6 := f[6] - f7 := f[7] - f8 := f[8] - f9 := f[9] - f0_2 := 2 * f0 - f1_2 := 2 * f1 - f2_2 := 2 * f2 - f3_2 := 2 * f3 - f4_2 := 2 * f4 - f5_2 := 2 * f5 - f6_2 := 2 * f6 - f7_2 := 2 * f7 - f5_38 := 38 * f5 // 1.31*2^30 - f6_19 := 19 * f6 // 1.31*2^30 - f7_38 := 38 * f7 // 1.31*2^30 - f8_19 := 19 * f8 // 1.31*2^30 - f9_38 := 38 * f9 // 1.31*2^30 - f0f0 := int64(f0) * int64(f0) - f0f1_2 := int64(f0_2) * int64(f1) - f0f2_2 := int64(f0_2) * int64(f2) - f0f3_2 := int64(f0_2) * int64(f3) - f0f4_2 := int64(f0_2) * int64(f4) - f0f5_2 := int64(f0_2) * int64(f5) - f0f6_2 := int64(f0_2) * int64(f6) - f0f7_2 := int64(f0_2) * int64(f7) - f0f8_2 := int64(f0_2) * int64(f8) - f0f9_2 := int64(f0_2) * int64(f9) - f1f1_2 := int64(f1_2) * int64(f1) - f1f2_2 := int64(f1_2) * int64(f2) - f1f3_4 := int64(f1_2) * int64(f3_2) - f1f4_2 := int64(f1_2) * int64(f4) - f1f5_4 := int64(f1_2) * int64(f5_2) - f1f6_2 := int64(f1_2) * int64(f6) - f1f7_4 := int64(f1_2) * int64(f7_2) - f1f8_2 := int64(f1_2) * int64(f8) - f1f9_76 := int64(f1_2) * int64(f9_38) - f2f2 := int64(f2) * int64(f2) - f2f3_2 := int64(f2_2) * int64(f3) - f2f4_2 := int64(f2_2) * int64(f4) - f2f5_2 := int64(f2_2) * int64(f5) - f2f6_2 := int64(f2_2) * int64(f6) - f2f7_2 := int64(f2_2) * int64(f7) - f2f8_38 := int64(f2_2) * int64(f8_19) - f2f9_38 := int64(f2) * int64(f9_38) - f3f3_2 := int64(f3_2) * int64(f3) - f3f4_2 := int64(f3_2) * int64(f4) - f3f5_4 := int64(f3_2) * int64(f5_2) - f3f6_2 := int64(f3_2) * int64(f6) - f3f7_76 := int64(f3_2) * int64(f7_38) - f3f8_38 := int64(f3_2) * int64(f8_19) - f3f9_76 := int64(f3_2) * int64(f9_38) - f4f4 := int64(f4) * int64(f4) - f4f5_2 := int64(f4_2) * int64(f5) - f4f6_38 := int64(f4_2) * int64(f6_19) - f4f7_38 := int64(f4) * int64(f7_38) - f4f8_38 := int64(f4_2) * int64(f8_19) - f4f9_38 := int64(f4) * int64(f9_38) - f5f5_38 := int64(f5) * int64(f5_38) - f5f6_38 := int64(f5_2) * int64(f6_19) - f5f7_76 := int64(f5_2) * int64(f7_38) - f5f8_38 := int64(f5_2) * int64(f8_19) - f5f9_76 := int64(f5_2) * int64(f9_38) - f6f6_19 := int64(f6) * int64(f6_19) - f6f7_38 := int64(f6) * int64(f7_38) - f6f8_38 := int64(f6_2) * int64(f8_19) - f6f9_38 := int64(f6) * int64(f9_38) - f7f7_38 := int64(f7) * int64(f7_38) - f7f8_38 := int64(f7_2) * int64(f8_19) - f7f9_76 := int64(f7_2) * int64(f9_38) - f8f8_19 := int64(f8) * int64(f8_19) - f8f9_38 := int64(f8) * int64(f9_38) - f9f9_38 := int64(f9) * int64(f9_38) - h0 := f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38 - h1 := f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38 - h2 := f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19 - h3 := f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38 - h4 := f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38 - h5 := f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38 - h6 := f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19 - h7 := f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38 - h8 := f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38 - h9 := f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2 - var carry [10]int64 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - - carry[1] = (h1 + (1 << 24)) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[5] = (h5 + (1 << 24)) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - - carry[2] = (h2 + (1 << 25)) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[6] = (h6 + (1 << 25)) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - - carry[3] = (h3 + (1 << 24)) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[7] = (h7 + (1 << 24)) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 +const ( + // ScalarSize is the size of the scalar input to X25519. + ScalarSize = 32 + // PointSize is the size of the point input to X25519. + PointSize = 32 +) - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[8] = (h8 + (1 << 25)) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 +// Basepoint is the canonical Curve25519 generator. +var Basepoint []byte - carry[9] = (h9 + (1 << 24)) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 +var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 +func init() { Basepoint = basePoint[:] } - h[0] = int32(h0) - h[1] = int32(h1) - h[2] = int32(h2) - h[3] = int32(h3) - h[4] = int32(h4) - h[5] = int32(h5) - h[6] = int32(h6) - h[7] = int32(h7) - h[8] = int32(h8) - h[9] = int32(h9) +func checkBasepoint() { + if subtle.ConstantTimeCompare(Basepoint, []byte{ + 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }) != 1 { + panic("curve25519: global Basepoint value was modified") + } } -// feMul121666 calculates h = f * 121666. Can overlap h with f. +// X25519 returns the result of the scalar multiplication (scalar * point), +// according to RFC 7748, Section 5. scalar, point and the return value are +// slices of 32 bytes. // -// Preconditions: -// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// scalar can be generated at random, for example with crypto/rand. point should +// be either Basepoint or the output of another X25519 call. // -// Postconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -func feMul121666(h, f *fieldElement) { - h0 := int64(f[0]) * 121666 - h1 := int64(f[1]) * 121666 - h2 := int64(f[2]) * 121666 - h3 := int64(f[3]) * 121666 - h4 := int64(f[4]) * 121666 - h5 := int64(f[5]) * 121666 - h6 := int64(f[6]) * 121666 - h7 := int64(f[7]) * 121666 - h8 := int64(f[8]) * 121666 - h9 := int64(f[9]) * 121666 - var carry [10]int64 - - carry[9] = (h9 + (1 << 24)) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 - carry[1] = (h1 + (1 << 24)) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[3] = (h3 + (1 << 24)) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[5] = (h5 + (1 << 24)) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - carry[7] = (h7 + (1 << 24)) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[2] = (h2 + (1 << 25)) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[6] = (h6 + (1 << 25)) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - carry[8] = (h8 + (1 << 25)) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 - - h[0] = int32(h0) - h[1] = int32(h1) - h[2] = int32(h2) - h[3] = int32(h3) - h[4] = int32(h4) - h[5] = int32(h5) - h[6] = int32(h6) - h[7] = int32(h7) - h[8] = int32(h8) - h[9] = int32(h9) -} - -// feInvert sets out = z^-1. -func feInvert(out, z *fieldElement) { - var t0, t1, t2, t3 fieldElement - var i int - - feSquare(&t0, z) - for i = 1; i < 1; i++ { - feSquare(&t0, &t0) - } - feSquare(&t1, &t0) - for i = 1; i < 2; i++ { - feSquare(&t1, &t1) - } - feMul(&t1, z, &t1) - feMul(&t0, &t0, &t1) - feSquare(&t2, &t0) - for i = 1; i < 1; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t1, &t2) - feSquare(&t2, &t1) - for i = 1; i < 5; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t2, &t1) - feSquare(&t2, &t1) - for i = 1; i < 10; i++ { - feSquare(&t2, &t2) - } - feMul(&t2, &t2, &t1) - feSquare(&t3, &t2) - for i = 1; i < 20; i++ { - feSquare(&t3, &t3) - } - feMul(&t2, &t3, &t2) - feSquare(&t2, &t2) - for i = 1; i < 10; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t2, &t1) - feSquare(&t2, &t1) - for i = 1; i < 50; i++ { - feSquare(&t2, &t2) - } - feMul(&t2, &t2, &t1) - feSquare(&t3, &t2) - for i = 1; i < 100; i++ { - feSquare(&t3, &t3) - } - feMul(&t2, &t3, &t2) - feSquare(&t2, &t2) - for i = 1; i < 50; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t2, &t1) - feSquare(&t1, &t1) - for i = 1; i < 5; i++ { - feSquare(&t1, &t1) - } - feMul(out, &t1, &t0) +// If point is Basepoint (but not if it's a different slice with the same +// contents) a precomputed implementation might be used for performance. +func X25519(scalar, point []byte) ([]byte, error) { + // Outline the body of function, to let the allocation be inlined in the + // caller, and possibly avoid escaping to the heap. + var dst [32]byte + return x25519(&dst, scalar, point) } -func scalarMult(out, in, base *[32]byte) { - var e [32]byte - - copy(e[:], in[:]) - e[0] &= 248 - e[31] &= 127 - e[31] |= 64 - - var x1, x2, z2, x3, z3, tmp0, tmp1 fieldElement - feFromBytes(&x1, base) - feOne(&x2) - feCopy(&x3, &x1) - feOne(&z3) - - swap := int32(0) - for pos := 254; pos >= 0; pos-- { - b := e[pos/8] >> uint(pos&7) - b &= 1 - swap ^= int32(b) - feCSwap(&x2, &x3, swap) - feCSwap(&z2, &z3, swap) - swap = int32(b) - - feSub(&tmp0, &x3, &z3) - feSub(&tmp1, &x2, &z2) - feAdd(&x2, &x2, &z2) - feAdd(&z2, &x3, &z3) - feMul(&z3, &tmp0, &x2) - feMul(&z2, &z2, &tmp1) - feSquare(&tmp0, &tmp1) - feSquare(&tmp1, &x2) - feAdd(&x3, &z3, &z2) - feSub(&z2, &z3, &z2) - feMul(&x2, &tmp1, &tmp0) - feSub(&tmp1, &tmp1, &tmp0) - feSquare(&z2, &z2) - feMul121666(&z3, &tmp1) - feSquare(&x3, &x3) - feAdd(&tmp0, &tmp0, &z3) - feMul(&z3, &x1, &z2) - feMul(&z2, &tmp1, &tmp0) - } - - feCSwap(&x2, &x3, swap) - feCSwap(&z2, &z3, swap) - - feInvert(&z2, &z2) - feMul(&x2, &x2, &z2) - feToBytes(out, &x2) +func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) { + var in [32]byte + if l := len(scalar); l != 32 { + return nil, fmt.Errorf("bad scalar length: %d, expected %d", l, 32) + } + if l := len(point); l != 32 { + return nil, fmt.Errorf("bad point length: %d, expected %d", l, 32) + } + copy(in[:], scalar) + if &point[0] == &Basepoint[0] { + checkBasepoint() + ScalarBaseMult(dst, &in) + } else { + var base, zero [32]byte + copy(base[:], point) + ScalarMult(dst, &in, &base) + if subtle.ConstantTimeCompare(dst[:], zero[:]) == 1 { + return nil, fmt.Errorf("bad input point: low order point") + } + } + return dst[:], nil } diff --git a/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go b/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go similarity index 99% rename from vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go rename to vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go index 5822bd5338349..5120b779b9b48 100644 --- a/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go +++ b/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64,!gccgo,!appengine +// +build amd64,!gccgo,!appengine,!purego package curve25519 diff --git a/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s b/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.s similarity index 76% rename from vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s rename to vendor/golang.org/x/crypto/curve25519/curve25519_amd64.s index e0ac30c70f11f..0250c8885929d 100644 --- a/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s +++ b/vendor/golang.org/x/crypto/curve25519/curve25519_amd64.s @@ -5,9 +5,84 @@ // This code was translated into a form compatible with 6a from the public // domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html -// +build amd64,!gccgo,!appengine +// +build amd64,!gccgo,!appengine,!purego -#include "const_amd64.h" +#define REDMASK51 0x0007FFFFFFFFFFFF + +// These constants cannot be encoded in non-MOVQ immediates. +// We access them directly from memory instead. + +DATA ·_121666_213(SB)/8, $996687872 +GLOBL ·_121666_213(SB), 8, $8 + +DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA +GLOBL ·_2P0(SB), 8, $8 + +DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE +GLOBL ·_2P1234(SB), 8, $8 + +// func freeze(inout *[5]uint64) +TEXT ·freeze(SB),7,$0-8 + MOVQ inout+0(FP), DI + + MOVQ 0(DI),SI + MOVQ 8(DI),DX + MOVQ 16(DI),CX + MOVQ 24(DI),R8 + MOVQ 32(DI),R9 + MOVQ $REDMASK51,AX + MOVQ AX,R10 + SUBQ $18,R10 + MOVQ $3,R11 +REDUCELOOP: + MOVQ SI,R12 + SHRQ $51,R12 + ANDQ AX,SI + ADDQ R12,DX + MOVQ DX,R12 + SHRQ $51,R12 + ANDQ AX,DX + ADDQ R12,CX + MOVQ CX,R12 + SHRQ $51,R12 + ANDQ AX,CX + ADDQ R12,R8 + MOVQ R8,R12 + SHRQ $51,R12 + ANDQ AX,R8 + ADDQ R12,R9 + MOVQ R9,R12 + SHRQ $51,R12 + ANDQ AX,R9 + IMUL3Q $19,R12,R12 + ADDQ R12,SI + SUBQ $1,R11 + JA REDUCELOOP + MOVQ $1,R12 + CMPQ R10,SI + CMOVQLT R11,R12 + CMPQ AX,DX + CMOVQNE R11,R12 + CMPQ AX,CX + CMOVQNE R11,R12 + CMPQ AX,R8 + CMOVQNE R11,R12 + CMPQ AX,R9 + CMOVQNE R11,R12 + NEGQ R12 + ANDQ R12,AX + ANDQ R12,R10 + SUBQ R10,SI + SUBQ AX,DX + SUBQ AX,CX + SUBQ AX,R8 + SUBQ AX,R9 + MOVQ SI,0(DI) + MOVQ DX,8(DI) + MOVQ CX,16(DI) + MOVQ R8,24(DI) + MOVQ R9,32(DI) + RET // func ladderstep(inout *[5][5]uint64) TEXT ·ladderstep(SB),0,$296-8 @@ -1375,3 +1450,344 @@ TEXT ·ladderstep(SB),0,$296-8 MOVQ AX,104(DI) MOVQ R10,112(DI) RET + +// func cswap(inout *[4][5]uint64, v uint64) +TEXT ·cswap(SB),7,$0 + MOVQ inout+0(FP),DI + MOVQ v+8(FP),SI + + SUBQ $1, SI + NOTQ SI + MOVQ SI, X15 + PSHUFD $0x44, X15, X15 + + MOVOU 0(DI), X0 + MOVOU 16(DI), X2 + MOVOU 32(DI), X4 + MOVOU 48(DI), X6 + MOVOU 64(DI), X8 + MOVOU 80(DI), X1 + MOVOU 96(DI), X3 + MOVOU 112(DI), X5 + MOVOU 128(DI), X7 + MOVOU 144(DI), X9 + + MOVO X1, X10 + MOVO X3, X11 + MOVO X5, X12 + MOVO X7, X13 + MOVO X9, X14 + + PXOR X0, X10 + PXOR X2, X11 + PXOR X4, X12 + PXOR X6, X13 + PXOR X8, X14 + PAND X15, X10 + PAND X15, X11 + PAND X15, X12 + PAND X15, X13 + PAND X15, X14 + PXOR X10, X0 + PXOR X10, X1 + PXOR X11, X2 + PXOR X11, X3 + PXOR X12, X4 + PXOR X12, X5 + PXOR X13, X6 + PXOR X13, X7 + PXOR X14, X8 + PXOR X14, X9 + + MOVOU X0, 0(DI) + MOVOU X2, 16(DI) + MOVOU X4, 32(DI) + MOVOU X6, 48(DI) + MOVOU X8, 64(DI) + MOVOU X1, 80(DI) + MOVOU X3, 96(DI) + MOVOU X5, 112(DI) + MOVOU X7, 128(DI) + MOVOU X9, 144(DI) + RET + +// func mul(dest, a, b *[5]uint64) +TEXT ·mul(SB),0,$16-24 + MOVQ dest+0(FP), DI + MOVQ a+8(FP), SI + MOVQ b+16(FP), DX + + MOVQ DX,CX + MOVQ 24(SI),DX + IMUL3Q $19,DX,AX + MOVQ AX,0(SP) + MULQ 16(CX) + MOVQ AX,R8 + MOVQ DX,R9 + MOVQ 32(SI),DX + IMUL3Q $19,DX,AX + MOVQ AX,8(SP) + MULQ 8(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 0(SI),AX + MULQ 0(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 0(SI),AX + MULQ 8(CX) + MOVQ AX,R10 + MOVQ DX,R11 + MOVQ 0(SI),AX + MULQ 16(CX) + MOVQ AX,R12 + MOVQ DX,R13 + MOVQ 0(SI),AX + MULQ 24(CX) + MOVQ AX,R14 + MOVQ DX,R15 + MOVQ 0(SI),AX + MULQ 32(CX) + MOVQ AX,BX + MOVQ DX,BP + MOVQ 8(SI),AX + MULQ 0(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SI),AX + MULQ 8(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 8(SI),AX + MULQ 16(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 8(SI),AX + MULQ 24(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 8(SI),DX + IMUL3Q $19,DX,AX + MULQ 32(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 16(SI),AX + MULQ 0(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 16(SI),AX + MULQ 8(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 16(SI),AX + MULQ 16(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 16(SI),DX + IMUL3Q $19,DX,AX + MULQ 24(CX) + ADDQ AX,R8 + ADCQ DX,R9 + MOVQ 16(SI),DX + IMUL3Q $19,DX,AX + MULQ 32(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 24(SI),AX + MULQ 0(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ 24(SI),AX + MULQ 8(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 0(SP),AX + MULQ 24(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 0(SP),AX + MULQ 32(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 32(SI),AX + MULQ 0(CX) + ADDQ AX,BX + ADCQ DX,BP + MOVQ 8(SP),AX + MULQ 16(CX) + ADDQ AX,R10 + ADCQ DX,R11 + MOVQ 8(SP),AX + MULQ 24(CX) + ADDQ AX,R12 + ADCQ DX,R13 + MOVQ 8(SP),AX + MULQ 32(CX) + ADDQ AX,R14 + ADCQ DX,R15 + MOVQ $REDMASK51,SI + SHLQ $13,R8,R9 + ANDQ SI,R8 + SHLQ $13,R10,R11 + ANDQ SI,R10 + ADDQ R9,R10 + SHLQ $13,R12,R13 + ANDQ SI,R12 + ADDQ R11,R12 + SHLQ $13,R14,R15 + ANDQ SI,R14 + ADDQ R13,R14 + SHLQ $13,BX,BP + ANDQ SI,BX + ADDQ R15,BX + IMUL3Q $19,BP,DX + ADDQ DX,R8 + MOVQ R8,DX + SHRQ $51,DX + ADDQ R10,DX + MOVQ DX,CX + SHRQ $51,DX + ANDQ SI,R8 + ADDQ R12,DX + MOVQ DX,R9 + SHRQ $51,DX + ANDQ SI,CX + ADDQ R14,DX + MOVQ DX,AX + SHRQ $51,DX + ANDQ SI,R9 + ADDQ BX,DX + MOVQ DX,R10 + SHRQ $51,DX + ANDQ SI,AX + IMUL3Q $19,DX,DX + ADDQ DX,R8 + ANDQ SI,R10 + MOVQ R8,0(DI) + MOVQ CX,8(DI) + MOVQ R9,16(DI) + MOVQ AX,24(DI) + MOVQ R10,32(DI) + RET + +// func square(out, in *[5]uint64) +TEXT ·square(SB),7,$0-16 + MOVQ out+0(FP), DI + MOVQ in+8(FP), SI + + MOVQ 0(SI),AX + MULQ 0(SI) + MOVQ AX,CX + MOVQ DX,R8 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 8(SI) + MOVQ AX,R9 + MOVQ DX,R10 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 16(SI) + MOVQ AX,R11 + MOVQ DX,R12 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 24(SI) + MOVQ AX,R13 + MOVQ DX,R14 + MOVQ 0(SI),AX + SHLQ $1,AX + MULQ 32(SI) + MOVQ AX,R15 + MOVQ DX,BX + MOVQ 8(SI),AX + MULQ 8(SI) + ADDQ AX,R11 + ADCQ DX,R12 + MOVQ 8(SI),AX + SHLQ $1,AX + MULQ 16(SI) + ADDQ AX,R13 + ADCQ DX,R14 + MOVQ 8(SI),AX + SHLQ $1,AX + MULQ 24(SI) + ADDQ AX,R15 + ADCQ DX,BX + MOVQ 8(SI),DX + IMUL3Q $38,DX,AX + MULQ 32(SI) + ADDQ AX,CX + ADCQ DX,R8 + MOVQ 16(SI),AX + MULQ 16(SI) + ADDQ AX,R15 + ADCQ DX,BX + MOVQ 16(SI),DX + IMUL3Q $38,DX,AX + MULQ 24(SI) + ADDQ AX,CX + ADCQ DX,R8 + MOVQ 16(SI),DX + IMUL3Q $38,DX,AX + MULQ 32(SI) + ADDQ AX,R9 + ADCQ DX,R10 + MOVQ 24(SI),DX + IMUL3Q $19,DX,AX + MULQ 24(SI) + ADDQ AX,R9 + ADCQ DX,R10 + MOVQ 24(SI),DX + IMUL3Q $38,DX,AX + MULQ 32(SI) + ADDQ AX,R11 + ADCQ DX,R12 + MOVQ 32(SI),DX + IMUL3Q $19,DX,AX + MULQ 32(SI) + ADDQ AX,R13 + ADCQ DX,R14 + MOVQ $REDMASK51,SI + SHLQ $13,CX,R8 + ANDQ SI,CX + SHLQ $13,R9,R10 + ANDQ SI,R9 + ADDQ R8,R9 + SHLQ $13,R11,R12 + ANDQ SI,R11 + ADDQ R10,R11 + SHLQ $13,R13,R14 + ANDQ SI,R13 + ADDQ R12,R13 + SHLQ $13,R15,BX + ANDQ SI,R15 + ADDQ R14,R15 + IMUL3Q $19,BX,DX + ADDQ DX,CX + MOVQ CX,DX + SHRQ $51,DX + ADDQ R9,DX + ANDQ SI,CX + MOVQ DX,R8 + SHRQ $51,DX + ADDQ R11,DX + ANDQ SI,R8 + MOVQ DX,R9 + SHRQ $51,DX + ADDQ R13,DX + ANDQ SI,R9 + MOVQ DX,AX + SHRQ $51,DX + ADDQ R15,DX + ANDQ SI,AX + MOVQ DX,R10 + SHRQ $51,DX + IMUL3Q $19,DX,DX + ADDQ DX,CX + ANDQ SI,R10 + MOVQ CX,0(DI) + MOVQ R8,8(DI) + MOVQ R9,16(DI) + MOVQ AX,24(DI) + MOVQ R10,32(DI) + RET diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519_generic.go b/vendor/golang.org/x/crypto/curve25519/curve25519_generic.go new file mode 100644 index 0000000000000..c43b13fc83e70 --- /dev/null +++ b/vendor/golang.org/x/crypto/curve25519/curve25519_generic.go @@ -0,0 +1,828 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package curve25519 + +import "encoding/binary" + +// This code is a port of the public domain, "ref10" implementation of +// curve25519 from SUPERCOP 20130419 by D. J. Bernstein. + +// fieldElement represents an element of the field GF(2^255 - 19). An element +// t, entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77 +// t[3]+2^102 t[4]+...+2^230 t[9]. Bounds on each t[i] vary depending on +// context. +type fieldElement [10]int32 + +func feZero(fe *fieldElement) { + for i := range fe { + fe[i] = 0 + } +} + +func feOne(fe *fieldElement) { + feZero(fe) + fe[0] = 1 +} + +func feAdd(dst, a, b *fieldElement) { + for i := range dst { + dst[i] = a[i] + b[i] + } +} + +func feSub(dst, a, b *fieldElement) { + for i := range dst { + dst[i] = a[i] - b[i] + } +} + +func feCopy(dst, src *fieldElement) { + for i := range dst { + dst[i] = src[i] + } +} + +// feCSwap replaces (f,g) with (g,f) if b == 1; replaces (f,g) with (f,g) if b == 0. +// +// Preconditions: b in {0,1}. +func feCSwap(f, g *fieldElement, b int32) { + b = -b + for i := range f { + t := b & (f[i] ^ g[i]) + f[i] ^= t + g[i] ^= t + } +} + +// load3 reads a 24-bit, little-endian value from in. +func load3(in []byte) int64 { + var r int64 + r = int64(in[0]) + r |= int64(in[1]) << 8 + r |= int64(in[2]) << 16 + return r +} + +// load4 reads a 32-bit, little-endian value from in. +func load4(in []byte) int64 { + return int64(binary.LittleEndian.Uint32(in)) +} + +func feFromBytes(dst *fieldElement, src *[32]byte) { + h0 := load4(src[:]) + h1 := load3(src[4:]) << 6 + h2 := load3(src[7:]) << 5 + h3 := load3(src[10:]) << 3 + h4 := load3(src[13:]) << 2 + h5 := load4(src[16:]) + h6 := load3(src[20:]) << 7 + h7 := load3(src[23:]) << 5 + h8 := load3(src[26:]) << 4 + h9 := (load3(src[29:]) & 0x7fffff) << 2 + + var carry [10]int64 + carry[9] = (h9 + 1<<24) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + carry[1] = (h1 + 1<<24) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[3] = (h3 + 1<<24) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[5] = (h5 + 1<<24) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + carry[7] = (h7 + 1<<24) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + + carry[0] = (h0 + 1<<25) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[2] = (h2 + 1<<25) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[4] = (h4 + 1<<25) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[6] = (h6 + 1<<25) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + carry[8] = (h8 + 1<<25) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + + dst[0] = int32(h0) + dst[1] = int32(h1) + dst[2] = int32(h2) + dst[3] = int32(h3) + dst[4] = int32(h4) + dst[5] = int32(h5) + dst[6] = int32(h6) + dst[7] = int32(h7) + dst[8] = int32(h8) + dst[9] = int32(h9) +} + +// feToBytes marshals h to s. +// Preconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +// +// Write p=2^255-19; q=floor(h/p). +// Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))). +// +// Proof: +// Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4. +// Also have |h-2^230 h9|<2^230 so |19 2^(-255)(h-2^230 h9)|<1/4. +// +// Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9). +// Then 0> 25 + q = (h[0] + q) >> 26 + q = (h[1] + q) >> 25 + q = (h[2] + q) >> 26 + q = (h[3] + q) >> 25 + q = (h[4] + q) >> 26 + q = (h[5] + q) >> 25 + q = (h[6] + q) >> 26 + q = (h[7] + q) >> 25 + q = (h[8] + q) >> 26 + q = (h[9] + q) >> 25 + + // Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. + h[0] += 19 * q + // Goal: Output h-2^255 q, which is between 0 and 2^255-20. + + carry[0] = h[0] >> 26 + h[1] += carry[0] + h[0] -= carry[0] << 26 + carry[1] = h[1] >> 25 + h[2] += carry[1] + h[1] -= carry[1] << 25 + carry[2] = h[2] >> 26 + h[3] += carry[2] + h[2] -= carry[2] << 26 + carry[3] = h[3] >> 25 + h[4] += carry[3] + h[3] -= carry[3] << 25 + carry[4] = h[4] >> 26 + h[5] += carry[4] + h[4] -= carry[4] << 26 + carry[5] = h[5] >> 25 + h[6] += carry[5] + h[5] -= carry[5] << 25 + carry[6] = h[6] >> 26 + h[7] += carry[6] + h[6] -= carry[6] << 26 + carry[7] = h[7] >> 25 + h[8] += carry[7] + h[7] -= carry[7] << 25 + carry[8] = h[8] >> 26 + h[9] += carry[8] + h[8] -= carry[8] << 26 + carry[9] = h[9] >> 25 + h[9] -= carry[9] << 25 + // h10 = carry9 + + // Goal: Output h[0]+...+2^255 h10-2^255 q, which is between 0 and 2^255-20. + // Have h[0]+...+2^230 h[9] between 0 and 2^255-1; + // evidently 2^255 h10-2^255 q = 0. + // Goal: Output h[0]+...+2^230 h[9]. + + s[0] = byte(h[0] >> 0) + s[1] = byte(h[0] >> 8) + s[2] = byte(h[0] >> 16) + s[3] = byte((h[0] >> 24) | (h[1] << 2)) + s[4] = byte(h[1] >> 6) + s[5] = byte(h[1] >> 14) + s[6] = byte((h[1] >> 22) | (h[2] << 3)) + s[7] = byte(h[2] >> 5) + s[8] = byte(h[2] >> 13) + s[9] = byte((h[2] >> 21) | (h[3] << 5)) + s[10] = byte(h[3] >> 3) + s[11] = byte(h[3] >> 11) + s[12] = byte((h[3] >> 19) | (h[4] << 6)) + s[13] = byte(h[4] >> 2) + s[14] = byte(h[4] >> 10) + s[15] = byte(h[4] >> 18) + s[16] = byte(h[5] >> 0) + s[17] = byte(h[5] >> 8) + s[18] = byte(h[5] >> 16) + s[19] = byte((h[5] >> 24) | (h[6] << 1)) + s[20] = byte(h[6] >> 7) + s[21] = byte(h[6] >> 15) + s[22] = byte((h[6] >> 23) | (h[7] << 3)) + s[23] = byte(h[7] >> 5) + s[24] = byte(h[7] >> 13) + s[25] = byte((h[7] >> 21) | (h[8] << 4)) + s[26] = byte(h[8] >> 4) + s[27] = byte(h[8] >> 12) + s[28] = byte((h[8] >> 20) | (h[9] << 6)) + s[29] = byte(h[9] >> 2) + s[30] = byte(h[9] >> 10) + s[31] = byte(h[9] >> 18) +} + +// feMul calculates h = f * g +// Can overlap h with f or g. +// +// Preconditions: +// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// |g| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// +// Postconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +// +// Notes on implementation strategy: +// +// Using schoolbook multiplication. +// Karatsuba would save a little in some cost models. +// +// Most multiplications by 2 and 19 are 32-bit precomputations; +// cheaper than 64-bit postcomputations. +// +// There is one remaining multiplication by 19 in the carry chain; +// one *19 precomputation can be merged into this, +// but the resulting data flow is considerably less clean. +// +// There are 12 carries below. +// 10 of them are 2-way parallelizable and vectorizable. +// Can get away with 11 carries, but then data flow is much deeper. +// +// With tighter constraints on inputs can squeeze carries into int32. +func feMul(h, f, g *fieldElement) { + f0 := f[0] + f1 := f[1] + f2 := f[2] + f3 := f[3] + f4 := f[4] + f5 := f[5] + f6 := f[6] + f7 := f[7] + f8 := f[8] + f9 := f[9] + g0 := g[0] + g1 := g[1] + g2 := g[2] + g3 := g[3] + g4 := g[4] + g5 := g[5] + g6 := g[6] + g7 := g[7] + g8 := g[8] + g9 := g[9] + g1_19 := 19 * g1 // 1.4*2^29 + g2_19 := 19 * g2 // 1.4*2^30; still ok + g3_19 := 19 * g3 + g4_19 := 19 * g4 + g5_19 := 19 * g5 + g6_19 := 19 * g6 + g7_19 := 19 * g7 + g8_19 := 19 * g8 + g9_19 := 19 * g9 + f1_2 := 2 * f1 + f3_2 := 2 * f3 + f5_2 := 2 * f5 + f7_2 := 2 * f7 + f9_2 := 2 * f9 + f0g0 := int64(f0) * int64(g0) + f0g1 := int64(f0) * int64(g1) + f0g2 := int64(f0) * int64(g2) + f0g3 := int64(f0) * int64(g3) + f0g4 := int64(f0) * int64(g4) + f0g5 := int64(f0) * int64(g5) + f0g6 := int64(f0) * int64(g6) + f0g7 := int64(f0) * int64(g7) + f0g8 := int64(f0) * int64(g8) + f0g9 := int64(f0) * int64(g9) + f1g0 := int64(f1) * int64(g0) + f1g1_2 := int64(f1_2) * int64(g1) + f1g2 := int64(f1) * int64(g2) + f1g3_2 := int64(f1_2) * int64(g3) + f1g4 := int64(f1) * int64(g4) + f1g5_2 := int64(f1_2) * int64(g5) + f1g6 := int64(f1) * int64(g6) + f1g7_2 := int64(f1_2) * int64(g7) + f1g8 := int64(f1) * int64(g8) + f1g9_38 := int64(f1_2) * int64(g9_19) + f2g0 := int64(f2) * int64(g0) + f2g1 := int64(f2) * int64(g1) + f2g2 := int64(f2) * int64(g2) + f2g3 := int64(f2) * int64(g3) + f2g4 := int64(f2) * int64(g4) + f2g5 := int64(f2) * int64(g5) + f2g6 := int64(f2) * int64(g6) + f2g7 := int64(f2) * int64(g7) + f2g8_19 := int64(f2) * int64(g8_19) + f2g9_19 := int64(f2) * int64(g9_19) + f3g0 := int64(f3) * int64(g0) + f3g1_2 := int64(f3_2) * int64(g1) + f3g2 := int64(f3) * int64(g2) + f3g3_2 := int64(f3_2) * int64(g3) + f3g4 := int64(f3) * int64(g4) + f3g5_2 := int64(f3_2) * int64(g5) + f3g6 := int64(f3) * int64(g6) + f3g7_38 := int64(f3_2) * int64(g7_19) + f3g8_19 := int64(f3) * int64(g8_19) + f3g9_38 := int64(f3_2) * int64(g9_19) + f4g0 := int64(f4) * int64(g0) + f4g1 := int64(f4) * int64(g1) + f4g2 := int64(f4) * int64(g2) + f4g3 := int64(f4) * int64(g3) + f4g4 := int64(f4) * int64(g4) + f4g5 := int64(f4) * int64(g5) + f4g6_19 := int64(f4) * int64(g6_19) + f4g7_19 := int64(f4) * int64(g7_19) + f4g8_19 := int64(f4) * int64(g8_19) + f4g9_19 := int64(f4) * int64(g9_19) + f5g0 := int64(f5) * int64(g0) + f5g1_2 := int64(f5_2) * int64(g1) + f5g2 := int64(f5) * int64(g2) + f5g3_2 := int64(f5_2) * int64(g3) + f5g4 := int64(f5) * int64(g4) + f5g5_38 := int64(f5_2) * int64(g5_19) + f5g6_19 := int64(f5) * int64(g6_19) + f5g7_38 := int64(f5_2) * int64(g7_19) + f5g8_19 := int64(f5) * int64(g8_19) + f5g9_38 := int64(f5_2) * int64(g9_19) + f6g0 := int64(f6) * int64(g0) + f6g1 := int64(f6) * int64(g1) + f6g2 := int64(f6) * int64(g2) + f6g3 := int64(f6) * int64(g3) + f6g4_19 := int64(f6) * int64(g4_19) + f6g5_19 := int64(f6) * int64(g5_19) + f6g6_19 := int64(f6) * int64(g6_19) + f6g7_19 := int64(f6) * int64(g7_19) + f6g8_19 := int64(f6) * int64(g8_19) + f6g9_19 := int64(f6) * int64(g9_19) + f7g0 := int64(f7) * int64(g0) + f7g1_2 := int64(f7_2) * int64(g1) + f7g2 := int64(f7) * int64(g2) + f7g3_38 := int64(f7_2) * int64(g3_19) + f7g4_19 := int64(f7) * int64(g4_19) + f7g5_38 := int64(f7_2) * int64(g5_19) + f7g6_19 := int64(f7) * int64(g6_19) + f7g7_38 := int64(f7_2) * int64(g7_19) + f7g8_19 := int64(f7) * int64(g8_19) + f7g9_38 := int64(f7_2) * int64(g9_19) + f8g0 := int64(f8) * int64(g0) + f8g1 := int64(f8) * int64(g1) + f8g2_19 := int64(f8) * int64(g2_19) + f8g3_19 := int64(f8) * int64(g3_19) + f8g4_19 := int64(f8) * int64(g4_19) + f8g5_19 := int64(f8) * int64(g5_19) + f8g6_19 := int64(f8) * int64(g6_19) + f8g7_19 := int64(f8) * int64(g7_19) + f8g8_19 := int64(f8) * int64(g8_19) + f8g9_19 := int64(f8) * int64(g9_19) + f9g0 := int64(f9) * int64(g0) + f9g1_38 := int64(f9_2) * int64(g1_19) + f9g2_19 := int64(f9) * int64(g2_19) + f9g3_38 := int64(f9_2) * int64(g3_19) + f9g4_19 := int64(f9) * int64(g4_19) + f9g5_38 := int64(f9_2) * int64(g5_19) + f9g6_19 := int64(f9) * int64(g6_19) + f9g7_38 := int64(f9_2) * int64(g7_19) + f9g8_19 := int64(f9) * int64(g8_19) + f9g9_38 := int64(f9_2) * int64(g9_19) + h0 := f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38 + h1 := f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19 + h2 := f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38 + h3 := f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19 + h4 := f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38 + h5 := f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19 + h6 := f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38 + h7 := f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19 + h8 := f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38 + h9 := f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0 + var carry [10]int64 + + // |h0| <= (1.1*1.1*2^52*(1+19+19+19+19)+1.1*1.1*2^50*(38+38+38+38+38)) + // i.e. |h0| <= 1.2*2^59; narrower ranges for h2, h4, h6, h8 + // |h1| <= (1.1*1.1*2^51*(1+1+19+19+19+19+19+19+19+19)) + // i.e. |h1| <= 1.5*2^58; narrower ranges for h3, h5, h7, h9 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + // |h0| <= 2^25 + // |h4| <= 2^25 + // |h1| <= 1.51*2^58 + // |h5| <= 1.51*2^58 + + carry[1] = (h1 + (1 << 24)) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[5] = (h5 + (1 << 24)) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + // |h1| <= 2^24; from now on fits into int32 + // |h5| <= 2^24; from now on fits into int32 + // |h2| <= 1.21*2^59 + // |h6| <= 1.21*2^59 + + carry[2] = (h2 + (1 << 25)) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[6] = (h6 + (1 << 25)) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + // |h2| <= 2^25; from now on fits into int32 unchanged + // |h6| <= 2^25; from now on fits into int32 unchanged + // |h3| <= 1.51*2^58 + // |h7| <= 1.51*2^58 + + carry[3] = (h3 + (1 << 24)) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[7] = (h7 + (1 << 24)) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + // |h3| <= 2^24; from now on fits into int32 unchanged + // |h7| <= 2^24; from now on fits into int32 unchanged + // |h4| <= 1.52*2^33 + // |h8| <= 1.52*2^33 + + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[8] = (h8 + (1 << 25)) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + // |h4| <= 2^25; from now on fits into int32 unchanged + // |h8| <= 2^25; from now on fits into int32 unchanged + // |h5| <= 1.01*2^24 + // |h9| <= 1.51*2^58 + + carry[9] = (h9 + (1 << 24)) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + // |h9| <= 2^24; from now on fits into int32 unchanged + // |h0| <= 1.8*2^37 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + // |h0| <= 2^25; from now on fits into int32 unchanged + // |h1| <= 1.01*2^24 + + h[0] = int32(h0) + h[1] = int32(h1) + h[2] = int32(h2) + h[3] = int32(h3) + h[4] = int32(h4) + h[5] = int32(h5) + h[6] = int32(h6) + h[7] = int32(h7) + h[8] = int32(h8) + h[9] = int32(h9) +} + +// feSquare calculates h = f*f. Can overlap h with f. +// +// Preconditions: +// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// +// Postconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +func feSquare(h, f *fieldElement) { + f0 := f[0] + f1 := f[1] + f2 := f[2] + f3 := f[3] + f4 := f[4] + f5 := f[5] + f6 := f[6] + f7 := f[7] + f8 := f[8] + f9 := f[9] + f0_2 := 2 * f0 + f1_2 := 2 * f1 + f2_2 := 2 * f2 + f3_2 := 2 * f3 + f4_2 := 2 * f4 + f5_2 := 2 * f5 + f6_2 := 2 * f6 + f7_2 := 2 * f7 + f5_38 := 38 * f5 // 1.31*2^30 + f6_19 := 19 * f6 // 1.31*2^30 + f7_38 := 38 * f7 // 1.31*2^30 + f8_19 := 19 * f8 // 1.31*2^30 + f9_38 := 38 * f9 // 1.31*2^30 + f0f0 := int64(f0) * int64(f0) + f0f1_2 := int64(f0_2) * int64(f1) + f0f2_2 := int64(f0_2) * int64(f2) + f0f3_2 := int64(f0_2) * int64(f3) + f0f4_2 := int64(f0_2) * int64(f4) + f0f5_2 := int64(f0_2) * int64(f5) + f0f6_2 := int64(f0_2) * int64(f6) + f0f7_2 := int64(f0_2) * int64(f7) + f0f8_2 := int64(f0_2) * int64(f8) + f0f9_2 := int64(f0_2) * int64(f9) + f1f1_2 := int64(f1_2) * int64(f1) + f1f2_2 := int64(f1_2) * int64(f2) + f1f3_4 := int64(f1_2) * int64(f3_2) + f1f4_2 := int64(f1_2) * int64(f4) + f1f5_4 := int64(f1_2) * int64(f5_2) + f1f6_2 := int64(f1_2) * int64(f6) + f1f7_4 := int64(f1_2) * int64(f7_2) + f1f8_2 := int64(f1_2) * int64(f8) + f1f9_76 := int64(f1_2) * int64(f9_38) + f2f2 := int64(f2) * int64(f2) + f2f3_2 := int64(f2_2) * int64(f3) + f2f4_2 := int64(f2_2) * int64(f4) + f2f5_2 := int64(f2_2) * int64(f5) + f2f6_2 := int64(f2_2) * int64(f6) + f2f7_2 := int64(f2_2) * int64(f7) + f2f8_38 := int64(f2_2) * int64(f8_19) + f2f9_38 := int64(f2) * int64(f9_38) + f3f3_2 := int64(f3_2) * int64(f3) + f3f4_2 := int64(f3_2) * int64(f4) + f3f5_4 := int64(f3_2) * int64(f5_2) + f3f6_2 := int64(f3_2) * int64(f6) + f3f7_76 := int64(f3_2) * int64(f7_38) + f3f8_38 := int64(f3_2) * int64(f8_19) + f3f9_76 := int64(f3_2) * int64(f9_38) + f4f4 := int64(f4) * int64(f4) + f4f5_2 := int64(f4_2) * int64(f5) + f4f6_38 := int64(f4_2) * int64(f6_19) + f4f7_38 := int64(f4) * int64(f7_38) + f4f8_38 := int64(f4_2) * int64(f8_19) + f4f9_38 := int64(f4) * int64(f9_38) + f5f5_38 := int64(f5) * int64(f5_38) + f5f6_38 := int64(f5_2) * int64(f6_19) + f5f7_76 := int64(f5_2) * int64(f7_38) + f5f8_38 := int64(f5_2) * int64(f8_19) + f5f9_76 := int64(f5_2) * int64(f9_38) + f6f6_19 := int64(f6) * int64(f6_19) + f6f7_38 := int64(f6) * int64(f7_38) + f6f8_38 := int64(f6_2) * int64(f8_19) + f6f9_38 := int64(f6) * int64(f9_38) + f7f7_38 := int64(f7) * int64(f7_38) + f7f8_38 := int64(f7_2) * int64(f8_19) + f7f9_76 := int64(f7_2) * int64(f9_38) + f8f8_19 := int64(f8) * int64(f8_19) + f8f9_38 := int64(f8) * int64(f9_38) + f9f9_38 := int64(f9) * int64(f9_38) + h0 := f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38 + h1 := f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38 + h2 := f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19 + h3 := f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38 + h4 := f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38 + h5 := f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38 + h6 := f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19 + h7 := f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38 + h8 := f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38 + h9 := f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2 + var carry [10]int64 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + + carry[1] = (h1 + (1 << 24)) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[5] = (h5 + (1 << 24)) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + + carry[2] = (h2 + (1 << 25)) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[6] = (h6 + (1 << 25)) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + + carry[3] = (h3 + (1 << 24)) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[7] = (h7 + (1 << 24)) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[8] = (h8 + (1 << 25)) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + + carry[9] = (h9 + (1 << 24)) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + + h[0] = int32(h0) + h[1] = int32(h1) + h[2] = int32(h2) + h[3] = int32(h3) + h[4] = int32(h4) + h[5] = int32(h5) + h[6] = int32(h6) + h[7] = int32(h7) + h[8] = int32(h8) + h[9] = int32(h9) +} + +// feMul121666 calculates h = f * 121666. Can overlap h with f. +// +// Preconditions: +// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. +// +// Postconditions: +// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. +func feMul121666(h, f *fieldElement) { + h0 := int64(f[0]) * 121666 + h1 := int64(f[1]) * 121666 + h2 := int64(f[2]) * 121666 + h3 := int64(f[3]) * 121666 + h4 := int64(f[4]) * 121666 + h5 := int64(f[5]) * 121666 + h6 := int64(f[6]) * 121666 + h7 := int64(f[7]) * 121666 + h8 := int64(f[8]) * 121666 + h9 := int64(f[9]) * 121666 + var carry [10]int64 + + carry[9] = (h9 + (1 << 24)) >> 25 + h0 += carry[9] * 19 + h9 -= carry[9] << 25 + carry[1] = (h1 + (1 << 24)) >> 25 + h2 += carry[1] + h1 -= carry[1] << 25 + carry[3] = (h3 + (1 << 24)) >> 25 + h4 += carry[3] + h3 -= carry[3] << 25 + carry[5] = (h5 + (1 << 24)) >> 25 + h6 += carry[5] + h5 -= carry[5] << 25 + carry[7] = (h7 + (1 << 24)) >> 25 + h8 += carry[7] + h7 -= carry[7] << 25 + + carry[0] = (h0 + (1 << 25)) >> 26 + h1 += carry[0] + h0 -= carry[0] << 26 + carry[2] = (h2 + (1 << 25)) >> 26 + h3 += carry[2] + h2 -= carry[2] << 26 + carry[4] = (h4 + (1 << 25)) >> 26 + h5 += carry[4] + h4 -= carry[4] << 26 + carry[6] = (h6 + (1 << 25)) >> 26 + h7 += carry[6] + h6 -= carry[6] << 26 + carry[8] = (h8 + (1 << 25)) >> 26 + h9 += carry[8] + h8 -= carry[8] << 26 + + h[0] = int32(h0) + h[1] = int32(h1) + h[2] = int32(h2) + h[3] = int32(h3) + h[4] = int32(h4) + h[5] = int32(h5) + h[6] = int32(h6) + h[7] = int32(h7) + h[8] = int32(h8) + h[9] = int32(h9) +} + +// feInvert sets out = z^-1. +func feInvert(out, z *fieldElement) { + var t0, t1, t2, t3 fieldElement + var i int + + feSquare(&t0, z) + for i = 1; i < 1; i++ { + feSquare(&t0, &t0) + } + feSquare(&t1, &t0) + for i = 1; i < 2; i++ { + feSquare(&t1, &t1) + } + feMul(&t1, z, &t1) + feMul(&t0, &t0, &t1) + feSquare(&t2, &t0) + for i = 1; i < 1; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t1, &t2) + feSquare(&t2, &t1) + for i = 1; i < 5; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t2, &t1) + feSquare(&t2, &t1) + for i = 1; i < 10; i++ { + feSquare(&t2, &t2) + } + feMul(&t2, &t2, &t1) + feSquare(&t3, &t2) + for i = 1; i < 20; i++ { + feSquare(&t3, &t3) + } + feMul(&t2, &t3, &t2) + feSquare(&t2, &t2) + for i = 1; i < 10; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t2, &t1) + feSquare(&t2, &t1) + for i = 1; i < 50; i++ { + feSquare(&t2, &t2) + } + feMul(&t2, &t2, &t1) + feSquare(&t3, &t2) + for i = 1; i < 100; i++ { + feSquare(&t3, &t3) + } + feMul(&t2, &t3, &t2) + feSquare(&t2, &t2) + for i = 1; i < 50; i++ { + feSquare(&t2, &t2) + } + feMul(&t1, &t2, &t1) + feSquare(&t1, &t1) + for i = 1; i < 5; i++ { + feSquare(&t1, &t1) + } + feMul(out, &t1, &t0) +} + +func scalarMultGeneric(out, in, base *[32]byte) { + var e [32]byte + + copy(e[:], in[:]) + e[0] &= 248 + e[31] &= 127 + e[31] |= 64 + + var x1, x2, z2, x3, z3, tmp0, tmp1 fieldElement + feFromBytes(&x1, base) + feOne(&x2) + feCopy(&x3, &x1) + feOne(&z3) + + swap := int32(0) + for pos := 254; pos >= 0; pos-- { + b := e[pos/8] >> uint(pos&7) + b &= 1 + swap ^= int32(b) + feCSwap(&x2, &x3, swap) + feCSwap(&z2, &z3, swap) + swap = int32(b) + + feSub(&tmp0, &x3, &z3) + feSub(&tmp1, &x2, &z2) + feAdd(&x2, &x2, &z2) + feAdd(&z2, &x3, &z3) + feMul(&z3, &tmp0, &x2) + feMul(&z2, &z2, &tmp1) + feSquare(&tmp0, &tmp1) + feSquare(&tmp1, &x2) + feAdd(&x3, &z3, &z2) + feSub(&z2, &z3, &z2) + feMul(&x2, &tmp1, &tmp0) + feSub(&tmp1, &tmp1, &tmp0) + feSquare(&z2, &z2) + feMul121666(&z3, &tmp1) + feSquare(&x3, &x3) + feAdd(&tmp0, &tmp0, &z3) + feMul(&z3, &x1, &z2) + feMul(&z2, &tmp1, &tmp0) + } + + feCSwap(&x2, &x3, swap) + feCSwap(&z2, &z3, swap) + + feInvert(&z2, &z2) + feMul(&x2, &x2, &z2) + feToBytes(out, &x2) +} diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go b/vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go new file mode 100644 index 0000000000000..047d49afc27e3 --- /dev/null +++ b/vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go @@ -0,0 +1,11 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !amd64 gccgo appengine purego + +package curve25519 + +func scalarMult(out, in, base *[32]byte) { + scalarMultGeneric(out, in, base) +} diff --git a/vendor/golang.org/x/crypto/curve25519/doc.go b/vendor/golang.org/x/crypto/curve25519/doc.go deleted file mode 100644 index da9b10d9c1ffd..0000000000000 --- a/vendor/golang.org/x/crypto/curve25519/doc.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package curve25519 provides an implementation of scalar multiplication on -// the elliptic curve known as curve25519. See https://cr.yp.to/ecdh.html -package curve25519 // import "golang.org/x/crypto/curve25519" - -// basePoint is the x coordinate of the generator of the curve. -var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - -// ScalarMult sets dst to the product in*base where dst and base are the x -// coordinates of group points and all values are in little-endian form. -func ScalarMult(dst, in, base *[32]byte) { - scalarMult(dst, in, base) -} - -// ScalarBaseMult sets dst to the product in*base where dst and base are the x -// coordinates of group points, base is the standard generator and all values -// are in little-endian form. -func ScalarBaseMult(dst, in *[32]byte) { - ScalarMult(dst, in, &basePoint) -} diff --git a/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s b/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s deleted file mode 100644 index 390816106ee99..0000000000000 --- a/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -#include "const_amd64.h" - -// func freeze(inout *[5]uint64) -TEXT ·freeze(SB),7,$0-8 - MOVQ inout+0(FP), DI - - MOVQ 0(DI),SI - MOVQ 8(DI),DX - MOVQ 16(DI),CX - MOVQ 24(DI),R8 - MOVQ 32(DI),R9 - MOVQ $REDMASK51,AX - MOVQ AX,R10 - SUBQ $18,R10 - MOVQ $3,R11 -REDUCELOOP: - MOVQ SI,R12 - SHRQ $51,R12 - ANDQ AX,SI - ADDQ R12,DX - MOVQ DX,R12 - SHRQ $51,R12 - ANDQ AX,DX - ADDQ R12,CX - MOVQ CX,R12 - SHRQ $51,R12 - ANDQ AX,CX - ADDQ R12,R8 - MOVQ R8,R12 - SHRQ $51,R12 - ANDQ AX,R8 - ADDQ R12,R9 - MOVQ R9,R12 - SHRQ $51,R12 - ANDQ AX,R9 - IMUL3Q $19,R12,R12 - ADDQ R12,SI - SUBQ $1,R11 - JA REDUCELOOP - MOVQ $1,R12 - CMPQ R10,SI - CMOVQLT R11,R12 - CMPQ AX,DX - CMOVQNE R11,R12 - CMPQ AX,CX - CMOVQNE R11,R12 - CMPQ AX,R8 - CMOVQNE R11,R12 - CMPQ AX,R9 - CMOVQNE R11,R12 - NEGQ R12 - ANDQ R12,AX - ANDQ R12,R10 - SUBQ R10,SI - SUBQ AX,DX - SUBQ AX,CX - SUBQ AX,R8 - SUBQ AX,R9 - MOVQ SI,0(DI) - MOVQ DX,8(DI) - MOVQ CX,16(DI) - MOVQ R8,24(DI) - MOVQ R9,32(DI) - RET diff --git a/vendor/golang.org/x/crypto/curve25519/mul_amd64.s b/vendor/golang.org/x/crypto/curve25519/mul_amd64.s deleted file mode 100644 index 1f76d1a3f59aa..0000000000000 --- a/vendor/golang.org/x/crypto/curve25519/mul_amd64.s +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -#include "const_amd64.h" - -// func mul(dest, a, b *[5]uint64) -TEXT ·mul(SB),0,$16-24 - MOVQ dest+0(FP), DI - MOVQ a+8(FP), SI - MOVQ b+16(FP), DX - - MOVQ DX,CX - MOVQ 24(SI),DX - IMUL3Q $19,DX,AX - MOVQ AX,0(SP) - MULQ 16(CX) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 32(SI),DX - IMUL3Q $19,DX,AX - MOVQ AX,8(SP) - MULQ 8(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 0(SI),AX - MULQ 0(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 0(SI),AX - MULQ 8(CX) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 0(SI),AX - MULQ 16(CX) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 0(SI),AX - MULQ 24(CX) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 0(SI),AX - MULQ 32(CX) - MOVQ AX,BX - MOVQ DX,BP - MOVQ 8(SI),AX - MULQ 0(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SI),AX - MULQ 8(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 8(SI),AX - MULQ 16(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 8(SI),AX - MULQ 24(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 8(SI),DX - IMUL3Q $19,DX,AX - MULQ 32(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 16(SI),AX - MULQ 0(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 16(SI),AX - MULQ 8(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 16(SI),AX - MULQ 16(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 16(SI),DX - IMUL3Q $19,DX,AX - MULQ 24(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 16(SI),DX - IMUL3Q $19,DX,AX - MULQ 32(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 24(SI),AX - MULQ 0(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 24(SI),AX - MULQ 8(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 0(SP),AX - MULQ 24(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 0(SP),AX - MULQ 32(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 32(SI),AX - MULQ 0(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 8(SP),AX - MULQ 16(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SP),AX - MULQ 24(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 8(SP),AX - MULQ 32(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ $REDMASK51,SI - SHLQ $13,R8,R9 - ANDQ SI,R8 - SHLQ $13,R10,R11 - ANDQ SI,R10 - ADDQ R9,R10 - SHLQ $13,R12,R13 - ANDQ SI,R12 - ADDQ R11,R12 - SHLQ $13,R14,R15 - ANDQ SI,R14 - ADDQ R13,R14 - SHLQ $13,BX,BP - ANDQ SI,BX - ADDQ R15,BX - IMUL3Q $19,BP,DX - ADDQ DX,R8 - MOVQ R8,DX - SHRQ $51,DX - ADDQ R10,DX - MOVQ DX,CX - SHRQ $51,DX - ANDQ SI,R8 - ADDQ R12,DX - MOVQ DX,R9 - SHRQ $51,DX - ANDQ SI,CX - ADDQ R14,DX - MOVQ DX,AX - SHRQ $51,DX - ANDQ SI,R9 - ADDQ BX,DX - MOVQ DX,R10 - SHRQ $51,DX - ANDQ SI,AX - IMUL3Q $19,DX,DX - ADDQ DX,R8 - ANDQ SI,R10 - MOVQ R8,0(DI) - MOVQ CX,8(DI) - MOVQ R9,16(DI) - MOVQ AX,24(DI) - MOVQ R10,32(DI) - RET diff --git a/vendor/golang.org/x/crypto/curve25519/square_amd64.s b/vendor/golang.org/x/crypto/curve25519/square_amd64.s deleted file mode 100644 index 07511a45af22d..0000000000000 --- a/vendor/golang.org/x/crypto/curve25519/square_amd64.s +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -#include "const_amd64.h" - -// func square(out, in *[5]uint64) -TEXT ·square(SB),7,$0-16 - MOVQ out+0(FP), DI - MOVQ in+8(FP), SI - - MOVQ 0(SI),AX - MULQ 0(SI) - MOVQ AX,CX - MOVQ DX,R8 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 8(SI) - MOVQ AX,R9 - MOVQ DX,R10 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 16(SI) - MOVQ AX,R11 - MOVQ DX,R12 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 24(SI) - MOVQ AX,R13 - MOVQ DX,R14 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 32(SI) - MOVQ AX,R15 - MOVQ DX,BX - MOVQ 8(SI),AX - MULQ 8(SI) - ADDQ AX,R11 - ADCQ DX,R12 - MOVQ 8(SI),AX - SHLQ $1,AX - MULQ 16(SI) - ADDQ AX,R13 - ADCQ DX,R14 - MOVQ 8(SI),AX - SHLQ $1,AX - MULQ 24(SI) - ADDQ AX,R15 - ADCQ DX,BX - MOVQ 8(SI),DX - IMUL3Q $38,DX,AX - MULQ 32(SI) - ADDQ AX,CX - ADCQ DX,R8 - MOVQ 16(SI),AX - MULQ 16(SI) - ADDQ AX,R15 - ADCQ DX,BX - MOVQ 16(SI),DX - IMUL3Q $38,DX,AX - MULQ 24(SI) - ADDQ AX,CX - ADCQ DX,R8 - MOVQ 16(SI),DX - IMUL3Q $38,DX,AX - MULQ 32(SI) - ADDQ AX,R9 - ADCQ DX,R10 - MOVQ 24(SI),DX - IMUL3Q $19,DX,AX - MULQ 24(SI) - ADDQ AX,R9 - ADCQ DX,R10 - MOVQ 24(SI),DX - IMUL3Q $38,DX,AX - MULQ 32(SI) - ADDQ AX,R11 - ADCQ DX,R12 - MOVQ 32(SI),DX - IMUL3Q $19,DX,AX - MULQ 32(SI) - ADDQ AX,R13 - ADCQ DX,R14 - MOVQ $REDMASK51,SI - SHLQ $13,CX,R8 - ANDQ SI,CX - SHLQ $13,R9,R10 - ANDQ SI,R9 - ADDQ R8,R9 - SHLQ $13,R11,R12 - ANDQ SI,R11 - ADDQ R10,R11 - SHLQ $13,R13,R14 - ANDQ SI,R13 - ADDQ R12,R13 - SHLQ $13,R15,BX - ANDQ SI,R15 - ADDQ R14,R15 - IMUL3Q $19,BX,DX - ADDQ DX,CX - MOVQ CX,DX - SHRQ $51,DX - ADDQ R9,DX - ANDQ SI,CX - MOVQ DX,R8 - SHRQ $51,DX - ADDQ R11,DX - ANDQ SI,R8 - MOVQ DX,R9 - SHRQ $51,DX - ADDQ R13,DX - ANDQ SI,R9 - MOVQ DX,AX - SHRQ $51,DX - ADDQ R15,DX - ANDQ SI,AX - MOVQ DX,R10 - SHRQ $51,DX - IMUL3Q $19,DX,DX - ADDQ DX,CX - ANDQ SI,R10 - MOVQ CX,0(DI) - MOVQ R8,8(DI) - MOVQ R9,16(DI) - MOVQ AX,24(DI) - MOVQ R10,32(DI) - RET diff --git a/vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s b/vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s deleted file mode 100644 index cde3fc989b729..0000000000000 --- a/vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s +++ /dev/null @@ -1,668 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Based on CRYPTOGAMS code with the following comment: -// # ==================================================================== -// # Written by Andy Polyakov for the OpenSSL -// # project. The module is, however, dual licensed under OpenSSL and -// # CRYPTOGAMS licenses depending on where you obtain it. For further -// # details see http://www.openssl.org/~appro/cryptogams/. -// # ==================================================================== - -// Original code can be found at the link below: -// https://github.com/dot-asm/cryptogams/commit/a60f5b50ed908e91e5c39ca79126a4a876d5d8ff - -// There are some differences between CRYPTOGAMS code and this one. The round -// loop for "_int" isn't the same as the original. Some adjustments were -// necessary because there are less vector registers available. For example, some -// X variables (r12, r13, r14, and r15) share the same register used by the -// counter. The original code uses ctr to name the counter. Here we use CNT -// because golang uses CTR as the counter register name. - -// +build ppc64le,!gccgo,!appengine - -#include "textflag.h" - -#define OUT R3 -#define INP R4 -#define LEN R5 -#define KEY R6 -#define CNT R7 - -#define TEMP R8 - -#define X0 R11 -#define X1 R12 -#define X2 R14 -#define X3 R15 -#define X4 R16 -#define X5 R17 -#define X6 R18 -#define X7 R19 -#define X8 R20 -#define X9 R21 -#define X10 R22 -#define X11 R23 -#define X12 R24 -#define X13 R25 -#define X14 R26 -#define X15 R27 - -#define CON0 X0 -#define CON1 X1 -#define CON2 X2 -#define CON3 X3 - -#define KEY0 X4 -#define KEY1 X5 -#define KEY2 X6 -#define KEY3 X7 -#define KEY4 X8 -#define KEY5 X9 -#define KEY6 X10 -#define KEY7 X11 - -#define CNT0 X12 -#define CNT1 X13 -#define CNT2 X14 -#define CNT3 X15 - -#define TMP0 R9 -#define TMP1 R10 -#define TMP2 R28 -#define TMP3 R29 - -#define CONSTS R8 - -#define A0 V0 -#define B0 V1 -#define C0 V2 -#define D0 V3 -#define A1 V4 -#define B1 V5 -#define C1 V6 -#define D1 V7 -#define A2 V8 -#define B2 V9 -#define C2 V10 -#define D2 V11 -#define T0 V12 -#define T1 V13 -#define T2 V14 - -#define K0 V15 -#define K1 V16 -#define K2 V17 -#define K3 V18 -#define K4 V19 -#define K5 V20 - -#define FOUR V21 -#define SIXTEEN V22 -#define TWENTY4 V23 -#define TWENTY V24 -#define TWELVE V25 -#define TWENTY5 V26 -#define SEVEN V27 - -#define INPPERM V28 -#define OUTPERM V29 -#define OUTMASK V30 - -#define DD0 V31 -#define DD1 SEVEN -#define DD2 T0 -#define DD3 T1 -#define DD4 T2 - -DATA ·consts+0x00(SB)/8, $0x3320646e61707865 -DATA ·consts+0x08(SB)/8, $0x6b20657479622d32 -DATA ·consts+0x10(SB)/8, $0x0000000000000001 -DATA ·consts+0x18(SB)/8, $0x0000000000000000 -DATA ·consts+0x20(SB)/8, $0x0000000000000004 -DATA ·consts+0x28(SB)/8, $0x0000000000000000 -DATA ·consts+0x30(SB)/8, $0x0a0b08090e0f0c0d -DATA ·consts+0x38(SB)/8, $0x0203000106070405 -DATA ·consts+0x40(SB)/8, $0x090a0b080d0e0f0c -DATA ·consts+0x48(SB)/8, $0x0102030005060704 -GLOBL ·consts(SB), RODATA, $80 - -//func chaCha20_ctr32_vmx(out, inp *byte, len int, key *[32]byte, counter *[16]byte) -TEXT ·chaCha20_ctr32_vmx(SB),NOSPLIT|NOFRAME,$0 - // Load the arguments inside the registers - MOVD out+0(FP), OUT - MOVD inp+8(FP), INP - MOVD len+16(FP), LEN - MOVD key+24(FP), KEY - MOVD counter+32(FP), CNT - - MOVD $·consts(SB), CONSTS // point to consts addr - - MOVD $16, X0 - MOVD $32, X1 - MOVD $48, X2 - MOVD $64, X3 - MOVD $31, X4 - MOVD $15, X5 - - // Load key - LVX (KEY)(R0), K1 - LVSR (KEY)(R0), T0 - LVX (KEY)(X0), K2 - LVX (KEY)(X4), DD0 - - // Load counter - LVX (CNT)(R0), K3 - LVSR (CNT)(R0), T1 - LVX (CNT)(X5), DD1 - - // Load constants - LVX (CONSTS)(R0), K0 - LVX (CONSTS)(X0), K5 - LVX (CONSTS)(X1), FOUR - LVX (CONSTS)(X2), SIXTEEN - LVX (CONSTS)(X3), TWENTY4 - - // Align key and counter - VPERM K2, K1, T0, K1 - VPERM DD0, K2, T0, K2 - VPERM DD1, K3, T1, K3 - - // Load counter to GPR - MOVWZ 0(CNT), CNT0 - MOVWZ 4(CNT), CNT1 - MOVWZ 8(CNT), CNT2 - MOVWZ 12(CNT), CNT3 - - // Adjust vectors for the initial state - VADDUWM K3, K5, K3 - VADDUWM K3, K5, K4 - VADDUWM K4, K5, K5 - - // Synthesized constants - VSPLTISW $-12, TWENTY - VSPLTISW $12, TWELVE - VSPLTISW $-7, TWENTY5 - - VXOR T0, T0, T0 - VSPLTISW $-1, OUTMASK - LVSR (INP)(R0), INPPERM - LVSL (OUT)(R0), OUTPERM - VPERM OUTMASK, T0, OUTPERM, OUTMASK - -loop_outer_vmx: - // Load constant - MOVD $0x61707865, CON0 - MOVD $0x3320646e, CON1 - MOVD $0x79622d32, CON2 - MOVD $0x6b206574, CON3 - - VOR K0, K0, A0 - VOR K0, K0, A1 - VOR K0, K0, A2 - VOR K1, K1, B0 - - MOVD $10, TEMP - - // Load key to GPR - MOVWZ 0(KEY), X4 - MOVWZ 4(KEY), X5 - MOVWZ 8(KEY), X6 - MOVWZ 12(KEY), X7 - VOR K1, K1, B1 - VOR K1, K1, B2 - MOVWZ 16(KEY), X8 - MOVWZ 0(CNT), X12 - MOVWZ 20(KEY), X9 - MOVWZ 4(CNT), X13 - VOR K2, K2, C0 - VOR K2, K2, C1 - MOVWZ 24(KEY), X10 - MOVWZ 8(CNT), X14 - VOR K2, K2, C2 - VOR K3, K3, D0 - MOVWZ 28(KEY), X11 - MOVWZ 12(CNT), X15 - VOR K4, K4, D1 - VOR K5, K5, D2 - - MOVD X4, TMP0 - MOVD X5, TMP1 - MOVD X6, TMP2 - MOVD X7, TMP3 - VSPLTISW $7, SEVEN - - MOVD TEMP, CTR - -loop_vmx: - // CRYPTOGAMS uses a macro to create a loop using perl. This isn't possible - // using assembly macros. Therefore, the macro expansion result was used - // in order to maintain the algorithm efficiency. - // This loop generates three keystream blocks using VMX instructions and, - // in parallel, one keystream block using scalar instructions. - ADD X4, X0, X0 - ADD X5, X1, X1 - VADDUWM A0, B0, A0 - VADDUWM A1, B1, A1 - ADD X6, X2, X2 - ADD X7, X3, X3 - VADDUWM A2, B2, A2 - VXOR D0, A0, D0 - XOR X0, X12, X12 - XOR X1, X13, X13 - VXOR D1, A1, D1 - VXOR D2, A2, D2 - XOR X2, X14, X14 - XOR X3, X15, X15 - VPERM D0, D0, SIXTEEN, D0 - VPERM D1, D1, SIXTEEN, D1 - ROTLW $16, X12, X12 - ROTLW $16, X13, X13 - VPERM D2, D2, SIXTEEN, D2 - VADDUWM C0, D0, C0 - ROTLW $16, X14, X14 - ROTLW $16, X15, X15 - VADDUWM C1, D1, C1 - VADDUWM C2, D2, C2 - ADD X12, X8, X8 - ADD X13, X9, X9 - VXOR B0, C0, T0 - VXOR B1, C1, T1 - ADD X14, X10, X10 - ADD X15, X11, X11 - VXOR B2, C2, T2 - VRLW T0, TWELVE, B0 - XOR X8, X4, X4 - XOR X9, X5, X5 - VRLW T1, TWELVE, B1 - VRLW T2, TWELVE, B2 - XOR X10, X6, X6 - XOR X11, X7, X7 - VADDUWM A0, B0, A0 - VADDUWM A1, B1, A1 - ROTLW $12, X4, X4 - ROTLW $12, X5, X5 - VADDUWM A2, B2, A2 - VXOR D0, A0, D0 - ROTLW $12, X6, X6 - ROTLW $12, X7, X7 - VXOR D1, A1, D1 - VXOR D2, A2, D2 - ADD X4, X0, X0 - ADD X5, X1, X1 - VPERM D0, D0, TWENTY4, D0 - VPERM D1, D1, TWENTY4, D1 - ADD X6, X2, X2 - ADD X7, X3, X3 - VPERM D2, D2, TWENTY4, D2 - VADDUWM C0, D0, C0 - XOR X0, X12, X12 - XOR X1, X13, X13 - VADDUWM C1, D1, C1 - VADDUWM C2, D2, C2 - XOR X2, X14, X14 - XOR X3, X15, X15 - VXOR B0, C0, T0 - VXOR B1, C1, T1 - ROTLW $8, X12, X12 - ROTLW $8, X13, X13 - VXOR B2, C2, T2 - VRLW T0, SEVEN, B0 - ROTLW $8, X14, X14 - ROTLW $8, X15, X15 - VRLW T1, SEVEN, B1 - VRLW T2, SEVEN, B2 - ADD X12, X8, X8 - ADD X13, X9, X9 - VSLDOI $8, C0, C0, C0 - VSLDOI $8, C1, C1, C1 - ADD X14, X10, X10 - ADD X15, X11, X11 - VSLDOI $8, C2, C2, C2 - VSLDOI $12, B0, B0, B0 - XOR X8, X4, X4 - XOR X9, X5, X5 - VSLDOI $12, B1, B1, B1 - VSLDOI $12, B2, B2, B2 - XOR X10, X6, X6 - XOR X11, X7, X7 - VSLDOI $4, D0, D0, D0 - VSLDOI $4, D1, D1, D1 - ROTLW $7, X4, X4 - ROTLW $7, X5, X5 - VSLDOI $4, D2, D2, D2 - VADDUWM A0, B0, A0 - ROTLW $7, X6, X6 - ROTLW $7, X7, X7 - VADDUWM A1, B1, A1 - VADDUWM A2, B2, A2 - ADD X5, X0, X0 - ADD X6, X1, X1 - VXOR D0, A0, D0 - VXOR D1, A1, D1 - ADD X7, X2, X2 - ADD X4, X3, X3 - VXOR D2, A2, D2 - VPERM D0, D0, SIXTEEN, D0 - XOR X0, X15, X15 - XOR X1, X12, X12 - VPERM D1, D1, SIXTEEN, D1 - VPERM D2, D2, SIXTEEN, D2 - XOR X2, X13, X13 - XOR X3, X14, X14 - VADDUWM C0, D0, C0 - VADDUWM C1, D1, C1 - ROTLW $16, X15, X15 - ROTLW $16, X12, X12 - VADDUWM C2, D2, C2 - VXOR B0, C0, T0 - ROTLW $16, X13, X13 - ROTLW $16, X14, X14 - VXOR B1, C1, T1 - VXOR B2, C2, T2 - ADD X15, X10, X10 - ADD X12, X11, X11 - VRLW T0, TWELVE, B0 - VRLW T1, TWELVE, B1 - ADD X13, X8, X8 - ADD X14, X9, X9 - VRLW T2, TWELVE, B2 - VADDUWM A0, B0, A0 - XOR X10, X5, X5 - XOR X11, X6, X6 - VADDUWM A1, B1, A1 - VADDUWM A2, B2, A2 - XOR X8, X7, X7 - XOR X9, X4, X4 - VXOR D0, A0, D0 - VXOR D1, A1, D1 - ROTLW $12, X5, X5 - ROTLW $12, X6, X6 - VXOR D2, A2, D2 - VPERM D0, D0, TWENTY4, D0 - ROTLW $12, X7, X7 - ROTLW $12, X4, X4 - VPERM D1, D1, TWENTY4, D1 - VPERM D2, D2, TWENTY4, D2 - ADD X5, X0, X0 - ADD X6, X1, X1 - VADDUWM C0, D0, C0 - VADDUWM C1, D1, C1 - ADD X7, X2, X2 - ADD X4, X3, X3 - VADDUWM C2, D2, C2 - VXOR B0, C0, T0 - XOR X0, X15, X15 - XOR X1, X12, X12 - VXOR B1, C1, T1 - VXOR B2, C2, T2 - XOR X2, X13, X13 - XOR X3, X14, X14 - VRLW T0, SEVEN, B0 - VRLW T1, SEVEN, B1 - ROTLW $8, X15, X15 - ROTLW $8, X12, X12 - VRLW T2, SEVEN, B2 - VSLDOI $8, C0, C0, C0 - ROTLW $8, X13, X13 - ROTLW $8, X14, X14 - VSLDOI $8, C1, C1, C1 - VSLDOI $8, C2, C2, C2 - ADD X15, X10, X10 - ADD X12, X11, X11 - VSLDOI $4, B0, B0, B0 - VSLDOI $4, B1, B1, B1 - ADD X13, X8, X8 - ADD X14, X9, X9 - VSLDOI $4, B2, B2, B2 - VSLDOI $12, D0, D0, D0 - XOR X10, X5, X5 - XOR X11, X6, X6 - VSLDOI $12, D1, D1, D1 - VSLDOI $12, D2, D2, D2 - XOR X8, X7, X7 - XOR X9, X4, X4 - ROTLW $7, X5, X5 - ROTLW $7, X6, X6 - ROTLW $7, X7, X7 - ROTLW $7, X4, X4 - BC 0x10, 0, loop_vmx - - SUB $256, LEN, LEN - - // Accumulate key block - ADD $0x61707865, X0, X0 - ADD $0x3320646e, X1, X1 - ADD $0x79622d32, X2, X2 - ADD $0x6b206574, X3, X3 - ADD TMP0, X4, X4 - ADD TMP1, X5, X5 - ADD TMP2, X6, X6 - ADD TMP3, X7, X7 - MOVWZ 16(KEY), TMP0 - MOVWZ 20(KEY), TMP1 - MOVWZ 24(KEY), TMP2 - MOVWZ 28(KEY), TMP3 - ADD TMP0, X8, X8 - ADD TMP1, X9, X9 - ADD TMP2, X10, X10 - ADD TMP3, X11, X11 - - MOVWZ 12(CNT), TMP0 - MOVWZ 8(CNT), TMP1 - MOVWZ 4(CNT), TMP2 - MOVWZ 0(CNT), TEMP - ADD TMP0, X15, X15 - ADD TMP1, X14, X14 - ADD TMP2, X13, X13 - ADD TEMP, X12, X12 - - // Accumulate key block - VADDUWM A0, K0, A0 - VADDUWM A1, K0, A1 - VADDUWM A2, K0, A2 - VADDUWM B0, K1, B0 - VADDUWM B1, K1, B1 - VADDUWM B2, K1, B2 - VADDUWM C0, K2, C0 - VADDUWM C1, K2, C1 - VADDUWM C2, K2, C2 - VADDUWM D0, K3, D0 - VADDUWM D1, K4, D1 - VADDUWM D2, K5, D2 - - // Increment counter - ADD $4, TEMP, TEMP - MOVW TEMP, 0(CNT) - - VADDUWM K3, FOUR, K3 - VADDUWM K4, FOUR, K4 - VADDUWM K5, FOUR, K5 - - // XOR the input slice (INP) with the keystream, which is stored in GPRs (X0-X3). - - // Load input (aligned or not) - MOVWZ 0(INP), TMP0 - MOVWZ 4(INP), TMP1 - MOVWZ 8(INP), TMP2 - MOVWZ 12(INP), TMP3 - - // XOR with input - XOR TMP0, X0, X0 - XOR TMP1, X1, X1 - XOR TMP2, X2, X2 - XOR TMP3, X3, X3 - MOVWZ 16(INP), TMP0 - MOVWZ 20(INP), TMP1 - MOVWZ 24(INP), TMP2 - MOVWZ 28(INP), TMP3 - XOR TMP0, X4, X4 - XOR TMP1, X5, X5 - XOR TMP2, X6, X6 - XOR TMP3, X7, X7 - MOVWZ 32(INP), TMP0 - MOVWZ 36(INP), TMP1 - MOVWZ 40(INP), TMP2 - MOVWZ 44(INP), TMP3 - XOR TMP0, X8, X8 - XOR TMP1, X9, X9 - XOR TMP2, X10, X10 - XOR TMP3, X11, X11 - MOVWZ 48(INP), TMP0 - MOVWZ 52(INP), TMP1 - MOVWZ 56(INP), TMP2 - MOVWZ 60(INP), TMP3 - XOR TMP0, X12, X12 - XOR TMP1, X13, X13 - XOR TMP2, X14, X14 - XOR TMP3, X15, X15 - - // Store output (aligned or not) - MOVW X0, 0(OUT) - MOVW X1, 4(OUT) - MOVW X2, 8(OUT) - MOVW X3, 12(OUT) - - ADD $64, INP, INP // INP points to the end of the slice for the alignment code below - - MOVW X4, 16(OUT) - MOVD $16, TMP0 - MOVW X5, 20(OUT) - MOVD $32, TMP1 - MOVW X6, 24(OUT) - MOVD $48, TMP2 - MOVW X7, 28(OUT) - MOVD $64, TMP3 - MOVW X8, 32(OUT) - MOVW X9, 36(OUT) - MOVW X10, 40(OUT) - MOVW X11, 44(OUT) - MOVW X12, 48(OUT) - MOVW X13, 52(OUT) - MOVW X14, 56(OUT) - MOVW X15, 60(OUT) - ADD $64, OUT, OUT - - // Load input - LVX (INP)(R0), DD0 - LVX (INP)(TMP0), DD1 - LVX (INP)(TMP1), DD2 - LVX (INP)(TMP2), DD3 - LVX (INP)(TMP3), DD4 - ADD $64, INP, INP - - VPERM DD1, DD0, INPPERM, DD0 // Align input - VPERM DD2, DD1, INPPERM, DD1 - VPERM DD3, DD2, INPPERM, DD2 - VPERM DD4, DD3, INPPERM, DD3 - VXOR A0, DD0, A0 // XOR with input - VXOR B0, DD1, B0 - LVX (INP)(TMP0), DD1 // Keep loading input - VXOR C0, DD2, C0 - LVX (INP)(TMP1), DD2 - VXOR D0, DD3, D0 - LVX (INP)(TMP2), DD3 - LVX (INP)(TMP3), DD0 - ADD $64, INP, INP - MOVD $63, TMP3 // 63 is not a typo - VPERM A0, A0, OUTPERM, A0 - VPERM B0, B0, OUTPERM, B0 - VPERM C0, C0, OUTPERM, C0 - VPERM D0, D0, OUTPERM, D0 - - VPERM DD1, DD4, INPPERM, DD4 // Align input - VPERM DD2, DD1, INPPERM, DD1 - VPERM DD3, DD2, INPPERM, DD2 - VPERM DD0, DD3, INPPERM, DD3 - VXOR A1, DD4, A1 - VXOR B1, DD1, B1 - LVX (INP)(TMP0), DD1 // Keep loading - VXOR C1, DD2, C1 - LVX (INP)(TMP1), DD2 - VXOR D1, DD3, D1 - LVX (INP)(TMP2), DD3 - - // Note that the LVX address is always rounded down to the nearest 16-byte - // boundary, and that it always points to at most 15 bytes beyond the end of - // the slice, so we cannot cross a page boundary. - LVX (INP)(TMP3), DD4 // Redundant in aligned case. - ADD $64, INP, INP - VPERM A1, A1, OUTPERM, A1 // Pre-misalign output - VPERM B1, B1, OUTPERM, B1 - VPERM C1, C1, OUTPERM, C1 - VPERM D1, D1, OUTPERM, D1 - - VPERM DD1, DD0, INPPERM, DD0 // Align Input - VPERM DD2, DD1, INPPERM, DD1 - VPERM DD3, DD2, INPPERM, DD2 - VPERM DD4, DD3, INPPERM, DD3 - VXOR A2, DD0, A2 - VXOR B2, DD1, B2 - VXOR C2, DD2, C2 - VXOR D2, DD3, D2 - VPERM A2, A2, OUTPERM, A2 - VPERM B2, B2, OUTPERM, B2 - VPERM C2, C2, OUTPERM, C2 - VPERM D2, D2, OUTPERM, D2 - - ANDCC $15, OUT, X1 // Is out aligned? - MOVD OUT, X0 - - VSEL A0, B0, OUTMASK, DD0 // Collect pre-misaligned output - VSEL B0, C0, OUTMASK, DD1 - VSEL C0, D0, OUTMASK, DD2 - VSEL D0, A1, OUTMASK, DD3 - VSEL A1, B1, OUTMASK, B0 - VSEL B1, C1, OUTMASK, C0 - VSEL C1, D1, OUTMASK, D0 - VSEL D1, A2, OUTMASK, A1 - VSEL A2, B2, OUTMASK, B1 - VSEL B2, C2, OUTMASK, C1 - VSEL C2, D2, OUTMASK, D1 - - STVX DD0, (OUT+TMP0) - STVX DD1, (OUT+TMP1) - STVX DD2, (OUT+TMP2) - ADD $64, OUT, OUT - STVX DD3, (OUT+R0) - STVX B0, (OUT+TMP0) - STVX C0, (OUT+TMP1) - STVX D0, (OUT+TMP2) - ADD $64, OUT, OUT - STVX A1, (OUT+R0) - STVX B1, (OUT+TMP0) - STVX C1, (OUT+TMP1) - STVX D1, (OUT+TMP2) - ADD $64, OUT, OUT - - BEQ aligned_vmx - - SUB X1, OUT, X2 // in misaligned case edges - MOVD $0, X3 // are written byte-by-byte - -unaligned_tail_vmx: - STVEBX D2, (X2+X3) - ADD $1, X3, X3 - CMPW X3, X1 - BNE unaligned_tail_vmx - SUB X1, X0, X2 - -unaligned_head_vmx: - STVEBX A0, (X2+X1) - CMPW X1, $15 - ADD $1, X1, X1 - BNE unaligned_head_vmx - - CMPU LEN, $255 // done with 256-byte block yet? - BGT loop_outer_vmx - - JMP done_vmx - -aligned_vmx: - STVX A0, (X0+R0) - CMPU LEN, $255 // done with 256-byte block yet? - BGT loop_outer_vmx - -done_vmx: - RET diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go deleted file mode 100644 index ad74e23aef489..0000000000000 --- a/vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.11 -// +build !gccgo - -package chacha20 - -const ( - haveAsm = true - bufSize = 256 -) - -//go:noescape -func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32) - -func (c *Cipher) xorKeyStreamAsm(dst, src []byte) { - - if len(src) >= bufSize { - xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter) - } - - if len(src)%bufSize != 0 { - i := len(src) - len(src)%bufSize - c.buf = [bufSize]byte{} - copy(c.buf[:], src[i:]) - xorKeyStreamVX(c.buf[:], c.buf[:], &c.key, &c.nonce, &c.counter) - c.len = bufSize - copy(dst[i:], c.buf[:len(src)%bufSize]) - } -} diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_generic.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_generic.go deleted file mode 100644 index 6570847f5e07a..0000000000000 --- a/vendor/golang.org/x/crypto/internal/chacha20/chacha_generic.go +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ChaCha20 implements the core ChaCha20 function as specified -// in https://tools.ietf.org/html/rfc7539#section-2.3. -package chacha20 - -import ( - "crypto/cipher" - "encoding/binary" - - "golang.org/x/crypto/internal/subtle" -) - -// assert that *Cipher implements cipher.Stream -var _ cipher.Stream = (*Cipher)(nil) - -// Cipher is a stateful instance of ChaCha20 using a particular key -// and nonce. A *Cipher implements the cipher.Stream interface. -type Cipher struct { - key [8]uint32 - counter uint32 // incremented after each block - nonce [3]uint32 - buf [bufSize]byte // buffer for unused keystream bytes - len int // number of unused keystream bytes at end of buf -} - -// New creates a new ChaCha20 stream cipher with the given key and nonce. -// The initial counter value is set to 0. -func New(key [8]uint32, nonce [3]uint32) *Cipher { - return &Cipher{key: key, nonce: nonce} -} - -// ChaCha20 constants spelling "expand 32-byte k" -const ( - j0 uint32 = 0x61707865 - j1 uint32 = 0x3320646e - j2 uint32 = 0x79622d32 - j3 uint32 = 0x6b206574 -) - -func quarterRound(a, b, c, d uint32) (uint32, uint32, uint32, uint32) { - a += b - d ^= a - d = (d << 16) | (d >> 16) - c += d - b ^= c - b = (b << 12) | (b >> 20) - a += b - d ^= a - d = (d << 8) | (d >> 24) - c += d - b ^= c - b = (b << 7) | (b >> 25) - return a, b, c, d -} - -// XORKeyStream XORs each byte in the given slice with a byte from the -// cipher's key stream. Dst and src must overlap entirely or not at all. -// -// If len(dst) < len(src), XORKeyStream will panic. It is acceptable -// to pass a dst bigger than src, and in that case, XORKeyStream will -// only update dst[:len(src)] and will not touch the rest of dst. -// -// Multiple calls to XORKeyStream behave as if the concatenation of -// the src buffers was passed in a single run. That is, Cipher -// maintains state and does not reset at each XORKeyStream call. -func (s *Cipher) XORKeyStream(dst, src []byte) { - if len(dst) < len(src) { - panic("chacha20: output smaller than input") - } - if subtle.InexactOverlap(dst[:len(src)], src) { - panic("chacha20: invalid buffer overlap") - } - - // xor src with buffered keystream first - if s.len != 0 { - buf := s.buf[len(s.buf)-s.len:] - if len(src) < len(buf) { - buf = buf[:len(src)] - } - td, ts := dst[:len(buf)], src[:len(buf)] // BCE hint - for i, b := range buf { - td[i] = ts[i] ^ b - } - s.len -= len(buf) - if s.len != 0 { - return - } - s.buf = [len(s.buf)]byte{} // zero the empty buffer - src = src[len(buf):] - dst = dst[len(buf):] - } - - if len(src) == 0 { - return - } - if haveAsm { - if uint64(len(src))+uint64(s.counter)*64 > (1<<38)-64 { - panic("chacha20: counter overflow") - } - s.xorKeyStreamAsm(dst, src) - return - } - - // set up a 64-byte buffer to pad out the final block if needed - // (hoisted out of the main loop to avoid spills) - rem := len(src) % 64 // length of final block - fin := len(src) - rem // index of final block - if rem > 0 { - copy(s.buf[len(s.buf)-64:], src[fin:]) - } - - // pre-calculate most of the first round - s1, s5, s9, s13 := quarterRound(j1, s.key[1], s.key[5], s.nonce[0]) - s2, s6, s10, s14 := quarterRound(j2, s.key[2], s.key[6], s.nonce[1]) - s3, s7, s11, s15 := quarterRound(j3, s.key[3], s.key[7], s.nonce[2]) - - n := len(src) - src, dst = src[:n:n], dst[:n:n] // BCE hint - for i := 0; i < n; i += 64 { - // calculate the remainder of the first round - s0, s4, s8, s12 := quarterRound(j0, s.key[0], s.key[4], s.counter) - - // execute the second round - x0, x5, x10, x15 := quarterRound(s0, s5, s10, s15) - x1, x6, x11, x12 := quarterRound(s1, s6, s11, s12) - x2, x7, x8, x13 := quarterRound(s2, s7, s8, s13) - x3, x4, x9, x14 := quarterRound(s3, s4, s9, s14) - - // execute the remaining 18 rounds - for i := 0; i < 9; i++ { - x0, x4, x8, x12 = quarterRound(x0, x4, x8, x12) - x1, x5, x9, x13 = quarterRound(x1, x5, x9, x13) - x2, x6, x10, x14 = quarterRound(x2, x6, x10, x14) - x3, x7, x11, x15 = quarterRound(x3, x7, x11, x15) - - x0, x5, x10, x15 = quarterRound(x0, x5, x10, x15) - x1, x6, x11, x12 = quarterRound(x1, x6, x11, x12) - x2, x7, x8, x13 = quarterRound(x2, x7, x8, x13) - x3, x4, x9, x14 = quarterRound(x3, x4, x9, x14) - } - - x0 += j0 - x1 += j1 - x2 += j2 - x3 += j3 - - x4 += s.key[0] - x5 += s.key[1] - x6 += s.key[2] - x7 += s.key[3] - x8 += s.key[4] - x9 += s.key[5] - x10 += s.key[6] - x11 += s.key[7] - - x12 += s.counter - x13 += s.nonce[0] - x14 += s.nonce[1] - x15 += s.nonce[2] - - // increment the counter - s.counter += 1 - if s.counter == 0 { - panic("chacha20: counter overflow") - } - - // pad to 64 bytes if needed - in, out := src[i:], dst[i:] - if i == fin { - // src[fin:] has already been copied into s.buf before - // the main loop - in, out = s.buf[len(s.buf)-64:], s.buf[len(s.buf)-64:] - } - in, out = in[:64], out[:64] // BCE hint - - // XOR the key stream with the source and write out the result - xor(out[0:], in[0:], x0) - xor(out[4:], in[4:], x1) - xor(out[8:], in[8:], x2) - xor(out[12:], in[12:], x3) - xor(out[16:], in[16:], x4) - xor(out[20:], in[20:], x5) - xor(out[24:], in[24:], x6) - xor(out[28:], in[28:], x7) - xor(out[32:], in[32:], x8) - xor(out[36:], in[36:], x9) - xor(out[40:], in[40:], x10) - xor(out[44:], in[44:], x11) - xor(out[48:], in[48:], x12) - xor(out[52:], in[52:], x13) - xor(out[56:], in[56:], x14) - xor(out[60:], in[60:], x15) - } - // copy any trailing bytes out of the buffer and into dst - if rem != 0 { - s.len = 64 - rem - copy(dst[fin:], s.buf[len(s.buf)-64:]) - } -} - -// Advance discards bytes in the key stream until the next 64 byte block -// boundary is reached and updates the counter accordingly. If the key -// stream is already at a block boundary no bytes will be discarded and -// the counter will be unchanged. -func (s *Cipher) Advance() { - s.len -= s.len % 64 - if s.len == 0 { - s.buf = [len(s.buf)]byte{} - } -} - -// XORKeyStream crypts bytes from in to out using the given key and counters. -// In and out must overlap entirely or not at all. Counter contains the raw -// ChaCha20 counter bytes (i.e. block counter followed by nonce). -func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) { - s := Cipher{ - key: [8]uint32{ - binary.LittleEndian.Uint32(key[0:4]), - binary.LittleEndian.Uint32(key[4:8]), - binary.LittleEndian.Uint32(key[8:12]), - binary.LittleEndian.Uint32(key[12:16]), - binary.LittleEndian.Uint32(key[16:20]), - binary.LittleEndian.Uint32(key[20:24]), - binary.LittleEndian.Uint32(key[24:28]), - binary.LittleEndian.Uint32(key[28:32]), - }, - nonce: [3]uint32{ - binary.LittleEndian.Uint32(counter[4:8]), - binary.LittleEndian.Uint32(counter[8:12]), - binary.LittleEndian.Uint32(counter[12:16]), - }, - counter: binary.LittleEndian.Uint32(counter[0:4]), - } - s.XORKeyStream(out, in) -} - -// HChaCha20 uses the ChaCha20 core to generate a derived key from a key and a -// nonce. It should only be used as part of the XChaCha20 construction. -func HChaCha20(key *[8]uint32, nonce *[4]uint32) [8]uint32 { - x0, x1, x2, x3 := j0, j1, j2, j3 - x4, x5, x6, x7 := key[0], key[1], key[2], key[3] - x8, x9, x10, x11 := key[4], key[5], key[6], key[7] - x12, x13, x14, x15 := nonce[0], nonce[1], nonce[2], nonce[3] - - for i := 0; i < 10; i++ { - x0, x4, x8, x12 = quarterRound(x0, x4, x8, x12) - x1, x5, x9, x13 = quarterRound(x1, x5, x9, x13) - x2, x6, x10, x14 = quarterRound(x2, x6, x10, x14) - x3, x7, x11, x15 = quarterRound(x3, x7, x11, x15) - - x0, x5, x10, x15 = quarterRound(x0, x5, x10, x15) - x1, x6, x11, x12 = quarterRound(x1, x6, x11, x12) - x2, x7, x8, x13 = quarterRound(x2, x7, x8, x13) - x3, x4, x9, x14 = quarterRound(x3, x4, x9, x14) - } - - var out [8]uint32 - out[0], out[1], out[2], out[3] = x0, x1, x2, x3 - out[4], out[5], out[6], out[7] = x12, x13, x14, x15 - return out -} diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go deleted file mode 100644 index bf8beba67084b..0000000000000 --- a/vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !ppc64le,!arm64,!s390x arm64,!go1.11 gccgo appengine - -package chacha20 - -const ( - bufSize = 64 - haveAsm = false -) - -func (*Cipher) xorKeyStreamAsm(dst, src []byte) { - panic("not implemented") -} diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go deleted file mode 100644 index 638cb5e5de53a..0000000000000 --- a/vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ppc64le,!gccgo,!appengine - -package chacha20 - -import "encoding/binary" - -const ( - bufSize = 256 - haveAsm = true -) - -//go:noescape -func chaCha20_ctr32_vmx(out, inp *byte, len int, key *[8]uint32, counter *uint32) - -func (c *Cipher) xorKeyStreamAsm(dst, src []byte) { - if len(src) >= bufSize { - chaCha20_ctr32_vmx(&dst[0], &src[0], len(src)-len(src)%bufSize, &c.key, &c.counter) - } - if len(src)%bufSize != 0 { - chaCha20_ctr32_vmx(&c.buf[0], &c.buf[0], bufSize, &c.key, &c.counter) - start := len(src) - len(src)%bufSize - ts, td, tb := src[start:], dst[start:], c.buf[:] - // Unroll loop to XOR 32 bytes per iteration. - for i := 0; i < len(ts)-32; i += 32 { - td, tb = td[:len(ts)], tb[:len(ts)] // bounds check elimination - s0 := binary.LittleEndian.Uint64(ts[0:8]) - s1 := binary.LittleEndian.Uint64(ts[8:16]) - s2 := binary.LittleEndian.Uint64(ts[16:24]) - s3 := binary.LittleEndian.Uint64(ts[24:32]) - b0 := binary.LittleEndian.Uint64(tb[0:8]) - b1 := binary.LittleEndian.Uint64(tb[8:16]) - b2 := binary.LittleEndian.Uint64(tb[16:24]) - b3 := binary.LittleEndian.Uint64(tb[24:32]) - binary.LittleEndian.PutUint64(td[0:8], s0^b0) - binary.LittleEndian.PutUint64(td[8:16], s1^b1) - binary.LittleEndian.PutUint64(td[16:24], s2^b2) - binary.LittleEndian.PutUint64(td[24:32], s3^b3) - ts, td, tb = ts[32:], td[32:], tb[32:] - } - td, tb = td[:len(ts)], tb[:len(ts)] // bounds check elimination - for i, v := range ts { - td[i] = tb[i] ^ v - } - c.len = bufSize - (len(src) % bufSize) - - } - -} diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.go deleted file mode 100644 index aad645b44762d..0000000000000 --- a/vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build s390x,!gccgo,!appengine - -package chacha20 - -import ( - "golang.org/x/sys/cpu" -) - -var haveAsm = cpu.S390X.HasVX - -const bufSize = 256 - -// xorKeyStreamVX is an assembly implementation of XORKeyStream. It must only -// be called when the vector facility is available. -// Implementation in asm_s390x.s. -//go:noescape -func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32, buf *[256]byte, len *int) - -func (c *Cipher) xorKeyStreamAsm(dst, src []byte) { - xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter, &c.buf, &c.len) -} - -// EXRL targets, DO NOT CALL! -func mvcSrcToBuf() -func mvcBufToDst() diff --git a/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go b/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go index 73f4fe3785914..72a6a739471ab 100644 --- a/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go +++ b/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go @@ -76,7 +76,9 @@ func Encrypt(random io.Reader, pub *PublicKey, msg []byte) (c1, c2 *big.Int, err // Bleichenbacher, Advances in Cryptology (Crypto '98), func Decrypt(priv *PrivateKey, c1, c2 *big.Int) (msg []byte, err error) { s := new(big.Int).Exp(c1, priv.X, priv.P) - s.ModInverse(s, priv.P) + if s.ModInverse(s, priv.P) == nil { + return nil, errors.New("elgamal: invalid private key") + } s.Mul(s, c2) s.Mod(s, priv.P) em := s.Bytes() diff --git a/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go b/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go index 02b372cf374ec..6d7639722c906 100644 --- a/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go +++ b/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go @@ -5,6 +5,7 @@ package packet import ( + "crypto" "crypto/rsa" "encoding/binary" "io" @@ -78,8 +79,9 @@ func (e *EncryptedKey) Decrypt(priv *PrivateKey, config *Config) error { // padding oracle attacks. switch priv.PubKeyAlgo { case PubKeyAlgoRSA, PubKeyAlgoRSAEncryptOnly: - k := priv.PrivateKey.(*rsa.PrivateKey) - b, err = rsa.DecryptPKCS1v15(config.Random(), k, padToKeySize(&k.PublicKey, e.encryptedMPI1.bytes)) + // Supports both *rsa.PrivateKey and crypto.Decrypter + k := priv.PrivateKey.(crypto.Decrypter) + b, err = k.Decrypt(config.Random(), padToKeySize(k.Public().(*rsa.PublicKey), e.encryptedMPI1.bytes), nil) case PubKeyAlgoElGamal: c1 := new(big.Int).SetBytes(e.encryptedMPI1.bytes) c2 := new(big.Int).SetBytes(e.encryptedMPI2.bytes) diff --git a/vendor/golang.org/x/crypto/openpgp/packet/private_key.go b/vendor/golang.org/x/crypto/openpgp/packet/private_key.go index 6f8ec0938416e..81abb7cef98f8 100644 --- a/vendor/golang.org/x/crypto/openpgp/packet/private_key.go +++ b/vendor/golang.org/x/crypto/openpgp/packet/private_key.go @@ -31,7 +31,7 @@ type PrivateKey struct { encryptedData []byte cipher CipherFunction s2k func(out, in []byte) - PrivateKey interface{} // An *{rsa|dsa|ecdsa}.PrivateKey or a crypto.Signer. + PrivateKey interface{} // An *{rsa|dsa|ecdsa}.PrivateKey or crypto.Signer/crypto.Decrypter (Decryptor RSA only). sha1Checksum bool iv []byte } diff --git a/vendor/golang.org/x/crypto/poly1305/bits_compat.go b/vendor/golang.org/x/crypto/poly1305/bits_compat.go new file mode 100644 index 0000000000000..157a69f61bd9a --- /dev/null +++ b/vendor/golang.org/x/crypto/poly1305/bits_compat.go @@ -0,0 +1,39 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.13 + +package poly1305 + +// Generic fallbacks for the math/bits intrinsics, copied from +// src/math/bits/bits.go. They were added in Go 1.12, but Add64 and Sum64 had +// variable time fallbacks until Go 1.13. + +func bitsAdd64(x, y, carry uint64) (sum, carryOut uint64) { + sum = x + y + carry + carryOut = ((x & y) | ((x | y) &^ sum)) >> 63 + return +} + +func bitsSub64(x, y, borrow uint64) (diff, borrowOut uint64) { + diff = x - y - borrow + borrowOut = ((^x & y) | (^(x ^ y) & diff)) >> 63 + return +} + +func bitsMul64(x, y uint64) (hi, lo uint64) { + const mask32 = 1<<32 - 1 + x0 := x & mask32 + x1 := x >> 32 + y0 := y & mask32 + y1 := y >> 32 + w0 := x0 * y0 + t := x1*y0 + w0>>32 + w1 := t & mask32 + w2 := t >> 32 + w1 += x0 * y1 + hi = x1*y1 + w2 + w1>>32 + lo = x * y + return +} diff --git a/vendor/golang.org/x/crypto/poly1305/bits_go1.13.go b/vendor/golang.org/x/crypto/poly1305/bits_go1.13.go new file mode 100644 index 0000000000000..a0a185f0fc771 --- /dev/null +++ b/vendor/golang.org/x/crypto/poly1305/bits_go1.13.go @@ -0,0 +1,21 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.13 + +package poly1305 + +import "math/bits" + +func bitsAdd64(x, y, carry uint64) (sum, carryOut uint64) { + return bits.Add64(x, y, carry) +} + +func bitsSub64(x, y, borrow uint64) (diff, borrowOut uint64) { + return bits.Sub64(x, y, borrow) +} + +func bitsMul64(x, y uint64) (hi, lo uint64) { + return bits.Mul64(x, y) +} diff --git a/vendor/golang.org/x/crypto/poly1305/poly1305.go b/vendor/golang.org/x/crypto/poly1305/poly1305.go index d076a562351f4..066159b797dd8 100644 --- a/vendor/golang.org/x/crypto/poly1305/poly1305.go +++ b/vendor/golang.org/x/crypto/poly1305/poly1305.go @@ -22,8 +22,14 @@ import "crypto/subtle" // TagSize is the size, in bytes, of a poly1305 authenticator. const TagSize = 16 -// Verify returns true if mac is a valid authenticator for m with the given -// key. +// Sum generates an authenticator for msg using a one-time key and puts the +// 16-byte result into out. Authenticating two different messages with the same +// key allows an attacker to forge messages at will. +func Sum(out *[16]byte, m []byte, key *[32]byte) { + sum(out, m, key) +} + +// Verify returns true if mac is a valid authenticator for m with the given key. func Verify(mac *[16]byte, m []byte, key *[32]byte) bool { var tmp [16]byte Sum(&tmp, m, key) diff --git a/vendor/golang.org/x/crypto/poly1305/sum_amd64.go b/vendor/golang.org/x/crypto/poly1305/sum_amd64.go index 2dbf42aa537a5..df56a652ff085 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_amd64.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_amd64.go @@ -7,62 +7,52 @@ package poly1305 //go:noescape -func initialize(state *[7]uint64, key *[32]byte) +func update(state *macState, msg []byte) -//go:noescape -func update(state *[7]uint64, msg []byte) - -//go:noescape -func finalize(tag *[TagSize]byte, state *[7]uint64) - -// Sum generates an authenticator for m using a one-time key and puts the -// 16-byte result into out. Authenticating two different messages with the same -// key allows an attacker to forge messages at will. -func Sum(out *[16]byte, m []byte, key *[32]byte) { +func sum(out *[16]byte, m []byte, key *[32]byte) { h := newMAC(key) h.Write(m) h.Sum(out) } func newMAC(key *[32]byte) (h mac) { - initialize(&h.state, key) + initialize(key, &h.r, &h.s) return } -type mac struct { - state [7]uint64 // := uint64{ h0, h1, h2, r0, r1, pad0, pad1 } - - buffer [TagSize]byte - offset int -} +// mac is a wrapper for macGeneric that redirects calls that would have gone to +// updateGeneric to update. +// +// Its Write and Sum methods are otherwise identical to the macGeneric ones, but +// using function pointers would carry a major performance cost. +type mac struct{ macGeneric } -func (h *mac) Write(p []byte) (n int, err error) { - n = len(p) +func (h *mac) Write(p []byte) (int, error) { + nn := len(p) if h.offset > 0 { - remaining := TagSize - h.offset - if n < remaining { - h.offset += copy(h.buffer[h.offset:], p) - return n, nil + n := copy(h.buffer[h.offset:], p) + if h.offset+n < TagSize { + h.offset += n + return nn, nil } - copy(h.buffer[h.offset:], p[:remaining]) - p = p[remaining:] + p = p[n:] h.offset = 0 - update(&h.state, h.buffer[:]) + update(&h.macState, h.buffer[:]) } - if nn := len(p) - (len(p) % TagSize); nn > 0 { - update(&h.state, p[:nn]) - p = p[nn:] + if n := len(p) - (len(p) % TagSize); n > 0 { + update(&h.macState, p[:n]) + p = p[n:] } if len(p) > 0 { h.offset += copy(h.buffer[h.offset:], p) } - return n, nil + return nn, nil } func (h *mac) Sum(out *[16]byte) { - state := h.state + state := h.macState if h.offset > 0 { update(&state, h.buffer[:h.offset]) } - finalize(out, &state) + finalize(out, &state.h, &state.s) } diff --git a/vendor/golang.org/x/crypto/poly1305/sum_amd64.s b/vendor/golang.org/x/crypto/poly1305/sum_amd64.s index 7d600f13cc87a..8c0cefbb3cb7a 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_amd64.s +++ b/vendor/golang.org/x/crypto/poly1305/sum_amd64.s @@ -54,10 +54,6 @@ ADCQ t3, h1; \ ADCQ $0, h2 -DATA ·poly1305Mask<>+0x00(SB)/8, $0x0FFFFFFC0FFFFFFF -DATA ·poly1305Mask<>+0x08(SB)/8, $0x0FFFFFFC0FFFFFFC -GLOBL ·poly1305Mask<>(SB), RODATA, $16 - // func update(state *[7]uint64, msg []byte) TEXT ·update(SB), $0-32 MOVQ state+0(FP), DI @@ -110,39 +106,3 @@ done: MOVQ R9, 8(DI) MOVQ R10, 16(DI) RET - -// func initialize(state *[7]uint64, key *[32]byte) -TEXT ·initialize(SB), $0-16 - MOVQ state+0(FP), DI - MOVQ key+8(FP), SI - - // state[0...7] is initialized with zero - MOVOU 0(SI), X0 - MOVOU 16(SI), X1 - MOVOU ·poly1305Mask<>(SB), X2 - PAND X2, X0 - MOVOU X0, 24(DI) - MOVOU X1, 40(DI) - RET - -// func finalize(tag *[TagSize]byte, state *[7]uint64) -TEXT ·finalize(SB), $0-16 - MOVQ tag+0(FP), DI - MOVQ state+8(FP), SI - - MOVQ 0(SI), AX - MOVQ 8(SI), BX - MOVQ 16(SI), CX - MOVQ AX, R8 - MOVQ BX, R9 - SUBQ $0xFFFFFFFFFFFFFFFB, AX - SBBQ $0xFFFFFFFFFFFFFFFF, BX - SBBQ $3, CX - CMOVQCS R8, AX - CMOVQCS R9, BX - ADDQ 40(SI), AX - ADCQ 48(SI), BX - - MOVQ AX, 0(DI) - MOVQ BX, 8(DI) - RET diff --git a/vendor/golang.org/x/crypto/poly1305/sum_arm.go b/vendor/golang.org/x/crypto/poly1305/sum_arm.go index 5dc321c2f39e6..6e695e4272e45 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_arm.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_arm.go @@ -6,14 +6,11 @@ package poly1305 -// This function is implemented in sum_arm.s +// poly1305_auth_armv6 is implemented in sum_arm.s //go:noescape func poly1305_auth_armv6(out *[16]byte, m *byte, mlen uint32, key *[32]byte) -// Sum generates an authenticator for m using a one-time key and puts the -// 16-byte result into out. Authenticating two different messages with the same -// key allows an attacker to forge messages at will. -func Sum(out *[16]byte, m []byte, key *[32]byte) { +func sum(out *[16]byte, m []byte, key *[32]byte) { var mPtr *byte if len(m) > 0 { mPtr = &m[0] diff --git a/vendor/golang.org/x/crypto/poly1305/sum_generic.go b/vendor/golang.org/x/crypto/poly1305/sum_generic.go index bab76ef0d83b4..1187eab78fd44 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_generic.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_generic.go @@ -2,18 +2,29 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This file provides the generic implementation of Sum and MAC. Other files +// might provide optimized assembly implementations of some of this code. + package poly1305 import "encoding/binary" -const ( - msgBlock = uint32(1 << 24) - finalBlock = uint32(0) -) +// Poly1305 [RFC 7539] is a relatively simple algorithm: the authentication tag +// for a 64 bytes message is approximately +// +// s + m[0:16] * r⁴ + m[16:32] * r³ + m[32:48] * r² + m[48:64] * r mod 2¹³⁰ - 5 +// +// for some secret r and s. It can be computed sequentially like +// +// for len(msg) > 0: +// h += read(msg, 16) +// h *= r +// h %= 2¹³⁰ - 5 +// return h + s +// +// All the complexity is about doing performant constant-time math on numbers +// larger than any available numeric type. -// sumGeneric generates an authenticator for msg using a one-time key and -// puts the 16-byte result into out. This is the generic implementation of -// Sum and should be called if no assembly implementation is available. func sumGeneric(out *[TagSize]byte, msg []byte, key *[32]byte) { h := newMACGeneric(key) h.Write(msg) @@ -21,152 +32,276 @@ func sumGeneric(out *[TagSize]byte, msg []byte, key *[32]byte) { } func newMACGeneric(key *[32]byte) (h macGeneric) { - h.r[0] = binary.LittleEndian.Uint32(key[0:]) & 0x3ffffff - h.r[1] = (binary.LittleEndian.Uint32(key[3:]) >> 2) & 0x3ffff03 - h.r[2] = (binary.LittleEndian.Uint32(key[6:]) >> 4) & 0x3ffc0ff - h.r[3] = (binary.LittleEndian.Uint32(key[9:]) >> 6) & 0x3f03fff - h.r[4] = (binary.LittleEndian.Uint32(key[12:]) >> 8) & 0x00fffff - - h.s[0] = binary.LittleEndian.Uint32(key[16:]) - h.s[1] = binary.LittleEndian.Uint32(key[20:]) - h.s[2] = binary.LittleEndian.Uint32(key[24:]) - h.s[3] = binary.LittleEndian.Uint32(key[28:]) + initialize(key, &h.r, &h.s) return } +// macState holds numbers in saturated 64-bit little-endian limbs. That is, +// the value of [x0, x1, x2] is x[0] + x[1] * 2⁶⁴ + x[2] * 2¹²⁸. +type macState struct { + // h is the main accumulator. It is to be interpreted modulo 2¹³⁰ - 5, but + // can grow larger during and after rounds. + h [3]uint64 + // r and s are the private key components. + r [2]uint64 + s [2]uint64 +} + type macGeneric struct { - h, r [5]uint32 - s [4]uint32 + macState buffer [TagSize]byte offset int } -func (h *macGeneric) Write(p []byte) (n int, err error) { - n = len(p) +// Write splits the incoming message into TagSize chunks, and passes them to +// update. It buffers incomplete chunks. +func (h *macGeneric) Write(p []byte) (int, error) { + nn := len(p) if h.offset > 0 { - remaining := TagSize - h.offset - if n < remaining { - h.offset += copy(h.buffer[h.offset:], p) - return n, nil + n := copy(h.buffer[h.offset:], p) + if h.offset+n < TagSize { + h.offset += n + return nn, nil } - copy(h.buffer[h.offset:], p[:remaining]) - p = p[remaining:] + p = p[n:] h.offset = 0 - updateGeneric(h.buffer[:], msgBlock, &(h.h), &(h.r)) + updateGeneric(&h.macState, h.buffer[:]) } - if nn := len(p) - (len(p) % TagSize); nn > 0 { - updateGeneric(p, msgBlock, &(h.h), &(h.r)) - p = p[nn:] + if n := len(p) - (len(p) % TagSize); n > 0 { + updateGeneric(&h.macState, p[:n]) + p = p[n:] } if len(p) > 0 { h.offset += copy(h.buffer[h.offset:], p) } - return n, nil + return nn, nil } -func (h *macGeneric) Sum(out *[16]byte) { - H, R := h.h, h.r +// Sum flushes the last incomplete chunk from the buffer, if any, and generates +// the MAC output. It does not modify its state, in order to allow for multiple +// calls to Sum, even if no Write is allowed after Sum. +func (h *macGeneric) Sum(out *[TagSize]byte) { + state := h.macState if h.offset > 0 { - var buffer [TagSize]byte - copy(buffer[:], h.buffer[:h.offset]) - buffer[h.offset] = 1 // invariant: h.offset < TagSize - updateGeneric(buffer[:], finalBlock, &H, &R) + updateGeneric(&state, h.buffer[:h.offset]) } - finalizeGeneric(out, &H, &(h.s)) + finalize(out, &state.h, &state.s) +} + +// [rMask0, rMask1] is the specified Poly1305 clamping mask in little-endian. It +// clears some bits of the secret coefficient to make it possible to implement +// multiplication more efficiently. +const ( + rMask0 = 0x0FFFFFFC0FFFFFFF + rMask1 = 0x0FFFFFFC0FFFFFFC +) + +func initialize(key *[32]byte, r, s *[2]uint64) { + r[0] = binary.LittleEndian.Uint64(key[0:8]) & rMask0 + r[1] = binary.LittleEndian.Uint64(key[8:16]) & rMask1 + s[0] = binary.LittleEndian.Uint64(key[16:24]) + s[1] = binary.LittleEndian.Uint64(key[24:32]) +} + +// uint128 holds a 128-bit number as two 64-bit limbs, for use with the +// bits.Mul64 and bits.Add64 intrinsics. +type uint128 struct { + lo, hi uint64 +} + +func mul64(a, b uint64) uint128 { + hi, lo := bitsMul64(a, b) + return uint128{lo, hi} } -func updateGeneric(msg []byte, flag uint32, h, r *[5]uint32) { - h0, h1, h2, h3, h4 := h[0], h[1], h[2], h[3], h[4] - r0, r1, r2, r3, r4 := uint64(r[0]), uint64(r[1]), uint64(r[2]), uint64(r[3]), uint64(r[4]) - R1, R2, R3, R4 := r1*5, r2*5, r3*5, r4*5 - - for len(msg) >= TagSize { - // h += msg - h0 += binary.LittleEndian.Uint32(msg[0:]) & 0x3ffffff - h1 += (binary.LittleEndian.Uint32(msg[3:]) >> 2) & 0x3ffffff - h2 += (binary.LittleEndian.Uint32(msg[6:]) >> 4) & 0x3ffffff - h3 += (binary.LittleEndian.Uint32(msg[9:]) >> 6) & 0x3ffffff - h4 += (binary.LittleEndian.Uint32(msg[12:]) >> 8) | flag - - // h *= r - d0 := (uint64(h0) * r0) + (uint64(h1) * R4) + (uint64(h2) * R3) + (uint64(h3) * R2) + (uint64(h4) * R1) - d1 := (d0 >> 26) + (uint64(h0) * r1) + (uint64(h1) * r0) + (uint64(h2) * R4) + (uint64(h3) * R3) + (uint64(h4) * R2) - d2 := (d1 >> 26) + (uint64(h0) * r2) + (uint64(h1) * r1) + (uint64(h2) * r0) + (uint64(h3) * R4) + (uint64(h4) * R3) - d3 := (d2 >> 26) + (uint64(h0) * r3) + (uint64(h1) * r2) + (uint64(h2) * r1) + (uint64(h3) * r0) + (uint64(h4) * R4) - d4 := (d3 >> 26) + (uint64(h0) * r4) + (uint64(h1) * r3) + (uint64(h2) * r2) + (uint64(h3) * r1) + (uint64(h4) * r0) - - // h %= p - h0 = uint32(d0) & 0x3ffffff - h1 = uint32(d1) & 0x3ffffff - h2 = uint32(d2) & 0x3ffffff - h3 = uint32(d3) & 0x3ffffff - h4 = uint32(d4) & 0x3ffffff - - h0 += uint32(d4>>26) * 5 - h1 += h0 >> 26 - h0 = h0 & 0x3ffffff - - msg = msg[TagSize:] +func add128(a, b uint128) uint128 { + lo, c := bitsAdd64(a.lo, b.lo, 0) + hi, c := bitsAdd64(a.hi, b.hi, c) + if c != 0 { + panic("poly1305: unexpected overflow") } + return uint128{lo, hi} +} - h[0], h[1], h[2], h[3], h[4] = h0, h1, h2, h3, h4 +func shiftRightBy2(a uint128) uint128 { + a.lo = a.lo>>2 | (a.hi&3)<<62 + a.hi = a.hi >> 2 + return a } -func finalizeGeneric(out *[TagSize]byte, h *[5]uint32, s *[4]uint32) { - h0, h1, h2, h3, h4 := h[0], h[1], h[2], h[3], h[4] - - // h %= p reduction - h2 += h1 >> 26 - h1 &= 0x3ffffff - h3 += h2 >> 26 - h2 &= 0x3ffffff - h4 += h3 >> 26 - h3 &= 0x3ffffff - h0 += 5 * (h4 >> 26) - h4 &= 0x3ffffff - h1 += h0 >> 26 - h0 &= 0x3ffffff - - // h - p - t0 := h0 + 5 - t1 := h1 + (t0 >> 26) - t2 := h2 + (t1 >> 26) - t3 := h3 + (t2 >> 26) - t4 := h4 + (t3 >> 26) - (1 << 26) - t0 &= 0x3ffffff - t1 &= 0x3ffffff - t2 &= 0x3ffffff - t3 &= 0x3ffffff - - // select h if h < p else h - p - t_mask := (t4 >> 31) - 1 - h_mask := ^t_mask - h0 = (h0 & h_mask) | (t0 & t_mask) - h1 = (h1 & h_mask) | (t1 & t_mask) - h2 = (h2 & h_mask) | (t2 & t_mask) - h3 = (h3 & h_mask) | (t3 & t_mask) - h4 = (h4 & h_mask) | (t4 & t_mask) - - // h %= 2^128 - h0 |= h1 << 26 - h1 = ((h1 >> 6) | (h2 << 20)) - h2 = ((h2 >> 12) | (h3 << 14)) - h3 = ((h3 >> 18) | (h4 << 8)) - - // s: the s part of the key - // tag = (h + s) % (2^128) - t := uint64(h0) + uint64(s[0]) - h0 = uint32(t) - t = uint64(h1) + uint64(s[1]) + (t >> 32) - h1 = uint32(t) - t = uint64(h2) + uint64(s[2]) + (t >> 32) - h2 = uint32(t) - t = uint64(h3) + uint64(s[3]) + (t >> 32) - h3 = uint32(t) - - binary.LittleEndian.PutUint32(out[0:], h0) - binary.LittleEndian.PutUint32(out[4:], h1) - binary.LittleEndian.PutUint32(out[8:], h2) - binary.LittleEndian.PutUint32(out[12:], h3) +// updateGeneric absorbs msg into the state.h accumulator. For each chunk m of +// 128 bits of message, it computes +// +// h₊ = (h + m) * r mod 2¹³⁰ - 5 +// +// If the msg length is not a multiple of TagSize, it assumes the last +// incomplete chunk is the final one. +func updateGeneric(state *macState, msg []byte) { + h0, h1, h2 := state.h[0], state.h[1], state.h[2] + r0, r1 := state.r[0], state.r[1] + + for len(msg) > 0 { + var c uint64 + + // For the first step, h + m, we use a chain of bits.Add64 intrinsics. + // The resulting value of h might exceed 2¹³⁰ - 5, but will be partially + // reduced at the end of the multiplication below. + // + // The spec requires us to set a bit just above the message size, not to + // hide leading zeroes. For full chunks, that's 1 << 128, so we can just + // add 1 to the most significant (2¹²⁸) limb, h2. + if len(msg) >= TagSize { + h0, c = bitsAdd64(h0, binary.LittleEndian.Uint64(msg[0:8]), 0) + h1, c = bitsAdd64(h1, binary.LittleEndian.Uint64(msg[8:16]), c) + h2 += c + 1 + + msg = msg[TagSize:] + } else { + var buf [TagSize]byte + copy(buf[:], msg) + buf[len(msg)] = 1 + + h0, c = bitsAdd64(h0, binary.LittleEndian.Uint64(buf[0:8]), 0) + h1, c = bitsAdd64(h1, binary.LittleEndian.Uint64(buf[8:16]), c) + h2 += c + + msg = nil + } + + // Multiplication of big number limbs is similar to elementary school + // columnar multiplication. Instead of digits, there are 64-bit limbs. + // + // We are multiplying a 3 limbs number, h, by a 2 limbs number, r. + // + // h2 h1 h0 x + // r1 r0 = + // ---------------- + // h2r0 h1r0 h0r0 <-- individual 128-bit products + // + h2r1 h1r1 h0r1 + // ------------------------ + // m3 m2 m1 m0 <-- result in 128-bit overlapping limbs + // ------------------------ + // m3.hi m2.hi m1.hi m0.hi <-- carry propagation + // + m3.lo m2.lo m1.lo m0.lo + // ------------------------------- + // t4 t3 t2 t1 t0 <-- final result in 64-bit limbs + // + // The main difference from pen-and-paper multiplication is that we do + // carry propagation in a separate step, as if we wrote two digit sums + // at first (the 128-bit limbs), and then carried the tens all at once. + + h0r0 := mul64(h0, r0) + h1r0 := mul64(h1, r0) + h2r0 := mul64(h2, r0) + h0r1 := mul64(h0, r1) + h1r1 := mul64(h1, r1) + h2r1 := mul64(h2, r1) + + // Since h2 is known to be at most 7 (5 + 1 + 1), and r0 and r1 have their + // top 4 bits cleared by rMask{0,1}, we know that their product is not going + // to overflow 64 bits, so we can ignore the high part of the products. + // + // This also means that the product doesn't have a fifth limb (t4). + if h2r0.hi != 0 { + panic("poly1305: unexpected overflow") + } + if h2r1.hi != 0 { + panic("poly1305: unexpected overflow") + } + + m0 := h0r0 + m1 := add128(h1r0, h0r1) // These two additions don't overflow thanks again + m2 := add128(h2r0, h1r1) // to the 4 masked bits at the top of r0 and r1. + m3 := h2r1 + + t0 := m0.lo + t1, c := bitsAdd64(m1.lo, m0.hi, 0) + t2, c := bitsAdd64(m2.lo, m1.hi, c) + t3, _ := bitsAdd64(m3.lo, m2.hi, c) + + // Now we have the result as 4 64-bit limbs, and we need to reduce it + // modulo 2¹³⁰ - 5. The special shape of this Crandall prime lets us do + // a cheap partial reduction according to the reduction identity + // + // c * 2¹³⁰ + n = c * 5 + n mod 2¹³⁰ - 5 + // + // because 2¹³⁰ = 5 mod 2¹³⁰ - 5. Partial reduction since the result is + // likely to be larger than 2¹³⁰ - 5, but still small enough to fit the + // assumptions we make about h in the rest of the code. + // + // See also https://speakerdeck.com/gtank/engineering-prime-numbers?slide=23 + + // We split the final result at the 2¹³⁰ mark into h and cc, the carry. + // Note that the carry bits are effectively shifted left by 2, in other + // words, cc = c * 4 for the c in the reduction identity. + h0, h1, h2 = t0, t1, t2&maskLow2Bits + cc := uint128{t2 & maskNotLow2Bits, t3} + + // To add c * 5 to h, we first add cc = c * 4, and then add (cc >> 2) = c. + + h0, c = bitsAdd64(h0, cc.lo, 0) + h1, c = bitsAdd64(h1, cc.hi, c) + h2 += c + + cc = shiftRightBy2(cc) + + h0, c = bitsAdd64(h0, cc.lo, 0) + h1, c = bitsAdd64(h1, cc.hi, c) + h2 += c + + // h2 is at most 3 + 1 + 1 = 5, making the whole of h at most + // + // 5 * 2¹²⁸ + (2¹²⁸ - 1) = 6 * 2¹²⁸ - 1 + } + + state.h[0], state.h[1], state.h[2] = h0, h1, h2 +} + +const ( + maskLow2Bits uint64 = 0x0000000000000003 + maskNotLow2Bits uint64 = ^maskLow2Bits +) + +// select64 returns x if v == 1 and y if v == 0, in constant time. +func select64(v, x, y uint64) uint64 { return ^(v-1)&x | (v-1)&y } + +// [p0, p1, p2] is 2¹³⁰ - 5 in little endian order. +const ( + p0 = 0xFFFFFFFFFFFFFFFB + p1 = 0xFFFFFFFFFFFFFFFF + p2 = 0x0000000000000003 +) + +// finalize completes the modular reduction of h and computes +// +// out = h + s mod 2¹²⁸ +// +func finalize(out *[TagSize]byte, h *[3]uint64, s *[2]uint64) { + h0, h1, h2 := h[0], h[1], h[2] + + // After the partial reduction in updateGeneric, h might be more than + // 2¹³⁰ - 5, but will be less than 2 * (2¹³⁰ - 5). To complete the reduction + // in constant time, we compute t = h - (2¹³⁰ - 5), and select h as the + // result if the subtraction underflows, and t otherwise. + + hMinusP0, b := bitsSub64(h0, p0, 0) + hMinusP1, b := bitsSub64(h1, p1, b) + _, b = bitsSub64(h2, p2, b) + + // h = h if h < p else h - p + h0 = select64(b, h0, hMinusP0) + h1 = select64(b, h1, hMinusP1) + + // Finally, we compute the last Poly1305 step + // + // tag = h + s mod 2¹²⁸ + // + // by just doing a wide addition with the 128 low bits of h and discarding + // the overflow. + h0, c := bitsAdd64(h0, s[0], 0) + h1, _ = bitsAdd64(h1, s[1], c) + + binary.LittleEndian.PutUint64(out[0:8], h0) + binary.LittleEndian.PutUint64(out[8:16], h1) } diff --git a/vendor/golang.org/x/crypto/poly1305/sum_noasm.go b/vendor/golang.org/x/crypto/poly1305/sum_noasm.go index 8a9c2070b9f2f..1682eda45f174 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_noasm.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_noasm.go @@ -6,10 +6,7 @@ package poly1305 -// Sum generates an authenticator for msg using a one-time key and puts the -// 16-byte result into out. Authenticating two different messages with the same -// key allows an attacker to forge messages at will. -func Sum(out *[TagSize]byte, msg []byte, key *[32]byte) { +func sum(out *[TagSize]byte, msg []byte, key *[32]byte) { h := newMAC(key) h.Write(msg) h.Sum(out) diff --git a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go index 2402b6371bfcc..3233616935bd8 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go @@ -7,62 +7,52 @@ package poly1305 //go:noescape -func initialize(state *[7]uint64, key *[32]byte) +func update(state *macState, msg []byte) -//go:noescape -func update(state *[7]uint64, msg []byte) - -//go:noescape -func finalize(tag *[TagSize]byte, state *[7]uint64) - -// Sum generates an authenticator for m using a one-time key and puts the -// 16-byte result into out. Authenticating two different messages with the same -// key allows an attacker to forge messages at will. -func Sum(out *[16]byte, m []byte, key *[32]byte) { +func sum(out *[16]byte, m []byte, key *[32]byte) { h := newMAC(key) h.Write(m) h.Sum(out) } func newMAC(key *[32]byte) (h mac) { - initialize(&h.state, key) + initialize(key, &h.r, &h.s) return } -type mac struct { - state [7]uint64 // := uint64{ h0, h1, h2, r0, r1, pad0, pad1 } - - buffer [TagSize]byte - offset int -} +// mac is a wrapper for macGeneric that redirects calls that would have gone to +// updateGeneric to update. +// +// Its Write and Sum methods are otherwise identical to the macGeneric ones, but +// using function pointers would carry a major performance cost. +type mac struct{ macGeneric } -func (h *mac) Write(p []byte) (n int, err error) { - n = len(p) +func (h *mac) Write(p []byte) (int, error) { + nn := len(p) if h.offset > 0 { - remaining := TagSize - h.offset - if n < remaining { - h.offset += copy(h.buffer[h.offset:], p) - return n, nil + n := copy(h.buffer[h.offset:], p) + if h.offset+n < TagSize { + h.offset += n + return nn, nil } - copy(h.buffer[h.offset:], p[:remaining]) - p = p[remaining:] + p = p[n:] h.offset = 0 - update(&h.state, h.buffer[:]) + update(&h.macState, h.buffer[:]) } - if nn := len(p) - (len(p) % TagSize); nn > 0 { - update(&h.state, p[:nn]) - p = p[nn:] + if n := len(p) - (len(p) % TagSize); n > 0 { + update(&h.macState, p[:n]) + p = p[n:] } if len(p) > 0 { h.offset += copy(h.buffer[h.offset:], p) } - return n, nil + return nn, nil } func (h *mac) Sum(out *[16]byte) { - state := h.state + state := h.macState if h.offset > 0 { update(&state, h.buffer[:h.offset]) } - finalize(out, &state) + finalize(out, &state.h, &state.s) } diff --git a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s index 55c7167ec9813..4e20bf299a5ea 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s +++ b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s @@ -58,7 +58,6 @@ DATA ·poly1305Mask<>+0x08(SB)/8, $0x0FFFFFFC0FFFFFFC GLOBL ·poly1305Mask<>(SB), RODATA, $16 // func update(state *[7]uint64, msg []byte) - TEXT ·update(SB), $0-32 MOVD state+0(FP), R3 MOVD msg_base+8(FP), R4 @@ -180,68 +179,3 @@ done: MOVD R9, 8(R3) MOVD R10, 16(R3) RET - -// func initialize(state *[7]uint64, key *[32]byte) -TEXT ·initialize(SB), $0-16 - MOVD state+0(FP), R3 - MOVD key+8(FP), R4 - - // state[0...7] is initialized with zero - // Load key - MOVD 0(R4), R5 - MOVD 8(R4), R6 - MOVD 16(R4), R7 - MOVD 24(R4), R8 - - // Address of key mask - MOVD $·poly1305Mask<>(SB), R9 - - // Save original key in state - MOVD R7, 40(R3) - MOVD R8, 48(R3) - - // Get mask - MOVD (R9), R7 - MOVD 8(R9), R8 - - // And with key - AND R5, R7, R5 - AND R6, R8, R6 - - // Save masked key in state - MOVD R5, 24(R3) - MOVD R6, 32(R3) - RET - -// func finalize(tag *[TagSize]byte, state *[7]uint64) -TEXT ·finalize(SB), $0-16 - MOVD tag+0(FP), R3 - MOVD state+8(FP), R4 - - // Get h0, h1, h2 from state - MOVD 0(R4), R5 - MOVD 8(R4), R6 - MOVD 16(R4), R7 - - // Save h0, h1 - MOVD R5, R8 - MOVD R6, R9 - MOVD $3, R20 - MOVD $-1, R21 - SUBC $-5, R5 - SUBE R21, R6 - SUBE R20, R7 - MOVD $0, R21 - SUBZE R21 - - // Check for carry - CMP $0, R21 - ISEL $2, R5, R8, R5 - ISEL $2, R6, R9, R6 - MOVD 40(R4), R8 - MOVD 48(R4), R9 - ADDC R8, R5 - ADDE R9, R6 - MOVD R5, 0(R3) - MOVD R6, 8(R3) - RET diff --git a/vendor/golang.org/x/crypto/poly1305/sum_s390x.go b/vendor/golang.org/x/crypto/poly1305/sum_s390x.go index ec99e07e9fb49..a8920ee9d21d9 100644 --- a/vendor/golang.org/x/crypto/poly1305/sum_s390x.go +++ b/vendor/golang.org/x/crypto/poly1305/sum_s390x.go @@ -22,10 +22,7 @@ func poly1305vx(out *[16]byte, m *byte, mlen uint64, key *[32]byte) //go:noescape func poly1305vmsl(out *[16]byte, m *byte, mlen uint64, key *[32]byte) -// Sum generates an authenticator for m using a one-time key and puts the -// 16-byte result into out. Authenticating two different messages with the same -// key allows an attacker to forge messages at will. -func Sum(out *[16]byte, m []byte, key *[32]byte) { +func sum(out *[16]byte, m []byte, key *[32]byte) { if cpu.S390X.HasVX { var mPtr *byte if len(m) > 0 { diff --git a/vendor/golang.org/x/crypto/ssh/cipher.go b/vendor/golang.org/x/crypto/ssh/cipher.go index a65a923be3d13..b0204ee59f263 100644 --- a/vendor/golang.org/x/crypto/ssh/cipher.go +++ b/vendor/golang.org/x/crypto/ssh/cipher.go @@ -16,9 +16,8 @@ import ( "hash" "io" "io/ioutil" - "math/bits" - "golang.org/x/crypto/internal/chacha20" + "golang.org/x/crypto/chacha20" "golang.org/x/crypto/poly1305" ) @@ -642,8 +641,8 @@ const chacha20Poly1305ID = "chacha20-poly1305@openssh.com" // the methods here also implement padding, which RFC4253 Section 6 // also requires of stream ciphers. type chacha20Poly1305Cipher struct { - lengthKey [8]uint32 - contentKey [8]uint32 + lengthKey [32]byte + contentKey [32]byte buf []byte } @@ -656,21 +655,21 @@ func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs directionA buf: make([]byte, 256), } - for i := range c.contentKey { - c.contentKey[i] = binary.LittleEndian.Uint32(key[i*4 : (i+1)*4]) - } - for i := range c.lengthKey { - c.lengthKey[i] = binary.LittleEndian.Uint32(key[(i+8)*4 : (i+9)*4]) - } + copy(c.contentKey[:], key[:32]) + copy(c.lengthKey[:], key[32:]) return c, nil } func (c *chacha20Poly1305Cipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) { - nonce := [3]uint32{0, 0, bits.ReverseBytes32(seqNum)} - s := chacha20.New(c.contentKey, nonce) - var polyKey [32]byte + nonce := make([]byte, 12) + binary.BigEndian.PutUint32(nonce[8:], seqNum) + s, err := chacha20.NewUnauthenticatedCipher(c.contentKey[:], nonce) + if err != nil { + return nil, err + } + var polyKey, discardBuf [32]byte s.XORKeyStream(polyKey[:], polyKey[:]) - s.Advance() // skip next 32 bytes + s.XORKeyStream(discardBuf[:], discardBuf[:]) // skip the next 32 bytes encryptedLength := c.buf[:4] if _, err := io.ReadFull(r, encryptedLength); err != nil { @@ -678,7 +677,11 @@ func (c *chacha20Poly1305Cipher) readCipherPacket(seqNum uint32, r io.Reader) ([ } var lenBytes [4]byte - chacha20.New(c.lengthKey, nonce).XORKeyStream(lenBytes[:], encryptedLength) + ls, err := chacha20.NewUnauthenticatedCipher(c.lengthKey[:], nonce) + if err != nil { + return nil, err + } + ls.XORKeyStream(lenBytes[:], encryptedLength) length := binary.BigEndian.Uint32(lenBytes[:]) if length > maxPacket { @@ -724,11 +727,15 @@ func (c *chacha20Poly1305Cipher) readCipherPacket(seqNum uint32, r io.Reader) ([ } func (c *chacha20Poly1305Cipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, payload []byte) error { - nonce := [3]uint32{0, 0, bits.ReverseBytes32(seqNum)} - s := chacha20.New(c.contentKey, nonce) - var polyKey [32]byte + nonce := make([]byte, 12) + binary.BigEndian.PutUint32(nonce[8:], seqNum) + s, err := chacha20.NewUnauthenticatedCipher(c.contentKey[:], nonce) + if err != nil { + return err + } + var polyKey, discardBuf [32]byte s.XORKeyStream(polyKey[:], polyKey[:]) - s.Advance() // skip next 32 bytes + s.XORKeyStream(discardBuf[:], discardBuf[:]) // skip the next 32 bytes // There is no blocksize, so fall back to multiple of 8 byte // padding, as described in RFC 4253, Sec 6. @@ -748,7 +755,11 @@ func (c *chacha20Poly1305Cipher) writeCipherPacket(seqNum uint32, w io.Writer, r } binary.BigEndian.PutUint32(c.buf, uint32(1+len(payload)+padding)) - chacha20.New(c.lengthKey, nonce).XORKeyStream(c.buf, c.buf[:4]) + ls, err := chacha20.NewUnauthenticatedCipher(c.lengthKey[:], nonce) + if err != nil { + return err + } + ls.XORKeyStream(c.buf, c.buf[:4]) c.buf[4] = byte(padding) copy(c.buf[5:], payload) packetEnd := 5 + len(payload) + padding diff --git a/vendor/golang.org/x/crypto/ssh/kex.go b/vendor/golang.org/x/crypto/ssh/kex.go index 16072004b17a9..6c3c648fc952c 100644 --- a/vendor/golang.org/x/crypto/ssh/kex.go +++ b/vendor/golang.org/x/crypto/ssh/kex.go @@ -212,7 +212,7 @@ func (group *dhGroup) Server(c packetConn, randSource io.Reader, magics *handsha HostKey: hostKeyBytes, Signature: sig, Hash: crypto.SHA1, - }, nil + }, err } // ecdh performs Elliptic Curve Diffie-Hellman key exchange as diff --git a/vendor/modules.txt b/vendor/modules.txt index 68834ae7fd38a..414c802772b68 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -436,7 +436,7 @@ go.mongodb.org/mongo-driver/bson/bsonrw go.mongodb.org/mongo-driver/bson/bsontype go.mongodb.org/mongo-driver/bson/primitive go.mongodb.org/mongo-driver/x/bsonx/bsoncore -# golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad +# golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f golang.org/x/crypto/acme golang.org/x/crypto/acme/autocert golang.org/x/crypto/argon2 @@ -444,10 +444,10 @@ golang.org/x/crypto/bcrypt golang.org/x/crypto/blake2b golang.org/x/crypto/blowfish golang.org/x/crypto/cast5 +golang.org/x/crypto/chacha20 golang.org/x/crypto/curve25519 golang.org/x/crypto/ed25519 golang.org/x/crypto/ed25519/internal/edwards25519 -golang.org/x/crypto/internal/chacha20 golang.org/x/crypto/internal/subtle golang.org/x/crypto/md4 golang.org/x/crypto/openpgp From a88a58a83e385531470149628866f557c397a2a8 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Wed, 20 Nov 2019 05:34:34 +0000 Subject: [PATCH 12/17] [skip ci] Updated translations via Crowdin --- options/locale/locale_ja-JP.ini | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index 35213cdd60465..78a85d357593f 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -327,6 +327,11 @@ team_no_units_error=少なくともひとつのリポジトリセクションへ email_been_used=メールアドレスが既に使用されています。 openid_been_used=OpenIDのアドレス '%s' は既に使用されています。 username_password_incorrect=ユーザー名またはパスワードが間違っています。 +password_complexity=パスワードが複雑性の要件を満たしていません: +password_lowercase_one=最低1文字の小文字 +password_uppercase_one=最低1文字の大文字 +password_digit_one=最低1文字の数字 +password_special_one=最低1文字の英字記号 (句読点、括弧、引用符、etc.) enterred_invalid_repo_name=入力したリポジトリ名が間違っています。 enterred_invalid_owner_name=新しいオーナーの名前が正しくありません。 enterred_invalid_password=入力されたパスワードが間違っています。 @@ -864,6 +869,10 @@ issues.closed_title=クローズ issues.num_comments=%d件のコメント issues.commented_at=`が %s にコメント` issues.delete_comment_confirm=このコメントを削除してよろしいですか? +issues.context.copy_link=リンクをコピー +issues.context.quote_reply=引用して返信 +issues.context.edit=編集 +issues.context.delete=削除 issues.no_content=まだ内容がありません issues.close_issue=クローズする issues.close_comment_issue=コメントしてクローズ @@ -873,6 +882,13 @@ issues.create_comment=コメントする issues.closed_at=`がクローズ %[2]s` issues.reopened_at=`が再オープン %[2]s` issues.commit_ref_at=`がコミットでこの課題を参照 %[2]s` +issues.ref_issue_from=`が%[4]s、この課題を参照 %[2]s` +issues.ref_pull_from=`が%[4]s、このプルリクエストを参照 %[2]s` +issues.ref_closing_from=`が%[4]s、プルリクエストがこの課題をクローズするよう参照 %[2]s` +issues.ref_reopening_from=`が%[4]s、プルリクエストがこの課題を再オープンするよう参照 %[2]s` +issues.ref_closed_from=`が%[4]s、この課題をクローズ %[2]s` +issues.ref_reopened_from=`が%[4]s、この課題を再オープン %[2]s` +issues.ref_from=` %[1]s にて` issues.poster=投稿者 issues.collaborator=共同作業者 issues.owner=オーナー From a85d916d3ebf5a6dcdc616f7e98926a952a7b144 Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Wed, 20 Nov 2019 03:17:14 -0300 Subject: [PATCH 13/17] Fix doc example for asciidoc (#9072) * Fix doc example for asciidoc * Update config-cheat-sheet.en-us.md * Update docs/content/doc/advanced/config-cheat-sheet.en-us.md Co-Authored-By: Lauris BH --- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index f56ed34e431e4..327efb34bd097 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -558,13 +558,13 @@ Gitea can support Markup using external tools. The example below will add a mark ```ini [markup.asciidoc] -ENABLED = false +ENABLED = true FILE_EXTENSIONS = .adoc,.asciidoc RENDER_COMMAND = "asciidoc --out-file=- -" IS_INPUT_FILE = false ``` -- ENABLED: **false** Enable markup support. +- ENABLED: **false** Enable markup support; set to **true** to enable this renderer. - FILE\_EXTENSIONS: **\** List of file extensions that should be rendered by an external command. Multiple extentions needs a comma as splitter. - RENDER\_COMMAND: External command to render all matching extensions. From 35c3ea952a6eb558e69de55fc94d301676feb935 Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Wed, 20 Nov 2019 10:07:09 +0100 Subject: [PATCH 14/17] Explore page: Add topic param to pagination (#9077) (#9078) --- routers/home.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/home.go b/routers/home.go index eddff28ee9965..50e1a2b2a4270 100644 --- a/routers/home.go +++ b/routers/home.go @@ -132,6 +132,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { keyword := strings.Trim(ctx.Query("q"), " ") topicOnly := ctx.QueryBool("topic") + ctx.Data["TopicOnly"] = topicOnly repos, count, err = models.SearchRepository(&models.SearchRepoOptions{ Page: page, @@ -155,6 +156,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { pager := context.NewPagination(int(count), opts.PageSize, page, 5) pager.SetDefaultParams(ctx) + pager.AddParam(ctx, "topic", "TopicOnly") ctx.Data["Page"] = pager ctx.HTML(200, opts.TplName) From 69a255defbf2747b066b2aeee66ba76cdd37104d Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Wed, 20 Nov 2019 12:27:49 +0100 Subject: [PATCH 15/17] Team permission to create repository in organization (#8312) * Add team permission setting to allow creating repo in organization. Signed-off-by: David Svantesson * Add test case for creating repo when have team creation access. Signed-off-by: David Svantesson * build error: should omit comparison to bool constant Signed-off-by: David Svantesson * Add comment on exported functions * Fix fixture consistency, fix existing unit tests * Fix boolean comparison in xorm query. * addCollaborator and changeCollaborationAccessMode separate steps More clear to use different if-cases. * Create and commit xorm session * fix * Add information of create repo permission in team sidebar * Add migration step * Clarify that repository creator will be administrator. * Fix some things after merge * Fix language text that use html * migrations file * Create repository permission -> Create repositories * fix merge * fix review comments --- integrations/api_repo_test.go | 2 ++ models/fixtures/org_user.yml | 13 +++++++++ models/fixtures/team.yml | 20 +++++++++++++ models/fixtures/team_user.yml | 12 ++++++++ models/fixtures/user.yml | 28 +++++++++++++++--- models/migrations/migrations.go | 2 ++ models/migrations/v109.go | 17 +++++++++++ models/org.go | 32 ++++++++++++++++++++ models/org_team.go | 1 + models/org_test.go | 12 ++++---- models/repo.go | 12 ++++++++ models/repo_collaboration.go | 52 ++++++++++++++++++++------------- models/user_test.go | 4 +-- models/userlist_test.go | 12 ++++---- modules/auth/org.go | 11 +++---- modules/context/org.go | 21 +++++++++---- modules/convert/convert.go | 1 + modules/structs/org_team.go | 9 ++++-- options/locale/locale_en-US.ini | 3 ++ routers/api/v1/org/team.go | 2 ++ routers/api/v1/repo/repo.go | 8 ++--- routers/org/teams.go | 2 ++ routers/repo/repo.go | 10 +++---- templates/org/home.tmpl | 2 +- templates/org/team/new.tmpl | 12 ++++++-- templates/org/team/sidebar.tmpl | 3 ++ templates/swagger/v1_json.tmpl | 12 ++++++++ 27 files changed, 252 insertions(+), 63 deletions(-) create mode 100644 models/migrations/v109.go diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 1682f386d31e9..e021911afdb2d 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -347,6 +347,8 @@ func TestAPIOrgRepoCreate(t *testing.T) { {ctxUserID: 1, orgName: "user3", repoName: "repo-admin", expectedStatus: http.StatusCreated}, {ctxUserID: 2, orgName: "user3", repoName: "repo-own", expectedStatus: http.StatusCreated}, {ctxUserID: 2, orgName: "user6", repoName: "repo-bad-org", expectedStatus: http.StatusForbidden}, + {ctxUserID: 28, orgName: "user3", repoName: "repo-creator", expectedStatus: http.StatusCreated}, + {ctxUserID: 28, orgName: "user6", repoName: "repo-not-creator", expectedStatus: http.StatusForbidden}, } prepareTestEnv(t) diff --git a/models/fixtures/org_user.yml b/models/fixtures/org_user.yml index 385492dd68d11..0b6a5e60a70fe 100644 --- a/models/fixtures/org_user.yml +++ b/models/fixtures/org_user.yml @@ -45,3 +45,16 @@ uid: 24 org_id: 25 is_public: true + +- + id: 9 + uid: 28 + org_id: 3 + is_public: true + +- + id: 10 + uid: 28 + org_id: 6 + is_public: true + diff --git a/models/fixtures/team.yml b/models/fixtures/team.yml index 4da87b731fff0..b7e38561720e2 100644 --- a/models/fixtures/team.yml +++ b/models/fixtures/team.yml @@ -96,3 +96,23 @@ authorize: 1 # read num_repos: 0 num_members: 0 + +- + id: 12 + org_id: 3 + lower_name: team12creators + name: team12Creators + authorize: 3 # admin + num_repos: 0 + num_members: 1 + can_create_org_repo: true + +- + id: 13 + org_id: 6 + lower_name: team13notcreators + name: team13NotCreators + authorize: 3 # admin + num_repos: 0 + num_members: 1 + can_create_org_repo: false diff --git a/models/fixtures/team_user.yml b/models/fixtures/team_user.yml index 4fc609791d396..d541156fe826f 100644 --- a/models/fixtures/team_user.yml +++ b/models/fixtures/team_user.yml @@ -69,3 +69,15 @@ org_id: 25 team_id: 10 uid: 24 + +- + id: 13 + org_id: 3 + team_id: 12 + uid: 28 + +- + id: 14 + org_id: 6 + team_id: 13 + uid: 28 diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index 5a3b04994cc99..17294b881f08d 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -50,8 +50,8 @@ avatar: avatar3 avatar_email: user3@example.com num_repos: 3 - num_members: 2 - num_teams: 3 + num_members: 3 + num_teams: 4 - id: 4 @@ -102,8 +102,8 @@ avatar: avatar6 avatar_email: user6@example.com num_repos: 0 - num_members: 1 - num_teams: 1 + num_members: 2 + num_teams: 2 - id: 7 @@ -443,3 +443,23 @@ avatar: avatar27 avatar_email: user27@example.com num_repos: 2 + +- + id: 28 + lower_name: user28 + name: user28 + full_name: "user27" + email: user28@example.com + keep_email_private: true + passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password + type: 0 # individual + salt: ZogKvWdyEx + is_admin: false + avatar: avatar28 + avatar_email: user28@example.com + num_repos: 0 + num_stars: 0 + num_followers: 0 + num_following: 0 + is_active: true + diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index e5bfc2b881eae..df82fe9b8b1f6 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -272,6 +272,8 @@ var migrations = []Migration{ NewMigration("Add template options to repository", addTemplateToRepo), // v108 -> v109 NewMigration("Add comment_id on table notification", addCommentIDOnNotification), + // v109 -> v110 + NewMigration("add can_create_org_repo to team", addCanCreateOrgRepoColumnForTeam), } // Migrate database to current version diff --git a/models/migrations/v109.go b/models/migrations/v109.go new file mode 100644 index 0000000000000..abe731768116b --- /dev/null +++ b/models/migrations/v109.go @@ -0,0 +1,17 @@ +// Copyright 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "xorm.io/xorm" +) + +func addCanCreateOrgRepoColumnForTeam(x *xorm.Engine) error { + type Team struct { + CanCreateOrgRepo bool `xorm:"NOT NULL DEFAULT false"` + } + + return x.Sync2(new(Team)) +} diff --git a/models/org.go b/models/org.go index 78b035b10147b..f14dad1dbb625 100644 --- a/models/org.go +++ b/models/org.go @@ -29,6 +29,11 @@ func (org *User) IsOrgMember(uid int64) (bool, error) { return IsOrganizationMember(org.ID, uid) } +// CanCreateOrgRepo returns true if given user can create repo in organization +func (org *User) CanCreateOrgRepo(uid int64) (bool, error) { + return CanCreateOrgRepo(org.ID, uid) +} + func (org *User) getTeam(e Engine, name string) (*Team, error) { return getTeam(e, org.ID, name) } @@ -158,6 +163,7 @@ func CreateOrganization(org, owner *User) (err error) { Authorize: AccessModeOwner, NumMembers: 1, IncludesAllRepositories: true, + CanCreateOrgRepo: true, } if _, err = sess.Insert(t); err != nil { return fmt.Errorf("insert owner team: %v", err) @@ -339,6 +345,19 @@ func IsPublicMembership(orgID, uid int64) (bool, error) { Exist() } +// CanCreateOrgRepo returns true if user can create repo in organization +func CanCreateOrgRepo(orgID, uid int64) (bool, error) { + if owner, err := IsOrganizationOwner(orgID, uid); owner || err != nil { + return owner, err + } + return x. + Where(builder.Eq{"team.can_create_org_repo": true}). + Join("INNER", "team_user", "team_user.team_id = team.id"). + And("team_user.uid = ?", uid). + And("team_user.org_id = ?", orgID). + Exist(new(Team)) +} + func getOrgsByUserID(sess *xorm.Session, userID int64, showAll bool) ([]*User, error) { orgs := make([]*User, 0, 10) if !showAll { @@ -418,6 +437,19 @@ func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) { return getOwnedOrgsByUserID(x.Desc(desc), userID) } +// GetOrgsCanCreateRepoByUserID returns a list of organizations where given user ID +// are allowed to create repos. +func GetOrgsCanCreateRepoByUserID(userID int64) ([]*User, error) { + orgs := make([]*User, 0, 10) + + return orgs, x.Join("INNER", "`team_user`", "`team_user`.org_id=`user`.id"). + Join("INNER", "`team`", "`team`.id=`team_user`.team_id"). + Where("`team_user`.uid=?", userID). + And(builder.Eq{"`team`.authorize": AccessModeOwner}.Or(builder.Eq{"`team`.can_create_org_repo": true})). + Desc("`user`.updated_unix"). + Find(&orgs) +} + // GetOrgUsersByUserID returns all organization-user relations by user ID. func GetOrgUsersByUserID(uid int64, all bool) ([]*OrgUser, error) { ous := make([]*OrgUser, 0, 10) diff --git a/models/org_team.go b/models/org_team.go index 126a8c896a212..2dadf3820c294 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -34,6 +34,7 @@ type Team struct { NumMembers int Units []*TeamUnit `xorm:"-"` IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"` + CanCreateOrgRepo bool `xorm:"NOT NULL DEFAULT false"` } // SearchTeamOptions holds the search options diff --git a/models/org_test.go b/models/org_test.go index 2f2c5a2d5eb19..1a6b288dc75dd 100644 --- a/models/org_test.go +++ b/models/org_test.go @@ -87,10 +87,11 @@ func TestUser_GetTeams(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) org := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User) assert.NoError(t, org.GetTeams()) - if assert.Len(t, org.Teams, 3) { + if assert.Len(t, org.Teams, 4) { assert.Equal(t, int64(1), org.Teams[0].ID) assert.Equal(t, int64(2), org.Teams[1].ID) - assert.Equal(t, int64(7), org.Teams[2].ID) + assert.Equal(t, int64(12), org.Teams[2].ID) + assert.Equal(t, int64(7), org.Teams[3].ID) } } @@ -98,9 +99,10 @@ func TestUser_GetMembers(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) org := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User) assert.NoError(t, org.GetMembers()) - if assert.Len(t, org.Members, 2) { + if assert.Len(t, org.Members, 3) { assert.Equal(t, int64(2), org.Members[0].ID) - assert.Equal(t, int64(4), org.Members[1].ID) + assert.Equal(t, int64(28), org.Members[1].ID) + assert.Equal(t, int64(4), org.Members[2].ID) } } @@ -395,7 +397,7 @@ func TestGetOrgUsersByOrgID(t *testing.T) { orgUsers, err := GetOrgUsersByOrgID(3) assert.NoError(t, err) - if assert.Len(t, orgUsers, 2) { + if assert.Len(t, orgUsers, 3) { assert.Equal(t, OrgUser{ ID: orgUsers[0].ID, OrgID: 3, diff --git a/models/repo.go b/models/repo.go index 851add409f372..eecc36377b354 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1586,6 +1586,18 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err } } } + + if isAdmin, err := isUserRepoAdmin(e, repo, doer); err != nil { + return fmt.Errorf("isUserRepoAdmin: %v", err) + } else if !isAdmin { + // Make creator repo admin if it wan't assigned automatically + if err = repo.addCollaborator(e, doer); err != nil { + return fmt.Errorf("AddCollaborator: %v", err) + } + if err = repo.changeCollaborationAccessMode(e, doer.ID, AccessModeAdmin); err != nil { + return fmt.Errorf("ChangeCollaborationAccessMode: %v", err) + } + } } else if err = repo.recalculateAccesses(e); err != nil { // Organization automatically called this in addRepository method. return fmt.Errorf("recalculateAccesses: %v", err) diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go index 3d6447c1963b3..f04507f3e830c 100644 --- a/models/repo_collaboration.go +++ b/models/repo_collaboration.go @@ -16,14 +16,13 @@ type Collaboration struct { Mode AccessMode `xorm:"DEFAULT 2 NOT NULL"` } -// AddCollaborator adds new collaboration to a repository with default access mode. -func (repo *Repository) AddCollaborator(u *User) error { +func (repo *Repository) addCollaborator(e Engine, u *User) error { collaboration := &Collaboration{ RepoID: repo.ID, UserID: u.ID, } - has, err := x.Get(collaboration) + has, err := e.Get(collaboration) if err != nil { return err } else if has { @@ -31,18 +30,23 @@ func (repo *Repository) AddCollaborator(u *User) error { } collaboration.Mode = AccessModeWrite - sess := x.NewSession() - defer sess.Close() - if err = sess.Begin(); err != nil { + if _, err = e.InsertOne(collaboration); err != nil { return err } - if _, err = sess.InsertOne(collaboration); err != nil { + return repo.recalculateUserAccess(e, u.ID) +} + +// AddCollaborator adds new collaboration to a repository with default access mode. +func (repo *Repository) AddCollaborator(u *User) error { + sess := x.NewSession() + defer sess.Close() + if err := sess.Begin(); err != nil { return err } - if err = repo.recalculateUserAccess(sess, u.ID); err != nil { - return fmt.Errorf("recalculateAccesses 'team=%v': %v", repo.Owner.IsOrganization(), err) + if err := repo.addCollaborator(sess, u); err != nil { + return err } return sess.Commit() @@ -105,8 +109,7 @@ func (repo *Repository) IsCollaborator(userID int64) (bool, error) { return repo.isCollaborator(x, userID) } -// ChangeCollaborationAccessMode sets new access mode for the collaboration. -func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode) error { +func (repo *Repository) changeCollaborationAccessMode(e Engine, uid int64, mode AccessMode) error { // Discard invalid input if mode <= AccessModeNone || mode > AccessModeOwner { return nil @@ -116,7 +119,7 @@ func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode RepoID: repo.ID, UserID: uid, } - has, err := x.Get(collaboration) + has, err := e.Get(collaboration) if err != nil { return fmt.Errorf("get collaboration: %v", err) } else if !has { @@ -128,21 +131,30 @@ func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode } collaboration.Mode = mode - sess := x.NewSession() - defer sess.Close() - if err = sess.Begin(); err != nil { - return err - } - - if _, err = sess. + if _, err = e. ID(collaboration.ID). Cols("mode"). Update(collaboration); err != nil { return fmt.Errorf("update collaboration: %v", err) - } else if _, err = sess.Exec("UPDATE access SET mode = ? WHERE user_id = ? AND repo_id = ?", mode, uid, repo.ID); err != nil { + } else if _, err = e.Exec("UPDATE access SET mode = ? WHERE user_id = ? AND repo_id = ?", mode, uid, repo.ID); err != nil { return fmt.Errorf("update access table: %v", err) } + return nil +} + +// ChangeCollaborationAccessMode sets new access mode for the collaboration. +func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode) error { + sess := x.NewSession() + defer sess.Close() + if err := sess.Begin(); err != nil { + return err + } + + if err := repo.changeCollaborationAccessMode(sess, uid, mode); err != nil { + return err + } + return sess.Commit() } diff --git a/models/user_test.go b/models/user_test.go index 2969e34a76ece..95f4d5d3633bb 100644 --- a/models/user_test.go +++ b/models/user_test.go @@ -153,13 +153,13 @@ func TestSearchUsers(t *testing.T) { } testUserSuccess(&SearchUserOptions{OrderBy: "id ASC", Page: 1}, - []int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27}) + []int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28}) testUserSuccess(&SearchUserOptions{Page: 1, IsActive: util.OptionalBoolFalse}, []int64{9}) testUserSuccess(&SearchUserOptions{OrderBy: "id ASC", Page: 1, IsActive: util.OptionalBoolTrue}, - []int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24}) + []int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 28}) testUserSuccess(&SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", Page: 1, IsActive: util.OptionalBoolTrue}, []int64{1, 10, 11, 12, 13, 14, 15, 16, 18}) diff --git a/models/userlist_test.go b/models/userlist_test.go index ca08cc90ce89c..c48cfb61c168b 100644 --- a/models/userlist_test.go +++ b/models/userlist_test.go @@ -17,8 +17,8 @@ func TestUserListIsPublicMember(t *testing.T) { orgid int64 expected map[int64]bool }{ - {3, map[int64]bool{2: true, 4: false}}, - {6, map[int64]bool{5: true}}, + {3, map[int64]bool{2: true, 4: false, 28: true}}, + {6, map[int64]bool{5: true, 28: true}}, {7, map[int64]bool{5: false}}, {25, map[int64]bool{24: true}}, {22, map[int64]bool{}}, @@ -43,8 +43,8 @@ func TestUserListIsUserOrgOwner(t *testing.T) { orgid int64 expected map[int64]bool }{ - {3, map[int64]bool{2: true, 4: false}}, - {6, map[int64]bool{5: true}}, + {3, map[int64]bool{2: true, 4: false, 28: false}}, + {6, map[int64]bool{5: true, 28: false}}, {7, map[int64]bool{5: true}}, {25, map[int64]bool{24: false}}, // ErrTeamNotExist {22, map[int64]bool{}}, // No member @@ -69,8 +69,8 @@ func TestUserListIsTwoFaEnrolled(t *testing.T) { orgid int64 expected map[int64]bool }{ - {3, map[int64]bool{2: false, 4: false}}, - {6, map[int64]bool{5: false}}, + {3, map[int64]bool{2: false, 4: false, 28: false}}, + {6, map[int64]bool{5: false, 28: false}}, {7, map[int64]bool{5: false}}, {25, map[int64]bool{24: true}}, {22, map[int64]bool{}}, diff --git a/modules/auth/org.go b/modules/auth/org.go index 509358882a385..20e2b09997e20 100644 --- a/modules/auth/org.go +++ b/modules/auth/org.go @@ -58,11 +58,12 @@ func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs binding.Error // CreateTeamForm form for creating team type CreateTeamForm struct { - TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"` - Description string `binding:"MaxSize(255)"` - Permission string - Units []models.UnitType - RepoAccess string + TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"` + Description string `binding:"MaxSize(255)"` + Permission string + Units []models.UnitType + RepoAccess string + CanCreateOrgRepo bool } // Validate validates the fields diff --git a/modules/context/org.go b/modules/context/org.go index 10791c9d01061..ae19aebfcc6c0 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -15,12 +15,13 @@ import ( // Organization contains organization context type Organization struct { - IsOwner bool - IsMember bool - IsTeamMember bool // Is member of team. - IsTeamAdmin bool // In owner team or team that has admin permission level. - Organization *models.User - OrgLink string + IsOwner bool + IsMember bool + IsTeamMember bool // Is member of team. + IsTeamAdmin bool // In owner team or team that has admin permission level. + Organization *models.User + OrgLink string + CanCreateOrgRepo bool Team *models.Team } @@ -73,6 +74,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Org.IsMember = true ctx.Org.IsTeamMember = true ctx.Org.IsTeamAdmin = true + ctx.Org.CanCreateOrgRepo = true } else if ctx.IsSigned { ctx.Org.IsOwner, err = org.IsOwnedBy(ctx.User.ID) if err != nil { @@ -84,12 +86,18 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Org.IsMember = true ctx.Org.IsTeamMember = true ctx.Org.IsTeamAdmin = true + ctx.Org.CanCreateOrgRepo = true } else { ctx.Org.IsMember, err = org.IsOrgMember(ctx.User.ID) if err != nil { ctx.ServerError("IsOrgMember", err) return } + ctx.Org.CanCreateOrgRepo, err = org.CanCreateOrgRepo(ctx.User.ID) + if err != nil { + ctx.ServerError("CanCreateOrgRepo", err) + return + } } } else { // Fake data. @@ -102,6 +110,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { } ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember + ctx.Data["CanCreateOrgRepo"] = ctx.Org.CanCreateOrgRepo ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.Name ctx.Data["OrgLink"] = ctx.Org.OrgLink diff --git a/modules/convert/convert.go b/modules/convert/convert.go index f65e4b4fe2409..d3b2e38165b95 100644 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -249,6 +249,7 @@ func ToTeam(team *models.Team) *api.Team { Name: team.Name, Description: team.Description, IncludesAllRepositories: team.IncludesAllRepositories, + CanCreateOrgRepo: team.CanCreateOrgRepo, Permission: team.Authorize.String(), Units: team.GetUnitNames(), } diff --git a/modules/structs/org_team.go b/modules/structs/org_team.go index 5053468b4a53d..16f83823d66b5 100644 --- a/modules/structs/org_team.go +++ b/modules/structs/org_team.go @@ -15,7 +15,8 @@ type Team struct { // enum: none,read,write,admin,owner Permission string `json:"permission"` // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] - Units []string `json:"units"` + Units []string `json:"units"` + CanCreateOrgRepo bool `json:"can_create_org_repo"` } // CreateTeamOption options for creating a team @@ -27,7 +28,8 @@ type CreateTeamOption struct { // enum: read,write,admin Permission string `json:"permission"` // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] - Units []string `json:"units"` + Units []string `json:"units"` + CanCreateOrgRepo bool `json:"can_create_org_repo"` } // EditTeamOption options for editing a team @@ -39,5 +41,6 @@ type EditTeamOption struct { // enum: read,write,admin Permission string `json:"permission"` // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] - Units []string `json:"units"` + Units []string `json:"units"` + CanCreateOrgRepo bool `json:"can_create_org_repo"` } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 99304c470d39d..b38e909e48881 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1596,6 +1596,8 @@ members.invite_now = Invite Now teams.join = Join teams.leave = Leave +teams.can_create_org_repo = Create repositories +teams.can_create_org_repo_helper = Members can create new repositories in organization. Creator will get administrator access to the new repository. teams.read_access = Read Access teams.read_access_helper = Members can view and clone team repositories. teams.write_access = Write Access @@ -1615,6 +1617,7 @@ teams.delete_team_success = The team has been deleted. teams.read_permission_desc = This team grants Read access: members can view and clone team repositories. teams.write_permission_desc = This team grants Write access: members can read from and push to team repositories. teams.admin_permission_desc = This team grants Admin access: members can read from, push to and add collaborators to team repositories. +teams.create_repo_permission_desc = Additionally, this team grants Create repository permission: members can create new repositories in organization. teams.repositories = Team Repositories teams.search_repo_placeholder = Search repository… teams.remove_all_repos_title = Remove all team repositories diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index b2b5fe6dadb38..c14742e3a4e64 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -132,6 +132,7 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { Name: form.Name, Description: form.Description, IncludesAllRepositories: form.IncludesAllRepositories, + CanCreateOrgRepo: form.CanCreateOrgRepo, Authorize: models.ParseAccessMode(form.Permission), } @@ -185,6 +186,7 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) { team := ctx.Org.Team team.Description = form.Description unitTypes := models.FindUnitTypes(form.Units...) + team.CanCreateOrgRepo = form.CanCreateOrgRepo isAuthChanged := false isIncludeAllChanged := false diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 05ab9cb38b174..e2a3bfc873018 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -322,12 +322,12 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { } if !ctx.User.IsAdmin { - isOwner, err := org.IsOwnedBy(ctx.User.ID) + canCreate, err := org.CanCreateOrgRepo(ctx.User.ID) if err != nil { - ctx.ServerError("IsOwnedBy", err) + ctx.ServerError("CanCreateOrgRepo", err) return - } else if !isOwner { - ctx.Error(403, "", "Given user is not owner of organization.") + } else if !canCreate { + ctx.Error(403, "", "Given user is not allowed to create repository in organization.") return } } diff --git a/routers/org/teams.go b/routers/org/teams.go index 873265803fd43..2aa69f5e93d45 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -201,6 +201,7 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { Description: form.Description, Authorize: models.ParseAccessMode(form.Permission), IncludesAllRepositories: includesAllRepositories, + CanCreateOrgRepo: form.CanCreateOrgRepo, } if t.Authorize < models.AccessModeOwner { @@ -316,6 +317,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { return } } + t.CanCreateOrgRepo = form.CanCreateOrgRepo if ctx.HasError() { ctx.HTML(200, tplTeamNew) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index cb4e483333005..b78dd5376ee07 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -53,9 +53,9 @@ func MustBeAbleToUpload(ctx *context.Context) { } func checkContextUser(ctx *context.Context, uid int64) *models.User { - orgs, err := models.GetOwnedOrgsByUserIDDesc(ctx.User.ID, "updated_unix") + orgs, err := models.GetOrgsCanCreateRepoByUserID(ctx.User.ID) if err != nil { - ctx.ServerError("GetOwnedOrgsByUserIDDesc", err) + ctx.ServerError("GetOrgsCanCreateRepoByUserID", err) return nil } ctx.Data["Orgs"] = orgs @@ -81,11 +81,11 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User { return nil } if !ctx.User.IsAdmin { - isOwner, err := org.IsOwnedBy(ctx.User.ID) + canCreate, err := org.CanCreateOrgRepo(ctx.User.ID) if err != nil { - ctx.ServerError("IsOwnedBy", err) + ctx.ServerError("CanCreateOrgRepo", err) return nil - } else if !isOwner { + } else if !canCreate { ctx.Error(403) return nil } diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 03bb5252767f7..0aa575707ab3c 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -22,7 +22,7 @@
- {{if .IsOrganizationOwner}} + {{if .CanCreateOrgRepo}} diff --git a/templates/org/team/new.tmpl b/templates/org/team/new.tmpl index e50a1777d2002..c38fa4d94019a 100644 --- a/templates/org/team/new.tmpl +++ b/templates/org/team/new.tmpl @@ -31,14 +31,22 @@
- {{.i18n.Tr "org.teams.specific_repositories_helper"}} + {{.i18n.Tr "org.teams.specific_repositories_helper" | Str2html}}
- {{.i18n.Tr "org.teams.all_repositories_helper"}} + {{.i18n.Tr "org.teams.all_repositories_helper" | Str2html}} +
+
+ +
+
+ + + {{.i18n.Tr "org.teams.can_create_org_repo_helper"}}
diff --git a/templates/org/team/sidebar.tmpl b/templates/org/team/sidebar.tmpl index dd189df5f313b..75c5ce756d445 100644 --- a/templates/org/team/sidebar.tmpl +++ b/templates/org/team/sidebar.tmpl @@ -40,6 +40,9 @@ {{.i18n.Tr "org.teams.admin_permission_desc" | Str2html}} {{end}} {{end}} + {{if .Team.CanCreateOrgRepo}} +

{{.i18n.Tr "org.teams.create_repo_permission_desc" | Str2html}} + {{end}}
{{if .IsOrganizationOwner}} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 6b424131c5d48..4427c28747366 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -8279,6 +8279,10 @@ "name" ], "properties": { + "can_create_org_repo": { + "type": "boolean", + "x-go-name": "CanCreateOrgRepo" + }, "description": { "type": "string", "x-go-name": "Description" @@ -8847,6 +8851,10 @@ "name" ], "properties": { + "can_create_org_repo": { + "type": "boolean", + "x-go-name": "CanCreateOrgRepo" + }, "description": { "type": "string", "x-go-name": "Description" @@ -10506,6 +10514,10 @@ "description": "Team represents a team in an organization", "type": "object", "properties": { + "can_create_org_repo": { + "type": "boolean", + "x-go-name": "CanCreateOrgRepo" + }, "description": { "type": "string", "x-go-name": "Description" From dfd8b94923b90edbd3109f5afc3670fb1012e9c8 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Wed, 20 Nov 2019 11:58:10 +0000 Subject: [PATCH 16/17] [skip ci] Updated translations via Crowdin --- options/locale/locale_pt-BR.ini | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index 8c6dd5d70d1e2..7458eb881ac20 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -327,6 +327,11 @@ team_no_units_error=Permitir acesso a pelo menos uma seção de repositório. email_been_used=Este endereço de e-mail já está sendo usado. openid_been_used=O endereço OpenID '%s' já está sendo usado. username_password_incorrect=Nome de usuário ou senha incorretos. +password_complexity=A senha não passa pelos requisitos de complexidade: +password_lowercase_one=Pelo menos um caractere minúsculo +password_uppercase_one=Pelo menos um caractere maiúsculo +password_digit_one=Pelo menos um dígito +password_special_one=Pelo menos um caractere especial (pontuação, parênteses, aspas, etc.) enterred_invalid_repo_name=O nome do repositório que você digitou está incorreto. enterred_invalid_owner_name=O nome do novo proprietário não é válido. enterred_invalid_password=A senha que você digitou está incorreta. @@ -865,6 +870,10 @@ issues.closed_title=Fechado issues.num_comments=%d comentários issues.commented_at=`comentou %s` issues.delete_comment_confirm=Tem certeza que deseja excluir este comentário? +issues.context.copy_link=Copiar link +issues.context.quote_reply=Citar resposta +issues.context.edit=Editar +issues.context.delete=Excluir issues.no_content=Ainda não há conteúdo. issues.close_issue=Fechar issues.close_comment_issue=Comentar e fechar @@ -1043,6 +1052,7 @@ pulls.rebase_merge_commit_pull_request=Aplicar Rebase e Merge (--no-ff) pulls.squash_merge_pull_request=Aplicar Squash e Merge pulls.invalid_merge_option=Você não pode usar esta opção de merge neste pull request. pulls.merge_conflict=Merge falhou: Houve um conflito durante o merge: %[1]s
%[2]s
Dica: Tente uma estratégia diferente +pulls.rebase_conflict=Merge Falhou: Houve um conflito durante o rebase do commit: %[1]s
%[2]s
%[3]s
Dica: Tente uma estratégia diferente pulls.unrelated_histories=Merge falhou: O merge do principal e da base não compartilham uma história comum. Dica: Tente uma estratégia diferente pulls.merge_out_of_date=Merge falhou: durante a geração do merge, a base não foi atualizada. Dica: Tente novamente. pulls.open_unmerged_pull_exists=`Não é possível executar uma operação de reabertura pois há um pull request pendente (#%d) com propriedades idênticas.` From 2ab8c78c30f6e29206b07fe15b0aec6c21df7005 Mon Sep 17 00:00:00 2001 From: 6543 <24977596+6543@users.noreply.github.com> Date: Wed, 20 Nov 2019 15:50:54 +0100 Subject: [PATCH 17/17] Refactor Issues Subscription (#8738) * FIX: getIssueWatchers() get only aktive suscriber * save query to work later with it or not ... * fix test + add new case * corect tests + GetIssueWatch * API issue_subscripton: Put/Delete require tocken * remove redundant code * swagger specify return value * remove unused binding * remove note because I'll implement this in a different way and in another PR * ID should be unique! * use xorm session * Revert "use xorm session" This reverts commit c1de540147199f2f1a8dd0d008f54af3603e2229. * better test code * more acurate comments * use assert.False/True instead of Equal * use more assert methodes --- models/fixtures/issue_watch.yml | 16 ++++++++ models/issue_watch.go | 2 + models/issue_watch_test.go | 23 +++++++---- routers/api/v1/api.go | 6 +-- routers/api/v1/repo/issue_subscription.go | 48 +++++------------------ templates/swagger/v1_json.tmpl | 4 +- 6 files changed, 47 insertions(+), 52 deletions(-) diff --git a/models/fixtures/issue_watch.yml b/models/fixtures/issue_watch.yml index 75351eb17f883..4bc3ff1b8b987 100644 --- a/models/fixtures/issue_watch.yml +++ b/models/fixtures/issue_watch.yml @@ -13,3 +13,19 @@ is_watching: false created_unix: 946684800 updated_unix: 946684800 + +- + id: 3 + user_id: 2 + issue_id: 7 + is_watching: true + created_unix: 946684800 + updated_unix: 946684800 + +- + id: 4 + user_id: 1 + issue_id: 7 + is_watching: false + created_unix: 946684800 + updated_unix: 946684800 diff --git a/models/issue_watch.go b/models/issue_watch.go index 3d7d48a125240..e42e371a1fae5 100644 --- a/models/issue_watch.go +++ b/models/issue_watch.go @@ -56,6 +56,7 @@ func getIssueWatch(e Engine, userID, issueID int64) (iw *IssueWatch, exists bool exists, err = e. Where("user_id = ?", userID). And("issue_id = ?", issueID). + And("is_watching = ?", true). Get(iw) return } @@ -80,6 +81,7 @@ func GetIssueWatchers(issueID int64) (IssueWatchList, error) { func getIssueWatchers(e Engine, issueID int64) (watches IssueWatchList, err error) { err = e. Where("`issue_watch`.issue_id = ?", issueID). + And("`issue_watch`.is_watching = ?", true). And("`user`.is_active = ?", true). And("`user`.prohibit_login = ?", false). Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id"). diff --git a/models/issue_watch_test.go b/models/issue_watch_test.go index ce0d2045ca688..1d0473426e8df 100644 --- a/models/issue_watch_test.go +++ b/models/issue_watch_test.go @@ -15,26 +15,26 @@ func TestCreateOrUpdateIssueWatch(t *testing.T) { assert.NoError(t, CreateOrUpdateIssueWatch(3, 1, true)) iw := AssertExistsAndLoadBean(t, &IssueWatch{UserID: 3, IssueID: 1}).(*IssueWatch) - assert.Equal(t, true, iw.IsWatching) + assert.True(t, iw.IsWatching) assert.NoError(t, CreateOrUpdateIssueWatch(1, 1, false)) iw = AssertExistsAndLoadBean(t, &IssueWatch{UserID: 1, IssueID: 1}).(*IssueWatch) - assert.Equal(t, false, iw.IsWatching) + assert.False(t, iw.IsWatching) } func TestGetIssueWatch(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) _, exists, err := GetIssueWatch(9, 1) - assert.Equal(t, true, exists) + assert.True(t, exists) assert.NoError(t, err) _, exists, err = GetIssueWatch(2, 2) - assert.Equal(t, true, exists) + assert.False(t, exists) assert.NoError(t, err) _, exists, err = GetIssueWatch(3, 1) - assert.Equal(t, false, exists) + assert.False(t, exists) assert.NoError(t, err) } @@ -44,13 +44,20 @@ func TestGetIssueWatchers(t *testing.T) { iws, err := GetIssueWatchers(1) assert.NoError(t, err) // Watcher is inactive, thus 0 - assert.Equal(t, 0, len(iws)) + assert.Len(t, iws, 0) iws, err = GetIssueWatchers(2) assert.NoError(t, err) - assert.Equal(t, 1, len(iws)) + // Watcher is explicit not watching + assert.Len(t, iws, 0) iws, err = GetIssueWatchers(5) assert.NoError(t, err) - assert.Equal(t, 0, len(iws)) + // Issue has no Watchers + assert.Len(t, iws, 0) + + iws, err = GetIssueWatchers(7) + assert.NoError(t, err) + // Issue has one watcher + assert.Len(t, iws, 1) } diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index ec6ec191d74eb..47c9c95c7fe00 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -691,9 +691,9 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/stop", reqToken(), repo.StopIssueStopwatch) }) m.Group("/subscriptions", func() { - m.Get("", bind(api.User{}), repo.GetIssueSubscribers) - m.Put("/:user", repo.AddIssueSubscription) - m.Delete("/:user", repo.DelIssueSubscription) + m.Get("", repo.GetIssueSubscribers) + m.Put("/:user", reqToken(), repo.AddIssueSubscription) + m.Delete("/:user", reqToken(), repo.DelIssueSubscription) }) }) }, mustEnableIssuesOrPulls) diff --git a/routers/api/v1/repo/issue_subscription.go b/routers/api/v1/repo/issue_subscription.go index 012dcda44fa85..2c5f75f1eca07 100644 --- a/routers/api/v1/repo/issue_subscription.go +++ b/routers/api/v1/repo/issue_subscription.go @@ -7,7 +7,6 @@ package repo import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/gitea/modules/structs" ) // AddIssueSubscription Subscribe user to issue @@ -48,40 +47,7 @@ func AddIssueSubscription(ctx *context.APIContext) { // description: User can only subscribe itself if he is no admin // "404": // description: Issue not found - issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) - if err != nil { - if models.IsErrIssueNotExist(err) { - ctx.NotFound() - } else { - ctx.Error(500, "GetIssueByIndex", err) - } - - return - } - - user, err := models.GetUserByName(ctx.Params(":user")) - if err != nil { - if models.IsErrUserNotExist(err) { - ctx.NotFound() - } else { - ctx.Error(500, "GetUserByName", err) - } - - return - } - - //only admin and user for itself can change subscription - if user.ID != ctx.User.ID && !ctx.User.IsAdmin { - ctx.Error(403, "User", nil) - return - } - - if err := models.CreateOrUpdateIssueWatch(user.ID, issue.ID, true); err != nil { - ctx.Error(500, "CreateOrUpdateIssueWatch", err) - return - } - - ctx.Status(201) + setIssueSubscription(ctx, true) } // DelIssueSubscription Unsubscribe user from issue @@ -122,6 +88,10 @@ func DelIssueSubscription(ctx *context.APIContext) { // description: User can only subscribe itself if he is no admin // "404": // description: Issue not found + setIssueSubscription(ctx, false) +} + +func setIssueSubscription(ctx *context.APIContext, watch bool) { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrIssueNotExist(err) { @@ -150,7 +120,7 @@ func DelIssueSubscription(ctx *context.APIContext) { return } - if err := models.CreateOrUpdateIssueWatch(user.ID, issue.ID, false); err != nil { + if err := models.CreateOrUpdateIssueWatch(user.ID, issue.ID, watch); err != nil { ctx.Error(500, "CreateOrUpdateIssueWatch", err) return } @@ -159,7 +129,7 @@ func DelIssueSubscription(ctx *context.APIContext) { } // GetIssueSubscribers return subscribers of an issue -func GetIssueSubscribers(ctx *context.APIContext, form api.User) { +func GetIssueSubscribers(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/issues/{index}/subscriptions issue issueSubscriptions // --- // summary: Get users who subscribed on an issue. @@ -185,8 +155,8 @@ func GetIssueSubscribers(ctx *context.APIContext, form api.User) { // format: int64 // required: true // responses: - // "201": - // "$ref": "#/responses/empty" + // "200": + // "$ref": "#/responses/UserList" // "404": // description: Issue not found issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 4427c28747366..338ab104e9e94 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -3832,8 +3832,8 @@ } ], "responses": { - "201": { - "$ref": "#/responses/empty" + "200": { + "$ref": "#/responses/UserList" }, "404": { "description": "Issue not found"